ZVT is more modern (as I think) alternative for JWT. It works with MsgPack instead of JSON, which makes it 1.5-2x smaller and 1.5x faster.
Works only with Bun.
bun i zv-token
import ZVToken from 'zv-token'
const zv = new ZVToken({
secret: 'jwt is gay',
// keys that u use in payload.data
structures: ['uid', 'sess'],
// pass true if u want to get
// error instead of { status: false, payload: undefined }
throwErrors: false // default
})
const token = zv.sign({
uid: 123,
exp: 2147483647,
sess: '471350b8-9fd4-42ae-98e6-a2255d9ec59a',
// any other data
})
console.log('token:', token)
const data = zv.verify(token)
console.log(data)
// {
// status: true,
// payload: {
// user_id: 123,
// session_id: 123,
// expires: Tue Jan 19 2038 06:14:07,
// data: { your payload }
// }
// }