@aientrophy/sdk 0.2.1 → 0.3.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/{console-BRZJJX1_.js → console-DbZZ4Ctg.js} +7 -0
- package/dist/{console-D3Kd9M_6.cjs → console-aIpHQlgP.cjs} +1 -1
- package/dist/core.js +1 -1
- package/dist/index.d.ts +21 -0
- package/dist/npm/index.cjs.js +1 -1
- package/dist/npm/index.es.js +1567 -192
- package/dist/sri-hashes.json +9 -0
- package/dist/types/challenge/ChallengeHandler.d.ts +1 -0
- package/dist/types/collection/BehaviorCollector.d.ts +0 -13
- package/dist/types/core/index.d.ts +14 -1
- package/dist/types/detectors/AutomationDetector.d.ts +43 -0
- package/dist/types/detectors/CanvasFingerprinter.d.ts +19 -2
- package/dist/types/detectors/CloudEnvironmentDetector.d.ts +51 -0
- package/dist/types/detectors/CrossContextDetector.d.ts +34 -0
- package/dist/types/detectors/HeadlessProbeDetector.d.ts +66 -0
- package/dist/types/detectors/InputTracker.d.ts +1 -0
- package/dist/types/detectors/MouseTracker.d.ts +2 -0
- package/dist/types/detectors/SessionAnalyzer.d.ts +39 -0
- package/dist/types/detectors/TabNavigationAnalyzer.d.ts +36 -0
- package/dist/types/detectors/console.d.ts +4 -0
- package/dist/types/protection/CrawlProtect.d.ts +38 -0
- package/dist/types/protection/CryptoUtils.d.ts +38 -3
- package/dist/types/transport/index.d.ts +3 -0
- package/package.json +2 -2
- package/dist/types/collector/index.d.ts +0 -11
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generated": "2026-03-20T02:39:39.149Z",
|
|
3
|
+
"algorithm": "sha384",
|
|
4
|
+
"hashes": {
|
|
5
|
+
"core.js": "sha384-a9oAPKIopFcC2T2/9FpPpgShfpq4tmSJuIAjkcTXEh2IdydxjJ5V642FuwONhhNv",
|
|
6
|
+
"core.wasm": "sha384-fPJjZg5frGy3uptl1c6t4ekPOoQRQPquQVQEbrMf09T7mCur5iJVX4gGqkRfu93q",
|
|
7
|
+
"loader.js": "sha384-0v1eaWmQUDG7Xzh8ujnAFroO2azUb0n547CCqAL1opB0WUltJC8WMyV8e1XoKf2R"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import { Transmitter } from '../transport';
|
|
2
2
|
export declare class BehaviorCollector {
|
|
3
3
|
private transmitter;
|
|
4
|
-
private trajectoryBuffer;
|
|
5
|
-
private keystrokeBuffer;
|
|
6
4
|
private isCollecting;
|
|
7
|
-
private flushInterval;
|
|
8
|
-
private flushTimer;
|
|
9
5
|
constructor(transmitter: Transmitter);
|
|
10
6
|
start(): void;
|
|
11
7
|
stop(): void;
|
|
12
|
-
private attachListeners;
|
|
13
|
-
private detachListeners;
|
|
14
|
-
private lastMouseMoveTime;
|
|
15
|
-
private onMouseMove;
|
|
16
|
-
private onKeyDown;
|
|
17
|
-
private onKeyUp;
|
|
18
|
-
private startFlushTimer;
|
|
19
|
-
private stopFlushTimer;
|
|
20
|
-
private flush;
|
|
21
8
|
}
|
|
@@ -5,6 +5,13 @@ export interface SecuritySDKConfig {
|
|
|
5
5
|
clientKey: string;
|
|
6
6
|
debug?: boolean;
|
|
7
7
|
callbacks?: SecuritySDKCallbacks;
|
|
8
|
+
/** Crawl protection config — set to enable anti-crawling */
|
|
9
|
+
crawlProtect?: {
|
|
10
|
+
/** CSS selectors to hide until JS challenge passes */
|
|
11
|
+
protectSelectors?: string[];
|
|
12
|
+
/** Insert honeypot data for non-JS crawlers */
|
|
13
|
+
insertHoneypot?: boolean;
|
|
14
|
+
};
|
|
8
15
|
serverConfig?: {
|
|
9
16
|
devtoolsDetection?: boolean;
|
|
10
17
|
[key: string]: any;
|
|
@@ -12,7 +19,6 @@ export interface SecuritySDKConfig {
|
|
|
12
19
|
}
|
|
13
20
|
declare class SecuritySDK {
|
|
14
21
|
private transmitter;
|
|
15
|
-
private collector;
|
|
16
22
|
private behaviorCollector;
|
|
17
23
|
private rapidClickDetector;
|
|
18
24
|
private honeypot;
|
|
@@ -21,6 +27,13 @@ declare class SecuritySDK {
|
|
|
21
27
|
private inputTracker;
|
|
22
28
|
private challengeHandler;
|
|
23
29
|
private invisibleInteraction;
|
|
30
|
+
private automationDetector;
|
|
31
|
+
private sessionAnalyzer;
|
|
32
|
+
private tabNavigationAnalyzer;
|
|
33
|
+
private cloudEnvironmentDetector;
|
|
34
|
+
private crossContextDetector;
|
|
35
|
+
private headlessProbeDetector;
|
|
36
|
+
private crawlProtect;
|
|
24
37
|
private initialized;
|
|
25
38
|
private wasmService;
|
|
26
39
|
private callbackManager;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Transmitter } from '../transport';
|
|
2
|
+
/**
|
|
3
|
+
* AutomationDetector — Detects browser automation tools.
|
|
4
|
+
*
|
|
5
|
+
* Detection layers:
|
|
6
|
+
* 1. navigator.webdriver flag (WebDriver protocol sets this)
|
|
7
|
+
* 2. CDP serialization side-effect (Playwright/Puppeteer rely on CDP)
|
|
8
|
+
* 3. Automation-injected globals (Selenium, PhantomJS, etc.)
|
|
9
|
+
* 4. WebGL renderer check (SwiftShader/Mesa = headless indicators)
|
|
10
|
+
* 5. Browser property inconsistencies
|
|
11
|
+
*/
|
|
12
|
+
export declare class AutomationDetector {
|
|
13
|
+
private transmitter;
|
|
14
|
+
private hasRun;
|
|
15
|
+
constructor(transmitter: Transmitter);
|
|
16
|
+
start(): void;
|
|
17
|
+
private detect;
|
|
18
|
+
/**
|
|
19
|
+
* CDP serialization detection.
|
|
20
|
+
* When CDP's Runtime domain is active (Playwright/Puppeteer),
|
|
21
|
+
* console.log triggers serialization of objects, invoking getters.
|
|
22
|
+
* In normal browsers without DevTools open, getters are NOT invoked.
|
|
23
|
+
*/
|
|
24
|
+
private detectCDP;
|
|
25
|
+
/**
|
|
26
|
+
* Check for automation framework globals injected into window.
|
|
27
|
+
*/
|
|
28
|
+
private detectAutomationGlobals;
|
|
29
|
+
/**
|
|
30
|
+
* Check WebGL renderer for headless indicators.
|
|
31
|
+
* SwiftShader, Mesa OffScreen, and ANGLE (software) are headless markers.
|
|
32
|
+
*/
|
|
33
|
+
private checkWebGL;
|
|
34
|
+
/**
|
|
35
|
+
* Cross-signal consistency checks.
|
|
36
|
+
* Compares multiple browser properties that should be correlated.
|
|
37
|
+
*/
|
|
38
|
+
private checkInconsistencies;
|
|
39
|
+
/**
|
|
40
|
+
* Additional headless Chrome detection signals.
|
|
41
|
+
*/
|
|
42
|
+
private checkHeadless;
|
|
43
|
+
}
|
|
@@ -2,9 +2,26 @@ import { Transmitter } from '../transport';
|
|
|
2
2
|
import { WasmService } from '../core/wasm';
|
|
3
3
|
export declare class CanvasFingerprinter {
|
|
4
4
|
private transmitter;
|
|
5
|
-
private wasmService;
|
|
6
5
|
private hasRun;
|
|
7
|
-
constructor(transmitter: Transmitter,
|
|
6
|
+
constructor(transmitter: Transmitter, _wasmService: WasmService);
|
|
8
7
|
start(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Generate canvas fingerprint using SHA-256 (upgraded from 32-bit FNV hash).
|
|
10
|
+
* SHA-256 eliminates collision risk at scale (2^128 vs ~77K for 32-bit).
|
|
11
|
+
*/
|
|
9
12
|
private generateFingerprint;
|
|
13
|
+
/**
|
|
14
|
+
* Compute SHA-256 hex digest using Web Crypto API.
|
|
15
|
+
*/
|
|
16
|
+
private sha256;
|
|
17
|
+
/**
|
|
18
|
+
* Collect WebGL fingerprint data for cross-signal consistency validation.
|
|
19
|
+
* Includes renderer, vendor, and hardware parameter profile.
|
|
20
|
+
*/
|
|
21
|
+
private collectWebGLFingerprint;
|
|
22
|
+
/**
|
|
23
|
+
* AudioContext fingerprint — the audio stack produces unique output
|
|
24
|
+
* per hardware/OS/browser combination, even for silent oscillators.
|
|
25
|
+
*/
|
|
26
|
+
private collectAudioFingerprint;
|
|
10
27
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Transmitter } from '../transport';
|
|
2
|
+
/**
|
|
3
|
+
* CloudEnvironmentDetector — Passively detects cloud VM, RDP, and virtual machine environments.
|
|
4
|
+
*
|
|
5
|
+
* This is a PASSIVE detector: it collects environment signals for logging and ML training
|
|
6
|
+
* but does NOT contribute to threat scoring. Cloud environments are not inherently malicious
|
|
7
|
+
* (remote workers, corporate VDI, etc.).
|
|
8
|
+
*
|
|
9
|
+
* Detection layers:
|
|
10
|
+
* 1. WebGL renderer analysis (virtual GPU identification)
|
|
11
|
+
* 2. Hardware characteristics (cores, memory, color depth)
|
|
12
|
+
* 3. Screen/display properties (VM-typical resolutions, no taskbar)
|
|
13
|
+
* 4. Media device availability (cameras, microphones, peripherals)
|
|
14
|
+
* 5. Canvas rendering performance benchmark
|
|
15
|
+
*/
|
|
16
|
+
export declare class CloudEnvironmentDetector {
|
|
17
|
+
private transmitter;
|
|
18
|
+
private hasRun;
|
|
19
|
+
constructor(transmitter: Transmitter);
|
|
20
|
+
start(): void;
|
|
21
|
+
private detect;
|
|
22
|
+
/**
|
|
23
|
+
* Analyze WebGL renderer to identify virtual GPUs.
|
|
24
|
+
*/
|
|
25
|
+
private analyzeGPU;
|
|
26
|
+
/**
|
|
27
|
+
* Categorize GPU renderer string into environment type.
|
|
28
|
+
*/
|
|
29
|
+
private categorizeGPU;
|
|
30
|
+
/**
|
|
31
|
+
* Collect hardware characteristics.
|
|
32
|
+
*/
|
|
33
|
+
private analyzeHardware;
|
|
34
|
+
/**
|
|
35
|
+
* Analyze screen properties for VM indicators.
|
|
36
|
+
*/
|
|
37
|
+
private analyzeScreen;
|
|
38
|
+
/**
|
|
39
|
+
* Check media device availability (cameras, microphones, peripherals).
|
|
40
|
+
*/
|
|
41
|
+
private analyzeMedia;
|
|
42
|
+
/**
|
|
43
|
+
* Quick canvas rendering benchmark.
|
|
44
|
+
* Software rendering (VM without GPU) is significantly slower.
|
|
45
|
+
*/
|
|
46
|
+
private benchmarkCanvas;
|
|
47
|
+
/**
|
|
48
|
+
* Classify the environment based on collected signals.
|
|
49
|
+
*/
|
|
50
|
+
private classify;
|
|
51
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Transmitter } from '../transport';
|
|
2
|
+
/**
|
|
3
|
+
* CrossContextDetector — iframe/Worker 크로스 컨텍스트 일관성 검증.
|
|
4
|
+
*
|
|
5
|
+
* 스푸핑 방어의 핵심: 메인 컨텍스트의 navigator 속성은 Object.defineProperty로
|
|
6
|
+
* 쉽게 조작 가능하지만, iframe이나 WebWorker 내부의 값은 별도 조작이 필요.
|
|
7
|
+
* 두 컨텍스트 간 불일치를 탐지하면 스푸핑을 높은 확률로 잡아냄.
|
|
8
|
+
*
|
|
9
|
+
* Detection:
|
|
10
|
+
* 1. iframe navigator.webdriver vs 메인
|
|
11
|
+
* 2. iframe navigator.plugins/languages vs 메인
|
|
12
|
+
* 3. WebWorker navigator 속성 vs 메인
|
|
13
|
+
* 4. WebWorker WebGL (OffscreenCanvas) vs 메인
|
|
14
|
+
*
|
|
15
|
+
* References:
|
|
16
|
+
* - deviceandbrowserinfo.com/are_you_a_bot (hasWebdriverInFrameTrue, hasInconsistentWorkerValues)
|
|
17
|
+
* - browserscan.net/bot-detection
|
|
18
|
+
*/
|
|
19
|
+
export declare class CrossContextDetector {
|
|
20
|
+
private transmitter;
|
|
21
|
+
private hasRun;
|
|
22
|
+
constructor(transmitter: Transmitter);
|
|
23
|
+
start(): void;
|
|
24
|
+
private detect;
|
|
25
|
+
/**
|
|
26
|
+
* Create a sandboxed iframe and compare navigator values.
|
|
27
|
+
*/
|
|
28
|
+
private checkIframe;
|
|
29
|
+
/**
|
|
30
|
+
* Spin up a WebWorker and compare navigator values.
|
|
31
|
+
* Workers have their own navigator which is harder to spoof.
|
|
32
|
+
*/
|
|
33
|
+
private checkWorker;
|
|
34
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Transmitter } from '../transport';
|
|
2
|
+
/**
|
|
3
|
+
* HeadlessProbeDetector — DOM/렌더링 기반 headless 탐지.
|
|
4
|
+
*
|
|
5
|
+
* 순수 JavaScript 속성 스푸핑으로는 우회 불가능한 항목들:
|
|
6
|
+
*
|
|
7
|
+
* 1. 깨진 이미지 크기 검사 (intoli, sannysoft)
|
|
8
|
+
* - 존재하지 않는 이미지의 naturalWidth/Height
|
|
9
|
+
* - 정상 브라우저: placeholder 크기 (>0), headless: 0x0
|
|
10
|
+
*
|
|
11
|
+
* 2. Client Hints 일관성 (deviceandbrowserinfo)
|
|
12
|
+
* - navigator.userAgentData.brands vs User-Agent 문자열
|
|
13
|
+
* - UA를 스푸핑해도 Client Hints를 같이 바꾸지 않으면 불일치
|
|
14
|
+
*
|
|
15
|
+
* 3. CDP 마우스 이벤트 구별 (deviceandbrowserinfo)
|
|
16
|
+
* - Input.dispatchMouseEvent는 네이티브와 미묘한 차이 존재
|
|
17
|
+
* - movementX/Y가 0, isTrusted가 true지만 screenX/Y 불일치 등
|
|
18
|
+
*
|
|
19
|
+
* 4. Hairline 지원 (intoli)
|
|
20
|
+
* - 0.5px border → offsetHeight 검사
|
|
21
|
+
*
|
|
22
|
+
* 5. Sequentum/추가 프레임워크 탐지
|
|
23
|
+
*/
|
|
24
|
+
export declare class HeadlessProbeDetector {
|
|
25
|
+
private transmitter;
|
|
26
|
+
private hasRun;
|
|
27
|
+
constructor(transmitter: Transmitter);
|
|
28
|
+
start(): void;
|
|
29
|
+
private detect;
|
|
30
|
+
/**
|
|
31
|
+
* Broken image dimensions test.
|
|
32
|
+
* Normal browsers render a placeholder for broken images (typically 16x16 or 24x24).
|
|
33
|
+
* Headless Chrome returns 0x0.
|
|
34
|
+
*/
|
|
35
|
+
private checkBrokenImage;
|
|
36
|
+
/**
|
|
37
|
+
* Client Hints consistency check.
|
|
38
|
+
* navigator.userAgentData (if available) should match UA string.
|
|
39
|
+
* Bots that spoof UA often forget to update Client Hints.
|
|
40
|
+
*/
|
|
41
|
+
private checkClientHints;
|
|
42
|
+
/**
|
|
43
|
+
* CDP mouse event signature detection.
|
|
44
|
+
* CDP's Input.dispatchMouseEvent creates events where:
|
|
45
|
+
* - movementX/Y are always 0 (no real mouse delta)
|
|
46
|
+
* - screenX/Y may not match clientX/Y + window offset
|
|
47
|
+
* - Multiple rapid mousemove without mousedown have consistent offsets
|
|
48
|
+
*
|
|
49
|
+
* We collect a few mouse events and check for CDP patterns.
|
|
50
|
+
*/
|
|
51
|
+
private checkCDPMouseSignature;
|
|
52
|
+
/**
|
|
53
|
+
* Hairline (0.5px border) support test.
|
|
54
|
+
* HiDPI devices support 0.5px borders. Headless Chrome may not.
|
|
55
|
+
*/
|
|
56
|
+
private checkHairlineSupport;
|
|
57
|
+
/**
|
|
58
|
+
* Additional automation framework globals.
|
|
59
|
+
*/
|
|
60
|
+
private checkExtraFrameworks;
|
|
61
|
+
/**
|
|
62
|
+
* CDP detection within WebWorker context.
|
|
63
|
+
* Same getter-trap technique but inside a Worker where it's harder to intercept.
|
|
64
|
+
*/
|
|
65
|
+
private checkWorkerCDP;
|
|
66
|
+
}
|
|
@@ -6,7 +6,9 @@ export declare class MouseTracker {
|
|
|
6
6
|
private buffer;
|
|
7
7
|
private readonly BUFFER_SIZE;
|
|
8
8
|
private readonly SAMPLE_INTERVAL;
|
|
9
|
+
private readonly SEND_COOLDOWN;
|
|
9
10
|
private lastSampleTime;
|
|
11
|
+
private lastSendTime;
|
|
10
12
|
constructor(transmitter: Transmitter, wasmService: WasmService);
|
|
11
13
|
start(): void;
|
|
12
14
|
stop(): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Transmitter } from '../transport';
|
|
2
|
+
/**
|
|
3
|
+
* SessionAnalyzer — Tracks session-level behavioral patterns that individual
|
|
4
|
+
* event detectors miss. Focuses on:
|
|
5
|
+
*
|
|
6
|
+
* 1. Page navigation timing (time between page transitions)
|
|
7
|
+
* 2. Interaction density (events per second)
|
|
8
|
+
* 3. Session duration vs form completion (too fast = bot)
|
|
9
|
+
* 4. Event timing distribution (coefficient of variation, entropy)
|
|
10
|
+
*/
|
|
11
|
+
export declare class SessionAnalyzer {
|
|
12
|
+
private transmitter;
|
|
13
|
+
private sessionStart;
|
|
14
|
+
private pageTransitions;
|
|
15
|
+
private interactionTimestamps;
|
|
16
|
+
private lastPageUrl;
|
|
17
|
+
private formStartTimes;
|
|
18
|
+
private reportInterval;
|
|
19
|
+
constructor(transmitter: Transmitter);
|
|
20
|
+
start(): void;
|
|
21
|
+
private observeNavigation;
|
|
22
|
+
private onPageTransition;
|
|
23
|
+
private observeForms;
|
|
24
|
+
private report;
|
|
25
|
+
private calculateIntervals;
|
|
26
|
+
private analyzeTimingDistribution;
|
|
27
|
+
private analyzePageTransitions;
|
|
28
|
+
/**
|
|
29
|
+
* Shannon entropy of intervals binned into buckets.
|
|
30
|
+
* Low entropy = predictable/regular timing = bot-like.
|
|
31
|
+
*/
|
|
32
|
+
private shannonEntropy;
|
|
33
|
+
/**
|
|
34
|
+
* Autocorrelation at lag-1.
|
|
35
|
+
* Human timing: moderate positive autocorrelation (motor control inertia).
|
|
36
|
+
* Random delays: near-zero autocorrelation.
|
|
37
|
+
*/
|
|
38
|
+
private autocorrelation;
|
|
39
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Transmitter } from '../transport';
|
|
2
|
+
/**
|
|
3
|
+
* TabNavigationAnalyzer — Detects robotic Tab key navigation patterns.
|
|
4
|
+
*
|
|
5
|
+
* Macros navigate forms by pressing Tab rapidly and uniformly to reach
|
|
6
|
+
* target elements, then stop to type/click. Humans have variable timing,
|
|
7
|
+
* occasionally overshoot (Shift+Tab), and don't maintain constant speed.
|
|
8
|
+
*
|
|
9
|
+
* Signals:
|
|
10
|
+
* 1. Tab interval CV (coefficient of variation) — low CV = mechanical regularity
|
|
11
|
+
* 2. Tab speed — avg interval < 50ms = superhuman
|
|
12
|
+
* 3. Shift+Tab ratio — absence of backtracking = suspicious (amplifier)
|
|
13
|
+
* 4. Tab bursts — consecutive rapid Tabs (< 80ms intervals)
|
|
14
|
+
*/
|
|
15
|
+
export declare class TabNavigationAnalyzer {
|
|
16
|
+
private transmitter;
|
|
17
|
+
private tabTimestamps;
|
|
18
|
+
private shiftTabCount;
|
|
19
|
+
private tabCount;
|
|
20
|
+
private isShiftDown;
|
|
21
|
+
private readonly BURST_THRESHOLD_MS;
|
|
22
|
+
private reportInterval;
|
|
23
|
+
private readonly REPORT_INTERVAL_MS;
|
|
24
|
+
private readonly MIN_TABS_TO_REPORT;
|
|
25
|
+
private readonly TAB_TRIGGER_COUNT;
|
|
26
|
+
constructor(transmitter: Transmitter);
|
|
27
|
+
start(): void;
|
|
28
|
+
stop(): void;
|
|
29
|
+
private onKeyDown;
|
|
30
|
+
private onKeyUp;
|
|
31
|
+
private report;
|
|
32
|
+
private resetBuffers;
|
|
33
|
+
private calculateIntervals;
|
|
34
|
+
private analyzeIntervals;
|
|
35
|
+
private analyzeBursts;
|
|
36
|
+
}
|
|
@@ -30,6 +30,10 @@ export declare class ConsoleDetector {
|
|
|
30
30
|
* When DevTools is docked (side or bottom), the browser viewport
|
|
31
31
|
* shrinks while outer dimensions stay the same.
|
|
32
32
|
* Threshold 160px covers DevTools minimum width/height.
|
|
33
|
+
*
|
|
34
|
+
* IMPORTANT: Skip on mobile/touch devices — mobile browsers have
|
|
35
|
+
* address bars, navigation bars, and soft keyboards that create
|
|
36
|
+
* large outerHeight-innerHeight gaps, causing false positives.
|
|
33
37
|
*/
|
|
34
38
|
private startSizeDetection;
|
|
35
39
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CrawlProtect — JS challenge-based crawling defense.
|
|
3
|
+
*
|
|
4
|
+
* Automatically solves a server-issued challenge and obtains a signed
|
|
5
|
+
* __aie_token cookie. This cookie proves the client executed JavaScript,
|
|
6
|
+
* which server-side crawlers (requests, wget, scrapy) cannot do.
|
|
7
|
+
*
|
|
8
|
+
* FE-only mode: Also provides content protection by gating sensitive
|
|
9
|
+
* DOM content behind challenge completion.
|
|
10
|
+
*/
|
|
11
|
+
export interface CrawlProtectConfig {
|
|
12
|
+
apiBase: string;
|
|
13
|
+
clientId: string;
|
|
14
|
+
/** Protect specific CSS selectors — hide until challenge passed */
|
|
15
|
+
protectSelectors?: string[];
|
|
16
|
+
/** Insert honeypot data for crawlers that bypass JS */
|
|
17
|
+
insertHoneypot?: boolean;
|
|
18
|
+
debug?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare class CrawlProtect {
|
|
21
|
+
private config;
|
|
22
|
+
private renewTimer;
|
|
23
|
+
private verified;
|
|
24
|
+
constructor(config: CrawlProtectConfig);
|
|
25
|
+
start(): Promise<boolean>;
|
|
26
|
+
isVerified(): boolean;
|
|
27
|
+
stop(): void;
|
|
28
|
+
private solveChallenge;
|
|
29
|
+
private hideContent;
|
|
30
|
+
private revealContent;
|
|
31
|
+
private insertHoneypotData;
|
|
32
|
+
private getToken;
|
|
33
|
+
private setToken;
|
|
34
|
+
private isExpired;
|
|
35
|
+
private scheduleRenewal;
|
|
36
|
+
private sha256;
|
|
37
|
+
private getFingerprint;
|
|
38
|
+
}
|
|
@@ -1,18 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cryptographic utilities for SDK ↔ Server secure communication.
|
|
3
|
+
*
|
|
4
|
+
* Supports two key-exchange modes:
|
|
5
|
+
* 1. ECDH + HKDF (default) — Perfect Forward Secrecy
|
|
6
|
+
* 2. RSA-OAEP (legacy fallback) — static server key
|
|
7
|
+
*
|
|
8
|
+
* Envelope format v2 (ECDH):
|
|
9
|
+
* { ek: base64(ECDH public key), d, iv, tag, v: 2 }
|
|
10
|
+
*
|
|
11
|
+
* Envelope format v1 (RSA, unchanged):
|
|
12
|
+
* { ek: base64(RSA-encrypted AES key), d, iv, tag }
|
|
13
|
+
*/
|
|
1
14
|
export declare class CryptoUtils {
|
|
2
15
|
private static sessionKey;
|
|
16
|
+
private static ecdhPublicKeyBase64;
|
|
3
17
|
private static encryptedSessionKey;
|
|
18
|
+
private static protocolVersion;
|
|
4
19
|
/**
|
|
5
|
-
* Initialize session key
|
|
20
|
+
* Initialize session key using ECDH + HKDF (PFS) or RSA fallback.
|
|
6
21
|
*/
|
|
7
22
|
static init(): Promise<void>;
|
|
8
23
|
/**
|
|
9
|
-
*
|
|
24
|
+
* ECDH + HKDF key exchange — provides Perfect Forward Secrecy.
|
|
25
|
+
*
|
|
26
|
+
* 1. Generate ephemeral ECDH key pair (P-256)
|
|
27
|
+
* 2. Fetch server's ephemeral ECDH public key from /key-exchange
|
|
28
|
+
* 3. Derive shared secret via ECDH
|
|
29
|
+
* 4. Derive AES-256-GCM key via HKDF-SHA256
|
|
30
|
+
*/
|
|
31
|
+
private static initECDH;
|
|
32
|
+
/**
|
|
33
|
+
* RSA-OAEP key exchange (legacy fallback, no PFS).
|
|
34
|
+
*/
|
|
35
|
+
private static initRSA;
|
|
36
|
+
/**
|
|
37
|
+
* Encrypt Payload using AES-GCM.
|
|
38
|
+
* Returns envelope with version indicator for server-side dispatch.
|
|
10
39
|
*/
|
|
11
40
|
static encrypt(data: any): Promise<{
|
|
12
41
|
ek: string;
|
|
13
42
|
d: string;
|
|
14
43
|
iv: string;
|
|
15
44
|
tag: string;
|
|
45
|
+
v?: number;
|
|
16
46
|
}>;
|
|
17
47
|
/**
|
|
18
48
|
* Decrypt Response using AES-GCM
|
|
@@ -22,7 +52,12 @@ export declare class CryptoUtils {
|
|
|
22
52
|
iv: string;
|
|
23
53
|
tag: string;
|
|
24
54
|
}): Promise<any>;
|
|
25
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Store the endpoint URL for ECDH key exchange.
|
|
57
|
+
* Called from Transmitter.setConfig().
|
|
58
|
+
*/
|
|
59
|
+
static setEndpoint(endpoint: string): void;
|
|
60
|
+
private static importRSAPublicKey;
|
|
26
61
|
private static str2ab;
|
|
27
62
|
private static arrayBufferToBase64;
|
|
28
63
|
private static base64ToArrayBuffer;
|
|
@@ -13,6 +13,9 @@ export declare class Transmitter {
|
|
|
13
13
|
private callbackManager;
|
|
14
14
|
private flushing;
|
|
15
15
|
private pendingFlush;
|
|
16
|
+
private backoffMs;
|
|
17
|
+
private maxBackoffMs;
|
|
18
|
+
private _lastBackoffStart;
|
|
16
19
|
constructor();
|
|
17
20
|
setConfig(config: SecuritySDKConfig): void;
|
|
18
21
|
setResponseHandler(handler: (response: any) => void): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aientrophy/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Aientrophy Security SDK – bot detection, threat monitoring, and CAPTCHA protection",
|
|
5
5
|
"main": "dist/npm/index.cjs.js",
|
|
6
6
|
"module": "dist/npm/index.es.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"scripts": {
|
|
22
22
|
"dev": "vite",
|
|
23
|
-
"build": "tsc && vite build -c vite.core.config.ts && vite build",
|
|
23
|
+
"build": "tsc && vite build -c vite.core.config.ts && vite build && node scripts/generate-sri.js",
|
|
24
24
|
"build:npm": "vite build -c vite.npm.config.ts && npx tsc -p tsconfig.npm.json",
|
|
25
25
|
"build:payload": "vite build -c vite.config.payload.ts",
|
|
26
26
|
"prepublishOnly": "npm run build:npm",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Transmitter } from '../transport';
|
|
2
|
-
export declare class EventCollector {
|
|
3
|
-
private transmitter;
|
|
4
|
-
private listeners;
|
|
5
|
-
constructor(transmitter: Transmitter);
|
|
6
|
-
start(): void;
|
|
7
|
-
stop(): void;
|
|
8
|
-
private attachListeners;
|
|
9
|
-
private detachListeners;
|
|
10
|
-
private throttle;
|
|
11
|
-
}
|