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

@cloak-business/sdk

v1.0.0

Published

Official JavaScript/TypeScript SDK for cloak.business PII detection and anonymization API

Readme

@cloak-business/sdk

Official JavaScript/TypeScript SDK for the cloak.business PII detection and anonymization API.

Installation

npm install @cloak-business/sdk

Quick Start

import { CloakClient } from '@cloak-business/sdk';

const client = new CloakClient({
  apiKey: 'cb_your_api_key_here',
});

// Analyze text for PII
const analysis = await client.analyze({
  text: 'Contact John Doe at [email protected]',
});

console.log(analysis.results);
// [
//   { entity_type: 'PERSON', start: 8, end: 16, score: 0.85 },
//   { entity_type: 'EMAIL_ADDRESS', start: 20, end: 36, score: 1.0 }
// ]

Features

  • Full TypeScript support with comprehensive type definitions
  • Automatic retry with exponential backoff on network/server errors
  • Rate limit handling with retry-after support
  • Request timeout configuration
  • Custom fetch implementation support (for testing or special environments)

API Reference

Configuration

const client = new CloakClient({
  apiKey: 'cb_your_api_key_here',  // Required: Your API key
  baseUrl: 'https://cloak.business/api',  // Optional: API base URL
  timeout: 30000,  // Optional: Request timeout in ms (default: 30000)
  retries: 3,      // Optional: Retry count on 5xx/network errors (default: 3)
});

Text Analysis

analyze(request)

Detect PII entities in text.

const result = await client.analyze({
  text: 'My email is [email protected] and my SSN is 123-45-6789',
  language: 'en',              // Optional: ISO 639-1 language code
  entities: ['EMAIL_ADDRESS', 'US_SSN'],  // Optional: Filter entity types
  score_threshold: 0.5,        // Optional: Minimum confidence (0.0-1.0)
});

batchAnalyze(request)

Analyze multiple texts in a single request (max 50 texts).

const result = await client.batchAnalyze({
  texts: [
    'Contact [email protected]',
    'Call me at 555-1234',
  ],
  language: 'en',
});

Anonymization

anonymize(request)

Anonymize detected PII entities using various operators.

const result = await client.anonymize({
  text: 'Contact John at [email protected]',
  analyzer_results: analysis.results,
  operators: {
    PERSON: { type: 'replace', new_value: '[NAME]' },
    EMAIL_ADDRESS: { type: 'hash', hash_type: 'sha256' },
    DEFAULT: { type: 'redact' },  // Fallback for other types
  },
});

Available Operators:

| Operator | Description | Options | |----------|-------------|---------| | replace | Replace with custom text | new_value | | redact | Remove completely | - | | hash | One-way hash | hash_type: 'sha256' or 'sha512' | | mask | Partial masking | masking_char, chars_to_mask, from_end | | encrypt | Reversible encryption | key (16/24/32 chars) | | keep | Leave unchanged | - |

deanonymize(request)

Decrypt encrypted PII entities.

const decrypted = await client.deanonymize({
  text: encrypted.text,
  anonymizer_results: encrypted.items,
  deanonymizers: {
    PERSON: { type: 'decrypt', key: 'my-32-character-secret-key!!' },
    EMAIL_ADDRESS: { type: 'decrypt', key: 'my-32-character-secret-key!!' },
  },
});

Image Processing

processImage(request)

Detect or redact PII in images.

// Analyze mode - returns detected entities
const analysis = await client.processImage({
  file: './document.png',  // File path, Buffer, or Blob
  mode: 'analyze',
  language: 'en',
});

// Redact mode - returns image buffer
const redactedBuffer = await client.processImage({
  file: imageBuffer,
  mode: 'redact',
  fill_color: 'black',  // 'black', 'white', 'red', 'green', 'blue', 'gray'
});

Account Management

// Get token balance
const balance = await client.getTokenBalance();
console.log(`Tokens: ${balance.balance}`);

// List encryption sessions
const sessions = await client.getSessions();

// Delete a session
await client.deleteSession('session-id');

Utility Methods

// Get API limits
const limits = await client.getLimits();

// Get available presets
const presets = await client.getPresets();

// Get all entity types
const entities = await client.getEntities();

// Health check
const health = await client.health();

Error Handling

The SDK provides typed errors for different failure scenarios:

import {
  CloakClient,
  AuthenticationError,
  RateLimitError,
  InsufficientTokensError,
  ValidationError,
} from '@cloak-business/sdk';

try {
  await client.analyze({ text: 'test' });
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Invalid API key');
  } else if (error instanceof RateLimitError) {
    console.error(`Rate limited. Retry after ${error.retryAfter}s`);
  } else if (error instanceof InsufficientTokensError) {
    console.error('Not enough tokens');
  } else if (error instanceof ValidationError) {
    console.error('Invalid request:', error.details);
  }
}

Requirements

  • Node.js 18.0.0 or higher
  • Browser environments with native fetch support

License

MIT