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/CHANGELOG.md CHANGED
@@ -7,6 +7,132 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ---
9
9
 
10
+ ## [Unreleased]
11
+
12
+ ---
13
+
14
+ ## [1.1.0] — 2026-10-05
15
+
16
+ Additive release. The 1.0 functions (`anonymize`, `tokenize`, `anonymizeObject`, the streams,
17
+ `sanitizeForLLM`, …) keep their behaviour, apart from the fixes listed under "Fixed". Text
18
+ processed with the `hipaa` and `ccpa` presets may have more values replaced (see "Changed").
19
+
20
+ The subpath exports `anonyma/engine`, `/vault`, `/audit`, `/compliance`, `/ai`, `/mcp` and
21
+ `/middleware` are new. They were experimental in 1.1.0-beta.0 and are stable from this release:
22
+ they follow semantic versioning like the rest of the package.
23
+
24
+ Changes since 1.1.0-beta.0:
25
+
26
+ - The error classes added in this release are exported from `"anonyma"`. The pre-release did
27
+ not export them from any entry point, so they could not be used with `instanceof`.
28
+ - The subpath exports are no longer experimental.
29
+ - The warnings that `anonymize()` and `anonymizeAsync()` print for a strategy they do not apply
30
+ name the span engine, which applies it, instead of `anonymizeAsync()`, which does not.
31
+ - The README and the TSDoc describe the subpath modules, and say which declared options the 1.x
32
+ functions do not apply (see "Known limitations").
33
+ - Releases are published through npm trusted publishing only, and a stable version only from a
34
+ commit on `main`. The tests also run on Node.js 26.
35
+
36
+ ### Added
37
+
38
+ - **`"anonyma/engine"`** — span-based engine. `createPipeline()` and `compilePipeline()`
39
+ build a reusable pipeline with `scan`, `test`, `transform` and `transformAsync`.
40
+ Overlapping detections are resolved so that no detected character is left in the
41
+ output, the confidence filter runs before overlap resolution, output is assembled in
42
+ one pass, and a synchronous transform throws `AsyncStrategyError` instead of
43
+ substituting another strategy. `createChunkTransformer()` and `createPipelineStream()`
44
+ detect values that are split across chunks.
45
+ - **Validating detectors** for email, US SSN, IBAN, IPv4, IPv6 and payment cards
46
+ (`emailDetector`, `ssnDetector`, `ibanDetector`, `ipv4Detector`, `ipv6Detector`,
47
+ `creditCardDetector`), plus `defineDetector()`, `defineRegexDetector()` and
48
+ `fromLegacyDetector()`. The 1.x detectors are available to the engine as
49
+ `LEGACY_DETECTORS`.
50
+ - **`"anonyma/vault"`** — `createSessionTokenizer()`, `createKeyedTokenizer()`,
51
+ `createSealedTokenizer()`, `createKeyRing()` (versioned keys, HKDF per purpose,
52
+ rotation, destruction), `createMemoryVault()`, `rewrapVault()`, `shredKey()`,
53
+ `restoreTokens()`, `tokenizeWith()`.
54
+ - **`"anonyma/audit"`** — `createAuditLogger()` (hash-chained records without personal
55
+ data), `verifyAuditChain()`, `memorySink()`, `lineSink()`, `summarizeSpans()`,
56
+ `inputChecksum()`.
57
+ - **`"anonyma/compliance"`** — `REGULATIONS` (GDPR, LGPD, PIPEDA, CCPA/CPRA, HIPAA,
58
+ PCI DSS with citations and coverage gaps), `parsePolicy()` / `checkPolicy()`,
59
+ `policyToSpec()`, `describeStrategy()`, `planErasure()`.
60
+ - **`"anonyma/ai"`** — `sanitizeJson()` / `sanitizeJsonAsync()`, `createLlmGuard()`,
61
+ `createRestoreStream()`, `restoreChunks()` with lenses, `restoreJsonText()`,
62
+ `toLanguageModelMiddleware()`.
63
+ - **`"anonyma/mcp"`** — MCP tool and resource declarations (`MCP_TOOLS`, `MCP_RESOURCES`,
64
+ `MCP_RESOURCE_TEMPLATES`) and a dependency-free server (`createMcpServer()`,
65
+ `serveStdio()`).
66
+ - **`"anonyma/middleware"`**, **`"anonyma/middleware/express"`**,
67
+ **`"anonyma/middleware/hono"`** — `createScrubber()`, `anonymaExpress()`, `anonymaHono()`.
68
+ - **Presets `lgpd` and `pipeda`.**
69
+ - **Error classes** `AsyncStrategyError`, `KeyManagementError`, `TokenVaultError`,
70
+ `PolicyError` and `AuditIntegrityError`, exported from `"anonyma"` like the others.
71
+ - **`./package.json`** in the export map.
72
+ - **Benchmark** (`npm run bench`, `bench/`) and labelled detector corpora
73
+ (`tests/fixtures/corpus/`).
74
+ - Development dependencies `fast-check`, `express` and `hono` for property-based and
75
+ integration tests.
76
+
77
+ ### Changed
78
+
79
+ - **Preset `hipaa`** also detects `credit-card`, `iban`, `passport`, `license-plate` and
80
+ `social-media`; its description no longer claims to cover all 18 Safe Harbor
81
+ identifiers. **Preset `ccpa`** also detects `medical-record`, `health-insurance` and
82
+ `api-key`. Text processed with these presets may have more values replaced than
83
+ before.
84
+ - **Build:** entry points share code chunks (`splitting: true`). Every entry point now
85
+ uses the same class instances, so `instanceof AnonymaError` holds for errors thrown
86
+ by any subpath. The `dist/` layout gains `chunk-*.js` files.
87
+ - `PresetNotFoundError` lists the eight presets.
88
+ - **Releases** are built and published by GitHub Actions from a version tag, through npm
89
+ trusted publishing, with an npm provenance attestation, a GitHub build attestation and a
90
+ CycloneDX SBOM attached to the GitHub release.
91
+ - **Development** needs Node.js 22.22 or newer. The package still supports Node.js 18:
92
+ every release is installed and exercised on Node.js 18, 20, 22, 24 and 26.
93
+
94
+ ### Fixed
95
+
96
+ - **`hash()`, `encrypt()` and `decrypt()` on Node.js 18** threw because they read
97
+ `globalThis.crypto`, which that runtime does not define. They now fall back to the Web
98
+ Crypto implementation in `node:crypto`.
99
+ - **`detectDateOfBirth()`** dropped every date that preceded a date of a more confident
100
+ format (`"born 12/05/1987. Admitted on March 3, 2021."` lost the first date): its
101
+ overlap check compared positions instead of testing for intersection.
102
+ - **`mask()` with `preserveFormat`** and the generic **`synthesize()`** copied letters and
103
+ digits outside ASCII into their output. Letters and digits of every script are now
104
+ replaced.
105
+ - **`synthesize()`** no longer crashes, or returns `[object Undefined]`, for a category
106
+ named like an `Object.prototype` member (`constructor`, `toString`, …).
107
+ - The warning printed when `anonymize()` or `anonymizeAsync()` redacts a value whose rule is
108
+ `tokenize`, `encrypt` or `synthesize` advised `anonymizeAsync()`, which redacts it too.
109
+
110
+ ### Known limitations
111
+
112
+ The 1.0 documentation described behaviour that the 1.x functions do not have. The
113
+ documentation now describes what they do; the behaviour itself is unchanged:
114
+
115
+ - `anonymize()`, `anonymizeAsync()` and the functions built on them redact a value whose rule
116
+ is `tokenize`, `encrypt` or `synthesize`, with a warning, and the synchronous functions
117
+ replace a `hash` rule with a seeded pseudonym. A pipeline from `"anonyma/engine"` applies
118
+ every strategy.
119
+ - `createAnonymizer()` does not apply `plugins` (`AnonymaPlugin`).
120
+ - With `preset` set, `anonymize()` ignores `enabledCategories`; a pipeline can add categories
121
+ to a preset.
122
+ - `tokenize()` does not apply `format: "custom"` with `tokenTemplate`, nor
123
+ `deterministic: false`, and no function applies `locales`.
124
+ - `AnonymizeOptionsSchema.parse()` removes `preset`, `allowlist`, `confidenceThreshold`,
125
+ `locales` and the other options the schema does not describe.
126
+
127
+ ---
128
+
129
+ ## [1.1.0-beta.0] — 2026-10-04
130
+
131
+ Pre-release of 1.1.0, published under the `next` dist-tag. Its changes are listed under
132
+ [1.1.0], together with the changes made since.
133
+
134
+ ---
135
+
10
136
  ## [1.0.0] — 2026-03-06
