Skip to content

Express Middleware

@webdecoy/express wraps the Node SDK as Express middleware: every request is analyzed, blocked requests get a 403 by default, and the detection result rides on req.webdecoy.

Terminal window
npm install @webdecoy/express @webdecoy/node
import express from 'express';
import { webdecoy } from '@webdecoy/express';
const app = express();
app.use(webdecoy({
threshold: 70,
skipPaths: ['/health', '/static'],
onBlocked: (req, res, detection) => {
res.status(403).json({ error: 'Blocked' });
}
}));
app.post('/api/login', (req, res) => {
const { decision, confidence, threat_level } = req.webdecoy;
if (decision === 'challenge') {
return res.status(429).json({ error: 'Please complete verification' });
}
// Process login...
});

Extends the core ProtectOptions (threshold, skipLocalAnalysis, metadata) with:

OptionDefaultDescription
getIPreq.ip / x-forwarded-forCustom IP extraction
onBlocked403 ForbiddenCustom handler for blocked requests
onErrorLog and allow (fail open)Custom error handler
skipPathsPaths to skip (health checks, static assets)
extractTLSfalseCapture JA3/JA4 TLS fingerprints from the socket
rulesLocal rules such as tripwire()

Tripwires run locally — no API key, no network call. And under session clearance, a tripwire hit from a tokened session feeds the clearance deny-list: the SDK forwards the session’s token with the violation, and the client gets the same durable, rotation-proof lockout as a hosted decoy hit.

import { webdecoy } from '@webdecoy/express';
import { tripwire, honeytoken } from '@webdecoy/node';
const trap = honeytoken();
app.use(webdecoy({
rules: [tripwire({ paths: [trap.path] })],
skipPaths: ['/health', '/static']
}));
// Inject the invisible link so scrapers find it
app.get('/', (req, res) => {
res.send('<!doctype html><html><body>' + trap.linkHtml + '</body></html>');
});

webdecoyCaptcha mounts the self-hosted captcha’s challenge and verify endpoints, which the Browser Client widget talks to:

import { webdecoyCaptcha } from '@webdecoy/express';
app.use(express.json());
app.use(webdecoyCaptcha({ secret: process.env.WEBDECOY_SECRET }));

  • Node SDK — the core API, configuration, and detection response
  • Browser Client — the widget for the captcha endpoints