@axeptio/behavior-detection 1.0.1 → 1.0.3
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/behavior-detection.esm.min.js.map +1 -1
- package/dist/behavior-detection.min.js.map +1 -1
- package/dist/behavior-detector.d.ts +2 -2
- package/dist/cjs/index.cjs +1422 -0
- package/dist/esm/behavior-detector.d.ts +2 -2
- package/dist/esm/browser.js +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +2 -2
- package/dist/esm/strategies/click.d.ts +1 -1
- package/dist/esm/strategies/click.js +1 -1
- package/dist/esm/strategies/environment.d.ts +1 -1
- package/dist/esm/strategies/environment.js +2 -2
- package/dist/esm/strategies/index.d.ts +14 -14
- package/dist/esm/strategies/index.js +14 -14
- package/dist/esm/strategies/keyboard.d.ts +1 -1
- package/dist/esm/strategies/keyboard.js +2 -2
- package/dist/esm/strategies/mouse.d.ts +1 -1
- package/dist/esm/strategies/mouse.js +2 -2
- package/dist/esm/strategies/resize.d.ts +1 -1
- package/dist/esm/strategies/resize.js +2 -2
- package/dist/esm/strategies/scroll.d.ts +1 -1
- package/dist/esm/strategies/scroll.js +2 -2
- package/dist/esm/strategies/tap.d.ts +1 -1
- package/dist/esm/strategies/tap.js +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/strategies/click.d.ts +1 -1
- package/dist/strategies/environment.d.ts +1 -1
- package/dist/strategies/index.d.ts +14 -14
- package/dist/strategies/keyboard.d.ts +1 -1
- package/dist/strategies/mouse.d.ts +1 -1
- package/dist/strategies/resize.d.ts +1 -1
- package/dist/strategies/scroll.d.ts +1 -1
- package/dist/strategies/tap.d.ts +1 -1
- package/package.json +16 -15
- package/dist/cjs/behavior-detector.d.ts +0 -102
- package/dist/cjs/behavior-detector.js +0 -315
- package/dist/cjs/browser.d.ts +0 -33
- package/dist/cjs/browser.js +0 -226
- package/dist/cjs/index.d.ts +0 -38
- package/dist/cjs/index.js +0 -55
- package/dist/cjs/math-utils.d.ts +0 -84
- package/dist/cjs/math-utils.js +0 -141
- package/dist/cjs/strategies/click.d.ts +0 -39
- package/dist/cjs/strategies/click.js +0 -173
- package/dist/cjs/strategies/environment.d.ts +0 -52
- package/dist/cjs/strategies/environment.js +0 -148
- package/dist/cjs/strategies/index.d.ts +0 -18
- package/dist/cjs/strategies/index.js +0 -36
- package/dist/cjs/strategies/keyboard.d.ts +0 -43
- package/dist/cjs/strategies/keyboard.js +0 -233
- package/dist/cjs/strategies/mouse.d.ts +0 -39
- package/dist/cjs/strategies/mouse.js +0 -159
- package/dist/cjs/strategies/resize.d.ts +0 -21
- package/dist/cjs/strategies/resize.js +0 -97
- package/dist/cjs/strategies/scroll.d.ts +0 -37
- package/dist/cjs/strategies/scroll.js +0 -149
- package/dist/cjs/strategies/tap.d.ts +0 -38
- package/dist/cjs/strategies/tap.js +0 -214
- package/dist/cjs/strategy.d.ts +0 -107
- package/dist/cjs/strategy.js +0 -33
- package/dist/cjs/types.d.ts +0 -168
- package/dist/cjs/types.js +0 -26
- package/dist/esm/browser-iife.d.ts +0 -5
- package/dist/esm/browser-iife.js +0 -157
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ScoreOptions, ScoreResult } from './types';
|
|
2
|
-
import type { DetectionStrategy, StrategyConfig, TickOptions } from './strategy';
|
|
1
|
+
import type { ScoreOptions, ScoreResult } from './types.js';
|
|
2
|
+
import type { DetectionStrategy, StrategyConfig, TickOptions } from './strategy.js';
|
|
3
3
|
/**
|
|
4
4
|
* Main class for behavior detection
|
|
5
5
|
* Uses modular strategy pattern for tree-shakeable, autonomous detection modules
|
package/dist/esm/browser.js
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* }
|
|
31
31
|
* </script>
|
|
32
32
|
*/
|
|
33
|
-
import { BehaviorDetector } from './behavior-detector';
|
|
33
|
+
import { BehaviorDetector } from './behavior-detector.js';
|
|
34
34
|
import { MouseStrategy, ScrollStrategy, ClickStrategy, TapStrategy, KeyboardStrategy, EnvironmentStrategy, ResizeStrategy, } from './strategies/index.js';
|
|
35
35
|
/**
|
|
36
36
|
* Detect if the current device is mobile
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
* const result = await detector.score();
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
export { BehaviorDetector } from './behavior-detector';
|
|
35
|
-
export type { DetectionStrategy, StrategyConfig } from './strategy';
|
|
34
|
+
export { BehaviorDetector } from './behavior-detector.js';
|
|
35
|
+
export type { DetectionStrategy, StrategyConfig } from './strategy.js';
|
|
36
36
|
export { Mouse, Scroll, Click, Tap, Keyboard, Environment, Resize, MouseStrategy, ScrollStrategy, ClickStrategy, TapStrategy, KeyboardStrategy, EnvironmentStrategy, ResizeStrategy, } from './strategies/index.js';
|
|
37
|
-
export type { BehaviorSettings, ScoreOptions, ScoreResult, ScoreBreakdown, TrackedEvent, EventType, ScoringFunction, } from './types';
|
|
38
|
-
export { DEFAULT_SETTINGS } from './types';
|
|
37
|
+
export type { BehaviorSettings, ScoreOptions, ScoreResult, ScoreBreakdown, TrackedEvent, EventType, ScoringFunction, } from './types.js';
|
|
38
|
+
export { DEFAULT_SETTINGS } from './types.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
* const result = await detector.score();
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
export { BehaviorDetector } from './behavior-detector';
|
|
34
|
+
export { BehaviorDetector } from './behavior-detector.js';
|
|
35
35
|
export { Mouse, Scroll, Click, Tap, Keyboard, Environment, Resize, MouseStrategy, ScrollStrategy, ClickStrategy, TapStrategy, KeyboardStrategy, EnvironmentStrategy, ResizeStrategy, } from './strategies/index.js';
|
|
36
|
-
export { DEFAULT_SETTINGS } from './types';
|
|
36
|
+
export { DEFAULT_SETTINGS } from './types.js';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Click Behavior Detection Strategy
|
|
3
3
|
* Monitors specific elements for click positioning patterns
|
|
4
4
|
*/
|
|
5
|
-
import { BaseStrategy } from '../strategy';
|
|
5
|
+
import { BaseStrategy } from '../strategy.js';
|
|
6
6
|
export declare class ClickStrategy extends BaseStrategy {
|
|
7
7
|
readonly name = "click";
|
|
8
8
|
readonly defaultWeight = 0.3;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Click Behavior Detection Strategy
|
|
3
3
|
* Monitors specific elements for click positioning patterns
|
|
4
4
|
*/
|
|
5
|
-
import { BaseStrategy } from '../strategy';
|
|
5
|
+
import { BaseStrategy } from '../strategy.js';
|
|
6
6
|
export class ClickStrategy extends BaseStrategy {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Environment Fingerprinting Strategy
|
|
3
3
|
* Captures browser environment on initialization and tick updates
|
|
4
4
|
*/
|
|
5
|
-
import { BaseStrategy } from '../strategy';
|
|
5
|
+
import { BaseStrategy } from '../strategy.js';
|
|
6
6
|
interface EnvironmentData {
|
|
7
7
|
screenWidth: number;
|
|
8
8
|
screenHeight: number;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Environment Fingerprinting Strategy
|
|
3
3
|
* Captures browser environment on initialization and tick updates
|
|
4
4
|
*/
|
|
5
|
-
import { BaseStrategy } from '../strategy';
|
|
6
|
-
import { inverseSigmoid, gaussian } from '../math-utils';
|
|
5
|
+
import { BaseStrategy } from '../strategy.js';
|
|
6
|
+
import { inverseSigmoid, gaussian } from '../math-utils.js';
|
|
7
7
|
export class EnvironmentStrategy extends BaseStrategy {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* Detection Strategies - Modular behavior analysis
|
|
3
3
|
* Import only what you need for optimal bundle size
|
|
4
4
|
*/
|
|
5
|
-
export { MouseStrategy } from './mouse';
|
|
6
|
-
export { ScrollStrategy } from './scroll';
|
|
7
|
-
export { ClickStrategy } from './click';
|
|
8
|
-
export { TapStrategy } from './tap';
|
|
9
|
-
export { KeyboardStrategy } from './keyboard';
|
|
10
|
-
export { EnvironmentStrategy } from './environment';
|
|
11
|
-
export { ResizeStrategy } from './resize';
|
|
12
|
-
export { MouseStrategy as Mouse } from './mouse';
|
|
13
|
-
export { ScrollStrategy as Scroll } from './scroll';
|
|
14
|
-
export { ClickStrategy as Click } from './click';
|
|
15
|
-
export { TapStrategy as Tap } from './tap';
|
|
16
|
-
export { KeyboardStrategy as Keyboard } from './keyboard';
|
|
17
|
-
export { EnvironmentStrategy as Environment } from './environment';
|
|
18
|
-
export { ResizeStrategy as Resize } from './resize';
|
|
5
|
+
export { MouseStrategy } from './mouse.js';
|
|
6
|
+
export { ScrollStrategy } from './scroll.js';
|
|
7
|
+
export { ClickStrategy } from './click.js';
|
|
8
|
+
export { TapStrategy } from './tap.js';
|
|
9
|
+
export { KeyboardStrategy } from './keyboard.js';
|
|
10
|
+
export { EnvironmentStrategy } from './environment.js';
|
|
11
|
+
export { ResizeStrategy } from './resize.js';
|
|
12
|
+
export { MouseStrategy as Mouse } from './mouse.js';
|
|
13
|
+
export { ScrollStrategy as Scroll } from './scroll.js';
|
|
14
|
+
export { ClickStrategy as Click } from './click.js';
|
|
15
|
+
export { TapStrategy as Tap } from './tap.js';
|
|
16
|
+
export { KeyboardStrategy as Keyboard } from './keyboard.js';
|
|
17
|
+
export { EnvironmentStrategy as Environment } from './environment.js';
|
|
18
|
+
export { ResizeStrategy as Resize } from './resize.js';
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* Detection Strategies - Modular behavior analysis
|
|
3
3
|
* Import only what you need for optimal bundle size
|
|
4
4
|
*/
|
|
5
|
-
export { MouseStrategy } from './mouse';
|
|
6
|
-
export { ScrollStrategy } from './scroll';
|
|
7
|
-
export { ClickStrategy } from './click';
|
|
8
|
-
export { TapStrategy } from './tap';
|
|
9
|
-
export { KeyboardStrategy } from './keyboard';
|
|
10
|
-
export { EnvironmentStrategy } from './environment';
|
|
11
|
-
export { ResizeStrategy } from './resize';
|
|
5
|
+
export { MouseStrategy } from './mouse.js';
|
|
6
|
+
export { ScrollStrategy } from './scroll.js';
|
|
7
|
+
export { ClickStrategy } from './click.js';
|
|
8
|
+
export { TapStrategy } from './tap.js';
|
|
9
|
+
export { KeyboardStrategy } from './keyboard.js';
|
|
10
|
+
export { EnvironmentStrategy } from './environment.js';
|
|
11
|
+
export { ResizeStrategy } from './resize.js';
|
|
12
12
|
// Convenience: All strategies
|
|
13
|
-
export { MouseStrategy as Mouse } from './mouse';
|
|
14
|
-
export { ScrollStrategy as Scroll } from './scroll';
|
|
15
|
-
export { ClickStrategy as Click } from './click';
|
|
16
|
-
export { TapStrategy as Tap } from './tap';
|
|
17
|
-
export { KeyboardStrategy as Keyboard } from './keyboard';
|
|
18
|
-
export { EnvironmentStrategy as Environment } from './environment';
|
|
19
|
-
export { ResizeStrategy as Resize } from './resize';
|
|
13
|
+
export { MouseStrategy as Mouse } from './mouse.js';
|
|
14
|
+
export { ScrollStrategy as Scroll } from './scroll.js';
|
|
15
|
+
export { ClickStrategy as Click } from './click.js';
|
|
16
|
+
export { TapStrategy as Tap } from './tap.js';
|
|
17
|
+
export { KeyboardStrategy as Keyboard } from './keyboard.js';
|
|
18
|
+
export { EnvironmentStrategy as Environment } from './environment.js';
|
|
19
|
+
export { ResizeStrategy as Resize } from './resize.js';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Monitors typing in specific input fields
|
|
4
4
|
* Analyzes keydown/keyup timing and micro-variations
|
|
5
5
|
*/
|
|
6
|
-
import { BaseStrategy } from '../strategy';
|
|
6
|
+
import { BaseStrategy } from '../strategy.js';
|
|
7
7
|
export declare class KeyboardStrategy extends BaseStrategy {
|
|
8
8
|
readonly name = "keyboard";
|
|
9
9
|
readonly defaultWeight = 0.1;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Monitors typing in specific input fields
|
|
4
4
|
* Analyzes keydown/keyup timing and micro-variations
|
|
5
5
|
*/
|
|
6
|
-
import { BaseStrategy } from '../strategy';
|
|
7
|
-
import { analyzeIntervals, scoreCoefficientOfVariation } from '../math-utils';
|
|
6
|
+
import { BaseStrategy } from '../strategy.js';
|
|
7
|
+
import { analyzeIntervals, scoreCoefficientOfVariation } from '../math-utils.js';
|
|
8
8
|
export class KeyboardStrategy extends BaseStrategy {
|
|
9
9
|
constructor(options) {
|
|
10
10
|
super();
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Autonomous module that manages its own mouse event listeners and state
|
|
4
4
|
* Tracks distance and angle to detect unnatural jumps and sharp turns
|
|
5
5
|
*/
|
|
6
|
-
import { BaseStrategy, type TimeSeriesPoint } from '../strategy';
|
|
6
|
+
import { BaseStrategy, type TimeSeriesPoint } from '../strategy.js';
|
|
7
7
|
export declare class MouseStrategy extends BaseStrategy {
|
|
8
8
|
readonly name = "mouse";
|
|
9
9
|
readonly defaultWeight = 0.3;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Autonomous module that manages its own mouse event listeners and state
|
|
4
4
|
* Tracks distance and angle to detect unnatural jumps and sharp turns
|
|
5
5
|
*/
|
|
6
|
-
import { BaseStrategy } from '../strategy';
|
|
7
|
-
import { calculateStatistics, gaussian } from '../math-utils';
|
|
6
|
+
import { BaseStrategy } from '../strategy.js';
|
|
7
|
+
import { calculateStatistics, gaussian } from '../math-utils.js';
|
|
8
8
|
export class MouseStrategy extends BaseStrategy {
|
|
9
9
|
constructor(options) {
|
|
10
10
|
super();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Resize Behavior Detection Strategy
|
|
3
3
|
*/
|
|
4
|
-
import { BaseStrategy } from '../strategy';
|
|
5
|
-
import { inverseSigmoid, sigmoid } from '../math-utils';
|
|
4
|
+
import { BaseStrategy } from '../strategy.js';
|
|
5
|
+
import { inverseSigmoid, sigmoid } from '../math-utils.js';
|
|
6
6
|
export class ResizeStrategy extends BaseStrategy {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Autonomous module managing scroll event listeners
|
|
4
4
|
* Tracks normalized scroll distance and velocity patterns
|
|
5
5
|
*/
|
|
6
|
-
import { BaseStrategy, type TimeSeriesPoint } from '../strategy';
|
|
6
|
+
import { BaseStrategy, type TimeSeriesPoint } from '../strategy.js';
|
|
7
7
|
export declare class ScrollStrategy extends BaseStrategy {
|
|
8
8
|
readonly name = "scroll";
|
|
9
9
|
readonly defaultWeight = 0.15;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Autonomous module managing scroll event listeners
|
|
4
4
|
* Tracks normalized scroll distance and velocity patterns
|
|
5
5
|
*/
|
|
6
|
-
import { BaseStrategy } from '../strategy';
|
|
7
|
-
import { calculateStatistics, gaussian, inverseSigmoid } from '../math-utils';
|
|
6
|
+
import { BaseStrategy } from '../strategy.js';
|
|
7
|
+
import { calculateStatistics, gaussian, inverseSigmoid } from '../math-utils.js';
|
|
8
8
|
export class ScrollStrategy extends BaseStrategy {
|
|
9
9
|
constructor(options) {
|
|
10
10
|
super();
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Monitors touch interactions on specific elements
|
|
4
4
|
* Analyzes tap duration, precision, movement, and timing patterns
|
|
5
5
|
*/
|
|
6
|
-
import { BaseStrategy } from '../strategy';
|
|
6
|
+
import { BaseStrategy } from '../strategy.js';
|
|
7
7
|
export declare class TapStrategy extends BaseStrategy {
|
|
8
8
|
readonly name = "tap";
|
|
9
9
|
readonly defaultWeight = 0.35;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Monitors touch interactions on specific elements
|
|
4
4
|
* Analyzes tap duration, precision, movement, and timing patterns
|
|
5
5
|
*/
|
|
6
|
-
import { BaseStrategy } from '../strategy';
|
|
7
|
-
import { analyzeIntervals, scoreCoefficientOfVariation, gaussian } from '../math-utils';
|
|
6
|
+
import { BaseStrategy } from '../strategy.js';
|
|
7
|
+
import { analyzeIntervals, scoreCoefficientOfVariation, gaussian } from '../math-utils.js';
|
|
8
8
|
export class TapStrategy extends BaseStrategy {
|
|
9
9
|
constructor(options) {
|
|
10
10
|
super();
|
package/dist/index.d.ts
CHANGED
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
* const result = await detector.score();
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
export { BehaviorDetector } from './behavior-detector';
|
|
35
|
-
export type { DetectionStrategy, StrategyConfig } from './strategy';
|
|
34
|
+
export { BehaviorDetector } from './behavior-detector.js';
|
|
35
|
+
export type { DetectionStrategy, StrategyConfig } from './strategy.js';
|
|
36
36
|
export { Mouse, Scroll, Click, Tap, Keyboard, Environment, Resize, MouseStrategy, ScrollStrategy, ClickStrategy, TapStrategy, KeyboardStrategy, EnvironmentStrategy, ResizeStrategy, } from './strategies/index.js';
|
|
37
|
-
export type { BehaviorSettings, ScoreOptions, ScoreResult, ScoreBreakdown, TrackedEvent, EventType, ScoringFunction, } from './types';
|
|
38
|
-
export { DEFAULT_SETTINGS } from './types';
|
|
37
|
+
export type { BehaviorSettings, ScoreOptions, ScoreResult, ScoreBreakdown, TrackedEvent, EventType, ScoringFunction, } from './types.js';
|
|
38
|
+
export { DEFAULT_SETTINGS } from './types.js';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Click Behavior Detection Strategy
|
|
3
3
|
* Monitors specific elements for click positioning patterns
|
|
4
4
|
*/
|
|
5
|
-
import { BaseStrategy } from '../strategy';
|
|
5
|
+
import { BaseStrategy } from '../strategy.js';
|
|
6
6
|
export declare class ClickStrategy extends BaseStrategy {
|
|
7
7
|
readonly name = "click";
|
|
8
8
|
readonly defaultWeight = 0.3;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Environment Fingerprinting Strategy
|
|
3
3
|
* Captures browser environment on initialization and tick updates
|
|
4
4
|
*/
|
|
5
|
-
import { BaseStrategy } from '../strategy';
|
|
5
|
+
import { BaseStrategy } from '../strategy.js';
|
|
6
6
|
interface EnvironmentData {
|
|
7
7
|
screenWidth: number;
|
|
8
8
|
screenHeight: number;
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* Detection Strategies - Modular behavior analysis
|
|
3
3
|
* Import only what you need for optimal bundle size
|
|
4
4
|
*/
|
|
5
|
-
export { MouseStrategy } from './mouse';
|
|
6
|
-
export { ScrollStrategy } from './scroll';
|
|
7
|
-
export { ClickStrategy } from './click';
|
|
8
|
-
export { TapStrategy } from './tap';
|
|
9
|
-
export { KeyboardStrategy } from './keyboard';
|
|
10
|
-
export { EnvironmentStrategy } from './environment';
|
|
11
|
-
export { ResizeStrategy } from './resize';
|
|
12
|
-
export { MouseStrategy as Mouse } from './mouse';
|
|
13
|
-
export { ScrollStrategy as Scroll } from './scroll';
|
|
14
|
-
export { ClickStrategy as Click } from './click';
|
|
15
|
-
export { TapStrategy as Tap } from './tap';
|
|
16
|
-
export { KeyboardStrategy as Keyboard } from './keyboard';
|
|
17
|
-
export { EnvironmentStrategy as Environment } from './environment';
|
|
18
|
-
export { ResizeStrategy as Resize } from './resize';
|
|
5
|
+
export { MouseStrategy } from './mouse.js';
|
|
6
|
+
export { ScrollStrategy } from './scroll.js';
|
|
7
|
+
export { ClickStrategy } from './click.js';
|
|
8
|
+
export { TapStrategy } from './tap.js';
|
|
9
|
+
export { KeyboardStrategy } from './keyboard.js';
|
|
10
|
+
export { EnvironmentStrategy } from './environment.js';
|
|
11
|
+
export { ResizeStrategy } from './resize.js';
|
|
12
|
+
export { MouseStrategy as Mouse } from './mouse.js';
|
|
13
|
+
export { ScrollStrategy as Scroll } from './scroll.js';
|
|
14
|
+
export { ClickStrategy as Click } from './click.js';
|
|
15
|
+
export { TapStrategy as Tap } from './tap.js';
|
|
16
|
+
export { KeyboardStrategy as Keyboard } from './keyboard.js';
|
|
17
|
+
export { EnvironmentStrategy as Environment } from './environment.js';
|
|
18
|
+
export { ResizeStrategy as Resize } from './resize.js';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Monitors typing in specific input fields
|
|
4
4
|
* Analyzes keydown/keyup timing and micro-variations
|
|
5
5
|
*/
|
|
6
|
-
import { BaseStrategy } from '../strategy';
|
|
6
|
+
import { BaseStrategy } from '../strategy.js';
|
|
7
7
|
export declare class KeyboardStrategy extends BaseStrategy {
|
|
8
8
|
readonly name = "keyboard";
|
|
9
9
|
readonly defaultWeight = 0.1;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Autonomous module that manages its own mouse event listeners and state
|
|
4
4
|
* Tracks distance and angle to detect unnatural jumps and sharp turns
|
|
5
5
|
*/
|
|
6
|
-
import { BaseStrategy, type TimeSeriesPoint } from '../strategy';
|
|
6
|
+
import { BaseStrategy, type TimeSeriesPoint } from '../strategy.js';
|
|
7
7
|
export declare class MouseStrategy extends BaseStrategy {
|
|
8
8
|
readonly name = "mouse";
|
|
9
9
|
readonly defaultWeight = 0.3;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Autonomous module managing scroll event listeners
|
|
4
4
|
* Tracks normalized scroll distance and velocity patterns
|
|
5
5
|
*/
|
|
6
|
-
import { BaseStrategy, type TimeSeriesPoint } from '../strategy';
|
|
6
|
+
import { BaseStrategy, type TimeSeriesPoint } from '../strategy.js';
|
|
7
7
|
export declare class ScrollStrategy extends BaseStrategy {
|
|
8
8
|
readonly name = "scroll";
|
|
9
9
|
readonly defaultWeight = 0.15;
|
package/dist/strategies/tap.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Monitors touch interactions on specific elements
|
|
4
4
|
* Analyzes tap duration, precision, movement, and timing patterns
|
|
5
5
|
*/
|
|
6
|
-
import { BaseStrategy } from '../strategy';
|
|
6
|
+
import { BaseStrategy } from '../strategy.js';
|
|
7
7
|
export declare class TapStrategy extends BaseStrategy {
|
|
8
8
|
readonly name = "tap";
|
|
9
9
|
readonly defaultWeight = 0.35;
|
package/package.json
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axeptio/behavior-detection",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Lightweight behavior detection library to assess human likelihood of user sessions",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/cjs/index.cjs",
|
|
6
7
|
"module": "./dist/esm/index.js",
|
|
7
8
|
"types": "./dist/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
11
|
"types": "./dist/index.d.ts",
|
|
11
12
|
"import": "./dist/esm/index.js",
|
|
12
|
-
"require": "./dist/cjs/index.
|
|
13
|
+
"require": "./dist/cjs/index.cjs"
|
|
13
14
|
}
|
|
14
15
|
},
|
|
15
16
|
"files": [
|
|
16
17
|
"dist"
|
|
17
18
|
],
|
|
18
19
|
"scripts": {
|
|
19
|
-
"build": "npm run build:
|
|
20
|
-
"build:cjs": "
|
|
20
|
+
"build": "npm run build:esm && npm run build:cjs && npm run build:types",
|
|
21
|
+
"build:cjs": "esbuild dist/esm/index.js --bundle --format=cjs --platform=node --target=es2017 --outfile=dist/cjs/index.cjs",
|
|
21
22
|
"build:esm": "tsc --module es2015 --outDir dist/esm",
|
|
22
23
|
"build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
|
|
23
24
|
"build:bundle": "npm run build:esm && esbuild dist/esm/index.js --bundle --minify --sourcemap --target=es2020 --tree-shaking=true --outfile=dist/behavior-detection.esm.min.js",
|
|
@@ -25,19 +26,19 @@
|
|
|
25
26
|
"build:browser:dev": "npm run build:esm && esbuild dist/esm/browser.js --bundle --minify --sourcemap --format=iife --global-name=BehaviorDetector --target=es2020 --tree-shaking=true --outfile=dist/behavior-detection.min.js",
|
|
26
27
|
"build:all": "npm run build && npm run build:bundle && npm run build:browser",
|
|
27
28
|
"clean": "rm -rf dist",
|
|
28
|
-
"deploy": "node scripts/deploy.
|
|
29
|
+
"deploy": "node scripts/deploy.cjs",
|
|
29
30
|
"release:patch": "npm version patch && git push && git push --tags",
|
|
30
31
|
"release:minor": "npm version minor && git push && git push --tags",
|
|
31
32
|
"release:major": "npm version major && git push && git push --tags",
|
|
32
|
-
"tryme": "npm run build && node scripts/serve.
|
|
33
|
-
"test": "npm run build && node tests/adversarial/run-tests.
|
|
34
|
-
"test:adversarial": "npm run build && node tests/adversarial/run-all.
|
|
35
|
-
"test:playwright": "npm run build && node tests/adversarial/playwright-test.
|
|
36
|
-
"test:selenium": "npm run build && node tests/adversarial/selenium-test.
|
|
37
|
-
"test:puppeteer": "npm run build && node tests/adversarial/puppeteer-test.
|
|
38
|
-
"test:stress": "npm run build && node tests/adversarial/detector-stress-test.
|
|
39
|
-
"test:stress:quick": "npm run build && node tests/adversarial/detector-stress-test.
|
|
40
|
-
"test:stress:intense": "npm run build && node tests/adversarial/detector-stress-test.
|
|
33
|
+
"tryme": "npm run build && node scripts/serve.cjs",
|
|
34
|
+
"test": "npm run build && node tests/adversarial/run-tests.cjs",
|
|
35
|
+
"test:adversarial": "npm run build && node tests/adversarial/run-all.cjs",
|
|
36
|
+
"test:playwright": "npm run build && node tests/adversarial/playwright-test.cjs",
|
|
37
|
+
"test:selenium": "npm run build && node tests/adversarial/selenium-test.cjs",
|
|
38
|
+
"test:puppeteer": "npm run build && node tests/adversarial/puppeteer-test.cjs",
|
|
39
|
+
"test:stress": "npm run build && node tests/adversarial/detector-stress-test.cjs",
|
|
40
|
+
"test:stress:quick": "npm run build && node tests/adversarial/detector-stress-test.cjs --cycles=3 --duration=5000",
|
|
41
|
+
"test:stress:intense": "npm run build && node tests/adversarial/detector-stress-test.cjs --cycles=10 --duration=20000"
|
|
41
42
|
},
|
|
42
43
|
"keywords": [
|
|
43
44
|
"behavior-detection",
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type { ScoreOptions, ScoreResult } from './types';
|
|
2
|
-
import type { DetectionStrategy, StrategyConfig, TickOptions } from './strategy';
|
|
3
|
-
/**
|
|
4
|
-
* Main class for behavior detection
|
|
5
|
-
* Uses modular strategy pattern for tree-shakeable, autonomous detection modules
|
|
6
|
-
*/
|
|
7
|
-
export declare class BehaviorDetector {
|
|
8
|
-
private strategies;
|
|
9
|
-
private isTracking;
|
|
10
|
-
private isPausedByVisibility;
|
|
11
|
-
private tickInterval;
|
|
12
|
-
private tickIntervalMs;
|
|
13
|
-
private pauseOnHidden;
|
|
14
|
-
private visibilityChangeHandler;
|
|
15
|
-
private confidenceScore;
|
|
16
|
-
private readonly CONFIDENCE_TARGET;
|
|
17
|
-
private readonly CONFIDENCE_DECAY;
|
|
18
|
-
constructor(tickOptions?: TickOptions);
|
|
19
|
-
/**
|
|
20
|
-
* Add a detection strategy
|
|
21
|
-
*/
|
|
22
|
-
addStrategy(strategy: DetectionStrategy, weight?: number): this;
|
|
23
|
-
/**
|
|
24
|
-
* Handle event from strategy - update confidence
|
|
25
|
-
*/
|
|
26
|
-
private onStrategyEvent;
|
|
27
|
-
/**
|
|
28
|
-
* Remove a detection strategy
|
|
29
|
-
*/
|
|
30
|
-
removeStrategy(name: string): this;
|
|
31
|
-
/**
|
|
32
|
-
* Enable/disable a strategy
|
|
33
|
-
*/
|
|
34
|
-
setStrategyEnabled(name: string, enabled: boolean): this;
|
|
35
|
-
/**
|
|
36
|
-
* Get all registered strategies
|
|
37
|
-
*/
|
|
38
|
-
getStrategies(): ReadonlyMap<string, StrategyConfig>;
|
|
39
|
-
/**
|
|
40
|
-
* Start tracking
|
|
41
|
-
*/
|
|
42
|
-
start(): void;
|
|
43
|
-
/**
|
|
44
|
-
* Stop tracking
|
|
45
|
-
*/
|
|
46
|
-
stop(): void;
|
|
47
|
-
/**
|
|
48
|
-
* Reset all data
|
|
49
|
-
*/
|
|
50
|
-
reset(): void;
|
|
51
|
-
/**
|
|
52
|
-
* Calculate human likelihood score
|
|
53
|
-
*/
|
|
54
|
-
score(options?: ScoreOptions): Promise<ScoreResult>;
|
|
55
|
-
/**
|
|
56
|
-
* Check if currently tracking
|
|
57
|
-
*/
|
|
58
|
-
isActive(): boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Check if currently paused due to tab visibility
|
|
61
|
-
*/
|
|
62
|
-
isPaused(): boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Get event count from all strategies
|
|
65
|
-
*/
|
|
66
|
-
getEventCount(): Record<string, number>;
|
|
67
|
-
/**
|
|
68
|
-
* Get debug info from all strategies
|
|
69
|
-
*/
|
|
70
|
-
getStrategyDebugInfo(): Record<string, any>;
|
|
71
|
-
/**
|
|
72
|
-
* Get current confidence score (0-1)
|
|
73
|
-
* Represents how much interaction data we've collected
|
|
74
|
-
* Higher confidence = more reliable classification
|
|
75
|
-
*/
|
|
76
|
-
getConfidence(): number;
|
|
77
|
-
/**
|
|
78
|
-
* Check if confidence is above threshold for reliable classification
|
|
79
|
-
* @param threshold - Minimum confidence (0-1), default 0.3
|
|
80
|
-
*/
|
|
81
|
-
hasConfidentData(threshold?: number): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Cleanup resources
|
|
84
|
-
*/
|
|
85
|
-
destroy(): void;
|
|
86
|
-
/**
|
|
87
|
-
* Handle visibility change events
|
|
88
|
-
*/
|
|
89
|
-
private handleVisibilityChange;
|
|
90
|
-
/**
|
|
91
|
-
* Start tick mechanism for strategies
|
|
92
|
-
*/
|
|
93
|
-
private startTick;
|
|
94
|
-
/**
|
|
95
|
-
* Stop tick mechanism
|
|
96
|
-
*/
|
|
97
|
-
private stopTick;
|
|
98
|
-
/**
|
|
99
|
-
* Calculate score using strategies
|
|
100
|
-
*/
|
|
101
|
-
private calculateStrategyScore;
|
|
102
|
-
}
|