fix(auth0-auth-js): surface mfa_required from passkey token exchange#187
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughThis PR enables MFA error handling for passkey token exchange by introducing a shared error normalizer that lifts ChangesPasskey MFA Error Handling Support
🎯 2 (Simple) | ⏱️ ~12 minutes Suggested Reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
d768d0b to
c0197ff
Compare
Description
When MFA is enabled, Auth0's passkey token exchange (
getTokenByPasskey, granturn:okta:params:oauth:grant-type:webauthn) returns anmfa_requirederror at/oauth/tokenwith anmfa_token— just like ROPG and other grants. The SDK was droppingmfa_token/mfa_requirementswhen buildingPasskeyGetTokenError, soisMfaRequiredError()returnedfalseand callers couldn't continue into the MFA flow after a passkey login. Passkey was the only token method missing this parity.Changes
passkey-client.ts—getTokenByPasskeynow normalizes the thrown error via the sharedtoOAuth2Error, liftingmfa_token/mfa_requirementsfrom the nestedopenid-clienterror cause.errors.ts— movedtoOAuth2Errorout ofauth-client.tsintoerrors.ts(a leaf module) and exported it, soauth-clientandpasskey-clientshare one canonical implementation with no circular import.isMfaRequiredErrorJSDoc now listsgetTokenByPasskey.auth-client.ts— importstoOAuth2Errorfromerrors.js; behavior unchanged for existing flows.passkey/errors.ts— addedPasskeyGetTokenApiErrorResponseand scoped the MFA fields toPasskeyGetTokenErroronly.PasskeyRegisterError/PasskeyChallengeErrorkeep the base type, since challenge requests can't returnmfa_required.EXAMPLES.md— documented MFA handling forgetTokenByPasskey.Usage
Breaking changes
None. Additive only — error class names, code values, and constructor signatures are unchanged. Verified backward-compatible with auth0-spa-js.
Note for reviewers
toOAuth2Erroris now reachable from the public type surface (viaexport * in index.ts), alongside the pre-existing transitive leak ofGrantRequestFn/*ClientOptions. This is intentionally deferred to a follow-up PR that will tighten the public API (e.g. stripInternal) in one deliberate, verified change — out of scope here.Testing
New tests:
mfa_token/mfa_requirementspreserved onPasskeyGetTokenError.cause; isMfaRequiredError()recognizes it.Summary by CodeRabbit
Bug Fixes
Documentation
Tests