API Reference

Complete API for @visulima/redact

Last updated:

API Reference

Functions

redact

function redact<T>(
  input: T,
  rules?: string[],
  options?: RedactOptions
): T

Redact sensitive properties from objects.

Parameters:

  • input - Object to redact
  • rules - Array of property paths to redact
  • options - Redaction options

Returns: New object with redacted values


stringAnonymize

function stringAnonymize(
  text: string,
  options?: AnonymizeOptions
): string

Anonymize sensitive information in text using NLP.

Parameters:

  • text - Text to anonymize
  • options - Anonymization options

Returns: Anonymized text


Options

RedactOptions

interface RedactOptions {
  replacement?: string;
  caseSensitive?: boolean;
}

Properties:

  • replacement - Custom replacement text. Default: "<FIELD_NAME>"
  • caseSensitive - Case-sensitive matching. Default: true

AnonymizeOptions

interface AnonymizeOptions {
  include?: string[];
  exclude?: string[];
  replacement?: string;
}

Properties:

  • include - Entity types to anonymize
  • exclude - Entity types to skip
  • replacement - Custom replacement pattern

Built-in Rules

Credentials

  • password - Password fields
  • apikey - API keys
  • token - Auth tokens
  • bearer - Bearer tokens
  • auth - Auth headers
  • secret - Secret values

Financial

  • creditcard - Credit card numbers
  • cvv / cvd - Card security codes
  • bankacc - Bank account numbers
  • routing - Routing numbers
  • PAN - Primary account numbers
  • money - Monetary values

Personal

  • email - Email addresses
  • ssn / us_social_security - Social Security Numbers
  • firstname / lastname - Names
  • phonenumber - Phone numbers
  • passport - Passport numbers
  • dl - Driver's license
  • uk_nin - UK National Insurance

Technical

  • ip - IP addresses
  • mac_address - MAC addresses
  • url - URLs
  • domain - Domain names
  • crypto - Cryptocurrency addresses

Other

  • date - Dates
  • time - Times
  • zip_code - Postal codes
  • isbn - ISBN numbers
  • organization - Organization names

Text Anonymization Categories

NLP-Detected Entities

  • Person - People's names
  • Organization - Company/org names
  • Place - Locations
  • Date - Date expressions
  • Money - Monetary amounts
  • PhoneNumber - Phone numbers
  • Email - Email addresses

Examples

All Options

import { redact, stringAnonymize } from "@visulima/redact";

// Object redaction with options
const safe = redact(data, ["password", "ssn"], {
  replacement: "[REDACTED]",
  caseSensitive: false
});

// Text anonymization with options
const anonymous = stringAnonymize(text, {
  include: ["Person", "Email"],
  exclude: ["Organization"],
  replacement: "<HIDDEN>"
});

Next Steps

Usage Guide

Detailed usage examples

Back to Overview

Return to overview

Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues