anonyma 1.0.0 → 1.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.
Files changed (183) hide show
  1. package/CHANGELOG.md +273 -144
  2. package/README.md +427 -143
  3. package/dist/ai/index.cjs +522 -0
  4. package/dist/ai/index.cjs.map +1 -0
  5. package/dist/ai/index.d.cts +322 -0
  6. package/dist/ai/index.d.ts +322 -0
  7. package/dist/ai/index.js +505 -0
  8. package/dist/ai/index.js.map +1 -0
  9. package/dist/audit/index.cjs +359 -0
  10. package/dist/audit/index.cjs.map +1 -0
  11. package/dist/audit/index.d.cts +287 -0
  12. package/dist/audit/index.d.ts +287 -0
  13. package/dist/audit/index.js +340 -0
  14. package/dist/audit/index.js.map +1 -0
  15. package/dist/chunk-26IHMQHL.cjs +662 -0
  16. package/dist/chunk-26IHMQHL.cjs.map +1 -0
  17. package/dist/chunk-2F2GWGTB.js +174 -0
  18. package/dist/chunk-2F2GWGTB.js.map +1 -0
  19. package/dist/chunk-2NNMJ55L.cjs +45 -0
  20. package/dist/chunk-2NNMJ55L.cjs.map +1 -0
  21. package/dist/chunk-2YG7R4KJ.cjs +114 -0
  22. package/dist/chunk-2YG7R4KJ.cjs.map +1 -0
  23. package/dist/chunk-2ZZHLCEJ.js +237 -0
  24. package/dist/chunk-2ZZHLCEJ.js.map +1 -0
  25. package/dist/chunk-3CY6ATKS.cjs +308 -0
  26. package/dist/chunk-3CY6ATKS.cjs.map +1 -0
  27. package/dist/chunk-3D5ZCJ7R.js +268 -0
  28. package/dist/chunk-3D5ZCJ7R.js.map +1 -0
  29. package/dist/chunk-6LDAIJBL.js +103 -0
  30. package/dist/chunk-6LDAIJBL.js.map +1 -0
  31. package/dist/chunk-7HK2V5Q4.js +111 -0
  32. package/dist/chunk-7HK2V5Q4.js.map +1 -0
  33. package/dist/chunk-AAP472NG.js +177 -0
  34. package/dist/chunk-AAP472NG.js.map +1 -0
  35. package/dist/chunk-AP4JIUNW.js +42 -0
  36. package/dist/chunk-AP4JIUNW.js.map +1 -0
  37. package/dist/chunk-BBJPQPGP.js +457 -0
  38. package/dist/chunk-BBJPQPGP.js.map +1 -0
  39. package/dist/chunk-CRXRJZEV.cjs +82 -0
  40. package/dist/chunk-CRXRJZEV.cjs.map +1 -0
  41. package/dist/chunk-E3PICZYI.js +20 -0
  42. package/dist/chunk-E3PICZYI.js.map +1 -0
  43. package/dist/chunk-F7O2FA3F.cjs +1255 -0
  44. package/dist/chunk-F7O2FA3F.cjs.map +1 -0
  45. package/dist/chunk-FB56NAAH.cjs +243 -0
  46. package/dist/chunk-FB56NAAH.cjs.map +1 -0
  47. package/dist/chunk-G4AN7FND.js +1063 -0
  48. package/dist/chunk-G4AN7FND.js.map +1 -0
  49. package/dist/chunk-GS3FRH4K.js +294 -0
  50. package/dist/chunk-GS3FRH4K.js.map +1 -0
  51. package/dist/chunk-GYMG5OI3.cjs +186 -0
  52. package/dist/chunk-GYMG5OI3.cjs.map +1 -0
  53. package/dist/chunk-IHEIYZPL.cjs +301 -0
  54. package/dist/chunk-IHEIYZPL.cjs.map +1 -0
  55. package/dist/chunk-IJAMLYOT.cjs +1087 -0
  56. package/dist/chunk-IJAMLYOT.cjs.map +1 -0
  57. package/dist/chunk-ISL5B4LU.cjs +181 -0
  58. package/dist/chunk-ISL5B4LU.cjs.map +1 -0
  59. package/dist/chunk-JKW36IPT.js +179 -0
  60. package/dist/chunk-JKW36IPT.js.map +1 -0
  61. package/dist/chunk-KOCQBDI4.cjs +179 -0
  62. package/dist/chunk-KOCQBDI4.cjs.map +1 -0
  63. package/dist/chunk-OGNLB2KA.js +79 -0
  64. package/dist/chunk-OGNLB2KA.js.map +1 -0
  65. package/dist/chunk-PKHZ7CVI.js +28 -0
  66. package/dist/chunk-PKHZ7CVI.js.map +1 -0
  67. package/dist/chunk-QYD4F6T7.cjs +114 -0
  68. package/dist/chunk-QYD4F6T7.cjs.map +1 -0
  69. package/dist/chunk-RCW5IPPR.js +1288 -0
  70. package/dist/chunk-RCW5IPPR.js.map +1 -0
  71. package/dist/chunk-RMMKYHUN.cjs +35 -0
  72. package/dist/chunk-RMMKYHUN.cjs.map +1 -0
  73. package/dist/chunk-S4BJ2ADB.cjs +22 -0
  74. package/dist/chunk-S4BJ2ADB.cjs.map +1 -0
  75. package/dist/chunk-S7NH6CHY.cjs +462 -0
  76. package/dist/chunk-S7NH6CHY.cjs.map +1 -0
  77. package/dist/chunk-SIHPDZXA.js +176 -0
  78. package/dist/chunk-SIHPDZXA.js.map +1 -0
  79. package/dist/chunk-TW7PM3UJ.cjs +30 -0
  80. package/dist/chunk-TW7PM3UJ.cjs.map +1 -0
  81. package/dist/chunk-UA3EOFBS.cjs +1322 -0
  82. package/dist/chunk-UA3EOFBS.cjs.map +1 -0
  83. package/dist/chunk-VE4CCW7W.js +32 -0
  84. package/dist/chunk-VE4CCW7W.js.map +1 -0
  85. package/dist/chunk-W6RBCHYF.js +651 -0
  86. package/dist/chunk-W6RBCHYF.js.map +1 -0
  87. package/dist/chunk-WLJN7GIS.cjs +189 -0
  88. package/dist/chunk-WLJN7GIS.cjs.map +1 -0
  89. package/dist/chunk-YMLR375Z.js +1244 -0
  90. package/dist/chunk-YMLR375Z.js.map +1 -0
  91. package/dist/compliance/index.cjs +88 -0
  92. package/dist/compliance/index.cjs.map +1 -0
  93. package/dist/compliance/index.d.cts +277 -0
  94. package/dist/compliance/index.d.ts +277 -0
  95. package/dist/compliance/index.js +47 -0
  96. package/dist/compliance/index.js.map +1 -0
  97. package/dist/crypto.cjs +12 -136
  98. package/dist/crypto.cjs.map +1 -1
  99. package/dist/crypto.d.cts +4 -3
  100. package/dist/crypto.d.ts +4 -3
  101. package/dist/crypto.js +3 -137
  102. package/dist/crypto.js.map +1 -1
  103. package/dist/detectors/index.cjs +146 -1483
  104. package/dist/detectors/index.cjs.map +1 -1
  105. package/dist/detectors/index.d.cts +1 -1
  106. package/dist/detectors/index.d.ts +1 -1
  107. package/dist/detectors/index.js +3 -1449
  108. package/dist/detectors/index.js.map +1 -1
  109. package/dist/engine/index.cjs +441 -0
  110. package/dist/engine/index.cjs.map +1 -0
  111. package/dist/engine/index.d.cts +728 -0
  112. package/dist/engine/index.d.ts +728 -0
  113. package/dist/engine/index.js +189 -0
  114. package/dist/engine/index.js.map +1 -0
  115. package/dist/hash-2PSYNDMM.cjs +14 -0
  116. package/dist/hash-2PSYNDMM.cjs.map +1 -0
  117. package/dist/hash-CELLDNKN.js +5 -0
  118. package/dist/hash-CELLDNKN.js.map +1 -0
  119. package/dist/index.cjs +153 -2816
  120. package/dist/index.cjs.map +1 -1
  121. package/dist/index.d.cts +93 -11
  122. package/dist/index.d.ts +93 -11
  123. package/dist/index.js +13 -2791
  124. package/dist/index.js.map +1 -1
  125. package/dist/json-CKDvlRtl.d.ts +147 -0
  126. package/dist/json-s8ny-RCo.d.cts +147 -0
  127. package/dist/mcp/index.cjs +751 -0
  128. package/dist/mcp/index.cjs.map +1 -0
  129. package/dist/mcp/index.d.cts +226 -0
  130. package/dist/mcp/index.d.ts +226 -0
  131. package/dist/mcp/index.js +744 -0
  132. package/dist/mcp/index.js.map +1 -0
  133. package/dist/middleware/express.cjs +93 -0
  134. package/dist/middleware/express.cjs.map +1 -0
  135. package/dist/middleware/express.d.cts +90 -0
  136. package/dist/middleware/express.d.ts +90 -0
  137. package/dist/middleware/express.js +91 -0
  138. package/dist/middleware/express.js.map +1 -0
  139. package/dist/middleware/hono.cjs +58 -0
  140. package/dist/middleware/hono.cjs.map +1 -0
  141. package/dist/middleware/hono.d.cts +75 -0
  142. package/dist/middleware/hono.d.ts +75 -0
  143. package/dist/middleware/hono.js +56 -0
  144. package/dist/middleware/hono.js.map +1 -0
  145. package/dist/middleware/index.cjs +24 -0
  146. package/dist/middleware/index.cjs.map +1 -0
  147. package/dist/middleware/index.d.cts +106 -0
  148. package/dist/middleware/index.d.ts +106 -0
  149. package/dist/middleware/index.js +15 -0
  150. package/dist/middleware/index.js.map +1 -0
  151. package/dist/schemas.cjs +5 -5
  152. package/dist/schemas.cjs.map +1 -1
  153. package/dist/schemas.d.cts +20 -10
  154. package/dist/schemas.d.ts +20 -10
  155. package/dist/schemas.js +5 -5
  156. package/dist/schemas.js.map +1 -1
  157. package/dist/session-BdRftyZ5.d.cts +102 -0
  158. package/dist/session-Cs2zlNQp.d.ts +102 -0
  159. package/dist/stream.cjs +13 -2262
  160. package/dist/stream.cjs.map +1 -1
  161. package/dist/stream.d.cts +1 -1
  162. package/dist/stream.d.ts +1 -1
  163. package/dist/stream.js +6 -2255
  164. package/dist/stream.js.map +1 -1
  165. package/dist/types--tPm_AjY.d.ts +199 -0
  166. package/dist/types-0BJH_wqc.d.cts +199 -0
  167. package/dist/types-CPUhjvl8.d.cts +629 -0
  168. package/dist/types-Dtht33aq.d.ts +629 -0
  169. package/dist/{types-D-9HzVuy.d.cts → types-EJTj_BKY.d.cts} +38 -7
  170. package/dist/{types-D-9HzVuy.d.ts → types-EJTj_BKY.d.ts} +38 -7
  171. package/dist/types-Zt_bZvwS.d.cts +182 -0
  172. package/dist/types-Zt_bZvwS.d.ts +182 -0
  173. package/dist/validators.cjs +39 -181
  174. package/dist/validators.cjs.map +1 -1
  175. package/dist/validators.js +1 -174
  176. package/dist/validators.js.map +1 -1
  177. package/dist/vault/index.cjs +688 -0
  178. package/dist/vault/index.cjs.map +1 -0
  179. package/dist/vault/index.d.cts +385 -0
  180. package/dist/vault/index.d.ts +385 -0
  181. package/dist/vault/index.js +669 -0
  182. package/dist/vault/index.js.map +1 -0
  183. package/package.json +128 -11
