@webdecoy/node 0.21.2 → 0.21.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,172 +1,226 @@
1
1
  # @webdecoy/node
2
2
 
3
- Core Web Decoy SDK for Node.js applications - Advanced bot detection with TLS fingerprinting.
3
+ The core WebDecoy SDK for Node.js and edge runtimes: tripwires, rate limits and other local rules, plus optional server-side bot detection reported to your WebDecoy dashboard.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@webdecoy/node.svg)](https://www.npmjs.com/package/@webdecoy/node)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
+ Full documentation: [docs.webdecoy.com/sdk-plugins/node-sdk](https://docs.webdecoy.com/sdk-plugins/node-sdk/). Copy-paste install snippets for every stack: [docs.webdecoy.com/installation/install-with-ai](https://docs.webdecoy.com/installation/install-with-ai/).
9
+
10
+ ## Using a framework? Install its adapter
11
+
12
+ Most apps should install a framework adapter alongside this package. The adapters handle request mapping, client IP, monitor mode and honeytoken injection for you. Install `@webdecoy/node` too: it is where `tripwire()`, `rateLimit()` and the other rules are imported from.
13
+
14
+ | Framework | Install |
15
+ |---|---|
16
+ | Express | `npm install @webdecoy/express @webdecoy/node` ([README](https://www.npmjs.com/package/@webdecoy/express)) |
17
+ | Fastify | `npm install @webdecoy/fastify @webdecoy/node` ([README](https://www.npmjs.com/package/@webdecoy/fastify)) |
18
+ | Next.js | `npm install @webdecoy/nextjs @webdecoy/node` ([README](https://www.npmjs.com/package/@webdecoy/nextjs)) |
19
+ | Hono (Workers, Bun, Deno, Node) | `npm install @webdecoy/hono @webdecoy/node` ([README](https://www.npmjs.com/package/@webdecoy/hono)) |
20
+ | Any other server or fetch runtime | `npm install @webdecoy/node` (this page) |
21
+
8
22
  ## Installation
9
23
 
10
24
  ```bash
11
25
  npm install @webdecoy/node
12
- # or
13
- yarn add @webdecoy/node
14
26
  ```
15
27
 
16
- ## Quick Start
28
+ ## Quick start
17
29
 
18
- ```typescript
30
+ ```js
31
+ import http from 'node:http';
19
32
  import { WebDecoy } from '@webdecoy/node';
20
33
 
21
- const webdecoy = new WebDecoy({
22
- apiKey: process.env.WEBDECOY_API_KEY,
23
- });
34
+ const wd = new WebDecoy({ apiKey: process.env.WEBDECOY_API_KEY });
35
+
36
+ http.createServer(async (req, res) => {
37
+ const decision = await wd.protect({
38
+ method: req.method,
39
+ path: new URL(req.url, 'http://localhost').pathname,
40
+ ip: req.socket.remoteAddress ?? '',
41
+ user_agent: req.headers['user-agent'],
42
+ headers: Object.fromEntries(
43
+ Object.entries(req.headers).map(([name, value]) => [name, String(value)])
44
+ ),
45
+ timestamp: Date.now(),
46
+ });
47
+
48
+ // protect() returns a decision and blocks nothing itself.
49
+ // Log decision.conclusion ('ALLOW', 'DENY', 'CHALLENGE' or 'ERROR') first;
50
+ // refuse with a 403 when decision.allowed is false only once you are ready.
51
+ res.end('ok');
52
+ }).listen(3000);
53
+ ```
24
54
 
25
- const result = await webdecoy.protect({
26
- method: 'GET',
27
- path: '/api/data',
28
- ip: '203.0.113.42',
29
- user_agent: req.headers['user-agent'],
30
- headers: req.headers,
31
- timestamp: Date.now(),
32
- });
55
+ Behind a proxy, `req.socket.remoteAddress` is the proxy. Use `resolveClientIp()` from this package to read the real client address (see [Client IP behind a proxy](#client-ip-behind-a-proxy)).
56
+
57
+ ### The API key is optional
58
+
59
+ `apiKey` is optional. Without it the SDK runs **local rules only** (tripwires by default, plus any rules you add), makes no network calls, and reports nothing to the dashboard. With it, the SDK also sends suspicious requests for server-side detection and reports rule hits to your dashboard.
60
+
61
+ The SDK does **not** read `WEBDECOY_API_KEY` from the environment by itself. Pass it as `apiKey`, as above.
62
+
63
+ To get a key: sign up at [app.webdecoy.com](https://app.webdecoy.com), add your site, then create a key on the **API Keys** page. Keys start with `sk_live_` (production) or `sk_test_` (testing); any other prefix throws when the SDK is constructed. Keep the key on the server and out of committed files.
33
64
 
34
- if (!result.allowed) {
35
- // Block the request
36
- return res.status(403).json({ error: 'Access denied' });
37
- }
65
+ ### Monitor first
66
+
67
+ `protect()` only returns a decision. It never writes a response, so nothing is blocked until your code acts on `decision.allowed`. The framework adapters and `createFetchGuard()` follow the same rule: they start in **monitor mode** (`mode: 'monitor'`), record the decision and serve every request. Set `mode: 'enforce'` only after you have reviewed what would have been blocked.
68
+
69
+ ## The decision
70
+
71
+ `protect(metadata, options?)` returns a `Decision`:
72
+
73
+ ```ts
74
+ const decision = await wd.protect(metadata);
75
+
76
+ decision.conclusion // 'ALLOW' | 'DENY' | 'CHALLENGE' | 'ERROR'
77
+ decision.allowed // true for ALLOW and ERROR (fails open), false for DENY and CHALLENGE
78
+ decision.id // 'dec_...'
79
+ decision.isDenied() // also isAllowed(), isChallenged(), isErrored()
80
+ decision.deniedBy('tripwire') // whether a named rule denied the request
81
+ decision.results // every configured rule, its state and its conclusion
82
+ decision.reason // the deciding reason, when there is one
83
+ decision.detection // { decision, confidence, threat_level, bot_detected, bot_type?, detection_id, rule_enforced }
84
+ decision.error // set when conclusion is 'ERROR'
85
+ decision.edge // what a WebDecoy edge validator said about this request, if one fronted it
38
86
  ```
39
87
 
40
- ## Configuration Options
88
+ Each entry in `results` has a `state`:
41
89
 
42
- ```typescript
43
- const webdecoy = new WebDecoy({
44
- // Required: Your API key from the dashboard
45
- apiKey: 'sk_live_xxxxx',
90
+ | `state` | Meaning |
91
+ |---|---|
92
+ | `RUN` | Evaluated, and its conclusion counts. |
93
+ | `DRY_RUN` | Evaluated; the conclusion is recorded but not enforced. |
94
+ | `NOT_RUN` | Could not evaluate because a signal it needs was absent (for example a `filter()` rule with no IP enrichment). |
95
+ | `CACHED` | Not evaluated; a prior decision for this key was reused. |
46
96
 
47
- // Optional: API endpoint (defaults to production)
48
- apiUrl: 'https://in.webdecoy.com',
97
+ `ERROR` is not a denial. It means no verdict was reached (for example WebDecoy could not be reached, or the request had no IP), and `allowed` is `true`.
49
98
 
50
- // Optional: Enable TLS fingerprinting (default: true)
51
- enableTLSFingerprinting: true,
99
+ `ProtectResult` is the exported interface type for this decision.
52
100
 
53
- // Optional: Threat score threshold for blocking (default: 80)
54
- threatScoreThreshold: 70,
101
+ ## Local rules
55
102
 
56
- // Optional: Request timeout in milliseconds (default: 5000)
57
- timeout: 5000,
103
+ Rules run in-process, in order, before any server call. The first `DENY` or `THROTTLE` decides. When you pass no `rules`, the SDK arms `tripwire()` with its built-in scanner-bait paths; pass `rules: []` to opt out.
58
104
 
59
- // Optional: Enable debug logging (default: false)
60
- debug: false,
105
+ ```ts
106
+ import { WebDecoy, tripwire, rateLimit, filter } from '@webdecoy/node';
61
107
 
62
- // Optional: Reject unauthorized TLS certificates (default: true)
63
- tlsRejectUnauthorized: true,
108
+ const wd = new WebDecoy({
109
+ rules: [
110
+ tripwire({ paths: ['/admin-backup.zip'] }), // plus built-in paths such as /.env
111
+ rateLimit({ max: 100, window: 60 }), // 100 requests per 60 s per IP
112
+ filter({ expression: 'ip.tor or ip.vpn' }), // needs an apiKey (IP enrichment)
113
+ ],
64
114
  });
65
115
  ```
66
116
 
67
- ## API Reference
117
+ | Rule | What it does | Needs an API key? |
118
+ |---|---|---|
119
+ | `tripwire({ paths?, prefixes?, patterns?, includeDefaults?, action?, dryRun? })` | Matches requests for decoy and scanner-bait paths. | No |
120
+ | `honeytoken()` | Returns `{ path, linkHtml }`: a hidden decoy link and the path to arm with `tripwire({ paths: [path] })`. | No |
121
+ | `rateLimit({ max, window, algorithm?, keyBy?, store?, action?, dryRun? })` | Fixed or sliding window, keyed by IP by default. In-memory unless you pass a shared `store` (for example `upstashRateLimitStore()`). | No |
122
+ | `attackSignatures({ inspect?, exclude?, action?, dryRun? })` | Denies requests carrying unambiguous injection payloads. | No |
123
+ | `webBotAuth()` | Verifies Web Bot Auth (RFC 9421) agent signatures and denies impersonators of known agents. | No |
124
+ | `botPolicy({ deny, allow })` | One crawler policy that produces both your `robots.txt` and the rule that enforces it. | No |
125
+ | `filter({ expression, action?, dryRun? })` | Expressions over IP reputation and geo, such as `ip.tor` or `ip.country in ["CN", "RU"]`. | Yes |
68
126
 
69
- ### `WebDecoy`
127
+ A tripwire match is evidence, not proof of intent: link prefetchers, preview bots and your own security scanners can request a hidden or scanner-bait path. Use `dryRun: true` on a rule to observe it before enforcing.
70
128
 
71
- Main SDK class for bot detection.
129
+ ## Fetch runtimes (Bun, Deno, Workers, Astro, SvelteKit, Remix)
72
130
 
73
- #### `protect(metadata: RequestMetadata, options?: ProtectOptions): Promise<ProtectResult>`
131
+ `createFetchGuard()` wraps the SDK for any runtime that hands you a WHATWG `Request`. It is the same implementation `@webdecoy/hono` uses.
74
132
 
75
- Analyze and protect a request.
133
+ ```ts
134
+ import { createFetchGuard } from '@webdecoy/node';
76
135
 
77
- ```typescript
78
- const result = await webdecoy.protect({
79
- method: 'GET',
80
- path: '/api/data',
81
- ip: '203.0.113.42',
82
- user_agent: 'Mozilla/5.0...',
83
- headers: { /* request headers */ },
84
- timestamp: Date.now(),
85
- });
136
+ const guard = createFetchGuard({ apiKey: process.env.WEBDECOY_API_KEY });
137
+
138
+ export default {
139
+ async fetch(request: Request): Promise<Response> {
140
+ const { response } = await guard.check(request);
141
+ if (response) return response; // only ever set in enforce mode
142
+ return guard.decorate(await handle(request)); // handle() is your app
143
+ },
144
+ };
86
145
  ```
87
146
 
88
- **Returns:**
89
- ```typescript
90
- interface ProtectResult {
91
- allowed: boolean;
92
- detection: {
93
- decision: 'allow' | 'block' | 'challenge';
94
- confidence: number; // 0-100 threat score
95
- threat_level: 'MINIMAL' | 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
96
- bot_detected: boolean;
97
- bot_type?: string;
98
- detection_id: string;
99
- rule_enforced: boolean;
100
- };
101
- error?: string;
102
- }
147
+ Options: everything in [Configuration](#configuration), plus `mode` (default `'monitor'`), `skipPaths`, `trustProxy` (default `1`), `getIP`, `honeytoken` (default on when an `apiKey` is set; injects a hidden trap link into HTML through `decorate()`) and `onBlocked`.
148
+
149
+ ## Clearance enforcement on Vercel
150
+
151
+ With a WebDecoy account, the paths you protect can require a clearance token, checked in Vercel Routing Middleware before the page renders. It follows the site's mode in WebDecoy (monitor until you switch it) and fails open.
152
+
153
+ ```ts
154
+ // middleware.ts (Astro, SvelteKit, Nuxt, Remix or a static site)
155
+ export { default } from '@webdecoy/node/vercel';
103
156
  ```
104
157
 
105
- #### `validateConfig(): Promise<{ valid: boolean; error?: string }>`
158
+ Next.js sites use `withClearance()` from `@webdecoy/nextjs` instead. Set `WEBDECOY_SITE_KEY`, `WEBDECOY_SCANNER_ID` and `WEBDECOY_SENSOR_KEY` (a secret) from **Enforcement, Setup** in the dashboard. Guide: [Vercel middleware](https://docs.webdecoy.com/installation/vercel-middleware/).
106
159
 
107
- Validate your API key and configuration.
160
+ ## Environment variables
108
161
 
109
- #### `getConfig(): Readonly<Required<WebDecoyConfig>>`
162
+ The SDK reads only these, and only in the features named:
110
163
 
111
- Get the current configuration.
164
+ | Variable | Read by |
165
+ |---|---|
166
+ | `WEBDECOY_SITE_KEY`, `WEBDECOY_SCANNER_ID`, `WEBDECOY_SENSOR_KEY` | The clearance gate (`@webdecoy/node/vercel`, `createClearanceGate()`), when the matching option is not passed. |
167
+ | `WEBDECOY_INGEST` | The clearance gate, to override its ingest endpoint. Optional. |
168
+ | `NODE_ENV` | The self-hosted captcha: with `production`, a missing or default `secret` throws. |
112
169
 
113
- ## Types
170
+ `WEBDECOY_API_KEY` is a naming convention used in these docs, not something the SDK reads.
114
171
 
115
- All TypeScript types are exported:
172
+ ## Configuration
116
173
 
117
- ```typescript
118
- import type {
119
- WebDecoyConfig,
120
- RequestMetadata,
121
- SDKDetectionResponse,
122
- ProtectResult,
123
- ProtectOptions,
124
- TLSInfo,
125
- LocalAnalysis,
126
- SDKDetectionRequest,
127
- } from '@webdecoy/node';
174
+ ```ts
175
+ const wd = new WebDecoy({
176
+ apiKey: process.env.WEBDECOY_API_KEY, // optional; without it, local rules only
177
+ rules: [tripwire()], // optional; default [tripwire()], [] to opt out
178
+ apiUrl: 'https://in.webdecoy.com', // optional (default shown)
179
+ threatScoreThreshold: 80, // optional, 0-100 (default 80)
180
+ timeout: 5000, // optional, ms (default 5000)
181
+ enableTLSFingerprinting: true, // optional (default true)
182
+ tlsRejectUnauthorized: true, // optional (default true)
183
+ countAIReferrals: true, // optional (default true; aggregate counts, only with an apiKey)
184
+ debug: false, // optional (default false)
185
+ });
128
186
  ```
129
187
 
130
- ## Self-Hosted Captcha & Detection Engine
188
+ Also accepted: `characteristics` (what identifies the same caller for rate limits and caching; default the client IP), `decisionCache`, `webBotAuth`, `logger` (any object with `debug`/`info`/`warn`/`error`; `fromPino()` adapts pino) and `tracer` (an OpenTelemetry tracer).
131
189
 
132
- In addition to the API-backed `protect()` flow above, the SDK ships a fully
133
- **in-process** bot-detection engine and captcha — no remote call required. It
134
- scores ~40 behavioral, environmental, and fingerprint signals collected by the
135
- [`@webdecoy/client`](https://www.npmjs.com/package/@webdecoy/client) browser
136
- widget, verifies a SHA-256 proof-of-work, and issues a signed session token.
190
+ `protect()` also takes per-request options: `threshold`, `skipLocalAnalysis` and `metadata`.
137
191
 
138
- ```
139
- Browser (@webdecoy/client) Your server (@webdecoy/node)
140
- collect signals + solve PoW ──▶ Captcha.verify()
141
- ├─ verify proof-of-work
142
- ├─ score signals (in-process engine)
143
- └─ issue session token on success
192
+ Without an API key no request leaves your server. With one, a request goes to WebDecoy only when local analysis flags it as needing verification (or carries TLS details); that call is awaited, bounded by `timeout`, and fails open on error.
193
+
194
+ ## Client IP behind a proxy
195
+
196
+ Rate limits and detections are keyed on the client address. `X-Forwarded-For` is partly written by the client, so read it only as far as your own infrastructure wrote it:
197
+
198
+ ```ts
199
+ import { resolveClientIp } from '@webdecoy/node';
200
+
201
+ const ip = resolveClientIp({
202
+ headers: req.headers,
203
+ peer: req.socket.remoteAddress,
204
+ trustProxy: 1, // proxies in front of this app; or 'cloudflare', 'railway', or your proxies' CIDRs
205
+ });
144
206
  ```
145
207
 
146
- ### Mounting the endpoints
208
+ `trustProxy` defaults to `false` here (believe no forwarding header). The adapters accept the same option.
147
209
 
148
- Use your framework adapter (or `createCaptchaEndpoints` directly). The handler
149
- serves `GET /__webdecoy/challenge`, `POST /__webdecoy/verify`, `POST
150
- /__webdecoy/score`, and `POST /__webdecoy/token/verify`.
210
+ ## Self-hosted captcha and detection engine
151
211
 
152
- ```typescript
212
+ The SDK also ships an in-process captcha: it scores behavioral, environmental and fingerprint signals collected by [`@webdecoy/client`](https://www.npmjs.com/package/@webdecoy/client), verifies a SHA-256 proof of work, and issues a signed session token. No remote call is needed.
213
+
214
+ Mount the endpoints with your adapter (`webdecoyCaptcha` in Express, `webdecoyCaptchaPlugin` in Fastify, `createCaptchaHandler` in Next.js) or with `createCaptchaEndpoints()`. They serve `GET /__webdecoy/challenge`, `POST /__webdecoy/verify`, `POST /__webdecoy/score` and `POST /__webdecoy/token/verify`.
215
+
216
+ ```ts
153
217
  import express from 'express';
154
218
  import { webdecoyCaptcha } from '@webdecoy/express';
219
+ import { Captcha } from '@webdecoy/node';
155
220
 
156
221
  const app = express();
157
222
  app.use(express.json());
158
-
159
- app.use(
160
- webdecoyCaptcha({
161
- secret: process.env.WEBDECOY_SECRET, // required in production
162
- }),
163
- );
164
- ```
165
-
166
- Then verify the token your form receives on a protected route:
167
-
168
- ```typescript
169
- import { Captcha } from '@webdecoy/node';
223
+ app.use(webdecoyCaptcha({ secret: process.env.WEBDECOY_SECRET })); // required in production
170
224
 
171
225
  const captcha = new Captcha({ secret: process.env.WEBDECOY_SECRET });
172
226
 
@@ -177,61 +231,35 @@ app.post('/login', async (req, res) => {
177
231
  });
178
232
  ```
179
233
 
180
- ### Using the engine directly
234
+ `WEBDECOY_SECRET` is just the variable name used here; pass the value as `secret`. Generate one with `openssl rand -hex 32`. Challenge and token stores are in memory by default; for serverless or multi-instance deployments, pass shared `challengeStore` and `tokenStore` implementations.
181
235
 
182
- For full control, score raw signals yourself:
236
+ To score signals yourself, use `new DetectionEngine(options).score(signals, context)`.
183
237
 
184
- ```typescript
185
- import { DetectionEngine } from '@webdecoy/node';
238
+ ## Testing your rules
186
239
 
187
- const engine = new DetectionEngine({ requirePoW: false });
188
- const verdict = engine.score(signals, {
189
- ip,
190
- siteKey: 'site',
191
- userAgent,
192
- headers,
193
- });
194
- // verdict: { success, score, recommendation: 'allow'|'challenge'|'block', categoryScores, detections }
195
- ```
240
+ ```ts
241
+ import { createTestHarness, get, expectDenied, expectAllowed } from '@webdecoy/node/testing';
242
+ import { tripwire } from '@webdecoy/node';
196
243
 
197
- > **Note on the scoring model:** the verdict is a confidence-weighted blend
198
- > across categories, so no single signal can cross the block threshold alone —
199
- > a missing proof-of-work on an otherwise-clean request yields `challenge`, not
200
- > `block`. Tune category weights via the `weights` option.
244
+ const wd = createTestHarness({ rules: [tripwire()] });
201
245
 
202
- ### Security & deployment notes
246
+ test('a scanner is denied and a visitor is not', async () => {
247
+ expectDenied(await wd.protect(get('/.env')), { rule: 'tripwire' });
248
+ expectAllowed(await wd.protect(get('/')));
249
+ });
250
+ ```
203
251
 
204
- - **`secret`** signs challenges and tokens. It is **required in production**
205
- (`NODE_ENV=production`); a missing or default secret throws. Generate one with
206
- `openssl rand -hex 32`.
207
- - Challenge/token/fingerprint stores are **in-memory** by default. For
208
- serverless or multi-instance deployments, supply a shared store via the
209
- `challengeStore` / `tokenStore` options (the `ChallengeStore` / `TokenStore`
210
- interfaces are the seam for Redis).
211
- - IP reputation (VPN/proxy/Tor, abuse score, geo) is still served by
212
- `api.webdecoy.com` via the SDK's IP-enrichment client.
252
+ The harness is offline by default: it drops any `apiKey` unless you pass `allowNetwork: true`.
213
253
 
214
- ## Framework Integrations
254
+ ## Verify the install
215
255
 
216
- For Express.js, use the dedicated middleware package:
256
+ With an `apiKey` configured, send one request with the reserved test User-Agent:
217
257
 
218
258
  ```bash
219
- npm install @webdecoy/express
259
+ curl -A "WebDecoy-Test/1.0" http://localhost:3000/
220
260
  ```
221
261
 
222
- See [@webdecoy/express](https://www.npmjs.com/package/@webdecoy/express) for details.
223
-
224
- ## Getting an API Key
225
-
226
- 1. Sign up at [app.webdecoy.com](https://app.webdecoy.com)
227
- 2. Create a new organization and property
228
- 3. Generate an API key in Settings
229
-
230
- API keys start with `sk_live_` for production or `sk_test_` for testing.
231
-
232
- ## Documentation
233
-
234
- For full documentation, visit the [GitHub repository](https://github.com/WebDecoy/node).
262
+ A detection labeled **Test** appears on the **Detections** page within a few seconds. Without an `apiKey` nothing is reported; the decision's `error` says so. See [Verify your install](https://docs.webdecoy.com/getting-started/verify-installation/).
235
263
 
236
264
  ## License
237
265
 
@@ -3160,7 +3160,7 @@ function endSpan(span) {
3160
3160
 
3161
3161
  // src/sdk.ts
3162
3162
  var WebDecoy = class {
3163
- constructor(config) {
3163
+ constructor(config = {}) {
3164
3164
  this.referralCounter = null;
3165
3165
  this.violationReporter = null;
3166
3166
  this.ipEnrichmentClient = null;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Rule, a as RuleContext, b as RuleResult, c as RuleEngineResult, d as RateLimitConfig, F as FilterConfig, T as TripwireConfig, B as BotRuleConfig, e as BotAgent, f as BotCategory, A as AgentCategory, g as RateLimitStore, h as RateLimitConsume, i as RateLimitOutcome, W as WebDecoy, P as ProtectResult, D as Decision, j as WebDecoyConfig, k as ProtectOptions, l as AgentVerifierOptions, m as AgentRequestInput, n as AgentVerdict, S as SignedAgentDirectory } from './sdk-FCU-Ce-1.mjs';
2
- export { o as AgentStatus, p as BOT_CATEGORIES, q as BOT_REGISTRY, r as BotVerdict, C as Characteristic, s as Conclusion, t as DEFAULT_CHARACTERISTICS, u as DecisionCache, v as DecisionCacheOptions, w as DecisionInit, E as EDGE_CLASS_HEADER, x as EDGE_CLEARANCE_HEADER, y as EdgeClass, z as EdgeVerdict, I as IPEnrichmentData, L as LocalAnalysis, G as LogFields, H as Logger, M as MemoryRateLimitStore, J as RequestMetadata, K as RuleOutcome, N as RuleState, O as SDKDetectionRequest, Q as SDKDetectionResponse, U as Span, V as SyncRateLimitStore, X as TLSInfo, Y as Tracer, Z as ViolationEvent, _ as classifyUserAgent, $ as consoleLogger, a0 as deriveKey, a1 as fromPino, a2 as matchUserAgent, a3 as newDecisionId, a4 as readEdgeVerdict, a5 as silentLogger } from './sdk-FCU-Ce-1.mjs';
1
+ import { R as Rule, a as RuleContext, b as RuleResult, c as RuleEngineResult, d as RateLimitConfig, F as FilterConfig, T as TripwireConfig, B as BotRuleConfig, e as BotAgent, f as BotCategory, A as AgentCategory, g as RateLimitStore, h as RateLimitConsume, i as RateLimitOutcome, W as WebDecoy, P as ProtectResult, D as Decision, j as WebDecoyConfig, k as ProtectOptions, l as AgentVerifierOptions, m as AgentRequestInput, n as AgentVerdict, S as SignedAgentDirectory } from './sdk-C-gaFOT_.mjs';
2
+ export { o as AgentStatus, p as BOT_CATEGORIES, q as BOT_REGISTRY, r as BotVerdict, C as Characteristic, s as Conclusion, t as DEFAULT_CHARACTERISTICS, u as DecisionCache, v as DecisionCacheOptions, w as DecisionInit, E as EDGE_CLASS_HEADER, x as EDGE_CLEARANCE_HEADER, y as EdgeClass, z as EdgeVerdict, I as IPEnrichmentData, L as LocalAnalysis, G as LogFields, H as Logger, M as MemoryRateLimitStore, J as RequestMetadata, K as RuleOutcome, N as RuleState, O as SDKDetectionRequest, Q as SDKDetectionResponse, U as Span, V as SyncRateLimitStore, X as TLSInfo, Y as Tracer, Z as ViolationEvent, _ as classifyUserAgent, $ as consoleLogger, a0 as deriveKey, a1 as fromPino, a2 as matchUserAgent, a3 as newDecisionId, a4 as readEdgeVerdict, a5 as silentLogger } from './sdk-C-gaFOT_.mjs';
3
3
  import { T as TrustedProxies } from './index-GXXXr_mb.mjs';
4
4
  export { B as CLEARANCE_GATE_BUILD, C as ClearanceContext, a as ClearanceGateOptions, G as GateEnv, b as GateOutcome, H as HeaderSource, R as ResolveClientIpOptions, c as createClearanceGate, i as ipInCidr, n as normalizeIp, r as resolveClientIp, d as resolveGateEnv } from './index-GXXXr_mb.mjs';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Rule, a as RuleContext, b as RuleResult, c as RuleEngineResult, d as RateLimitConfig, F as FilterConfig, T as TripwireConfig, B as BotRuleConfig, e as BotAgent, f as BotCategory, A as AgentCategory, g as RateLimitStore, h as RateLimitConsume, i as RateLimitOutcome, W as WebDecoy, P as ProtectResult, D as Decision, j as WebDecoyConfig, k as ProtectOptions, l as AgentVerifierOptions, m as AgentRequestInput, n as AgentVerdict, S as SignedAgentDirectory } from './sdk-FCU-Ce-1.js';
2
- export { o as AgentStatus, p as BOT_CATEGORIES, q as BOT_REGISTRY, r as BotVerdict, C as Characteristic, s as Conclusion, t as DEFAULT_CHARACTERISTICS, u as DecisionCache, v as DecisionCacheOptions, w as DecisionInit, E as EDGE_CLASS_HEADER, x as EDGE_CLEARANCE_HEADER, y as EdgeClass, z as EdgeVerdict, I as IPEnrichmentData, L as LocalAnalysis, G as LogFields, H as Logger, M as MemoryRateLimitStore, J as RequestMetadata, K as RuleOutcome, N as RuleState, O as SDKDetectionRequest, Q as SDKDetectionResponse, U as Span, V as SyncRateLimitStore, X as TLSInfo, Y as Tracer, Z as ViolationEvent, _ as classifyUserAgent, $ as consoleLogger, a0 as deriveKey, a1 as fromPino, a2 as matchUserAgent, a3 as newDecisionId, a4 as readEdgeVerdict, a5 as silentLogger } from './sdk-FCU-Ce-1.js';
1
+ import { R as Rule, a as RuleContext, b as RuleResult, c as RuleEngineResult, d as RateLimitConfig, F as FilterConfig, T as TripwireConfig, B as BotRuleConfig, e as BotAgent, f as BotCategory, A as AgentCategory, g as RateLimitStore, h as RateLimitConsume, i as RateLimitOutcome, W as WebDecoy, P as ProtectResult, D as Decision, j as WebDecoyConfig, k as ProtectOptions, l as AgentVerifierOptions, m as AgentRequestInput, n as AgentVerdict, S as SignedAgentDirectory } from './sdk-C-gaFOT_.js';
2
+ export { o as AgentStatus, p as BOT_CATEGORIES, q as BOT_REGISTRY, r as BotVerdict, C as Characteristic, s as Conclusion, t as DEFAULT_CHARACTERISTICS, u as DecisionCache, v as DecisionCacheOptions, w as DecisionInit, E as EDGE_CLASS_HEADER, x as EDGE_CLEARANCE_HEADER, y as EdgeClass, z as EdgeVerdict, I as IPEnrichmentData, L as LocalAnalysis, G as LogFields, H as Logger, M as MemoryRateLimitStore, J as RequestMetadata, K as RuleOutcome, N as RuleState, O as SDKDetectionRequest, Q as SDKDetectionResponse, U as Span, V as SyncRateLimitStore, X as TLSInfo, Y as Tracer, Z as ViolationEvent, _ as classifyUserAgent, $ as consoleLogger, a0 as deriveKey, a1 as fromPino, a2 as matchUserAgent, a3 as newDecisionId, a4 as readEdgeVerdict, a5 as silentLogger } from './sdk-C-gaFOT_.js';
3
3
  import { T as TrustedProxies } from './index-GXXXr_mb.js';
4
4
  export { B as CLEARANCE_GATE_BUILD, C as ClearanceContext, a as ClearanceGateOptions, G as GateEnv, b as GateOutcome, H as HeaderSource, R as ResolveClientIpOptions, c as createClearanceGate, i as ipInCidr, n as normalizeIp, r as resolveClientIp, d as resolveGateEnv } from './index-GXXXr_mb.js';
5
5
 
package/dist/index.js CHANGED
@@ -3267,7 +3267,7 @@ function isTestTriggerUserAgent(userAgent) {
3267
3267
 
3268
3268
  // src/sdk.ts
3269
3269
  var WebDecoy = class {
3270
- constructor(config) {
3270
+ constructor(config = {}) {
3271
3271
  this.referralCounter = null;
3272
3272
  this.violationReporter = null;
3273
3273
  this.ipEnrichmentClient = null;
package/dist/index.mjs CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  tripwire,
55
55
  upstashRateLimitStore,
56
56
  webBotAuth
57
- } from "./chunk-HSG6RWOQ.mjs";
57
+ } from "./chunk-7SOUHH7Z.mjs";
58
58
  import {
59
59
  createClearanceGate,
60
60
  ipInCidr,
@@ -1348,7 +1348,7 @@ declare class WebDecoy {
1348
1348
  /** Optional OpenTelemetry tracer. Absent means no spans and no cost. */
1349
1349
  private readonly tracer?;
1350
1350
  private readonly decisionCache;
1351
- constructor(config: WebDecoyConfig);
1351
+ constructor(config?: WebDecoyConfig);
1352
1352
  /**
1353
1353
  * Evaluate rules against request metadata (synchronous).
1354
1354
  * Returns null if no rules are configured.
@@ -1348,7 +1348,7 @@ declare class WebDecoy {
1348
1348
  /** Optional OpenTelemetry tracer. Absent means no spans and no cost. */
1349
1349
  private readonly tracer?;
1350
1350
  private readonly decisionCache;
1351
- constructor(config: WebDecoyConfig);
1351
+ constructor(config?: WebDecoyConfig);
1352
1352
  /**
1353
1353
  * Evaluate rules against request metadata (synchronous).
1354
1354
  * Returns null if no rules are configured.
@@ -1,4 +1,4 @@
1
- import { j as WebDecoyConfig, J as RequestMetadata, W as WebDecoy, P as ProtectResult, N as RuleState } from './sdk-FCU-Ce-1.mjs';
1
+ import { j as WebDecoyConfig, J as RequestMetadata, W as WebDecoy, P as ProtectResult, N as RuleState } from './sdk-C-gaFOT_.mjs';
2
2
 
3
3
  /**
4
4
  * Testing utilities, for the application's test suite rather than ours.
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { j as WebDecoyConfig, J as RequestMetadata, W as WebDecoy, P as ProtectResult, N as RuleState } from './sdk-FCU-Ce-1.js';
1
+ import { j as WebDecoyConfig, J as RequestMetadata, W as WebDecoy, P as ProtectResult, N as RuleState } from './sdk-C-gaFOT_.js';
2
2
 
3
3
  /**
4
4
  * Testing utilities, for the application's test suite rather than ours.
package/dist/testing.js CHANGED
@@ -2007,7 +2007,7 @@ function isTestTriggerUserAgent(userAgent) {
2007
2007
 
2008
2008
  // src/sdk.ts
2009
2009
  var WebDecoy = class {
2010
- constructor(config) {
2010
+ constructor(config = {}) {
2011
2011
  this.referralCounter = null;
2012
2012
  this.violationReporter = null;
2013
2013
  this.ipEnrichmentClient = null;
package/dist/testing.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  WebDecoy,
3
3
  silentLogger
4
- } from "./chunk-HSG6RWOQ.mjs";
4
+ } from "./chunk-7SOUHH7Z.mjs";
5
5
 
6
6
  // src/testing.ts
7
7
  function request(over = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webdecoy/node",
3
- "version": "0.21.2",
3
+ "version": "0.21.3",
4
4
  "description": "Web Decoy SDK for Node.js - Bot detection with TLS fingerprinting",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",