njwt icon indicating copy to clipboard operation
njwt copied to clipboard

Do not set an expiration claim if it has already been defined by the user

Open pingvinen opened this issue 7 years ago • 0 comments

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?

pingvinen avatar Jul 06 '18 19:07 pingvinen