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

@gonk/auth

v0.5.1

Published

Transport-independent authenticated principal, authorization, security-key, receipt, and redaction contracts for Gonk hosts and adapters.

Readme

@gonk/auth

Transport-independent security contracts for Gonk hosts, registries, and adapters. Hosts authenticate callers using their native mechanism and normalize the result into an AuthenticatedPrincipal; Gonk carries that principal through an AuthContext and records redacted authorization and approval receipts.

This package does not verify JWTs, host login UI, store credentials, depend on MCP, or implement a policy engine.

Principal and delegation

identity is the effective subject whose authority is being exercised. delegation records the verified immediate agent or service acting for that subject.

import type { AuthenticatedPrincipal } from "@gonk/auth";

const principal: AuthenticatedPrincipal = {
  id: "principal:user-1",
  kind: "human",
  identity: {
    issuer: "https://accounts.example",
    subject: "user-1",
    method: "oauth",
  },
  workspaceId: "workspace-1",
  delegation: {
    actorKind: "agent",
    actor: {
      issuer: "sigil:eve",
      subject: "agent-1",
      method: "service-token",
    },
    actorId: "eve-agent-1",
    actorSessionId: "session-a",
  },
  roles: ["member"],
  scopes: ["reviews:write"],
};

Binding keys

import { persistentGrantKey, securityContextKey } from "@gonk/auth";

const sessionKey = securityContextKey({ principal });
const alwaysAllowKey = persistentGrantKey({ principal });

Both opaque keys bind subject, actor identity/id, tenant, and workspace. securityContextKey also binds the delegated actor session and is used for stateful transports, one-call assertions, and session grants. persistentGrantKey deliberately survives an agent-session restart and is used for tightly constrained persistent grants.

Roles, scopes, token expiry, and host attributes are revalidated policy inputs; they are not key material. Attributes use the exported recursive AuthClaimRecord plain-data contract—no functions, class instances, Set, Map, or mutable date objects cross the authorization boundary.

Authorization

import type { AuthContext } from "@gonk/auth";

const auth: AuthContext = {
  principal,
  authorize: ({ action, resource }) =>
    policy.authorize(principal, action, resource),
};

AuthContext is generic and imports no tool-registry or transport types.

Request-bound capture

Use captureAuthContext(auth) when an authorization context crosses into an asynchronous request lifecycle. It validates, clones, and deeply freezes the principal, then binds authorize once. Later mutation of the host's principal object or replacement of its policy method cannot change the identity or policy function captured for that request. Class-based policy receivers remain supported.

Audit redaction

redactAuthzResource() removes resource metadata and returns the small attributable projection accepted by security receipts. Credentials, complete tool inputs, prompts, and document bodies do not belong in receipts.

Install

npm i @gonk/auth

License

Apache-2.0.