11
137
 
12
138
  ### Added
@@ -107,14 +233,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
107
233
  Six presets are available out of the box, each pre-configuring `enabledCategories` and
108
234
  `defaultStrategy`:
109
235
 
110
- | Preset | Default Strategy | Coverage |
111
- |---|---|---|
112
- | `"gdpr"` | `pseudonymize` | All personal data categories defined by the EU GDPR. |
113
- | `"hipaa"` | `redact` | All 18 HIPAA Safe Harbor identifiers for PHI de-identification. |
114
- | `"ccpa"` | `redact` | Consumer data categories defined by the California Consumer Privacy Act. |
115
- | `"pci-dss"` | `redact` (card numbers: `mask` keepTrailing 4) | Cardholder and sensitive authentication data per PCI-DSS. |
116
- | `"sox"` | `redact` | Financial records and corporate officer identifiers for SOX audit trails. |
117
- | `"ferpa"` | `redact` | Student education records as defined by FERPA. |
236
+ | Preset | Default Strategy | Coverage |
237
+ | ----------- | ---------------------------------------------- | ------------------------------------------------------------------------- |
238
+ | `"gdpr"` | `pseudonymize` | All personal data categories defined by the EU GDPR. |
239
+ | `"hipaa"` | `redact` | All 18 HIPAA Safe Harbor identifiers for PHI de-identification. |
240
+ | `"ccpa"` | `redact` | Consumer data categories defined by the California Consumer Privacy Act. |
241
+ | `"pci-dss"` | `redact` (card numbers: `mask` keepTrailing 4) | Cardholder and sensitive authentication data per PCI-DSS. |
242
+ | `"sox"` | `redact` | Financial records and corporate officer identifiers for SOX audit trails. |
243
+ | `"ferpa"` | `redact` | Student education records as defined by FERPA. |
118
244
 
