Skip to content

zero-dependencies JWT module to generate and validate HS256 tokens

Notifications You must be signed in to change notification settings

maxwellium/jwt-hs256

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.test.ts). You can test the results on https://jwt.io/ .


Copyright (c) 2020 Max Dancau

License MIT

About

zero-dependencies JWT module to generate and validate HS256 tokens

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published