@npm-pipl/device-intelligence 1.1.1
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 +8 -0
- package/dist/agent.d.ts +77 -0
- package/dist/attributes/collectors/accessibility.d.ts +9 -0
- package/dist/attributes/collectors/audio.d.ts +9 -0
- package/dist/attributes/collectors/browser.d.ts +9 -0
- package/dist/attributes/collectors/fonts.d.ts +9 -0
- package/dist/attributes/collectors/graphics.d.ts +9 -0
- package/dist/attributes/collectors/hardware.d.ts +9 -0
- package/dist/attributes/collectors/index.d.ts +75 -0
- package/dist/attributes/collectors/network.d.ts +9 -0
- package/dist/attributes/collectors/platform.d.ts +9 -0
- package/dist/attributes/collectors/risk.d.ts +9 -0
- package/dist/attributes/collectors/runtime.d.ts +9 -0
- package/dist/attributes/collectors/screen.d.ts +9 -0
- package/dist/attributes/collectors/storage.d.ts +9 -0
- package/dist/attributes/default_collectors.d.ts +99 -0
- package/dist/attributes/engine.d.ts +26 -0
- package/dist/attributes/types.d.ts +61 -0
- package/dist/constants.d.ts +40 -0
- package/dist/device-intelligence.cjs.js +6569 -0
- package/dist/device-intelligence.cjs.js.map +1 -0
- package/dist/device-intelligence.esm.js +6562 -0
- package/dist/device-intelligence.esm.js.map +1 -0
- package/dist/device-intelligence.esm.min.js +7 -0
- package/dist/device-intelligence.esm.min.js.map +1 -0
- package/dist/device-intelligence.js +6574 -0
- package/dist/device-intelligence.js.map +1 -0
- package/dist/device-intelligence.min.js +7 -0
- package/dist/device-intelligence.min.js.map +1 -0
- package/dist/device-intelligence.umd.js +6575 -0
- package/dist/device-intelligence.umd.js.map +1 -0
- package/dist/device-intelligence.umd.min.js +7 -0
- package/dist/device-intelligence.umd.min.js.map +1 -0
- package/dist/encryption.d.ts +28 -0
- package/dist/index.d.ts +80 -0
- package/dist/types.d.ts +171 -0
- package/dist/utils.d.ts +31 -0
- package/package.json +81 -0
package/README.md
ADDED
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Intelligence Agent
|
|
3
|
+
*
|
|
4
|
+
* Manages the lifecycle of attribute collection including:
|
|
5
|
+
* - Collection timing (immediate, onLoad, manual)
|
|
6
|
+
* - State tracking
|
|
7
|
+
* - Attribute caching with TTL
|
|
8
|
+
* - Elephant device caching
|
|
9
|
+
* - Promise-based waiting for collection completion
|
|
10
|
+
*/
|
|
11
|
+
import type { DeviceIntelligenceOptions, UserData, IDeviceIntelligence, DebugInfo } from "./types";
|
|
12
|
+
/**
|
|
13
|
+
* DeviceIntelligenceAgent - manages attribute collection lifecycle
|
|
14
|
+
*/
|
|
15
|
+
export declare class DeviceIntelligenceAgent implements IDeviceIntelligence {
|
|
16
|
+
private options;
|
|
17
|
+
private log;
|
|
18
|
+
private attributeEngine;
|
|
19
|
+
private state;
|
|
20
|
+
private cachedCollection;
|
|
21
|
+
private cachedElephantDevice;
|
|
22
|
+
private collectionAndSendPromise;
|
|
23
|
+
private localElephantDevice;
|
|
24
|
+
private isInitialized;
|
|
25
|
+
private lastSendSucceeded;
|
|
26
|
+
private pendingUserData;
|
|
27
|
+
/**
|
|
28
|
+
* Initialize the agent with options and start collection based on timing configuration.
|
|
29
|
+
* Returns a Promise that resolves with debug info (in debug mode) or null when collection is complete.
|
|
30
|
+
* In debug mode, the Promise rejects on errors; callers can await to catch them.
|
|
31
|
+
*/
|
|
32
|
+
init(options?: DeviceIntelligenceOptions): Promise<DebugInfo | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Add user data and send collected attributes to the server.
|
|
35
|
+
* If collection is in progress, merges user data and waits for it.
|
|
36
|
+
* Returns debug info in debug mode, null otherwise.
|
|
37
|
+
*/
|
|
38
|
+
addUserData(userData?: UserData): Promise<DebugInfo | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the elephant device issued by the server (public identifier).
|
|
41
|
+
* This is not the internal local identifier used in payloads.
|
|
42
|
+
*/
|
|
43
|
+
getElephantDevice(): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Get debug information including collected attributes.
|
|
46
|
+
* Only available when debug mode is enabled.
|
|
47
|
+
*/
|
|
48
|
+
private getDebugInfo;
|
|
49
|
+
/**
|
|
50
|
+
* Collect attributes and send to server with optional user data.
|
|
51
|
+
* This is the main unified function used by both init() and addUserData().
|
|
52
|
+
* Returns debug info in debug mode, null otherwise.
|
|
53
|
+
*/
|
|
54
|
+
collectAndSend(userData?: UserData): Promise<DebugInfo | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Check if the cached collection is still valid
|
|
57
|
+
*/
|
|
58
|
+
private isCacheValid;
|
|
59
|
+
/**
|
|
60
|
+
* Collect device attributes and cache them.
|
|
61
|
+
*/
|
|
62
|
+
private collectAttributes;
|
|
63
|
+
/**
|
|
64
|
+
* Build payload and send to server
|
|
65
|
+
* @param userData - Optional user data to include
|
|
66
|
+
*/
|
|
67
|
+
private buildAndSendPayload;
|
|
68
|
+
/**
|
|
69
|
+
* Convert attribute results to DeviceAttributes format
|
|
70
|
+
*/
|
|
71
|
+
private toAttributes;
|
|
72
|
+
/**
|
|
73
|
+
* Send payload to server (with encryption when supported)
|
|
74
|
+
* Returns true if send was successful, false otherwise.
|
|
75
|
+
*/
|
|
76
|
+
private sendToServer;
|
|
77
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessibility Collectors
|
|
3
|
+
*
|
|
4
|
+
* User preferences: Contrast, Motion, Dark Mode.
|
|
5
|
+
* Explicitly groups user-defined settings vs. hardware capabilities.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { AttributeCollector } from "../types";
|
|
9
|
+
export declare const accessibilityCollectors: AttributeCollector[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audio Collectors
|
|
3
|
+
*
|
|
4
|
+
* Audio hardware and processing (AudioContext).
|
|
5
|
+
* High-entropy fingerprints from audio processing differences.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { AttributeCollector } from "../types";
|
|
9
|
+
export declare const audioCollectors: AttributeCollector[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser Collectors
|
|
3
|
+
*
|
|
4
|
+
* Software features: Plugins, MimeTypes, PDF Viewer, Codecs.
|
|
5
|
+
* Captures the browser software configuration rather than the device.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { AttributeCollector } from "../types";
|
|
9
|
+
export declare const browserCollectors: AttributeCollector[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graphics Collectors
|
|
3
|
+
*
|
|
4
|
+
* All rendering capabilities: Canvas, WebGL, GPU, SVG.
|
|
5
|
+
* These provide the highest uniqueness for device fingerprinting.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { AttributeCollector } from "../types";
|
|
9
|
+
export declare const graphicsCollectors: AttributeCollector[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hardware Collectors
|
|
3
|
+
*
|
|
4
|
+
* Physical device specs: CPU cores, Memory, Battery, Touch, Sensors.
|
|
5
|
+
* Distinct from "OS" or "Platform"; describes the silicon.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { AttributeCollector } from "../types";
|
|
9
|
+
export declare const hardwareCollectors: AttributeCollector[];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attribute Collectors Index
|
|
3
|
+
*
|
|
4
|
+
* This file re-exports all collector arrays from the category-specific files.
|
|
5
|
+
* Collectors are organized into 12 categories based on the new standard:
|
|
6
|
+
*
|
|
7
|
+
* 1. Graphics (20 attrs): Canvas, WebGL, GPU, SVG rendering
|
|
8
|
+
* 2. Audio (4 attrs): AudioContext and audio hardware
|
|
9
|
+
* 3. Screen (13 attrs): Display properties (resolution, color depth, HDR)
|
|
10
|
+
* 4. Hardware (12 attrs): Physical device specs (CPU, memory, battery, sensors)
|
|
11
|
+
* 5. Platform (18 attrs): OS and navigator identity (UA, locale, timezone)
|
|
12
|
+
* 6. Runtime (10 attrs): JS engine quirks (math, workers, stack limits)
|
|
13
|
+
* 7. Fonts (9 attrs): Font enumeration and metrics
|
|
14
|
+
* 8. Browser (26 attrs): Software features (plugins, codecs, permissions)
|
|
15
|
+
* 9. Network (2 attrs): Connectivity (WebRTC, connection type)
|
|
16
|
+
* 10. Storage (3 attrs): Persistence capabilities (cookies, IndexedDB)
|
|
17
|
+
* 11. Accessibility (9 attrs): User preferences (contrast, motion, dark mode)
|
|
18
|
+
* 12. Risk (5 attrs): Bot detection, debugger, tampering
|
|
19
|
+
*
|
|
20
|
+
* Total: 131+ attributes
|
|
21
|
+
*
|
|
22
|
+
* Usage:
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { getAllCollectors } from './collectors';
|
|
25
|
+
*
|
|
26
|
+
* const collectors = getAllCollectors();
|
|
27
|
+
* // Or import specific categories:
|
|
28
|
+
* import { graphicsCollectors } from './collectors/graphics';
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
import type { AttributeCollector } from "../types";
|
|
32
|
+
export { graphicsCollectors } from "./graphics";
|
|
33
|
+
export { audioCollectors } from "./audio";
|
|
34
|
+
export { screenCollectors } from "./screen";
|
|
35
|
+
export { hardwareCollectors } from "./hardware";
|
|
36
|
+
export { platformCollectors } from "./platform";
|
|
37
|
+
export { runtimeCollectors } from "./runtime";
|
|
38
|
+
export { fontsCollectors } from "./fonts";
|
|
39
|
+
export { browserCollectors } from "./browser";
|
|
40
|
+
export { networkCollectors } from "./network";
|
|
41
|
+
export { storageCollectors } from "./storage";
|
|
42
|
+
export { accessibilityCollectors } from "./accessibility";
|
|
43
|
+
export { riskCollectors } from "./risk";
|
|
44
|
+
/**
|
|
45
|
+
* Map of category names to their collector arrays.
|
|
46
|
+
*/
|
|
47
|
+
export declare const collectorsByCategory: Record<string, AttributeCollector[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Returns all collectors combined in optimal collection order:
|
|
50
|
+
* - Synchronous high-entropy collectors first (graphics, fonts)
|
|
51
|
+
* - Platform and hardware next
|
|
52
|
+
* - Browser features
|
|
53
|
+
* - Async operations last (audio, network, storage persistence)
|
|
54
|
+
*
|
|
55
|
+
* @returns Array of all attribute collectors
|
|
56
|
+
*/
|
|
57
|
+
export declare function getAllCollectors(): AttributeCollector[];
|
|
58
|
+
/**
|
|
59
|
+
* Returns collectors for a specific category.
|
|
60
|
+
*
|
|
61
|
+
* @param category - One of: graphics, audio, screen, hardware, platform, runtime, fonts, browser, network, storage, accessibility, risk
|
|
62
|
+
* @returns Array of collectors for that category
|
|
63
|
+
*/
|
|
64
|
+
export declare function getCollectorsByCategory(category: string): AttributeCollector[];
|
|
65
|
+
/**
|
|
66
|
+
* Returns statistics about collectors.
|
|
67
|
+
*
|
|
68
|
+
* @returns Object with counts per category and total
|
|
69
|
+
*/
|
|
70
|
+
export declare function getCollectorStats(): Record<string, number>;
|
|
71
|
+
/**
|
|
72
|
+
* List of all category names.
|
|
73
|
+
*/
|
|
74
|
+
export declare const categoryNames: readonly ["graphics", "audio", "screen", "hardware", "platform", "runtime", "fonts", "browser", "network", "storage", "accessibility", "risk"];
|
|
75
|
+
export type CategoryName = (typeof categoryNames)[number];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Collectors
|
|
3
|
+
*
|
|
4
|
+
* Connectivity: WebRTC IPs, Connection Type.
|
|
5
|
+
* Aligns with Network Information API and WebRTC leakage.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { AttributeCollector } from "../types";
|
|
9
|
+
export declare const networkCollectors: AttributeCollector[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Collectors
|
|
3
|
+
*
|
|
4
|
+
* The OS and Navigator identity: UA, Platform, Architecture, Locale.
|
|
5
|
+
* "Platform" is the standard term for OS/UA-CH.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { AttributeCollector } from "../types";
|
|
9
|
+
export declare const platformCollectors: AttributeCollector[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Risk Collectors
|
|
3
|
+
*
|
|
4
|
+
* Heuristics: Bot detection, Debugger, Tampering.
|
|
5
|
+
* Clearly labels signals that are inferred (like "is_bot") rather than read.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { AttributeCollector } from "../types";
|
|
9
|
+
export declare const riskCollectors: AttributeCollector[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Collectors
|
|
3
|
+
*
|
|
4
|
+
* JS Engine quirks: Math primitives, Worker diffs, Stack limits.
|
|
5
|
+
* Groups floating-point math and JS execution limits.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { AttributeCollector } from "../types";
|
|
9
|
+
export declare const runtimeCollectors: AttributeCollector[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Screen Collectors
|
|
3
|
+
*
|
|
4
|
+
* Physical display properties: Resolution, Color Depth, HDR.
|
|
5
|
+
* Matches the standard DOM window.screen API interface.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { AttributeCollector } from "../types";
|
|
9
|
+
export declare const screenCollectors: AttributeCollector[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Collectors
|
|
3
|
+
*
|
|
4
|
+
* Persistence capabilities: Cookies, IndexedDB, LocalStorage.
|
|
5
|
+
* Matches the Storage Manager API family.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { AttributeCollector } from "../types";
|
|
9
|
+
export declare const storageCollectors: AttributeCollector[];
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Collectors
|
|
3
|
+
*
|
|
4
|
+
* This module provides the default set of attribute collectors shipped with the SDK.
|
|
5
|
+
*
|
|
6
|
+
* The collectors are organized into 12 categories:
|
|
7
|
+
*
|
|
8
|
+
* 1. Graphics - Canvas, WebGL, GPU, SVG rendering (highest entropy)
|
|
9
|
+
* 2. Audio - AudioContext and audio hardware
|
|
10
|
+
* 3. Screen - Display properties (resolution, color depth, HDR)
|
|
11
|
+
* 4. Hardware - Physical device specs (CPU, memory, battery, sensors)
|
|
12
|
+
* 5. Platform - OS and navigator identity (UA, locale, timezone)
|
|
13
|
+
* 6. Runtime - JS engine quirks (math, workers, stack limits)
|
|
14
|
+
* 7. Fonts - Font enumeration and metrics (high entropy)
|
|
15
|
+
* 8. Browser - Software features (plugins, codecs, permissions)
|
|
16
|
+
* 9. Network - Connectivity (WebRTC, connection type)
|
|
17
|
+
* 10. Storage - Persistence capabilities (cookies, IndexedDB)
|
|
18
|
+
* 11. Accessibility - User preferences (contrast, motion, dark mode)
|
|
19
|
+
* 12. Risk - Bot detection, debugger, tampering
|
|
20
|
+
*
|
|
21
|
+
* Total: 131+ unique attributes
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
import type { AttributeCollector } from "./types";
|
|
25
|
+
import { getCollectorsByCategory, getCollectorStats, categoryNames, type CategoryName } from "./collectors";
|
|
26
|
+
/**
|
|
27
|
+
* Default collectors shipped in the SDK.
|
|
28
|
+
*
|
|
29
|
+
* This returns all 131+ collectors organized by category and optimized
|
|
30
|
+
* for collection order (high-entropy synchronous signals first,
|
|
31
|
+
* async operations last).
|
|
32
|
+
*/
|
|
33
|
+
export declare function getDefaultCollectors(): AttributeCollector[];
|
|
34
|
+
/**
|
|
35
|
+
* Get a minimal set of fast collectors (no async operations).
|
|
36
|
+
*
|
|
37
|
+
* Useful for scenarios where speed is critical and async operations
|
|
38
|
+
* (audio fingerprint, WebRTC, permissions) are not needed.
|
|
39
|
+
*
|
|
40
|
+
* Excludes:
|
|
41
|
+
* - Audio fingerprint (async, ~50-100ms)
|
|
42
|
+
* - WebRTC IP handling (async, network dependent)
|
|
43
|
+
* - Permissions state (async)
|
|
44
|
+
* - Speech synthesis (async)
|
|
45
|
+
* - User agent data high entropy (async)
|
|
46
|
+
* - Battery status (async)
|
|
47
|
+
* - CPU architecture (async via userAgentData)
|
|
48
|
+
* - Worker differences (async)
|
|
49
|
+
* - Storage persistence (async)
|
|
50
|
+
* - Media devices (async)
|
|
51
|
+
* - Keyboard layout map (async)
|
|
52
|
+
* - Subtle crypto support (async)
|
|
53
|
+
* - DRM support (async)
|
|
54
|
+
* - Incognito mode (async)
|
|
55
|
+
*/
|
|
56
|
+
export declare function getFastCollectors(): AttributeCollector[];
|
|
57
|
+
/**
|
|
58
|
+
* Get critical-only collectors (highest entropy signals).
|
|
59
|
+
*
|
|
60
|
+
* Useful for lightweight fingerprinting where only the most
|
|
61
|
+
* distinguishing signals are needed.
|
|
62
|
+
*
|
|
63
|
+
* Includes:
|
|
64
|
+
* - Canvas fingerprint
|
|
65
|
+
* - WebGL fingerprint
|
|
66
|
+
* - Audio fingerprint
|
|
67
|
+
* - GPU vendor/renderer
|
|
68
|
+
* - Screen resolution
|
|
69
|
+
* - Installed fonts
|
|
70
|
+
* - User agent
|
|
71
|
+
* - Platform
|
|
72
|
+
* - Timezone
|
|
73
|
+
* - Math fingerprint
|
|
74
|
+
* - Automation detection
|
|
75
|
+
* - Hardware concurrency
|
|
76
|
+
* - Device memory
|
|
77
|
+
*/
|
|
78
|
+
export declare function getCriticalCollectors(): AttributeCollector[];
|
|
79
|
+
/**
|
|
80
|
+
* Get collectors for a specific category.
|
|
81
|
+
*
|
|
82
|
+
* @param category - One of: graphics, audio, screen, hardware, platform, runtime, fonts, browser, network, storage, accessibility, risk
|
|
83
|
+
* @returns Array of collectors for that category
|
|
84
|
+
*/
|
|
85
|
+
export { getCollectorsByCategory };
|
|
86
|
+
/**
|
|
87
|
+
* Get collector statistics by category.
|
|
88
|
+
*
|
|
89
|
+
* @returns Object with counts per category and total
|
|
90
|
+
*/
|
|
91
|
+
export { getCollectorStats };
|
|
92
|
+
/**
|
|
93
|
+
* List of all available category names.
|
|
94
|
+
*/
|
|
95
|
+
export { categoryNames };
|
|
96
|
+
/**
|
|
97
|
+
* Type for category names.
|
|
98
|
+
*/
|
|
99
|
+
export type { CategoryName };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AttributeCollector, AttributeResult } from "./types";
|
|
2
|
+
type EngineOptions = {
|
|
3
|
+
collectors: AttributeCollector[];
|
|
4
|
+
debug: boolean;
|
|
5
|
+
log: (...args: unknown[]) => void;
|
|
6
|
+
/** Optional limit for concurrent collectors (useful for heavy attributes) */
|
|
7
|
+
concurrency?: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* AttributeEngine
|
|
11
|
+
*
|
|
12
|
+
* Executes a list of attribute collectors with per-collector error isolation,
|
|
13
|
+
* caching, timeouts, and optional concurrency limiting.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AttributeEngine {
|
|
16
|
+
private readonly collectors;
|
|
17
|
+
private readonly ctx;
|
|
18
|
+
private readonly concurrency;
|
|
19
|
+
private readonly collectorKeys;
|
|
20
|
+
constructor(opts: EngineOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Collect all attributes and return results (including per-attribute errors).
|
|
23
|
+
*/
|
|
24
|
+
collectAll(parentSignal?: AbortSignal): Promise<AttributeResult[]>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attribute collection (internal) types.
|
|
3
|
+
*
|
|
4
|
+
* We use the term "attributes" (not signals) across the SDK.
|
|
5
|
+
*/
|
|
6
|
+
export type AttributeStatus = "ok" | "error" | "skipped";
|
|
7
|
+
export type AttributeError = {
|
|
8
|
+
name: string;
|
|
9
|
+
message: string;
|
|
10
|
+
retryable?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type AttributeResult<T = unknown> = {
|
|
13
|
+
/** Attribute classification (e.g. "graphics", "audio", "screen", "hardware", "platform", "runtime", "fonts", "browser", "network", "storage", "accessibility", "risk") */
|
|
14
|
+
category: string;
|
|
15
|
+
key: string;
|
|
16
|
+
version: number;
|
|
17
|
+
status: AttributeStatus;
|
|
18
|
+
value?: T;
|
|
19
|
+
error?: AttributeError;
|
|
20
|
+
durationMs: number;
|
|
21
|
+
};
|
|
22
|
+
export type AttributeContext = {
|
|
23
|
+
debug: boolean;
|
|
24
|
+
log: (...args: unknown[]) => void;
|
|
25
|
+
now: () => number;
|
|
26
|
+
cache: Map<string, {
|
|
27
|
+
expiresAt: number;
|
|
28
|
+
value: unknown;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
export interface AttributeCollector<T = unknown> {
|
|
32
|
+
/**
|
|
33
|
+
* Attribute classification. One of:
|
|
34
|
+
* - graphics: Canvas, WebGL, GPU, SVG rendering
|
|
35
|
+
* - audio: AudioContext and audio hardware
|
|
36
|
+
* - screen: Display properties (resolution, color depth, HDR)
|
|
37
|
+
* - hardware: Physical device specs (CPU, memory, battery, touch, sensors)
|
|
38
|
+
* - platform: OS and navigator identity (UA, locale, timezone)
|
|
39
|
+
* - runtime: JS engine quirks (math, workers, stack limits)
|
|
40
|
+
* - fonts: Font enumeration and metrics
|
|
41
|
+
* - browser: Software features (plugins, codecs, permissions)
|
|
42
|
+
* - network: Connectivity (WebRTC, connection type)
|
|
43
|
+
* - storage: Persistence (cookies, IndexedDB, localStorage)
|
|
44
|
+
* - accessibility: User preferences (contrast, motion, dark mode)
|
|
45
|
+
* - risk: Heuristics (bot detection, debugger, tampering)
|
|
46
|
+
*
|
|
47
|
+
* Optional: defaults to "browser".
|
|
48
|
+
*/
|
|
49
|
+
category?: string;
|
|
50
|
+
/** Key (must be unique across collectors if you want a flat attributes map) */
|
|
51
|
+
key: string;
|
|
52
|
+
/** Bump when logic changes materially */
|
|
53
|
+
version: number;
|
|
54
|
+
/** If false, engine will mark as skipped (no error) */
|
|
55
|
+
isSupported?: (ctx: AttributeContext) => boolean;
|
|
56
|
+
/** Per-collector timeout cap (ms) */
|
|
57
|
+
timeoutMs?: number;
|
|
58
|
+
/** Cache within a page/session for this long (ms) */
|
|
59
|
+
cacheTtlMs?: number;
|
|
60
|
+
collect: (ctx: AttributeContext, signal: AbortSignal) => Promise<T> | T;
|
|
61
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Intelligence SDK Constants
|
|
3
|
+
*/
|
|
4
|
+
import type { ResolvedOptions } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Schema version for payload format
|
|
7
|
+
*/
|
|
8
|
+
export declare const SCHEMA_VERSION = 1;
|
|
9
|
+
/**
|
|
10
|
+
* SDK type identifier
|
|
11
|
+
*/
|
|
12
|
+
export declare const SDK_TYPE = "web";
|
|
13
|
+
/**
|
|
14
|
+
* RSA Public Key for payload encryption (PEM format)
|
|
15
|
+
* Private key is stored on server only
|
|
16
|
+
*/
|
|
17
|
+
export declare const RSA_PUBLIC_KEY_PEM = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1DV8em/rKKXLkNE+5uKK\nHRb8nt46DaQrHrzK1GAi2ZcPQQHPT/Iiy/TCI3HCGGXeSl8/ZFHlT9Xuc+g4Wuce\njE5mNAHwJrbUqZgJKSfkK0KwbTz84U0Bic3HWpjW7E2I+cEbdjnGuQfI8ZNqw19g\ns7Zo6xVYArdd57nbInF7dh/kRVnYxmbqtpt3SpyqtaBPouLDsSTkjHefXKBA0uNM\nU7ix5OlOHFsUGTjsbWoQbiMRDrcozp1KtVJN7n0d095gJW+bsBSBMd3/LMIbVPox\nrfokGe0h+6z0RLxSSu3178r8Cug01xz9D4pXWpugTJvJNN4boMeOV5rItLdqyNq0\nZwIDAQAB\n-----END PUBLIC KEY-----";
|
|
18
|
+
/**
|
|
19
|
+
* Local storage keys
|
|
20
|
+
*/
|
|
21
|
+
export declare const STORAGE_KEYS: {
|
|
22
|
+
/** localStorage key for persistent local client id (matches CollectPayload.local_elephant_device) */
|
|
23
|
+
readonly LOCAL_ELEPHANT_DEVICE: "local_elephant_device";
|
|
24
|
+
/** localStorage key for server-issued elephant device */
|
|
25
|
+
readonly ELEPHANT_DEVICE: "elephant_device";
|
|
26
|
+
readonly SENT_PAYLOADS: "sent_payloads";
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Default attribute cache TTL (5 minutes)
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_ATTRIBUTE_CACHE_TTL: number;
|
|
32
|
+
/**
|
|
33
|
+
* Default minimum send interval (5 hours)
|
|
34
|
+
* Prevents sending identical payloads more often than this
|
|
35
|
+
*/
|
|
36
|
+
export declare const DEFAULT_MIN_SEND_INTERVAL: number;
|
|
37
|
+
/**
|
|
38
|
+
* Default configuration options
|
|
39
|
+
*/
|
|
40
|
+
export declare const DEFAULT_OPTIONS: ResolvedOptions;
|