119
245
  ---
120
246
 
@@ -174,71 +300,71 @@ individually for maximum tree-shaking. Twenty-seven categories are supported.
174
300
 
175
301
  **Email, Network & Identity**
176
302
 
177
- | Function | Confidence | Notes |
178
- |---|---|---|
179
- | `detectEmail` | 0.99 | RFC 5321 email addresses. |
180
- | `detectEmailAggressive` | 0.75 | Obfuscated formats, e.g. `user [at] example [dot] com`. |
181
- | `detectIpv4` | 0.98 | Dotted-decimal IPv4 with optional CIDR notation. |
182
- | `detectIpv6` | 0.98 | Full and compressed IPv6 addresses. |
183
- | `detectUrl` | 0.95 | http and https URLs with paths, query strings, and fragments. |
184
- | `detectApiKey` | — | Common API key patterns (hex strings, Bearer tokens, `sk-`/`pk-`/`ghp_`-prefixed keys, etc.). |
185
- | `detectSocialMedia` | — | Social media handles (`@username`) and profile URL patterns. |
303
+ | Function | Confidence | Notes |
304
+ | ----------------------- | ---------- | --------------------------------------------------------------------------------------------- |
305
+ | `detectEmail` | 0.99 | RFC 5321 email addresses. |
306
+ | `detectEmailAggressive` | 0.75 | Obfuscated formats, e.g. `user [at] example [dot] com`. |
307
+ | `detectIpv4` | 0.98 | Dotted-decimal IPv4 with optional CIDR notation. |
308
+ | `detectIpv6` | 0.98 | Full and compressed IPv6 addresses. |
309
+ | `detectUrl` | 0.95 | http and https URLs with paths, query strings, and fragments. |
310
+ | `detectApiKey` | — | Common API key patterns (hex strings, Bearer tokens, `sk-`/`pk-`/`ghp_`-prefixed keys, etc.). |
311
+ | `detectSocialMedia` | — | Social media handles (`@username`) and profile URL patterns. |
186
312
 
187
313
  **Phone & Identity Numbers**
188
314
 
189
- | Function | Confidence | Notes |
190
- |---|---|---|
191
- | `detectPhone` | 0.90 | North American + E.164 international formats. |
192
- | `detectPhoneAggressive` | 0.70 | 7-digit local formats (e.g. `555-1234`). |
193
- | `detectSsn` | 0.95 | US Social Security Numbers with format and known-invalid range exclusions. |
194
- | `detectSsnAggressive` | 0.80 | Expanded SSN pattern set. |
315
+ | Function | Confidence | Notes |
316
+ | ----------------------- | ---------- | -------------------------------------------------------------------------- |
317
+ | `detectPhone` | 0.90 | North American + E.164 international formats. |
318
+ | `detectPhoneAggressive` | 0.70 | 7-digit local formats (e.g. `555-1234`). |
319
+ | `detectSsn` | 0.95 | US Social Security Numbers with format and known-invalid range exclusions. |
320
+ | `detectSsnAggressive` | 0.80 | Expanded SSN pattern set. |
195
321
 
196
322
  **Financial**
197
323
 
198
- | Function | Confidence | Notes |
199
- |---|---|---|
200
- | `detectCreditCard` | 0.97 | 13–19 digit card numbers validated with the Luhn algorithm. |
201
- | `detectCreditCardAggressive` | 0.80 | Also catches masked formats `****-****-****-1234`. |
202
- | `detectIban` | 0.99 | IBAN strings validated with the ISO 13616 MOD-97 algorithm. |
203
- | `detectBankAccount` | — | Common bank account number formats. |
204
- | `detectCryptocurrency` | — | Bitcoin, Ethereum, and other common cryptocurrency wallet addresses. |
205
- | `detectTaxId` | — | US EIN and common international tax identification number formats. |
324
+ | Function | Confidence | Notes |
325
+ | ---------------------------- | ---------- | -------------------------------------------------------------------- |
326
+ | `detectCreditCard` | 0.97 | 13–19 digit card numbers validated with the Luhn algorithm. |
327
+ | `detectCreditCardAggressive` | 0.80 | Also catches masked formats `****-****-****-1234`. |
328
+ | `detectIban` | 0.99 | IBAN strings validated with the ISO 13616 MOD-97 algorithm. |
329
+ | `detectBankAccount` | — | Common bank account number formats. |
330
+ | `detectCryptocurrency` | — | Bitcoin, Ethereum, and other common cryptocurrency wallet addresses. |
331
+ | `detectTaxId` | — | US EIN and common international tax identification number formats. |
206
332
 
207
333
  **Personal Information**
208
334
 
