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

@authcube/pst

v1.1.6

Published

Typescript library implementing Private State Token API (https://wicg.github.io/trust-token-api/)

Readme

Private State Tokens

Typescript library implementing Private State Token API (https://wicg.github.io/trust-token-api/)

This library depends on Cloudflare's voprf-ts tested implementation to compute the Scalars and transformations.

Security Disclaimer

🚨 This library is offered as-is, and without a guarantee. Therefore, it is expected that changes in the code, repository, and API occur in the future. We recommend to take caution before using this library in a production application since part of its content is experimental. All security issues must be reported, please notify us immediately.

Install Dependencies and Build

npm install
npm run build

Sample Issuer

Sample has been built using Express Library

  • Start Sample Server

    npm run example
  • Running with Docker

    • build
      docker-compose build
    • start
      docker-compose up

Running with Static Key-Pair and Expiration

  • Generate up to 6 KeyPairs

    node bin/voprf_gen_keys.cjs 1
    node bin/voprf_gen_keys.cjs 2
    # Keep creating until node bin/voprf_gen_keys.cjs 6
  • Export Keys as Environment Variables

    export PRIVATE_KEY1=<BASE64 PRIVATE KEY 1 GENERATED PREVIOUSLY>
    export PUBLIC_KEY1=<BASE64 PUBLIC KEY 1 GENERATED PREVIOUSLY>
    export PRIVATE_KEY2=<BASE64 PRIVATE KEY 2 GENERATED PREVIOUSLY>
    export PUBLIC_KEY2=<BASE64 PUBLIC KEY 2 GENERATED PREVIOUSLY>
    # Keep defining until PRIVATE_KEY6 and PUBLIC_KEY6
  • Export Key Expiration as Environment Variable

    export EXPIRY1=1709509052048
    export EXPIRY2=1709994102048
    # Keep defining until EXPIRY6

If running with Docker define those variables in docker-compose.yaml or -e argument for docker inline

Endpoints

  • Key Commitment Endpoint

    curl http://localhost:3000/.well-known/trust-token/key-commitment

Resources, Libraries and Specs:

How to use this library

Token Issuance

To issue a token, you must check for the request header sec-private-state-token, after verify it is present and it is not null or empty you can use the Issuer class like the code bellow:

import { PSTRedeemer, PSTResources } from "@authcube/pst";

const sec_private_state_token = req.headers[
  "sec-private-state-token"
] as string;
if (sec_private_state_token && !sec_private_state_token.match(BASE64FORMAT)) {
  return res.sendStatus(400);
}

try {
  let issuer = await PSTResources.getIssuer();
  const token = await issuer.issueToken(sec_private_state_token);

  res.statusCode = 200;
  res.setHeader("Content-Type", "text/html");
  res.append("sec-private-state-token", token);
  res.setHeader("Sec-Private-State-Token", token);
  res.write("Issuing tokens.");
  res.send();

  return res.end();
} catch (e: any) {
  // deal with the error as you see fit
  console.error("Error issuing PST", e);
  return res.sendStatus(500);
}

Token Redeemption

To redeem an issued token the process is similar, your endpoint must check for the request header sec-private-state-token, if it is present and it is not null or empty you can proceed to the redeemption

import { PSTRedeemer, PSTResources } from "@authcube/pst";

try {
  const redemptionToken = req.headers["sec-private-state-token"] as string;

  if (redemptionToken && !redemptionToken.match(BASE64FORMAT)) {
    return res.sendStatus(400);
  }

  const redeemer = new PSTRedeemer();

  // This call will throw an Error if the token is invalid
  const resToken = await redeemer.redeemToken(redemptionToken);

  res.statusCode = 200;
  res.setHeader("Access-Control-Allow-Origin", "*");
  res.append("sec-private-state-token", resToken);
  res.write("Token redeemed.");
  return res.send();
} catch (e) {
  // deal with the error as you see fit
  console.error(`Error on redemption: ${e}`);
  return res.sendStatus(400);
}