Zero-Trust Data Sanitization

Developer SDK: Zero-Trust PII & Secrets Redaction for AI Pipelines

Sub-Millisecond Zero-Trust Sanitization for Modern AI Engineering

100% Local RAM Processing
Trusted by 10,000+ teams & engineers · $199/mo SDK / $1,990/yr Annual
Airplane Mode Verified
0 Bytes Server Egress
Developer SDK & NPM Package

AI Summary / Key Takeaways

Verified Zero-Trust Logic

"Integrate PrivacyScrubber's sub-millisecond in-memory engine directly into your backend infrastructure. The Developer SDK (@privacyscrubber/sdk) provides transparent OpenAI client wrapping, LangChain/LlamaIndex middleware, vector DB de-identification, and CISO compliance telemetry with 0 network latency and 0 subprocessor liability."

What environments and runtimes does @privacyscrubber/sdk support?
How does the 1-line wrapOpenAI helper work?
How does the SDK protect Vector Databases (Pinecone, Chroma, Qdrant, Milvus, pgvector)?

Enterprise-Grade AI Privacy

Add custom redaction rules and priority support with PRO.

GO PRO
Live Turnkey Simulator · ZTDS Engine

Interactive PII Detection & Sanitization Sandbox

Test real-time client-side RAM tokenization. Choose a specialized preset or paste your own raw prompt to test instant reversible redaction.

0 Bytes Server Egress
<1.8ms Latency
Select Industry Test Payload:
Raw Input Payload
0 chars
RAM-Only Isolated Session
Automated Detection Classes:
Customer / Employee NamesSSNPhone NumbersEmail AddressesCredit Card Numbers (PAN)API Access Keys / TokensPhysical AddressesInternal Server Hostnames
Enterprise Challenge

The Challenge with AI Data Workflows

Sending raw prompts to cloud DLP proxies (like Nightfall or Google DLP) introduces 250ms+ latency, HTTP 429 rate limits, and 6-to-8 week security review bottlenecks. Storing unmasked PII in vector databases creates permanent GDPR Article 17 compliance debt.

Zero-Egress Data Protection
Eliminates corporate data leaks before prompts hit external AI models.
Zero-Trust Resolution

How It Works

1

Install via npm

Add @privacyscrubber/sdk to your project using npm, yarn, or pnpm. Operates with zero runtime dependencies across Node.js 18+ and modern browser ESM contexts.

2

Wrap LLM or Sanitize Direct

Use wrapOpenAI(client) for 1-line transparent prompt sanitization, or call sanitize(text, { profile: 'dev' }) to strip PII and infrastructure secrets before vector DB ingestion.

3

Deterministic Restore & Audit Receipts

Re-hydrate tokens in AI responses with restore(response, tokenMap) and output signed Markdown/JSON CISO audit receipts mapped to GDPR, HIPAA, and SOC 2.

Customer Proof

What Teams Achieve with Local PII Masking

"Integrating @privacyscrubber/sdk took less than 15 minutes. wrapOpenAI automatically sanitized patient identifiers before reaching GPT-4o, and restored the original names in the response automatically. Zero network egress meant our HIPAA audit passed on day one."

J

James C., CTO at HealthTech Startup

Verified User

"We dropped the SDK into our Pinecone RAG ingestion pipeline. Sanitizing 500k documents took under 2 minutes in memory with zero cloud egress. The built-in DevOps secrets detector caught AWS keys and DB URIs that standard regex libraries missed completely."

A

Aisha L., Lead AI Engineer

Verified User

"Replacing cloud DLP proxy roundtrips with the in-memory SDK reduced our RAG pipeline latency from 320ms to 1.4ms per chunk. The bidirectional token recovery eliminated hallucinations in multi-turn conversations."

D

David S., Staff Infrastructure Architect

Verified User

Swipe to read verified reviews

Supported Formats & Limitations

Supported Formats

NPM Package (@privacyscrubber/sdk)Browser ES ModuleNode.js CJS / ESMTypeScript (Bundled .d.ts)

System Limitations

  • Licensed for internal backend infrastructure, microservices, and RAG pipelines (OEM required for commercial SaaS embedding)
  • License keys are non-transferable; store securely in environment secret managers (Vault, AWS Secrets Manager, Doppler)
  • Emergency key revocation available via SHA-256 Key Revocation List (KRL) by contacting support
  • Requires modern JavaScript engine (Node.js 18+, Bun, or modern ES2020+ browser runtime)
Zero Dependencies • <1ms In-Memory Node.js • Next.js • TypeScript

