swa-token
v2.0.2
Published
The "SWA" token is similar to JWT token but it just shorter.
Downloads
16
Maintainers
Readme
Short web application token
The "SWA" token is similar to JWT token but it just shorter.
Install
# npm users
npm i swa-token
# yarn users
yarn add swa-token
How to use
- Create SWAT instance
import SWAT from 'swa-token'
const swat = createSWAT('Your-secret-key')
- Issue new token
swat.create('1', 'user')
- Verify a token
swat.verify(token)
- Get token info
swat.parse(token)
- Change to difference signature provider
// By default SWAT use HS256 to create signature
// Bellow is example to change HS512 algo
swat.use('HS512')
- Custom signature provider
swat.use('YourAlgo', {
sign: (data: string) => 'signature',
verify: (data: string, signature: string) => true || false
})