@ianmenethil/zp-devicefp 0.1.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # Browser Fingerprint Library
2
+
3
+ Async-first TypeScript browser and device fingerprinting library built from the supplied design brief. It collects a tiered set of browser signals, computes per-component hashes, returns a composite thumbprint, and includes a lightweight anomaly report instead of pretending a client-only fingerprint is unforgeable.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add @ianmenethil/zp-devicefp
9
+ ```
10
+
11
+ ```ts
12
+ import { createFingerprintClient } from '@ianmenethil/zp-devicefp';
13
+ ```
14
+
15
+ ## Package contents
16
+
17
+ ```text
18
+ @ianmenethil/zp-devicefp/
19
+ ├── dist/
20
+ │ ├── npm/
21
+ │ │ ├── index.mjs ← ESM entry (browser, es2022)
22
+ │ │ ├── index.cjs ← CJS entry (Node 22+)
23
+ │ │ └── index.d.ts ← public types
24
+ │ └── cdn/
25
+ │ ├── zp.dfp.js ← IIFE (unminified)
26
+ │ ├── zp.dfp.min.js ← IIFE (minified)
27
+ │ ├── zp.dfp.obf.js ← IIFE (minified + obfuscated)
28
+ │ ├── zp.dfp.esm.js ← ESM for import()
29
+ │ └── zp.dfp.manifest.json ← SRI integrity hashes
30
+ ├── README.md
31
+ ├── LICENSE
32
+ └── docs/
33
+ ```
34
+
35
+ ## CDN
36
+
37
+ CDN files are available from two sources — jsDelivr (automatic from each npm publish) and the self-hosted CDN at `cdn.zenithpayments.support` (deployed on every build).
38
+
39
+ | File | jsDelivr | Self-hosted |
40
+ |------|----------|-------------|
41
+ | IIFE (minified) | `@ianmenethil/zp-devicefp/dist/cdn/zp.dfp.min.js` | `devicefp/latest/zp.dfp.min.js` |
42
+ | IIFE (unminified) | `@ianmenethil/zp-devicefp/dist/cdn/zp.dfp.js` | `devicefp/latest/zp.dfp.js` |
43
+ | IIFE (obfuscated) | `@ianmenethil/zp-devicefp/dist/cdn/zp.dfp.obf.js` | `devicefp/latest/zp.dfp.obf.js` |
44
+ | ESM | `@ianmenethil/zp-devicefp/dist/cdn/zp.dfp.esm.js` | `devicefp/latest/zp.dfp.esm.js` |
45
+ | Manifest | `@ianmenethil/zp-devicefp/dist/cdn/zp.dfp.manifest.json` | `devicefp/latest/zp.dfp.manifest.json` |
46
+
47
+ - **jsDelivr base:** `https://cdn.jsdelivr.net/npm/` — drop the version tag for latest, or pin with `@2.1` or `@2`.
48
+ - **Self-hosted base:** `https://cdn.zenithpayments.support/` — `latest/` always points to the most recent build; versioned folders (`2.1.1/`) are created on `bun run release`.
49
+
50
+ ### CDN usage
51
+
52
+ ```html
53
+ <!-- jsDelivr -->
54
+ <script src="https://cdn.jsdelivr.net/npm/@ianmenethil/zp-devicefp/dist/cdn/zp.dfp.min.js"></script>
55
+
56
+ <!-- Self-hosted -->
57
+ <script src="https://cdn.zenithpayments.support/devicefp/latest/zp.dfp.min.js"></script>
58
+
59
+ <script>
60
+ const client = await window.DeviceFP.createFingerprintClient({ timeoutMs: 1500 });
61
+ const result = await client.collect();
62
+ </script>
63
+ ```
64
+
65
+ ## Public API
66
+
67
+ ```ts
68
+ import { createFingerprintClient } from '@ianmenethil/zp-devicefp';
69
+
70
+ const client = await createFingerprintClient({
71
+ timeoutMs: 1500,
72
+ extended: false,
73
+ });
74
+
75
+ const result = await client.collect();
76
+ console.log(result.thumbprint, result.antiSpoof);
77
+ console.log(result.diagnostics);
78
+ ```
79
+
80
+ `collectSync()` intentionally returns a partial fingerprint that only uses sync-safe collectors.
81
+
82
+ Each result also includes:
83
+
84
+ - `componentHashes`: deterministic per-signal digests
85
+ - `antiSpoof`: anomaly and automation hints
86
+ - `diagnostics`: requested signals, completed signals, and elapsed runtime
87
+ - `warnings`: collection-time warnings that are scoped to that run only
88
+
89
+ ## Signals
90
+
91
+ Core tier:
92
+
93
+ `ua` · `uaHints` · `locale` · `screen` · `hardware` · `storage` · `fonts` · `canvas` · `webgl` · `audio`
94
+
95
+ Extended tier:
96
+
97
+ `mediaDevices` · `permissions` · `webrtc` · `frameInfo` · `networkInfo` · `paymentSupport` · `referrerInfo` · `navigationInfo` · `riskSignals`
98
+
99
+ ## Design choices
100
+
101
+ - Async first: high-value collectors like audio, UA hints, media devices, permissions, and WebRTC run in `collect()`.
102
+ - Explainable output: every signal includes a status and duration.
103
+ - No dangerous defaults: no battery, sensors, arbitrary installed-app probes, or local IP harvesting.
104
+ - Anti-spoofing focuses on coherence checks and automation hints.
105
+ - Upload is backend-neutral and optional.
106
+
107
+ ## Build and test
108
+
109
+ ```bash
110
+ bun install
111
+ bun run build # lint → typecheck → knip → jscpd → tests + coverage → esbuild → CDN deploy
112
+ bun test # 84 tests, 95% line coverage
113
+ bun run smoke # validates all dist artifacts
114
+ ```
115
+
116
+ The build pipeline runs esbuild to produce `dist/npm/` and `dist/cdn/`, then copies CDN files to the local CDN server directory for self-hosting.
117
+
118
+ ## Limitations
119
+
120
+ - Browser-side fingerprints are probabilistic, not identity proofs.
121
+ - The default font probe is intentionally bounded and conservative.
122
+ - The anti-spoof report is heuristic and should be combined with server-side context for real fraud or login-risk decisions.
123
+
124
+ ## Layout
125
+
126
+ ```text
127
+ zp-devicefp/
128
+ ├── src/ # 19 signal collectors, core modules
129
+ ├── tests/ # bun test (unit + integration)
130
+ ├── docs/ # architecture, privacy, testing docs
131
+ ├── .scripts/ # esbuild build pipeline
132
+ ├── scripts/ # smoke tests
133
+ └── dist/ # generated (npm/ + cdn/)
134
+ ```