summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/methods
diff options
context:
space:
mode:
Diffstat (limited to 'packages/browser/src/methods')
-rw-r--r--packages/browser/src/methods/startAuthentication.ts16
-rw-r--r--packages/browser/src/methods/startRegistration.ts5
2 files changed, 14 insertions, 7 deletions
diff --git a/packages/browser/src/methods/startAuthentication.ts b/packages/browser/src/methods/startAuthentication.ts
index 0bcd097..0ab7e6b 100644
--- a/packages/browser/src/methods/startAuthentication.ts
+++ b/packages/browser/src/methods/startAuthentication.ts
@@ -42,7 +42,8 @@ export async function startAuthentication(
allowCredentials,
};
- const options: CredentialRequestOptions = { publicKey };
+ // Prepare options for `.get()`
+ const options: CredentialRequestOptions = {};
/**
* Set up the page to prompt the user to select a credential for authentication via the browser's
@@ -64,15 +65,20 @@ export async function startAuthentication(
// `CredentialMediationRequirement` doesn't know about "conditional" yet as of
// typescript@4.6.3
options.mediation = 'conditional' as CredentialMediationRequirement;
- // Massage options into a suitable structure
- delete options.publicKey?.allowCredentials;
+ // Conditional UI requires an empty allow list
+ publicKey.allowCredentials = [];
+
+ console.log('ready for conditional UI');
}
+ // Finalize options
+ options.publicKey = publicKey;
+ // Set up the ability to cancel this request if the user attempts another
+ options.signal = webauthnAbortService.createNewAbortSignal();
+
// Wait for the user to complete assertion
let credential;
try {
- // Set up the ability to cancel this request if the user attempts another
- options.signal = webauthnAbortService.createNewAbortSignal();
credential = (await navigator.credentials.get(options)) as AuthenticationCredential;
} catch (err) {
throw identifyAuthenticationError({ error: err as Error, options });
diff --git a/packages/browser/src/methods/startRegistration.ts b/packages/browser/src/methods/startRegistration.ts
index 237744f..f7149d7 100644
--- a/packages/browser/src/methods/startRegistration.ts
+++ b/packages/browser/src/methods/startRegistration.ts
@@ -35,13 +35,14 @@ export async function startRegistration(
excludeCredentials: creationOptionsJSON.excludeCredentials.map(toPublicKeyCredentialDescriptor),
};
+ // Finalize options
const options: CredentialCreationOptions = { publicKey };
+ // Set up the ability to cancel this request if the user attempts another
+ options.signal = webauthnAbortService.createNewAbortSignal();
// 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 });