package/dist/index.d.cts CHANGED
@@ -1,6 +1,8 @@
1
- import { A as AnonymizeOptions, a as AnonymizeResult, F as FieldRuleMap, c as AnonymizerConfig, d as Anonymizer, P as PiiCategory, D as Detector, e as PiiMatch, f as DetokenizeResult, T as TokenizeOptions, b as TokenizeResult, B as BatchResult, C as CompliancePreset, S as StrategyOptions, g as AnonymizationRule, M as MaskOptions, R as RedactOptions, h as PseudonymizeOptions, H as HashOptions, G as GeneralizeOptions, i as SynthesizeOptions } from './types-D-9HzVuy.cjs';
2
- export { j as AnonymaPlugin, k as CustomPattern, l as DetectorRegistry, E as EncryptOptions, m as FieldRule, L as Locale, n as StrategyName, o as TokenFormat, V as ValidatorFunction } from './types-D-9HzVuy.cjs';
1
+ import { A as AnonymizeOptions, a as AnonymizeResult, F as FieldRuleMap, e as AnonymizerConfig, f as Anonymizer, P as PiiCategory, D as Detector, g as PiiMatch, h as DetokenizeResult, T as TokenizeOptions, b as TokenizeResult, B as BatchResult, C as CompliancePreset, S as StrategyOptions, i as AnonymizationRule, M as MaskOptions, R as RedactOptions, c as PseudonymizeOptions, H as HashOptions, G as GeneralizeOptions, d as SynthesizeOptions } from './types-EJTj_BKY.cjs';
2
+ export { j as AnonymaPlugin, k as CustomPattern, l as DetectorRegistry, E as EncryptOptions, m as FieldRule, L as Locale, n as StrategyName, o as TokenFormat, V as ValidatorFunction } from './types-EJTj_BKY.cjs';
3
3
  export { decrypt, encrypt } from './crypto.cjs';
4
+ import { c as PolicyIssue } from './types-0BJH_wqc.cjs';
5
+ import './types-CPUhjvl8.cjs';
4
6
 
5
7
  /**
6
8
  * @module anonymize
@@ -371,19 +373,25 @@ declare function detectBatch(texts: readonly string[], categories?: readonly Pii
371
373
 
372
374
  /**
373
375
  * @module presets
374
- * @description Built-in compliance preset configurations for GDPR, HIPAA, CCPA,
375
- * PCI-DSS, SOX, and FERPA. Import from `"anonyma"` or extend using the
376
- * `preset` option in {@link AnonymizeOptions}.
376
+ * @description Built-in compliance preset configurations for GDPR, LGPD,
377
+ * PIPEDA, CCPA/CPRA, HIPAA, PCI-DSS, SOX, and FERPA. Import from `"anonyma"`
378
+ * or extend using the `preset` option in {@link AnonymizeOptions}.
379
+ *
380
+ * A preset selects the categories that the library can detect for an
381
+ * instrument and the strategy applied to them. The legal provisions behind
382
+ * each category, and the data elements each instrument names that no detector
383
+ * covers, are documented in `"anonyma/compliance"`.
377
384
  *
378
385
  * @example
379
386
  * ```ts
380
387
  * import { anonymize } from "anonyma";
381
388
  *
382
- * // Apply HIPAA preset — redacts all 18 HIPAA Safe Harbor identifiers
389
+ * // Apply HIPAA preset — redacts the Safe Harbor identifiers that have a detector
383
390
  * anonymize(text, { preset: "hipaa" });
384
391
  *
385
- * // Extend GDPR preset with API key detection
386
- * anonymize(text, { preset: "gdpr", enabledCategories: { "api-key": true } });
392
+ * // Extend GDPR preset with API key detection (anonymize() uses the preset's categories)
393
+ * import { compilePipeline } from "anonyma/engine";
394
+ * compilePipeline({ preset: "gdpr", categories: [...getPreset("gdpr").categories, "api-key"] });
387
395
  * ```
388
396
  */
