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

@quantumpipes/capsule

v1.2.0

Published

Capsule Protocol Specification (CPS) — TypeScript reference implementation

Readme

Capsule Protocol — TypeScript Reference Implementation

Status: Conformant — 16/16 golden fixtures passing, 101 tests, 100% coverage

TypeScript reference implementation of the Capsule Protocol Specification (CPS). Create, seal, verify, and chain Capsules in TypeScript/JavaScript.


Install

npm install @quantumpipes/capsule

Requires Node.js >= 20.19.0.


Quick Start

import { createCapsule, seal, verify, generateKeyPair } from "@quantumpipes/capsule";

const capsule = createCapsule({
  type: "agent",
  trigger: {
    type: "user_request",
    source: "deploy-bot",
    timestamp: new Date().toISOString().replace("Z", "+00:00"),
    request: "Deploy service v2.4 to production",
    correlation_id: null,
    user_id: null,
  },
});

const { privateKey, publicKey } = generateKeyPair();
const pub = await publicKey;

await seal(capsule, privateKey);
const valid = await verify(capsule, pub);
console.log(`Sealed: ${capsule.hash.slice(0, 16)}... Valid: ${valid}`);

API

Capsule Model

| Export | Description | |---|---| | createCapsule(partial?) | Create a Capsule with defaults for all 6 sections | | toDict(capsule) | Extract content dict (excludes seal fields) | | isSealed(capsule) | Check if hash and signature are present | | Factory functions | createTrigger, createContext, createReasoning, createAuthority, createExecution, createOutcome |

Canonical Serialization

| Export | Description | |---|---| | canonicalize(value) | CPS Section 2 compliant canonical JSON |

Cryptographic Seal

| Export | Description | |---|---| | computeHash(capsuleDict) | SHA3-256 of canonical JSON (64-char hex) | | seal(capsule, privateKey) | Hash + Ed25519 sign | | verify(capsule, publicKey) | Recompute hash + verify signature | | generateKeyPair() | Ed25519 key pair generation | | getFingerprint(privateKey) | Public key fingerprint (16 hex chars) |

Chain Verification

| Export | Description | |---|---| | verifyChain(capsules) | Validate sequence numbers and hash linkage |


Crypto Libraries

| Capability | Library | Version | |---|---|---| | SHA3-256 | @noble/hashes | ^2.0.1 | | Ed25519 | @noble/ed25519 | ^3.0.0 |

Both are audited, zero-dependency, pure-JS implementations by Paul Miller.


Conformance

This implementation passes all 16 golden test vectors from conformance/fixtures.json.

npm test    # 101 tests: 47 conformance + 22 canonical + 15 capsule + 11 seal + 6 chain

Known TypeScript Pitfalls (CPS Section 2)

  • JSON.stringify does not distinguish float from integer -- confidence: 1.0 serializes as 1, but the protocol requires 1.0. The canonicalize() function handles this via float-path detection.
  • DateTime format must use +00:00, not Z.
  • Non-ASCII Unicode must serialize as literal UTF-8, not \uXXXX.

Development

cd reference/typescript
npm install
npm run build
npm test

License

Apache License 2.0 with additional patent grant.