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

cloudist

v2.4.5

Published

Simple WAF Web App Firewall, middleware for Node.js — blocks SQLi, XSS, path traversal, command injection & bots, with a waf-style browser check, framework-agnostic

Downloads

17

Readme

Cloudist

Simple WAF (Web Application Firewall) middleware for Node.js. It blocks common attacks such as SQL injection, XSS, path traversal, and command injection, and adds a Cloudflare-style browser check for suspicious traffic. Zero dependencies, framework-agnostic.

Features

  • Blocks SQL injection, XSS, path traversal, and command injection payloads
  • Detects known bad bot user-agents and basic HTTP script libraries
  • Behavior scoring based on request headers, to catch bots that fake their user-agent
  • Rate limiting per IP
  • Connection flood and slowloris protection
  • Automatic "under attack" detection when traffic spikes
  • Optional automatic IP banning after repeated violations
  • Browser challenge page (interstitial) or an unobtrusive checkbox widget
  • Works with Express, Connect, or plain http.createServer

Installation

npm install cloudist

Quick start

With Express:

const express = require('express');
const cloudist = require('cloudist');

const app = express();

app.use(cloudist({
  secret: 'change-this-to-a-random-string',
  mode: 'block'
}));

app.get('/', (req, res) => {
  res.send('Hello world');
});

app.listen(3000);

With plain http:

const http = require('http');
const cloudist = require('cloudist');

const waf = cloudist({ secret: 'change-this-to-a-random-string' });

const server = http.createServer((req, res) => {
  waf(req, res, () => {
    res.end('Hello world');
  });
});

server.listen(3000);

Always set your own secret. The default value is only a placeholder and is not safe to use in production, since it is used to sign the verification token.

How it works

Every request goes through these checks, in order:

  1. Whitelist check — whitelisted IPs skip everything else.
  2. Ban check — if the IP was auto-banned, it gets rejected immediately.
  3. Connection flood check — too many simultaneous connections from one IP.
  4. Rate limit check — too many requests in the configured time window.
  5. Threat detection — the URL and request body are scanned for SQLi, XSS, path traversal, and command injection patterns.
  6. Behavior scoring — headers are analyzed to see how closely the request resembles a real browser.
  7. Bot/challenge handling — depending on mode and the behavior score, suspicious requests see a captcha page, a challenge page, a checkbox widget, or (if nothing is suspicious) are passed through to your app.

Modes

Cloudist supports three modes, set with the mode option:

  • block (default) — malicious requests are blocked with a 403 page. Requests that only look bot-like (not malicious) get a short browser challenge page.
  • challenge — every request must pass the browser challenge page first, then gets a cookie so it isn't challenged again for a while. The page waits out the delay and confirms with the server (with a signed, time-locked ticket) before the verified cookie is issued — a scraper reading the page source can't skip the wait.
  • checkbox — your page loads normally. A small checkbox widget is injected into the bottom of the HTML response. Clicking it shows a full-page overlay with a spinner, then a randomly generated code the visitor must type manually (pasting is blocked). The code is verified against a signed server-side proof, so it can't be bypassed by calling the verify endpoint directly. Actual attacks (SQLi, XSS, etc.) are still blocked in this mode regardless of verification status.

Captcha fallback

Independent of mode, any request whose behavior score drops below captchaThreshold (a much lower bar than behaviorThreshold) is treated as an obvious bot and gets a distorted-text image captcha instead of the lighter challenge/checkbox flow — waiting out a delay or clicking a checkbox doesn't help a script that scores this low.

The image is an inline SVG (no external image requests, nothing to self-host): each character gets independent rotation, vertical jitter, and size variance, plus background noise lines and dots, so it can't be lifted with a fixed-position crop. The answer is verified the same way as the checkbox code — a signed, time-limited, IP-bound proof embedded in the page, checked server-side with no session storage needed.

cloudist({
  captchaThreshold: 20,                     // behavior score below this triggers the captcha page instead of challenge/checkbox
  captchaVerifyPath: '/__cl-captcha-verify', // internal endpoint used by the captcha page
  captchaLength: 6                          // number of characters in the captcha image
})

