Shield – Zero-dependency PII and secret masking for LLMs (MIT PromptAudit released Shield, an MIT-licensed, zero-dependency TypeScript module that masks PII and secrets in prompts before they reach LLMs and restores the original values in the caller's process memory via shield(), unshield() and withShield(). Shield validates IBANs (ISO 7064 Mod 97), payment cards (Luhn plus brand prefix), US SSNs (SSA rules) and ABA routing numbers (3-7-1), and detects OpenAI/Anthropic sk- keys, AWS AKIA/ASIA keys, GitHub ghp_/github_pat_ tokens, Slack xox tokens, JWTs and PEM private keys, running in browsers, Node, Bun, Deno and edge workers with no network calls or telemetry. PromptAudit states the pattern-based tool does not detect names without a title, free-text addresses or medical terms, and that detection is best-effort rather than a guarantee that no personal data leaves a system. Zero-dependency, fast & reversible PII and secret masking for LLMs & AI agents. npm install @promptaudit/shield js import { withShield } from "@promptaudit/shield"; const answer = await withShield userPrompt, safe = llm.complete safe ; // The model saw API KEY 1 , IBAN 1 … — your user gets the real values back. You wrote: Deploy with key sk-proj-AbC123…xyz and refund Mr. John Miller, IBAN CH93 0076 2011 6238 5295 7 Model sees: Deploy with key API KEY 1 and refund Mr. NAME 1 , IBAN IBAN 1 You get: the model's answer with the original values restored in your process memory - Zero dependencies. One small TypeScript module. Browser, Node, Bun, Deno, edge workers. - Checksum-validated. IBAN ISO 7064 Mod 97 , cards Luhn + brand prefix , US SSN SSA rules , ABA routing 3-7-1 . Order and serial numbers are not masked by accident. - Secrets included. OpenAI/Anthropic sk-… , AWS AKIA… / ASIA… , GitHub ghp … / github pat … , Slack xox…- , JWT and PEM private keys. - Reversible. Placeholders go out, the map stays in your process memory. - Obfuscation-aware. Zero-width characters and full-width digits are normalised first. - No network, no telemetry. | | Typical Python NLP stack | Ad-hoc regex snippets | @promptaudit/shield | |---|---|---|---| | Runtime | Python server | varies | Browser, Node, Bun, Deno, edge | | Dependencies | NLP models and packages | varies | 0 | | Checksum validation | partial | rarely | IBAN, cards, SSN, ABA | | API keys / secrets | separate tooling | rarely | built in | | Restore originals | manual | usually one-way | unshield / withShield | NLP stacks e.g. Microsoft Presidio detect free-text names and addresses, which Shield does not. Choose by need; they can be combined. | Function | Purpose | |---|---| | shield text, detectors? | Returns { masked, map, counts } | | unshield text, map | Restores originals in a model answer | | withShield prompt, call | Mask → call → restore in one step | | DEFAULT DETECTORS | Extend with your own { category, pattern, validate? } | IBAN · payment card · US SSN · US routing with keyword · e-mail · international phone + prefix · names after Mr./Mrs./Ms./Dr./Prof. · API keys · private keys - Pattern-based, not NER: names without a title, free-text addresses and medical terms are not detected. - Unknown key formats are not caught. - Detection is best-effort. It reduces exposure; it does not guarantee that no personal data leaves your system. - No audit trail. Shield runs inside your code. Teams that must prove what was sent, by whom and when — with browser enforcement for every employee, append-only hash-chained logs and Swiss storage — use the PromptAudit platform https://promptaudit.ch . Try it live: https://promptaudit.ch/shield https://promptaudit.ch/shield · MIT © PromptAudit