diff --git a/package.json b/package.json index 7683924..ce9be5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@authsignal/browser", - "version": "1.14.1", + "version": "1.15.0", "type": "module", "main": "dist/index.js", "module": "dist/index.js", diff --git a/src/passkey.ts b/src/passkey.ts index ac58a95..ef39161 100644 --- a/src/passkey.ts +++ b/src/passkey.ts @@ -4,6 +4,7 @@ import { AuthenticationResponseJSON, RegistrationResponseJSON, AuthenticatorAttachment, + PublicKeyCredentialHint, } from "@simplewebauthn/browser"; import {PasskeyApiClient} from "./api/passkey-api-client"; @@ -25,6 +26,7 @@ type SignUpParams = { username?: string; displayName?: string; authenticatorAttachment?: AuthenticatorAttachment | null; + hints?: PublicKeyCredentialHint[]; useAutoRegister?: boolean; useCookies?: boolean; }; @@ -73,6 +75,7 @@ export class Passkey { displayName, token, authenticatorAttachment = "platform", + hints, useAutoRegister = false, useCookies = false, }: SignUpParams): Promise> { @@ -103,7 +106,9 @@ export class Passkey { } try { - const registrationResponse = await startRegistration({optionsJSON: optionsResponse.options, useAutoRegister}); + const optionsJSON = hints ? {...optionsResponse.options, hints} : optionsResponse.options; + + const registrationResponse = await startRegistration({optionsJSON, useAutoRegister}); const addAuthenticatorResponse = await this.api.addAuthenticator({ registrationCredential: registrationResponse, diff --git a/src/security-key.ts b/src/security-key.ts index 73962b0..f184089 100644 --- a/src/security-key.ts +++ b/src/security-key.ts @@ -3,6 +3,7 @@ import { startRegistration, AuthenticationResponseJSON, RegistrationResponseJSON, + PublicKeyCredentialHint, } from "@simplewebauthn/browser"; import {TokenCache} from "./token-cache"; @@ -38,7 +39,7 @@ export class SecurityKey { this.enableLogging = enableLogging; } - async enroll(): Promise> { + async enroll({hints}: {hints?: PublicKeyCredentialHint[]} = {}): Promise> { if (!this.cache.token) { return this.cache.handleTokenNotSetError(); } @@ -54,7 +55,9 @@ export class SecurityKey { } try { - const registrationResponse = await startRegistration({optionsJSON: optionsResponse}); + const optionsJSON = hints ? {...optionsResponse, hints} : optionsResponse; + + const registrationResponse = await startRegistration({optionsJSON}); const addAuthenticatorResponse = await this.api.addAuthenticator({ registrationCredential: registrationResponse,