@privacyscrubber/sdk 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +258 -0
- package/index.d.ts +217 -0
- package/index.js +581 -0
- package/package.json +51 -0
- package/polyfill.js +33 -0
- package/ps-license-manager.js +257 -0
- package/ps-pii-engine.cjs +1297 -0
- package/ps-pii-engine.js +1297 -0
- package/scrubber-core.cjs +1711 -0
- package/shared-ui.js +533 -0
- package/ui-modals.js +819 -0
package/README.md
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# @privacyscrubber/sdk
|
|
2
|
+
|
|
3
|
+
> **Zero-Trust Data Sanitization (ZTDS) & PII Redaction Engine**
|
|
4
|
+
> 100% Client-Side & In-Memory Execution. Zero Data Leakage. Zero Network Requests for Sanitization.
|
|
5
|
+
|
|
6
|
+
The official Node.js / Browser SDK for [PrivacyScrubber.com](https://privacyscrubber.com). It provides enterprise-grade PII sanitization, cloud secrets redaction, cryptographic license enforcement, and deterministic token restoration for AI pipelines (OpenAI, Anthropic, LangChain, LlamaIndex).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## โก Highlights
|
|
11
|
+
|
|
12
|
+
- ๐ก๏ธ **Zero-Trust & In-Memory**: All sanitization executes locally in RAM. No PII or raw text is ever transmitted over the network.
|
|
13
|
+
- ๐ค **Transparent AI Wrapper**: `wrapOpenAI(client)` automatically scrubs sensitive tokens before outbound API requests and deterministically restores them in responses.
|
|
14
|
+
- โก **High Throughput**: Under 2ms average execution time per 10k characters.
|
|
15
|
+
- ๐ **23 Industry Compliance Profiles**: General, Dev/DevOps, Medical (HIPAA), Financial (PCI-DSS), Legal, HR, Executive, and more.
|
|
16
|
+
- ๐งพ **CISO Audit Receipts**: Automated generation of Markdown compliance receipts (GDPR Art. 4, HIPAA ยง164.514, SOC 2 Type II, ISO 27001, NIST SP 800-53).
|
|
17
|
+
- ๐ **Cryptographic License Engine**: Native RS256 JWT and cryptographic checksum verification.
|
|
18
|
+
- ๐ท๏ธ **TypeScript Support**: Full `.d.ts` typings included out of the box.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## ๐ฆ Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @privacyscrubber/sdk
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## ๐ Quickstart
|
|
31
|
+
|
|
32
|
+
### 1. Simple Sanitize & Restore
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import { sanitize, restore } from '@privacyscrubber/sdk';
|
|
36
|
+
|
|
37
|
+
const rawPrompt = "Hello, my name is Alice Smith and my email is alice@corp.com.";
|
|
38
|
+
|
|
39
|
+
// 1. Sanitize text before sending to LLM
|
|
40
|
+
const { scrubbedText, tokenMap, telemetry, auditReceipt } = sanitize(rawPrompt);
|
|
41
|
+
|
|
42
|
+
console.log(scrubbedText);
|
|
43
|
+
// "Hello, my name is [NAME_1] and my email is [EMAIL_1]."
|
|
44
|
+
|
|
45
|
+
console.log(auditReceipt);
|
|
46
|
+
// > ๐ก๏ธ **PrivacyScrubber Audit Receipt**
|
|
47
|
+
// > * **Risk Level:** ๐ด CRITICAL (HIGH EXPOSURE)
|
|
48
|
+
// > * **Compliance Enforced:** ZTDS Standard, GDPR (Art. 4), CCPA/CPRA
|
|
49
|
+
// > * **Tokens Masked:** 2 (1 NAME, 1 EMAIL)
|
|
50
|
+
|
|
51
|
+
// 2. Restore response from LLM
|
|
52
|
+
const aiResponse = "I have drafted a confirmation email to [NAME_1] ([EMAIL_1]).";
|
|
53
|
+
const { restoredText } = restore(aiResponse, tokenMap);
|
|
54
|
+
|
|
55
|
+
console.log(restoredText);
|
|
56
|
+
// "I have drafted a confirmation email to Alice Smith (alice@corp.com)."
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### 2. Transparent OpenAI Client Wrapper
|
|
62
|
+
|
|
63
|
+
Zero changes to your prompting architecture. Wrap your existing OpenAI SDK instance and PrivacyScrubber intercepts outbound prompts and restores incoming responses automatically:
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
import OpenAI from 'openai';
|
|
67
|
+
import { wrapOpenAI } from '@privacyscrubber/sdk';
|
|
68
|
+
|
|
69
|
+
const openai = wrapOpenAI(new OpenAI({ apiKey: process.env.OPENAI_API_KEY }));
|
|
70
|
+
|
|
71
|
+
// Prompts are scrubbed in RAM before leaving your server,
|
|
72
|
+
// and the returned choice content is restored before reaching your application logic!
|
|
73
|
+
const completion = await openai.chat.completions.create({
|
|
74
|
+
model: 'gpt-4o',
|
|
75
|
+
messages: [
|
|
76
|
+
{ role: 'user', content: 'Contact John Doe at john@acme.com regarding invoice #99281.' }
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
console.log(completion.choices[0].message.content);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### 3. Stateful Conversational Engine (`PrivacyScrubberEngine`)
|
|
86
|
+
|
|
87
|
+
Maintain token map consistency across multi-turn chats or session threads:
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
import { PrivacyScrubberEngine } from '@privacyscrubber/sdk';
|
|
91
|
+
|
|
92
|
+
const engine = new PrivacyScrubberEngine({ defaultProfile: 'General' });
|
|
93
|
+
|
|
94
|
+
// Turn 1
|
|
95
|
+
const turn1 = engine.sanitize("My name is John Doe and my phone is 555-0199.");
|
|
96
|
+
// Tokens: [NAME_1], [PHONE_1]
|
|
97
|
+
|
|
98
|
+
// Turn 2: Re-uses [NAME_1] for John Doe consistently
|
|
99
|
+
const turn2 = engine.sanitize("John Doe needs an update on ticket #402.");
|
|
100
|
+
// Tokens: [NAME_1]
|
|
101
|
+
|
|
102
|
+
// Restore full thread context
|
|
103
|
+
const restored = engine.restore("Notified [NAME_1] at [PHONE_1].");
|
|
104
|
+
console.log(restored.restoredText);
|
|
105
|
+
// "Notified John Doe at 555-0199."
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### 4. Specialized Industry Profiles & DevOps Secrets
|
|
111
|
+
|
|
112
|
+
Sanitize AWS credentials, JWT tokens, Stripe API keys, database connection strings, and HIPAA records:
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
import { sanitize } from '@privacyscrubber/sdk';
|
|
116
|
+
|
|
117
|
+
const devLog = `
|
|
118
|
+
AWS_KEY=AKIAIOSFODNN7EXAMPLE
|
|
119
|
+
DB_URI=postgres://admin:secret123@db.internal:5432/prod
|
|
120
|
+
`;
|
|
121
|
+
|
|
122
|
+
const result = sanitize(devLog, { profile: 'Dev' });
|
|
123
|
+
console.log(result.scrubbedText);
|
|
124
|
+
// AWS_KEY=[AWS_KEY_1]
|
|
125
|
+
// DB_URI=[SECRET_1]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## ๐ผ Commercial Production Pipelines (Recipes)
|
|
131
|
+
|
|
132
|
+
### 1. AI Mortgage & Loan Underwriting Pipeline (W-2, Paystubs & DTI Calculation)
|
|
133
|
+
*Enables Loan Officers and AI Underwriting bots (e.g. CalChat) to analyze borrower income without violating GLBA or transmitting SSNs to OpenAI/Anthropic.*
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
import OpenAI from 'openai';
|
|
137
|
+
import { sanitize, restore } from '@privacyscrubber/sdk';
|
|
138
|
+
|
|
139
|
+
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
140
|
+
|
|
141
|
+
async function underwriteLoanApplication(w2RawText) {
|
|
142
|
+
// 1. Sanitize borrower W-2 in RAM (SSN, EIN, Employer, Address -> Masked; Wages/Rates -> Preserved)
|
|
143
|
+
const { scrubbedText, tokenMap } = sanitize(w2RawText, { profile: 'Finance' });
|
|
144
|
+
|
|
145
|
+
// 2. Transmit mathematical numbers to LLM for Debt-to-Income (DTI) & qualifying income calculation
|
|
146
|
+
const aiResponse = await openai.chat.completions.create({
|
|
147
|
+
model: 'gpt-4o',
|
|
148
|
+
messages: [
|
|
149
|
+
{ role: 'system', content: 'You are an automated mortgage underwriting assistant. Calculate monthly qualifying income and front-end DTI.' },
|
|
150
|
+
{ role: 'user', content: scrubbedText }
|
|
151
|
+
]
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// 3. Rehydrate borrower name and employer into the final formal credit memo
|
|
155
|
+
const { restoredText } = restore(aiResponse.choices[0].message.content, tokenMap);
|
|
156
|
+
return restoredText;
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### 2. Blind AI HR Screening Pipeline (EEOC & GDPR Compliant)
|
|
161
|
+
*Strips names, photos, gender markers, contact details, and graduation years from candidate resumes to prevent algorithmic bias while retaining 100% skills, experience, and GPA.*
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
import { sanitize } from '@privacyscrubber/sdk';
|
|
165
|
+
|
|
166
|
+
function prepareCandidateForAIScoring(resumeText) {
|
|
167
|
+
const { scrubbedText, telemetry } = sanitize(resumeText, { profile: 'HR' });
|
|
168
|
+
|
|
169
|
+
// Resume is now completely anonymous (Zero EEOC bias risk)
|
|
170
|
+
// Skills (Python, Kubernetes, Leadership) and achievements are 100% intact.
|
|
171
|
+
return { anonymousResume: scrubbedText, auditReceipt: telemetry };
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 3. B2B Invoice & Expense Reconciliation Pipeline
|
|
176
|
+
*Redacts corporate payment accounts (PCI-DSS), direct deposit info, and signatory names while preserving line items, tax rates (VAT/Sales Tax), quantities, and chart-of-accounts codes.*
|
|
177
|
+
|
|
178
|
+
```javascript
|
|
179
|
+
import { sanitize, restore } from '@privacyscrubber/sdk';
|
|
180
|
+
|
|
181
|
+
function processVendorInvoice(invoiceText) {
|
|
182
|
+
const { scrubbedText, tokenMap } = sanitize(invoiceText, { profile: 'Accounting' });
|
|
183
|
+
// Line items ($350.00, $1,200.00) and general ledger accounts remain fully intact for AI categorization.
|
|
184
|
+
return { scrubbedText, tokenMap };
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## ๐ License Activation & Commercial Tiers
|
|
191
|
+
|
|
192
|
+
PrivacyScrubber works free out-of-the-box with standard limits:
|
|
193
|
+
- **Free Tier**: Up to 15,000 characters per request, General & standard profiles.
|
|
194
|
+
- **PRO & TEAMS Tiers**: Unlimited throughput, all 23 specialized compliance profiles, custom regex rules, multi-user sync.
|
|
195
|
+
|
|
196
|
+
### Activating Your License
|
|
197
|
+
|
|
198
|
+
Set the environment variable or pass your key explicitly:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
export PRIVACYSCRUBBER_KEY="your-license-key-here"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
```javascript
|
|
205
|
+
import { sanitize, validateLicense } from '@privacyscrubber/sdk';
|
|
206
|
+
|
|
207
|
+
// Validate programmatically
|
|
208
|
+
const license = validateLicense(process.env.PRIVACYSCRUBBER_KEY);
|
|
209
|
+
console.log(`Active Tier: ${license.tier}, Valid: ${license.valid}`);
|
|
210
|
+
|
|
211
|
+
// Or pass directly in options
|
|
212
|
+
const result = sanitize(largeDocument, {
|
|
213
|
+
licenseKey: 'PS-PRO-XXXX-XXXX',
|
|
214
|
+
profile: 'Medical'
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
To purchase or upgrade a license, visit:
|
|
219
|
+
๐ **[PrivacyScrubber Pricing & Licensing](https://privacyscrubber.com/pricing?utm_source=npm_core&utm_medium=readme&utm_campaign=dev_upsell)**
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## ๐ก๏ธ Supported Compliance Frameworks
|
|
224
|
+
|
|
225
|
+
- **GDPR (Art. 4)**: Direct & indirect personal identifiers.
|
|
226
|
+
- **HIPAA (ยง164.514 Safe Harbor)**: 18 protected health information identifiers (MRN, dates, clinical IDs).
|
|
227
|
+
- **PCI-DSS v4.0**: Primary Account Numbers (PAN), CVVs, banking tokens.
|
|
228
|
+
- **SOC 2 Type II / ISO 27001 (A.8.11)**: Data masking and access segregation.
|
|
229
|
+
- **NIST SP 800-53**: Automated secrets and credential redaction.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## ๐ Legacy API Compatibility
|
|
234
|
+
|
|
235
|
+
Full backward compatibility is retained for existing integrations using `scrubText` and `unscrubText`:
|
|
236
|
+
|
|
237
|
+
```javascript
|
|
238
|
+
import { scrubText, unscrubText } from '@privacyscrubber/sdk';
|
|
239
|
+
|
|
240
|
+
const result = scrubText("Raw text", [], {}, 'General', {}, true);
|
|
241
|
+
const restored = unscrubText(result.scrubbedText, result.tokenMap);
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## ๐ Ecosystem & Links
|
|
247
|
+
|
|
248
|
+
- ๐ **Web App**: [https://privacyscrubber.com](https://privacyscrubber.com)
|
|
249
|
+
- ๐ **MCP Server**: [@privacyscrubber/mcp-server](https://www.npmjs.com/package/@privacyscrubber/mcp-server)
|
|
250
|
+
- ๐งฉ **Chrome Extension**: [Chrome Web Store](https://chromewebstore.google.com/detail/privacyscrubber/gmmimjcmidhmbjcbgeojpajefebfepco)
|
|
251
|
+
- ๐ **Documentation & Support**: [https://privacyscrubber.com/docs](https://privacyscrubber.com/docs)
|
|
252
|
+
- ๐ฌ **Feedback & Feature Requests**: [https://privacyscrubber.com/feedback](https://privacyscrubber.com/feedback)
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## โ๏ธ License
|
|
257
|
+
|
|
258
|
+
MIT License ยฉ 2026 PrivacyScrubber. Commercial features require an active PRO/TEAMS license.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript Definitions for @privacyscrubber/sdk
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export interface CustomRule {
|
|
6
|
+
name: string;
|
|
7
|
+
regex: RegExp;
|
|
8
|
+
mask?: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type PiiProfile =
|
|
13
|
+
| 'General'
|
|
14
|
+
| 'Dev'
|
|
15
|
+
| 'Medical'
|
|
16
|
+
| 'Financial'
|
|
17
|
+
| 'Legal'
|
|
18
|
+
| 'HR'
|
|
19
|
+
| 'Security'
|
|
20
|
+
| 'Marketing'
|
|
21
|
+
| 'BizOps'
|
|
22
|
+
| 'Sales'
|
|
23
|
+
| 'Support'
|
|
24
|
+
| 'RealEstate'
|
|
25
|
+
| 'Compliance'
|
|
26
|
+
| 'CCPA'
|
|
27
|
+
| 'Engineering'
|
|
28
|
+
| 'Agents'
|
|
29
|
+
| 'Academic'
|
|
30
|
+
| 'Creative'
|
|
31
|
+
| 'Tech'
|
|
32
|
+
| 'Personal'
|
|
33
|
+
| 'WealthMgmt'
|
|
34
|
+
| 'Insurance'
|
|
35
|
+
| 'Accounting'
|
|
36
|
+
| 'Pharma'
|
|
37
|
+
| 'Underwriting'
|
|
38
|
+
| 'Crypto'
|
|
39
|
+
| 'Cloud'
|
|
40
|
+
| 'E-Commerce'
|
|
41
|
+
| 'Education'
|
|
42
|
+
| 'Telecom'
|
|
43
|
+
| 'Cybersecurity'
|
|
44
|
+
| 'Gaming'
|
|
45
|
+
| 'Government'
|
|
46
|
+
| 'Automotive'
|
|
47
|
+
| 'SocialMedia'
|
|
48
|
+
| 'Logistics'
|
|
49
|
+
| 'Energy'
|
|
50
|
+
| 'Hospitality'
|
|
51
|
+
| 'Travel'
|
|
52
|
+
| 'Defense'
|
|
53
|
+
| string;
|
|
54
|
+
|
|
55
|
+
export interface SanitizeOptions {
|
|
56
|
+
/** Target compliance profile (Default: 'General'). */
|
|
57
|
+
profile?: PiiProfile;
|
|
58
|
+
/** PrivacyScrubber PRO / TEAMS / SDK / ENTERPRISE license key. */
|
|
59
|
+
licenseKey?: string;
|
|
60
|
+
/** Custom regex rules array. */
|
|
61
|
+
customRules?: CustomRule[];
|
|
62
|
+
/** Custom label mappings (e.g. { NAME: 'INDIVIDUAL' }). */
|
|
63
|
+
tokenLabelMap?: Record<string, string>;
|
|
64
|
+
/** Pre-existing token session map for stateful conversation tracking. */
|
|
65
|
+
existingSessionMap?: Record<string, string>;
|
|
66
|
+
/** Whether to generate a CISO Markdown audit receipt (Default: true). */
|
|
67
|
+
generateReceipt?: boolean;
|
|
68
|
+
/** Throw PrivacyScrubberLicenseError when free tier limits are reached (Default: true). */
|
|
69
|
+
throwOnLimit?: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface LicenseMetadata {
|
|
73
|
+
isPro: boolean;
|
|
74
|
+
tier: 'PRO' | 'TEAMS' | 'SDK' | 'ENTERPRISE' | 'OEM' | 'FREE';
|
|
75
|
+
limit: number;
|
|
76
|
+
upgradeUrl?: string;
|
|
77
|
+
recommendation?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface AuditTelemetry {
|
|
81
|
+
totalCount: number;
|
|
82
|
+
entities: Record<string, number>;
|
|
83
|
+
types: string[];
|
|
84
|
+
riskLevel: 'CLEAN (ZERO PII)' | 'LOW EXPOSURE' | 'MODERATE EXPOSURE' | 'CRITICAL (HIGH EXPOSURE)';
|
|
85
|
+
frameworksList: string[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface SanitizeResult {
|
|
89
|
+
/** The scrubbed text with PII/secrets masked. */
|
|
90
|
+
scrubbedText: string;
|
|
91
|
+
/** The volatile in-memory token map needed to restore data. */
|
|
92
|
+
tokenMap: Record<string, string>;
|
|
93
|
+
/** Total number of tokens masked. */
|
|
94
|
+
count: number;
|
|
95
|
+
/** Execution duration in milliseconds. */
|
|
96
|
+
executionMs: number;
|
|
97
|
+
/** Active license state and tier info. */
|
|
98
|
+
license: LicenseMetadata;
|
|
99
|
+
/** CISO compliance telemetry. */
|
|
100
|
+
telemetry: AuditTelemetry;
|
|
101
|
+
/** Markdown formatted compliance audit receipt. */
|
|
102
|
+
auditReceipt: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface RestoreResult {
|
|
106
|
+
/** The desanitized text with original values restored. */
|
|
107
|
+
restoredText: string;
|
|
108
|
+
/** Number of tokens restored. */
|
|
109
|
+
restoredCount: number;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface LicenseValidationResult {
|
|
113
|
+
valid: boolean;
|
|
114
|
+
tier: 'PRO' | 'TEAMS' | 'SDK' | 'ENTERPRISE' | 'OEM' | null;
|
|
115
|
+
expires: number | null;
|
|
116
|
+
error: string | null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export class PrivacyScrubberLicenseError extends Error {
|
|
120
|
+
tier: string;
|
|
121
|
+
currentLength: number;
|
|
122
|
+
limit: number;
|
|
123
|
+
profile: string;
|
|
124
|
+
upgradeUrl: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function validateLicense(key: string): LicenseValidationResult;
|
|
128
|
+
export function validateLicenseKey(key: string): 'PRO' | 'TEAMS' | 'SDK' | 'ENTERPRISE' | 'OEM' | null;
|
|
129
|
+
|
|
130
|
+
export function buildAuditTelemetry(currentTokenMap?: Record<string, string> | string[]): AuditTelemetry;
|
|
131
|
+
export function formatAuditReceipt(telemetry: AuditTelemetry): string;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Sanitizes input text, masking all PII and secrets with zero network requests.
|
|
135
|
+
*/
|
|
136
|
+
export function sanitize(text: string, options?: SanitizeOptions): SanitizeResult;
|
|
137
|
+
export function scrub(text: string, options?: SanitizeOptions): SanitizeResult;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Restores masked tokens in AI outputs back to original plaintext in-memory.
|
|
141
|
+
*/
|
|
142
|
+
export function restore(aiResponse: string, tokenMap: Record<string, string>): RestoreResult;
|
|
143
|
+
export function unscrub(aiResponse: string, tokenMap: Record<string, string>): RestoreResult;
|
|
144
|
+
|
|
145
|
+
export interface EngineConfig {
|
|
146
|
+
licenseKey?: string;
|
|
147
|
+
apiKey?: string;
|
|
148
|
+
defaultProfile?: PiiProfile;
|
|
149
|
+
profile?: PiiProfile;
|
|
150
|
+
customRules?: CustomRule[];
|
|
151
|
+
tokenLabelMap?: Record<string, string>;
|
|
152
|
+
generateReceipt?: boolean;
|
|
153
|
+
initialSessionMap?: Record<string, string>;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export class PrivacyScrubberEngine {
|
|
157
|
+
constructor(config?: EngineConfig);
|
|
158
|
+
setLicenseKey(key: string): LicenseValidationResult;
|
|
159
|
+
sanitize(text: string, options?: SanitizeOptions & { persistSession?: boolean }): SanitizeResult;
|
|
160
|
+
restore(aiResponse: string, tokenMap?: Record<string, string> | null): RestoreResult;
|
|
161
|
+
resetSession(): void;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Transparent zero-trust wrapper for OpenAI SDK client.
|
|
166
|
+
*/
|
|
167
|
+
export function wrapOpenAI<T = any>(openaiClient: T, options?: SanitizeOptions): T;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Middleware transform for LangChain and LlamaIndex pipelines.
|
|
171
|
+
*/
|
|
172
|
+
export function createLangChainTransform(options?: SanitizeOptions): {
|
|
173
|
+
preprocess: (input: string) => SanitizeResult;
|
|
174
|
+
postprocess: (output: string, tokenMap: Record<string, string>) => RestoreResult;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// Legacy exports
|
|
178
|
+
export function scrubText(
|
|
179
|
+
text: string,
|
|
180
|
+
customRules?: any[],
|
|
181
|
+
tokenLabelMap?: Record<string, string>,
|
|
182
|
+
profile?: string,
|
|
183
|
+
existingSessionMap?: Record<string, string>,
|
|
184
|
+
isPro?: boolean
|
|
185
|
+
): {
|
|
186
|
+
scrubbedText: string;
|
|
187
|
+
tokenMap: Record<string, string>;
|
|
188
|
+
count: number;
|
|
189
|
+
executionMs: number;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export function unscrubText(
|
|
193
|
+
aiResponse: string,
|
|
194
|
+
tokenMap: Record<string, string>
|
|
195
|
+
): {
|
|
196
|
+
restoredText: string;
|
|
197
|
+
restoredCount: number;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
declare const defaultExport: {
|
|
201
|
+
sanitize: typeof sanitize;
|
|
202
|
+
scrub: typeof scrub;
|
|
203
|
+
restore: typeof restore;
|
|
204
|
+
unscrub: typeof unscrub;
|
|
205
|
+
validateLicense: typeof validateLicense;
|
|
206
|
+
validateLicenseKey: typeof validateLicenseKey;
|
|
207
|
+
buildAuditTelemetry: typeof buildAuditTelemetry;
|
|
208
|
+
formatAuditReceipt: typeof formatAuditReceipt;
|
|
209
|
+
PrivacyScrubberEngine: typeof PrivacyScrubberEngine;
|
|
210
|
+
PrivacyScrubberLicenseError: typeof PrivacyScrubberLicenseError;
|
|
211
|
+
wrapOpenAI: typeof wrapOpenAI;
|
|
212
|
+
createLangChainTransform: typeof createLangChainTransform;
|
|
213
|
+
scrubText: typeof scrubText;
|
|
214
|
+
unscrubText: typeof unscrubText;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
export default defaultExport;
|