Skip to content

alexzvn/swa-token

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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