@privacyscrubber/sdk 2.4.5 → 2.4.7

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/index.d.ts CHANGED
@@ -120,6 +120,14 @@ export interface IpHoldings {
120
120
  trademark: string;
121
121
  }
122
122
 
123
+ export interface AgenticProtocolMetadata {
124
+ protocolsSupported: string[];
125
+ agentCardUrl: string;
126
+ ztdsStandardCardUrl: string;
127
+ regulatorySafeHarbor: string[];
128
+ zeroCleartextEgress: boolean;
129
+ }
130
+
123
131
  export interface AuditTelemetry {
124
132
  totalCount: number;
125
133
  entities: Record<string, number>;
@@ -128,6 +136,7 @@ export interface AuditTelemetry {
128
136
  frameworksList: string[];
129
137
  statutoryCitations?: StatutoryCitation[];
130
138
  ipHoldings?: IpHoldings;
139
+ agenticProtocol?: AgenticProtocolMetadata;
131
140
  }
132
141
 
133
142
  export interface SanitizeResult {
@@ -256,17 +265,67 @@ export interface ProcurementMemoOptions {
256
265
  */
257
266
  export function generateProcurementMemo(options?: ProcurementMemoOptions): string;
258
267
 
268
+ export const SDK_VERSION: string;
269
+ export const PSR2_VERSION: 'PSR-2';
270
+ export const PSR2_STATEMENTS: {
271
+ measured: string[];
272
+ byDesign: string[];
273
+ limits: string[];
274
+ };
275
+ export const DEVOPS_SECRETS_DETECTOR: Array<{
276
+ name: string;
277
+ regex: RegExp;
278
+ label: string;
279
+ }>;
280
+
281
+ export interface Psr2Receipt {
282
+ version: string;
283
+ timestamp: string;
284
+ outputSha256: string | null;
285
+ manifestSha256: string;
286
+ entityCounts: string;
287
+ tokensTotal: number;
288
+ tokensPresentInOutput: number | null;
289
+ canonical: string;
290
+ receiptSha256: string;
291
+ }
292
+
293
+ export function buildPsr2Receipt(tokenMap?: Record<string, string>, timestamp?: string): Psr2Receipt;
294
+ export function psr2Lines(receipt: Psr2Receipt): string[];
295
+ export function _resetCommunityNoticeForTesting(): void;
296
+ export function _resetDevSecretNoticeForTesting(): void;
297
+
259
298
  /**
260
299
  * Sanitizes input text, masking all PII and secrets with zero network requests.
261
300
  */
262
301
  export function sanitize(text: string, options?: SanitizeOptions): SanitizeResult;
263
302
  export function scrub(text: string, options?: SanitizeOptions): SanitizeResult;
264
303
 
304
+ export interface SanitizeObjectResult<T = any> {
305
+ sanitized: T;
306
+ tokenMap: Record<string, string>;
307
+ count: number;
308
+ executionMs: number;
309
+ telemetry: AuditTelemetry;
310
+ auditReceipt: string;
311
+ }
312
+
313
+ /**
314
+ * Recursively sanitizes all string values within an object, array, Map, or Set.
315
+ */
316
+ export function sanitizeObject<T = any>(obj: T, options?: SanitizeOptions): SanitizeObjectResult<T>;
317
+
265
318
  /**
266
319
  * Restores masked tokens in AI outputs back to original plaintext in-memory.
267
320
  */
268
321
  export function restore(aiResponse: string, tokenMap: Record<string, string>): RestoreResult;
269
322
  export function unscrub(aiResponse: string, tokenMap: Record<string, string>): RestoreResult;
323
+ export function desanitize(aiResponse: string, tokenMap: Record<string, string>): RestoreResult;
324
+
325
+ /**
326
+ * Recursively restores all masked tokens within a sanitized object, array, Map, or Set.
327
+ */
328
+ export function restoreObject<T = any>(obj: T, tokenMap?: Record<string, string>): T;
270
329
 
271
330
  export interface EngineConfig {
272
331
  licenseKey?: string;
@@ -279,23 +338,98 @@ export interface EngineConfig {
279
338
  tokenLabelMap?: Record<string, string>;
280
339
  generateReceipt?: boolean;
281
340
  initialSessionMap?: Record<string, string>;
341
+ ignoreList?: string[] | Set<string>;
342
+ maxSessionTokens?: number;
282
343
  }
283
344
 
284
345
  export class PrivacyScrubberEngine {
346
+ sessionMap: Record<string, string>;
347
+ ignoreList: Set<string>;
285
348
  constructor(config?: EngineConfig);
286
349
  setLicenseKey(key: string): LicenseValidationResult;
287
- sanitize(text: string, options?: SanitizeOptions & { persistSession?: boolean }): SanitizeResult;
350
+ sanitize(text: string, options?: SanitizeOptions & { persistSession?: boolean; maxSessionTokens?: number }): SanitizeResult;
288
351
  restore(aiResponse: string, tokenMap?: Record<string, string> | null): RestoreResult;
289
352
  resetSession(): void;
353
+ markFalsePositive(token: string): { success: boolean; token?: string; original?: string; ignoreListSize?: number; reason?: string };
354
+ clearIgnoreList(): void;
290
355
  createStreamRestorer(tokenMap?: Record<string, string> | null, options?: any): StreamTokenRestorer;
291
356
  wrapStream<T = any>(stream: AsyncIterable<T>, tokenMap?: Record<string, string> | null, options?: any): AsyncGenerator<any, void, unknown>;
292
357
  }
293
358
 
294
359
  /**
295
- * Transparent zero-trust wrapper for OpenAI SDK client.
360
+ * Transparent zero-trust wrapper for OpenAI SDK client (chat.completions.create & responses.create).
296
361
  */
297
362
  export function wrapOpenAI<T = any>(openaiClient: T, options?: SanitizeOptions): T;
298
363
 
364
+ /**
365
+ * Transparent zero-trust wrapper for Anthropic SDK client (messages.create).
366
+ */
367
+ export function wrapAnthropic<T = any>(anthropicClient: T, options?: SanitizeOptions): T;
368
+
369
+ /**
370
+ * Transparent zero-trust wrapper for Google Gemini SDKs (@google/genai and @google/generative-ai).
371
+ * Sanitizes string/Part[]/Content[] prompts and systemInstruction in RAM and restores tokens in sync and streaming responses.
372
+ */
373
+ export function wrapGemini<T = any>(geminiClientOrModel: T, options?: SanitizeOptions & { engine?: PrivacyScrubberEngine }): T;
374
+ export const wrapGoogleGenAI: typeof wrapGemini;
375
+
376
+ /**
377
+ * Universal drop-in HTTP/SSE fetch wrapper for any OpenAI-compatible or custom LLM SDK
378
+ * (OpenAI, Anthropic, OpenRouter, Groq, DeepSeek, Mistral, Together, Ollama, Cloudflare AI Gateway).
379
+ */
380
+ export interface PrivacyFetchOptions extends SanitizeOptions {
381
+ fetch?: typeof fetch;
382
+ engine?: PrivacyScrubberEngine;
383
+ sanitizeInputs?: boolean;
384
+ sanitizeOutputs?: boolean;
385
+ streamingOptions?: any;
386
+ onSanitized?: (telemetry: { url: string; tokenMap: Record<string, string>; tokenCount: number }) => void;
387
+ }
388
+ export function createPrivacyFetch(options?: PrivacyFetchOptions): typeof fetch & { engine: PrivacyScrubberEngine };
389
+
390
+ /**
391
+ * OpenAI Agents SDK (@openai/agents) compatible InputGuardrail and OutputGuardrail factory.
392
+ */
393
+ export interface OpenAIAgentGuardrailsOptions extends SanitizeOptions {
394
+ engine?: PrivacyScrubberEngine;
395
+ inputGuardrailName?: string;
396
+ outputGuardrailName?: string;
397
+ tripwireOnCritical?: boolean;
398
+ tripwireOnAnyPii?: boolean;
399
+ tripwireOnOutputLeak?: boolean;
400
+ mutateInPlace?: boolean;
401
+ }
402
+ export interface OpenAIAgentGuardrailsResult {
403
+ inputGuardrail: {
404
+ name: string;
405
+ execute: (args: { input: any; context?: any; agent?: any }) => Promise<{
406
+ tripwireTriggered: boolean;
407
+ outputInfo: {
408
+ scrubbedInput: any;
409
+ tokenMap: Record<string, string>;
410
+ tokenCount: number;
411
+ riskLevel: string;
412
+ frameworks?: string[];
413
+ telemetry: AuditTelemetry;
414
+ };
415
+ }>;
416
+ };
417
+ outputGuardrail: {
418
+ name: string;
419
+ execute: (args: { agentOutput: any; context?: any; agent?: any }) => Promise<{
420
+ tripwireTriggered: boolean;
421
+ outputInfo: {
422
+ restoredOutput: any;
423
+ restoredCount: number;
424
+ };
425
+ }>;
426
+ };
427
+ inputGuardrails: Array<OpenAIAgentGuardrailsResult['inputGuardrail']>;
428
+ outputGuardrails: Array<OpenAIAgentGuardrailsResult['outputGuardrail']>;
429
+ engine: PrivacyScrubberEngine;
430
+ }
431
+ export function createOpenAIAgentGuardrails(options?: OpenAIAgentGuardrailsOptions): OpenAIAgentGuardrailsResult;
432
+
299
433
  /**
300
434
  * Transparent zero-trust wrapper for Vercel AI SDK language models.
301
435
  * Sanitizes prompts in local RAM and detokenizes streaming and final outputs.
@@ -595,11 +729,15 @@ export function unscrubText(
595
729
  };
596
730
 
597
731
  declare const defaultExport: {
732
+ SDK_VERSION: typeof SDK_VERSION;
598
733
  clean: typeof clean;
599
734
  sanitize: typeof sanitize;
735
+ sanitizeObject: typeof sanitizeObject;
600
736
  scrub: typeof scrub;
601
737
  restore: typeof restore;
738
+ restoreObject: typeof restoreObject;
602
739
  unscrub: typeof unscrub;
740
+ desanitize: typeof desanitize;
603
741
  StreamingDetokenizer: typeof StreamingDetokenizer;
604
742
  createStreamTokenRestorer: typeof createStreamTokenRestorer;
605
743
  createNodeStreamTokenRestorer: typeof createNodeStreamTokenRestorer;
@@ -610,13 +748,28 @@ declare const defaultExport: {
610
748
  validateLicense: typeof validateLicense;
611
749
  validateLicenseKey: typeof validateLicenseKey;
612
750
  buildAuditTelemetry: typeof buildAuditTelemetry;
751
+ buildCisoAuditTelemetry: typeof buildCisoAuditTelemetry;
613
752
  formatAuditReceipt: typeof formatAuditReceipt;
753
+ generateAuditReport: typeof generateAuditReport;
754
+ PSR2_VERSION: typeof PSR2_VERSION;
755
+ PSR2_STATEMENTS: typeof PSR2_STATEMENTS;
756
+ buildPsr2Receipt: typeof buildPsr2Receipt;
757
+ psr2Lines: typeof psr2Lines;
758
+ formatCefEvent: typeof formatCefEvent;
759
+ formatSyslogEvent: typeof formatSyslogEvent;
760
+ formatJsonlEvent: typeof formatJsonlEvent;
761
+ createAuditLogger: typeof createAuditLogger;
614
762
  generateProcurementMemo: typeof generateProcurementMemo;
615
763
  PrivacyScrubberEngine: typeof PrivacyScrubberEngine;
616
764
  PrivacyScrubberLicenseError: typeof PrivacyScrubberLicenseError;
617
765
  wrapOpenAI: typeof wrapOpenAI;
766
+ wrapAnthropic: typeof wrapAnthropic;
767
+ wrapGemini: typeof wrapGemini;
768
+ wrapGoogleGenAI: typeof wrapGoogleGenAI;
618
769
  wrapAiModel: typeof wrapAiModel;
619
770
  wrapAiSdk: typeof wrapAiSdk;
771
+ createPrivacyFetch: typeof createPrivacyFetch;
772
+ createOpenAIAgentGuardrails: typeof createOpenAIAgentGuardrails;
620
773
  createLangChainTransform: typeof createLangChainTransform;
621
774
  createDocumentTransformer: typeof createDocumentTransformer;
622
775
  createLangChainDocumentTransformer: typeof createLangChainDocumentTransformer;
@@ -628,6 +781,7 @@ declare const defaultExport: {
628
781
  createGuardedTools: typeof createGuardedTools;
629
782
  scrubText: typeof scrubText;
630
783
  unscrubText: typeof unscrubText;
784
+ DEVOPS_SECRETS_DETECTOR: typeof DEVOPS_SECRETS_DETECTOR;
631
785
  stripExifMetadata: typeof stripExifMetadata;
632
786
  redactImageBoundingBoxes: typeof redactImageBoundingBoxes;
633
787
  generateSvgRedactionOverlay: typeof generateSvgRedactionOverlay;