Skip to content

Commit

Permalink
fix: auth_time resolution in generated tokens
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'antego/master'
  • Loading branch information
jagregory committed Jul 24, 2021
2 parents 5f9b915 + 604bc94 commit f300df4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/services/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function generateTokens(
userPoolId: string
) {
const eventId = uuid.v4();
const authTime = new Date().getTime();
const authTime = Math.floor(new Date().getTime() / 1000);

return {
AccessToken: jwt.sign(
Expand Down
8 changes: 4 additions & 4 deletions src/targets/initiateAuth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ describe("InitiateAuth target", () => {
username: "0000-0000",
event_id: expect.stringMatching(UUID),
scope: "aws.cognito.signin.user.admin", // TODO: scopes
auth_time: now.getTime(),
auth_time: Math.floor(now.getTime() / 1000),
jti: expect.stringMatching(UUID),
});
expect(
Expand All @@ -405,7 +405,7 @@ describe("InitiateAuth target", () => {
"cognito:username": "0000-0000",
email_verified: true,
event_id: expect.stringMatching(UUID),
auth_time: now.getTime(),
auth_time: Math.floor(now.getTime() / 1000),
email: "[email protected]",
});
expect(
Expand Down Expand Up @@ -461,7 +461,7 @@ describe("InitiateAuth target", () => {
username: "0000-0000",
event_id: expect.stringMatching(UUID),
scope: "aws.cognito.signin.user.admin", // TODO: scopes
auth_time: now.getTime(),
auth_time: Math.floor(now.getTime() / 1000),
jti: expect.stringMatching(UUID),
});
expect(
Expand All @@ -483,7 +483,7 @@ describe("InitiateAuth target", () => {
"cognito:username": "0000-0000",
email_verified: true,
event_id: expect.stringMatching(UUID),
auth_time: now.getTime(),
auth_time: Math.floor(now.getTime() / 1000),
email: "[email protected]",
});
expect(
Expand Down
4 changes: 2 additions & 2 deletions src/targets/respondToAuthChallenge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe("RespondToAuthChallenge target", () => {
username: "0000-0000",
event_id: expect.stringMatching(UUID),
scope: "aws.cognito.signin.user.admin", // TODO: scopes
auth_time: now.getTime(),
auth_time: Math.floor(now.getTime() / 1000),
jti: expect.stringMatching(UUID),
});
expect(
Expand All @@ -118,7 +118,7 @@ describe("RespondToAuthChallenge target", () => {
"cognito:username": "0000-0000",
email_verified: true,
event_id: expect.stringMatching(UUID),
auth_time: now.getTime(),
auth_time: Math.floor(now.getTime() / 1000),
email: "[email protected]",
});
expect(
Expand Down

0 comments on commit f300df4

Please sign in to comment.