Skip to content

fix: for issues with _allowCredentials and device registration#582

Merged
ryanbas21 merged 1 commit intoForgeRock:developfrom
thomas-schofield-fr:webauthn-additional-fix
Mar 10, 2026
Merged

fix: for issues with _allowCredentials and device registration#582
ryanbas21 merged 1 commit intoForgeRock:developfrom
thomas-schofield-fr:webauthn-additional-fix

Conversation

@thomas-schofield-fr
Copy link
Contributor

JIRA Ticket

Fixes for original changes made by:

  1. AME-33781
  2. AME-33773

Description

Fixes 2 bugs:

  1. Check for isWebAuthnSupported() should have been inverted when registering a new device.
  2. _allowCredentials array entries have an id property which needed to be a typed array for navigator.credentials.get().

@changeset-bot
Copy link

changeset-bot bot commented Mar 8, 2026

⚠️ No Changeset found

Latest commit: ad9026a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines +537 to +538
// The incoming _allowCredentials entries have an `id` property of type `Array`, which is rejected by `navigator.credentials.get()`.
// Converting it to a TypedArray here to meet the spec (https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialRequestOptions#id).
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this comment. The type PublicKeyCredentialDescriptor shows this

interface PublicKeyCredentialDescriptor {
    id: BufferSource;
    transports?: AuthenticatorTransport[];
    type: PublicKeyCredentialType;
}

This type comes from lib.dom.ts https://www.dec112.at/docs/ng112-js/1.9.4/interfaces/_internal_.PublicKeyCredentialDescriptor.html

Are we saying this is wrong?

navigator.credentials.get accepts CredentialRequestOptions

interface CredentialRequestOptions {
    mediation?: CredentialMediationRequirement;
    publicKey?: PublicKeyCredentialRequestOptions;
    signal?: AbortSignal;
}

Pulling your branch down, and just looking at cred it seems like this is already the correct type?

Image

I'm a bit confused by this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think TypeScript just doesn't correctly verify the incoming metadataCallback.getOutputValue('data') is actually the correct type all the way through - specifically, the id property is Array which doesn't conform to BufferSource.
Screenshot 2026-03-10 at 16 19 18

If we don't make the change, the error from navigator.credentials.get is fairly clear:
Screenshot 2026-03-10 at 16 24 00

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this happen on the latest version of the SDK before these changes? I feel like this would be a pretty breaking bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@ryanbas21 ryanbas21 left a comment

Choose a reason for hiding this comment

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

Ran this locally with a local publish + webauthn flow and it worked.

@ryanbas21 ryanbas21 merged commit 9fe007e into ForgeRock:develop Mar 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants