
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
A token generator library to encode and decode data using a secret key
A better, faster, lighter and more secure version of jsonwebtoken
To install mini-jwt
# with npm:
npm install mini-jwt --save
# with yarn:
yarn add mini-jwt
mini-jwt exports different functions for data encryption for different use cases:
For a faster (but less secure) encoding and decoding of data using a secret, mini-jwt exports the following functions:
sign(secret, data, options): returns encoded token(technically, not a jwt)verify(secret, token): returns decoded dataimport { sign, verify } from 'mini-jwt'
const secret = 'top-secret'
const token = sign(secret, { uid: 'user_id' }, { sl: 8 }) // no expiration
const data = verify(secret, token)
console.log(data) // { uid: 'user_id' }
secret can be string
data can be an object literal, buffer or string representing valid JSON.
options:
expiresIn can be a numeric value representing time in ms (no expiration by default).sl can be a numberic value representing salt length (default value is 16). Salt is a random string which is added on top of data to keep the token different everytime even for the same data.For a more secure (but slower) encryption and decryption of data using a secret, mini-jwt exports the following functions that uses sjcl under the hood:
encrypt(secret, data, options): return encrypted token(technically, not a jwt)decrypt(secret, token): returns decrypted dataimport { encrypt, decrypt } from 'mini-jwt'
const secret = 'top-secret'
const token = encrypt(secret, { uid: 'user_id' }, { expiresIn: 180000 }) // will expire after 30 minutes of token creation
const data = decrypt(secret, token)
console.log(data) // { uid: 'user_id' }
secret can be string
data can be an object literal, buffer or string representing valid JSON.
options:
expiresIn can be a numeric value representing time in ms (no expiration by default).FAQs
A token generator library to encode and decode data using a secret key
The npm package mini-jwt receives a total of 0 weekly downloads. As such, mini-jwt popularity was classified as not popular.
We found that mini-jwt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.