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

@ima-jin/auth

v0.8.17

Published

DID-based identity, session, and app-token auth for Imajin services — signing/verification, session and app-token middleware, scope grants, and identity tiers.

Readme

@ima-jin/auth

DID-based identity, session, and app-token auth for Imajin services — signing/verification, session and app-token middleware, scope grants, and identity tiers.

Install

npm install @ima-jin/auth

Usage

import { requireAuth, authErrorResponse } from '@ima-jin/auth';
import { sign, verify } from '@ima-jin/auth';
import { requireSessionOrAppToken, requireHardDIDOrAppToken } from '@ima-jin/auth';

requireSessionOrAppToken(request, { slug }) / requireHardDIDOrAppToken(request, { slug }) verify the Bearer token's aud against the app's registry slug (e.g. 'dykil'), never its host — path-routed apps share one host, and the registry's token_audiences holds slugs. Set IMAJIN_APP_AUD to override the audience; a host-shaped value is rejected. A Bearer that fails verification is a 401 — it never falls back to the session cookie (#2706).

requireHardDIDOrAppToken is requireSessionOrAppToken plus a hard-DID gate: soft (email-only) DIDs get a 403. Tier is read from the session for cookie callers and looked up from the kernel's public GET /auth/api/identity/:did for app-token callers — tokens carry no tier claim. Only hard tiers are cached (30s); a soft result is never cached, so a buyer who upgrades soft → hard succeeds on the next request.

Subpath exports are available for consumers that only need specific vocabularies without pulling in the rest of the package:

import { BROKER_CONSENT_SCOPES } from '@ima-jin/auth/broker-consent-vocabulary';
import { SCOPES } from '@ima-jin/auth/scope-vocabulary';
import { GRANT_SCOPES } from '@ima-jin/auth/grant-scopes';

Acting as a group DID

requireSessionOrAppToken returns auth.actingAs (the group DID) when the app token was minted with actAs. The kernel checks the user's authority over the group once, at mint, and only for an app the operator approved for act-as; there is no per-request re-check, and the token's expiry bounds staleness. Own records as auth.actingAs ?? auth.did. The session-cookie fallback never sets it.

const result = await requireSessionOrAppToken(request, { slug: 'market' });
if ('error' in result) return new Response(result.error, { status: result.status });
const ownerDid = result.auth.actingAs ?? result.auth.did;

validateActingAs (the existing per-service group gate behind requireAuth's x-acting-as handling) is now exported for the kernel's mint-time check.

Agent delegation (actingFor)

requireSessionOrAppToken / requireHardDIDOrAppToken surface auth.actingFor (the owner DID) when the request carries X-Acting-For and the delegation verifies — the same grants-first check requireAuth runs (/auth/api/internal/verify-delegation, legacy membership fallback). auth.did is the delegate. A delegation that does not verify is a 403, and the raw header is never surfaced. Feed it to the delegation policy so a delegate is denied on irreversible routes:

import { enforceRoutePolicy } from '@ima-jin/auth/delegation-policy';

const { auth } = result;
const denied = enforceRoutePolicy({ id: auth.did, actingFor: auth.actingFor }, 'learn.course.delete');
if (denied) return denied;

The app's environment needs AUTH_SERVICE_URL and AUTH_INTERNAL_API_KEY; without them the check fails closed (403) rather than trusting the header.

What's included

  • Sessions — cookie-based session issuance and validation
  • App tokens — scoped tokens for registered third-party apps
  • Signing — Ed25519 sign/verify helpers for DID-based identities
  • Identity tiers — verified / established / steward / operator tier checks
  • Attestations — emit and evaluate identity attestations

@ima-jin/auth depends on @ima-jin/config and @ima-jin/logger (both published alongside it) and is DB-free — credential resolution happens behind an internal kernel route rather than a direct database connection.

Part of Imajin

Imajin — sovereign technology infrastructure. Open source.