Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ var jwtLib = {
jwt.setSigningAlgorithm(args.length===3 ? alg : 'HS256');
jwt.setSigningKey(secret);
}
jwt.setExpiration((nowEpochSeconds() + (60*60))*1000); // one hour
jwt.setExpiration(claims.exp * 1000 || (nowEpochSeconds() + (60 * 60)) * 1000);
return jwt;
}
};

module.exports = jwtLib;
module.exports = jwtLib;
9 changes: 6 additions & 3 deletions test/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ describe('create()',function(){
assert.equal(nJwt.create({},uuid()).body.exp , oneHourFromNow);
});

it('should not create default exp field, if exp is given',function(){
var time = Math.floor(Date.now()/1000)
var token = nJwt.create({exp: time},uuid())
assert.equal(token.body.exp , time);
});

it('should not overwrite a defined jti field',function(){
assert.equal(nJwt.create({jti: 1},uuid()).body.jti , 1);
});
Expand Down Expand Up @@ -108,6 +114,3 @@ describe('base64 URL Encoding',function(){

});
});