diff --git a/package.json b/package.json index 50cdde1..9300a37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@authsignal/browser", - "version": "0.5.1", + "version": "0.5.2", "type": "module", "main": "dist/index.js", "module": "dist/index.js", diff --git a/src/passkey.ts b/src/passkey.ts index 3e925af..506ac54 100644 --- a/src/passkey.ts +++ b/src/passkey.ts @@ -21,6 +21,13 @@ type SignUpResponse = { token?: string; }; +type SignInParams = { + token?: string; + autofill?: boolean; + action?: string; + onVerificationStarted?: () => unknown; +}; + type SignInResponse = { token?: string; userId?: string; @@ -81,13 +88,7 @@ export class Passkey { }; } - async signIn(): Promise; - async signIn(params?: {action: string; autofill?: boolean}): Promise; - async signIn(params?: {token: string}): Promise; - async signIn(params?: {autofill: boolean}): Promise; - async signIn( - params?: {token?: string; autofill?: boolean; action?: string} | undefined - ): Promise { + async signIn(params?: SignInParams): Promise { if (params?.token && params.autofill) { throw new Error("autofill is not supported when providing a token"); } @@ -115,6 +116,10 @@ export class Passkey { const authenticationResponse = await startAuthentication(optionsResponse.options, params?.autofill); + if (params?.onVerificationStarted) { + params.onVerificationStarted(); + } + const verifyResponse = await this.api.verify({ challengeId: optionsResponse.challengeId, authenticationCredential: authenticationResponse,