@stll/anonymize 1.0.4 → 1.0.6
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/LICENSE +1 -1
- package/README.md +44 -48
- package/dist/index.d.mts +20 -2
- package/dist/index.mjs +356 -79
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -9
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,79 +1,75 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="
|
|
2
|
+
<img src="../../.github/assets/banner.png" alt="Stella anonymize" width="100%" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
# @stll/anonymize
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Features
|
|
12
|
-
|
|
13
|
-
- **Regex detector** — IBAN, email, phone, credit card,
|
|
14
|
-
Czech birth numbers, dates (22 languages), company IDs
|
|
15
|
-
- **Trigger phrases** — Czech, German, English, French,
|
|
16
|
-
Spanish, Italian, Polish, Hungarian, Romanian, Swedish
|
|
17
|
-
- **Name corpus** — first names, surnames, titles with
|
|
18
|
-
Czech/Slovak declension handling
|
|
19
|
-
- **Legal form detection** — s.r.o., GmbH, Ltd., S.A.,
|
|
20
|
-
and 1000+ forms across 20+ countries
|
|
21
|
-
- **GLiNER NER** — zero-shot named entity recognition
|
|
22
|
-
- **Deny-list gazetteer** — workspace-scoped Aho-Corasick
|
|
23
|
-
+ fuzzy matching
|
|
24
|
-
- **Coreference** — tracks "dále jen" / "hereinafter"
|
|
25
|
-
aliases with Czech declension variants
|
|
26
|
-
- **Confidence boosting** — context-aware score adjustment
|
|
27
|
-
- **False positive filtering** — template placeholders,
|
|
28
|
-
section numbers, generic roles
|
|
29
|
-
- **Operators** — replace (reversible) and redact
|
|
30
|
-
- **De-anonymization** — reverse replacements with key
|
|
7
|
+
Runtime package for multi-layer PII detection and anonymization.
|
|
8
|
+
|
|
9
|
+
It combines regex detectors, trigger phrases, deny-list matching, coreference handling, and NER into a single pipeline that works in native Node.js and in browser builds through the WASM entrypoint.
|
|
31
10
|
|
|
32
11
|
## Install
|
|
33
12
|
|
|
34
13
|
```bash
|
|
35
|
-
|
|
36
|
-
# Optional
|
|
37
|
-
|
|
14
|
+
bun add @stll/anonymize
|
|
15
|
+
# Optional data bundle for deny lists and dictionaries
|
|
16
|
+
bun add @stll/anonymize-data
|
|
38
17
|
```
|
|
39
18
|
|
|
40
|
-
|
|
19
|
+
For browser targets, install `@stll/anonymize-wasm` instead. It exposes the same runtime API through WebAssembly and is the supported entrypoint for Vite-based bundles.
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
41
22
|
|
|
42
|
-
```
|
|
43
|
-
import { runPipeline } from
|
|
23
|
+
```ts
|
|
24
|
+
import { runPipeline } from "@stll/anonymize";
|
|
44
25
|
|
|
45
26
|
const entities = await runPipeline({
|
|
46
27
|
fullText: text,
|
|
47
28
|
config: {
|
|
48
|
-
labels: [
|
|
49
|
-
|
|
29
|
+
labels: [
|
|
30
|
+
"person",
|
|
31
|
+
"organization",
|
|
32
|
+
"address",
|
|
33
|
+
"date",
|
|
34
|
+
"iban",
|
|
35
|
+
"phone number",
|
|
36
|
+
],
|
|
50
37
|
threshold: 0.5,
|
|
51
38
|
enableRegex: true,
|
|
52
39
|
enableTriggerPhrases: true,
|
|
53
40
|
enableLegalForms: true,
|
|
54
41
|
enableNameCorpus: true,
|
|
42
|
+
enableDenyList: false,
|
|
43
|
+
enableGazetteer: false,
|
|
44
|
+
enableNer: false,
|
|
45
|
+
enableConfidenceBoost: true,
|
|
46
|
+
enableCoreference: true,
|
|
47
|
+
workspaceId: "default",
|
|
55
48
|
},
|
|
56
49
|
gazetteerEntries: [],
|
|
57
|
-
})
|
|
50
|
+
});
|
|
58
51
|
```
|
|
59
52
|
|
|
60
|
-
##
|
|
53
|
+
## Browser setup
|
|
61
54
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
If you use Vite with the WASM build, exclude the bundle from dependency pre-bundling:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import stllWasm from "@stll/anonymize-wasm/vite";
|
|
59
|
+
|
|
60
|
+
export default {
|
|
61
|
+
plugins: [stllWasm()],
|
|
62
|
+
};
|
|
69
63
|
```
|
|
70
64
|
|
|
71
|
-
##
|
|
65
|
+
## Notes
|
|
72
66
|
|
|
73
|
-
- [
|
|
74
|
-
-
|
|
75
|
-
-
|
|
67
|
+
- `labels: []` disables deterministic label filtering; when NER is enabled it falls back to the default label set.
|
|
68
|
+
- `enableNameCorpus` also controls whether first names, surnames, and titles are injected into deny-list matching when `enableDenyList` is enabled.
|
|
69
|
+
- The optional `@stll/anonymize-data` package carries the published dictionary and trigger data used by the deny-list layer.
|
|
76
70
|
|
|
77
|
-
##
|
|
71
|
+
## Built on
|
|
78
72
|
|
|
79
|
-
|
|
73
|
+
- `@stll/text-search`
|
|
74
|
+
- `@stll/stdnum`
|
|
75
|
+
- `@stll/anonymize-data`
|
package/dist/index.d.mts
CHANGED
|
@@ -178,6 +178,19 @@ type PipelineConfig = {
|
|
|
178
178
|
threshold: number;
|
|
179
179
|
enableTriggerPhrases: boolean;
|
|
180
180
|
enableRegex: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Enables legal-form organization detection.
|
|
183
|
+
* Required for typed callers; legacy untyped
|
|
184
|
+
* callers that omit this field are treated as
|
|
185
|
+
* enabled at runtime for backward compatibility.
|
|
186
|
+
*/
|
|
187
|
+
enableLegalForms: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Enables first-name/surname/title corpus matching.
|
|
190
|
+
* When deny-list mode is enabled, this also controls
|
|
191
|
+
* whether name-corpus entries are injected into the
|
|
192
|
+
* deny-list search automaton.
|
|
193
|
+
*/
|
|
181
194
|
enableNameCorpus: boolean;
|
|
182
195
|
enableDenyList: boolean;
|
|
183
196
|
denyListCountries?: string[];
|
|
@@ -189,6 +202,11 @@ type PipelineConfig = {
|
|
|
189
202
|
enableCoreference: boolean;
|
|
190
203
|
enableZoneClassification?: boolean;
|
|
191
204
|
enableHotwordRules?: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Requested output labels. An empty array means
|
|
207
|
+
* "do not filter by label" for deterministic
|
|
208
|
+
* detectors; NER falls back to DEFAULT_ENTITY_LABELS.
|
|
209
|
+
*/
|
|
192
210
|
labels: string[];
|
|
193
211
|
workspaceId: string;
|
|
194
212
|
};
|
|
@@ -243,7 +261,7 @@ declare const CURRENCY_PATTERN_META: Readonly<RegexMeta>;
|
|
|
243
261
|
declare const processRegexMatches: (allMatches: Match[], sliceStart: number, sliceEnd: number, meta_: readonly RegexMeta[]) => Entity[];
|
|
244
262
|
//#endregion
|
|
245
263
|
//#region src/detectors/deny-list.d.ts
|
|
246
|
-
type DenyListConfig = Pick<PipelineConfig, "enableDenyList" | "denyListCountries" | "denyListRegions" | "denyListExcludeCategories">;
|
|
264
|
+
type DenyListConfig = Pick<PipelineConfig, "enableDenyList" | "enableNameCorpus" | "denyListCountries" | "denyListRegions" | "denyListExcludeCategories">;
|
|
247
265
|
/**
|
|
248
266
|
* Source tag for each pattern in the automaton.
|
|
249
267
|
* "deny-list" = standard deny list entry
|
|
@@ -707,7 +725,7 @@ declare const resolveCountries: (regions?: string[], countries?: string[]) => Se
|
|
|
707
725
|
* Runs as a post-processing step after all detection
|
|
708
726
|
* layers have merged.
|
|
709
727
|
*/
|
|
710
|
-
declare const filterFalsePositives: (entities: Entity[], ctx?: PipelineContext) => Entity[];
|
|
728
|
+
declare const filterFalsePositives: (entities: Entity[], ctx?: PipelineContext, fullText?: string) => Entity[];
|
|
711
729
|
//#endregion
|
|
712
730
|
//#region src/filters/confidence-boost.d.ts
|
|
713
731
|
/**
|