The "SWA" token is similar to JWT token but it just shorter.
# npm users
npm i swa-token
# yarn users
yarn add swa-token
- 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
})