Overview
The Two-Factor Authentication API provides comprehensive support for multiple 2FA providers including authenticator apps (TOTP), email, Duo, YubiKey, WebAuthn (FIDO2), and recovery codes. It manages both user-level and organization-level 2FA configurations.TwoFactorService
Core service for managing two-factor authentication providers and state.Methods
init()
getSupportedProviders()
win- Window object for client capability detection
Promise<TwoFactorProviderDetails[]> - List of supported providers or empty list if none are stored
getDefaultProvider()
webAuthnSupported- Whether WebAuthn is supported by the client. Prevents WebAuthn from being the default provider if false
Promise<TwoFactorProviderType> - The default or selected provider type
setSelectedProvider()
type- The type of two-factor provider to set as selected
Promise<void>
clearSelectedProvider()
Promise<void>
setProviders()
response- The response from Identity when 2FA is required. Includes the list of available 2FA providers
Promise<void>
clearProviders()
Promise<void>
getProviders()
Promise<Map<TwoFactorProviderType, object> | null> - Map of providers or null
Provider Configuration Methods (User)
getEnabledTwoFactorProviders()
Promise<ListResponse<TwoFactorProviderResponse>> - List of enabled provider configurations
getTwoFactorAuthenticator()
request- Secret verification request to prove authentication. UseUserVerificationService.buildRequest()to create
Promise<TwoFactorAuthenticatorResponse> - Authenticator configuration including the secret key
getTwoFactorEmail()
request- Secret verification request to prove authentication
Promise<TwoFactorEmailResponse> - Email two-factor configuration
getTwoFactorDuo()
request- Secret verification request to prove authentication
Promise<TwoFactorDuoResponse> - Duo configuration
getTwoFactorYubiKey()
request- Secret verification request to prove authentication
Promise<TwoFactorYubiKeyResponse> - YubiKey configuration
getTwoFactorWebAuthn()
request- Secret verification request to prove authentication
Promise<TwoFactorWebAuthnResponse> - WebAuthn configuration including registered credentials
getTwoFactorWebAuthnChallenge()
putTwoFactorWebAuthn() to obtain the cryptographic challenge required for credential creation.
Parameters:
request- Secret verification request to prove authentication
Promise<ChallengeResponse> - Credential creation options containing the challenge
getTwoFactorRecover()
request- Secret verification request to prove authentication
Promise<TwoFactorRecoverResponse> - Recovery code configuration
Provider Update Methods (User)
putTwoFactorAuthenticator()
request- Update request containing the configuration. UseUserVerificationService.buildRequest()to create
Promise<TwoFactorAuthenticatorResponse> - Updated authenticator configuration
deleteTwoFactorAuthenticator()
request- Disable request. UseUserVerificationService.buildRequest()to create
Promise<TwoFactorProviderResponse> - Updated provider status
putTwoFactorEmail()
postTwoFactorEmailSetup() before enabling.
Parameters:
request- Update request. UseUserVerificationService.buildRequest()to create
Promise<TwoFactorEmailResponse> - Updated email two-factor configuration
putTwoFactorDuo()
request- Update request. UseUserVerificationService.buildRequest()to create
Promise<TwoFactorDuoResponse> - Updated Duo configuration
putTwoFactorYubiKey()
request- Update request. UseUserVerificationService.buildRequest()to create
Promise<TwoFactorYubiKeyResponse> - Updated YubiKey configuration
putTwoFactorWebAuthn()
getTwoFactorWebAuthnChallenge() to complete the registration flow.
Parameters:
request- Update request containing the device response. UseUserVerificationService.buildRequest()to create
Promise<TwoFactorWebAuthnResponse> - Updated WebAuthn configuration with the new credential
deleteTwoFactorWebAuthn()
request- Delete request. UseUserVerificationService.buildRequest()to create
Promise<TwoFactorWebAuthnResponse> - Updated WebAuthn configuration
putTwoFactorDisable()
request- Provider request. UseUserVerificationService.buildRequest()to create
Promise<TwoFactorProviderResponse> - Updated provider status
Email 2FA Methods
postTwoFactorEmailSetup()
putTwoFactorEmail() to complete setup. Only used during initial configuration, not during login flows.
Parameters:
request- Email request. UseUserVerificationService.buildRequest()to create
Promise<any> - Resolves when verification email has been sent
postTwoFactorEmail()
request- Email request. UseUserVerificationService.buildRequest()to create
Promise<any> - Resolves when authentication email has been sent
Organization Methods
getTwoFactorOrganizationProviders()
organizationId- The ID of the organization
Promise<ListResponse<TwoFactorProviderResponse>> - List of enabled provider configurations
getTwoFactorOrganizationDuo()
organizationId- The ID of the organizationrequest- Secret verification request
Promise<TwoFactorDuoResponse> - Organization Duo configuration
putTwoFactorOrganizationDuo()
organizationId- The ID of the organizationrequest- Update request
Promise<TwoFactorDuoResponse> - Updated organization Duo configuration
putTwoFactorOrganizationDisable()
organizationId- The ID of the organizationrequest- Provider request
Promise<TwoFactorProviderResponse> - Updated provider status