3.0.0 • Published 3 years ago

jwt-hs256 v3.0.0

Weekly downloads
43
License
MIT
Repository
github
Last release
3 years ago

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

3.0.0

3 years ago

2.0.1

3 years ago

2.0.0

4 years ago

1.0.0

4 years ago

0.1.0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago