@webdecoy/node 0.13.0 → 0.14.0

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
@@ -45,7 +45,7 @@ const webdecoy = new WebDecoy({
45
45
  apiKey: 'sk_live_xxxxx',
46
46
 
47
47
  // Optional: API endpoint (defaults to production)
48
- apiUrl: 'https://ingest.webdecoy.com',
48
+ apiUrl: 'https://in.webdecoy.com',
49
49
 
50
50
  // Optional: Enable TLS fingerprinting (default: true)
51
51
  enableTLSFingerprinting: true,
@@ -863,6 +863,7 @@ var BOT_CATEGORIES = [
863
863
  "none"
864
864
  ];
865
865
  var BOT_REGISTRY = [
866
+ { id: "reflectionbot", name: "Reflectionbot", category: "training_crawler", organization: "Reflection AI", baseScore: 70, respectsRobots: true, uaPatterns: ["reflectionbot"] },
866
867
  { id: "gptbot", name: "GPTBot", category: "training_crawler", organization: "OpenAI", baseScore: 85, respectsRobots: true, uaPatterns: ["gptbot"] },
867
868
  { id: "chatgpt-user", name: "ChatGPT-User", category: "training_crawler", organization: "OpenAI", baseScore: 85, respectsRobots: true, uaPatterns: ["chatgpt-user", "chatgpt"] },
868
869
  { id: "oai-searchbot", name: "OAI-SearchBot", category: "training_crawler", organization: "OpenAI", baseScore: 80, respectsRobots: true, uaPatterns: ["oai-searchbot"] },
@@ -891,6 +892,10 @@ var BOT_REGISTRY = [
891
892
  { id: "velenpublicwebcrawler", name: "VelenPublicWebCrawler", category: "training_crawler", organization: "Velen", baseScore: 70, respectsRobots: false, uaPatterns: ["velenpublicwebcrawler"] },
892
893
  { id: "isscyberriskcrawler", name: "ISSCyberRiskCrawler", category: "training_crawler", organization: "ISS", baseScore: 65, respectsRobots: false, uaPatterns: ["isscyberriskcrawler"] },
893
894
  { id: "friendlycrawler", name: "FriendlyCrawler", category: "training_crawler", organization: "Unknown", baseScore: 65, respectsRobots: true, uaPatterns: ["friendlycrawler"] },
895
+ { id: "duckassistbot", name: "DuckAssistBot", category: "ai_search_crawler", organization: "DuckDuckGo", baseScore: 65, respectsRobots: true, uaPatterns: ["duckassistbot"] },
896
+ { id: "sofyabot", name: "SofyaBot", category: "ai_search_crawler", organization: "Sofya", baseScore: 65, respectsRobots: true, uaPatterns: ["sofyabot"] },
897
+ { id: "xai-searchbot", name: "xAI-SearchBot", category: "ai_search_crawler", organization: "xAI", baseScore: 70, respectsRobots: true, uaPatterns: ["xai-searchbot"] },
898
+ { id: "linkupbot", name: "LinkupBot", category: "ai_search_crawler", organization: "Linkup", baseScore: 65, respectsRobots: true, uaPatterns: ["linkupbot"] },
894
899
  { id: "searchgpt", name: "SearchGPT", category: "ai_search_crawler", organization: "OpenAI", baseScore: 75, respectsRobots: true, uaPatterns: ["searchgpt"] },
895
900
  { id: "phind", name: "Phind", category: "ai_search_crawler", organization: "Phind", baseScore: 70, respectsRobots: true, uaPatterns: ["phind"] },
896
901
  { id: "kagi", name: "Kagi", category: "ai_search_crawler", organization: "Kagi", baseScore: 65, respectsRobots: true, uaPatterns: ["kagi"] },
@@ -907,6 +912,7 @@ var BOT_REGISTRY = [
907
912
  { id: "browser-use", name: "Browser-Use", category: "ai_agent", organization: "Open Source", baseScore: 70, respectsRobots: false, uaPatterns: ["browser-use"] },
908
913
  { id: "stagehand", name: "Stagehand", category: "ai_agent", organization: "Browserbase", baseScore: 70, respectsRobots: false, uaPatterns: ["stagehand"] },
909
914
  { id: "multion", name: "MultiOn", category: "ai_agent", organization: "MultiOn", baseScore: 70, respectsRobots: false, uaPatterns: ["multion"] },
915
+ { id: "iboubot", name: "IbouBot", category: "search_crawler", organization: "Ibou", baseScore: 30, respectsRobots: true, uaPatterns: ["iboubot"] },
910
916
  { id: "googlebot", name: "Googlebot", category: "search_crawler", organization: "Google", baseScore: 30, respectsRobots: true, uaPatterns: ["googlebot"] },
911
917
  { id: "bingbot", name: "Bingbot", category: "search_crawler", organization: "Microsoft", baseScore: 30, respectsRobots: true, uaPatterns: ["bingbot"] },
912
918
  { id: "yandexbot", name: "YandexBot", category: "search_crawler", organization: "Yandex", baseScore: 35, respectsRobots: true, uaPatterns: ["yandexbot"] },
@@ -2812,6 +2818,43 @@ var IPEnrichmentClient = class {
2812
2818
  }
2813
2819
  };
2814
2820
 
2821
+ // src/tracing.ts
2822
+ var STATUS_ERROR = 2;
2823
+ var NOOP_SPAN = {
2824
+ setAttribute: () => void 0,
2825
+ end: () => void 0
2826
+ };
2827
+ function startSpan(tracer, name) {
2828
+ if (!tracer) return NOOP_SPAN;
2829
+ try {
2830
+ return tracer.startSpan(name) ?? NOOP_SPAN;
2831
+ } catch {
2832
+ return NOOP_SPAN;
2833
+ }
2834
+ }
2835
+ function setAttribute(span, key, value) {
2836
+ try {
2837
+ span.setAttribute(key, value);
2838
+ } catch {
2839
+ }
2840
+ }
2841
+ function recordError(span, error) {
2842
+ try {
2843
+ span.recordException?.(error);
2844
+ span.setStatus?.({
2845
+ code: STATUS_ERROR,
2846
+ message: error instanceof Error ? error.message : String(error)
2847
+ });
2848
+ } catch {
2849
+ }
2850
+ }
2851
+ function endSpan(span) {
2852
+ try {
2853
+ span.end();
2854
+ } catch {
2855
+ }
2856
+ }
2857
+
2815
2858
  // src/sdk.ts
2816
2859
  var WebDecoy = class {
2817
2860
  constructor(config) {
@@ -2831,7 +2874,7 @@ var WebDecoy = class {
2831
2874
  }
2832
2875
  this.config = {
2833
2876
  apiKey: config.apiKey,
2834
- apiUrl: config.apiUrl || "https://ingest.webdecoy.com",
2877
+ apiUrl: config.apiUrl || "https://in.webdecoy.com",
2835
2878
  enableTLSFingerprinting: config.enableTLSFingerprinting ?? true,
2836
2879
  threatScoreThreshold: config.threatScoreThreshold ?? 80,
2837
2880
  timeout: config.timeout ?? 5e3,
@@ -2839,6 +2882,7 @@ var WebDecoy = class {
2839
2882
  tlsRejectUnauthorized: config.tlsRejectUnauthorized ?? true
2840
2883
  };
2841
2884
  this.log = resolveLogger(config.logger, this.config.debug);
2885
+ this.tracer = config.tracer;
2842
2886
  if (hasApiKey) {
2843
2887
  this.client = new WebDecoyClient({
2844
2888
  apiKey: config.apiKey,
@@ -2966,7 +3010,13 @@ var WebDecoy = class {
2966
3010
  /** Evaluate rules against a prepared context and report any violations. */
2967
3011
  runRules(context) {
2968
3012
  if (!this.ruleEngine) return null;
3013
+ const span = startSpan(this.tracer, "webdecoy.rules");
2969
3014
  const result = this.ruleEngine.evaluate(context);
3015
+ setAttribute(span, "webdecoy.rules.action", result.action);
3016
+ setAttribute(span, "webdecoy.rules.evaluated", result.results.length);
3017
+ setAttribute(span, "webdecoy.rules.violations", result.violations.length);
3018
+ if (result.rule) setAttribute(span, "webdecoy.rules.deciding", result.rule);
3019
+ endSpan(span);
2970
3020
  if (result.violations.length > 0 && this.violationReporter) {
2971
3021
  this.violationReporter.report(result.violations);
2972
3022
  }
@@ -3034,7 +3084,31 @@ var WebDecoy = class {
3034
3084
  */
3035
3085
  async protect(metadata, options = {}) {
3036
3086
  const edge = readEdgeVerdict(metadata.headers);
3037
- return (await this.decide(metadata, options)).withEdge(edge);
3087
+ const span = startSpan(this.tracer, "webdecoy.protect");
3088
+ try {
3089
+ const decision = (await this.decide(metadata, options)).withEdge(edge);
3090
+ setAttribute(span, "webdecoy.decision.id", decision.id);
3091
+ setAttribute(span, "webdecoy.decision.conclusion", decision.conclusion);
3092
+ setAttribute(span, "webdecoy.decision.allowed", decision.allowed);
3093
+ setAttribute(span, "webdecoy.rules.evaluated", decision.results.length);
3094
+ if (decision.ruleResult?.rule) {
3095
+ setAttribute(span, "webdecoy.decision.rule", decision.ruleResult.rule);
3096
+ }
3097
+ setAttribute(
3098
+ span,
3099
+ "webdecoy.remote",
3100
+ decision.detection.detection_id !== decision.id
3101
+ );
3102
+ if (decision.error) {
3103
+ setAttribute(span, "webdecoy.error", decision.error);
3104
+ }
3105
+ return decision;
3106
+ } catch (error) {
3107
+ recordError(span, error);
3108
+ throw error;
3109
+ } finally {
3110
+ endSpan(span);
3111
+ }
3038
3112
  }
3039
3113
  async decide(metadata, options = {}) {
3040
3114
  const id = newDecisionId();
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Rule, a as RuleContext, b as RuleResult, D as Decision, W as WebDecoy, c as WebDecoyConfig, P as ProtectOptions, d as RuleEngineResult, e as RateLimitConfig, F as FilterConfig, T as TripwireConfig, B as BotRuleConfig, f as BotAgent, g as BotCategory, A as AgentCategory, h as RateLimitStore, i as RateLimitConsume, j as RateLimitOutcome, k as AgentVerifierOptions, l as AgentRequestInput, m as AgentVerdict, S as SignedAgentDirectory } from './sdk-DjeCBrHu.mjs';
2
- export { n as AgentStatus, o as BOT_CATEGORIES, p as BOT_REGISTRY, q as BotVerdict, C as Characteristic, r as Conclusion, s as DEFAULT_CHARACTERISTICS, t as DecisionCache, u as DecisionCacheOptions, v as DecisionInit, E as EDGE_CLASS_HEADER, w as EDGE_CLEARANCE_HEADER, x as EdgeClass, y as EdgeVerdict, I as IPEnrichmentData, L as LocalAnalysis, z as LogFields, G as Logger, M as MemoryRateLimitStore, H as ProtectResult, J as RequestMetadata, K as RuleOutcome, N as RuleState, O as SDKDetectionRequest, Q as SDKDetectionResponse, U as SyncRateLimitStore, V as TLSInfo, X as ViolationEvent, Y as classifyUserAgent, Z as consoleLogger, _ as deriveKey, $ as fromPino, a0 as matchUserAgent, a1 as newDecisionId, a2 as readEdgeVerdict, a3 as silentLogger } from './sdk-DjeCBrHu.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-qUjMf8ZX.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-qUjMf8ZX.mjs';
3
3
 
4
4
  /**
5
5
  * The reserved test trigger.
@@ -634,92 +634,6 @@ declare class ClientSignalRule implements Rule {
634
634
  /** Act on the browser widget's verdict for this session. See {@link ClientSignalConfig}. */
635
635
  declare function clientSignals(config: ClientSignalConfig): Rule;
636
636
 
637
- /**
638
- * One adapter, for every runtime that speaks `Request` and `Response`.
639
- *
640
- * WHY THIS EXISTS
641
- *
642
- * Express, Fastify and Next.js each grew their own copy of the same middleware:
643
- * skip-path matching, monitor-versus-enforce, honeytoken arming, the 429 with a
644
- * `Retry-After`, fail-open error handling. Three copies of a decision tree is
645
- * three places for the branch that matters to be subtly different — and it
646
- * already had been, which is how the leftmost-`X-Forwarded-For` bug survived in
647
- * two adapters after the WordPress plugin fixed it.
648
- *
649
- * It is also the answer to "which framework do you support?". Hono, Bun, Deno,
650
- * Astro, Nitro, SvelteKit and Remix all hand you a WHATWG `Request` and want a
651
- * `Response` back. Written once here, each of those is a translation layer thin
652
- * enough not to need a package — see the README recipe — and `@webdecoy/hono` is
653
- * the one that does, because Hono has a middleware contract worth fitting.
654
- *
655
- * No `node:` imports: this is the code path that has to run on Workers.
656
- */
657
-
658
- interface FetchGuardOptions extends WebDecoyConfig, ProtectOptions {
659
- /**
660
- * Whether a blocking verdict actually blocks. Defaults to `'monitor'`.
661
- *
662
- * Nobody adopts a defence by having it break their site on the first install.
663
- * Watch what it would have done, then switch.
664
- */
665
- mode?: 'monitor' | 'enforce';
666
- /** Paths to skip entirely — health checks, static assets. */
667
- skipPaths?: (string | RegExp)[];
668
- /**
669
- * How much of the `X-Forwarded-For` chain to believe. Defaults to `1` trusted
670
- * hop: a fetch handler has no socket to fall back on, so there is no
671
- * believe-nothing default available. See `resolveClientIp`.
672
- */
673
- trustProxy?: TrustedProxies;
674
- /** Override IP resolution entirely. */
675
- getIP?: (request: Request) => string;
676
- /**
677
- * Inject a hidden honeytoken link into HTML responses, and arm the tripwire it
678
- * points at. Defaults to on when an `apiKey` is present.
679
- */
680
- honeytoken?: boolean;
681
- /** Build the blocking response. Defaults to 403, or 429 for a throttle. */
682
- onBlocked?: (request: Request, decision: Decision) => Response | Promise<Response>;
683
- }
684
- interface GuardOutcome {
685
- /** What the SDK concluded. Always present, in both modes. */
686
- decision: Decision;
687
- /**
688
- * The response to return instead of calling the handler, or undefined to
689
- * carry on. Undefined in monitor mode even when the decision is a denial.
690
- */
691
- response?: Response;
692
- }
693
- interface FetchGuard {
694
- /** Evaluate one request. */
695
- check(request: Request, peer?: string): Promise<GuardOutcome>;
696
- /**
697
- * Rewrite an HTML response to carry the honeytoken link. Returns the response
698
- * unchanged when there is no token yet, or the body is not injectable HTML.
699
- */
700
- decorate(response: Response): Promise<Response>;
701
- /** Whether this path is skipped. */
702
- skips(pathname: string): boolean;
703
- /** The underlying SDK, for `detectBot()` and friends. */
704
- sdk: WebDecoy;
705
- }
706
- /**
707
- * A guard over WHATWG `Request`/`Response`.
708
- *
709
- * ```ts
710
- * const guard = createFetchGuard({ rules: [tripwire()] });
711
- *
712
- * export default {
713
- * async fetch(request) {
714
- * const { response } = await guard.check(request);
715
- * if (response) return response;
716
- * return guard.decorate(await handle(request));
717
- * },
718
- * };
719
- * ```
720
- */
721
- declare function createFetchGuard(options?: FetchGuardOptions): FetchGuard;
722
-
723
637
  /**
724
638
  * Rule Engine
725
639
  * Evaluates rules in order — first DENY/THROTTLE wins
@@ -1398,6 +1312,165 @@ declare function tripwire(config?: TripwireConfig): Rule;
1398
1312
  */
1399
1313
  declare function bots(config?: BotRuleConfig): Rule;
1400
1314
 
1315
+ /**
1316
+ * The parts of a middleware that are the same in every framework.
1317
+ *
1318
+ * WHY THIS EXISTS
1319
+ *
1320
+ * Express, Fastify, Next.js and the fetch guard each grew their own copy of the
1321
+ * same decision tree: skip-path matching, monitor-versus-enforce, honeytoken
1322
+ * arming, the 429 payload, the 403 payload. Four copies of one set of rules.
1323
+ *
1324
+ * That is not a tidiness complaint. The leftmost-`X-Forwarded-For` bug survived
1325
+ * in two adapters after the same class of bug had already been fixed elsewhere,
1326
+ * precisely because there was no one place to fix. Every copy is a place the
1327
+ * next correction can fail to land, and each one reads perfectly sensibly on its
1328
+ * own — which is why review does not catch it.
1329
+ *
1330
+ * WHAT STAYS IN THE ADAPTERS
1331
+ *
1332
+ * Everything that touches the framework: reading metadata off its request
1333
+ * object, writing its response, and injecting the honeytoken link into whatever
1334
+ * that framework calls a body. Response mechanics differ genuinely — Express
1335
+ * intercepts `res.write`/`res.end`, Fastify uses an `onSend` hook, a fetch
1336
+ * handler rebuilds a `Response` — and the detail in each is hard-won. This
1337
+ * module holds the decisions, not the I/O.
1338
+ */
1339
+
1340
+ /** Whether a request path is exempt from protection. */
1341
+ declare function shouldSkipPath(path: string, patterns: readonly (string | RegExp)[] | undefined): boolean;
1342
+ /** A framework-agnostic description of the response a blocked request gets. */
1343
+ interface BlockResponse {
1344
+ status: number;
1345
+ headers: Record<string, string>;
1346
+ body: Record<string, unknown>;
1347
+ }
1348
+ /**
1349
+ * What to answer a request the rules refused.
1350
+ *
1351
+ * Returns null when the decision was not a rule refusal — a server-score block
1352
+ * has no rule to name, and each adapter's `onBlocked` handles that case with its
1353
+ * own default.
1354
+ */
1355
+ declare function ruleBlockResponse(decision: ProtectResult): BlockResponse | null;
1356
+ interface HoneytokenArmingOptions {
1357
+ /** The site honeytoken is derived from this. No key, no token. */
1358
+ apiKey?: string;
1359
+ /** Defaults to on when an apiKey is present. */
1360
+ enabled?: boolean;
1361
+ /** Reported when derivation fails, so a silent absence is at least loggable. */
1362
+ onError?: (error: unknown) => void;
1363
+ }
1364
+ /**
1365
+ * Derive the site honeytoken and arm the tripwire it points at.
1366
+ *
1367
+ * Returns a getter rather than a promise: derivation is async (WebCrypto HMAC,
1368
+ * so this still runs on edge runtimes) and requests served before it settles
1369
+ * simply carry no link. That is a few milliseconds at boot against the
1370
+ * alternative of blocking startup on crypto.
1371
+ *
1372
+ * The token is derived from the API key so every replica computes the same path
1373
+ * without coordinating. A random per-process token would advertise a link whose
1374
+ * tripwire only one replica had armed — bait with no trap behind it.
1375
+ */
1376
+ declare function armSiteHoneytoken(sdk: WebDecoy, options: HoneytokenArmingOptions): () => SiteHoneytoken | null;
1377
+ /**
1378
+ * Derive and arm, awaited.
1379
+ *
1380
+ * For a framework whose registration is already an async boot phase — Fastify's
1381
+ * plugin hook — where waiting costs nothing and removes the window in which
1382
+ * early requests are served without the link. Same logic as
1383
+ * {@link armSiteHoneytoken}; only the timing differs, which is why it is a
1384
+ * second entry point rather than a second implementation.
1385
+ */
1386
+ declare function deriveAndArm(sdk: WebDecoy, options: HoneytokenArmingOptions): Promise<SiteHoneytoken | null>;
1387
+
1388
+ /**
1389
+ * One adapter, for every runtime that speaks `Request` and `Response`.
1390
+ *
1391
+ * WHY THIS EXISTS
1392
+ *
1393
+ * Express, Fastify and Next.js each grew their own copy of the same middleware:
1394
+ * skip-path matching, monitor-versus-enforce, honeytoken arming, the 429 with a
1395
+ * `Retry-After`, fail-open error handling. Three copies of a decision tree is
1396
+ * three places for the branch that matters to be subtly different — and it
1397
+ * already had been, which is how the leftmost-`X-Forwarded-For` bug survived in
1398
+ * two adapters after the WordPress plugin fixed it.
1399
+ *
1400
+ * It is also the answer to "which framework do you support?". Hono, Bun, Deno,
1401
+ * Astro, Nitro, SvelteKit and Remix all hand you a WHATWG `Request` and want a
1402
+ * `Response` back. Written once here, each of those is a translation layer thin
1403
+ * enough not to need a package — see the README recipe — and `@webdecoy/hono` is
1404
+ * the one that does, because Hono has a middleware contract worth fitting.
1405
+ *
1406
+ * No `node:` imports: this is the code path that has to run on Workers.
1407
+ */
1408
+
1409
+ interface FetchGuardOptions extends WebDecoyConfig, ProtectOptions {
1410
+ /**
1411
+ * Whether a blocking verdict actually blocks. Defaults to `'monitor'`.
1412
+ *
1413
+ * Nobody adopts a defence by having it break their site on the first install.
1414
+ * Watch what it would have done, then switch.
1415
+ */
1416
+ mode?: 'monitor' | 'enforce';
1417
+ /** Paths to skip entirely — health checks, static assets. */
1418
+ skipPaths?: (string | RegExp)[];
1419
+ /**
1420
+ * How much of the `X-Forwarded-For` chain to believe. Defaults to `1` trusted
1421
+ * hop: a fetch handler has no socket to fall back on, so there is no
1422
+ * believe-nothing default available. See `resolveClientIp`.
1423
+ */
1424
+ trustProxy?: TrustedProxies;
1425
+ /** Override IP resolution entirely. */
1426
+ getIP?: (request: Request) => string;
1427
+ /**
1428
+ * Inject a hidden honeytoken link into HTML responses, and arm the tripwire it
1429
+ * points at. Defaults to on when an `apiKey` is present.
1430
+ */
1431
+ honeytoken?: boolean;
1432
+ /** Build the blocking response. Defaults to 403, or 429 for a throttle. */
1433
+ onBlocked?: (request: Request, decision: Decision) => Response | Promise<Response>;
1434
+ }
1435
+ interface GuardOutcome {
1436
+ /** What the SDK concluded. Always present, in both modes. */
1437
+ decision: Decision;
1438
+ /**
1439
+ * The response to return instead of calling the handler, or undefined to
1440
+ * carry on. Undefined in monitor mode even when the decision is a denial.
1441
+ */
1442
+ response?: Response;
1443
+ }
1444
+ interface FetchGuard {
1445
+ /** Evaluate one request. */
1446
+ check(request: Request, peer?: string): Promise<GuardOutcome>;
1447
+ /**
1448
+ * Rewrite an HTML response to carry the honeytoken link. Returns the response
1449
+ * unchanged when there is no token yet, or the body is not injectable HTML.
1450
+ */
1451
+ decorate(response: Response): Promise<Response>;
1452
+ /** Whether this path is skipped. */
1453
+ skips(pathname: string): boolean;
1454
+ /** The underlying SDK, for `detectBot()` and friends. */
1455
+ sdk: WebDecoy;
1456
+ }
1457
+ /**
1458
+ * A guard over WHATWG `Request`/`Response`.
1459
+ *
1460
+ * ```ts
1461
+ * const guard = createFetchGuard({ rules: [tripwire()] });
1462
+ *
1463
+ * export default {
1464
+ * async fetch(request) {
1465
+ * const { response } = await guard.check(request);
1466
+ * if (response) return response;
1467
+ * return guard.decorate(await handle(request));
1468
+ * },
1469
+ * };
1470
+ * ```
1471
+ */
1472
+ declare function createFetchGuard(options?: FetchGuardOptions): FetchGuard;
1473
+
1401
1474
  /**
1402
1475
  * AgentVerifier — the public entry point for local Web Bot Auth verification.
1403
1476
  *
@@ -1779,4 +1852,4 @@ declare function createCaptchaEndpoints(options?: CaptchaEndpointsOptions): {
1779
1852
  };
1780
1853
  type CaptchaEndpoints = ReturnType<typeof createCaptchaEndpoints>;
1781
1854
 
1782
- export { ATTACK_SIGNATURE_IDS, AgentCategory, AgentRequestInput, AgentVerdict, AgentVerifier, AgentVerifierOptions, type AttackSignatureConfig, AttackSignatureRule, type BehavioralSignals, BotAgent, BotCategory, BotPolicy, type BotPolicyOptions, BotRule, BotRuleConfig, CLIENT_SESSION_COOKIE, CLIENT_SESSION_HEADER, Captcha, type CaptchaEndpoints, type CaptchaEndpointsOptions, type CaptchaHttpResponse, type CaptchaOptions, type CaptchaRequest, type CategoryScores, type ChallengeData, type ChallengeStore, type ClientSignalConfig, ClientSignalRule, type ClientSignalStore, type ClientVerdict, DEFAULT_SIGNED_AGENT_DIRECTORIES, DEFAULT_TRIPWIRE_PATHS, DEFAULT_WEIGHTS, Decision, type Detection, type DetectionContext, DetectionEngine, type DetectionEngineOptions, DirectoryCache, type EnvironmentalSignals, type FetchGuard, type FetchGuardOptions, FilterConfig, FilterRule, type FingerprintStore, type FormAnalysisSignals, type GuardOutcome, HONEYTOKEN_BASE_PATH, type HeaderSource, type Honeytoken, type HoneytokenLinkProps, type HoneytokenOptions, InMemoryChallengeStore, InMemoryFingerprintStore, InMemoryRateLimiter, InMemoryTokenStore, MemoryClientSignalStore, type MemoryClientSignalStoreOptions, PoWManager, type PoWManagerOptions, type PoWOutcome, type PoWSolution, type PoWVerification, ProtectOptions, RateLimitConfig, RateLimitConsume, RateLimitOutcome, RateLimitRule, RateLimitStore, type RateLimiter, type Recommendation, type ResolveClientIpOptions, type RobotsTxtOptions, Rule, RuleContext, RuleEngine, RuleEngineResult, RuleResult, type ScoreResult, type Signals, SignedAgentDirectory, type SiteHoneytoken, type SiteHoneytokenOptions, type StoredChallenge, TEST_TRIGGER_UA_PREFIX, TEST_TRIGGER_USER_AGENT, type TemporalSignals, type TextareaKeyboardStats, TokenManager, type TokenManagerOptions, type TokenStore, type TokenVerification, TripwireConfig, TripwireRule, type TrustedProxies, UpstashRateLimitStore, type UpstashStoreOptions, type Verdict, type VerifyInput, type VerifyResult, type WebBotAuthConfig, WebBotAuthRule, WebDecoy, WebDecoyConfig, attackSignatures, botPolicy, bots, calculateCategoryScores, calculateFinalScore, clientSignals, createAgentVerifier, createCaptchaEndpoints, createFetchGuard, filter, honeytoken, injectHoneytokenLink, ipInCidr, isDatacenterIP, isInjectableHtml, isMobileUA, isTestTriggerUserAgent, normalizeIp, parseUserAgent, rateLimit, readClientSession, recommend, resolveClientIp, resolveSecret, siteHoneytoken, tripwire, upstashRateLimitStore, webBotAuth };
1855
+ export { ATTACK_SIGNATURE_IDS, AgentCategory, AgentRequestInput, AgentVerdict, AgentVerifier, AgentVerifierOptions, type AttackSignatureConfig, AttackSignatureRule, type BehavioralSignals, type BlockResponse, BotAgent, BotCategory, BotPolicy, type BotPolicyOptions, BotRule, BotRuleConfig, CLIENT_SESSION_COOKIE, CLIENT_SESSION_HEADER, Captcha, type CaptchaEndpoints, type CaptchaEndpointsOptions, type CaptchaHttpResponse, type CaptchaOptions, type CaptchaRequest, type CategoryScores, type ChallengeData, type ChallengeStore, type ClientSignalConfig, ClientSignalRule, type ClientSignalStore, type ClientVerdict, DEFAULT_SIGNED_AGENT_DIRECTORIES, DEFAULT_TRIPWIRE_PATHS, DEFAULT_WEIGHTS, Decision, type Detection, type DetectionContext, DetectionEngine, type DetectionEngineOptions, DirectoryCache, type EnvironmentalSignals, type FetchGuard, type FetchGuardOptions, FilterConfig, FilterRule, type FingerprintStore, type FormAnalysisSignals, type GuardOutcome, HONEYTOKEN_BASE_PATH, type HeaderSource, type Honeytoken, type HoneytokenArmingOptions, type HoneytokenLinkProps, type HoneytokenOptions, InMemoryChallengeStore, InMemoryFingerprintStore, InMemoryRateLimiter, InMemoryTokenStore, MemoryClientSignalStore, type MemoryClientSignalStoreOptions, PoWManager, type PoWManagerOptions, type PoWOutcome, type PoWSolution, type PoWVerification, ProtectOptions, ProtectResult, RateLimitConfig, RateLimitConsume, RateLimitOutcome, RateLimitRule, RateLimitStore, type RateLimiter, type Recommendation, type ResolveClientIpOptions, type RobotsTxtOptions, Rule, RuleContext, RuleEngine, RuleEngineResult, RuleResult, type ScoreResult, type Signals, SignedAgentDirectory, type SiteHoneytoken, type SiteHoneytokenOptions, type StoredChallenge, TEST_TRIGGER_UA_PREFIX, TEST_TRIGGER_USER_AGENT, type TemporalSignals, type TextareaKeyboardStats, TokenManager, type TokenManagerOptions, type TokenStore, type TokenVerification, TripwireConfig, TripwireRule, type TrustedProxies, UpstashRateLimitStore, type UpstashStoreOptions, type Verdict, type VerifyInput, type VerifyResult, type WebBotAuthConfig, WebBotAuthRule, WebDecoy, WebDecoyConfig, armSiteHoneytoken, attackSignatures, botPolicy, bots, calculateCategoryScores, calculateFinalScore, clientSignals, createAgentVerifier, createCaptchaEndpoints, createFetchGuard, deriveAndArm, filter, honeytoken, injectHoneytokenLink, ipInCidr, isDatacenterIP, isInjectableHtml, isMobileUA, isTestTriggerUserAgent, normalizeIp, parseUserAgent, rateLimit, readClientSession, recommend, resolveClientIp, resolveSecret, ruleBlockResponse, shouldSkipPath, siteHoneytoken, tripwire, upstashRateLimitStore, webBotAuth };