Skip to main content

@gz/jwt@0.1.0
Built and signed on GitHub Actions

JSON Web Token (JWT)

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
2 weeks ago (0.1.0)

JSON Web Token (JWT)

A simple JSON Web Token (JWT) library for Deno and Node.js, partially compliant with the JWT specification.

Installation

To install the JWT library, run the following command:

# deno
deno add jsr:@gz/jwt

# npm (use any of npx, yarn dlx, pnpm dlx, or bunx)
npx jsr add @gz/jwt

Usage

To encode a payload, use the encode() function:

import { encode } from "@gz/jwt";

const payload = {userId: 123, name: "John Doe"};

const token = await encode(payload, "secret", {algorithm: "HS256"});

To decode a token, use the decode() function:

import { decode } from "@gz/jwt";

const decoded = await decode<User>(token, "secret", {algorithm: "HS256"});
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@gz/jwt

Import symbol

import * as mod from "@gz/jwt";

---- OR ----

Import directly with a jsr specifier

import * as mod from "jsr:@gz/jwt";

Add Package

npx jsr add @gz/jwt

Import symbol

import * as mod from "@gz/jwt";

Add Package

yarn dlx jsr add @gz/jwt

Import symbol

import * as mod from "@gz/jwt";

Add Package

pnpm dlx jsr add @gz/jwt

Import symbol

import * as mod from "@gz/jwt";

Add Package

bunx jsr add @gz/jwt

Import symbol

import * as mod from "@gz/jwt";