summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/methods/startAuthentication.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2024-04-12 13:04:48 -0700
committerMatthew Miller <matthew@millerti.me>2024-04-12 13:04:48 -0700
commit6e780a49d702c0f52dc17820ce85a64fa9df346f (patch)
treec230504fd4f86b3b635d40f8b6147875fea942f1 /packages/browser/src/methods/startAuthentication.ts
parent9ebd9ec6199d0fb716b6dfea80dbcffee8f88e92 (diff)
Rename options JSON args in browser methods
Diffstat (limited to 'packages/browser/src/methods/startAuthentication.ts')
-rw-r--r--packages/browser/src/methods/startAuthentication.ts17
1 files changed, 8 insertions, 9 deletions
diff --git a/packages/browser/src/methods/startAuthentication.ts b/packages/browser/src/methods/startAuthentication.ts
index a63eed9..8b2e02d 100644
--- a/packages/browser/src/methods/startAuthentication.ts
+++ b/packages/browser/src/methods/startAuthentication.ts
@@ -16,12 +16,11 @@ import { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment'
/**
* Begin authenticator "login" via WebAuthn assertion
*
- * @param requestOptionsJSON Output from **@simplewebauthn/server**'s `generateAuthenticationOptions()`
- * @param useBrowserAutofill Initialize conditional UI to enable logging in via browser
- * autofill prompts
+ * @param optionsJSON Output from **@simplewebauthn/server**'s `generateAuthenticationOptions()`
+ * @param useBrowserAutofill (Optional) Initialize conditional UI to enable logging in via browser autofill prompts. Defaults to `false`.
*/
export async function startAuthentication(
- requestOptionsJSON: PublicKeyCredentialRequestOptionsJSON,
+ optionsJSON: PublicKeyCredentialRequestOptionsJSON,
useBrowserAutofill = false,
): Promise<AuthenticationResponseJSON> {
if (!browserSupportsWebAuthn()) {
@@ -31,16 +30,16 @@ export async function startAuthentication(
// We need to avoid passing empty array to avoid blocking retrieval
// of public key
let allowCredentials;
- if (requestOptionsJSON.allowCredentials?.length !== 0) {
- allowCredentials = requestOptionsJSON.allowCredentials?.map(
+ if (optionsJSON.allowCredentials?.length !== 0) {
+ allowCredentials = optionsJSON.allowCredentials?.map(
toPublicKeyCredentialDescriptor,
);
}
// We need to convert some values to Uint8Arrays before passing the credentials to the navigator
const publicKey: PublicKeyCredentialRequestOptions = {
- ...requestOptionsJSON,
- challenge: base64URLStringToBuffer(requestOptionsJSON.challenge),
+ ...optionsJSON,
+ challenge: base64URLStringToBuffer(optionsJSON.challenge),
allowCredentials,
};
@@ -58,7 +57,7 @@ export async function startAuthentication(
// Check for an <input> with "webauthn" in its `autocomplete` attribute
const eligibleInputs = document.querySelectorAll(
- 'input[autocomplete$=\'webauthn\']',
+ "input[autocomplete$='webauthn']",
);
// WebAuthn autofill requires at least one valid input