@guhttps/veu 0.7.1 → 0.8.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/dist/addresses.js +1 -1
- package/dist/analyzer.js +21 -3
- package/dist/anonymizer.js +10 -0
- package/dist/data.d.ts +1 -0
- package/dist/data.js +35 -12
- package/dist/entities.js +10 -2
- package/dist/patterns.js +78 -2
- package/dist/persons.d.ts +3 -0
- package/dist/persons.js +23 -1
- package/dist/secrets.d.ts +5 -0
- package/dist/secrets.js +107 -7
- package/dist/validators.d.ts +23 -0
- package/dist/validators.js +125 -0
- package/dist/vault.js +80 -11
- package/dist/veu.global.js +20 -13
- package/package.json +1 -1
package/dist/addresses.js
CHANGED
|
@@ -17,7 +17,7 @@ const LOWERCASE = new RegExp("(?<![\\p{L}\\p{N}_])(?:rua|avenida|av\\.?|travessa
|
|
|
17
17
|
const ADDRESS_CONTEXT = [
|
|
18
18
|
"moro", "mora", "moramos", "resido", "reside", "residente", "domiciliado", "domiciliada", "endereco",
|
|
19
19
|
"entrega", "entregar", "enviar para", "envio para", "localizado", "localizada", "situado", "situada",
|
|
20
|
-
"sede", "fica na", "fica no", "cobranca", "imovel",
|
|
20
|
+
"sede", "fica na", "fica no", "cobranca", "imovel", "logradouro", "xlgr", "enderdest", "enderemit",
|
|
21
21
|
];
|
|
22
22
|
export class AddressRecognizer {
|
|
23
23
|
name = "enderecos";
|
package/dist/analyzer.js
CHANGED
|
@@ -11,8 +11,26 @@ export const DEFAULT_THRESHOLD = 0.5;
|
|
|
11
11
|
// invisível), hífens tipográficos ("529.982.247‑25" copiado do Word) e letras e dígitos de largura total.
|
|
12
12
|
const INVISIBLE = "\u00ad\u200b\u200c\u200d\u2060\ufeff";
|
|
13
13
|
const HYPHENS = "\u2010\u2011\u2012\u2013\u2212\ufe63\uff0d";
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// Letras cir\u00edlicas e gregas iguais \u00e0s latinas ("m\u0430ria@..." com "\u0430" cir\u00edlico) e d\u00edgitos de outros sistemas (ar\u00e1bico-
|
|
15
|
+
// \u00edndicos, persas, devan\u00e1gari, bengali): trocados um por um, s\u00f3 para a detec\u00e7\u00e3o, para um disfarce n\u00e3o passar.
|
|
16
|
+
const CONFUSABLES_FROM = "\u0430\u0435\u043e\u0440\u0441\u0443\u0445\u0456\u0458\u0455\u0501\u04bb\u04cf\u051b\u051d\u0410\u0412\u0415\u041a\u041c\u041d\u041e\u0420\u0421\u0422\u0425\u0406\u0408\u0405\u04ae\u0391\u0392\u0395\u0396\u0397\u0399\u039a\u039c\u039d\u039f\u03a1\u03a4\u03a5\u03a7\u03bf\u03b1\u03c1\u03bd\u03b9\u03ba";
|
|
17
|
+
const CONFUSABLES_TO = "aeopcyxijsdhlqwABEKMHOPCTXIJSYABEZHIKMNOPTYXoapvik";
|
|
18
|
+
const DIGIT_BLOCKS = [0x0660, 0x06f0, 0x0966, 0x09e6];
|
|
19
|
+
const DIGIT_RANGES = DIGIT_BLOCKS.map((block) => `${String.fromCharCode(block)}-${String.fromCharCode(block + 9)}`).join("");
|
|
20
|
+
const SPECIAL = new RegExp(`[${INVISIBLE}${HYPHENS}\uff01-\uff5e${CONFUSABLES_FROM}${DIGIT_RANGES}]`, "u");
|
|
21
|
+
const SAME_LENGTH = new RegExp(`[${HYPHENS}\uff01-\uff5e${CONFUSABLES_FROM}${DIGIT_RANGES}]`, "gu");
|
|
22
|
+
function sameLength(char) {
|
|
23
|
+
if (HYPHENS.includes(char))
|
|
24
|
+
return "-";
|
|
25
|
+
const confusable = CONFUSABLES_FROM.indexOf(char);
|
|
26
|
+
if (confusable !== -1)
|
|
27
|
+
return CONFUSABLES_TO[confusable];
|
|
28
|
+
const code = char.charCodeAt(0);
|
|
29
|
+
const block = DIGIT_BLOCKS.find((start) => code >= start && code <= start + 9);
|
|
30
|
+
if (block !== undefined)
|
|
31
|
+
return String(code - block);
|
|
32
|
+
return String.fromCharCode(code - 0xfee0);
|
|
33
|
+
}
|
|
16
34
|
const HAS_INVISIBLE = new RegExp(`[${INVISIBLE}]`, "u");
|
|
17
35
|
/**
|
|
18
36
|
* Texto para a detecção e, se algum caractere saiu, a posição original de cada um (mais uma no fim).
|
|
@@ -21,7 +39,7 @@ const HAS_INVISIBLE = new RegExp(`[${INVISIBLE}]`, "u");
|
|
|
21
39
|
export function normalizeForDetection(text) {
|
|
22
40
|
if (!SPECIAL.test(text))
|
|
23
41
|
return [text, null];
|
|
24
|
-
const swapped = text.replace(SAME_LENGTH,
|
|
42
|
+
const swapped = text.replace(SAME_LENGTH, sameLength);
|
|
25
43
|
if (!HAS_INVISIBLE.test(swapped))
|
|
26
44
|
return [swapped, null];
|
|
27
45
|
const positions = [];
|
package/dist/anonymizer.js
CHANGED
|
@@ -124,6 +124,13 @@ export class AnonymizationResult {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
// Palavras de nome (letras, com apóstrofo): a mesma definição do detector de nomes.
|
|
127
|
+
// Sobrenome que também é cidade: depois de um código postal, de "cidade de" ou antes do estado, é o lugar.
|
|
128
|
+
const PLACE_BEFORE = /(?:\d{4,5}-\d{3}[ \t]*|(?:cidade|munic[íi]pio|comarca)[ \t]+de[ \t]+)$/i;
|
|
129
|
+
const PLACE_AFTER = /[ \t]*(?:\/[ \t]*|[-–][ \t]+)[A-Z]{2}(?![\p{L}\p{N}_])/uy;
|
|
130
|
+
function placeAfter(text, end) {
|
|
131
|
+
PLACE_AFTER.lastIndex = end;
|
|
132
|
+
return PLACE_AFTER.test(text);
|
|
133
|
+
}
|
|
127
134
|
const NAME_WORD = /[A-Za-zÀ-ÖØ-öø-ÿ]+(?:['’][A-Za-zÀ-ÖØ-öø-ÿ]+)*/gu;
|
|
128
135
|
const WORD_CHAR = /[\p{L}\p{N}_]/u;
|
|
129
136
|
/** Sequências de palavras cuja forma normalizada está em parts (a mais longa primeiro), com custo linear. */
|
|
@@ -262,6 +269,9 @@ export class Anonymizer {
|
|
|
262
269
|
// "Costa" é a pessoa; "costa" (o litoral) e "data de nascimento", não.
|
|
263
270
|
if (capitalizedOnly.has(key) && text[start] === text[start].toLowerCase())
|
|
264
271
|
continue;
|
|
272
|
+
// "4050-262 Porto", "Campos/RJ": a cidade, não o Sr. Porto nem a Sra. Campos.
|
|
273
|
+
if (PLACE_BEFORE.test(text.slice(Math.max(0, start - 20), start)) || placeAfter(text, end))
|
|
274
|
+
continue;
|
|
265
275
|
added.push({ label: "PESSOA", start, end, score: 0.7, recognizer: "vinculo", text: text.slice(start, end) });
|
|
266
276
|
canonical.set(start, parts.get(key));
|
|
267
277
|
}
|
package/dist/data.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const ibgeAmbiguous: readonly string[];
|
|
|
5
5
|
export declare const stopwords: readonly string[];
|
|
6
6
|
export declare const places: readonly string[];
|
|
7
7
|
export declare const organizations: readonly string[];
|
|
8
|
+
export declare const bip39: readonly string[];
|
|
8
9
|
export interface SecretRuleData {
|
|
9
10
|
id: string;
|
|
10
11
|
entidade: string;
|