From c560710a634cbf93c49d45e95af9a3d83b7c8944 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 5 Jul 2026 21:15:06 -0700 Subject: [PATCH 1/7] Pull in Base64URLString from TS DOM types --- packages/types/extract-dom-types.ts | 1 + packages/types/src/dom.ts | 1 + packages/types/src/index.ts | 7 ++----- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/types/extract-dom-types.ts b/packages/types/extract-dom-types.ts index 2e9c301e..5aeac8ba 100644 --- a/packages/types/extract-dom-types.ts +++ b/packages/types/extract-dom-types.ts @@ -45,6 +45,7 @@ const types = [ 'AuthenticationExtensionsClientInputs', 'AuthenticationExtensionsClientOutputs', 'AuthenticatorSelectionCriteria', + 'Base64URLString', 'COSEAlgorithmIdentifier', 'CredentialCreationOptions', 'CredentialRequestOptions', diff --git a/packages/types/src/dom.ts b/packages/types/src/dom.ts index 82941cba..d2138304 100644 --- a/packages/types/src/dom.ts +++ b/packages/types/src/dom.ts @@ -584,6 +584,7 @@ export interface RsaKeyGenParams extends Algorithm { export type AttestationConveyancePreference = "direct" | "enterprise" | "indirect" | "none"; export type AuthenticatorTransport = "ble" | "hybrid" | "internal" | "nfc" | "usb"; +export type Base64URLString = string; export type COSEAlgorithmIdentifier = number; export type ResidentKeyRequirement = "discouraged" | "preferred" | "required"; export type UserVerificationRequirement = "discouraged" | "preferred" | "required"; diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index ae69b9c0..72196580 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -6,6 +6,7 @@ import type { AuthenticatorAttachment, AuthenticatorAttestationResponse, AuthenticatorSelectionCriteria, + Base64URLString, COSEAlgorithmIdentifier, PublicKeyCredential, PublicKeyCredentialCreationOptions, @@ -26,6 +27,7 @@ export type { AuthenticatorAttestationResponse, AuthenticatorSelectionCriteria, AuthenticatorTransport, + Base64URLString, COSEAlgorithmIdentifier, CredentialCreationOptions, CredentialRequestOptions, @@ -184,11 +186,6 @@ export type WebAuthnCredential = { transports?: AuthenticatorTransportFuture[]; }; -/** - * An attempt to communicate that this isn't just any string, but a Base64URL-encoded string - */ -export type Base64URLString = string; - /** * AuthenticatorAttestationResponse in TypeScript's DOM lib is outdated (up through v3.9.7). * Maintain an augmented version here so we can implement additional properties as the WebAuthn From c0375746cde3a7c0205f71df7839868f8216c653 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 5 Jul 2026 21:17:33 -0700 Subject: [PATCH 2/7] Pull in PublicKeyCredentialDescriptorJSON from TS --- packages/types/extract-dom-types.ts | 1 + packages/types/src/dom.ts | 6 ++++++ packages/types/src/index.ts | 11 ++--------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/types/extract-dom-types.ts b/packages/types/extract-dom-types.ts index 5aeac8ba..0c0b0610 100644 --- a/packages/types/extract-dom-types.ts +++ b/packages/types/extract-dom-types.ts @@ -53,6 +53,7 @@ const types = [ 'PublicKeyCredential', 'PublicKeyCredentialCreationOptions', 'PublicKeyCredentialDescriptor', + 'PublicKeyCredentialDescriptorJSON', 'PublicKeyCredentialParameters', 'PublicKeyCredentialRequestOptions', 'PublicKeyCredentialUserEntity', diff --git a/packages/types/src/dom.ts b/packages/types/src/dom.ts index d2138304..59e762ef 100644 --- a/packages/types/src/dom.ts +++ b/packages/types/src/dom.ts @@ -128,6 +128,12 @@ export interface PublicKeyCredentialDescriptor { type: PublicKeyCredentialType; } +export interface PublicKeyCredentialDescriptorJSON { + id: Base64URLString; + transports?: string[]; + type: string; +} + export interface PublicKeyCredentialParameters { alg: COSEAlgorithmIdentifier; type: PublicKeyCredentialType; diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 72196580..5af5f468 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -11,6 +11,7 @@ import type { PublicKeyCredential, PublicKeyCredentialCreationOptions, PublicKeyCredentialDescriptor, + PublicKeyCredentialDescriptorJSON, PublicKeyCredentialParameters, PublicKeyCredentialRequestOptions, PublicKeyCredentialRpEntity, @@ -35,6 +36,7 @@ export type { PublicKeyCredential, PublicKeyCredentialCreationOptions, PublicKeyCredentialDescriptor, + PublicKeyCredentialDescriptorJSON, PublicKeyCredentialParameters, PublicKeyCredentialRequestOptions, PublicKeyCredentialRpEntity, @@ -81,15 +83,6 @@ export interface PublicKeyCredentialRequestOptionsJSON { extensions?: AuthenticationExtensionsClientInputs; } -/** - * https://w3c.github.io/webauthn/#dictdef-publickeycredentialdescriptorjson - */ -export interface PublicKeyCredentialDescriptorJSON { - id: Base64URLString; - type: PublicKeyCredentialType; - transports?: AuthenticatorTransportFuture[]; -} - /** * https://w3c.github.io/webauthn/#dictdef-publickeycredentialuserentityjson */ From 528e9ed6d1519c7c8943d46d52e277395f6761ba Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 5 Jul 2026 21:21:12 -0700 Subject: [PATCH 3/7] Loosen typing on `transports` to string[] --- .../browser/src/helpers/toPublicKeyCredentialDescriptor.ts | 7 ++----- packages/browser/src/methods/startRegistration.ts | 3 +-- .../src/authentication/generateAuthenticationOptions.ts | 3 +-- .../server/src/registration/generateRegistrationOptions.ts | 3 +-- packages/types/src/index.ts | 6 +++--- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/browser/src/helpers/toPublicKeyCredentialDescriptor.ts b/packages/browser/src/helpers/toPublicKeyCredentialDescriptor.ts index e19bbd9d..1eca3321 100644 --- a/packages/browser/src/helpers/toPublicKeyCredentialDescriptor.ts +++ b/packages/browser/src/helpers/toPublicKeyCredentialDescriptor.ts @@ -2,6 +2,7 @@ import type { AuthenticatorTransport, PublicKeyCredentialDescriptor, PublicKeyCredentialDescriptorJSON, + PublicKeyCredentialType, } from '../types/index.ts'; import { base64URLStringToBuffer } from './base64URLStringToBuffer.ts'; @@ -13,11 +14,7 @@ export function toPublicKeyCredentialDescriptor( return { ...descriptor, id: base64URLStringToBuffer(id), - /** - * `descriptor.transports` is an array of our `AuthenticatorTransportFuture` that includes newer - * transports that TypeScript's DOM lib is ignorant of. Convince TS that our list of transports - * are fine to pass to WebAuthn since browsers will recognize the new value. - */ transports: descriptor.transports as AuthenticatorTransport[], + type: descriptor.type as PublicKeyCredentialType, }; } diff --git a/packages/browser/src/methods/startRegistration.ts b/packages/browser/src/methods/startRegistration.ts index a601526a..fbf38a7f 100644 --- a/packages/browser/src/methods/startRegistration.ts +++ b/packages/browser/src/methods/startRegistration.ts @@ -1,5 +1,4 @@ import type { - AuthenticatorTransportFuture, CredentialCreationOptions, PublicKeyCredentialCreationOptions, PublicKeyCredentialCreationOptionsJSON, @@ -90,7 +89,7 @@ export async function startRegistration( const { id, rawId, response, type } = credential; // Continue to play it safe with `getTransports()` for now, even when L3 types say it's required - let transports: AuthenticatorTransportFuture[] | undefined = undefined; + let transports: string[] | undefined = undefined; if (typeof response.getTransports === 'function') { transports = response.getTransports(); } diff --git a/packages/server/src/authentication/generateAuthenticationOptions.ts b/packages/server/src/authentication/generateAuthenticationOptions.ts index 21db84d4..f0d9f8d0 100644 --- a/packages/server/src/authentication/generateAuthenticationOptions.ts +++ b/packages/server/src/authentication/generateAuthenticationOptions.ts @@ -1,6 +1,5 @@ import type { AuthenticationExtensionsClientInputs, - AuthenticatorTransportFuture, Base64URLString, PublicKeyCredentialRequestOptionsJSON, Uint8Array_, @@ -27,7 +26,7 @@ export async function generateAuthenticationOptions( rpID: string; allowCredentials?: { id: Base64URLString; - transports?: AuthenticatorTransportFuture[]; + transports?: string[]; }[]; challenge?: string | Uint8Array_; timeout?: number; diff --git a/packages/server/src/registration/generateRegistrationOptions.ts b/packages/server/src/registration/generateRegistrationOptions.ts index 1065c009..12fc23c2 100644 --- a/packages/server/src/registration/generateRegistrationOptions.ts +++ b/packages/server/src/registration/generateRegistrationOptions.ts @@ -1,7 +1,6 @@ import type { AuthenticationExtensionsClientInputs, AuthenticatorSelectionCriteria, - AuthenticatorTransportFuture, Base64URLString, COSEAlgorithmIdentifier, PublicKeyCredentialCreationOptionsJSON, @@ -94,7 +93,7 @@ export async function generateRegistrationOptions( attestationType?: 'direct' | 'enterprise' | 'none'; excludeCredentials?: { id: Base64URLString; - transports?: AuthenticatorTransportFuture[]; + transports?: string[]; }[]; authenticatorSelection?: AuthenticatorSelectionCriteria; extensions?: AuthenticationExtensionsClientInputs; diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 5af5f468..44005d07 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -148,7 +148,7 @@ export interface AuthenticatorAttestationResponseJSON { // Optional in L2, but becomes required in L3. Play it safe until L3 becomes Recommendation authenticatorData?: Base64URLString; // Optional in L2, but becomes required in L3. Play it safe until L3 becomes Recommendation - transports?: AuthenticatorTransportFuture[]; + transports?: string[]; // Optional in L2, but becomes required in L3. Play it safe until L3 becomes Recommendation publicKeyAlgorithm?: COSEAlgorithmIdentifier; publicKey?: Base64URLString; @@ -175,8 +175,8 @@ export type WebAuthnCredential = { publicKey: Uint8Array_; // Number of times this authenticator is expected to have been used counter: number; - // From browser's `startRegistration()` -> RegistrationCredentialJSON.transports (API L2 and up) - transports?: AuthenticatorTransportFuture[]; + // From browser's `startRegistration()` -> RegistrationCredential.response.transports (API L2 and up) + transports?: string[]; }; /** From b71c96e949240adb980ff43da9a2896fa37da054 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 5 Jul 2026 21:23:23 -0700 Subject: [PATCH 4/7] Remove AuthenticatorTransportFuture --- packages/types/src/index.ts | 40 +------------------------------------ 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 44005d07..12a5857d 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -10,7 +10,6 @@ import type { COSEAlgorithmIdentifier, PublicKeyCredential, PublicKeyCredentialCreationOptions, - PublicKeyCredentialDescriptor, PublicKeyCredentialDescriptorJSON, PublicKeyCredentialParameters, PublicKeyCredentialRequestOptions, @@ -96,7 +95,7 @@ export interface PublicKeyCredentialUserEntityJSON { * The value returned from navigator.credentials.create() */ export interface RegistrationCredential extends PublicKeyCredentialFuture { - response: AuthenticatorAttestationResponseFuture; + response: AuthenticatorAttestationResponse; } /** @@ -179,43 +178,6 @@ export type WebAuthnCredential = { transports?: string[]; }; -/** - * AuthenticatorAttestationResponse in TypeScript's DOM lib is outdated (up through v3.9.7). - * Maintain an augmented version here so we can implement additional properties as the WebAuthn - * spec evolves. - * - * See https://www.w3.org/TR/webauthn-2/#iface-authenticatorattestationresponse - * - * Properties marked optional are not supported in all browsers. - */ -export interface AuthenticatorAttestationResponseFuture extends AuthenticatorAttestationResponse { - getTransports(): AuthenticatorTransportFuture[]; -} - -/** - * A super class of TypeScript's `AuthenticatorTransport` that includes support for the latest - * transports. Should eventually be replaced by TypeScript's when TypeScript gets updated to - * know about it (sometime after 4.6.3) - */ -export type AuthenticatorTransportFuture = - | 'ble' - | 'cable' - | 'hybrid' - | 'internal' - | 'nfc' - | 'smart-card' - | 'usb'; - -/** - * A super class of TypeScript's `PublicKeyCredentialDescriptor` that knows about the latest - * transports. Should eventually be replaced by TypeScript's when TypeScript gets updated to - * know about it (sometime after 4.6.3) - */ -export interface PublicKeyCredentialDescriptorFuture - extends Omit { - transports?: AuthenticatorTransportFuture[]; -} - /** */ export type PublicKeyCredentialJSON = | RegistrationResponseJSON From d9c3cac3e645410dd4c51b566a924d26742f3037 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 5 Jul 2026 21:29:42 -0700 Subject: [PATCH 5/7] Sneaking these reversions in --- packages/browser/src/methods/startAuthentication.ts | 2 +- packages/browser/src/methods/startRegistration.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/browser/src/methods/startAuthentication.ts b/packages/browser/src/methods/startAuthentication.ts index 2a95e56f..ee6cb200 100644 --- a/packages/browser/src/methods/startAuthentication.ts +++ b/packages/browser/src/methods/startAuthentication.ts @@ -105,7 +105,7 @@ export async function startAuthentication( // Wait for the user to complete assertion let credential; try { - credential = (await navigator.credentials.get(getOptions as globalThis.CredentialRequestOptions)) as AuthenticationCredential; + credential = (await navigator.credentials.get(getOptions)) as AuthenticationCredential; } catch (err) { throw identifyAuthenticationError({ error: err as Error, options: getOptions }); } diff --git a/packages/browser/src/methods/startRegistration.ts b/packages/browser/src/methods/startRegistration.ts index fbf38a7f..d93df4c4 100644 --- a/packages/browser/src/methods/startRegistration.ts +++ b/packages/browser/src/methods/startRegistration.ts @@ -77,7 +77,7 @@ export async function startRegistration( // Wait for the user to complete attestation let credential; try { - credential = (await navigator.credentials.create(createOptions as globalThis.CredentialCreationOptions)) as RegistrationCredential; + credential = (await navigator.credentials.create(createOptions)) as RegistrationCredential; } catch (err) { throw identifyRegistrationError({ error: err as Error, options: createOptions }); } From 66493c879c21faf1e9e87c839252474521a10d2c Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 5 Jul 2026 21:29:54 -0700 Subject: [PATCH 6/7] Codegen types into browser and server --- packages/browser/src/types/dom.ts | 7 ++++ packages/browser/src/types/index.ts | 64 ++++------------------------- packages/server/src/types/dom.ts | 7 ++++ packages/server/src/types/index.ts | 64 ++++------------------------- 4 files changed, 30 insertions(+), 112 deletions(-) diff --git a/packages/browser/src/types/dom.ts b/packages/browser/src/types/dom.ts index 38eb272e..d3ad8e0e 100644 --- a/packages/browser/src/types/dom.ts +++ b/packages/browser/src/types/dom.ts @@ -136,6 +136,12 @@ export interface PublicKeyCredentialDescriptor { type: PublicKeyCredentialType; } +export interface PublicKeyCredentialDescriptorJSON { + id: Base64URLString; + transports?: string[]; + type: string; +} + export interface PublicKeyCredentialParameters { alg: COSEAlgorithmIdentifier; type: PublicKeyCredentialType; @@ -592,6 +598,7 @@ export interface RsaKeyGenParams extends Algorithm { export type AttestationConveyancePreference = "direct" | "enterprise" | "indirect" | "none"; export type AuthenticatorTransport = "ble" | "hybrid" | "internal" | "nfc" | "usb"; +export type Base64URLString = string; export type COSEAlgorithmIdentifier = number; export type ResidentKeyRequirement = "discouraged" | "preferred" | "required"; export type UserVerificationRequirement = "discouraged" | "preferred" | "required"; diff --git a/packages/browser/src/types/index.ts b/packages/browser/src/types/index.ts index 915f8bd7..e565d1c3 100644 --- a/packages/browser/src/types/index.ts +++ b/packages/browser/src/types/index.ts @@ -16,10 +16,11 @@ import type { AuthenticatorAttachment, AuthenticatorAttestationResponse, AuthenticatorSelectionCriteria, + Base64URLString, COSEAlgorithmIdentifier, PublicKeyCredential, PublicKeyCredentialCreationOptions, - PublicKeyCredentialDescriptor, + PublicKeyCredentialDescriptorJSON, PublicKeyCredentialParameters, PublicKeyCredentialRequestOptions, PublicKeyCredentialRpEntity, @@ -36,6 +37,7 @@ export type { AuthenticatorAttestationResponse, AuthenticatorSelectionCriteria, AuthenticatorTransport, + Base64URLString, COSEAlgorithmIdentifier, CredentialCreationOptions, CredentialRequestOptions, @@ -43,6 +45,7 @@ export type { PublicKeyCredential, PublicKeyCredentialCreationOptions, PublicKeyCredentialDescriptor, + PublicKeyCredentialDescriptorJSON, PublicKeyCredentialParameters, PublicKeyCredentialRequestOptions, PublicKeyCredentialRpEntity, @@ -89,15 +92,6 @@ export interface PublicKeyCredentialRequestOptionsJSON { extensions?: AuthenticationExtensionsClientInputs; } -/** - * https://w3c.github.io/webauthn/#dictdef-publickeycredentialdescriptorjson - */ -export interface PublicKeyCredentialDescriptorJSON { - id: Base64URLString; - type: PublicKeyCredentialType; - transports?: AuthenticatorTransportFuture[]; -} - /** * https://w3c.github.io/webauthn/#dictdef-publickeycredentialuserentityjson */ @@ -111,7 +105,7 @@ export interface PublicKeyCredentialUserEntityJSON { * The value returned from navigator.credentials.create() */ export interface RegistrationCredential extends PublicKeyCredentialFuture { - response: AuthenticatorAttestationResponseFuture; + response: AuthenticatorAttestationResponse; } /** @@ -163,7 +157,7 @@ export interface AuthenticatorAttestationResponseJSON { // Optional in L2, but becomes required in L3. Play it safe until L3 becomes Recommendation authenticatorData?: Base64URLString; // Optional in L2, but becomes required in L3. Play it safe until L3 becomes Recommendation - transports?: AuthenticatorTransportFuture[]; + transports?: string[]; // Optional in L2, but becomes required in L3. Play it safe until L3 becomes Recommendation publicKeyAlgorithm?: COSEAlgorithmIdentifier; publicKey?: Base64URLString; @@ -190,52 +184,10 @@ export type WebAuthnCredential = { publicKey: Uint8Array_; // Number of times this authenticator is expected to have been used counter: number; - // From browser's `startRegistration()` -> RegistrationCredentialJSON.transports (API L2 and up) - transports?: AuthenticatorTransportFuture[]; + // From browser's `startRegistration()` -> RegistrationCredential.response.transports (API L2 and up) + transports?: string[]; }; -/** - * An attempt to communicate that this isn't just any string, but a Base64URL-encoded string - */ -export type Base64URLString = string; - -/** - * AuthenticatorAttestationResponse in TypeScript's DOM lib is outdated (up through v3.9.7). - * Maintain an augmented version here so we can implement additional properties as the WebAuthn - * spec evolves. - * - * See https://www.w3.org/TR/webauthn-2/#iface-authenticatorattestationresponse - * - * Properties marked optional are not supported in all browsers. - */ -export interface AuthenticatorAttestationResponseFuture extends AuthenticatorAttestationResponse { - getTransports(): AuthenticatorTransportFuture[]; -} - -/** - * A super class of TypeScript's `AuthenticatorTransport` that includes support for the latest - * transports. Should eventually be replaced by TypeScript's when TypeScript gets updated to - * know about it (sometime after 4.6.3) - */ -export type AuthenticatorTransportFuture = - | 'ble' - | 'cable' - | 'hybrid' - | 'internal' - | 'nfc' - | 'smart-card' - | 'usb'; - -/** - * A super class of TypeScript's `PublicKeyCredentialDescriptor` that knows about the latest - * transports. Should eventually be replaced by TypeScript's when TypeScript gets updated to - * know about it (sometime after 4.6.3) - */ -export interface PublicKeyCredentialDescriptorFuture - extends Omit { - transports?: AuthenticatorTransportFuture[]; -} - /** */ export type PublicKeyCredentialJSON = | RegistrationResponseJSON diff --git a/packages/server/src/types/dom.ts b/packages/server/src/types/dom.ts index 38eb272e..d3ad8e0e 100644 --- a/packages/server/src/types/dom.ts +++ b/packages/server/src/types/dom.ts @@ -136,6 +136,12 @@ export interface PublicKeyCredentialDescriptor { type: PublicKeyCredentialType; } +export interface PublicKeyCredentialDescriptorJSON { + id: Base64URLString; + transports?: string[]; + type: string; +} + export interface PublicKeyCredentialParameters { alg: COSEAlgorithmIdentifier; type: PublicKeyCredentialType; @@ -592,6 +598,7 @@ export interface RsaKeyGenParams extends Algorithm { export type AttestationConveyancePreference = "direct" | "enterprise" | "indirect" | "none"; export type AuthenticatorTransport = "ble" | "hybrid" | "internal" | "nfc" | "usb"; +export type Base64URLString = string; export type COSEAlgorithmIdentifier = number; export type ResidentKeyRequirement = "discouraged" | "preferred" | "required"; export type UserVerificationRequirement = "discouraged" | "preferred" | "required"; diff --git a/packages/server/src/types/index.ts b/packages/server/src/types/index.ts index 915f8bd7..e565d1c3 100644 --- a/packages/server/src/types/index.ts +++ b/packages/server/src/types/index.ts @@ -16,10 +16,11 @@ import type { AuthenticatorAttachment, AuthenticatorAttestationResponse, AuthenticatorSelectionCriteria, + Base64URLString, COSEAlgorithmIdentifier, PublicKeyCredential, PublicKeyCredentialCreationOptions, - PublicKeyCredentialDescriptor, + PublicKeyCredentialDescriptorJSON, PublicKeyCredentialParameters, PublicKeyCredentialRequestOptions, PublicKeyCredentialRpEntity, @@ -36,6 +37,7 @@ export type { AuthenticatorAttestationResponse, AuthenticatorSelectionCriteria, AuthenticatorTransport, + Base64URLString, COSEAlgorithmIdentifier, CredentialCreationOptions, CredentialRequestOptions, @@ -43,6 +45,7 @@ export type { PublicKeyCredential, PublicKeyCredentialCreationOptions, PublicKeyCredentialDescriptor, + PublicKeyCredentialDescriptorJSON, PublicKeyCredentialParameters, PublicKeyCredentialRequestOptions, PublicKeyCredentialRpEntity, @@ -89,15 +92,6 @@ export interface PublicKeyCredentialRequestOptionsJSON { extensions?: AuthenticationExtensionsClientInputs; } -/** - * https://w3c.github.io/webauthn/#dictdef-publickeycredentialdescriptorjson - */ -export interface PublicKeyCredentialDescriptorJSON { - id: Base64URLString; - type: PublicKeyCredentialType; - transports?: AuthenticatorTransportFuture[]; -} - /** * https://w3c.github.io/webauthn/#dictdef-publickeycredentialuserentityjson */ @@ -111,7 +105,7 @@ export interface PublicKeyCredentialUserEntityJSON { * The value returned from navigator.credentials.create() */ export interface RegistrationCredential extends PublicKeyCredentialFuture { - response: AuthenticatorAttestationResponseFuture; + response: AuthenticatorAttestationResponse; } /** @@ -163,7 +157,7 @@ export interface AuthenticatorAttestationResponseJSON { // Optional in L2, but becomes required in L3. Play it safe until L3 becomes Recommendation authenticatorData?: Base64URLString; // Optional in L2, but becomes required in L3. Play it safe until L3 becomes Recommendation - transports?: AuthenticatorTransportFuture[]; + transports?: string[]; // Optional in L2, but becomes required in L3. Play it safe until L3 becomes Recommendation publicKeyAlgorithm?: COSEAlgorithmIdentifier; publicKey?: Base64URLString; @@ -190,52 +184,10 @@ export type WebAuthnCredential = { publicKey: Uint8Array_; // Number of times this authenticator is expected to have been used counter: number; - // From browser's `startRegistration()` -> RegistrationCredentialJSON.transports (API L2 and up) - transports?: AuthenticatorTransportFuture[]; + // From browser's `startRegistration()` -> RegistrationCredential.response.transports (API L2 and up) + transports?: string[]; }; -/** - * An attempt to communicate that this isn't just any string, but a Base64URL-encoded string - */ -export type Base64URLString = string; - -/** - * AuthenticatorAttestationResponse in TypeScript's DOM lib is outdated (up through v3.9.7). - * Maintain an augmented version here so we can implement additional properties as the WebAuthn - * spec evolves. - * - * See https://www.w3.org/TR/webauthn-2/#iface-authenticatorattestationresponse - * - * Properties marked optional are not supported in all browsers. - */ -export interface AuthenticatorAttestationResponseFuture extends AuthenticatorAttestationResponse { - getTransports(): AuthenticatorTransportFuture[]; -} - -/** - * A super class of TypeScript's `AuthenticatorTransport` that includes support for the latest - * transports. Should eventually be replaced by TypeScript's when TypeScript gets updated to - * know about it (sometime after 4.6.3) - */ -export type AuthenticatorTransportFuture = - | 'ble' - | 'cable' - | 'hybrid' - | 'internal' - | 'nfc' - | 'smart-card' - | 'usb'; - -/** - * A super class of TypeScript's `PublicKeyCredentialDescriptor` that knows about the latest - * transports. Should eventually be replaced by TypeScript's when TypeScript gets updated to - * know about it (sometime after 4.6.3) - */ -export interface PublicKeyCredentialDescriptorFuture - extends Omit { - transports?: AuthenticatorTransportFuture[]; -} - /** */ export type PublicKeyCredentialJSON = | RegistrationResponseJSON From 51d8e4ab2bd184c2eee7372d98c71f6751779f92 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 5 Jul 2026 21:47:21 -0700 Subject: [PATCH 7/7] Remember why the casting was needed --- packages/browser/src/methods/startAuthentication.ts | 5 ++++- packages/browser/src/methods/startRegistration.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/browser/src/methods/startAuthentication.ts b/packages/browser/src/methods/startAuthentication.ts index ee6cb200..5260e38a 100644 --- a/packages/browser/src/methods/startAuthentication.ts +++ b/packages/browser/src/methods/startAuthentication.ts @@ -105,7 +105,10 @@ export async function startAuthentication( // Wait for the user to complete assertion let credential; try { - credential = (await navigator.credentials.get(getOptions)) as AuthenticationCredential; + credential = (await navigator.credentials.get( + // TODO: Newer versions of Deno require this casting, revisit once we're using Deno 2.6+ + getOptions as globalThis.CredentialRequestOptions, + )) as AuthenticationCredential; } catch (err) { throw identifyAuthenticationError({ error: err as Error, options: getOptions }); } diff --git a/packages/browser/src/methods/startRegistration.ts b/packages/browser/src/methods/startRegistration.ts index d93df4c4..918be719 100644 --- a/packages/browser/src/methods/startRegistration.ts +++ b/packages/browser/src/methods/startRegistration.ts @@ -77,7 +77,10 @@ export async function startRegistration( // Wait for the user to complete attestation let credential; try { - credential = (await navigator.credentials.create(createOptions)) as RegistrationCredential; + credential = (await navigator.credentials.create( + // TODO: Newer versions of Deno require this casting, revisit once we're using Deno 2.6+ + createOptions as globalThis.CredentialCreationOptions, + )) as RegistrationCredential; } catch (err) { throw identifyRegistrationError({ error: err as Error, options: createOptions }); }