Getting the error
"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60
I looked at where the error was being thrown in index.js line 86:
payload.exp = timespan(options.expiresIn);
I stepped through the timespan function and everything looks good there if I pass in either string or number. However the function always returns undefined?
I should have read the documentation better:
payload could be an object literal, buffer or string. Please note that exp is only set if the payload is an object literal.
I was sending in a string.
Closing as non-issue.
After updating to 5.5, I started seeing this error, whereas I wasn't seeing it before.
I am also passing a string in rather than an object literal, so I went ahead and removed the expiration since it's not being used and it cleared the error up.
However, this error message is incorrect - the format of "expiresIn" was correct, so this is an open bug in my opinion.
Please re-open
Notice that it will be silently ignored now when the payload doesn't support expiration. I plan to fail explicitly in the next major version.
Out of nowhere I'm facing exact same issue. First it was working fine and now its giving me this error
invalid expiresIn option for string payload
const accessToken = jwt.sign(phone, JWT_AUTH_TOKEN, { expiresIn: '30s' });
const refreshToken = jwt.sign(phone, JWT_REFRESH_TOKEN, { expiresIn: '1y' });
Most helpful comment
Out of nowhere I'm facing exact same issue. First it was working fine and now its giving me this error
invalid expiresIn option for string payload