Skip to content

task(passkeys): Add WebAuthn error categorization utility#20089

Merged
vbudhram merged 1 commit intomainfrom
FXA-12912
Feb 25, 2026
Merged

task(passkeys): Add WebAuthn error categorization utility#20089
vbudhram merged 1 commit intomainfrom
FXA-12912

Conversation

@vpomerleau
Copy link
Copy Markdown
Contributor

@vpomerleau vpomerleau commented Feb 20, 2026

Because

  • Raw DOMExceptions from createCredential() / getCredential() must be translated into semantic, UI-safe categories before they reach components
  • Error handling strategy (Sentry routing, user messaging) differs by both error type and ceremony context (registration vs. authentication)
  • WebAuthn browser errors are explicitly out of scope for auth-errors and must not use the errno-based registry (see FXA-12910 for server errors)

This pull request

  • Adds categorizeWebAuthnError(error, operation) — maps DOMException names and TypeError to one of three categories (UserAction, DevicePlatform, Unexpected), returns an operation-specific FTL key and logToSentry flag; never throws
  • Adds handleWebAuthnError(error, operation, captureException) — single call site that categorizes the error and conditionally fires Sentry
  • Covers all WebAuthn Level 3 error types including DataError and EncodingError (thrown by parseCreationOptionsFromJSON / parseRequestOptionsFromJSON for malformed options)
  • Adds FTL strings for all 15 error/operation combinations

Issue that this pull request solves

Closes: FXA-12912

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

Based on FXA-12911, only latest commit is relevant for this PR. Will rebase once previous PR is finalized and merged.

@vpomerleau vpomerleau marked this pull request as ready for review February 24, 2026 02:19
@vpomerleau vpomerleau requested review from a team as code owners February 24, 2026 02:19
Copy link
Copy Markdown
Contributor

@vbudhram vbudhram left a comment

Choose a reason for hiding this comment

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

Reviewed c9935ea since its built on #20088. This is only adding error file with ftl so pretty low risk and can fix issues in upcoming PRs.

Comment thread packages/fxa-settings/src/lib/passkeys/en.ftl Outdated
Comment thread packages/fxa-settings/src/lib/passkeys/en.ftl Outdated
Comment thread packages/fxa-settings/src/lib/passkeys/en.ftl Outdated
Comment thread packages/fxa-settings/src/lib/passkeys/en.ftl Outdated
Comment thread packages/fxa-settings/src/lib/passkeys/en.ftl Outdated
Comment thread packages/fxa-settings/src/lib/passkeys/en.ftl Outdated
Comment thread packages/fxa-settings/src/lib/passkeys/en.ftl Outdated
Because:

- Raw DOMExceptions from createCredential() / getCredential() must be translated into semantic, UI-safe categories before they reach components
- Error handling strategy (Sentry routing, user messaging) differs by both error type and ceremony context (registration vs. authentication)
- WebAuthn browser errors are explicitly out of scope for auth-errors and must not use the errno-based registry (see FXA-12910 for server errors)

This commit:
- Adds categorizeWebAuthnError(error, operation) — maps DOMException names and TypeError to one of three categories (UserAction, DevicePlatform, Unexpected), returns an operation-specific FTL key and logToSentry flag; never throws
- Adds handleWebAuthnError(error, operation, captureException) — single call site that categorizes the error and conditionally fires Sentry
- Covers all WebAuthn Level 3 error types including DataError and EncodingError (thrown by parseCreationOptionsFromJSON / parseRequestOptionsFromJSON for malformed options)
- Adds  FTL strings for all 15 error/operation combinations

Closes #FXA-12912
@vbudhram vbudhram merged commit 84f34db into main Feb 25, 2026
22 checks passed
@vbudhram vbudhram deleted the FXA-12912 branch February 25, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants