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/nextjs

v0.1.3

Published

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

Readme

@agent-id/nextjs

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

Install

npm install @agent-id/nextjs

Requires next >= 16.

Setup — 2 steps

1. Add the proxy

Create proxy.ts in your project root (same level as app/):

import { createAgentIDMiddleware } from '@agent-id/nextjs';
import type { NextRequest } from 'next/server';

const agentID = createAgentIDMiddleware();

export function proxy(request: NextRequest) {
  return agentID(request);
}

// Protect your API routes
export const config = {
  matcher: '/:path*',
};

That's it. The proxy 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/api/anything/route.ts
import { getAgentIDResult } from '@agent-id/nextjs';
import type { NextRequest } from 'next/server';

export async function GET(request: NextRequest) {
  const agent = getAgentIDResult(request);

  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"
  }

  // Human traffic: agent.verified === false, agent.reason === 'not_agent'
  return Response.json({ ok: true });
}

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 — createAgentIDMiddleware() with no arguments works out of the box.

createAgentIDMiddleware({
  // 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: (request, reason) =>
    NextResponse.json({ error: 'No AgentID token', reason }, { status: 403 }),
})

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 |