1.0.2 • Published 7 months ago

@dbcdk/set-jwt-expiration-date v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

#set-new-expiration-date

This script is used to edit content of JWT/JWE tokens generated by the next-auth framework as used by DBC (mainly for Cypress testing). See next-auth general documentation here: https://next-auth.js.org/

The script overwrites a next-auth token's expiration date with a new date 365 days from now unless provided with another value. It overwrites the expiration date of the token itself and also the expiration date of the access token from Adgangsplatformen contained inside the JWT.

To do this, it encrypts the token using the provided next-auth secret, changes the content, and re-encrypts with the same secret. Encoding and decoding methods are taken from the next-auth implementation. The script only works with encrypted (not signed) tokens, i.e. tokens used from version 4 of next-auth.

WARNING: Be careful with who has access to the generated token (especially if generated with next-auth secrets used in production) since it might grant umlimited access to your running application!

To overwrite a token, run:

npx --yes @dbcdk/set-jwt-expiration-date@latest <secret> <token> <optional: expires-in>

Where <secret> is your next-auth secret, <token> is a next-auth session token generated by your application and stored in a browser, and <optional: expires-in> is a timespan in seconds until token should expire. If provided, it sets the expiration date to x seconds from now. Otherwise it sets expiration date to 365 days from now.

Result: The script prints the old decoded token, the new encoded token and the new decoded token.

1.0.2

7 months ago

1.0.1

9 months ago

1.0.0

9 months ago

0.0.6-alpha

3 years ago

0.0.5-alpha

3 years ago

0.0.4-alpha

3 years ago

0.0.3-alpha

3 years ago

0.0.2-alpha

3 years ago

0.0.1-alpha

3 years ago