Class: Infrawrench::ProfileMfaNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/infrawrench/client.rb,
sig/infrawrench/sdk.rbs

Overview

client.profile.mfa

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ ProfileMfaNamespace

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ProfileMfaNamespace.

Parameters:



3215
3216
3217
# File 'lib/infrawrench/client.rb', line 3215

def initialize(transport)
  @transport = transport
end

Instance Method Details

#challenge(factor_id:, request_options: nil) ⇒ Hash

Issue a fresh challenge for a factor

POST /api/profile/mfa/factorId/challenge

Raises on 401: Unauthenticated

Raises on 404: Not found

Parameters:

  • factor_id (String)
  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • factor_id: (String)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Hash — see sig/infrawrench/sdk.rbs.

Raises:



3231
3232
3233
3234
3235
3236
3237
3238
# File 'lib/infrawrench/client.rb', line 3231

def challenge(factor_id:, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/profile/mfa/{factorId}/challenge",
    path_params: { "factorId" => factor_id },
    request_options: request_options
  )
end

#create(request_options: nil) ⇒ Hash

Begin TOTP enrolment

Creates the factor and a first challenge. The factor only becomes usable once a code is verified; abandon the flow by DELETEing the returned factorId.

POST /api/profile/mfa

Raises on 401: Unauthenticated

Raises on 403: Recent sign-in required. Send the user through sign-in again and retry; the request itself was well-formed.

Parameters:

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as TotpEnrollment — see sig/infrawrench/sdk.rbs.

Raises:



3256
3257
3258
3259
3260
3261
3262
# File 'lib/infrawrench/client.rb', line 3256

def create(request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/profile/mfa",
    request_options: request_options
  )
end

#delete(factor_id:, request_options: nil) ⇒ Hash

Remove an authentication factor

DELETE /api/profile/mfa/factorId

Raises on 401: Unauthenticated

Raises on 403: Recent sign-in required. Send the user through sign-in again and retry; the request itself was well-formed.

Raises on 404: Not found

Parameters:

  • factor_id (String)
  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • factor_id: (String)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Ok — see sig/infrawrench/sdk.rbs.

Raises:



3279
3280
3281
3282
3283
3284
3285
3286
# File 'lib/infrawrench/client.rb', line 3279

def delete(factor_id:, request_options: nil)
  @transport.request(
    http_method: "DELETE",
    path: "/api/profile/mfa/{factorId}",
    path_params: { "factorId" => factor_id },
    request_options: request_options
  )
end

#list(request_options: nil) ⇒ Array<Hash>

List enrolled authentication factors

Includes factors whose enrolment was never confirmed — WorkOS does not expose a verified flag.

GET /api/profile/mfa

Raises on 401: Unauthenticated

Parameters:

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Array<Hash>)

    Parsed JSON, shaped as Array<AuthFactor> — see sig/infrawrench/sdk.rbs.

Raises:



3301
3302
3303
3304
3305
3306
3307
# File 'lib/infrawrench/client.rb', line 3301

def list(request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/profile/mfa",
    request_options: request_options
  )
end

#verify(factor_id:, body: nil, request_options: nil) ⇒ Hash

Verify a code against a challenge

POST /api/profile/mfa/factorId/verify

Raises on 400: Bad request

Raises on 401: Unauthenticated

Raises on 404: Not found

Parameters:

  • factor_id (String)
  • body (Hash, nil) (defaults to: nil)

    Request body, shaped as Hash.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • factor_id: (String)
  • body: ({ "challengeId" => String, "code" => String }, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Hash — see sig/infrawrench/sdk.rbs.

Raises:



3324
3325
3326
3327
3328
3329
3330
3331
3332
# File 'lib/infrawrench/client.rb', line 3324

def verify(factor_id:, body: nil, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/profile/mfa/{factorId}/verify",
    path_params: { "factorId" => factor_id },
    body: body,
    request_options: request_options
  )
end