209
- | Function | Confidence | Notes |
210
- |---|---|---|
211
- | `detectName` | 0.75 | Heuristic: catches names preceded by greeting/salutation keywords (`Dear`, `Hi`, `Hello`, `To`, `From`, `Patient`, `Client`, `Defendant`, etc.). Not an NLP-based named-entity recogniser. |
212
- | `detectNameAggressive` | 0.65 | Extends `detectName` with title-prefix patterns (`Mr.`, `Mrs.`, `Ms.`, `Dr.`, `Prof.`). |
213
- | `detectDateOfBirth` | 0.78–0.88 | ISO 8601, US (`MM/DD/YYYY`), European (`DD/MM/YYYY`), and long-form date patterns. |
214
- | `detectAddress` | — | Multi-line postal address patterns (street number, city, state/zip). |
215
- | `detectPassport` | — | Passport number formats for major issuing countries. |
216
- | `detectDriversLicense` | — | US and international driver's licence number patterns. |
217
- | `detectNationalId` | — | National identity document numbers (SSN-adjacent, Aadhaar, NINO, etc.). |
335
+ | Function | Confidence | Notes |
336
+ | ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
337
+ | `detectName` | 0.75 | Heuristic: catches names preceded by greeting/salutation keywords (`Dear`, `Hi`, `Hello`, `To`, `From`, `Patient`, `Client`, `Defendant`, etc.). Not an NLP-based named-entity recogniser. |
338
+ | `detectNameAggressive` | 0.65 | Extends `detectName` with title-prefix patterns (`Mr.`, `Mrs.`, `Ms.`, `Dr.`, `Prof.`). |
339
+ | `detectDateOfBirth` | 0.78–0.88 | ISO 8601, US (`MM/DD/YYYY`), European (`DD/MM/YYYY`), and long-form date patterns. |
340
+ | `detectAddress` | — | Multi-line postal address patterns (street number, city, state/zip). |
341
+ | `detectPassport` | — | Passport number formats for major issuing countries. |
342
+ | `detectDriversLicense` | — | US and international driver's licence number patterns. |
343
+ | `detectNationalId` | — | National identity document numbers (SSN-adjacent, Aadhaar, NINO, etc.). |
218
344
 
219
345
  **Healthcare**
220
346
 
221
- | Function | Notes |
222
- |---|---|
223
- | `detectMedicalRecord` | Medical record number (MRN) patterns. |
347
+ | Function | Notes |
348
+ | ----------------------- | ------------------------------------------------------ |
349
+ | `detectMedicalRecord` | Medical record number (MRN) patterns. |
224
350
  | `detectHealthInsurance` | Health insurance member ID and policy number patterns. |
225
- | `detectPrescription` | Prescription and DEA registration number patterns. |
351
+ | `detectPrescription` | Prescription and DEA registration number patterns. |
226
352
 
227
353
  **Vehicles & Transportation**
228
354
 
229
- | Function | Notes |
230
- |---|---|
231
- | `detectVin` | 17-character Vehicle Identification Numbers validated with the ISO 3779 mod-11 checksum. |
232
- | `detectVinAggressive` | Expanded VIN pattern set for partial or obfuscated VINs. |
233
- | `detectLicensePlate` | Common licence plate formats across multiple countries. |
234
- | `detectTrackingNumber` | Shipping tracking numbers (UPS, FedEx, USPS, DHL formats). |
355
+ | Function | Notes |
356
+ | ---------------------- | ---------------------------------------------------------------------------------------- |
357
+ | `detectVin` | 17-character Vehicle Identification Numbers validated with the ISO 3779 mod-11 checksum. |
358
+ | `detectVinAggressive` | Expanded VIN pattern set for partial or obfuscated VINs. |
359
+ | `detectLicensePlate` | Common licence plate formats across multiple countries. |
360
+ | `detectTrackingNumber` | Shipping tracking numbers (UPS, FedEx, USPS, DHL formats). |
235
361
 
236
362
  **Government & Legal**
237
363
 
238
- | Function | Notes |
239
- |---|---|
240
- | `detectCaseNumber` | Court case number formats (`YYYY-CV-NNNNN` and variants). |
241
- | `detectCompanyRegistration` | Company registration and incorporation number formats. |
364
+ | Function | Notes |
365
+ | --------------------------- | --------------------------------------------------------- |
366
+ | `detectCaseNumber` | Court case number formats (`YYYY-CV-NNNNN` and variants). |
367
+ | `detectCompanyRegistration` | Company registration and incorporation number formats. |
242
368
 
243
369
  **Registries**
244
370
 
@@ -253,23 +379,23 @@ individually for maximum tree-shaking. Twenty-seven categories are supported.
253
379
 
254
380
  #### `AnonymizeOptions` Reference
255
381
 
