Skip to content

Commit

Permalink
fix: allow any JSON numeric value for timestamp values
Browse files Browse the repository at this point in the history
resolves #263
  • Loading branch information
panva committed Jun 1, 2020
1 parent b80124d commit a24a759
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,9 @@ module.exports = (issuer, aadIssValidation = false) => class Client extends Base
jwt: idToken,
});
}
if (!Number.isInteger(payload.auth_time)) {
if (typeof payload.auth_time !== 'number') {
throw new RPError({
message: 'JWT auth_time claim must be a JSON number integer',
message: 'JWT auth_time claim must be a JSON numeric value',
jwt: idToken,
});
}
Expand Down Expand Up @@ -852,18 +852,18 @@ module.exports = (issuer, aadIssValidation = false) => class Client extends Base
}

if (payload.iat !== undefined) {
if (!Number.isInteger(payload.iat)) {
if (typeof payload.iat !== 'number') {
throw new RPError({
message: 'JWT iat claim must be a JSON number integer',
message: 'JWT iat claim must be a JSON numeric value',
jwt,
});
}
}

if (payload.nbf !== undefined) {
if (!Number.isInteger(payload.nbf)) {
if (typeof payload.nbf !== 'number') {
throw new RPError({
message: 'JWT nbf claim must be a JSON number integer',
message: 'JWT nbf claim must be a JSON numeric value',
jwt,
});
}
Expand All @@ -879,9 +879,9 @@ module.exports = (issuer, aadIssValidation = false) => class Client extends Base
}

if (payload.exp !== undefined) {
if (!Number.isInteger(payload.exp)) {
if (typeof payload.exp !== 'number') {
throw new RPError({
message: 'JWT exp claim must be a JSON number integer',
message: 'JWT exp claim must be a JSON numeric value',
jwt,
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@types/got": "^9.6.9",
"base64url": "^3.0.1",
"got": "^9.6.0",
"jose": "^1.25.2",
"jose": "^1.27.1",
"lodash": "^4.17.15",
"lru-cache": "^5.1.1",
"make-error": "^1.3.6",
Expand Down
8 changes: 4 additions & 4 deletions test/client/client_instance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2297,7 +2297,7 @@ describe('Client', () => {
return this.IdToken(this.keystore.get(), 'RS256', payload)
.then((token) => this.client.validateIdToken(token))
.then(fail, (error) => {
expect(error).to.have.property('message', 'JWT iat claim must be a JSON number integer');
expect(error).to.have.property('message', 'JWT iat claim must be a JSON numeric value');
});
});

Expand Down Expand Up @@ -2327,7 +2327,7 @@ describe('Client', () => {
return this.IdToken(this.keystore.get(), 'RS256', payload)
.then((token) => this.client.validateIdToken(token))
.then(fail, (error) => {
expect(error).to.have.property('message', 'JWT exp claim must be a JSON number integer');
expect(error).to.have.property('message', 'JWT exp claim must be a JSON numeric value');
});
});

Expand Down Expand Up @@ -2374,7 +2374,7 @@ describe('Client', () => {
return this.IdToken(this.keystore.get(), 'RS256', payload)
.then((token) => this.client.validateIdToken(token))
.then(fail, (error) => {
expect(error).to.have.property('message', 'JWT nbf claim must be a JSON number integer');
expect(error).to.have.property('message', 'JWT nbf claim must be a JSON numeric value');
});
});

Expand Down Expand Up @@ -2469,7 +2469,7 @@ describe('Client', () => {
return this.IdToken(this.keystore.get(), 'RS256', payload)
.then((token) => this.client.validateIdToken(token, null, null, 300))
.then(fail, (error) => {
expect(error).to.have.property('message', 'JWT auth_time claim must be a JSON number integer');
expect(error).to.have.property('message', 'JWT auth_time claim must be a JSON numeric value');
});
});

Expand Down

0 comments on commit a24a759

Please sign in to comment.