Skip to content

everettmorgan/jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
everettmorgan
Nov 29, 2021
c1b814e · Nov 29, 2021

History

25 Commits
Nov 29, 2021
Nov 29, 2021
Nov 29, 2021
Nov 29, 2021
Nov 28, 2021
Nov 29, 2021
Nov 29, 2021
Nov 28, 2021
Nov 29, 2021

Repository files navigation

ejmorgan-jwt

A simple implementation of the JWT rfc spec.

Usage

const JWT = require("ejmorgan-jwt");

const jwt = JWT.New({
  key: 'my-key',
  header: {
    alg: "sha256",
  },
  payload: {
    aud: "audience",
    custom: "my-key",
  },
});

const str = jwt.toString();

console.log(str);
// eyJhbGciOiJzaGEyNTYifQ.eyJhdWQiOiJhdWRpZW5jZSIsImN1c3RvbSI6Im15LWtleSJ9.bY7PCElW5f245tSaLVkiGIfLBISU7kdyfCniJ62FsDM=

const [err, ajwt]= JWT.Read(str, 'my-key');

console.log(ajwt);
// JSONWebToken {
//  header: { alg: 'sha256' },
//  payload: { aud: 'audience', custom: 'my-key' },
//  signature: 'bY7PCElW5f245tSaLVkiGIfLBISU7kdyfCniJ62FsDM='
// }

ajwt.payload.aud = 'hehehe';

const ok = JWT.Validate(ajwt, 'my-key');

console.log(ok);
// false

About

My implementation of the JWT rfc spec.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published