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

@allowly/verifier

v4.0.1

Published

Reference verifier for the Allowly Receipt Format. Verifies signed receipts of AI agent authorization decisions.

Downloads

939

Readme

@allowly/verifier

TypeScript reference verifier for Allowly Receipt Format wire version 4.

Zero runtime dependencies. Uses Node.js's built-in WebCrypto for Ed25519 verification.

Install

npm install @allowly/verifier

Requires Node.js 20+.

Usage

import { verifyReceipt, VerificationError, loadKeysFromJson } from "@allowly/verifier";

const receipt = JSON.parse(receiptJson);
const keysDoc = JSON.parse(keysJson);
const configuredWorkspaceId = process.env.ALLOWLY_WORKSPACE_ID;
const configuredKeyFingerprint = process.env.ALLOWLY_TRUSTED_KEY_FINGERPRINT;
if (!configuredWorkspaceId) throw new Error("ALLOWLY_WORKSPACE_ID is required");
if (!configuredKeyFingerprint) throw new Error("ALLOWLY_TRUSTED_KEY_FINGERPRINT is required");
if (keysDoc.workspace_id !== configuredWorkspaceId) {
  throw new Error("key document workspace does not match configuration");
}
const keys = loadKeysFromJson(keysDoc);

try {
  await verifyReceipt(receipt, keys, {
    expectedWorkspaceId: configuredWorkspaceId,
    trustedKeyFingerprints: new Set([configuredKeyFingerprint]),
  });
  console.log("valid");
} catch (e) {
  if (e instanceof VerificationError) {
    console.log(`invalid: ${e.message}`);
  } else {
    throw e;
  }
}

Fetching the public keys

const configuredWorkspaceId = process.env.ALLOWLY_WORKSPACE_ID;
if (!configuredWorkspaceId) throw new Error("ALLOWLY_WORKSPACE_ID is required");
const res = await fetch(`https://api.allowly.ai/v1/workspaces/${configuredWorkspaceId}/keys`);
const keysDoc = await res.json();
if (keysDoc.workspace_id !== configuredWorkspaceId) {
  throw new Error("key document workspace does not match configuration");
}
const keys = loadKeysFromJson(keysDoc);

Honor the issuer's Cache-Control header. Allowly currently returns no-store, so do not HTTP-cache the response; retain trusted key material separately for offline audits.

API

verifyReceipt(receipt, publicKeys, opts?)

Verifies a receipt. Resolves on success, throws VerificationError on any failure.

  • receipt — the full receipt object (payload + signature).
  • publicKeys — array of PublicKey objects. Get these via loadKeysFromJson.
  • opts.now — optional Date override for time checks. Defaults to new Date().
  • opts.expectedWorkspaceId — optional. If set, the receipt's workspace_id must equal it. Pass a caller-trusted configured workspace ID, never one copied from the receipt or key document (spec §7, "Workspace binding"); a key_id alone does not bind a receipt to a workspace.
  • opts.trustedKeyFingerprints — optional ReadonlySet<string>. If set, the selected receipt key must match a caller-trusted sha256:<64 lowercase hex> fingerprint. Include every trusted rotation key that may have signed the selected receipts.

canonicalize(payload)

Produces the canonical JSON byte sequence per spec §4. Exposed for implementers building signers in TypeScript.

verifyCheckpoint(checkpoint, receipts, publicKeys, opts)

Verifies the checkpoint and member signatures, exact UTC-day period, count, Merkle root, and optional prior checkpoint linkage. opts.expectedWorkspaceId is required and must come from caller-trusted configuration. Pass caller-trusted rotation keys through opts.trustedKeyFingerprints; the pins are applied to the checkpoint, every member, and the optional prior checkpoint. Success proves the supplied set matches the signed commitment; without external anchoring it does not prove issuer-registry or real-world completeness.

loadKeysFromJson(doc)

Parses the /v1/workspaces/{id}/keys response into a PublicKey[]. It requires a non-empty workspace_id, requires every key's alg to equal Ed25519, and validates any advertised public_key_fingerprint against the decoded key. Bundled fingerprint values are not caller-trusted merely because they accompany the receipts.

publicKeyFingerprint(key)

Returns the canonical sha256:<64 lowercase hex> fingerprint over the key's decoded raw 32-byte Ed25519 public key.

matchesRef(key, fieldName, value, ref)

Implements the optional hmac-v1 keyed-pseudonym convention in specification Appendix A. Decode the show-once integration key, then match locally — no call to Allowly:

import { matchesRef } from "@allowly/verifier";

const key = Buffer.from(encodedKeyB64url, "base64url"); // per-integration pseudonym key
const ok = matchesRef(key, "record", "MRN-48291", receipt.context.record_ref);

key is a Uint8Array of at least 16 bytes; fieldName is one of project, record, actor, full_tuple. The value is used exactly as supplied — no trimming, case folding, or Unicode normalization — and comparison is constant-time. Use context.ref_key_version to select the retained key version. This helper is unrelated to signature verification and does not touch the receipt schema, canonicalization, or wire version.

verifyReceipt accepts an already-parsed object. JSON.parse cannot report duplicate member names or preserve whether an integer was written as 1, 1.0, or 1e0; reject those forms at the raw-JSON boundary when the original receipt text is untrusted (spec §4.2).

What verification proves

A valid receipt proves that the selected private key signed the exact recorded decision and timestamp for the recorded subject/action. It does not independently prove when signing happened, that the action actually happened, that the user's authorization was informed, or that the user_id corresponds to any real-world person. See spec §7.1.

License

Apache 2.0. Contributions welcome — see CONTRIBUTING.md.