monster-jwt-decode-verify
v1.0.2
Published
Utility library for decoding and verifying JWTs.
Downloads
5
Maintainers
Readme
monster-jwt-decode-verify
A utility library for decoding and verifying JWTs (JSON Web Tokens).
Installation
Install monster-jwt-decode-verify
using npm:
npm install monster-jwt-decode-verify
Usage
Decoding JWT
To decode a JWT without verifying its signature:
const { decode } = require('monster-jwt-decode-verify');
const decodedToken = decode(yourJWT);
console.log(decodedToken);
Verifying JWT
To verify the signature of a JWT:
const { verify } = require('monster-jwt-decode-verify');
const verificationResult = verify(yourJWT, 'yourSecretOrPublicKey');
if (verificationResult.valid) {
console.log('JWT is valid:', verificationResult);
} else {
console.log('JWT validation failed:', verificationResult.error);
}