Skip to content

Tag: jwt

Persist the login state in Next js using localstorage

I’m writing an authentication application in Next Js (v12.2.5). The application also uses React (v18.2.0). The problem is with persisting the authentication state. When the browser is refreshed, the login session is killed. Why is this happening even though I am getting and setting the token in the local storage. I would like to persist the login session to survive

How to deal with a TokenExpiredError: jwt expired?

I have a project with NodeJS with jwt for managing user authentication. After a period of time, my app stops working and my server prints the following: Now, the person who was working in this project before me had this code for managing the tokens: My guess is that the issue is the expiresIn: ‘7d’ (since I’m quite new with

How to retrieve Token for API calls in cypress

Due to a lack of knowledge in JS, I do face with below problem. I do automation testing with cypress and for external API endpoints, I need to use Dynamic Token that expires every 3600 secs. I did some short research and find out that, for reaching to JWT Token I will need 1st SSO login (that my app has).

How to verify a JWT signature using Node-jose

I am trying to use node-jose to verify signatures of my JWTs. I know the secret, but am having trouble converting this secret into a JWK used for the verification. Here is an example of how I am trying to create my key with my secret and verify my token. This results in Error: no key found. Do I need

Convert AWS KMS ECDSA_SHA_256 Signature from DER encoded ANS.1 format to JWT base64url encoded R || S format in NodeJS/Javascript

I am trying to create JWT Signature in NodeJS with ES256 algorithm using AWS KMS Customer Managed Keys. The signature created using AWS KMS with cryptographic Signing Algorithms ECDSA_SHA_256 is not JWT accepted R || S format. As per AWS doc, Signature will be in DER encoded ANS X9.62–2005 format ( I tried to convert the AWS KMS Sign to

Creating Compressed JWT Payload in JavaScript

I have a function which parses a compressed JWT Payload into JSON. It makes sense to me the way the function works. I want to create a function that can do the exact opposite: Take a JSON object and turn it into a COMPRESSED JWT Payload. The function that parses and decompresses: …outputs the JSON. …inputs the JSON. My attempt