@webdecoy/node 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +39 -2
- package/dist/index.d.ts +39 -2
- package/dist/index.js +67 -0
- package/dist/index.mjs +64 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -232,7 +232,7 @@ declare function readEdgeVerdict(headers: Record<string, string> | undefined): E
|
|
|
232
232
|
* agents share User-Agent substrings, so sorting this array changes how real
|
|
233
233
|
* traffic is classified.
|
|
234
234
|
*
|
|
235
|
-
*
|
|
235
|
+
* 169 agents across 15 categories.
|
|
236
236
|
*/
|
|
237
237
|
/**
|
|
238
238
|
* Classification categories, mirroring `agents.Category` in Go.
|
|
@@ -855,6 +855,18 @@ declare class WebDecoy {
|
|
|
855
855
|
*/
|
|
856
856
|
protect(metadata: RequestMetadata, options?: ProtectOptions): Promise<ProtectResult>;
|
|
857
857
|
private decide;
|
|
858
|
+
/**
|
|
859
|
+
* Report a test-trigger request and return a blocking verdict.
|
|
860
|
+
*
|
|
861
|
+
* The verdict is `allowed: false` so an enforce-mode adapter answers the
|
|
862
|
+
* curl with a 403 — a visibly different response that tells the developer
|
|
863
|
+
* their middleware acted, Arcjet-quickstart style. (The default monitor
|
|
864
|
+
* mode still serves the request; the dashboard row is the real receipt.)
|
|
865
|
+
*
|
|
866
|
+
* Without an API key nothing can reach the dashboard, so the verdict says
|
|
867
|
+
* so via `error` instead of pretending the test ran.
|
|
868
|
+
*/
|
|
869
|
+
private reportTestTrigger;
|
|
858
870
|
/**
|
|
859
871
|
* Validate the API key configuration
|
|
860
872
|
* Useful for testing integration during setup
|
|
@@ -886,6 +898,31 @@ declare class WebDecoy {
|
|
|
886
898
|
destroy(): Promise<void>;
|
|
887
899
|
}
|
|
888
900
|
|
|
901
|
+
/**
|
|
902
|
+
* The reserved test trigger.
|
|
903
|
+
*
|
|
904
|
+
* A request whose User-Agent starts with `WebDecoy-Test/` is the documented
|
|
905
|
+
* install-verification probe:
|
|
906
|
+
*
|
|
907
|
+
* curl -A "WebDecoy-Test/1.0" http://localhost:3000/
|
|
908
|
+
*
|
|
909
|
+
* The SDK always reports it to ingest — before rules, before local-analysis
|
|
910
|
+
* thresholds, before sampling of any kind — so the developer who just
|
|
911
|
+
* installed the middleware gets a guaranteed, labeled detection in the
|
|
912
|
+
* dashboard within seconds, including from localhost. Ingest recognizes the
|
|
913
|
+
* same prefix server-side, marks the row `is_test`, and keeps it out of
|
|
914
|
+
* stats, billing, actor scoring, and enforcement.
|
|
915
|
+
*
|
|
916
|
+
* Prefix-anchored on purpose: a UA that merely mentions the string mid-way
|
|
917
|
+
* is NOT the trigger, so real traffic can't hide behind the test label.
|
|
918
|
+
*/
|
|
919
|
+
/** Any User-Agent starting with this (case-insensitive) is a test trigger. */
|
|
920
|
+
declare const TEST_TRIGGER_UA_PREFIX = "WebDecoy-Test/";
|
|
921
|
+
/** The exact value the quickstart docs tell developers to send. */
|
|
922
|
+
declare const TEST_TRIGGER_USER_AGENT = "WebDecoy-Test/1.0";
|
|
923
|
+
/** Whether this User-Agent is the reserved test trigger. */
|
|
924
|
+
declare function isTestTriggerUserAgent(userAgent: string | undefined): boolean;
|
|
925
|
+
|
|
889
926
|
/**
|
|
890
927
|
* Rule Engine
|
|
891
928
|
* Evaluates rules in order — first DENY/THROTTLE wins
|
|
@@ -2095,4 +2132,4 @@ declare function createCaptchaEndpoints(options?: CaptchaEndpointsOptions): {
|
|
|
2095
2132
|
};
|
|
2096
2133
|
type CaptchaEndpoints = ReturnType<typeof createCaptchaEndpoints>;
|
|
2097
2134
|
|
|
2098
|
-
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 };
|
|
2135
|
+
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, TEST_TRIGGER_UA_PREFIX, TEST_TRIGGER_USER_AGENT, 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, isTestTriggerUserAgent, matchUserAgent, parseUserAgent, rateLimit, readEdgeVerdict, recommend, resolveSecret, siteHoneytoken, tripwire, webBotAuth };
|
package/dist/index.d.ts
CHANGED
|
@@ -232,7 +232,7 @@ declare function readEdgeVerdict(headers: Record<string, string> | undefined): E
|
|
|
232
232
|
* agents share User-Agent substrings, so sorting this array changes how real
|
|
233
233
|
* traffic is classified.
|
|
234
234
|
*
|
|
235
|
-
*
|
|
235
|
+
* 169 agents across 15 categories.
|
|
236
236
|
*/
|
|
237
237
|
/**
|
|
238
238
|
* Classification categories, mirroring `agents.Category` in Go.
|
|
@@ -855,6 +855,18 @@ declare class WebDecoy {
|
|
|
855
855
|
*/
|
|
856
856
|
protect(metadata: RequestMetadata, options?: ProtectOptions): Promise<ProtectResult>;
|
|
857
857
|
private decide;
|
|
858
|
+
/**
|
|
859
|
+
* Report a test-trigger request and return a blocking verdict.
|
|
860
|
+
*
|
|
861
|
+
* The verdict is `allowed: false` so an enforce-mode adapter answers the
|
|
862
|
+
* curl with a 403 — a visibly different response that tells the developer
|
|
863
|
+
* their middleware acted, Arcjet-quickstart style. (The default monitor
|
|
864
|
+
* mode still serves the request; the dashboard row is the real receipt.)
|
|
865
|
+
*
|
|
866
|
+
* Without an API key nothing can reach the dashboard, so the verdict says
|
|
867
|
+
* so via `error` instead of pretending the test ran.
|
|
868
|
+
*/
|
|
869
|
+
private reportTestTrigger;
|
|
858
870
|
/**
|
|
859
871
|
* Validate the API key configuration
|
|
860
872
|
* Useful for testing integration during setup
|
|
@@ -886,6 +898,31 @@ declare class WebDecoy {
|
|
|
886
898
|
destroy(): Promise<void>;
|
|
887
899
|
}
|
|
888
900
|
|
|
901
|
+
/**
|
|
902
|
+
* The reserved test trigger.
|
|
903
|
+
*
|
|
904
|
+
* A request whose User-Agent starts with `WebDecoy-Test/` is the documented
|
|
905
|
+
* install-verification probe:
|
|
906
|
+
*
|
|
907
|
+
* curl -A "WebDecoy-Test/1.0" http://localhost:3000/
|
|
908
|
+
*
|
|
909
|
+
* The SDK always reports it to ingest — before rules, before local-analysis
|
|
910
|
+
* thresholds, before sampling of any kind — so the developer who just
|
|
911
|
+
* installed the middleware gets a guaranteed, labeled detection in the
|
|
912
|
+
* dashboard within seconds, including from localhost. Ingest recognizes the
|
|
913
|
+
* same prefix server-side, marks the row `is_test`, and keeps it out of
|
|
914
|
+
* stats, billing, actor scoring, and enforcement.
|
|
915
|
+
*
|
|
916
|
+
* Prefix-anchored on purpose: a UA that merely mentions the string mid-way
|
|
917
|
+
* is NOT the trigger, so real traffic can't hide behind the test label.
|
|
918
|
+
*/
|
|
919
|
+
/** Any User-Agent starting with this (case-insensitive) is a test trigger. */
|
|
920
|
+
declare const TEST_TRIGGER_UA_PREFIX = "WebDecoy-Test/";
|
|
921
|
+
/** The exact value the quickstart docs tell developers to send. */
|
|
922
|
+
declare const TEST_TRIGGER_USER_AGENT = "WebDecoy-Test/1.0";
|
|
923
|
+
/** Whether this User-Agent is the reserved test trigger. */
|
|
924
|
+
declare function isTestTriggerUserAgent(userAgent: string | undefined): boolean;
|
|
925
|
+
|
|
889
926
|
/**
|
|
890
927
|
* Rule Engine
|
|
891
928
|
* Evaluates rules in order — first DENY/THROTTLE wins
|
|
@@ -2095,4 +2132,4 @@ declare function createCaptchaEndpoints(options?: CaptchaEndpointsOptions): {
|
|
|
2095
2132
|
};
|
|
2096
2133
|
type CaptchaEndpoints = ReturnType<typeof createCaptchaEndpoints>;
|
|
2097
2134
|
|
|
2098
|
-
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 };
|
|
2135
|
+
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, TEST_TRIGGER_UA_PREFIX, TEST_TRIGGER_USER_AGENT, 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, isTestTriggerUserAgent, matchUserAgent, parseUserAgent, rateLimit, readEdgeVerdict, recommend, resolveSecret, siteHoneytoken, tripwire, webBotAuth };
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,8 @@ __export(index_exports, {
|
|
|
41
41
|
PoWManager: () => PoWManager,
|
|
42
42
|
RateLimitRule: () => RateLimitRule,
|
|
43
43
|
RuleEngine: () => RuleEngine,
|
|
44
|
+
TEST_TRIGGER_UA_PREFIX: () => TEST_TRIGGER_UA_PREFIX,
|
|
45
|
+
TEST_TRIGGER_USER_AGENT: () => TEST_TRIGGER_USER_AGENT,
|
|
44
46
|
TokenManager: () => TokenManager,
|
|
45
47
|
TripwireRule: () => TripwireRule,
|
|
46
48
|
WebBotAuthRule: () => WebBotAuthRule,
|
|
@@ -57,6 +59,7 @@ __export(index_exports, {
|
|
|
57
59
|
isDatacenterIP: () => isDatacenterIP2,
|
|
58
60
|
isInjectableHtml: () => isInjectableHtml,
|
|
59
61
|
isMobileUA: () => isMobileUA,
|
|
62
|
+
isTestTriggerUserAgent: () => isTestTriggerUserAgent,
|
|
60
63
|
matchUserAgent: () => matchUserAgent,
|
|
61
64
|
parseUserAgent: () => parseUserAgent,
|
|
62
65
|
rateLimit: () => rateLimit,
|
|
@@ -2229,6 +2232,7 @@ var BOT_REGISTRY = [
|
|
|
2229
2232
|
{ id: "libwww-perl", name: "libwww-perl", category: "fetcher", organization: "Perl", baseScore: 50, respectsRobots: false, uaPatterns: ["libwww-perl"] },
|
|
2230
2233
|
{ id: "lwp", name: "LWP", category: "fetcher", organization: "Perl", baseScore: 50, respectsRobots: false, uaPatterns: ["lwp-"] },
|
|
2231
2234
|
{ id: "httrack", name: "HTTrack", category: "fetcher", organization: "Open Source", baseScore: 60, respectsRobots: true, uaPatterns: ["httrack"] },
|
|
2235
|
+
{ id: "webdecoybot", name: "WebDecoyBot", category: "monitoring", organization: "WebDecoy", baseScore: 5, respectsRobots: true, uaPatterns: ["webdecoybot"] },
|
|
2232
2236
|
{ id: "uptimerobot", name: "UptimeRobot", category: "monitoring", organization: "UptimeRobot", baseScore: 20, respectsRobots: true, uaPatterns: ["uptimerobot"] },
|
|
2233
2237
|
{ id: "pingdom", name: "Pingdom", category: "monitoring", organization: "SolarWinds", baseScore: 20, respectsRobots: true, uaPatterns: ["pingdom"] },
|
|
2234
2238
|
{ id: "statuscake", name: "StatusCake", category: "monitoring", organization: "StatusCake", baseScore: 20, respectsRobots: true, uaPatterns: ["statuscake"] },
|
|
@@ -2312,6 +2316,14 @@ function classifyUserAgent(userAgent) {
|
|
|
2312
2316
|
};
|
|
2313
2317
|
}
|
|
2314
2318
|
|
|
2319
|
+
// src/test-trigger.ts
|
|
2320
|
+
var TEST_TRIGGER_UA_PREFIX = "WebDecoy-Test/";
|
|
2321
|
+
var TEST_TRIGGER_USER_AGENT = "WebDecoy-Test/1.0";
|
|
2322
|
+
function isTestTriggerUserAgent(userAgent) {
|
|
2323
|
+
if (!userAgent) return false;
|
|
2324
|
+
return userAgent.trimStart().toLowerCase().startsWith(TEST_TRIGGER_UA_PREFIX.toLowerCase());
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2315
2327
|
// src/sdk.ts
|
|
2316
2328
|
var WebDecoy = class {
|
|
2317
2329
|
constructor(config) {
|
|
@@ -2535,6 +2547,9 @@ var WebDecoy = class {
|
|
|
2535
2547
|
if (!metadata.timestamp) {
|
|
2536
2548
|
metadata.timestamp = Date.now();
|
|
2537
2549
|
}
|
|
2550
|
+
if (isTestTriggerUserAgent(metadata.user_agent)) {
|
|
2551
|
+
return this.reportTestTrigger(metadata);
|
|
2552
|
+
}
|
|
2538
2553
|
let ruleResult;
|
|
2539
2554
|
let agentVerdict;
|
|
2540
2555
|
if (this.ruleEngine && (this._hasFilterRules || this._hasAgentRules)) {
|
|
@@ -2655,6 +2670,55 @@ var WebDecoy = class {
|
|
|
2655
2670
|
};
|
|
2656
2671
|
}
|
|
2657
2672
|
}
|
|
2673
|
+
/**
|
|
2674
|
+
* Report a test-trigger request and return a blocking verdict.
|
|
2675
|
+
*
|
|
2676
|
+
* The verdict is `allowed: false` so an enforce-mode adapter answers the
|
|
2677
|
+
* curl with a 403 — a visibly different response that tells the developer
|
|
2678
|
+
* their middleware acted, Arcjet-quickstart style. (The default monitor
|
|
2679
|
+
* mode still serves the request; the dashboard row is the real receipt.)
|
|
2680
|
+
*
|
|
2681
|
+
* Without an API key nothing can reach the dashboard, so the verdict says
|
|
2682
|
+
* so via `error` instead of pretending the test ran.
|
|
2683
|
+
*/
|
|
2684
|
+
async reportTestTrigger(metadata) {
|
|
2685
|
+
const blocked = {
|
|
2686
|
+
decision: "block",
|
|
2687
|
+
confidence: 100,
|
|
2688
|
+
threat_level: "HIGH",
|
|
2689
|
+
bot_detected: true,
|
|
2690
|
+
bot_type: "test_trigger",
|
|
2691
|
+
detection_id: "test_" + Date.now(),
|
|
2692
|
+
rule_enforced: false
|
|
2693
|
+
};
|
|
2694
|
+
if (!this.client) {
|
|
2695
|
+
return {
|
|
2696
|
+
allowed: false,
|
|
2697
|
+
detection: blocked,
|
|
2698
|
+
error: "Test trigger recognized, but no apiKey is configured \u2014 nothing was reported to the dashboard."
|
|
2699
|
+
};
|
|
2700
|
+
}
|
|
2701
|
+
try {
|
|
2702
|
+
const detection = await this.client.detect({
|
|
2703
|
+
request_metadata: metadata,
|
|
2704
|
+
local_analysis: {
|
|
2705
|
+
suspicious_headers: false,
|
|
2706
|
+
missing_sec_ch_ua: false,
|
|
2707
|
+
datacenter_ip: false,
|
|
2708
|
+
local_score: 100,
|
|
2709
|
+
needs_verification: true,
|
|
2710
|
+
flags: ["test_trigger"]
|
|
2711
|
+
}
|
|
2712
|
+
});
|
|
2713
|
+
return { allowed: false, detection };
|
|
2714
|
+
} catch (error) {
|
|
2715
|
+
return {
|
|
2716
|
+
allowed: false,
|
|
2717
|
+
detection: blocked,
|
|
2718
|
+
error: error instanceof Error ? error.message : "Failed to report test detection"
|
|
2719
|
+
};
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2658
2722
|
/**
|
|
2659
2723
|
* Validate the API key configuration
|
|
2660
2724
|
* Useful for testing integration during setup
|
|
@@ -4701,6 +4765,8 @@ function createCaptchaEndpoints(options = {}) {
|
|
|
4701
4765
|
PoWManager,
|
|
4702
4766
|
RateLimitRule,
|
|
4703
4767
|
RuleEngine,
|
|
4768
|
+
TEST_TRIGGER_UA_PREFIX,
|
|
4769
|
+
TEST_TRIGGER_USER_AGENT,
|
|
4704
4770
|
TokenManager,
|
|
4705
4771
|
TripwireRule,
|
|
4706
4772
|
WebBotAuthRule,
|
|
@@ -4717,6 +4783,7 @@ function createCaptchaEndpoints(options = {}) {
|
|
|
4717
4783
|
isDatacenterIP,
|
|
4718
4784
|
isInjectableHtml,
|
|
4719
4785
|
isMobileUA,
|
|
4786
|
+
isTestTriggerUserAgent,
|
|
4720
4787
|
matchUserAgent,
|
|
4721
4788
|
parseUserAgent,
|
|
4722
4789
|
rateLimit,
|
package/dist/index.mjs
CHANGED
|
@@ -2158,6 +2158,7 @@ var BOT_REGISTRY = [
|
|
|
2158
2158
|
{ id: "libwww-perl", name: "libwww-perl", category: "fetcher", organization: "Perl", baseScore: 50, respectsRobots: false, uaPatterns: ["libwww-perl"] },
|
|
2159
2159
|
{ id: "lwp", name: "LWP", category: "fetcher", organization: "Perl", baseScore: 50, respectsRobots: false, uaPatterns: ["lwp-"] },
|
|
2160
2160
|
{ id: "httrack", name: "HTTrack", category: "fetcher", organization: "Open Source", baseScore: 60, respectsRobots: true, uaPatterns: ["httrack"] },
|
|
2161
|
+
{ id: "webdecoybot", name: "WebDecoyBot", category: "monitoring", organization: "WebDecoy", baseScore: 5, respectsRobots: true, uaPatterns: ["webdecoybot"] },
|
|
2161
2162
|
{ id: "uptimerobot", name: "UptimeRobot", category: "monitoring", organization: "UptimeRobot", baseScore: 20, respectsRobots: true, uaPatterns: ["uptimerobot"] },
|
|
2162
2163
|
{ id: "pingdom", name: "Pingdom", category: "monitoring", organization: "SolarWinds", baseScore: 20, respectsRobots: true, uaPatterns: ["pingdom"] },
|
|
2163
2164
|
{ id: "statuscake", name: "StatusCake", category: "monitoring", organization: "StatusCake", baseScore: 20, respectsRobots: true, uaPatterns: ["statuscake"] },
|
|
@@ -2241,6 +2242,14 @@ function classifyUserAgent(userAgent) {
|
|
|
2241
2242
|
};
|
|
2242
2243
|
}
|
|
2243
2244
|
|
|
2245
|
+
// src/test-trigger.ts
|
|
2246
|
+
var TEST_TRIGGER_UA_PREFIX = "WebDecoy-Test/";
|
|
2247
|
+
var TEST_TRIGGER_USER_AGENT = "WebDecoy-Test/1.0";
|
|
2248
|
+
function isTestTriggerUserAgent(userAgent) {
|
|
2249
|
+
if (!userAgent) return false;
|
|
2250
|
+
return userAgent.trimStart().toLowerCase().startsWith(TEST_TRIGGER_UA_PREFIX.toLowerCase());
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2244
2253
|
// src/sdk.ts
|
|
2245
2254
|
var WebDecoy = class {
|
|
2246
2255
|
constructor(config) {
|
|
@@ -2464,6 +2473,9 @@ var WebDecoy = class {
|
|
|
2464
2473
|
if (!metadata.timestamp) {
|
|
2465
2474
|
metadata.timestamp = Date.now();
|
|
2466
2475
|
}
|
|
2476
|
+
if (isTestTriggerUserAgent(metadata.user_agent)) {
|
|
2477
|
+
return this.reportTestTrigger(metadata);
|
|
2478
|
+
}
|
|
2467
2479
|
let ruleResult;
|
|
2468
2480
|
let agentVerdict;
|
|
2469
2481
|
if (this.ruleEngine && (this._hasFilterRules || this._hasAgentRules)) {
|
|
@@ -2584,6 +2596,55 @@ var WebDecoy = class {
|
|
|
2584
2596
|
};
|
|
2585
2597
|
}
|
|
2586
2598
|
}
|
|
2599
|
+
/**
|
|
2600
|
+
* Report a test-trigger request and return a blocking verdict.
|
|
2601
|
+
*
|
|
2602
|
+
* The verdict is `allowed: false` so an enforce-mode adapter answers the
|
|
2603
|
+
* curl with a 403 — a visibly different response that tells the developer
|
|
2604
|
+
* their middleware acted, Arcjet-quickstart style. (The default monitor
|
|
2605
|
+
* mode still serves the request; the dashboard row is the real receipt.)
|
|
2606
|
+
*
|
|
2607
|
+
* Without an API key nothing can reach the dashboard, so the verdict says
|
|
2608
|
+
* so via `error` instead of pretending the test ran.
|
|
2609
|
+
*/
|
|
2610
|
+
async reportTestTrigger(metadata) {
|
|
2611
|
+
const blocked = {
|
|
2612
|
+
decision: "block",
|
|
2613
|
+
confidence: 100,
|
|
2614
|
+
threat_level: "HIGH",
|
|
2615
|
+
bot_detected: true,
|
|
2616
|
+
bot_type: "test_trigger",
|
|
2617
|
+
detection_id: "test_" + Date.now(),
|
|
2618
|
+
rule_enforced: false
|
|
2619
|
+
};
|
|
2620
|
+
if (!this.client) {
|
|
2621
|
+
return {
|
|
2622
|
+
allowed: false,
|
|
2623
|
+
detection: blocked,
|
|
2624
|
+
error: "Test trigger recognized, but no apiKey is configured \u2014 nothing was reported to the dashboard."
|
|
2625
|
+
};
|
|
2626
|
+
}
|
|
2627
|
+
try {
|
|
2628
|
+
const detection = await this.client.detect({
|
|
2629
|
+
request_metadata: metadata,
|
|
2630
|
+
local_analysis: {
|
|
2631
|
+
suspicious_headers: false,
|
|
2632
|
+
missing_sec_ch_ua: false,
|
|
2633
|
+
datacenter_ip: false,
|
|
2634
|
+
local_score: 100,
|
|
2635
|
+
needs_verification: true,
|
|
2636
|
+
flags: ["test_trigger"]
|
|
2637
|
+
}
|
|
2638
|
+
});
|
|
2639
|
+
return { allowed: false, detection };
|
|
2640
|
+
} catch (error) {
|
|
2641
|
+
return {
|
|
2642
|
+
allowed: false,
|
|
2643
|
+
detection: blocked,
|
|
2644
|
+
error: error instanceof Error ? error.message : "Failed to report test detection"
|
|
2645
|
+
};
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2587
2648
|
/**
|
|
2588
2649
|
* Validate the API key configuration
|
|
2589
2650
|
* Useful for testing integration during setup
|
|
@@ -4629,6 +4690,8 @@ export {
|
|
|
4629
4690
|
PoWManager,
|
|
4630
4691
|
RateLimitRule,
|
|
4631
4692
|
RuleEngine,
|
|
4693
|
+
TEST_TRIGGER_UA_PREFIX,
|
|
4694
|
+
TEST_TRIGGER_USER_AGENT,
|
|
4632
4695
|
TokenManager,
|
|
4633
4696
|
TripwireRule,
|
|
4634
4697
|
WebBotAuthRule,
|
|
@@ -4645,6 +4708,7 @@ export {
|
|
|
4645
4708
|
isDatacenterIP2 as isDatacenterIP,
|
|
4646
4709
|
isInjectableHtml,
|
|
4647
4710
|
isMobileUA,
|
|
4711
|
+
isTestTriggerUserAgent,
|
|
4648
4712
|
matchUserAgent,
|
|
4649
4713
|
parseUserAgent,
|
|
4650
4714
|
rateLimit,
|