389
397
 
@@ -537,7 +545,8 @@ declare function pseudonymize(value: string, options?: PseudonymizeOptions): str
537
545
  * `pepper` makes the output specific to your deployment and prevents
538
546
  * rainbow-table attacks.
539
547
  *
540
- * ⚠️ Requires Node.js ≥ 18 or an environment that exposes `globalThis.crypto.subtle`.
548
+ * Uses the Web Crypto API: `globalThis.crypto` where the runtime exposes it,
549
+ * and Node's own implementation (`node:crypto`) on Node.js 18, which does not.
541
550
  */
542
551
 
543
552
  /**
@@ -547,7 +556,7 @@ declare function pseudonymize(value: string, options?: PseudonymizeOptions): str
547
556
  * @param options - Hashing configuration.
548
557
  * @returns A Promise that resolves to a hex-encoded (possibly truncated) hash.
549
558
  *
550
- * @throws {@link CryptoNotAvailableError} When `globalThis.crypto.subtle` is not available.
559
+ * @throws {@link CryptoNotAvailableError} When the runtime has no Web Crypto API at all.
551
560
  * @throws {@link ValidationError} When `truncate` is not a positive integer ≤ 64.
552
561
  *
553
562
  * @example
@@ -650,6 +659,7 @@ declare function synthesize(value: string, category: string, options?: Synthesiz
650
659
  * }
651
660
  * ```
652
661
  */
