1.0.0 • Published 2 years ago

@uon/jwt v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
2 years ago

JWT

A simple library to encode, decode and verify JWTs.

NOTE: No browser support yet. Works on node.js apps only because of 'crypto' and Buffer dependencies.

Installation

    npm i @uon/jwt

Usage

import { Encode, Decode, Verify, JwtToken, VerifyResult } from '@uon/jwt';


const payload = {
    hello: 'world',
    iat: Date.now(),
    exp: Date.now() + 60 * 1000
};

// encode a payload to jwt string
const token_str = Encode(payload, 'my-secret', 'HS256');


// verify a token
const verify_result: VerifyResult = Verify(token_str, 'my-secret', { ... });
// verify_result.sig === true

// decode a token to its components
const token: JwtToken = Decode(token_str);

Limitations

  • No support for payload encryption yet
1.0.0

2 years ago

0.11.0

2 years ago

0.9.0

5 years ago

0.4.0

5 years ago