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

@agent-id/express

v0.1.2

Published

AgentID verifier middleware for Express.js — blocks unauthorized AI agents from your API routes

Readme

@agent-id/express

Express.js middleware that automatically detects AI-agent traffic and requires a valid AgentID JWT. Human browser traffic always passes through untouched.

Install

npm install @agent-id/express

Requires express >= 4 and node >= 18.

Setup — 2 steps

1. Add the middleware

import express from 'express';
import { agentID } from '@agent-id/express';

const app = express();

app.use(agentID());

app.listen(3000);

That's it. The middleware now:

  • Lets all human browser traffic through unchanged
  • Requires a valid AgentID JWT from any AI agent / bot
  • Returns 403 AGENT_UNAUTHORIZED when the JWT is missing or invalid

2. Read the verified identity in your route handlers (optional)

app.get('/api/data', (req, res) => {
  const agent = req.agentId;

  if (agent?.verified) {
    // Verified AI agent — claims are fully typed
    console.log(agent.claims.sub);          // pseudonymous stable user ID
    console.log(agent.claims.auth_method);  // "bankid"
    return res.json({ ok: true, sub: agent.claims.sub });
  }

  // Human traffic: agent.reason === 'not_agent'
  return res.json({ ok: true });
});

req.agentId is typed automatically — no extra TypeScript configuration needed.

How agents authenticate

Agents add one header to every request:

Authorization: Bearer <agentid-jwt>

The JWT is obtained by completing a BankID flow at agentidapp.vercel.app. Tokens are valid for 1 hour.

Options

All options are optional — agentID() with no arguments works out of the box.

app.use(agentID({
  // Return 403 when an agent has no valid token (default: true).
  // Set to false to let unverified agents through (useful for logging / gradual rollout).
  blockUnauthorizedAgents: true,

  // Override the JWKS endpoint — only needed if you self-host AgentID.
  jwksUrl: 'https://your-agentid.example.com/api/jwks',

  // Clock skew tolerance in seconds (default: 30).
  clockTolerance: 30,

  // Fully custom response when an agent is rejected.
  onUnauthorizedAgent: (req, res, next, reason) => {
    res.status(403).json({ error: 'No AgentID token', reason });
  },
}));

What gets verified

Verification is fully offline after the first request. The public key is fetched once from the AgentID JWKS endpoint and cached for 1 hour — no per-request network call.

| Check | Requirement | |---|---| | Signature | RS256 — alg:none and HS256 are explicitly rejected | | Issuer (iss) | Must equal "agentid" | | Expiry (exp) | Must be in the future | | auth_method | Must equal "bankid" |

JWT claims

| Field | Description | |---|---| | sub | Pseudonymous stable user ID (HMAC-SHA256 of BankID personal number — non-reversible, same person always gets the same ID) | | auth_method | Always "bankid" | | iss | "agentid" | | exp | Unix timestamp — 1 hour from issue | | iat | Unix timestamp — when issued | | jti | Unique token ID |