Based on what Krzysztof Sztompka published, I could get Ext to show the correct expiration date. (my initial requirement was for 1 hour in the future)
In order to track changes compared to previous errors, I will not update the code above, so here is what I changed:
var d = new Date(); var calculatedExpiresIn = (((d.getTime()) + (60 * 60 * 1000)) - (d.getTime() - d.getMilliseconds()) / 1000); var token = jwt.sign({"id": user._id}, configGeneral.JWT, { expiresIn: calculatedExpiresIn });
Now the .log console will show that Ext the way I wanted, now + 1 hour.
In order for Iat to display the correct date (after setting it in the sign function, and then checking the health in the decode function), I had to set it as part of the payload. I got my answer here
So, in order to display Iat correctly, I added it to the payload, as shown here:
var token = jwt.sign({"id": user._id, "iat": (new Date().getTime())}, configGeneral.JWT, { expiresIn: calculatedExpiresIn });
This gives the conclusion:
{ id: '56253091fe0397c80133f3e4', iat: 1445763099706, exp: 1445766699705 } Sun Oct 25 2015 11:51:39 GMT+0200 (South Africa Standard Time) Sun Oct 25 2015 10:51:39 GMT+0200 (South Africa Standard Time)
This is an unencrypted JWT that I will pass on to users when they have successfully logged in and will allow me to check whether the JWT should pass, since every future request is still valid and has not expired.