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 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. Optionally save a reverse lookup hash. */
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
- * Format-Preserving Encryption (FPE) token generation.
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
- * Return a **deterministic**, format-preserving token for rawText using its entityType.
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. Optionally save a reverse lookup hash. */
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
- * Format-Preserving Encryption (FPE) token generation.
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
- * Return a **deterministic**, format-preserving token for rawText using its entityType.
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.