mask-privacy 3.5.1 → 4.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/dist/index.d.mts +14 -12
- package/dist/index.d.ts +14 -12
- package/dist/index.js +749 -162
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +744 -156
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/src/config.ts +6 -0
- package/src/core/crypto.ts +50 -15
- package/src/core/dlp/registry.ts +7 -1
- package/src/core/exceptions.ts +25 -0
- package/src/core/ff1.ts +196 -0
- package/src/core/fpe.ts +134 -74
- package/src/core/fpe_utils.ts +24 -14
- package/src/core/scanner.ts +2 -1
- package/src/core/span.ts +3 -0
- package/src/core/synthesisLibrary.ts +41 -0
- package/src/core/vault.ts +66 -17
- package/src/telemetry/audit_logger.ts +45 -1
- package/tests/bijective_fpe.test.ts +107 -0
- package/tests/fpe.test.ts +17 -8
- package/tests/security_hardening.test.ts +26 -0
- package/tests/vault.test.ts +67 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/** Interface every vault backend must implement. */
|
|
2
2
|
declare abstract class BaseVault {
|
|
3
|
-
/** Persist a token → plaintext mapping with a TTL
|
|
4
|
-
abstract store(token: string, plaintext: string, ttlSeconds: number, ptHash?: string | null): Promise<void>;
|
|
3
|
+
/** Persist a token → encrypted plaintext mapping with a TTL and optional compliance metadata. */
|
|
4
|
+
abstract store(token: string, plaintext: string, ttlSeconds: number, ptHash?: string | null, metadata?: Record<string, string> | null): Promise<void>;
|
|
5
5
|
/** Return the existing unexpired token for a given plaintext hash, or null. */
|
|
6
6
|
abstract getTokenByPlaintextHash(ptHash: string): Promise<string | null>;
|
|
7
7
|
/** Return the plaintext for token, or null if missing/expired. */
|
|
8
8
|
abstract retrieve(token: string): Promise<string | null>;
|
|
9
|
+
/** Return the plaintext hash stored for this token (used for collision detection), or null. */
|
|
10
|
+
abstract getPtHashForToken(token: string): Promise<string | null>;
|
|
9
11
|
/** Delete a token and its reverse mapping. */
|
|
10
12
|
abstract delete(token: string): Promise<void>;
|
|
11
13
|
}
|
|
@@ -15,6 +17,7 @@ type EncodeOptions = {
|
|
|
15
17
|
searchBuckets?: ('year' | 'month' | 'day' | 'numeric')[];
|
|
16
18
|
searchBucketSize?: number;
|
|
17
19
|
entityType?: string;
|
|
20
|
+
metadata?: Record<string, string> | null;
|
|
18
21
|
};
|
|
19
22
|
/**
|
|
20
23
|
* Tokenise rawText, encrypt it, store in vault, return the FPE token.
|
|
@@ -41,18 +44,11 @@ declare const adetokenizeText: typeof detokenizeText;
|
|
|
41
44
|
declare function looksLikeToken(value: string | any): boolean;
|
|
42
45
|
|
|
43
46
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* Generates structurally valid, **deterministic** tokens that preserve the
|
|
47
|
-
* format of the original data type so downstream tools, schemas, and
|
|
48
|
-
* validators continue to work without modification.
|
|
47
|
+
* Deterministic Pseudonymization (DP) token generation using NIST SP 800-38G FF1.
|
|
49
48
|
*/
|
|
50
|
-
/** Clear the cached master key. Useful in tests. */
|
|
51
49
|
declare function resetMasterKey(): void;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
55
|
-
declare function generateFPEToken(rawText: string, entityType?: string): Promise<string>;
|
|
50
|
+
declare function generateDPToken(rawText: string, entityType?: string): Promise<string>;
|
|
51
|
+
declare const generateFPEToken: typeof generateDPToken;
|
|
56
52
|
|
|
57
53
|
/**
|
|
58
54
|
* Span Resolution Engine — Sweep-Line Overlap Resolver (TypeScript).
|
|
@@ -69,6 +65,8 @@ interface Span {
|
|
|
69
65
|
confidence: number;
|
|
70
66
|
method: string;
|
|
71
67
|
language?: string;
|
|
68
|
+
ruleId?: string;
|
|
69
|
+
complianceScope?: ReadonlySet<string>;
|
|
72
70
|
maskedValue?: string;
|
|
73
71
|
}
|
|
74
72
|
|
|
@@ -234,6 +232,8 @@ declare class AuditLogger {
|
|
|
234
232
|
private _strictMode;
|
|
235
233
|
private _bufferFullWarned;
|
|
236
234
|
private _shutdownRegistered;
|
|
235
|
+
private _signingKey;
|
|
236
|
+
private _prevSig;
|
|
237
237
|
private constructor();
|
|
238
238
|
static getInstance(): AuditLogger;
|
|
239
239
|
log(action: string, token: string, dataType?: string, agent?: string, tool?: string, extra?: Record<string, any>): void;
|
|
@@ -371,6 +371,8 @@ interface PatternDescriptor {
|
|
|
371
371
|
validatorTag: string | null;
|
|
372
372
|
isHighEntropy: boolean;
|
|
373
373
|
supportedLocales: string[];
|
|
374
|
+
ruleId: string;
|
|
375
|
+
complianceScope: ReadonlySet<string>;
|
|
374
376
|
}
|
|
375
377
|
/**
|
|
376
378
|
* Immutable catalogue of sensitive-data regex signatures.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/** Interface every vault backend must implement. */
|
|
2
2
|
declare abstract class BaseVault {
|
|
3
|
-
/** Persist a token → plaintext mapping with a TTL
|
|
4
|
-
abstract store(token: string, plaintext: string, ttlSeconds: number, ptHash?: string | null): Promise<void>;
|
|
3
|
+
/** Persist a token → encrypted plaintext mapping with a TTL and optional compliance metadata. */
|
|
4
|
+
abstract store(token: string, plaintext: string, ttlSeconds: number, ptHash?: string | null, metadata?: Record<string, string> | null): Promise<void>;
|
|
5
5
|
/** Return the existing unexpired token for a given plaintext hash, or null. */
|
|
6
6
|
abstract getTokenByPlaintextHash(ptHash: string): Promise<string | null>;
|
|
7
7
|
/** Return the plaintext for token, or null if missing/expired. */
|
|
8
8
|
abstract retrieve(token: string): Promise<string | null>;
|
|
9
|
+
/** Return the plaintext hash stored for this token (used for collision detection), or null. */
|
|
10
|
+
abstract getPtHashForToken(token: string): Promise<string | null>;
|
|
9
11
|
/** Delete a token and its reverse mapping. */
|
|
10
12
|
abstract delete(token: string): Promise<void>;
|
|
11
13
|
}
|
|
@@ -15,6 +17,7 @@ type EncodeOptions = {
|
|
|
15
17
|
searchBuckets?: ('year' | 'month' | 'day' | 'numeric')[];
|
|
16
18
|
searchBucketSize?: number;
|
|
17
19
|
entityType?: string;
|
|
20
|
+
metadata?: Record<string, string> | null;
|
|
18
21
|
};
|
|
19
22
|
/**
|
|
20
23
|
* Tokenise rawText, encrypt it, store in vault, return the FPE token.
|
|
@@ -41,18 +44,11 @@ declare const adetokenizeText: typeof detokenizeText;
|
|
|
41
44
|
declare function looksLikeToken(value: string | any): boolean;
|
|
42
45
|
|
|
43
46
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* Generates structurally valid, **deterministic** tokens that preserve the
|
|
47
|
-
* format of the original data type so downstream tools, schemas, and
|
|
48
|
-
* validators continue to work without modification.
|
|
47
|
+
* Deterministic Pseudonymization (DP) token generation using NIST SP 800-38G FF1.
|
|
49
48
|
*/
|
|
50
|
-
/** Clear the cached master key. Useful in tests. */
|
|
51
49
|
declare function resetMasterKey(): void;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
55
|
-
declare function generateFPEToken(rawText: string, entityType?: string): Promise<string>;
|
|
50
|
+
declare function generateDPToken(rawText: string, entityType?: string): Promise<string>;
|
|
51
|
+
declare const generateFPEToken: typeof generateDPToken;
|
|
56
52
|
|
|
57
53
|
/**
|
|
58
54
|
* Span Resolution Engine — Sweep-Line Overlap Resolver (TypeScript).
|
|
@@ -69,6 +65,8 @@ interface Span {
|
|
|
69
65
|
confidence: number;
|
|
70
66
|
method: string;
|
|
71
67
|
language?: string;
|
|
68
|
+
ruleId?: string;
|
|
69
|
+
complianceScope?: ReadonlySet<string>;
|
|
72
70
|
maskedValue?: string;
|
|
73
71
|
}
|
|
74
72
|
|
|
@@ -234,6 +232,8 @@ declare class AuditLogger {
|
|
|
234
232
|
private _strictMode;
|
|
235
233
|
private _bufferFullWarned;
|
|
236
234
|
private _shutdownRegistered;
|
|
235
|
+
private _signingKey;
|
|
236
|
+
private _prevSig;
|
|
237
237
|
private constructor();
|
|
238
238
|
static getInstance(): AuditLogger;
|
|
239
239
|
log(action: string, token: string, dataType?: string, agent?: string, tool?: string, extra?: Record<string, any>): void;
|
|
@@ -371,6 +371,8 @@ interface PatternDescriptor {
|
|
|
371
371
|
validatorTag: string | null;
|
|
372
372
|
isHighEntropy: boolean;
|
|
373
373
|
supportedLocales: string[];
|
|
374
|
+
ruleId: string;
|
|
375
|
+
complianceScope: ReadonlySet<string>;
|
|
374
376
|
}
|
|
375
377
|
/**
|
|
376
378
|
* Immutable catalogue of sensitive-data regex signatures.
|