mfa-phone-enrollment 画面の機能を実装するクラスです。
この画面では、ユーザーが電話番号を用いた MFA(多要素認証)の登録を行えます。
import MfaPhoneEnrollment from '@auth0/auth0-acul-js/mfa-phone-enrollment';
const mfaPhoneEnrollmentManager = new MfaPhoneEnrollment();
async function handlePickCountryCode() {
try {
await mfaPhoneEnrollmentManager.pickCountryCode();
console.log('国コードの選択が完了しました。');
} catch (error) {
console.error('国コード選択時のエラー:', 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',
});
}
/**
指定された電話番号とタイプ(SMSまたは音声)で登録プロセスを続行します。
@param payload 電話番号とタイプ(SMSまたは音声)。
@example
MfaPhoneEnrollment 画面のインスタンスを作成します。
指定された電話番号とタイプ(SMS または音声)で登録プロセスを継続します。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', // または 'voice'
});
console.log('Phone enrollment continued successfully.');
} catch (error) {
console.error('Error continuing phone enrollment:', error);
}
}
コンテキストからトランザクションのエラー配列を取得します。存在しない場合は空の配列を返します。トランザクションコンテキストから取得されるエラーオブジェクトの配列です。
国コード選択画面に遷移します。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);
}
}
ユーザーが別の MFA(多要素認証)手段を試せるようにします。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);
}
}