@webdecoy/node 0.30.0 → 0.32.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 CHANGED
@@ -200,6 +200,8 @@ Local rules decide the request before the SDK reports their events. With an API
200
200
 
201
201
  For a long-lived SDK instance, call `getViolationDeliveryStats()` for counts of events acknowledged by ingest, failed batches, discarded events, and events waiting for an attempt. Call `await sdk.destroy()` during graceful shutdown to finish an in-flight send and attempt the remaining queue. Reporting has a fixed in-memory buffer. When the client pauses after a failure, unattempted events stay buffered. An attempted batch with an uncertain acknowledgment is discarded to avoid replaying its server-side effects.
202
202
 
203
+ Each event carries a unique `eventId`. Ingest stores an event once per id, so a batch that reaches it twice, for example through a proxy retry, adds no second violation and no second detection, and the repeat is still acknowledged. If the process exits without `destroy()`, the reporter keeps it open for at most one flush interval plus the request timeout to attempt the events it holds. It never keeps the process open while the client is paused after a failure. The Fastify plugin sends its remaining events when `fastify.close()` runs, and the Hono middleware hands each send to `executionCtx.waitUntil` on runtimes that provide one, such as Cloudflare Workers.
204
+
203
205
  ## Fetch runtimes (Bun, Deno, Workers, Astro, SvelteKit, Remix)
204
206
 
205
207
  `createFetchGuard()` wraps the SDK for any runtime that hands you a WHATWG `Request`. It is the same implementation `@webdecoy/hono` uses.
