Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when set expiresIn option on JWT signing #985

Closed
maulanasatyaadi opened this issue Jan 30, 2025 · 3 comments
Closed

Error when set expiresIn option on JWT signing #985

maulanasatyaadi opened this issue Jan 30, 2025 · 3 comments

Comments

@maulanasatyaadi
Copy link

maulanasatyaadi commented Jan 30, 2025

Description

Error when I set the expiresIn on the sign function. The error message is invalid invalid expiresIn option for string payload
I've tried to put 10m and 600 as value but it still invalid.

Reproduction

const token = JWT.sign("This is the content", key, {
  algorithm: 'PS256',
  expiresIn: 600
})

Environment

  • v9.0.2
  • Node 18
  • Windows 11 Pro and Ubuntu 24.04 LTS
@maulanasatyaadi maulanasatyaadi changed the title Error when put expiresIn on JWT signing Error when set expiresIn option on JWT signing Jan 30, 2025
@jessyi-ownup
Copy link

I'm getting this error as well. Specifically:

Types of property 'expiresIn' are incompatible.
        Type 'string' is not assignable to type 'number | StringValue | undefined'.

@maulanasatyaadi
Copy link
Author

Apparently, the string payload doesn't support the options follows:

  • expiresIn
  • notBefore
  • noTimestamp
  • audience
  • issuer
  • subject
  • jwtid

@maulanasatyaadi
Copy link
Author

Due to RFC 7519, the string payload should be deprecated. The payload must be in JSON format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants