0.0.12-1 • Published 4 years ago
jwtea v0.0.12-1
⚠ The project is in development. Please don't use in production.
jwtea is an ultra-lightweight JWT implementation in TypeScript, compiled to Native ESM with minimum dependencies.
Some jwtea
features are:
- :heavy_check_mark: Native ESM and CommonJS support
- :hammer: Types out of the box
- :clamp: 2x smaller than jsonwebtoken
- :zap: Faster than jsonwebtoken and jose, see benchmark for details.
Install
jwtea requires Node.js 12.4.0 or newer. It is recommended to use pnpm, but you can also use either npm
or yarn
.
# npm
npm i jwtea
# pnpm
pnpm i jwtea
# yarn
yarn add jwtea
Get Started
This library is pretty similiar to node-jsonwebtoken
that we all already know. Just replace commonjs import to esm import and you're good to go.
Synchronous Sign with default algotrithm (HMAC SHA256)
import { sign } from "jwtea"
const token = sign({ foo: "bar" }, "verystrongsecret")
Sign asynchronously
import { sign } from "jwtea"
const token = sign({ foo: "bar" }, "verystrongsecret", (err, token) => {
console.log(token)
})
Verify synchronously
import { verify } from "jwtea"
const decoded = verify(token, "verystrongsecret")
Verify asynchronously
import { verify } from "jwtea"
const decoded = verify(token, "verystrongsecret", (err, payload) => {
console.log(payload)
})
Docs
You can see the documentation here. (WIP)
Benchmark
For benchmark detail, go to the benchmark folder
License
MIT © elianiva