
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
PII security for AI workflows, coding agents and browser workloads.
Detects, replaces, encrypts, and rehydrates back when needed.
npm i rehydra · npm i @rehydra/cli · npm i @rehydra/opencode
When you send code, messages, or documents through an LLM, real names, emails, and API keys go with them. Existing anonymizers strip PII permanently but that breaks the conversation. The LLM can't reason about "John" if it never sees "John," and it can't write a file referencing john@acme.com if that address was permanently removed.
You need pseudonyms that the LLM can work with, and that your tools can reverse.
<PII type="PERSON" id="1"/>. The LLM works with these instead of real data.Run a local proxy that anonymizes PII before it reaches the LLM and rehydrates responses. Works with Claude Code, Cursor, and any OpenAI/Anthropic-compatible client.
npx @rehydra/cli proxy claude --api-key sk-ant-...
rehydra proxy
Provider anthropic (https://api.anthropic.com)
Listening http://127.0.0.1:8787
NER quantized
Configure your tools:
Claude Code
ANTHROPIC_BASE_URL=http://127.0.0.1:8787 claude
Names, emails, phone numbers, and secrets are replaced with placeholders in transit. Tool results (file reads, bash output) are anonymized on the way out. Tool call arguments (file writes, bash commands) are rehydrated on the way back. The LLM never sees real PII — but your tools always get real values.
Note: The proxy requires an Anthropic API key. Claude Max/Pro subscriptions use OAuth which
api.anthropic.comdoes not support through proxies.
npm install @rehydra/opencode
{ "plugin": ["@rehydra/opencode"] }
Intercepts the conversation between OpenCode and the LLM. Secrets from .env files are replaced with placeholders before they leave your machine and restored before tools execute.
For automation and server-side use.
Highly customizable backbone of the implementations above. Supports custom NER models, encryption key providers, session storage providers, tag formats and many more tweaks.
import { anonymize } from 'rehydra';
const { anonymizedText } = await anonymize(
'Email john.smith@acme-corp.com or call John at +41 79 123 45 67'
);
Works in Node.js, Bun, and browsers. No data leaves your machine.
Most PII libraries mask or redact permanently. Rehydra encrypts the original values with AES-256-GCM and restores them on demand. Anonymize for the LLM, rehydrate for your tools — a full round-trip, not a one-way street.
PERSON_1 stays PERSON_1 across every message in the conversation. When John Smith comes up in message 1, message 5, and message 20, the LLM sees the same placeholder every time. It can track relationships, reference earlier context, and produce coherent multi-turn output — without ever seeing real PII. Sessions persist to SQLite (server), IndexedDB (browser), or in-memory, so identity mappings survive restarts.
NER inference runs locally via ONNX Runtime (~280 MB quantized model). No API calls to external services. Works offline. PII never leaves your machine.
The CLI proxy sits between your coding agent and the API. It anonymizes outbound messages and — critically — rehydrates tool-call arguments before they execute. When the LLM says "write <PII type="EMAIL" id="1"/> to config.yaml," the proxy restores the real email before the file is written. Your agent works normally. Your data stays private.
Beyond names, emails, and phone numbers, Rehydra detects API keys (OpenAI, Anthropic, Stripe, AWS, GitHub...), JWTs, private keys, database connection strings, and .env secrets.
Purpose-built for LLM token streams. A sentence-buffered chunking system with NER overlap preservation ensures accurate detection even when PII spans chunk boundaries — with a low-latency mode for real-time streaming.
Optional gender and scope attributes on PII tags (<PII type="PERSON" gender="male" id="1"/>, <PII type="LOCATION" scope="city" id="2"/>) preserve grammatical context for downstream systems.
import {
createAnonymizer,
InMemoryKeyProvider,
SQLitePIIStorageProvider,
} from 'rehydra';
const keyProvider = new InMemoryKeyProvider();
const anonymizer = createAnonymizer({
ner: {
mode: 'quantized', // ~280 MB model, auto-downloads on first use
caseFallback: true, // detect lowercase names like "tom"
thresholds: { PERSON: 0.8 }, // require higher confidence for names
onStatus: console.log, // log model download progress
},
semantic: { enabled: true }, // adds gender/scope attributes for MT
secrets: { enabled: true }, // detect API keys, JWTs, connection strings
keyProvider,
piiStorageProvider: new SQLitePIIStorageProvider('./pii.db'),
});
const session = anonymizer.session('chat-123');
// Message 1 — NER detects names and orgs, regex catches emails
const r1 = await session.anonymize(
'Tell John Smith at Acme Corp (john.smith@acme-corp.com) we accept the offer'
);
// → "Tell <PII type="PERSON" gender="male" id="1"/> at <PII type="ORG" id="2"/>
// (<PII type="EMAIL" id="3"/>) we accept the offer"
// Message 2 — same entities keep their IDs across messages
const r2 = await session.anonymize(
'CC john.smith@acme-corp.com and loop in admin@acme-corp.com'
);
// → "CC <PII type="EMAIL" id="3"/> and loop in <PII type="EMAIL" id="4"/>"
// Rehydrate any message — PII map is loaded from SQLite automatically
const original = await session.rehydrate(r2.anonymizedText);
// → "CC john.smith@acme-corp.com and loop in admin@acme-corp.com"
await anonymizer.dispose();
| Package | Description |
|---|---|
rehydra | Core SDK — detect, anonymize, rehydrate |
@rehydra/cli | CLI proxy and terminal anonymization |
@rehydra/opencode | OpenCode plugin — scrubs secrets before they reach LLM providers |
For API reference, configuration, guides, and examples, visit docs.rehydra.ai.
FAQs
On-device PII anonymization module for high-privacy AI workflows
The npm package rehydra receives a total of 756 weekly downloads. As such, rehydra popularity was classified as not popular.
We found that rehydra demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.