256
- | Option | Type | Default | Description |
257
- |---|---|---|---|
258
- | `rules` | `AnonymizationRule[]` | `[]` | Per-category strategy overrides. When non-empty, only listed categories are scanned. |
259
- | `defaultStrategy` | `StrategyOptions` | `{ strategy: "redact" }` | Strategy applied to any category not covered by `rules`. |
260
- | `includeMatches` | `boolean` | `false` | Include the `PiiMatch` array in the result. |
261
- | `customDetectors` | `Partial<Record<PiiCategory, Detector>>` | — | Replace built-in detectors on a per-category basis. |
262
- | `customPatterns` | `CustomPattern[]` | — | Ad-hoc `RegExp` patterns merged into the detection pipeline. Matches participate in standard overlap deduplication. |
263
- | `globalReplacement` | `string` | — | Replace every detected entity with this exact string, overriding all strategy settings. |
264
- | `consistentTokens` | `boolean` | `false` | Map repeated identical PII values to the same token within a single call (e.g. `EMAIL_1`, `EMAIL_1` for the same address appearing twice). Different values get different counters. |
265
- | `aggressive` | `boolean` | `false` | Switch to `AGGRESSIVE_DETECTOR_REGISTRY` for all built-in categories. |
266
- | `enabledCategories` | `Partial<Record<PiiCategory, boolean>>` | — | Convenience boolean map. Only categories set to `true` are active; `rules` takes precedence for categories it covers. |
267
- | `allowlist` | `string[]` | `[]` | Exact values to never anonymize (case-insensitive by default). |
268
- | `allowlistPatterns` | `RegExp[]` | `[]` | Regular expressions matched against detected values; matches are skipped. |
269
- | `allowlistCaseSensitive` | `boolean` | `false` | Make `allowlist` string matching case-sensitive. |
270
- | `confidenceThreshold` | `number` | `0` | Minimum confidence score `[0, 1]` for a match to be anonymized. |
271
- | `preset` | `CompliancePreset` | — | Apply a compliance preset as the base configuration. Explicit `rules` and `defaultStrategy` take precedence. |
272
- | `locales` | `Locale[]` | `["global"]` | Activate locale-specific detector patterns. Values: `"global"`, `"us"`, `"uk"`, `"eu"`, `"ca"`, `"au"`, `"br"`, `"in"`, `"cn"`, `"jp"`, `"kr"`, `"za"`. |
382
+ | Option | Type | Default | Description |
383
+ | ------------------------ | ---------------------------------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
384
+ | `rules` | `AnonymizationRule[]` | `[]` | Per-category strategy overrides. When non-empty, only listed categories are scanned. |
385
+ | `defaultStrategy` | `StrategyOptions` | `{ strategy: "redact" }` | Strategy applied to any category not covered by `rules`. |
386
+ | `includeMatches` | `boolean` | `false` | Include the `PiiMatch` array in the result. |
387
+ | `customDetectors` | `Partial<Record<PiiCategory, Detector>>` | — | Replace built-in detectors on a per-category basis. |
388
+ | `customPatterns` | `CustomPattern[]` | — | Ad-hoc `RegExp` patterns merged into the detection pipeline. Matches participate in standard overlap deduplication. |
389
+ | `globalReplacement` | `string` | — | Replace every detected entity with this exact string, overriding all strategy settings. |
390
+ | `consistentTokens` | `boolean` | `false` | Map repeated identical PII values to the same token within a single call (e.g. `EMAIL_1`, `EMAIL_1` for the same address appearing twice). Different values get different counters. |
391
+ | `aggressive` | `boolean` | `false` | Switch to `AGGRESSIVE_DETECTOR_REGISTRY` for all built-in categories. |
392
+ | `enabledCategories` | `Partial<Record<PiiCategory, boolean>>` | — | Convenience boolean map. Only categories set to `true` are active; `rules` takes precedence for categories it covers. |
393
+ | `allowlist` | `string[]` | `[]` | Exact values to never anonymize (case-insensitive by default). |
394
+ | `allowlistPatterns` | `RegExp[]` | `[]` | Regular expressions matched against detected values; matches are skipped. |
395
+ | `allowlistCaseSensitive` | `boolean` | `false` | Make `allowlist` string matching case-sensitive. |
396
+ | `confidenceThreshold` | `number` | `0` | Minimum confidence score `[0, 1]` for a match to be anonymized. |
397
+ | `preset` | `CompliancePreset` | — | Apply a compliance preset as the base configuration. Explicit `rules` and `defaultStrategy` take precedence. |
398
+ | `locales` | `Locale[]` | `["global"]` | Activate locale-specific detector patterns. Values: `"global"`, `"us"`, `"uk"`, `"eu"`, `"ca"`, `"au"`, `"br"`, `"in"`, `"cn"`, `"jp"`, `"kr"`, `"za"`. |
273
399
 
274
400
  ---
275
401
 
@@ -278,17 +404,17 @@ individually for maximum tree-shaking. Twenty-seven categories are supported.
278
404
  All errors extend `AnonymaError` and carry a machine-readable `code` string, enabling
279
405
  precise `switch`/`instanceof` error handling.
280
406
 