662
+
653
663
  /**
654
664
  * Base class for all errors thrown by the anonyma library.
655
665
  * Consumers can use `err instanceof AnonymaError` to narrowly handle library errors.
@@ -768,5 +778,77 @@ declare class BatchProcessingError extends AnonymaError {
768
778
  readonly total: number;
769
779
  constructor(succeeded: number, failed: number, total: number);
770
780
  }
781
+ /**
782
+ * Thrown by a synchronous pipeline entry point when a replacer returns a
783
+ * promise. Use the asynchronous entry point (`transformAsync()`, an async
784
+ * chunk transformer, or an async stream) with that replacer instead.
785
+ *
786
+ * @example
787
+ * ```ts
788
+ * throw new AsyncStrategyError("email");
789
+ * ```
790
+ */
791
+ declare class AsyncStrategyError extends AnonymaError {
792
+ /** The category whose replacer is asynchronous. */
793
+ readonly category: string;
794
+ constructor(category: string);
795
+ }
796
+ /**
797
+ * Thrown when a key version is unknown, destroyed, malformed, or cannot be
798
+ * derived. The message never contains key material.
799
+ *
800
+ * @example
801
+ * ```ts
802
+ * throw new KeyManagementError("key version has been destroyed", "k1");
803
+ * ```
804
+ */
805
+ declare class KeyManagementError extends AnonymaError {
806
+ /** The key version the error refers to, when there is one. */
807
+ readonly keyId: string | undefined;
808
+ constructor(reason: string, keyId?: string);
809
+ }
810
+ /**
811
+ * Thrown when a token vault operation fails or would corrupt the vault. The
812
+ * message never contains an original value.
813
+ *
814
+ * @example
815
+ * ```ts
816
+ * throw new TokenVaultError("token identifier collision; increase idLength");
817
+ * ```
818
+ */
819
+ declare class TokenVaultError extends AnonymaError {
820
+ constructor(reason: string);
821
+ }
822
+ /**
823
+ * Thrown when a policy document is malformed or violates a requirement of a
824
+ * regulation it extends. `issues` lists every problem that was found.
825
+ *
826
+ * @example
827
+ * ```ts
828
+ * try {
829
+ * parsePolicy(document);
830
+ * } catch (err) {
831
+ * if (err instanceof PolicyError) {
832
+ * for (const issue of err.issues) console.error(issue.path, issue.message);
833
+ * }
834
+ * }
835
+ * ```
836
+ */
837
+ declare class PolicyError extends AnonymaError {
838
+ /** Every problem found in the document, errors first. */
839
+ readonly issues: readonly PolicyIssue[];
840
+ constructor(issues: readonly PolicyIssue[]);
841
+ }
842
+ /**
843
+ * Thrown when the audit chain cannot be extended or does not verify.
844
+ *
845
+ * @example
846
+ * ```ts
847
+ * throw new AuditIntegrityError("a sink rejected record 12; the logger is closed");
848
+ * ```
849
+ */
850
+ declare class AuditIntegrityError extends AnonymaError {
851
+ constructor(reason: string);
852
+ }
771
853
 
