zv-token

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.


Keywords
jwt, web token
Install
npm install zv-token@0.2.1

Documentation

ZV Token

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.

Important note

Works only with Bun.

Install

bun i zv-token

Usage

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 }
//    }
// }

Benchmark

ZV Token Benchmark

Goida

2024-04-0405 50 22-ezgif com-optimize