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

@kokuin/store-delegation

v0.7.3

Published

Hozon-backed delegation token and revocation store

Downloads

988

Readme

@kokuin/store-delegation

Hozon-backed store for delegation tokens and capability revocations.

Installation

npm install @kokuin/store-delegation

Usage

import { HozonDB } from '@hozon/db'
import {
  createDelegationRevocationChecker,
  delegationStoreDefinition,
  getDelegationStore,
} from '@kokuin/store-delegation'

const db = new HozonDB({ adapter }) // an @hozon/node-sqlite or @hozon/postgres adapter
db.register(delegationStoreDefinition)
const store = await getDelegationStore(db)

// A `verifyToken` hook for `@kokuin/capability`'s `checkCapability`.
const verifyToken = createDelegationRevocationChecker({ api: store, methods })

The checker and its verdict accept per-call yield?: boolean, forwarded by checkCapability. A supplied policy overrides the construction policy. Omitting it retains the captured policy and default yielding.

Every write carries a caller-supplied hlc stamp, and the purge methods must be scheduled by the consumer. See docs/reference/stores.md.

Crypto provider migration to 0.7.0

createDelegationRevocationChecker(params: CreateDelegationRevocationCheckerParams) accepts options.crypto?: CryptoProvider. It captures options and forwards the provider through tracked backend and resolver wrappers. createDelegationRevocationBackend retains its signature. Checker construction stays synchronous and its returned hook stays asynchronous. Strict default verification applies on reverification. Custom algorithm verifiers retain precedence and own their policy. Provider operational failures propagate unchanged. No historical rescan or version gate is introduced.

See provider adoption for selection, migration and verification policy.

Named params migration

| Export | Named params type | Fields | | --- | --- | --- | | new VerifiedRevocationError | VerifiedRevocationErrorParams | message, options? |

These signature and typing changes preserve cryptographic results, error causes, ordering and storage behaviour.

Additional APIs use the same flat params convention.

| Export | Named params type | Previous positional form | | --- | --- | --- | | createDelegationStore | CreateDelegationStoreParams | createDelegationStore(db: Kysely<DelegationStoreTables>, adapter: Adapter, context: StoreContext) | | createDelegationRevocationChecker | CreateDelegationRevocationCheckerParams | createDelegationRevocationChecker(params: CreateDelegationRevocationCheckerParams) |

Method and callback contracts follow the same convention.

| API | Named params type | Previous form | | --- | --- | --- | | DelegationStoreAPI.getRevocationByIssuer | DelegationStoreAPIGetRevocationByIssuerParams | getRevocationByIssuer(jti, issuer) | | DelegationStoreAPI.isRevokedBy | DelegationStoreAPIIsRevokedByParams | isRevokedBy(jti, issuer) | | DelegationStoreAPI.markRevocationVerified | DelegationStoreAPIMarkRevocationVerifiedParams | markRevocationVerified(jti, issuer, params) | | DelegationStoreAPI.getPendingRevocationByIssuer | DelegationStoreAPIGetPendingRevocationByIssuerParams | getPendingRevocationByIssuer(jti, issuer) | | DelegationStoreAPI.deletePendingRevocationsFromOtherIssuers | DelegationStoreAPIDeletePendingRevocationsFromOtherIssuersParams | deletePendingRevocationsFromOtherIssuers(jti, issuer) |

| API | Named params type | Previous form | | --- | --- | --- | | createDelegationRevocationChecker(...).verdict | DelegationRevocationVerdictParams | verdict(token, raw) |

Bounded held-token reads

getHeldTokenStats({ audience, atTime }) returns { count, bytes } using SQL aggregates without fetching token rows. getHeldTokenPage({ audience, atTime, after?, limit, maxBytes? }) returns { tokens, next, oversized? } with the same authority filters as getHeldTokens. The package exports HeldTokenStats, HeldTokenPage, HeldTokenPageOversized and MAX_HELD_TOKEN_PAGE_SIZE (1,000). Limits outside the integer range 1–1,000 throw RangeError.

Pass next as after until it is null, keeping the audience and time fixed. Pages use the composite table key, since JTIs are not globally unique. Stats count UTF-8 token bytes on PostgreSQL and adapter-created SQLite databases. See the store reference for encoding, cursor and concurrency contracts. Without maxBytes, pages retain their row-only bound. Optional maxBytes must be a positive safe integer, otherwise the call throws RangeError. SQL returns the longest key-ordered prefix within both limits, measuring token bytes with the stats expression. Bodies outside that prefix never reach the driver result, including after concurrent inserts or replacements. If the first eligible row exceeds the allowance, the page returns no tokens and oversized: { jti, bytes }. On that result, next equals the requested after, or null when after was omitted. Check oversized before treating next: null as completion. Retry with a larger allowance or stop. The byte allowance covers token bodies only, excluding row metadata and driver overhead. Use a caller transaction with snapshot isolation for a consistent preflight and page traversal.