Package Exports
- @cfworker/jwt
- @cfworker/jwt/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@cfworker/jwt) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
cfworker/jwt
Tiny lib for decoding JWTs and verifying signatures, using native crypto APIs.
Currently supports alg:'RS256' only.
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 }
}