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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.20latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.20
0.1.11
0.1.00

Package Sidebar

Install

npm i jted

Weekly Downloads

1

Version

0.1.2

License

Apache-2.0

Unpacked Size

23.4 kB

Total Files

29

Last publish

Collaborators

  • sovrin