summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/methods/startRegistration.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2022-06-17 23:03:46 -0700
committerMatthew Miller <matthew@millerti.me>2022-06-17 23:03:46 -0700
commit6b1f531754a2816bc4d0a0ea51543a1c6ba54316 (patch)
tree06d92d992cb01653d436fb1d6999c11cb30ba793 /packages/browser/src/methods/startRegistration.ts
parent0c62c20f32514079e904f2925d73bf46d670cf20 (diff)
Create WebAuthnAbortService for abort signal mgmt
Diffstat (limited to 'packages/browser/src/methods/startRegistration.ts')
-rw-r--r--packages/browser/src/methods/startRegistration.ts3
1 files changed, 3 insertions, 0 deletions
diff --git a/packages/browser/src/methods/startRegistration.ts b/packages/browser/src/methods/startRegistration.ts
index 4037092..40a3dd9 100644
--- a/packages/browser/src/methods/startRegistration.ts
+++ b/packages/browser/src/methods/startRegistration.ts
@@ -10,6 +10,7 @@ import base64URLStringToBuffer from '../helpers/base64URLStringToBuffer';
import { browserSupportsWebauthn } from '../helpers/browserSupportsWebauthn';
import toPublicKeyCredentialDescriptor from '../helpers/toPublicKeyCredentialDescriptor';
import { identifyRegistrationError } from '../helpers/identifyRegistrationError';
+import { webauthnAbortService } from '../helpers/webAuthnAbortService';
/**
* Begin authenticator "registration" via WebAuthn attestation
@@ -39,6 +40,8 @@ export default async function startRegistration(
// Wait for the user to complete attestation
let credential;
try {
+ // Set up the ability to cancel this request if the user attempts another
+ options.signal = webauthnAbortService.createNewAbortSignal();
credential = (await navigator.credentials.create(options)) as RegistrationCredential;
} catch (err) {
throw identifyRegistrationError({ error: err as Error, options });