Skip to content

bug(fix): Support webauthn implementations that return plain object#20401

Merged
vpomerleau merged 1 commit intomainfrom
passkey-type-fixes
Apr 24, 2026
Merged

bug(fix): Support webauthn implementations that return plain object#20401
vpomerleau merged 1 commit intomainfrom
passkey-type-fixes

Conversation

@vpomerleau
Copy link
Copy Markdown
Contributor

@vpomerleau vpomerleau commented Apr 17, 2026

Because

This pull request

  • duck-type WebAuthn credential to support 1Password proxy objects

Issue that this pull request solves

Closes: (issue number)

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).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • Key files/areas to focus on:
  • Suggested review order:
  • Risky or complex parts:

Screenshots (Optional)

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

Other information (Optional)

This PR previously contained other types mismatches - these changes were moved to their own PR

@vpomerleau vpomerleau requested a review from a team as a code owner April 17, 2026 19:45
Copilot AI review requested due to automatic review settings April 17, 2026 19:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses passkey/WebAuthn typing and compatibility issues encountered during passkey registration testing, including support for password manager “proxy” credential objects.

Changes:

  • Duck-types WebAuthn credentials by checking for toJSON() to support non-PublicKeyCredential proxy objects (e.g., 1Password).
  • Fixes Buffer vs Uint8Array type expectations in the server-side WebAuthn adapter for userID and publicKey.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
packages/fxa-settings/src/lib/passkeys/webauthn.ts Adjusts credential handling to prefer toJSON() duck-typing over relying on instanceof PublicKeyCredential.
libs/accounts/passkey/src/lib/webauthn-adapter.ts Converts Buffer inputs to Uint8Array for fields typed as Uint8Array by SimpleWebAuthn server types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/fxa-settings/src/lib/passkeys/webauthn.ts Outdated
Comment thread libs/accounts/passkey/src/lib/webauthn-adapter.ts Outdated
Comment thread libs/accounts/passkey/src/lib/webauthn-adapter.ts Outdated
Comment thread packages/fxa-settings/src/lib/passkeys/webauthn.ts Outdated
Comment thread packages/fxa-settings/src/lib/passkeys/webauthn.ts Outdated
Comment thread packages/fxa-settings/src/lib/passkeys/webauthn.ts Outdated
throw new DOMException(`${operation} returned null`, 'UnknownError');
}
if (typeof (rawCredential as CredentialWithToJSON).toJSON === 'function') {
return (rawCredential as CredentialWithToJSON).toJSON!();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We shouldn't use !. A type guard should be able to avoid having to use the !.

@vpomerleau vpomerleau changed the title Passkey type fixes bug(fix): Support webauthn impelementation that return plain object Apr 24, 2026
@vpomerleau vpomerleau changed the title bug(fix): Support webauthn impelementation that return plain object bug(fix): Support webauthn implementations that return plain object Apr 24, 2026
// ─── Credential extraction ──────────────────────────────────────────────────

/** Type guard for objects that can serialize to credential JSON. */
function hasToJSON(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Copy Markdown
Contributor

@dschom dschom left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@vpomerleau vpomerleau merged commit 335ea61 into main Apr 24, 2026
21 checks passed
@vpomerleau vpomerleau deleted the passkey-type-fixes branch April 24, 2026 20:15
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.

4 participants