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

typepki-jwt

v0.3.0

Published

JWT/JWS sub module for TypePKI library (beta)

Readme

typepki-jwt: JWT/JWS sub module for TypePKI library (Beta)

TOP | github | npm | TypePKI

The 'TypePKI' library is an opensource free TypeScript PKI library which is the successor of the long lived jsrsasign library.

The 'typepki-jwt' is a JWT(JSON Web Token) and JWS(JSON Web Signatures) sub module for TypePKI library.

FEATURE

  • signing and verifying JWS(JSON Web Signatures)
  • verifying JWT(JSON Web Token)
  • Dual CommonJS/ES module package supporting CommonJS(CJS) and ES modules

Uasge

signing JWS with private key

This supports asymmetric private key or shared key of CrytoKey object of W3C Crypto API for signing. It may be useful to generate a key or import a key by using typepki-webcrypto module.

import { importPEM } from "typepki-webcrypto";
const prvkey = await importPEM("-----BEGIN PRIVATE...", "SHA256withRSA");

Now you can generate JWS signature.

import { signJWS } from "typepki-jwt";
const sJWS = await signJWS("RS256", prvkey, "eyJOe...", "eyJpc...");

"sJWS" will be a string such like "eyJOe...".

It is even easier if you specify the PEM or HMAC key string directly instead of the CryptoKey object:

const sJWS = await signJWS("RS256", "-----BEGIN PRIVATE KEY...", "eyJOe...", "eyJpc...");

verifying JWS with public key

Verifying JWS will be similar way. Importing a public key first:

import { importPEM } from "typepki-webcrypto";
const pubkey = await importPEM("-----BEGIN PUBLIC...", "SHA256withRSA");

Verifying JWS signature will be:

import { verifyJWS } from "typepki-jwt";
const isValid = await verifyJWS(sJWS, pubkey, ["RS256", "RS384", "RS512"]);

NOTE: It is strongly recommended to specify the "acceptAlgs" optional argument such like "['RS256', 'RS384']" to prevent algorithm down grade attacks.

verifying JWT

Verifying JWT will be similar to JWS by {@link verifyJWS}. To verify JWT you need to specify JWT acceptable parameters by {@link JWTVerifyOption}. Whey you want to accept JWT tokens with:

  • with HS256 and HS384 signature algorithms
  • "http://issuer1.example.com/" or "http://issuer2.example.com/" as issuers
  • verify at current time (by without verifyAt member)

JWTVerifyOption will be following

const opt: JWTVerifyOption = {
  alg: ["HS256", "HS384"],
  iss: ["http://issuer1.example.com/", "http://issuer2.example.com/"],
};

Then you can verify a JWT by {@link verifyJWT} funciton.

await verifyJWT("eyJ...", key, opt) -> true