772
- export { AllowlistMatchError, AnonymaError, AnonymizationRule, AnonymizeOptions, AnonymizeResult, Anonymizer, AnonymizerConfig, BatchProcessingError, BatchResult, CompliancePreset, CryptoNotAvailableError, Detector, DetokenizeResult, EncryptionError, FieldRuleMap, GeneralizeOptions, HashOptions, MaskOptions, PRESET_REGISTRY, PiiCategory, PiiMatch, type PresetConfig, PresetNotFoundError, PseudonymizeOptions, RedactOptions, StrategyOptions, SynthesizeOptions, TokenizeOptions, TokenizeResult, UnknownCategoryError, UnsupportedStrategyError, ValidationError, anonymize, anonymizeAsync, anonymizeBatch, anonymizeBatchAsync, anonymizeObject, anonymizeRecord, createAnonymizer, detect, detectBatch, detokenize, generalize, getPreset, hasPII, hash, mask, pseudonymize, redact, restoreFromLLM, sanitizeForLLM, synthesize, tokenize, tokenizeAsync, tokenizeBatch };
854
+ export { AllowlistMatchError, AnonymaError, AnonymizationRule, AnonymizeOptions, AnonymizeResult, Anonymizer, AnonymizerConfig, AsyncStrategyError, AuditIntegrityError, BatchProcessingError, BatchResult, CompliancePreset, CryptoNotAvailableError, Detector, DetokenizeResult, EncryptionError, FieldRuleMap, GeneralizeOptions, HashOptions, KeyManagementError, MaskOptions, PRESET_REGISTRY, PiiCategory, PiiMatch, PolicyError, type PresetConfig, PresetNotFoundError, PseudonymizeOptions, RedactOptions, StrategyOptions, SynthesizeOptions, TokenVaultError, TokenizeOptions, TokenizeResult, UnknownCategoryError, UnsupportedStrategyError, ValidationError, anonymize, anonymizeAsync, anonymizeBatch, anonymizeBatchAsync, anonymizeObject, anonymizeRecord, createAnonymizer, detect, detectBatch, detokenize, generalize, getPreset, hasPII, hash, mask, pseudonymize, redact, restoreFromLLM, sanitizeForLLM, synthesize, tokenize, tokenizeAsync, tokenizeBatch };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import { A as AnonymizeOptions, a as AnonymizeResult, F as FieldRuleMap, c as AnonymizerConfig, d as Anonymizer, P as PiiCategory, D as Detector, e as PiiMatch, f as DetokenizeResult, T as TokenizeOptions, b as TokenizeResult, B as BatchResult, C as CompliancePreset, S as StrategyOptions, g as AnonymizationRule, M as MaskOptions, R as RedactOptions, h as PseudonymizeOptions, H as HashOptions, G as GeneralizeOptions, i as SynthesizeOptions } from './types-D-9HzVuy.js';
2
- export { j as AnonymaPlugin, k as CustomPattern, l as DetectorRegistry, E as EncryptOptions, m as FieldRule, L as Locale, n as StrategyName, o as TokenFormat, V as ValidatorFunction } from './types-D-9HzVuy.js';
1
+ import { A as AnonymizeOptions, a as AnonymizeResult, F as FieldRuleMap, e as AnonymizerConfig, f as Anonymizer, P as PiiCategory, D as Detector, g as PiiMatch, h as DetokenizeResult, T as TokenizeOptions, b as TokenizeResult, B as BatchResult, C as CompliancePreset, S as StrategyOptions, i as AnonymizationRule, M as MaskOptions, R as RedactOptions, c as PseudonymizeOptions, H as HashOptions, G as GeneralizeOptions, d as SynthesizeOptions } from './types-EJTj_BKY.js';
2
+ export { j as AnonymaPlugin, k as CustomPattern, l as DetectorRegistry, E as EncryptOptions, m as FieldRule, L as Locale, n as StrategyName, o as TokenFormat, V as ValidatorFunction } from './types-EJTj_BKY.js';
3
3
  export { decrypt, encrypt } from './crypto.js';
4
+ import { c as PolicyIssue } from './types--tPm_AjY.js';
5
+ import './types-Dtht33aq.js';
4
6
 
