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

@defen.so/sdk-node

v0.2.0

Published

Defenso Node.js SDK — fail-open WAF, bot detection, and attack-log middleware for Express, Fastify, and Next.js. One line, always on. If Defenso is unreachable, your app keeps serving.

Downloads

211

Readme

@defen.so/sdk-node

One-line WAF, bot detection, and attack logging for Node, Express, Fastify, Next.js, Bun, and Deno. Part of Defenso — your security layer, shipped in 30 seconds.

  • Managed WAF with OWASP Top 10 + Core Rule Set + your custom rules
  • Bot detection with UA classification + rate limits
  • Attack logging with full context (IP, ASN, country, payload, route, verdict)
  • Fails open — if Defenso is unreachable, your app keeps serving
  • ~0.1 ms in-process latency (rules cached, evaluation is local)
  • Attack events queued and flushed in the background
  • $0 to start · Pro $29/mo per site

Install

npm install @defen.so/sdk-node

Get a token at https://app.defen.so/developer.

Frameworks

Express

import express from 'express';
import { defenso } from '@defen.so/sdk-node/express';

const app = express();
app.use(defenso({ token: process.env.DEFENSO_TOKEN! }));

app.get('/', (req, res) => res.send('hi'));
app.listen(3000);

Fastify

import Fastify from 'fastify';
import { defensoFastify } from '@defen.so/sdk-node/fastify';

const app = Fastify();
await app.register(defensoFastify, { token: process.env.DEFENSO_TOKEN! });

app.get('/', async () => ({ hello: 'world' }));
app.listen({ port: 3000 });

Next.js (App or Pages router)

// middleware.ts
import { NextResponse } from 'next/server';
import { defensoNext } from '@defen.so/sdk-node/next';

const inspect = defensoNext({ token: process.env.DEFENSO_TOKEN! });

export function middleware(req: Request) {
    const verdict = inspect(req);
    if (verdict.blocked) {
        return new NextResponse(JSON.stringify({ error: verdict.reason }), { status: 403 });
    }
    return NextResponse.next();
}

Bun

defensoNext inspects any Web Request and returns { blocked, reason }, so it wires straight into Bun.serve:

import { defensoNext } from '@defen.so/sdk-node/next';

const inspect = defensoNext({ token: Bun.env.DEFENSO_TOKEN! });

Bun.serve({
    fetch(req) {
        const verdict = inspect(req);
        if (verdict.blocked) {
            return new Response(JSON.stringify({ error: verdict.reason }), { status: 403 });
        }
        return new Response('hi');
    },
});

Deno

import { defensoNext } from 'npm:@defen.so/sdk-node/next';

const inspect = defensoNext({ token: Deno.env.get('DEFENSO_TOKEN')! });

Deno.serve((req) => {
    const verdict = inspect(req);
    if (verdict.blocked) {
        return new Response(JSON.stringify({ error: verdict.reason }), { status: 403 });
    }
    return new Response('hi');
});

How it works

  • Policy (WAF rules) is pulled from Defenso every 5 min and cached in-memory.
  • Requests are inspected in-process against the cached policy. Latency ~0.1 ms.
  • Attack events are queued and flushed to Defenso every 10 s in the background.
  • If Defenso is down, requests are allowed. Your app never blocks on the network.

Options

All framework adapters (defenso, defensoFastify, defensoNext) accept the same options object:

{
    token: '...',                        // required
    api: 'https://app.defen.so/api',     // override for self-hosted
    policyRefreshMs: 5 * 60_000,         // how often to pull rules
    logFlushMs: 10_000,                  // background log flush cadence
    logBatchSize: 50,                    // immediate flush at this batch size
    policyTimeoutMs: 250,                // fail-open threshold on policy fetch
}

What Defenso stops

SQL injection, XSS (reflected / stored / DOM), CSRF, SSRF, path traversal, XXE, NoSQL / LDAP / command injection, brute force, credential stuffing, malicious file uploads (polyglots, PHP-in-PNG), bot scrapers, headless browser abuse, TOR exit nodes, exposed secrets, wide-open cloud config. Full list at defen.so/threats.

Part of the Defenso platform

This SDK is the in-process WAF layer. It plugs into the same account that powers uptime monitoring, quick pentest (headers, TLS, email security SPF/DKIM/DMARC, and compliance-style findings), vibe-coder and repo/secret scans, active deception, and the real-time attack log — all managed from app.defen.so.

Links

License

MIT