@@ -53,6 +53,8 @@ var BOT_REGISTRY = [
53
53
  { id: "kimibot", name: "KimiBot", category: "training_crawler", organization: "Moonshot AI", baseScore: 80, respectsRobots: true, uaPatterns: ["kimibot"] },
54
54
  { id: "moonshotbot", name: "MoonshotBot", category: "training_crawler", organization: "Moonshot AI", baseScore: 80, respectsRobots: false, uaPatterns: ["moonshotbot"] },
55
55
  { id: "chatglm-spider", name: "ChatGLM-Spider", category: "training_crawler", organization: "Zhipu AI", baseScore: 80, respectsRobots: false, uaPatterns: ["chatglm-spider"] },
56
+ { id: "generalretrievalbot", name: "GeneralRetrievalBot", category: "ai_search_crawler", organization: "General Retrieval", baseScore: 60, respectsRobots: true, uaPatterns: ["generalretrievalbot"] },
57
+ { id: "andi-searchbot", name: "Andi-SearchBot", category: "ai_search_crawler", organization: "Andi", baseScore: 55, respectsRobots: true, uaPatterns: ["andi-searchbot"] },
56
58
  { id: "talarionsearchbot", name: "TalarionSearchBot", category: "ai_search_crawler", organization: "Talarion", baseScore: 65, respectsRobots: false, uaPatterns: ["talarionsearchbot"] },
57
59
  { id: "unfragilebot", name: "UnfragileBot", category: "ai_search_crawler", organization: "Unfragile", baseScore: 65, respectsRobots: true, uaPatterns: ["unfragilebot"] },
58
60
  { id: "aranet-searchbot", name: "Aranet-SearchBot", category: "ai_search_crawler", organization: "Aranet", baseScore: 65, respectsRobots: false, uaPatterns: ["aranet-searchbot"] },
@@ -88,6 +90,9 @@ var BOT_REGISTRY = [
88
90
  { id: "manus-user", name: "Manus-User", category: "ai_agent", organization: "Manus", baseScore: 70, respectsRobots: false, uaPatterns: ["manus-user"] },
89
91
  { id: "multion", name: "MultiOn", category: "ai_agent", organization: "MultiOn", baseScore: 70, respectsRobots: false, uaPatterns: ["multion"] },
90
92
  { id: "opencode-user", name: "OpenCode-User", category: "ai_agent", organization: "OpenCode", baseScore: 75, respectsRobots: false, uaPatterns: ["opencode-user"] },
93
+ { id: "jambot", name: "Jambot", category: "search_crawler", organization: "Jambot", baseScore: 40, respectsRobots: true, uaPatterns: ["jambot"] },
94
+ { id: "fyndbot", name: "fyndbot", category: "search_crawler", organization: "Fynd", baseScore: 40, respectsRobots: true, uaPatterns: ["fyndbot"] },
95
+ { id: "pexelsbot", name: "PexelsBot", category: "search_crawler", organization: "pexels.de", baseScore: 40, respectsRobots: true, uaPatterns: ["pexelsbot"] },
91
96
  { id: "360spider", name: "360Spider", category: "search_crawler", organization: "Qihoo 360", baseScore: 40, respectsRobots: true, uaPatterns: ["360spider"] },
92
97
  { id: "cgmsearchbot", name: "CGMSearchBot", category: "search_crawler", organization: "CGMIMM", baseScore: 40, respectsRobots: true, uaPatterns: ["cgmsearchbot"] },
93
98
  { id: "iboubot", name: "IbouBot", category: "search_crawler", organization: "Ibou", baseScore: 30, respectsRobots: true, uaPatterns: ["iboubot", "ibou-search"] },
@@ -111,6 +116,10 @@ var BOT_REGISTRY = [
111
116
  { id: "coccocbot", name: "Coc Coc", category: "search_crawler", organization: "Coc Coc", baseScore: 35, respectsRobots: true, uaPatterns: ["coccocbot"] },
112
117
  { id: "yisouspider", name: "YisouSpider", category: "search_crawler", organization: "Alibaba", baseScore: 40, respectsRobots: true, uaPatterns: ["yisouspider"] },
113
118
  { id: "yepbot", name: "YepBot", category: "search_crawler", organization: "Ahrefs", baseScore: 30, respectsRobots: true, uaPatterns: ["yepbot"] },
119
+ { id: "agentreadyscan", name: "AgentReadyScan", category: "seo_crawler", organization: "Agent Ready", baseScore: 45, respectsRobots: true, uaPatterns: ["agentreadyscan"] },
120
+ { id: "crawlcheck", name: "CrawlCheck", category: "seo_crawler", organization: "CrawlCheck", baseScore: 45, respectsRobots: true, uaPatterns: ["crawlcheck/"] },
121
+ { id: "kostobot", name: "KostoBot", category: "seo_crawler", organization: "Kosto", baseScore: 50, respectsRobots: true, uaPatterns: ["kostobot"] },
122
+ { id: "keys-so-bot", name: "keys.so", category: "seo_crawler", organization: "Keys.so", baseScore: 50, respectsRobots: false, uaPatterns: ["keys-so-bot"] },
114
123
  { id: "crolbot", name: "CrolBot", category: "seo_crawler", organization: "cloro", baseScore: 50, respectsRobots: false, uaPatterns: ["crolbot"] },
115
124
  { id: "ahrefsbot", name: "AhrefsBot", category: "seo_crawler", organization: "Ahrefs", baseScore: 50, respectsRobots: true, uaPatterns: ["ahrefsbot", "ahrefs"] },
116
125
  { id: "semrushbot", name: "SemrushBot", category: "seo_crawler", organization: "Semrush", baseScore: 50, respectsRobots: true, uaPatterns: ["semrushbot", "semrush"] },
@@ -136,6 +145,10 @@ var BOT_REGISTRY = [
136
145
  { id: "seojuice-searchbot", name: "SEOJuice-SearchBot", category: "seo_crawler", organization: "SEOJuice", baseScore: 50, respectsRobots: true, uaPatterns: ["seojuice-searchbot"] },
137
146
  { id: "trendictionbot", name: "trendictionbot", category: "seo_crawler", organization: "Talkwalker", baseScore: 50, respectsRobots: true, uaPatterns: ["trendictionbot"] },
138
147
  { id: "hubspot-crawler", name: "HubSpot Crawler", category: "seo_crawler", organization: "HubSpot", baseScore: 45, respectsRobots: true, uaPatterns: ["hubspot crawler"] },
148
+ { id: "bitsightbot", name: "BitSightBot", category: "security_scanner", organization: "BitSight", baseScore: 70, respectsRobots: false, uaPatterns: ["bitsightbot"] },
149
+ { id: "leakix", name: "LeakIX", category: "security_scanner", organization: "LeakIX", baseScore: 75, respectsRobots: false, uaPatterns: ["l9scan"] },
150
+ { id: "modatscanner", name: "ModatScanner", category: "security_scanner", organization: "Modat", baseScore: 75, respectsRobots: false, uaPatterns: ["modatscanner"] },
151
+ { id: "umaibot", name: "UmaiBot", category: "security_scanner", organization: "UMAI", baseScore: 60, respectsRobots: true, uaPatterns: ["umaibot"] },
139
152
  { id: "artex", name: "ARTEX", category: "security_scanner", organization: "Open Source", baseScore: 90, respectsRobots: false, uaPatterns: ["artex-enrich/"] },
140
153
  { id: "nessus", name: "Nessus", category: "security_scanner", organization: "Tenable", baseScore: 70, respectsRobots: false, uaPatterns: ["nessus"] },
141
154
  { id: "qualys", name: "Qualys", category: "security_scanner", organization: "Qualys", baseScore: 70, respectsRobots: false, uaPatterns: ["qualys"] },
@@ -190,6 +203,8 @@ var BOT_REGISTRY = [
190
203
  { id: "wayback", name: "Wayback Machine", category: "archiver", organization: "Internet Archive", baseScore: 25, respectsRobots: true, uaPatterns: ["wayback"] },
191
204
  { id: "heritrix", name: "Heritrix", category: "archiver", organization: "Internet Archive", baseScore: 30, respectsRobots: true, uaPatterns: ["heritrix"] },
192
205
  { id: "brozzler", name: "Brozzler", category: "archiver", organization: "Internet Archive", baseScore: 30, respectsRobots: true, uaPatterns: ["brozzler"] },
206
+ { id: "findfiles-linkchecker", name: "FindFiles.net LinkChecker", category: "fetcher", organization: "FindFiles.net", baseScore: 30, respectsRobots: true, uaPatterns: ["findfiles.net-linkchecker"] },
207
+ { id: "hstspreload-bot", name: "hstspreload-bot", category: "fetcher", organization: "Chromium", baseScore: 20, respectsRobots: false, uaPatterns: ["hstspreload-bot"] },
193
208
  { id: "facebookexternalhit", name: "Facebook", category: "fetcher", organization: "Meta", baseScore: 25, respectsRobots: true, uaPatterns: ["facebookexternalhit"] },
194
209
  { id: "facebot", name: "Facebot", category: "fetcher", organization: "Meta", baseScore: 25, respectsRobots: true, uaPatterns: ["facebot"] },
195
210
  { id: "twitterbot", name: "Twitterbot", category: "fetcher", organization: "X Corp", baseScore: 25, respectsRobots: true, uaPatterns: ["twitterbot"] },
@@ -214,6 +229,7 @@ var BOT_REGISTRY = [
214
229
  { id: "libwww-perl", name: "libwww-perl", category: "fetcher", organization: "Perl", baseScore: 50, respectsRobots: false, uaPatterns: ["libwww-perl"] },
215
230
  { id: "lwp", name: "LWP", category: "fetcher", organization: "Perl", baseScore: 50, respectsRobots: false, uaPatterns: ["lwp-"] },
216
231
  { id: "httrack", name: "HTTrack", category: "fetcher", organization: "Open Source", baseScore: 60, respectsRobots: true, uaPatterns: ["httrack"] },
232
+ { id: "truetierbot", name: "TrueTierBot", category: "monitoring", organization: "TrueTier", baseScore: 25, respectsRobots: true, uaPatterns: ["truetierbot"] },
217
233
  { id: "webdecoybot", name: "WebDecoyBot", category: "monitoring", organization: "WebDecoy", baseScore: 5, respectsRobots: true, uaPatterns: ["webdecoybot"] },
218
234
  { id: "uptimerobot", name: "UptimeRobot", category: "monitoring", organization: "UptimeRobot", baseScore: 20, respectsRobots: true, uaPatterns: ["uptimerobot"] },
219
235
  { id: "pingdom", name: "Pingdom", category: "monitoring", organization: "SolarWinds", baseScore: 20, respectsRobots: true, uaPatterns: ["pingdom"] },
@@ -227,6 +243,9 @@ var BOT_REGISTRY = [
227
243
  { id: "nodeping", name: "NodePing", category: "monitoring", organization: "NodePing", baseScore: 20, respectsRobots: true, uaPatterns: ["nodeping"] },
228
244
  { id: "gtmetrix", name: "GTmetrix", category: "monitoring", organization: "GTmetrix", baseScore: 20, respectsRobots: true, uaPatterns: ["gtmetrix"] },
229
245
  { id: "chrome-lighthouse", name: "Lighthouse", category: "monitoring", organization: "Google", baseScore: 20, respectsRobots: true, uaPatterns: ["chrome-lighthouse", "google page speed"] },
246
+ { id: "andifeedbot", name: "AndiFeedBot", category: "feed_reader", organization: "Andi", baseScore: 30, respectsRobots: true, uaPatterns: ["andifeedbot"] },
247
+ { id: "librarianbot", name: "LibrarianBot", category: "feed_reader", organization: "GenioFab", baseScore: 30, respectsRobots: true, uaPatterns: ["librarianbot"] },
248
+ { id: "oursignal", name: "oursignal", category: "feed_reader", organization: "oursignal", baseScore: 25, respectsRobots: true, uaPatterns: ["oursignal/"] },
230
249
  { id: "feedly", name: "Feedly", category: "feed_reader", organization: "Feedly", baseScore: 25, respectsRobots: true, uaPatterns: ["feedly"] },
231
250
  { id: "livelapbot", name: "LivelapBot", category: "feed_reader", organization: "Livelap", baseScore: 30, respectsRobots: true, uaPatterns: ["livelapbot"] },
232
251
  { id: "feedfetcher-google", name: "Feedfetcher-Google", category: "feed_reader", organization: "Google", baseScore: 25, respectsRobots: true, uaPatterns: ["feedfetcher"] },
@@ -237,6 +256,12 @@ var BOT_REGISTRY = [
237
256
  { id: "miniflux", name: "Miniflux", category: "feed_reader", organization: "Open Source", baseScore: 25, respectsRobots: true, uaPatterns: ["miniflux"] },
238
257
  { id: "freshrss", name: "FreshRSS", category: "feed_reader", organization: "Open Source", baseScore: 25, respectsRobots: true, uaPatterns: ["freshrss"] },
239
258
  { id: "commafeed", name: "CommaFeed", category: "feed_reader", organization: "Open Source", baseScore: 25, respectsRobots: true, uaPatterns: ["commafeed"] },
259
+ { id: "tphotobot", name: "tphotobot", category: "commercial_scraper", organization: "Estidraft", baseScore: 50, respectsRobots: true, uaPatterns: ["tphotobot"] },
260
+ { id: "bangobot", name: "BangoBot", category: "commercial_scraper", organization: "Bango API", baseScore: 55, respectsRobots: false, uaPatterns: ["bangobot"] },
261
+ { id: "kamatabot", name: "KamataBot", category: "commercial_scraper", organization: "Kamata", baseScore: 55, respectsRobots: true, uaPatterns: ["kamatabot"] },
262
+ { id: "boehmbot", name: "BoehmBot", category: "commercial_scraper", organization: "b\xF6hm systems", baseScore: 50, respectsRobots: true, uaPatterns: ["boehmbot"] },
263
+ { id: "pipericbot", name: "PipericBot", category: "commercial_scraper", organization: "Piperic", baseScore: 55, respectsRobots: true, uaPatterns: ["pipericbot"] },
264
+ { id: "pandalytics", name: "Pandalytics", category: "commercial_scraper", organization: "Domainsbot", baseScore: 50, respectsRobots: true, uaPatterns: ["pandalytics"] },
240
265
  { id: "spiderling", name: "SpiderLing", category: "commercial_scraper", organization: "Lexical Computing", baseScore: 55, respectsRobots: true, uaPatterns: ["spiderling", "sketchengine"] },
241
266
  { id: "netapi", name: "NetAPI Bot", category: "commercial_scraper", organization: "NetAPI", baseScore: 50, respectsRobots: true, uaPatterns: ["netapi/"] },
242
267
  { id: "anticlonebot", name: "AntiCloneBot", category: "commercial_scraper", organization: "AntiClone", baseScore: 45, respectsRobots: true, uaPatterns: ["anticlonebot"] },
@@ -254,6 +279,7 @@ var BOT_REGISTRY = [
254
279
  { id: "apify", name: "Apify", category: "commercial_scraper", organization: "Apify", baseScore: 65, respectsRobots: true, uaPatterns: ["apify"] },
255
280
  { id: "crawlbase", name: "Crawlbase", category: "commercial_scraper", organization: "Crawlbase", baseScore: 65, respectsRobots: true, uaPatterns: ["crawlbase"] },
256
281
  { id: "webscrapingapi", name: "WebScrapingAPI", category: "commercial_scraper", organization: "WebScrapingAPI", baseScore: 65, respectsRobots: true, uaPatterns: ["webscrapingapi"] },
282
+ { id: "andi-user", name: "Andi-User", category: "ai_assistant", organization: "Andi", baseScore: 60, respectsRobots: false, uaPatterns: ["andi-user"] },
257
283
  { id: "chatgpt-user", name: "ChatGPT-User", category: "ai_assistant", organization: "OpenAI", baseScore: 85, respectsRobots: true, uaPatterns: ["chatgpt-user"] },
258
284
  { id: "perplexity-user", name: "Perplexity-User", category: "ai_assistant", organization: "Perplexity AI", baseScore: 75, respectsRobots: false, uaPatterns: ["perplexity-user"] },
259
285
  { id: "mistralai-user", name: "MistralAI-User", category: "ai_assistant", organization: "Mistral AI", baseScore: 75, respectsRobots: true, uaPatterns: ["mistralai-user"] },
@@ -3198,6 +3224,7 @@ var ViolationReporter = class {
3198
3224
  this.maxBufferSize = config.maxBufferSize ?? 50;
3199
3225
  this.debug = config.debug ?? false;
3200
3226
  const flushInterval = config.flushInterval ?? 5e3;
3227
+ this.flushInterval = flushInterval;
3201
3228
  this.flushTimer = setInterval(() => void this.flush(), flushInterval);
3202
3229
  if (this.flushTimer.unref) {
3203
3230
  this.flushTimer.unref();
@@ -3207,7 +3234,9 @@ var ViolationReporter = class {
3207
3234
  * Add violations to the buffer. Auto-flushes when buffer reaches maxBufferSize.
3208
3235
  */
3209
3236
  report(violations) {
3210
- this.buffer.push(...violations);
3237
+ for (const violation of violations) {
3238
+ this.buffer.push(violation.eventId ? violation : { ...violation, eventId: crypto.randomUUID() });
3239
+ }
3211
3240
  if (this.buffer.length > MAX_BUFFERED_VIOLATIONS) {
3212
3241
  const overflow = this.buffer.length - MAX_BUFFERED_VIOLATIONS;
3213
3242
  this.buffer.splice(0, overflow);
@@ -3216,8 +3245,32 @@ var ViolationReporter = class {
3216
3245
  if (this.buffer.length >= this.maxBufferSize) {
3217
3246
  this.flush().catch(() => {
3218
3247
  });
3248
+ } else {
3249
+ this.scheduleDelivery();
3219
3250
  }
3220
3251
  }
3252
+ /**
3253
+ * Give buffered events one delivery attempt before the process can exit.
3254
+ *
3255
+ * The interval above is unref'd so an idle reporter never holds a process
3256
+ * open. On its own that meant a server shut down gracefully (Express after
3257
+ * server.close(), Fastify after close(), Hono on Node) exited with its last
3258
+ * events unsent and uncounted. This one-shot timer is left ref'd, so a
3259
+ * natural exit waits at most one flush interval plus the request timeout.
3260
+ * It is not re-armed while the client is paused, so an outage cannot keep
3261
+ * the process alive.
3262
+ */
3263
+ cancelDelivery() {
3264
+ clearTimeout(this.deliveryTimer);
3265
+ this.deliveryTimer = void 0;
3266
+ }
3267
+ scheduleDelivery() {
3268
+ if (this.deliveryTimer) return;
3269
+ this.deliveryTimer = setTimeout(() => {
3270
+ this.deliveryTimer = void 0;
3271
+ void this.flush();
3272
+ }, this.flushInterval);
3273
+ }
3221
3274
  /** Flush the buffer, coalescing requests that arrive during an active send. */
3222
3275
  flush() {
3223
3276
  if (this.queuedFlush) return this.queuedFlush;
@@ -3233,6 +3286,7 @@ var ViolationReporter = class {
3233
3286
  const size = this.buffer.length;
3234
3287
  this.flushPromise = Promise.resolve().then(() => this.flushBatches(size)).finally(() => {
3235
3288
  this.flushPromise = void 0;
3289
+ if (this.buffer.length === 0) this.cancelDelivery();
3236
3290
  });
3237
3291
  return this.flushPromise;
3238
3292
  }
@@ -3262,6 +3316,7 @@ var ViolationReporter = class {
3262
3316
  /** Stop the timer and give remaining events one final flush. */
3263
3317
  async destroy() {
3264
3318
  clearInterval(this.flushTimer);
3319
+ this.cancelDelivery();
3265
3320
  if (this.flushPromise) await this.flushPromise;
3266
3321
  await this.flush();
3267
3322
  this.droppedEvents += this.buffer.length;