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

3.0.0 • Public • Published

Small zero-dependencies vanilla module to generate, verify and extract JWTs in their most common HS256 (HMAC with SHA-256) variant.

console.log( generateHS256Token( {
  sub: '1234567890',
  name: 'John Doe'
}, 'test' ) );
// 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0.aXzC7q7z1lX_hxk5P0R368xEU7H1xRwnBQQcLAmG0EY'

console.log( extractHS256Token(
  'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0.aXzC7q7z1lX_hxk5P0R368xEU7H1xRwnBQQcLAmG0EY',
  'test'
) );
// { sub: '1234567890', name: 'John Doe' }

(see test/index.ts). You can test the results on https://jwt.io/ .


Copyright (c) 2020 Max Dancau

License MIT

Readme

Keywords

none

Package Sidebar

Install

npm i jwt-hs256

Weekly Downloads

50

Version

3.0.0

License

MIT

Unpacked Size

4.43 kB

Total Files

5

Last publish

Collaborators

  • maxwellium