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

@atlasauth/pca-next

v0.4.3

Published

Next.js helper for Proof-Carrying Authority: wrap a Route Handler so the inbound PCActn is verified before your handler runs, with a 401/403 response otherwise.

Readme

@atlasauth/pca-next

Next.js (App Router) helper for Proof-Carrying Authority (PCA). withPCA wraps a Route Handler so the inbound PCActn is verified with the resource-server guard from @atlasauth/pca before your handler runs; otherwise it returns a 401/403 JSON response with a WWW-Authenticate challenge. Verification is default-deny.

Install

npm i @atlasauth/pca-next @atlasauth/pca
npm i next   # optional peer dependency (^14 || ^15)

Usage

// app/refunds/route.ts
import { withPCA } from '@atlasauth/pca-next';
import { memoryPcaStore } from '@atlasauth/pca';

export const POST = withPCA(
  {
    audience: 'ins_acme',                       // this resource server's id; the PCActn's signed `aud` must match
    resolveGrant: async (ref) => grants.get(ref) ?? null, // look up the Root Intent Grant by grant_ref
    budgetStore: memoryPcaStore(),              // replay counter store (use a durable one in production)
    hooks: { revocation: async () => ({ enforced: true, ok: !(await isRevoked()) }) }, // revocation checker
    context: async (req, pcactn) => ({          // facts only the resource server can vouch for
      params: { amount: 20, currency: 'usd' },
      plan: authorizedPlanNodes,                // your copy of the principal-authorized plan
      planAuthorized: true,
      budget: { B: 500, tau: 0 },
      risk: { blastRadius: 0.04 },              // risk inputs you can vouch for (missing ones fail closed to worst case)
    }),
  },
  async (req, { pca }) => {
    const { verdict, pcactn } = pca;            // handler only runs for a valid PCActn
    return Response.json({ ok: true });
  },
);

The client sends the PCActn as a PCA-Action: <base64url> header (see pcaHeaders in @atlasauth/pca) or as a JSON body { pcactn }; the default extractor reads both. The wrapper reads a clone of the request body, so your handler can still read it. By default a deployment must supply budgetStore, a hooks.revocation checker, and a context() returning the server's own plan and planAuthorized: true; otherwise requests are denied. insecureAllowUnenforced: true relaxes this for local development only.

API

  • withPCA(options, handler) - returns (req: Request) => Promise<Response>. Options extend RequirePcaOptions from @atlasauth/pca, plus onDeny(result, req) to customize the error response.
  • Re-exports requirePCA, defaultExtract, memoryPcaStore.

Status

This package only wires the guard into Next.js route handlers; all verification logic lives in @atlasauth/pca. PCA cryptography has not been independently audited.

License

MIT - see LICENSE