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

0.0.5 • Public • Published

@avanio/jwt-util

This JWT utility is a simple tool to help verify JWT symmetric and asymmetric tokens.

Main features

IssuerManager

Manages multiple JWT issuers (symmetric and asymmetric) and can be used to get issuer key string or buffer. This is easy to add if already have valdation in plave for JWT tokens. (requires iss and kid to exists in token)

JwtManager

Wraps IssuerManager and can be used to verify JWT tokens.

Examples

Simple symmetric issuer

const privateKeyIssuer = new SymmetricIssuer(['http://localhost:8080']);
privateKeyIssuer.add('01', 'some-very-long-secret');

const issuerManager = new IssuerManager();
issuerManager.add(privateKeyIssuer);

await issuerManager.get('http://localhost:8080', '01'); // returns 'some-very-long-secret'

Azure multitenant issuer with one allowed tenant and JwtManager

const jwt = new JwtManager(new IssuerManager([new JwtAzureMultitenantTokenIssuer({allowedIssuers: [`https://sts.windows.net/${process.env.AZ_TENANT_ID}/`]})]));
// validate with jwt manager
const {isCached, body} = await jwt.verify(token);

Readme

Keywords

Package Sidebar

Install

npm i @avanio/jwt-util

Weekly Downloads

2

Version

0.0.5

License

LGPL-2.0-only

Unpacked Size

132 kB

Total Files

45

Last publish

Collaborators

  • samutoljamo
  • olliglorioso
  • mharj