@webdecoy/node 0.19.0 → 0.20.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/dist/chunk-2G4TLK3R.mjs +1350 -0
- package/dist/{chunk-5WMRRJ4A.mjs → chunk-MQIYUGYQ.mjs} +27 -9
- package/dist/index-GXXXr_mb.d.mts +168 -0
- package/dist/index-GXXXr_mb.d.ts +168 -0
- package/dist/index.d.mts +5 -95
- package/dist/index.d.ts +5 -95
- package/dist/index.js +1288 -69
- package/dist/index.mjs +12 -148
- package/dist/{sdk-CSHYCT9a.d.mts → sdk--ub6PNZO.d.mts} +4 -1
- package/dist/{sdk-CSHYCT9a.d.ts → sdk--ub6PNZO.d.ts} +4 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +27 -9
- package/dist/testing.mjs +1 -1
- package/dist/vercel.d.mts +42 -0
- package/dist/vercel.d.ts +42 -0
- package/dist/vercel.js +1400 -0
- package/dist/vercel.mjs +34 -0
- package/package.json +9 -4
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ __export(index_exports, {
|
|
|
27
27
|
BOT_REGISTRY: () => BOT_REGISTRY,
|
|
28
28
|
BotPolicy: () => BotPolicy,
|
|
29
29
|
BotRule: () => BotRule,
|
|
30
|
+
CLEARANCE_GATE_BUILD: () => re,
|
|
30
31
|
CLIENT_SESSION_COOKIE: () => CLIENT_SESSION_COOKIE,
|
|
31
32
|
CLIENT_SESSION_HEADER: () => CLIENT_SESSION_HEADER,
|
|
32
33
|
Captcha: () => Captcha,
|
|
@@ -70,6 +71,7 @@ __export(index_exports, {
|
|
|
70
71
|
consoleLogger: () => consoleLogger,
|
|
71
72
|
createAgentVerifier: () => createAgentVerifier,
|
|
72
73
|
createCaptchaEndpoints: () => createCaptchaEndpoints,
|
|
74
|
+
createClearanceGate: () => createClearanceGate,
|
|
73
75
|
createFetchGuard: () => createFetchGuard,
|
|
74
76
|
deriveAndArm: () => deriveAndArm,
|
|
75
77
|
deriveKey: () => deriveKey,
|
|
@@ -91,6 +93,7 @@ __export(index_exports, {
|
|
|
91
93
|
readEdgeVerdict: () => readEdgeVerdict,
|
|
92
94
|
recommend: () => recommend,
|
|
93
95
|
resolveClientIp: () => resolveClientIp,
|
|
96
|
+
resolveGateEnv: () => resolveGateEnv,
|
|
94
97
|
resolveSecret: () => resolveSecret,
|
|
95
98
|
ruleBlockResponse: () => ruleBlockResponse,
|
|
96
99
|
shouldSkipPath: () => shouldSkipPath,
|
|
@@ -102,6 +105,24 @@ __export(index_exports, {
|
|
|
102
105
|
});
|
|
103
106
|
module.exports = __toCommonJS(index_exports);
|
|
104
107
|
|
|
108
|
+
// src/report-headers.ts
|
|
109
|
+
var CREDENTIAL_HEADER = /cookie|auth|token|secret|passw|session|credential|csrf|xsrf|api[-_]?key|access[-_]?key|private[-_]?key/i;
|
|
110
|
+
var CLEARANCE_COOKIE = "wd_clearance";
|
|
111
|
+
function reportableHeaders(headers) {
|
|
112
|
+
const out = {};
|
|
113
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
114
|
+
if (!CREDENTIAL_HEADER.test(name)) {
|
|
115
|
+
out[name] = value;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
out[name] = name.toLowerCase() === "cookie" ? clearanceCookieOnly(value) : "";
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
function clearanceCookieOnly(cookie) {
|
|
123
|
+
return String(cookie ?? "").split(";").map((pair) => pair.trim()).filter((pair) => pair.slice(0, pair.indexOf("=")).trim() === CLEARANCE_COOKIE).join("; ");
|
|
124
|
+
}
|
|
125
|
+
|
|
105
126
|
// src/client.ts
|
|
106
127
|
var WebDecoyUnavailableError = class extends Error {
|
|
107
128
|
constructor(retryAt) {
|
|
@@ -315,16 +336,16 @@ var WebDecoyClient = class {
|
|
|
315
336
|
}
|
|
316
337
|
};
|
|
317
338
|
function toWireDetectionRequest(request) {
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
return {
|
|
322
|
-
...request,
|
|
323
|
-
request_metadata: {
|
|
324
|
-
...request.request_metadata,
|
|
325
|
-
tls_info: { ...rest, alpn: rest.alpn ?? alpn_protocols }
|
|
326
|
-
}
|
|
339
|
+
const metadata = {
|
|
340
|
+
...request.request_metadata,
|
|
341
|
+
headers: reportableHeaders(request.request_metadata.headers ?? {})
|
|
327
342
|
};
|
|
343
|
+
const tls = metadata.tls_info;
|
|
344
|
+
if (tls && tls.alpn_protocols !== void 0) {
|
|
345
|
+
const { alpn_protocols, ...rest } = tls;
|
|
346
|
+
metadata.tls_info = { ...rest, alpn: rest.alpn ?? alpn_protocols };
|
|
347
|
+
}
|
|
348
|
+
return { ...request, request_metadata: metadata };
|
|
328
349
|
}
|
|
329
350
|
|
|
330
351
|
// src/local-analysis.ts
|
|
@@ -1290,7 +1311,7 @@ var TripwireRule = class {
|
|
|
1290
1311
|
}
|
|
1291
1312
|
evaluate(context) {
|
|
1292
1313
|
const path = canonicalizeTripwirePath(context.path);
|
|
1293
|
-
const hit = this.exact.has(path) || this.prefixes.some((prefix) => path.startsWith(prefix)) || this.patterns.some((
|
|
1314
|
+
const hit = this.exact.has(path) || this.prefixes.some((prefix) => path.startsWith(prefix)) || this.patterns.some((re2) => re2.test(path));
|
|
1294
1315
|
if (hit) {
|
|
1295
1316
|
return {
|
|
1296
1317
|
action: this.dryRun ? "ALLOW" : this.action,
|
|
@@ -2098,9 +2119,9 @@ function injectHoneytokenLink(html, linkHtml) {
|
|
|
2098
2119
|
if (!html || html.includes(linkHtml)) return html;
|
|
2099
2120
|
const lower = html.toLowerCase();
|
|
2100
2121
|
for (const close of ["</body>", "</html>"]) {
|
|
2101
|
-
const
|
|
2102
|
-
if (
|
|
2103
|
-
return html.slice(0,
|
|
2122
|
+
const at2 = lower.lastIndexOf(close);
|
|
2123
|
+
if (at2 !== -1) {
|
|
2124
|
+
return html.slice(0, at2) + linkHtml + html.slice(at2);
|
|
2104
2125
|
}
|
|
2105
2126
|
}
|
|
2106
2127
|
return html;
|
|
@@ -2259,7 +2280,7 @@ var MAX_ENTRIES = 500;
|
|
|
2259
2280
|
var header = (headers, name) => {
|
|
2260
2281
|
const v = headers[name] ?? headers[name.toLowerCase()];
|
|
2261
2282
|
if (v !== void 0) return v;
|
|
2262
|
-
for (const [
|
|
2283
|
+
for (const [k2, value] of Object.entries(headers)) if (k2.toLowerCase() === name) return value;
|
|
2263
2284
|
return "";
|
|
2264
2285
|
};
|
|
2265
2286
|
var AIReferralCounter = class {
|
|
@@ -2381,19 +2402,19 @@ var encoder2 = new TextEncoder();
|
|
|
2381
2402
|
async function rsaThumbprint(n, e) {
|
|
2382
2403
|
return digest(`{"e":${JSON.stringify(e)},"kty":"RSA","n":${JSON.stringify(n)}}`);
|
|
2383
2404
|
}
|
|
2384
|
-
async function okpThumbprint(crv,
|
|
2385
|
-
return digest(`{"crv":${JSON.stringify(crv)},"kty":"OKP","x":${JSON.stringify(
|
|
2405
|
+
async function okpThumbprint(crv, x2) {
|
|
2406
|
+
return digest(`{"crv":${JSON.stringify(crv)},"kty":"OKP","x":${JSON.stringify(x2)}}`);
|
|
2386
2407
|
}
|
|
2387
|
-
async function jwkThumbprint(
|
|
2388
|
-
switch (
|
|
2408
|
+
async function jwkThumbprint(k2) {
|
|
2409
|
+
switch (k2.kty) {
|
|
2389
2410
|
case "OKP":
|
|
2390
|
-
if (!
|
|
2391
|
-
return okpThumbprint(
|
|
2411
|
+
if (!k2.crv || !k2.x) throw new Error("thumbprint: OKP JWK missing crv or x");
|
|
2412
|
+
return okpThumbprint(k2.crv, k2.x);
|
|
2392
2413
|
case "RSA":
|
|
2393
|
-
if (!
|
|
2394
|
-
return rsaThumbprint(
|
|
2414
|
+
if (!k2.n || !k2.e) throw new Error("thumbprint: RSA JWK missing n or e");
|
|
2415
|
+
return rsaThumbprint(k2.n, k2.e);
|
|
2395
2416
|
default:
|
|
2396
|
-
throw new Error(`thumbprint: unsupported kty ${JSON.stringify(
|
|
2417
|
+
throw new Error(`thumbprint: unsupported kty ${JSON.stringify(k2.kty)}`);
|
|
2397
2418
|
}
|
|
2398
2419
|
}
|
|
2399
2420
|
async function digest(canonical) {
|
|
@@ -2462,7 +2483,7 @@ var DirectoryCache = class {
|
|
|
2462
2483
|
for (const keys of results) {
|
|
2463
2484
|
if (keys === null) continue;
|
|
2464
2485
|
fetchedAny = true;
|
|
2465
|
-
for (const
|
|
2486
|
+
for (const k2 of keys) next.set(k2.thumbprint, k2.key);
|
|
2466
2487
|
}
|
|
2467
2488
|
if (fetchedAny) {
|
|
2468
2489
|
this.keys = next;
|
|
@@ -2868,10 +2889,10 @@ function dictMemberValue(header2, key) {
|
|
|
2868
2889
|
function parseSignatureInput(value) {
|
|
2869
2890
|
return parseDictionary(value).map((d) => {
|
|
2870
2891
|
if (!d.isList) throw new Error(`Signature-Input member ${d.key} is not an inner list`);
|
|
2871
|
-
const components = d.items.map((
|
|
2872
|
-
if (typeof
|
|
2873
|
-
const keyParam =
|
|
2874
|
-
return { name:
|
|
2892
|
+
const components = d.items.map((it2) => {
|
|
2893
|
+
if (typeof it2.value !== "string") throw new Error("component identifier is not a string");
|
|
2894
|
+
const keyParam = it2.params.get("key");
|
|
2895
|
+
return { name: it2.value, keyParam: typeof keyParam === "string" ? keyParam : void 0 };
|
|
2875
2896
|
});
|
|
2876
2897
|
return { label: d.key, components, params: d.params, raw: d.raw };
|
|
2877
2898
|
});
|
|
@@ -2960,8 +2981,8 @@ function isRequest(input) {
|
|
|
2960
2981
|
}
|
|
2961
2982
|
function toHeaders(record) {
|
|
2962
2983
|
const h = new Headers();
|
|
2963
|
-
for (const [
|
|
2964
|
-
if (v !== void 0 && v !== null) h.set(
|
|
2984
|
+
for (const [k2, v] of Object.entries(record)) {
|
|
2985
|
+
if (v !== void 0 && v !== null) h.set(k2, String(v));
|
|
2965
2986
|
}
|
|
2966
2987
|
return h;
|
|
2967
2988
|
}
|
|
@@ -2990,9 +3011,9 @@ function readEdgeVerdict(headers) {
|
|
|
2990
3011
|
let clearanceRaw;
|
|
2991
3012
|
let classRaw;
|
|
2992
3013
|
for (const key of Object.keys(headers)) {
|
|
2993
|
-
const
|
|
2994
|
-
if (
|
|
2995
|
-
else if (
|
|
3014
|
+
const k2 = key.toLowerCase();
|
|
3015
|
+
if (k2 === EDGE_CLEARANCE_HEADER) clearanceRaw = headers[key];
|
|
3016
|
+
else if (k2 === EDGE_CLASS_HEADER) classRaw = headers[key];
|
|
2996
3017
|
}
|
|
2997
3018
|
const clearance = clearanceRaw?.trim() || void 0;
|
|
2998
3019
|
const cls = normaliseClass(classRaw);
|
|
@@ -3905,6 +3926,1201 @@ function resolveClientIp(options) {
|
|
|
3905
3926
|
return full[0] ?? void 0 ?? singleHeaderFallback() ?? peer;
|
|
3906
3927
|
}
|
|
3907
3928
|
|
|
3929
|
+
// src/clearance/gate.generated.js
|
|
3930
|
+
var k = { "chat.deepseek.com": "DeepSeek", "chat.openai.com": "ChatGPT", "chatgpt.com": "ChatGPT", "claude.ai": "Claude", "copilot.microsoft.com": "Copilot", "deepseek.com": "DeepSeek", "gemini.google.com": "Gemini", "grok.com": "Grok", "kagi.com": "Kagi", "meta.ai": "Meta AI", "perplexity.ai": "Perplexity", "phind.com": "Phind", "www.deepseek.com": "DeepSeek", "www.grok.com": "Grok", "www.kagi.com": "Kagi", "www.meta.ai": "Meta AI", "www.perplexity.ai": "Perplexity", "www.phind.com": "Phind", "www.you.com": "You.com", "you.com": "You.com" };
|
|
3931
|
+
var tt = ["utm_source", "ref", "utm_medium"];
|
|
3932
|
+
var oe = 500;
|
|
3933
|
+
function rt(e, t) {
|
|
3934
|
+
let r = (e ?? "").trim();
|
|
3935
|
+
if (r) try {
|
|
3936
|
+
return k[new URL(r).hostname.toLowerCase()] ?? "";
|
|
3937
|
+
} catch {
|
|
3938
|
+
return "";
|
|
3939
|
+
}
|
|
3940
|
+
let n;
|
|
3941
|
+
try {
|
|
3942
|
+
n = new URL(t);
|
|
3943
|
+
} catch {
|
|
3944
|
+
return "";
|
|
3945
|
+
}
|
|
3946
|
+
for (let o of tt) for (let a of n.searchParams.getAll(o)) {
|
|
3947
|
+
let i = nt(a);
|
|
3948
|
+
if (i) return i;
|
|
3949
|
+
}
|
|
3950
|
+
return "";
|
|
3951
|
+
}
|
|
3952
|
+
var ae = (e) => e.replace(/[ \-_.]/g, "");
|
|
3953
|
+
function nt(e) {
|
|
3954
|
+
let t = e.trim().toLowerCase();
|
|
3955
|
+
if (!t) return "";
|
|
3956
|
+
try {
|
|
3957
|
+
let n = new URL(t).hostname;
|
|
3958
|
+
n && (t = n.toLowerCase());
|
|
3959
|
+
} catch {
|
|
3960
|
+
}
|
|
3961
|
+
if (t = t.replace(/\.$/, ""), k[t]) return k[t];
|
|
3962
|
+
let r = ae(t);
|
|
3963
|
+
for (let [n, o] of Object.entries(k)) if (r === ae(o.toLowerCase()) || r === n.replace(/^www\./, "").replace(/\./g, "")) return o;
|
|
3964
|
+
return "";
|
|
3965
|
+
}
|
|
3966
|
+
function ie(e, t) {
|
|
3967
|
+
if (e.method !== "GET") return null;
|
|
3968
|
+
let r = e.headers;
|
|
3969
|
+
if (r.get("sec-fetch-mode") !== "navigate") return null;
|
|
3970
|
+
let n = r.get("sec-fetch-dest");
|
|
3971
|
+
if (n && n !== "document") return null;
|
|
3972
|
+
let o = rt(r.get("referer") ?? "", t.toString());
|
|
3973
|
+
if (!o) return null;
|
|
3974
|
+
let a = t.pathname || "/";
|
|
3975
|
+
return a.length > oe && (a = a.slice(0, oe)), { platform: o, path: a };
|
|
3976
|
+
}
|
|
3977
|
+
var ot = "web-bot-auth";
|
|
3978
|
+
async function se(e, t) {
|
|
3979
|
+
let r = e.headers.get("signature-input"), n = e.headers.get("signature");
|
|
3980
|
+
if (!r && !n) return { status: "none" };
|
|
3981
|
+
if (!r || !n) return { status: "invalid" };
|
|
3982
|
+
if (!t || t.length === 0) return { status: "unknown_key" };
|
|
3983
|
+
let o, a;
|
|
3984
|
+
try {
|
|
3985
|
+
o = ut(r), a = gt(n);
|
|
3986
|
+
} catch {
|
|
3987
|
+
return { status: "invalid" };
|
|
3988
|
+
}
|
|
3989
|
+
let i = false, s = false;
|
|
3990
|
+
for (let c of o) {
|
|
3991
|
+
if (c.params.get("tag") !== ot) continue;
|
|
3992
|
+
i = true;
|
|
3993
|
+
let u = a.get(c.label);
|
|
3994
|
+
if (!u) continue;
|
|
3995
|
+
let p = c.params.get("keyid");
|
|
3996
|
+
if (typeof p != "string") continue;
|
|
3997
|
+
let w;
|
|
3998
|
+
try {
|
|
3999
|
+
w = at(e, c);
|
|
4000
|
+
} catch {
|
|
4001
|
+
s || (s = t.some((f) => f.keyid === p));
|
|
4002
|
+
continue;
|
|
4003
|
+
}
|
|
4004
|
+
let d = t.find((f) => {
|
|
4005
|
+
if (f.keyid !== p) return false;
|
|
4006
|
+
try {
|
|
4007
|
+
return ce(f.directory) === w;
|
|
4008
|
+
} catch {
|
|
4009
|
+
return false;
|
|
4010
|
+
}
|
|
4011
|
+
});
|
|
4012
|
+
if (!d) continue;
|
|
4013
|
+
s = true;
|
|
4014
|
+
let y = Date.now() / 1e3, b = c.params.get("created"), g = c.params.get("expires");
|
|
4015
|
+
if (typeof b != "number" || typeof g != "number" || y >= g + 10 || y + 10 < b || g <= b || g - b > 1440 * 60 || !c.components.some((f) => f.name === "@authority" || f.name === "@target-uri")) continue;
|
|
4016
|
+
let A;
|
|
4017
|
+
try {
|
|
4018
|
+
A = it(e, c);
|
|
4019
|
+
} catch {
|
|
4020
|
+
continue;
|
|
4021
|
+
}
|
|
4022
|
+
let l = false;
|
|
4023
|
+
try {
|
|
4024
|
+
let f = await crypto.subtle.importKey("raw", pe(d.public_key), { name: "Ed25519" }, false, ["verify"]);
|
|
4025
|
+
l = await crypto.subtle.verify({ name: "Ed25519" }, f, u, new TextEncoder().encode(A));
|
|
4026
|
+
} catch {
|
|
4027
|
+
l = false;
|
|
4028
|
+
}
|
|
4029
|
+
if (l) return { status: "verified", name: d.name, category: d.category, keyid: p };
|
|
4030
|
+
}
|
|
4031
|
+
return s ? { status: "invalid" } : i ? { status: "unknown_key" } : { status: "none" };
|
|
4032
|
+
}
|
|
4033
|
+
function at(e, t) {
|
|
4034
|
+
let r = e.headers.get("signature-agent");
|
|
4035
|
+
if (r === null) throw new Error("missing signature-agent");
|
|
4036
|
+
let n = t.components.find((i) => i.name.toLowerCase() === "signature-agent");
|
|
4037
|
+
if (!n) throw new Error("signature-agent is not covered");
|
|
4038
|
+
let o = r.trim(), a;
|
|
4039
|
+
if (o.startsWith('"')) {
|
|
4040
|
+
if (n.keyParam !== void 0) throw new Error("legacy string cannot select a member");
|
|
4041
|
+
let i = new P(o);
|
|
4042
|
+
if (a = fe(i), i.skipSP(), !i.eof()) throw new Error("trailing signature-agent data");
|
|
4043
|
+
} else {
|
|
4044
|
+
if (n.keyParam === void 0) throw new Error("dictionary member is not covered");
|
|
4045
|
+
let i = T(o).find((c) => c.key === n.keyParam), s = i?.items[0]?.value;
|
|
4046
|
+
if (!i || i.isList || i.items.length !== 1 || typeof s != "string") throw new Error("signature-agent member is not a string");
|
|
4047
|
+
a = s;
|
|
4048
|
+
}
|
|
4049
|
+
return ce(a);
|
|
4050
|
+
}
|
|
4051
|
+
function ce(e) {
|
|
4052
|
+
let t = new URL(e);
|
|
4053
|
+
if (t.protocol !== "https:" || !t.hostname || t.username || t.password) throw new Error("signature-agent must be an https URL");
|
|
4054
|
+
return `https://${H(t)}`;
|
|
4055
|
+
}
|
|
4056
|
+
function it(e, t) {
|
|
4057
|
+
let r = new URL(e.url), n = [];
|
|
4058
|
+
for (let o of t.components) n.push(`${st(o)}: ${ct(e, r, o)}`);
|
|
4059
|
+
return n.push(`"@signature-params": ${t.raw.trim()}`), n.join(`
|
|
4060
|
+
`);
|
|
4061
|
+
}
|
|
4062
|
+
function st(e) {
|
|
4063
|
+
let t = `"${e.name.toLowerCase()}"`;
|
|
4064
|
+
return e.keyParam !== void 0 ? `${t};key="${e.keyParam}"` : t;
|
|
4065
|
+
}
|
|
4066
|
+
function ct(e, t, r) {
|
|
4067
|
+
let n = r.name.toLowerCase();
|
|
4068
|
+
if (n === "@authority") return H(t);
|
|
4069
|
+
if (n === "@target-uri") return `${t.protocol}//${H(t)}${t.pathname}${t.search}`;
|
|
4070
|
+
if (n === "signature-agent") {
|
|
4071
|
+
let o = e.headers.get("signature-agent");
|
|
4072
|
+
if (o === null) throw new Error("signature-agent covered but absent");
|
|
4073
|
+
return r.keyParam !== void 0 ? lt(o, r.keyParam) : o.trim().replace(/\s+/g, " ");
|
|
4074
|
+
}
|
|
4075
|
+
throw new Error(`unsupported covered component ${n}`);
|
|
4076
|
+
}
|
|
4077
|
+
function H(e) {
|
|
4078
|
+
let t = e.hostname.toLowerCase(), r = e.port;
|
|
4079
|
+
return !r || e.protocol === "https:" && r === "443" || e.protocol === "http:" && r === "80" ? t : `${t}:${r}`;
|
|
4080
|
+
}
|
|
4081
|
+
function lt(e, t) {
|
|
4082
|
+
let n = T(e).find((o) => o.key === t);
|
|
4083
|
+
if (!n) throw new Error(`signature-agent has no member ${t}`);
|
|
4084
|
+
return n.raw;
|
|
4085
|
+
}
|
|
4086
|
+
function ut(e) {
|
|
4087
|
+
return T(e).map((r) => {
|
|
4088
|
+
if (!r.isList) throw new Error(`Signature-Input member ${r.key} is not an inner list`);
|
|
4089
|
+
let n = r.items.map((o) => {
|
|
4090
|
+
if (typeof o.value != "string") throw new Error("component identifier is not a string");
|
|
4091
|
+
let a = o.params.get("key");
|
|
4092
|
+
return { name: o.value, keyParam: typeof a == "string" ? a : void 0 };
|
|
4093
|
+
});
|
|
4094
|
+
return { label: r.key, components: n, params: r.params, raw: r.raw };
|
|
4095
|
+
});
|
|
4096
|
+
}
|
|
4097
|
+
function gt(e) {
|
|
4098
|
+
let t = T(e), r = /* @__PURE__ */ new Map();
|
|
4099
|
+
for (let n of t) {
|
|
4100
|
+
if (n.isList || n.items.length !== 1) throw new Error(`Signature member ${n.key} is not a byte sequence`);
|
|
4101
|
+
let o = n.items[0].bytes;
|
|
4102
|
+
if (!o) throw new Error(`Signature member ${n.key} is not a byte sequence`);
|
|
4103
|
+
r.set(n.key, o);
|
|
4104
|
+
}
|
|
4105
|
+
return r;
|
|
4106
|
+
}
|
|
4107
|
+
var P = class {
|
|
4108
|
+
constructor(t, r = 0) {
|
|
4109
|
+
this.s = t;
|
|
4110
|
+
this.i = r;
|
|
4111
|
+
}
|
|
4112
|
+
eof() {
|
|
4113
|
+
return this.i >= this.s.length;
|
|
4114
|
+
}
|
|
4115
|
+
peek() {
|
|
4116
|
+
return this.s[this.i];
|
|
4117
|
+
}
|
|
4118
|
+
skipSP() {
|
|
4119
|
+
for (; !this.eof() && (this.peek() === " " || this.peek() === " "); ) this.i++;
|
|
4120
|
+
}
|
|
4121
|
+
};
|
|
4122
|
+
function T(e) {
|
|
4123
|
+
let t = new P(e), r = [];
|
|
4124
|
+
for (t.skipSP(); !t.eof(); ) {
|
|
4125
|
+
let o = { key: ue(t), raw: "", isList: false, items: [], params: /* @__PURE__ */ new Map() };
|
|
4126
|
+
if (!t.eof() && t.peek() === "=") {
|
|
4127
|
+
t.i++;
|
|
4128
|
+
let a = t.i;
|
|
4129
|
+
if (!t.eof() && t.peek() === "(") o.isList = true, ft(t, o);
|
|
4130
|
+
else {
|
|
4131
|
+
let { value: i, params: s, bytes: c } = le(t);
|
|
4132
|
+
o.items.push({ value: i, params: s, ...c ? { bytes: c } : {} });
|
|
4133
|
+
}
|
|
4134
|
+
o.raw = e.slice(a, t.i);
|
|
4135
|
+
} else o.params = K(t), o.items.push({ value: true, params: /* @__PURE__ */ new Map() });
|
|
4136
|
+
if (r.push(o), t.skipSP(), t.eof()) break;
|
|
4137
|
+
if (t.peek() !== ",") throw new Error(`expected ',' at ${t.i}`);
|
|
4138
|
+
if (t.i++, t.skipSP(), t.eof()) throw new Error("trailing comma");
|
|
4139
|
+
}
|
|
4140
|
+
return r;
|
|
4141
|
+
}
|
|
4142
|
+
function ft(e, t) {
|
|
4143
|
+
for (e.i++; ; ) {
|
|
4144
|
+
if (e.skipSP(), e.eof()) throw new Error("unterminated inner list");
|
|
4145
|
+
if (e.peek() === ")") {
|
|
4146
|
+
e.i++;
|
|
4147
|
+
break;
|
|
4148
|
+
}
|
|
4149
|
+
let { value: r, params: n } = le(e);
|
|
4150
|
+
if (t.items.push({ value: r, params: n }), e.eof()) throw new Error("unterminated inner list");
|
|
4151
|
+
let o = e.peek();
|
|
4152
|
+
if (o !== " " && o !== ")") throw new Error(`bad inner list at ${e.i}`);
|
|
4153
|
+
}
|
|
4154
|
+
t.params = K(e);
|
|
4155
|
+
}
|
|
4156
|
+
function le(e) {
|
|
4157
|
+
let { value: t, bytes: r } = ge(e), n = K(e);
|
|
4158
|
+
return { value: t, params: n, bytes: r };
|
|
4159
|
+
}
|
|
4160
|
+
function K(e) {
|
|
4161
|
+
let t = /* @__PURE__ */ new Map();
|
|
4162
|
+
for (; !e.eof() && e.peek() === ";"; ) {
|
|
4163
|
+
e.i++, e.skipSP();
|
|
4164
|
+
let r = ue(e), n = true;
|
|
4165
|
+
if (!e.eof() && e.peek() === "=") {
|
|
4166
|
+
e.i++;
|
|
4167
|
+
let o = ge(e);
|
|
4168
|
+
n = (typeof o.value == "boolean", o.value);
|
|
4169
|
+
}
|
|
4170
|
+
typeof n != "boolean" && t.set(r, n);
|
|
4171
|
+
}
|
|
4172
|
+
return t;
|
|
4173
|
+
}
|
|
4174
|
+
function ue(e) {
|
|
4175
|
+
let t = e.peek();
|
|
4176
|
+
if (!t || !/[a-z*]/.test(t)) throw new Error(`invalid key at ${e.i}`);
|
|
4177
|
+
let r = e.i;
|
|
4178
|
+
for (; !e.eof() && /[a-z0-9_\-.*]/.test(e.peek()); ) e.i++;
|
|
4179
|
+
return e.s.slice(r, e.i);
|
|
4180
|
+
}
|
|
4181
|
+
function ge(e) {
|
|
4182
|
+
let t = e.peek();
|
|
4183
|
+
if (t === '"') return { value: fe(e) };
|
|
4184
|
+
if (t === ":") return { value: "", bytes: pt(e) };
|
|
4185
|
+
if (t === "?") {
|
|
4186
|
+
e.i++;
|
|
4187
|
+
let r = e.peek();
|
|
4188
|
+
if (e.i++, r === "1") return { value: true };
|
|
4189
|
+
if (r === "0") return { value: false };
|
|
4190
|
+
throw new Error("bad boolean");
|
|
4191
|
+
}
|
|
4192
|
+
if (t === "-" || /[0-9]/.test(t)) return { value: dt(e) };
|
|
4193
|
+
if (/[a-zA-Z*]/.test(t)) return { value: ht(e) };
|
|
4194
|
+
throw new Error(`invalid bare item at ${e.i}`);
|
|
4195
|
+
}
|
|
4196
|
+
function fe(e) {
|
|
4197
|
+
e.i++;
|
|
4198
|
+
let t = "";
|
|
4199
|
+
for (; !e.eof(); ) {
|
|
4200
|
+
let r = e.s[e.i++];
|
|
4201
|
+
if (r === '"') return t;
|
|
4202
|
+
if (r === "\\") {
|
|
4203
|
+
let n = e.s[e.i++];
|
|
4204
|
+
if (n !== '"' && n !== "\\") throw new Error("bad escape");
|
|
4205
|
+
t += n;
|
|
4206
|
+
} else {
|
|
4207
|
+
let n = r.charCodeAt(0);
|
|
4208
|
+
if (n < 32 || n > 126) throw new Error("bad char in string");
|
|
4209
|
+
t += r;
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4212
|
+
throw new Error("unterminated string");
|
|
4213
|
+
}
|
|
4214
|
+
function pt(e) {
|
|
4215
|
+
e.i++;
|
|
4216
|
+
let t = e.i;
|
|
4217
|
+
for (; !e.eof() && e.peek() !== ":"; ) e.i++;
|
|
4218
|
+
if (e.eof()) throw new Error("unterminated byte sequence");
|
|
4219
|
+
let r = e.s.slice(t, e.i);
|
|
4220
|
+
return e.i++, pe(r);
|
|
4221
|
+
}
|
|
4222
|
+
function dt(e) {
|
|
4223
|
+
let t = e.i;
|
|
4224
|
+
for (e.peek() === "-" && e.i++; !e.eof() && /[0-9]/.test(e.peek()); ) e.i++;
|
|
4225
|
+
if (!e.eof() && e.peek() === ".") for (e.i++; !e.eof() && /[0-9]/.test(e.peek()); ) e.i++;
|
|
4226
|
+
return Number(e.s.slice(t, e.i));
|
|
4227
|
+
}
|
|
4228
|
+
function ht(e) {
|
|
4229
|
+
let t = e.i;
|
|
4230
|
+
for (e.i++; !e.eof() && /[a-zA-Z0-9!#$%&'*+\-.^_`|~:/]/.test(e.peek()); ) e.i++;
|
|
4231
|
+
return e.s.slice(t, e.i);
|
|
4232
|
+
}
|
|
4233
|
+
function pe(e) {
|
|
4234
|
+
let t = atob(e), r = new Uint8Array(new ArrayBuffer(t.length));
|
|
4235
|
+
for (let n = 0; n < t.length; n++) r[n] = t.charCodeAt(n);
|
|
4236
|
+
return r;
|
|
4237
|
+
}
|
|
4238
|
+
function de(e, t) {
|
|
4239
|
+
return e === "ai_crawlers" ? t.ai_crawlers : e === "search_engines" ? t.search_engines : e === "monitoring" ? t.monitoring : false;
|
|
4240
|
+
}
|
|
4241
|
+
var z = { "attested-human": 2, "human-likely": 1, clean: 0 };
|
|
4242
|
+
function mt(e) {
|
|
4243
|
+
return z[e ?? ""] ?? 0;
|
|
4244
|
+
}
|
|
4245
|
+
function V(e) {
|
|
4246
|
+
return e > 0 ? Object.keys(z).find((t) => z[t] === e) ?? "" : "";
|
|
4247
|
+
}
|
|
4248
|
+
function he(e) {
|
|
4249
|
+
return e = wt(e), e = yt(e), e.toLowerCase();
|
|
4250
|
+
}
|
|
4251
|
+
function wt(e) {
|
|
4252
|
+
for (let t = 0; t < 4; t++) {
|
|
4253
|
+
let r = bt(e);
|
|
4254
|
+
if (r === e) break;
|
|
4255
|
+
e = r;
|
|
4256
|
+
}
|
|
4257
|
+
return e;
|
|
4258
|
+
}
|
|
4259
|
+
function bt(e) {
|
|
4260
|
+
if (!e.includes("%")) return e;
|
|
4261
|
+
let t = "";
|
|
4262
|
+
for (let r = 0; r < e.length; r++) {
|
|
4263
|
+
if (e[r] === "%" && r + 2 < e.length) {
|
|
4264
|
+
let n = me(e.charCodeAt(r + 1)), o = me(e.charCodeAt(r + 2));
|
|
4265
|
+
if (n >= 0 && o >= 0) {
|
|
4266
|
+
let a = n << 4 | o;
|
|
4267
|
+
if (a < 128) {
|
|
4268
|
+
t += String.fromCharCode(a), r += 2;
|
|
4269
|
+
continue;
|
|
4270
|
+
}
|
|
4271
|
+
}
|
|
4272
|
+
}
|
|
4273
|
+
t += e[r];
|
|
4274
|
+
}
|
|
4275
|
+
return t;
|
|
4276
|
+
}
|
|
4277
|
+
function me(e) {
|
|
4278
|
+
return e >= 48 && e <= 57 ? e - 48 : e >= 97 && e <= 102 ? e - 97 + 10 : e >= 65 && e <= 70 ? e - 65 + 10 : -1;
|
|
4279
|
+
}
|
|
4280
|
+
function yt(e) {
|
|
4281
|
+
if (e === "") return e;
|
|
4282
|
+
let t = e.length > 1 && e[e.length - 1] === "/", r = [];
|
|
4283
|
+
for (let o of e.split("/")) if (!(o === "" || o === ".")) {
|
|
4284
|
+
if (o === "..") {
|
|
4285
|
+
r.length > 0 && r.pop();
|
|
4286
|
+
continue;
|
|
4287
|
+
}
|
|
4288
|
+
r.push(o);
|
|
4289
|
+
}
|
|
4290
|
+
let n = "/" + r.join("/");
|
|
4291
|
+
return t && n !== "/" && (n += "/"), n;
|
|
4292
|
+
}
|
|
4293
|
+
function O(e, t) {
|
|
4294
|
+
let r = he(e), n = he(t);
|
|
4295
|
+
if (n.endsWith("/*")) {
|
|
4296
|
+
let o = n.slice(0, -2);
|
|
4297
|
+
return o === "" ? true : r === o || r.startsWith(o + "/");
|
|
4298
|
+
}
|
|
4299
|
+
return r === n;
|
|
4300
|
+
}
|
|
4301
|
+
function B(e) {
|
|
4302
|
+
return e.endsWith("/*") ? e.length - 2 : 1 << 20;
|
|
4303
|
+
}
|
|
4304
|
+
function we(e, t, r) {
|
|
4305
|
+
let n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), a = [], i = [], s = /* @__PURE__ */ new Map(), c = (l, f) => {
|
|
4306
|
+
let v = new Set(l);
|
|
4307
|
+
for (let R of f) for (let _ of s.get(R) ?? []) v.add(_);
|
|
4308
|
+
return v.size === 0 ? void 0 : [...v].sort();
|
|
4309
|
+
}, u = (l, f, v) => v ? { pattern: l, required_trust: f, refused_behaviors: v } : { pattern: l, required_trust: f };
|
|
4310
|
+
for (let l of t) {
|
|
4311
|
+
if (!O(e, l.pattern)) continue;
|
|
4312
|
+
if ((l.exceptions ?? []).some((R) => O(e, R))) {
|
|
4313
|
+
i.push(l.pattern);
|
|
4314
|
+
continue;
|
|
4315
|
+
}
|
|
4316
|
+
let f = n.get(l.pattern);
|
|
4317
|
+
f === void 0 && a.push(l.pattern);
|
|
4318
|
+
let v = mt(l.min_trust);
|
|
4319
|
+
(f === void 0 || v > f) && n.set(l.pattern, v), l.mode !== "monitor" && o.add(l.pattern);
|
|
4320
|
+
for (let R of l.refuse_behaviors ?? []) s.has(l.pattern) || s.set(l.pattern, /* @__PURE__ */ new Set()), s.get(l.pattern)?.add(R);
|
|
4321
|
+
}
|
|
4322
|
+
let p = [];
|
|
4323
|
+
if (a.length === 0) {
|
|
4324
|
+
let l = "";
|
|
4325
|
+
for (let f of i) (l === "" || B(f) > B(l)) && (l = f);
|
|
4326
|
+
return { covering: a, deciding_mode: "", attributed: "", required_trust: "", requirement_source: "", previews: p, excepted_by: l, refused_behaviors: [] };
|
|
4327
|
+
}
|
|
4328
|
+
a.sort((l, f) => B(f) - B(l));
|
|
4329
|
+
let w = r === "monitor", d = a.filter((l) => o.has(l)), y = w ? "monitor" : "enforce";
|
|
4330
|
+
if (d.length === 0) {
|
|
4331
|
+
if (!w) for (let l of a) p.push(u(l, V(n.get(l) ?? 0), c([], [l])));
|
|
4332
|
+
d = a, y = "monitor";
|
|
4333
|
+
}
|
|
4334
|
+
let b = 0, g = "";
|
|
4335
|
+
for (let l of d) {
|
|
4336
|
+
let f = n.get(l) ?? 0;
|
|
4337
|
+
f > b && (b = f, g = l);
|
|
4338
|
+
}
|
|
4339
|
+
let A = c([], d) ?? [];
|
|
4340
|
+
if (y === "enforce") for (let l of a) o.has(l) || p.push(u(l, V(Math.max(b, n.get(l) ?? 0)), c(A, [l])));
|
|
4341
|
+
return { covering: a, deciding_mode: y, attributed: d[0], required_trust: V(b), requirement_source: g, previews: p, excepted_by: "", refused_behaviors: A };
|
|
4342
|
+
}
|
|
4343
|
+
var vt = "other";
|
|
4344
|
+
var _t = { "search engine crawler": "search", "ai search": "search", "ai assistant": "agent", "ai crawler": "training", "page preview": "link_preview", "feed fetcher": "feeds", "monitoring & analytics": "monitoring", "search engine optimization": "seo", security: "security_testing" };
|
|
4345
|
+
function I(e) {
|
|
4346
|
+
let t = e.trim().toLowerCase();
|
|
4347
|
+
return t ? _t[t] ?? vt : "";
|
|
4348
|
+
}
|
|
4349
|
+
function W(e, t) {
|
|
4350
|
+
let r = I(e);
|
|
4351
|
+
return r !== "" && t.includes(r);
|
|
4352
|
+
}
|
|
4353
|
+
var xt = { search_engines: ["search engine crawler"], ai_crawlers: ["ai assistant", "ai crawler", "ai search"], monitoring: ["monitoring & analytics"] };
|
|
4354
|
+
function be(e, t) {
|
|
4355
|
+
let r = xt[e];
|
|
4356
|
+
return r ? r.every((n) => W(n, t)) : false;
|
|
4357
|
+
}
|
|
4358
|
+
var At = O;
|
|
4359
|
+
function ye(e, t, r) {
|
|
4360
|
+
return e ? t ? t.some((n) => At(r, n)) : true : false;
|
|
4361
|
+
}
|
|
4362
|
+
var Rt = "x-wd-service-token";
|
|
4363
|
+
var Ct = "wd_clearance";
|
|
4364
|
+
function ve(e, t, r = []) {
|
|
4365
|
+
if (e.graded && t && !Bt(e.graded.trust, t)) return { pass: false, label: "insufficient-trust" };
|
|
4366
|
+
if (e.crawler && r.length > 0) {
|
|
4367
|
+
if (e.crawler.behavior && r.includes(e.crawler.behavior)) return { pass: false, label: "crawler-refused" };
|
|
4368
|
+
if (!e.crawler.behavior && e.crawler.exempted) return { pass: false, label: "missing" };
|
|
4369
|
+
}
|
|
4370
|
+
return { pass: e.pass, label: e.label };
|
|
4371
|
+
}
|
|
4372
|
+
async function Re(e, t, r) {
|
|
4373
|
+
let n = new URL(e.url).pathname, o = we(n, Pt(t), t.mode), a = o.deciding_mode || t.mode, i = await kt(e, t, r, o.covering.length > 0, o.excepted_by !== ""), s = i.behavior ?? "", c = ve(i, o.required_trust, o.refused_behaviors), u = c.label === "excepted" ? o.excepted_by : c.label === "unscoped" ? "" : o.attributed, p = !c.pass && a === "enforce", w = o.previews.map((d) => {
|
|
4374
|
+
let y = ve(i, d.required_trust, d.refused_behaviors ?? []);
|
|
4375
|
+
return { pattern: d.pattern, refused: !y.pass && !p ? y.label : "" };
|
|
4376
|
+
});
|
|
4377
|
+
return { pass: c.pass, label: c.label, pattern: u, mode: a, previews: w, behavior: c.pass ? s : "", crawlerBehavior: i.crawler?.behavior ?? "", referral: ie(e, new URL(e.url)), outsideReach: i.outsideReach ?? "" };
|
|
4378
|
+
}
|
|
4379
|
+
async function kt(e, t, r, n, o) {
|
|
4380
|
+
let a = await St(e, t, r);
|
|
4381
|
+
if (a.grants) return { pass: true, label: "machine" };
|
|
4382
|
+
let i = await Et(e, t, r, n, o);
|
|
4383
|
+
return a.outsideReach ? { ...i, outsideReach: a.outsideReach } : i;
|
|
4384
|
+
}
|
|
4385
|
+
async function St(e, t, r) {
|
|
4386
|
+
let n = e.headers.get(Rt);
|
|
4387
|
+
if (!n) return { grants: false, outsideReach: "" };
|
|
4388
|
+
let o = await ke(n, t.keys, r.siteKey);
|
|
4389
|
+
if (!o || o.typ !== "machine" || !o.sub) return { grants: false, outsideReach: "" };
|
|
4390
|
+
if (t.active_credentials.includes(o.sub)) return { grants: true, outsideReach: "" };
|
|
4391
|
+
let a = (t.restricted_credentials ?? []).find((s) => s && s.id === o.sub);
|
|
4392
|
+
if (!a) return { grants: false, outsideReach: "" };
|
|
4393
|
+
let i = new URL(e.url).pathname;
|
|
4394
|
+
return ye(a.here, a.paths, i) ? { grants: true, outsideReach: "" } : { grants: false, outsideReach: o.sub };
|
|
4395
|
+
}
|
|
4396
|
+
async function Et(e, t, r, n, o) {
|
|
4397
|
+
let a = await r.verifiedBotCategory(e, n) || "", i = a ? { behavior: I(a), exempted: false } : void 0;
|
|
4398
|
+
if (a && Ot(a, t)) {
|
|
4399
|
+
let p = I(a);
|
|
4400
|
+
return { pass: true, label: "verified-bot", behavior: p, crawler: { behavior: p, exempted: true } };
|
|
4401
|
+
}
|
|
4402
|
+
let s = await se(e, t.signed_agents);
|
|
4403
|
+
if (s.status === "verified" && It(s.category, t)) return { pass: true, label: "signed-agent", behavior: xe(s.category), crawler: { behavior: xe(s.category), exempted: true } };
|
|
4404
|
+
if (s.status === "invalid" && n) return { pass: false, label: "agent-impersonation", crawler: i };
|
|
4405
|
+
if (!n) return o ? { pass: true, label: "excepted", crawler: i } : { pass: true, label: "unscoped", crawler: i };
|
|
4406
|
+
let c = j(e.headers.get("cookie") ?? "", Ct);
|
|
4407
|
+
if (!c) return { pass: false, label: "missing", crawler: i };
|
|
4408
|
+
let u = await ke(c, t.keys, r.siteKey);
|
|
4409
|
+
return !u || (u.typ ?? "") !== "" ? { pass: false, label: "invalid", crawler: i } : t.denied_fps && t.denied_fps.includes(u.fp) ? { pass: false, label: "revoked", crawler: i } : { pass: true, label: "valid", graded: { trust: u.trust }, crawler: i };
|
|
4410
|
+
}
|
|
4411
|
+
function Pt(e) {
|
|
4412
|
+
let t = new Set(e.routes), r = /* @__PURE__ */ new Map();
|
|
4413
|
+
for (let o of e.route_exceptions ?? []) t.has(o.pattern) && Array.isArray(o.except) && r.set(o.pattern, o.except);
|
|
4414
|
+
let n = e.routes.map((o) => ({ pattern: o, exceptions: r.get(o) }));
|
|
4415
|
+
for (let o of e.route_min_trust ?? []) t.has(o.pattern) && n.push({ pattern: o.pattern, min_trust: o.min_trust, exceptions: r.get(o.pattern) });
|
|
4416
|
+
for (let o of e.monitor_routes ?? []) n.push({ pattern: o.pattern, min_trust: o.min_trust, mode: "monitor", exceptions: o.except });
|
|
4417
|
+
for (let o of e.route_refusals ?? []) !Array.isArray(o.refuse_behaviors) || o.refuse_behaviors.length === 0 || (o.mode === "monitor" ? n.push({ pattern: o.pattern, mode: "monitor", refuse_behaviors: o.refuse_behaviors }) : t.has(o.pattern) && n.push({ pattern: o.pattern, exceptions: r.get(o.pattern), refuse_behaviors: o.refuse_behaviors }));
|
|
4418
|
+
return n;
|
|
4419
|
+
}
|
|
4420
|
+
var Tt = { "attested-human": 2, "human-likely": 1, clean: 0 };
|
|
4421
|
+
function _e(e) {
|
|
4422
|
+
return Tt[e ?? ""] ?? 0;
|
|
4423
|
+
}
|
|
4424
|
+
function Bt(e, t) {
|
|
4425
|
+
return _e(e) >= _e(t);
|
|
4426
|
+
}
|
|
4427
|
+
function Ot(e, t) {
|
|
4428
|
+
let r = t.allow_behaviors;
|
|
4429
|
+
return r ? W(e, r) : Dt(e, t.allow);
|
|
4430
|
+
}
|
|
4431
|
+
function It(e, t) {
|
|
4432
|
+
let r = t.allow_behaviors;
|
|
4433
|
+
return r ? be(e, r) : de(e, t.allow);
|
|
4434
|
+
}
|
|
4435
|
+
function xe(e) {
|
|
4436
|
+
return e === "search_engines" ? "search" : e === "monitoring" ? "monitoring" : "";
|
|
4437
|
+
}
|
|
4438
|
+
function Dt(e, t) {
|
|
4439
|
+
let r = e.trim().toLowerCase();
|
|
4440
|
+
return !!(t.search_engines && r.includes("search engine crawler") || t.ai_crawlers && r.startsWith("ai ") || t.monitoring && r.includes("monitoring"));
|
|
4441
|
+
}
|
|
4442
|
+
function F(e) {
|
|
4443
|
+
return !e.pass && e.mode === "enforce" && (e.label === "missing" || e.label === "invalid");
|
|
4444
|
+
}
|
|
4445
|
+
function Ce(e) {
|
|
4446
|
+
return F(e) ? { ...e, pass: true, label: "outage-pass" } : e;
|
|
4447
|
+
}
|
|
4448
|
+
function j(e, t) {
|
|
4449
|
+
for (let r of e.split(";")) {
|
|
4450
|
+
let n = r.indexOf("=");
|
|
4451
|
+
if (!(n < 0) && r.slice(0, n).trim() === t) return r.slice(n + 1).trim() || null;
|
|
4452
|
+
}
|
|
4453
|
+
return null;
|
|
4454
|
+
}
|
|
4455
|
+
async function ke(e, t, r) {
|
|
4456
|
+
try {
|
|
4457
|
+
let n = e.indexOf(".");
|
|
4458
|
+
if (n < 0) return null;
|
|
4459
|
+
let o = Ae(e.slice(0, n)), a = Ae(e.slice(n + 1)), i = JSON.parse(new TextDecoder().decode(o)), s = t.find((p) => p.kid === i.kid);
|
|
4460
|
+
if (!s) return null;
|
|
4461
|
+
let c = await crypto.subtle.importKey("raw", Mt(s.public_key), { name: "Ed25519" }, false, ["verify"]);
|
|
4462
|
+
return !await crypto.subtle.verify({ name: "Ed25519" }, c, a, o) || i.tenant !== r || Date.now() / 1e3 >= i.exp ? null : i;
|
|
4463
|
+
} catch {
|
|
4464
|
+
return null;
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
function Ae(e) {
|
|
4468
|
+
let t = e.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - e.length % 4) % 4);
|
|
4469
|
+
return Se(atob(t));
|
|
4470
|
+
}
|
|
4471
|
+
function Mt(e) {
|
|
4472
|
+
return Se(atob(e));
|
|
4473
|
+
}
|
|
4474
|
+
function Se(e) {
|
|
4475
|
+
let t = new Uint8Array(new ArrayBuffer(e.length));
|
|
4476
|
+
for (let r = 0; r < e.length; r++) t[r] = e.charCodeAt(r);
|
|
4477
|
+
return t;
|
|
4478
|
+
}
|
|
4479
|
+
var M = "/.well-known/wd-clearance/outage";
|
|
4480
|
+
var q = "wd_outage";
|
|
4481
|
+
var Lt = "wd-outage-v1";
|
|
4482
|
+
var D = null;
|
|
4483
|
+
var S = null;
|
|
4484
|
+
async function Ut(e, t, r, n = fetch) {
|
|
4485
|
+
if (D && r - D.at < 3e4) return D.available;
|
|
4486
|
+
if (S) return S;
|
|
4487
|
+
S = (async () => {
|
|
4488
|
+
let o = false;
|
|
4489
|
+
try {
|
|
4490
|
+
let a = new AbortController(), i = setTimeout(() => a.abort(), 3e3);
|
|
4491
|
+
try {
|
|
4492
|
+
let s = await n(e.replace(/\/+$/, "") + "/api/v1/clearance", { method: "POST", headers: { "content-type": "application/json", "user-agent": "WebDecoy-OutageProbe/1" }, body: JSON.stringify({ aid: t, fp: "wd-outage-probe", scope: "", ua: "WebDecoy-OutageProbe/1" }), signal: a.signal });
|
|
4493
|
+
s.status < 300 && (o = typeof (await s.json())?.granted == "boolean");
|
|
4494
|
+
} finally {
|
|
4495
|
+
clearTimeout(i);
|
|
4496
|
+
}
|
|
4497
|
+
} catch {
|
|
4498
|
+
o = false;
|
|
4499
|
+
}
|
|
4500
|
+
return D = { at: r, available: o }, o;
|
|
4501
|
+
})();
|
|
4502
|
+
try {
|
|
4503
|
+
return await S;
|
|
4504
|
+
} finally {
|
|
4505
|
+
S = null;
|
|
4506
|
+
}
|
|
4507
|
+
}
|
|
4508
|
+
function Ee(e) {
|
|
4509
|
+
let t = "";
|
|
4510
|
+
for (let r of new Uint8Array(e)) t += String.fromCharCode(r);
|
|
4511
|
+
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
4512
|
+
}
|
|
4513
|
+
async function Pe(e, t) {
|
|
4514
|
+
let r = await crypto.subtle.importKey("raw", new TextEncoder().encode(e), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
4515
|
+
return Ee(await crypto.subtle.sign("HMAC", r, new TextEncoder().encode(t)));
|
|
4516
|
+
}
|
|
4517
|
+
async function Te(e) {
|
|
4518
|
+
return Ee(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(e))).slice(0, 16);
|
|
4519
|
+
}
|
|
4520
|
+
function Be(e, t, r) {
|
|
4521
|
+
return `${Lt}|${e}|${t}|${r}`;
|
|
4522
|
+
}
|
|
4523
|
+
async function Nt(e, t, r, n) {
|
|
4524
|
+
let o = Math.floor(n / 1e3) + 300;
|
|
4525
|
+
return `${o}.${await Pe(e, Be(t, o, await Te(r)))}`;
|
|
4526
|
+
}
|
|
4527
|
+
async function Oe(e, t, r, n, o) {
|
|
4528
|
+
if (!t || !e) return false;
|
|
4529
|
+
let a = e.indexOf(".");
|
|
4530
|
+
if (a <= 0) return false;
|
|
4531
|
+
let i = Number(e.slice(0, a));
|
|
4532
|
+
if (!Number.isInteger(i) || i <= Math.floor(o / 1e3) || i > Math.floor(o / 1e3) + 300) return false;
|
|
4533
|
+
let s = await Pe(t, Be(r, i, await Te(n))), c = e.slice(a + 1);
|
|
4534
|
+
if (c.length !== s.length) return false;
|
|
4535
|
+
let u = 0;
|
|
4536
|
+
for (let p = 0; p < s.length; p++) u |= s.charCodeAt(p) ^ c.charCodeAt(p);
|
|
4537
|
+
return u === 0;
|
|
4538
|
+
}
|
|
4539
|
+
async function Ie(e, t, r = Date.now(), n = fetch) {
|
|
4540
|
+
let o = (i, s, c = {}) => new Response(JSON.stringify(s), { status: i, headers: { "content-type": "application/json", "cache-control": "no-store", ...c } });
|
|
4541
|
+
if (e.method !== "POST") return o(405, { pass: false });
|
|
4542
|
+
if (!t.sensorKey) return o(503, { pass: false, reason: "unsupported" });
|
|
4543
|
+
if (await Ut(t.apiBase, t.siteKey, r, n)) return o(409, { pass: false, reason: "mint_available" });
|
|
4544
|
+
let a = await Nt(t.sensorKey, t.host, e.headers.get("user-agent") ?? "", r);
|
|
4545
|
+
return o(200, { pass: true, expires_in: 300 }, { "set-cookie": `${q}=${a}; Path=/; Secure; SameSite=Lax; HttpOnly; Max-Age=300` });
|
|
4546
|
+
}
|
|
4547
|
+
var Gt = "wdfp1";
|
|
4548
|
+
var De = `
|
|
4549
|
+
async function wdDeviceFP() {
|
|
4550
|
+
// Canvas: 32-bit rolling hash of the dataURL, matching
|
|
4551
|
+
// EnvironmentalCollector._getCanvasHash in @webdecoy/client. The drawing
|
|
4552
|
+
// parameters below are part of the fingerprint \u2014 changing any of them
|
|
4553
|
+
// changes every fingerprint.
|
|
4554
|
+
var canvas32 = 'na';
|
|
4555
|
+
try {
|
|
4556
|
+
var c = document.createElement('canvas');
|
|
4557
|
+
c.width = 200; c.height = 50;
|
|
4558
|
+
var x = c.getContext('2d');
|
|
4559
|
+
x.textBaseline = 'top'; x.font = '14px Arial';
|
|
4560
|
+
x.fillStyle = '#f60'; x.fillRect(125, 1, 62, 20);
|
|
4561
|
+
x.fillStyle = '#069'; x.fillText('FCaptcha', 2, 15);
|
|
4562
|
+
x.fillStyle = 'rgba(102, 204, 0, 0.7)'; x.fillText('FCaptcha', 4, 17);
|
|
4563
|
+
var dataUrl = c.toDataURL();
|
|
4564
|
+
var h = 0;
|
|
4565
|
+
for (var i = 0; i < dataUrl.length; i++) { h = ((h << 5) - h) + dataUrl.charCodeAt(i); h = h & h; }
|
|
4566
|
+
canvas32 = h.toString(16);
|
|
4567
|
+
} catch (e) { canvas32 = 'na'; }
|
|
4568
|
+
|
|
4569
|
+
var webgl = 'na';
|
|
4570
|
+
try {
|
|
4571
|
+
var gc = document.createElement('canvas');
|
|
4572
|
+
var gl = gc.getContext('webgl') || gc.getContext('experimental-webgl');
|
|
4573
|
+
if (gl) {
|
|
4574
|
+
var dbg = gl.getExtension('WEBGL_debug_renderer_info');
|
|
4575
|
+
var vendor = dbg ? gl.getParameter(dbg.UNMASKED_VENDOR_WEBGL) : 'unknown';
|
|
4576
|
+
var renderer = dbg ? gl.getParameter(dbg.UNMASKED_RENDERER_WEBGL) : 'unknown';
|
|
4577
|
+
webgl = String(renderer) + '~' + String(vendor);
|
|
4578
|
+
}
|
|
4579
|
+
} catch (e) { webgl = 'na'; }
|
|
4580
|
+
|
|
4581
|
+
var tz = 'na';
|
|
4582
|
+
try { tz = Intl.DateTimeFormat().resolvedOptions().timeZone || 'na'; } catch (e) {}
|
|
4583
|
+
|
|
4584
|
+
var raw = ['${Gt}', canvas32, webgl,
|
|
4585
|
+
screen.width + 'x' + screen.height + 'x' + screen.colorDepth,
|
|
4586
|
+
tz, navigator.platform || 'na', navigator.language || 'na'
|
|
4587
|
+
].join('|');
|
|
4588
|
+
var buf = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(raw));
|
|
4589
|
+
var fp = Array.from(new Uint8Array(buf)).map(function (b) {
|
|
4590
|
+
return b.toString(16).padStart(2, '0');
|
|
4591
|
+
}).join('');
|
|
4592
|
+
|
|
4593
|
+
return { fp: fp, canvas32: canvas32, webgl: webgl };
|
|
4594
|
+
}
|
|
4595
|
+
`;
|
|
4596
|
+
function J(e) {
|
|
4597
|
+
let r = ["missing", "invalid", "insufficient-trust", "revoked", "crawler-refused", "agent-impersonation"].includes(e) ? e : "denied";
|
|
4598
|
+
return { version: 1, reason: r, recoverable: r === "missing" || r === "invalid" || r === "insufficient-trust" };
|
|
4599
|
+
}
|
|
4600
|
+
function Me(e) {
|
|
4601
|
+
let t = J(e);
|
|
4602
|
+
return { "cache-control": "no-store", "x-wd-clearance": "challenged", "x-wd-challenge": String(t.version), "x-wd-challenge-reason": t.reason, "x-wd-challenge-recoverable": String(t.recoverable) };
|
|
4603
|
+
}
|
|
4604
|
+
var $t = 6e4;
|
|
4605
|
+
var L = "x-wd-clearance";
|
|
4606
|
+
var Le = "x-wd-class";
|
|
4607
|
+
var Ue = "__wd_clearance_check";
|
|
4608
|
+
var Z = "/.well-known/wd-clearance/pat";
|
|
4609
|
+
var E = /* @__PURE__ */ new Map();
|
|
4610
|
+
var Ht = 16;
|
|
4611
|
+
var Kt = 3e4;
|
|
4612
|
+
var Vt = 3e5;
|
|
4613
|
+
var X = /* @__PURE__ */ new Map();
|
|
4614
|
+
var Y = /* @__PURE__ */ new Map();
|
|
4615
|
+
var zt = 86400;
|
|
4616
|
+
function Ne(e, t) {
|
|
4617
|
+
return `https://wd-config.invalid/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;
|
|
4618
|
+
}
|
|
4619
|
+
function Ge() {
|
|
4620
|
+
try {
|
|
4621
|
+
return globalThis.caches?.default ?? null;
|
|
4622
|
+
} catch {
|
|
4623
|
+
return null;
|
|
4624
|
+
}
|
|
4625
|
+
}
|
|
4626
|
+
async function $e(e, t) {
|
|
4627
|
+
let r = Ge();
|
|
4628
|
+
if (!r) return null;
|
|
4629
|
+
try {
|
|
4630
|
+
let n = await r.match(Ne(e, t));
|
|
4631
|
+
return n ? await n.json() : null;
|
|
4632
|
+
} catch {
|
|
4633
|
+
return null;
|
|
4634
|
+
}
|
|
4635
|
+
}
|
|
4636
|
+
async function Wt(e, t, r) {
|
|
4637
|
+
let n = Ge();
|
|
4638
|
+
if (n) try {
|
|
4639
|
+
await n.put(Ne(e, t), new Response(JSON.stringify(r), { headers: { "content-type": "application/json", "cache-control": `max-age=${zt}` } }));
|
|
4640
|
+
} catch {
|
|
4641
|
+
}
|
|
4642
|
+
}
|
|
4643
|
+
function Ft(e) {
|
|
4644
|
+
let t = e?.headers.get("retry-after"), r = t ? Number(t) : NaN;
|
|
4645
|
+
return Number.isFinite(r) && r > 0 ? Math.min(Math.max(r * 1e3, 5e3), Vt) : Kt;
|
|
4646
|
+
}
|
|
4647
|
+
async function He(e, t) {
|
|
4648
|
+
let r = Date.now(), n = t, o = E.get(n);
|
|
4649
|
+
if (o && r - o.at < $t) return o.config;
|
|
4650
|
+
let a = X.get(n);
|
|
4651
|
+
if (a !== void 0 && r < a) return o?.config ?? await $e(e.siteKey, t);
|
|
4652
|
+
let i = Y.get(n);
|
|
4653
|
+
if (i) return o?.config ?? i;
|
|
4654
|
+
let s = jt(e, t, n, r, o?.config ?? null);
|
|
4655
|
+
Y.set(n, s);
|
|
4656
|
+
try {
|
|
4657
|
+
return await s;
|
|
4658
|
+
} finally {
|
|
4659
|
+
Y.delete(n);
|
|
4660
|
+
}
|
|
4661
|
+
}
|
|
4662
|
+
async function jt(e, t, r, n, o) {
|
|
4663
|
+
let a = null;
|
|
4664
|
+
try {
|
|
4665
|
+
let i = `${e.apiBase}/api/v1/clearance/config?aid=${encodeURIComponent(e.siteKey)}`;
|
|
4666
|
+
if (e.propertyId && (i += `&pid=${encodeURIComponent(e.propertyId)}`), t && (i += `&host=${encodeURIComponent(t)}`), a = await fetch(i, { signal: AbortSignal.timeout(3e3) }), a.ok) {
|
|
4667
|
+
let s = await a.json();
|
|
4668
|
+
if (X.delete(r), E.set(r, { config: s, at: n }), E.size > Ht) {
|
|
4669
|
+
let c = E.keys().next();
|
|
4670
|
+
c.done || E.delete(c.value);
|
|
4671
|
+
}
|
|
4672
|
+
return await Wt(e.siteKey, t, s), s;
|
|
4673
|
+
}
|
|
4674
|
+
} catch {
|
|
4675
|
+
}
|
|
4676
|
+
return X.set(r, n + Ft(a)), o ?? await $e(e.siteKey, t);
|
|
4677
|
+
}
|
|
4678
|
+
function Ke(e, t, r, n) {
|
|
4679
|
+
return new Response(JSON.stringify({ wd_clearance: true, nonce: e, mode: t, site_key: r, capabilities: n }), { status: 200, headers: { "content-type": "application/json", "cache-control": "no-store", "access-control-allow-origin": "*" } });
|
|
4680
|
+
}
|
|
4681
|
+
var qt = 3e3;
|
|
4682
|
+
async function Ve(e, t) {
|
|
4683
|
+
let r = new URL(e.url).searchParams.get("fp") ?? "", n = `${t}/api/v1/clearance/pat?fp=${encodeURIComponent(r)}`, o = new Headers(), a = e.headers.get("authorization");
|
|
4684
|
+
a && o.set("authorization", a);
|
|
4685
|
+
let i;
|
|
4686
|
+
try {
|
|
4687
|
+
i = await fetch(n, { method: "GET", headers: o, redirect: "manual", signal: AbortSignal.timeout(qt) });
|
|
4688
|
+
} catch {
|
|
4689
|
+
return new Response(JSON.stringify({ attested: false, reason: "unreachable" }), { status: 200, headers: { "content-type": "application/json", "cache-control": "no-store" } });
|
|
4690
|
+
}
|
|
4691
|
+
let s = new Headers({ "content-type": "application/json", "cache-control": "no-store" }), c = i.headers.get("www-authenticate");
|
|
4692
|
+
return c && s.set("www-authenticate", c), new Response(i.body, { status: i.status, headers: s });
|
|
4693
|
+
}
|
|
4694
|
+
function ze(e, t, r, n = "denied") {
|
|
4695
|
+
let o = e.headers.get("accept") ?? "";
|
|
4696
|
+
if (e.method !== "GET" || !o.includes("text/html")) return new Response(JSON.stringify({ error: "clearance required", challenge: J(n) }), { status: 403, headers: { "content-type": "application/json", ...Me(n) } });
|
|
4697
|
+
let a = Yt(t, r);
|
|
4698
|
+
return new Response(a, { status: 403, headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-store", [L]: "challenged" } });
|
|
4699
|
+
}
|
|
4700
|
+
var Jt = "https://cdn.webdecoy.com/wordpress/assets/icon-128x128.png";
|
|
4701
|
+
function Yt(e, t) {
|
|
4702
|
+
return `<!doctype html>
|
|
4703
|
+
<html lang="en">
|
|
4704
|
+
<head>
|
|
4705
|
+
<meta charset="utf-8">
|
|
4706
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
4707
|
+
<title>Checking your browser\u2026</title>
|
|
4708
|
+
<style>
|
|
4709
|
+
body { font-family: system-ui, sans-serif; display: flex; align-items: center;
|
|
4710
|
+
justify-content: center; min-height: 100vh; margin: 0; background: #0b0e14; color: #e6e6e6; }
|
|
4711
|
+
.box { text-align: center; max-width: 24rem; padding: 2rem; }
|
|
4712
|
+
.brand { display: flex; align-items: center; justify-content: center; gap: 0.6rem; margin-bottom: 1.5rem;
|
|
4713
|
+
font-weight: 600; font-size: 1rem; letter-spacing: 0.01em; }
|
|
4714
|
+
.brand img { width: 2.25rem; height: 2.25rem; border-radius: 0.5rem; }
|
|
4715
|
+
.spin { width: 2rem; height: 2rem; margin: 0 auto 1rem; border: 3px solid #2a2f3a;
|
|
4716
|
+
border-top-color: #f90289; border-radius: 50%; animation: r 0.8s linear infinite; }
|
|
4717
|
+
@keyframes r { to { transform: rotate(360deg); } }
|
|
4718
|
+
p { color: #9aa4b2; font-size: 0.9rem; line-height: 1.5; }
|
|
4719
|
+
.foot { margin-top: 2rem; font-size: 0.75rem; color: #6b7280; }
|
|
4720
|
+
.foot a { color: #9aa4b2; text-decoration: none; }
|
|
4721
|
+
</style>
|
|
4722
|
+
</head>
|
|
4723
|
+
<body>
|
|
4724
|
+
<div class="box">
|
|
4725
|
+
<div class="brand"><img src="${Jt}" alt="" width="36" height="36">WebDecoy</div>
|
|
4726
|
+
<div class="spin" id="spin"></div>
|
|
4727
|
+
<h1 style="font-size:1.1rem">Checking your browser</h1>
|
|
4728
|
+
<p id="msg">This takes a moment and happens only once.</p>
|
|
4729
|
+
<p class="foot">This site is protected by <a href="https://webdecoy.com" rel="noopener">WebDecoy</a>.</p>
|
|
4730
|
+
</div>
|
|
4731
|
+
<script>
|
|
4732
|
+
${De}
|
|
4733
|
+
(async function () {
|
|
4734
|
+
var msg = document.getElementById('msg');
|
|
4735
|
+
try {
|
|
4736
|
+
// CANONICAL device fp, from the single shared source in device-fp.ts.
|
|
4737
|
+
// Returns the fingerprint plus the raw canvas/WebGL signals the integrity
|
|
4738
|
+
// check below also needs, so neither context is built twice.
|
|
4739
|
+
var dfp = await wdDeviceFP();
|
|
4740
|
+
var fp = dfp.fp;
|
|
4741
|
+
var canvas32 = dfp.canvas32;
|
|
4742
|
+
var webgl = dfp.webgl;
|
|
4743
|
+
|
|
4744
|
+
// Browser-integrity signals (#327). Collected in-browser and reported raw \u2014
|
|
4745
|
+
// the server decides. A real browser is internally consistent; a standard
|
|
4746
|
+
// headless/automation environment betrays incoherence it does not spoof by
|
|
4747
|
+
// default (permission vs Notification state, absent navigator.languages,
|
|
4748
|
+
// a Chrome UA with no window.chrome). Coherent signals earn the token a
|
|
4749
|
+
// 'human-likely' grade; anything off falls back to 'clean' (never blocked).
|
|
4750
|
+
var integrity = {
|
|
4751
|
+
webdriver: navigator.webdriver === true,
|
|
4752
|
+
headless_ua: /headless/i.test(navigator.userAgent),
|
|
4753
|
+
no_plugins: !(navigator.plugins && navigator.plugins.length > 0),
|
|
4754
|
+
no_languages: !(navigator.languages && navigator.languages.length > 0),
|
|
4755
|
+
hardware: navigator.hardwareConcurrency || 0,
|
|
4756
|
+
canvas_ok: canvas32 !== 'na',
|
|
4757
|
+
webgl_ok: webgl !== 'na',
|
|
4758
|
+
chrome_ua: /chrome|chromium|crios/i.test(navigator.userAgent),
|
|
4759
|
+
chrome_obj: (typeof window.chrome === 'object' && window.chrome !== null),
|
|
4760
|
+
perm_coherent: true
|
|
4761
|
+
};
|
|
4762
|
+
try {
|
|
4763
|
+
if (navigator.permissions && navigator.permissions.query && typeof Notification !== 'undefined') {
|
|
4764
|
+
var perm = await navigator.permissions.query({ name: 'notifications' });
|
|
4765
|
+
// Classic headless-Chrome tell: Notification.permission is the default
|
|
4766
|
+
// 'default', yet the Permissions API reports 'denied'. A real browser
|
|
4767
|
+
// agrees with itself.
|
|
4768
|
+
if (Notification.permission === 'default' && perm.state === 'denied') integrity.perm_coherent = false;
|
|
4769
|
+
}
|
|
4770
|
+
} catch (e) { /* permissions unsupported \u2014 leave coherent, fail open */ }
|
|
4771
|
+
|
|
4772
|
+
// Device attestation (#329). On a supporting client \u2014 Apple platforms
|
|
4773
|
+
// today \u2014 this endpoint answers 401 with a PrivateToken challenge, the OS
|
|
4774
|
+
// silently obtains a token and retries, and we get back a receipt worth an
|
|
4775
|
+
// 'attested-human' grade. No puzzle, no interaction, nothing to see.
|
|
4776
|
+
//
|
|
4777
|
+
// Everywhere else it fails or 401s and we move on: the absence of
|
|
4778
|
+
// attestation must never cost a visitor anything, because attester
|
|
4779
|
+
// coverage is thin and not their fault.
|
|
4780
|
+
var patReceipt = '';
|
|
4781
|
+
try {
|
|
4782
|
+
// SAME-ORIGIN by way of the validator's proxy. Fetching WebDecoy directly
|
|
4783
|
+
// meant Safari ignored the 401 challenge entirely \u2014 cross-origin
|
|
4784
|
+
// WWW-Authenticate does not trigger its challenge/response handling, so a
|
|
4785
|
+
// token was never requested. credentials stay same-origin so the browser
|
|
4786
|
+
// is permitted to do the auth exchange.
|
|
4787
|
+
var patRes = await fetch(
|
|
4788
|
+
${JSON.stringify(Z)} + '?fp=' + encodeURIComponent(fp),
|
|
4789
|
+
{ credentials: 'same-origin' }
|
|
4790
|
+
);
|
|
4791
|
+
if (patRes.ok) {
|
|
4792
|
+
var patOut = await patRes.json();
|
|
4793
|
+
if (patOut && patOut.attested && patOut.receipt) patReceipt = patOut.receipt;
|
|
4794
|
+
}
|
|
4795
|
+
} catch (e) { /* unsupported or unreachable \u2014 proceed unattested */ }
|
|
4796
|
+
|
|
4797
|
+
var mintBody = JSON.stringify({
|
|
4798
|
+
aid: ${JSON.stringify(t)},
|
|
4799
|
+
fp: fp,
|
|
4800
|
+
scope: '',
|
|
4801
|
+
ua: navigator.userAgent,
|
|
4802
|
+
webdriver: integrity.webdriver,
|
|
4803
|
+
headless: integrity.headless_ua,
|
|
4804
|
+
integrity: integrity,
|
|
4805
|
+
pat_receipt: patReceipt
|
|
4806
|
+
});
|
|
4807
|
+
// Mint, retrying only when WebDecoy could not be reached (#1245): a network
|
|
4808
|
+
// error, a timeout, 429 or 5xx. An ANSWER of "not granted" is a refusal and
|
|
4809
|
+
// is never retried or bypassed.
|
|
4810
|
+
var waits = [0, 1500, 4000];
|
|
4811
|
+
for (var attempt = 0; attempt < waits.length; attempt++) {
|
|
4812
|
+
if (waits[attempt]) await new Promise(function (r) { setTimeout(r, waits[attempt]); });
|
|
4813
|
+
var out = null;
|
|
4814
|
+
try {
|
|
4815
|
+
var ctl = new AbortController();
|
|
4816
|
+
var timer = setTimeout(function () { ctl.abort(); }, 4000);
|
|
4817
|
+
var res = await fetch(${JSON.stringify(e)} + '/api/v1/clearance', {
|
|
4818
|
+
method: 'POST',
|
|
4819
|
+
headers: { 'content-type': 'application/json' },
|
|
4820
|
+
body: mintBody,
|
|
4821
|
+
signal: ctl.signal
|
|
4822
|
+
});
|
|
4823
|
+
clearTimeout(timer);
|
|
4824
|
+
if (res.ok) out = await res.json();
|
|
4825
|
+
} catch (e) { out = null; }
|
|
4826
|
+
if (out && out.granted && out.token) {
|
|
4827
|
+
document.cookie = 'wd_clearance=' + out.token +
|
|
4828
|
+
'; path=/; secure; samesite=lax; max-age=' + (out.expires_in || 1800);
|
|
4829
|
+
location.reload();
|
|
4830
|
+
return;
|
|
4831
|
+
}
|
|
4832
|
+
if (out && out.granted === false) {
|
|
4833
|
+
document.getElementById('spin').style.display = 'none';
|
|
4834
|
+
msg.textContent = 'Verification did not pass. If you believe this is an error, contact the site owner.';
|
|
4835
|
+
return;
|
|
4836
|
+
}
|
|
4837
|
+
}
|
|
4838
|
+
// WebDecoy could not mint at all. The site owner chose to let visitors
|
|
4839
|
+
// through in that case; the validator confirms the outage itself before it
|
|
4840
|
+
// signs a short pass, so this cannot be used while minting works.
|
|
4841
|
+
try {
|
|
4842
|
+
var pass = await fetch(${JSON.stringify(M)}, { method: 'POST', credentials: 'same-origin' });
|
|
4843
|
+
if (pass.ok) {
|
|
4844
|
+
var passOut = await pass.json();
|
|
4845
|
+
if (passOut && passOut.pass) { location.reload(); return; }
|
|
4846
|
+
}
|
|
4847
|
+
} catch (e) { /* fall through to the retry message */ }
|
|
4848
|
+
document.getElementById('spin').style.display = 'none';
|
|
4849
|
+
msg.textContent = 'Verification could not complete. Please retry shortly.';
|
|
4850
|
+
} catch (e) {
|
|
4851
|
+
document.getElementById('spin').style.display = 'none';
|
|
4852
|
+
msg.textContent = 'Verification could not complete. Please retry shortly.';
|
|
4853
|
+
}
|
|
4854
|
+
})();
|
|
4855
|
+
</script>
|
|
4856
|
+
</body>
|
|
4857
|
+
</html>`;
|
|
4858
|
+
}
|
|
4859
|
+
function U(e) {
|
|
4860
|
+
if (typeof e != "string") return "";
|
|
4861
|
+
let t = e.trim().toLowerCase().replace(/:\d+$/, "").replace(/\.$/, "");
|
|
4862
|
+
return t.length > 0 && t.length <= 253 ? t : "";
|
|
4863
|
+
}
|
|
4864
|
+
var We = ["route_min_trust", "route_attribution", "monitor_routes", "route_exceptions", "bot_behaviors", "credential_reach", "route_refusals", "crawler_behavior", "ai_referrals"];
|
|
4865
|
+
var Q = 60;
|
|
4866
|
+
var Xt = 500;
|
|
4867
|
+
var Zt = 6e3;
|
|
4868
|
+
var Fe = 40;
|
|
4869
|
+
var Qt = 60;
|
|
4870
|
+
var er = 16;
|
|
4871
|
+
var C = new TextEncoder();
|
|
4872
|
+
var tr = 3e3;
|
|
4873
|
+
var rr = 2e4;
|
|
4874
|
+
var nr = 1e4;
|
|
4875
|
+
var or = 16;
|
|
4876
|
+
var x = /* @__PURE__ */ new Map();
|
|
4877
|
+
function ar(e, t, r) {
|
|
4878
|
+
return `${e}|${t}|${r}`;
|
|
4879
|
+
}
|
|
4880
|
+
function je(e, t, r, n, o = Date.now()) {
|
|
4881
|
+
try {
|
|
4882
|
+
let a = e?.label ?? "", i = e?.mode ?? "", s = e?.pattern ?? "", c = e?.previews ?? [], u = e?.behavior ?? "", p = e?.crawlerBehavior ?? "", w = e?.outsideReach ?? "";
|
|
4883
|
+
if (!a || !r || !r.siteKey || !r.apiBase) return;
|
|
4884
|
+
let d = U(t);
|
|
4885
|
+
if (!d) return;
|
|
4886
|
+
let y = Math.floor(o / 1e3 / Q) * Q, b = ar(y, i, d);
|
|
4887
|
+
for (let [h, m] of x) m.bucketStart !== y && (N(m, r, n), x.delete(h));
|
|
4888
|
+
let g = x.get(b);
|
|
4889
|
+
if (!g) {
|
|
4890
|
+
if (x.size >= or) for (let [h, m] of x) N(m, r, n), x.delete(h);
|
|
4891
|
+
g = { bucketStart: y, mode: i, host: d, counts: /* @__PURE__ */ new Map(), routes: /* @__PURE__ */ new Map(), previews: /* @__PURE__ */ new Map(), credentials: /* @__PURE__ */ new Map(), referrals: /* @__PURE__ */ new Map(), routeBytes: 0, total: 0 }, x.set(b, g), ir(b, g, r, n, o);
|
|
4892
|
+
}
|
|
4893
|
+
g.counts.set(a, (g.counts.get(a) ?? 0) + 1);
|
|
4894
|
+
let A = typeof s == "string" ? s : "", l = typeof u == "string" ? u : "", f = typeof p == "string" ? p : "", v = `${A}
|
|
4895
|
+
${a}
|
|
4896
|
+
${l}
|
|
4897
|
+
${f}`, R = g.routes.get(v);
|
|
4898
|
+
R ? R.count++ : (g.routes.set(v, { pattern: A, verdict: a, behavior: l, crawlerBehavior: f, count: 1 }), g.routeBytes += C.encode(A).length + C.encode(a).length + C.encode(l).length + C.encode(f).length + Fe);
|
|
4899
|
+
for (let h of Array.isArray(c) ? c : []) {
|
|
4900
|
+
if (!h || typeof h.pattern != "string" || !h.pattern) continue;
|
|
4901
|
+
let m = g.previews.get(h.pattern);
|
|
4902
|
+
m || (m = { evaluated: 0, refused: /* @__PURE__ */ new Map() }, g.previews.set(h.pattern, m), g.routeBytes += C.encode(h.pattern).length + Qt), m.evaluated++, typeof h.refused == "string" && h.refused && (m.refused.has(h.refused) || (g.routeBytes += C.encode(h.refused).length + er), m.refused.set(h.refused, (m.refused.get(h.refused) ?? 0) + 1));
|
|
4903
|
+
}
|
|
4904
|
+
typeof w == "string" && w && g.credentials.set(w, (g.credentials.get(w) ?? 0) + 1);
|
|
4905
|
+
let _ = e?.referral;
|
|
4906
|
+
if (_ && typeof _.platform == "string" && _.platform && typeof _.path == "string") {
|
|
4907
|
+
let h = `${_.platform}
|
|
4908
|
+
${_.path}`, m = g.referrals.get(h);
|
|
4909
|
+
m ? m.count++ : (g.referrals.set(h, { platform: _.platform, path: _.path, count: 1 }), g.routeBytes += C.encode(_.platform).length + C.encode(_.path).length + Fe);
|
|
4910
|
+
}
|
|
4911
|
+
g.total++, (g.total >= Xt || g.routeBytes >= Zt) && (N(g, r, n), x.delete(b));
|
|
4912
|
+
} catch {
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4915
|
+
function ir(e, t, r, n, o) {
|
|
4916
|
+
try {
|
|
4917
|
+
let a = (t.bucketStart + Q) * 1e3, i = Math.floor(Math.random() * nr), s = Math.max(0, Math.min(a - o + i, rr));
|
|
4918
|
+
n.waitUntil(new Promise((c) => {
|
|
4919
|
+
setTimeout(() => {
|
|
4920
|
+
try {
|
|
4921
|
+
x.get(e) === t && (N(t, r, n), x.delete(e));
|
|
4922
|
+
} catch {
|
|
4923
|
+
}
|
|
4924
|
+
c();
|
|
4925
|
+
}, s);
|
|
4926
|
+
}));
|
|
4927
|
+
} catch {
|
|
4928
|
+
}
|
|
4929
|
+
}
|
|
4930
|
+
function N(e, t, r) {
|
|
4931
|
+
try {
|
|
4932
|
+
if (e.total <= 0 || e.counts.size === 0) return;
|
|
4933
|
+
let n = {};
|
|
4934
|
+
for (let [s, c] of e.counts) n[s] = c;
|
|
4935
|
+
let o = [];
|
|
4936
|
+
for (let s of e.routes.values()) {
|
|
4937
|
+
let c = { pattern: s.pattern, verdict: s.verdict, count: s.count };
|
|
4938
|
+
s.behavior && (c.behavior = s.behavior), s.crawlerBehavior && (c.crawler_behavior = s.crawlerBehavior), o.push(c);
|
|
4939
|
+
}
|
|
4940
|
+
let a = { organization_id: t.siteKey, bucket_start: e.bucketStart, mode: e.mode, counts: n, route_counts: o, report_id: crypto.randomUUID() };
|
|
4941
|
+
if (e.previews.size > 0) {
|
|
4942
|
+
let s = [];
|
|
4943
|
+
for (let [c, u] of e.previews) {
|
|
4944
|
+
let p = {};
|
|
4945
|
+
for (let [w, d] of u.refused) p[w] = d;
|
|
4946
|
+
s.push({ pattern: c, evaluated: u.evaluated, additional_refusals: p });
|
|
4947
|
+
}
|
|
4948
|
+
a.previews = s;
|
|
4949
|
+
}
|
|
4950
|
+
if (e.credentials.size > 0) {
|
|
4951
|
+
let s = [];
|
|
4952
|
+
for (let [c, u] of e.credentials) s.push({ credential_id: c, outside_reach: u });
|
|
4953
|
+
a.credential_presentations = s;
|
|
4954
|
+
}
|
|
4955
|
+
e.referrals.size > 0 && (a.ai_referrals = [...e.referrals.values()].map((s) => ({ platform: s.platform, path: s.path, count: s.count }))), t.propertyId && (a.property_id = t.propertyId), a.host = e.host, t.bundleVersion && (a.reporter_version = t.bundleVersion);
|
|
4956
|
+
let i = !!(t.scannerId && t.sensorKey);
|
|
4957
|
+
i && (a.scanner_id = t.scannerId), a.capabilities = t.capabilities ?? We, r.waitUntil(sr(t.apiBase, JSON.stringify(a), i ? t.sensorKey : void 0).then(() => {
|
|
4958
|
+
}, () => {
|
|
4959
|
+
}));
|
|
4960
|
+
} catch {
|
|
4961
|
+
}
|
|
4962
|
+
}
|
|
4963
|
+
async function sr(e, t, r) {
|
|
4964
|
+
let n = new AbortController(), o = setTimeout(() => n.abort(), tr), a = { "content-type": "application/json" };
|
|
4965
|
+
r && (a["x-wd-sensor-key"] = r);
|
|
4966
|
+
try {
|
|
4967
|
+
await fetch(e.replace(/\/+$/, "") + "/api/v1/clearance/telemetry", { method: "POST", headers: a, body: t, signal: n.signal });
|
|
4968
|
+
} finally {
|
|
4969
|
+
clearTimeout(o);
|
|
4970
|
+
}
|
|
4971
|
+
}
|
|
4972
|
+
var G = ["route_min_trust", "route_attribution", "monitor_routes", "route_exceptions", "bot_behaviors", "credential_reach", "bot_verification_rdns", "crawler_behavior", "ai_referrals"];
|
|
4973
|
+
var cr = [{ category: "search_engines", suffixes: [".googlebot.com", ".google.com", ".search.msn.com", ".crawl.yahoo.net", ".applebot.apple.com", ".yandex.com", ".yandex.net", ".yandex.ru", ".crawl.baidu.com", ".crawl.baidu.jp"] }];
|
|
4974
|
+
function lr(e, t) {
|
|
4975
|
+
let r = e.toLowerCase().replace(/\.$/, "");
|
|
4976
|
+
for (let n of cr) if (t[n.category]) {
|
|
4977
|
+
for (let o of n.suffixes) if (r.endsWith(o)) return n.category;
|
|
4978
|
+
}
|
|
4979
|
+
return null;
|
|
4980
|
+
}
|
|
4981
|
+
var $ = /* @__PURE__ */ new Map();
|
|
4982
|
+
var ur = 36e5;
|
|
4983
|
+
var gr = 5e3;
|
|
4984
|
+
async function qe(e, t, r, n) {
|
|
4985
|
+
let o = $.get(e);
|
|
4986
|
+
if (o && n - o.at < ur) return o.category;
|
|
4987
|
+
let a = null;
|
|
4988
|
+
try {
|
|
4989
|
+
let i = await r.reverse(e);
|
|
4990
|
+
for (let s of i) {
|
|
4991
|
+
let c = lr(s, t);
|
|
4992
|
+
if (c && await fr(s, e, r)) {
|
|
4993
|
+
a = c;
|
|
4994
|
+
break;
|
|
4995
|
+
}
|
|
4996
|
+
}
|
|
4997
|
+
} catch {
|
|
4998
|
+
a = null;
|
|
4999
|
+
}
|
|
5000
|
+
return $.size >= gr && $.clear(), $.set(e, { category: a, at: n }), a;
|
|
5001
|
+
}
|
|
5002
|
+
async function fr(e, t, r) {
|
|
5003
|
+
let n = e.replace(/\.$/, ""), o = t.includes(":") ? [r.resolve6(n)] : [r.resolve4(n)];
|
|
5004
|
+
try {
|
|
5005
|
+
return (await Promise.all(o)).flat().some((i) => i === t);
|
|
5006
|
+
} catch {
|
|
5007
|
+
return false;
|
|
5008
|
+
}
|
|
5009
|
+
}
|
|
5010
|
+
var Je = [["reflectionbot", "Reflectionbot", "reflectionbot", "crawler"], ["gptbot", "GPTBot", "gptbot", "crawler"], ["claudebot", "ClaudeBot", "claudebot", "crawler"], ["anthropic-ai", "Anthropic", "anthropic", "crawler"], ["claude-web", "Claude-Web", "claude-web", "crawler"], ["ccbot", "CCBot", "ccbot", "crawler"], ["google-extended", "Google-Extended", "google-extended", "crawler"], ["bytespider", "ByteSpider", "bytespider", "crawler"], ["amazonbot", "Amazonbot", "amazonbot", "crawler"], ["facebookbot", "FacebookBot", "facebookbot", "crawler"], ["meta-externalagent", "Meta-ExternalAgent", "meta-externalagent", "crawler"], ["cohere-ai", "Cohere", "cohere-ai", "crawler"], ["cohere", "Cohere", "cohere-ai", "crawler"], ["applebot-extended", "Applebot-Extended", "applebot-extended", "crawler"], ["youbot", "YouBot", "youbot", "crawler"], ["mistralbot", "MistralBot", "mistral", "crawler"], ["gemini", "Gemini", "gemini", "crawler"], ["ai2bot", "AI2Bot", "ai2bot", "crawler"], ["deepseek", "DeepSeek", "deepseek", "crawler"], ["qwen", "Qwen", "qwen", "crawler"], ["webzio", "Webz.io", "webzio", "crawler"], ["sentibot", "Sentibot", "sentibot", "crawler"], ["omgili", "Omgili", "omgili", "crawler"], ["img2dataset", "img2dataset", "img2dataset", "crawler"], ["timpibot", "Timpibot", "timpibot", "crawler"], ["velenpublicwebcrawler", "VelenPublicWebCrawler", "velenpublicwebcrawler", "crawler"], ["isscyberriskcrawler", "ISSCyberRiskCrawler", "isscyberriskcrawler", "crawler"], ["friendlycrawler", "FriendlyCrawler", "friendlycrawler", "crawler"], ["duckassistbot", "DuckAssistBot", "duckassistbot", "crawler"], ["sofyabot", "SofyaBot", "sofyabot", "crawler"], ["xai-searchbot", "xAI-SearchBot", "xai-searchbot", "crawler"], ["linkupbot", "LinkupBot", "linkupbot", "crawler"], ["perplexitybot", "PerplexityBot", "perplexitybot", "crawler"], ["claude-searchbot", "Claude-SearchBot", "claude-searchbot", "crawler"], ["oai-searchbot", "OAI-SearchBot", "oai-searchbot", "crawler"], ["searchgpt", "SearchGPT", "searchgpt", "crawler"], ["phind", "Phind", "phind", "crawler"], ["kagi", "Kagi", "kagi", "crawler"], ["exa.ai", "Exa", "exa", "crawler"], ["exabot", "Exa", "exa", "crawler"], ["metaphor", "Metaphor", "metaphor", "crawler"], ["tavily", "Tavily", "tavily", "crawler"], ["bravesearch", "BraveSearch", "brave-search", "crawler"], ["neevabot", "NeevaBot", "neeva", "crawler"], ["operator", "Operator", "operator", "crawler"], ["claude-user", "Claude-User", "claude-user", "crawler"], ["gemini-user", "Gemini-User", "gemini-user", "crawler"], ["googleagent-mariner", "GoogleAgent-Mariner", "googleagent-mariner", "crawler"], ["mariner", "GoogleAgent-Mariner", "googleagent-mariner", "crawler"], ["amazonbuyforme", "AmazonBuyForMe", "amazon-buyforme", "crawler"], ["buyforme", "AmazonBuyForMe", "amazon-buyforme", "crawler"], ["browser-use", "Browser-Use", "browser-use", "crawler"], ["stagehand", "Stagehand", "stagehand", "crawler"], ["multion", "MultiOn", "multion", "crawler"], ["iboubot", "IbouBot", "iboubot", "crawler"], ["googlebot", "Googlebot", "googlebot", "crawler"], ["google-inspectiontool", "Google-InspectionTool", "google-inspectiontool", "crawler"], ["bingbot", "Bingbot", "bingbot", "crawler"], ["msnbot", "MSNBot", "msnbot", "crawler"], ["yandexbot", "YandexBot", "yandexbot", "crawler"], ["baiduspider", "Baiduspider", "baiduspider", "crawler"], ["duckduckbot", "DuckDuckBot", "duckduckbot", "crawler"], ["applebot", "Applebot", "applebot", "crawler"], ["sogou", "Sogou Spider", "sogou", "crawler"], ["qwantify", "Qwantify", "qwantify", "crawler"], ["naver", "Naver", "naver", "crawler"], ["yeti", "Naver", "naver", "crawler"], ["seznambot", "SeznamBot", "seznam", "crawler"], ["ecosia", "Ecosia", "ecosia", "crawler"], ["mojeekbot", "MojeekBot", "mojeek", "crawler"], ["slurp", "Yahoo! Slurp", "yahoo-slurp", "crawler"], ["ahrefsbot", "AhrefsBot", "ahrefsbot", "crawler"], ["ahrefs", "AhrefsBot", "ahrefsbot", "crawler"], ["semrushbot", "SemrushBot", "semrushbot", "crawler"], ["semrush", "SemrushBot", "semrushbot", "crawler"], ["mj12bot", "MJ12bot", "mj12bot", "crawler"], ["dotbot", "DotBot", "dotbot", "crawler"], ["rogerbot", "Rogerbot", "rogerbot", "crawler"], ["screaming frog", "Screaming Frog", "screaming-frog", "crawler"], ["sitebulb", "Sitebulb", "sitebulb", "crawler"], ["deepcrawl", "DeepCrawl", "deepcrawl", "crawler"], ["oncrawl", "OnCrawl", "oncrawl", "crawler"], ["botify", "Botify", "botify", "crawler"], ["contentking", "ContentKing", "contentking", "crawler"], ["sistrix", "SISTRIX", "sistrix", "crawler"], ["serpstat", "Serpstat", "serpstat", "crawler"], ["spyfu", "SpyFu", "spyfu", "crawler"], ["nessus", "Nessus", "nessus", "crawler"], ["qualys", "Qualys", "qualys", "crawler"], ["shodan", "Shodan", "shodan", "crawler"], ["censys", "Censys", "censys", "crawler"], ["nmap", "Nmap", "nmap", "crawler"], ["zap/", "OWASP ZAP", "zap", "crawler"], ["burp", "Burp Suite", "burp", "crawler"], ["nikto", "Nikto", "nikto", "crawler"], ["nuclei", "Nuclei", "nuclei", "crawler"], ["acunetix", "Acunetix", "acunetix", "crawler"], ["netsparker", "Netsparker", "netsparker", "crawler"], ["detectify", "Detectify", "detectify", "crawler"], ["intruder", "Intruder", "intruder", "crawler"], ["python-requests", "Python-Requests", "python-requests", "tool"], ["python-urllib", "Python-urllib", "python-urllib", "tool"], ["python/", "Python", "python", "tool"], ["scrapy", "Scrapy", "scrapy", "tool"], ["httpx", "HTTPX", "httpx", "tool"], ["aiohttp", "aiohttp", "aiohttp", "tool"], ["beautifulsoup", "BeautifulSoup", "beautifulsoup", "tool"], ["node-fetch", "node-fetch", "node-fetch", "tool"], ["axios/", "Axios", "axios", "tool"], ["got/", "Got", "got", "tool"], ["undici", "Undici", "undici", "tool"], ["go-http-client", "Go-HTTP-Client", "go-http-client", "tool"], ["colly", "Colly", "colly", "tool"], ["java/", "Java", "java", "tool"], ["okhttp", "OkHttp", "okhttp", "tool"], ["apache-httpclient", "Apache-HttpClient", "apache-httpclient", "tool"], ["jsoup", "Jsoup", "jsoup", "tool"], ["guzzlehttp", "GuzzleHttp", "guzzlehttp", "tool"], ["php/", "PHP", "php", "tool"], ["ruby", "Ruby", "ruby", "tool"], ["faraday", "Faraday", "faraday", "tool"], ["mechanize", "Mechanize", "mechanize", "tool"], ["headlesschrome", "HeadlessChrome", "headlesschrome", "tool"], ["puppeteer", "Puppeteer", "puppeteer", "tool"], ["playwright", "Playwright", "playwright", "tool"], ["selenium", "Selenium", "selenium", "tool"], ["phantomjs", "PhantomJS", "phantomjs", "tool"], ["splash", "Splash", "splash", "tool"], ["browserless", "Browserless", "browserless", "tool"], ["browserbase", "Browserbase", "browserbase", "tool"], ["ia_archiver", "Internet Archive", "ia-archiver", "crawler"], ["archive.org_bot", "Archive.org", "archive-org-bot", "crawler"], ["wayback", "Wayback Machine", "wayback", "crawler"], ["heritrix", "Heritrix", "heritrix", "crawler"], ["brozzler", "Brozzler", "brozzler", "crawler"], ["facebookexternalhit", "Facebook", "facebookexternalhit", "crawler"], ["facebot", "Facebot", "facebot", "crawler"], ["twitterbot", "Twitterbot", "twitterbot", "crawler"], ["linkedinbot", "LinkedInBot", "linkedinbot", "crawler"], ["slackbot", "Slackbot", "slackbot", "crawler"], ["telegrambot", "TelegramBot", "telegrambot", "crawler"], ["whatsapp", "WhatsApp", "whatsapp", "crawler"], ["discordbot", "Discordbot", "discordbot", "crawler"], ["pinterest", "Pinterest", "pinterestbot", "crawler"], ["tumblr", "Tumblr", "tumblr", "crawler"], ["reddit", "Reddit", "reddit", "crawler"], ["embedly", "Embedly", "embedly", "crawler"], ["iframely", "Iframely", "iframely", "crawler"], ["curl/", "cURL", "curl", "tool"], ["wget/", "Wget", "wget", "tool"], ["libwww-perl", "libwww-perl", "libwww-perl", "tool"], ["lwp-", "LWP", "lwp", "tool"], ["httrack", "HTTrack", "httrack", "tool"], ["webdecoybot", "WebDecoyBot", "webdecoybot", "crawler"], ["uptimerobot", "UptimeRobot", "uptimerobot", "crawler"], ["pingdom", "Pingdom", "pingdom", "crawler"], ["statuscake", "StatusCake", "statuscake", "crawler"], ["betteruptime", "Better Uptime", "better-uptime", "crawler"], ["datadog", "Datadog Synthetics", "datadog-synthetics", "crawler"], ["newrelic", "New Relic", "newrelic", "crawler"], ["site24x7", "Site24x7", "site24x7", "crawler"], ["freshping", "Freshping", "freshping", "crawler"], ["hetrixtools", "HetrixTools", "hetrixtools", "crawler"], ["nodeping", "NodePing", "nodeping", "crawler"], ["gtmetrix", "GTmetrix", "gtmetrix", "crawler"], ["chrome-lighthouse", "Lighthouse", "chrome-lighthouse", "crawler"], ["google page speed", "Lighthouse", "chrome-lighthouse", "crawler"], ["feedly", "Feedly", "feedly", "crawler"], ["feedfetcher", "Feedfetcher-Google", "feedfetcher-google", "crawler"], ["newsblur", "NewsBlur", "newsblur", "crawler"], ["inoreader", "Inoreader", "inoreader", "crawler"], ["theoldreader", "The Old Reader", "theoldreader", "crawler"], ["feedbin", "Feedbin", "feedbin", "crawler"], ["miniflux", "Miniflux", "miniflux", "crawler"], ["freshrss", "FreshRSS", "freshrss", "crawler"], ["commafeed", "CommaFeed", "commafeed", "crawler"], ["diffbot", "Diffbot", "diffbot", "crawler"], ["import.io", "Import.io", "import-io", "crawler"], ["brightdata", "Bright Data", "bright-data", "crawler"], ["luminati", "Bright Data", "bright-data", "crawler"], ["oxylabs", "Oxylabs", "oxylabs", "crawler"], ["scrapingbee", "ScrapingBee", "scrapingbee", "crawler"], ["scrapingant", "ScrapingAnt", "scrapingant", "crawler"], ["zyte", "Zyte", "zyte", "crawler"], ["scrapinghub", "Zyte", "zyte", "crawler"], ["apify", "Apify", "apify", "crawler"], ["crawlbase", "Crawlbase", "crawlbase", "crawler"], ["webscrapingapi", "WebScrapingAPI", "webscrapingapi", "crawler"], ["chatgpt-user", "ChatGPT-User", "chatgpt-user", "crawler"], ["perplexity-user", "Perplexity-User", "perplexity-user", "crawler"], ["mistralai-user", "MistralAI-User", "mistralai-user", "crawler"], ["meta-externalfetcher", "Meta-ExternalFetcher", "meta-externalfetcher", "crawler"], ["gemini-deep-research", "Gemini-Deep-Research", "gemini-deep-research", "crawler"], ["copilot", "Microsoft Copilot", "copilot", "crawler"], ["cortana", "Cortana", "cortana", "crawler"], ["siri", "Siri", "siri", "crawler"]];
|
|
5011
|
+
function pr(e) {
|
|
5012
|
+
for (let [t, r, n, o] of Je) if (e.includes(t)) return { name: r, id: n, kind: o };
|
|
5013
|
+
return null;
|
|
5014
|
+
}
|
|
5015
|
+
var dr = /(?:bot|crawler|spider)(?:[/\s);,]|$)/i;
|
|
5016
|
+
function Ye(e) {
|
|
5017
|
+
let t = e.toLowerCase(), r = pr(t);
|
|
5018
|
+
return r?.kind === "crawler" || !r && dr.test(e);
|
|
5019
|
+
}
|
|
5020
|
+
var hr = "Search Engine Crawler";
|
|
5021
|
+
var ee = 1e3;
|
|
5022
|
+
var mr = { search_engines: true, ai_crawlers: true, monitoring: true };
|
|
5023
|
+
function wr(e) {
|
|
5024
|
+
if (!e.includes(":")) return e.split(".").reverse().join(".") + ".in-addr.arpa";
|
|
5025
|
+
let [t, r = ""] = e.split("::"), n = t ? t.split(":") : [], o = r ? r.split(":") : [], a = 8 - n.length - o.length;
|
|
5026
|
+
return a < 0 ? "" : [...n, ...Array(Math.max(0, a)).fill("0"), ...o].map((s) => s.padStart(4, "0")).join("").split("").reverse().join(".") + ".ip6.arpa";
|
|
5027
|
+
}
|
|
5028
|
+
function te(e, t) {
|
|
5029
|
+
return Promise.race([e, new Promise((r, n) => setTimeout(() => n(new Error("dns timeout")), t))]);
|
|
5030
|
+
}
|
|
5031
|
+
function br(e) {
|
|
5032
|
+
return { reverse: (t) => te(e(wr(t), "PTR"), ee), resolve4: (t) => te(e(t, "A"), ee), resolve6: (t) => te(e(t, "AAAA"), ee) };
|
|
5033
|
+
}
|
|
5034
|
+
function Xe(e, t, r, n = typeof Deno < "u" && Deno && typeof Deno.resolveDns == "function" ? Deno.resolveDns.bind(Deno) : void 0, o = Date.now()) {
|
|
5035
|
+
return !r || !e || !n || !Ye(t) ? Promise.resolve("") : qe(e, mr, br(n), o).then((a) => a === "search_engines" ? hr : "").catch(() => "");
|
|
5036
|
+
}
|
|
5037
|
+
var yr = "https://cloudflare-dns.com/dns-query";
|
|
5038
|
+
var vr = 1e3;
|
|
5039
|
+
var _r = { A: 1, PTR: 12, AAAA: 28 };
|
|
5040
|
+
function xr(e = fetch) {
|
|
5041
|
+
return async (t, r) => {
|
|
5042
|
+
let n = _r[r];
|
|
5043
|
+
if (!n) throw new Error(`unsupported record type ${r}`);
|
|
5044
|
+
let o = `${yr}?name=${encodeURIComponent(t)}&type=${r}`, a = await e(o, { headers: { accept: "application/dns-json" }, signal: AbortSignal.timeout(vr) });
|
|
5045
|
+
if (!a.ok) throw new Error(`doh ${a.status}`);
|
|
5046
|
+
let i = await a.json();
|
|
5047
|
+
if (i.Status !== 0) throw new Error(`dns status ${i.Status}`);
|
|
5048
|
+
let s = (i.Answer ?? []).filter((c) => c.type === n && typeof c.data == "string").map((c) => c.data);
|
|
5049
|
+
if (s.length === 0) throw new Error("no records");
|
|
5050
|
+
return s;
|
|
5051
|
+
};
|
|
5052
|
+
}
|
|
5053
|
+
function Ze(e, t, r, n = fetch) {
|
|
5054
|
+
return Xe(e, t, r, xr(n));
|
|
5055
|
+
}
|
|
5056
|
+
var re = "vercel-9971cf5b9746";
|
|
5057
|
+
var Qe = "https://in.webdecoy.com";
|
|
5058
|
+
function et(e) {
|
|
5059
|
+
let t = new Headers(e.headers);
|
|
5060
|
+
return t.delete(L), t.delete(Le), t;
|
|
5061
|
+
}
|
|
5062
|
+
function ne(e, t) {
|
|
5063
|
+
let r = et(e);
|
|
5064
|
+
return t && r.set(L, t), { action: "continue", headers: r, verdict: t };
|
|
5065
|
+
}
|
|
5066
|
+
async function Ar(e, t, r) {
|
|
5067
|
+
try {
|
|
5068
|
+
let n = (r.ingest ?? "").trim().replace(/\/+$/, "") || Qe, o = new URL(e.url), a = o.searchParams.get(Ue), i = U(o.hostname), s = await He({ apiBase: n, siteKey: r.siteKey }, i);
|
|
5069
|
+
if (a !== null) return { action: "respond", response: Ke(a, s ? s.mode : "unknown", r.siteKey, G) };
|
|
5070
|
+
if (o.pathname === Z) return { action: "respond", response: await Ve(e, n) };
|
|
5071
|
+
if (o.pathname === M) return { action: "respond", response: await Ie(e, { apiBase: n, siteKey: r.siteKey, sensorKey: r.sensorKey, host: i }) };
|
|
5072
|
+
if (!s) return ne(e, null);
|
|
5073
|
+
let c = await Re(e, s, { siteKey: r.siteKey, verifiedBotCategory: (u, p) => Ze(t.ip, u.headers.get("user-agent") ?? "", p, t.fetch ?? fetch) });
|
|
5074
|
+
if (F(c)) {
|
|
5075
|
+
let u = j(e.headers.get("cookie") ?? "", q);
|
|
5076
|
+
u && await Oe(u, r.sensorKey, i, e.headers.get("user-agent") ?? "", Date.now()) && (c = Ce(c));
|
|
5077
|
+
}
|
|
5078
|
+
return je(c, o.hostname, { siteKey: r.siteKey, apiBase: n, scannerId: r.scannerId, sensorKey: r.sensorKey, bundleVersion: re, capabilities: G }, { waitUntil: (u) => t.waitUntil?.(u) }, Date.now()), c.pass || c.mode !== "enforce" ? ne(e, c.label) : { action: "respond", response: ze(e, n, r.siteKey, c.label) };
|
|
5079
|
+
} catch {
|
|
5080
|
+
try {
|
|
5081
|
+
return ne(e, null);
|
|
5082
|
+
} catch {
|
|
5083
|
+
return { action: "continue", headers: null, verdict: null };
|
|
5084
|
+
}
|
|
5085
|
+
}
|
|
5086
|
+
}
|
|
5087
|
+
|
|
5088
|
+
// src/clearance/index.ts
|
|
5089
|
+
function fromEnv(name) {
|
|
5090
|
+
try {
|
|
5091
|
+
const env = globalThis.process?.env;
|
|
5092
|
+
return (env?.[name] ?? "").trim();
|
|
5093
|
+
} catch {
|
|
5094
|
+
return "";
|
|
5095
|
+
}
|
|
5096
|
+
}
|
|
5097
|
+
function resolveGateEnv(options = {}) {
|
|
5098
|
+
const siteKey = (options.siteKey ?? fromEnv("WEBDECOY_SITE_KEY")).trim();
|
|
5099
|
+
const scannerId = (options.scannerId ?? fromEnv("WEBDECOY_SCANNER_ID")).trim();
|
|
5100
|
+
const sensorKey = (options.sensorKey ?? fromEnv("WEBDECOY_SENSOR_KEY")).trim();
|
|
5101
|
+
if (!siteKey || !scannerId || !sensorKey) return null;
|
|
5102
|
+
const ingest = (options.ingest ?? fromEnv("WEBDECOY_INGEST")).trim() || Qe;
|
|
5103
|
+
return { siteKey, scannerId, sensorKey, ingest };
|
|
5104
|
+
}
|
|
5105
|
+
var warnedMissing = false;
|
|
5106
|
+
function createClearanceGate(options = {}) {
|
|
5107
|
+
const trustProxy = options.trustProxy ?? 1;
|
|
5108
|
+
return async (request, context = {}) => {
|
|
5109
|
+
const env = resolveGateEnv(options);
|
|
5110
|
+
if (!env) {
|
|
5111
|
+
if (!warnedMissing) {
|
|
5112
|
+
warnedMissing = true;
|
|
5113
|
+
console.warn(
|
|
5114
|
+
"[WebDecoy] clearance gate is off: set WEBDECOY_SITE_KEY, WEBDECOY_SCANNER_ID and WEBDECOY_SENSOR_KEY."
|
|
5115
|
+
);
|
|
5116
|
+
}
|
|
5117
|
+
return { action: "continue", headers: et(request), verdict: null };
|
|
5118
|
+
}
|
|
5119
|
+
const ip = resolveClientIp({ headers: request.headers, trustProxy }) ?? "";
|
|
5120
|
+
return Ar(request, { ip, waitUntil: context.waitUntil }, env);
|
|
5121
|
+
};
|
|
5122
|
+
}
|
|
5123
|
+
|
|
3908
5124
|
// src/client-signals.ts
|
|
3909
5125
|
var MemoryClientSignalStore = class {
|
|
3910
5126
|
constructor(options = {}) {
|
|
@@ -4022,28 +5238,28 @@ function shouldSkipPath(path, patterns) {
|
|
|
4022
5238
|
);
|
|
4023
5239
|
}
|
|
4024
5240
|
function ruleBlockResponse(decision) {
|
|
4025
|
-
const
|
|
4026
|
-
if (decision.allowed || !
|
|
4027
|
-
if (
|
|
4028
|
-
const retryAfter = Number(
|
|
5241
|
+
const rr2 = decision.ruleResult;
|
|
5242
|
+
if (decision.allowed || !rr2) return null;
|
|
5243
|
+
if (rr2.action === "THROTTLE") {
|
|
5244
|
+
const retryAfter = Number(rr2.metadata?.retryAfter ?? 60);
|
|
4029
5245
|
return {
|
|
4030
5246
|
status: 429,
|
|
4031
5247
|
headers: { "Retry-After": String(retryAfter) },
|
|
4032
5248
|
body: {
|
|
4033
5249
|
error: "Too Many Requests",
|
|
4034
|
-
message:
|
|
5250
|
+
message: rr2.reason || "Rate limit exceeded",
|
|
4035
5251
|
retry_after: retryAfter
|
|
4036
5252
|
}
|
|
4037
5253
|
};
|
|
4038
5254
|
}
|
|
4039
|
-
if (
|
|
5255
|
+
if (rr2.action === "DENY") {
|
|
4040
5256
|
return {
|
|
4041
5257
|
status: 403,
|
|
4042
5258
|
headers: {},
|
|
4043
5259
|
body: {
|
|
4044
5260
|
error: "Forbidden",
|
|
4045
|
-
message:
|
|
4046
|
-
rule:
|
|
5261
|
+
message: rr2.reason || "Access denied by rule",
|
|
5262
|
+
rule: rr2.rule
|
|
4047
5263
|
}
|
|
4048
5264
|
};
|
|
4049
5265
|
}
|
|
@@ -4950,13 +6166,13 @@ function analyzeAudioContext(audioInfo) {
|
|
|
4950
6166
|
reason: "AudioContext missing baseLatency (mocked/headless audio)"
|
|
4951
6167
|
});
|
|
4952
6168
|
}
|
|
4953
|
-
const
|
|
4954
|
-
if (
|
|
6169
|
+
const sr2 = audioInfo.sampleRate;
|
|
6170
|
+
if (sr2 !== void 0 && sr2 !== 44100 && sr2 !== 48e3) {
|
|
4955
6171
|
detections.push({
|
|
4956
6172
|
category: "headless",
|
|
4957
6173
|
score: 0.4,
|
|
4958
6174
|
confidence: 0.5,
|
|
4959
|
-
reason: `Unusual AudioContext sample rate (${
|
|
6175
|
+
reason: `Unusual AudioContext sample rate (${sr2})`
|
|
4960
6176
|
});
|
|
4961
6177
|
}
|
|
4962
6178
|
return detections;
|
|
@@ -5166,16 +6382,16 @@ function stddev(arr) {
|
|
|
5166
6382
|
const variance = arr.reduce((acc, v) => acc + (v - m) * (v - m), 0) / arr.length;
|
|
5167
6383
|
return Math.sqrt(variance);
|
|
5168
6384
|
}
|
|
5169
|
-
function erf(
|
|
5170
|
-
const sign =
|
|
5171
|
-
|
|
5172
|
-
const t = 1 / (1 + 0.3275911 *
|
|
5173
|
-
const y = 1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-
|
|
6385
|
+
function erf(x2) {
|
|
6386
|
+
const sign = x2 >= 0 ? 1 : -1;
|
|
6387
|
+
x2 = Math.abs(x2);
|
|
6388
|
+
const t = 1 / (1 + 0.3275911 * x2);
|
|
6389
|
+
const y = 1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-x2 * x2);
|
|
5174
6390
|
return sign * y;
|
|
5175
6391
|
}
|
|
5176
|
-
function normalCDF(
|
|
5177
|
-
if (sigma <= 0) return
|
|
5178
|
-
return 0.5 * (1 + erf((
|
|
6392
|
+
function normalCDF(x2, mu, sigma) {
|
|
6393
|
+
if (sigma <= 0) return x2 >= mu ? 1 : 0;
|
|
6394
|
+
return 0.5 * (1 + erf((x2 - mu) / (sigma * Math.SQRT2)));
|
|
5179
6395
|
}
|
|
5180
6396
|
function ksTestStatistic(samples, cdfFn) {
|
|
5181
6397
|
const n = samples.length;
|
|
@@ -5216,15 +6432,15 @@ function shannonEntropy(arr, bins) {
|
|
|
5216
6432
|
function lag1Autocorrelation(arr) {
|
|
5217
6433
|
if (arr.length < 3) return 0;
|
|
5218
6434
|
const n = arr.length - 1;
|
|
5219
|
-
const
|
|
6435
|
+
const x2 = arr.slice(0, n);
|
|
5220
6436
|
const y = arr.slice(1);
|
|
5221
|
-
const mx = mean(
|
|
6437
|
+
const mx = mean(x2);
|
|
5222
6438
|
const my = mean(y);
|
|
5223
6439
|
let num = 0;
|
|
5224
6440
|
let dx2 = 0;
|
|
5225
6441
|
let dy2 = 0;
|
|
5226
6442
|
for (let i = 0; i < n; i++) {
|
|
5227
|
-
const dx =
|
|
6443
|
+
const dx = x2[i] - mx;
|
|
5228
6444
|
const dy = y[i] - my;
|
|
5229
6445
|
num += dx * dy;
|
|
5230
6446
|
dx2 += dx * dx;
|
|
@@ -5263,12 +6479,12 @@ function analyzeKeystrokeCadence(stats) {
|
|
|
5263
6479
|
if (logIntervals.length >= 10) {
|
|
5264
6480
|
const mu = mean(logIntervals);
|
|
5265
6481
|
const sigma = stddev(logIntervals);
|
|
5266
|
-
const
|
|
6482
|
+
const D2 = ksTestStatistic(logIntervals, (x2) => normalCDF(x2, mu, sigma));
|
|
5267
6483
|
const critical = 1.22 / Math.sqrt(logIntervals.length);
|
|
5268
6484
|
let score;
|
|
5269
|
-
if (
|
|
5270
|
-
else if (
|
|
5271
|
-
else if (
|
|
6485
|
+
if (D2 <= critical * 0.8) score = 1;
|
|
6486
|
+
else if (D2 <= critical) score = 0.7;
|
|
6487
|
+
else if (D2 <= critical * 1.5) score = 0.3;
|
|
5272
6488
|
else score = 0;
|
|
5273
6489
|
metrics.logNormalFit = score;
|
|
5274
6490
|
totalWeight += 0.2;
|
|
@@ -5280,11 +6496,11 @@ function analyzeKeystrokeCadence(stats) {
|
|
|
5280
6496
|
const minI = Math.min(...intervals);
|
|
5281
6497
|
const maxI = Math.max(...intervals);
|
|
5282
6498
|
if (maxI > minI) {
|
|
5283
|
-
const
|
|
6499
|
+
const D2 = ksTestStatistic(intervals, (x2) => (x2 - minI) / (maxI - minI));
|
|
5284
6500
|
let score;
|
|
5285
|
-
if (
|
|
5286
|
-
else if (
|
|
5287
|
-
else if (
|
|
6501
|
+
if (D2 < 0.05) score = 0;
|
|
6502
|
+
else if (D2 < 0.1) score = 0.3;
|
|
6503
|
+
else if (D2 < 0.15) score = 0.6;
|
|
5288
6504
|
else score = 1;
|
|
5289
6505
|
metrics.uniformity = score;
|
|
5290
6506
|
totalWeight += 0.15;
|
|
@@ -5324,13 +6540,13 @@ function analyzeKeystrokeCadence(stats) {
|
|
|
5324
6540
|
activeMetricCount++;
|
|
5325
6541
|
}
|
|
5326
6542
|
if (intervals.length >= 15) {
|
|
5327
|
-
const
|
|
6543
|
+
const H2 = shannonEntropy(intervals, 10);
|
|
5328
6544
|
let score;
|
|
5329
|
-
if (
|
|
5330
|
-
else if (
|
|
5331
|
-
else if (
|
|
5332
|
-
else if (
|
|
5333
|
-
else if (
|
|
6545
|
+
if (H2 < 0.5) score = 0.1;
|
|
6546
|
+
else if (H2 < 1.5) score = 0.1 + 0.5 * (H2 - 0.5);
|
|
6547
|
+
else if (H2 < 2) score = 0.6 + 0.4 * (H2 - 1.5) / 0.5;
|
|
6548
|
+
else if (H2 <= 3) score = 1;
|
|
6549
|
+
else if (H2 <= 3.3) score = 0.7;
|
|
5334
6550
|
else score = 0.4;
|
|
5335
6551
|
metrics.entropy = score;
|
|
5336
6552
|
totalWeight += 0.15;
|
|
@@ -6130,6 +7346,7 @@ function createCaptchaEndpoints(options = {}) {
|
|
|
6130
7346
|
BOT_REGISTRY,
|
|
6131
7347
|
BotPolicy,
|
|
6132
7348
|
BotRule,
|
|
7349
|
+
CLEARANCE_GATE_BUILD,
|
|
6133
7350
|
CLIENT_SESSION_COOKIE,
|
|
6134
7351
|
CLIENT_SESSION_HEADER,
|
|
6135
7352
|
Captcha,
|
|
@@ -6173,6 +7390,7 @@ function createCaptchaEndpoints(options = {}) {
|
|
|
6173
7390
|
consoleLogger,
|
|
6174
7391
|
createAgentVerifier,
|
|
6175
7392
|
createCaptchaEndpoints,
|
|
7393
|
+
createClearanceGate,
|
|
6176
7394
|
createFetchGuard,
|
|
6177
7395
|
deriveAndArm,
|
|
6178
7396
|
deriveKey,
|
|
@@ -6194,6 +7412,7 @@ function createCaptchaEndpoints(options = {}) {
|
|
|
6194
7412
|
readEdgeVerdict,
|
|
6195
7413
|
recommend,
|
|
6196
7414
|
resolveClientIp,
|
|
7415
|
+
resolveGateEnv,
|
|
6197
7416
|
resolveSecret,
|
|
6198
7417
|
ruleBlockResponse,
|
|
6199
7418
|
shouldSkipPath,
|