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

Passkeys #28

Merged
merged 7 commits into from
May 16, 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
Prev Previous commit
Throw error if both a token and autofill is specified
  • Loading branch information
hwhmeikle committed May 16, 2023
commit b2aec78e9748d193a70614632d72c2f118180d84
20 changes: 12 additions & 8 deletions src/passkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export class Passkey {
}

async signUp({userName, token}: SignUpParams) {
const optsResponse = await this.api.registrationOptions({userName, token});
const optionsResponse = await this.api.registrationOptions({userName, token});

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

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

Expand All @@ -40,14 +40,18 @@ export class Passkey {
async signIn(params?: {token: string}): Promise<string | undefined>;
async signIn(params?: {autofill: boolean}): Promise<string | undefined>;
async signIn(params?: {token?: string; autofill?: boolean} | undefined) {
const optsResponse = await this.api.authenticationOptions({token: params?.token});
if (params?.token && params.autofill) {
throw new Error("Autofill is not supported when providing a token");
}

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

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

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

Expand Down