npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

browser-fingerprint-ts

v1.0.2

Published

A TypeScript library for generating browser fingerprints with support for both UMD and ES modules

Readme

浏览器指纹工具库

一个用于生成浏览器指纹的工具库,支持多种引入方式。

功能特性

  • 🎯 生成唯一的浏览器指纹
  • 🔧 支持多种指纹生成选项
  • 📦 支持UMD和ES模块引入
  • 🚀 轻量级,无外部依赖
  • 📱 支持现代浏览器

安装

npm install browser-fingerprint-ts

使用方法

1. 通过script标签引入(UMD)

<script src="/dist/browser-fingerprint.js"></script>
<script>
  // 使用全局变量
  const { BrowserFingerprint } = window.BrowserFingerprint;
  
  // 创建实例
  const fingerprint = new BrowserFingerprint();
  
  // 生成指纹
  fingerprint.generate().then(result => {
    console.log('指纹数据:', result);
    console.log('指纹哈希:', result.hash);
  });
</script>

2. 通过ES模块引入

<script type="module">
  import BrowserFingerprint from 'browser-fingerprint-ts';
  
  const fingerprint = new BrowserFingerprint();
  fingerprint.generate().then(result => {
    console.log('指纹数据:', result);
    console.log('指纹哈希:', result.hash);
  });
</script>

3. 在Node.js中使用

const BrowserFingerprint = require('browser-fingerprint-ts');

const fingerprint = new BrowserFingerprint();
fingerprint.generate().then(result => {
  console.log('指纹数据:', result);
  console.log('指纹哈希:', result.hash);
});

API文档

BrowserFingerprint类

构造函数

new BrowserFingerprint(options?: FingerprintOptions)

方法

  • generate(): 生成完整的浏览器指纹数据
  • getHash(): 获取指纹的哈希值
  • getJSON(): 获取指纹的JSON字符串
  • updateOptions(options): 更新配置选项
  • getOptions(): 获取当前配置

便捷方法

import { generateFingerprint, getFingerprintHash, getFingerprintJSON } from 'browser-fingerprint-ts';

// 直接使用便捷方法
const fingerprint = generateFingerprint();
const hash = getFingerprintHash();
const json = getFingerprintJSON();

配置选项

interface FingerprintOptions {
  includeScreen?: boolean;        // 是否包含屏幕信息
  includeTimezone?: boolean;      // 是否包含时区信息
  includeCPU?: boolean;          // 是否包含CPU信息
  includeFonts?: boolean;        // 是否包含字体信息
  includeAudio?: boolean;        // 是否包含音频信息
  includeGPU?: boolean;          // 是否包含GPU信息
  includeWritingScripts?: boolean; // 是否包含书写脚本
  includeIncognito?: boolean;    // 是否检测隐身模式
}

指纹数据格式

interface FingerprintData {
  screen: {                      // 屏幕信息
    screenWidth: number;
    screenHeight: number;
    colorDepth: number;
    pixelDepth: number;
    availWidth: number;
    availHeight: number;
  };
  timezone: {                    // 时区信息
    timezoneOffset: number;
    timezone: string;
  };
  cpuCores: number;             // CPU核心数
  stableFonts: string[];        // 稳定字体列表
  binnedAudio: {                // 音频信息
    sampleRate: number;
    state: string;
  };
  gpuHash: string | null;        // GPU哈希值
  writingScripts: string[];     // 书写脚本
  isIncognito: boolean;         // 是否隐身模式
  hash: string;                 // 指纹哈希值
}

使用示例

基础使用

const fingerprint = new BrowserFingerprint();

// 生成完整指纹
fingerprint.generate().then(result => {
  console.log('指纹数据:', result);
  console.log('指纹哈希:', result.hash);
});

// 或者使用async/await
async function getFingerprint() {
  const result = await fingerprint.generate();
  console.log('指纹数据:', result);
  console.log('指纹哈希:', result.hash);
}

自定义配置

const fingerprint = new BrowserFingerprint({
  includeScreen: true,
  includeAudio: false,
  includeGPU: true,
  includeFonts: true,
  includeWritingScripts: false
});

fingerprint.generate().then(result => {
  console.log('自定义配置的指纹:', result);
});

动态更新配置

const fingerprint = new BrowserFingerprint();

// 更新配置
fingerprint.updateOptions({
  includeAudio: true
});

fingerprint.generate().then(result => {
  console.log('更新配置后的指纹:', result);
});

浏览器兼容性

  • Chrome 60+
  • Firefox 55+
  • Safari 12+
  • Edge 79+

许可证

MIT License

贡献

欢迎提交Issue和Pull Request!