Skip to main content
The MfaPhoneEnrollment class implements the mfa-phone-enrollment screen functionality. This screen allows users to enroll using a phone number for MFA.
MfaPhoneEnrollment

Constructors

Create an instance of MfaPhoneEnrollment screen
Example
import MfaPhoneEnrollment from '@auth0/auth0-acul-js/mfa-phone-enrollment';
const mfaPhoneEnrollmentManager = new MfaPhoneEnrollment();
async function handlePickCountryCode() {
 try {
   await mfaPhoneEnrollmentManager.pickCountryCode();
   console.log('Country code selection successful.');
 } catch (error) {
   console.error('Error selecting country code:', error);
 }
}
/
  async pickCountryCode(payload?: CustomOptions): Promise<void> {
    const options = {
      state: this.transaction.state,
      telemetry: [MfaPhoneEnrollment.screenIdentifier, 'pickCountryCode'],
    };
    await new FormHandler(options).submitData<CustomOptions>({
      ...payload,
      action: 'pick-country-code',
    });
  }

  /**
Continues the enrollment process with the provided phone number and type (SMS or voice).
@param payload The phone number and type (SMS or voice).
@example

Properties

branding
Provides branding-related configurations, such as branding theme and settings.
client
Provides client-related configurations, such as id, name, and logoUrl.
organization
Provides information about the user’s organization, such as organization id and name.
prompt
Contains data about the current prompt in the authentication flow.
screen
Contains details specific to the screen, including its configuration and context.
tenant
Contains data related to the tenant, such as id and associated metadata.
transaction
Provides transaction-specific data, such as active identifiers and flow states.
untrustedData
Handles untrusted data passed to the SDK, such as user input during login.
user
Details of the active user, including username, email, and roles.

Methods

continueEnrollment
(options ?)
This method continues the enrollment process with the provided phone number and type (SMS or voice).
Example
import MfaPhoneEnrollment from '@auth0/auth0-acul-js/mfa-phone-enrollment';
const mfaPhoneEnrollmentManager = new MfaPhoneEnrollment();
async function handleContinueEnrollment() {
 try {
   await mfaPhoneEnrollmentManager.continueEnrollment({
     phone: '+1234567890',
     type: 'sms', // or 'voice'
   });
   console.log('Phone enrollment continued successfully.');
 } catch (error) {
   console.error('Error continuing phone enrollment:', error);
 }
}
options
OPTIONAL
The phone number and type (SMS or voice).
getErrors
This method retrieves the array of transaction errors from the context, or an empty array if none exist.
pickCountryCode
(options ?)
This method navigates to the country code selection screen.
Example
import MfaPhoneEnrollment from '@auth0/auth0-acul-js/mfa-phone-enrollment';
const mfaPhoneEnrollmentManager = new MfaPhoneEnrollment();
async function handlePickCountryCode() {
 try {
   await mfaPhoneEnrollmentManager.pickCountryCode();
   console.log('Country code selection successful.');
 } catch (error) {
   console.error('Error selecting country code:', error);
 }
}

options
OPTIONAL
Optional custom options to include with the request.
tryAnotherMethod
(options ?)
This method allows the user to try another MFA method.
Example
import MfaPhoneEnrollment from '@auth0/auth0-acul-js/mfa-phone-enrollment';
const mfaPhoneEnrollmentManager = new MfaPhoneEnrollment();
async function handleTryAnotherMethod() {
 try {
   await mfaPhoneEnrollmentManager.tryAnotherMethod(); 
   console.log('Switched to another authentication method.');
  } catch (error) { 
 console.error('Error switching authenticator method:', error);
 }
}
options
OPTIONAL
Optional custom options to include with the request.