Zero-Trust Edge PII Masking Middleware
Your legal team blocked OpenAI access because of PII leaks. This unblocks them — legally.
The Problem
Enterprise legal and compliance teams are blocking developers from using OpenAI or Claude because employees accidentally paste sensitive customer data (emails, credit cards, NHS numbers, financial records) into prompts. The data leaves the company network unencrypted.
The Solution
A lightweight TypeScript middleware wrapper. It intercepts the prompt at the Edge before it leaves your network, uses optimized local regex + lightweight NER to identify and hash all sensitive data, sends the clean prompt to the AI API, and decodes hashes back into real values only inside the secure browser context.
Why You Have No Choice
Allows corporate developers to use public AI models without violating company data privacy policies, GDPR, POPIA, or HIPAA. The only alternative is building an on-premise LLM — which costs $500,000+.
Code Preview
This is what you'll drop into your codebase. The full package includes all configuration options and integrations.
// pii-masker.edge.ts — intercept before prompt leaves network
import { maskPII, unmaskPII } from './pii-masker.edge'
// In your Next.js API route:
export async function POST(req: Request) {
const { prompt } = await req.json()
// Mask PII before sending to OpenAI
const { cleanPrompt, vault } = await maskPII(prompt)
const response = await openai.chat.completions.create({
messages: [{ role: 'user', content: cleanPrompt }]
})
// Restore real values only for the user's browser
const safeResponse = unmaskPII(response.choices[0].message.content, vault)
return Response.json({ content: safeResponse })
}What's in the Package
TypeScript Edge middleware + client-side decoder. Works in Next.js API routes, Vercel Edge Functions, or standalone Node.js.
Compliance Law This Addresses
🇪🇺Errors This Package Fixes
Instant download after payment. Secure checkout via Lemon Squeezy.
⚖️ Developer Tool — Important Notice
VektorIndex developer tools are technical software packages provided to assist developers in implementing compliance-relevant technical controls. They do not constitute legal advice, legal services, or a guarantee of regulatory compliance. Each tool solves a specific technical problem — whether a tool satisfies your specific legal obligations depends on your use case, jurisdiction, and how the tool is configured and deployed. You must engage qualified legal counsel to confirm your compliance posture. VektorIndex does not represent that use of any tool will make your product compliant with any specific law or regulation.
Prices in USD. Billed monthly. Annual plans available at 20% discount. Taxes may apply depending on your jurisdiction. VektorIndex is a digital goods merchant — you are purchasing a software license, not a physical product. Subscription management: Lemon Squeezy customer portal.