Skip to content

Commit bb98733

Browse files
committed
Fix bugs
1 parent 55944a5 commit bb98733

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

api/endpoints/admin/passkeyAuth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const handler = async (event: APIGatewayEvent): Promise<APIGatewayProxyRe
2727

2828
const currentTime = Math.floor(Date.now() / 1000);
2929
if (challengeRecord.expiresAt < currentTime) {
30-
await deleteItem(PASSKEY_CHALLENGES_TABLE, challengeRecord.challenge);
30+
await deleteItem(PASSKEY_CHALLENGES_TABLE, challengeRecord.id);
3131
return buildErrorResponse(event, HttpResponseStatus.BAD_REQUEST, "Challenge expired");
3232
}
3333

@@ -50,7 +50,7 @@ export const handler = async (event: APIGatewayEvent): Promise<APIGatewayProxyRe
5050

5151
const verification = await verifyAuthenticationResponse({
5252
response: body.response,
53-
expectedChallenge: challengeRecord.challenge,
53+
expectedChallenge: challengeRecord.id,
5454
expectedOrigin: RP_ORIGIN,
5555
expectedRPID: RP_ID,
5656
credential: webAuthnCredential
@@ -65,7 +65,7 @@ export const handler = async (event: APIGatewayEvent): Promise<APIGatewayProxyRe
6565
counter: verification.authenticationInfo.newCounter
6666
});
6767

68-
await deleteItem(PASSKEY_CHALLENGES_TABLE, challengeRecord.challenge);
68+
await deleteItem(PASSKEY_CHALLENGES_TABLE, challengeRecord.id);
6969

7070
const token = await generateToken("admin", GrantType.AUTH);
7171

api/endpoints/admin/passkeyAuthOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const handler = async (event: APIGatewayEvent): Promise<APIGatewayProxyRe
1919
})),
2020
});
2121
await putItem(PASSKEY_CHALLENGES_TABLE, {
22-
...options,
22+
id: options.challenge,
2323
type: "authentication",
2424
expiresAt: Math.floor(Date.now() / 1000) + 300 // 5 minutes from now
2525
});

api/endpoints/admin/passkeyRegister.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ export const handler = async (event: APIGatewayEvent): Promise<APIGatewayProxyRe
3434

3535
const currentTime = Math.floor(Date.now() / 1000);
3636
if (challengeRecord.expiresAt < currentTime) {
37-
await deleteItem(PASSKEY_CHALLENGES_TABLE, challengeRecord.challenge);
37+
await deleteItem(PASSKEY_CHALLENGES_TABLE, challengeRecord.id);
3838
return buildErrorResponse(event, HttpResponseStatus.BAD_REQUEST, "Challenge expired");
3939
}
4040

4141
try {
4242
const verification = await verifyRegistrationResponse({
4343
response: body.response,
44-
expectedChallenge: challengeRecord.challenge,
44+
expectedChallenge: challengeRecord.id,
4545
expectedOrigin: RP_ORIGIN,
4646
expectedRPID: RP_ID
4747
});
@@ -63,7 +63,7 @@ export const handler = async (event: APIGatewayEvent): Promise<APIGatewayProxyRe
6363
counter: credential.counter,
6464
transports: body.response.response.transports
6565
});
66-
await deleteItem(PASSKEY_CHALLENGES_TABLE, challengeRecord.challenge);
66+
await deleteItem(PASSKEY_CHALLENGES_TABLE, challengeRecord.id);
6767

6868
return buildResponse(event, HttpResponseStatus.OK, {
6969
verified: true,

api/endpoints/admin/passkeyRegisterOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const handler = async (event: APIGatewayEvent): Promise<APIGatewayProxyRe
1717
});
1818

1919
await putItem(PASSKEY_CHALLENGES_TABLE, {
20-
challenge: options.challenge,
20+
id: options.challenge,
2121
type: "registration",
2222
expiresAt: Math.floor(Date.now() / 1000) + 300 // 5 minutes
2323
});

api/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export type PasskeyCredential = {
2929
};
3030

3131
export type PasskeyChallenge = {
32-
challenge: string;
32+
id: string;
3333
expiresAt: number;
3434
type: "registration" | "authentication";
3535
};

0 commit comments

Comments
 (0)