anonyma 1.1.0 → 1.2.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/CHANGELOG.md +131 -2
- package/README.md +125 -7
- package/dist/ai/index.cjs +31 -20
- package/dist/ai/index.cjs.map +1 -1
- package/dist/ai/index.d.cts +5 -5
- package/dist/ai/index.d.ts +5 -5
- package/dist/ai/index.js +24 -13
- package/dist/ai/index.js.map +1 -1
- package/dist/audit/index.cjs +14 -14
- package/dist/audit/index.d.cts +2 -2
- package/dist/audit/index.d.ts +2 -2
- package/dist/audit/index.js +9 -9
- package/dist/{chunk-YMLR375Z.js → chunk-264R3VFP.js} +4 -3
- package/dist/chunk-264R3VFP.js.map +1 -0
- package/dist/{chunk-ISL5B4LU.cjs → chunk-32U3DM7M.cjs} +11 -11
- package/dist/{chunk-ISL5B4LU.cjs.map → chunk-32U3DM7M.cjs.map} +1 -1
- package/dist/{chunk-26IHMQHL.cjs → chunk-42ZZZUMO.cjs} +245 -85
- package/dist/chunk-42ZZZUMO.cjs.map +1 -0
- package/dist/chunk-4BYN6GVK.js +213 -0
- package/dist/chunk-4BYN6GVK.js.map +1 -0
- package/dist/{chunk-JKW36IPT.js → chunk-A2OMTO3L.js} +4 -4
- package/dist/{chunk-JKW36IPT.js.map → chunk-A2OMTO3L.js.map} +1 -1
- package/dist/{chunk-TW7PM3UJ.cjs → chunk-AITKBKQX.cjs} +2 -2
- package/dist/{chunk-TW7PM3UJ.cjs.map → chunk-AITKBKQX.cjs.map} +1 -1
- package/dist/{chunk-G4AN7FND.js → chunk-BWE4O2ES.js} +23 -9
- package/dist/chunk-BWE4O2ES.js.map +1 -0
- package/dist/{chunk-GS3FRH4K.js → chunk-CMJXIEBA.js} +2 -2
- package/dist/chunk-CMJXIEBA.js.map +1 -0
- package/dist/{chunk-GYMG5OI3.cjs → chunk-ESVFPMG4.cjs} +2 -2
- package/dist/{chunk-GYMG5OI3.cjs.map → chunk-ESVFPMG4.cjs.map} +1 -1
- package/dist/{chunk-2YG7R4KJ.cjs → chunk-EUNLKSYP.cjs} +5 -5
- package/dist/{chunk-2YG7R4KJ.cjs.map → chunk-EUNLKSYP.cjs.map} +1 -1
- package/dist/{chunk-S7NH6CHY.cjs → chunk-F3BYJFUM.cjs} +5 -3
- package/dist/chunk-F3BYJFUM.cjs.map +1 -0
- package/dist/{chunk-IJAMLYOT.cjs → chunk-HDHQXVUM.cjs} +50 -36
- package/dist/chunk-HDHQXVUM.cjs.map +1 -0
- package/dist/{chunk-OGNLB2KA.js → chunk-HFAIBE3T.js} +3 -3
- package/dist/{chunk-OGNLB2KA.js.map → chunk-HFAIBE3T.js.map} +1 -1
- package/dist/{chunk-PKHZ7CVI.js → chunk-IBDFBUFZ.js} +2 -2
- package/dist/chunk-IBDFBUFZ.js.map +1 -0
- package/dist/{chunk-3CY6ATKS.cjs → chunk-JBH2EFFF.cjs} +36 -36
- package/dist/{chunk-3CY6ATKS.cjs.map → chunk-JBH2EFFF.cjs.map} +1 -1
- package/dist/chunk-JPU7KQZX.cjs +82 -0
- package/dist/{chunk-CRXRJZEV.cjs.map → chunk-JPU7KQZX.cjs.map} +1 -1
- package/dist/{chunk-E3PICZYI.js → chunk-KHT23UVV.js} +3 -3
- package/dist/{chunk-E3PICZYI.js.map → chunk-KHT23UVV.js.map} +1 -1
- package/dist/{chunk-2ZZHLCEJ.js → chunk-LAZIR73I.js} +18 -87
- package/dist/chunk-LAZIR73I.js.map +1 -0
- package/dist/{chunk-FB56NAAH.cjs → chunk-NO4ZCIM6.cjs} +19 -92
- package/dist/chunk-NO4ZCIM6.cjs.map +1 -0
- package/dist/{chunk-S4BJ2ADB.cjs → chunk-PCU6AG7H.cjs} +4 -4
- package/dist/{chunk-S4BJ2ADB.cjs.map → chunk-PCU6AG7H.cjs.map} +1 -1
- package/dist/{chunk-W6RBCHYF.js → chunk-PSZHBY5V.js} +235 -75
- package/dist/chunk-PSZHBY5V.js.map +1 -0
- package/dist/{chunk-6LDAIJBL.js → chunk-QBBJR7DZ.js} +2 -2
- package/dist/{chunk-6LDAIJBL.js.map → chunk-QBBJR7DZ.js.map} +1 -1
- package/dist/{chunk-3D5ZCJ7R.js → chunk-QHQ2AU45.js} +3 -3
- package/dist/{chunk-3D5ZCJ7R.js.map → chunk-QHQ2AU45.js.map} +1 -1
- package/dist/{chunk-IHEIYZPL.cjs → chunk-RJX27YEX.cjs} +2 -2
- package/dist/chunk-RJX27YEX.cjs.map +1 -0
- package/dist/{chunk-QYD4F6T7.cjs → chunk-ROXNQKOA.cjs} +2 -2
- package/dist/{chunk-QYD4F6T7.cjs.map → chunk-ROXNQKOA.cjs.map} +1 -1
- package/dist/chunk-SHEXFU6T.js +107 -0
- package/dist/chunk-SHEXFU6T.js.map +1 -0
- package/dist/chunk-T2KIN6VL.cjs +218 -0
- package/dist/chunk-T2KIN6VL.cjs.map +1 -0
- package/dist/{chunk-RCW5IPPR.js → chunk-UCT6HDUD.js} +3 -3
- package/dist/{chunk-RCW5IPPR.js.map → chunk-UCT6HDUD.js.map} +1 -1
- package/dist/chunk-UN74SYHV.cjs +115 -0
- package/dist/chunk-UN74SYHV.cjs.map +1 -0
- package/dist/{chunk-F7O2FA3F.cjs → chunk-VAO3Y3HZ.cjs} +7 -6
- package/dist/chunk-VAO3Y3HZ.cjs.map +1 -0
- package/dist/{chunk-BBJPQPGP.js → chunk-VE3OSDM7.js} +5 -3
- package/dist/chunk-VE3OSDM7.js.map +1 -0
- package/dist/{chunk-7HK2V5Q4.js → chunk-X7IVXKDE.js} +3 -3
- package/dist/{chunk-7HK2V5Q4.js.map → chunk-X7IVXKDE.js.map} +1 -1
- package/dist/{chunk-UA3EOFBS.cjs → chunk-XVCVIUZS.cjs} +8 -8
- package/dist/{chunk-UA3EOFBS.cjs.map → chunk-XVCVIUZS.cjs.map} +1 -1
- package/dist/{chunk-SIHPDZXA.js → chunk-YSTC7WRF.js} +2 -2
- package/dist/{chunk-SIHPDZXA.js.map → chunk-YSTC7WRF.js.map} +1 -1
- package/dist/compliance/index.cjs +15 -15
- package/dist/compliance/index.d.cts +4 -4
- package/dist/compliance/index.d.ts +4 -4
- package/dist/compliance/index.js +5 -5
- package/dist/crypto.cjs +4 -4
- package/dist/crypto.d.cts +1 -1
- package/dist/crypto.d.ts +1 -1
- package/dist/crypto.js +2 -2
- package/dist/detectors/index.cjs +38 -38
- package/dist/detectors/index.d.cts +1 -1
- package/dist/detectors/index.d.ts +1 -1
- package/dist/detectors/index.js +3 -3
- package/dist/engine/index.cjs +70 -70
- package/dist/engine/index.d.cts +3 -3
- package/dist/engine/index.d.ts +3 -3
- package/dist/engine/index.js +8 -8
- package/dist/hash-P2VGKVFP.cjs +14 -0
- package/dist/{hash-2PSYNDMM.cjs.map → hash-P2VGKVFP.cjs.map} +1 -1
- package/dist/hash-T6YJG3DU.js +5 -0
- package/dist/{hash-CELLDNKN.js.map → hash-T6YJG3DU.js.map} +1 -1
- package/dist/index.cjs +44 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -5
- package/dist/index.d.ts +23 -5
- package/dist/index.js +11 -9
- package/dist/index.js.map +1 -1
- package/dist/{json-s8ny-RCo.d.cts → json-BXN577tt.d.cts} +3 -2
- package/dist/{json-CKDvlRtl.d.ts → json-BudrzkOQ.d.ts} +3 -2
- package/dist/mcp/index.cjs +29 -28
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.js +14 -13
- package/dist/mcp/index.js.map +1 -1
- package/dist/middleware/express.cjs +11 -11
- package/dist/middleware/express.d.cts +3 -3
- package/dist/middleware/express.d.ts +3 -3
- package/dist/middleware/express.js +10 -10
- package/dist/middleware/hono.cjs +11 -11
- package/dist/middleware/hono.d.cts +3 -3
- package/dist/middleware/hono.d.ts +3 -3
- package/dist/middleware/hono.js +10 -10
- package/dist/middleware/index.cjs +11 -11
- package/dist/middleware/index.d.cts +3 -3
- package/dist/middleware/index.d.ts +3 -3
- package/dist/middleware/index.js +10 -10
- package/dist/schemas.cjs +47 -47
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +2 -2
- package/dist/schemas.d.ts +2 -2
- package/dist/schemas.js +2 -2
- package/dist/schemas.js.map +1 -1
- package/dist/{session-BdRftyZ5.d.cts → session-CPXEQ2uC.d.cts} +18 -5
- package/dist/{session-Cs2zlNQp.d.ts → session-D3WMN6fE.d.ts} +18 -5
- package/dist/stream.cjs +10 -8
- package/dist/stream.cjs.map +1 -1
- package/dist/stream.d.cts +1 -1
- package/dist/stream.d.ts +1 -1
- package/dist/stream.js +7 -5
- package/dist/stream.js.map +1 -1
- package/dist/{types-Dtht33aq.d.ts → types-B3VjDuP8.d.cts} +2 -282
- package/dist/{types--tPm_AjY.d.ts → types-DHAVKfzT.d.ts} +2 -2
- package/dist/types-LZHFEgx5.d.cts +1083 -0
- package/dist/types-LZHFEgx5.d.ts +1083 -0
- package/dist/{types-0BJH_wqc.d.cts → types-vmONSbz4.d.cts} +2 -2
- package/dist/{types-CPUhjvl8.d.cts → types-yZHnS7yv.d.ts} +2 -282
- package/dist/validators.cjs +10 -10
- package/dist/validators.js +1 -1
- package/dist/vault/index.cjs +65 -46
- package/dist/vault/index.cjs.map +1 -1
- package/dist/vault/index.d.cts +98 -5
- package/dist/vault/index.d.ts +98 -5
- package/dist/vault/index.js +11 -5
- package/dist/vault/index.js.map +1 -1
- package/package.json +16 -7
- package/dist/chunk-26IHMQHL.cjs.map +0 -1
- package/dist/chunk-2ZZHLCEJ.js.map +0 -1
- package/dist/chunk-BBJPQPGP.js.map +0 -1
- package/dist/chunk-CRXRJZEV.cjs +0 -82
- package/dist/chunk-F7O2FA3F.cjs.map +0 -1
- package/dist/chunk-FB56NAAH.cjs.map +0 -1
- package/dist/chunk-G4AN7FND.js.map +0 -1
- package/dist/chunk-GS3FRH4K.js.map +0 -1
- package/dist/chunk-IHEIYZPL.cjs.map +0 -1
- package/dist/chunk-IJAMLYOT.cjs.map +0 -1
- package/dist/chunk-PKHZ7CVI.js.map +0 -1
- package/dist/chunk-S7NH6CHY.cjs.map +0 -1
- package/dist/chunk-W6RBCHYF.js.map +0 -1
- package/dist/chunk-YMLR375Z.js.map +0 -1
- package/dist/hash-2PSYNDMM.cjs +0 -14
- package/dist/hash-CELLDNKN.js +0 -5
- package/dist/types-EJTj_BKY.d.cts +0 -584
- package/dist/types-EJTj_BKY.d.ts +0 -584
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkJPU7KQZX_cjs = require('./chunk-JPU7KQZX.cjs');
|
|
4
|
+
var chunkRJX27YEX_cjs = require('./chunk-RJX27YEX.cjs');
|
|
5
|
+
var chunkT2KIN6VL_cjs = require('./chunk-T2KIN6VL.cjs');
|
|
5
6
|
var chunkWLJN7GIS_cjs = require('./chunk-WLJN7GIS.cjs');
|
|
6
7
|
|
|
7
8
|
// src/strategies/tokenize.ts
|
|
@@ -19,15 +20,15 @@ function assignToken(store, category, value, prefix, format = "bracket") {
|
|
|
19
20
|
const count = (store.counters.get(prefix) ?? 0) + 1;
|
|
20
21
|
store.counters.set(prefix, count);
|
|
21
22
|
const id = format === "bracket" ? String(count).padStart(4, "0") : String(count);
|
|
22
|
-
const token = format === "bracket" ? `[${prefix}_${id}]` : `<${prefix}_${id}>`;
|
|
23
|
+
const token = format === "bracket" ? `[${prefix}_${id}]` : format === "brace" ? `{{${prefix}_${id}}}` : `<${prefix}_${id}>`;
|
|
23
24
|
store.index.set(indexKey, token);
|
|
24
25
|
store.tokens.set(token, value);
|
|
25
26
|
return token;
|
|
26
27
|
}
|
|
28
|
+
var LEGACY_TOKEN_PATTERN = /\[[A-Z][A-Z0-9_]{0,60}_\d{1,12}\]|<[A-Z][A-Z0-9_]{0,60}_\d{1,12}>|\{\{[A-Z][A-Z0-9_]{0,60}_\d{1,12}\}\}/g;
|
|
27
29
|
function detokenizeText(text, store) {
|
|
28
30
|
const unresolved = [];
|
|
29
|
-
const
|
|
30
|
-
const result = text.replace(re, (token) => {
|
|
31
|
+
const result = text.replace(LEGACY_TOKEN_PATTERN, (token) => {
|
|
31
32
|
const original = store.tokens.get(token);
|
|
32
33
|
if (original !== void 0) return original;
|
|
33
34
|
unresolved.push(token);
|
|
@@ -36,6 +37,16 @@ function detokenizeText(text, store) {
|
|
|
36
37
|
return { text: result, unresolved };
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
// src/internal/allowlist.ts
|
|
41
|
+
function compileAllowlist(entries, patterns, caseSensitive) {
|
|
42
|
+
if (entries.length === 0 && patterns.length === 0) return () => false;
|
|
43
|
+
const exact = new Set(entries.map((entry) => caseSensitive ? entry : entry.toLowerCase()));
|
|
44
|
+
const compiled = patterns.map(
|
|
45
|
+
(pattern) => new RegExp(pattern.source, pattern.flags.replace(/[gy]/g, ""))
|
|
46
|
+
);
|
|
47
|
+
return (value) => exact.has(caseSensitive ? value : value.toLowerCase()) || compiled.some((pattern) => pattern.test(value));
|
|
48
|
+
}
|
|
49
|
+
|
|
39
50
|
// src/anonymize.ts
|
|
40
51
|
var ALL_CATEGORIES = [
|
|
41
52
|
"email",
|
|
@@ -95,34 +106,66 @@ var TOKEN_PREFIX_MAP = {
|
|
|
95
106
|
"case-number": "CASE_NUMBER",
|
|
96
107
|
"company-registration": "COMPANY_REG"
|
|
97
108
|
};
|
|
109
|
+
var STRATEGY_NAMES = /* @__PURE__ */ new Set([
|
|
110
|
+
"mask",
|
|
111
|
+
"redact",
|
|
112
|
+
"pseudonymize",
|
|
113
|
+
"hash",
|
|
114
|
+
"generalize",
|
|
115
|
+
"tokenize",
|
|
116
|
+
"encrypt",
|
|
117
|
+
"synthesize"
|
|
118
|
+
]);
|
|
119
|
+
var NO_PLUGINS = {
|
|
120
|
+
detectors: {},
|
|
121
|
+
strategies: /* @__PURE__ */ new Map(),
|
|
122
|
+
validators: /* @__PURE__ */ new Map()
|
|
123
|
+
};
|
|
124
|
+
function isCategory(name) {
|
|
125
|
+
return ALL_CATEGORIES.includes(name);
|
|
126
|
+
}
|
|
127
|
+
function isBuiltinStrategy(opts) {
|
|
128
|
+
return STRATEGY_NAMES.has(opts.strategy);
|
|
129
|
+
}
|
|
98
130
|
function applyStrategySync(value, opts) {
|
|
99
131
|
switch (opts.strategy) {
|
|
100
132
|
case "mask":
|
|
101
|
-
return
|
|
133
|
+
return chunkRJX27YEX_cjs.mask(value, opts);
|
|
102
134
|
case "redact":
|
|
103
|
-
return
|
|
135
|
+
return chunkRJX27YEX_cjs.redact(value, opts);
|
|
104
136
|
case "pseudonymize":
|
|
105
|
-
return
|
|
137
|
+
return chunkRJX27YEX_cjs.pseudonymize(value, opts);
|
|
106
138
|
case "hash":
|
|
107
139
|
console.warn(
|
|
108
140
|
"[anonyma] The `hash` strategy is async and cannot be used in the synchronous `anonymize()` pipeline. Falling back to a deterministic pseudonym. Use `anonymizeAsync()` or `hash()` for SHA-256 output."
|
|
109
141
|
);
|
|
110
|
-
return
|
|
142
|
+
return chunkRJX27YEX_cjs.pseudonymize(value, { seed: opts.pepper ?? "__hash_fallback__", prefix: "hsh_" });
|
|
111
143
|
case "generalize":
|
|
112
|
-
return
|
|
144
|
+
return chunkRJX27YEX_cjs.generalize(value, opts);
|
|
113
145
|
case "tokenize":
|
|
114
146
|
case "encrypt":
|
|
115
147
|
case "synthesize":
|
|
116
148
|
console.warn(
|
|
117
149
|
`[anonyma] anonymize() and anonymizeAsync() do not apply the \`${opts.strategy}\` strategy; the value is redacted instead. Use a pipeline of "anonyma/engine" to apply it.`
|
|
118
150
|
);
|
|
119
|
-
return
|
|
151
|
+
return chunkRJX27YEX_cjs.redact(value);
|
|
152
|
+
/* v8 ignore start -- applyStrategy() passes built-in strategies only */
|
|
120
153
|
default: {
|
|
121
154
|
const _exhaustive = opts;
|
|
122
155
|
throw new chunkWLJN7GIS_cjs.UnsupportedStrategyError(_exhaustive.strategy);
|
|
123
156
|
}
|
|
124
157
|
}
|
|
125
158
|
}
|
|
159
|
+
function applyStrategy(value, opts, plugins) {
|
|
160
|
+
if (isBuiltinStrategy(opts)) return applyStrategySync(value, opts);
|
|
161
|
+
const strategy = plugins.strategies.get(opts.strategy);
|
|
162
|
+
if (strategy === void 0) throw new chunkWLJN7GIS_cjs.UnsupportedStrategyError(opts.strategy);
|
|
163
|
+
const replacement = strategy(value, opts.options);
|
|
164
|
+
if (typeof replacement !== "string") {
|
|
165
|
+
throw new chunkWLJN7GIS_cjs.ValidationError(`strategies.${opts.strategy}`, "must return a string");
|
|
166
|
+
}
|
|
167
|
+
return replacement;
|
|
168
|
+
}
|
|
126
169
|
function deduplicateMatches(matches) {
|
|
127
170
|
const sorted = [...matches].sort((a, b) => a.start - b.start || b.confidence - a.confidence);
|
|
128
171
|
const result = [];
|
|
@@ -135,9 +178,17 @@ function deduplicateMatches(matches) {
|
|
|
135
178
|
}
|
|
136
179
|
return result;
|
|
137
180
|
}
|
|
138
|
-
function resolveDetector(category, customDetectors, aggressive) {
|
|
181
|
+
function resolveDetector(category, customDetectors, aggressive, plugins) {
|
|
139
182
|
if (customDetectors?.[category]) return customDetectors[category];
|
|
140
|
-
|
|
183
|
+
const pluginDetector = plugins.detectors[category];
|
|
184
|
+
if (pluginDetector) return pluginDetector;
|
|
185
|
+
return aggressive ? chunkJPU7KQZX_cjs.AGGRESSIVE_DETECTOR_REGISTRY[category] : chunkJPU7KQZX_cjs.DETECTOR_REGISTRY[category];
|
|
186
|
+
}
|
|
187
|
+
function runDetector(text, category, customDetectors, aggressive, plugins) {
|
|
188
|
+
const matches = resolveDetector(category, customDetectors, aggressive, plugins)(text);
|
|
189
|
+
const validators = plugins.validators.get(category);
|
|
190
|
+
if (validators === void 0) return matches;
|
|
191
|
+
return matches.filter((match) => validators.every((validate) => validate(match.value)));
|
|
141
192
|
}
|
|
142
193
|
function detectCustomPatterns(text, customPatterns) {
|
|
143
194
|
const results = [];
|
|
@@ -175,6 +226,9 @@ function resolveCategories(options) {
|
|
|
175
226
|
return [...ALL_CATEGORIES];
|
|
176
227
|
}
|
|
177
228
|
function detect(text, categories = ALL_CATEGORIES, customDetectors, aggressive) {
|
|
229
|
+
return detectWith(text, categories, customDetectors, aggressive, NO_PLUGINS);
|
|
230
|
+
}
|
|
231
|
+
function detectWith(text, categories, customDetectors, aggressive, plugins) {
|
|
178
232
|
if (typeof text !== "string") {
|
|
179
233
|
throw new chunkWLJN7GIS_cjs.ValidationError("text", "must be a string");
|
|
180
234
|
}
|
|
@@ -183,12 +237,14 @@ function detect(text, categories = ALL_CATEGORIES, customDetectors, aggressive)
|
|
|
183
237
|
if (!ALL_CATEGORIES.includes(category)) {
|
|
184
238
|
throw new chunkWLJN7GIS_cjs.UnknownCategoryError(category);
|
|
185
239
|
}
|
|
186
|
-
|
|
187
|
-
raw.push(...detector(text));
|
|
240
|
+
raw.push(...runDetector(text, category, customDetectors, aggressive, plugins));
|
|
188
241
|
}
|
|
189
242
|
return deduplicateMatches(raw);
|
|
190
243
|
}
|
|
191
244
|
function hasPII(text, categories = ALL_CATEGORIES, customDetectors) {
|
|
245
|
+
return hasPIIWith(text, categories, customDetectors, NO_PLUGINS);
|
|
246
|
+
}
|
|
247
|
+
function hasPIIWith(text, categories, customDetectors, plugins) {
|
|
192
248
|
if (typeof text !== "string") {
|
|
193
249
|
throw new chunkWLJN7GIS_cjs.ValidationError("text", "must be a string");
|
|
194
250
|
}
|
|
@@ -196,12 +252,14 @@ function hasPII(text, categories = ALL_CATEGORIES, customDetectors) {
|
|
|
196
252
|
if (!ALL_CATEGORIES.includes(category)) {
|
|
197
253
|
throw new chunkWLJN7GIS_cjs.UnknownCategoryError(category);
|
|
198
254
|
}
|
|
199
|
-
|
|
200
|
-
if (detector(text).length > 0) return true;
|
|
255
|
+
if (runDetector(text, category, customDetectors, void 0, plugins).length > 0) return true;
|
|
201
256
|
}
|
|
202
257
|
return false;
|
|
203
258
|
}
|
|
204
259
|
function anonymize(text, options = {}) {
|
|
260
|
+
return anonymizeWith(text, options, NO_PLUGINS);
|
|
261
|
+
}
|
|
262
|
+
function anonymizeWith(text, options, plugins) {
|
|
205
263
|
if (typeof text !== "string") {
|
|
206
264
|
throw new chunkWLJN7GIS_cjs.ValidationError("text", "must be a string");
|
|
207
265
|
}
|
|
@@ -211,7 +269,7 @@ function anonymize(text, options = {}) {
|
|
|
211
269
|
let resolvedPreset;
|
|
212
270
|
if (options.preset) {
|
|
213
271
|
try {
|
|
214
|
-
resolvedPreset =
|
|
272
|
+
resolvedPreset = chunkRJX27YEX_cjs.getPreset(options.preset);
|
|
215
273
|
} catch {
|
|
216
274
|
throw new chunkWLJN7GIS_cjs.PresetNotFoundError(options.preset);
|
|
217
275
|
}
|
|
@@ -245,17 +303,8 @@ function anonymize(text, options = {}) {
|
|
|
245
303
|
rules,
|
|
246
304
|
...enabledCategories !== void 0 ? { enabledCategories } : {}
|
|
247
305
|
});
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
...allowlist.map(
|
|
251
|
-
(entry) => new RegExp(entry.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), allowlistCaseSensitive ? "" : "i")
|
|
252
|
-
)
|
|
253
|
-
];
|
|
254
|
-
function isAllowlisted(value) {
|
|
255
|
-
if (compiledAllowlistPatterns.length === 0) return false;
|
|
256
|
-
return compiledAllowlistPatterns.some((re) => re.test(value));
|
|
257
|
-
}
|
|
258
|
-
const builtInMatches = detect(text, categories, customDetectors, aggressive);
|
|
306
|
+
const isAllowlisted = compileAllowlist(allowlist, allowlistPatterns, allowlistCaseSensitive);
|
|
307
|
+
const builtInMatches = detectWith(text, categories, customDetectors, aggressive, plugins);
|
|
259
308
|
const customMatches = customPatterns.length > 0 ? detectCustomPatterns(text, customPatterns) : [];
|
|
260
309
|
const filteredBuiltInMatches = builtInMatches.filter(
|
|
261
310
|
(m) => m.confidence >= confidenceThreshold && !isAllowlisted(m.value)
|
|
@@ -287,7 +336,7 @@ function anonymize(text, options = {}) {
|
|
|
287
336
|
replacement = match.replacement;
|
|
288
337
|
} else {
|
|
289
338
|
const strategy = ruleMap.get(match.category) ?? defaultStrategy;
|
|
290
|
-
replacement =
|
|
339
|
+
replacement = applyStrategy(match.value, strategy, plugins);
|
|
291
340
|
}
|
|
292
341
|
result = result.slice(0, match.start) + replacement + result.slice(match.end);
|
|
293
342
|
}
|
|
@@ -298,19 +347,22 @@ function anonymize(text, options = {}) {
|
|
|
298
347
|
};
|
|
299
348
|
}
|
|
300
349
|
async function anonymizeAsync(text, options = {}) {
|
|
350
|
+
return anonymizeAsyncWith(text, options, NO_PLUGINS);
|
|
351
|
+
}
|
|
352
|
+
async function anonymizeAsyncWith(text, options, plugins) {
|
|
301
353
|
if (typeof text !== "string") {
|
|
302
354
|
throw new chunkWLJN7GIS_cjs.ValidationError("text", "must be a string");
|
|
303
355
|
}
|
|
304
356
|
const hasAsyncStrategy = (opts) => opts.strategy === "hash" || opts.strategy === "encrypt" || opts.strategy === "tokenize" || opts.strategy === "synthesize";
|
|
305
357
|
const needsAsync = options.defaultStrategy != null && hasAsyncStrategy(options.defaultStrategy) || (options.rules ?? []).some((r) => hasAsyncStrategy(r.strategy));
|
|
306
358
|
if (!needsAsync) {
|
|
307
|
-
return
|
|
359
|
+
return anonymizeWith(text, options, plugins);
|
|
308
360
|
}
|
|
309
|
-
const { hash: hashFn } = await import('./hash-
|
|
361
|
+
const { hash: hashFn } = await import('./hash-P2VGKVFP.cjs');
|
|
310
362
|
let resolvedPreset;
|
|
311
363
|
if (options.preset) {
|
|
312
364
|
try {
|
|
313
|
-
resolvedPreset =
|
|
365
|
+
resolvedPreset = chunkRJX27YEX_cjs.getPreset(options.preset);
|
|
314
366
|
} catch {
|
|
315
367
|
throw new chunkWLJN7GIS_cjs.PresetNotFoundError(options.preset);
|
|
316
368
|
}
|
|
@@ -342,15 +394,9 @@ async function anonymizeAsync(text, options = {}) {
|
|
|
342
394
|
rules,
|
|
343
395
|
...enabledCategories !== void 0 ? { enabledCategories } : {}
|
|
344
396
|
});
|
|
345
|
-
const builtInMatches =
|
|
397
|
+
const builtInMatches = detectWith(text, categories, customDetectors, aggressive, plugins);
|
|
346
398
|
const customMatches = customPatterns.length > 0 ? detectCustomPatterns(text, customPatterns) : [];
|
|
347
|
-
const
|
|
348
|
-
...allowlistPatterns,
|
|
349
|
-
...allowlist.map(
|
|
350
|
-
(entry) => new RegExp(entry.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), allowlistCaseSensitive ? "" : "i")
|
|
351
|
-
)
|
|
352
|
-
];
|
|
353
|
-
const isAllowlisted = (value) => compiledAllowlistPatterns.some((re) => re.test(value));
|
|
399
|
+
const isAllowlisted = compileAllowlist(allowlist, allowlistPatterns, allowlistCaseSensitive);
|
|
354
400
|
const filteredBuiltInMatches = builtInMatches.filter(
|
|
355
401
|
(m) => m.confidence >= confidenceThreshold && !isAllowlisted(m.value)
|
|
356
402
|
);
|
|
@@ -381,10 +427,10 @@ async function anonymizeAsync(text, options = {}) {
|
|
|
381
427
|
replacement = match.replacement;
|
|
382
428
|
} else {
|
|
383
429
|
const strategy = ruleMap.get(match.category) ?? defaultStrategy;
|
|
384
|
-
if (strategy.strategy === "hash") {
|
|
430
|
+
if (isBuiltinStrategy(strategy) && strategy.strategy === "hash") {
|
|
385
431
|
replacement = await hashFn(match.value, strategy);
|
|
386
432
|
} else {
|
|
387
|
-
replacement =
|
|
433
|
+
replacement = applyStrategy(match.value, strategy, plugins);
|
|
388
434
|
}
|
|
389
435
|
}
|
|
390
436
|
result = result.slice(0, match.start) + replacement + result.slice(match.end);
|
|
@@ -395,15 +441,18 @@ async function anonymizeAsync(text, options = {}) {
|
|
|
395
441
|
};
|
|
396
442
|
}
|
|
397
443
|
function anonymizeObject(obj, options) {
|
|
444
|
+
return anonymizeObjectWith(obj, options, NO_PLUGINS);
|
|
445
|
+
}
|
|
446
|
+
function anonymizeObjectWith(obj, options, plugins) {
|
|
398
447
|
if (typeof obj !== "object") {
|
|
399
448
|
throw new chunkWLJN7GIS_cjs.ValidationError("obj", "must be an object");
|
|
400
449
|
}
|
|
401
|
-
return deepAnonymizeValue(obj, options, /* @__PURE__ */ new WeakSet());
|
|
450
|
+
return deepAnonymizeValue(obj, options, /* @__PURE__ */ new WeakSet(), plugins);
|
|
402
451
|
}
|
|
403
|
-
function deepAnonymizeValue(value, options, seen) {
|
|
452
|
+
function deepAnonymizeValue(value, options, seen, plugins) {
|
|
404
453
|
if (value === null || value === void 0) return value;
|
|
405
454
|
if (typeof value === "string") {
|
|
406
|
-
return
|
|
455
|
+
return anonymizeWith(value, options ?? {}, plugins).text;
|
|
407
456
|
}
|
|
408
457
|
if (typeof value !== "object") {
|
|
409
458
|
return value;
|
|
@@ -413,13 +462,18 @@ function deepAnonymizeValue(value, options, seen) {
|
|
|
413
462
|
}
|
|
414
463
|
seen.add(value);
|
|
415
464
|
if (Array.isArray(value)) {
|
|
416
|
-
const result2 = value.map((item) => deepAnonymizeValue(item, options, seen));
|
|
465
|
+
const result2 = value.map((item) => deepAnonymizeValue(item, options, seen, plugins));
|
|
417
466
|
seen.delete(value);
|
|
418
467
|
return result2;
|
|
419
468
|
}
|
|
420
469
|
const result = {};
|
|
421
470
|
for (const key of Object.keys(value)) {
|
|
422
|
-
result[key] = deepAnonymizeValue(
|
|
471
|
+
result[key] = deepAnonymizeValue(
|
|
472
|
+
value[key],
|
|
473
|
+
options,
|
|
474
|
+
seen,
|
|
475
|
+
plugins
|
|
476
|
+
);
|
|
423
477
|
}
|
|
424
478
|
seen.delete(value);
|
|
425
479
|
return result;
|
|
@@ -448,6 +502,9 @@ function setByPath(obj, path, value) {
|
|
|
448
502
|
};
|
|
449
503
|
}
|
|
450
504
|
function anonymizeRecord(record, rules) {
|
|
505
|
+
return anonymizeRecordWith(record, rules, NO_PLUGINS);
|
|
506
|
+
}
|
|
507
|
+
function anonymizeRecordWith(record, rules, plugins) {
|
|
451
508
|
if (typeof record !== "object" || Array.isArray(record)) {
|
|
452
509
|
throw new chunkWLJN7GIS_cjs.ValidationError("record", "must be a plain object");
|
|
453
510
|
}
|
|
@@ -458,17 +515,70 @@ function anonymizeRecord(record, rules) {
|
|
|
458
515
|
if (raw === void 0 || raw === null) continue;
|
|
459
516
|
if (typeof raw !== "string" && typeof raw !== "number" && typeof raw !== "boolean") continue;
|
|
460
517
|
const strValue = String(raw);
|
|
461
|
-
const anonymized =
|
|
518
|
+
const anonymized = applyStrategy(strValue, rule.strategy, plugins);
|
|
462
519
|
result = setByPath(result, path, anonymized);
|
|
463
520
|
}
|
|
464
521
|
}
|
|
465
522
|
return result;
|
|
466
523
|
}
|
|
524
|
+
function resolvePlugins(plugins) {
|
|
525
|
+
const names = /* @__PURE__ */ new Set();
|
|
526
|
+
const detectors = {};
|
|
527
|
+
const detectorOwners = /* @__PURE__ */ new Map();
|
|
528
|
+
const strategies = /* @__PURE__ */ new Map();
|
|
529
|
+
const strategyOwners = /* @__PURE__ */ new Map();
|
|
530
|
+
const validators = /* @__PURE__ */ new Map();
|
|
531
|
+
plugins.forEach((plugin, index) => {
|
|
532
|
+
const field = `plugins[${String(index)}]`;
|
|
533
|
+
const { name } = plugin;
|
|
534
|
+
if (typeof name !== "string" || name.length === 0) {
|
|
535
|
+
throw new chunkWLJN7GIS_cjs.ValidationError(`${field}.name`, "must be a non-empty string");
|
|
536
|
+
}
|
|
537
|
+
if (names.has(name)) {
|
|
538
|
+
throw new chunkWLJN7GIS_cjs.ValidationError(`${field}.name`, `another plugin is named "${name}"`);
|
|
539
|
+
}
|
|
540
|
+
names.add(name);
|
|
541
|
+
for (const [category, detector] of Object.entries(plugin.detectors ?? {})) {
|
|
542
|
+
if (!isCategory(category)) throw new chunkWLJN7GIS_cjs.UnknownCategoryError(category);
|
|
543
|
+
const owner = detectorOwners.get(category);
|
|
544
|
+
if (owner !== void 0) {
|
|
545
|
+
throw new chunkWLJN7GIS_cjs.ValidationError(
|
|
546
|
+
`${field}.detectors.${category}`,
|
|
547
|
+
`plugin "${owner}" registers a detector for this category`
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
detectorOwners.set(category, name);
|
|
551
|
+
detectors[category] = detector;
|
|
552
|
+
}
|
|
553
|
+
for (const [strategyName, strategy] of Object.entries(plugin.strategies ?? {})) {
|
|
554
|
+
if (STRATEGY_NAMES.has(strategyName)) {
|
|
555
|
+
throw new chunkWLJN7GIS_cjs.ValidationError(
|
|
556
|
+
`${field}.strategies.${strategyName}`,
|
|
557
|
+
"a built-in strategy has this name"
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
const owner = strategyOwners.get(strategyName);
|
|
561
|
+
if (owner !== void 0) {
|
|
562
|
+
throw new chunkWLJN7GIS_cjs.ValidationError(
|
|
563
|
+
`${field}.strategies.${strategyName}`,
|
|
564
|
+
`plugin "${owner}" registers a strategy with this name`
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
strategyOwners.set(strategyName, name);
|
|
568
|
+
strategies.set(strategyName, strategy);
|
|
569
|
+
}
|
|
570
|
+
for (const [category, validator] of Object.entries(plugin.validators ?? {})) {
|
|
571
|
+
if (!isCategory(category)) throw new chunkWLJN7GIS_cjs.UnknownCategoryError(category);
|
|
572
|
+
validators.set(category, [...validators.get(category) ?? [], validator]);
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
return { detectors, strategies, validators };
|
|
576
|
+
}
|
|
467
577
|
function createAnonymizer(config = {}) {
|
|
468
578
|
let presetConfig;
|
|
469
579
|
if (config.preset) {
|
|
470
580
|
try {
|
|
471
|
-
presetConfig =
|
|
581
|
+
presetConfig = chunkRJX27YEX_cjs.getPreset(config.preset);
|
|
472
582
|
} catch {
|
|
473
583
|
throw new chunkWLJN7GIS_cjs.PresetNotFoundError(config.preset);
|
|
474
584
|
}
|
|
@@ -480,13 +590,18 @@ function createAnonymizer(config = {}) {
|
|
|
480
590
|
customPatterns,
|
|
481
591
|
globalReplacement,
|
|
482
592
|
consistentTokens,
|
|
483
|
-
aggressive
|
|
593
|
+
aggressive,
|
|
594
|
+
plugins = []
|
|
484
595
|
} = config;
|
|
485
596
|
for (const cat of categories) {
|
|
486
597
|
if (!ALL_CATEGORIES.includes(cat)) {
|
|
487
598
|
throw new chunkWLJN7GIS_cjs.UnknownCategoryError(cat);
|
|
488
599
|
}
|
|
489
600
|
}
|
|
601
|
+
const registry = resolvePlugins(plugins);
|
|
602
|
+
if (!isBuiltinStrategy(defaultStrategy) && !registry.strategies.has(defaultStrategy.strategy)) {
|
|
603
|
+
throw new chunkWLJN7GIS_cjs.UnsupportedStrategyError(defaultStrategy.strategy);
|
|
604
|
+
}
|
|
490
605
|
function baseOptions(overrides) {
|
|
491
606
|
const base = {
|
|
492
607
|
defaultStrategy,
|
|
@@ -508,19 +623,19 @@ function createAnonymizer(config = {}) {
|
|
|
508
623
|
}
|
|
509
624
|
return {
|
|
510
625
|
anonymize(text, options) {
|
|
511
|
-
return
|
|
626
|
+
return anonymizeWith(text, baseOptions(options), registry);
|
|
512
627
|
},
|
|
513
628
|
detect(text) {
|
|
514
|
-
return
|
|
629
|
+
return detectWith(text, categories, customDetectors, aggressive, registry);
|
|
515
630
|
},
|
|
516
631
|
anonymizeRecord(record, rules) {
|
|
517
|
-
return
|
|
632
|
+
return anonymizeRecordWith(record, rules, registry);
|
|
518
633
|
},
|
|
519
634
|
anonymizeObject(obj, options) {
|
|
520
|
-
return
|
|
635
|
+
return anonymizeObjectWith(obj, baseOptions(options), registry);
|
|
521
636
|
},
|
|
522
637
|
async anonymizeAsync(text, options) {
|
|
523
|
-
return
|
|
638
|
+
return anonymizeAsyncWith(text, baseOptions(options), registry);
|
|
524
639
|
},
|
|
525
640
|
tokenize(text, options) {
|
|
526
641
|
const {
|
|
@@ -532,13 +647,14 @@ function createAnonymizer(config = {}) {
|
|
|
532
647
|
allowlist: tAllowlist = [],
|
|
533
648
|
allowlistCaseSensitive: tCaseSensitive = false
|
|
534
649
|
} = options ?? {};
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
650
|
+
const isAllowlisted = compileAllowlist(tAllowlist, [], tCaseSensitive);
|
|
651
|
+
const tMatches = detectWith(
|
|
652
|
+
text,
|
|
653
|
+
tCats ?? categories,
|
|
654
|
+
tCustDet ?? customDetectors,
|
|
655
|
+
tAgg,
|
|
656
|
+
registry
|
|
657
|
+
).filter((m) => m.confidence >= tConfidence && !isAllowlisted(m.value));
|
|
542
658
|
const store = createTokenStore();
|
|
543
659
|
let tResult = text;
|
|
544
660
|
const tTokens = [];
|
|
@@ -557,7 +673,7 @@ function createAnonymizer(config = {}) {
|
|
|
557
673
|
return { text: tResult, mapping: store.tokens, tokens: tTokens };
|
|
558
674
|
},
|
|
559
675
|
hasPII(text) {
|
|
560
|
-
return
|
|
676
|
+
return hasPIIWith(text, categories, customDetectors, registry);
|
|
561
677
|
}
|
|
562
678
|
};
|
|
563
679
|
}
|
|
@@ -593,30 +709,78 @@ var TOKEN_PREFIX_MAP2 = {
|
|
|
593
709
|
"company-registration": "COMPANY_REG"
|
|
594
710
|
};
|
|
595
711
|
function tokenize(text, options = {}) {
|
|
712
|
+
const matches = detectForTokenize(text, options);
|
|
713
|
+
if (options.vault !== void 0) {
|
|
714
|
+
const tokenizer = vaultTokenizerFor(options.vault, options.format);
|
|
715
|
+
const placed = matches.map((match) => {
|
|
716
|
+
const token = tokenizer.tokenize(match.value, { category: match.category });
|
|
717
|
+
if (chunkT2KIN6VL_cjs.isThenable(token)) {
|
|
718
|
+
void token.catch(() => void 0);
|
|
719
|
+
throw new chunkWLJN7GIS_cjs.ValidationError("vault", "answers asynchronously: use tokenizeAsync()");
|
|
720
|
+
}
|
|
721
|
+
return { match, token };
|
|
722
|
+
});
|
|
723
|
+
return replaceInOrder(text, placed);
|
|
724
|
+
}
|
|
725
|
+
const store = createTokenStore();
|
|
726
|
+
let result = text;
|
|
727
|
+
const reversed = [...matches].reverse();
|
|
728
|
+
const tokenMatches = [];
|
|
729
|
+
const format = options.format ?? "bracket";
|
|
730
|
+
for (const match of reversed) {
|
|
731
|
+
const prefix = TOKEN_PREFIX_MAP2[match.category] ?? match.category.toUpperCase();
|
|
732
|
+
const token = assignToken(store, match.category, match.value, prefix, format);
|
|
733
|
+
tokenMatches.push({
|
|
734
|
+
token,
|
|
735
|
+
original: match.value,
|
|
736
|
+
category: match.category,
|
|
737
|
+
start: match.start,
|
|
738
|
+
end: match.end
|
|
739
|
+
});
|
|
740
|
+
result = result.slice(0, match.start) + token + result.slice(match.end);
|
|
741
|
+
}
|
|
742
|
+
return { text: result, mapping: store.tokens, tokens: tokenMatches };
|
|
743
|
+
}
|
|
744
|
+
async function tokenizeAsync(text, options = {}) {
|
|
745
|
+
if (options.vault === void 0) return tokenize(text, options);
|
|
746
|
+
const matches = detectForTokenize(text, options);
|
|
747
|
+
const tokenizer = vaultTokenizerFor(options.vault, options.format);
|
|
748
|
+
const placed = [];
|
|
749
|
+
for (const match of matches) {
|
|
750
|
+
placed.push({
|
|
751
|
+
match,
|
|
752
|
+
token: await tokenizer.tokenize(match.value, { category: match.category })
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
return replaceInOrder(text, placed);
|
|
756
|
+
}
|
|
757
|
+
function detectForTokenize(text, options) {
|
|
596
758
|
if (typeof text !== "string") throw new chunkWLJN7GIS_cjs.ValidationError("text", "must be a string");
|
|
597
759
|
const {
|
|
598
760
|
categories,
|
|
599
|
-
format = "bracket",
|
|
600
761
|
customDetectors,
|
|
601
762
|
aggressive = false,
|
|
602
763
|
confidenceThreshold = 0,
|
|
603
764
|
allowlist = [],
|
|
604
765
|
allowlistCaseSensitive = false
|
|
605
766
|
} = options;
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
);
|
|
609
|
-
const isAllowlisted = (v) => compiledAllowlist.some((re) => re.test(v));
|
|
610
|
-
const allMatches = detect(text, categories, customDetectors, aggressive).filter(
|
|
767
|
+
const isAllowlisted = compileAllowlist(allowlist, [], allowlistCaseSensitive);
|
|
768
|
+
return detect(text, categories, customDetectors, aggressive).filter(
|
|
611
769
|
(m) => m.confidence >= confidenceThreshold && !isAllowlisted(m.value)
|
|
612
770
|
);
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
771
|
+
}
|
|
772
|
+
function vaultTokenizerFor(vault, format = "brace") {
|
|
773
|
+
return chunkT2KIN6VL_cjs.createVaultTokenizer({ vault, format: format === "custom" ? "angle" : format });
|
|
774
|
+
}
|
|
775
|
+
function replaceInOrder(text, placed) {
|
|
776
|
+
const parts = [];
|
|
777
|
+
const mapping = /* @__PURE__ */ new Map();
|
|
616
778
|
const tokenMatches = [];
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
779
|
+
let cursor = 0;
|
|
780
|
+
for (const { match, token } of placed) {
|
|
781
|
+
parts.push(text.slice(cursor, match.start), token);
|
|
782
|
+
cursor = match.end;
|
|
783
|
+
if (!mapping.has(token)) mapping.set(token, match.value);
|
|
620
784
|
tokenMatches.push({
|
|
621
785
|
token,
|
|
622
786
|
original: match.value,
|
|
@@ -624,12 +788,9 @@ function tokenize(text, options = {}) {
|
|
|
624
788
|
start: match.start,
|
|
625
789
|
end: match.end
|
|
626
790
|
});
|
|
627
|
-
result = result.slice(0, match.start) + token + result.slice(match.end);
|
|
628
791
|
}
|
|
629
|
-
|
|
630
|
-
}
|
|
631
|
-
function tokenizeAsync(text, options = {}) {
|
|
632
|
-
return Promise.resolve(tokenize(text, options));
|
|
792
|
+
parts.push(text.slice(cursor));
|
|
793
|
+
return { text: parts.join(""), mapping, tokens: tokenMatches };
|
|
633
794
|
}
|
|
634
795
|
function detokenize(text, mapping) {
|
|
635
796
|
if (typeof text !== "string") throw new chunkWLJN7GIS_cjs.ValidationError("text", "must be a string");
|
|
@@ -638,8 +799,7 @@ function detokenize(text, mapping) {
|
|
|
638
799
|
store.tokens.set(token, value);
|
|
639
800
|
}
|
|
640
801
|
const result = detokenizeText(text, store);
|
|
641
|
-
const
|
|
642
|
-
const totalInText = (text.match(TOKEN_RE) ?? []).length;
|
|
802
|
+
const totalInText = (text.match(LEGACY_TOKEN_PATTERN) ?? []).length;
|
|
643
803
|
const replacedCount = totalInText - result.unresolved.length;
|
|
644
804
|
return {
|
|
645
805
|
text: result.text,
|
|
@@ -658,5 +818,5 @@ exports.detokenize = detokenize;
|
|
|
658
818
|
exports.hasPII = hasPII;
|
|
659
819
|
exports.tokenize = tokenize;
|
|
660
820
|
exports.tokenizeAsync = tokenizeAsync;
|
|
661
|
-
//# sourceMappingURL=chunk-
|
|
662
|
-
//# sourceMappingURL=chunk-
|
|
821
|
+
//# sourceMappingURL=chunk-42ZZZUMO.cjs.map
|
|
822
|
+
//# sourceMappingURL=chunk-42ZZZUMO.cjs.map
|