summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/methods/startAuthentication.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/browser/src/methods/startAuthentication.ts')
-rw-r--r--packages/browser/src/methods/startAuthentication.ts16
1 files changed, 11 insertions, 5 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 });