njwt
njwt copied to clipboard
Do not set an expiration claim if it has already been defined by the user
I find it a little confusing that I have to do the following in order to set an expiration - am I just missing something?
const claims = {
exp: expirationTimestampInSeconds
}
const jwt = njwt.create(claims, signingKey, 'HS256');
jwt.setExpiration(claims.exp * 1000); // this accepts milliseconds for some reason
return jwt.compact();
In create, why not skip the expiration setting part, if the claims already contains the exp claim?