Skip to content

Commit 6231a08

Browse files
committed
Recover gracefully if browser doesn't support getTransports()
1 parent c459c87 commit 6231a08

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ fetch(/* ... */) // Make the call that returns the credential
236236
response: {
237237
attestationObject: uint8arrayToBase64url(publicKeyCredential.response.attestationObject),
238238
clientDataJSON: uint8arrayToBase64url(publicKeyCredential.response.clientDataJSON),
239-
transports: publicKeyCredential.response.getTransports() || [],
239+
240+
// Attempt to read transports, but recover gracefully if not supported by the browser
241+
transports: publicKeyCredential.response.getTransports && publicKeyCredential.response.getTransports() || [],
240242
},
241243

242244
// Warning: Client extension results could also contain binary data that needs encoding

webauthn-server-demo/src/main/webapp/js/webauthn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
response: {
142142
attestationObject: base64url.fromByteArray(response.response.attestationObject),
143143
clientDataJSON: base64url.fromByteArray(response.response.clientDataJSON),
144-
transports: response.response.getTransports() || [],
144+
transports: response.response.getTransports && response.response.getTransports() || [],
145145
},
146146
clientExtensionResults,
147147
};

0 commit comments

Comments
 (0)