@webdecoy/node 0.28.0 → 0.30.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 +13 -0
- package/dist/{chunk-P6IWJ7K5.mjs → chunk-VPPTUL5K.mjs} +3 -1
- package/dist/index.d.mts +55 -7
- package/dist/index.d.ts +55 -7
- package/dist/index.js +257 -92
- package/dist/index.mjs +255 -92
- package/dist/vercel.js +3 -1
- package/dist/vercel.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -318,6 +318,10 @@ Mount the endpoints with your adapter (`webdecoyCaptcha` in Express, `webdecoyCa
|
|
|
318
318
|
|
|
319
319
|
When the browser provides usable scroll samples, `/verify` and `/score` return an `observations` entry with the ID `large-scroll-step-v1`. It summarizes the sample count and largest step in CSS pixels for diagnostics.
|
|
320
320
|
|
|
321
|
+
The default `weighted-mean-v1` policy preserves the original SDK behavior. Pass `onScoringComparison` to the server adapter, `Captcha`, or `DetectionEngine` to receive that baseline and the `noisy-or-floors-v1` score and recommendation on the server. Both scores use your configured category weights. The noisy-OR policy applies a decisive score floor to explicit WebDriver declarations and known driver injection signals in enabled categories. It also applies a corroboration floor when measured interaction and known driver findings agree.
|
|
322
|
+
|
|
323
|
+
After validating the comparison in your traffic, pass `scoringPolicy: 'noisy-or-floors-v1'` to enforce it for verification and token issuance. The option is available on `DetectionEngine`, `Captcha`, and every CAPTCHA server adapter; unknown policy names throw instead of silently falling back.
|
|
324
|
+
|
|
321
325
|
```ts
|
|
322
326
|
import express from 'express';
|
|
323
327
|
import { webdecoyCaptcha } from '@webdecoy/express';
|
|
@@ -336,6 +340,15 @@ app.post('/login', async (req, res) => {
|
|
|
336
340
|
});
|
|
337
341
|
```
|
|
338
342
|
|
|
343
|
+
To enforce the noisy-OR policy, replace the adapter registration above with:
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
app.use(webdecoyCaptcha({
|
|
347
|
+
secret: process.env.WEBDECOY_SECRET,
|
|
348
|
+
scoringPolicy: 'noisy-or-floors-v1',
|
|
349
|
+
}));
|
|
350
|
+
```
|
|
351
|
+
|
|
339
352
|
`WEBDECOY_SECRET` is just the variable name used here; pass the value as `secret`. Generate one with `openssl rand -hex 32`. Challenge and token stores are in memory by default; for serverless or multi-instance deployments, pass shared `challengeStore` and `tokenStore` implementations.
|
|
340
353
|
|
|
341
354
|
To score signals yourself, use `new DetectionEngine(options).score(signals, context)`.
|
|
@@ -1470,12 +1470,14 @@ function createFetchGuard(options = {}) {
|
|
|
1470
1470
|
},
|
|
1471
1471
|
async check(request, peer) {
|
|
1472
1472
|
const url = new URL(request.url);
|
|
1473
|
+
const headers = headerRecord(request.headers);
|
|
1474
|
+
if (!headers.host && !headers[":authority"]) headers.host = url.host;
|
|
1473
1475
|
const metadata = {
|
|
1474
1476
|
method: request.method,
|
|
1475
1477
|
path: url.pathname,
|
|
1476
1478
|
ip: resolveIP(request, peer),
|
|
1477
1479
|
user_agent: request.headers.get("user-agent") ?? void 0,
|
|
1478
|
-
headers
|
|
1480
|
+
headers,
|
|
1479
1481
|
query: url.search ? url.search.slice(1) : void 0,
|
|
1480
1482
|
timestamp: Date.now()
|
|
1481
1483
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -64,6 +64,10 @@ interface BehavioralSignals {
|
|
|
64
64
|
touchEvents?: number;
|
|
65
65
|
pointerHasNonMouseType?: boolean;
|
|
66
66
|
keyEvents?: number;
|
|
67
|
+
/** Number of completed key holds in the browser's timing summary. */
|
|
68
|
+
keyHoldSamples?: number;
|
|
69
|
+
/** Average hold duration in milliseconds for those samples. */
|
|
70
|
+
keyHoldAvg?: number;
|
|
67
71
|
/** Count of recent scroll events and largest CSS pixel step between them. */
|
|
68
72
|
scrollMorphology?: {
|
|
69
73
|
samples?: number;
|
|
@@ -115,6 +119,8 @@ interface EnvironmentalSignals {
|
|
|
115
119
|
[key: string]: unknown;
|
|
116
120
|
};
|
|
117
121
|
automationFlags?: {
|
|
122
|
+
/** Explicit browser-declared WebDriver flag from navigator.webdriver. */
|
|
123
|
+
webdriver?: boolean;
|
|
118
124
|
plugins?: number;
|
|
119
125
|
languages?: boolean;
|
|
120
126
|
chrome?: boolean;
|
|
@@ -337,9 +343,9 @@ interface ScrollJumpObservation {
|
|
|
337
343
|
}
|
|
338
344
|
/** Final verdict returned by {@link DetectionEngine.score}. */
|
|
339
345
|
interface Verdict {
|
|
340
|
-
/** True when the
|
|
346
|
+
/** True when the selected policy's score is below the success threshold (< 0.5). */
|
|
341
347
|
success: boolean;
|
|
342
|
-
/**
|
|
348
|
+
/** Selected policy's final score, 0..1. */
|
|
343
349
|
score: number;
|
|
344
350
|
/** Recommended action. */
|
|
345
351
|
recommendation: Recommendation;
|
|
@@ -394,9 +400,27 @@ declare class InMemoryRateLimiter implements RateLimiter {
|
|
|
394
400
|
* supplies a {@link PoWOutcome} and the engine emits the matching detections.
|
|
395
401
|
*/
|
|
396
402
|
|
|
403
|
+
type DetectionScoringPolicy = 'weighted-mean-v1' | 'noisy-or-floors-v1';
|
|
404
|
+
interface ScoringComparison {
|
|
405
|
+
policy: 'noisy-or-floors-v1';
|
|
406
|
+
current: {
|
|
407
|
+
score: number;
|
|
408
|
+
recommendation: Recommendation;
|
|
409
|
+
};
|
|
410
|
+
candidate: {
|
|
411
|
+
score: number;
|
|
412
|
+
recommendation: Recommendation;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
397
415
|
interface DetectionEngineOptions {
|
|
398
416
|
/** Override the per-category weights (defaults to {@link DEFAULT_WEIGHTS}). */
|
|
399
417
|
weights?: Record<string, number>;
|
|
418
|
+
/**
|
|
419
|
+
* Aggregation policy used for the returned verdict and CAPTCHA token decision.
|
|
420
|
+
* Defaults to `weighted-mean-v1`; opt in to `noisy-or-floors-v1` to enforce
|
|
421
|
+
* the FCaptcha-aligned noisy-OR, decisive-floor, and corroboration-floor policy.
|
|
422
|
+
*/
|
|
423
|
+
scoringPolicy?: DetectionScoringPolicy;
|
|
400
424
|
/**
|
|
401
425
|
* When true (default), a request with no PoW outcome emits a hard-fail "No PoW
|
|
402
426
|
* solution provided" detection — matching the reference server. Set false to
|
|
@@ -407,18 +431,22 @@ interface DetectionEngineOptions {
|
|
|
407
431
|
fingerprintStore?: FingerprintStore;
|
|
408
432
|
/** Rate limiter for rate-abuse detection (defaults to in-memory). */
|
|
409
433
|
rateLimiter?: RateLimiter;
|
|
434
|
+
/** Receive a server-side comparison of the two aggregation methods using the same weights. */
|
|
435
|
+
onScoringComparison?: (comparison: ScoringComparison) => void | Promise<void>;
|
|
410
436
|
}
|
|
411
437
|
declare class DetectionEngine {
|
|
412
438
|
private readonly weights;
|
|
439
|
+
private readonly scoringPolicy;
|
|
413
440
|
private readonly requirePoW;
|
|
414
441
|
private readonly fingerprintStore;
|
|
415
442
|
private readonly rateLimiter;
|
|
443
|
+
private readonly onScoringComparison;
|
|
416
444
|
constructor(options?: DetectionEngineOptions);
|
|
417
445
|
/** Score `signals` for the given request context and return a verdict. */
|
|
418
446
|
score(signals: Signals, context: DetectionContext): Verdict;
|
|
419
447
|
}
|
|
420
448
|
|
|
421
|
-
/**
|
|
449
|
+
/** Per-category score aggregation and weighted totals. */
|
|
422
450
|
|
|
423
451
|
/**
|
|
424
452
|
* Aggregate detections into per-category scores. Each category's score is the
|
|
@@ -499,8 +527,14 @@ declare function parseUserAgent(ua: string): UserAgentInfo;
|
|
|
499
527
|
|
|
500
528
|
/** The engine's verdict on one browser session. */
|
|
501
529
|
interface ClientVerdict {
|
|
502
|
-
/**
|
|
530
|
+
/** Identifier used by the store. */
|
|
503
531
|
sessionId: string;
|
|
532
|
+
/** Scope of a receipt issued by the embedded score endpoint. */
|
|
533
|
+
receipt?: {
|
|
534
|
+
host: string;
|
|
535
|
+
siteKey: string;
|
|
536
|
+
expiresAt: number;
|
|
537
|
+
};
|
|
504
538
|
/** 0–1, higher is more bot-like. */
|
|
505
539
|
score: number;
|
|
506
540
|
/** What the engine recommends doing about it. */
|
|
@@ -536,14 +570,16 @@ declare class MemoryClientSignalStore implements ClientSignalStore {
|
|
|
536
570
|
set(verdict: ClientVerdict): void;
|
|
537
571
|
get size(): number;
|
|
538
572
|
}
|
|
539
|
-
/**
|
|
573
|
+
/** Session references supplied by an existing application integration. */
|
|
540
574
|
declare const CLIENT_SESSION_COOKIE = "wd_cs";
|
|
541
575
|
declare const CLIENT_SESSION_HEADER = "x-wd-session";
|
|
542
|
-
/** Read the
|
|
576
|
+
/** Read the server receipt or an application-supplied legacy session id. */
|
|
543
577
|
declare function readClientSession(headers: Record<string, string>): string | undefined;
|
|
544
578
|
interface ClientSignalConfig {
|
|
545
579
|
/** Where verdicts are read from. Must be the store `/score` writes to. */
|
|
546
580
|
store: ClientSignalStore;
|
|
581
|
+
/** Site key expected by this rule when several site keys share a request host. */
|
|
582
|
+
siteKey?: string;
|
|
547
583
|
/**
|
|
548
584
|
* Deny at or above this score, 0–1. The engine's own `recommendation` is used
|
|
549
585
|
* when this is omitted.
|
|
@@ -563,6 +599,7 @@ interface ClientSignalConfig {
|
|
|
563
599
|
declare class ClientSignalRule implements Rule {
|
|
564
600
|
readonly name = "client-signals";
|
|
565
601
|
private readonly store;
|
|
602
|
+
private readonly siteKey?;
|
|
566
603
|
private readonly minScore?;
|
|
567
604
|
private readonly action;
|
|
568
605
|
private readonly dryRun;
|
|
@@ -1633,6 +1670,10 @@ interface CaptchaOptions {
|
|
|
1633
1670
|
secret?: string;
|
|
1634
1671
|
/** Override per-category detection weights. */
|
|
1635
1672
|
weights?: Record<string, number>;
|
|
1673
|
+
/** Aggregation policy used for scoring, verification, and token issuance. */
|
|
1674
|
+
scoringPolicy?: DetectionEngineOptions['scoringPolicy'];
|
|
1675
|
+
/** Receive score and recommendation comparisons on the server without affecting verification. */
|
|
1676
|
+
onScoringComparison?: DetectionEngineOptions['onScoringComparison'];
|
|
1636
1677
|
/**
|
|
1637
1678
|
* Trusted reverse-proxy header names carrying a JA4 fingerprint, matched
|
|
1638
1679
|
* against the lower-cased request header keys (e.g. `['x-ja4']`).
|
|
@@ -1667,6 +1708,13 @@ declare class Captcha {
|
|
|
1667
1708
|
score(input: VerifyInput & {
|
|
1668
1709
|
action?: string;
|
|
1669
1710
|
}): Promise<ScoreResult>;
|
|
1711
|
+
/** @internal Return the score and whether the server verified the committed signals. */
|
|
1712
|
+
scoreForSession(input: VerifyInput & {
|
|
1713
|
+
action?: string;
|
|
1714
|
+
}): Promise<{
|
|
1715
|
+
result: ScoreResult;
|
|
1716
|
+
verifiedSignals: boolean;
|
|
1717
|
+
}>;
|
|
1670
1718
|
/** Verify a previously issued token (single-use, optionally IP-bound). */
|
|
1671
1719
|
verifyToken(token: string, ip?: string | null): Promise<TokenVerification>;
|
|
1672
1720
|
}
|
|
@@ -1733,4 +1781,4 @@ declare function createCaptchaEndpoints(options?: CaptchaEndpointsOptions): {
|
|
|
1733
1781
|
};
|
|
1734
1782
|
type CaptchaEndpoints = ReturnType<typeof createCaptchaEndpoints>;
|
|
1735
1783
|
|
|
1736
|
-
export { ATTACK_SIGNATURE_IDS, AgentCategory, AgentRequestInput, AgentVerdict, AgentVerifier, AgentVerifierOptions, type AttackSignatureConfig, AttackSignatureRule, type BehavioralSignals, type BlockResponse, BotAgent, BotCategory, BotPolicy, type BotPolicyOptions, BotRule, BotRuleConfig, CLIENT_SESSION_COOKIE, CLIENT_SESSION_HEADER, Captcha, type CaptchaEndpoints, type CaptchaEndpointsOptions, type CaptchaHttpResponse, type CaptchaOptions, type CaptchaRequest, type CategoryScores, type ChallengeData, type ChallengeStore, type ClientSignalConfig, ClientSignalRule, type ClientSignalStore, type ClientVerdict, DEFAULT_SIGNED_AGENT_DIRECTORIES, DEFAULT_TRIPWIRE_PATHS, DEFAULT_WEIGHTS, type Detection, type DetectionContext, DetectionEngine, type DetectionEngineOptions, DirectoryCache, type EnvironmentalSignals, FilterConfig, FilterRule, type FingerprintStore, type FormAnalysisSignals, HONEYTOKEN_BASE_PATH, type Honeytoken, type HoneytokenArmingOptions, type HoneytokenLinkProps, type HoneytokenOptions, InMemoryChallengeStore, InMemoryFingerprintStore, InMemoryRateLimiter, InMemoryTokenStore, MemoryClientSignalStore, type MemoryClientSignalStoreOptions, PoWManager, type PoWManagerOptions, type PoWOutcome, type PoWSolution, type PoWVerification, ProtectResult, RateLimitConfig, RateLimitConsume, RateLimitOutcome, RateLimitRule, RateLimitStore, type RateLimiter, type Recommendation, type RobotsTxtOptions, Rule, RuleContext, RuleEngine, RuleEngineResult, RuleResult, type ScoreResult, type ScrollJumpObservation, type Signals, SignedAgentDirectory, type SiteHoneytoken, type SiteHoneytokenOptions, type StoredChallenge, TEST_TRIGGER_UA_PREFIX, TEST_TRIGGER_USER_AGENT, type TemporalSignals, type TextareaKeyboardStats, TokenManager, type TokenManagerOptions, type TokenStore, type TokenVerification, TripwireConfig, TripwireRule, UpstashRateLimitStore, type UpstashStoreOptions, type Verdict, type VerifyInput, type VerifyResult, type WebBotAuthConfig, WebBotAuthRule, WebDecoy, armSiteHoneytoken, attackSignatures, botPolicy, bots, calculateCategoryScores, calculateFinalScore, clientSignals, createAgentVerifier, createCaptchaEndpoints, deriveAndArm, filter, honeytoken, injectHoneytokenLink, isDatacenterIP, isInjectableHtml, isMobileUA, isTestTriggerUserAgent, parseUserAgent, rateLimit, readClientSession, recommend, resolveSecret, ruleBlockResponse, shouldSkipPath, siteHoneytoken, tripwire, upstashRateLimitStore, webBotAuth };
|
|
1784
|
+
export { ATTACK_SIGNATURE_IDS, AgentCategory, AgentRequestInput, AgentVerdict, AgentVerifier, AgentVerifierOptions, type AttackSignatureConfig, AttackSignatureRule, type BehavioralSignals, type BlockResponse, BotAgent, BotCategory, BotPolicy, type BotPolicyOptions, BotRule, BotRuleConfig, CLIENT_SESSION_COOKIE, CLIENT_SESSION_HEADER, Captcha, type CaptchaEndpoints, type CaptchaEndpointsOptions, type CaptchaHttpResponse, type CaptchaOptions, type CaptchaRequest, type CategoryScores, type ChallengeData, type ChallengeStore, type ClientSignalConfig, ClientSignalRule, type ClientSignalStore, type ClientVerdict, DEFAULT_SIGNED_AGENT_DIRECTORIES, DEFAULT_TRIPWIRE_PATHS, DEFAULT_WEIGHTS, type Detection, type DetectionContext, DetectionEngine, type DetectionEngineOptions, type DetectionScoringPolicy, DirectoryCache, type EnvironmentalSignals, FilterConfig, FilterRule, type FingerprintStore, type FormAnalysisSignals, HONEYTOKEN_BASE_PATH, type Honeytoken, type HoneytokenArmingOptions, type HoneytokenLinkProps, type HoneytokenOptions, InMemoryChallengeStore, InMemoryFingerprintStore, InMemoryRateLimiter, InMemoryTokenStore, MemoryClientSignalStore, type MemoryClientSignalStoreOptions, PoWManager, type PoWManagerOptions, type PoWOutcome, type PoWSolution, type PoWVerification, ProtectResult, RateLimitConfig, RateLimitConsume, RateLimitOutcome, RateLimitRule, RateLimitStore, type RateLimiter, type Recommendation, type RobotsTxtOptions, Rule, RuleContext, RuleEngine, RuleEngineResult, RuleResult, type ScoreResult, type ScoringComparison, type ScrollJumpObservation, type Signals, SignedAgentDirectory, type SiteHoneytoken, type SiteHoneytokenOptions, type StoredChallenge, TEST_TRIGGER_UA_PREFIX, TEST_TRIGGER_USER_AGENT, type TemporalSignals, type TextareaKeyboardStats, TokenManager, type TokenManagerOptions, type TokenStore, type TokenVerification, TripwireConfig, TripwireRule, UpstashRateLimitStore, type UpstashStoreOptions, type Verdict, type VerifyInput, type VerifyResult, type WebBotAuthConfig, WebBotAuthRule, WebDecoy, armSiteHoneytoken, attackSignatures, botPolicy, bots, calculateCategoryScores, calculateFinalScore, clientSignals, createAgentVerifier, createCaptchaEndpoints, deriveAndArm, filter, honeytoken, injectHoneytokenLink, isDatacenterIP, isInjectableHtml, isMobileUA, isTestTriggerUserAgent, parseUserAgent, rateLimit, readClientSession, recommend, resolveSecret, ruleBlockResponse, shouldSkipPath, siteHoneytoken, tripwire, upstashRateLimitStore, webBotAuth };
|
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,10 @@ interface BehavioralSignals {
|
|
|
64
64
|
touchEvents?: number;
|
|
65
65
|
pointerHasNonMouseType?: boolean;
|
|
66
66
|
keyEvents?: number;
|
|
67
|
+
/** Number of completed key holds in the browser's timing summary. */
|
|
68
|
+
keyHoldSamples?: number;
|
|
69
|
+
/** Average hold duration in milliseconds for those samples. */
|
|
70
|
+
keyHoldAvg?: number;
|
|
67
71
|
/** Count of recent scroll events and largest CSS pixel step between them. */
|
|
68
72
|
scrollMorphology?: {
|
|
69
73
|
samples?: number;
|
|
@@ -115,6 +119,8 @@ interface EnvironmentalSignals {
|
|
|
115
119
|
[key: string]: unknown;
|
|
116
120
|
};
|
|
117
121
|
automationFlags?: {
|
|
122
|
+
/** Explicit browser-declared WebDriver flag from navigator.webdriver. */
|
|
123
|
+
webdriver?: boolean;
|
|
118
124
|
plugins?: number;
|
|
119
125
|
languages?: boolean;
|
|
120
126
|
chrome?: boolean;
|
|
@@ -337,9 +343,9 @@ interface ScrollJumpObservation {
|
|
|
337
343
|
}
|
|
338
344
|
/** Final verdict returned by {@link DetectionEngine.score}. */
|
|
339
345
|
interface Verdict {
|
|
340
|
-
/** True when the
|
|
346
|
+
/** True when the selected policy's score is below the success threshold (< 0.5). */
|
|
341
347
|
success: boolean;
|
|
342
|
-
/**
|
|
348
|
+
/** Selected policy's final score, 0..1. */
|
|
343
349
|
score: number;
|
|
344
350
|
/** Recommended action. */
|
|
345
351
|
recommendation: Recommendation;
|
|
@@ -394,9 +400,27 @@ declare class InMemoryRateLimiter implements RateLimiter {
|
|
|
394
400
|
* supplies a {@link PoWOutcome} and the engine emits the matching detections.
|
|
395
401
|
*/
|
|
396
402
|
|
|
403
|
+
type DetectionScoringPolicy = 'weighted-mean-v1' | 'noisy-or-floors-v1';
|
|
404
|
+
interface ScoringComparison {
|
|
405
|
+
policy: 'noisy-or-floors-v1';
|
|
406
|
+
current: {
|
|
407
|
+
score: number;
|
|
408
|
+
recommendation: Recommendation;
|
|
409
|
+
};
|
|
410
|
+
candidate: {
|
|
411
|
+
score: number;
|
|
412
|
+
recommendation: Recommendation;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
397
415
|
interface DetectionEngineOptions {
|
|
398
416
|
/** Override the per-category weights (defaults to {@link DEFAULT_WEIGHTS}). */
|
|
399
417
|
weights?: Record<string, number>;
|
|
418
|
+
/**
|
|
419
|
+
* Aggregation policy used for the returned verdict and CAPTCHA token decision.
|
|
420
|
+
* Defaults to `weighted-mean-v1`; opt in to `noisy-or-floors-v1` to enforce
|
|
421
|
+
* the FCaptcha-aligned noisy-OR, decisive-floor, and corroboration-floor policy.
|
|
422
|
+
*/
|
|
423
|
+
scoringPolicy?: DetectionScoringPolicy;
|
|
400
424
|
/**
|
|
401
425
|
* When true (default), a request with no PoW outcome emits a hard-fail "No PoW
|
|
402
426
|
* solution provided" detection — matching the reference server. Set false to
|
|
@@ -407,18 +431,22 @@ interface DetectionEngineOptions {
|
|
|
407
431
|
fingerprintStore?: FingerprintStore;
|
|
408
432
|
/** Rate limiter for rate-abuse detection (defaults to in-memory). */
|
|
409
433
|
rateLimiter?: RateLimiter;
|
|
434
|
+
/** Receive a server-side comparison of the two aggregation methods using the same weights. */
|
|
435
|
+
onScoringComparison?: (comparison: ScoringComparison) => void | Promise<void>;
|
|
410
436
|
}
|
|
411
437
|
declare class DetectionEngine {
|
|
412
438
|
private readonly weights;
|
|
439
|
+
private readonly scoringPolicy;
|
|
413
440
|
private readonly requirePoW;
|
|
414
441
|
private readonly fingerprintStore;
|
|
415
442
|
private readonly rateLimiter;
|
|
443
|
+
private readonly onScoringComparison;
|
|
416
444
|
constructor(options?: DetectionEngineOptions);
|
|
417
445
|
/** Score `signals` for the given request context and return a verdict. */
|
|
418
446
|
score(signals: Signals, context: DetectionContext): Verdict;
|
|
419
447
|
}
|
|
420
448
|
|
|
421
|
-
/**
|
|
449
|
+
/** Per-category score aggregation and weighted totals. */
|
|
422
450
|
|
|
423
451
|
/**
|
|
424
452
|
* Aggregate detections into per-category scores. Each category's score is the
|
|
@@ -499,8 +527,14 @@ declare function parseUserAgent(ua: string): UserAgentInfo;
|
|
|
499
527
|
|
|
500
528
|
/** The engine's verdict on one browser session. */
|
|
501
529
|
interface ClientVerdict {
|
|
502
|
-
/**
|
|
530
|
+
/** Identifier used by the store. */
|
|
503
531
|
sessionId: string;
|
|
532
|
+
/** Scope of a receipt issued by the embedded score endpoint. */
|
|
533
|
+
receipt?: {
|
|
534
|
+
host: string;
|
|
535
|
+
siteKey: string;
|
|
536
|
+
expiresAt: number;
|
|
537
|
+
};
|
|
504
538
|
/** 0–1, higher is more bot-like. */
|
|
505
539
|
score: number;
|
|
506
540
|
/** What the engine recommends doing about it. */
|
|
@@ -536,14 +570,16 @@ declare class MemoryClientSignalStore implements ClientSignalStore {
|
|
|
536
570
|
set(verdict: ClientVerdict): void;
|
|
537
571
|
get size(): number;
|
|
538
572
|
}
|
|
539
|
-
/**
|
|
573
|
+
/** Session references supplied by an existing application integration. */
|
|
540
574
|
declare const CLIENT_SESSION_COOKIE = "wd_cs";
|
|
541
575
|
declare const CLIENT_SESSION_HEADER = "x-wd-session";
|
|
542
|
-
/** Read the
|
|
576
|
+
/** Read the server receipt or an application-supplied legacy session id. */
|
|
543
577
|
declare function readClientSession(headers: Record<string, string>): string | undefined;
|
|
544
578
|
interface ClientSignalConfig {
|
|
545
579
|
/** Where verdicts are read from. Must be the store `/score` writes to. */
|
|
546
580
|
store: ClientSignalStore;
|
|
581
|
+
/** Site key expected by this rule when several site keys share a request host. */
|
|
582
|
+
siteKey?: string;
|
|
547
583
|
/**
|
|
548
584
|
* Deny at or above this score, 0–1. The engine's own `recommendation` is used
|
|
549
585
|
* when this is omitted.
|
|
@@ -563,6 +599,7 @@ interface ClientSignalConfig {
|
|
|
563
599
|
declare class ClientSignalRule implements Rule {
|
|
564
600
|
readonly name = "client-signals";
|
|
565
601
|
private readonly store;
|
|
602
|
+
private readonly siteKey?;
|
|
566
603
|
private readonly minScore?;
|
|
567
604
|
private readonly action;
|
|
568
605
|
private readonly dryRun;
|
|
@@ -1633,6 +1670,10 @@ interface CaptchaOptions {
|
|
|
1633
1670
|
secret?: string;
|
|
1634
1671
|
/** Override per-category detection weights. */
|
|
1635
1672
|
weights?: Record<string, number>;
|
|
1673
|
+
/** Aggregation policy used for scoring, verification, and token issuance. */
|
|
1674
|
+
scoringPolicy?: DetectionEngineOptions['scoringPolicy'];
|
|
1675
|
+
/** Receive score and recommendation comparisons on the server without affecting verification. */
|
|
1676
|
+
onScoringComparison?: DetectionEngineOptions['onScoringComparison'];
|
|
1636
1677
|
/**
|
|
1637
1678
|
* Trusted reverse-proxy header names carrying a JA4 fingerprint, matched
|
|
1638
1679
|
* against the lower-cased request header keys (e.g. `['x-ja4']`).
|
|
@@ -1667,6 +1708,13 @@ declare class Captcha {
|
|
|
1667
1708
|
score(input: VerifyInput & {
|
|
1668
1709
|
action?: string;
|
|
1669
1710
|
}): Promise<ScoreResult>;
|
|
1711
|
+
/** @internal Return the score and whether the server verified the committed signals. */
|
|
1712
|
+
scoreForSession(input: VerifyInput & {
|
|
1713
|
+
action?: string;
|
|
1714
|
+
}): Promise<{
|
|
1715
|
+
result: ScoreResult;
|
|
1716
|
+
verifiedSignals: boolean;
|
|
1717
|
+
}>;
|
|
1670
1718
|
/** Verify a previously issued token (single-use, optionally IP-bound). */
|
|
1671
1719
|
verifyToken(token: string, ip?: string | null): Promise<TokenVerification>;
|
|
1672
1720
|
}
|
|
@@ -1733,4 +1781,4 @@ declare function createCaptchaEndpoints(options?: CaptchaEndpointsOptions): {
|
|
|
1733
1781
|
};
|
|
1734
1782
|
type CaptchaEndpoints = ReturnType<typeof createCaptchaEndpoints>;
|
|
1735
1783
|
|
|
1736
|
-
export { ATTACK_SIGNATURE_IDS, AgentCategory, AgentRequestInput, AgentVerdict, AgentVerifier, AgentVerifierOptions, type AttackSignatureConfig, AttackSignatureRule, type BehavioralSignals, type BlockResponse, BotAgent, BotCategory, BotPolicy, type BotPolicyOptions, BotRule, BotRuleConfig, CLIENT_SESSION_COOKIE, CLIENT_SESSION_HEADER, Captcha, type CaptchaEndpoints, type CaptchaEndpointsOptions, type CaptchaHttpResponse, type CaptchaOptions, type CaptchaRequest, type CategoryScores, type ChallengeData, type ChallengeStore, type ClientSignalConfig, ClientSignalRule, type ClientSignalStore, type ClientVerdict, DEFAULT_SIGNED_AGENT_DIRECTORIES, DEFAULT_TRIPWIRE_PATHS, DEFAULT_WEIGHTS, type Detection, type DetectionContext, DetectionEngine, type DetectionEngineOptions, DirectoryCache, type EnvironmentalSignals, FilterConfig, FilterRule, type FingerprintStore, type FormAnalysisSignals, HONEYTOKEN_BASE_PATH, type Honeytoken, type HoneytokenArmingOptions, type HoneytokenLinkProps, type HoneytokenOptions, InMemoryChallengeStore, InMemoryFingerprintStore, InMemoryRateLimiter, InMemoryTokenStore, MemoryClientSignalStore, type MemoryClientSignalStoreOptions, PoWManager, type PoWManagerOptions, type PoWOutcome, type PoWSolution, type PoWVerification, ProtectResult, RateLimitConfig, RateLimitConsume, RateLimitOutcome, RateLimitRule, RateLimitStore, type RateLimiter, type Recommendation, type RobotsTxtOptions, Rule, RuleContext, RuleEngine, RuleEngineResult, RuleResult, type ScoreResult, type ScrollJumpObservation, type Signals, SignedAgentDirectory, type SiteHoneytoken, type SiteHoneytokenOptions, type StoredChallenge, TEST_TRIGGER_UA_PREFIX, TEST_TRIGGER_USER_AGENT, type TemporalSignals, type TextareaKeyboardStats, TokenManager, type TokenManagerOptions, type TokenStore, type TokenVerification, TripwireConfig, TripwireRule, UpstashRateLimitStore, type UpstashStoreOptions, type Verdict, type VerifyInput, type VerifyResult, type WebBotAuthConfig, WebBotAuthRule, WebDecoy, armSiteHoneytoken, attackSignatures, botPolicy, bots, calculateCategoryScores, calculateFinalScore, clientSignals, createAgentVerifier, createCaptchaEndpoints, deriveAndArm, filter, honeytoken, injectHoneytokenLink, isDatacenterIP, isInjectableHtml, isMobileUA, isTestTriggerUserAgent, parseUserAgent, rateLimit, readClientSession, recommend, resolveSecret, ruleBlockResponse, shouldSkipPath, siteHoneytoken, tripwire, upstashRateLimitStore, webBotAuth };
|
|
1784
|
+
export { ATTACK_SIGNATURE_IDS, AgentCategory, AgentRequestInput, AgentVerdict, AgentVerifier, AgentVerifierOptions, type AttackSignatureConfig, AttackSignatureRule, type BehavioralSignals, type BlockResponse, BotAgent, BotCategory, BotPolicy, type BotPolicyOptions, BotRule, BotRuleConfig, CLIENT_SESSION_COOKIE, CLIENT_SESSION_HEADER, Captcha, type CaptchaEndpoints, type CaptchaEndpointsOptions, type CaptchaHttpResponse, type CaptchaOptions, type CaptchaRequest, type CategoryScores, type ChallengeData, type ChallengeStore, type ClientSignalConfig, ClientSignalRule, type ClientSignalStore, type ClientVerdict, DEFAULT_SIGNED_AGENT_DIRECTORIES, DEFAULT_TRIPWIRE_PATHS, DEFAULT_WEIGHTS, type Detection, type DetectionContext, DetectionEngine, type DetectionEngineOptions, type DetectionScoringPolicy, DirectoryCache, type EnvironmentalSignals, FilterConfig, FilterRule, type FingerprintStore, type FormAnalysisSignals, HONEYTOKEN_BASE_PATH, type Honeytoken, type HoneytokenArmingOptions, type HoneytokenLinkProps, type HoneytokenOptions, InMemoryChallengeStore, InMemoryFingerprintStore, InMemoryRateLimiter, InMemoryTokenStore, MemoryClientSignalStore, type MemoryClientSignalStoreOptions, PoWManager, type PoWManagerOptions, type PoWOutcome, type PoWSolution, type PoWVerification, ProtectResult, RateLimitConfig, RateLimitConsume, RateLimitOutcome, RateLimitRule, RateLimitStore, type RateLimiter, type Recommendation, type RobotsTxtOptions, Rule, RuleContext, RuleEngine, RuleEngineResult, RuleResult, type ScoreResult, type ScoringComparison, type ScrollJumpObservation, type Signals, SignedAgentDirectory, type SiteHoneytoken, type SiteHoneytokenOptions, type StoredChallenge, TEST_TRIGGER_UA_PREFIX, TEST_TRIGGER_USER_AGENT, type TemporalSignals, type TextareaKeyboardStats, TokenManager, type TokenManagerOptions, type TokenStore, type TokenVerification, TripwireConfig, TripwireRule, UpstashRateLimitStore, type UpstashStoreOptions, type Verdict, type VerifyInput, type VerifyResult, type WebBotAuthConfig, WebBotAuthRule, WebDecoy, armSiteHoneytoken, attackSignatures, botPolicy, bots, calculateCategoryScores, calculateFinalScore, clientSignals, createAgentVerifier, createCaptchaEndpoints, deriveAndArm, filter, honeytoken, injectHoneytokenLink, isDatacenterIP, isInjectableHtml, isMobileUA, isTestTriggerUserAgent, parseUserAgent, rateLimit, readClientSession, recommend, resolveSecret, ruleBlockResponse, shouldSkipPath, siteHoneytoken, tripwire, upstashRateLimitStore, webBotAuth };
|