Skip to content

feat: MFA APIs#2502

Open
tusharpandey13 wants to merge 31 commits intofeat/mfa-basefrom
feat/mfa-apis
Open

feat: MFA APIs#2502
tusharpandey13 wants to merge 31 commits intofeat/mfa-basefrom
feat/mfa-apis

Conversation

@tusharpandey13
Copy link
Contributor

@tusharpandey13 tusharpandey13 commented Jan 26, 2026

Important

This PR is the 2nd PR in a PR stack
Current base: #2480

Adds MFA API support, enabling getAuthenticators, enroll, challenge and verify functionality.

Changes

  • Added MfaClient classes for server and client
  • Added business logic for getAuthenticators, enroll, challenge and verify
  • Added server handlers for the same
  • Added flow tests for client and server scenarios
  • Added documentation

Tests

Added flow tests testing all MFA flows for server and client.

Usage

try {
  const { token } = await auth0.getAccessToken({ audience: 'https://api.example.com' });
} catch (error) {
  if (error instanceof MfaRequiredError) {

    // Get available authenticators
    const authenticators = await auth0.mfa.getAuthenticators({
      mfaToken: error.mfa_token
    });

    // Enrollment
    const enrollment = await auth0.mfa.enroll({
      mfaToken,
      authenticatorTypes: ["otp"]
    });

    // Initiate challenge
    const challenge = await auth0.mfa.challenge({
      mfaToken: error.mfa_token,
      challengeType: 'otp',
      authenticatorId: authenticators[0].id
    });

    // Verify code
    const tokens = await auth0.mfa.verify({
      mfaToken: error.mfa_token,
      otp: '123456'
    });
  }
}

@tusharpandey13 tusharpandey13 requested a review from a team as a code owner January 26, 2026 19:54
@tusharpandey13 tusharpandey13 marked this pull request as draft January 27, 2026 10:19
@tusharpandey13 tusharpandey13 changed the title feat: MFA Apis feat: MFA APIs Jan 28, 2026
@tusharpandey13 tusharpandey13 marked this pull request as ready for review February 3, 2026 11:15
@tusharpandey13 tusharpandey13 changed the title feat: MFA APIs feat: [MFA PR 2/4] MFA APIs Feb 5, 2026
@tusharpandey13 tusharpandey13 changed the title feat: [MFA PR 2/4] MFA APIs feat: MFA APIs Feb 5, 2026
mfaToken,
authenticatorTypes: ["oob"],
oobChannels: ["email"],
email: "user@example.com"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tusharpandey13 enrolment signatures are slightly different from spa

https://github.com/auth0/auth0-spa-js/blob/main/EXAMPLES.md?plain=1#L890

For enrolment we are not accepting oobChannels: ["email"], in array notation, rather a simplified factorType which internally calculates oobChannel.

You can refer the above code snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants