jted
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

jted

npm version types size coverage vulnerabilities dependencies devDependencies License

just JWT en-/decoding

Installation

$ npm i jted

Usage

import {encode} from 'jted';

const payload = {
    foo: 'bar';
    user: 'John Doe',
    role: 'moderator'
};

const key = 'change me to a very secure key';

// create token with payload and key
const token = encode(payload, key);

API

encode(payload: Payload, key: string, algorithm: Algorithm = 'sha512', options?: Options): string

Create a JWT via the payload, key, algorithm and optional options.


decode(token: string, key: string, algorithm: Algorithm = null, validate: boolean = true): Payload

Retrieve the payload by decoding token with key and algorithm.


verify(input: string, key: string, algorithm: Algorithm, signature: string): boolean

Verify if provided token is legit.


Supported algorithms

  • sha256
  • sha384
  • sha512
  • RSA-SHA256

Todo

  • check nodejs support for other algorithms

Licence

Apache-2.0 License, see LICENSE

Readme

Keywords

Package Sidebar

Install

npm i jted

Weekly Downloads

46

Version

0.1.2

License

Apache-2.0

Unpacked Size

23.4 kB

Total Files

29

Last publish

Collaborators

  • sovrin