Skip to content

Commit 75da746

Browse files
committed
use math.floor instead of round fixes auth0#17
1 parent 80fb9f0 commit 75da746

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports.sign = function(payload, secretOrPrivateKey, options) {
1010

1111
var header = {typ: 'JWT', alg: options.algorithm || 'HS256'};
1212

13-
payload.iat = Math.round(Date.now() / 1000);
13+
payload.iat = Math.floor(Date.now() / 1000);
1414

1515
if (options.expiresInMinutes) {
1616
var ms = options.expiresInMinutes * 60;
@@ -56,7 +56,7 @@ module.exports.verify = function(jwtString, secretOrPublicKey, options, callback
5656
var payload = this.decode(jwtString);
5757

5858
if (payload.exp) {
59-
if (Math.round(Date.now()) / 1000 >= payload.exp)
59+
if (Math.floor(Date.now()) / 1000 >= payload.exp)
6060
return callback(new TokenExpiredError('jwt expired', new Date(payload.exp * 1000)));
6161
}
6262

0 commit comments

Comments
 (0)