Registry / security / piiranha

piiranha

JSON →
library3.5.8jsnpmunverified

Piiranha v3.5.8 is a TypeScript library for removing personally identifiable information (PII) from text. It provides both synchronous and asynchronous APIs, built-in regex patterns for common PII types (names, emails, phone numbers, credit card numbers, IP addresses, SSNs, etc.), and supports custom redaction rules and replacement values. It is a maintained fork of solvvy/redact-pii, compiles to ES2016, and is tested on Node.js 18.x and 20.x. Key differentiators: dual sync/async API, customizable replacements, and extensible via custom regex or functions.

npm install piiranha
INSTALL
IMPORT
SIG · PIIRANHA
P
piiranha
securityjavascriptv3.5.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SyncRedactor
import { SyncRedactor } from 'piiranha'
const SyncRedactor = require('piiranha').SyncRedactor
Correct ESM import for synchronous redactor.
AsyncRedactor
import { AsyncRedactor } from 'piiranha'
ESM import for asynchronous redactor. Also works with dynamic import.

Synchronous PII redaction: redacts names and phone numbers from a string.

import { SyncRedactor } from 'piiranha'; const redactor = new SyncRedactor(); const redacted = redactor.redact('Hi David Johnson, call 555-555-5555'); console.log(redacted); // Hi NAME, call PHONE_NUMBER
Debug
Known issues
breakingv3.0.0 changed the default replacement value from '***' to 'NAME', 'PHONE_NUMBER', etc.
fix
Set custom replaceWith values in configuration if you need the old behavior.
affects: >=3.0.0
deprecatedThe previous package name 'redact-pii' is deprecated; use 'piiranha'.
fix
Replace require('redact-pii') or import from 'redact-pii' with 'piiranha'.
affects: >=3.0.0
gotchaAsync redactor must be awaited or used with .then(); otherwise, it returns a Promise object, not a string.
fix
Use await or .then() when calling redactAsync().
affects: >=1.0.0
breakingv2.0.0 removed the built-in 'ssn' pattern; renamed to 'usSocialSecurityNumber'.
fix
Update configuration references from 'ssn' to 'usSocialSecurityNumber'.
affects: >=2.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Package is ESM-only; commonjs require not supported without bundler transforms.
fix
Use import syntax, or in Node.js set "type": "module" in package.json, or use a transpiler like esbuild or webpack.
TypeError: redactor.redactAsync(...).then is not a function
Using sync redactor's redactAsync (does not exist) or async redactor's redact (sync) incorrectly.
fix
Use SyncRedactor with redact() and AsyncRedactor with redactAsync().
Upgrade
Version history
3.5.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
Resources
piiranha — npm install piiranha · libregistry