Set captchaThreshold to 0 to disable the captcha fallback entirely (only challenge/checkbox/block will be used).

Configuration options

cloudist({
  secret: 'change-this-to-a-random-string', // used to sign challenge tokens
  mode: 'block',                            // 'block' | 'challenge' | 'checkbox'
  siteName: 'My Site',                      // shown on the challenge/block page
  theme: 'mono',                            // 'mono' | 'color'

  cookieName: 'cl_verify',
  cookieMaxAgeMs: 30 * 60 * 1000,           // how long a verified visitor stays verified
  challengeDelaySeconds: 4,
  challengeVerifyPath: '/__cl-challenge-verify', // internal endpoint used by the challenge page

  checkboxVerifyPath: '/__cl-verify',       // internal endpoint used by the checkbox widget
  checkboxSpinnerSeconds: 4,                // how long the spinner overlay shows before the code appears
  checkboxCodeLength: 6,                    // length of the manual-entry verification code

  whitelist: [],                            // array of IPs that skip all checks

  rateLimit: {
    windowMs: 60000,
    max: 100
  },

  maxConcurrentConnections: 50,             // per IP

  underAttack: {
    windowMs: 10000,
    requestThreshold: 200,
    cooldownMs: 60000
  },

  behaviorThreshold: 50,                    // score below this is treated as bot-like

  fingerprintCookieName: 'cl_fp',
  requireFingerprint: false,                // reject requests with a suspicious client fingerprint

  captchaThreshold: 20,                     // behavior score below this triggers a captcha page (0 disables it)
  captchaVerifyPath: '/__cl-captcha-verify',
  captchaLength: 6,

  autoban: {
    threshold: 5,                           // violations before a ban
    windowMs: 10 * 60 * 1000,
    banDurationMs: 60 * 60 * 1000,
    filePath: null,                         // optional path to persist bans to disk
    onBan: (ip, reason) => {}
  },

  onBlock: ({ ip, reason, req }) => {
    // called whenever a request gets blocked, for logging etc.
  }
})

All options are optional except secret, which you should always set explicitly in production.

Rate limiting

Pass a rateLimit object to enable it:

cloudist({
  rateLimit: { windowMs: 60000, max: 100 } // max 100 requests per IP per minute
});

Automatic IP banning

Disabled by default. Enable it with the autoban option:

cloudist({
  autoban: {
    threshold: 3,                   // ban after 3 violations
    windowMs: 10 * 60 * 1000,       // violations are counted within this window
    banDurationMs: 60 * 60 * 1000,  // ban lasts 1 hour
    onBan: (ip, reason) => {
      console.log(`Banned ${ip} for ${reason}`);
    }
  }
});

You can inspect or manage bans manually through the middleware's blacklist property:

const waf = cloudist({ autoban: { threshold: 3 } });

waf.blacklist.isBanned('1.2.3.4');
waf.blacklist.unban('1.2.3.4');

Whitelisting IPs

cloudist({
  whitelist: ['127.0.0.1', '10.0.0.5']
});

Whitelisted IPs skip every check, including threat detection.

Attaching to a raw server (connection flood and slowloris protection)

Connection-level protections (flood detection, slowloris) need access to the underlying server, not just each request. Attach them like this:

const http = require('http');
const cloudist = require('cloudist');

const waf = cloudist({ secret: 'change-this-to-a-random-string' });

const server = http.createServer((req, res) => {
  waf(req, res, () => res.end('ok'));
});

waf.attachToServer(server);
server.listen(3000);

Checking attack status programmatically

const waf = cloudist({ /* ... */ });

if (waf.isUnderAttack()) {
  console.log('Traffic spike detected');
}

Running the examples

The examples/ folder has a small Express demo for the checkbox mode:

npm install express
node examples/checkbox-server.js

Then open http://localhost:3000. See examples/README.md for details.

Running tests

npm test

License

MIT