diff options
-rw-r--r-- | packages/browser/src/methods/startAuthentication.ts | 17 | ||||
-rw-r--r-- | packages/browser/src/methods/startRegistration.ts | 14 |
2 files changed, 15 insertions, 16 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 diff --git a/packages/browser/src/methods/startRegistration.ts b/packages/browser/src/methods/startRegistration.ts index 73c899e..b661de7 100644 --- a/packages/browser/src/methods/startRegistration.ts +++ b/packages/browser/src/methods/startRegistration.ts @@ -16,10 +16,10 @@ import { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment' /** * Begin authenticator "registration" via WebAuthn attestation * - * @param creationOptionsJSON Output from **@simplewebauthn/server**'s `generateRegistrationOptions()` + * @param optionsJSON Output from **@simplewebauthn/server**'s `generateRegistrationOptions()` */ export async function startRegistration( - creationOptionsJSON: PublicKeyCredentialCreationOptionsJSON, + optionsJSON: PublicKeyCredentialCreationOptionsJSON, ): Promise<RegistrationResponseJSON> { if (!browserSupportsWebAuthn()) { throw new Error('WebAuthn is not supported in this browser'); @@ -27,13 +27,13 @@ export async function startRegistration( // We need to convert some values to Uint8Arrays before passing the credentials to the navigator const publicKey: PublicKeyCredentialCreationOptions = { - ...creationOptionsJSON, - challenge: base64URLStringToBuffer(creationOptionsJSON.challenge), + ...optionsJSON, + challenge: base64URLStringToBuffer(optionsJSON.challenge), user: { - ...creationOptionsJSON.user, - id: base64URLStringToBuffer(creationOptionsJSON.user.id), + ...optionsJSON.user, + id: base64URLStringToBuffer(optionsJSON.user.id), }, - excludeCredentials: creationOptionsJSON.excludeCredentials?.map( + excludeCredentials: optionsJSON.excludeCredentials?.map( toPublicKeyCredentialDescriptor, ), }; |