@webdecoy/node 0.18.0 → 0.18.2

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
@@ -170,8 +170,8 @@ import { Captcha } from '@webdecoy/node';
170
170
 
171
171
  const captcha = new Captcha({ secret: process.env.WEBDECOY_SECRET });
172
172
 
173
- app.post('/login', (req, res) => {
174
- const result = captcha.verifyToken(req.body.webdecoy_token, req.ip);
173
+ app.post('/login', async (req, res) => {
174
+ const result = await captcha.verifyToken(req.body.webdecoy_token, req.ip);
175
175
  if (!result.valid) return res.status(403).json({ error: 'captcha failed' });
176
176
  // ...proceed
177
177
  });
@@ -1659,8 +1659,9 @@ function base64urlBytes(bytes) {
1659
1659
  var WELL_KNOWN = "/.well-known/http-message-signatures-directory";
1660
1660
  var COLD_RETRY_BACKOFF_MS = 3e4;
1661
1661
  var DEFAULT_SIGNED_AGENT_DIRECTORIES = [
1662
- { name: "OpenAI", category: "ai_crawlers", directory: "https://operator.openai.com" },
1663
- { name: "OpenAI ChatGPT", category: "ai_crawlers", directory: "https://chatgpt.com" }
1662
+ { name: "OpenAI ChatGPT", category: "ai_crawlers", directory: "https://chatgpt.com" },
1663
+ { name: "Google Agent", category: "ai_crawlers", directory: "https://agent.bot.goog" },
1664
+ { name: "WebDecoyBot", category: "monitoring", directory: "https://bot.webdecoy.com" }
1664
1665
  ];
1665
1666
  var DirectoryCache = class {
1666
1667
  constructor(opts) {
@@ -2515,7 +2516,7 @@ var WebDecoyClient = class {
2515
2516
  response = await this.request(
2516
2517
  "POST",
2517
2518
  "/api/v1/sdk/detect",
2518
- request
2519
+ toWireDetectionRequest(request)
2519
2520
  );
2520
2521
  } catch (error) {
2521
2522
  if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) {
@@ -2619,6 +2620,18 @@ var WebDecoyClient = class {
2619
2620
  }
2620
2621
  }
2621
2622
  };
2623
+ function toWireDetectionRequest(request) {
2624
+ const tls = request.request_metadata.tls_info;
2625
+ if (!tls || tls.alpn_protocols === void 0) return request;
2626
+ const { alpn_protocols, ...rest } = tls;
2627
+ return {
2628
+ ...request,
2629
+ request_metadata: {
2630
+ ...request.request_metadata,
2631
+ tls_info: { ...rest, alpn: rest.alpn ?? alpn_protocols }
2632
+ }
2633
+ };
2634
+ }
2622
2635
 
2623
2636
  // src/local-analysis.ts
2624
2637
  var DATACENTER_RANGES = [
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-BTqYTW4I.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-BTqYTW4I.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-CIlgQzZt.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-CIlgQzZt.mjs';
3
3
 
4
4
  /**
5
5
  * The reserved test trigger.
@@ -393,7 +393,12 @@ interface DetectionContext {
393
393
  headers?: Record<string, string>;
394
394
  /** Client-supplied JA3 hash (spoofable). */
395
395
  ja3Hash?: string | null;
396
- /** Trusted reverse-proxy header names carrying a JA4 fingerprint. */
396
+ /**
397
+ * Trusted reverse-proxy header names carrying a JA4 fingerprint, matched
398
+ * against the lower-cased `headers` keys. The value is checked against
399
+ * `KNOWN_BOT_JA4_HASHES`, which ships empty, so it does not currently
400
+ * change the score.
401
+ */
397
402
  trustedJA4Headers?: string[];
398
403
  /** Proof-of-work verification outcome (supplied by the PoW subsystem). */
399
404
  pow?: PoWOutcome;
@@ -1555,6 +1560,13 @@ type KeyResolver = (keyId: string) => Promise<VerificationKey | undefined>;
1555
1560
  /**
1556
1561
  * The default curated allowlist. These are the agents that sign production
1557
1562
  * traffic today; kept in lock-step with the backend's curated list.
1563
+ *
1564
+ * `https://operator.openai.com` is not listed: that host no longer resolves,
1565
+ * so it contributed no keys. OpenAI's signed traffic verifies against the
1566
+ * `https://chatgpt.com` directory.
1567
+ *
1568
+ * Google Agent is Google's AI browsing agent, not Googlebot. Googlebot does not
1569
+ * sign requests and is verified by IP range and reverse DNS instead.
1558
1570
  */
1559
1571
  declare const DEFAULT_SIGNED_AGENT_DIRECTORIES: SignedAgentDirectory[];
1560
1572
  interface DirectoryCacheOptions {
@@ -1766,7 +1778,15 @@ interface CaptchaOptions {
1766
1778
  secret?: string;
1767
1779
  /** Override per-category detection weights. */
1768
1780
  weights?: Record<string, number>;
1769
- /** Trusted reverse-proxy header names carrying a JA4 fingerprint. */
1781
+ /**
1782
+ * Trusted reverse-proxy header names carrying a JA4 fingerprint, matched
1783
+ * against the lower-cased request header keys (e.g. `['x-ja4']`).
1784
+ *
1785
+ * Today this has no effect on the score: the value is read and compared with
1786
+ * a built-in table of known automation JA4 fingerprints that ships empty, so
1787
+ * nothing matches. It is not recorded on the verdict and not sent anywhere.
1788
+ * Only list headers your own proxy sets, since a client can send any header.
1789
+ */
1770
1790
  trustedJA4Headers?: string[];
1771
1791
  /** Pluggable stores (default to in-memory; swap for Redis in production). */
1772
1792
  challengeStore?: ChallengeStore;
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-BTqYTW4I.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-BTqYTW4I.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-CIlgQzZt.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-CIlgQzZt.js';
3
3
 
4
4
  /**
5
5
  * The reserved test trigger.
@@ -393,7 +393,12 @@ interface DetectionContext {
393
393
  headers?: Record<string, string>;
394
394
  /** Client-supplied JA3 hash (spoofable). */
395
395
  ja3Hash?: string | null;
396
- /** Trusted reverse-proxy header names carrying a JA4 fingerprint. */
396
+ /**
397
+ * Trusted reverse-proxy header names carrying a JA4 fingerprint, matched
398
+ * against the lower-cased `headers` keys. The value is checked against
399
+ * `KNOWN_BOT_JA4_HASHES`, which ships empty, so it does not currently
400
+ * change the score.
401
+ */
397
402
  trustedJA4Headers?: string[];
398
403
  /** Proof-of-work verification outcome (supplied by the PoW subsystem). */
399
404
  pow?: PoWOutcome;
@@ -1555,6 +1560,13 @@ type KeyResolver = (keyId: string) => Promise<VerificationKey | undefined>;
1555
1560
  /**
1556
1561
  * The default curated allowlist. These are the agents that sign production
1557
1562
  * traffic today; kept in lock-step with the backend's curated list.
1563
+ *
1564
+ * `https://operator.openai.com` is not listed: that host no longer resolves,
1565
+ * so it contributed no keys. OpenAI's signed traffic verifies against the
1566
+ * `https://chatgpt.com` directory.
1567
+ *
1568
+ * Google Agent is Google's AI browsing agent, not Googlebot. Googlebot does not
1569
+ * sign requests and is verified by IP range and reverse DNS instead.
1558
1570
  */
1559
1571
  declare const DEFAULT_SIGNED_AGENT_DIRECTORIES: SignedAgentDirectory[];
1560
1572
  interface DirectoryCacheOptions {
@@ -1766,7 +1778,15 @@ interface CaptchaOptions {
1766
1778
  secret?: string;
1767
1779
  /** Override per-category detection weights. */
1768
1780
  weights?: Record<string, number>;
1769
- /** Trusted reverse-proxy header names carrying a JA4 fingerprint. */
1781
+ /**
1782
+ * Trusted reverse-proxy header names carrying a JA4 fingerprint, matched
1783
+ * against the lower-cased request header keys (e.g. `['x-ja4']`).
1784
+ *
1785
+ * Today this has no effect on the score: the value is read and compared with
1786
+ * a built-in table of known automation JA4 fingerprints that ships empty, so
1787
+ * nothing matches. It is not recorded on the verdict and not sent anywhere.
1788
+ * Only list headers your own proxy sets, since a client can send any header.
1789
+ */
1770
1790
  trustedJA4Headers?: string[];
1771
1791
  /** Pluggable stores (default to in-memory; swap for Redis in production). */
1772
1792
  challengeStore?: ChallengeStore;
package/dist/index.js CHANGED
@@ -167,7 +167,7 @@ var WebDecoyClient = class {
167
167
  response = await this.request(
168
168
  "POST",
169
169
  "/api/v1/sdk/detect",
170
- request
170
+ toWireDetectionRequest(request)
171
171
  );
172
172
  } catch (error) {
173
173
  if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) {
@@ -271,6 +271,18 @@ var WebDecoyClient = class {
271
271
  }
272
272
  }
273
273
  };
274
+ function toWireDetectionRequest(request) {
275
+ const tls = request.request_metadata.tls_info;
276
+ if (!tls || tls.alpn_protocols === void 0) return request;
277
+ const { alpn_protocols, ...rest } = tls;
278
+ return {
279
+ ...request,
280
+ request_metadata: {
281
+ ...request.request_metadata,
282
+ tls_info: { ...rest, alpn: rest.alpn ?? alpn_protocols }
283
+ }
284
+ };
285
+ }
274
286
 
275
287
  // src/local-analysis.ts
276
288
  var DATACENTER_RANGES = [
@@ -2293,8 +2305,9 @@ function base64urlBytes(bytes) {
2293
2305
  var WELL_KNOWN = "/.well-known/http-message-signatures-directory";
2294
2306
  var COLD_RETRY_BACKOFF_MS = 3e4;
2295
2307
  var DEFAULT_SIGNED_AGENT_DIRECTORIES = [
2296
- { name: "OpenAI", category: "ai_crawlers", directory: "https://operator.openai.com" },
2297
- { name: "OpenAI ChatGPT", category: "ai_crawlers", directory: "https://chatgpt.com" }
2308
+ { name: "OpenAI ChatGPT", category: "ai_crawlers", directory: "https://chatgpt.com" },
2309
+ { name: "Google Agent", category: "ai_crawlers", directory: "https://agent.bot.goog" },
2310
+ { name: "WebDecoyBot", category: "monitoring", directory: "https://bot.webdecoy.com" }
2298
2311
  ];
2299
2312
  var DirectoryCache = class {
2300
2313
  constructor(opts) {
package/dist/index.mjs CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  tripwire,
55
55
  upstashRateLimitStore,
56
56
  webBotAuth
57
- } from "./chunk-MHCY2FDT.mjs";
57
+ } from "./chunk-JV5P2YEA.mjs";
58
58
 
59
59
  // src/client-ip.ts
60
60
  var IPV4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
@@ -142,7 +142,7 @@ interface SignedAgentDirectory {
142
142
  category: AgentCategory;
143
143
  /**
144
144
  * Origin (scheme + host) whose well-known HTTP Message Signatures directory
145
- * publishes the agent's keys, e.g. `https://operator.openai.com`. The
145
+ * publishes the agent's keys, e.g. `https://chatgpt.com`. The
146
146
  * `/.well-known/http-message-signatures-directory` path is appended
147
147
  * automatically. A full URL ending in a path is also accepted verbatim.
148
148
  */
@@ -726,7 +726,13 @@ interface TLSInfo {
726
726
  signature_algorithms?: number[];
727
727
  /** Server name indication */
728
728
  server_name?: string;
729
- /** ALPN protocols */
729
+ /** ALPN protocols offered by the client, in wire order (e.g. `['h2', 'http/1.1']`). */
730
+ alpn?: string[];
731
+ /**
732
+ * @deprecated Use {@link TLSInfo.alpn}. The detection service reads `alpn`
733
+ * and ignores this name. It is still accepted here and is sent as `alpn`
734
+ * when `alpn` itself is not set.
735
+ */
730
736
  alpn_protocols?: string[];
731
737
  }
732
738
  /**
@@ -142,7 +142,7 @@ interface SignedAgentDirectory {
142
142
  category: AgentCategory;
143
143
  /**
144
144
  * Origin (scheme + host) whose well-known HTTP Message Signatures directory
145
- * publishes the agent's keys, e.g. `https://operator.openai.com`. The
145
+ * publishes the agent's keys, e.g. `https://chatgpt.com`. The
146
146
  * `/.well-known/http-message-signatures-directory` path is appended
147
147
  * automatically. A full URL ending in a path is also accepted verbatim.
148
148
  */
@@ -726,7 +726,13 @@ interface TLSInfo {
726
726
  signature_algorithms?: number[];
727
727
  /** Server name indication */
728
728
  server_name?: string;
729
- /** ALPN protocols */
729
+ /** ALPN protocols offered by the client, in wire order (e.g. `['h2', 'http/1.1']`). */
730
+ alpn?: string[];
731
+ /**
732
+ * @deprecated Use {@link TLSInfo.alpn}. The detection service reads `alpn`
733
+ * and ignores this name. It is still accepted here and is sent as `alpn`
734
+ * when `alpn` itself is not set.
735
+ */
730
736
  alpn_protocols?: string[];
731
737
  }
732
738
  /**
@@ -1,4 +1,4 @@
1
- import { j as WebDecoyConfig, J as RequestMetadata, W as WebDecoy, P as ProtectResult, N as RuleState } from './sdk-BTqYTW4I.mjs';
1
+ import { j as WebDecoyConfig, J as RequestMetadata, W as WebDecoy, P as ProtectResult, N as RuleState } from './sdk-CIlgQzZt.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-BTqYTW4I.js';
1
+ import { j as WebDecoyConfig, J as RequestMetadata, W as WebDecoy, P as ProtectResult, N as RuleState } from './sdk-CIlgQzZt.js';
2
2
 
3
3
  /**
4
4
  * Testing utilities, for the application's test suite rather than ours.
package/dist/testing.js CHANGED
@@ -97,7 +97,7 @@ var WebDecoyClient = class {
97
97
  response = await this.request(
98
98
  "POST",
99
99
  "/api/v1/sdk/detect",
100
- request2
100
+ toWireDetectionRequest(request2)
101
101
  );
102
102
  } catch (error) {
103
103
  if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) {
@@ -201,6 +201,18 @@ var WebDecoyClient = class {
201
201
  }
202
202
  }
203
203
  };
204
+ function toWireDetectionRequest(request2) {
205
+ const tls = request2.request_metadata.tls_info;
206
+ if (!tls || tls.alpn_protocols === void 0) return request2;
207
+ const { alpn_protocols, ...rest } = tls;
208
+ return {
209
+ ...request2,
210
+ request_metadata: {
211
+ ...request2.request_metadata,
212
+ tls_info: { ...rest, alpn: rest.alpn ?? alpn_protocols }
213
+ }
214
+ };
215
+ }
204
216
 
205
217
  // src/local-analysis.ts
206
218
  var DATACENTER_RANGES = [
@@ -1048,8 +1060,9 @@ function base64urlBytes(bytes) {
1048
1060
  var WELL_KNOWN = "/.well-known/http-message-signatures-directory";
1049
1061
  var COLD_RETRY_BACKOFF_MS = 3e4;
1050
1062
  var DEFAULT_SIGNED_AGENT_DIRECTORIES = [
1051
- { name: "OpenAI", category: "ai_crawlers", directory: "https://operator.openai.com" },
1052
- { name: "OpenAI ChatGPT", category: "ai_crawlers", directory: "https://chatgpt.com" }
1063
+ { name: "OpenAI ChatGPT", category: "ai_crawlers", directory: "https://chatgpt.com" },
1064
+ { name: "Google Agent", category: "ai_crawlers", directory: "https://agent.bot.goog" },
1065
+ { name: "WebDecoyBot", category: "monitoring", directory: "https://bot.webdecoy.com" }
1053
1066
  ];
1054
1067
  var DirectoryCache = class {
1055
1068
  constructor(opts) {
package/dist/testing.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  WebDecoy,
3
3
  silentLogger
4
- } from "./chunk-MHCY2FDT.mjs";
4
+ } from "./chunk-JV5P2YEA.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.18.0",
3
+ "version": "0.18.2",
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",