Start in 10 seconds with the zero-trust NPM SDK

Transparent OpenAI client wrapping, vector DB de-identification, and 25+ compliance profiles.

$npm i @privacyscrubber/sdk
View on NPM

Why AI Engineers & Backend Architects Adopt @privacyscrubber/sdk

When deploying LLMs, Autonomous Agents, and RAG pipelines in production, sending raw customer data to cloud redaction proxies introduces unacceptable latency, rate limits, and 6-to-8 week security questionnaire bottlenecks. The PrivacyScrubber Developer SDK (@privacyscrubber/sdk) executes 100% in-memory in your existing Node.js, Next.js, or browser runtime at sub-millisecond speeds — providing true Privacy by Design with 0 network egress and 0 subprocessor liability.

Zero-Trust SDK Architecture: In-Memory Lifecycle

<1ms In-Memory Execution

The SDK intercepts raw payloads at your application boundary, tokenizes all PII and infrastructure secrets in volatile RAM, and forwards safe tokens to external LLMs or vector databases. Responses are deterministically restored before reaching the user.

Raw InputPII / Secrets
sanitize()
SDK RAM Engine25+ Profiles
tokenMap
[TOKEN_1]Safe Prompt
OpenAI / LLM
AI ModelTokens Only
restore()
RestoredOriginal Text

Outcome-First Integration Patterns for AI Developers

1

1-Line Transparent OpenAI SDK Wrapper

Zero Pipeline Refactoring

Wrap your standard OpenAI client. Outbound prompt messages are automatically sanitized before cloud transmission, and incoming assistant responses are restored deterministically before resolving.

import OpenAI from 'openai';
import { wrapOpenAI } from '@privacyscrubber/sdk';

// Wrap any OpenAI client instance in 1 line
const openai = wrapOpenAI(new OpenAI({ apiKey: process.env.OPENAI_API_KEY }), {
    profile: 'Legal',            // 25+ profiles: Medical, Finance, HR, Security...
    detectSecrets: true,        // Automatically strip AWS keys, JWTs, DB passwords
    licenseKey: process.env.PRIVACYSCRUBBER_KEY
});

// Use standard OpenAI API calls — prompts are sanitized in RAM automatically!
const completion = await openai.chat.completions.create({
    model: 'gpt-4o',
    messages: [{ role: 'user', content: 'Draft NDA for Alice Smith at alice@corp.com with SSN 421-55-0147.' }]
});

console.log(completion.choices[0].message.content);
// AI received tokens only; returned response is automatically restored to Alice Smith!
2

RAG & Vector Database Ingestion (Pinecone, Chroma, pgvector)

GDPR Art. 17 Compliance

Storing raw PII inside vector embeddings is irreversible and violates GDPR Right to be Forgotten. Sanitize document chunks prior to vectorization to keep your vector database 100% de-identified.

import { sanitize } from '@privacyscrubber/sdk';

// Pre-process unstructured document chunks prior to embedding
function prepareVectorChunk(rawDocumentChunk) {
    const { scrubbedText, tokenMap, telemetry } = sanitize(rawDocumentChunk, {
        profile: 'Healthcare',
        licenseKey: process.env.PRIVACYSCRUBBER_KEY
    });
    
    // Embed only the anonymized text into Pinecone / Chroma / Milvus / pgvector
    return {
        anonymizedChunk: scrubbedText,
        riskScore: telemetry.riskLevel, // 'CLEAN' | 'LOW' | 'MODERATE'
        frameworks: telemetry.frameworksList // ['HIPAA Safe Harbor (§164.514)', ...]
    };
}
3

Autonomous AI Agents (LangChain, AutoGen, CrewAI, LlamaIndex)

Stateful Multi-Turn Consistency

Maintain persistent token bindings across multi-step agent reasoning loops. [NAME_1] consistently maps to the same individual across tool executions and conversation history.

import { PrivacyScrubberEngine, createLangChainTransform } from '@privacyscrubber/sdk';

// Initialize stateful engine for agent session
const agentScrubber = new PrivacyScrubberEngine({
    defaultProfile: 'DevOps',
    licenseKey: process.env.PRIVACYSCRUBBER_KEY
});

// Turn 1: Sanitize user input and assign [NAME_1], [SECRET_1]
const turn1 = agentScrubber.sanitize('User John Doe ran deploy with token ghp_abc123456.');

