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

@cartai2025/device-sdk

v1.0.3

Published

Advanced browser identification library with the highest accuracy and stability

Readme

CartAI Device SDK

Advanced browser identification library with the highest accuracy and stability for fraud detection and device analysis.

Installation

npm install @cartai2025/device-sdk

Or using yarn:

yarn add @cartai2025/device-sdk

Quick Start

Basic Usage

import CartAI from '@cartai2025/device-sdk'

// Initialize the agent
const cartaiAgent = await CartAI.load()

// Get visitor identifier
const result = await cartaiAgent.get()

console.log('Visitor ID:', result.visitorId)
console.log('Confidence:', result.confidence)

ES Modules

import { load } from '@cartai2025/device-sdk'

async function getDeviceFingerprint() {
  const agent = await load()
  const result = await agent.get()
  
  return {
    visitorId: result.visitorId,
    confidence: result.confidence.score,
    components: result.components
  }
}

getDeviceFingerprint().then(data => {
  console.log('Device fingerprint:', data)
})

CDN Usage (Browser)

<!DOCTYPE html>
<html>
<head>
    <script src="https://d24lz8mxe7yhfu.cloudfront.net/cartai-device-sdk/cartai-device-sdk.min.js"></script>
</head>
<body>
    <script>
        CartAI.load().then(agent => {
            return agent.get()
        }).then(result => {
            console.log('Visitor ID:', result.visitorId)
            console.log('Confidence:', result.confidence.score)
        })
    </script>
</body>
</html>

API Reference

load(options?)

Loads and initializes the CartAI agent.

Parameters:

  • options (optional): Configuration options
    • delayFallback (number, default: 50): Fallback delay for older browsers in milliseconds
    • debug (boolean, default: false): Enable debug logging

Returns: Promise

const agent = await CartAI.load({
  delayFallback: 100,
  debug: true
})

agent.get(options?)

Gets the visitor identifier and device fingerprint.

Parameters:

  • options (optional): Get options
    • debug (boolean): Enable debug logging (deprecated - use load options instead)

Returns: Promise

const result = await agent.get()

GetResult Object

The result object contains:

  • visitorId (string): Unique visitor identifier
  • confidence (Confidence): Confidence score and details
  • components (object): Raw fingerprinting components used for identification
  • version (string): SDK version used for identification
{
  visitorId: "abc123def456...",
  confidence: {
    score: 0.99,
    comment: "High confidence"
  },
  components: {
    // Various device and browser characteristics
  },
  version: "1.0.0"
}

Advanced Usage

Custom Configuration

import { load } from '@cartai2025/device-sdk'

const agent = await load({
  delayFallback: 200,  // Custom delay for older browsers
  debug: true          // Enable detailed logging
})

const result = await agent.get()

Working with Components

import { load, hashComponents, componentsToDebugString } from '@cartai2025/device-sdk'

const agent = await load()
const result = await agent.get()

// Get debug information about components
const debugInfo = componentsToDebugString(result.components)
console.log('Components debug info:', debugInfo)

// Generate custom hash from components
const customHash = hashComponents(result.components)
console.log('Custom hash:', customHash)

Error Handling

import CartAI from '@cartai2025/device-sdk'

try {
  const agent = await CartAI.load({
    debug: true
  })
  
  const result = await agent.get()
  
  if (result.confidence.score > 0.8) {
    console.log('High confidence ID:', result.visitorId)
  } else {
    console.log('Lower confidence ID:', result.visitorId)
    console.log('Confidence details:', result.confidence.comment)
  }
} catch (error) {
  console.error('CartAI initialization failed:', error)
}

Browser Compatibility

CartAI Device SDK supports all modern browsers:

  • Chrome 49+
  • Firefox 52+
  • Safari 10+
  • Edge 79+
  • Opera 36+

Privacy & Security

  • No personal information is collected
  • All processing happens locally in the browser
  • Compliant with privacy regulations (GDPR, CCPA)
  • Respects Do Not Track headers

Performance

  • Lightweight (~50KB minified)
  • Lazy loading of detection modules
  • Optimized for minimal impact on page load
  • Uses requestIdleCallback when available

Use Cases

  • Fraud Prevention: Identify suspicious devices and behavior
  • Analytics: Track unique visitors without cookies
  • Security: Detect bot traffic and automated attacks
  • Personalization: Provide consistent experience across sessions
  • A/B Testing: Ensure users stay in the same test group

TypeScript Support

Full TypeScript definitions are included:

import { Agent, GetResult, LoadOptions } from '@cartai2025/device-sdk'

const options: LoadOptions = {
  delayFallback: 100,
  debug: false
}

const agent: Agent = await CartAI.load(options)
const result: GetResult = await agent.get()

License

This project is licensed under the Business Source License 1.1 (BUSL-1.1).

Support

For support and questions:

Changelog

See CHANGELOG.md for version history and updates.