Skip to content

Rename AuthError to ServerAuthError and add BrowserAuthError#40

Closed
cfuehrmann wants to merge 2 commits into
mainfrom
refactor-auth-error-naming
Closed

Rename AuthError to ServerAuthError and add BrowserAuthError#40
cfuehrmann wants to merge 2 commits into
mainfrom
refactor-auth-error-naming

Conversation

@cfuehrmann

Copy link
Copy Markdown
Owner

Summary

Improves error handling by clearly separating server-side and browser-side authentication errors:

  • ServerAuthError (in @repo/fido2-auth): Errors from the auth service on the server (username taken, user not found, etc.)
  • BrowserAuthError (in web demo): Errors from the browser's WebAuthn API (user cancelled, passkey already registered)

This separation clarifies which world each error type lives in, which is important if the auth package is later wrapped behind a JSON/HTTP API and called from different technology stacks.

Changes

@repo/fido2-auth package

  • Rename AuthError to ServerAuthError
  • Rename AuthErrorCode to ServerAuthErrorCode

Web demo

  • Add BrowserAuthError class with codes: CANCELLED_OR_DENIED, ALREADY_REGISTERED
  • Add toBrowserAuthError() utility to convert WebAuthn errors
  • Update all UI error handling to use the new utility
  • Standardize error message to "Cancelled or timed out" across all pages

- Rename AuthError to ServerAuthError in @repo/fido2-auth to clarify it's server-side
- Add BrowserAuthError in web demo for client-side WebAuthn errors
- Add toBrowserAuthError() utility to convert browser errors
- Update all UI error handling to use the new error types
- Standardize error message to 'Cancelled or timed out' across all pages
Replace the BrowserAuthError class with a simpler function that just
returns the error code directly. The class added indirection without
providing additional value for the current usage pattern.
@cfuehrmann

Copy link
Copy Markdown
Owner Author

Closing: after discussion, the refactoring doesn't add enough value to justify the indirection.

@cfuehrmann cfuehrmann closed this Feb 15, 2026
@cfuehrmann cfuehrmann deleted the refactor-auth-error-naming branch March 8, 2026 10:19
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.

1 participant