Skip to content

Commit

Permalink
Add passkey signIn onVerificationStarted callback param (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisfisher authored Jul 29, 2024
1 parent aff09b1 commit 249dbf8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
19 changes: 12 additions & 7 deletions src/passkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ type SignUpResponse = {
token?: string;
};

type SignInParams = {
token?: string;
autofill?: boolean;
action?: string;
onVerificationStarted?: () => unknown;
};

type SignInResponse = {
token?: string;
userId?: string;
Expand Down Expand Up @@ -81,13 +88,7 @@ export class Passkey {
};
}

async signIn(): Promise<SignInResponse | undefined>;
async signIn(params?: {action: string; autofill?: boolean}): Promise<SignInResponse | undefined>;
async signIn(params?: {token: string}): Promise<SignInResponse | undefined>;
async signIn(params?: {autofill: boolean}): Promise<SignInResponse | undefined>;
async signIn(
params?: {token?: string; autofill?: boolean; action?: string} | undefined
): Promise<SignInResponse | undefined> {
async signIn(params?: SignInParams): Promise<SignInResponse | undefined> {
if (params?.token && params.autofill) {
throw new Error("autofill is not supported when providing a token");
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 249dbf8

Please sign in to comment.