summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/methods/startAuthentication.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/browser/src/methods/startAuthentication.ts')
-rw-r--r--packages/browser/src/methods/startAuthentication.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/packages/browser/src/methods/startAuthentication.ts b/packages/browser/src/methods/startAuthentication.ts
index 277b8f0..ee401a1 100644
--- a/packages/browser/src/methods/startAuthentication.ts
+++ b/packages/browser/src/methods/startAuthentication.ts
@@ -9,6 +9,7 @@ import base64URLStringToBuffer from '../helpers/base64URLStringToBuffer';
import bufferToUTF8String from '../helpers/bufferToUTF8String';
import { browserSupportsWebauthn } from '../helpers/browserSupportsWebauthn';
import toPublicKeyCredentialDescriptor from '../helpers/toPublicKeyCredentialDescriptor';
+import { identifyAuthenticationError } from '../helpers/identifyAuthenticationError';
/**
* Begin authenticator "login" via WebAuthn assertion
@@ -36,8 +37,15 @@ export default async function startAuthentication(
allowCredentials,
};
+ const options: CredentialRequestOptions = { publicKey };
+
// Wait for the user to complete assertion
- const credential = (await navigator.credentials.get({ publicKey })) as AuthenticationCredential;
+ let credential;
+ try {
+ credential = (await navigator.credentials.get(options)) as AuthenticationCredential;
+ } catch (err) {
+ throw identifyAuthenticationError({ error: err as Error, options });
+ }
if (!credential) {
throw new Error('Authentication was not completed');