@webdecoy/node 0.17.0 → 0.18.1
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 +2 -2
- package/dist/{chunk-MHCY2FDT.mjs → chunk-JV5P2YEA.mjs} +16 -3
- package/dist/index.d.mts +30 -5
- package/dist/index.d.ts +30 -5
- package/dist/index.js +19 -3
- package/dist/index.mjs +4 -1
- package/dist/{sdk-BTqYTW4I.d.mts → sdk-CIlgQzZt.d.mts} +8 -2
- package/dist/{sdk-BTqYTW4I.d.ts → sdk-CIlgQzZt.d.ts} +8 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +16 -3
- package/dist/testing.mjs +1 -1
- package/package.json +1 -1
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://
|
|
1663
|
-
{ name: "
|
|
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-
|
|
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-
|
|
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.
|
|
@@ -67,11 +67,16 @@ declare function isTestTriggerUserAgent(userAgent: string | undefined): boolean;
|
|
|
67
67
|
* - `'cloudflare'` — use `CF-Connecting-IP`. Only meaningful if the origin is
|
|
68
68
|
* unreachable except through Cloudflare, since the header is otherwise just
|
|
69
69
|
* another thing a client can send.
|
|
70
|
+
* - `'railway'` — the app runs on Railway with nothing else in front. Railway's
|
|
71
|
+
* edge replaces any `X-Forwarded-For` the client sent with exactly
|
|
72
|
+
* `<client>, <edge>`, so the client is two entries from the right. The
|
|
73
|
+
* common guess of `1` names Railway's edge for every visitor. With a CDN in
|
|
74
|
+
* front of Railway, configure for the CDN instead (`'cloudflare'`).
|
|
70
75
|
* - `string[]` — CIDRs (or bare addresses) of the proxies you run. The chain is
|
|
71
76
|
* walked right to left and the first address that isn't one of yours is the
|
|
72
77
|
* client. Use this when the depth varies.
|
|
73
78
|
*/
|
|
74
|
-
type TrustedProxies = false | number | 'cloudflare' | string[];
|
|
79
|
+
type TrustedProxies = false | number | 'cloudflare' | 'railway' | string[];
|
|
75
80
|
/** Headers as either a Node-style bag or a WHATWG `Headers`. */
|
|
76
81
|
type HeaderSource = Record<string, string | string[] | undefined> | {
|
|
77
82
|
get(name: string): string | null;
|
|
@@ -388,7 +393,12 @@ interface DetectionContext {
|
|
|
388
393
|
headers?: Record<string, string>;
|
|
389
394
|
/** Client-supplied JA3 hash (spoofable). */
|
|
390
395
|
ja3Hash?: string | null;
|
|
391
|
-
/**
|
|
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
|
+
*/
|
|
392
402
|
trustedJA4Headers?: string[];
|
|
393
403
|
/** Proof-of-work verification outcome (supplied by the PoW subsystem). */
|
|
394
404
|
pow?: PoWOutcome;
|
|
@@ -1550,6 +1560,13 @@ type KeyResolver = (keyId: string) => Promise<VerificationKey | undefined>;
|
|
|
1550
1560
|
/**
|
|
1551
1561
|
* The default curated allowlist. These are the agents that sign production
|
|
1552
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.
|
|
1553
1570
|
*/
|
|
1554
1571
|
declare const DEFAULT_SIGNED_AGENT_DIRECTORIES: SignedAgentDirectory[];
|
|
1555
1572
|
interface DirectoryCacheOptions {
|
|
@@ -1761,7 +1778,15 @@ interface CaptchaOptions {
|
|
|
1761
1778
|
secret?: string;
|
|
1762
1779
|
/** Override per-category detection weights. */
|
|
1763
1780
|
weights?: Record<string, number>;
|
|
1764
|
-
/**
|
|
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
|
+
*/
|
|
1765
1790
|
trustedJA4Headers?: string[];
|
|
1766
1791
|
/** Pluggable stores (default to in-memory; swap for Redis in production). */
|
|
1767
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-
|
|
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-
|
|
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.
|
|
@@ -67,11 +67,16 @@ declare function isTestTriggerUserAgent(userAgent: string | undefined): boolean;
|
|
|
67
67
|
* - `'cloudflare'` — use `CF-Connecting-IP`. Only meaningful if the origin is
|
|
68
68
|
* unreachable except through Cloudflare, since the header is otherwise just
|
|
69
69
|
* another thing a client can send.
|
|
70
|
+
* - `'railway'` — the app runs on Railway with nothing else in front. Railway's
|
|
71
|
+
* edge replaces any `X-Forwarded-For` the client sent with exactly
|
|
72
|
+
* `<client>, <edge>`, so the client is two entries from the right. The
|
|
73
|
+
* common guess of `1` names Railway's edge for every visitor. With a CDN in
|
|
74
|
+
* front of Railway, configure for the CDN instead (`'cloudflare'`).
|
|
70
75
|
* - `string[]` — CIDRs (or bare addresses) of the proxies you run. The chain is
|
|
71
76
|
* walked right to left and the first address that isn't one of yours is the
|
|
72
77
|
* client. Use this when the depth varies.
|
|
73
78
|
*/
|
|
74
|
-
type TrustedProxies = false | number | 'cloudflare' | string[];
|
|
79
|
+
type TrustedProxies = false | number | 'cloudflare' | 'railway' | string[];
|
|
75
80
|
/** Headers as either a Node-style bag or a WHATWG `Headers`. */
|
|
76
81
|
type HeaderSource = Record<string, string | string[] | undefined> | {
|
|
77
82
|
get(name: string): string | null;
|
|
@@ -388,7 +393,12 @@ interface DetectionContext {
|
|
|
388
393
|
headers?: Record<string, string>;
|
|
389
394
|
/** Client-supplied JA3 hash (spoofable). */
|
|
390
395
|
ja3Hash?: string | null;
|
|
391
|
-
/**
|
|
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
|
+
*/
|
|
392
402
|
trustedJA4Headers?: string[];
|
|
393
403
|
/** Proof-of-work verification outcome (supplied by the PoW subsystem). */
|
|
394
404
|
pow?: PoWOutcome;
|
|
@@ -1550,6 +1560,13 @@ type KeyResolver = (keyId: string) => Promise<VerificationKey | undefined>;
|
|
|
1550
1560
|
/**
|
|
1551
1561
|
* The default curated allowlist. These are the agents that sign production
|
|
1552
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.
|
|
1553
1570
|
*/
|
|
1554
1571
|
declare const DEFAULT_SIGNED_AGENT_DIRECTORIES: SignedAgentDirectory[];
|
|
1555
1572
|
interface DirectoryCacheOptions {
|
|
@@ -1761,7 +1778,15 @@ interface CaptchaOptions {
|
|
|
1761
1778
|
secret?: string;
|
|
1762
1779
|
/** Override per-category detection weights. */
|
|
1763
1780
|
weights?: Record<string, number>;
|
|
1764
|
-
/**
|
|
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
|
+
*/
|
|
1765
1790
|
trustedJA4Headers?: string[];
|
|
1766
1791
|
/** Pluggable stores (default to in-memory; swap for Redis in production). */
|
|
1767
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://
|
|
2297
|
-
{ name: "
|
|
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) {
|
|
@@ -3766,6 +3779,9 @@ function resolveClientIp(options) {
|
|
|
3766
3779
|
if (trustProxy === "cloudflare") {
|
|
3767
3780
|
return normalizeIp(readHeader(headers, "cf-connecting-ip")) ?? peer;
|
|
3768
3781
|
}
|
|
3782
|
+
if (trustProxy === "railway") {
|
|
3783
|
+
return resolveClientIp({ headers, peer: options.peer, trustProxy: 2 });
|
|
3784
|
+
}
|
|
3769
3785
|
const chain = forwardedChain(headers);
|
|
3770
3786
|
const singleHeaderFallback = () => normalizeIp(readHeader(headers, "x-real-ip")) ?? normalizeIp(readHeader(headers, "x-vercel-forwarded-for")?.split(",").pop()) ?? void 0;
|
|
3771
3787
|
if (typeof trustProxy === "number") {
|
package/dist/index.mjs
CHANGED
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
tripwire,
|
|
55
55
|
upstashRateLimitStore,
|
|
56
56
|
webBotAuth
|
|
57
|
-
} from "./chunk-
|
|
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})$/;
|
|
@@ -183,6 +183,9 @@ function resolveClientIp(options) {
|
|
|
183
183
|
if (trustProxy === "cloudflare") {
|
|
184
184
|
return normalizeIp(readHeader(headers, "cf-connecting-ip")) ?? peer;
|
|
185
185
|
}
|
|
186
|
+
if (trustProxy === "railway") {
|
|
187
|
+
return resolveClientIp({ headers, peer: options.peer, trustProxy: 2 });
|
|
188
|
+
}
|
|
186
189
|
const chain = forwardedChain(headers);
|
|
187
190
|
const singleHeaderFallback = () => normalizeIp(readHeader(headers, "x-real-ip")) ?? normalizeIp(readHeader(headers, "x-vercel-forwarded-for")?.split(",").pop()) ?? void 0;
|
|
188
191
|
if (typeof trustProxy === "number") {
|
|
@@ -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://
|
|
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://
|
|
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
|
/**
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as WebDecoyConfig, J as RequestMetadata, W as WebDecoy, P as ProtectResult, N as RuleState } from './sdk-
|
|
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-
|
|
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://
|
|
1052
|
-
{ name: "
|
|
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