engagelab-captcha-sdk 1.0.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/captcha-sdk.esm.js +1 -0
- package/dist/captcha-sdk.umd.js +1 -0
- package/dist/types/api.d.ts +12 -0
- package/dist/types/challenges/dragsort.d.ts +24 -0
- package/dist/types/challenges/grid.d.ts +20 -0
- package/dist/types/challenges/icons.d.ts +18 -0
- package/dist/types/challenges/invisible.d.ts +8 -0
- package/dist/types/challenges/physics.d.ts +40 -0
- package/dist/types/challenges/rotate.d.ts +14 -0
- package/dist/types/challenges/slider.d.ts +17 -0
- package/dist/types/challenges/spatial.d.ts +12 -0
- package/dist/types/compat/hcaptcha.d.ts +1 -0
- package/dist/types/compat/recaptcha.d.ts +1 -0
- package/dist/types/crypto.d.ts +11 -0
- package/dist/types/deep_probes.d.ts +13 -0
- package/dist/types/degradation.d.ts +27 -0
- package/dist/types/device_attestation.d.ts +19 -0
- package/dist/types/fingerprint.d.ts +2 -0
- package/dist/types/headless.d.ts +2 -0
- package/dist/types/i18n.d.ts +7 -0
- package/dist/types/index.d.ts +36 -0
- package/dist/types/integrity.d.ts +3 -0
- package/dist/types/logger.d.ts +49 -0
- package/dist/types/native_monitor.d.ts +21 -0
- package/dist/types/passive_signals.d.ts +119 -0
- package/dist/types/pow.d.ts +2 -0
- package/dist/types/reporter.d.ts +8 -0
- package/dist/types/session_persist.d.ts +18 -0
- package/dist/types/theme.d.ts +11 -0
- package/dist/types/timing.d.ts +2 -0
- package/dist/types/trajectory.d.ts +18 -0
- package/dist/types/types.d.ts +182 -0
- package/dist/types/ui/container.d.ts +20 -0
- package/dist/types/ui/styles.d.ts +1 -0
- package/dist/types/wasm_core.d.ts +44 -0
- package/dist/types/web-component.d.ts +11 -0
- package/package.json +22 -0
- package/rollup.config.mjs +62 -0
- package/src/api.ts +180 -0
- package/src/challenges/dragsort.ts +168 -0
- package/src/challenges/grid.ts +147 -0
- package/src/challenges/icons.ts +106 -0
- package/src/challenges/invisible.ts +57 -0
- package/src/challenges/physics.ts +437 -0
- package/src/challenges/rotate.ts +81 -0
- package/src/challenges/slider.ts +168 -0
- package/src/challenges/spatial.ts +91 -0
- package/src/compat/hcaptcha.ts +112 -0
- package/src/compat/recaptcha.ts +108 -0
- package/src/crypto.ts +69 -0
- package/src/deep_probes.ts +690 -0
- package/src/degradation.ts +113 -0
- package/src/device_attestation.ts +109 -0
- package/src/fingerprint.ts +247 -0
- package/src/headless.ts +233 -0
- package/src/i18n.ts +455 -0
- package/src/index.ts +527 -0
- package/src/integrity.ts +100 -0
- package/src/logger.ts +170 -0
- package/src/native_monitor.ts +100 -0
- package/src/passive_signals.ts +544 -0
- package/src/pow.ts +120 -0
- package/src/reporter.ts +75 -0
- package/src/session_persist.ts +90 -0
- package/src/theme.ts +41 -0
- package/src/timing.ts +79 -0
- package/src/trajectory.ts +110 -0
- package/src/types.ts +199 -0
- package/src/ui/container.ts +161 -0
- package/src/ui/styles.ts +153 -0
- package/src/wasm_core.ts +189 -0
- package/src/web-component.ts +103 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InitResponse, VerifyResponse } from './types';
|
|
2
|
+
export declare class CaptchaAPI {
|
|
3
|
+
private baseUrl;
|
|
4
|
+
private siteKey;
|
|
5
|
+
constructor(baseUrl: string, siteKey?: string);
|
|
6
|
+
init(siteKey: string, entityHash?: string): Promise<InitResponse>;
|
|
7
|
+
verify(sessionId: string, data: any): Promise<VerifyResponse>;
|
|
8
|
+
getChallenge(sessionId: string, type: string): Promise<any>;
|
|
9
|
+
getResult(sessionId: string): Promise<any>;
|
|
10
|
+
private post;
|
|
11
|
+
private get;
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface DragSortResult {
|
|
2
|
+
sortOrder: number[];
|
|
3
|
+
trajectory: any[];
|
|
4
|
+
passtime: number;
|
|
5
|
+
dragEvents: {
|
|
6
|
+
fromIndex: number;
|
|
7
|
+
toIndex: number;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
export declare class DragSortChallenge {
|
|
12
|
+
private recorder;
|
|
13
|
+
private startTime;
|
|
14
|
+
private currentOrder;
|
|
15
|
+
private dragEvents;
|
|
16
|
+
private draggedEl;
|
|
17
|
+
create(imageBase64: string, instruction: string, itemCount: number): {
|
|
18
|
+
element: HTMLElement;
|
|
19
|
+
getResult: () => DragSortResult;
|
|
20
|
+
};
|
|
21
|
+
private getCurrentOrder;
|
|
22
|
+
private setupDragHandlers;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface GridResult {
|
|
2
|
+
selectedCells: number[];
|
|
3
|
+
clickSequence: {
|
|
4
|
+
cell: number;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
}[];
|
|
7
|
+
passtime: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class GridChallenge {
|
|
10
|
+
private startTime;
|
|
11
|
+
private selected;
|
|
12
|
+
private clickSequence;
|
|
13
|
+
private cellElements;
|
|
14
|
+
create(imageBase64: string, instruction: string, gridSize: number): {
|
|
15
|
+
element: HTMLElement;
|
|
16
|
+
getResult: () => GridResult;
|
|
17
|
+
};
|
|
18
|
+
private toggleCell;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface IconResult {
|
|
2
|
+
clicks: {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
index: number;
|
|
7
|
+
}[];
|
|
8
|
+
passtime: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class IconChallenge {
|
|
11
|
+
private resolve?;
|
|
12
|
+
private clicks;
|
|
13
|
+
private startTime;
|
|
14
|
+
create(imageBase64: string, instruction: string, iconCount: number): {
|
|
15
|
+
element: HTMLElement;
|
|
16
|
+
promise: Promise<IconResult>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Physics-based interactive CAPTCHA challenge.
|
|
3
|
+
*
|
|
4
|
+
* Renders 2D physics simulations using Canvas:
|
|
5
|
+
* - Tilt Ball: tilt a platform to guide a ball into a target hole
|
|
6
|
+
* - Gravity Drop: predict where an object lands
|
|
7
|
+
* - Balance Scale: place weights to balance a scale
|
|
8
|
+
*
|
|
9
|
+
* These challenges are extremely difficult for AI/ML because they require
|
|
10
|
+
* real-time spatial-physical reasoning, not just image recognition.
|
|
11
|
+
*/
|
|
12
|
+
interface PhysicsResult {
|
|
13
|
+
answer: Record<string, any> | string;
|
|
14
|
+
passtime: number;
|
|
15
|
+
interactionEvents?: Array<{
|
|
16
|
+
type: string;
|
|
17
|
+
time: number;
|
|
18
|
+
value: any;
|
|
19
|
+
}>;
|
|
20
|
+
events?: any[];
|
|
21
|
+
error?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class PhysicsChallenge {
|
|
24
|
+
private canvas;
|
|
25
|
+
private ctx;
|
|
26
|
+
private startTime;
|
|
27
|
+
private events;
|
|
28
|
+
private animFrameId;
|
|
29
|
+
private boundListeners;
|
|
30
|
+
create(challengeConfig: any, previewBase64: string): {
|
|
31
|
+
element: HTMLElement;
|
|
32
|
+
promise: Promise<PhysicsResult>;
|
|
33
|
+
};
|
|
34
|
+
destroy(): void;
|
|
35
|
+
private addListener;
|
|
36
|
+
private setupTiltBall;
|
|
37
|
+
private setupGravityDrop;
|
|
38
|
+
private setupBalanceScale;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface RotateResult {
|
|
2
|
+
angle: number;
|
|
3
|
+
trajectory: any[];
|
|
4
|
+
passtime: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class RotateChallenge {
|
|
7
|
+
private recorder;
|
|
8
|
+
private resolve?;
|
|
9
|
+
private currentAngle;
|
|
10
|
+
create(imageBase64: string): {
|
|
11
|
+
element: HTMLElement;
|
|
12
|
+
promise: Promise<RotateResult>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface SliderResult {
|
|
2
|
+
sliderX: number;
|
|
3
|
+
trajectory: any[];
|
|
4
|
+
passtime: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class SliderChallenge {
|
|
7
|
+
private recorder;
|
|
8
|
+
private resolve?;
|
|
9
|
+
private targetX;
|
|
10
|
+
private cleanupFns;
|
|
11
|
+
create(targetX: number): {
|
|
12
|
+
element: HTMLElement;
|
|
13
|
+
promise: Promise<SliderResult>;
|
|
14
|
+
};
|
|
15
|
+
destroy(): void;
|
|
16
|
+
private setupDrag;
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface SpatialResult {
|
|
2
|
+
answerIndex: number;
|
|
3
|
+
passtime: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class SpatialChallenge {
|
|
6
|
+
private resolve?;
|
|
7
|
+
private startTime;
|
|
8
|
+
create(imageBase64: string, question: string, options: string[]): {
|
|
9
|
+
element: HTMLElement;
|
|
10
|
+
promise: Promise<SpatialResult>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function installHCaptchaCompat(apiBase: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function installRecaptchaCompat(apiBase: string): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Communication security: AES-256-GCM encryption + HMAC-SHA256 signing.
|
|
3
|
+
* MVP uses a simplified approach with server-provided key material.
|
|
4
|
+
*/
|
|
5
|
+
export declare function encryptPayload(data: any, sessionKey: string): Promise<{
|
|
6
|
+
encrypted: string;
|
|
7
|
+
iv: string;
|
|
8
|
+
hmac: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function createRequestSignature(method: string, path: string, body: string, timestamp: number, nonce: string, secretKey: string): Promise<string>;
|
|
11
|
+
export declare function generateNonce(): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep environment probes — counter Camoufox/Nodriver/Stealth attacks.
|
|
3
|
+
* These tests exploit behavioral and timing differences that are extremely
|
|
4
|
+
* difficult to fake even with C++-level browser patching.
|
|
5
|
+
*/
|
|
6
|
+
export interface DeepProbeResult {
|
|
7
|
+
name: string;
|
|
8
|
+
detected: boolean;
|
|
9
|
+
value: string;
|
|
10
|
+
weight: number;
|
|
11
|
+
confidence: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function runDeepProbes(): Promise<DeepProbeResult[]>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface DegradationConfig {
|
|
2
|
+
maxRetries: number;
|
|
3
|
+
retryDelayMs: number;
|
|
4
|
+
fallbackMode: 'invisible' | 'local-pow' | 'always-pass';
|
|
5
|
+
healthCheckIntervalMs: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class DegradationManager {
|
|
8
|
+
private config;
|
|
9
|
+
private isServerHealthy;
|
|
10
|
+
private consecutiveFailures;
|
|
11
|
+
private healthCheckTimer;
|
|
12
|
+
constructor(config?: Partial<DegradationConfig>);
|
|
13
|
+
executeWithRetry<T>(fn: () => Promise<T>): Promise<T | null>;
|
|
14
|
+
shouldDegrade(): boolean;
|
|
15
|
+
getDegradedResult(): {
|
|
16
|
+
success: boolean;
|
|
17
|
+
token: string;
|
|
18
|
+
degraded: boolean;
|
|
19
|
+
};
|
|
20
|
+
private localPoW;
|
|
21
|
+
private simpleHash;
|
|
22
|
+
startHealthCheck(healthFn: () => Promise<boolean>): void;
|
|
23
|
+
stopHealthCheck(): void;
|
|
24
|
+
private onSuccess;
|
|
25
|
+
private onFailure;
|
|
26
|
+
private delay;
|
|
27
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Attestation — hardware-backed trust verification.
|
|
3
|
+
*
|
|
4
|
+
* Web: WebAuthn/FIDO2 for device binding
|
|
5
|
+
* The server can optionally require device attestation for high-risk scenarios.
|
|
6
|
+
*/
|
|
7
|
+
export interface AttestationResult {
|
|
8
|
+
supported: boolean;
|
|
9
|
+
type: 'webauthn' | 'none';
|
|
10
|
+
credential?: string;
|
|
11
|
+
attestationObject?: string;
|
|
12
|
+
clientDataJSON?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function checkDeviceAttestationSupport(): Promise<{
|
|
15
|
+
webauthn: boolean;
|
|
16
|
+
platformAuthenticator: boolean;
|
|
17
|
+
conditionalMediation: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function requestDeviceAttestation(challenge: Uint8Array, rpId: string, userId: string): Promise<AttestationResult>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type Locale = string;
|
|
2
|
+
export declare function setLocale(locale: string): void;
|
|
3
|
+
export declare function getLocale(): string;
|
|
4
|
+
export declare function isRtl(): boolean;
|
|
5
|
+
export declare function detectLocale(): string;
|
|
6
|
+
export declare function registerLocale(locale: string, msgs: Record<string, string>): void;
|
|
7
|
+
export declare function t(key: string): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CaptchaConfig } from './types';
|
|
2
|
+
import type { DeepProbeResult } from './deep_probes';
|
|
3
|
+
export type { DeepProbeResult };
|
|
4
|
+
export { DegradationManager, DegradationConfig } from './degradation';
|
|
5
|
+
export declare class EngageLabCaptcha {
|
|
6
|
+
private config;
|
|
7
|
+
private api;
|
|
8
|
+
private container;
|
|
9
|
+
private sessionId;
|
|
10
|
+
private sdkInitTime;
|
|
11
|
+
private pageTrajectory;
|
|
12
|
+
private passiveCollector;
|
|
13
|
+
private nativeMonitor;
|
|
14
|
+
private sessionPersist;
|
|
15
|
+
private escalationDepth;
|
|
16
|
+
private cachedCollectedData;
|
|
17
|
+
private static readonly MAX_ESCALATION_DEPTH;
|
|
18
|
+
constructor(config: CaptchaConfig);
|
|
19
|
+
execute(challengeType?: string): Promise<void>;
|
|
20
|
+
private runChallenge;
|
|
21
|
+
reset(): void;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
private collectAllData;
|
|
24
|
+
private runInvisible;
|
|
25
|
+
private runSlider;
|
|
26
|
+
private runSpatial;
|
|
27
|
+
private runRotate;
|
|
28
|
+
private runIcons;
|
|
29
|
+
private runDragSort;
|
|
30
|
+
private runGrid;
|
|
31
|
+
private runPhysics;
|
|
32
|
+
private handleResult;
|
|
33
|
+
private handleServiceUnavailable;
|
|
34
|
+
}
|
|
35
|
+
export { registerWebComponent, EngageLabCaptchaElement } from './web-component';
|
|
36
|
+
export default EngageLabCaptcha;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EngageLab CAPTCHA SDK Logger
|
|
3
|
+
*
|
|
4
|
+
* Provides structured logging with levels and optional console output.
|
|
5
|
+
* Can be enabled via config or localStorage for debugging.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum LogLevel {
|
|
8
|
+
NONE = 0,
|
|
9
|
+
ERROR = 1,
|
|
10
|
+
WARN = 2,
|
|
11
|
+
INFO = 3,
|
|
12
|
+
DEBUG = 4
|
|
13
|
+
}
|
|
14
|
+
interface LogEntry {
|
|
15
|
+
timestamp: number;
|
|
16
|
+
level: string;
|
|
17
|
+
module: string;
|
|
18
|
+
message: string;
|
|
19
|
+
data?: any;
|
|
20
|
+
}
|
|
21
|
+
declare class SDKLogger {
|
|
22
|
+
private level;
|
|
23
|
+
private logs;
|
|
24
|
+
private maxLogs;
|
|
25
|
+
private prefix;
|
|
26
|
+
private apiBase;
|
|
27
|
+
private siteKey;
|
|
28
|
+
private sessionId;
|
|
29
|
+
private flushTimer;
|
|
30
|
+
private isFlushing;
|
|
31
|
+
setLevel(level: LogLevel): void;
|
|
32
|
+
enableDebug(): void;
|
|
33
|
+
disable(): void;
|
|
34
|
+
error(module: string, message: string, data?: any): void;
|
|
35
|
+
warn(module: string, message: string, data?: any): void;
|
|
36
|
+
info(module: string, message: string, data?: any): void;
|
|
37
|
+
debug(module: string, message: string, data?: any): void;
|
|
38
|
+
getLogs(): LogEntry[];
|
|
39
|
+
clearLogs(): void;
|
|
40
|
+
private log;
|
|
41
|
+
configure(apiBase: string, siteKey: string): void;
|
|
42
|
+
setSessionId(id: string): void;
|
|
43
|
+
startAutoFlush(intervalMs?: number): void;
|
|
44
|
+
stopAutoFlush(): void;
|
|
45
|
+
flush(): Promise<void>;
|
|
46
|
+
destroy(): void;
|
|
47
|
+
}
|
|
48
|
+
export declare const sdkLogger: SDKLogger;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeMonitor — wrap sensitive global functions to detect automation tool injection.
|
|
3
|
+
*
|
|
4
|
+
* Records stack traces from calls to eval, Function constructor, and setTimeout(string).
|
|
5
|
+
* Provides disable() and a config flag (disableEvalPatching) for environments
|
|
6
|
+
* where wrapping interferes with HMR or dev tooling.
|
|
7
|
+
*/
|
|
8
|
+
import type { NativeTrace } from './types';
|
|
9
|
+
export declare class NativeMonitor {
|
|
10
|
+
private traces;
|
|
11
|
+
private originals;
|
|
12
|
+
private active;
|
|
13
|
+
start(): void;
|
|
14
|
+
disable(): void;
|
|
15
|
+
getTraces(): NativeTrace[];
|
|
16
|
+
private record;
|
|
17
|
+
private wrapEval;
|
|
18
|
+
private wrapFunctionConstructor;
|
|
19
|
+
private wrapSetTimeoutString;
|
|
20
|
+
private restore;
|
|
21
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passive Signal Collection — detect bots through background behavioral analysis.
|
|
3
|
+
* These signals are collected BEFORE the user interacts with any challenge.
|
|
4
|
+
*/
|
|
5
|
+
export interface DeviceMotionResult {
|
|
6
|
+
sampleCount: number;
|
|
7
|
+
avgAcceleration: number;
|
|
8
|
+
stdAcceleration: number;
|
|
9
|
+
avgRotationRate: number;
|
|
10
|
+
stdRotationRate: number;
|
|
11
|
+
hasGravity: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface DeviceOrientationResult {
|
|
14
|
+
sampleCount: number;
|
|
15
|
+
avgGammaDelta: number;
|
|
16
|
+
avgBetaDelta: number;
|
|
17
|
+
hasData: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface PassiveSignalResult {
|
|
20
|
+
rafTiming: RafTimingResult;
|
|
21
|
+
hoverTrap: HoverTrapResult;
|
|
22
|
+
eventTiming: EventTimingResult;
|
|
23
|
+
scrollBehavior: ScrollBehaviorResult;
|
|
24
|
+
idlePattern: IdlePatternResult;
|
|
25
|
+
inputBehavior: InputBehaviorResult;
|
|
26
|
+
deviceMotion?: DeviceMotionResult;
|
|
27
|
+
deviceOrientation?: DeviceOrientationResult;
|
|
28
|
+
}
|
|
29
|
+
interface RafTimingResult {
|
|
30
|
+
avgInterval: number;
|
|
31
|
+
stdInterval: number;
|
|
32
|
+
minInterval: number;
|
|
33
|
+
maxInterval: number;
|
|
34
|
+
frameCount: number;
|
|
35
|
+
anomaly: boolean;
|
|
36
|
+
anomalyType: string;
|
|
37
|
+
}
|
|
38
|
+
interface HoverTrapResult {
|
|
39
|
+
triggered: boolean;
|
|
40
|
+
hoverCount: number;
|
|
41
|
+
mouseOverHidden: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface EventTimingResult {
|
|
44
|
+
mousedownToMouseup: number[];
|
|
45
|
+
mousemoveToClick: number;
|
|
46
|
+
avgClickDuration: number;
|
|
47
|
+
hasNaturalVariance: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface ScrollBehaviorResult {
|
|
50
|
+
scrollEvents: number;
|
|
51
|
+
hasInertia: boolean;
|
|
52
|
+
avgScrollDelta: number;
|
|
53
|
+
scrollPatternRegular: boolean;
|
|
54
|
+
}
|
|
55
|
+
interface IdlePatternResult {
|
|
56
|
+
idlePeriods: number;
|
|
57
|
+
avgIdleDuration: number;
|
|
58
|
+
hasNaturalPauses: boolean;
|
|
59
|
+
}
|
|
60
|
+
interface InputBehaviorResult {
|
|
61
|
+
keyPressIntervals: number[];
|
|
62
|
+
hasTypingRhythm: boolean;
|
|
63
|
+
avgKeyInterval: number;
|
|
64
|
+
keystrokeDynamics: KeystrokeDynamics;
|
|
65
|
+
}
|
|
66
|
+
interface KeystrokeDynamics {
|
|
67
|
+
dwellTimes: number[];
|
|
68
|
+
flightTimes: number[];
|
|
69
|
+
avgDwell: number;
|
|
70
|
+
avgFlight: number;
|
|
71
|
+
dwellVariance: number;
|
|
72
|
+
flightVariance: number;
|
|
73
|
+
digraphLatencies: Record<string, number[]>;
|
|
74
|
+
}
|
|
75
|
+
export declare class PassiveSignalCollector {
|
|
76
|
+
private rafTimings;
|
|
77
|
+
private lastRafTime;
|
|
78
|
+
private rafHandle;
|
|
79
|
+
private mouseEvents;
|
|
80
|
+
private scrollEvents;
|
|
81
|
+
private keyEvents;
|
|
82
|
+
private hoverTrapTriggered;
|
|
83
|
+
private hoverTrapElement;
|
|
84
|
+
private idlePeriods;
|
|
85
|
+
private lastActivityTime;
|
|
86
|
+
private collecting;
|
|
87
|
+
private motionSamples;
|
|
88
|
+
private motionHasGravity;
|
|
89
|
+
private orientationDeltas;
|
|
90
|
+
private lastGamma;
|
|
91
|
+
private lastBeta;
|
|
92
|
+
private isMobileDevice;
|
|
93
|
+
start(): void;
|
|
94
|
+
stop(): void;
|
|
95
|
+
getResults(): PassiveSignalResult;
|
|
96
|
+
private measureRaf;
|
|
97
|
+
private analyzeRafTiming;
|
|
98
|
+
private setupHoverTrap;
|
|
99
|
+
private removeHoverTrap;
|
|
100
|
+
private analyzeHoverTrap;
|
|
101
|
+
private onMouseEvent;
|
|
102
|
+
private onScrollEvent;
|
|
103
|
+
private onKeyDown;
|
|
104
|
+
private onKeyUp;
|
|
105
|
+
private recordActivity;
|
|
106
|
+
private attachListeners;
|
|
107
|
+
private detachListeners;
|
|
108
|
+
private analyzeEventTiming;
|
|
109
|
+
private analyzeScrollBehavior;
|
|
110
|
+
private analyzeIdlePattern;
|
|
111
|
+
private analyzeInputBehavior;
|
|
112
|
+
private onDeviceMotion;
|
|
113
|
+
private onDeviceOrientation;
|
|
114
|
+
private startDeviceSensors;
|
|
115
|
+
private stopDeviceSensors;
|
|
116
|
+
private analyzeDeviceMotion;
|
|
117
|
+
private analyzeDeviceOrientation;
|
|
118
|
+
}
|
|
119
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error reporting and performance monitoring for the SDK.
|
|
3
|
+
* Collects exceptions and performance metrics, sends via beacon.
|
|
4
|
+
*/
|
|
5
|
+
export declare function initReporter(endpoint: string, key: string): void;
|
|
6
|
+
export declare function reportError(error: Error, context?: Record<string, string | number>): void;
|
|
7
|
+
export declare function reportPerf(metric: string, durationMs: number): void;
|
|
8
|
+
export declare function destroyReporter(): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Session Persistence — store session metadata in IndexedDB for cross-page context.
|
|
3
|
+
*
|
|
4
|
+
* Persists: sessionCount, lastVerifyTime, fingerprintCache hash.
|
|
5
|
+
* Used to report returning-user signals to the risk engine.
|
|
6
|
+
*/
|
|
7
|
+
export interface SessionData {
|
|
8
|
+
sessionCount: number;
|
|
9
|
+
lastVerifyTime: number;
|
|
10
|
+
fingerprintHash: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class SessionPersist {
|
|
13
|
+
private db;
|
|
14
|
+
private data;
|
|
15
|
+
load(): Promise<SessionData>;
|
|
16
|
+
recordVerify(fingerprintHash: string): Promise<void>;
|
|
17
|
+
getData(): SessionData;
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface CaptchaTheme {
|
|
2
|
+
primaryColor?: string;
|
|
3
|
+
successColor?: string;
|
|
4
|
+
errorColor?: string;
|
|
5
|
+
backgroundColor?: string;
|
|
6
|
+
textColor?: string;
|
|
7
|
+
borderRadius?: number;
|
|
8
|
+
fontFamily?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function setTheme(theme: CaptchaTheme): void;
|
|
11
|
+
export declare function getTheme(): Required<CaptchaTheme>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TrajectoryPoint } from './types';
|
|
2
|
+
export declare class TrajectoryRecorder {
|
|
3
|
+
private points;
|
|
4
|
+
private recording;
|
|
5
|
+
private element;
|
|
6
|
+
private handlers;
|
|
7
|
+
start(element: HTMLElement): void;
|
|
8
|
+
stop(): TrajectoryPoint[];
|
|
9
|
+
getPoints(): TrajectoryPoint[];
|
|
10
|
+
private bindEvents;
|
|
11
|
+
private unbindEvents;
|
|
12
|
+
private addPoint;
|
|
13
|
+
private onMouseMove;
|
|
14
|
+
private onMouseDown;
|
|
15
|
+
private onMouseUp;
|
|
16
|
+
private onClick;
|
|
17
|
+
private onTouchEvent;
|
|
18
|
+
}
|