@cfworker/jwt
v6.0.0
Published
Tiny lib for decoding JWTs and verifying signatures, using native crypto APIs
Downloads
4,458
Maintainers
Readme
cfworker/jwt
Tiny lib for decoding JWTs and verifying signatures, using native crypto APIs.
Currently supports RS256, RS384, and RS512.
const jwt = request.headers.get('Authorization');
const issuer = '...'; // Auth0 origin.
const audience = '...'; // Auth0 client id.
const result = await parseJwt({ jwt, issuer, audience });
if (!result.valid) {
console.log(result.reason); // Invalid issuer/audience, expired, etc
} else {
console.log(result.payload); // { iss, sub, aud, iat, exp, ...claims }
}