I am a bit stumped by this one. I am trying to set up a valid JWT. I am using node.js with the jsonwebtoken middleware. I have followed the documentation located on the repo (located here), but I keep getting the wrong Exp and Iat. Obviously I would like to get this right so that I don't allow JWT's which has expired.
As a test I have the following code:
var token = jwt.sign({"id": user._id}, configGeneral.JWT, { expiresIn: '1h' });
var decoded = jwt.decode(token, configGeneral.JWT);
var d1 = new Date(decoded.exp);
var d2 = new Date(decoded.iat);
console.log(decoded);
console.log(d1);
console.log(d2);
The output of this is:
{ id: '56253091fe0397c80133f3e4',
iat: 1445714161,
exp: 1445717761 }
Sat Jan 17 1970 19:35:17 GMT+0200 (South Africa Standard Time)
Sat Jan 17 1970 19:35:14 GMT+0200 (South Africa Standard Time)
How do I get the timestamp to not reflect the javascript epoch, but rather the time 1 hour from now? (for both the iat and exp.)