Description
If the iat payload value is is zero, in other words, the UNIX epoch, it is not respected and the current time is used instead. I believe it is because zero evaluates to false here:
https://github.com/auth0/node-jsonwebtoken/blob/master/sign.js#L179
Reproduction
jwt.sign({ iat: 0, data: 'foobar' }, 'secret', { expiresIn: 86400 });
Expected payload iat value should be zero and exp is expected to be 86400. The actual iat value is the current time and exp is the current time plus 86400.
Environment
- Version: 9.0.0
- Node v14.18.1 (npm v8.12.2)
Description
If the
iatpayload value is is zero, in other words, the UNIX epoch, it is not respected and the current time is used instead. I believe it is because zero evaluates to false here:https://github.com/auth0/node-jsonwebtoken/blob/master/sign.js#L179
Reproduction
jwt.sign({ iat: 0, data: 'foobar' }, 'secret', { expiresIn: 86400 });Expected payload
iatvalue should be zero andexpis expected to be 86400. The actualiatvalue is the current time andexpis the current time plus 86400.Environment