@stll/anonymize-wasm 1.4.6 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/triggers.global.mjs +73 -28
- package/dist/wasm.d.mts +1 -1
- package/dist/wasm.mjs +37 -4
- package/dist/wasm.mjs.map +1 -1
- package/package.json +3 -3
package/dist/triggers.global.mjs
CHANGED
|
@@ -1,33 +1,78 @@
|
|
|
1
1
|
//#region src/data/triggers.global.json
|
|
2
|
-
var triggers_global_default = [
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
2
|
+
var triggers_global_default = [
|
|
3
|
+
{
|
|
4
|
+
"id": "swift-bic",
|
|
5
|
+
"triggers": ["SWIFT", "BIC"],
|
|
6
|
+
"label": "bank account number",
|
|
7
|
+
"strategy": {
|
|
8
|
+
"type": "n-words",
|
|
9
|
+
"count": 1
|
|
10
|
+
},
|
|
11
|
+
"extensions": ["add-colon"],
|
|
12
|
+
"validations": [{
|
|
13
|
+
"type": "matches-pattern",
|
|
14
|
+
"pattern": "^[A-Za-z]{4}[A-Za-z]{2}[A-Za-z0-9]{2}(?:[A-Za-z0-9]{3})?$"
|
|
15
|
+
}]
|
|
9
16
|
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
17
|
+
{
|
|
18
|
+
"id": "us-aba-routing",
|
|
19
|
+
"triggers": [
|
|
20
|
+
"ABA",
|
|
21
|
+
"ABA Number",
|
|
22
|
+
"RTN",
|
|
23
|
+
"Routing Number",
|
|
24
|
+
"Routing No.",
|
|
25
|
+
"Routing Transit Number"
|
|
26
|
+
],
|
|
27
|
+
"label": "bank account number",
|
|
28
|
+
"strategy": {
|
|
29
|
+
"type": "n-words",
|
|
30
|
+
"count": 1
|
|
31
|
+
},
|
|
32
|
+
"extensions": ["add-colon"],
|
|
33
|
+
"validations": [{ "type": "has-digits" }, {
|
|
34
|
+
"type": "valid-id",
|
|
35
|
+
"validator": "us.rtn"
|
|
36
|
+
}]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "intl-labeled-phone",
|
|
40
|
+
"triggers": [
|
|
41
|
+
"fax",
|
|
42
|
+
"telecopy",
|
|
43
|
+
"telecopier",
|
|
44
|
+
"facsimile",
|
|
45
|
+
"telephone",
|
|
46
|
+
"phone number",
|
|
47
|
+
"contact phone number"
|
|
48
|
+
],
|
|
49
|
+
"label": "phone number",
|
|
50
|
+
"strategy": {
|
|
51
|
+
"type": "match-pattern",
|
|
52
|
+
"pattern": "(?:\\+\\d{1,3}[\\s.\\-]?)?\\(?\\d{1,4}\\)?(?:[\\s.\\-]\\d{1,4}){2,4}"
|
|
53
|
+
},
|
|
54
|
+
"validations": [{
|
|
55
|
+
"type": "matches-pattern",
|
|
56
|
+
"pattern": "(?:\\d[^\\d]*){6,}"
|
|
57
|
+
}]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "amount-prefix",
|
|
61
|
+
"triggers": [
|
|
62
|
+
"ve výši",
|
|
63
|
+
"in the amount of",
|
|
64
|
+
"in Höhe von",
|
|
65
|
+
"d'un montant de",
|
|
66
|
+
"w wysokości",
|
|
67
|
+
"nell'importo di",
|
|
68
|
+
"por un importe de"
|
|
69
|
+
],
|
|
70
|
+
"label": "monetary amount",
|
|
71
|
+
"strategy": { "type": "to-next-comma" },
|
|
72
|
+
"extensions": ["add-colon"],
|
|
73
|
+
"validations": [{ "type": "has-digits" }]
|
|
74
|
+
}
|
|
75
|
+
];
|
|
31
76
|
//#endregion
|
|
32
77
|
export { triggers_global_default as default };
|
|
33
78
|
|
package/dist/wasm.d.mts
CHANGED
|
@@ -117,7 +117,7 @@ type TriggerValidation = {
|
|
|
117
117
|
};
|
|
118
118
|
/** Built-in stdnum validators that can be referenced
|
|
119
119
|
* by `valid-id` validations. */
|
|
120
|
-
type ValidIdValidator = "br.cpf" | "br.cnpj";
|
|
120
|
+
type ValidIdValidator = "br.cpf" | "br.cnpj" | "us.rtn";
|
|
121
121
|
/** Auto-generated trigger variants — closed set. */
|
|
122
122
|
type TriggerExtension = "add-colon" | "add-trailing-space" | "add-colon-space" | "normalize-spaces";
|
|
123
123
|
/** V2 trigger config entry (JSON shape). */
|
package/dist/wasm.mjs
CHANGED
|
@@ -8592,6 +8592,35 @@ const HONORIFIC_BOUNDARY = new Set([
|
|
|
8592
8592
|
"Señora"
|
|
8593
8593
|
]);
|
|
8594
8594
|
/**
|
|
8595
|
+
* Honorifics that are abbreviations: a dot after them is an
|
|
8596
|
+
* abbreviation dot (same sentence), so the detector keeps an
|
|
8597
|
+
* optional `.` between the title and the name ("Mr. Smith").
|
|
8598
|
+
* Every other honorific is a full word — a trailing dot ends a
|
|
8599
|
+
* sentence, so the detector must NOT consume it (otherwise a span
|
|
8600
|
+
* like "President. The Employee" crosses the sentence boundary).
|
|
8601
|
+
*
|
|
8602
|
+
* Maintained explicitly, NOT derived from "ends in a dot": "Mr" is
|
|
8603
|
+
* an abbreviation written without a dot, and "Lord" is a full word.
|
|
8604
|
+
*/
|
|
8605
|
+
const HONORIFIC_ABBREVIATION = new Set([
|
|
8606
|
+
"Avv.",
|
|
8607
|
+
"Dott.",
|
|
8608
|
+
"M.",
|
|
8609
|
+
"Me",
|
|
8610
|
+
"Messrs",
|
|
8611
|
+
"Mlle",
|
|
8612
|
+
"Mme",
|
|
8613
|
+
"Mr",
|
|
8614
|
+
"Mrs",
|
|
8615
|
+
"Ms",
|
|
8616
|
+
"Pr",
|
|
8617
|
+
"Pr.",
|
|
8618
|
+
"Sig.",
|
|
8619
|
+
"Sig.ra",
|
|
8620
|
+
"Sr.",
|
|
8621
|
+
"Sra."
|
|
8622
|
+
]);
|
|
8623
|
+
/**
|
|
8595
8624
|
* Post-nominal degrees (comma or space separated after name).
|
|
8596
8625
|
* Plain text; the detector auto-escapes for regex.
|
|
8597
8626
|
*/
|
|
@@ -9118,11 +9147,14 @@ const POST_NOMINAL = POST_NOMINALS.toSorted((a, b) => b.length - a.length).map(e
|
|
|
9118
9147
|
const NAME_WORD = `\\p{Lu}\\p{Ll}+`;
|
|
9119
9148
|
const PARTICLE = "(?:van der|van den|de la|della|von|van|dos|ibn|ben|bin|del|zum|zur|ten|ter|da|de|di|al|el|le|la|zu|af|av)";
|
|
9120
9149
|
const SP = "[^\\S\\n]";
|
|
9121
|
-
/** Honorific alternation built from titles.ts config.
|
|
9122
|
-
|
|
9150
|
+
/** Honorific alternation built from titles.ts config. Sorted
|
|
9151
|
+
* longest-first so e.g. "Sig.ra" wins over "Sig.". */
|
|
9152
|
+
const buildHonorificAlt = (entries) => [...entries].toSorted((a, b) => b.length - a.length).map((h) => {
|
|
9123
9153
|
const escaped = escapeRegex$2(h);
|
|
9124
9154
|
return HONORIFIC_BOUNDARY.has(h) ? `\\b${escaped}` : escaped;
|
|
9125
9155
|
}).join("|");
|
|
9156
|
+
const HONORIFIC_ABBREV_ALT = buildHonorificAlt(HONORIFICS.filter((h) => HONORIFIC_ABBREVIATION.has(h)));
|
|
9157
|
+
const HONORIFIC_FULLWORD_ALT = buildHonorificAlt(HONORIFICS.filter((h) => !HONORIFIC_ABBREVIATION.has(h)));
|
|
9126
9158
|
const AMOUNT_WORDS = amount_words_default;
|
|
9127
9159
|
const toEntry = (validator, label, score) => {
|
|
9128
9160
|
const pattern = toRegex(validator).source;
|
|
@@ -9214,7 +9246,7 @@ const TITLED_PERSON = {
|
|
|
9214
9246
|
score: .95
|
|
9215
9247
|
};
|
|
9216
9248
|
const HONORIFIC_PERSON = {
|
|
9217
|
-
pattern: `(?:${
|
|
9249
|
+
pattern: `(?:(?:${HONORIFIC_ABBREV_ALT})\\.?|(?:${HONORIFIC_FULLWORD_ALT}))${SP}+${NAME_WORD}(?:(?:${SP}|-){1,2}(?:${PARTICLE}${SP}+)?${NAME_WORD}){0,3}(?:${SP}+(?:QC|KC|SC|LJ|AG))?`,
|
|
9218
9250
|
label: "person",
|
|
9219
9251
|
score: .95
|
|
9220
9252
|
};
|
|
@@ -10089,7 +10121,8 @@ const dropOverlapping = (candidates) => {
|
|
|
10089
10121
|
//#region src/detectors/triggers.ts
|
|
10090
10122
|
const VALID_ID_VALIDATORS = {
|
|
10091
10123
|
"br.cpf": br.cpf,
|
|
10092
|
-
"br.cnpj": br.cnpj
|
|
10124
|
+
"br.cnpj": br.cnpj,
|
|
10125
|
+
"us.rtn": us.rtn
|
|
10093
10126
|
};
|
|
10094
10127
|
const TRIGGER_SCORE = .95;
|
|
10095
10128
|
const WHITESPACE_RE$1 = /\s+/;
|