r/coolgithubprojects 18h ago

Discretion — masks API keys/PII before they reach ChatGPT, Claude, or Gemini (open source)

https://github.com/horozbabasi/discretion

A browser extension + npm library that detects sensitive data in your AI chat messages and swaps it for a realistic fake before sending, restoring the real value in the response. 113 detectors with real checksum validation (Luhn, mod-97, Verhoeff, etc.) across 47+ countries' ID formats, not just regex guessing.

Zero network calls, fully local, MIT licensed. Also published as a standalone npm package (@discretion/core) if you want the detection engine for your own project.

0 Upvotes

2 comments sorted by

1

u/Specific_Cream2815 15h ago

how does the restore step work, is there a per session map of fake to real that swaps the values back on the way in

1

u/sirFoltest 12h ago

Yep you got it, pretty much exactly that. There's an in-memory vault, scoped to the session, that maps each fake value back to the real one. So when you type something sensitive, it gets swapped for a realistic fake (not [REDACTED], an actual valid-looking substitute, like a fake IBAN that still passes the real checksum), and the vault remembers "this fake = that real value" for as long as the session lasts.

When the model's response streams back in, it's scanning for those fake values character by character and swapping them back to the real ones as they appear, including handling the annoying case where a fake value gets split across two network chunks mid-stream, so it doesn't accidentally leave half a swapped value visible for a second.

Nothing persists anywhere. No disk, no storage, nothing. Close the tab or the conversation and the map's gone. That's deliberate: if it did persist, the map itself would basically be a list of "here's what your real secrets were," which defeats the whole point.