@digitalbranch/jwt

1.0.2 • Public • Published

JWT

JWT library for nodejs

Supports HS256 and RS256

Usage

install with npm

npm i @digitalbranch/jwt

Creating and verifying a HS256 token

const secret = 'my secret'

const token = JWT.sign(
  { alg: 'HS256' },
  { name: 'john', exp: new Date(Date.now() + 900000).getTime() },
  secret
)

assert(JWT.verify(token, secret))

Creating and verifying a RS256 token

JWT.createKeys().then(({ privateKey }) => {
  const token = JWT.sign(
    { alg: 'RS256' },
    { name: 'john', exp: new Date(Date.now() + 900000).getTime() },
    privateKey
  )

  assert(JWT.verify(token, privateKey))
})

Readme

Keywords

Package Sidebar

Install

npm i @digitalbranch/jwt

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

7.77 kB

Total Files

22

Last publish

Collaborators

  • vincentcorbee