Skip to content

alexzvn/swa-token

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Alexzvn
Jul 25, 2022
a540e7e · Jul 25, 2022

History

22 Commits
Apr 17, 2022
Jul 25, 2022
Apr 17, 2022
Apr 17, 2022
Apr 20, 2022
Jul 25, 2022
Apr 17, 2022
Apr 17, 2022

Repository files navigation

Short web application token

The "SWA" token is similar to JWT token but it just shorter.

image

Install

# npm users
npm i swa-token

# yarn users
yarn add swa-token

How to use

  1. Create SWAT instance
import SWAT from 'swa-token'

const swat = createSWAT('Your-secret-key')
  1. Issue new token
swat.create('1', 'user')
  1. Verify a token
swat.verify(token)
  1. Get token info
swat.parse(token)
  1. Change to difference signature provider
// By default SWAT use HS256 to create signature
// Bellow is example to change HS512 algo
swat.use('HS512')
  1. Custom signature provider
swat.use('YourAlgo', {
  sign: (data: string) => 'signature',
  verify: (data: string, signature: string) => true || false
})

About

Short web application token

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published