Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to remove 'iat' option from jwt payload in jsonwebtoken library typescript?

I want to remove 'iat' option from header for the creation of correct request to the external server. I've tried to do something like this

let token = jwt.sign(
    {payload: payload, iat: undefined},
    generateAndGetDeviceKey(),
    { algorithm: 'HS512' }
);

but it doesn't work. I got error

Uncaught (in promise) Error: "iat" should be a number of seconds

like image 993
Valeriy Bondar Avatar asked Oct 25 '25 04:10

Valeriy Bondar


1 Answers

You can pass the noTimestamp option, which will prevent adding iat.

Something like this should work.

let token = jwt.sign(
    {payload: payload},
    generateAndGetDeviceKey(),
    { algorithm: 'HS512', noTimestamp: true }
);
like image 163
Michal Trojanowski Avatar answered Oct 26 '25 19:10

Michal Trojanowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!