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

traffic-guard

v0.2.0

Published

High-throughput traffic and attack defense gate with zero required dependencies, wire-order analysis, and TypeSafe System One acceleration.

Readme

traffic-guard

High-throughput traffic and attack defense gate for incoming web traffic with zero required dependencies, wire-order analysis, and TypeSafe System One acceleration.

npm install traffic-guard

Quick start

import trafficguard from 'traffic-guard';

const decision = await trafficguard(req);

if (decision.shouldBlock) {
  return res.status(403).json({ error: 'Forbidden', reasons: decision.reasons });
}

trafficguard(req) inspects headers, wire sequence order, payload entropy, and velocity signals in under 30 µs. Returns action, shouldBlock, shouldTarpit, riskScore, and calibrated reasons.

Express middleware

import express from 'express';
import trafficguard from 'traffic-guard';

const app = express();

app.use(trafficguard.middleware({
  policy: 'balanced',
  allowGoodBots: true,
  honeypotPaths: ['/__tg_trap'], // instant ban for web spiders touching hidden links
  whitelistedPaths: ['/healthz', /^\/public\//]
}));

app.get('/api/data', (req, res) => res.json({ message: 'Hello Human!' }));
app.listen(3000);

Advanced defense patterns implemented

  1. Header Order Sequence Analysis: Real Chromium browsers send Host before User-Agent and Client Hints (sec-ch-ua) in a strict order. Bots forging user-agents in Python/cURL exhibit sequence disorder.
  2. Stateless HMAC Tokens & Velocity Tracking: Signs a signed __trafficguard cookie via HMAC-SHA256 tracking request velocity in 10-second sliding windows with zero database dependency.
  3. Silent Proof-of-Work (PoW) Micro-Challenge: Serves an inline 1.2 KB HashCash puzzle. Legitimate browsers solve it in 15–30 ms; automated CLI scrapers cannot execute JS.
  4. Tarpitting (Slowdown Defense): Configurable artificial latency delay for scrapers to exhaust their concurrency pools.
  5. Canary Honeypot Traps: Immediate blocking of crawlers that scrape invisible honeypot URLs.

Progressive TypeSafe System One tiering (Optional)

By default, the in-tree zero-dependency engine evaluates traffic in <100 µs. To elevate to TypeSafe System One for semantic reasoning on complex attacks:

export TYPESAFE_API_KEY=ts_live_...
import { TrafficGuard } from 'traffic-guard';

const guard = new TrafficGuard({
  apiKey: process.env.TYPESAFE_API_KEY,
  model: 'jev-latest' // default
});

Empirical benchmark

Evaluated on 25 canonical golden test cases (bench/dataset.json):

| Metric | In-Tree Zero-Dep Engine (JS) | TypeSafe Cloud Tier (Jev-latest) | |---|---|---| | Category Classification | 100.0% | 100.0% | | Action Accuracy | 100.0% | 100.0% | | Attack Block Rate (Recall) | 100.0% | 100.0% | | Human False Positive Rate | 0.0% | 0.0% | | Good Bot Passthrough Rate | 100.0% | 100.0% | | Mean Latency | 30 µs (0.03 ms) | ~250 ms | | p95 Latency | 56 µs | ~320 ms | | External Dependencies | 0 required | Optional @typesafe-ai/sdk |

License

MIT © Hemanth.HM