fix: for issues with _allowCredentials and device registration#582
Conversation
|
| // 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). |
There was a problem hiding this comment.
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?
I'm a bit confused by this change.
There was a problem hiding this comment.
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.

If we don't make the change, the error from navigator.credentials.get is fairly clear:

There was a problem hiding this comment.
Does this happen on the latest version of the SDK before these changes? I feel like this would be a pretty breaking bug?
There was a problem hiding this comment.
It does not, it's a new issue since 03135cf#diff-112486585734aee9407beea04e071c53e7eddce56a465b7462455fcb0e3bb346R514
9681ae0 to
ad9026a
Compare
ryanbas21
left a comment
There was a problem hiding this comment.
Ran this locally with a local publish + webauthn flow and it worked.
JIRA Ticket
Fixes for original changes made by:
Description
Fixes 2 bugs:
isWebAuthnSupported()should have been inverted when registering a new device._allowCredentialsarray entries have anidproperty which needed to be a typed array fornavigator.credentials.get().