@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 +21 -0
- package/README.md +134 -0
- package/dist/cdn/zp.dfp.esm.js +1449 -0
- package/dist/cdn/zp.dfp.js +1453 -0
- package/dist/cdn/zp.dfp.manifest.json +34 -0
- package/dist/cdn/zp.dfp.min.js +1 -0
- package/dist/cdn/zp.dfp.obf.js +1 -0
- package/dist/npm/index.cjs +1478 -0
- package/dist/npm/index.d.ts +101 -0
- package/dist/npm/index.mjs +1449 -0
- package/docs/architecture.md +40 -0
- package/docs/privacy.md +20 -0
- package/docs/testing.md +32 -0
- package/package.json +75 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
## High-level flow
|
|
4
|
+
|
|
5
|
+
1. Resolve the active signal set from `CollectOptions`.
|
|
6
|
+
2. Run each collector with per-signal timing and timeout handling.
|
|
7
|
+
3. Canonicalize each successful value into stable JSON.
|
|
8
|
+
4. Hash each component with SHA-256.
|
|
9
|
+
5. Derive a composite thumbprint from the ordered component hashes.
|
|
10
|
+
6. Generate an anti-spoof report from cross-signal consistency checks.
|
|
11
|
+
7. Compute a local confidence score from signal quality and anomaly penalties.
|
|
12
|
+
|
|
13
|
+
## Module map
|
|
14
|
+
|
|
15
|
+
- `src/client.ts`: public client factory and orchestration
|
|
16
|
+
- `src/signals/*.ts`: one module per signal collector
|
|
17
|
+
- `src/core/canonicalize.ts`: deterministic serialization
|
|
18
|
+
- `src/core/hash.ts`: zero-dependency SHA-256 implementation
|
|
19
|
+
- `src/core/antiSpoof.ts`: anomaly and automation heuristics
|
|
20
|
+
- `src/core/confidence.ts`: local signal-quality scoring
|
|
21
|
+
- `src/core/upload.ts`: optional backend-neutral upload helper
|
|
22
|
+
- `src/runtime/browser.ts`: runtime feature access
|
|
23
|
+
|
|
24
|
+
## Signal tiers
|
|
25
|
+
|
|
26
|
+
The package splits collectors into:
|
|
27
|
+
|
|
28
|
+
- Core: safe defaults that avoid permission prompts and still provide broad browser/device context.
|
|
29
|
+
- Extended: slower or more privacy-sensitive capability probes such as permissions, media-device counts, and WebRTC codec signatures.
|
|
30
|
+
|
|
31
|
+
## Anti-spoof strategy
|
|
32
|
+
|
|
33
|
+
The library does not use “secret” client tricks. It scores coherence:
|
|
34
|
+
|
|
35
|
+
- user-agent vs platform contradictions
|
|
36
|
+
- headless or webdriver hints
|
|
37
|
+
- mobile user-agent with implausibly desktop geometry
|
|
38
|
+
- obviously implausible hardware values
|
|
39
|
+
|
|
40
|
+
This report is meant to enrich downstream server-side risk logic, not replace it.
|
package/docs/privacy.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Privacy Notes
|
|
2
|
+
|
|
3
|
+
This implementation follows the brief's privacy-by-design direction:
|
|
4
|
+
|
|
5
|
+
- The default collector avoids permission prompts.
|
|
6
|
+
- It does not attempt raw local IP discovery.
|
|
7
|
+
- It does not probe battery state, arbitrary sensors, or installed apps.
|
|
8
|
+
- Media devices are summarized by counts and kinds only.
|
|
9
|
+
- WebRTC collection uses capability signatures derived from SDP, not network-address harvesting.
|
|
10
|
+
|
|
11
|
+
## Recommended operational posture
|
|
12
|
+
|
|
13
|
+
- Treat the output as pseudonymous device intelligence, not anonymous data.
|
|
14
|
+
- Retain raw signal payloads for a shorter window than derived hashes or risk scores.
|
|
15
|
+
- Scope identifiers per product or tenant if cross-context correlation is not required.
|
|
16
|
+
- Provide notice and an account- or tenant-level suppression path where appropriate.
|
|
17
|
+
|
|
18
|
+
## Jurisdiction reminder
|
|
19
|
+
|
|
20
|
+
The code can support legitimate security and fraud-prevention use cases, but the legal position still depends on purpose, notice, retention, and jurisdiction. The bundle is intentionally structured so upload is optional and backend handling can enforce local policy.
|
package/docs/testing.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Testing
|
|
2
|
+
|
|
3
|
+
The project uses Node 24's built-in TypeScript execution and test runner.
|
|
4
|
+
|
|
5
|
+
## Coverage intent
|
|
6
|
+
|
|
7
|
+
The included tests focus on:
|
|
8
|
+
|
|
9
|
+
- deterministic canonicalization
|
|
10
|
+
- stable hashing
|
|
11
|
+
- anomaly scoring
|
|
12
|
+
- storage and WebRTC collector behavior
|
|
13
|
+
- audio and media-device collector behavior
|
|
14
|
+
- client sync collection
|
|
15
|
+
- parallel async collection
|
|
16
|
+
- abort and timeout paths
|
|
17
|
+
- warning isolation between runs
|
|
18
|
+
- upload plumbing
|
|
19
|
+
- built-artifact smoke loading
|
|
20
|
+
|
|
21
|
+
## Run locally
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
node --test ./tests/**/*.test.ts
|
|
25
|
+
node ./scripts/build.mjs
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Suggested next expansion
|
|
29
|
+
|
|
30
|
+
- Add browser-matrix tests in Playwright for Chromium, Firefox, and WebKit.
|
|
31
|
+
- Add snapshot tests for collector outputs in privacy-hardened environments.
|
|
32
|
+
- Add server-side reconciliation tests once an API consumer is introduced.
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ianmenethil/zp-devicefp",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "Async-first browser and device fingerprinting library with explainable signals and anomaly scoring.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/npm/index.cjs",
|
|
7
|
+
"module": "./dist/npm/index.mjs",
|
|
8
|
+
"types": "./dist/npm/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/npm/index.d.ts",
|
|
13
|
+
"import": "./dist/npm/index.mjs",
|
|
14
|
+
"require": "./dist/npm/index.cjs",
|
|
15
|
+
"default": "./dist/npm/index.mjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"docs"
|
|
23
|
+
],
|
|
24
|
+
"packageManager": "bun@1.3.9",
|
|
25
|
+
"engines": {
|
|
26
|
+
"bun": ">=1.3.0",
|
|
27
|
+
"node": ">=22"
|
|
28
|
+
},
|
|
29
|
+
"prepublishOnly": "bun run build",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "bun run check && bun run test:coverage && bun -e \"await import('./.scripts/build.ts')\"",
|
|
32
|
+
"test": "bun test",
|
|
33
|
+
"test:coverage": "bun test --coverage",
|
|
34
|
+
"release": "sh -c 'V=$(npm version \"${1:-minor}\" -m \"chore: release %s\" | tail -1 | sed s/v//) && bun publish --access public && mkdir -p \"F:/_ZP-Main/apps/CDN-server/public/devicefp/$V\" && cp -r dist/cdn/* \"F:/_ZP-Main/apps/CDN-server/public/devicefp/$V/\" && mkdir -p \"F:/_ZP-Main/apps/CDN-server/public/devicefp/latest\" && cp -r dist/cdn/* \"F:/_ZP-Main/apps/CDN-server/public/devicefp/latest/\" && git push --follow-tags' --",
|
|
35
|
+
"smoke": "bun run scripts/smoke.mjs",
|
|
36
|
+
"check": "bun run lint && bun run typecheck && bun run knip && bun run jscpd",
|
|
37
|
+
"lint": "eslint . --config eslint.config.js",
|
|
38
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
39
|
+
"knip": "knip --config knip.json",
|
|
40
|
+
"jscpd": "jscpd --config .jscpd.json",
|
|
41
|
+
"format": "prettier --write .",
|
|
42
|
+
"format:check": "prettier --check ."
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"browser",
|
|
46
|
+
"device",
|
|
47
|
+
"fingerprint",
|
|
48
|
+
"typescript",
|
|
49
|
+
"fraud",
|
|
50
|
+
"risk"
|
|
51
|
+
],
|
|
52
|
+
"author": "Ian / Zenith Payments",
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"homepage": "https://github.com/ianmenethil/zp-devicefp#readme",
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "git+https://github.com/ianmenethil/zp-devicefp.git"
|
|
58
|
+
},
|
|
59
|
+
"bugs": {
|
|
60
|
+
"url": "https://github.com/ianmenethil/zp-devicefp/issues"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@eslint/js": "^10.0.1",
|
|
64
|
+
"esbuild": "^0.28.0",
|
|
65
|
+
"eslint": "^10.3.0",
|
|
66
|
+
"eslint-plugin-tsdoc": "^0.5.2",
|
|
67
|
+
"javascript-obfuscator": "^5.4.2",
|
|
68
|
+
"jscpd": "^4.1.1",
|
|
69
|
+
"knip": "^6.13.1",
|
|
70
|
+
"lefthook": "^2.1.6",
|
|
71
|
+
"prettier": "^3.8.3",
|
|
72
|
+
"typescript": "~6.0.3",
|
|
73
|
+
"typescript-eslint": "^8.59.3"
|
|
74
|
+
}
|
|
75
|
+
}
|