@cfworker/jwt
TypeScript icon, indicating that this package has built-in type declarations

4.0.6 • Public • Published

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 }
}

Package Sidebar

Install

npm i @cfworker/jwt

Weekly Downloads

798

Version

4.0.6

License

MIT

Unpacked Size

24.6 kB

Total Files

27

Last publish

Collaborators

  • jdanyow