diff options
author | Matthew Miller <matthew@millerti.me> | 2022-03-08 20:42:52 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-08 20:42:52 -0800 |
commit | 30ed8e8913ab59f97587258b4a2f5e3e8b867f5b (patch) | |
tree | ba4859ee4b70b0ca646d631d2c14d1e1981a386f /packages/browser/src/methods/startAuthentication.ts | |
parent | 4a8fb255d4fd6fbc146dedf0a2efc938b99f5973 (diff) | |
parent | c62c1ce7451cb3876851c802d52254dd9fe6d91c (diff) |
Merge pull request #184 from MasterKale/feat/identify-errors
feat/identify-errors
Diffstat (limited to 'packages/browser/src/methods/startAuthentication.ts')
-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'); |