// Turn 2: Engine remembers [NAME_1] is John Doe for subsequent reasoning steps
const turn2 = agentScrubber.sanitize('Assign ticket to John Doe.');
// Result: 'Assign ticket to [NAME_1].' (Token numbering is consistently preserved!)

// Restore full multi-turn assistant answer
const finalResponse = agentScrubber.restore(agentOutputText);

Empirical Performance Benchmarks

Verified execution latency on Node.js 20 / Apple Silicon & x86-64 server hardware:

<1ms
Latency
per 10k chars
~180KB
Bundle Size
0 dependencies
0 B
Disk Writes
RAM-only GC
+2.8%
Token Delta
avg overhead
25+
Profiles
regulatory presets
0
Network Calls
air-gapped

Architecture Comparison: SDK vs Legacy Cloud DLP Proxies

Why in-memory zero-trust execution outperforms cloud redaction APIs and containerized engines:

Dimension @privacyscrubber/sdkGoogle Cloud DLPMS Presidio
Processing ModelLocal In-Memory (<1ms)Remote Cloud API (150–400ms)Self-hosted Python (~30ms)
Network EgressZero (Air-gapped certified)Full unencrypted payload egressInternal network hop
Runtime Footprint180KB (Zero dependencies)Cloud Managed Service~500MB Docker image + spaCy
OpenAI 1-Line Drop-inYes (wrapOpenAI helper)Custom manual pipelineCustom wrapper required
DevOps Secrets ScanningBuilt-in (AWS, JWT, DB URIs)Separate custom detectorsRequires custom regex rules
Pricing Predictability$199/mo Flat (Unlimited nodes)Pay-per-GB / Pay-per-scan feesCompute & DevOps maintenance overhead

Multi-Framework Integration Examples

Drop the SDK into backend microservices, web apps, or serverless actions:

Express / FastifysanitizeMiddleware.js
import { sanitize } from '@privacyscrubber/sdk';

export function piiGuard(req, res, next) {
  if (req.body?.prompt) {
    const { scrubbedText, tokenMap } = sanitize(req.body.prompt, {
      profile: 'Security',
      detectSecrets: true
    });
    req.body.prompt = scrubbedText;
    req.tokenMap = tokenMap;
  }
  next();
}
Next.js Actionactions.ts
'use server';
import { sanitize, restore } from '@privacyscrubber/sdk';

export async function askAI(prompt: string) {
  const { scrubbedText, tokenMap } = sanitize(prompt, { profile: 'Legal' });
  const rawAI = await callLLM(scrubbedText);
  const { restoredText } = restore(rawAI, tokenMap);
  return restoredText;
}
React HookuseScrubber.ts
import { useState, useCallback } from 'react';
import { sanitize, restore } from '@privacyscrubber/sdk';

export function useScrubber() {
  const [map, setMap] = useState>({});
  const scrub = useCallback((text: string) => {
    const res = sanitize(text);
    setMap(res.tokenMap);
    return res.scrubbedText;
  }, []);
  const reveal = useCallback((text: string) => restore(text, map).restoredText, [map]);
  return { scrub, reveal };
}

Zero-Trust Cryptographic Guarantees

Verified boundaries enforced at the library level:

0 Network Calls

No HTTP requests, WebSocket connections, or phone-home telemetry pings.

0 Telemetry

No user tracking, error beacons, or remote key-validation roundtrips.

0 Disk Storage

No localStorage, cookies, or fs writes. Volatile in-memory garbage collection.

0 eval() / Dynamic

Zero eval() or dynamic code execution. 100% strict CSP compatible.

Developer SDK Commercial Licensing

Instant offline cryptographic license token for unlimited internal microservices, RAG databases, and backend services at $199/mo (or $1,990/yr with 2 months free). OEM redistribution starts at $599/mo.

Client-Side Reliability & Audit Verification

Powered by the Zero-Trust Sanitization Engine (ZTDS). All detection, tokenization, and regex evaluation execute 100% inside your local client process boundary — eliminating cloud proxies, intermediate servers, and third-party data retention risks.

100% Local Execution RAM-Only (Zero Disk I/O) Zero Outbound Telemetry
Airplane Mode
Zero Network Dependency

Step-by-Step Guide

How to use this feature

3 min total
1

Install Package

Run 'npm install @privacyscrubber/sdk' in your terminal.

2

Import SDK

import { sanitize, restore, wrapOpenAI } from '@privacyscrubber/sdk';

3

Transparent OpenAI Wrapper

const openai = wrapOpenAI(new OpenAI(), { profile: 'legal' });

4

Call LLM Safely

