@webdecoy/node 0.22.2 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/{chunk-F2T5V6NK.mjs → chunk-ANOZMV4M.mjs} +100 -17
- package/dist/{chunk-POXOR4DB.mjs → chunk-HQVMNN6X.mjs} +204 -199
- package/dist/{detect-and-gate-9-vm6nEN.d.mts → detect-and-gate-BUFbu1y5.d.mts} +1 -1
- package/dist/{detect-and-gate-DeD4UBzX.d.ts → detect-and-gate-CU2u2EZD.d.ts} +1 -1
- package/dist/index.d.mts +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.js +303 -215
- package/dist/index.mjs +2 -2
- package/dist/{sdk-U_qp9ync.d.mts → sdk-CmWmCDuZ.d.mts} +1 -1
- package/dist/{sdk-U_qp9ync.d.ts → sdk-CmWmCDuZ.d.ts} +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +100 -17
- package/dist/testing.mjs +1 -1
- package/dist/vercel.d.mts +2 -2
- package/dist/vercel.d.ts +2 -2
- package/dist/vercel.js +303 -215
- package/dist/vercel.mjs +2 -2
- package/package.json +20 -8
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
resolveGateEnv,
|
|
12
12
|
ruleBlockResponse,
|
|
13
13
|
shouldSkipPath
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HQVMNN6X.mjs";
|
|
15
15
|
import {
|
|
16
16
|
ATTACK_SIGNATURE_IDS,
|
|
17
17
|
AgentVerifier,
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
tripwire,
|
|
69
69
|
upstashRateLimitStore,
|
|
70
70
|
webBotAuth
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-ANOZMV4M.mjs";
|
|
72
72
|
|
|
73
73
|
// src/client-signals.ts
|
|
74
74
|
var MemoryClientSignalStore = class {
|
|
@@ -310,7 +310,7 @@ declare function readEdgeVerdict(headers: Record<string, string> | undefined): E
|
|
|
310
310
|
* agents share User-Agent substrings, so sorting this array changes how real
|
|
311
311
|
* traffic is classified.
|
|
312
312
|
*
|
|
313
|
-
*
|
|
313
|
+
* 235 agents across 15 categories.
|
|
314
314
|
*/
|
|
315
315
|
/**
|
|
316
316
|
* Classification categories, mirroring `agents.Category` in Go.
|
|
@@ -310,7 +310,7 @@ declare function readEdgeVerdict(headers: Record<string, string> | undefined): E
|
|
|
310
310
|
* agents share User-Agent substrings, so sorting this array changes how real
|
|
311
311
|
* traffic is classified.
|
|
312
312
|
*
|
|
313
|
-
*
|
|
313
|
+
* 235 agents across 15 categories.
|
|
314
314
|
*/
|
|
315
315
|
/**
|
|
316
316
|
* Classification categories, mirroring `agents.Category` in Go.
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Z as WebDecoyConfig, H as RequestMetadata, W as WebDecoy, P as ProtectResult, K as RuleState } from './sdk-
|
|
1
|
+
import { Z as WebDecoyConfig, H as RequestMetadata, W as WebDecoy, P as ProtectResult, K as RuleState } from './sdk-CmWmCDuZ.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 { Z as WebDecoyConfig, H as RequestMetadata, W as WebDecoy, P as ProtectResult, K as RuleState } from './sdk-
|
|
1
|
+
import { Z as WebDecoyConfig, H as RequestMetadata, W as WebDecoy, P as ProtectResult, K as RuleState } from './sdk-CmWmCDuZ.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Testing utilities, for the application's test suite rather than ours.
|
package/dist/testing.js
CHANGED
|
@@ -305,6 +305,7 @@ var BOT_REGISTRY = [
|
|
|
305
305
|
{ id: "isscyberriskcrawler", name: "ISSCyberRiskCrawler", category: "training_crawler", organization: "ISS", baseScore: 65, respectsRobots: false, uaPatterns: ["isscyberriskcrawler"] },
|
|
306
306
|
{ id: "friendlycrawler", name: "FriendlyCrawler", category: "training_crawler", organization: "Unknown", baseScore: 65, respectsRobots: true, uaPatterns: ["friendlycrawler"] },
|
|
307
307
|
{ id: "elevenlabscrawler", name: "ElevenlabsCrawler", category: "training_crawler", organization: "ElevenLabs", baseScore: 80, respectsRobots: true, uaPatterns: ["elevenlabscrawler"] },
|
|
308
|
+
{ id: "riverbot", name: "RiverBot", category: "training_crawler", organization: "River", baseScore: 80, respectsRobots: true, uaPatterns: ["riverbot"] },
|
|
308
309
|
{ id: "kimibot", name: "KimiBot", category: "training_crawler", organization: "Moonshot AI", baseScore: 80, respectsRobots: true, uaPatterns: ["kimibot"] },
|
|
309
310
|
{ id: "moonshotbot", name: "MoonshotBot", category: "training_crawler", organization: "Moonshot AI", baseScore: 80, respectsRobots: false, uaPatterns: ["moonshotbot"] },
|
|
310
311
|
{ id: "chatglm-spider", name: "ChatGLM-Spider", category: "training_crawler", organization: "Zhipu AI", baseScore: 80, respectsRobots: false, uaPatterns: ["chatglm-spider"] },
|
|
@@ -326,6 +327,7 @@ var BOT_REGISTRY = [
|
|
|
326
327
|
{ id: "brave-search", name: "BraveSearch", category: "ai_search_crawler", organization: "Brave", baseScore: 65, respectsRobots: true, uaPatterns: ["bravesearch"] },
|
|
327
328
|
{ id: "neeva", name: "NeevaBot", category: "ai_search_crawler", organization: "Neeva", baseScore: 65, respectsRobots: true, uaPatterns: ["neevabot"] },
|
|
328
329
|
{ id: "kimi-searchbot", name: "Kimi-SearchBot", category: "ai_search_crawler", organization: "Moonshot AI", baseScore: 65, respectsRobots: true, uaPatterns: ["kimi-searchbot"] },
|
|
330
|
+
{ id: "isonsearchbot", name: "IsonSearchBot", category: "ai_search_crawler", organization: "Ison Search", baseScore: 65, respectsRobots: true, uaPatterns: ["isonsearchbot"] },
|
|
329
331
|
{ id: "keenablebot", name: "KeenableBot", category: "ai_search_crawler", organization: "Keenable", baseScore: 65, respectsRobots: true, uaPatterns: ["keenablebot"] },
|
|
330
332
|
{ id: "azureai-searchbot", name: "AzureAI-SearchBot", category: "ai_search_crawler", organization: "Microsoft", baseScore: 65, respectsRobots: false, uaPatterns: ["azureai-searchbot"] },
|
|
331
333
|
{ id: "grokbot", name: "GrokBot", category: "ai_search_crawler", organization: "xAI", baseScore: 70, respectsRobots: false, uaPatterns: ["grokbot"] },
|
|
@@ -376,6 +378,9 @@ var BOT_REGISTRY = [
|
|
|
376
378
|
{ id: "spyfu", name: "SpyFu", category: "seo_crawler", organization: "SpyFu", baseScore: 50, respectsRobots: true, uaPatterns: ["spyfu"] },
|
|
377
379
|
{ id: "meta-externalads", name: "meta-externalads", category: "seo_crawler", organization: "Meta", baseScore: 40, respectsRobots: true, uaPatterns: ["meta-externalads"] },
|
|
378
380
|
{ id: "dataforseobot", name: "DataForSeoBot", category: "seo_crawler", organization: "DataForSEO", baseScore: 50, respectsRobots: true, uaPatterns: ["dataforseobot"] },
|
|
381
|
+
{ id: "barkrowler", name: "Barkrowler", category: "seo_crawler", organization: "Babbar", baseScore: 50, respectsRobots: true, uaPatterns: ["barkrowler"] },
|
|
382
|
+
{ id: "scrunchbot", name: "Scrunchbot", category: "seo_crawler", organization: "Scrunch", baseScore: 50, respectsRobots: true, uaPatterns: ["scrunchbot"] },
|
|
383
|
+
{ id: "webxtrendbot", name: "webXtrendBot", category: "seo_crawler", organization: "webXtrend", baseScore: 50, respectsRobots: true, uaPatterns: ["webxtrendbot"] },
|
|
379
384
|
{ id: "serankingbacklinksbot", name: "SERankingBacklinksBot", category: "seo_crawler", organization: "SE Ranking", baseScore: 50, respectsRobots: true, uaPatterns: ["serankingbacklinksbot"] },
|
|
380
385
|
{ id: "awariobot", name: "AwarioBot", category: "seo_crawler", organization: "Awario", baseScore: 50, respectsRobots: true, uaPatterns: ["awariobot", "awariosmartbot"] },
|
|
381
386
|
{ id: "seojuice-searchbot", name: "SEOJuice-SearchBot", category: "seo_crawler", organization: "SEOJuice", baseScore: 50, respectsRobots: true, uaPatterns: ["seojuice-searchbot"] },
|
|
@@ -393,6 +398,10 @@ var BOT_REGISTRY = [
|
|
|
393
398
|
{ id: "acunetix", name: "Acunetix", category: "security_scanner", organization: "Invicti", baseScore: 70, respectsRobots: false, uaPatterns: ["acunetix"] },
|
|
394
399
|
{ id: "netsparker", name: "Netsparker", category: "security_scanner", organization: "Invicti", baseScore: 70, respectsRobots: false, uaPatterns: ["netsparker"] },
|
|
395
400
|
{ id: "detectify", name: "Detectify", category: "security_scanner", organization: "Detectify", baseScore: 65, respectsRobots: false, uaPatterns: ["detectify"] },
|
|
401
|
+
{ id: "paloalto-xpanse", name: "Palo Alto Networks Cortex Xpanse", category: "security_scanner", organization: "Palo Alto Networks", baseScore: 65, respectsRobots: false, uaPatterns: ["palo alto networks"] },
|
|
402
|
+
{ id: "recordedfuture", name: "Recorded Future Crawler", category: "security_scanner", organization: "Recorded Future", baseScore: 65, respectsRobots: false, uaPatterns: ["recordedfuture"] },
|
|
403
|
+
{ id: "cloudflare-security-center", name: "Cloudflare Security Center", category: "security_scanner", organization: "Cloudflare", baseScore: 40, respectsRobots: false, uaPatterns: ["developers.cloudflare.com/security-center"] },
|
|
404
|
+
{ id: "virustotal-cloud", name: "VirusTotal", category: "security_scanner", organization: "Google", baseScore: 40, respectsRobots: false, uaPatterns: ["virustotalcloud"] },
|
|
396
405
|
{ id: "intruder", name: "Intruder", category: "security_scanner", organization: "Intruder", baseScore: 65, respectsRobots: false, uaPatterns: ["intruder"] },
|
|
397
406
|
{ id: "python-requests", name: "Python-Requests", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["python-requests"] },
|
|
398
407
|
{ id: "python-urllib", name: "Python-urllib", category: "generic_scraper", organization: "Python", baseScore: 55, respectsRobots: false, uaPatterns: ["python-urllib"] },
|
|
@@ -443,6 +452,7 @@ var BOT_REGISTRY = [
|
|
|
443
452
|
{ id: "embedly", name: "Embedly", category: "fetcher", organization: "Medium", baseScore: 30, respectsRobots: true, uaPatterns: ["embedly"] },
|
|
444
453
|
{ id: "iframely", name: "Iframely", category: "fetcher", organization: "Iframely", baseScore: 30, respectsRobots: true, uaPatterns: ["iframely"] },
|
|
445
454
|
{ id: "adsbot-google", name: "AdsBot-Google", category: "fetcher", organization: "Google", baseScore: 25, respectsRobots: true, uaPatterns: ["adsbot-google"] },
|
|
455
|
+
{ id: "stripebot", name: "Stripebot", category: "fetcher", organization: "Stripe", baseScore: 25, respectsRobots: true, uaPatterns: ["stripebot"] },
|
|
446
456
|
{ id: "google-read-aloud", name: "Google-Read-Aloud", category: "fetcher", organization: "Google", baseScore: 25, respectsRobots: false, uaPatterns: ["google-read-aloud"] },
|
|
447
457
|
{ id: "google-safety", name: "Google-Safety", category: "fetcher", organization: "Google", baseScore: 25, respectsRobots: false, uaPatterns: ["google-safety"] },
|
|
448
458
|
{ id: "oai-adsbot", name: "OAI-AdsBot", category: "fetcher", organization: "OpenAI", baseScore: 30, respectsRobots: true, uaPatterns: ["oai-adsbot"] },
|
|
@@ -466,6 +476,7 @@ var BOT_REGISTRY = [
|
|
|
466
476
|
{ id: "gtmetrix", name: "GTmetrix", category: "monitoring", organization: "GTmetrix", baseScore: 20, respectsRobots: true, uaPatterns: ["gtmetrix"] },
|
|
467
477
|
{ id: "chrome-lighthouse", name: "Lighthouse", category: "monitoring", organization: "Google", baseScore: 20, respectsRobots: true, uaPatterns: ["chrome-lighthouse", "google page speed"] },
|
|
468
478
|
{ id: "feedly", name: "Feedly", category: "feed_reader", organization: "Feedly", baseScore: 25, respectsRobots: true, uaPatterns: ["feedly"] },
|
|
479
|
+
{ id: "livelapbot", name: "LivelapBot", category: "feed_reader", organization: "Livelap", baseScore: 30, respectsRobots: true, uaPatterns: ["livelapbot"] },
|
|
469
480
|
{ id: "feedfetcher-google", name: "Feedfetcher-Google", category: "feed_reader", organization: "Google", baseScore: 25, respectsRobots: true, uaPatterns: ["feedfetcher"] },
|
|
470
481
|
{ id: "newsblur", name: "NewsBlur", category: "feed_reader", organization: "NewsBlur", baseScore: 25, respectsRobots: true, uaPatterns: ["newsblur"] },
|
|
471
482
|
{ id: "inoreader", name: "Inoreader", category: "feed_reader", organization: "Inoreader", baseScore: 25, respectsRobots: true, uaPatterns: ["inoreader"] },
|
|
@@ -477,6 +488,9 @@ var BOT_REGISTRY = [
|
|
|
477
488
|
{ id: "diffbot", name: "Diffbot", category: "commercial_scraper", organization: "Diffbot", baseScore: 70, respectsRobots: true, uaPatterns: ["diffbot"] },
|
|
478
489
|
{ id: "import-io", name: "Import.io", category: "commercial_scraper", organization: "Import.io", baseScore: 65, respectsRobots: true, uaPatterns: ["import.io"] },
|
|
479
490
|
{ id: "bright-data", name: "Bright Data", category: "commercial_scraper", organization: "Bright Data", baseScore: 70, respectsRobots: false, uaPatterns: ["brightdata", "luminati"] },
|
|
491
|
+
{ id: "brightbot", name: "Brightbot", category: "commercial_scraper", organization: "Bright Data", baseScore: 60, respectsRobots: true, uaPatterns: ["brightbot"] },
|
|
492
|
+
{ id: "cloudflare-crawl", name: "Cloudflare Browser Rendering Crawler", category: "commercial_scraper", organization: "Cloudflare", baseScore: 55, respectsRobots: true, uaPatterns: ["cloudflarebrowserrenderingcrawler"] },
|
|
493
|
+
{ id: "ev-crawler", name: "ev-crawler", category: "commercial_scraper", organization: "Headline", baseScore: 55, respectsRobots: true, uaPatterns: ["ev-crawler"] },
|
|
480
494
|
{ id: "oxylabs", name: "Oxylabs", category: "commercial_scraper", organization: "Oxylabs", baseScore: 70, respectsRobots: false, uaPatterns: ["oxylabs"] },
|
|
481
495
|
{ id: "scrapingbee", name: "ScrapingBee", category: "commercial_scraper", organization: "ScrapingBee", baseScore: 65, respectsRobots: true, uaPatterns: ["scrapingbee"] },
|
|
482
496
|
{ id: "scrapingant", name: "ScrapingAnt", category: "commercial_scraper", organization: "ScrapingAnt", baseScore: 65, respectsRobots: true, uaPatterns: ["scrapingant"] },
|
|
@@ -1214,8 +1228,31 @@ function base64urlBytes(bytes) {
|
|
|
1214
1228
|
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1215
1229
|
}
|
|
1216
1230
|
|
|
1231
|
+
// src/agent/identity.ts
|
|
1232
|
+
var WELL_KNOWN_DIRECTORY = "/.well-known/http-message-signatures-directory";
|
|
1233
|
+
function resolveSignatureAgent(value) {
|
|
1234
|
+
if (!/^https:\/\/[^/\\]/i.test(value)) throw new Error("signature-agent must be an https URL");
|
|
1235
|
+
const url = new URL(value);
|
|
1236
|
+
if (url.protocol !== "https:" || !url.hostname || url.username || url.password) {
|
|
1237
|
+
throw new Error("signature-agent must be an https URL");
|
|
1238
|
+
}
|
|
1239
|
+
url.hash = "";
|
|
1240
|
+
const hasQuery = url.href.includes("?");
|
|
1241
|
+
const authority = canonicalAuthority(url);
|
|
1242
|
+
if (url.pathname === "/" && !hasQuery) {
|
|
1243
|
+
const wellKnown = `https://${authority}${WELL_KNOWN_DIRECTORY}`;
|
|
1244
|
+
return { fetch: wellKnown, identifier: wellKnown };
|
|
1245
|
+
}
|
|
1246
|
+
const path = url.pathname.replace(/%[0-9a-f]{2}/gi, (m) => m.toUpperCase());
|
|
1247
|
+
return { fetch: url.href, identifier: `https://${authority}${path}` };
|
|
1248
|
+
}
|
|
1249
|
+
function canonicalAuthority(url) {
|
|
1250
|
+
const host = url.hostname.toLowerCase();
|
|
1251
|
+
if (!url.port || url.port === "443") return host;
|
|
1252
|
+
return `${host}:${url.port}`;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1217
1255
|
// src/agent/directory.ts
|
|
1218
|
-
var WELL_KNOWN = "/.well-known/http-message-signatures-directory";
|
|
1219
1256
|
var COLD_RETRY_BACKOFF_MS = 3e4;
|
|
1220
1257
|
var DEFAULT_SIGNED_AGENT_DIRECTORIES = [
|
|
1221
1258
|
{ name: "OpenAI ChatGPT", category: "ai_crawlers", directory: "https://chatgpt.com" },
|
|
@@ -1228,10 +1265,14 @@ var DirectoryCache = class {
|
|
|
1228
1265
|
this.refreshedAt = 0;
|
|
1229
1266
|
this.nextColdRetryAt = 0;
|
|
1230
1267
|
this.inflight = null;
|
|
1231
|
-
/**
|
|
1232
|
-
|
|
1268
|
+
/**
|
|
1269
|
+
* Resolve a keyid published by one agent identity (a resolved
|
|
1270
|
+
* Signature-Agent URL) to a verification key, fetching/refreshing as
|
|
1271
|
+
* needed. A key is only ever attributed to the directory that published it.
|
|
1272
|
+
*/
|
|
1273
|
+
this.resolveKey = async (keyId, agent) => {
|
|
1233
1274
|
await this.ensureFresh();
|
|
1234
|
-
return this.keys.get(keyId);
|
|
1275
|
+
return this.keys.get(cacheKey(agent, keyId));
|
|
1235
1276
|
};
|
|
1236
1277
|
this.opts = opts;
|
|
1237
1278
|
}
|
|
@@ -1270,7 +1311,7 @@ var DirectoryCache = class {
|
|
|
1270
1311
|
for (const keys of results) {
|
|
1271
1312
|
if (keys === null) continue;
|
|
1272
1313
|
fetchedAny = true;
|
|
1273
|
-
for (const k of keys) next.set(k.thumbprint, k.key);
|
|
1314
|
+
for (const k of keys) next.set(cacheKey(k.identifier, k.thumbprint), k.key);
|
|
1274
1315
|
}
|
|
1275
1316
|
if (fetchedAny) {
|
|
1276
1317
|
this.keys = next;
|
|
@@ -1283,7 +1324,14 @@ var DirectoryCache = class {
|
|
|
1283
1324
|
}
|
|
1284
1325
|
}
|
|
1285
1326
|
async fetchDirectory(src) {
|
|
1286
|
-
|
|
1327
|
+
let url;
|
|
1328
|
+
let identifier;
|
|
1329
|
+
try {
|
|
1330
|
+
({ fetch: url, identifier } = resolveSignatureAgent(src.directory));
|
|
1331
|
+
} catch {
|
|
1332
|
+
this.debug(`${src.name}: directory is not an https URL`);
|
|
1333
|
+
return null;
|
|
1334
|
+
}
|
|
1287
1335
|
const controller = new AbortController();
|
|
1288
1336
|
const timer = setTimeout(() => controller.abort(), this.opts.fetchTimeoutMs);
|
|
1289
1337
|
try {
|
|
@@ -1292,7 +1340,8 @@ var DirectoryCache = class {
|
|
|
1292
1340
|
headers: {
|
|
1293
1341
|
Accept: "application/http-message-signatures-directory+json, application/jwk-set+json, application/json"
|
|
1294
1342
|
},
|
|
1295
|
-
|
|
1343
|
+
// Web Bot Auth draft 01 §5.5: redirects are a discovery failure.
|
|
1344
|
+
redirect: "error"
|
|
1296
1345
|
});
|
|
1297
1346
|
if (!res.ok) {
|
|
1298
1347
|
this.debug(`${src.name}: HTTP ${res.status}`);
|
|
@@ -1306,7 +1355,7 @@ var DirectoryCache = class {
|
|
|
1306
1355
|
const out = [];
|
|
1307
1356
|
for (const jwk of body.keys) {
|
|
1308
1357
|
const resolved = await importKey(jwk, src);
|
|
1309
|
-
if (resolved) out.push(resolved);
|
|
1358
|
+
if (resolved) out.push({ identifier, ...resolved });
|
|
1310
1359
|
}
|
|
1311
1360
|
this.debug(`${src.name}: ${out.length} key(s)`);
|
|
1312
1361
|
return out;
|
|
@@ -1321,11 +1370,8 @@ var DirectoryCache = class {
|
|
|
1321
1370
|
if (this.opts.debug) console.log(`[WebDecoy][web-bot-auth] ${msg}`);
|
|
1322
1371
|
}
|
|
1323
1372
|
};
|
|
1324
|
-
function
|
|
1325
|
-
|
|
1326
|
-
if (u.pathname && u.pathname !== "/") return u.toString();
|
|
1327
|
-
u.pathname = WELL_KNOWN;
|
|
1328
|
-
return u.toString();
|
|
1373
|
+
function cacheKey(agent, keyId) {
|
|
1374
|
+
return `${agent} ${keyId}`;
|
|
1329
1375
|
}
|
|
1330
1376
|
async function importKey(jwk, src) {
|
|
1331
1377
|
try {
|
|
@@ -1395,6 +1441,14 @@ var Cursor = class {
|
|
|
1395
1441
|
while (!this.eof() && (this.peek() === " " || this.peek() === " ")) this.i++;
|
|
1396
1442
|
}
|
|
1397
1443
|
};
|
|
1444
|
+
function parseBareString(input) {
|
|
1445
|
+
const p = new Cursor(input);
|
|
1446
|
+
p.skipSP();
|
|
1447
|
+
const value = parseString(p);
|
|
1448
|
+
p.skipSP();
|
|
1449
|
+
if (!p.eof()) throw new Error("trailing data after string");
|
|
1450
|
+
return value;
|
|
1451
|
+
}
|
|
1398
1452
|
function parseDictionary(input) {
|
|
1399
1453
|
const p = new Cursor(input);
|
|
1400
1454
|
const out = [];
|
|
@@ -1562,7 +1616,14 @@ async function verifyWebBotAuth(req, resolveKey, toleranceSec) {
|
|
|
1562
1616
|
const keyid = m.params.get("keyid");
|
|
1563
1617
|
if (typeof keyid !== "string") continue;
|
|
1564
1618
|
if (!m.components.some((c) => c.name === "@authority" || c.name === "@target-uri")) continue;
|
|
1565
|
-
|
|
1619
|
+
let agent;
|
|
1620
|
+
try {
|
|
1621
|
+
agent = coveredSignatureAgent(req, m);
|
|
1622
|
+
} catch {
|
|
1623
|
+
best = higher(best, { outcome: "claimed", keyId: keyid, reason: "unbound-agent" });
|
|
1624
|
+
continue;
|
|
1625
|
+
}
|
|
1626
|
+
const key = await resolveKey(keyid, agent);
|
|
1566
1627
|
if (!key) {
|
|
1567
1628
|
best = higher(best, { outcome: "claimed", keyId: keyid, reason: "unknown-key" });
|
|
1568
1629
|
continue;
|
|
@@ -1635,11 +1696,11 @@ function componentValue(req, c) {
|
|
|
1635
1696
|
case "@method":
|
|
1636
1697
|
return req.method.toUpperCase();
|
|
1637
1698
|
case "@authority":
|
|
1638
|
-
return
|
|
1699
|
+
return canonicalAuthority2(req.url);
|
|
1639
1700
|
case "@scheme":
|
|
1640
1701
|
return req.url.protocol.replace(/:$/, "").toLowerCase();
|
|
1641
1702
|
case "@target-uri":
|
|
1642
|
-
return `${req.url.protocol}//${
|
|
1703
|
+
return `${req.url.protocol}//${canonicalAuthority2(req.url)}${req.url.pathname}${req.url.search}`;
|
|
1643
1704
|
case "@path":
|
|
1644
1705
|
return req.url.pathname;
|
|
1645
1706
|
case "@query":
|
|
@@ -1658,7 +1719,7 @@ function componentValue(req, c) {
|
|
|
1658
1719
|
}
|
|
1659
1720
|
}
|
|
1660
1721
|
}
|
|
1661
|
-
function
|
|
1722
|
+
function canonicalAuthority2(url) {
|
|
1662
1723
|
const host = url.hostname.toLowerCase();
|
|
1663
1724
|
const port = url.port;
|
|
1664
1725
|
if (!port) return host;
|
|
@@ -1673,6 +1734,28 @@ function dictMemberValue(header2, key) {
|
|
|
1673
1734
|
if (!found) throw new Error(`signature-agent has no member ${key}`);
|
|
1674
1735
|
return found.raw;
|
|
1675
1736
|
}
|
|
1737
|
+
function coveredSignatureAgent(req, m) {
|
|
1738
|
+
const header2 = req.headers.get("signature-agent");
|
|
1739
|
+
if (header2 === null) throw new Error("missing signature-agent");
|
|
1740
|
+
const component = m.components.find((c) => c.name.toLowerCase() === "signature-agent");
|
|
1741
|
+
if (!component) throw new Error("signature-agent is not covered");
|
|
1742
|
+
const trimmed = header2.trim();
|
|
1743
|
+
let value;
|
|
1744
|
+
if (trimmed.startsWith('"')) {
|
|
1745
|
+
if (component.keyParam !== void 0) throw new Error("legacy string cannot select a member");
|
|
1746
|
+
value = parseBareString(trimmed);
|
|
1747
|
+
} else {
|
|
1748
|
+
if (component.keyParam === void 0) throw new Error("dictionary member is not covered");
|
|
1749
|
+
const member = parseDictionary(trimmed).find((d) => d.key === component.keyParam);
|
|
1750
|
+
const item = member?.items[0];
|
|
1751
|
+
if (!member || member.isList || member.items.length !== 1 || typeof item?.value !== "string") {
|
|
1752
|
+
throw new Error("signature-agent member is not a string");
|
|
1753
|
+
}
|
|
1754
|
+
if (item.params.size > 0) throw new Error("signature-agent member carries parameters");
|
|
1755
|
+
value = item.value;
|
|
1756
|
+
}
|
|
1757
|
+
return resolveSignatureAgent(value).identifier;
|
|
1758
|
+
}
|
|
1676
1759
|
function parseSignatureInput(value) {
|
|
1677
1760
|
return parseDictionary(value).map((d) => {
|
|
1678
1761
|
if (!d.isList) throw new Error(`Signature-Input member ${d.key} is not an inner list`);
|
package/dist/testing.mjs
CHANGED
package/dist/vercel.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClearanceGateOptions, C as ClearanceContext, D as DetectAndGateOptions, d as GateOutcome } from './detect-and-gate-
|
|
2
|
-
import './sdk-
|
|
1
|
+
import { a as ClearanceGateOptions, C as ClearanceContext, D as DetectAndGateOptions, d as GateOutcome } from './detect-and-gate-BUFbu1y5.mjs';
|
|
2
|
+
import './sdk-CmWmCDuZ.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* WebDecoy for Vercel Routing Middleware, any framework.
|
package/dist/vercel.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClearanceGateOptions, C as ClearanceContext, D as DetectAndGateOptions, d as GateOutcome } from './detect-and-gate-
|
|
2
|
-
import './sdk-
|
|
1
|
+
import { a as ClearanceGateOptions, C as ClearanceContext, D as DetectAndGateOptions, d as GateOutcome } from './detect-and-gate-CU2u2EZD.js';
|
|
2
|
+
import './sdk-CmWmCDuZ.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* WebDecoy for Vercel Routing Middleware, any framework.
|