jsonwebtoken
Advanced tools
Comparing version 5.5.0 to 5.5.1
@@ -62,3 +62,3 @@ var jws = require('jws'); | ||
if (options.notBefore) { | ||
if (typeof options.notBefore !== 'undefined') { | ||
payload.nbf = timespan(options.notBefore); | ||
@@ -86,3 +86,3 @@ if (typeof payload.nbf === 'undefined') { | ||
payload.exp = timestamp + expiresInSeconds; | ||
} else if (options.expiresIn) { | ||
} else if (typeof options.expiresIn !== 'undefined') { | ||
payload.exp = timespan(options.expiresIn); | ||
@@ -214,4 +214,3 @@ if (typeof payload.exp === 'undefined') { | ||
} | ||
if (payload.nbf >= Math.floor(Date.now() / 1000)) { | ||
console.log(payload.nbf, '>=', Math.floor(Date.now() / 1000)); | ||
if (payload.nbf > Math.floor(Date.now() / 1000)) { | ||
return done(new NotBeforeError('jwt not active', new Date(payload.nbf * 1000))); | ||
@@ -218,0 +217,0 @@ } |
{ | ||
"name": "jsonwebtoken", | ||
"version": "5.5.0", | ||
"version": "5.5.1", | ||
"description": "JSON Web Token implementation (symmetric and asymmetric)", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "mocha --require test/util/fakeDate" | ||
}, | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -118,2 +118,16 @@ var jwt = require('../index'); | ||
it('should valid when date are equals', function(done) { | ||
Date.fix(1451908031); | ||
token = jwt.sign({ foo: 'bar' }, priv, { algorithm: 'RS256', notBefore: 0 }); | ||
jwt.verify(token, pub, function(err, decoded) { | ||
assert.isNull(err); | ||
assert.isNotNull(decoded); | ||
Date.unfix(); | ||
done(); | ||
}); | ||
}); | ||
it('should NOT be invalid', function(done) { | ||
@@ -120,0 +134,0 @@ // not active token |
62681
34
1020