summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/methods
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2022-03-04 09:08:09 -0800
committerMatthew Miller <matthew@millerti.me>2022-03-04 09:08:09 -0800
commit26dc995ee796a0ba3298d23dd2127f4c3b2dc40b (patch)
tree6bb055a37e1d989af21d2614f9739b75c10e5300 /packages/browser/src/methods
parentc277856acfcaa101e275ac7262010819ec85bf95 (diff)
Identify error during startRegistration
Diffstat (limited to 'packages/browser/src/methods')
-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..4cc92cc 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');