@webdecoy/node 0.10.0 → 0.11.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 +38 -1
- package/dist/index.d.ts +38 -1
- package/dist/index.js +66 -0
- package/dist/index.mjs +63 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -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
|
@@ -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,
|
|
@@ -2312,6 +2315,14 @@ function classifyUserAgent(userAgent) {
|
|
|
2312
2315
|
};
|
|
2313
2316
|
}
|
|
2314
2317
|
|
|
2318
|
+
// src/test-trigger.ts
|
|
2319
|
+
var TEST_TRIGGER_UA_PREFIX = "WebDecoy-Test/";
|
|
2320
|
+
var TEST_TRIGGER_USER_AGENT = "WebDecoy-Test/1.0";
|
|
2321
|
+
function isTestTriggerUserAgent(userAgent) {
|
|
2322
|
+
if (!userAgent) return false;
|
|
2323
|
+
return userAgent.trimStart().toLowerCase().startsWith(TEST_TRIGGER_UA_PREFIX.toLowerCase());
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2315
2326
|
// src/sdk.ts
|
|
2316
2327
|
var WebDecoy = class {
|
|
2317
2328
|
constructor(config) {
|
|
@@ -2535,6 +2546,9 @@ var WebDecoy = class {
|
|
|
2535
2546
|
if (!metadata.timestamp) {
|
|
2536
2547
|
metadata.timestamp = Date.now();
|
|
2537
2548
|
}
|
|
2549
|
+
if (isTestTriggerUserAgent(metadata.user_agent)) {
|
|
2550
|
+
return this.reportTestTrigger(metadata);
|
|
2551
|
+
}
|
|
2538
2552
|
let ruleResult;
|
|
2539
2553
|
let agentVerdict;
|
|
2540
2554
|
if (this.ruleEngine && (this._hasFilterRules || this._hasAgentRules)) {
|
|
@@ -2655,6 +2669,55 @@ var WebDecoy = class {
|
|
|
2655
2669
|
};
|
|
2656
2670
|
}
|
|
2657
2671
|
}
|
|
2672
|
+
/**
|
|
2673
|
+
* Report a test-trigger request and return a blocking verdict.
|
|
2674
|
+
*
|
|
2675
|
+
* The verdict is `allowed: false` so an enforce-mode adapter answers the
|
|
2676
|
+
* curl with a 403 — a visibly different response that tells the developer
|
|
2677
|
+
* their middleware acted, Arcjet-quickstart style. (The default monitor
|
|
2678
|
+
* mode still serves the request; the dashboard row is the real receipt.)
|
|
2679
|
+
*
|
|
2680
|
+
* Without an API key nothing can reach the dashboard, so the verdict says
|
|
2681
|
+
* so via `error` instead of pretending the test ran.
|
|
2682
|
+
*/
|
|
2683
|
+
async reportTestTrigger(metadata) {
|
|
2684
|
+
const blocked = {
|
|
2685
|
+
decision: "block",
|
|
2686
|
+
confidence: 100,
|
|
2687
|
+
threat_level: "HIGH",
|
|
2688
|
+
bot_detected: true,
|
|
2689
|
+
bot_type: "test_trigger",
|
|
2690
|
+
detection_id: "test_" + Date.now(),
|
|
2691
|
+
rule_enforced: false
|
|
2692
|
+
};
|
|
2693
|
+
if (!this.client) {
|
|
2694
|
+
return {
|
|
2695
|
+
allowed: false,
|
|
2696
|
+
detection: blocked,
|
|
2697
|
+
error: "Test trigger recognized, but no apiKey is configured \u2014 nothing was reported to the dashboard."
|
|
2698
|
+
};
|
|
2699
|
+
}
|
|
2700
|
+
try {
|
|
2701
|
+
const detection = await this.client.detect({
|
|
2702
|
+
request_metadata: metadata,
|
|
2703
|
+
local_analysis: {
|
|
2704
|
+
suspicious_headers: false,
|
|
2705
|
+
missing_sec_ch_ua: false,
|
|
2706
|
+
datacenter_ip: false,
|
|
2707
|
+
local_score: 100,
|
|
2708
|
+
needs_verification: true,
|
|
2709
|
+
flags: ["test_trigger"]
|
|
2710
|
+
}
|
|
2711
|
+
});
|
|
2712
|
+
return { allowed: false, detection };
|
|
2713
|
+
} catch (error) {
|
|
2714
|
+
return {
|
|
2715
|
+
allowed: false,
|
|
2716
|
+
detection: blocked,
|
|
2717
|
+
error: error instanceof Error ? error.message : "Failed to report test detection"
|
|
2718
|
+
};
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2658
2721
|
/**
|
|
2659
2722
|
* Validate the API key configuration
|
|
2660
2723
|
* Useful for testing integration during setup
|
|
@@ -4701,6 +4764,8 @@ function createCaptchaEndpoints(options = {}) {
|
|
|
4701
4764
|
PoWManager,
|
|
4702
4765
|
RateLimitRule,
|
|
4703
4766
|
RuleEngine,
|
|
4767
|
+
TEST_TRIGGER_UA_PREFIX,
|
|
4768
|
+
TEST_TRIGGER_USER_AGENT,
|
|
4704
4769
|
TokenManager,
|
|
4705
4770
|
TripwireRule,
|
|
4706
4771
|
WebBotAuthRule,
|
|
@@ -4717,6 +4782,7 @@ function createCaptchaEndpoints(options = {}) {
|
|
|
4717
4782
|
isDatacenterIP,
|
|
4718
4783
|
isInjectableHtml,
|
|
4719
4784
|
isMobileUA,
|
|
4785
|
+
isTestTriggerUserAgent,
|
|
4720
4786
|
matchUserAgent,
|
|
4721
4787
|
parseUserAgent,
|
|
4722
4788
|
rateLimit,
|
package/dist/index.mjs
CHANGED
|
@@ -2241,6 +2241,14 @@ function classifyUserAgent(userAgent) {
|
|
|
2241
2241
|
};
|
|
2242
2242
|
}
|
|
2243
2243
|
|
|
2244
|
+
// src/test-trigger.ts
|
|
2245
|
+
var TEST_TRIGGER_UA_PREFIX = "WebDecoy-Test/";
|
|
2246
|
+
var TEST_TRIGGER_USER_AGENT = "WebDecoy-Test/1.0";
|
|
2247
|
+
function isTestTriggerUserAgent(userAgent) {
|
|
2248
|
+
if (!userAgent) return false;
|
|
2249
|
+
return userAgent.trimStart().toLowerCase().startsWith(TEST_TRIGGER_UA_PREFIX.toLowerCase());
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2244
2252
|
// src/sdk.ts
|
|
2245
2253
|
var WebDecoy = class {
|
|
2246
2254
|
constructor(config) {
|
|
@@ -2464,6 +2472,9 @@ var WebDecoy = class {
|
|
|
2464
2472
|
if (!metadata.timestamp) {
|
|
2465
2473
|
metadata.timestamp = Date.now();
|
|
2466
2474
|
}
|
|
2475
|
+
if (isTestTriggerUserAgent(metadata.user_agent)) {
|
|
2476
|
+
return this.reportTestTrigger(metadata);
|
|
2477
|
+
}
|
|
2467
2478
|
let ruleResult;
|
|
2468
2479
|
let agentVerdict;
|
|
2469
2480
|
if (this.ruleEngine && (this._hasFilterRules || this._hasAgentRules)) {
|
|
@@ -2584,6 +2595,55 @@ var WebDecoy = class {
|
|
|
2584
2595
|
};
|
|
2585
2596
|
}
|
|
2586
2597
|
}
|
|
2598
|
+
/**
|
|
2599
|
+
* Report a test-trigger request and return a blocking verdict.
|
|
2600
|
+
*
|
|
2601
|
+
* The verdict is `allowed: false` so an enforce-mode adapter answers the
|
|
2602
|
+
* curl with a 403 — a visibly different response that tells the developer
|
|
2603
|
+
* their middleware acted, Arcjet-quickstart style. (The default monitor
|
|
2604
|
+
* mode still serves the request; the dashboard row is the real receipt.)
|
|
2605
|
+
*
|
|
2606
|
+
* Without an API key nothing can reach the dashboard, so the verdict says
|
|
2607
|
+
* so via `error` instead of pretending the test ran.
|
|
2608
|
+
*/
|
|
2609
|
+
async reportTestTrigger(metadata) {
|
|
2610
|
+
const blocked = {
|
|
2611
|
+
decision: "block",
|
|
2612
|
+
confidence: 100,
|
|
2613
|
+
threat_level: "HIGH",
|
|
2614
|
+
bot_detected: true,
|
|
2615
|
+
bot_type: "test_trigger",
|
|
2616
|
+
detection_id: "test_" + Date.now(),
|
|
2617
|
+
rule_enforced: false
|
|
2618
|
+
};
|
|
2619
|
+
if (!this.client) {
|
|
2620
|
+
return {
|
|
2621
|
+
allowed: false,
|
|
2622
|
+
detection: blocked,
|
|
2623
|
+
error: "Test trigger recognized, but no apiKey is configured \u2014 nothing was reported to the dashboard."
|
|
2624
|
+
};
|
|
2625
|
+
}
|
|
2626
|
+
try {
|
|
2627
|
+
const detection = await this.client.detect({
|
|
2628
|
+
request_metadata: metadata,
|
|
2629
|
+
local_analysis: {
|
|
2630
|
+
suspicious_headers: false,
|
|
2631
|
+
missing_sec_ch_ua: false,
|
|
2632
|
+
datacenter_ip: false,
|
|
2633
|
+
local_score: 100,
|
|
2634
|
+
needs_verification: true,
|
|
2635
|
+
flags: ["test_trigger"]
|
|
2636
|
+
}
|
|
2637
|
+
});
|
|
2638
|
+
return { allowed: false, detection };
|
|
2639
|
+
} catch (error) {
|
|
2640
|
+
return {
|
|
2641
|
+
allowed: false,
|
|
2642
|
+
detection: blocked,
|
|
2643
|
+
error: error instanceof Error ? error.message : "Failed to report test detection"
|
|
2644
|
+
};
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2587
2647
|
/**
|
|
2588
2648
|
* Validate the API key configuration
|
|
2589
2649
|
* Useful for testing integration during setup
|
|
@@ -4629,6 +4689,8 @@ export {
|
|
|
4629
4689
|
PoWManager,
|
|
4630
4690
|
RateLimitRule,
|
|
4631
4691
|
RuleEngine,
|
|
4692
|
+
TEST_TRIGGER_UA_PREFIX,
|
|
4693
|
+
TEST_TRIGGER_USER_AGENT,
|
|
4632
4694
|
TokenManager,
|
|
4633
4695
|
TripwireRule,
|
|
4634
4696
|
WebBotAuthRule,
|
|
@@ -4645,6 +4707,7 @@ export {
|
|
|
4645
4707
|
isDatacenterIP2 as isDatacenterIP,
|
|
4646
4708
|
isInjectableHtml,
|
|
4647
4709
|
isMobileUA,
|
|
4710
|
+
isTestTriggerUserAgent,
|
|
4648
4711
|
matchUserAgent,
|
|
4649
4712
|
parseUserAgent,
|
|
4650
4713
|
rateLimit,
|