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

@web-axag/server

v1.1.1

Published

Server-side enforcement for AXAG actions: confirmation, approval, tenant scope, CSRF and audit

Readme

@web-axag/server

Enforces, on the server, what an annotation promised. The page's middleware improves what a cooperative agent does; this is what makes it true.

npm install @web-axag/server

Why both halves exist

An agent running in the page holds the page's credentials. It can skip your confirmation dialog and call the API directly. So every safety field an annotation declares is checked again here, against the generated manifest rather than against anything the caller sent.

import { createEnforcer } from '@web-axag/server';
import { axagGuard, axagConfirmRoute } from '@web-axag/server/express';
import manifest from './public/.well-known/axag-manifest.json' with { type: 'json' };

const enforcer = createEnforcer({
  manifest,
  approvals: async ({ action, actor }) => approvals.exists(action.intent, actor.id),
  csrfOf: request => request.session.csrfToken,
  audit: record => log.info(record),
});

const actorOf = req => ({ id: req.session.userId, tenant: req.session.tenant, roles: req.session.roles });

app.post('/axag/confirm', express.json(), axagConfirmRoute(enforcer, { actorOf }));
app.use('/api', express.json(), axagGuard(enforcer, { actorOf }));

axagGuard reads the X-AXAG-Intent header the page's enforcers send. Routing by path instead? Pass intentOf.

Not using Express? enforcer.check({ intent, parameters, headers, actor }) is the whole API; it throws an AxagError carrying the code and HTTP status.

What it checks

| Declared in the annotation | Checked here | |---------------------------|--------------| | risk_level at or above high, or confirmation_required | A confirmation token bound to this intent, these parameters and this person, used once, not expired | | approval_required | Your approvals hook grants it; the roles come from approval_roles | | required_roles | The actor holds one of them | | scope: "tenant" | The session has a tenant; a claimed tenant matches it; under tenant_boundary: "strict" no parameter points elsewhere | | — | CSRF token, when csrfOf is set |

Every check produces the error code the specification defines — AXAG_CONFIRMATION_MISSING (428), AXAG_TENANT_BOUNDARY (403), AXAG_ROLE_INSUFFICIENT (403), AXAG_INTENT_NOT_FOUND (404) — so a refusal means the same thing on the client, in the manifest and in your logs.

Confirmation tokens

A token proves a person saw this action with these parameters and agreed. It is bound to the intent, a hash of the parameters (key order doesn't matter) and the actor; it works once and expires after five minutes.

const confirmation = await enforcer.issueConfirmation({ intent, parameters, actor });

MemoryConfirmationStore is the default and fine for one process. Running more than one? Implement ConfirmationStore over Redis or your database — two methods, issue and consume.

Audit

createEnforcer({ manifest, audit: record => log.info(record) });

Each record carries the intent, actor, tenant, risk level, outcome, the refusal code when denied, and parameter names only — values can be personal data.

Keeping the linter honest

writeFileSync('axag-enforced.json', JSON.stringify({ intents: enforcer.enforcedIntents() }, null, 2));

Point enforcedIntentsPath at that file in .axaglintrc.json and AXAG-LINT-037 warns about any high-risk action your server isn't enforcing.