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

x402-agent-score

v0.1.0

Published

Hono middleware to gate x402 API requests by agent reputation score

Readme

x402-agent-score

Hono middleware that checks the DJD Agent Score reputation of the wallet paying your x402 API — and optionally blocks low-reputation agents.

Scores are based on on-chain signals: wallet age, transaction history, ETH balance, USDC activity, Basename ownership, and GitHub-verified registration. Scores range 0–100.

Install

npm install x402-agent-score

Usage

import { Hono } from 'hono'
import { paymentMiddleware } from 'x402-hono'
import { agentScoreGate } from 'x402-agent-score'

const app = new Hono()

// 1. x402 payment middleware (verifies USDC payment)
app.use(paymentMiddleware(PAY_TO, routes, { url: FACILITATOR_URL }))

// 2. Agent score gate (runs after payment is verified)
app.use(agentScoreGate({
  minScore: 25,        // block wallets scoring below 25
  onUnknown: 'allow',  // let unscored wallets through (score fetched async)
}))

app.get('/my-api', (c) => c.json({ result: 'ok' }))

Every response gets three headers:

| Header | Value | |--------|-------| | X-Agent-Score | 0100, or unscored if not yet cached | | X-Agent-Tier | Elite / Trusted / Emerging / Unverified / Unknown | | X-Agent-Recommendation | proceed / proceed_with_caution / review / block |

Options

agentScoreGate({
  // Minimum score to allow. Below this → 403. Default: 0 (headers only, nothing blocked)
  minScore: 25,

  // What to do for wallets with no score yet. Default: 'allow'
  // 'allow'  — let through, fetch score async for next request
  // 'reject' — return 403 until the wallet has been scored
  onUnknown: 'allow',

  // How to get the paying wallet from Hono context.
  // Default: tries c.get('x402PayerAddress'), X-Agent-Wallet header, ?wallet query param
  getWallet: (c) => c.get('myPayerAddress'),

  // Score API base URL. Default: https://djd-agent-score.fly.dev
  apiUrl: 'https://djd-agent-score.fly.dev',

  // Local cache TTL (ms). Avoids a score API call on every request. Default: 5 min
  cacheTtl: 300_000,
})

How it works

  1. The middleware extracts the paying wallet address from the request context
  2. If the wallet has a cached score (from a previous request in this process), it enforces minScore and adds headers
  3. If the wallet is unknown, it fires an async score fetch to warm the cache, then either allows or rejects based on onUnknown
  4. The cache is in-process (a Map). Scores are refreshed after cacheTtl ms

The async-fetch design means the first request from any wallet is never delayed — it passes through while the score is fetched in the background, so the second request gets the enforcement.

Extracting the wallet from x402 context

The default wallet extractor tries these in order:

  1. c.get('x402PayerAddress') — if your x402 middleware sets this
  2. X-Agent-Wallet request header
  3. ?wallet query parameter

If none of these work for your setup, provide getWallet:

agentScoreGate({
  getWallet: (c) => {
    // Example: extract from a custom auth header
    return c.req.header('x-paying-wallet')
  }
})

Blocking unverified agents

To require a minimum reputation before serving any paid request:

agentScoreGate({
  minScore: 20,       // block Unverified tier (scores < 20 are brand new wallets)
  onUnknown: 'allow', // still allow first-time wallets (they get scored async)
})

A rejected request receives:

{
  "error": "agent_score_too_low",
  "score": 12,
  "tier": "Unverified",
  "minRequired": 20,
  "improve": "https://djd-agent-score.fly.dev/v1/agent/register"
}

Agent registration

Agents can boost their score by self-registering:

curl -X POST https://djd-agent-score.fly.dev/v1/agent/register \
  -H 'Content-Type: application/json' \
  -d '{"wallet":"0x...","name":"My Agent","github_url":"https://github.com/..."}'

Registration is free and adds +10–45 pts to the identity dimension.

License

MIT