@toolpal/pii-redact
publicv2.0published 1 download this weekMIT
Scans and redacts personal information (emails, phone numbers, SSNs, Luhn-verified credit cards, IBANs, IP addresses) and credentials/secrets (API keys, JWTs, private keys, database URLs, Bearer tokens) locally from text or files (TXT, MD, CSV, JSON, LOG, ENV, DOCX). Runs 100% offline with zero network access and no API keys.
# @toolpal/pii-redact
Scans and redacts personal data (PII) and credentials/secrets locally from text or files — completely offline (`net: false`, no API keys) — before sharing documents or sending them to an AI model.
## How it works
1. Scans inline `text` or a `file` (`.txt`, `.md`, `.csv`, `.json`, `.log`, `.env`, `.xml`, `.html`, `.yaml`, `.docx`).
2. Detects PII and secrets across 11 categories:
- **PII:** `email`, `phone`, `ssn`, `credit_card` (Luhn checksum verified), `iban` (ISO 7064 mod-97 verified), `ip` (IPv4 & IPv6)
- **Secrets:** `api_key` (AWS, GitHub, OpenAI, Anthropic, OpenRouter, Stripe, Slack, Google, SendGrid, Resend, npm, PyPI), `jwt`, `private_key` (PEM blocks), `connection_string` (database/SMTP URLs with passwords), `secret_assignment` (Bearer tokens & `KEY=secret` assignments)
- Plus optional `customTerms` (client names, internal codenames) and an `allowlist`.
3. In `redact` mode (default), replaces every match consistently using:
- `placeholder` (default): `[EMAIL_1]`, `[CREDIT_CARD_1]` — the same value gets the same tag across the document so relationships stay readable.
- `mask`: partial masking like `j***@example.com` or `****-****-****-4242`.
- `hash`: deterministic short SHA-256 tag like `[EMAIL:a1b2c3d4]`.
4. For `.docx` files, redacts text in place while keeping the Word document's formatting and structure.
## Example
```json
{
"text": "Contact Jane at [email protected] or +1-415-555-0192. Key: sk-proj-abc12345678901234567890",
"style": "placeholder"
}
```
## Notes
- Runs 100% offline (`net: false`, zero environment variables).
- Finding previews are always masked so raw secrets are never echoed back in audit summaries.
- Maximum file size: 25 MB.