summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/methods/startAssertion.ts
diff options
context:
space:
mode:
authorAntoine Cormouls <contact.antoine.cormouls@gmail.com>2020-12-07 09:11:40 +0100
committerAntoine Cormouls <contact.antoine.cormouls@gmail.com>2020-12-07 09:11:40 +0100
commit106e05f4294aabed133a26efb31252628fffec93 (patch)
tree596112b13f0ae40521d8e589fbae7e47e1814ef2 /packages/browser/src/methods/startAssertion.ts
parente2f91c5facf90a43c3c017ace1200a6c5eeb0ae6 (diff)
review fixes
Diffstat (limited to 'packages/browser/src/methods/startAssertion.ts')
-rw-r--r--packages/browser/src/methods/startAssertion.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/packages/browser/src/methods/startAssertion.ts b/packages/browser/src/methods/startAssertion.ts
index fbc6f59..e02e577 100644
--- a/packages/browser/src/methods/startAssertion.ts
+++ b/packages/browser/src/methods/startAssertion.ts
@@ -21,16 +21,18 @@ export default async function startAssertion(
throw new Error('WebAuthn is not supported in this browser');
}
+ // We need to avoid passing empty array to avoid blocking retrieval
+ // of public key
+ let allowCredentials;
+ if (requestOptionsJSON.allowCredentials?.length !== 0) {
+ allowCredentials = requestOptionsJSON.allowCredentials?.map(toPublicKeyCredentialDescriptor);
+ }
+
// We need to convert some values to Uint8Arrays before passing the credentials to the navigator
const publicKey: PublicKeyCredentialRequestOptions = {
...requestOptionsJSON,
challenge: base64URLStringToBuffer(requestOptionsJSON.challenge),
- // We need to avoid passing empty array to avoid blocking retrieval
- // of public key
- allowCredentials:
- requestOptionsJSON.allowCredentials?.length === 0
- ? undefined
- : requestOptionsJSON.allowCredentials?.map(toPublicKeyCredentialDescriptor),
+ allowCredentials,
};
// Wait for the user to complete assertion