From d5fe27f1137d486e7ee40871bb91f55ec45ee1e3 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Mon, 7 Mar 2022 20:32:54 -0800 Subject: Wire up authentication error identification --- packages/browser/src/methods/startAuthentication.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'packages/browser/src/methods') 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'); -- cgit v1.2.3