@webdecoy/node 0.8.0 → 0.9.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/index.d.mts +214 -1
- package/dist/index.d.ts +214 -1
- package/dist/index.js +313 -1
- package/dist/index.mjs +307 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -219,6 +219,119 @@ interface EdgeVerdict {
|
|
|
219
219
|
*/
|
|
220
220
|
declare function readEdgeVerdict(headers: Record<string, string> | undefined): EdgeVerdict;
|
|
221
221
|
|
|
222
|
+
/**
|
|
223
|
+
* GENERATED FILE — DO NOT EDIT.
|
|
224
|
+
*
|
|
225
|
+
* Source of truth: WebDecoy/app `pkg/agents` (Go).
|
|
226
|
+
* Regenerate with `packages/webdecoy/scripts/gen-bot-registry.mjs`; see that
|
|
227
|
+
* script for the command.
|
|
228
|
+
*
|
|
229
|
+
* ORDER IS SIGNIFICANT. Entries are in `agents.MatchUserAgent` order — AI data
|
|
230
|
+
* scrapers first, then AI search crawlers, AI agents, search engines, then the
|
|
231
|
+
* remaining categories. `matchUserAgent()` returns the first hit, and several
|
|
232
|
+
* agents share User-Agent substrings, so sorting this array changes how real
|
|
233
|
+
* traffic is classified.
|
|
234
|
+
*
|
|
235
|
+
* 168 agents across 15 categories.
|
|
236
|
+
*/
|
|
237
|
+
/**
|
|
238
|
+
* Classification categories, mirroring `agents.Category` in Go.
|
|
239
|
+
*
|
|
240
|
+
* Declared here rather than hand-written next door so a category added in Go
|
|
241
|
+
* cannot go missing in TypeScript.
|
|
242
|
+
*/
|
|
243
|
+
type BotCategory = "training_crawler" | "ai_search_crawler" | "ai_agent" | "ai_assistant" | "search_crawler" | "seo_crawler" | "security_scanner" | "generic_scraper" | "archiver" | "fetcher" | "monitoring" | "headless_browser" | "feed_reader" | "commercial_scraper" | "none";
|
|
244
|
+
/** One entry in the registry. */
|
|
245
|
+
interface BotAgent {
|
|
246
|
+
/** Stable lowercase slug, e.g. `gptbot`. */
|
|
247
|
+
id: string;
|
|
248
|
+
/** Display name, e.g. `GPTBot`. */
|
|
249
|
+
name: string;
|
|
250
|
+
category: BotCategory;
|
|
251
|
+
/** Operator, e.g. `OpenAI`. */
|
|
252
|
+
organization: string;
|
|
253
|
+
/** The registry's default threat score for this agent (0-100). */
|
|
254
|
+
baseScore: number;
|
|
255
|
+
/** Whether the operator documents honouring robots.txt. */
|
|
256
|
+
respectsRobots: boolean;
|
|
257
|
+
/** Lowercase User-Agent substrings that identify it. */
|
|
258
|
+
uaPatterns: readonly string[];
|
|
259
|
+
}
|
|
260
|
+
/** Every declared category, including any with no agents yet. */
|
|
261
|
+
declare const BOT_CATEGORIES: readonly BotCategory[];
|
|
262
|
+
/** The agent table, in match order. */
|
|
263
|
+
declare const BOT_REGISTRY: readonly BotAgent[];
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Local bot classification (#500).
|
|
267
|
+
*
|
|
268
|
+
* WHY THIS IS IN THE SDK AT ALL
|
|
269
|
+
*
|
|
270
|
+
* The scoring pipeline already identifies named agents server-side, but it does
|
|
271
|
+
* so *after* the request is reported — which is too late to decide anything. A
|
|
272
|
+
* customer who wants "block AI training crawlers, allow search crawlers" needs
|
|
273
|
+
* the answer synchronously, in the request path, with no network call. So the Go
|
|
274
|
+
* registry is generated into {@link BOT_REGISTRY} and matched here.
|
|
275
|
+
*
|
|
276
|
+
* WHAT THIS IS NOT
|
|
277
|
+
*
|
|
278
|
+
* This is a User-Agent lookup. It identifies agents that say who they are, and
|
|
279
|
+
* nothing else. An agent that spoofs Chrome is invisible to it, and always will
|
|
280
|
+
* be — that is the point of the 1% User-Agent weight in the unified score, and
|
|
281
|
+
* nothing here changes that arithmetic.
|
|
282
|
+
*
|
|
283
|
+
* That is a feature for the use case it serves. GPTBot, ClaudeBot and Googlebot
|
|
284
|
+
* all self-identify honestly, and the decision a customer wants to make about
|
|
285
|
+
* them ("don't train on my content") is a POLICY choice about a cooperative
|
|
286
|
+
* agent, not a threat judgement about a hostile one. Acting on a claim is
|
|
287
|
+
* correct when the claim is the thing you care about.
|
|
288
|
+
*
|
|
289
|
+
* For agents that lie, the answer is the rest of the product: tripwires,
|
|
290
|
+
* honeytokens and the edge classifier see behaviour, which cannot be spoofed by
|
|
291
|
+
* editing a header.
|
|
292
|
+
*/
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* What a rule sees about the agent behind a request.
|
|
296
|
+
*
|
|
297
|
+
* Always populated, never undefined: a rule that has to check whether
|
|
298
|
+
* classification ran is a rule people get wrong. When nothing matched,
|
|
299
|
+
* `known` is false and `category` is `'none'`.
|
|
300
|
+
*/
|
|
301
|
+
interface BotVerdict {
|
|
302
|
+
/** Whether the User-Agent matched a known agent. */
|
|
303
|
+
known: boolean;
|
|
304
|
+
/** Registry slug, e.g. `gptbot`. Undefined when unknown. */
|
|
305
|
+
id?: string;
|
|
306
|
+
/** Display name, e.g. `GPTBot`. Undefined when unknown. */
|
|
307
|
+
name?: string;
|
|
308
|
+
/** Customer-facing category — the same vocabulary as the dashboard. */
|
|
309
|
+
category: BotCategory;
|
|
310
|
+
/** Operator, e.g. `OpenAI`. Undefined when unknown. */
|
|
311
|
+
organization?: string;
|
|
312
|
+
/** The registry's threat score for this agent, 0-100. 0 when unknown. */
|
|
313
|
+
score: number;
|
|
314
|
+
/**
|
|
315
|
+
* Whether the operator documents honouring robots.txt. Undefined when unknown.
|
|
316
|
+
*
|
|
317
|
+
* Documented behaviour, not observed behaviour — it is what the operator
|
|
318
|
+
* publishes, so treat it as a claim like any other.
|
|
319
|
+
*/
|
|
320
|
+
respectsRobots?: boolean;
|
|
321
|
+
/** True for training crawlers, AI search crawlers, AI agents and assistants. */
|
|
322
|
+
isAI: boolean;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Find the agent behind a User-Agent string, or undefined.
|
|
326
|
+
*
|
|
327
|
+
* Returns the FIRST match in registry order, which is why {@link BOT_REGISTRY}
|
|
328
|
+
* must not be sorted: the table arrives ordered by category priority, mirroring
|
|
329
|
+
* `agents.MatchUserAgent` in Go so both sides classify identically.
|
|
330
|
+
*/
|
|
331
|
+
declare function matchUserAgent(userAgent: string | undefined | null): BotAgent | undefined;
|
|
332
|
+
/** Classify a User-Agent into the verdict rules evaluate against. */
|
|
333
|
+
declare function classifyUserAgent(userAgent: string | undefined | null): BotVerdict;
|
|
334
|
+
|
|
222
335
|
/**
|
|
223
336
|
* Rules Engine Types
|
|
224
337
|
* Core interfaces for the WebDecoy rules engine
|
|
@@ -255,6 +368,15 @@ interface RuleContext {
|
|
|
255
368
|
* `edge.class`, `edge.clearance` and `edge.present`.
|
|
256
369
|
*/
|
|
257
370
|
edge?: EdgeVerdict;
|
|
371
|
+
/**
|
|
372
|
+
* Who the User-Agent says it is (#500), matched against the generated agent
|
|
373
|
+
* registry. Always populated — `known: false` when nothing matched. Filter
|
|
374
|
+
* expressions read it as `bot.category`, `bot.name`, `bot.ai` and friends.
|
|
375
|
+
*
|
|
376
|
+
* A self-declared identity, so it is evidence about cooperative agents only.
|
|
377
|
+
* See {@link BotVerdict}.
|
|
378
|
+
*/
|
|
379
|
+
bot?: BotVerdict;
|
|
258
380
|
}
|
|
259
381
|
/**
|
|
260
382
|
* Result of evaluating a single rule
|
|
@@ -308,6 +430,32 @@ interface FilterConfig {
|
|
|
308
430
|
/** Dry run mode: log violations but don't block */
|
|
309
431
|
dryRun?: boolean;
|
|
310
432
|
}
|
|
433
|
+
/**
|
|
434
|
+
* Configuration for bot-category rules (#500)
|
|
435
|
+
*/
|
|
436
|
+
interface BotRuleConfig {
|
|
437
|
+
/**
|
|
438
|
+
* Categories to act on, e.g. `['training_crawler']`. Uses the same vocabulary
|
|
439
|
+
* as the dashboard's `ai_scraper_category` column.
|
|
440
|
+
*/
|
|
441
|
+
categories?: BotCategory[];
|
|
442
|
+
/** Specific agents by registry slug or display name, e.g. `['gptbot']`. */
|
|
443
|
+
agents?: string[];
|
|
444
|
+
/**
|
|
445
|
+
* Act on every AI client — training crawlers, AI search crawlers, AI agents
|
|
446
|
+
* and AI assistants.
|
|
447
|
+
*/
|
|
448
|
+
ai?: boolean;
|
|
449
|
+
/**
|
|
450
|
+
* Never act on these, whatever else matches. Applied last, so
|
|
451
|
+
* `{ ai: true, allow: ['perplexitybot'] }` reads the way it looks.
|
|
452
|
+
*/
|
|
453
|
+
allow?: string[];
|
|
454
|
+
/** Action when an agent matches: 'DENY' (default) or 'THROTTLE'. */
|
|
455
|
+
action?: 'DENY' | 'THROTTLE';
|
|
456
|
+
/** Log the violation but don't block. */
|
|
457
|
+
dryRun?: boolean;
|
|
458
|
+
}
|
|
311
459
|
/**
|
|
312
460
|
* Configuration for tripwire (honeypot-path) rules
|
|
313
461
|
*/
|
|
@@ -826,6 +974,41 @@ declare class TripwireRule implements Rule {
|
|
|
826
974
|
evaluate(context: RuleContext): RuleResult;
|
|
827
975
|
}
|
|
828
976
|
|
|
977
|
+
/**
|
|
978
|
+
* Bot-category rule (#500).
|
|
979
|
+
*
|
|
980
|
+
* The one-liner for the policy this product category exists to express:
|
|
981
|
+
*
|
|
982
|
+
* ```typescript
|
|
983
|
+
* bots({ categories: ['training_crawler'] }) // no AI training on my content
|
|
984
|
+
* ```
|
|
985
|
+
*
|
|
986
|
+
* This is expressible as a filter expression too — `bot.category ==
|
|
987
|
+
* "training_crawler"` — and that is the right tool once the policy has
|
|
988
|
+
* conditions. This exists because the common case should not require learning an
|
|
989
|
+
* expression language, and because `allow` is fiddly to spell correctly by hand.
|
|
990
|
+
*
|
|
991
|
+
* WHAT IT CAN AND CANNOT SEE
|
|
992
|
+
*
|
|
993
|
+
* It matches on the User-Agent, so it only ever acts on agents that declare
|
|
994
|
+
* themselves. That is sound for this policy — GPTBot and ClaudeBot identify
|
|
995
|
+
* honestly, and the decision is about a cooperative agent's access, not about
|
|
996
|
+
* catching a liar. Anything spoofing Chrome passes straight through, and the
|
|
997
|
+
* tripwire and edge layers are what catch those.
|
|
998
|
+
*/
|
|
999
|
+
|
|
1000
|
+
declare class BotRule implements Rule {
|
|
1001
|
+
readonly name = "bots";
|
|
1002
|
+
private readonly categories;
|
|
1003
|
+
private readonly agents;
|
|
1004
|
+
private readonly ai;
|
|
1005
|
+
private readonly allow;
|
|
1006
|
+
private readonly action;
|
|
1007
|
+
private readonly dryRun;
|
|
1008
|
+
constructor(config?: BotRuleConfig);
|
|
1009
|
+
evaluate(context: RuleContext): RuleResult;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
829
1012
|
/**
|
|
830
1013
|
* Web Bot Auth rule (WebDecoy/app#323).
|
|
831
1014
|
*
|
|
@@ -1089,6 +1272,36 @@ declare function filter(config: FilterConfig): Rule;
|
|
|
1089
1272
|
* ```
|
|
1090
1273
|
*/
|
|
1091
1274
|
declare function tripwire(config?: TripwireConfig): Rule;
|
|
1275
|
+
/**
|
|
1276
|
+
* Factory function to create a bot-category rule (#500).
|
|
1277
|
+
*
|
|
1278
|
+
* Acts on agents that identify themselves in the User-Agent, matched against the
|
|
1279
|
+
* registry generated from the same table the scoring pipeline uses — so
|
|
1280
|
+
* `'training_crawler'` here means what `ai_scraper_category` means in your
|
|
1281
|
+
* dashboard.
|
|
1282
|
+
*
|
|
1283
|
+
* @example
|
|
1284
|
+
* ```typescript
|
|
1285
|
+
* import { WebDecoy, bots } from '@webdecoy/node';
|
|
1286
|
+
*
|
|
1287
|
+
* const sdk = new WebDecoy({
|
|
1288
|
+
* rules: [
|
|
1289
|
+
* // Keep AI models out of your content, keep your search ranking.
|
|
1290
|
+
* bots({ categories: ['training_crawler'] }),
|
|
1291
|
+
*
|
|
1292
|
+
* // Or everything AI, minus the one you want referral traffic from.
|
|
1293
|
+
* bots({ ai: true, allow: ['perplexitybot'] }),
|
|
1294
|
+
*
|
|
1295
|
+
* // Or a specific operator.
|
|
1296
|
+
* bots({ agents: ['gptbot', 'ClaudeBot'], action: 'THROTTLE' }),
|
|
1297
|
+
* ],
|
|
1298
|
+
* });
|
|
1299
|
+
* ```
|
|
1300
|
+
*
|
|
1301
|
+
* Only catches agents that declare themselves — anything spoofing a browser
|
|
1302
|
+
* passes through, by design. Pair with {@link tripwire} for agents that lie.
|
|
1303
|
+
*/
|
|
1304
|
+
declare function bots(config?: BotRuleConfig): Rule;
|
|
1092
1305
|
|
|
1093
1306
|
/**
|
|
1094
1307
|
* AgentVerifier — the public entry point for local Web Bot Auth verification.
|
|
@@ -1880,4 +2093,4 @@ declare function createCaptchaEndpoints(options?: CaptchaEndpointsOptions): {
|
|
|
1880
2093
|
};
|
|
1881
2094
|
type CaptchaEndpoints = ReturnType<typeof createCaptchaEndpoints>;
|
|
1882
2095
|
|
|
1883
|
-
export { type AgentCategory, type AgentRequestInput, type AgentStatus, type AgentVerdict, AgentVerifier, type AgentVerifierOptions, type BehavioralSignals, Captcha, type CaptchaEndpoints, type CaptchaEndpointsOptions, type CaptchaHttpResponse, type CaptchaOptions, type CaptchaRequest, type CategoryScores, type ChallengeData, type ChallengeStore, DEFAULT_SIGNED_AGENT_DIRECTORIES, DEFAULT_TRIPWIRE_PATHS, DEFAULT_WEIGHTS, type Detection, type DetectionContext, DetectionEngine, type DetectionEngineOptions, DirectoryCache, EDGE_CLASS_HEADER, EDGE_CLEARANCE_HEADER, type EdgeClass, type EdgeVerdict, type EnvironmentalSignals, type FilterConfig, FilterRule, type FingerprintStore, type FormAnalysisSignals, HONEYTOKEN_BASE_PATH, type Honeytoken, type HoneytokenLinkProps, type HoneytokenOptions, type IPEnrichmentData, InMemoryChallengeStore, InMemoryFingerprintStore, InMemoryRateLimiter, InMemoryTokenStore, type LocalAnalysis, PoWManager, type PoWManagerOptions, type PoWOutcome, type PoWSolution, type PoWVerification, type ProtectOptions, type ProtectResult, type RateLimitConfig, RateLimitRule, type RateLimiter, type Recommendation, type RequestMetadata, type Rule, type RuleContext, RuleEngine, type RuleEngineResult, type RuleResult, type SDKDetectionRequest, type SDKDetectionResponse, type ScoreResult, type Signals, type SignedAgentDirectory, type SiteHoneytoken, type SiteHoneytokenOptions, type StoredChallenge, type TLSInfo, type TemporalSignals, type TextareaKeyboardStats, TokenManager, type TokenManagerOptions, type TokenStore, type TokenVerification, type TripwireConfig, TripwireRule, type Verdict, type VerifyInput, type VerifyResult, type ViolationEvent, type WebBotAuthConfig, WebBotAuthRule, WebDecoy, type WebDecoyConfig, calculateCategoryScores, calculateFinalScore, createAgentVerifier, createCaptchaEndpoints, filter, honeytoken, injectHoneytokenLink, isDatacenterIP, isInjectableHtml, isMobileUA, parseUserAgent, rateLimit, readEdgeVerdict, recommend, resolveSecret, siteHoneytoken, tripwire, webBotAuth };
|
|
2096
|
+
export { type AgentCategory, type AgentRequestInput, type AgentStatus, type AgentVerdict, AgentVerifier, type AgentVerifierOptions, BOT_CATEGORIES, BOT_REGISTRY, type BehavioralSignals, type BotAgent, type BotCategory, BotRule, type BotRuleConfig, type BotVerdict, Captcha, type CaptchaEndpoints, type CaptchaEndpointsOptions, type CaptchaHttpResponse, type CaptchaOptions, type CaptchaRequest, type CategoryScores, type ChallengeData, type ChallengeStore, DEFAULT_SIGNED_AGENT_DIRECTORIES, DEFAULT_TRIPWIRE_PATHS, DEFAULT_WEIGHTS, type Detection, type DetectionContext, DetectionEngine, type DetectionEngineOptions, DirectoryCache, EDGE_CLASS_HEADER, EDGE_CLEARANCE_HEADER, type EdgeClass, type EdgeVerdict, type EnvironmentalSignals, type FilterConfig, FilterRule, type FingerprintStore, type FormAnalysisSignals, HONEYTOKEN_BASE_PATH, type Honeytoken, type HoneytokenLinkProps, type HoneytokenOptions, type IPEnrichmentData, InMemoryChallengeStore, InMemoryFingerprintStore, InMemoryRateLimiter, InMemoryTokenStore, type LocalAnalysis, PoWManager, type PoWManagerOptions, type PoWOutcome, type PoWSolution, type PoWVerification, type ProtectOptions, type ProtectResult, type RateLimitConfig, RateLimitRule, type RateLimiter, type Recommendation, type RequestMetadata, type Rule, type RuleContext, RuleEngine, type RuleEngineResult, type RuleResult, type SDKDetectionRequest, type SDKDetectionResponse, type ScoreResult, type Signals, type SignedAgentDirectory, type SiteHoneytoken, type SiteHoneytokenOptions, type StoredChallenge, type TLSInfo, type TemporalSignals, type TextareaKeyboardStats, TokenManager, type TokenManagerOptions, type TokenStore, type TokenVerification, type TripwireConfig, TripwireRule, type Verdict, type VerifyInput, type VerifyResult, type ViolationEvent, type WebBotAuthConfig, WebBotAuthRule, WebDecoy, type WebDecoyConfig, bots, calculateCategoryScores, calculateFinalScore, classifyUserAgent, createAgentVerifier, createCaptchaEndpoints, filter, honeytoken, injectHoneytokenLink, isDatacenterIP, isInjectableHtml, isMobileUA, matchUserAgent, parseUserAgent, rateLimit, readEdgeVerdict, recommend, resolveSecret, siteHoneytoken, tripwire, webBotAuth };
|
package/dist/index.d.ts
CHANGED
|
@@ -219,6 +219,119 @@ interface EdgeVerdict {
|
|
|
219
219
|
*/
|
|
220
220
|
declare function readEdgeVerdict(headers: Record<string, string> | undefined): EdgeVerdict;
|
|
221
221
|
|
|
222
|
+
/**
|
|
223
|
+
* GENERATED FILE — DO NOT EDIT.
|
|
224
|
+
*
|
|
225
|
+
* Source of truth: WebDecoy/app `pkg/agents` (Go).
|
|
226
|
+
* Regenerate with `packages/webdecoy/scripts/gen-bot-registry.mjs`; see that
|
|
227
|
+
* script for the command.
|
|
228
|
+
*
|
|
229
|
+
* ORDER IS SIGNIFICANT. Entries are in `agents.MatchUserAgent` order — AI data
|
|
230
|
+
* scrapers first, then AI search crawlers, AI agents, search engines, then the
|
|
231
|
+
* remaining categories. `matchUserAgent()` returns the first hit, and several
|
|
232
|
+
* agents share User-Agent substrings, so sorting this array changes how real
|
|
233
|
+
* traffic is classified.
|
|
234
|
+
*
|
|
235
|
+
* 168 agents across 15 categories.
|
|
236
|
+
*/
|
|
237
|
+
/**
|
|
238
|
+
* Classification categories, mirroring `agents.Category` in Go.
|
|
239
|
+
*
|
|
240
|
+
* Declared here rather than hand-written next door so a category added in Go
|
|
241
|
+
* cannot go missing in TypeScript.
|
|
242
|
+
*/
|
|
243
|
+
type BotCategory = "training_crawler" | "ai_search_crawler" | "ai_agent" | "ai_assistant" | "search_crawler" | "seo_crawler" | "security_scanner" | "generic_scraper" | "archiver" | "fetcher" | "monitoring" | "headless_browser" | "feed_reader" | "commercial_scraper" | "none";
|
|
244
|
+
/** One entry in the registry. */
|
|
245
|
+
interface BotAgent {
|
|
246
|
+
/** Stable lowercase slug, e.g. `gptbot`. */
|
|
247
|
+
id: string;
|
|
248
|
+
/** Display name, e.g. `GPTBot`. */
|
|
249
|
+
name: string;
|
|
250
|
+
category: BotCategory;
|
|
251
|
+
/** Operator, e.g. `OpenAI`. */
|
|
252
|
+
organization: string;
|
|
253
|
+
/** The registry's default threat score for this agent (0-100). */
|
|
254
|
+
baseScore: number;
|
|
255
|
+
/** Whether the operator documents honouring robots.txt. */
|
|
256
|
+
respectsRobots: boolean;
|
|
257
|
+
/** Lowercase User-Agent substrings that identify it. */
|
|
258
|
+
uaPatterns: readonly string[];
|
|
259
|
+
}
|
|
260
|
+
/** Every declared category, including any with no agents yet. */
|
|
261
|
+
declare const BOT_CATEGORIES: readonly BotCategory[];
|
|
262
|
+
/** The agent table, in match order. */
|
|
263
|
+
declare const BOT_REGISTRY: readonly BotAgent[];
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Local bot classification (#500).
|
|
267
|
+
*
|
|
268
|
+
* WHY THIS IS IN THE SDK AT ALL
|
|
269
|
+
*
|
|
270
|
+
* The scoring pipeline already identifies named agents server-side, but it does
|
|
271
|
+
* so *after* the request is reported — which is too late to decide anything. A
|
|
272
|
+
* customer who wants "block AI training crawlers, allow search crawlers" needs
|
|
273
|
+
* the answer synchronously, in the request path, with no network call. So the Go
|
|
274
|
+
* registry is generated into {@link BOT_REGISTRY} and matched here.
|
|
275
|
+
*
|
|
276
|
+
* WHAT THIS IS NOT
|
|
277
|
+
*
|
|
278
|
+
* This is a User-Agent lookup. It identifies agents that say who they are, and
|
|
279
|
+
* nothing else. An agent that spoofs Chrome is invisible to it, and always will
|
|
280
|
+
* be — that is the point of the 1% User-Agent weight in the unified score, and
|
|
281
|
+
* nothing here changes that arithmetic.
|
|
282
|
+
*
|
|
283
|
+
* That is a feature for the use case it serves. GPTBot, ClaudeBot and Googlebot
|
|
284
|
+
* all self-identify honestly, and the decision a customer wants to make about
|
|
285
|
+
* them ("don't train on my content") is a POLICY choice about a cooperative
|
|
286
|
+
* agent, not a threat judgement about a hostile one. Acting on a claim is
|
|
287
|
+
* correct when the claim is the thing you care about.
|
|
288
|
+
*
|
|
289
|
+
* For agents that lie, the answer is the rest of the product: tripwires,
|
|
290
|
+
* honeytokens and the edge classifier see behaviour, which cannot be spoofed by
|
|
291
|
+
* editing a header.
|
|
292
|
+
*/
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* What a rule sees about the agent behind a request.
|
|
296
|
+
*
|
|
297
|
+
* Always populated, never undefined: a rule that has to check whether
|
|
298
|
+
* classification ran is a rule people get wrong. When nothing matched,
|
|
299
|
+
* `known` is false and `category` is `'none'`.
|
|
300
|
+
*/
|
|
301
|
+
interface BotVerdict {
|
|
302
|
+
/** Whether the User-Agent matched a known agent. */
|
|
303
|
+
known: boolean;
|
|
304
|
+
/** Registry slug, e.g. `gptbot`. Undefined when unknown. */
|
|
305
|
+
id?: string;
|
|
306
|
+
/** Display name, e.g. `GPTBot`. Undefined when unknown. */
|
|
307
|
+
name?: string;
|
|
308
|
+
/** Customer-facing category — the same vocabulary as the dashboard. */
|
|
309
|
+
category: BotCategory;
|
|
310
|
+
/** Operator, e.g. `OpenAI`. Undefined when unknown. */
|
|
311
|
+
organization?: string;
|
|
312
|
+
/** The registry's threat score for this agent, 0-100. 0 when unknown. */
|
|
313
|
+
score: number;
|
|
314
|
+
/**
|
|
315
|
+
* Whether the operator documents honouring robots.txt. Undefined when unknown.
|
|
316
|
+
*
|
|
317
|
+
* Documented behaviour, not observed behaviour — it is what the operator
|
|
318
|
+
* publishes, so treat it as a claim like any other.
|
|
319
|
+
*/
|
|
320
|
+
respectsRobots?: boolean;
|
|
321
|
+
/** True for training crawlers, AI search crawlers, AI agents and assistants. */
|
|
322
|
+
isAI: boolean;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Find the agent behind a User-Agent string, or undefined.
|
|
326
|
+
*
|
|
327
|
+
* Returns the FIRST match in registry order, which is why {@link BOT_REGISTRY}
|
|
328
|
+
* must not be sorted: the table arrives ordered by category priority, mirroring
|
|
329
|
+
* `agents.MatchUserAgent` in Go so both sides classify identically.
|
|
330
|
+
*/
|
|
331
|
+
declare function matchUserAgent(userAgent: string | undefined | null): BotAgent | undefined;
|
|
332
|
+
/** Classify a User-Agent into the verdict rules evaluate against. */
|
|
333
|
+
declare function classifyUserAgent(userAgent: string | undefined | null): BotVerdict;
|
|
334
|
+
|
|
222
335
|
/**
|
|
223
336
|
* Rules Engine Types
|
|
224
337
|
* Core interfaces for the WebDecoy rules engine
|
|
@@ -255,6 +368,15 @@ interface RuleContext {
|
|
|
255
368
|
* `edge.class`, `edge.clearance` and `edge.present`.
|
|
256
369
|
*/
|
|
257
370
|
edge?: EdgeVerdict;
|
|
371
|
+
/**
|
|
372
|
+
* Who the User-Agent says it is (#500), matched against the generated agent
|
|
373
|
+
* registry. Always populated — `known: false` when nothing matched. Filter
|
|
374
|
+
* expressions read it as `bot.category`, `bot.name`, `bot.ai` and friends.
|
|
375
|
+
*
|
|
376
|
+
* A self-declared identity, so it is evidence about cooperative agents only.
|
|
377
|
+
* See {@link BotVerdict}.
|
|
378
|
+
*/
|
|
379
|
+
bot?: BotVerdict;
|
|
258
380
|
}
|
|
259
381
|
/**
|
|
260
382
|
* Result of evaluating a single rule
|
|
@@ -308,6 +430,32 @@ interface FilterConfig {
|
|
|
308
430
|
/** Dry run mode: log violations but don't block */
|
|
309
431
|
dryRun?: boolean;
|
|
310
432
|
}
|
|
433
|
+
/**
|
|
434
|
+
* Configuration for bot-category rules (#500)
|
|
435
|
+
*/
|
|
436
|
+
interface BotRuleConfig {
|
|
437
|
+
/**
|
|
438
|
+
* Categories to act on, e.g. `['training_crawler']`. Uses the same vocabulary
|
|
439
|
+
* as the dashboard's `ai_scraper_category` column.
|
|
440
|
+
*/
|
|
441
|
+
categories?: BotCategory[];
|
|
442
|
+
/** Specific agents by registry slug or display name, e.g. `['gptbot']`. */
|
|
443
|
+
agents?: string[];
|
|
444
|
+
/**
|
|
445
|
+
* Act on every AI client — training crawlers, AI search crawlers, AI agents
|
|
446
|
+
* and AI assistants.
|
|
447
|
+
*/
|
|
448
|
+
ai?: boolean;
|
|
449
|
+
/**
|
|
450
|
+
* Never act on these, whatever else matches. Applied last, so
|
|
451
|
+
* `{ ai: true, allow: ['perplexitybot'] }` reads the way it looks.
|
|
452
|
+
*/
|
|
453
|
+
allow?: string[];
|
|
454
|
+
/** Action when an agent matches: 'DENY' (default) or 'THROTTLE'. */
|
|
455
|
+
action?: 'DENY' | 'THROTTLE';
|
|
456
|
+
/** Log the violation but don't block. */
|
|
457
|
+
dryRun?: boolean;
|
|
458
|
+
}
|
|
311
459
|
/**
|
|
312
460
|
* Configuration for tripwire (honeypot-path) rules
|
|
313
461
|
*/
|
|
@@ -826,6 +974,41 @@ declare class TripwireRule implements Rule {
|
|
|
826
974
|
evaluate(context: RuleContext): RuleResult;
|
|
827
975
|
}
|
|
828
976
|
|
|
977
|
+
/**
|
|
978
|
+
* Bot-category rule (#500).
|
|
979
|
+
*
|
|
980
|
+
* The one-liner for the policy this product category exists to express:
|
|
981
|
+
*
|
|
982
|
+
* ```typescript
|
|
983
|
+
* bots({ categories: ['training_crawler'] }) // no AI training on my content
|
|
984
|
+
* ```
|
|
985
|
+
*
|
|
986
|
+
* This is expressible as a filter expression too — `bot.category ==
|
|
987
|
+
* "training_crawler"` — and that is the right tool once the policy has
|
|
988
|
+
* conditions. This exists because the common case should not require learning an
|
|
989
|
+
* expression language, and because `allow` is fiddly to spell correctly by hand.
|
|
990
|
+
*
|
|
991
|
+
* WHAT IT CAN AND CANNOT SEE
|
|
992
|
+
*
|
|
993
|
+
* It matches on the User-Agent, so it only ever acts on agents that declare
|
|
994
|
+
* themselves. That is sound for this policy — GPTBot and ClaudeBot identify
|
|
995
|
+
* honestly, and the decision is about a cooperative agent's access, not about
|
|
996
|
+
* catching a liar. Anything spoofing Chrome passes straight through, and the
|
|
997
|
+
* tripwire and edge layers are what catch those.
|
|
998
|
+
*/
|
|
999
|
+
|
|
1000
|
+
declare class BotRule implements Rule {
|
|
1001
|
+
readonly name = "bots";
|
|
1002
|
+
private readonly categories;
|
|
1003
|
+
private readonly agents;
|
|
1004
|
+
private readonly ai;
|
|
1005
|
+
private readonly allow;
|
|
1006
|
+
private readonly action;
|
|
1007
|
+
private readonly dryRun;
|
|
1008
|
+
constructor(config?: BotRuleConfig);
|
|
1009
|
+
evaluate(context: RuleContext): RuleResult;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
829
1012
|
/**
|
|
830
1013
|
* Web Bot Auth rule (WebDecoy/app#323).
|
|
831
1014
|
*
|
|
@@ -1089,6 +1272,36 @@ declare function filter(config: FilterConfig): Rule;
|
|
|
1089
1272
|
* ```
|
|
1090
1273
|
*/
|
|
1091
1274
|
declare function tripwire(config?: TripwireConfig): Rule;
|
|
1275
|
+
/**
|
|
1276
|
+
* Factory function to create a bot-category rule (#500).
|
|
1277
|
+
*
|
|
1278
|
+
* Acts on agents that identify themselves in the User-Agent, matched against the
|
|
1279
|
+
* registry generated from the same table the scoring pipeline uses — so
|
|
1280
|
+
* `'training_crawler'` here means what `ai_scraper_category` means in your
|
|
1281
|
+
* dashboard.
|
|
1282
|
+
*
|
|
1283
|
+
* @example
|
|
1284
|
+
* ```typescript
|
|
1285
|
+
* import { WebDecoy, bots } from '@webdecoy/node';
|
|
1286
|
+
*
|
|
1287
|
+
* const sdk = new WebDecoy({
|
|
1288
|
+
* rules: [
|
|
1289
|
+
* // Keep AI models out of your content, keep your search ranking.
|
|
1290
|
+
* bots({ categories: ['training_crawler'] }),
|
|
1291
|
+
*
|
|
1292
|
+
* // Or everything AI, minus the one you want referral traffic from.
|
|
1293
|
+
* bots({ ai: true, allow: ['perplexitybot'] }),
|
|
1294
|
+
*
|
|
1295
|
+
* // Or a specific operator.
|
|
1296
|
+
* bots({ agents: ['gptbot', 'ClaudeBot'], action: 'THROTTLE' }),
|
|
1297
|
+
* ],
|
|
1298
|
+
* });
|
|
1299
|
+
* ```
|
|
1300
|
+
*
|
|
1301
|
+
* Only catches agents that declare themselves — anything spoofing a browser
|
|
1302
|
+
* passes through, by design. Pair with {@link tripwire} for agents that lie.
|
|
1303
|
+
*/
|
|
1304
|
+
declare function bots(config?: BotRuleConfig): Rule;
|
|
1092
1305
|
|
|
1093
1306
|
/**
|
|
1094
1307
|
* AgentVerifier — the public entry point for local Web Bot Auth verification.
|
|
@@ -1880,4 +2093,4 @@ declare function createCaptchaEndpoints(options?: CaptchaEndpointsOptions): {
|
|
|
1880
2093
|
};
|
|
1881
2094
|
type CaptchaEndpoints = ReturnType<typeof createCaptchaEndpoints>;
|
|
1882
2095
|
|
|
1883
|
-
export { type AgentCategory, type AgentRequestInput, type AgentStatus, type AgentVerdict, AgentVerifier, type AgentVerifierOptions, type BehavioralSignals, Captcha, type CaptchaEndpoints, type CaptchaEndpointsOptions, type CaptchaHttpResponse, type CaptchaOptions, type CaptchaRequest, type CategoryScores, type ChallengeData, type ChallengeStore, DEFAULT_SIGNED_AGENT_DIRECTORIES, DEFAULT_TRIPWIRE_PATHS, DEFAULT_WEIGHTS, type Detection, type DetectionContext, DetectionEngine, type DetectionEngineOptions, DirectoryCache, EDGE_CLASS_HEADER, EDGE_CLEARANCE_HEADER, type EdgeClass, type EdgeVerdict, type EnvironmentalSignals, type FilterConfig, FilterRule, type FingerprintStore, type FormAnalysisSignals, HONEYTOKEN_BASE_PATH, type Honeytoken, type HoneytokenLinkProps, type HoneytokenOptions, type IPEnrichmentData, InMemoryChallengeStore, InMemoryFingerprintStore, InMemoryRateLimiter, InMemoryTokenStore, type LocalAnalysis, PoWManager, type PoWManagerOptions, type PoWOutcome, type PoWSolution, type PoWVerification, type ProtectOptions, type ProtectResult, type RateLimitConfig, RateLimitRule, type RateLimiter, type Recommendation, type RequestMetadata, type Rule, type RuleContext, RuleEngine, type RuleEngineResult, type RuleResult, type SDKDetectionRequest, type SDKDetectionResponse, type ScoreResult, type Signals, type SignedAgentDirectory, type SiteHoneytoken, type SiteHoneytokenOptions, type StoredChallenge, type TLSInfo, type TemporalSignals, type TextareaKeyboardStats, TokenManager, type TokenManagerOptions, type TokenStore, type TokenVerification, type TripwireConfig, TripwireRule, type Verdict, type VerifyInput, type VerifyResult, type ViolationEvent, type WebBotAuthConfig, WebBotAuthRule, WebDecoy, type WebDecoyConfig, calculateCategoryScores, calculateFinalScore, createAgentVerifier, createCaptchaEndpoints, filter, honeytoken, injectHoneytokenLink, isDatacenterIP, isInjectableHtml, isMobileUA, parseUserAgent, rateLimit, readEdgeVerdict, recommend, resolveSecret, siteHoneytoken, tripwire, webBotAuth };
|
|
2096
|
+
export { type AgentCategory, type AgentRequestInput, type AgentStatus, type AgentVerdict, AgentVerifier, type AgentVerifierOptions, BOT_CATEGORIES, BOT_REGISTRY, type BehavioralSignals, type BotAgent, type BotCategory, BotRule, type BotRuleConfig, type BotVerdict, Captcha, type CaptchaEndpoints, type CaptchaEndpointsOptions, type CaptchaHttpResponse, type CaptchaOptions, type CaptchaRequest, type CategoryScores, type ChallengeData, type ChallengeStore, DEFAULT_SIGNED_AGENT_DIRECTORIES, DEFAULT_TRIPWIRE_PATHS, DEFAULT_WEIGHTS, type Detection, type DetectionContext, DetectionEngine, type DetectionEngineOptions, DirectoryCache, EDGE_CLASS_HEADER, EDGE_CLEARANCE_HEADER, type EdgeClass, type EdgeVerdict, type EnvironmentalSignals, type FilterConfig, FilterRule, type FingerprintStore, type FormAnalysisSignals, HONEYTOKEN_BASE_PATH, type Honeytoken, type HoneytokenLinkProps, type HoneytokenOptions, type IPEnrichmentData, InMemoryChallengeStore, InMemoryFingerprintStore, InMemoryRateLimiter, InMemoryTokenStore, type LocalAnalysis, PoWManager, type PoWManagerOptions, type PoWOutcome, type PoWSolution, type PoWVerification, type ProtectOptions, type ProtectResult, type RateLimitConfig, RateLimitRule, type RateLimiter, type Recommendation, type RequestMetadata, type Rule, type RuleContext, RuleEngine, type RuleEngineResult, type RuleResult, type SDKDetectionRequest, type SDKDetectionResponse, type ScoreResult, type Signals, type SignedAgentDirectory, type SiteHoneytoken, type SiteHoneytokenOptions, type StoredChallenge, type TLSInfo, type TemporalSignals, type TextareaKeyboardStats, TokenManager, type TokenManagerOptions, type TokenStore, type TokenVerification, type TripwireConfig, TripwireRule, type Verdict, type VerifyInput, type VerifyResult, type ViolationEvent, type WebBotAuthConfig, WebBotAuthRule, WebDecoy, type WebDecoyConfig, bots, calculateCategoryScores, calculateFinalScore, classifyUserAgent, createAgentVerifier, createCaptchaEndpoints, filter, honeytoken, injectHoneytokenLink, isDatacenterIP, isInjectableHtml, isMobileUA, matchUserAgent, parseUserAgent, rateLimit, readEdgeVerdict, recommend, resolveSecret, siteHoneytoken, tripwire, webBotAuth };
|