diff options
author | Matthew Miller <matthew@millerti.me> | 2022-03-07 20:32:54 -0800 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2022-03-07 20:32:54 -0800 |
commit | d5fe27f1137d486e7ee40871bb91f55ec45ee1e3 (patch) | |
tree | 9a65b2a5e869c71284dad343a21940cac7adbdee /packages/browser/src/methods | |
parent | 635bd46e3a4c585f413af8924a4a825d6ba42e21 (diff) |
Wire up authentication error identification
Diffstat (limited to 'packages/browser/src/methods')
-rw-r--r-- | packages/browser/src/methods/startAuthentication.ts | 10 |
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'); |