@privacyscrubber/sdk 2.2.3 → 2.2.5
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 +52 -1
- package/cli.js +4 -4
- package/index.d.ts +123 -0
- package/index.js +648 -0
- package/package.json +1 -1
- package/ps-license-manager.js +1 -1
- package/ps-pii-engine.cjs +1 -1
- package/scrubber-core.cjs +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/@privacyscrubber/sdk)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
[-06b6d4.svg)](https://privacyscrubber.com/patents/)
|
|
10
|
+
[](https://datatracker.ietf.org/doc/draft-sibiryakov-ztds-protocol/)
|
|
10
11
|
[](https://github.com/moxno/privacyscrubber-mcp)
|
|
11
12
|
|
|
12
13
|
> **In-Process Consumer Privacy Defense & Pre-Emptive Interception Engine**
|
|
@@ -49,6 +50,26 @@ The official Node.js / TypeScript programmatic SDK for [PrivacyScrubber.com](htt
|
|
|
49
50
|
| **Cloud DLP Egress Fees & Latency** | **$1,500–$4,000/mo** + 350ms added prompt delay | **0 egress bytes**: Pure in-memory execution, 0 network dependencies |
|
|
50
51
|
| **Third-Party Subprocessor Vendor Audit** | **$25,000+** per enterprise vendor review (SOC 2, DPA, Legal) | **0 Subprocessors**: No third party touches data; zero security review backlog |
|
|
51
52
|
|
|
53
|
+
### 🛡️ Architecture & Security Deep-Dive (CISO & DevSecOps Verification)
|
|
54
|
+
|
|
55
|
+
Backend engineering and InfoSec review boards consistently ask four core architectural questions before clearing SDK dependencies:
|
|
56
|
+
|
|
57
|
+
1. **Volatile In-Memory Isolation (Zero Network Egress)**:
|
|
58
|
+
All string masking, token mapping, and session states execute strictly in the host Node.js process V8 heap memory. The SDK initiates **zero outbound network connections**, writes zero files to persistent disk, and communicates over zero IPC sockets. It operates seamlessly in 100% air-gapped VPCs and AWS Lambda / Google Cloud Run container environments.
|
|
59
|
+
2. **Deterministic Lookarounds vs Stochastic NER (Presidio/BERT)**:
|
|
60
|
+
To scrub data with cloud NER models, cleartext must first traverse an internal or external network to reach a Python microservice, violating zero-trust at step zero. Furthermore, stochastic NLP models hallucinate, drift between model weights, and consume 500MB+ RAM with cold starts. `@privacyscrubber/sdk` utilizes deterministic abstract syntax lookarounds with 30 pre-compiled sector profiles (HIPAA EHR numbers, legal privilege codes, SWIFT/IBAN structures, and cloud API tokens) guaranteeing 100% reproducible results in <1ms.
|
|
61
|
+
3. **Fuzzy Reverse Unscrubbing (LLM Token Drift Protection)**:
|
|
62
|
+
When external LLMs reformat or alter tokens in their completions (e.g. changing `[NAME_1]` to `[Name 1]`, altering casing, or adding Markdown formatting `**[NAME_1]**`), our fault-tolerant unscrubbing engine maps tokens back to original cleartext without corruption.
|
|
63
|
+
4. **Local Cryptographic Audit Receipts**:
|
|
64
|
+
Generate signed SHA-256 session integrity receipts for enterprise SIEM ingestion (Splunk, Datadog, Elastic) directly within your backend microservice, proving regulatory compliance (GDPR Art. 25/32, HIPAA § 164.514, SOC 2 CC6.6) with zero telemetry leaving your VPC.
|
|
65
|
+
|
|
66
|
+
> 📚 **Academic & Standards Track SSOT**:
|
|
67
|
+
> - **IETF Specification**: [draft-sibiryakov-ztds-protocol-00](https://datatracker.ietf.org/doc/draft-sibiryakov-ztds-protocol/)
|
|
68
|
+
> - **CERN / Zenodo Foundation**: [DOI 10.5281/zenodo.22058770](https://doi.org/10.5281/zenodo.22058770)
|
|
69
|
+
> - **Center for Open Science (OSF) Benchmark**: [DOI 10.17605/OSF.IO/5BYJF](https://doi.org/10.17605/OSF.IO/5BYJF)
|
|
70
|
+
> - **Law Archive Treatise**: [osf.io/preprints/lawarchive/4wc86/](https://osf.io/preprints/lawarchive/4wc86/)
|
|
71
|
+
> - **Patent Pending**: Israel Patent Office Application `IL 331905` (WIPO DAS Code: `B17B`)
|
|
72
|
+
|
|
52
73
|
---
|
|
53
74
|
|
|
54
75
|
## 📦 Installation
|
|
@@ -402,6 +423,29 @@ test('pipeline prompt does not leak PII to third-party LLM', () => {
|
|
|
402
423
|
assert.ok(!scrubbedText.includes(mockUserData.email));
|
|
403
424
|
assert.ok(!scrubbedText.includes(mockUserData.apiKey));
|
|
404
425
|
});
|
|
426
|
+
### 11. Client-Side Website Form Interceptor (`@privacyscrubber/sdk/browser`)
|
|
427
|
+
|
|
428
|
+
Intercept customer support forms, loan applications, and lead generation inputs inside the browser DOM before network transmission. Dispatches safe surrogate tokens to public CRMs (Zendesk, HubSpot) or LLMs while isolating the encrypted `tokenMap` in your private database:
|
|
429
|
+
|
|
430
|
+
```html
|
|
431
|
+
<script type="module">
|
|
432
|
+
import { sanitize } from '@privacyscrubber/sdk/browser';
|
|
433
|
+
|
|
434
|
+
document.querySelector('#support-form').addEventListener('submit', async (e) => {
|
|
435
|
+
e.preventDefault();
|
|
436
|
+
const textarea = e.target.querySelector('textarea');
|
|
437
|
+
|
|
438
|
+
// 1. Sanitize in local browser RAM (<0.4ms)
|
|
439
|
+
const { scrubbedText, tokenMap } = sanitize(textarea.value, { profile: 'support' });
|
|
440
|
+
|
|
441
|
+
// 2. Transmit sanitized prompt to public CRM / AI (Zero PII Egress)
|
|
442
|
+
await fetch('/api/tickets', {
|
|
443
|
+
method: 'POST',
|
|
444
|
+
headers: { 'Content-Type': 'application/json' },
|
|
445
|
+
body: JSON.stringify({ message: scrubbedText, tokenMap })
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
</script>
|
|
405
449
|
```
|
|
406
450
|
|
|
407
451
|
---
|
|
@@ -498,7 +542,14 @@ The Zero-Trust Data Sanitization (ZTDS) architecture, in-memory deterministic to
|
|
|
498
542
|
|
|
499
543
|
- **Patent Office:** State of Israel Ministry of Justice, Patent Office (ILPO)
|
|
500
544
|
- **Application Number:** `331905` (Tracking ID: `94221`)
|
|
501
|
-
- **
|
|
545
|
+
- **WIPO DAS Access Control Code:** `B17B` (World Intellectual Property Organization Digital Access Service electronic priority document exchange for USPTO, EPO, CNIPA, and PCT receiving offices)
|
|
546
|
+
- **Filing / Priority Date:** September 14, 2026 (Paris Convention Art. 4 & 35 U.S.C. § 119 Priority locked through September 14, 2027)
|
|
502
547
|
- **Official Title:** *SYSTEM AND METHOD FOR CLIENT-SIDE ZERO-TRUST DATA SANITIZATION AND CRYPTOGRAPHIC SESSION HANDOFF IN ARTIFICIAL INTELLIGENCE WORKFLOWS*
|
|
503
548
|
- **Virtual Patent Marking:** [privacyscrubber.com/patents/](https://privacyscrubber.com/patents/) in accordance with 35 U.S.C. § 287(a).
|
|
504
549
|
|
|
550
|
+
### 🌐 Internet Engineering Task Force (IETF) Specification
|
|
551
|
+
- **Specification Title:** *The Zero-Trust Data Sanitization (ZTDS) Protocol for Frontier Artificial Intelligence Ingestion*
|
|
552
|
+
- **Standards Track:** IETF Internet Standard Track
|
|
553
|
+
- **IETF Datatracker:** [https://datatracker.ietf.org/doc/draft-sibiryakov-ztds-protocol/](https://datatracker.ietf.org/doc/draft-sibiryakov-ztds-protocol/)
|
|
554
|
+
- **Archive Plaintext:** [https://www.ietf.org/archive/id/draft-sibiryakov-ztds-protocol-00.txt](https://www.ietf.org/archive/id/draft-sibiryakov-ztds-protocol-00.txt)
|
|
555
|
+
|
package/cli.js
CHANGED
|
@@ -21,7 +21,7 @@ const __dirname = path.dirname(__filename);
|
|
|
21
21
|
const args = process.argv.slice(2);
|
|
22
22
|
|
|
23
23
|
if (args.includes('--version') || args.includes('-v')) {
|
|
24
|
-
let version = '2.2.
|
|
24
|
+
let version = '2.2.5';
|
|
25
25
|
try {
|
|
26
26
|
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
|
|
27
27
|
version = pkg.version || version;
|
|
@@ -203,7 +203,7 @@ function handleExecution(text) {
|
|
|
203
203
|
|
|
204
204
|
if (isVerifyCi) {
|
|
205
205
|
if (!text || !text.trim()) {
|
|
206
|
-
console.log(`>
|
|
206
|
+
console.log(`> **Verified by PrivacyScrubber (ZTDS Standard)**\n> * **Status:** PASSED · 0 PII / 0 Secrets detected in prompt pipeline (Empty payload)\n> * **Execution:** Local RAM (<1ms) · 0 Network Egress Bytes\n> * **Compliance Spec:** [Zero-Trust Data Sanitization (ZTDS)](https://privacyscrubber.com/solutions/engineering/zero-trust-ai-data-sanitization?src=ci_stamp) | [Developer SDK ($199/mo)](https://privacyscrubber.com/pricing?tier=sdk&src=ci_stamp)`);
|
|
207
207
|
process.exit(0);
|
|
208
208
|
}
|
|
209
209
|
|
|
@@ -212,8 +212,8 @@ function handleExecution(text) {
|
|
|
212
212
|
const hash = crypto.createHash('sha256').update(scrubbedText).digest('hex').slice(0, 16);
|
|
213
213
|
|
|
214
214
|
const stamp = `
|
|
215
|
-
>
|
|
216
|
-
> * **Status:**
|
|
215
|
+
> **Verified by PrivacyScrubber (ZTDS Standard)**
|
|
216
|
+
> * **Status:** PASSED · ${maskedCount} item(s) protected (${telemetry?.riskLevel || 'CLEAN'})
|
|
217
217
|
> * **Execution:** Local RAM (<1ms) · 0 Network Egress Bytes
|
|
218
218
|
> * **Audit Hash:** \`${hash}\` (Zero-Trust Verified)
|
|
219
219
|
> * **Compliance Spec:** [Zero-Trust Data Sanitization (ZTDS)](https://privacyscrubber.com/solutions/engineering/zero-trust-ai-data-sanitization?src=ci_stamp) | [Developer SDK ($199/mo)](https://privacyscrubber.com/pricing?tier=sdk&src=ci_stamp)
|
package/index.d.ts
CHANGED
|
@@ -136,6 +136,62 @@ export function validateLicenseKey(key: string): 'PRO' | 'TEAMS' | 'SDK' | 'ENTE
|
|
|
136
136
|
export function buildAuditTelemetry(currentTokenMap?: Record<string, string> | string[]): AuditTelemetry;
|
|
137
137
|
export function formatAuditReceipt(telemetry: AuditTelemetry): string;
|
|
138
138
|
|
|
139
|
+
export interface AuditEventData {
|
|
140
|
+
timestamp?: string;
|
|
141
|
+
version?: string;
|
|
142
|
+
protocol?: string;
|
|
143
|
+
event?: string;
|
|
144
|
+
riskLevel?: string;
|
|
145
|
+
tokensMasked?: number;
|
|
146
|
+
entities?: Record<string, number>;
|
|
147
|
+
frameworks?: string[];
|
|
148
|
+
sessionHash?: string;
|
|
149
|
+
source?: string;
|
|
150
|
+
action?: string;
|
|
151
|
+
organization?: string;
|
|
152
|
+
department?: string;
|
|
153
|
+
executionMs?: number;
|
|
154
|
+
metadata?: Record<string, any>;
|
|
155
|
+
[key: string]: any;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function formatCefEvent(eventData?: AuditEventData): string;
|
|
159
|
+
export function formatSyslogEvent(eventData?: AuditEventData): string;
|
|
160
|
+
export function formatJsonlEvent(eventData?: AuditEventData): string;
|
|
161
|
+
|
|
162
|
+
export interface AuditLoggerOptions {
|
|
163
|
+
format?: 'jsonl' | 'cef' | 'syslog' | 'json';
|
|
164
|
+
destination?: string | any;
|
|
165
|
+
organization?: string;
|
|
166
|
+
department?: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface AuditLogger {
|
|
170
|
+
formatEvent(eventData: AuditEventData): string;
|
|
171
|
+
logSanitization(result: SanitizeResult | Record<string, string>, context?: any): string;
|
|
172
|
+
logEvent(eventData: AuditEventData): string;
|
|
173
|
+
log(eventData: AuditEventData): string;
|
|
174
|
+
getEntries(): string[];
|
|
175
|
+
getBuffer(): string[];
|
|
176
|
+
clear(): void;
|
|
177
|
+
clearBuffer(): void;
|
|
178
|
+
format: string;
|
|
179
|
+
destination: any;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function createAuditLogger(options?: AuditLoggerOptions): AuditLogger;
|
|
183
|
+
|
|
184
|
+
export interface GenerateAuditReportOptions {
|
|
185
|
+
companyName?: string;
|
|
186
|
+
department?: string;
|
|
187
|
+
format?: 'markdown' | 'json' | 'summary' | 'cef' | 'syslog' | 'jsonl';
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function generateAuditReport(
|
|
191
|
+
sessionMap?: Record<string, string>,
|
|
192
|
+
options?: GenerateAuditReportOptions
|
|
193
|
+
): any;
|
|
194
|
+
|
|
139
195
|
export interface ProcurementMemoOptions {
|
|
140
196
|
/** Target application or pipeline name (Default: 'Internal AI Applications & LLM Pipelines'). */
|
|
141
197
|
appName?: string;
|
|
@@ -202,6 +258,69 @@ export function createLangChainTransform(options?: SanitizeOptions): {
|
|
|
202
258
|
postprocess: (output: string, tokenMap: Record<string, string>) => RestoreResult;
|
|
203
259
|
};
|
|
204
260
|
|
|
261
|
+
export interface LangChainDocument {
|
|
262
|
+
pageContent: string;
|
|
263
|
+
metadata?: Record<string, any>;
|
|
264
|
+
[key: string]: any;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface DocumentTransformerOptions extends SanitizeOptions {
|
|
268
|
+
sensitiveMetadataKeys?: string[];
|
|
269
|
+
attachTelemetry?: boolean;
|
|
270
|
+
attachTokenMap?: boolean;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface DocumentTransformer {
|
|
274
|
+
transformDocuments(documents: LangChainDocument[]): Promise<LangChainDocument[]>;
|
|
275
|
+
invoke(documents: LangChainDocument[]): Promise<LangChainDocument[]>;
|
|
276
|
+
sessionMap: Record<string, string>;
|
|
277
|
+
restore(output: string, tokenMap?: Record<string, string>): RestoreResult;
|
|
278
|
+
resetSession(): void;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export function createDocumentTransformer(options?: DocumentTransformerOptions): DocumentTransformer;
|
|
282
|
+
export const createLangChainDocumentTransformer: typeof createDocumentTransformer;
|
|
283
|
+
|
|
284
|
+
export interface LlamaIndexNode {
|
|
285
|
+
text?: string;
|
|
286
|
+
pageContent?: string;
|
|
287
|
+
getContent?: () => string;
|
|
288
|
+
setContent?: (text: string) => void;
|
|
289
|
+
metadata?: Record<string, any>;
|
|
290
|
+
[key: string]: any;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface LlamaIndexTransform {
|
|
294
|
+
transform<T extends LlamaIndexNode | LlamaIndexNode[]>(nodes: T): T;
|
|
295
|
+
sessionMap: Record<string, string>;
|
|
296
|
+
restore(text: string, map?: Record<string, string>): RestoreResult;
|
|
297
|
+
resetSession(): void;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function createLlamaIndexTransform(options?: SanitizeOptions): LlamaIndexTransform;
|
|
301
|
+
|
|
302
|
+
export interface VectorIngestionGuardOptions extends SanitizeOptions {
|
|
303
|
+
sensitiveMetadataKeys?: string[];
|
|
304
|
+
autoRestoreResults?: boolean;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface VectorIngestionGuard {
|
|
308
|
+
sanitizeRecords<T = any>(records: T): T;
|
|
309
|
+
sanitizeQuery(query: string): {
|
|
310
|
+
query: string;
|
|
311
|
+
rawQuery: string;
|
|
312
|
+
tokensDetected: number;
|
|
313
|
+
tokenMap: Record<string, string>;
|
|
314
|
+
};
|
|
315
|
+
restoreSearchResults<T = any>(results: T, customTokenMap?: Record<string, string> | null): T;
|
|
316
|
+
wrapVectorStore<T = any>(vectorStore: T): T;
|
|
317
|
+
sessionMap: Record<string, string>;
|
|
318
|
+
restore(text: string, map?: Record<string, string>): RestoreResult;
|
|
319
|
+
resetSession(): void;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export function createVectorIngestionGuard(options?: VectorIngestionGuardOptions): VectorIngestionGuard;
|
|
323
|
+
|
|
205
324
|
export interface ApplyPatchOptions {
|
|
206
325
|
tokenMap?: Record<string, string>;
|
|
207
326
|
engine?: PrivacyScrubberEngine;
|
|
@@ -444,6 +563,10 @@ declare const defaultExport: {
|
|
|
444
563
|
PrivacyScrubberLicenseError: typeof PrivacyScrubberLicenseError;
|
|
445
564
|
wrapOpenAI: typeof wrapOpenAI;
|
|
446
565
|
createLangChainTransform: typeof createLangChainTransform;
|
|
566
|
+
createDocumentTransformer: typeof createDocumentTransformer;
|
|
567
|
+
createLangChainDocumentTransformer: typeof createLangChainDocumentTransformer;
|
|
568
|
+
createLlamaIndexTransform: typeof createLlamaIndexTransform;
|
|
569
|
+
createVectorIngestionGuard: typeof createVectorIngestionGuard;
|
|
447
570
|
createSanitizeStream: typeof createSanitizeStream;
|
|
448
571
|
applyPatch: typeof applyPatch;
|
|
449
572
|
restoreToFile: typeof restoreToFile;
|