{"slug": "stop-leaking-api-keys-customer-data-in-looms-ai-prompts-building-a-100-local-pii", "title": "Stop Leaking API Keys & Customer Data in Looms & AI Prompts: Building a 100% Local PII Scrubber and Demo Mode in Vanilla JS", "summary": "An independent developer built DemoCloak, a free Manifest V3 Chrome/Edge extension and two zero-upload web tools that detect and mask sensitive data such as API keys, emails, and card numbers entirely client-side in vanilla JavaScript. The engine uses Luhn checksums to avoid false-positive card matches, priority-ordered token detection for secrets like sk_live_ and AKIA keys, and 32-bit FNV-1a hashing to map matched strings to deterministic realistic placeholders that can be restored to the original DOM. The extension requests only activeTab, scripting, storage, and tabs permissions, using optional_host_permissions for per-domain auto-apply, and is currently under review on the Chrome Web Store and Microsoft Edge Add-ons.", "body_md": "Every developer has had the same minor heart attack: you share your screen on Zoom, record a Loom walkthrough, or paste a production JSON stack trace into Claude/ChatGPT—and two seconds later notice a real customer email, revenue total, or `sk_live_` key sitting right there on screen.\n\nExisting screen-blur extensions mostly fall into two camps: manual click-only blur tools that smear your whole UI into ugly smudges, or cloud/subscription tools that charge monthly fees just to hide text.\n\nSo I built **two free zero-upload web tools** plus a lightweight Manifest V3 Chrome/Edge extension (**DemoCloak**) powered by the exact same 100% client-side vanilla JS detection engine.\n\nHere are the four engineering problems that actually mattered when building it cleanly:\n\nNaive regex redactors ruin dashboards because a 16-digit order ID looks like a credit card, and `2026-11-25` looks like a phone number.\n\nFor card detection, every candidate match runs through a lightweight Luhn checksum before we touch the DOM:\n\n``` js\nexport function isValidLuhn(digitsOnly) {\n  const digits = String(digitsOnly || '').replace(/\\D/g, '');\n  if (digits.length < 13 || digits.length > 19) return false;\n  if (/^(\\d)\\1+$/.test(digits)) return false;\n  let sum = 0;\n  let dbl = false;\n  for (let i = digits.length - 1; i >= 0; i -= 1) {\n    let d = digits.charCodeAt(i) - 48;\n    if (dbl) { d *= 2; if (d > 9) d -= 9; }\n    sum += d;\n    dbl = !dbl;\n  }\n  return sum % 10 === 0;\n}\n```\n\nWe also enforce strict priority precedence: developer tokens (`sk_live_`, `ghp_`, `AKIA`, `AIza`, `xoxb-`, JWTs, `Bearer ...`) match **before** generic emails or numbers, and custom user keywords/regex take top priority.\n\nBlurred boxes work for quick meetings, but they look awful in product demos, docs, and landing page screenshots. Instead of random gibberish, we hash each matched string with **32-bit FNV-1a** so identical customer emails or revenue totals map deterministically to the same realistic placeholder everywhere on the page—preserving currency symbols (`$`, `€`, `£`, `¥`), European vs. US decimal commas, and rough order of magnitude:\n\n`$48,920.50` → `$62,480.00`\n`ceo@realclient.io` → `alex.chen@acme.example`\n`sk_live_...` → `sk_live_demo_••••9f2a`\nEvery wrapped `<span>` keeps its original string in memory (`data-dc-orig`) so clicking **Restore All** unwraps every node cleanly back to the exact original DOM.\n\n`TreeWalker` + `rAF` Batching + `MutationObserver`)\nLive dashboards (Stripe, Gmail, AWS, CRMs) inject rows dynamically as you scroll. To prevent jank on large DOM trees:\n\n`document.createTreeWalker` (skipping `<script>`, `<style>`, `<textarea>`, and `contenteditable`) and mutated in `requestAnimationFrame` batches`Alt+Shift+B` full-tab Panic Veil) live inside a Many privacy extensions ironically ask for `<all_urls>` on install. DemoCloak requests **zero** broad host permissions upfront—only `activeTab`, `scripting`, `storage`, and `tabs`. Per-domain auto-apply rules use `optional_host_permissions` and only ask Chrome for the single specific origin you click **Auto-Apply on Site** for.\n\nIf you just want to test the engine directly in your browser right now:\n\n`.env` snippets, or JSON payloads → mask into `[EMAIL_1]` / `[SECRET_1]` or realistic fake data → paste ChatGPT/Claude's reply back and restore your real values locally in 1 click.`Ctrl+V` / `⌘V`) or drop any screenshot, draw blur/pixelate/blackout boxes locally, and export a clean EXIF-stripped PNG.`$19` one-time lifetime Pro license — no subscription). Currently under review on Chrome Web Store & Microsoft Edge Add-ons, with the unpacked release ready to try now.\nIf you spot any tricky secret formats, currency formats, or SPA edge cases where the scrubber misses a pattern, drop a comment below and I'll add test cases for them!", "url": "https://wpnews.pro/news/stop-leaking-api-keys-customer-data-in-looms-ai-prompts-building-a-100-local-pii", "canonical_source": "https://dev.to/orzi_zhou_c044b3db3575386/stop-leaking-api-keys-customer-data-in-looms-ai-prompts-building-a-100-local-pii-scrubber-and-2p9c", "published_at": "2026-11-25 09:40:43+00:00", "updated_at": "2026-11-25 09:42:50.910837+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "ai-safety"], "entities": ["DemoCloak", "Chrome Web Store", "Microsoft Edge Add-ons", "Chrome", "Edge"], "also_reported_by": [], "takeaway": "Run every card-number candidate through a Luhn checksum and match developer tokens like sk_live_, ghp_, AKIA, and JWTs before generic emails or numbers to cut false positives in client-side PII redaction.", "recommendation": {"advice": "Validate card candidates with Luhn and order detection so secrets match before generic emails or numbers, and request only activeTab plus optional per-origin host permissions instead of all_urls.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/stop-leaking-api-keys-customer-data-in-looms-ai-prompts-building-a-100-local-pii", "markdown": "https://wpnews.pro/news/stop-leaking-api-keys-customer-data-in-looms-ai-prompts-building-a-100-local-pii.md", "text": "https://wpnews.pro/news/stop-leaking-api-keys-customer-data-in-looms-ai-prompts-building-a-100-local-pii.txt", "jsonld": "https://wpnews.pro/news/stop-leaking-api-keys-customer-data-in-looms-ai-prompts-building-a-100-local-pii.jsonld"}}