summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/methods/startRegistration.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2022-03-08 20:42:52 -0800
committerGitHub <noreply@github.com>2022-03-08 20:42:52 -0800
commit30ed8e8913ab59f97587258b4a2f5e3e8b867f5b (patch)
treeba4859ee4b70b0ca646d631d2c14d1e1981a386f /packages/browser/src/methods/startRegistration.ts
parent4a8fb255d4fd6fbc146dedf0a2efc938b99f5973 (diff)
parentc62c1ce7451cb3876851c802d52254dd9fe6d91c (diff)
Merge pull request #184 from MasterKale/feat/identify-errors
feat/identify-errors
Diffstat (limited to 'packages/browser/src/methods/startRegistration.ts')
-rw-r--r--packages/browser/src/methods/startRegistration.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/packages/browser/src/methods/startRegistration.ts b/packages/browser/src/methods/startRegistration.ts
index eec07c5..4037092 100644
--- a/packages/browser/src/methods/startRegistration.ts
+++ b/packages/browser/src/methods/startRegistration.ts
@@ -9,6 +9,7 @@ import bufferToBase64URLString from '../helpers/bufferToBase64URLString';
import base64URLStringToBuffer from '../helpers/base64URLStringToBuffer';
import { browserSupportsWebauthn } from '../helpers/browserSupportsWebauthn';
import toPublicKeyCredentialDescriptor from '../helpers/toPublicKeyCredentialDescriptor';
+import { identifyRegistrationError } from '../helpers/identifyRegistrationError';
/**
* Begin authenticator "registration" via WebAuthn attestation
@@ -33,8 +34,15 @@ export default async function startRegistration(
excludeCredentials: creationOptionsJSON.excludeCredentials.map(toPublicKeyCredentialDescriptor),
};
+ const options: CredentialCreationOptions = { publicKey };
+
// Wait for the user to complete attestation
- const credential = (await navigator.credentials.create({ publicKey })) as RegistrationCredential;
+ let credential;
+ try {
+ credential = (await navigator.credentials.create(options)) as RegistrationCredential;
+ } catch (err) {
+ throw identifyRegistrationError({ error: err as Error, options });
+ }
if (!credential) {
throw new Error('Registration was not completed');