Skip to content

Commit 1883637

Browse files
authored
Merge pull request #8 from nmemoto/fix-iat-verification
Fixed the condition to judge as valid iat
2 parents a2d752f + 00c806e commit 1883637

File tree

2 files changed

+1
-12
lines changed

2 files changed

+1
-12
lines changed

src/jwt-decoder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const decodePayload = (payloadPart: string, currentTimestamp: number): DecodedPa
9696
throw new JwtError(JwtErrorCode.INVALID_ARGUMENT, `"iat" claim must be a number but got "${payload.iat}"`);
9797
}
9898

99-
if (currentTimestamp <= payload.iat) {
99+
if (currentTimestamp < payload.iat) {
100100
throw new JwtError(
101101
JwtErrorCode.INVALID_ARGUMENT,
102102
`Incorrect "iat" claim must be a older than "${currentTimestamp}" (iat: "${payload.iat}")`

tests/jwt-decoder.test.ts

-11
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,6 @@ describe('TokenDecoder', () => {
8787
`Incorrect "iat" claim must be a older than "${currentTimestamp}" (iat: "${currentTimestamp + 10000}")`
8888
),
8989
],
90-
[
91-
'iat is now',
92-
{
93-
...payload,
94-
iat: currentTimestamp,
95-
},
96-
new JwtError(
97-
JwtErrorCode.INVALID_ARGUMENT,
98-
`Incorrect "iat" claim must be a older than "${currentTimestamp}" (iat: "${currentTimestamp}")`
99-
),
100-
],
10190
[
10291
'exp is in past',
10392
{

0 commit comments

Comments
 (0)