From cbfa15930382f98e215c2e68103e5ac8770b22fe Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Tue, 27 Dec 2022 20:51:40 -0800 Subject: Be more cautious with transports --- packages/browser/src/methods/startRegistration.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'packages/browser/src') diff --git a/packages/browser/src/methods/startRegistration.ts b/packages/browser/src/methods/startRegistration.ts index f72a10b..bceff2a 100644 --- a/packages/browser/src/methods/startRegistration.ts +++ b/packages/browser/src/methods/startRegistration.ts @@ -2,6 +2,7 @@ import { PublicKeyCredentialCreationOptionsJSON, RegistrationCredential, RegistrationResponseJSON, + AuthenticatorTransportFuture, } from '@simplewebauthn/typescript-types'; import { utf8StringToBuffer } from '../helpers/utf8StringToBuffer'; @@ -55,13 +56,19 @@ 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; + if (typeof response.getTransports === 'function') { + transports = response.getTransports(); + } + return { id, rawId: bufferToBase64URLString(rawId), response: { attestationObject: bufferToBase64URLString(response.attestationObject), clientDataJSON: bufferToBase64URLString(response.clientDataJSON), - transports: response.getTransports(), + transports, }, type, clientExtensionResults: credential.getClientExtensionResults(), -- cgit v1.2.3