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

tr-jwk

v1.0.0

Published

JWK key generation library (HMAC, EC, RSA, ML-DSA, AES)

Readme

tr-jwk

JWK key generation library for Node.js. Produces JSON Web Keys ready to use with JWT signers, JWE encryptors, ECDH-ES key agreement, and AES content-encryption / key-wrap operations.

The package exposes three utilities:

  • macKeyGen(alg) for HMAC, ECDSA, RSA, and ML-DSA signing keys
  • cipherKeyGen(alg) for AES content-encryption and AES-GCM key-wrap keys
  • ecKeyGen(curve) for EC key pairs used with ECDH-ES

Reference

Installation

npm install tr-jwk

Node.js >=24.0.0 is required.

macKeyGen(alg)

Generates a private JWK suitable for JWT signing.

Supported alg values:

  • HS256, HS384, HS512
  • ES256, ES384, ES512
  • RS256, RS384, RS512
  • ML-DSA-44, ML-DSA-65, ML-DSA-87

Example:

const { macKeyGen } = require('tr-jwk');

const key = macKeyGen('ES256');
console.log(key);

Notes:

  • HMAC keys are returned as oct JWKs with random k material.
  • EC, RSA, and ML-DSA keys are returned as private JWKs.
  • A random kid is always added.

cipherKeyGen(alg)

Generates a symmetric JWK for encryption or key wrapping.

Supported alg values:

  • A128GCM, A192GCM, A256GCM
  • A128GCMKW, A192GCMKW, A256GCMKW

Example:

const { cipherKeyGen } = require('tr-jwk');

const key = cipherKeyGen('A256GCM');
console.log(key);

Returned keys include:

  • kty: "oct"
  • alg
  • key_ops
  • use: "enc"
  • random kid

ecKeyGen(curve)

Generates an EC key pair and returns both the private and public JWK.

Supported curve values:

  • P-256
  • P-384
  • P-521

Example:

const { ecKeyGen } = require('tr-jwk');

const { secretKey, publicKey } = ecKeyGen('P-256');

Both returned JWKs share the same kid.

Exports

const { macKeyGen, cipherKeyGen, ecKeyGen } = require('tr-jwk');

Author

Timo J. Rinne [email protected] — https://github.com/rinne/

Copyright

Copyright © 2023–2026 Timo J. Rinne [email protected]. See COPYING for the full MIT license text.

License

MIT License