Replies: 1 comment
-
|
If you want to freeze time you have to make it so that date is also frozen, e.g. with https://www.npmjs.com/package/timekeeper the timespan syntax works off of current date, not the token's iat |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
In my tests, I'm "freezing" the time so I test everything that is date-dependent always at the same time.
For instance, I'm asserting via a snapshot that my sign in function always returns the same JWT.
But there is an issue with jose. The snapshots always differ because even if I set
issuedAtat a specific time,expirationTimeis computed from the actual current time.Here is a small snippet to illustrate :
In the output above, I'd expect the last
expISOto be2024-03-10T16:30:00.000Z(i.e. 2 hours after the issue time).Do you think it's doable/desirable to have
expirationTimecomputed fromissuedAtwhen the provided value is a string duration (e.g.2h,4 days) ? Maybe it could be interesting to have a dedicatedsetExpirationInor similar ?I'm naturally aware that this could be a breaking change, hence the opening of this discussion.
I'm also aware that we could compute the
expirationTimeourselves but that would make us reimplement the2h,4 daysparsing logic, which would be unfortunate since jose does it really well.Best,
Beta Was this translation helpful? Give feedback.
All reactions