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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@neuraltrust/trustgate-client

v1.0.0

Published

A browser-based bot detection library that wraps HTTP clients and collects fingerprinting data

Readme

TrustGate Client

A browser-based bot detection library that wraps HTTP clients and collects fingerprinting data to help identify and prevent bot traffic.

Features

  • 🔍 Environment Fingerprinting: Collects browser environment data (User-Agent, languages, timezone, screen resolution, etc.)
  • 🖼️ Visual Fingerprinting: Canvas, WebGL, and AudioContext fingerprinting
  • 🛜 Network Information: Connection type, downlink, RTT
  • 🧪 Automation Detection: Detects headless browsers and automation tools
  • 🔐 Persistence Checking: Verifies cookies, localStorage, sessionStorage, and indexedDB support
  • 🔄 HTTP Client Wrapper: Wraps existing HTTP clients or provides a simple built-in client

Installation

npm install trustgate-client

Development

CI/CD

This project uses GitHub Actions for continuous integration and continuous delivery. The workflow automatically runs unit tests and builds the project on every push to the main branch and on pull requests.

Unit Tests and Build

Usage

Basic Usage

import { TrustGateClient } from 'trustgate-client';

// Create a new client with default options
const botDetection = new TrustGateClient();

// Collect bot detection data
const data = botDetection.collectData();
console.log(data);

Wrapping an Existing HTTP Client

import axios from 'axios';
import { TrustGateClient } from 'trustgate-client';

// Create a new client that wraps axios
const botDetection = new TrustGateClient({
  httpClient: axios,
  appendTo: 'headers' // Add data to request headers (default)
});

// Now use axios as normal, bot detection data will be automatically added
// Using async/await
const fetchData = async () => {
  try {
    const response = await axios.get('https://api.example.com/data');
    console.log(response.data);
  } catch (error) {
    console.error(error);
  }
};

fetchData();

Using the Built-in HTTP Client

import { TrustGateClient } from 'trustgate-client';

// Create a new client
const botDetection = new TrustGateClient({
  appendTo: 'body' // Add data to request body instead of headers
});

// Create a simple HTTP client with bot detection
const httpClient = botDetection.createHttpClient();

// Use the HTTP client with async/await
const fetchData = async () => {
  try {
    const response = await httpClient.get('https://api.example.com/data');
    console.log(response.data);
  } catch (error) {
    console.error(error);
  }
};

fetchData();

Configuration Options

import { TrustGateClient } from 'trustgate-client';

const botDetection = new TrustGateClient({
  // Where to append the collected data ('headers' or 'body')
  appendTo: 'headers',

  // HTTP client to wrap (optional)
  httpClient: null,

  // Enable/disable specific collectors
  collectEnvironment: true,
  collectVisualFingerprint: true,
  collectNetworkInfo: true,
  detectAutomation: true,
  checkPersistence: true
});

Collected Data

The library collects the following data:

Environment Data

  • User-Agent (browser, operating system)
  • Languages (navigator.language, navigator.languages)
  • Timezone and offset
  • Screen resolution and window size
  • Color depth
  • Plugins installed
  • Browser feature support

Visual Fingerprinting

  • Canvas fingerprinting (rendering text, shapes, colors)
  • WebGL fingerprinting (vendor, renderer, version, extensions)
  • AudioContext fingerprinting (sample rate, channel count)

Network Information

  • Connection type, effective type, downlink, RTT

Automation Detection

  • navigator.webdriver check
  • Chrome headless detection
  • Automation tool properties (Puppeteer, Playwright, etc.)
  • Inconsistency detection (resolution, timezone, etc.)

Persistence Checks

  • Cookies enabled
  • LocalStorage/SessionStorage/IndexedDB support

TypeScript Support

This library includes full TypeScript support with type definitions. You can use it in your TypeScript projects as follows:

Basic TypeScript Usage

import { TrustGateClient, TrustGateClientOptions } from 'trustgate-client';

// Define options with TypeScript types
const options: TrustGateClientOptions = {
  appendTo: 'headers',
  collectEnvironment: true
};

// Create a new client with typed options
const botDetection = new TrustGateClient(options);

// Collect bot detection data
const data = botDetection.collectData();

// Create a simple HTTP client with bot detection
const httpClient = botDetection.createHttpClient();

// Use the HTTP client
httpClient.get('https://api.example.com/data')
  .then(response => console.log(response.data))
  .catch(error => console.error(error));

Advanced TypeScript Usage

import { 
  TrustGateClient, 
  TrustGateClientOptions, 
  HttpClient, 
  HttpClientResponse 
} from 'trustgate-client';

// Create a client with typed options
const botDetection = new TrustGateClient({
  appendTo: 'body',
  collectVisualFingerprint: true,
  detectAutomation: true
});

// Create an HTTP client with custom headers
const httpClient: HttpClient = botDetection.createHttpClient({
  headers: {
    'Custom-Header': 'Value'
  }
});

// Use with async/await
async function fetchData(): Promise<any> {
  try {
    const response: HttpClientResponse = await httpClient.get('https://api.example.com/data');
    return response.data;
  } catch (error) {
    console.error('Error:', error);
    throw error;
  }
}

TypeScript Configuration

The library includes a tsconfig.json file for TypeScript configuration. If you're using this library in your TypeScript project, you can build the types with:

npm run build:types

You can also check the types without emitting files:

npm run check-types

For a complete TypeScript example, see examples/typescript-example.ts.

Browser Compatibility

This library is designed for modern browsers and may not work in older browsers that don't support the required APIs.

License

MIT