@secured-ai/core 0.1.0
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 +41 -0
- package/dist/index.d.ts +529 -0
- package/dist/index.js +5252 -0
- package/dist/privacyClient.worker.d.ts +2 -0
- package/dist/privacyClient.worker.js +5253 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @secured-ai/core
|
|
2
|
+
|
|
3
|
+
Browser-first privacy tooling for detecting sensitive data, obfuscating it before it leaves the client, and restoring protected text with the original values when needed.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @secured-ai/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What it provides
|
|
12
|
+
|
|
13
|
+
- `PrivacyClient` for local PII detection, obfuscation, restoration, text review, sessions, and vault-backed restoration.
|
|
14
|
+
- Built-in detection engines for common sensitive data such as names, emails, phone numbers, addresses, account identifiers, government IDs, URLs, and custom patterns.
|
|
15
|
+
- Browser file privacy helpers for supported documents and data files.
|
|
16
|
+
- TypeScript types for scan results, detected entities, sessions, vault entries, and client configuration.
|
|
17
|
+
|
|
18
|
+
## Basic usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { PrivacyClient } from '@secured-ai/core'
|
|
22
|
+
|
|
23
|
+
const client = new PrivacyClient()
|
|
24
|
+
await client.initialize()
|
|
25
|
+
|
|
26
|
+
const result = await client.obfuscate('Email Jane at jane@example.com')
|
|
27
|
+
|
|
28
|
+
console.log(result.processed)
|
|
29
|
+
console.log(result.sessionId)
|
|
30
|
+
|
|
31
|
+
const restored = await client.restore(result.processed, result.sessionId)
|
|
32
|
+
console.log(restored.restored)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Publishing contents
|
|
36
|
+
|
|
37
|
+
The npm package is built from `dist` only. Source files, tests, coverage output, and source maps are not included in the published package.
|
|
38
|
+
|
|
39
|
+
## Docs
|
|
40
|
+
|
|
41
|
+
See the developer documentation at https://dev-docs.securedai.com/docs.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
declare const ENTITY_TYPES: readonly ["PERSON", "EMAIL", "PHONE", "SSN", "CREDIT_CARD", "CVV", "ORG", "GPE", "LOC", "ADDRESS", "ZIP_CODE", "DATE", "TAX_ID", "INVOICE_NUMBER", "REFERENCE_ID", "MEDICAL_ID", "INSURANCE_ID", "CASE_NUMBER", "LEGAL_CITATION", "DRIVER_LICENSE", "PASSPORT", "IP_ADDRESS", "MAC_ADDRESS", "URL", "ROUTING_NUMBER", "IBAN", "EIN", "ACCOUNT_NUMBER", "TIME", "NORP", "FAC", "PRODUCT", "EVENT", "WORK_OF_ART", "LAW", "LANGUAGE", "QUANTITY", "CARDINAL", "ORDINAL", "PERCENT", "MISC", "CREDIT_CARD_EXPIRY", "CUSTOM"];
|
|
2
|
+
type EntityType = (typeof ENTITY_TYPES)[number];
|
|
3
|
+
type DetectionSource = "regex-patterns" | "compromise-nlp" | "compromise-regex" | "huggingface" | "gliner" | "custom";
|
|
4
|
+
interface SensitiveEntity {
|
|
5
|
+
text: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
confidence: number;
|
|
10
|
+
type: EntityType;
|
|
11
|
+
source?: string;
|
|
12
|
+
fileId?: string;
|
|
13
|
+
fileName?: string;
|
|
14
|
+
}
|
|
15
|
+
interface ExtendedSensitiveEntity extends SensitiveEntity {
|
|
16
|
+
detectionSource: DetectionSource;
|
|
17
|
+
detectionMethod?: string;
|
|
18
|
+
}
|
|
19
|
+
interface DetectionResult {
|
|
20
|
+
entities: ExtendedSensitiveEntity[];
|
|
21
|
+
processingTime: number;
|
|
22
|
+
source: DetectionSource;
|
|
23
|
+
}
|
|
24
|
+
interface PrivacyScanResult {
|
|
25
|
+
entities: ExtendedSensitiveEntity[];
|
|
26
|
+
sensitiveEntities: SensitiveEntity[];
|
|
27
|
+
processingTime: number;
|
|
28
|
+
sourceStats: Record<DetectionSource, number>;
|
|
29
|
+
isClean: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface SessionMapping {
|
|
32
|
+
id: string;
|
|
33
|
+
original: string;
|
|
34
|
+
replacement: string;
|
|
35
|
+
entityType: EntityType;
|
|
36
|
+
position: {
|
|
37
|
+
start: number;
|
|
38
|
+
end: number;
|
|
39
|
+
};
|
|
40
|
+
obfuscationMode?: ObfuscationMode | "custom";
|
|
41
|
+
replacementSource?: ReplacementSource;
|
|
42
|
+
}
|
|
43
|
+
interface PrivacySession {
|
|
44
|
+
sessionId: string;
|
|
45
|
+
mappings: SessionMapping[];
|
|
46
|
+
createdAt: Date;
|
|
47
|
+
processedText: string;
|
|
48
|
+
originalText: string;
|
|
49
|
+
}
|
|
50
|
+
interface SerializedPrivacySession {
|
|
51
|
+
sessionId: string;
|
|
52
|
+
mappings: SessionMapping[];
|
|
53
|
+
createdAt: string;
|
|
54
|
+
processedText: string;
|
|
55
|
+
originalText: string;
|
|
56
|
+
}
|
|
57
|
+
interface TextReviewOccurrence {
|
|
58
|
+
start: number;
|
|
59
|
+
end: number;
|
|
60
|
+
text: string;
|
|
61
|
+
}
|
|
62
|
+
interface TextReviewItem extends SensitiveEntity {
|
|
63
|
+
id: string;
|
|
64
|
+
replacement: string;
|
|
65
|
+
defaultReplacement: string;
|
|
66
|
+
obfuscationMode?: ObfuscationMode | "custom";
|
|
67
|
+
replacementSource?: ReplacementSource;
|
|
68
|
+
isRemoved: boolean;
|
|
69
|
+
isCustomAdded: boolean;
|
|
70
|
+
occurrences: TextReviewOccurrence[];
|
|
71
|
+
}
|
|
72
|
+
interface TextReview {
|
|
73
|
+
originalText: string;
|
|
74
|
+
items: TextReviewItem[];
|
|
75
|
+
}
|
|
76
|
+
interface FinalizedTextReview {
|
|
77
|
+
processedText: string;
|
|
78
|
+
entities: SensitiveEntity[];
|
|
79
|
+
mappings: SessionMapping[];
|
|
80
|
+
sessionId: string;
|
|
81
|
+
session: PrivacySession;
|
|
82
|
+
serializedSession: SerializedPrivacySession;
|
|
83
|
+
hasSensitiveData: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface ObfuscationResult {
|
|
86
|
+
processed: string;
|
|
87
|
+
sessionId: string;
|
|
88
|
+
hasSensitiveData: boolean;
|
|
89
|
+
}
|
|
90
|
+
type ObfuscationMode = "detailed" | "neutral";
|
|
91
|
+
type ReplacementSource = "generated" | "vault" | "thread" | "custom";
|
|
92
|
+
interface ObfuscationOptions {
|
|
93
|
+
threadId?: string | null;
|
|
94
|
+
obfuscationMode?: ObfuscationMode;
|
|
95
|
+
}
|
|
96
|
+
interface TextReviewOptions {
|
|
97
|
+
obfuscationMode?: ObfuscationMode;
|
|
98
|
+
resolveReplacement?: (entity: SensitiveEntity) => string;
|
|
99
|
+
}
|
|
100
|
+
interface RestorationResult {
|
|
101
|
+
restored: string;
|
|
102
|
+
mappingsApplied: number;
|
|
103
|
+
success: boolean;
|
|
104
|
+
}
|
|
105
|
+
interface InitProgressEvent {
|
|
106
|
+
engine: string;
|
|
107
|
+
stage: "downloading" | "loading" | "ready";
|
|
108
|
+
percent: number;
|
|
109
|
+
}
|
|
110
|
+
interface InitProgress {
|
|
111
|
+
overall: number;
|
|
112
|
+
engines: Record<string, number>;
|
|
113
|
+
}
|
|
114
|
+
type PrivacyJobProgress = {
|
|
115
|
+
operation: "initialize";
|
|
116
|
+
event: InitProgressEvent;
|
|
117
|
+
} | {
|
|
118
|
+
operation: "detect";
|
|
119
|
+
phase: "starting" | "running-engines" | "merging" | "done";
|
|
120
|
+
percent: number;
|
|
121
|
+
detail?: string;
|
|
122
|
+
} | {
|
|
123
|
+
operation: "detectInFile";
|
|
124
|
+
phase: "starting" | "extracting-file" | "detecting" | "done";
|
|
125
|
+
percent: number;
|
|
126
|
+
detail?: string;
|
|
127
|
+
} | {
|
|
128
|
+
operation: "obfuscateFile";
|
|
129
|
+
phase: "starting" | "extracting-file" | "resolving-replacements" | "rewriting-file" | "done";
|
|
130
|
+
percent: number;
|
|
131
|
+
detail?: string;
|
|
132
|
+
};
|
|
133
|
+
interface PrivacyJobProgressEvent {
|
|
134
|
+
requestId: string;
|
|
135
|
+
progress: PrivacyJobProgress;
|
|
136
|
+
}
|
|
137
|
+
interface CustomPattern {
|
|
138
|
+
name: string;
|
|
139
|
+
pattern: RegExp;
|
|
140
|
+
entityType: EntityType;
|
|
141
|
+
confidence?: number;
|
|
142
|
+
}
|
|
143
|
+
interface EngineConfig {
|
|
144
|
+
regex?: boolean;
|
|
145
|
+
nlp?: boolean;
|
|
146
|
+
ml?: boolean;
|
|
147
|
+
gliner?: boolean;
|
|
148
|
+
custom?: boolean;
|
|
149
|
+
}
|
|
150
|
+
interface ReplacementPoolConfig {
|
|
151
|
+
[entityType: string]: string[] | undefined;
|
|
152
|
+
}
|
|
153
|
+
interface PrivacyClientConfig {
|
|
154
|
+
engines?: EngineConfig;
|
|
155
|
+
sdkAccessToken?: string;
|
|
156
|
+
baseUrl?: string;
|
|
157
|
+
confidenceThreshold?: number;
|
|
158
|
+
maxProcessingTime?: number;
|
|
159
|
+
disableGLiNERChunking?: boolean;
|
|
160
|
+
replacementPools?: Partial<Record<EntityType, string[]>>;
|
|
161
|
+
debug?: boolean;
|
|
162
|
+
onInitProgress?: (event: InitProgressEvent) => void;
|
|
163
|
+
vault?: PrivacyVaultConfig;
|
|
164
|
+
}
|
|
165
|
+
interface FileProcessingResult {
|
|
166
|
+
entities: ExtendedSensitiveEntity[];
|
|
167
|
+
text: string;
|
|
168
|
+
processingTime: number;
|
|
169
|
+
fileType: SupportedFileType;
|
|
170
|
+
}
|
|
171
|
+
type SupportedFileType = "pdf" | "docx" | "xlsx" | "csv" | "txt" | "json" | "image";
|
|
172
|
+
interface FileObfuscationOptions {
|
|
173
|
+
entities?: SensitiveEntity[];
|
|
174
|
+
extractedText?: string;
|
|
175
|
+
}
|
|
176
|
+
interface IDetectionEngine {
|
|
177
|
+
initialize(onProgress?: (event: InitProgressEvent) => void): Promise<void>;
|
|
178
|
+
detect(text: string): Promise<DetectionResult>;
|
|
179
|
+
isReady(): boolean;
|
|
180
|
+
getName(): string;
|
|
181
|
+
}
|
|
182
|
+
interface IEntityValidator {
|
|
183
|
+
validate(entityType: EntityType, text: string): boolean;
|
|
184
|
+
}
|
|
185
|
+
interface VaultEntry {
|
|
186
|
+
original: string;
|
|
187
|
+
replacement: string;
|
|
188
|
+
type: string;
|
|
189
|
+
}
|
|
190
|
+
interface EncryptedVaultPayload {
|
|
191
|
+
saltB64: string;
|
|
192
|
+
ivB64: string;
|
|
193
|
+
ciphertextB64: string;
|
|
194
|
+
}
|
|
195
|
+
interface EncryptedVaultSnapshot {
|
|
196
|
+
scope: "global" | "thread";
|
|
197
|
+
threadId?: string;
|
|
198
|
+
version: string;
|
|
199
|
+
updatedAt: string;
|
|
200
|
+
payload: EncryptedVaultPayload;
|
|
201
|
+
}
|
|
202
|
+
interface VaultSnapshot {
|
|
203
|
+
scope: "global" | "thread";
|
|
204
|
+
threadId?: string;
|
|
205
|
+
entries: VaultEntry[];
|
|
206
|
+
version: string;
|
|
207
|
+
updatedAt: string;
|
|
208
|
+
}
|
|
209
|
+
interface VaultSnapshotState extends VaultSnapshot {
|
|
210
|
+
fetchedAt: string;
|
|
211
|
+
isStale: boolean;
|
|
212
|
+
}
|
|
213
|
+
interface VaultRepositoryRequestContext {
|
|
214
|
+
cacheNamespace: string | null;
|
|
215
|
+
}
|
|
216
|
+
interface VaultRepository {
|
|
217
|
+
getGlobalSnapshot(context: VaultRepositoryRequestContext): Promise<EncryptedVaultSnapshot | null>;
|
|
218
|
+
getThreadSnapshot?(threadId: string, context: VaultRepositoryRequestContext): Promise<EncryptedVaultSnapshot | null>;
|
|
219
|
+
}
|
|
220
|
+
interface VaultCrypto {
|
|
221
|
+
encryptEntries(entries: VaultEntry[], masterKey: string): Promise<EncryptedVaultPayload>;
|
|
222
|
+
decryptEntries(payload: EncryptedVaultPayload, masterKey: string): Promise<VaultEntry[]>;
|
|
223
|
+
}
|
|
224
|
+
interface VaultCache {
|
|
225
|
+
get(key: string): Promise<string | null>;
|
|
226
|
+
set(key: string, value: string): Promise<void>;
|
|
227
|
+
delete(key: string): Promise<void>;
|
|
228
|
+
clear(): Promise<void>;
|
|
229
|
+
}
|
|
230
|
+
type RuntimeValue<T> = T | (() => Promise<T | null>);
|
|
231
|
+
interface PrivacyVaultConfig {
|
|
232
|
+
repository: VaultRepository;
|
|
233
|
+
masterKey: RuntimeValue<string>;
|
|
234
|
+
cache?: VaultCache;
|
|
235
|
+
cacheNamespace?: RuntimeValue<string>;
|
|
236
|
+
crypto?: VaultCrypto;
|
|
237
|
+
}
|
|
238
|
+
interface VaultStatus {
|
|
239
|
+
isEnabled: boolean;
|
|
240
|
+
isInitialized: boolean;
|
|
241
|
+
activeThreadId: string | null;
|
|
242
|
+
cacheNamespace: string | null;
|
|
243
|
+
hasGlobalSnapshot: boolean;
|
|
244
|
+
isGlobalSnapshotStale: boolean;
|
|
245
|
+
}
|
|
246
|
+
interface VaultResolveOptions {
|
|
247
|
+
threadId?: string | null;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
declare function deobfuscate(content: string, mappings: SessionMapping[]): string;
|
|
251
|
+
|
|
252
|
+
declare class VaultManager {
|
|
253
|
+
private readonly enabled;
|
|
254
|
+
private readonly cache;
|
|
255
|
+
private readonly crypto;
|
|
256
|
+
private readonly repository;
|
|
257
|
+
private readonly masterKeyInput;
|
|
258
|
+
private readonly cacheNamespaceInput?;
|
|
259
|
+
private globalSnapshot;
|
|
260
|
+
private readonly threadSnapshots;
|
|
261
|
+
private readonly runtimeThreadEntries;
|
|
262
|
+
private activeThreadId;
|
|
263
|
+
private pendingEntries;
|
|
264
|
+
private resolvedNamespace;
|
|
265
|
+
private resolvedMasterKey;
|
|
266
|
+
private initialized;
|
|
267
|
+
constructor(config?: PrivacyVaultConfig | null);
|
|
268
|
+
initialize(): Promise<void>;
|
|
269
|
+
refreshContext(): Promise<void>;
|
|
270
|
+
clearCache(): Promise<void>;
|
|
271
|
+
setThreadContext(threadId: string | null): Promise<void>;
|
|
272
|
+
getGlobalSnapshot(): VaultSnapshotState | null;
|
|
273
|
+
getThreadSnapshot(threadId: string): VaultSnapshotState | null;
|
|
274
|
+
loadThreadSnapshot(threadId: string): Promise<VaultSnapshotState | null>;
|
|
275
|
+
getRuntimeThreadEntries(threadId: string): VaultEntry[];
|
|
276
|
+
getPendingEntries(): VaultEntry[];
|
|
277
|
+
getStatus(): VaultStatus;
|
|
278
|
+
resolveReplacement(entity: SensitiveEntity, options?: VaultResolveOptions): Promise<VaultEntry | null>;
|
|
279
|
+
rememberGeneratedEntry(entity: SensitiveEntity, replacement: string, options?: VaultResolveOptions): Promise<void>;
|
|
280
|
+
isReplacementInUse(replacement: string, options?: VaultResolveOptions): Promise<boolean>;
|
|
281
|
+
deobfuscate(text: string, options?: VaultResolveOptions): Promise<string>;
|
|
282
|
+
private ensureInitialized;
|
|
283
|
+
private loadGlobalSnapshot;
|
|
284
|
+
private loadThreadSnapshotInternal;
|
|
285
|
+
private loadRuntimeThreadEntries;
|
|
286
|
+
private loadPendingEntries;
|
|
287
|
+
private getCachedSnapshot;
|
|
288
|
+
private resolveMasterKey;
|
|
289
|
+
private getCacheKey;
|
|
290
|
+
private getThreadCacheKey;
|
|
291
|
+
private getRuntimeThreadCacheKey;
|
|
292
|
+
private getPendingCacheKey;
|
|
293
|
+
private getRepositoryContext;
|
|
294
|
+
private findEntry;
|
|
295
|
+
private deserializeEntries;
|
|
296
|
+
private upsertEntry;
|
|
297
|
+
private migratePendingEntries;
|
|
298
|
+
private upsertEntries;
|
|
299
|
+
private getEntriesForScope;
|
|
300
|
+
private getEntriesByPrecedence;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
declare class PrivacyClient {
|
|
304
|
+
private readonly config;
|
|
305
|
+
private readonly engines;
|
|
306
|
+
private readonly customEngine;
|
|
307
|
+
private readonly sessionManager;
|
|
308
|
+
private readonly replacementPool;
|
|
309
|
+
private readonly filePrivacyService;
|
|
310
|
+
private readonly obfuscatedFileCreator;
|
|
311
|
+
private readonly logger;
|
|
312
|
+
private readonly vaultManager;
|
|
313
|
+
private readonly initProgress;
|
|
314
|
+
private readonly workerBridge;
|
|
315
|
+
private readonly workerProgressListeners;
|
|
316
|
+
private workerState;
|
|
317
|
+
private readonly workerFailureTimestamps;
|
|
318
|
+
private workerFallbackToLocal;
|
|
319
|
+
private slowEngineInitTimer;
|
|
320
|
+
private slowEngineInitInFlight;
|
|
321
|
+
private readonly isFirstPartyBrowserClient;
|
|
322
|
+
private initialized;
|
|
323
|
+
private initializing;
|
|
324
|
+
constructor(config?: PrivacyClientConfig);
|
|
325
|
+
initialize(): Promise<void>;
|
|
326
|
+
private verifyBrowserSdkAccessToken;
|
|
327
|
+
private bindVaultRepositoryBaseUrl;
|
|
328
|
+
detect(text: string): Promise<PrivacyScanResult>;
|
|
329
|
+
private detectLocally;
|
|
330
|
+
private tryDetectWithWorker;
|
|
331
|
+
private tryDetectInFileWithWorker;
|
|
332
|
+
private tryObfuscateFileWithWorker;
|
|
333
|
+
obfuscate(text: string, options?: ObfuscationOptions): Promise<ObfuscationResult>;
|
|
334
|
+
createTextReview(text: string, entities: SensitiveEntity[], optionsOrResolveReplacement?: TextReviewOptions | ((entity: SensitiveEntity) => string)): TextReview;
|
|
335
|
+
setTextReviewReplacement(review: TextReview, itemId: string, replacement: string): TextReview;
|
|
336
|
+
setTextReviewItemMode(review: TextReview, itemId: string, mode: NonNullable<SessionMapping["obfuscationMode"]>): TextReview;
|
|
337
|
+
removeTextReviewItem(review: TextReview, itemId: string): TextReview;
|
|
338
|
+
restoreTextReviewItem(review: TextReview, itemId: string): TextReview;
|
|
339
|
+
addTextReviewEntity(review: TextReview, entity: SensitiveEntity, replacement: string): TextReview;
|
|
340
|
+
previewTextReview(review: TextReview): Omit<FinalizedTextReview, "sessionId" | "session" | "serializedSession">;
|
|
341
|
+
finalizeTextReview(review: TextReview): FinalizedTextReview;
|
|
342
|
+
createSessionFromMappings(originalText: string, processedText: string, mappings: SessionMapping[]): PrivacySession;
|
|
343
|
+
get vault(): VaultManager;
|
|
344
|
+
subscribeToJobProgress(listener: (event: PrivacyJobProgressEvent) => void): () => void;
|
|
345
|
+
setThreadContext(threadId: string | null): Promise<void>;
|
|
346
|
+
refreshVaultContext(): Promise<void>;
|
|
347
|
+
clearVaultCache(): Promise<void>;
|
|
348
|
+
private createObfuscationResult;
|
|
349
|
+
private getGeneratedReplacement;
|
|
350
|
+
private getEntityOccurrenceKey;
|
|
351
|
+
private getReplacementKeysByOccurrence;
|
|
352
|
+
private getNeutralReplacementForReviewItem;
|
|
353
|
+
private resolveFileText;
|
|
354
|
+
restore(text: string, sessionId: string): Promise<RestorationResult>;
|
|
355
|
+
detectInFile(file: File): Promise<FileProcessingResult>;
|
|
356
|
+
private detectInFileLocally;
|
|
357
|
+
obfuscateFile(file: File, entitiesOrOptions?: SensitiveEntity[] | FileObfuscationOptions): Promise<Blob>;
|
|
358
|
+
getSession(sessionId: string): PrivacySession | undefined;
|
|
359
|
+
exportSession(sessionId: string): SerializedPrivacySession | undefined;
|
|
360
|
+
importSession(session: PrivacySession | SerializedPrivacySession): PrivacySession;
|
|
361
|
+
getSessions(): PrivacySession[];
|
|
362
|
+
clearSession(sessionId: string): void;
|
|
363
|
+
clearAllSessions(): void;
|
|
364
|
+
addPattern(pattern: CustomPattern): void;
|
|
365
|
+
removePattern(name: string): boolean;
|
|
366
|
+
get isReady(): boolean;
|
|
367
|
+
get isFullyReady(): boolean;
|
|
368
|
+
get readyEngines(): string[];
|
|
369
|
+
getInitProgress(): InitProgress;
|
|
370
|
+
clearModelCache(): void;
|
|
371
|
+
private runWithTimeout;
|
|
372
|
+
private detectWithChunking;
|
|
373
|
+
private initializeEngine;
|
|
374
|
+
private scheduleSlowEnginesForBackgroundInitialization;
|
|
375
|
+
private getPendingSlowEngines;
|
|
376
|
+
private handleInitProgress;
|
|
377
|
+
private handleWorkerProgress;
|
|
378
|
+
private shouldUseWorker;
|
|
379
|
+
private handleWorkerExecutionFailure;
|
|
380
|
+
private syncWorkerState;
|
|
381
|
+
private getEngineNames;
|
|
382
|
+
private getWorkerClientConfig;
|
|
383
|
+
private escapeRegex;
|
|
384
|
+
private restoreAmbiguousOccurrences;
|
|
385
|
+
private hasAmbiguousReplacements;
|
|
386
|
+
private wasMappingApplied;
|
|
387
|
+
private emptyResult;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
declare function createTextReview(text: string, entities: SensitiveEntity[], resolveReplacement: (entity: SensitiveEntity) => string): TextReview;
|
|
391
|
+
declare function setTextReviewReplacement(review: TextReview, itemId: string, replacement: string): TextReview;
|
|
392
|
+
declare function setTextReviewItemMode(review: TextReview, itemId: string, mode: TextReviewItem['obfuscationMode'], replacement: string): TextReview;
|
|
393
|
+
declare function removeTextReviewItem(review: TextReview, itemId: string): TextReview;
|
|
394
|
+
declare function restoreTextReviewItem(review: TextReview, itemId: string): TextReview;
|
|
395
|
+
declare function addTextReviewEntity(review: TextReview, entity: SensitiveEntity, replacement: string): TextReview;
|
|
396
|
+
declare function finalizeTextReview(review: TextReview): {
|
|
397
|
+
processedText: string;
|
|
398
|
+
entities: SensitiveEntity[];
|
|
399
|
+
mappings: SessionMapping[];
|
|
400
|
+
hasSensitiveData: boolean;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
interface EntityIdentityInput {
|
|
404
|
+
text: string;
|
|
405
|
+
type: EntityType | string;
|
|
406
|
+
}
|
|
407
|
+
interface EntityIdentityGroup<T extends EntityIdentityInput> {
|
|
408
|
+
representative: T;
|
|
409
|
+
entities: T[];
|
|
410
|
+
}
|
|
411
|
+
declare function getEntityIdentityKey(entity: EntityIdentityInput): string;
|
|
412
|
+
declare function groupEntitiesByIdentity<T extends EntityIdentityInput>(entities: T[]): Array<EntityIdentityGroup<T>>;
|
|
413
|
+
declare function entitiesShareIdentity(left: EntityIdentityInput, right: EntityIdentityInput): boolean;
|
|
414
|
+
declare function normalizeEntityText(text: string): string;
|
|
415
|
+
declare function canonicalizeEntityType(type: EntityType | string): string;
|
|
416
|
+
declare function isFuzzyEligibleType(type: EntityType | string): boolean;
|
|
417
|
+
|
|
418
|
+
interface MatchResult {
|
|
419
|
+
matched: boolean;
|
|
420
|
+
confidence: number;
|
|
421
|
+
matchType: 'exact' | 'case-insensitive' | 'fuzzy' | 'none';
|
|
422
|
+
suggestion?: string;
|
|
423
|
+
}
|
|
424
|
+
interface MatchConfig {
|
|
425
|
+
minConfidence: number;
|
|
426
|
+
maxEditDistance: number;
|
|
427
|
+
enableCaseInsensitive: boolean;
|
|
428
|
+
enableFuzzyMatching: boolean;
|
|
429
|
+
}
|
|
430
|
+
declare class StringMatcher {
|
|
431
|
+
private readonly config;
|
|
432
|
+
constructor(config?: Partial<MatchConfig>);
|
|
433
|
+
match(target: string, candidate: string): MatchResult;
|
|
434
|
+
private fuzzyMatch;
|
|
435
|
+
private levenshteinDistance;
|
|
436
|
+
private calculateLevenshteinDistance;
|
|
437
|
+
findBestMatch(target: string, candidates: string[]): MatchResult & {
|
|
438
|
+
candidate?: string;
|
|
439
|
+
};
|
|
440
|
+
similarity(str1: string, str2: string): number;
|
|
441
|
+
isLikelySameEntity(original: string, candidate: string): boolean;
|
|
442
|
+
}
|
|
443
|
+
declare const defaultStringMatcher: StringMatcher;
|
|
444
|
+
declare const strictStringMatcher: StringMatcher;
|
|
445
|
+
declare const lenientStringMatcher: StringMatcher;
|
|
446
|
+
|
|
447
|
+
declare class MemoryVaultCache implements VaultCache {
|
|
448
|
+
private readonly records;
|
|
449
|
+
get(key: string): Promise<string | null>;
|
|
450
|
+
set(key: string, value: string): Promise<void>;
|
|
451
|
+
delete(key: string): Promise<void>;
|
|
452
|
+
clear(): Promise<void>;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
type FetchLike = typeof fetch;
|
|
456
|
+
interface DefaultVaultRepositoryOptions {
|
|
457
|
+
getAuthToken?: RuntimeValue<string | null>;
|
|
458
|
+
fetch?: FetchLike;
|
|
459
|
+
includeCredentials?: boolean;
|
|
460
|
+
}
|
|
461
|
+
declare class DefaultVaultRepository implements VaultRepository {
|
|
462
|
+
private baseUrl;
|
|
463
|
+
private readonly fetchImpl;
|
|
464
|
+
private readonly getAuthToken?;
|
|
465
|
+
private readonly includeCredentials;
|
|
466
|
+
constructor(options: DefaultVaultRepositoryOptions);
|
|
467
|
+
__setSdkBaseUrl(baseUrl: string): void;
|
|
468
|
+
getGlobalSnapshot(_context: VaultRepositoryRequestContext): Promise<EncryptedVaultSnapshot | null>;
|
|
469
|
+
getThreadSnapshot(threadId: string, _context: VaultRepositoryRequestContext): Promise<EncryptedVaultSnapshot | null>;
|
|
470
|
+
private request;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
declare class IndexedDbVaultCache implements VaultCache {
|
|
474
|
+
private readonly dbName;
|
|
475
|
+
private readonly storeName;
|
|
476
|
+
private readonly factory;
|
|
477
|
+
constructor(dbName?: string, storeName?: string, factory?: IDBFactory);
|
|
478
|
+
get(key: string): Promise<string | null>;
|
|
479
|
+
set(key: string, value: string): Promise<void>;
|
|
480
|
+
delete(key: string): Promise<void>;
|
|
481
|
+
clear(): Promise<void>;
|
|
482
|
+
private openDatabase;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
interface VaultEntryDeobfuscateOptions {
|
|
486
|
+
caseInsensitive?: boolean;
|
|
487
|
+
wordBoundaryTypes?: string[];
|
|
488
|
+
partialNameTypes?: string[];
|
|
489
|
+
}
|
|
490
|
+
declare function deobfuscateWithVaultEntries(text: string, entries: Array<Pick<VaultEntry, 'original' | 'replacement' | 'type'>>, options?: VaultEntryDeobfuscateOptions): string;
|
|
491
|
+
|
|
492
|
+
declare function canonicalizeVaultEntityType(type: string): string;
|
|
493
|
+
declare function vaultEntityTypesMatch(left: string, right: string): boolean;
|
|
494
|
+
declare function normalizeVaultEntryKey(original: string, type: string): string;
|
|
495
|
+
declare function vaultEntryMatchesEntity(entry: Pick<VaultEntry, 'original' | 'type'>, entity: Pick<SensitiveEntity, 'text'> & {
|
|
496
|
+
type: string;
|
|
497
|
+
}): boolean;
|
|
498
|
+
|
|
499
|
+
declare class WebCryptoVaultCrypto implements VaultCrypto {
|
|
500
|
+
encryptEntries(entries: VaultEntry[], masterKey: string): Promise<EncryptedVaultPayload>;
|
|
501
|
+
decryptEntries(payload: EncryptedVaultPayload, masterKey: string): Promise<VaultEntry[]>;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
interface StorageLike {
|
|
505
|
+
getItem(key: string): string | null;
|
|
506
|
+
setItem(key: string, value: string): void;
|
|
507
|
+
removeItem(key: string): void;
|
|
508
|
+
clear(): void;
|
|
509
|
+
}
|
|
510
|
+
declare class WebStorageVaultCache implements VaultCache {
|
|
511
|
+
private readonly storage;
|
|
512
|
+
constructor(storage: StorageLike);
|
|
513
|
+
get(key: string): Promise<string | null>;
|
|
514
|
+
set(key: string, value: string): Promise<void>;
|
|
515
|
+
delete(key: string): Promise<void>;
|
|
516
|
+
clear(): Promise<void>;
|
|
517
|
+
}
|
|
518
|
+
declare class LocalStorageVaultCache extends WebStorageVaultCache {
|
|
519
|
+
constructor(storage?: StorageLike);
|
|
520
|
+
}
|
|
521
|
+
declare class SessionStorageVaultCache extends WebStorageVaultCache {
|
|
522
|
+
constructor(storage?: StorageLike);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
declare function resolveRuntimeValue<T>(value: RuntimeValue<T> | null | undefined): Promise<T | null>;
|
|
526
|
+
|
|
527
|
+
declare const version = "0.1.0";
|
|
528
|
+
|
|
529
|
+
export { type CustomPattern, DefaultVaultRepository, type DefaultVaultRepositoryOptions, type DetectionResult, type DetectionSource, ENTITY_TYPES, type EncryptedVaultPayload, type EncryptedVaultSnapshot, type EngineConfig, type EntityIdentityGroup, type EntityIdentityInput, type EntityType, type ExtendedSensitiveEntity, type FileObfuscationOptions, type FileProcessingResult, type FinalizedTextReview, type IDetectionEngine, type IEntityValidator, IndexedDbVaultCache, type InitProgress, type InitProgressEvent, LocalStorageVaultCache, type MatchConfig, type MatchResult, MemoryVaultCache, type ObfuscationMode, type ObfuscationOptions, type ObfuscationResult, PrivacyClient, type PrivacyClientConfig, type PrivacyJobProgress, type PrivacyJobProgressEvent, type PrivacyScanResult, type PrivacySession, type PrivacyVaultConfig, type ReplacementPoolConfig, type ReplacementSource, type RestorationResult, type RuntimeValue, type SensitiveEntity, type SerializedPrivacySession, type SessionMapping, SessionStorageVaultCache, type StorageLike, StringMatcher, type SupportedFileType, type TextReview, type TextReviewItem, type TextReviewOccurrence, type TextReviewOptions, type VaultCache, type VaultCrypto, type VaultEntry, type VaultEntryDeobfuscateOptions, VaultManager, type VaultRepository, type VaultRepositoryRequestContext, type VaultResolveOptions, type VaultSnapshot, type VaultSnapshotState, type VaultStatus, WebCryptoVaultCrypto, WebStorageVaultCache, addTextReviewEntity, canonicalizeEntityType, canonicalizeVaultEntityType, createTextReview, defaultStringMatcher, deobfuscate, deobfuscateWithVaultEntries, entitiesShareIdentity, finalizeTextReview, getEntityIdentityKey, groupEntitiesByIdentity, isFuzzyEligibleType, lenientStringMatcher, normalizeEntityText, normalizeVaultEntryKey, removeTextReviewItem, resolveRuntimeValue, restoreTextReviewItem, setTextReviewItemMode, setTextReviewReplacement, strictStringMatcher, vaultEntityTypesMatch, vaultEntryMatchesEntity, version };
|