Lorenzo-Coslado/fingerprinter-js
GitHub: Lorenzo-Coslado/fingerprinter-js
轻量级 TypeScript 浏览器指纹库,提供稳定设备识别和 Bot 检测能力。
Stars: 97 | Forks: 3
# FingerprinterJS v2.0
🔐 **企业级浏览器指纹识别**,包含 19 个采集器、高级 Bot 检测和稳定哈希算法。
[](https://www.npmjs.com/package/fingerprinter-js)
[](https://www.npmjs.com/package/fingerprinter-js)
[](https://opensource.org/licenses/MIT)
[在线演示](https://lorenzo-coslado.github.io/fingerprinter-js) • [NPM 包](https://www.npmjs.com/package/fingerprinter-js)
## ✨ 功能特性
- **19 个采集器** - 全面的浏览器数据采集
- **稳定哈希** - 仅使用稳定数据生成指纹哈希
- **Bot 检测** - 检测 Puppeteer、Playwright、Selenium 和无头浏览器
- **TypeScript** - 完整的类型安全
- **零依赖** - 轻量级(~15KB gzipped)
- **并行采集** - 快速的数据收集
## 📦 安装
```
npm install fingerprinter-js
```
## 🚀 快速开始
```
import { Fingerprint } from "fingerprinter-js";
const result = await Fingerprint.generate({
includeSuspectAnalysis: true
});
console.log(result.fingerprint); // "a1b2c3d4..."
console.log(result.confidence); // 100
console.log(result.entropy); // 85
console.log(result.suspectAnalysis?.riskLevel); // "LOW"
```
## 📊 结果结构
```
interface FingerprintResult {
fingerprint: string; // SHA-256 hash (stable collectors only)
components: Record; // All collected data
confidence: number; // 0-100%
entropy: number; // Bits of entropy
duration: number; // Generation time (ms)
version: string; // "2.0.0"
suspectAnalysis?: {
score: number; // 0-100 (higher = more suspicious)
riskLevel: "LOW" | "MEDIUM" | "HIGH";
signals: SuspectSignal[];
};
}
```
## 🎯 采集器
### 稳定采集器(包含在哈希中)
| 采集器 | 描述 | 熵值 |
|-----------|-------------|---------|
| `userAgent` | 浏览器 User-Agent | ~8 bits |
| `language` | 首选语言 | ~3 bits |
| `timezone` | 时区偏移与名称 | ~4 bits |
| `screen` | 分辨率、颜色深度 | ~6 bits |
| `plugins` | 已安装的插件 | ~5 bits |
| `canvas` | 2D Canvas 指纹 | ~10 bits |
| `webgl` | GPU 供应商与渲染器 | ~9 bits |
| `fonts` | 可用的系统字体 | ~8 bits |
| `hardware` | CPU 核心数、内存、平台 | ~5 bits |
| `clientHints` | UA Client Hints API | ~7 bits |
| `storage` | Storage API 可用性 | ~4 bits |
| `touch` | 触控能力 | ~4 bits |
| `math` | 数学精度值 | ~2 bits |
| `mediaDevices` | 摄像头/麦克风数量 | ~5 bits |
### 不稳定采集器(收集数据但**不**计入哈希)
| 采集器 | 描述 | 不稳定原因 |
|-----------|-------------|--------------|
| `webrtc` | 本地 IP、SDP | IP 可能变更 |
| `battery` | 电池电量与充电状态 | 数值波动 |
| `connection` | 网络类型与速度 | 变量变化 |
| `permissions` | 权限状态 | 用户可更改 |
| `audio` | 音频处理指纹 | 首次运行时变化 |
## 🛡️ Bot 检测
```
const result = await Fingerprint.generate({
includeSuspectAnalysis: true
});
if (result.suspectAnalysis?.riskLevel === "HIGH") {
console.log("Bot detected:", result.suspectAnalysis.signals);
}
```
### 检测能力
- **自动化工具**:Puppeteer、Playwright、Selenium、PhantomJS
- **无头浏览器**:HeadlessChrome、CDP 痕迹
- **不一致性**:UA/平台不匹配、硬件异常
- **隐私工具**:Canvas 噪声、属性篡改
- **已知爬虫**:Googlebot、Bingbot、Crawlers
## 🔧 配置选项
```
const result = await Fingerprint.generate({
// Exclude specific collectors
excludeCanvas: false,
excludeWebGL: false,
excludeAudio: false,
excludeFonts: false,
excludeWebRTC: false,
excludeHardware: false,
excludeClientHints: false,
excludeStorage: false,
excludeBattery: false,
excludeConnection: false,
excludeTouch: false,
excludePermissions: false,
excludeMath: false,
excludeMediaDevices: false,
// Bot detection
includeSuspectAnalysis: true,
// Custom data (optional)
customData: {
userId: "12345"
},
// Allow unstable custom data
allowUnstableData: false,
// Timeout per collector (ms)
timeout: 5000
});
```
## 📱 浏览器支持
| 浏览器 | 版本 |
|---------|---------|
| Chrome | 60+ |
| Firefox | 55+ |
| Safari | 12+ |
| Edge | 79+ |
## 🔄 稳定性保证
指纹哈希**在页面重新加载时保持稳定**,因为:
1. 只有**稳定采集器**参与哈希计算
2. 时间值(时间戳、UUID)会自动从自定义数据中过滤
3. 不稳定的平台数据(电池电量、网络速度)会被收集但排除在哈希之外
```
// This will produce the same hash every time
const result1 = await Fingerprint.generate();
const result2 = await Fingerprint.generate();
console.log(result1.fingerprint === result2.fingerprint); // true
```
## 🧩 单独采集器
```
import {
CanvasCollector,
WebGLCollector,
FontsCollector
} from "fingerprinter-js";
// Use collectors individually
const canvas = new CanvasCollector();
const data = canvas.collect();
console.log(data);
```
## 📄 许可证
MIT © [Lorenzo Coslado](https://github.com/Lorenzo-Coslado)
## 🔗 链接
- [GitHub 仓库](https://github.com/Lorenzo-Coslado/fingerprinter-js)
- [NPM 包](https://www.npmjs.com/package/fingerprinter-js)
- [在线演示](https://lorenzo-coslado.github.io/fingerprinter-js)
标签:FingerprinterJS, Headless浏览器, JavaScript库, Selenium检测, SHA-256哈希, TypeScript, 企业级安全, 反欺诈, 安全插件, 数据可视化, 无依赖, 机器人检测, 浏览器指纹, 用户追踪, 系统分析, 网络分析, 网络安全, 自动化攻击, 设备画像, 设备识别, 隐私保护, 风险控制