Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AUT-1266] Propagate errors in passkey methods #40

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove try/catch
  • Loading branch information
hwhmeikle committed Aug 10, 2023
commit 92fb3f08a61c69c8c6e80e1a43333ce0fe0c1c53
40 changes: 16 additions & 24 deletions src/passkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,15 @@ export class Passkey {
async signUp({userName, token}: SignUpParams) {
const optionsResponse = await this.api.registrationOptions({userName, token});

try {
const registrationResponse = await startRegistration(optionsResponse.options);

const addAuthenticatorResponse = await this.api.addAuthenticator({
challengeId: optionsResponse.challengeId,
registrationCredential: registrationResponse,
token,
});

return addAuthenticatorResponse?.accessToken;
} catch (error) {
console.error(error);
}
const registrationResponse = await startRegistration(optionsResponse.options);

const addAuthenticatorResponse = await this.api.addAuthenticator({
challengeId: optionsResponse.challengeId,
registrationCredential: registrationResponse,
token,
});

return addAuthenticatorResponse?.accessToken;
}

async signIn(params?: {token: string}): Promise<string | undefined>;
Expand All @@ -46,18 +42,14 @@ export class Passkey {

const optionsResponse = await this.api.authenticationOptions({token: params?.token});

try {
const authenticationResponse = await startAuthentication(optionsResponse.options, params?.autofill);
const authenticationResponse = await startAuthentication(optionsResponse.options, params?.autofill);

const verifyResponse = await this.api.verify({
challengeId: optionsResponse.challengeId,
authenticationCredential: authenticationResponse,
token: params?.token,
});
const verifyResponse = await this.api.verify({
challengeId: optionsResponse.challengeId,
authenticationCredential: authenticationResponse,
token: params?.token,
});

return verifyResponse?.accessToken;
} catch (error) {
console.error(error);
}
return verifyResponse?.accessToken;
}
}