281
- | Class | Code | Extra Properties | When Thrown |
282
- |---|---|---|---|
283
- | `AnonymaError` | — | `code: string` | Base class; never thrown directly. |
284
- | `ValidationError` | `VALIDATION_ERROR` | `field: string` | A function argument fails validation (wrong type, out-of-range value, etc.). |
285
- | `UnsupportedStrategyError` | `UNSUPPORTED_STRATEGY` | `strategy: string` | An unrecognised strategy name is passed. |
286
- | `UnknownCategoryError` | `UNKNOWN_CATEGORY` | `category: string` | A rule or config references an unknown PII category. |
287
- | `CryptoNotAvailableError` | `CRYPTO_NOT_AVAILABLE` | — | `globalThis.crypto.subtle` is absent (Node < 18 or no polyfill). |
288
- | `EncryptionError` | `ENCRYPTION_ERROR` | `operation: "encrypt" \| "decrypt"` | The underlying AES-GCM operation fails (wrong key, corrupt ciphertext, etc.). |
289
- | `PresetNotFoundError` | `PRESET_NOT_FOUND` | `preset: string` | `getPreset()` is called with an unknown preset name. |
290
- | `AllowlistMatchError` | `ALLOWLIST_MATCH_ERROR` | `field: string` | An allowlist configuration entry is malformed. |
291
- | `BatchProcessingError` | `BATCH_PROCESSING_ERROR` | `succeeded`, `failed`, `total: number` | One or more items in a batch fail; carries partial result counts. |
407
+ | Class | Code | Extra Properties | When Thrown |
408
+ | -------------------------- | ------------------------ | -------------------------------------- | ----------------------------------------------------------------------------- |
409
+ | `AnonymaError` | — | `code: string` | Base class; never thrown directly. |
410
+ | `ValidationError` | `VALIDATION_ERROR` | `field: string` | A function argument fails validation (wrong type, out-of-range value, etc.). |
411
+ | `UnsupportedStrategyError` | `UNSUPPORTED_STRATEGY` | `strategy: string` | An unrecognised strategy name is passed. |
412
+ | `UnknownCategoryError` | `UNKNOWN_CATEGORY` | `category: string` | A rule or config references an unknown PII category. |
413
+ | `CryptoNotAvailableError` | `CRYPTO_NOT_AVAILABLE` | — | `globalThis.crypto.subtle` is absent (Node < 18 or no polyfill). |
414
+ | `EncryptionError` | `ENCRYPTION_ERROR` | `operation: "encrypt" \| "decrypt"` | The underlying AES-GCM operation fails (wrong key, corrupt ciphertext, etc.). |
415
+ | `PresetNotFoundError` | `PRESET_NOT_FOUND` | `preset: string` | `getPreset()` is called with an unknown preset name. |
416
+ | `AllowlistMatchError` | `ALLOWLIST_MATCH_ERROR` | `field: string` | An allowlist configuration entry is malformed. |
417
+ | `BatchProcessingError` | `BATCH_PROCESSING_ERROR` | `succeeded`, `failed`, `total: number` | One or more items in a batch fail; carries partial result counts. |
292
418
 
293
419
  ---
294
420
 
@@ -317,17 +443,17 @@ unavailable.
317
443
  Pure validation functions for PII checksum and format algorithms. All accept a string and
318
444
  return `boolean`.
319
445
 
320
- | Function | Algorithm / Standard | Notes |
321
- |---|---|---|
322
- | `luhn(digits)` | Luhn (ISO/IEC 7812) | Credit/debit card numbers and some national IDs. |
323
- | `verhoeff(digits)` | Verhoeff | Indian Aadhaar numbers and some other national IDs. |
324
- | `nhsMod11(value)` | NHS mod-11 | UK NHS 10-digit numbers (with or without spaces/hyphens). |
325
- | `cpfChecksum(value)` | Brazilian CPF | 11-digit CPF with two check digits; rejects all-same-digit sequences. |
326
- | `vinChecksum(vin)` | ISO 3779 mod-11 | 17-character Vehicle Identification Numbers. |
327
- | `deaChecksum(value)` | DEA mod-10 | US Drug Enforcement Administration registration numbers. |
328
- | `ibanMod97(value)` | ISO 13616 mod-97 | IBAN strings (15–34 characters, with or without spaces). |
329
- | `ninoValid(value)` | UK NINO format | UK National Insurance Numbers; rejects invalid letter prefixes. |
330
- | `aadhaarFormat(value)` | Aadhaar format | 12-digit Indian Aadhaar; does not start with `0` or `1`. |
446
+ | Function | Algorithm / Standard | Notes |
447
+ | ---------------------- | -------------------- | --------------------------------------------------------------------- |
448
+ | `luhn(digits)` | Luhn (ISO/IEC 7812) | Credit/debit card numbers and some national IDs. |
449
+ | `verhoeff(digits)` | Verhoeff | Indian Aadhaar numbers and some other national IDs. |
450
+ | `nhsMod11(value)` | NHS mod-11 | UK NHS 10-digit numbers (with or without spaces/hyphens). |
451
+ | `cpfChecksum(value)` | Brazilian CPF | 11-digit CPF with two check digits; rejects all-same-digit sequences. |
452
+ | `vinChecksum(vin)` | ISO 3779 mod-11 | 17-character Vehicle Identification Numbers. |
453
+ | `deaChecksum(value)` | DEA mod-10 | US Drug Enforcement Administration registration numbers. |
454
+ | `ibanMod97(value)` | ISO 13616 mod-97 | IBAN strings (15–34 characters, with or without spaces). |
455
+ | `ninoValid(value)` | UK NINO format | UK National Insurance Numbers; rejects invalid letter prefixes. |
456
+ | `aadhaarFormat(value)` | Aadhaar format | 12-digit Indian Aadhaar; does not start with `0` or `1`. |
331
457
 
332
458
  ---
333
459
 
@@ -351,22 +477,22 @@ Requires `zod` as a peer dependency. Import from `"anonyma/schemas"`.
351
477
 
352
478
  **Zod Schemas**
353
479
 