5
7
  /**
6
8
  * @module anonymize
@@ -371,19 +373,25 @@ declare function detectBatch(texts: readonly string[], categories?: readonly Pii
371
373
 
372
374
  /**
373
375
  * @module presets
374
- * @description Built-in compliance preset configurations for GDPR, HIPAA, CCPA,
375
- * PCI-DSS, SOX, and FERPA. Import from `"anonyma"` or extend using the
376
- * `preset` option in {@link AnonymizeOptions}.
376
+ * @description Built-in compliance preset configurations for GDPR, LGPD,
377
+ * PIPEDA, CCPA/CPRA, HIPAA, PCI-DSS, SOX, and FERPA. Import from `"anonyma"`
378
+ * or extend using the `preset` option in {@link AnonymizeOptions}.
379
+ *
380
+ * A preset selects the categories that the library can detect for an
381
+ * instrument and the strategy applied to them. The legal provisions behind
382
+ * each category, and the data elements each instrument names that no detector
383
+ * covers, are documented in `"anonyma/compliance"`.
377
384
  *
378
385
  * @example
379
386
  * ```ts
380
387
  * import { anonymize } from "anonyma";
381
388
  *
382
- * // Apply HIPAA preset — redacts all 18 HIPAA Safe Harbor identifiers
389
+ * // Apply HIPAA preset — redacts the Safe Harbor identifiers that have a detector
383
390
  * anonymize(text, { preset: "hipaa" });
384
391
  *
385
- * // Extend GDPR preset with API key detection
386
- * anonymize(text, { preset: "gdpr", enabledCategories: { "api-key": true } });
392
+ * // Extend GDPR preset with API key detection (anonymize() uses the preset's categories)
393
+ * import { compilePipeline } from "anonyma/engine";
394
+ * compilePipeline({ preset: "gdpr", categories: [...getPreset("gdpr").categories, "api-key"] });
387
395
  * ```
388
396
  */
389
397
 
@@ -537,7 +545,8 @@ declare function pseudonymize(value: string, options?: PseudonymizeOptions): str
537
545
  * `pepper` makes the output specific to your deployment and prevents
538
546
  * rainbow-table attacks.
539
547
  *
540
- * ⚠️ Requires Node.js ≥ 18 or an environment that exposes `globalThis.crypto.subtle`.
548
+ * Uses the Web Crypto API: `globalThis.crypto` where the runtime exposes it,
549
+ * and Node's own implementation (`node:crypto`) on Node.js 18, which does not.
541
550
  */
542
551
 
543
552
  /**
@@ -547,7 +556,7 @@ declare function pseudonymize(value: string, options?: PseudonymizeOptions): str
547
556
  * @param options - Hashing configuration.
548
557
  * @returns A Promise that resolves to a hex-encoded (possibly truncated) hash.
549
558
  *
550
- * @throws {@link CryptoNotAvailableError} When `globalThis.crypto.subtle` is not available.
559
+ * @throws {@link CryptoNotAvailableError} When the runtime has no Web Crypto API at all.
551
560
  * @throws {@link ValidationError} When `truncate` is not a positive integer ≤ 64.
552
561
  *
553
562
  * @example
@@ -650,6 +659,7 @@ declare function synthesize(value: string, category: string, options?: Synthesiz
650
659
  * }
651
660
  * ```
652
661
  */