const response = await openai.chat.completions.create({ model: 'gpt-4o', messages: [{ role: 'user', content: rawPrompt }] });

What you need: Node.js 18+ or modern browser environment NPM, Yarn, or PNPM package manager

Frequently Asked Questions

Technical Details & Privacy Architecture

What environments and runtimes does @privacyscrubber/sdk support?
The PrivacyScrubber SDK is 100% isomorphic and operates with zero runtime dependencies. It runs natively across Node.js (18+), Bun, Deno, Next.js Server Actions / Route Handlers, Express, Fastify, AWS Lambda, Cloudflare Workers, Electron, Tauri, and modern browser frontends (React, Vue, Svelte, Web Workers).
How does the 1-line wrapOpenAI helper work?
wrapOpenAI wraps any standard OpenAI SDK client instance (new OpenAI()). It intercepts chat.completions.create calls, automatically scrubs all sensitive prompt messages in local memory, forwards only safe tokens to OpenAI's servers, and transparently re-hydrates the returned completion with original values before returning the response to your application.
How does the SDK protect Vector Databases (Pinecone, Chroma, Qdrant, Milvus, pgvector)?
Ingesting raw PII into vector embeddings creates irreversible compliance debt: under GDPR Article 17 ('Right to be Forgotten'), vector embeddings containing personal data cannot be selectively deleted without costly database re-indexing. By passing raw text through sanitize(chunk, { profile: 'legal' }) prior to generating vector embeddings, your vector index remains 100% anonymized while preserving semantic search fidelity.
How does the SDK handle multi-turn AI agents and state consistency?
For multi-turn autonomous agents (LangChain, AutoGen, CrewAI, LlamaIndex), the PrivacyScrubberEngine class maintains a stateful sessionMap in memory. Token assignments remain deterministic across conversations ([NAME_1] consistently maps to the same individual across Turn 1, Turn 2, and Turn 10). The engine also supports engine.markFalsePositive(token) and engine.resetSession().
Does the SDK detect infrastructure secrets and DevOps tokens?
Yes. When detectSecrets: true is passed, the SDK's built-in DevOps Secrets Detector scans for and masks AWS Access Keys (AKIA...), Bearer JWT tokens, GitHub Personal Access Tokens (ghp_...), Stripe Secret Keys (sk_live_...), OpenAI API keys (sk-...), and database connection URIs (postgres://, mongodb://) before code or logs reach LLMs.
What compliance frameworks and audit telemetry are generated?
Every sanitize() call automatically generates a compliance telemetry payload and signed Markdown audit receipt mapping masked entities to GDPR Article 4(1), HIPAA Safe Harbor (§164.514), SOC 2 Type II, PCI DSS v4.0, and NIST SP 800-53. Risk levels (CLEAN, LOW, MODERATE, CRITICAL) are calculated in memory without external API calls.
Does the SDK require an outbound internet connection to validate licenses?
No. The SDK operates in a completely air-gapped manner. Commercial licenses (PRO, TEAMS, SDK, OEM, ENTERPRISE) use instant offline cryptographic checksum verification and RS256 JWT tokens. There are zero phone-home pings, zero telemetry calls, and zero external network requests.
How does the SDK compare to MS Presidio and Google Cloud DLP?
Google Cloud DLP requires sending full text payloads across the internet, adding 100–500ms latency and forming a third-party subprocessor relationship. MS Presidio requires running a heavy 500MB+ Docker container with high RAM overhead. PrivacyScrubber SDK is a 180KB zero-dependency library executing in <1ms directly inside your application's RAM.
Is the SDK fully typed with TypeScript?
Yes. The SDK ships with comprehensive, strongly-typed TypeScript definitions (index.d.ts). All methods (sanitize, restore, wrapOpenAI, createLangChainTransform, PrivacyScrubberEngine), configuration options, profile presets, and telemetry structures provide full IntelliSense autocompletion in VS Code, Cursor, and WebStorm without extra @types packages.
How does pricing and quota management work for the Developer SDK?
The Developer SDK plan is $199/mo (or $1,990/yr Annual with 2 months free) for unlimited internal backend services, microservices, and RAG vector databases. For commercial SaaS platforms embedding and redistributing PrivacyScrubber to external end-users, OEM licensing starts at $599/mo. Free tier includes 15,000 characters for General profile and 5,000 characters trial quota across all 25 specialized profiles.
100% Zero-Trust Deployment

Embed Zero-Trust PII Masking into Your AI Stack

Instant offline Ed25519 license key. 14-day money-back guarantee.