354
- | Export | Validates |
355
- |---|---|
356
- | `PiiCategorySchema` | All 27 `PiiCategory` string literals. |
357
- | `MaskOptionsSchema` | `MaskOptions` including `maskChar`, `keepLeading`, `keepTrailing`. |
358
- | `RedactOptionsSchema` | `RedactOptions` with `label`. |
359
- | `PseudonymizeOptionsSchema` | `PseudonymizeOptions` with `seed` and `prefix`. |
360
- | `HashOptionsSchema` | `HashOptions` with `truncate` and `pepper`. |
361
- | `GeneralizeOptionsSchema` | `GeneralizeOptions` with `bucketSize`. |
362
- | `StrategyOptionsSchema` | Discriminated union of all strategy option shapes. |
363
- | `PiiMatchSchema` | `PiiMatch` output object. |
364
- | `AnonymizeResultSchema` | `AnonymizeResult` with `text` and `matches`. |
365
- | `AnonymizationRuleSchema` | Single `{ category, strategy }` rule. |
366
- | `CustomPatternSchema` | `CustomPattern` with `pattern` (RegExp instance), `category`, `confidence`, `label`. |
367
- | `AnonymizeOptionsSchema` | Full `AnonymizeOptions` input object. |
368
- | `FieldRuleSchema` | Single field-level `{ strategy }` rule. |
369
- | `FieldRuleMapSchema` | `Record<string, FieldRule>` for `anonymizeRecord()`. |
480
+ | Export | Validates |
481
+ | --------------------------- | ------------------------------------------------------------------------------------ |
482
+ | `PiiCategorySchema` | All 27 `PiiCategory` string literals. |
483
+ | `MaskOptionsSchema` | `MaskOptions` including `maskChar`, `keepLeading`, `keepTrailing`. |
484
+ | `RedactOptionsSchema` | `RedactOptions` with `label`. |
485
+ | `PseudonymizeOptionsSchema` | `PseudonymizeOptions` with `seed` and `prefix`. |
486
+ | `HashOptionsSchema` | `HashOptions` with `truncate` and `pepper`. |
487
+ | `GeneralizeOptionsSchema` | `GeneralizeOptions` with `bucketSize`. |
488
+ | `StrategyOptionsSchema` | Discriminated union of all strategy option shapes. |
489
+ | `PiiMatchSchema` | `PiiMatch` output object. |
490
+ | `AnonymizeResultSchema` | `AnonymizeResult` with `text` and `matches`. |
491
+ | `AnonymizationRuleSchema` | Single `{ category, strategy }` rule. |
492
+ | `CustomPatternSchema` | `CustomPattern` with `pattern` (RegExp instance), `category`, `confidence`, `label`. |
493
+ | `AnonymizeOptionsSchema` | Full `AnonymizeOptions` input object. |
494
+ | `FieldRuleSchema` | Single field-level `{ strategy }` rule. |
495
+ | `FieldRuleMapSchema` | `Record<string, FieldRule>` for `anonymizeRecord()`. |
370
496
 
371
497
  **OpenAI / MCP Tool Definitions**
372
498
 
@@ -397,41 +523,41 @@ All Zod schema input/output types are re-exported as TypeScript types:
397
523
 
398
524
  All types are zero-cost, type-only exports (stripped by `tsc`; no runtime overhead).
399
525
 