662
+
653
663
  /**
654
664
  * Base class for all errors thrown by the anonyma library.
655
665
  * Consumers can use `err instanceof AnonymaError` to narrowly handle library errors.
@@ -768,5 +778,77 @@ declare class BatchProcessingError extends AnonymaError {
768
778
  readonly total: number;
769
779
  constructor(succeeded: number, failed: number, total: number);
770
780
  }
781
+ /**
782
+ * Thrown by a synchronous pipeline entry point when a replacer returns a
783
+ * promise. Use the asynchronous entry point (`transformAsync()`, an async
784
+ * chunk transformer, or an async stream) with that replacer instead.
785
+ *
786
+ * @example
787
+ * ```ts
788
+ * throw new AsyncStrategyError("email");
789
+ * ```
790
+ */
791
+ declare class AsyncStrategyError extends AnonymaError {
792
+ /** The category whose replacer is asynchronous. */
793
+ readonly category: string;
794
+ constructor(category: string);
795
+ }
796
+ /**
797
+ * Thrown when a key version is unknown, destroyed, malformed, or cannot be
798
+ * derived. The message never contains key material.
799
+ *
800
+ * @example
801
+ * ```ts
802
+ * throw new KeyManagementError("key version has been destroyed", "k1");
803
+ * ```
804
+ */
805
+ declare class KeyManagementError extends AnonymaError {
806
+ /** The key version the error refers to, when there is one. */
807
+ readonly keyId: string | undefined;
808
+ constructor(reason: string, keyId?: string);
809
+ }
810
+ /**
811
+ * Thrown when a token vault operation fails or would corrupt the vault. The
812
+ * message never contains an original value.
813
+ *
814
+ * @example
815
+ * ```ts
816
+ * throw new TokenVaultError("token identifier collision; increase idLength");
817
+ * ```
818
+ */
819
+ declare class TokenVaultError extends AnonymaError {
820
+ constructor(reason: string);
821
+ }
822
+ /**
823
+ * Thrown when a policy document is malformed or violates a requirement of a
824
+ * regulation it extends. `issues` lists every problem that was found.
825
+ *
826
+ * @example
827
+ * ```ts
828
+ * try {
829
+ * parsePolicy(document);
830
+ * } catch (err) {
831
+ * if (err instanceof PolicyError) {
832
+ * for (const issue of err.issues) console.error(issue.path, issue.message);
833
+ * }
834
+ * }
835
+ * ```
836
+ */
837
+ declare class PolicyError extends AnonymaError {
838
+ /** Every problem found in the document, errors first. */
839
+ readonly issues: readonly PolicyIssue[];
840
+ constructor(issues: readonly PolicyIssue[]);
841
+ }
842
+ /**
843
+ * Thrown when the audit chain cannot be extended or does not verify.
844
+ *
845
+ * @example
846
+ * ```ts
847
+ * throw new AuditIntegrityError("a sink rejected record 12; the logger is closed");
848
+ * ```
849
+ */
850
+ declare class AuditIntegrityError extends AnonymaError {
851
+ constructor(reason: string);
852
+ }
771
853
 
772
- export { AllowlistMatchError, AnonymaError, AnonymizationRule, AnonymizeOptions, AnonymizeResult, Anonymizer, AnonymizerConfig, BatchProcessingError, BatchResult, CompliancePreset, CryptoNotAvailableError, Detector, DetokenizeResult, EncryptionError, FieldRuleMap, GeneralizeOptions, HashOptions, MaskOptions, PRESET_REGISTRY, PiiCategory, PiiMatch, type PresetConfig, PresetNotFoundError, PseudonymizeOptions, RedactOptions, StrategyOptions, SynthesizeOptions, TokenizeOptions, TokenizeResult, UnknownCategoryError, UnsupportedStrategyError, ValidationError, anonymize, anonymizeAsync, anonymizeBatch, anonymizeBatchAsync, anonymizeObject, anonymizeRecord, createAnonymizer, detect, detectBatch, detokenize, generalize, getPreset, hasPII, hash, mask, pseudonymize, redact, restoreFromLLM, sanitizeForLLM, synthesize, tokenize, tokenizeAsync, tokenizeBatch };
854
+ export { AllowlistMatchError, AnonymaError, AnonymizationRule, AnonymizeOptions, AnonymizeResult, Anonymizer, AnonymizerConfig, AsyncStrategyError, AuditIntegrityError, BatchProcessingError, BatchResult, CompliancePreset, CryptoNotAvailableError, Detector, DetokenizeResult, EncryptionError, FieldRuleMap, GeneralizeOptions, HashOptions, KeyManagementError, MaskOptions, PRESET_REGISTRY, PiiCategory, PiiMatch, PolicyError, type PresetConfig, PresetNotFoundError, PseudonymizeOptions, RedactOptions, StrategyOptions, SynthesizeOptions, TokenVaultError, TokenizeOptions, TokenizeResult, UnknownCategoryError, UnsupportedStrategyError, ValidationError, anonymize, anonymizeAsync, anonymizeBatch, anonymizeBatchAsync, anonymizeObject, anonymizeRecord, createAnonymizer, detect, detectBatch, detokenize, generalize, getPreset, hasPII, hash, mask, pseudonymize, redact, restoreFromLLM, sanitizeForLLM, synthesize, tokenize, tokenizeAsync, tokenizeBatch };