npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@polyjose/node

v0.2.0

Published

polyjose for Node.js: JOSE (JWS, JWE, JWK, JWT) in pure Rust through Node-API, with the shared TypeScript facade (ADR 0031, ADR 0047).

Readme

@polyjose/node

polyjose for Node.js: JOSE (JWS, JWE, JWK and JWT; RFC 7515 to 7519) implemented in pure Rust and loaded as a Node-API addon. All cryptography comes from the RustCrypto and dalek crates, with no OpenSSL. Verify and decrypt always take an explicit algorithm allow-list, and none is never accepted (RFC 8725).

Install

npm install @polyjose/node

Prebuilt for macOS, Linux (glibc and musl) and Windows, see the docs for platform support. Needs Node.js 22.12 or later.

Import

The package is ESM:

import { jwtSign, jwtVerify } from "@polyjose/node";

CommonJS code can load it too, through Node's require(esm):

const { jwtSign, jwtVerify } = require("@polyjose/node");

Every function returns a Promise, and the work runs on the libuv thread pool, so it doesn't block the event loop. The API is the same as @polyjose/wasm's.

Quick start

Sign a JWT, then verify it with an explicit algorithm allow-list and the issuer and audience you expect. exp is required and checked, with 60 seconds of leeway (RFC 8725 §3.8 to §3.10).

import { jwkGenerateForAlg, jwkToPublic, jwtSign, jwtVerify, PolyjoseError } from "@polyjose/node";

// An ES256 key pair. The verifier needs only the public half.
const privateKey = await jwkGenerateForAlg("ES256");
const publicKey = await jwkToPublic(privateKey);

const now = Math.floor(Date.now() / 1000);
const token = await jwtSign(
  { iss: "https://issuer.example", sub: "user-123", aud: "https://api.example", exp: now + 300 },
  privateKey,
  { alg: "ES256" },
);

try {
  const verified = await jwtVerify(token, publicKey, {
    allowedAlgs: ["ES256"], // never trust the token's own `alg` (RFC 8725 §3.1)
    issuers: ["https://issuer.example"],
    audiences: ["https://api.example"],
  });
  console.log(verified.claims.sub); // "user-123"
} catch (err) {
  if (err instanceof PolyjoseError) console.error(err.code); // e.g. "TokenExpired"
  else throw err;
}

Encrypt to a recipient's public key, then decrypt, naming the algorithms you accept:

import { jweDecryptCompact, jweEncryptCompact, jwkGenerateEc, jwkToPublic } from "@polyjose/node";

const recipientKey = await jwkGenerateEc("P-256");
const recipientPublicKey = await jwkToPublic(recipientKey);

const jwe = await jweEncryptCompact(new TextEncoder().encode("top secret"), {
  enc: "A256GCM",
  recipients: [{ alg: "ECDH-ES+A256KW", key: recipientPublicKey }],
});

const decrypted = await jweDecryptCompact(jwe, recipientKey, {
  allowedAlgs: ["ECDH-ES+A256KW"],
  allowedEnc: ["A256GCM"],
});
console.log(new TextDecoder().decode(decrypted.plaintext)); // "top secret"
decrypted.plaintext.fill(0); // results are plain data: wipe secret bytes, and never log them

Documentation

License

MIT; see LICENSE. THIRD-PARTY-NOTICES.txt in the package lists the third-party code it contains.