400
- | Type | Description |
401
- |---|---|
402
- | `PiiCategory` | Union of all 27 supported category string literals. |
403
- | `PiiMatch` | `{ category, value, start, end, confidence }` — a single detected PII entity. |
404
- | `CustomPattern` | `{ pattern: RegExp; category?; confidence?; label? }` — ad-hoc detection pattern. |
405
- | `Locale` | `"global" \| "us" \| "uk" \| "eu" \| "ca" \| "au" \| "br" \| "in" \| "cn" \| "jp" \| "kr" \| "za"` |
406
- | `CompliancePreset` | `"gdpr" \| "hipaa" \| "ccpa" \| "pci-dss" \| "sox" \| "ferpa"` |
407
- | `StrategyName` | `"mask" \| "redact" \| "pseudonymize" \| "hash" \| "generalize" \| "tokenize" \| "encrypt" \| "synthesize"` |
408
- | `StrategyOptions` | Discriminated union of all per-strategy option shapes. |
409
- | `MaskOptions` | `{ maskChar?, keepLeading?, keepTrailing?, preserveFormat? }` |
410
- | `RedactOptions` | `{ label? }` |
411
- | `PseudonymizeOptions` | `{ seed?, prefix? }` |
412
- | `HashOptions` | `{ truncate?, pepper? }` |
413
- | `GeneralizeOptions` | `{ bucketSize? }` |
414
- | `EncryptOptions` | `{ passphrase?, keyBytes?, encoding? }` |
415
- | `SynthesizeOptions` | `{ seed?, locale? }` |
416
- | `AnonymizationRule` | `{ category: PiiCategory, strategy: StrategyOptions }` |
417
- | `AnonymizeOptions` | Full options accepted by `anonymize()` and `anonymizeAsync()`. |
418
- | `AnonymizeResult` | `{ text: string, matches: ReadonlyArray<PiiMatch> }` |
419
- | `TokenFormat` | `"angle" \| "bracket" \| "custom"` |
420
- | `TokenizeOptions` | Options for `tokenize()` including `categories`, `format`, `tokenTemplate`, `deterministic`, `aggressive`, `locales`, `confidenceThreshold`, `allowlist`. |
421
- | `TokenizeResult` | `{ text, mapping: ReadonlyMap<string, string>, tokens: TokenMatch[] }` |
422
- | `DetokenizeResult` | `{ text, replacedCount, unresolved: string[] }` |
423
- | `TokenMatch` | `{ token, original, category, start, end }` |
424
- | `BatchResult<T>` | Discriminated union: `{ index, ok: true, value: T } \| { index, ok: false, error: Error }` |
425
- | `FieldRule` | `{ strategy: StrategyOptions }` |
426
- | `FieldRuleMap` | `Record<string, FieldRule>` — dot-notation paths for `anonymizeRecord()`. |
427
- | `Detector` | `(text: string) => PiiMatch[]` — detector function signature. |
428
- | `DetectorRegistry` | `Record<PiiCategory, Detector>` |
429
- | `Anonymizer` | Interface returned by `createAnonymizer()`. |
430
- | `AnonymizerConfig` | Config accepted by `createAnonymizer()`. |
431
- | `AnonymaPlugin` | `{ name, detectors?, strategies?, validators? }` — plugin extension point. |
432
- | `ValidatorFunction` | `(value: string) => boolean` |
433
- | `StrategyFunction` | `(value: string, options?) => string` |
434
- | `PresetConfig` | Full configuration shape for a compliance preset. |
526
+ | Type | Description |
527
+ | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
528
+ | `PiiCategory` | Union of all 27 supported category string literals. |
529
+ | `PiiMatch` | `{ category, value, start, end, confidence }` — a single detected PII entity. |
530
+ | `CustomPattern` | `{ pattern: RegExp; category?; confidence?; label? }` — ad-hoc detection pattern. |
531
+ | `Locale` | `"global" \| "us" \| "uk" \| "eu" \| "ca" \| "au" \| "br" \| "in" \| "cn" \| "jp" \| "kr" \| "za"` |
532
+ | `CompliancePreset` | `"gdpr" \| "hipaa" \| "ccpa" \| "pci-dss" \| "sox" \| "ferpa"` |
533
+ | `StrategyName` | `"mask" \| "redact" \| "pseudonymize" \| "hash" \| "generalize" \| "tokenize" \| "encrypt" \| "synthesize"` |
534
+ | `StrategyOptions` | Discriminated union of all per-strategy option shapes. |
535
+ | `MaskOptions` | `{ maskChar?, keepLeading?, keepTrailing?, preserveFormat? }` |
536
+ | `RedactOptions` | `{ label? }` |
537
+ | `PseudonymizeOptions` | `{ seed?, prefix? }` |
538
+ | `HashOptions` | `{ truncate?, pepper? }` |
539
+ | `GeneralizeOptions` | `{ bucketSize? }` |
540
+ | `EncryptOptions` | `{ passphrase?, keyBytes?, encoding? }` |
541
+ | `SynthesizeOptions` | `{ seed?, locale? }` |
542
+ | `AnonymizationRule` | `{ category: PiiCategory, strategy: StrategyOptions }` |
543
+ | `AnonymizeOptions` | Full options accepted by `anonymize()` and `anonymizeAsync()`. |
544
+ | `AnonymizeResult` | `{ text: string, matches: ReadonlyArray<PiiMatch> }` |
545
+ | `TokenFormat` | `"angle" \| "bracket" \| "custom"` |
546
+ | `TokenizeOptions` | Options for `tokenize()` including `categories`, `format`, `tokenTemplate`, `deterministic`, `aggressive`, `locales`, `confidenceThreshold`, `allowlist`. |
547
+ | `TokenizeResult` | `{ text, mapping: ReadonlyMap<string, string>, tokens: TokenMatch[] }` |
548
+ | `DetokenizeResult` | `{ text, replacedCount, unresolved: string[] }` |
549
+ | `TokenMatch` | `{ token, original, category, start, end }` |
550
+ | `BatchResult<T>` | Discriminated union: `{ index, ok: true, value: T } \| { index, ok: false, error: Error }` |
551
+ | `FieldRule` | `{ strategy: StrategyOptions }` |
552
+ | `FieldRuleMap` | `Record<string, FieldRule>` — dot-notation paths for `anonymizeRecord()`. |
553
+ | `Detector` | `(text: string) => PiiMatch[]` — detector function signature. |
554
+ | `DetectorRegistry` | `Record<PiiCategory, Detector>` |
555
+ | `Anonymizer` | Interface returned by `createAnonymizer()`. |
556
+ | `AnonymizerConfig` | Config accepted by `createAnonymizer()`. |
557
+ | `AnonymaPlugin` | `{ name, detectors?, strategies?, validators? }` — plugin extension point. |
558
+ | `ValidatorFunction` | `(value: string) => boolean` |
559
+ | `StrategyFunction` | `(value: string, options?) => string` |
560
+ | `PresetConfig` | Full configuration shape for a compliance preset. |
435
561
 
436
562
  ---
437
563
 
@@ -454,4 +580,7 @@ All types are zero-cost, type-only exports (stripped by `tsc`; no runtime overhe
454
580
  - **Prettier** code formatting.
455
581
  - **MIT License**.
456
582
 
583
+ [Unreleased]: https://github.com/izaccavalheiro/anonyma/compare/v1.1.0...HEAD
584
+ [1.1.0]: https://github.com/izaccavalheiro/anonyma/releases/tag/v1.1.0
585
+ [1.1.0-beta.0]: https://github.com/izaccavalheiro/anonyma/releases/tag/v1.1.0-beta.0
457
586
  [1.0.0]: https://github.com/izaccavalheiro/anonyma/releases/tag/v1.0.0