nodejs-jwt-validator
TypeScript icon, indicating that this package has built-in type declarations

0.1.11 • Public • Published

nodejs-jwt-validator

NodeJS module which validates the signature and the claims of a JWT.

Description

This module was created following the documentation of AWS for verification of Cognito tokens: https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-verifying-a-jwt.html

and the example code from this repo: https://github.com/awslabs/aws-support-tools/blob/master/Cognito/decode-verify-jwt/decode-verify-jwt.ts

Example

import { JwtValidator } from "nodejs-jwt-validator";
import { IJwtValidatorConfig } from "nodejs-jwt-validator/declarations/declarations";

const clientId = "my-client-id";
const issuerUrl = "https://my-issuer.com/";
const tokenUse = "access";

const config: IJwtValidatorConfig = { issuerUrl, clientId, tokenUse };

const validator = new JwtValidator(config);

const token = "my-jwt";
// Validate the signature of the token and the exp, iss and token_use claims.
const result = await validator.validateToken(token);
console.log(result);

Readme

Keywords

none

Package Sidebar

Install

npm i nodejs-jwt-validator

Weekly Downloads

586

Version

0.1.11

License

Apache-2.0

Unpacked Size

25.9 kB

Total Files

16

Last publish

Collaborators

  • kerezov
  • tsvetan.milanov
  • tnikolov