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

casbin-receipt-watcher

v0.1.0

Published

Casbin WatcherEx that signs policy mutations with Ed25519, producing Veritas Acta receipts. First WatcherEx implementation with cryptographic audit trail.

Readme

casbin-receipt-watcher

Casbin WatcherEx implementation that signs every policy mutation with Ed25519, producing independently verifiable Veritas Acta receipts.

The first WatcherEx implementation with a cryptographic audit trail.

Install

npm install casbin-receipt-watcher casbin

Usage

import { newEnforcer } from 'casbin';
import { ReceiptWatcher } from 'casbin-receipt-watcher';

const watcher = new ReceiptWatcher({
  privateKeyHex: process.env.SIGNING_KEY,
  issuerId: 'casbin:my-service',
});

const enforcer = await newEnforcer('model.conf', 'policy.csv');
enforcer.setWatcher(watcher);

// Every policy change now produces a signed receipt
await enforcer.addPolicy('alice', '/api/data', 'read');

// Inspect receipts
console.log(watcher.receipts);

What it does

Every time a Casbin policy is modified (add, remove, save), the watcher:

  1. Captures the mutation details (section, ptype, params)
  2. Canonicalizes the event using JCS (RFC 8785)
  3. Signs with Ed25519 (RFC 8032)
  4. Emits a signed receipt to configured output(s)

Receipts are independently verifiable by anyone, offline, forever:

import { verifyReceipt } from 'casbin-receipt-watcher';

const valid = verifyReceipt(receipt); // true if untampered

Or with the Veritas Acta CLI:

npx @veritasacta/verify receipt.json

Configuration

new ReceiptWatcher({
  // Required: Ed25519 private key (hex, 64+ chars)
  privateKeyHex: '...',

  // Optional: issuer identifier (default: "casbin:default")
  issuerId: 'casbin:my-service',

  // Optional: output destination(s) (default: console)
  output: [
    { type: 'console' },
    { type: 'callback', fn: (receipt) => db.insert(receipt) },
    { type: 'http', url: 'https://api.example.com/receipts' },
    { type: 'file', path: '/var/log/casbin-receipts.jsonl' },
  ],
});

Receipt format

{
  "receipt_id": "rec_casbin_a8f3b291c4d5e6f7",
  "receipt_version": "1.0",
  "issuer_id": "casbin:my-service",
  "event_time": "2026-04-15T03:22:41.891Z",
  "event_type": "policy_mutation",
  "mutation_type": "add_policy",
  "section": "p",
  "ptype": "p",
  "params": [["alice", "/api/data", "read"]],
  "model_hash": "sha256:b7e2...",
  "public_key": "4437ca56815c0516...",
  "signature": "4cde814b7889e987..."
}

WatcherEx methods covered

| Method | Receipt mutation_type | |--------|----------------------| | updateForAddPolicy | add_policy | | updateForRemovePolicy | remove_policy | | updateForRemoveFilteredPolicy | remove_filtered_policy | | updateForSavePolicy | save_policy | | updateForAddPolicies | add_policies | | updateForRemovePolicies | remove_policies |

Standards

  • Ed25519 (RFC 8032) for digital signatures
  • JCS (RFC 8785) for deterministic JSON canonicalization
  • Veritas Acta receipt format for interoperability

Related

License

MIT