@blindfold/sdk 1.0.2
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 +21 -0
- package/README.md +427 -0
- package/dist/index-CsE6Vhax.d.mts +177 -0
- package/dist/index-CsE6Vhax.d.mts.map +1 -0
- package/dist/index-Dfv8zV_d.d.ts +177 -0
- package/dist/index-Dfv8zV_d.d.ts.map +1 -0
- package/dist/index.d.mts +450 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +450 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +575 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +568 -0
- package/dist/index.mjs.map +1 -0
- package/dist/regex/index.d.mts +2 -0
- package/dist/regex/index.d.ts +2 -0
- package/dist/regex/index.js +5 -0
- package/dist/regex/index.mjs +4 -0
- package/dist/regex-BEaK0E7Y.js +4881 -0
- package/dist/regex-BEaK0E7Y.js.map +1 -0
- package/dist/regex-ByjZg3Zy.mjs +4839 -0
- package/dist/regex-ByjZg3Zy.mjs.map +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,4881 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//#region rolldown:runtime
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __esm = (fn, res) => function() {
|
|
10
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
+
};
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all) __defProp(target, name, {
|
|
14
|
+
get: all[name],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
+
key = keys[i];
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
+
get: ((k) => from[k]).bind(null, key),
|
|
23
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
+
value: mod,
|
|
30
|
+
enumerable: true
|
|
31
|
+
}) : target, mod));
|
|
32
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
const crypto = __toESM(require("crypto"));
|
|
36
|
+
|
|
37
|
+
//#region src/regex/registry.ts
|
|
38
|
+
/** Register a universal (locale-independent) detector class. */
|
|
39
|
+
function registerUniversal(cls) {
|
|
40
|
+
UNIVERSAL_DETECTORS.push(cls);
|
|
41
|
+
}
|
|
42
|
+
/** Register a region-specific detector class. */
|
|
43
|
+
function registerRegion(locale, cls) {
|
|
44
|
+
if (!REGION_DETECTORS[locale]) REGION_DETECTORS[locale] = [];
|
|
45
|
+
REGION_DETECTORS[locale].push(cls);
|
|
46
|
+
}
|
|
47
|
+
var UNIVERSAL_DETECTORS, REGION_DETECTORS, DetectorRegistry;
|
|
48
|
+
var init_registry = __esm({ "src/regex/registry.ts"() {
|
|
49
|
+
UNIVERSAL_DETECTORS = [];
|
|
50
|
+
REGION_DETECTORS = {
|
|
51
|
+
us: [],
|
|
52
|
+
eu: [],
|
|
53
|
+
uk: []
|
|
54
|
+
};
|
|
55
|
+
DetectorRegistry = class {
|
|
56
|
+
_detectors = [];
|
|
57
|
+
constructor(locales) {
|
|
58
|
+
const resolvedLocales = (locales ?? ["us"]).map((loc) => loc.toLowerCase());
|
|
59
|
+
this._build(resolvedLocales);
|
|
60
|
+
}
|
|
61
|
+
_build(locales) {
|
|
62
|
+
for (const Cls of UNIVERSAL_DETECTORS) this._detectors.push(new Cls());
|
|
63
|
+
for (const locale of locales) {
|
|
64
|
+
const regionClasses = REGION_DETECTORS[locale] ?? [];
|
|
65
|
+
for (const Cls of regionClasses) this._detectors.push(new Cls());
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
get detectors() {
|
|
69
|
+
return this._detectors;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
} });
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/regex/synthesizers.ts
|
|
76
|
+
function randInt(min, max) {
|
|
77
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
78
|
+
}
|
|
79
|
+
function randChar(chars) {
|
|
80
|
+
return chars[Math.floor(Math.random() * chars.length)];
|
|
81
|
+
}
|
|
82
|
+
function randHex(len) {
|
|
83
|
+
let result = "";
|
|
84
|
+
for (let i = 0; i < len; i++) result += randChar("0123456789abcdef");
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Format-preserving default: replace digits with random digits,
|
|
89
|
+
* uppercase with random uppercase, lowercase with random lowercase,
|
|
90
|
+
* keep everything else (separators, symbols) intact.
|
|
91
|
+
*/
|
|
92
|
+
function formatPreserving(original) {
|
|
93
|
+
const chars = [];
|
|
94
|
+
for (const ch of original) if (ch >= "0" && ch <= "9") chars.push(randChar(DIGITS));
|
|
95
|
+
else if (ch >= "A" && ch <= "Z") chars.push(randChar(UPPER));
|
|
96
|
+
else if (ch >= "a" && ch <= "z") chars.push(randChar(LOWER));
|
|
97
|
+
else chars.push(ch);
|
|
98
|
+
const result = chars.join("");
|
|
99
|
+
if (result === original) return formatPreserving(original);
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
function synthesizeEmail() {
|
|
103
|
+
const id = randHex(8);
|
|
104
|
+
return `user${id}@example.com`;
|
|
105
|
+
}
|
|
106
|
+
function synthesizeUrl() {
|
|
107
|
+
const path = randHex(10);
|
|
108
|
+
return `https://example.com/${path}`;
|
|
109
|
+
}
|
|
110
|
+
function synthesizeIp() {
|
|
111
|
+
const a = randInt(1, 254);
|
|
112
|
+
const b = randInt(0, 255);
|
|
113
|
+
const c = randInt(0, 255);
|
|
114
|
+
const d = randInt(1, 254);
|
|
115
|
+
return `${a}.${b}.${c}.${d}`;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Generate a credit card number with valid Luhn checksum,
|
|
119
|
+
* preserving the separator pattern of the original.
|
|
120
|
+
*/
|
|
121
|
+
function synthesizeCreditCard(original) {
|
|
122
|
+
const digitsOnly = original.replace(/\D/g, "");
|
|
123
|
+
const numDigits = digitsOnly.length;
|
|
124
|
+
const payload = [];
|
|
125
|
+
for (let i = 0; i < numDigits - 1; i++) payload.push(randInt(0, 9));
|
|
126
|
+
let sum = 0;
|
|
127
|
+
for (let i = payload.length - 1; i >= 0; i--) {
|
|
128
|
+
let d = payload[i];
|
|
129
|
+
if ((payload.length - 1 - i) % 2 === 0) {
|
|
130
|
+
d *= 2;
|
|
131
|
+
if (d > 9) d -= 9;
|
|
132
|
+
}
|
|
133
|
+
sum += d;
|
|
134
|
+
}
|
|
135
|
+
const checkDigit = (10 - sum % 10) % 10;
|
|
136
|
+
payload.push(checkDigit);
|
|
137
|
+
let digitIdx = 0;
|
|
138
|
+
let result = "";
|
|
139
|
+
for (const ch of original) if (ch >= "0" && ch <= "9") result += payload[digitIdx++];
|
|
140
|
+
else result += ch;
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Generate an IBAN-like value preserving length with a valid mod-97 check.
|
|
145
|
+
*/
|
|
146
|
+
function synthesizeIban(original) {
|
|
147
|
+
const stripped = original.replace(/\s/g, "");
|
|
148
|
+
const len = stripped.length;
|
|
149
|
+
if (len < 5) return formatPreserving(original);
|
|
150
|
+
const bbanLen = len - 4;
|
|
151
|
+
let bban = "";
|
|
152
|
+
for (let i = 0; i < bbanLen; i++) bban += randChar(DIGITS);
|
|
153
|
+
const numericStr = bban + "333300";
|
|
154
|
+
let remainder = 0;
|
|
155
|
+
for (const ch of numericStr) remainder = (remainder * 10 + parseInt(ch, 10)) % 97;
|
|
156
|
+
const checkDigits = (98 - remainder).toString().padStart(2, "0");
|
|
157
|
+
const iban = "XX" + checkDigits + bban;
|
|
158
|
+
if (original.includes(" ")) {
|
|
159
|
+
let spaceIdx = 0;
|
|
160
|
+
let result = "";
|
|
161
|
+
for (const ch of original) if (ch === " ") result += " ";
|
|
162
|
+
else result += iban[spaceIdx++] || "0";
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
return iban;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Generate a synthetic replacement for a detected PII value.
|
|
169
|
+
* Uses format-preserving random by default, with specific generators
|
|
170
|
+
* for types where structural validity matters.
|
|
171
|
+
*/
|
|
172
|
+
function synthesizeValue(entityType, originalText) {
|
|
173
|
+
switch (entityType) {
|
|
174
|
+
case "Email Address": return synthesizeEmail();
|
|
175
|
+
case "URL": return synthesizeUrl();
|
|
176
|
+
case "IP Address": return synthesizeIp();
|
|
177
|
+
case "Credit Card Number": return synthesizeCreditCard(originalText);
|
|
178
|
+
case "IBAN": return synthesizeIban(originalText);
|
|
179
|
+
default: return formatPreserving(originalText);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
var UPPER, LOWER, DIGITS;
|
|
183
|
+
var init_synthesizers = __esm({ "src/regex/synthesizers.ts"() {
|
|
184
|
+
UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
185
|
+
LOWER = "abcdefghijklmnopqrstuvwxyz";
|
|
186
|
+
DIGITS = "0123456789";
|
|
187
|
+
} });
|
|
188
|
+
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/regex/base.ts
|
|
191
|
+
var Detector, RegexDetector;
|
|
192
|
+
var init_base = __esm({ "src/regex/base.ts"() {
|
|
193
|
+
Detector = class {
|
|
194
|
+
score = .85;
|
|
195
|
+
baseScore = null;
|
|
196
|
+
contextKeywords = [];
|
|
197
|
+
contextRequired = false;
|
|
198
|
+
contextWindow = 50;
|
|
199
|
+
locale = "";
|
|
200
|
+
needsDigit = true;
|
|
201
|
+
/** Check if any context keyword appears near the match position. */
|
|
202
|
+
hasContext(text, start, end = 0) {
|
|
203
|
+
if (this.contextKeywords.length === 0) return true;
|
|
204
|
+
const lower = this._textLower || text.toLowerCase();
|
|
205
|
+
const windowStart = Math.max(0, start - this.contextWindow);
|
|
206
|
+
const before = lower.slice(windowStart, start);
|
|
207
|
+
const after = end ? lower.slice(end, end + this.contextWindow) : "";
|
|
208
|
+
const window = before + " " + after;
|
|
209
|
+
return this.contextKeywords.some((kw) => window.includes(kw));
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
RegexDetector = class extends Detector {
|
|
213
|
+
validator;
|
|
214
|
+
/** Optional fast pre-check before running regex. Override in subclasses. */
|
|
215
|
+
preCheck(_text) {
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
iterMatches(text) {
|
|
219
|
+
if (!this.preCheck(text)) return [];
|
|
220
|
+
const results = [];
|
|
221
|
+
this.pattern.lastIndex = 0;
|
|
222
|
+
let match;
|
|
223
|
+
while ((match = this.pattern.exec(text)) !== null) {
|
|
224
|
+
const matchedText = match[0];
|
|
225
|
+
const start = match.index;
|
|
226
|
+
const end = start + matchedText.length;
|
|
227
|
+
const hasCtx = this.hasContext(text, start, end);
|
|
228
|
+
if (this.contextRequired && !hasCtx) continue;
|
|
229
|
+
let score;
|
|
230
|
+
if (this.validator) {
|
|
231
|
+
if (!this.validator(matchedText)) continue;
|
|
232
|
+
score = hasCtx ? 1 : this.score;
|
|
233
|
+
} else if (hasCtx) score = this.score;
|
|
234
|
+
else score = this.baseScore !== null ? this.baseScore : this.score;
|
|
235
|
+
results.push({
|
|
236
|
+
entityType: this.entityType,
|
|
237
|
+
text: matchedText,
|
|
238
|
+
start,
|
|
239
|
+
end,
|
|
240
|
+
score
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
return results;
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
} });
|
|
247
|
+
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/regex/entities.ts
|
|
250
|
+
var EntityType;
|
|
251
|
+
var init_entities = __esm({ "src/regex/entities.ts"() {
|
|
252
|
+
EntityType = /* @__PURE__ */ function(EntityType$1) {
|
|
253
|
+
EntityType$1["EMAIL_ADDRESS"] = "Email Address";
|
|
254
|
+
EntityType$1["CREDIT_CARD"] = "Credit Card Number";
|
|
255
|
+
EntityType$1["PHONE_NUMBER"] = "Phone Number";
|
|
256
|
+
EntityType$1["IP_ADDRESS"] = "IP Address";
|
|
257
|
+
EntityType$1["URL"] = "URL";
|
|
258
|
+
EntityType$1["MAC_ADDRESS"] = "MAC Address";
|
|
259
|
+
EntityType$1["DATE_OF_BIRTH"] = "Date of Birth";
|
|
260
|
+
EntityType$1["CVV"] = "CVV";
|
|
261
|
+
EntityType$1["SSN"] = "Social Security Number";
|
|
262
|
+
EntityType$1["DRIVERS_LICENSE"] = "Driver's License";
|
|
263
|
+
EntityType$1["US_PASSPORT"] = "US Passport";
|
|
264
|
+
EntityType$1["TAX_ID"] = "Tax ID";
|
|
265
|
+
EntityType$1["ZIP_CODE"] = "ZIP Code";
|
|
266
|
+
EntityType$1["IBAN"] = "IBAN";
|
|
267
|
+
EntityType$1["EU_POSTAL_CODE"] = "Postal Code";
|
|
268
|
+
EntityType$1["VAT_ID"] = "VAT ID";
|
|
269
|
+
EntityType$1["NI_NUMBER"] = "NI Number";
|
|
270
|
+
EntityType$1["NHS_NUMBER"] = "NHS Number";
|
|
271
|
+
EntityType$1["UK_POSTCODE"] = "UK Postcode";
|
|
272
|
+
EntityType$1["UK_PASSPORT"] = "UK Passport";
|
|
273
|
+
EntityType$1["DE_PERSONAL_ID"] = "German Personal ID";
|
|
274
|
+
EntityType$1["DE_TAX_ID"] = "German Tax ID";
|
|
275
|
+
EntityType$1["FR_NATIONAL_ID"] = "French National ID";
|
|
276
|
+
EntityType$1["ES_DNI"] = "Spanish DNI";
|
|
277
|
+
EntityType$1["ES_NIE"] = "Spanish NIE";
|
|
278
|
+
EntityType$1["IT_CODICE_FISCALE"] = "Italian Codice Fiscale";
|
|
279
|
+
EntityType$1["PT_NIF"] = "Portuguese NIF";
|
|
280
|
+
EntityType$1["PL_PESEL"] = "Polish PESEL";
|
|
281
|
+
EntityType$1["PL_NIP"] = "Polish NIP";
|
|
282
|
+
EntityType$1["CZ_BIRTH_NUMBER"] = "Czech Birth Number";
|
|
283
|
+
EntityType$1["CZ_ICO"] = "Czech ICO";
|
|
284
|
+
EntityType$1["CZ_DIC"] = "Czech DIC";
|
|
285
|
+
EntityType$1["CZ_BANK_ACCOUNT"] = "Czech Bank Account";
|
|
286
|
+
EntityType$1["RU_INN"] = "Russian INN";
|
|
287
|
+
EntityType$1["RU_SNILS"] = "Russian SNILS";
|
|
288
|
+
EntityType$1["NL_BSN"] = "Dutch BSN";
|
|
289
|
+
EntityType$1["RO_CNP"] = "Romanian CNP";
|
|
290
|
+
EntityType$1["SK_BIRTH_NUMBER"] = "Slovak Birth Number";
|
|
291
|
+
EntityType$1["DK_CPR"] = "Danish CPR";
|
|
292
|
+
EntityType$1["SE_PERSONNUMMER"] = "Swedish Personnummer";
|
|
293
|
+
EntityType$1["NO_BIRTH_NUMBER"] = "Norwegian Birth Number";
|
|
294
|
+
EntityType$1["BR_CPF"] = "Brazilian CPF";
|
|
295
|
+
EntityType$1["BR_CNPJ"] = "Brazilian CNPJ";
|
|
296
|
+
EntityType$1["US_ITIN"] = "US ITIN";
|
|
297
|
+
EntityType$1["UK_UTR"] = "UK UTR";
|
|
298
|
+
EntityType$1["FR_SIREN"] = "French SIREN";
|
|
299
|
+
EntityType$1["ES_NSS"] = "Spanish NSS";
|
|
300
|
+
EntityType$1["ES_CIF"] = "Spanish CIF";
|
|
301
|
+
EntityType$1["IT_PARTITA_IVA"] = "Italian Partita IVA";
|
|
302
|
+
EntityType$1["PL_REGON"] = "Polish REGON";
|
|
303
|
+
EntityType$1["SK_ICO"] = "Slovak ICO";
|
|
304
|
+
EntityType$1["SK_DIC"] = "Slovak DIC";
|
|
305
|
+
EntityType$1["RO_CUI"] = "Romanian CUI";
|
|
306
|
+
EntityType$1["DK_CVR"] = "Danish CVR";
|
|
307
|
+
EntityType$1["SE_ORGNR"] = "Swedish Organisationsnummer";
|
|
308
|
+
EntityType$1["NO_ORGNR"] = "Norwegian Organisasjonsnummer";
|
|
309
|
+
EntityType$1["BE_NATIONAL_NUMBER"] = "Belgian National Number";
|
|
310
|
+
EntityType$1["BE_ENTERPRISE_NUMBER"] = "Belgian Enterprise Number";
|
|
311
|
+
EntityType$1["AT_SVNR"] = "Austrian SVNR";
|
|
312
|
+
EntityType$1["IE_PPS"] = "Irish PPS Number";
|
|
313
|
+
EntityType$1["FI_HETU"] = "Finnish HETU";
|
|
314
|
+
EntityType$1["FI_YTUNNUS"] = "Finnish Y-tunnus";
|
|
315
|
+
EntityType$1["HU_TAX_ID"] = "Hungarian Tax ID";
|
|
316
|
+
EntityType$1["HU_TAJ"] = "Hungarian TAJ";
|
|
317
|
+
EntityType$1["BG_EGN"] = "Bulgarian EGN";
|
|
318
|
+
EntityType$1["HR_OIB"] = "Croatian OIB";
|
|
319
|
+
EntityType$1["SI_EMSO"] = "Slovenian EMSO";
|
|
320
|
+
EntityType$1["SI_TAX_NUMBER"] = "Slovenian Tax Number";
|
|
321
|
+
EntityType$1["LT_PERSONAL_CODE"] = "Lithuanian Personal Code";
|
|
322
|
+
EntityType$1["LV_PERSONAL_CODE"] = "Latvian Personal Code";
|
|
323
|
+
EntityType$1["EE_PERSONAL_CODE"] = "Estonian Personal Code";
|
|
324
|
+
EntityType$1["CA_SIN"] = "Canadian SIN";
|
|
325
|
+
EntityType$1["CH_AHV"] = "Swiss AHV";
|
|
326
|
+
EntityType$1["AU_TFN"] = "Australian TFN";
|
|
327
|
+
EntityType$1["AU_MEDICARE"] = "Australian Medicare";
|
|
328
|
+
EntityType$1["NZ_IRD"] = "New Zealand IRD";
|
|
329
|
+
EntityType$1["IN_AADHAAR"] = "Indian Aadhaar";
|
|
330
|
+
EntityType$1["IN_PAN"] = "Indian PAN";
|
|
331
|
+
EntityType$1["JP_MY_NUMBER"] = "Japanese My Number";
|
|
332
|
+
EntityType$1["KR_RRN"] = "Korean RRN";
|
|
333
|
+
EntityType$1["ZA_ID"] = "South African ID";
|
|
334
|
+
EntityType$1["TR_KIMLIK"] = "Turkish Kimlik";
|
|
335
|
+
EntityType$1["IL_ID"] = "Israeli ID";
|
|
336
|
+
EntityType$1["AR_CUIT"] = "Argentine CUIT";
|
|
337
|
+
EntityType$1["CL_RUT"] = "Chilean RUT";
|
|
338
|
+
EntityType$1["CO_NIT"] = "Colombian NIT";
|
|
339
|
+
return EntityType$1;
|
|
340
|
+
}({});
|
|
341
|
+
} });
|
|
342
|
+
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/regex/detectors/email.ts
|
|
345
|
+
var EmailDetector;
|
|
346
|
+
var init_email = __esm({ "src/regex/detectors/email.ts"() {
|
|
347
|
+
init_base();
|
|
348
|
+
init_entities();
|
|
349
|
+
init_registry();
|
|
350
|
+
EmailDetector = class extends RegexDetector {
|
|
351
|
+
entityType = EntityType.EMAIL_ADDRESS;
|
|
352
|
+
score = .95;
|
|
353
|
+
needsDigit = false;
|
|
354
|
+
pattern = /\b[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}\b/g;
|
|
355
|
+
preCheck(text) {
|
|
356
|
+
return text.includes("@");
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
registerUniversal(EmailDetector);
|
|
360
|
+
} });
|
|
361
|
+
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/regex/validators.ts
|
|
364
|
+
/** Validate a number string using the Luhn algorithm (ISO/IEC 7812). */
|
|
365
|
+
function luhnChecksum(number) {
|
|
366
|
+
const digits = [];
|
|
367
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
368
|
+
if (digits.length < 2) return false;
|
|
369
|
+
let total = 0;
|
|
370
|
+
const reversed = digits.slice().reverse();
|
|
371
|
+
for (let i = 0; i < reversed.length; i++) {
|
|
372
|
+
let d = reversed[i];
|
|
373
|
+
if (i % 2 === 1) {
|
|
374
|
+
d *= 2;
|
|
375
|
+
if (d > 9) d -= 9;
|
|
376
|
+
}
|
|
377
|
+
total += d;
|
|
378
|
+
}
|
|
379
|
+
return total % 10 === 0;
|
|
380
|
+
}
|
|
381
|
+
/** Validate IBAN using ISO 7064 mod-97 checksum. */
|
|
382
|
+
function ibanMod97(iban) {
|
|
383
|
+
const cleaned = iban.replace(/[\s-]/g, "").toUpperCase();
|
|
384
|
+
if (cleaned.length < 5) return false;
|
|
385
|
+
if (!/^[A-Z]{2}/.test(cleaned) || !/^\d{2}/.test(cleaned.slice(2, 4))) return false;
|
|
386
|
+
const rearranged = cleaned.slice(4) + cleaned.slice(0, 4);
|
|
387
|
+
let numeric = "";
|
|
388
|
+
for (const c of rearranged) if (c >= "0" && c <= "9") numeric += c;
|
|
389
|
+
else if (c >= "A" && c <= "Z") numeric += String(c.charCodeAt(0) - 55);
|
|
390
|
+
else return false;
|
|
391
|
+
let remainder = 0;
|
|
392
|
+
for (let i = 0; i < numeric.length; i++) remainder = (remainder * 10 + parseInt(numeric[i], 10)) % 97;
|
|
393
|
+
return remainder === 1;
|
|
394
|
+
}
|
|
395
|
+
/** Check SSN format rules: no 000/666/9xx area, no 00 group, no 0000 serial. */
|
|
396
|
+
function ssnValidFormat(ssn) {
|
|
397
|
+
let digits = "";
|
|
398
|
+
for (const c of ssn) if (c >= "0" && c <= "9") digits += c;
|
|
399
|
+
if (digits.length !== 9) return false;
|
|
400
|
+
const area = parseInt(digits.slice(0, 3), 10);
|
|
401
|
+
const group = parseInt(digits.slice(3, 5), 10);
|
|
402
|
+
const serial = parseInt(digits.slice(5), 10);
|
|
403
|
+
if (area === 0 || area === 666 || area >= 900) return false;
|
|
404
|
+
if (group === 0) return false;
|
|
405
|
+
if (serial === 0) return false;
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
/** Validate German Tax ID using ISO 7064 Mod 11,10. */
|
|
409
|
+
function deTaxIdChecksum(number) {
|
|
410
|
+
const digits = [];
|
|
411
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
412
|
+
if (digits.length !== 11) return false;
|
|
413
|
+
let product = 10;
|
|
414
|
+
for (let i = 0; i < 10; i++) {
|
|
415
|
+
let total = (digits[i] + product) % 10;
|
|
416
|
+
if (total === 0) total = 10;
|
|
417
|
+
product = total * 2 % 11;
|
|
418
|
+
}
|
|
419
|
+
let check = 11 - product;
|
|
420
|
+
if (check === 10) check = 0;
|
|
421
|
+
return digits[10] === check;
|
|
422
|
+
}
|
|
423
|
+
/** Validate French NIR using mod 97 checksum. */
|
|
424
|
+
function frNirChecksum(number) {
|
|
425
|
+
const cleaned = number.toUpperCase().replace(/2A/g, "19").replace(/2B/g, "18");
|
|
426
|
+
let digitsStr = "";
|
|
427
|
+
for (const c of cleaned) if (c >= "0" && c <= "9") digitsStr += c;
|
|
428
|
+
if (digitsStr.length !== 15) return false;
|
|
429
|
+
const base = parseInt(digitsStr.slice(0, 13), 10);
|
|
430
|
+
const key = parseInt(digitsStr.slice(13, 15), 10);
|
|
431
|
+
return key === 97 - base % 97;
|
|
432
|
+
}
|
|
433
|
+
/** Validate Spanish DNI check letter using mod-23 table. */
|
|
434
|
+
function esDniLetter(number) {
|
|
435
|
+
let cleaned = "";
|
|
436
|
+
for (const c of number) if (c >= "0" && c <= "9" || c >= "A" && c <= "Z" || c >= "a" && c <= "z") cleaned += c;
|
|
437
|
+
if (cleaned.length !== 9) return false;
|
|
438
|
+
const digitsStr = cleaned.slice(0, 8);
|
|
439
|
+
const letter = cleaned[8].toUpperCase();
|
|
440
|
+
for (const c of digitsStr) if (c < "0" || c > "9") return false;
|
|
441
|
+
const expected = ES_DNI_LETTERS[parseInt(digitsStr, 10) % 23];
|
|
442
|
+
return letter === expected;
|
|
443
|
+
}
|
|
444
|
+
/** Validate Spanish NIE check letter (X/Y/Z prefix, then same as DNI). */
|
|
445
|
+
function esNieLetter(number) {
|
|
446
|
+
let cleaned = "";
|
|
447
|
+
for (const c of number) if (c >= "0" && c <= "9" || c >= "A" && c <= "Z" || c >= "a" && c <= "z") cleaned += c;
|
|
448
|
+
if (cleaned.length !== 9) return false;
|
|
449
|
+
const prefix = cleaned[0].toUpperCase();
|
|
450
|
+
const mapping = {
|
|
451
|
+
X: "0",
|
|
452
|
+
Y: "1",
|
|
453
|
+
Z: "2"
|
|
454
|
+
};
|
|
455
|
+
if (!(prefix in mapping)) return false;
|
|
456
|
+
const digitsStr = mapping[prefix] + cleaned.slice(1, 8);
|
|
457
|
+
const letter = cleaned[8].toUpperCase();
|
|
458
|
+
for (const c of digitsStr) if (c < "0" || c > "9") return false;
|
|
459
|
+
const expected = ES_DNI_LETTERS[parseInt(digitsStr, 10) % 23];
|
|
460
|
+
return letter === expected;
|
|
461
|
+
}
|
|
462
|
+
/** Validate Italian Codice Fiscale using odd/even position lookup tables. */
|
|
463
|
+
function itCodiceFiscaleCheck(code) {
|
|
464
|
+
let cleaned = "";
|
|
465
|
+
for (const c of code) if (c >= "0" && c <= "9" || c >= "A" && c <= "Z" || c >= "a" && c <= "z") cleaned += c;
|
|
466
|
+
cleaned = cleaned.toUpperCase();
|
|
467
|
+
if (cleaned.length !== 16) return false;
|
|
468
|
+
let total = 0;
|
|
469
|
+
for (let i = 0; i < 15; i++) {
|
|
470
|
+
const c = cleaned[i];
|
|
471
|
+
const val = (i + 1) % 2 === 1 ? IT_ODD_TABLE[c] : IT_EVEN_TABLE[c];
|
|
472
|
+
if (val === void 0) return false;
|
|
473
|
+
total += val;
|
|
474
|
+
}
|
|
475
|
+
const expected = String.fromCharCode(total % 26 + "A".charCodeAt(0));
|
|
476
|
+
return cleaned[15] === expected;
|
|
477
|
+
}
|
|
478
|
+
/** Validate Portuguese NIF using weighted checksum. */
|
|
479
|
+
function ptNifChecksum(number) {
|
|
480
|
+
const digits = [];
|
|
481
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
482
|
+
if (digits.length !== 9) return false;
|
|
483
|
+
if (![
|
|
484
|
+
1,
|
|
485
|
+
2,
|
|
486
|
+
3,
|
|
487
|
+
5,
|
|
488
|
+
6,
|
|
489
|
+
8,
|
|
490
|
+
9
|
|
491
|
+
].includes(digits[0])) return false;
|
|
492
|
+
let total = 0;
|
|
493
|
+
for (let i = 0; i < 8; i++) total += digits[i] * (9 - i);
|
|
494
|
+
const remainder = total % 11;
|
|
495
|
+
const check = remainder < 2 ? 0 : 11 - remainder;
|
|
496
|
+
return digits[8] === check;
|
|
497
|
+
}
|
|
498
|
+
/** Validate Polish PESEL using weighted mod-10 checksum. */
|
|
499
|
+
function plPeselChecksum(number) {
|
|
500
|
+
const digits = [];
|
|
501
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
502
|
+
if (digits.length !== 11) return false;
|
|
503
|
+
const weights = [
|
|
504
|
+
1,
|
|
505
|
+
3,
|
|
506
|
+
7,
|
|
507
|
+
9,
|
|
508
|
+
1,
|
|
509
|
+
3,
|
|
510
|
+
7,
|
|
511
|
+
9,
|
|
512
|
+
1,
|
|
513
|
+
3
|
|
514
|
+
];
|
|
515
|
+
let total = 0;
|
|
516
|
+
for (let i = 0; i < 10; i++) total += digits[i] * weights[i];
|
|
517
|
+
const check = (10 - total % 10) % 10;
|
|
518
|
+
return digits[10] === check;
|
|
519
|
+
}
|
|
520
|
+
/** Validate Polish NIP using weighted mod-11 checksum. */
|
|
521
|
+
function plNipChecksum(number) {
|
|
522
|
+
const digits = [];
|
|
523
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
524
|
+
if (digits.length !== 10) return false;
|
|
525
|
+
const weights = [
|
|
526
|
+
6,
|
|
527
|
+
5,
|
|
528
|
+
7,
|
|
529
|
+
2,
|
|
530
|
+
3,
|
|
531
|
+
4,
|
|
532
|
+
5,
|
|
533
|
+
6,
|
|
534
|
+
7
|
|
535
|
+
];
|
|
536
|
+
let total = 0;
|
|
537
|
+
for (let i = 0; i < 9; i++) total += digits[i] * weights[i];
|
|
538
|
+
const check = total % 11;
|
|
539
|
+
if (check === 10) return false;
|
|
540
|
+
return digits[9] === check;
|
|
541
|
+
}
|
|
542
|
+
/** Validate Czech Birth Number: divisible by 11 + month check. */
|
|
543
|
+
function czBirthNumberValid(number) {
|
|
544
|
+
const cleaned = number.replace(/[/ ]/g, "");
|
|
545
|
+
for (const c of cleaned) if (c < "0" || c > "9") return false;
|
|
546
|
+
if (cleaned.length !== 9 && cleaned.length !== 10) return false;
|
|
547
|
+
if (cleaned.length === 10) {
|
|
548
|
+
let remainder = 0;
|
|
549
|
+
for (const c of cleaned) remainder = (remainder * 10 + parseInt(c, 10)) % 11;
|
|
550
|
+
if (remainder !== 0) return false;
|
|
551
|
+
}
|
|
552
|
+
const month = parseInt(cleaned.slice(2, 4), 10);
|
|
553
|
+
let baseMonth = month % 50;
|
|
554
|
+
if (baseMonth > 20) baseMonth -= 20;
|
|
555
|
+
if (baseMonth < 1 || baseMonth > 12) return false;
|
|
556
|
+
return true;
|
|
557
|
+
}
|
|
558
|
+
/** Validate Czech ICO (Company ID) using mod-11 weighted checksum. */
|
|
559
|
+
function czIcoChecksum(number) {
|
|
560
|
+
const digits = [];
|
|
561
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
562
|
+
if (digits.length !== 8) return false;
|
|
563
|
+
const weights = [
|
|
564
|
+
8,
|
|
565
|
+
7,
|
|
566
|
+
6,
|
|
567
|
+
5,
|
|
568
|
+
4,
|
|
569
|
+
3,
|
|
570
|
+
2
|
|
571
|
+
];
|
|
572
|
+
let total = 0;
|
|
573
|
+
for (let i = 0; i < 7; i++) total += digits[i] * weights[i];
|
|
574
|
+
const remainder = total % 11;
|
|
575
|
+
let check;
|
|
576
|
+
if (remainder === 0) check = 1;
|
|
577
|
+
else if (remainder === 1) check = 0;
|
|
578
|
+
else check = 11 - remainder;
|
|
579
|
+
return digits[7] === check;
|
|
580
|
+
}
|
|
581
|
+
/** Validate Czech DIC (Tax/VAT ID): CZ prefix + ICO or birth number checksum. */
|
|
582
|
+
function czDicValid(number) {
|
|
583
|
+
let cleaned = number.trim();
|
|
584
|
+
if (cleaned.toUpperCase().startsWith("CZ")) cleaned = cleaned.slice(2);
|
|
585
|
+
if (!/^\d+$/.test(cleaned)) return false;
|
|
586
|
+
if (cleaned.length === 8) return czIcoChecksum(cleaned);
|
|
587
|
+
if (cleaned.length === 10) {
|
|
588
|
+
let remainder = 0;
|
|
589
|
+
for (const c of cleaned) remainder = (remainder * 10 + parseInt(c, 10)) % 11;
|
|
590
|
+
return remainder === 0;
|
|
591
|
+
}
|
|
592
|
+
if (cleaned.length === 9) {
|
|
593
|
+
const month = parseInt(cleaned.slice(2, 4), 10);
|
|
594
|
+
let baseMonth = month % 50;
|
|
595
|
+
if (baseMonth > 20) baseMonth -= 20;
|
|
596
|
+
return baseMonth >= 1 && baseMonth <= 12;
|
|
597
|
+
}
|
|
598
|
+
return false;
|
|
599
|
+
}
|
|
600
|
+
/** Validate Czech bank account number using mod-11 weighted checksum. */
|
|
601
|
+
function czBankAccountValid(number) {
|
|
602
|
+
const parts = number.split("/");
|
|
603
|
+
if (parts.length !== 2) return false;
|
|
604
|
+
const bankCode = parts[1];
|
|
605
|
+
if (!/^\d{4}$/.test(bankCode)) return false;
|
|
606
|
+
const accountPart = parts[0];
|
|
607
|
+
let prefix = "";
|
|
608
|
+
let account = accountPart;
|
|
609
|
+
if (accountPart.includes("-")) {
|
|
610
|
+
const split = accountPart.split("-");
|
|
611
|
+
if (split.length !== 2) return false;
|
|
612
|
+
prefix = split[0];
|
|
613
|
+
account = split[1];
|
|
614
|
+
}
|
|
615
|
+
if (!/^\d{1,6}$/.test(prefix) && prefix !== "") return false;
|
|
616
|
+
if (!/^\d{2,10}$/.test(account)) return false;
|
|
617
|
+
const weights = [
|
|
618
|
+
6,
|
|
619
|
+
3,
|
|
620
|
+
7,
|
|
621
|
+
9,
|
|
622
|
+
10,
|
|
623
|
+
5,
|
|
624
|
+
8,
|
|
625
|
+
4,
|
|
626
|
+
2,
|
|
627
|
+
1
|
|
628
|
+
];
|
|
629
|
+
const accDigits = account.padStart(10, "0").split("").map(Number);
|
|
630
|
+
let total = 0;
|
|
631
|
+
for (let i = 0; i < 10; i++) total += accDigits[i] * weights[i];
|
|
632
|
+
if (total % 11 !== 0) return false;
|
|
633
|
+
if (prefix !== "") {
|
|
634
|
+
const prefDigits = prefix.padStart(6, "0").split("").map(Number);
|
|
635
|
+
const prefWeights = weights.slice(4);
|
|
636
|
+
let prefTotal = 0;
|
|
637
|
+
for (let i = 0; i < 6; i++) prefTotal += prefDigits[i] * prefWeights[i];
|
|
638
|
+
if (prefTotal % 11 !== 0) return false;
|
|
639
|
+
}
|
|
640
|
+
if (prefix === "" && account.length === 6 && czBirthNumberValid(number)) return false;
|
|
641
|
+
return true;
|
|
642
|
+
}
|
|
643
|
+
/** Validate Slovak Birth Number (same logic as Czech). */
|
|
644
|
+
function skBirthNumberValid(number) {
|
|
645
|
+
return czBirthNumberValid(number);
|
|
646
|
+
}
|
|
647
|
+
/** Validate Russian INN using weighted checksum (10 or 12 digits). */
|
|
648
|
+
function ruInnChecksum(number) {
|
|
649
|
+
const digits = [];
|
|
650
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
651
|
+
if (digits.length === 10) {
|
|
652
|
+
const weights = [
|
|
653
|
+
2,
|
|
654
|
+
4,
|
|
655
|
+
10,
|
|
656
|
+
3,
|
|
657
|
+
5,
|
|
658
|
+
9,
|
|
659
|
+
4,
|
|
660
|
+
6,
|
|
661
|
+
8
|
|
662
|
+
];
|
|
663
|
+
let total = 0;
|
|
664
|
+
for (let i = 0; i < 9; i++) total += digits[i] * weights[i];
|
|
665
|
+
return digits[9] === total % 11 % 10;
|
|
666
|
+
} else if (digits.length === 12) {
|
|
667
|
+
const weights1 = [
|
|
668
|
+
7,
|
|
669
|
+
2,
|
|
670
|
+
4,
|
|
671
|
+
10,
|
|
672
|
+
3,
|
|
673
|
+
5,
|
|
674
|
+
9,
|
|
675
|
+
4,
|
|
676
|
+
6,
|
|
677
|
+
8
|
|
678
|
+
];
|
|
679
|
+
let total1 = 0;
|
|
680
|
+
for (let i = 0; i < 10; i++) total1 += digits[i] * weights1[i];
|
|
681
|
+
const check1 = total1 % 11 % 10;
|
|
682
|
+
if (digits[10] !== check1) return false;
|
|
683
|
+
const weights2 = [
|
|
684
|
+
3,
|
|
685
|
+
7,
|
|
686
|
+
2,
|
|
687
|
+
4,
|
|
688
|
+
10,
|
|
689
|
+
3,
|
|
690
|
+
5,
|
|
691
|
+
9,
|
|
692
|
+
4,
|
|
693
|
+
6,
|
|
694
|
+
8
|
|
695
|
+
];
|
|
696
|
+
let total2 = 0;
|
|
697
|
+
for (let i = 0; i < 11; i++) total2 += digits[i] * weights2[i];
|
|
698
|
+
const check2 = total2 % 11 % 10;
|
|
699
|
+
return digits[11] === check2;
|
|
700
|
+
}
|
|
701
|
+
return false;
|
|
702
|
+
}
|
|
703
|
+
/** Validate Russian SNILS using mod-101 checksum. */
|
|
704
|
+
function ruSnilsChecksum(number) {
|
|
705
|
+
const digits = [];
|
|
706
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
707
|
+
if (digits.length !== 11) return false;
|
|
708
|
+
let base = 0;
|
|
709
|
+
for (let i = 0; i < 9; i++) base = base * 10 + digits[i];
|
|
710
|
+
if (base <= 1001998) return true;
|
|
711
|
+
let total = 0;
|
|
712
|
+
for (let i = 0; i < 9; i++) total += digits[i] * (9 - i);
|
|
713
|
+
let check = total % 101;
|
|
714
|
+
if (check === 100) check = 0;
|
|
715
|
+
const checkValue = digits[9] * 10 + digits[10];
|
|
716
|
+
return checkValue === check;
|
|
717
|
+
}
|
|
718
|
+
/** Validate Dutch BSN using the 11-test. */
|
|
719
|
+
function nlBsn11test(number) {
|
|
720
|
+
const digits = [];
|
|
721
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
722
|
+
if (digits.length !== 9) return false;
|
|
723
|
+
let total = 0;
|
|
724
|
+
for (let i = 0; i < 8; i++) total += digits[i] * (9 - i);
|
|
725
|
+
total -= digits[8];
|
|
726
|
+
return total % 11 === 0 && total !== 0;
|
|
727
|
+
}
|
|
728
|
+
/** Validate Romanian CNP using weighted checksum. */
|
|
729
|
+
function roCnpChecksum(number) {
|
|
730
|
+
const digits = [];
|
|
731
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
732
|
+
if (digits.length !== 13) return false;
|
|
733
|
+
if (digits[0] < 1 || digits[0] > 8) return false;
|
|
734
|
+
const weights = [
|
|
735
|
+
2,
|
|
736
|
+
7,
|
|
737
|
+
9,
|
|
738
|
+
1,
|
|
739
|
+
4,
|
|
740
|
+
6,
|
|
741
|
+
3,
|
|
742
|
+
5,
|
|
743
|
+
8,
|
|
744
|
+
2,
|
|
745
|
+
7,
|
|
746
|
+
9
|
|
747
|
+
];
|
|
748
|
+
let total = 0;
|
|
749
|
+
for (let i = 0; i < 12; i++) total += digits[i] * weights[i];
|
|
750
|
+
let check = total % 11;
|
|
751
|
+
if (check === 10) check = 1;
|
|
752
|
+
return digits[12] === check;
|
|
753
|
+
}
|
|
754
|
+
/** Validate Danish CPR number by checking the date portion. */
|
|
755
|
+
function dkCprValidDate(number) {
|
|
756
|
+
let digits = "";
|
|
757
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
758
|
+
if (digits.length !== 10) return false;
|
|
759
|
+
const day = parseInt(digits.slice(0, 2), 10);
|
|
760
|
+
const month = parseInt(digits.slice(2, 4), 10);
|
|
761
|
+
if (day < 1 || day > 31) return false;
|
|
762
|
+
if (month < 1 || month > 12) return false;
|
|
763
|
+
return true;
|
|
764
|
+
}
|
|
765
|
+
/** Validate Swedish Personnummer using Luhn on last 10 digits. */
|
|
766
|
+
function sePersonnummerLuhn(number) {
|
|
767
|
+
let digitsStr = "";
|
|
768
|
+
for (const c of number) if (c >= "0" && c <= "9") digitsStr += c;
|
|
769
|
+
if (digitsStr.length === 12) digitsStr = digitsStr.slice(2);
|
|
770
|
+
if (digitsStr.length !== 10) return false;
|
|
771
|
+
const month = parseInt(digitsStr.slice(2, 4), 10);
|
|
772
|
+
const day = parseInt(digitsStr.slice(4, 6), 10);
|
|
773
|
+
if (month < 1 || month > 12) return false;
|
|
774
|
+
if (day < 1 || day > 31) return false;
|
|
775
|
+
return luhnChecksum(digitsStr);
|
|
776
|
+
}
|
|
777
|
+
/** Validate Norwegian Birth Number using dual weighted checksums. */
|
|
778
|
+
function noBirthNumberChecksum(number) {
|
|
779
|
+
const digits = [];
|
|
780
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
781
|
+
if (digits.length !== 11) return false;
|
|
782
|
+
const weights1 = [
|
|
783
|
+
3,
|
|
784
|
+
7,
|
|
785
|
+
6,
|
|
786
|
+
1,
|
|
787
|
+
8,
|
|
788
|
+
9,
|
|
789
|
+
4,
|
|
790
|
+
5,
|
|
791
|
+
2
|
|
792
|
+
];
|
|
793
|
+
let total1 = 0;
|
|
794
|
+
for (let i = 0; i < 9; i++) total1 += digits[i] * weights1[i];
|
|
795
|
+
let check1 = 11 - total1 % 11;
|
|
796
|
+
if (check1 === 11) check1 = 0;
|
|
797
|
+
if (check1 === 10) return false;
|
|
798
|
+
if (digits[9] !== check1) return false;
|
|
799
|
+
const weights2 = [
|
|
800
|
+
5,
|
|
801
|
+
4,
|
|
802
|
+
3,
|
|
803
|
+
2,
|
|
804
|
+
7,
|
|
805
|
+
6,
|
|
806
|
+
5,
|
|
807
|
+
4,
|
|
808
|
+
3,
|
|
809
|
+
2
|
|
810
|
+
];
|
|
811
|
+
let total2 = 0;
|
|
812
|
+
for (let i = 0; i < 10; i++) total2 += digits[i] * weights2[i];
|
|
813
|
+
let check2 = 11 - total2 % 11;
|
|
814
|
+
if (check2 === 11) check2 = 0;
|
|
815
|
+
if (check2 === 10) return false;
|
|
816
|
+
return digits[10] === check2;
|
|
817
|
+
}
|
|
818
|
+
/** Validate Brazilian CPF using weighted mod-11 checksum. */
|
|
819
|
+
function brCpfChecksum(number) {
|
|
820
|
+
const digits = [];
|
|
821
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
822
|
+
if (digits.length !== 11) return false;
|
|
823
|
+
if (new Set(digits).size === 1) return false;
|
|
824
|
+
let total1 = 0;
|
|
825
|
+
for (let i = 0; i < 9; i++) total1 += digits[i] * (10 - i);
|
|
826
|
+
let check1 = total1 * 10 % 11;
|
|
827
|
+
if (check1 === 10) check1 = 0;
|
|
828
|
+
if (digits[9] !== check1) return false;
|
|
829
|
+
let total2 = 0;
|
|
830
|
+
for (let i = 0; i < 10; i++) total2 += digits[i] * (11 - i);
|
|
831
|
+
let check2 = total2 * 10 % 11;
|
|
832
|
+
if (check2 === 10) check2 = 0;
|
|
833
|
+
return digits[10] === check2;
|
|
834
|
+
}
|
|
835
|
+
/** Validate Brazilian CNPJ using weighted mod-11 checksum. */
|
|
836
|
+
function brCnpjChecksum(number) {
|
|
837
|
+
const digits = [];
|
|
838
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
839
|
+
if (digits.length !== 14) return false;
|
|
840
|
+
const weights1 = [
|
|
841
|
+
5,
|
|
842
|
+
4,
|
|
843
|
+
3,
|
|
844
|
+
2,
|
|
845
|
+
9,
|
|
846
|
+
8,
|
|
847
|
+
7,
|
|
848
|
+
6,
|
|
849
|
+
5,
|
|
850
|
+
4,
|
|
851
|
+
3,
|
|
852
|
+
2
|
|
853
|
+
];
|
|
854
|
+
let total1 = 0;
|
|
855
|
+
for (let i = 0; i < 12; i++) total1 += digits[i] * weights1[i];
|
|
856
|
+
let check1 = total1 % 11;
|
|
857
|
+
check1 = check1 < 2 ? 0 : 11 - check1;
|
|
858
|
+
if (digits[12] !== check1) return false;
|
|
859
|
+
const weights2 = [
|
|
860
|
+
6,
|
|
861
|
+
5,
|
|
862
|
+
4,
|
|
863
|
+
3,
|
|
864
|
+
2,
|
|
865
|
+
9,
|
|
866
|
+
8,
|
|
867
|
+
7,
|
|
868
|
+
6,
|
|
869
|
+
5,
|
|
870
|
+
4,
|
|
871
|
+
3,
|
|
872
|
+
2
|
|
873
|
+
];
|
|
874
|
+
let total2 = 0;
|
|
875
|
+
for (let i = 0; i < 13; i++) total2 += digits[i] * weights2[i];
|
|
876
|
+
let check2 = total2 % 11;
|
|
877
|
+
check2 = check2 < 2 ? 0 : 11 - check2;
|
|
878
|
+
return digits[13] === check2;
|
|
879
|
+
}
|
|
880
|
+
/** Validate US ITIN format: 9XX-[7X|8X|9X|70-88]-XXXX. */
|
|
881
|
+
function usItinValid(number) {
|
|
882
|
+
let digits = "";
|
|
883
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
884
|
+
if (digits.length !== 9) return false;
|
|
885
|
+
if (digits[0] !== "9") return false;
|
|
886
|
+
const d4 = parseInt(digits[3], 10);
|
|
887
|
+
if (d4 < 7) return false;
|
|
888
|
+
return true;
|
|
889
|
+
}
|
|
890
|
+
/** Validate UK UTR using mod-11 weighted checksum. */
|
|
891
|
+
function ukUtrChecksum(number) {
|
|
892
|
+
const digits = [];
|
|
893
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
894
|
+
if (digits.length !== 10) return false;
|
|
895
|
+
const weights = [
|
|
896
|
+
6,
|
|
897
|
+
7,
|
|
898
|
+
8,
|
|
899
|
+
9,
|
|
900
|
+
10,
|
|
901
|
+
5,
|
|
902
|
+
4,
|
|
903
|
+
3,
|
|
904
|
+
2
|
|
905
|
+
];
|
|
906
|
+
let total = 0;
|
|
907
|
+
for (let i = 0; i < 9; i++) total += digits[i + 1] * weights[i];
|
|
908
|
+
const remainder = total % 11;
|
|
909
|
+
const check = 11 - remainder === 10 ? 0 : 11 - remainder;
|
|
910
|
+
return digits[0] === check || 11 - remainder === 11 && digits[0] === 0;
|
|
911
|
+
}
|
|
912
|
+
/** Validate Spanish NSS using mod-97 checksum. */
|
|
913
|
+
function esNssChecksum(number) {
|
|
914
|
+
let digits = "";
|
|
915
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
916
|
+
if (digits.length !== 12) return false;
|
|
917
|
+
const province = parseInt(digits.slice(0, 2), 10);
|
|
918
|
+
if (province < 1 || province > 53) return false;
|
|
919
|
+
const baseNum = parseInt(digits.slice(0, 10), 10);
|
|
920
|
+
const check = parseInt(digits.slice(10, 12), 10);
|
|
921
|
+
return baseNum % 97 === check;
|
|
922
|
+
}
|
|
923
|
+
/** Validate Spanish CIF using custom checksum. */
|
|
924
|
+
function esCifChecksum(number) {
|
|
925
|
+
let cleaned = "";
|
|
926
|
+
for (const c of number) if (c >= "0" && c <= "9" || c >= "A" && c <= "Z" || c >= "a" && c <= "z") cleaned += c;
|
|
927
|
+
cleaned = cleaned.toUpperCase();
|
|
928
|
+
if (cleaned.length !== 9) return false;
|
|
929
|
+
const letter = cleaned[0];
|
|
930
|
+
if (!"ABCDEFGHJNPQRSUVW".includes(letter)) return false;
|
|
931
|
+
let totalEven = 0;
|
|
932
|
+
let totalOdd = 0;
|
|
933
|
+
for (let i = 1; i <= 7; i++) {
|
|
934
|
+
const d = parseInt(cleaned[i], 10);
|
|
935
|
+
if (isNaN(d)) return false;
|
|
936
|
+
if (i % 2 === 0) totalEven += d;
|
|
937
|
+
else {
|
|
938
|
+
const doubled = d * 2;
|
|
939
|
+
totalOdd += Math.floor(doubled / 10) + doubled % 10;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
const total = totalEven + totalOdd;
|
|
943
|
+
const checkDigit = (10 - total % 10) % 10;
|
|
944
|
+
const control = cleaned[8];
|
|
945
|
+
if ("KPQS".includes(letter)) return control === String.fromCharCode("A".charCodeAt(0) + checkDigit);
|
|
946
|
+
if ("ABEH".includes(letter)) return control === String(checkDigit);
|
|
947
|
+
return control === String(checkDigit) || control === String.fromCharCode("A".charCodeAt(0) + checkDigit);
|
|
948
|
+
}
|
|
949
|
+
/** Validate Italian Partita IVA using Luhn-like algorithm. */
|
|
950
|
+
function itPartitaIvaChecksum(number) {
|
|
951
|
+
const digits = [];
|
|
952
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
953
|
+
if (digits.length !== 11) return false;
|
|
954
|
+
if (digits.every((d) => d === 0)) return false;
|
|
955
|
+
let total = 0;
|
|
956
|
+
for (let i = 0; i < 10; i++) if (i % 2 === 0) total += digits[i];
|
|
957
|
+
else {
|
|
958
|
+
const doubled = digits[i] * 2;
|
|
959
|
+
total += doubled > 9 ? doubled - 9 : doubled;
|
|
960
|
+
}
|
|
961
|
+
const check = (10 - total % 10) % 10;
|
|
962
|
+
return digits[10] === check;
|
|
963
|
+
}
|
|
964
|
+
/** Validate Polish REGON using mod-11 weighted checksum (9 or 14 digits). */
|
|
965
|
+
function plRegonChecksum(number) {
|
|
966
|
+
const digits = [];
|
|
967
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
968
|
+
if (digits.length === 9) {
|
|
969
|
+
const weights = [
|
|
970
|
+
8,
|
|
971
|
+
9,
|
|
972
|
+
2,
|
|
973
|
+
3,
|
|
974
|
+
4,
|
|
975
|
+
5,
|
|
976
|
+
6,
|
|
977
|
+
7
|
|
978
|
+
];
|
|
979
|
+
let total = 0;
|
|
980
|
+
for (let i = 0; i < 8; i++) total += digits[i] * weights[i];
|
|
981
|
+
const check = total % 11 === 10 ? 0 : total % 11;
|
|
982
|
+
return digits[8] === check;
|
|
983
|
+
}
|
|
984
|
+
if (digits.length === 14) {
|
|
985
|
+
const weights9 = [
|
|
986
|
+
8,
|
|
987
|
+
9,
|
|
988
|
+
2,
|
|
989
|
+
3,
|
|
990
|
+
4,
|
|
991
|
+
5,
|
|
992
|
+
6,
|
|
993
|
+
7
|
|
994
|
+
];
|
|
995
|
+
let total9 = 0;
|
|
996
|
+
for (let i = 0; i < 8; i++) total9 += digits[i] * weights9[i];
|
|
997
|
+
const check9 = total9 % 11 === 10 ? 0 : total9 % 11;
|
|
998
|
+
if (digits[8] !== check9) return false;
|
|
999
|
+
const weights14 = [
|
|
1000
|
+
2,
|
|
1001
|
+
4,
|
|
1002
|
+
8,
|
|
1003
|
+
5,
|
|
1004
|
+
0,
|
|
1005
|
+
9,
|
|
1006
|
+
7,
|
|
1007
|
+
3,
|
|
1008
|
+
6,
|
|
1009
|
+
1,
|
|
1010
|
+
2,
|
|
1011
|
+
4,
|
|
1012
|
+
8
|
|
1013
|
+
];
|
|
1014
|
+
let total14 = 0;
|
|
1015
|
+
for (let i = 0; i < 13; i++) total14 += digits[i] * weights14[i];
|
|
1016
|
+
const check14 = total14 % 11 === 10 ? 0 : total14 % 11;
|
|
1017
|
+
return digits[13] === check14;
|
|
1018
|
+
}
|
|
1019
|
+
return false;
|
|
1020
|
+
}
|
|
1021
|
+
/** Validate Slovak ICO using same algorithm as Czech ICO. */
|
|
1022
|
+
function skIcoChecksum(number) {
|
|
1023
|
+
return czIcoChecksum(number);
|
|
1024
|
+
}
|
|
1025
|
+
/** Validate Slovak DIC: SK prefix + digits divisible by 11. */
|
|
1026
|
+
function skDicValid(number) {
|
|
1027
|
+
let cleaned = number.trim();
|
|
1028
|
+
if (cleaned.toUpperCase().startsWith("SK")) cleaned = cleaned.slice(2);
|
|
1029
|
+
if (!/^\d{10}$/.test(cleaned)) return false;
|
|
1030
|
+
let remainder = 0;
|
|
1031
|
+
for (const c of cleaned) remainder = (remainder * 10 + parseInt(c, 10)) % 11;
|
|
1032
|
+
return remainder === 0;
|
|
1033
|
+
}
|
|
1034
|
+
/** Validate Romanian CUI using mod-11 weighted checksum. */
|
|
1035
|
+
function roCuiChecksum(number) {
|
|
1036
|
+
let cleaned = number.trim().toUpperCase();
|
|
1037
|
+
if (cleaned.startsWith("RO")) cleaned = cleaned.slice(2);
|
|
1038
|
+
const digits = [];
|
|
1039
|
+
for (const c of cleaned) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1040
|
+
if (digits.length < 2 || digits.length > 10) return false;
|
|
1041
|
+
const weights = [
|
|
1042
|
+
7,
|
|
1043
|
+
5,
|
|
1044
|
+
3,
|
|
1045
|
+
2,
|
|
1046
|
+
1,
|
|
1047
|
+
7,
|
|
1048
|
+
5,
|
|
1049
|
+
3,
|
|
1050
|
+
2
|
|
1051
|
+
];
|
|
1052
|
+
const padded = Array(10 - digits.length).fill(0).concat(digits);
|
|
1053
|
+
const check = padded.pop();
|
|
1054
|
+
let total = 0;
|
|
1055
|
+
for (let i = 0; i < 9; i++) total += padded[i] * weights[i];
|
|
1056
|
+
const expected = total * 10 % 11 === 10 ? 0 : total * 10 % 11;
|
|
1057
|
+
return check === expected;
|
|
1058
|
+
}
|
|
1059
|
+
/** Validate Danish CVR using mod-11 weighted checksum. */
|
|
1060
|
+
function dkCvrChecksum(number) {
|
|
1061
|
+
const digits = [];
|
|
1062
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1063
|
+
if (digits.length !== 8) return false;
|
|
1064
|
+
const weights = [
|
|
1065
|
+
2,
|
|
1066
|
+
7,
|
|
1067
|
+
6,
|
|
1068
|
+
5,
|
|
1069
|
+
4,
|
|
1070
|
+
3,
|
|
1071
|
+
2,
|
|
1072
|
+
1
|
|
1073
|
+
];
|
|
1074
|
+
let total = 0;
|
|
1075
|
+
for (let i = 0; i < 8; i++) total += digits[i] * weights[i];
|
|
1076
|
+
return total % 11 === 0;
|
|
1077
|
+
}
|
|
1078
|
+
/** Validate Swedish Organisationsnummer using Luhn on 10 digits. */
|
|
1079
|
+
function seOrgnrChecksum(number) {
|
|
1080
|
+
let digits = "";
|
|
1081
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
1082
|
+
if (digits.length !== 10) return false;
|
|
1083
|
+
const d3 = parseInt(digits[2], 10);
|
|
1084
|
+
if (d3 < 2) return false;
|
|
1085
|
+
return luhnChecksum(digits);
|
|
1086
|
+
}
|
|
1087
|
+
/** Validate Norwegian Organisasjonsnummer using mod-11 weighted checksum. */
|
|
1088
|
+
function noOrgnrChecksum(number) {
|
|
1089
|
+
const digits = [];
|
|
1090
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1091
|
+
if (digits.length !== 9) return false;
|
|
1092
|
+
const weights = [
|
|
1093
|
+
3,
|
|
1094
|
+
2,
|
|
1095
|
+
7,
|
|
1096
|
+
6,
|
|
1097
|
+
5,
|
|
1098
|
+
4,
|
|
1099
|
+
3,
|
|
1100
|
+
2
|
|
1101
|
+
];
|
|
1102
|
+
let total = 0;
|
|
1103
|
+
for (let i = 0; i < 8; i++) total += digits[i] * weights[i];
|
|
1104
|
+
const remainder = total % 11;
|
|
1105
|
+
if (remainder === 1) return false;
|
|
1106
|
+
const check = remainder === 0 ? 0 : 11 - remainder;
|
|
1107
|
+
return digits[8] === check;
|
|
1108
|
+
}
|
|
1109
|
+
/** Validate Belgian National Number using mod-97 checksum. */
|
|
1110
|
+
function beNationalNumberChecksum(number) {
|
|
1111
|
+
let digits = "";
|
|
1112
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
1113
|
+
if (digits.length !== 11) return false;
|
|
1114
|
+
const base = parseInt(digits.slice(0, 9), 10);
|
|
1115
|
+
const check = parseInt(digits.slice(9, 11), 10);
|
|
1116
|
+
if (97 - base % 97 === check) return true;
|
|
1117
|
+
const base2000 = parseInt("2" + digits.slice(0, 9), 10);
|
|
1118
|
+
return 97 - base2000 % 97 === check;
|
|
1119
|
+
}
|
|
1120
|
+
/** Validate Belgian Enterprise Number using mod-97 checksum. */
|
|
1121
|
+
function beEnterpriseChecksum(number) {
|
|
1122
|
+
let digits = "";
|
|
1123
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
1124
|
+
if (digits.length !== 10) return false;
|
|
1125
|
+
if (digits[0] !== "0" && digits[0] !== "1") return false;
|
|
1126
|
+
const base = parseInt(digits.slice(0, 8), 10);
|
|
1127
|
+
const check = parseInt(digits.slice(8, 10), 10);
|
|
1128
|
+
return 97 - base % 97 === check;
|
|
1129
|
+
}
|
|
1130
|
+
/** Validate Austrian SVNR (Social Insurance Number). */
|
|
1131
|
+
function atSvnrChecksum(number) {
|
|
1132
|
+
const digits = [];
|
|
1133
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1134
|
+
if (digits.length !== 10) return false;
|
|
1135
|
+
const weights = [
|
|
1136
|
+
3,
|
|
1137
|
+
7,
|
|
1138
|
+
9,
|
|
1139
|
+
0,
|
|
1140
|
+
5,
|
|
1141
|
+
8,
|
|
1142
|
+
4,
|
|
1143
|
+
2,
|
|
1144
|
+
1,
|
|
1145
|
+
6
|
|
1146
|
+
];
|
|
1147
|
+
let total = 0;
|
|
1148
|
+
for (let i = 0; i < 10; i++) total += digits[i] * weights[i];
|
|
1149
|
+
return total % 11 === digits[3];
|
|
1150
|
+
}
|
|
1151
|
+
/** Validate Irish PPS Number using mod-23 checksum. */
|
|
1152
|
+
function iePpsChecksum(number) {
|
|
1153
|
+
let cleaned = "";
|
|
1154
|
+
for (const c of number) if (c >= "0" && c <= "9" || c >= "A" && c <= "Z" || c >= "a" && c <= "z") cleaned += c;
|
|
1155
|
+
cleaned = cleaned.toUpperCase();
|
|
1156
|
+
if (cleaned.length < 8 || cleaned.length > 9) return false;
|
|
1157
|
+
let total = 0;
|
|
1158
|
+
for (let i = 0; i < 7; i++) {
|
|
1159
|
+
const d = parseInt(cleaned[i], 10);
|
|
1160
|
+
if (isNaN(d)) return false;
|
|
1161
|
+
total += d * (8 - i);
|
|
1162
|
+
}
|
|
1163
|
+
if (cleaned.length === 9 && cleaned[8] >= "A" && cleaned[8] <= "Z") total += (cleaned[8].charCodeAt(0) - 64) * 9;
|
|
1164
|
+
const remainder = total % 23;
|
|
1165
|
+
const expected = remainder === 0 ? "W" : String.fromCharCode("A".charCodeAt(0) + remainder - 1);
|
|
1166
|
+
return cleaned[7] === expected;
|
|
1167
|
+
}
|
|
1168
|
+
/** Validate Finnish HETU (Personal Identity Code) using mod-31 checksum. */
|
|
1169
|
+
function fiHetuChecksum(number) {
|
|
1170
|
+
let cleaned = number.replace(/[\s-]/g, "");
|
|
1171
|
+
if (cleaned.length !== 11) cleaned = number.trim();
|
|
1172
|
+
if (cleaned.length !== 11) return false;
|
|
1173
|
+
const datePart = cleaned.slice(0, 6);
|
|
1174
|
+
for (const c of datePart) if (c < "0" || c > "9") return false;
|
|
1175
|
+
const sep = cleaned[6];
|
|
1176
|
+
if (!"-+ABCDEFYXWVU".includes(sep)) return false;
|
|
1177
|
+
const numPart = cleaned.slice(7, 10);
|
|
1178
|
+
for (const c of numPart) if (c < "0" || c > "9") return false;
|
|
1179
|
+
const checkChars = "0123456789ABCDEFHJKLMNPRSTUVWXY";
|
|
1180
|
+
const combined = parseInt(datePart + numPart, 10);
|
|
1181
|
+
const expected = checkChars[combined % 31];
|
|
1182
|
+
return cleaned[10].toUpperCase() === expected;
|
|
1183
|
+
}
|
|
1184
|
+
/** Validate Finnish Y-tunnus (Business ID) using mod-11 weighted checksum. */
|
|
1185
|
+
function fiYtunnusChecksum(number) {
|
|
1186
|
+
let digits = "";
|
|
1187
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
1188
|
+
if (digits.length !== 8) return false;
|
|
1189
|
+
const weights = [
|
|
1190
|
+
7,
|
|
1191
|
+
9,
|
|
1192
|
+
10,
|
|
1193
|
+
5,
|
|
1194
|
+
8,
|
|
1195
|
+
4,
|
|
1196
|
+
2
|
|
1197
|
+
];
|
|
1198
|
+
let total = 0;
|
|
1199
|
+
for (let i = 0; i < 7; i++) total += parseInt(digits[i], 10) * weights[i];
|
|
1200
|
+
const remainder = total % 11;
|
|
1201
|
+
if (remainder === 1) return false;
|
|
1202
|
+
const check = remainder === 0 ? 0 : 11 - remainder;
|
|
1203
|
+
return parseInt(digits[7], 10) === check;
|
|
1204
|
+
}
|
|
1205
|
+
/** Validate Hungarian Tax ID using mod-11 weighted checksum. */
|
|
1206
|
+
function huTaxIdChecksum(number) {
|
|
1207
|
+
const digits = [];
|
|
1208
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1209
|
+
if (digits.length !== 10) return false;
|
|
1210
|
+
if (digits[0] !== 8) return false;
|
|
1211
|
+
const weights = [
|
|
1212
|
+
1,
|
|
1213
|
+
2,
|
|
1214
|
+
3,
|
|
1215
|
+
4,
|
|
1216
|
+
5,
|
|
1217
|
+
6,
|
|
1218
|
+
7,
|
|
1219
|
+
8,
|
|
1220
|
+
9
|
|
1221
|
+
];
|
|
1222
|
+
let total = 0;
|
|
1223
|
+
for (let i = 0; i < 9; i++) total += digits[i] * weights[i];
|
|
1224
|
+
return digits[9] === total % 11;
|
|
1225
|
+
}
|
|
1226
|
+
/** Validate Hungarian TAJ (Social Security) using mod-10 with 3/7 weights. */
|
|
1227
|
+
function huTajChecksum(number) {
|
|
1228
|
+
const digits = [];
|
|
1229
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1230
|
+
if (digits.length !== 9) return false;
|
|
1231
|
+
let total = 0;
|
|
1232
|
+
for (let i = 0; i < 8; i++) total += digits[i] * (i % 2 === 0 ? 3 : 7);
|
|
1233
|
+
return digits[8] === total % 10;
|
|
1234
|
+
}
|
|
1235
|
+
/** Validate Bulgarian EGN using weighted mod-11 checksum. */
|
|
1236
|
+
function bgEgnChecksum(number) {
|
|
1237
|
+
const digits = [];
|
|
1238
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1239
|
+
if (digits.length !== 10) return false;
|
|
1240
|
+
const month = parseInt(number.slice(2, 4), 10);
|
|
1241
|
+
const baseMonth = month > 40 ? month - 40 : month > 20 ? month - 20 : month;
|
|
1242
|
+
if (baseMonth < 1 || baseMonth > 12) return false;
|
|
1243
|
+
const weights = [
|
|
1244
|
+
2,
|
|
1245
|
+
4,
|
|
1246
|
+
8,
|
|
1247
|
+
5,
|
|
1248
|
+
10,
|
|
1249
|
+
9,
|
|
1250
|
+
7,
|
|
1251
|
+
3,
|
|
1252
|
+
6
|
|
1253
|
+
];
|
|
1254
|
+
let total = 0;
|
|
1255
|
+
for (let i = 0; i < 9; i++) total += digits[i] * weights[i];
|
|
1256
|
+
let check = total % 11;
|
|
1257
|
+
if (check === 10) check = 0;
|
|
1258
|
+
return digits[9] === check;
|
|
1259
|
+
}
|
|
1260
|
+
/** Validate Croatian OIB using ISO 7064 MOD 11,2. */
|
|
1261
|
+
function hrOibChecksum(number) {
|
|
1262
|
+
const digits = [];
|
|
1263
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1264
|
+
if (digits.length !== 11) return false;
|
|
1265
|
+
let remainder = 10;
|
|
1266
|
+
for (let i = 0; i < 10; i++) {
|
|
1267
|
+
remainder = (remainder + digits[i]) % 10;
|
|
1268
|
+
if (remainder === 0) remainder = 10;
|
|
1269
|
+
remainder = remainder * 2 % 11;
|
|
1270
|
+
}
|
|
1271
|
+
let check = 11 - remainder;
|
|
1272
|
+
if (check === 10) check = 0;
|
|
1273
|
+
return digits[10] === check;
|
|
1274
|
+
}
|
|
1275
|
+
/** Validate Slovenian EMSO using mod-11 weighted checksum. */
|
|
1276
|
+
function siEmsoChecksum(number) {
|
|
1277
|
+
const digits = [];
|
|
1278
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1279
|
+
if (digits.length !== 13) return false;
|
|
1280
|
+
const weights = [
|
|
1281
|
+
7,
|
|
1282
|
+
6,
|
|
1283
|
+
5,
|
|
1284
|
+
4,
|
|
1285
|
+
3,
|
|
1286
|
+
2,
|
|
1287
|
+
7,
|
|
1288
|
+
6,
|
|
1289
|
+
5,
|
|
1290
|
+
4,
|
|
1291
|
+
3,
|
|
1292
|
+
2
|
|
1293
|
+
];
|
|
1294
|
+
let total = 0;
|
|
1295
|
+
for (let i = 0; i < 12; i++) total += digits[i] * weights[i];
|
|
1296
|
+
const remainder = total % 11;
|
|
1297
|
+
const check = remainder === 0 ? 0 : 11 - remainder;
|
|
1298
|
+
if (check === 10) return false;
|
|
1299
|
+
return digits[12] === check;
|
|
1300
|
+
}
|
|
1301
|
+
/** Validate Slovenian Tax Number using mod-11. */
|
|
1302
|
+
function siTaxNumberChecksum(number) {
|
|
1303
|
+
let cleaned = number.trim().toUpperCase();
|
|
1304
|
+
if (cleaned.startsWith("SI")) cleaned = cleaned.slice(2);
|
|
1305
|
+
const digits = [];
|
|
1306
|
+
for (const c of cleaned) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1307
|
+
if (digits.length !== 8) return false;
|
|
1308
|
+
const weights = [
|
|
1309
|
+
8,
|
|
1310
|
+
7,
|
|
1311
|
+
6,
|
|
1312
|
+
5,
|
|
1313
|
+
4,
|
|
1314
|
+
3,
|
|
1315
|
+
2
|
|
1316
|
+
];
|
|
1317
|
+
let total = 0;
|
|
1318
|
+
for (let i = 0; i < 7; i++) total += digits[i] * weights[i];
|
|
1319
|
+
const remainder = total % 11;
|
|
1320
|
+
if (remainder === 0 || remainder === 1) return digits[7] === 0;
|
|
1321
|
+
return digits[7] === 11 - remainder;
|
|
1322
|
+
}
|
|
1323
|
+
/** Validate Lithuanian Personal Code using dual-pass mod-11 checksum. */
|
|
1324
|
+
function ltPersonalCodeChecksum(number) {
|
|
1325
|
+
const digits = [];
|
|
1326
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1327
|
+
if (digits.length !== 11) return false;
|
|
1328
|
+
if (digits[0] < 1 || digits[0] > 6) return false;
|
|
1329
|
+
const weights1 = [
|
|
1330
|
+
1,
|
|
1331
|
+
2,
|
|
1332
|
+
3,
|
|
1333
|
+
4,
|
|
1334
|
+
5,
|
|
1335
|
+
6,
|
|
1336
|
+
7,
|
|
1337
|
+
8,
|
|
1338
|
+
9,
|
|
1339
|
+
1
|
|
1340
|
+
];
|
|
1341
|
+
let total = 0;
|
|
1342
|
+
for (let i = 0; i < 10; i++) total += digits[i] * weights1[i];
|
|
1343
|
+
let check = total % 11;
|
|
1344
|
+
if (check === 10) {
|
|
1345
|
+
const weights2 = [
|
|
1346
|
+
3,
|
|
1347
|
+
4,
|
|
1348
|
+
5,
|
|
1349
|
+
6,
|
|
1350
|
+
7,
|
|
1351
|
+
8,
|
|
1352
|
+
9,
|
|
1353
|
+
1,
|
|
1354
|
+
2,
|
|
1355
|
+
3
|
|
1356
|
+
];
|
|
1357
|
+
total = 0;
|
|
1358
|
+
for (let i = 0; i < 10; i++) total += digits[i] * weights2[i];
|
|
1359
|
+
check = total % 11;
|
|
1360
|
+
if (check === 10) check = 0;
|
|
1361
|
+
}
|
|
1362
|
+
return digits[10] === check;
|
|
1363
|
+
}
|
|
1364
|
+
/** Validate Latvian Personal Code (old format with checksum). */
|
|
1365
|
+
function lvPersonalCodeChecksum(number) {
|
|
1366
|
+
let digits = "";
|
|
1367
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
1368
|
+
if (digits.length !== 11) return false;
|
|
1369
|
+
const day = parseInt(digits.slice(0, 2), 10);
|
|
1370
|
+
const month = parseInt(digits.slice(2, 4), 10);
|
|
1371
|
+
if (digits[0] === "3" && digits[1] === "2") return true;
|
|
1372
|
+
if (day < 1 || day > 31) return false;
|
|
1373
|
+
if (month < 1 || month > 12) return false;
|
|
1374
|
+
const weights = [
|
|
1375
|
+
1,
|
|
1376
|
+
6,
|
|
1377
|
+
3,
|
|
1378
|
+
7,
|
|
1379
|
+
9,
|
|
1380
|
+
10,
|
|
1381
|
+
5,
|
|
1382
|
+
8,
|
|
1383
|
+
4,
|
|
1384
|
+
2
|
|
1385
|
+
];
|
|
1386
|
+
let total = 0;
|
|
1387
|
+
for (let i = 0; i < 10; i++) total += parseInt(digits[i], 10) * weights[i];
|
|
1388
|
+
const check = (1101 - total) % 11 % 10;
|
|
1389
|
+
return parseInt(digits[10], 10) === check;
|
|
1390
|
+
}
|
|
1391
|
+
/** Validate Estonian Personal Code using dual-pass mod-11 checksum. */
|
|
1392
|
+
function eePersonalCodeChecksum(number) {
|
|
1393
|
+
const digits = [];
|
|
1394
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1395
|
+
if (digits.length !== 11) return false;
|
|
1396
|
+
if (digits[0] < 1 || digits[0] > 6) return false;
|
|
1397
|
+
const weights1 = [
|
|
1398
|
+
1,
|
|
1399
|
+
2,
|
|
1400
|
+
3,
|
|
1401
|
+
4,
|
|
1402
|
+
5,
|
|
1403
|
+
6,
|
|
1404
|
+
7,
|
|
1405
|
+
8,
|
|
1406
|
+
9,
|
|
1407
|
+
1
|
|
1408
|
+
];
|
|
1409
|
+
let total = 0;
|
|
1410
|
+
for (let i = 0; i < 10; i++) total += digits[i] * weights1[i];
|
|
1411
|
+
let check = total % 11;
|
|
1412
|
+
if (check === 10) {
|
|
1413
|
+
const weights2 = [
|
|
1414
|
+
3,
|
|
1415
|
+
4,
|
|
1416
|
+
5,
|
|
1417
|
+
6,
|
|
1418
|
+
7,
|
|
1419
|
+
8,
|
|
1420
|
+
9,
|
|
1421
|
+
1,
|
|
1422
|
+
2,
|
|
1423
|
+
3
|
|
1424
|
+
];
|
|
1425
|
+
total = 0;
|
|
1426
|
+
for (let i = 0; i < 10; i++) total += digits[i] * weights2[i];
|
|
1427
|
+
check = total % 11;
|
|
1428
|
+
if (check === 10) check = 0;
|
|
1429
|
+
}
|
|
1430
|
+
return digits[10] === check;
|
|
1431
|
+
}
|
|
1432
|
+
/** Validate Swiss AHV using EAN-13 checksum. */
|
|
1433
|
+
function chAhvChecksum(number) {
|
|
1434
|
+
let digits = "";
|
|
1435
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
1436
|
+
if (digits.length !== 13) return false;
|
|
1437
|
+
if (!digits.startsWith("756")) return false;
|
|
1438
|
+
let total = 0;
|
|
1439
|
+
for (let i = 0; i < 12; i++) total += parseInt(digits[i], 10) * (i % 2 === 0 ? 1 : 3);
|
|
1440
|
+
const check = (10 - total % 10) % 10;
|
|
1441
|
+
return parseInt(digits[12], 10) === check;
|
|
1442
|
+
}
|
|
1443
|
+
/** Validate Australian TFN using mod-11 weighted checksum. */
|
|
1444
|
+
function auTfnChecksum(number) {
|
|
1445
|
+
const digits = [];
|
|
1446
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1447
|
+
if (digits.length !== 9 && digits.length !== 8) return false;
|
|
1448
|
+
if (digits.length === 8) {
|
|
1449
|
+
const weights$1 = [
|
|
1450
|
+
10,
|
|
1451
|
+
7,
|
|
1452
|
+
8,
|
|
1453
|
+
4,
|
|
1454
|
+
6,
|
|
1455
|
+
3,
|
|
1456
|
+
5,
|
|
1457
|
+
1
|
|
1458
|
+
];
|
|
1459
|
+
let total$1 = 0;
|
|
1460
|
+
for (let i = 0; i < 8; i++) total$1 += digits[i] * weights$1[i];
|
|
1461
|
+
return total$1 % 11 === 0;
|
|
1462
|
+
}
|
|
1463
|
+
const weights = [
|
|
1464
|
+
1,
|
|
1465
|
+
4,
|
|
1466
|
+
3,
|
|
1467
|
+
7,
|
|
1468
|
+
5,
|
|
1469
|
+
8,
|
|
1470
|
+
6,
|
|
1471
|
+
9,
|
|
1472
|
+
10
|
|
1473
|
+
];
|
|
1474
|
+
let total = 0;
|
|
1475
|
+
for (let i = 0; i < 9; i++) total += digits[i] * weights[i];
|
|
1476
|
+
return total % 11 === 0;
|
|
1477
|
+
}
|
|
1478
|
+
/** Validate Australian Medicare number using mod-10 weighted checksum. */
|
|
1479
|
+
function auMedicareChecksum(number) {
|
|
1480
|
+
let digits = "";
|
|
1481
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
1482
|
+
if (digits.length < 10 || digits.length > 11) return false;
|
|
1483
|
+
const weights = [
|
|
1484
|
+
1,
|
|
1485
|
+
3,
|
|
1486
|
+
7,
|
|
1487
|
+
9,
|
|
1488
|
+
1,
|
|
1489
|
+
3,
|
|
1490
|
+
7,
|
|
1491
|
+
9
|
|
1492
|
+
];
|
|
1493
|
+
let total = 0;
|
|
1494
|
+
for (let i = 0; i < 8; i++) total += parseInt(digits[i], 10) * weights[i];
|
|
1495
|
+
return parseInt(digits[8], 10) === total % 10;
|
|
1496
|
+
}
|
|
1497
|
+
/** Validate New Zealand IRD using dual-pass mod-11 checksum. */
|
|
1498
|
+
function nzIrdChecksum(number) {
|
|
1499
|
+
let digits = "";
|
|
1500
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
1501
|
+
if (digits.length !== 8 && digits.length !== 9) return false;
|
|
1502
|
+
if (digits.length === 8) digits = "0" + digits;
|
|
1503
|
+
const d = digits.split("").map(Number);
|
|
1504
|
+
const weights1 = [
|
|
1505
|
+
3,
|
|
1506
|
+
2,
|
|
1507
|
+
7,
|
|
1508
|
+
6,
|
|
1509
|
+
5,
|
|
1510
|
+
4,
|
|
1511
|
+
3,
|
|
1512
|
+
2
|
|
1513
|
+
];
|
|
1514
|
+
let total = 0;
|
|
1515
|
+
for (let i = 0; i < 8; i++) total += d[i] * weights1[i];
|
|
1516
|
+
const remainder = total % 11;
|
|
1517
|
+
if (remainder === 0) return d[8] === 0;
|
|
1518
|
+
if (11 - remainder !== 10) return d[8] === 11 - remainder;
|
|
1519
|
+
const weights2 = [
|
|
1520
|
+
7,
|
|
1521
|
+
4,
|
|
1522
|
+
3,
|
|
1523
|
+
2,
|
|
1524
|
+
5,
|
|
1525
|
+
2,
|
|
1526
|
+
7,
|
|
1527
|
+
6
|
|
1528
|
+
];
|
|
1529
|
+
total = 0;
|
|
1530
|
+
for (let i = 0; i < 8; i++) total += d[i] * weights2[i];
|
|
1531
|
+
const r2 = total % 11;
|
|
1532
|
+
if (r2 === 0) return d[8] === 0;
|
|
1533
|
+
return d[8] === 11 - r2;
|
|
1534
|
+
}
|
|
1535
|
+
/** Validate Indian Aadhaar using Verhoeff algorithm. */
|
|
1536
|
+
function inAadhaarChecksum(number) {
|
|
1537
|
+
let digits = "";
|
|
1538
|
+
for (const c$1 of number) if (c$1 >= "0" && c$1 <= "9") digits += c$1;
|
|
1539
|
+
if (digits.length !== 12) return false;
|
|
1540
|
+
if (digits[0] === "0" || digits[0] === "1") return false;
|
|
1541
|
+
let c = 0;
|
|
1542
|
+
for (let i = digits.length - 1; i >= 0; i--) c = VERHOEFF_D[c][VERHOEFF_P[(digits.length - 1 - i) % 8][parseInt(digits[i], 10)]];
|
|
1543
|
+
return c === 0;
|
|
1544
|
+
}
|
|
1545
|
+
/** Validate Indian PAN format: AAAAA0000A. */
|
|
1546
|
+
function inPanValid(number) {
|
|
1547
|
+
const cleaned = number.trim().toUpperCase();
|
|
1548
|
+
if (cleaned.length !== 10) return false;
|
|
1549
|
+
return /^[A-Z]{3}[ABCFGHLJPT][A-Z]\d{4}[A-Z]$/.test(cleaned);
|
|
1550
|
+
}
|
|
1551
|
+
/** Validate Japanese My Number using mod-11 checksum. */
|
|
1552
|
+
function jpMyNumberChecksum(number) {
|
|
1553
|
+
let digits = "";
|
|
1554
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
1555
|
+
if (digits.length !== 12) return false;
|
|
1556
|
+
let total = 0;
|
|
1557
|
+
for (let i = 0; i < 11; i++) {
|
|
1558
|
+
const p = 11 - i;
|
|
1559
|
+
const q = p <= 6 ? p + 1 : p - 5;
|
|
1560
|
+
total += parseInt(digits[i], 10) * q;
|
|
1561
|
+
}
|
|
1562
|
+
const remainder = total % 11;
|
|
1563
|
+
const check = remainder <= 1 ? 0 : 11 - remainder;
|
|
1564
|
+
return parseInt(digits[11], 10) === check;
|
|
1565
|
+
}
|
|
1566
|
+
/** Validate Korean RRN using weighted mod checksum. */
|
|
1567
|
+
function krRrnChecksum(number) {
|
|
1568
|
+
let digits = "";
|
|
1569
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
1570
|
+
if (digits.length !== 13) return false;
|
|
1571
|
+
const weights = [
|
|
1572
|
+
2,
|
|
1573
|
+
3,
|
|
1574
|
+
4,
|
|
1575
|
+
5,
|
|
1576
|
+
6,
|
|
1577
|
+
7,
|
|
1578
|
+
8,
|
|
1579
|
+
9,
|
|
1580
|
+
2,
|
|
1581
|
+
3,
|
|
1582
|
+
4,
|
|
1583
|
+
5
|
|
1584
|
+
];
|
|
1585
|
+
let total = 0;
|
|
1586
|
+
for (let i = 0; i < 12; i++) total += parseInt(digits[i], 10) * weights[i];
|
|
1587
|
+
const check = (11 - total % 11) % 10;
|
|
1588
|
+
return parseInt(digits[12], 10) === check;
|
|
1589
|
+
}
|
|
1590
|
+
/** Validate Turkish Kimlik using custom dual check digit algorithm. */
|
|
1591
|
+
function trKimlikChecksum(number) {
|
|
1592
|
+
const digits = [];
|
|
1593
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1594
|
+
if (digits.length !== 11) return false;
|
|
1595
|
+
if (digits[0] === 0) return false;
|
|
1596
|
+
const oddSum = digits[0] + digits[2] + digits[4] + digits[6] + digits[8];
|
|
1597
|
+
const evenSum = digits[1] + digits[3] + digits[5] + digits[7];
|
|
1598
|
+
const check1 = (oddSum * 7 - evenSum) % 10;
|
|
1599
|
+
if (check1 < 0 ? check1 + 10 : check1 !== digits[9]) return false;
|
|
1600
|
+
let total = 0;
|
|
1601
|
+
for (let i = 0; i < 10; i++) total += digits[i];
|
|
1602
|
+
return total % 10 === digits[10];
|
|
1603
|
+
}
|
|
1604
|
+
/** Validate Argentine CUIT using mod-11 weighted checksum. */
|
|
1605
|
+
function arCuitChecksum(number) {
|
|
1606
|
+
let digits = "";
|
|
1607
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
1608
|
+
if (digits.length !== 11) return false;
|
|
1609
|
+
const weights = [
|
|
1610
|
+
5,
|
|
1611
|
+
4,
|
|
1612
|
+
3,
|
|
1613
|
+
2,
|
|
1614
|
+
7,
|
|
1615
|
+
6,
|
|
1616
|
+
5,
|
|
1617
|
+
4,
|
|
1618
|
+
3,
|
|
1619
|
+
2
|
|
1620
|
+
];
|
|
1621
|
+
let total = 0;
|
|
1622
|
+
for (let i = 0; i < 10; i++) total += parseInt(digits[i], 10) * weights[i];
|
|
1623
|
+
const remainder = total % 11;
|
|
1624
|
+
const check = remainder === 0 ? 0 : remainder === 1 ? 9 : 11 - remainder;
|
|
1625
|
+
return parseInt(digits[10], 10) === check;
|
|
1626
|
+
}
|
|
1627
|
+
/** Validate Chilean RUT using mod-11 checksum with K. */
|
|
1628
|
+
function clRutChecksum(number) {
|
|
1629
|
+
let cleaned = number.replace(/[.\s]/g, "").toUpperCase();
|
|
1630
|
+
if (cleaned.includes("-")) {
|
|
1631
|
+
const parts = cleaned.split("-");
|
|
1632
|
+
if (parts.length !== 2) return false;
|
|
1633
|
+
cleaned = parts[0] + parts[1];
|
|
1634
|
+
}
|
|
1635
|
+
if (cleaned.length < 2) return false;
|
|
1636
|
+
const body = cleaned.slice(0, -1);
|
|
1637
|
+
const check = cleaned.slice(-1);
|
|
1638
|
+
if (!/^\d+$/.test(body)) return false;
|
|
1639
|
+
let total = 0;
|
|
1640
|
+
let mul = 2;
|
|
1641
|
+
for (let i = body.length - 1; i >= 0; i--) {
|
|
1642
|
+
total += parseInt(body[i], 10) * mul;
|
|
1643
|
+
mul = mul === 7 ? 2 : mul + 1;
|
|
1644
|
+
}
|
|
1645
|
+
const remainder = 11 - total % 11;
|
|
1646
|
+
let expected;
|
|
1647
|
+
if (remainder === 11) expected = "0";
|
|
1648
|
+
else if (remainder === 10) expected = "K";
|
|
1649
|
+
else expected = String(remainder);
|
|
1650
|
+
return check === expected;
|
|
1651
|
+
}
|
|
1652
|
+
/** Validate Colombian NIT using mod-11 with prime-based weights. */
|
|
1653
|
+
function coNitChecksum(number) {
|
|
1654
|
+
let digits = "";
|
|
1655
|
+
for (const c of number) if (c >= "0" && c <= "9") digits += c;
|
|
1656
|
+
if (digits.length < 8 || digits.length > 10) return false;
|
|
1657
|
+
const body = digits.slice(0, -1);
|
|
1658
|
+
const check = parseInt(digits.slice(-1), 10);
|
|
1659
|
+
const weights = [
|
|
1660
|
+
3,
|
|
1661
|
+
7,
|
|
1662
|
+
13,
|
|
1663
|
+
17,
|
|
1664
|
+
19,
|
|
1665
|
+
23,
|
|
1666
|
+
29,
|
|
1667
|
+
37,
|
|
1668
|
+
41,
|
|
1669
|
+
43,
|
|
1670
|
+
47,
|
|
1671
|
+
53,
|
|
1672
|
+
59,
|
|
1673
|
+
67,
|
|
1674
|
+
71
|
|
1675
|
+
];
|
|
1676
|
+
let total = 0;
|
|
1677
|
+
for (let i = 0; i < body.length; i++) total += parseInt(body[body.length - 1 - i], 10) * weights[i];
|
|
1678
|
+
const remainder = total % 11;
|
|
1679
|
+
const expected = remainder === 0 ? 0 : remainder === 1 ? 1 : 11 - remainder;
|
|
1680
|
+
return check === expected;
|
|
1681
|
+
}
|
|
1682
|
+
/** Validate NHS number using modulus 11 checksum. */
|
|
1683
|
+
function nhsChecksum(number) {
|
|
1684
|
+
const digits = [];
|
|
1685
|
+
for (const c of number) if (c >= "0" && c <= "9") digits.push(parseInt(c, 10));
|
|
1686
|
+
if (digits.length !== 10) return false;
|
|
1687
|
+
const weights = [
|
|
1688
|
+
10,
|
|
1689
|
+
9,
|
|
1690
|
+
8,
|
|
1691
|
+
7,
|
|
1692
|
+
6,
|
|
1693
|
+
5,
|
|
1694
|
+
4,
|
|
1695
|
+
3,
|
|
1696
|
+
2
|
|
1697
|
+
];
|
|
1698
|
+
let total = 0;
|
|
1699
|
+
for (let i = 0; i < 9; i++) total += digits[i] * weights[i];
|
|
1700
|
+
const remainder = total % 11;
|
|
1701
|
+
let checkDigit = 11 - remainder;
|
|
1702
|
+
if (checkDigit === 11) checkDigit = 0;
|
|
1703
|
+
if (checkDigit === 10) return false;
|
|
1704
|
+
return digits[9] === checkDigit;
|
|
1705
|
+
}
|
|
1706
|
+
var ES_DNI_LETTERS, IT_ODD_TABLE, IT_EVEN_TABLE, VERHOEFF_D, VERHOEFF_P;
|
|
1707
|
+
var init_validators = __esm({ "src/regex/validators.ts"() {
|
|
1708
|
+
ES_DNI_LETTERS = "TRWAGMYFPDXBNJZSQVHLCKE";
|
|
1709
|
+
IT_ODD_TABLE = {
|
|
1710
|
+
"0": 1,
|
|
1711
|
+
"1": 0,
|
|
1712
|
+
"2": 5,
|
|
1713
|
+
"3": 7,
|
|
1714
|
+
"4": 9,
|
|
1715
|
+
"5": 13,
|
|
1716
|
+
"6": 15,
|
|
1717
|
+
"7": 17,
|
|
1718
|
+
"8": 19,
|
|
1719
|
+
"9": 21,
|
|
1720
|
+
A: 1,
|
|
1721
|
+
B: 0,
|
|
1722
|
+
C: 5,
|
|
1723
|
+
D: 7,
|
|
1724
|
+
E: 9,
|
|
1725
|
+
F: 13,
|
|
1726
|
+
G: 15,
|
|
1727
|
+
H: 17,
|
|
1728
|
+
I: 19,
|
|
1729
|
+
J: 21,
|
|
1730
|
+
K: 2,
|
|
1731
|
+
L: 4,
|
|
1732
|
+
M: 18,
|
|
1733
|
+
N: 20,
|
|
1734
|
+
O: 11,
|
|
1735
|
+
P: 3,
|
|
1736
|
+
Q: 6,
|
|
1737
|
+
R: 8,
|
|
1738
|
+
S: 12,
|
|
1739
|
+
T: 14,
|
|
1740
|
+
U: 16,
|
|
1741
|
+
V: 10,
|
|
1742
|
+
W: 22,
|
|
1743
|
+
X: 25,
|
|
1744
|
+
Y: 24,
|
|
1745
|
+
Z: 23
|
|
1746
|
+
};
|
|
1747
|
+
IT_EVEN_TABLE = {
|
|
1748
|
+
"0": 0,
|
|
1749
|
+
"1": 1,
|
|
1750
|
+
"2": 2,
|
|
1751
|
+
"3": 3,
|
|
1752
|
+
"4": 4,
|
|
1753
|
+
"5": 5,
|
|
1754
|
+
"6": 6,
|
|
1755
|
+
"7": 7,
|
|
1756
|
+
"8": 8,
|
|
1757
|
+
"9": 9,
|
|
1758
|
+
A: 0,
|
|
1759
|
+
B: 1,
|
|
1760
|
+
C: 2,
|
|
1761
|
+
D: 3,
|
|
1762
|
+
E: 4,
|
|
1763
|
+
F: 5,
|
|
1764
|
+
G: 6,
|
|
1765
|
+
H: 7,
|
|
1766
|
+
I: 8,
|
|
1767
|
+
J: 9,
|
|
1768
|
+
K: 10,
|
|
1769
|
+
L: 11,
|
|
1770
|
+
M: 12,
|
|
1771
|
+
N: 13,
|
|
1772
|
+
O: 14,
|
|
1773
|
+
P: 15,
|
|
1774
|
+
Q: 16,
|
|
1775
|
+
R: 17,
|
|
1776
|
+
S: 18,
|
|
1777
|
+
T: 19,
|
|
1778
|
+
U: 20,
|
|
1779
|
+
V: 21,
|
|
1780
|
+
W: 22,
|
|
1781
|
+
X: 23,
|
|
1782
|
+
Y: 24,
|
|
1783
|
+
Z: 25
|
|
1784
|
+
};
|
|
1785
|
+
VERHOEFF_D = [
|
|
1786
|
+
[
|
|
1787
|
+
0,
|
|
1788
|
+
1,
|
|
1789
|
+
2,
|
|
1790
|
+
3,
|
|
1791
|
+
4,
|
|
1792
|
+
5,
|
|
1793
|
+
6,
|
|
1794
|
+
7,
|
|
1795
|
+
8,
|
|
1796
|
+
9
|
|
1797
|
+
],
|
|
1798
|
+
[
|
|
1799
|
+
1,
|
|
1800
|
+
2,
|
|
1801
|
+
3,
|
|
1802
|
+
4,
|
|
1803
|
+
0,
|
|
1804
|
+
6,
|
|
1805
|
+
7,
|
|
1806
|
+
8,
|
|
1807
|
+
9,
|
|
1808
|
+
5
|
|
1809
|
+
],
|
|
1810
|
+
[
|
|
1811
|
+
2,
|
|
1812
|
+
3,
|
|
1813
|
+
4,
|
|
1814
|
+
0,
|
|
1815
|
+
1,
|
|
1816
|
+
7,
|
|
1817
|
+
8,
|
|
1818
|
+
9,
|
|
1819
|
+
5,
|
|
1820
|
+
6
|
|
1821
|
+
],
|
|
1822
|
+
[
|
|
1823
|
+
3,
|
|
1824
|
+
4,
|
|
1825
|
+
0,
|
|
1826
|
+
1,
|
|
1827
|
+
2,
|
|
1828
|
+
8,
|
|
1829
|
+
9,
|
|
1830
|
+
5,
|
|
1831
|
+
6,
|
|
1832
|
+
7
|
|
1833
|
+
],
|
|
1834
|
+
[
|
|
1835
|
+
4,
|
|
1836
|
+
0,
|
|
1837
|
+
1,
|
|
1838
|
+
2,
|
|
1839
|
+
3,
|
|
1840
|
+
9,
|
|
1841
|
+
5,
|
|
1842
|
+
6,
|
|
1843
|
+
7,
|
|
1844
|
+
8
|
|
1845
|
+
],
|
|
1846
|
+
[
|
|
1847
|
+
5,
|
|
1848
|
+
9,
|
|
1849
|
+
8,
|
|
1850
|
+
7,
|
|
1851
|
+
6,
|
|
1852
|
+
0,
|
|
1853
|
+
4,
|
|
1854
|
+
3,
|
|
1855
|
+
2,
|
|
1856
|
+
1
|
|
1857
|
+
],
|
|
1858
|
+
[
|
|
1859
|
+
6,
|
|
1860
|
+
5,
|
|
1861
|
+
9,
|
|
1862
|
+
8,
|
|
1863
|
+
7,
|
|
1864
|
+
1,
|
|
1865
|
+
0,
|
|
1866
|
+
4,
|
|
1867
|
+
3,
|
|
1868
|
+
2
|
|
1869
|
+
],
|
|
1870
|
+
[
|
|
1871
|
+
7,
|
|
1872
|
+
6,
|
|
1873
|
+
5,
|
|
1874
|
+
9,
|
|
1875
|
+
8,
|
|
1876
|
+
2,
|
|
1877
|
+
1,
|
|
1878
|
+
0,
|
|
1879
|
+
4,
|
|
1880
|
+
3
|
|
1881
|
+
],
|
|
1882
|
+
[
|
|
1883
|
+
8,
|
|
1884
|
+
7,
|
|
1885
|
+
6,
|
|
1886
|
+
5,
|
|
1887
|
+
9,
|
|
1888
|
+
3,
|
|
1889
|
+
2,
|
|
1890
|
+
1,
|
|
1891
|
+
0,
|
|
1892
|
+
4
|
|
1893
|
+
],
|
|
1894
|
+
[
|
|
1895
|
+
9,
|
|
1896
|
+
8,
|
|
1897
|
+
7,
|
|
1898
|
+
6,
|
|
1899
|
+
5,
|
|
1900
|
+
4,
|
|
1901
|
+
3,
|
|
1902
|
+
2,
|
|
1903
|
+
1,
|
|
1904
|
+
0
|
|
1905
|
+
]
|
|
1906
|
+
];
|
|
1907
|
+
VERHOEFF_P = [
|
|
1908
|
+
[
|
|
1909
|
+
0,
|
|
1910
|
+
1,
|
|
1911
|
+
2,
|
|
1912
|
+
3,
|
|
1913
|
+
4,
|
|
1914
|
+
5,
|
|
1915
|
+
6,
|
|
1916
|
+
7,
|
|
1917
|
+
8,
|
|
1918
|
+
9
|
|
1919
|
+
],
|
|
1920
|
+
[
|
|
1921
|
+
1,
|
|
1922
|
+
5,
|
|
1923
|
+
7,
|
|
1924
|
+
6,
|
|
1925
|
+
2,
|
|
1926
|
+
8,
|
|
1927
|
+
3,
|
|
1928
|
+
0,
|
|
1929
|
+
9,
|
|
1930
|
+
4
|
|
1931
|
+
],
|
|
1932
|
+
[
|
|
1933
|
+
5,
|
|
1934
|
+
8,
|
|
1935
|
+
0,
|
|
1936
|
+
3,
|
|
1937
|
+
7,
|
|
1938
|
+
9,
|
|
1939
|
+
6,
|
|
1940
|
+
1,
|
|
1941
|
+
4,
|
|
1942
|
+
2
|
|
1943
|
+
],
|
|
1944
|
+
[
|
|
1945
|
+
8,
|
|
1946
|
+
9,
|
|
1947
|
+
1,
|
|
1948
|
+
6,
|
|
1949
|
+
0,
|
|
1950
|
+
4,
|
|
1951
|
+
3,
|
|
1952
|
+
5,
|
|
1953
|
+
2,
|
|
1954
|
+
7
|
|
1955
|
+
],
|
|
1956
|
+
[
|
|
1957
|
+
9,
|
|
1958
|
+
4,
|
|
1959
|
+
5,
|
|
1960
|
+
3,
|
|
1961
|
+
1,
|
|
1962
|
+
2,
|
|
1963
|
+
6,
|
|
1964
|
+
8,
|
|
1965
|
+
7,
|
|
1966
|
+
0
|
|
1967
|
+
],
|
|
1968
|
+
[
|
|
1969
|
+
4,
|
|
1970
|
+
2,
|
|
1971
|
+
8,
|
|
1972
|
+
6,
|
|
1973
|
+
5,
|
|
1974
|
+
7,
|
|
1975
|
+
3,
|
|
1976
|
+
9,
|
|
1977
|
+
0,
|
|
1978
|
+
1
|
|
1979
|
+
],
|
|
1980
|
+
[
|
|
1981
|
+
2,
|
|
1982
|
+
7,
|
|
1983
|
+
9,
|
|
1984
|
+
3,
|
|
1985
|
+
8,
|
|
1986
|
+
0,
|
|
1987
|
+
6,
|
|
1988
|
+
4,
|
|
1989
|
+
1,
|
|
1990
|
+
5
|
|
1991
|
+
],
|
|
1992
|
+
[
|
|
1993
|
+
7,
|
|
1994
|
+
0,
|
|
1995
|
+
4,
|
|
1996
|
+
6,
|
|
1997
|
+
9,
|
|
1998
|
+
1,
|
|
1999
|
+
3,
|
|
2000
|
+
2,
|
|
2001
|
+
5,
|
|
2002
|
+
8
|
|
2003
|
+
]
|
|
2004
|
+
];
|
|
2005
|
+
} });
|
|
2006
|
+
|
|
2007
|
+
//#endregion
|
|
2008
|
+
//#region src/regex/detectors/credit-card.ts
|
|
2009
|
+
var CC_KNOWN, CC_GENERIC, CC_CONTEXT, CreditCardDetector;
|
|
2010
|
+
var init_credit_card = __esm({ "src/regex/detectors/credit-card.ts"() {
|
|
2011
|
+
init_base();
|
|
2012
|
+
init_entities();
|
|
2013
|
+
init_registry();
|
|
2014
|
+
init_validators();
|
|
2015
|
+
CC_KNOWN = new RegExp("\\b(?:4\\d{3}[-\\s]?\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}(?:[-\\s]?\\d{3})?|4\\d{12}|5[1-5]\\d{2}[-\\s]?\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}|2[2-7]\\d{2}[-\\s]?\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}|3[47]\\d{2}[-\\s]?\\d{6}[-\\s]?\\d{5}|6(?:011|5\\d{2})[-\\s]?\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}|3(?:0[0-5]|[68]\\d)\\d{11,13}|35(?:2[89]|[3-8]\\d)\\d{12}|62\\d{14,17}|50(?:18|20|38)\\d{8,15}|6(?:304|7(?:59|6[1-3]))\\d{8,15})\\b", "g");
|
|
2016
|
+
CC_GENERIC = /\b\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{1,7}\b/g;
|
|
2017
|
+
CC_CONTEXT = [
|
|
2018
|
+
"credit card",
|
|
2019
|
+
"card number",
|
|
2020
|
+
"card no",
|
|
2021
|
+
"card #",
|
|
2022
|
+
"cc:",
|
|
2023
|
+
"cc #",
|
|
2024
|
+
"payment card",
|
|
2025
|
+
"debit card",
|
|
2026
|
+
"billing",
|
|
2027
|
+
"card:",
|
|
2028
|
+
"credit",
|
|
2029
|
+
"payment"
|
|
2030
|
+
];
|
|
2031
|
+
CreditCardDetector = class extends Detector {
|
|
2032
|
+
entityType = EntityType.CREDIT_CARD;
|
|
2033
|
+
score = .9;
|
|
2034
|
+
iterMatches(text) {
|
|
2035
|
+
if (!text.match(/\d/)) return [];
|
|
2036
|
+
const results = [];
|
|
2037
|
+
CC_KNOWN.lastIndex = 0;
|
|
2038
|
+
let match;
|
|
2039
|
+
while ((match = CC_KNOWN.exec(text)) !== null) {
|
|
2040
|
+
const matchedText = match[0];
|
|
2041
|
+
if (!luhnChecksum(matchedText)) continue;
|
|
2042
|
+
results.push({
|
|
2043
|
+
entityType: this.entityType,
|
|
2044
|
+
text: matchedText,
|
|
2045
|
+
start: match.index,
|
|
2046
|
+
end: match.index + matchedText.length,
|
|
2047
|
+
score: 1
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2050
|
+
CC_GENERIC.lastIndex = 0;
|
|
2051
|
+
while ((match = CC_GENERIC.exec(text)) !== null) {
|
|
2052
|
+
const matchedText = match[0];
|
|
2053
|
+
const start = match.index;
|
|
2054
|
+
if (results.some((r) => r.start <= start && start < r.end)) continue;
|
|
2055
|
+
if (!luhnChecksum(matchedText)) continue;
|
|
2056
|
+
const windowStart = Math.max(0, start - 100);
|
|
2057
|
+
const lower = this._textLower || text.toLowerCase();
|
|
2058
|
+
const window = lower.slice(windowStart, start);
|
|
2059
|
+
if (!CC_CONTEXT.some((kw) => window.includes(kw))) continue;
|
|
2060
|
+
results.push({
|
|
2061
|
+
entityType: this.entityType,
|
|
2062
|
+
text: matchedText,
|
|
2063
|
+
start,
|
|
2064
|
+
end: start + matchedText.length,
|
|
2065
|
+
score: 1
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
2068
|
+
return results;
|
|
2069
|
+
}
|
|
2070
|
+
};
|
|
2071
|
+
registerUniversal(CreditCardDetector);
|
|
2072
|
+
} });
|
|
2073
|
+
|
|
2074
|
+
//#endregion
|
|
2075
|
+
//#region src/regex/detectors/phone.ts
|
|
2076
|
+
function phoneLengthCheck(text) {
|
|
2077
|
+
let digits = 0;
|
|
2078
|
+
for (const c of text) if (c >= "0" && c <= "9") digits++;
|
|
2079
|
+
if (digits < 7 || digits > 15) return false;
|
|
2080
|
+
if (DATE_LIKE.test(text)) return false;
|
|
2081
|
+
if (SSN_LIKE.test(text)) return false;
|
|
2082
|
+
return true;
|
|
2083
|
+
}
|
|
2084
|
+
var DATE_LIKE, SSN_LIKE, PhoneDetector;
|
|
2085
|
+
var init_phone = __esm({ "src/regex/detectors/phone.ts"() {
|
|
2086
|
+
init_base();
|
|
2087
|
+
init_entities();
|
|
2088
|
+
init_registry();
|
|
2089
|
+
DATE_LIKE = /^\d{1,2}[-./]\d{1,2}[-./]\d{2,4}$/;
|
|
2090
|
+
SSN_LIKE = /^\d{3}[-.\s]\d{2}[-.\s]\d{4}$/;
|
|
2091
|
+
PhoneDetector = class extends RegexDetector {
|
|
2092
|
+
entityType = EntityType.PHONE_NUMBER;
|
|
2093
|
+
score = .85;
|
|
2094
|
+
contextKeywords = [
|
|
2095
|
+
"phone",
|
|
2096
|
+
"tel",
|
|
2097
|
+
"telephone",
|
|
2098
|
+
"call",
|
|
2099
|
+
"mobile",
|
|
2100
|
+
"cell",
|
|
2101
|
+
"fax",
|
|
2102
|
+
"contact",
|
|
2103
|
+
"dial",
|
|
2104
|
+
"reach",
|
|
2105
|
+
"ring",
|
|
2106
|
+
"text",
|
|
2107
|
+
"sms",
|
|
2108
|
+
"whatsapp",
|
|
2109
|
+
"number",
|
|
2110
|
+
"ph#",
|
|
2111
|
+
"ph #",
|
|
2112
|
+
"cell#",
|
|
2113
|
+
"cell #"
|
|
2114
|
+
];
|
|
2115
|
+
contextWindow = 80;
|
|
2116
|
+
pattern = new RegExp("(?<!\\d)(?:(?:\\+?1[-.\\s]?)?\\([2-9]\\d{2}\\)[-.\\s]?[2-9]\\d{2}[-.\\s]?\\d{4}|(?:\\+?1[-.\\s]?)?[2-9]\\d{2}[-.\\s][2-9]\\d{2}[-.\\s]?\\d{4}|\\+[1-9]\\d{0,2}[-.\\s]?\\(?\\d{1,4}\\)?[-.\\s]?\\d{1,4}[-.\\s]?\\d{1,9}|0\\d{1,3}[-.\\s]\\d{2,4}[-.\\s]?\\d{2,4}[-.\\s]?\\d{0,4})(?:\\s?(?:x|ext\\.?)\\s?\\d{1,5})?(?!\\d)", "g");
|
|
2117
|
+
validator = phoneLengthCheck;
|
|
2118
|
+
};
|
|
2119
|
+
registerUniversal(PhoneDetector);
|
|
2120
|
+
} });
|
|
2121
|
+
|
|
2122
|
+
//#endregion
|
|
2123
|
+
//#region src/regex/detectors/ip-address.ts
|
|
2124
|
+
var IPV4, IPV6, IpAddressDetector;
|
|
2125
|
+
var init_ip_address = __esm({ "src/regex/detectors/ip-address.ts"() {
|
|
2126
|
+
init_base();
|
|
2127
|
+
init_entities();
|
|
2128
|
+
init_registry();
|
|
2129
|
+
IPV4 = /\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b/g;
|
|
2130
|
+
IPV6 = new RegExp("\\b(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\\b|\\b(?:[0-9a-fA-F]{1,4}:){1,7}:\\b|\\b::(?:[0-9a-fA-F]{1,4}:){0,5}[0-9a-fA-F]{1,4}\\b", "g");
|
|
2131
|
+
IpAddressDetector = class IpAddressDetector extends Detector {
|
|
2132
|
+
entityType = EntityType.IP_ADDRESS;
|
|
2133
|
+
score = .95;
|
|
2134
|
+
iterMatches(text) {
|
|
2135
|
+
const results = [];
|
|
2136
|
+
for (const pattern of [IPV4, IPV6]) {
|
|
2137
|
+
pattern.lastIndex = 0;
|
|
2138
|
+
let match;
|
|
2139
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
2140
|
+
const matchedText = match[0];
|
|
2141
|
+
const start = match.index;
|
|
2142
|
+
if (pattern === IPV4 && IpAddressDetector.isVersionNumber(text, start)) continue;
|
|
2143
|
+
results.push({
|
|
2144
|
+
entityType: this.entityType,
|
|
2145
|
+
text: matchedText,
|
|
2146
|
+
start,
|
|
2147
|
+
end: start + matchedText.length,
|
|
2148
|
+
score: this.score
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
return results;
|
|
2153
|
+
}
|
|
2154
|
+
/** Skip patterns preceded by 'v' or 'version' that look like version numbers. */
|
|
2155
|
+
static isVersionNumber(text, start) {
|
|
2156
|
+
if (start > 0 && text[start - 1].toLowerCase() === "v") return true;
|
|
2157
|
+
const prefix = text.slice(Math.max(0, start - 10), start).toLowerCase().trim();
|
|
2158
|
+
return prefix.endsWith("version");
|
|
2159
|
+
}
|
|
2160
|
+
};
|
|
2161
|
+
registerUniversal(IpAddressDetector);
|
|
2162
|
+
} });
|
|
2163
|
+
|
|
2164
|
+
//#endregion
|
|
2165
|
+
//#region src/regex/detectors/url.ts
|
|
2166
|
+
function urlValidTld(text) {
|
|
2167
|
+
try {
|
|
2168
|
+
const afterScheme = text.split("://", 2)[1];
|
|
2169
|
+
if (!afterScheme) return false;
|
|
2170
|
+
const domain = afterScheme.split("/")[0].split("?")[0].split("#")[0];
|
|
2171
|
+
const parts = domain.replace(/\.$/, "").split(".");
|
|
2172
|
+
if (parts.length < 2) return false;
|
|
2173
|
+
const tld = parts[parts.length - 1].toLowerCase();
|
|
2174
|
+
return VALID_TLDS.has(tld);
|
|
2175
|
+
} catch {
|
|
2176
|
+
return false;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
var VALID_TLDS, UrlDetector;
|
|
2180
|
+
var init_url = __esm({ "src/regex/detectors/url.ts"() {
|
|
2181
|
+
init_base();
|
|
2182
|
+
init_entities();
|
|
2183
|
+
init_registry();
|
|
2184
|
+
VALID_TLDS = new Set([
|
|
2185
|
+
"com",
|
|
2186
|
+
"org",
|
|
2187
|
+
"net",
|
|
2188
|
+
"edu",
|
|
2189
|
+
"gov",
|
|
2190
|
+
"mil",
|
|
2191
|
+
"int",
|
|
2192
|
+
"io",
|
|
2193
|
+
"co",
|
|
2194
|
+
"dev",
|
|
2195
|
+
"app",
|
|
2196
|
+
"ai",
|
|
2197
|
+
"me",
|
|
2198
|
+
"us",
|
|
2199
|
+
"uk",
|
|
2200
|
+
"de",
|
|
2201
|
+
"fr",
|
|
2202
|
+
"it",
|
|
2203
|
+
"es",
|
|
2204
|
+
"nl",
|
|
2205
|
+
"be",
|
|
2206
|
+
"at",
|
|
2207
|
+
"ch",
|
|
2208
|
+
"se",
|
|
2209
|
+
"no",
|
|
2210
|
+
"dk",
|
|
2211
|
+
"fi",
|
|
2212
|
+
"pl",
|
|
2213
|
+
"cz",
|
|
2214
|
+
"sk",
|
|
2215
|
+
"pt",
|
|
2216
|
+
"ru",
|
|
2217
|
+
"br",
|
|
2218
|
+
"jp",
|
|
2219
|
+
"kr",
|
|
2220
|
+
"cn",
|
|
2221
|
+
"in",
|
|
2222
|
+
"au",
|
|
2223
|
+
"nz",
|
|
2224
|
+
"za",
|
|
2225
|
+
"ca",
|
|
2226
|
+
"mx",
|
|
2227
|
+
"ar",
|
|
2228
|
+
"cl",
|
|
2229
|
+
"il",
|
|
2230
|
+
"tr",
|
|
2231
|
+
"ie",
|
|
2232
|
+
"hu",
|
|
2233
|
+
"ro",
|
|
2234
|
+
"bg",
|
|
2235
|
+
"hr",
|
|
2236
|
+
"si",
|
|
2237
|
+
"lt",
|
|
2238
|
+
"lv",
|
|
2239
|
+
"ee",
|
|
2240
|
+
"info",
|
|
2241
|
+
"biz",
|
|
2242
|
+
"name",
|
|
2243
|
+
"pro",
|
|
2244
|
+
"xyz",
|
|
2245
|
+
"online",
|
|
2246
|
+
"site",
|
|
2247
|
+
"tech",
|
|
2248
|
+
"store",
|
|
2249
|
+
"shop",
|
|
2250
|
+
"cloud",
|
|
2251
|
+
"page",
|
|
2252
|
+
"link",
|
|
2253
|
+
"top",
|
|
2254
|
+
"icu",
|
|
2255
|
+
"live",
|
|
2256
|
+
"world",
|
|
2257
|
+
"blog",
|
|
2258
|
+
"news",
|
|
2259
|
+
"tv",
|
|
2260
|
+
"cc",
|
|
2261
|
+
"ly",
|
|
2262
|
+
"gg",
|
|
2263
|
+
"to",
|
|
2264
|
+
"eu",
|
|
2265
|
+
"asia"
|
|
2266
|
+
]);
|
|
2267
|
+
UrlDetector = class extends RegexDetector {
|
|
2268
|
+
entityType = EntityType.URL;
|
|
2269
|
+
score = .85;
|
|
2270
|
+
needsDigit = false;
|
|
2271
|
+
pattern = /https?:\/\/(?:[\w\-]+\.)+[a-zA-Z]{2,}(?:\/[^\s<>"')\]]*)?/gi;
|
|
2272
|
+
validator = urlValidTld;
|
|
2273
|
+
preCheck(text) {
|
|
2274
|
+
return text.includes("://");
|
|
2275
|
+
}
|
|
2276
|
+
};
|
|
2277
|
+
registerUniversal(UrlDetector);
|
|
2278
|
+
} });
|
|
2279
|
+
|
|
2280
|
+
//#endregion
|
|
2281
|
+
//#region src/regex/detectors/mac-address.ts
|
|
2282
|
+
var MacAddressDetector;
|
|
2283
|
+
var init_mac_address = __esm({ "src/regex/detectors/mac-address.ts"() {
|
|
2284
|
+
init_base();
|
|
2285
|
+
init_entities();
|
|
2286
|
+
init_registry();
|
|
2287
|
+
MacAddressDetector = class extends RegexDetector {
|
|
2288
|
+
entityType = EntityType.MAC_ADDRESS;
|
|
2289
|
+
score = .95;
|
|
2290
|
+
pattern = /\b(?:[0-9A-Fa-f]{2}[:\-]){5}[0-9A-Fa-f]{2}\b/g;
|
|
2291
|
+
};
|
|
2292
|
+
registerUniversal(MacAddressDetector);
|
|
2293
|
+
} });
|
|
2294
|
+
|
|
2295
|
+
//#endregion
|
|
2296
|
+
//#region src/regex/detectors/date-of-birth.ts
|
|
2297
|
+
function validDate(text) {
|
|
2298
|
+
if (/[a-zA-Z]/i.test(text.replace(/T/g, ""))) return true;
|
|
2299
|
+
const groups = text.match(/\d+/g);
|
|
2300
|
+
return groups !== null && groups.length >= 3;
|
|
2301
|
+
}
|
|
2302
|
+
var MONTHS, DateOfBirthDetector;
|
|
2303
|
+
var init_date_of_birth = __esm({ "src/regex/detectors/date-of-birth.ts"() {
|
|
2304
|
+
init_base();
|
|
2305
|
+
init_entities();
|
|
2306
|
+
init_registry();
|
|
2307
|
+
MONTHS = "(?:january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|oct|nov|dec)";
|
|
2308
|
+
DateOfBirthDetector = class extends RegexDetector {
|
|
2309
|
+
entityType = EntityType.DATE_OF_BIRTH;
|
|
2310
|
+
score = .75;
|
|
2311
|
+
contextKeywords = [
|
|
2312
|
+
"born",
|
|
2313
|
+
"dob",
|
|
2314
|
+
"date of birth",
|
|
2315
|
+
"birthday",
|
|
2316
|
+
"birthdate",
|
|
2317
|
+
"d.o.b",
|
|
2318
|
+
"birth date",
|
|
2319
|
+
"birth",
|
|
2320
|
+
"b-day",
|
|
2321
|
+
"bday",
|
|
2322
|
+
"age",
|
|
2323
|
+
"d/o/b",
|
|
2324
|
+
"born on",
|
|
2325
|
+
"date de naissance",
|
|
2326
|
+
"geburtsdatum",
|
|
2327
|
+
"fecha de nacimiento",
|
|
2328
|
+
"geboortedatum",
|
|
2329
|
+
"data di nascita"
|
|
2330
|
+
];
|
|
2331
|
+
contextRequired = true;
|
|
2332
|
+
contextWindow = 100;
|
|
2333
|
+
validator = validDate;
|
|
2334
|
+
pattern = new RegExp(
|
|
2335
|
+
// MM/DD/YYYY (4-digit year, month 1-12)
|
|
2336
|
+
"\\b(?:0?[1-9]|1[0-2])[/\\-.](?:0?[1-9]|[12]\\d|3[01])[/\\-.](?:19|20)\\d{2}\\b|\\b(?:1[3-9]|2\\d|3[01])[/\\-.](?:0?[1-9]|1[0-2])[/\\-.](?:19|20)\\d{2}\\b|\\b(?:0?[1-9]|1[0-2])[/\\-.](?:0?[1-9]|[12]\\d|3[01])[/\\-.]\\d{2}\\b|\\b(?:1[3-9]|2\\d|3[01])[/\\-.](?:0?[1-9]|1[0-2])[/\\-.]\\d{2}\\b|\\b(?:19|20)\\d{2}[/\\-.](?:0?[1-9]|1[0-2])[/\\-.](?:0?[1-9]|[12]\\d|3[01])(?:T\\d{2}:\\d{2}:\\d{2})?\\b|\\b" + MONTHS + "\\s+\\d{1,2}(?:st|nd|rd|th)?,?\\s+(?:19|20)\\d{2}\\b|\\b\\d{1,2}(?:st|nd|rd|th)?\\s+" + MONTHS + ",?\\s+(?:19|20)\\d{2}\\b|\\b" + MONTHS + "[/\\-.]\\d{2}\\b",
|
|
2337
|
+
"gi"
|
|
2338
|
+
);
|
|
2339
|
+
};
|
|
2340
|
+
registerUniversal(DateOfBirthDetector);
|
|
2341
|
+
} });
|
|
2342
|
+
|
|
2343
|
+
//#endregion
|
|
2344
|
+
//#region src/regex/detectors/cvv.ts
|
|
2345
|
+
var CvvDetector;
|
|
2346
|
+
var init_cvv = __esm({ "src/regex/detectors/cvv.ts"() {
|
|
2347
|
+
init_base();
|
|
2348
|
+
init_entities();
|
|
2349
|
+
init_registry();
|
|
2350
|
+
CvvDetector = class extends RegexDetector {
|
|
2351
|
+
entityType = EntityType.CVV;
|
|
2352
|
+
score = .8;
|
|
2353
|
+
contextKeywords = [
|
|
2354
|
+
"cvv",
|
|
2355
|
+
"cvc",
|
|
2356
|
+
"security code",
|
|
2357
|
+
"card verification",
|
|
2358
|
+
"cvv2",
|
|
2359
|
+
"cvc2",
|
|
2360
|
+
"csv"
|
|
2361
|
+
];
|
|
2362
|
+
contextRequired = true;
|
|
2363
|
+
contextWindow = 50;
|
|
2364
|
+
pattern = /\b\d{3,4}\b/g;
|
|
2365
|
+
};
|
|
2366
|
+
registerUniversal(CvvDetector);
|
|
2367
|
+
} });
|
|
2368
|
+
|
|
2369
|
+
//#endregion
|
|
2370
|
+
//#region src/regex/detectors/us/ssn.ts
|
|
2371
|
+
var SSN_WITH_SEP, SSN_NO_SEP, SsnDetector;
|
|
2372
|
+
var init_ssn = __esm({ "src/regex/detectors/us/ssn.ts"() {
|
|
2373
|
+
init_base();
|
|
2374
|
+
init_entities();
|
|
2375
|
+
init_registry();
|
|
2376
|
+
init_validators();
|
|
2377
|
+
SSN_WITH_SEP = new RegExp("\\b(?!000|666|9\\d{2})\\d{3}[-.\\s](?!00)\\d{2}[-.\\s](?!0000)\\d{4}\\b", "g");
|
|
2378
|
+
SSN_NO_SEP = new RegExp("\\b(?!000|666|9\\d{2})\\d{3}(?!00)\\d{2}(?!0000)\\d{4}\\b", "g");
|
|
2379
|
+
SsnDetector = class extends Detector {
|
|
2380
|
+
entityType = EntityType.SSN;
|
|
2381
|
+
score = .85;
|
|
2382
|
+
contextKeywords = [
|
|
2383
|
+
"ssn",
|
|
2384
|
+
"social security",
|
|
2385
|
+
"social sec",
|
|
2386
|
+
"ss#",
|
|
2387
|
+
"ss #",
|
|
2388
|
+
"social",
|
|
2389
|
+
"tax id",
|
|
2390
|
+
"taxpayer",
|
|
2391
|
+
"tin",
|
|
2392
|
+
"social number",
|
|
2393
|
+
"soc number",
|
|
2394
|
+
"socialnum"
|
|
2395
|
+
];
|
|
2396
|
+
contextRequired = false;
|
|
2397
|
+
contextWindow = 100;
|
|
2398
|
+
iterMatches(text) {
|
|
2399
|
+
const results = [];
|
|
2400
|
+
SSN_WITH_SEP.lastIndex = 0;
|
|
2401
|
+
let match;
|
|
2402
|
+
while ((match = SSN_WITH_SEP.exec(text)) !== null) {
|
|
2403
|
+
const matchedText = match[0];
|
|
2404
|
+
if (!ssnValidFormat(matchedText)) continue;
|
|
2405
|
+
const start = match.index;
|
|
2406
|
+
const end = start + matchedText.length;
|
|
2407
|
+
const hasCtx = this.hasContext(text, start, end);
|
|
2408
|
+
results.push({
|
|
2409
|
+
entityType: this.entityType,
|
|
2410
|
+
text: matchedText,
|
|
2411
|
+
start,
|
|
2412
|
+
end,
|
|
2413
|
+
score: hasCtx ? 1 : this.score
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
SSN_NO_SEP.lastIndex = 0;
|
|
2417
|
+
while ((match = SSN_NO_SEP.exec(text)) !== null) {
|
|
2418
|
+
const matchedText = match[0];
|
|
2419
|
+
const start = match.index;
|
|
2420
|
+
const end = start + matchedText.length;
|
|
2421
|
+
if (results.some((r) => r.start <= start && start < r.end)) continue;
|
|
2422
|
+
if (!ssnValidFormat(matchedText)) continue;
|
|
2423
|
+
if (!this.hasContext(text, start, end)) continue;
|
|
2424
|
+
results.push({
|
|
2425
|
+
entityType: this.entityType,
|
|
2426
|
+
text: matchedText,
|
|
2427
|
+
start,
|
|
2428
|
+
end,
|
|
2429
|
+
score: 1
|
|
2430
|
+
});
|
|
2431
|
+
}
|
|
2432
|
+
return results;
|
|
2433
|
+
}
|
|
2434
|
+
};
|
|
2435
|
+
registerRegion("us", SsnDetector);
|
|
2436
|
+
} });
|
|
2437
|
+
|
|
2438
|
+
//#endregion
|
|
2439
|
+
//#region src/regex/detectors/us/drivers-license.ts
|
|
2440
|
+
var DriversLicenseDetector;
|
|
2441
|
+
var init_drivers_license = __esm({ "src/regex/detectors/us/drivers-license.ts"() {
|
|
2442
|
+
init_base();
|
|
2443
|
+
init_entities();
|
|
2444
|
+
init_registry();
|
|
2445
|
+
DriversLicenseDetector = class extends RegexDetector {
|
|
2446
|
+
entityType = EntityType.DRIVERS_LICENSE;
|
|
2447
|
+
score = .75;
|
|
2448
|
+
contextKeywords = [
|
|
2449
|
+
"driver",
|
|
2450
|
+
"license",
|
|
2451
|
+
"licence",
|
|
2452
|
+
"dl",
|
|
2453
|
+
"driver's license",
|
|
2454
|
+
"driving license",
|
|
2455
|
+
"dl#",
|
|
2456
|
+
"dl #",
|
|
2457
|
+
"dmv",
|
|
2458
|
+
"permit"
|
|
2459
|
+
];
|
|
2460
|
+
contextRequired = true;
|
|
2461
|
+
contextWindow = 50;
|
|
2462
|
+
pattern = new RegExp("\\b(?:[A-Z]\\d{14}|[A-Z]\\d{13}|[A-Z]\\d{12}|[A-Z]\\d{11}|[A-Z]\\d{10}|[A-Z]\\d{8}|[A-Z]{2}\\d{6}|[A-Z]\\d{7}|\\d{9}|\\d{8})\\b", "g");
|
|
2463
|
+
};
|
|
2464
|
+
registerRegion("us", DriversLicenseDetector);
|
|
2465
|
+
} });
|
|
2466
|
+
|
|
2467
|
+
//#endregion
|
|
2468
|
+
//#region src/regex/detectors/us/passport.ts
|
|
2469
|
+
var UsPassportDetector;
|
|
2470
|
+
var init_passport$1 = __esm({ "src/regex/detectors/us/passport.ts"() {
|
|
2471
|
+
init_base();
|
|
2472
|
+
init_entities();
|
|
2473
|
+
init_registry();
|
|
2474
|
+
UsPassportDetector = class extends RegexDetector {
|
|
2475
|
+
entityType = EntityType.US_PASSPORT;
|
|
2476
|
+
score = .75;
|
|
2477
|
+
contextKeywords = [
|
|
2478
|
+
"passport",
|
|
2479
|
+
"passport#",
|
|
2480
|
+
"passport #",
|
|
2481
|
+
"passport number",
|
|
2482
|
+
"passport no"
|
|
2483
|
+
];
|
|
2484
|
+
contextRequired = true;
|
|
2485
|
+
contextWindow = 50;
|
|
2486
|
+
pattern = /\b\d{9}\b/g;
|
|
2487
|
+
};
|
|
2488
|
+
registerRegion("us", UsPassportDetector);
|
|
2489
|
+
} });
|
|
2490
|
+
|
|
2491
|
+
//#endregion
|
|
2492
|
+
//#region src/regex/detectors/us/tax-id.ts
|
|
2493
|
+
var TaxIdDetector;
|
|
2494
|
+
var init_tax_id$2 = __esm({ "src/regex/detectors/us/tax-id.ts"() {
|
|
2495
|
+
init_base();
|
|
2496
|
+
init_entities();
|
|
2497
|
+
init_registry();
|
|
2498
|
+
TaxIdDetector = class extends RegexDetector {
|
|
2499
|
+
entityType = EntityType.TAX_ID;
|
|
2500
|
+
score = .8;
|
|
2501
|
+
contextKeywords = [
|
|
2502
|
+
"ein",
|
|
2503
|
+
"tax id",
|
|
2504
|
+
"tax identification",
|
|
2505
|
+
"employer identification",
|
|
2506
|
+
"tin",
|
|
2507
|
+
"tax #",
|
|
2508
|
+
"ein#"
|
|
2509
|
+
];
|
|
2510
|
+
contextRequired = true;
|
|
2511
|
+
contextWindow = 50;
|
|
2512
|
+
pattern = /\b\d{2}-\d{7}\b/g;
|
|
2513
|
+
};
|
|
2514
|
+
registerRegion("us", TaxIdDetector);
|
|
2515
|
+
} });
|
|
2516
|
+
|
|
2517
|
+
//#endregion
|
|
2518
|
+
//#region src/regex/detectors/us/zip-code.ts
|
|
2519
|
+
function zipValid(text) {
|
|
2520
|
+
let digits = "";
|
|
2521
|
+
for (const c of text) if (c >= "0" && c <= "9") digits += c;
|
|
2522
|
+
return !digits.startsWith("000");
|
|
2523
|
+
}
|
|
2524
|
+
var ZipCodeDetector;
|
|
2525
|
+
var init_zip_code = __esm({ "src/regex/detectors/us/zip-code.ts"() {
|
|
2526
|
+
init_base();
|
|
2527
|
+
init_entities();
|
|
2528
|
+
init_registry();
|
|
2529
|
+
ZipCodeDetector = class extends RegexDetector {
|
|
2530
|
+
entityType = EntityType.ZIP_CODE;
|
|
2531
|
+
score = .7;
|
|
2532
|
+
contextKeywords = [
|
|
2533
|
+
"zip",
|
|
2534
|
+
"postal",
|
|
2535
|
+
"zip code",
|
|
2536
|
+
"zipcode",
|
|
2537
|
+
"postal code",
|
|
2538
|
+
"address",
|
|
2539
|
+
"city",
|
|
2540
|
+
"state",
|
|
2541
|
+
"mailing",
|
|
2542
|
+
"shipping",
|
|
2543
|
+
"billing",
|
|
2544
|
+
"delivery",
|
|
2545
|
+
"location",
|
|
2546
|
+
"resident",
|
|
2547
|
+
"zip+4",
|
|
2548
|
+
"usa",
|
|
2549
|
+
"united states"
|
|
2550
|
+
];
|
|
2551
|
+
contextRequired = true;
|
|
2552
|
+
contextWindow = 150;
|
|
2553
|
+
pattern = /\b\d{5}(?:-\d{4})?\b/g;
|
|
2554
|
+
validator = zipValid;
|
|
2555
|
+
};
|
|
2556
|
+
registerRegion("us", ZipCodeDetector);
|
|
2557
|
+
} });
|
|
2558
|
+
|
|
2559
|
+
//#endregion
|
|
2560
|
+
//#region src/regex/detectors/us/itin.ts
|
|
2561
|
+
var UsItinDetector;
|
|
2562
|
+
var init_itin = __esm({ "src/regex/detectors/us/itin.ts"() {
|
|
2563
|
+
init_base();
|
|
2564
|
+
init_entities();
|
|
2565
|
+
init_registry();
|
|
2566
|
+
init_validators();
|
|
2567
|
+
UsItinDetector = class extends RegexDetector {
|
|
2568
|
+
entityType = EntityType.US_ITIN;
|
|
2569
|
+
score = .85;
|
|
2570
|
+
contextKeywords = [
|
|
2571
|
+
"itin",
|
|
2572
|
+
"individual taxpayer",
|
|
2573
|
+
"tax identification"
|
|
2574
|
+
];
|
|
2575
|
+
contextRequired = true;
|
|
2576
|
+
pattern = /\b9\d{2}[- ]?\d{2}[- ]?\d{4}\b/g;
|
|
2577
|
+
validator = usItinValid;
|
|
2578
|
+
};
|
|
2579
|
+
registerRegion("us", UsItinDetector);
|
|
2580
|
+
} });
|
|
2581
|
+
|
|
2582
|
+
//#endregion
|
|
2583
|
+
//#region src/regex/detectors/us/index.ts
|
|
2584
|
+
var init_us = __esm({ "src/regex/detectors/us/index.ts"() {
|
|
2585
|
+
init_ssn();
|
|
2586
|
+
init_drivers_license();
|
|
2587
|
+
init_passport$1();
|
|
2588
|
+
init_tax_id$2();
|
|
2589
|
+
init_zip_code();
|
|
2590
|
+
init_itin();
|
|
2591
|
+
} });
|
|
2592
|
+
|
|
2593
|
+
//#endregion
|
|
2594
|
+
//#region src/regex/detectors/eu/iban.ts
|
|
2595
|
+
var IbanDetector;
|
|
2596
|
+
var init_iban = __esm({ "src/regex/detectors/eu/iban.ts"() {
|
|
2597
|
+
init_base();
|
|
2598
|
+
init_entities();
|
|
2599
|
+
init_registry();
|
|
2600
|
+
init_validators();
|
|
2601
|
+
IbanDetector = class extends RegexDetector {
|
|
2602
|
+
entityType = EntityType.IBAN;
|
|
2603
|
+
score = .9;
|
|
2604
|
+
pattern = /\b[A-Z]{2}\d{2}\s?[\dA-Z]{4}(?:\s?[\dA-Z]{4}){1,7}(?:\s?[\dA-Z]{1,4})?\b/g;
|
|
2605
|
+
validator = ibanMod97;
|
|
2606
|
+
};
|
|
2607
|
+
registerRegion("eu", IbanDetector);
|
|
2608
|
+
} });
|
|
2609
|
+
|
|
2610
|
+
//#endregion
|
|
2611
|
+
//#region src/regex/detectors/eu/postal-code.ts
|
|
2612
|
+
var EuPostalCodeDetector;
|
|
2613
|
+
var init_postal_code = __esm({ "src/regex/detectors/eu/postal-code.ts"() {
|
|
2614
|
+
init_base();
|
|
2615
|
+
init_entities();
|
|
2616
|
+
init_registry();
|
|
2617
|
+
EuPostalCodeDetector = class extends RegexDetector {
|
|
2618
|
+
entityType = EntityType.EU_POSTAL_CODE;
|
|
2619
|
+
score = .7;
|
|
2620
|
+
contextKeywords = [
|
|
2621
|
+
"postal",
|
|
2622
|
+
"postcode",
|
|
2623
|
+
"post code",
|
|
2624
|
+
"zip",
|
|
2625
|
+
"plz",
|
|
2626
|
+
"postleitzahl",
|
|
2627
|
+
"code postal"
|
|
2628
|
+
];
|
|
2629
|
+
contextRequired = true;
|
|
2630
|
+
contextWindow = 50;
|
|
2631
|
+
pattern = new RegExp("\\b(?:\\d{5}|\\d{4}\\s?[A-Z]{2})\\b", "g");
|
|
2632
|
+
};
|
|
2633
|
+
registerRegion("eu", EuPostalCodeDetector);
|
|
2634
|
+
} });
|
|
2635
|
+
|
|
2636
|
+
//#endregion
|
|
2637
|
+
//#region src/regex/detectors/eu/vat-id.ts
|
|
2638
|
+
var VatIdDetector;
|
|
2639
|
+
var init_vat_id = __esm({ "src/regex/detectors/eu/vat-id.ts"() {
|
|
2640
|
+
init_base();
|
|
2641
|
+
init_entities();
|
|
2642
|
+
init_registry();
|
|
2643
|
+
VatIdDetector = class extends RegexDetector {
|
|
2644
|
+
entityType = EntityType.VAT_ID;
|
|
2645
|
+
score = .9;
|
|
2646
|
+
pattern = new RegExp("\\b(?:ATU\\d{8}|BE[01]\\d{9}|DE\\d{9}|DK\\d{8}|ES[A-Z0-9]\\d{7}[A-Z0-9]|FI\\d{8}|FR[A-Z0-9]{2}\\d{9}|IT\\d{11}|LU\\d{8}|NL\\d{9}B\\d{2}|PL\\d{10}|PT\\d{9}|SE\\d{12})\\b", "g");
|
|
2647
|
+
};
|
|
2648
|
+
registerRegion("eu", VatIdDetector);
|
|
2649
|
+
} });
|
|
2650
|
+
|
|
2651
|
+
//#endregion
|
|
2652
|
+
//#region src/regex/detectors/eu/index.ts
|
|
2653
|
+
var init_eu = __esm({ "src/regex/detectors/eu/index.ts"() {
|
|
2654
|
+
init_iban();
|
|
2655
|
+
init_postal_code();
|
|
2656
|
+
init_vat_id();
|
|
2657
|
+
} });
|
|
2658
|
+
|
|
2659
|
+
//#endregion
|
|
2660
|
+
//#region src/regex/detectors/uk/ni-number.ts
|
|
2661
|
+
var NiNumberDetector;
|
|
2662
|
+
var init_ni_number = __esm({ "src/regex/detectors/uk/ni-number.ts"() {
|
|
2663
|
+
init_base();
|
|
2664
|
+
init_entities();
|
|
2665
|
+
init_registry();
|
|
2666
|
+
NiNumberDetector = class extends RegexDetector {
|
|
2667
|
+
entityType = EntityType.NI_NUMBER;
|
|
2668
|
+
score = .9;
|
|
2669
|
+
pattern = new RegExp("\\b(?!BG)(?!GB)(?!NK)(?!KN)(?!TN)(?!NT)(?!ZZ)[A-CEGHJ-PR-TW-Z][A-CEGHJ-NPR-TW-Z]\\s?\\d{2}\\s?\\d{2}\\s?\\d{2}\\s?[A-D]\\b", "gi");
|
|
2670
|
+
};
|
|
2671
|
+
registerRegion("uk", NiNumberDetector);
|
|
2672
|
+
} });
|
|
2673
|
+
|
|
2674
|
+
//#endregion
|
|
2675
|
+
//#region src/regex/detectors/uk/nhs-number.ts
|
|
2676
|
+
var NhsNumberDetector;
|
|
2677
|
+
var init_nhs_number = __esm({ "src/regex/detectors/uk/nhs-number.ts"() {
|
|
2678
|
+
init_base();
|
|
2679
|
+
init_entities();
|
|
2680
|
+
init_registry();
|
|
2681
|
+
init_validators();
|
|
2682
|
+
NhsNumberDetector = class extends RegexDetector {
|
|
2683
|
+
entityType = EntityType.NHS_NUMBER;
|
|
2684
|
+
score = .85;
|
|
2685
|
+
contextKeywords = [
|
|
2686
|
+
"nhs",
|
|
2687
|
+
"national health",
|
|
2688
|
+
"nhs number",
|
|
2689
|
+
"nhs#"
|
|
2690
|
+
];
|
|
2691
|
+
contextRequired = false;
|
|
2692
|
+
contextWindow = 50;
|
|
2693
|
+
pattern = /\b\d{3}\s?\d{3}\s?\d{4}\b/g;
|
|
2694
|
+
validator = nhsChecksum;
|
|
2695
|
+
};
|
|
2696
|
+
registerRegion("uk", NhsNumberDetector);
|
|
2697
|
+
} });
|
|
2698
|
+
|
|
2699
|
+
//#endregion
|
|
2700
|
+
//#region src/regex/detectors/uk/postcode.ts
|
|
2701
|
+
var UkPostcodeDetector;
|
|
2702
|
+
var init_postcode = __esm({ "src/regex/detectors/uk/postcode.ts"() {
|
|
2703
|
+
init_base();
|
|
2704
|
+
init_entities();
|
|
2705
|
+
init_registry();
|
|
2706
|
+
UkPostcodeDetector = class extends RegexDetector {
|
|
2707
|
+
entityType = EntityType.UK_POSTCODE;
|
|
2708
|
+
score = .85;
|
|
2709
|
+
pattern = new RegExp("\\b(?:[A-Z]{1,2}\\d[A-Z\\d]?\\s?\\d[A-Z]{2})\\b", "gi");
|
|
2710
|
+
};
|
|
2711
|
+
registerRegion("uk", UkPostcodeDetector);
|
|
2712
|
+
} });
|
|
2713
|
+
|
|
2714
|
+
//#endregion
|
|
2715
|
+
//#region src/regex/detectors/uk/passport.ts
|
|
2716
|
+
var UkPassportDetector;
|
|
2717
|
+
var init_passport = __esm({ "src/regex/detectors/uk/passport.ts"() {
|
|
2718
|
+
init_base();
|
|
2719
|
+
init_entities();
|
|
2720
|
+
init_registry();
|
|
2721
|
+
UkPassportDetector = class extends RegexDetector {
|
|
2722
|
+
entityType = EntityType.UK_PASSPORT;
|
|
2723
|
+
score = .75;
|
|
2724
|
+
contextKeywords = [
|
|
2725
|
+
"passport",
|
|
2726
|
+
"passport#",
|
|
2727
|
+
"passport #",
|
|
2728
|
+
"passport number",
|
|
2729
|
+
"passport no"
|
|
2730
|
+
];
|
|
2731
|
+
contextRequired = true;
|
|
2732
|
+
contextWindow = 50;
|
|
2733
|
+
pattern = /\b\d{9}\b/g;
|
|
2734
|
+
};
|
|
2735
|
+
registerRegion("uk", UkPassportDetector);
|
|
2736
|
+
} });
|
|
2737
|
+
|
|
2738
|
+
//#endregion
|
|
2739
|
+
//#region src/regex/detectors/uk/utr.ts
|
|
2740
|
+
var UkUtrDetector;
|
|
2741
|
+
var init_utr = __esm({ "src/regex/detectors/uk/utr.ts"() {
|
|
2742
|
+
init_base();
|
|
2743
|
+
init_entities();
|
|
2744
|
+
init_registry();
|
|
2745
|
+
init_validators();
|
|
2746
|
+
UkUtrDetector = class extends RegexDetector {
|
|
2747
|
+
entityType = EntityType.UK_UTR;
|
|
2748
|
+
score = .85;
|
|
2749
|
+
contextKeywords = [
|
|
2750
|
+
"utr",
|
|
2751
|
+
"unique taxpayer",
|
|
2752
|
+
"tax reference",
|
|
2753
|
+
"self assessment",
|
|
2754
|
+
"hmrc"
|
|
2755
|
+
];
|
|
2756
|
+
contextRequired = true;
|
|
2757
|
+
pattern = /\b\d{10}\b/g;
|
|
2758
|
+
validator = ukUtrChecksum;
|
|
2759
|
+
};
|
|
2760
|
+
registerRegion("uk", UkUtrDetector);
|
|
2761
|
+
} });
|
|
2762
|
+
|
|
2763
|
+
//#endregion
|
|
2764
|
+
//#region src/regex/detectors/uk/index.ts
|
|
2765
|
+
var init_uk = __esm({ "src/regex/detectors/uk/index.ts"() {
|
|
2766
|
+
init_ni_number();
|
|
2767
|
+
init_nhs_number();
|
|
2768
|
+
init_postcode();
|
|
2769
|
+
init_passport();
|
|
2770
|
+
init_utr();
|
|
2771
|
+
} });
|
|
2772
|
+
|
|
2773
|
+
//#endregion
|
|
2774
|
+
//#region src/regex/detectors/de/personal-id.ts
|
|
2775
|
+
var DePersonalIdDetector;
|
|
2776
|
+
var init_personal_id = __esm({ "src/regex/detectors/de/personal-id.ts"() {
|
|
2777
|
+
init_base();
|
|
2778
|
+
init_entities();
|
|
2779
|
+
init_registry();
|
|
2780
|
+
DePersonalIdDetector = class extends RegexDetector {
|
|
2781
|
+
entityType = EntityType.DE_PERSONAL_ID;
|
|
2782
|
+
score = .75;
|
|
2783
|
+
contextKeywords = [
|
|
2784
|
+
"personalausweis",
|
|
2785
|
+
"personal id",
|
|
2786
|
+
"ausweis",
|
|
2787
|
+
"identifikation",
|
|
2788
|
+
"id-nummer",
|
|
2789
|
+
"ausweisnummer"
|
|
2790
|
+
];
|
|
2791
|
+
contextRequired = true;
|
|
2792
|
+
contextWindow = 50;
|
|
2793
|
+
pattern = /\b[CFGHJKLMNPRTVWXYZ][0-9A-Z][0-9]{7}[0-9]\b/gi;
|
|
2794
|
+
};
|
|
2795
|
+
registerRegion("de", DePersonalIdDetector);
|
|
2796
|
+
} });
|
|
2797
|
+
|
|
2798
|
+
//#endregion
|
|
2799
|
+
//#region src/regex/detectors/de/tax-id.ts
|
|
2800
|
+
var DeTaxIdDetector;
|
|
2801
|
+
var init_tax_id$1 = __esm({ "src/regex/detectors/de/tax-id.ts"() {
|
|
2802
|
+
init_base();
|
|
2803
|
+
init_entities();
|
|
2804
|
+
init_registry();
|
|
2805
|
+
init_validators();
|
|
2806
|
+
DeTaxIdDetector = class extends RegexDetector {
|
|
2807
|
+
entityType = EntityType.DE_TAX_ID;
|
|
2808
|
+
score = .85;
|
|
2809
|
+
contextKeywords = [
|
|
2810
|
+
"steuer",
|
|
2811
|
+
"tax id",
|
|
2812
|
+
"steueridentifikationsnummer",
|
|
2813
|
+
"tin",
|
|
2814
|
+
"identifikationsnummer",
|
|
2815
|
+
"steuernummer"
|
|
2816
|
+
];
|
|
2817
|
+
contextRequired = false;
|
|
2818
|
+
pattern = /\b\d{2}\s?\d{3}\s?\d{3}\s?\d{3}\b/g;
|
|
2819
|
+
validator = deTaxIdChecksum;
|
|
2820
|
+
};
|
|
2821
|
+
registerRegion("de", DeTaxIdDetector);
|
|
2822
|
+
} });
|
|
2823
|
+
|
|
2824
|
+
//#endregion
|
|
2825
|
+
//#region src/regex/detectors/de/index.ts
|
|
2826
|
+
var init_de = __esm({ "src/regex/detectors/de/index.ts"() {
|
|
2827
|
+
init_personal_id();
|
|
2828
|
+
init_tax_id$1();
|
|
2829
|
+
} });
|
|
2830
|
+
|
|
2831
|
+
//#endregion
|
|
2832
|
+
//#region src/regex/detectors/fr/national-id.ts
|
|
2833
|
+
var FrNationalIdDetector;
|
|
2834
|
+
var init_national_id = __esm({ "src/regex/detectors/fr/national-id.ts"() {
|
|
2835
|
+
init_base();
|
|
2836
|
+
init_entities();
|
|
2837
|
+
init_registry();
|
|
2838
|
+
init_validators();
|
|
2839
|
+
FrNationalIdDetector = class extends RegexDetector {
|
|
2840
|
+
entityType = EntityType.FR_NATIONAL_ID;
|
|
2841
|
+
score = .9;
|
|
2842
|
+
contextKeywords = [
|
|
2843
|
+
"nir",
|
|
2844
|
+
"securite sociale",
|
|
2845
|
+
"social security",
|
|
2846
|
+
"numero national",
|
|
2847
|
+
"insee"
|
|
2848
|
+
];
|
|
2849
|
+
contextRequired = false;
|
|
2850
|
+
pattern = /\b[12]\s?\d{2}\s?(?:0[1-9]|1[0-2]|[2-9]\d)\s?\d{2,3}\s?\d{3}\s?\d{3}\s?\d{2}\b/g;
|
|
2851
|
+
validator = frNirChecksum;
|
|
2852
|
+
};
|
|
2853
|
+
registerRegion("fr", FrNationalIdDetector);
|
|
2854
|
+
} });
|
|
2855
|
+
|
|
2856
|
+
//#endregion
|
|
2857
|
+
//#region src/regex/detectors/fr/siren.ts
|
|
2858
|
+
var FrSirenDetector;
|
|
2859
|
+
var init_siren = __esm({ "src/regex/detectors/fr/siren.ts"() {
|
|
2860
|
+
init_base();
|
|
2861
|
+
init_entities();
|
|
2862
|
+
init_registry();
|
|
2863
|
+
init_validators();
|
|
2864
|
+
FrSirenDetector = class extends RegexDetector {
|
|
2865
|
+
entityType = EntityType.FR_SIREN;
|
|
2866
|
+
score = .85;
|
|
2867
|
+
contextKeywords = [
|
|
2868
|
+
"siren",
|
|
2869
|
+
"siret",
|
|
2870
|
+
"registre du commerce",
|
|
2871
|
+
"rcs",
|
|
2872
|
+
"company number"
|
|
2873
|
+
];
|
|
2874
|
+
contextRequired = true;
|
|
2875
|
+
pattern = /\b\d{3}[- ]?\d{3}[- ]?\d{3}\b/g;
|
|
2876
|
+
validator = luhnChecksum;
|
|
2877
|
+
};
|
|
2878
|
+
registerRegion("fr", FrSirenDetector);
|
|
2879
|
+
} });
|
|
2880
|
+
|
|
2881
|
+
//#endregion
|
|
2882
|
+
//#region src/regex/detectors/fr/index.ts
|
|
2883
|
+
var init_fr = __esm({ "src/regex/detectors/fr/index.ts"() {
|
|
2884
|
+
init_national_id();
|
|
2885
|
+
init_siren();
|
|
2886
|
+
} });
|
|
2887
|
+
|
|
2888
|
+
//#endregion
|
|
2889
|
+
//#region src/regex/detectors/es/dni.ts
|
|
2890
|
+
var EsDniDetector;
|
|
2891
|
+
var init_dni = __esm({ "src/regex/detectors/es/dni.ts"() {
|
|
2892
|
+
init_base();
|
|
2893
|
+
init_entities();
|
|
2894
|
+
init_registry();
|
|
2895
|
+
init_validators();
|
|
2896
|
+
EsDniDetector = class extends RegexDetector {
|
|
2897
|
+
entityType = EntityType.ES_DNI;
|
|
2898
|
+
score = .9;
|
|
2899
|
+
contextKeywords = [
|
|
2900
|
+
"dni",
|
|
2901
|
+
"documento nacional",
|
|
2902
|
+
"identidad"
|
|
2903
|
+
];
|
|
2904
|
+
contextRequired = false;
|
|
2905
|
+
pattern = /\b\d{8}[-\s]?[A-Z]\b/gi;
|
|
2906
|
+
validator = esDniLetter;
|
|
2907
|
+
};
|
|
2908
|
+
registerRegion("es", EsDniDetector);
|
|
2909
|
+
} });
|
|
2910
|
+
|
|
2911
|
+
//#endregion
|
|
2912
|
+
//#region src/regex/detectors/es/nie.ts
|
|
2913
|
+
var EsNieDetector;
|
|
2914
|
+
var init_nie = __esm({ "src/regex/detectors/es/nie.ts"() {
|
|
2915
|
+
init_base();
|
|
2916
|
+
init_entities();
|
|
2917
|
+
init_registry();
|
|
2918
|
+
init_validators();
|
|
2919
|
+
EsNieDetector = class extends RegexDetector {
|
|
2920
|
+
entityType = EntityType.ES_NIE;
|
|
2921
|
+
score = .9;
|
|
2922
|
+
contextKeywords = [
|
|
2923
|
+
"nie",
|
|
2924
|
+
"extranjero",
|
|
2925
|
+
"numero de identidad"
|
|
2926
|
+
];
|
|
2927
|
+
contextRequired = false;
|
|
2928
|
+
pattern = /\b[XYZ]\d{7}[-\s]?[A-Z]\b/gi;
|
|
2929
|
+
validator = esNieLetter;
|
|
2930
|
+
};
|
|
2931
|
+
registerRegion("es", EsNieDetector);
|
|
2932
|
+
} });
|
|
2933
|
+
|
|
2934
|
+
//#endregion
|
|
2935
|
+
//#region src/regex/detectors/es/nss.ts
|
|
2936
|
+
var EsNssDetector;
|
|
2937
|
+
var init_nss = __esm({ "src/regex/detectors/es/nss.ts"() {
|
|
2938
|
+
init_base();
|
|
2939
|
+
init_entities();
|
|
2940
|
+
init_registry();
|
|
2941
|
+
init_validators();
|
|
2942
|
+
EsNssDetector = class extends RegexDetector {
|
|
2943
|
+
entityType = EntityType.ES_NSS;
|
|
2944
|
+
score = .85;
|
|
2945
|
+
contextKeywords = [
|
|
2946
|
+
"nss",
|
|
2947
|
+
"numero seguridad social",
|
|
2948
|
+
"seguridad social",
|
|
2949
|
+
"social security"
|
|
2950
|
+
];
|
|
2951
|
+
contextRequired = true;
|
|
2952
|
+
pattern = /\b\d{2}[- ]?\d{8}[- ]?\d{2}\b/g;
|
|
2953
|
+
validator = esNssChecksum;
|
|
2954
|
+
};
|
|
2955
|
+
registerRegion("es", EsNssDetector);
|
|
2956
|
+
} });
|
|
2957
|
+
|
|
2958
|
+
//#endregion
|
|
2959
|
+
//#region src/regex/detectors/es/cif.ts
|
|
2960
|
+
var EsCifDetector;
|
|
2961
|
+
var init_cif = __esm({ "src/regex/detectors/es/cif.ts"() {
|
|
2962
|
+
init_base();
|
|
2963
|
+
init_entities();
|
|
2964
|
+
init_registry();
|
|
2965
|
+
init_validators();
|
|
2966
|
+
EsCifDetector = class extends RegexDetector {
|
|
2967
|
+
entityType = EntityType.ES_CIF;
|
|
2968
|
+
score = .85;
|
|
2969
|
+
contextKeywords = [
|
|
2970
|
+
"cif",
|
|
2971
|
+
"codigo de identificacion fiscal",
|
|
2972
|
+
"tax id",
|
|
2973
|
+
"nif empresa"
|
|
2974
|
+
];
|
|
2975
|
+
contextRequired = false;
|
|
2976
|
+
pattern = /\b[A-HJ-NP-SUVW]\d{7}[0-9A-J]\b/gi;
|
|
2977
|
+
validator = esCifChecksum;
|
|
2978
|
+
};
|
|
2979
|
+
registerRegion("es", EsCifDetector);
|
|
2980
|
+
} });
|
|
2981
|
+
|
|
2982
|
+
//#endregion
|
|
2983
|
+
//#region src/regex/detectors/es/index.ts
|
|
2984
|
+
var init_es = __esm({ "src/regex/detectors/es/index.ts"() {
|
|
2985
|
+
init_dni();
|
|
2986
|
+
init_nie();
|
|
2987
|
+
init_nss();
|
|
2988
|
+
init_cif();
|
|
2989
|
+
} });
|
|
2990
|
+
|
|
2991
|
+
//#endregion
|
|
2992
|
+
//#region src/regex/detectors/it/codice-fiscale.ts
|
|
2993
|
+
var ItCodiceFiscaleDetector;
|
|
2994
|
+
var init_codice_fiscale = __esm({ "src/regex/detectors/it/codice-fiscale.ts"() {
|
|
2995
|
+
init_base();
|
|
2996
|
+
init_entities();
|
|
2997
|
+
init_registry();
|
|
2998
|
+
init_validators();
|
|
2999
|
+
ItCodiceFiscaleDetector = class extends RegexDetector {
|
|
3000
|
+
entityType = EntityType.IT_CODICE_FISCALE;
|
|
3001
|
+
score = .9;
|
|
3002
|
+
contextKeywords = [
|
|
3003
|
+
"codice fiscale",
|
|
3004
|
+
"cf",
|
|
3005
|
+
"fiscal code"
|
|
3006
|
+
];
|
|
3007
|
+
contextRequired = false;
|
|
3008
|
+
pattern = /\b[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]\b/gi;
|
|
3009
|
+
validator = itCodiceFiscaleCheck;
|
|
3010
|
+
};
|
|
3011
|
+
registerRegion("it", ItCodiceFiscaleDetector);
|
|
3012
|
+
} });
|
|
3013
|
+
|
|
3014
|
+
//#endregion
|
|
3015
|
+
//#region src/regex/detectors/it/partita-iva.ts
|
|
3016
|
+
var ItPartitaIvaDetector;
|
|
3017
|
+
var init_partita_iva = __esm({ "src/regex/detectors/it/partita-iva.ts"() {
|
|
3018
|
+
init_base();
|
|
3019
|
+
init_entities();
|
|
3020
|
+
init_registry();
|
|
3021
|
+
init_validators();
|
|
3022
|
+
ItPartitaIvaDetector = class extends RegexDetector {
|
|
3023
|
+
entityType = EntityType.IT_PARTITA_IVA;
|
|
3024
|
+
score = .85;
|
|
3025
|
+
contextKeywords = [
|
|
3026
|
+
"partita iva",
|
|
3027
|
+
"p.iva",
|
|
3028
|
+
"p. iva",
|
|
3029
|
+
"vat",
|
|
3030
|
+
"iva"
|
|
3031
|
+
];
|
|
3032
|
+
contextRequired = true;
|
|
3033
|
+
pattern = /\b(?:IT)?\d{11}\b/gi;
|
|
3034
|
+
validator = itPartitaIvaChecksum;
|
|
3035
|
+
};
|
|
3036
|
+
registerRegion("it", ItPartitaIvaDetector);
|
|
3037
|
+
} });
|
|
3038
|
+
|
|
3039
|
+
//#endregion
|
|
3040
|
+
//#region src/regex/detectors/it/index.ts
|
|
3041
|
+
var init_it = __esm({ "src/regex/detectors/it/index.ts"() {
|
|
3042
|
+
init_codice_fiscale();
|
|
3043
|
+
init_partita_iva();
|
|
3044
|
+
} });
|
|
3045
|
+
|
|
3046
|
+
//#endregion
|
|
3047
|
+
//#region src/regex/detectors/pt/nif.ts
|
|
3048
|
+
var PtNifDetector;
|
|
3049
|
+
var init_nif = __esm({ "src/regex/detectors/pt/nif.ts"() {
|
|
3050
|
+
init_base();
|
|
3051
|
+
init_entities();
|
|
3052
|
+
init_registry();
|
|
3053
|
+
init_validators();
|
|
3054
|
+
PtNifDetector = class extends RegexDetector {
|
|
3055
|
+
entityType = EntityType.PT_NIF;
|
|
3056
|
+
score = .85;
|
|
3057
|
+
contextKeywords = [
|
|
3058
|
+
"nif",
|
|
3059
|
+
"contribuinte",
|
|
3060
|
+
"fiscal",
|
|
3061
|
+
"tax"
|
|
3062
|
+
];
|
|
3063
|
+
contextRequired = true;
|
|
3064
|
+
pattern = /\b[1-3589]\d{8}\b/g;
|
|
3065
|
+
validator = ptNifChecksum;
|
|
3066
|
+
};
|
|
3067
|
+
registerRegion("pt", PtNifDetector);
|
|
3068
|
+
} });
|
|
3069
|
+
|
|
3070
|
+
//#endregion
|
|
3071
|
+
//#region src/regex/detectors/pt/index.ts
|
|
3072
|
+
var init_pt = __esm({ "src/regex/detectors/pt/index.ts"() {
|
|
3073
|
+
init_nif();
|
|
3074
|
+
} });
|
|
3075
|
+
|
|
3076
|
+
//#endregion
|
|
3077
|
+
//#region src/regex/detectors/pl/pesel.ts
|
|
3078
|
+
var PlPeselDetector;
|
|
3079
|
+
var init_pesel = __esm({ "src/regex/detectors/pl/pesel.ts"() {
|
|
3080
|
+
init_base();
|
|
3081
|
+
init_entities();
|
|
3082
|
+
init_registry();
|
|
3083
|
+
init_validators();
|
|
3084
|
+
PlPeselDetector = class extends RegexDetector {
|
|
3085
|
+
entityType = EntityType.PL_PESEL;
|
|
3086
|
+
score = .85;
|
|
3087
|
+
contextKeywords = ["pesel"];
|
|
3088
|
+
contextRequired = false;
|
|
3089
|
+
pattern = /\b\d{11}\b/g;
|
|
3090
|
+
validator = plPeselChecksum;
|
|
3091
|
+
};
|
|
3092
|
+
registerRegion("pl", PlPeselDetector);
|
|
3093
|
+
} });
|
|
3094
|
+
|
|
3095
|
+
//#endregion
|
|
3096
|
+
//#region src/regex/detectors/pl/nip.ts
|
|
3097
|
+
var PlNipDetector;
|
|
3098
|
+
var init_nip = __esm({ "src/regex/detectors/pl/nip.ts"() {
|
|
3099
|
+
init_base();
|
|
3100
|
+
init_entities();
|
|
3101
|
+
init_registry();
|
|
3102
|
+
init_validators();
|
|
3103
|
+
PlNipDetector = class extends RegexDetector {
|
|
3104
|
+
entityType = EntityType.PL_NIP;
|
|
3105
|
+
score = .85;
|
|
3106
|
+
contextKeywords = [
|
|
3107
|
+
"nip",
|
|
3108
|
+
"tax",
|
|
3109
|
+
"podatkowy"
|
|
3110
|
+
];
|
|
3111
|
+
contextRequired = true;
|
|
3112
|
+
pattern = /\b\d{3}[-\s]?\d{3}[-\s]?\d{2}[-\s]?\d{2}\b/g;
|
|
3113
|
+
validator = plNipChecksum;
|
|
3114
|
+
};
|
|
3115
|
+
registerRegion("pl", PlNipDetector);
|
|
3116
|
+
} });
|
|
3117
|
+
|
|
3118
|
+
//#endregion
|
|
3119
|
+
//#region src/regex/detectors/pl/regon.ts
|
|
3120
|
+
var PlRegonDetector;
|
|
3121
|
+
var init_regon = __esm({ "src/regex/detectors/pl/regon.ts"() {
|
|
3122
|
+
init_base();
|
|
3123
|
+
init_entities();
|
|
3124
|
+
init_registry();
|
|
3125
|
+
init_validators();
|
|
3126
|
+
PlRegonDetector = class extends RegexDetector {
|
|
3127
|
+
entityType = EntityType.PL_REGON;
|
|
3128
|
+
score = .85;
|
|
3129
|
+
contextKeywords = [
|
|
3130
|
+
"regon",
|
|
3131
|
+
"statistical number",
|
|
3132
|
+
"numer statystyczny"
|
|
3133
|
+
];
|
|
3134
|
+
contextRequired = true;
|
|
3135
|
+
pattern = /\b\d{9}(?:\d{5})?\b/g;
|
|
3136
|
+
validator = plRegonChecksum;
|
|
3137
|
+
};
|
|
3138
|
+
registerRegion("pl", PlRegonDetector);
|
|
3139
|
+
} });
|
|
3140
|
+
|
|
3141
|
+
//#endregion
|
|
3142
|
+
//#region src/regex/detectors/pl/index.ts
|
|
3143
|
+
var init_pl = __esm({ "src/regex/detectors/pl/index.ts"() {
|
|
3144
|
+
init_pesel();
|
|
3145
|
+
init_nip();
|
|
3146
|
+
init_regon();
|
|
3147
|
+
} });
|
|
3148
|
+
|
|
3149
|
+
//#endregion
|
|
3150
|
+
//#region src/regex/detectors/cz/birth-number.ts
|
|
3151
|
+
var CzBirthNumberDetector;
|
|
3152
|
+
var init_birth_number$2 = __esm({ "src/regex/detectors/cz/birth-number.ts"() {
|
|
3153
|
+
init_base();
|
|
3154
|
+
init_entities();
|
|
3155
|
+
init_registry();
|
|
3156
|
+
init_validators();
|
|
3157
|
+
CzBirthNumberDetector = class extends RegexDetector {
|
|
3158
|
+
entityType = EntityType.CZ_BIRTH_NUMBER;
|
|
3159
|
+
score = .85;
|
|
3160
|
+
contextKeywords = [
|
|
3161
|
+
"rodne cislo",
|
|
3162
|
+
"birth number",
|
|
3163
|
+
"rc",
|
|
3164
|
+
"rodné číslo"
|
|
3165
|
+
];
|
|
3166
|
+
contextRequired = false;
|
|
3167
|
+
pattern = /\b\d{6}\/?\d{3,4}\b/g;
|
|
3168
|
+
validator = czBirthNumberValid;
|
|
3169
|
+
};
|
|
3170
|
+
registerRegion("cz", CzBirthNumberDetector);
|
|
3171
|
+
} });
|
|
3172
|
+
|
|
3173
|
+
//#endregion
|
|
3174
|
+
//#region src/regex/detectors/cz/ico.ts
|
|
3175
|
+
var CzIcoDetector;
|
|
3176
|
+
var init_ico$1 = __esm({ "src/regex/detectors/cz/ico.ts"() {
|
|
3177
|
+
init_base();
|
|
3178
|
+
init_entities();
|
|
3179
|
+
init_registry();
|
|
3180
|
+
init_validators();
|
|
3181
|
+
CzIcoDetector = class extends RegexDetector {
|
|
3182
|
+
entityType = EntityType.CZ_ICO;
|
|
3183
|
+
score = .85;
|
|
3184
|
+
contextKeywords = [
|
|
3185
|
+
"ico",
|
|
3186
|
+
"ičo",
|
|
3187
|
+
"identifikacni cislo",
|
|
3188
|
+
"identifikační číslo",
|
|
3189
|
+
"company id",
|
|
3190
|
+
"business id"
|
|
3191
|
+
];
|
|
3192
|
+
contextRequired = true;
|
|
3193
|
+
pattern = /\b\d{8}\b/g;
|
|
3194
|
+
validator = czIcoChecksum;
|
|
3195
|
+
};
|
|
3196
|
+
registerRegion("cz", CzIcoDetector);
|
|
3197
|
+
} });
|
|
3198
|
+
|
|
3199
|
+
//#endregion
|
|
3200
|
+
//#region src/regex/detectors/cz/dic.ts
|
|
3201
|
+
var CzDicDetector;
|
|
3202
|
+
var init_dic$1 = __esm({ "src/regex/detectors/cz/dic.ts"() {
|
|
3203
|
+
init_base();
|
|
3204
|
+
init_entities();
|
|
3205
|
+
init_registry();
|
|
3206
|
+
init_validators();
|
|
3207
|
+
CzDicDetector = class extends RegexDetector {
|
|
3208
|
+
entityType = EntityType.CZ_DIC;
|
|
3209
|
+
score = .85;
|
|
3210
|
+
contextKeywords = [
|
|
3211
|
+
"dic",
|
|
3212
|
+
"dič",
|
|
3213
|
+
"danove identifikacni cislo",
|
|
3214
|
+
"daňové identifikační číslo",
|
|
3215
|
+
"vat",
|
|
3216
|
+
"tax id"
|
|
3217
|
+
];
|
|
3218
|
+
contextRequired = false;
|
|
3219
|
+
pattern = /\bCZ\d{8,10}\b/gi;
|
|
3220
|
+
validator = czDicValid;
|
|
3221
|
+
};
|
|
3222
|
+
registerRegion("cz", CzDicDetector);
|
|
3223
|
+
} });
|
|
3224
|
+
|
|
3225
|
+
//#endregion
|
|
3226
|
+
//#region src/regex/detectors/cz/bank-account.ts
|
|
3227
|
+
var CzBankAccountDetector;
|
|
3228
|
+
var init_bank_account = __esm({ "src/regex/detectors/cz/bank-account.ts"() {
|
|
3229
|
+
init_base();
|
|
3230
|
+
init_entities();
|
|
3231
|
+
init_registry();
|
|
3232
|
+
init_validators();
|
|
3233
|
+
CzBankAccountDetector = class extends RegexDetector {
|
|
3234
|
+
entityType = EntityType.CZ_BANK_ACCOUNT;
|
|
3235
|
+
score = .85;
|
|
3236
|
+
contextKeywords = [
|
|
3237
|
+
"ucet",
|
|
3238
|
+
"účet",
|
|
3239
|
+
"cislo uctu",
|
|
3240
|
+
"číslo účtu",
|
|
3241
|
+
"bank account",
|
|
3242
|
+
"bankovni",
|
|
3243
|
+
"bankovní"
|
|
3244
|
+
];
|
|
3245
|
+
contextRequired = false;
|
|
3246
|
+
pattern = /\b(?:\d{1,6}-)?\d{2,10}\/\d{4}\b/g;
|
|
3247
|
+
validator = czBankAccountValid;
|
|
3248
|
+
};
|
|
3249
|
+
registerRegion("cz", CzBankAccountDetector);
|
|
3250
|
+
} });
|
|
3251
|
+
|
|
3252
|
+
//#endregion
|
|
3253
|
+
//#region src/regex/detectors/cz/index.ts
|
|
3254
|
+
var init_cz = __esm({ "src/regex/detectors/cz/index.ts"() {
|
|
3255
|
+
init_birth_number$2();
|
|
3256
|
+
init_ico$1();
|
|
3257
|
+
init_dic$1();
|
|
3258
|
+
init_bank_account();
|
|
3259
|
+
} });
|
|
3260
|
+
|
|
3261
|
+
//#endregion
|
|
3262
|
+
//#region src/regex/detectors/ru/inn.ts
|
|
3263
|
+
var RuInnDetector;
|
|
3264
|
+
var init_inn = __esm({ "src/regex/detectors/ru/inn.ts"() {
|
|
3265
|
+
init_base();
|
|
3266
|
+
init_entities();
|
|
3267
|
+
init_registry();
|
|
3268
|
+
init_validators();
|
|
3269
|
+
RuInnDetector = class extends RegexDetector {
|
|
3270
|
+
entityType = EntityType.RU_INN;
|
|
3271
|
+
score = .85;
|
|
3272
|
+
contextKeywords = [
|
|
3273
|
+
"inn",
|
|
3274
|
+
"инн",
|
|
3275
|
+
"taxpayer",
|
|
3276
|
+
"налог"
|
|
3277
|
+
];
|
|
3278
|
+
contextRequired = true;
|
|
3279
|
+
pattern = /\b\d{10}\b|\b\d{12}\b/g;
|
|
3280
|
+
validator = ruInnChecksum;
|
|
3281
|
+
};
|
|
3282
|
+
registerRegion("ru", RuInnDetector);
|
|
3283
|
+
} });
|
|
3284
|
+
|
|
3285
|
+
//#endregion
|
|
3286
|
+
//#region src/regex/detectors/ru/snils.ts
|
|
3287
|
+
var RuSnilsDetector;
|
|
3288
|
+
var init_snils = __esm({ "src/regex/detectors/ru/snils.ts"() {
|
|
3289
|
+
init_base();
|
|
3290
|
+
init_entities();
|
|
3291
|
+
init_registry();
|
|
3292
|
+
init_validators();
|
|
3293
|
+
RuSnilsDetector = class extends RegexDetector {
|
|
3294
|
+
entityType = EntityType.RU_SNILS;
|
|
3295
|
+
score = .85;
|
|
3296
|
+
contextKeywords = [
|
|
3297
|
+
"snils",
|
|
3298
|
+
"снилс",
|
|
3299
|
+
"pension",
|
|
3300
|
+
"пенсион",
|
|
3301
|
+
"страховое свидетельство"
|
|
3302
|
+
];
|
|
3303
|
+
contextRequired = true;
|
|
3304
|
+
pattern = /\b\d{3}[-\s]?\d{3}[-\s]?\d{3}[-\s]?\d{2}\b/g;
|
|
3305
|
+
validator = ruSnilsChecksum;
|
|
3306
|
+
};
|
|
3307
|
+
registerRegion("ru", RuSnilsDetector);
|
|
3308
|
+
} });
|
|
3309
|
+
|
|
3310
|
+
//#endregion
|
|
3311
|
+
//#region src/regex/detectors/ru/index.ts
|
|
3312
|
+
var init_ru = __esm({ "src/regex/detectors/ru/index.ts"() {
|
|
3313
|
+
init_inn();
|
|
3314
|
+
init_snils();
|
|
3315
|
+
} });
|
|
3316
|
+
|
|
3317
|
+
//#endregion
|
|
3318
|
+
//#region src/regex/detectors/nl/bsn.ts
|
|
3319
|
+
var NlBsnDetector;
|
|
3320
|
+
var init_bsn = __esm({ "src/regex/detectors/nl/bsn.ts"() {
|
|
3321
|
+
init_base();
|
|
3322
|
+
init_entities();
|
|
3323
|
+
init_registry();
|
|
3324
|
+
init_validators();
|
|
3325
|
+
NlBsnDetector = class extends RegexDetector {
|
|
3326
|
+
entityType = EntityType.NL_BSN;
|
|
3327
|
+
score = .85;
|
|
3328
|
+
contextKeywords = [
|
|
3329
|
+
"bsn",
|
|
3330
|
+
"burgerservicenummer",
|
|
3331
|
+
"sofi",
|
|
3332
|
+
"citizen service"
|
|
3333
|
+
];
|
|
3334
|
+
contextRequired = true;
|
|
3335
|
+
pattern = /\b\d{9}\b/g;
|
|
3336
|
+
validator = nlBsn11test;
|
|
3337
|
+
};
|
|
3338
|
+
registerRegion("nl", NlBsnDetector);
|
|
3339
|
+
} });
|
|
3340
|
+
|
|
3341
|
+
//#endregion
|
|
3342
|
+
//#region src/regex/detectors/nl/index.ts
|
|
3343
|
+
var init_nl = __esm({ "src/regex/detectors/nl/index.ts"() {
|
|
3344
|
+
init_bsn();
|
|
3345
|
+
} });
|
|
3346
|
+
|
|
3347
|
+
//#endregion
|
|
3348
|
+
//#region src/regex/detectors/ro/cnp.ts
|
|
3349
|
+
var RoCnpDetector;
|
|
3350
|
+
var init_cnp = __esm({ "src/regex/detectors/ro/cnp.ts"() {
|
|
3351
|
+
init_base();
|
|
3352
|
+
init_entities();
|
|
3353
|
+
init_registry();
|
|
3354
|
+
init_validators();
|
|
3355
|
+
RoCnpDetector = class extends RegexDetector {
|
|
3356
|
+
entityType = EntityType.RO_CNP;
|
|
3357
|
+
score = .9;
|
|
3358
|
+
contextKeywords = [
|
|
3359
|
+
"cnp",
|
|
3360
|
+
"cod numeric personal",
|
|
3361
|
+
"personal numeric code"
|
|
3362
|
+
];
|
|
3363
|
+
contextRequired = false;
|
|
3364
|
+
pattern = /\b[1-8]\d{12}\b/g;
|
|
3365
|
+
validator = roCnpChecksum;
|
|
3366
|
+
};
|
|
3367
|
+
registerRegion("ro", RoCnpDetector);
|
|
3368
|
+
} });
|
|
3369
|
+
|
|
3370
|
+
//#endregion
|
|
3371
|
+
//#region src/regex/detectors/ro/cui.ts
|
|
3372
|
+
var RoCuiDetector;
|
|
3373
|
+
var init_cui = __esm({ "src/regex/detectors/ro/cui.ts"() {
|
|
3374
|
+
init_base();
|
|
3375
|
+
init_entities();
|
|
3376
|
+
init_registry();
|
|
3377
|
+
init_validators();
|
|
3378
|
+
RoCuiDetector = class extends RegexDetector {
|
|
3379
|
+
entityType = EntityType.RO_CUI;
|
|
3380
|
+
score = .85;
|
|
3381
|
+
contextKeywords = [
|
|
3382
|
+
"cui",
|
|
3383
|
+
"cod unic",
|
|
3384
|
+
"cod de inregistrare",
|
|
3385
|
+
"fiscal code",
|
|
3386
|
+
"cif"
|
|
3387
|
+
];
|
|
3388
|
+
contextRequired = true;
|
|
3389
|
+
pattern = /\b(?:RO)?\d{2,10}\b/gi;
|
|
3390
|
+
validator = roCuiChecksum;
|
|
3391
|
+
};
|
|
3392
|
+
registerRegion("ro", RoCuiDetector);
|
|
3393
|
+
} });
|
|
3394
|
+
|
|
3395
|
+
//#endregion
|
|
3396
|
+
//#region src/regex/detectors/ro/index.ts
|
|
3397
|
+
var init_ro = __esm({ "src/regex/detectors/ro/index.ts"() {
|
|
3398
|
+
init_cnp();
|
|
3399
|
+
init_cui();
|
|
3400
|
+
} });
|
|
3401
|
+
|
|
3402
|
+
//#endregion
|
|
3403
|
+
//#region src/regex/detectors/sk/birth-number.ts
|
|
3404
|
+
var SkBirthNumberDetector;
|
|
3405
|
+
var init_birth_number$1 = __esm({ "src/regex/detectors/sk/birth-number.ts"() {
|
|
3406
|
+
init_base();
|
|
3407
|
+
init_entities();
|
|
3408
|
+
init_registry();
|
|
3409
|
+
init_validators();
|
|
3410
|
+
SkBirthNumberDetector = class extends RegexDetector {
|
|
3411
|
+
entityType = EntityType.SK_BIRTH_NUMBER;
|
|
3412
|
+
score = .85;
|
|
3413
|
+
contextKeywords = [
|
|
3414
|
+
"rodne cislo",
|
|
3415
|
+
"birth number",
|
|
3416
|
+
"rc",
|
|
3417
|
+
"rodné číslo"
|
|
3418
|
+
];
|
|
3419
|
+
contextRequired = false;
|
|
3420
|
+
pattern = /\b\d{6}\/?\d{3,4}\b/g;
|
|
3421
|
+
validator = skBirthNumberValid;
|
|
3422
|
+
};
|
|
3423
|
+
registerRegion("sk", SkBirthNumberDetector);
|
|
3424
|
+
} });
|
|
3425
|
+
|
|
3426
|
+
//#endregion
|
|
3427
|
+
//#region src/regex/detectors/sk/ico.ts
|
|
3428
|
+
var SkIcoDetector;
|
|
3429
|
+
var init_ico = __esm({ "src/regex/detectors/sk/ico.ts"() {
|
|
3430
|
+
init_base();
|
|
3431
|
+
init_entities();
|
|
3432
|
+
init_registry();
|
|
3433
|
+
init_validators();
|
|
3434
|
+
SkIcoDetector = class extends RegexDetector {
|
|
3435
|
+
entityType = EntityType.SK_ICO;
|
|
3436
|
+
score = .85;
|
|
3437
|
+
contextKeywords = [
|
|
3438
|
+
"ico",
|
|
3439
|
+
"ičo",
|
|
3440
|
+
"identifikacne cislo",
|
|
3441
|
+
"identifikačné číslo",
|
|
3442
|
+
"company id",
|
|
3443
|
+
"business id"
|
|
3444
|
+
];
|
|
3445
|
+
contextRequired = true;
|
|
3446
|
+
pattern = /\b\d{8}\b/g;
|
|
3447
|
+
validator = skIcoChecksum;
|
|
3448
|
+
};
|
|
3449
|
+
registerRegion("sk", SkIcoDetector);
|
|
3450
|
+
} });
|
|
3451
|
+
|
|
3452
|
+
//#endregion
|
|
3453
|
+
//#region src/regex/detectors/sk/dic.ts
|
|
3454
|
+
var SkDicDetector;
|
|
3455
|
+
var init_dic = __esm({ "src/regex/detectors/sk/dic.ts"() {
|
|
3456
|
+
init_base();
|
|
3457
|
+
init_entities();
|
|
3458
|
+
init_registry();
|
|
3459
|
+
init_validators();
|
|
3460
|
+
SkDicDetector = class extends RegexDetector {
|
|
3461
|
+
entityType = EntityType.SK_DIC;
|
|
3462
|
+
score = .85;
|
|
3463
|
+
contextKeywords = [
|
|
3464
|
+
"dic",
|
|
3465
|
+
"dič",
|
|
3466
|
+
"danove identifikacne cislo",
|
|
3467
|
+
"daňové identifikačné číslo",
|
|
3468
|
+
"vat",
|
|
3469
|
+
"tax id"
|
|
3470
|
+
];
|
|
3471
|
+
contextRequired = false;
|
|
3472
|
+
pattern = /\bSK\d{10}\b/gi;
|
|
3473
|
+
validator = skDicValid;
|
|
3474
|
+
};
|
|
3475
|
+
registerRegion("sk", SkDicDetector);
|
|
3476
|
+
} });
|
|
3477
|
+
|
|
3478
|
+
//#endregion
|
|
3479
|
+
//#region src/regex/detectors/sk/index.ts
|
|
3480
|
+
var init_sk = __esm({ "src/regex/detectors/sk/index.ts"() {
|
|
3481
|
+
init_birth_number$1();
|
|
3482
|
+
init_ico();
|
|
3483
|
+
init_dic();
|
|
3484
|
+
} });
|
|
3485
|
+
|
|
3486
|
+
//#endregion
|
|
3487
|
+
//#region src/regex/detectors/dk/cpr.ts
|
|
3488
|
+
var DkCprDetector;
|
|
3489
|
+
var init_cpr = __esm({ "src/regex/detectors/dk/cpr.ts"() {
|
|
3490
|
+
init_base();
|
|
3491
|
+
init_entities();
|
|
3492
|
+
init_registry();
|
|
3493
|
+
init_validators();
|
|
3494
|
+
DkCprDetector = class extends RegexDetector {
|
|
3495
|
+
entityType = EntityType.DK_CPR;
|
|
3496
|
+
score = .85;
|
|
3497
|
+
contextKeywords = [
|
|
3498
|
+
"cpr",
|
|
3499
|
+
"personnummer",
|
|
3500
|
+
"cpr-nummer",
|
|
3501
|
+
"central person"
|
|
3502
|
+
];
|
|
3503
|
+
contextRequired = true;
|
|
3504
|
+
pattern = /\b(?:0[1-9]|[12]\d|3[01])(?:0[1-9]|1[0-2])\d{2}[-\s]?\d{4}\b/g;
|
|
3505
|
+
validator = dkCprValidDate;
|
|
3506
|
+
};
|
|
3507
|
+
registerRegion("dk", DkCprDetector);
|
|
3508
|
+
} });
|
|
3509
|
+
|
|
3510
|
+
//#endregion
|
|
3511
|
+
//#region src/regex/detectors/dk/cvr.ts
|
|
3512
|
+
var DkCvrDetector;
|
|
3513
|
+
var init_cvr = __esm({ "src/regex/detectors/dk/cvr.ts"() {
|
|
3514
|
+
init_base();
|
|
3515
|
+
init_entities();
|
|
3516
|
+
init_registry();
|
|
3517
|
+
init_validators();
|
|
3518
|
+
DkCvrDetector = class extends RegexDetector {
|
|
3519
|
+
entityType = EntityType.DK_CVR;
|
|
3520
|
+
score = .85;
|
|
3521
|
+
contextKeywords = [
|
|
3522
|
+
"cvr",
|
|
3523
|
+
"virksomhed",
|
|
3524
|
+
"erhvervsstyrelsen",
|
|
3525
|
+
"company number",
|
|
3526
|
+
"business id"
|
|
3527
|
+
];
|
|
3528
|
+
contextRequired = true;
|
|
3529
|
+
pattern = /\b(?:DK)?\d{8}\b/gi;
|
|
3530
|
+
validator = dkCvrChecksum;
|
|
3531
|
+
};
|
|
3532
|
+
registerRegion("dk", DkCvrDetector);
|
|
3533
|
+
} });
|
|
3534
|
+
|
|
3535
|
+
//#endregion
|
|
3536
|
+
//#region src/regex/detectors/dk/index.ts
|
|
3537
|
+
var init_dk = __esm({ "src/regex/detectors/dk/index.ts"() {
|
|
3538
|
+
init_cpr();
|
|
3539
|
+
init_cvr();
|
|
3540
|
+
} });
|
|
3541
|
+
|
|
3542
|
+
//#endregion
|
|
3543
|
+
//#region src/regex/detectors/se/personnummer.ts
|
|
3544
|
+
var SePersonnummerDetector;
|
|
3545
|
+
var init_personnummer = __esm({ "src/regex/detectors/se/personnummer.ts"() {
|
|
3546
|
+
init_base();
|
|
3547
|
+
init_entities();
|
|
3548
|
+
init_registry();
|
|
3549
|
+
init_validators();
|
|
3550
|
+
SePersonnummerDetector = class extends RegexDetector {
|
|
3551
|
+
entityType = EntityType.SE_PERSONNUMMER;
|
|
3552
|
+
score = .9;
|
|
3553
|
+
contextKeywords = [
|
|
3554
|
+
"personnummer",
|
|
3555
|
+
"personal number",
|
|
3556
|
+
"pnr"
|
|
3557
|
+
];
|
|
3558
|
+
contextRequired = false;
|
|
3559
|
+
pattern = /\b(?:\d{8}|\d{6})[-+]?\d{4}\b/g;
|
|
3560
|
+
validator = sePersonnummerLuhn;
|
|
3561
|
+
};
|
|
3562
|
+
registerRegion("se", SePersonnummerDetector);
|
|
3563
|
+
} });
|
|
3564
|
+
|
|
3565
|
+
//#endregion
|
|
3566
|
+
//#region src/regex/detectors/se/orgnr.ts
|
|
3567
|
+
var SeOrgnrDetector;
|
|
3568
|
+
var init_orgnr$1 = __esm({ "src/regex/detectors/se/orgnr.ts"() {
|
|
3569
|
+
init_base();
|
|
3570
|
+
init_entities();
|
|
3571
|
+
init_registry();
|
|
3572
|
+
init_validators();
|
|
3573
|
+
SeOrgnrDetector = class extends RegexDetector {
|
|
3574
|
+
entityType = EntityType.SE_ORGNR;
|
|
3575
|
+
score = .85;
|
|
3576
|
+
contextKeywords = [
|
|
3577
|
+
"organisationsnummer",
|
|
3578
|
+
"orgnr",
|
|
3579
|
+
"org nr",
|
|
3580
|
+
"organization number",
|
|
3581
|
+
"foretag"
|
|
3582
|
+
];
|
|
3583
|
+
contextRequired = true;
|
|
3584
|
+
pattern = /\b\d{6}-?\d{4}\b/g;
|
|
3585
|
+
validator = seOrgnrChecksum;
|
|
3586
|
+
};
|
|
3587
|
+
registerRegion("se", SeOrgnrDetector);
|
|
3588
|
+
} });
|
|
3589
|
+
|
|
3590
|
+
//#endregion
|
|
3591
|
+
//#region src/regex/detectors/se/index.ts
|
|
3592
|
+
var init_se = __esm({ "src/regex/detectors/se/index.ts"() {
|
|
3593
|
+
init_personnummer();
|
|
3594
|
+
init_orgnr$1();
|
|
3595
|
+
} });
|
|
3596
|
+
|
|
3597
|
+
//#endregion
|
|
3598
|
+
//#region src/regex/detectors/no/birth-number.ts
|
|
3599
|
+
var NoBirthNumberDetector;
|
|
3600
|
+
var init_birth_number = __esm({ "src/regex/detectors/no/birth-number.ts"() {
|
|
3601
|
+
init_base();
|
|
3602
|
+
init_entities();
|
|
3603
|
+
init_registry();
|
|
3604
|
+
init_validators();
|
|
3605
|
+
NoBirthNumberDetector = class extends RegexDetector {
|
|
3606
|
+
entityType = EntityType.NO_BIRTH_NUMBER;
|
|
3607
|
+
score = .9;
|
|
3608
|
+
contextKeywords = [
|
|
3609
|
+
"fodselsnummer",
|
|
3610
|
+
"birth number",
|
|
3611
|
+
"personnummer",
|
|
3612
|
+
"fødselsnummer"
|
|
3613
|
+
];
|
|
3614
|
+
contextRequired = false;
|
|
3615
|
+
pattern = /\b(?:0[1-9]|[12]\d|3[01])(?:0[1-9]|1[0-2])\d{7}\b/g;
|
|
3616
|
+
validator = noBirthNumberChecksum;
|
|
3617
|
+
};
|
|
3618
|
+
registerRegion("no", NoBirthNumberDetector);
|
|
3619
|
+
} });
|
|
3620
|
+
|
|
3621
|
+
//#endregion
|
|
3622
|
+
//#region src/regex/detectors/no/orgnr.ts
|
|
3623
|
+
var NoOrgnrDetector;
|
|
3624
|
+
var init_orgnr = __esm({ "src/regex/detectors/no/orgnr.ts"() {
|
|
3625
|
+
init_base();
|
|
3626
|
+
init_entities();
|
|
3627
|
+
init_registry();
|
|
3628
|
+
init_validators();
|
|
3629
|
+
NoOrgnrDetector = class extends RegexDetector {
|
|
3630
|
+
entityType = EntityType.NO_ORGNR;
|
|
3631
|
+
score = .85;
|
|
3632
|
+
contextKeywords = [
|
|
3633
|
+
"organisasjonsnummer",
|
|
3634
|
+
"orgnr",
|
|
3635
|
+
"org nr",
|
|
3636
|
+
"organization number",
|
|
3637
|
+
"foretaksnummer"
|
|
3638
|
+
];
|
|
3639
|
+
contextRequired = true;
|
|
3640
|
+
pattern = /\b\d{9}\b/g;
|
|
3641
|
+
validator = noOrgnrChecksum;
|
|
3642
|
+
};
|
|
3643
|
+
registerRegion("no", NoOrgnrDetector);
|
|
3644
|
+
} });
|
|
3645
|
+
|
|
3646
|
+
//#endregion
|
|
3647
|
+
//#region src/regex/detectors/no/index.ts
|
|
3648
|
+
var init_no = __esm({ "src/regex/detectors/no/index.ts"() {
|
|
3649
|
+
init_birth_number();
|
|
3650
|
+
init_orgnr();
|
|
3651
|
+
} });
|
|
3652
|
+
|
|
3653
|
+
//#endregion
|
|
3654
|
+
//#region src/regex/detectors/br/cpf.ts
|
|
3655
|
+
var BrCpfDetector;
|
|
3656
|
+
var init_cpf = __esm({ "src/regex/detectors/br/cpf.ts"() {
|
|
3657
|
+
init_base();
|
|
3658
|
+
init_entities();
|
|
3659
|
+
init_registry();
|
|
3660
|
+
init_validators();
|
|
3661
|
+
BrCpfDetector = class extends RegexDetector {
|
|
3662
|
+
entityType = EntityType.BR_CPF;
|
|
3663
|
+
score = .9;
|
|
3664
|
+
contextKeywords = ["cpf", "cadastro de pessoa"];
|
|
3665
|
+
contextRequired = false;
|
|
3666
|
+
pattern = /\b\d{3}\.?\d{3}\.?\d{3}[-.]?\d{2}\b/g;
|
|
3667
|
+
validator = brCpfChecksum;
|
|
3668
|
+
};
|
|
3669
|
+
registerRegion("br", BrCpfDetector);
|
|
3670
|
+
} });
|
|
3671
|
+
|
|
3672
|
+
//#endregion
|
|
3673
|
+
//#region src/regex/detectors/br/cnpj.ts
|
|
3674
|
+
var BrCnpjDetector;
|
|
3675
|
+
var init_cnpj = __esm({ "src/regex/detectors/br/cnpj.ts"() {
|
|
3676
|
+
init_base();
|
|
3677
|
+
init_entities();
|
|
3678
|
+
init_registry();
|
|
3679
|
+
init_validators();
|
|
3680
|
+
BrCnpjDetector = class extends RegexDetector {
|
|
3681
|
+
entityType = EntityType.BR_CNPJ;
|
|
3682
|
+
score = .9;
|
|
3683
|
+
contextKeywords = ["cnpj", "cadastro nacional"];
|
|
3684
|
+
contextRequired = false;
|
|
3685
|
+
pattern = /\b\d{2}\.?\d{3}\.?\d{3}\/?\d{4}[-.]?\d{2}\b/g;
|
|
3686
|
+
validator = brCnpjChecksum;
|
|
3687
|
+
};
|
|
3688
|
+
registerRegion("br", BrCnpjDetector);
|
|
3689
|
+
} });
|
|
3690
|
+
|
|
3691
|
+
//#endregion
|
|
3692
|
+
//#region src/regex/detectors/br/index.ts
|
|
3693
|
+
var init_br = __esm({ "src/regex/detectors/br/index.ts"() {
|
|
3694
|
+
init_cpf();
|
|
3695
|
+
init_cnpj();
|
|
3696
|
+
} });
|
|
3697
|
+
|
|
3698
|
+
//#endregion
|
|
3699
|
+
//#region src/regex/detectors/be/national-number.ts
|
|
3700
|
+
var BeNationalNumberDetector;
|
|
3701
|
+
var init_national_number = __esm({ "src/regex/detectors/be/national-number.ts"() {
|
|
3702
|
+
init_base();
|
|
3703
|
+
init_entities();
|
|
3704
|
+
init_registry();
|
|
3705
|
+
init_validators();
|
|
3706
|
+
BeNationalNumberDetector = class extends RegexDetector {
|
|
3707
|
+
entityType = EntityType.BE_NATIONAL_NUMBER;
|
|
3708
|
+
score = .85;
|
|
3709
|
+
contextKeywords = [
|
|
3710
|
+
"rijksregisternummer",
|
|
3711
|
+
"national number",
|
|
3712
|
+
"numero national",
|
|
3713
|
+
"registre national",
|
|
3714
|
+
"nn"
|
|
3715
|
+
];
|
|
3716
|
+
contextRequired = true;
|
|
3717
|
+
contextWindow = 50;
|
|
3718
|
+
pattern = /\b\d{2}[. ]?\d{2}[. ]?\d{2}[- ]?\d{3}[. ]?\d{2}\b/g;
|
|
3719
|
+
validator = beNationalNumberChecksum;
|
|
3720
|
+
};
|
|
3721
|
+
registerRegion("be", BeNationalNumberDetector);
|
|
3722
|
+
} });
|
|
3723
|
+
|
|
3724
|
+
//#endregion
|
|
3725
|
+
//#region src/regex/detectors/be/enterprise-number.ts
|
|
3726
|
+
var BeEnterpriseNumberDetector;
|
|
3727
|
+
var init_enterprise_number = __esm({ "src/regex/detectors/be/enterprise-number.ts"() {
|
|
3728
|
+
init_base();
|
|
3729
|
+
init_entities();
|
|
3730
|
+
init_registry();
|
|
3731
|
+
init_validators();
|
|
3732
|
+
BeEnterpriseNumberDetector = class extends RegexDetector {
|
|
3733
|
+
entityType = EntityType.BE_ENTERPRISE_NUMBER;
|
|
3734
|
+
score = .85;
|
|
3735
|
+
contextKeywords = [
|
|
3736
|
+
"bce",
|
|
3737
|
+
"kbo",
|
|
3738
|
+
"enterprise number",
|
|
3739
|
+
"ondernemingsnummer",
|
|
3740
|
+
"numero entreprise"
|
|
3741
|
+
];
|
|
3742
|
+
contextRequired = true;
|
|
3743
|
+
contextWindow = 50;
|
|
3744
|
+
pattern = /\b[01]\d{3}[. ]?\d{3}[. ]?\d{3}\b/g;
|
|
3745
|
+
validator = beEnterpriseChecksum;
|
|
3746
|
+
};
|
|
3747
|
+
registerRegion("be", BeEnterpriseNumberDetector);
|
|
3748
|
+
} });
|
|
3749
|
+
|
|
3750
|
+
//#endregion
|
|
3751
|
+
//#region src/regex/detectors/be/index.ts
|
|
3752
|
+
var init_be = __esm({ "src/regex/detectors/be/index.ts"() {
|
|
3753
|
+
init_national_number();
|
|
3754
|
+
init_enterprise_number();
|
|
3755
|
+
} });
|
|
3756
|
+
|
|
3757
|
+
//#endregion
|
|
3758
|
+
//#region src/regex/detectors/at/svnr.ts
|
|
3759
|
+
var AtSvnrDetector;
|
|
3760
|
+
var init_svnr = __esm({ "src/regex/detectors/at/svnr.ts"() {
|
|
3761
|
+
init_base();
|
|
3762
|
+
init_entities();
|
|
3763
|
+
init_registry();
|
|
3764
|
+
init_validators();
|
|
3765
|
+
AtSvnrDetector = class extends RegexDetector {
|
|
3766
|
+
entityType = EntityType.AT_SVNR;
|
|
3767
|
+
score = .85;
|
|
3768
|
+
contextKeywords = [
|
|
3769
|
+
"svnr",
|
|
3770
|
+
"sozialversicherungsnummer",
|
|
3771
|
+
"versicherungsnummer",
|
|
3772
|
+
"social insurance"
|
|
3773
|
+
];
|
|
3774
|
+
contextRequired = true;
|
|
3775
|
+
contextWindow = 50;
|
|
3776
|
+
pattern = /\b\d{4}[- ]?\d{6}\b/g;
|
|
3777
|
+
validator = atSvnrChecksum;
|
|
3778
|
+
};
|
|
3779
|
+
registerRegion("at", AtSvnrDetector);
|
|
3780
|
+
} });
|
|
3781
|
+
|
|
3782
|
+
//#endregion
|
|
3783
|
+
//#region src/regex/detectors/at/index.ts
|
|
3784
|
+
var init_at = __esm({ "src/regex/detectors/at/index.ts"() {
|
|
3785
|
+
init_svnr();
|
|
3786
|
+
} });
|
|
3787
|
+
|
|
3788
|
+
//#endregion
|
|
3789
|
+
//#region src/regex/detectors/ie/pps.ts
|
|
3790
|
+
var IePpsDetector;
|
|
3791
|
+
var init_pps = __esm({ "src/regex/detectors/ie/pps.ts"() {
|
|
3792
|
+
init_base();
|
|
3793
|
+
init_entities();
|
|
3794
|
+
init_registry();
|
|
3795
|
+
init_validators();
|
|
3796
|
+
IePpsDetector = class extends RegexDetector {
|
|
3797
|
+
entityType = EntityType.IE_PPS;
|
|
3798
|
+
score = .85;
|
|
3799
|
+
contextKeywords = [
|
|
3800
|
+
"pps",
|
|
3801
|
+
"ppsn",
|
|
3802
|
+
"personal public service",
|
|
3803
|
+
"revenue"
|
|
3804
|
+
];
|
|
3805
|
+
contextRequired = false;
|
|
3806
|
+
contextWindow = 50;
|
|
3807
|
+
pattern = /\b\d{7}[A-Z]{1,2}\b/gi;
|
|
3808
|
+
validator = iePpsChecksum;
|
|
3809
|
+
};
|
|
3810
|
+
registerRegion("ie", IePpsDetector);
|
|
3811
|
+
} });
|
|
3812
|
+
|
|
3813
|
+
//#endregion
|
|
3814
|
+
//#region src/regex/detectors/ie/index.ts
|
|
3815
|
+
var init_ie = __esm({ "src/regex/detectors/ie/index.ts"() {
|
|
3816
|
+
init_pps();
|
|
3817
|
+
} });
|
|
3818
|
+
|
|
3819
|
+
//#endregion
|
|
3820
|
+
//#region src/regex/detectors/fi/hetu.ts
|
|
3821
|
+
var FiHetuDetector;
|
|
3822
|
+
var init_hetu = __esm({ "src/regex/detectors/fi/hetu.ts"() {
|
|
3823
|
+
init_base();
|
|
3824
|
+
init_entities();
|
|
3825
|
+
init_registry();
|
|
3826
|
+
init_validators();
|
|
3827
|
+
FiHetuDetector = class extends RegexDetector {
|
|
3828
|
+
entityType = EntityType.FI_HETU;
|
|
3829
|
+
score = .85;
|
|
3830
|
+
contextKeywords = [
|
|
3831
|
+
"henkilotunnus",
|
|
3832
|
+
"hetu",
|
|
3833
|
+
"personal identity code",
|
|
3834
|
+
"sosiaaliturvatunnus"
|
|
3835
|
+
];
|
|
3836
|
+
contextRequired = false;
|
|
3837
|
+
pattern = /\b\d{6}[-+ABCDEFYXWVUabcdefyxwvu]\d{3}[0-9A-Za-z]\b/g;
|
|
3838
|
+
validator = fiHetuChecksum;
|
|
3839
|
+
};
|
|
3840
|
+
registerRegion("fi", FiHetuDetector);
|
|
3841
|
+
} });
|
|
3842
|
+
|
|
3843
|
+
//#endregion
|
|
3844
|
+
//#region src/regex/detectors/fi/ytunnus.ts
|
|
3845
|
+
var FiYtunnusDetector;
|
|
3846
|
+
var init_ytunnus = __esm({ "src/regex/detectors/fi/ytunnus.ts"() {
|
|
3847
|
+
init_base();
|
|
3848
|
+
init_entities();
|
|
3849
|
+
init_registry();
|
|
3850
|
+
init_validators();
|
|
3851
|
+
FiYtunnusDetector = class extends RegexDetector {
|
|
3852
|
+
entityType = EntityType.FI_YTUNNUS;
|
|
3853
|
+
score = .85;
|
|
3854
|
+
contextKeywords = [
|
|
3855
|
+
"y-tunnus",
|
|
3856
|
+
"ytunnus",
|
|
3857
|
+
"business id",
|
|
3858
|
+
"yritystunnus",
|
|
3859
|
+
"fo-nummer"
|
|
3860
|
+
];
|
|
3861
|
+
contextRequired = true;
|
|
3862
|
+
contextWindow = 50;
|
|
3863
|
+
pattern = /\b\d{7}-\d\b/g;
|
|
3864
|
+
validator = fiYtunnusChecksum;
|
|
3865
|
+
};
|
|
3866
|
+
registerRegion("fi", FiYtunnusDetector);
|
|
3867
|
+
} });
|
|
3868
|
+
|
|
3869
|
+
//#endregion
|
|
3870
|
+
//#region src/regex/detectors/fi/index.ts
|
|
3871
|
+
var init_fi = __esm({ "src/regex/detectors/fi/index.ts"() {
|
|
3872
|
+
init_hetu();
|
|
3873
|
+
init_ytunnus();
|
|
3874
|
+
} });
|
|
3875
|
+
|
|
3876
|
+
//#endregion
|
|
3877
|
+
//#region src/regex/detectors/hu/tax-id.ts
|
|
3878
|
+
var HuTaxIdDetector;
|
|
3879
|
+
var init_tax_id = __esm({ "src/regex/detectors/hu/tax-id.ts"() {
|
|
3880
|
+
init_base();
|
|
3881
|
+
init_entities();
|
|
3882
|
+
init_registry();
|
|
3883
|
+
init_validators();
|
|
3884
|
+
HuTaxIdDetector = class extends RegexDetector {
|
|
3885
|
+
entityType = EntityType.HU_TAX_ID;
|
|
3886
|
+
score = .85;
|
|
3887
|
+
contextKeywords = [
|
|
3888
|
+
"adoazonosito",
|
|
3889
|
+
"adószám",
|
|
3890
|
+
"tax id",
|
|
3891
|
+
"tax number",
|
|
3892
|
+
"adoazonosito jel"
|
|
3893
|
+
];
|
|
3894
|
+
contextRequired = true;
|
|
3895
|
+
contextWindow = 50;
|
|
3896
|
+
pattern = /\b8\d{9}\b/g;
|
|
3897
|
+
validator = huTaxIdChecksum;
|
|
3898
|
+
};
|
|
3899
|
+
registerRegion("hu", HuTaxIdDetector);
|
|
3900
|
+
} });
|
|
3901
|
+
|
|
3902
|
+
//#endregion
|
|
3903
|
+
//#region src/regex/detectors/hu/taj.ts
|
|
3904
|
+
var HuTajDetector;
|
|
3905
|
+
var init_taj = __esm({ "src/regex/detectors/hu/taj.ts"() {
|
|
3906
|
+
init_base();
|
|
3907
|
+
init_entities();
|
|
3908
|
+
init_registry();
|
|
3909
|
+
init_validators();
|
|
3910
|
+
HuTajDetector = class extends RegexDetector {
|
|
3911
|
+
entityType = EntityType.HU_TAJ;
|
|
3912
|
+
score = .85;
|
|
3913
|
+
contextKeywords = [
|
|
3914
|
+
"taj",
|
|
3915
|
+
"tarsadalombiztositasi",
|
|
3916
|
+
"social security",
|
|
3917
|
+
"társadalombiztosítási"
|
|
3918
|
+
];
|
|
3919
|
+
contextRequired = true;
|
|
3920
|
+
contextWindow = 50;
|
|
3921
|
+
pattern = /\b\d{3}[- ]?\d{3}[- ]?\d{3}\b/g;
|
|
3922
|
+
validator = huTajChecksum;
|
|
3923
|
+
};
|
|
3924
|
+
registerRegion("hu", HuTajDetector);
|
|
3925
|
+
} });
|
|
3926
|
+
|
|
3927
|
+
//#endregion
|
|
3928
|
+
//#region src/regex/detectors/hu/index.ts
|
|
3929
|
+
var init_hu = __esm({ "src/regex/detectors/hu/index.ts"() {
|
|
3930
|
+
init_tax_id();
|
|
3931
|
+
init_taj();
|
|
3932
|
+
} });
|
|
3933
|
+
|
|
3934
|
+
//#endregion
|
|
3935
|
+
//#region src/regex/detectors/bg/egn.ts
|
|
3936
|
+
var BgEgnDetector;
|
|
3937
|
+
var init_egn = __esm({ "src/regex/detectors/bg/egn.ts"() {
|
|
3938
|
+
init_base();
|
|
3939
|
+
init_entities();
|
|
3940
|
+
init_registry();
|
|
3941
|
+
init_validators();
|
|
3942
|
+
BgEgnDetector = class extends RegexDetector {
|
|
3943
|
+
entityType = EntityType.BG_EGN;
|
|
3944
|
+
score = .85;
|
|
3945
|
+
contextKeywords = [
|
|
3946
|
+
"egn",
|
|
3947
|
+
"егн",
|
|
3948
|
+
"edinen grazhdanski nomer",
|
|
3949
|
+
"personal number",
|
|
3950
|
+
"civil number"
|
|
3951
|
+
];
|
|
3952
|
+
contextRequired = true;
|
|
3953
|
+
contextWindow = 50;
|
|
3954
|
+
pattern = /\b\d{10}\b/g;
|
|
3955
|
+
validator = bgEgnChecksum;
|
|
3956
|
+
};
|
|
3957
|
+
registerRegion("bg", BgEgnDetector);
|
|
3958
|
+
} });
|
|
3959
|
+
|
|
3960
|
+
//#endregion
|
|
3961
|
+
//#region src/regex/detectors/bg/index.ts
|
|
3962
|
+
var init_bg = __esm({ "src/regex/detectors/bg/index.ts"() {
|
|
3963
|
+
init_egn();
|
|
3964
|
+
} });
|
|
3965
|
+
|
|
3966
|
+
//#endregion
|
|
3967
|
+
//#region src/regex/detectors/hr/oib.ts
|
|
3968
|
+
var HrOibDetector;
|
|
3969
|
+
var init_oib = __esm({ "src/regex/detectors/hr/oib.ts"() {
|
|
3970
|
+
init_base();
|
|
3971
|
+
init_entities();
|
|
3972
|
+
init_registry();
|
|
3973
|
+
init_validators();
|
|
3974
|
+
HrOibDetector = class extends RegexDetector {
|
|
3975
|
+
entityType = EntityType.HR_OIB;
|
|
3976
|
+
score = .85;
|
|
3977
|
+
contextKeywords = [
|
|
3978
|
+
"oib",
|
|
3979
|
+
"osobni identifikacijski broj",
|
|
3980
|
+
"personal identification",
|
|
3981
|
+
"identifikacijski"
|
|
3982
|
+
];
|
|
3983
|
+
contextRequired = true;
|
|
3984
|
+
contextWindow = 50;
|
|
3985
|
+
pattern = /\b\d{11}\b/g;
|
|
3986
|
+
validator = hrOibChecksum;
|
|
3987
|
+
};
|
|
3988
|
+
registerRegion("hr", HrOibDetector);
|
|
3989
|
+
} });
|
|
3990
|
+
|
|
3991
|
+
//#endregion
|
|
3992
|
+
//#region src/regex/detectors/hr/index.ts
|
|
3993
|
+
var init_hr = __esm({ "src/regex/detectors/hr/index.ts"() {
|
|
3994
|
+
init_oib();
|
|
3995
|
+
} });
|
|
3996
|
+
|
|
3997
|
+
//#endregion
|
|
3998
|
+
//#region src/regex/detectors/si/emso.ts
|
|
3999
|
+
var SiEmsoDetector;
|
|
4000
|
+
var init_emso = __esm({ "src/regex/detectors/si/emso.ts"() {
|
|
4001
|
+
init_base();
|
|
4002
|
+
init_entities();
|
|
4003
|
+
init_registry();
|
|
4004
|
+
init_validators();
|
|
4005
|
+
SiEmsoDetector = class extends RegexDetector {
|
|
4006
|
+
entityType = EntityType.SI_EMSO;
|
|
4007
|
+
score = .85;
|
|
4008
|
+
contextKeywords = [
|
|
4009
|
+
"emso",
|
|
4010
|
+
"enotna maticna stevilka",
|
|
4011
|
+
"maticna stevilka",
|
|
4012
|
+
"personal number"
|
|
4013
|
+
];
|
|
4014
|
+
contextRequired = true;
|
|
4015
|
+
contextWindow = 50;
|
|
4016
|
+
pattern = /\b\d{13}\b/g;
|
|
4017
|
+
validator = siEmsoChecksum;
|
|
4018
|
+
};
|
|
4019
|
+
registerRegion("si", SiEmsoDetector);
|
|
4020
|
+
} });
|
|
4021
|
+
|
|
4022
|
+
//#endregion
|
|
4023
|
+
//#region src/regex/detectors/si/tax-number.ts
|
|
4024
|
+
var SiTaxNumberDetector;
|
|
4025
|
+
var init_tax_number = __esm({ "src/regex/detectors/si/tax-number.ts"() {
|
|
4026
|
+
init_base();
|
|
4027
|
+
init_entities();
|
|
4028
|
+
init_registry();
|
|
4029
|
+
init_validators();
|
|
4030
|
+
SiTaxNumberDetector = class extends RegexDetector {
|
|
4031
|
+
entityType = EntityType.SI_TAX_NUMBER;
|
|
4032
|
+
score = .85;
|
|
4033
|
+
contextKeywords = [
|
|
4034
|
+
"davcna stevilka",
|
|
4035
|
+
"davcna",
|
|
4036
|
+
"tax number",
|
|
4037
|
+
"davčna številka"
|
|
4038
|
+
];
|
|
4039
|
+
contextRequired = true;
|
|
4040
|
+
contextWindow = 50;
|
|
4041
|
+
pattern = /\b(?:SI)?\d{8}\b/gi;
|
|
4042
|
+
validator = siTaxNumberChecksum;
|
|
4043
|
+
};
|
|
4044
|
+
registerRegion("si", SiTaxNumberDetector);
|
|
4045
|
+
} });
|
|
4046
|
+
|
|
4047
|
+
//#endregion
|
|
4048
|
+
//#region src/regex/detectors/si/index.ts
|
|
4049
|
+
var init_si = __esm({ "src/regex/detectors/si/index.ts"() {
|
|
4050
|
+
init_emso();
|
|
4051
|
+
init_tax_number();
|
|
4052
|
+
} });
|
|
4053
|
+
|
|
4054
|
+
//#endregion
|
|
4055
|
+
//#region src/regex/detectors/lt/personal-code.ts
|
|
4056
|
+
var LtPersonalCodeDetector;
|
|
4057
|
+
var init_personal_code$2 = __esm({ "src/regex/detectors/lt/personal-code.ts"() {
|
|
4058
|
+
init_base();
|
|
4059
|
+
init_entities();
|
|
4060
|
+
init_registry();
|
|
4061
|
+
init_validators();
|
|
4062
|
+
LtPersonalCodeDetector = class extends RegexDetector {
|
|
4063
|
+
entityType = EntityType.LT_PERSONAL_CODE;
|
|
4064
|
+
score = .85;
|
|
4065
|
+
contextKeywords = [
|
|
4066
|
+
"asmens kodas",
|
|
4067
|
+
"personal code",
|
|
4068
|
+
"asmens"
|
|
4069
|
+
];
|
|
4070
|
+
contextRequired = true;
|
|
4071
|
+
contextWindow = 50;
|
|
4072
|
+
pattern = /\b[1-6]\d{10}\b/g;
|
|
4073
|
+
validator = ltPersonalCodeChecksum;
|
|
4074
|
+
};
|
|
4075
|
+
registerRegion("lt", LtPersonalCodeDetector);
|
|
4076
|
+
} });
|
|
4077
|
+
|
|
4078
|
+
//#endregion
|
|
4079
|
+
//#region src/regex/detectors/lt/index.ts
|
|
4080
|
+
var init_lt = __esm({ "src/regex/detectors/lt/index.ts"() {
|
|
4081
|
+
init_personal_code$2();
|
|
4082
|
+
} });
|
|
4083
|
+
|
|
4084
|
+
//#endregion
|
|
4085
|
+
//#region src/regex/detectors/lv/personal-code.ts
|
|
4086
|
+
var LvPersonalCodeDetector;
|
|
4087
|
+
var init_personal_code$1 = __esm({ "src/regex/detectors/lv/personal-code.ts"() {
|
|
4088
|
+
init_base();
|
|
4089
|
+
init_entities();
|
|
4090
|
+
init_registry();
|
|
4091
|
+
init_validators();
|
|
4092
|
+
LvPersonalCodeDetector = class extends RegexDetector {
|
|
4093
|
+
entityType = EntityType.LV_PERSONAL_CODE;
|
|
4094
|
+
score = .85;
|
|
4095
|
+
contextKeywords = [
|
|
4096
|
+
"personas kods",
|
|
4097
|
+
"personal code",
|
|
4098
|
+
"personas"
|
|
4099
|
+
];
|
|
4100
|
+
contextRequired = true;
|
|
4101
|
+
contextWindow = 50;
|
|
4102
|
+
pattern = /\b\d{6}-?\d{5}\b/g;
|
|
4103
|
+
validator = lvPersonalCodeChecksum;
|
|
4104
|
+
};
|
|
4105
|
+
registerRegion("lv", LvPersonalCodeDetector);
|
|
4106
|
+
} });
|
|
4107
|
+
|
|
4108
|
+
//#endregion
|
|
4109
|
+
//#region src/regex/detectors/lv/index.ts
|
|
4110
|
+
var init_lv = __esm({ "src/regex/detectors/lv/index.ts"() {
|
|
4111
|
+
init_personal_code$1();
|
|
4112
|
+
} });
|
|
4113
|
+
|
|
4114
|
+
//#endregion
|
|
4115
|
+
//#region src/regex/detectors/ee/personal-code.ts
|
|
4116
|
+
var EePersonalCodeDetector;
|
|
4117
|
+
var init_personal_code = __esm({ "src/regex/detectors/ee/personal-code.ts"() {
|
|
4118
|
+
init_base();
|
|
4119
|
+
init_entities();
|
|
4120
|
+
init_registry();
|
|
4121
|
+
init_validators();
|
|
4122
|
+
EePersonalCodeDetector = class extends RegexDetector {
|
|
4123
|
+
entityType = EntityType.EE_PERSONAL_CODE;
|
|
4124
|
+
score = .85;
|
|
4125
|
+
contextKeywords = [
|
|
4126
|
+
"isikukood",
|
|
4127
|
+
"personal code",
|
|
4128
|
+
"identity code"
|
|
4129
|
+
];
|
|
4130
|
+
contextRequired = true;
|
|
4131
|
+
contextWindow = 50;
|
|
4132
|
+
pattern = /\b[1-6]\d{10}\b/g;
|
|
4133
|
+
validator = eePersonalCodeChecksum;
|
|
4134
|
+
};
|
|
4135
|
+
registerRegion("ee", EePersonalCodeDetector);
|
|
4136
|
+
} });
|
|
4137
|
+
|
|
4138
|
+
//#endregion
|
|
4139
|
+
//#region src/regex/detectors/ee/index.ts
|
|
4140
|
+
var init_ee = __esm({ "src/regex/detectors/ee/index.ts"() {
|
|
4141
|
+
init_personal_code();
|
|
4142
|
+
} });
|
|
4143
|
+
|
|
4144
|
+
//#endregion
|
|
4145
|
+
//#region src/regex/detectors/ca/sin.ts
|
|
4146
|
+
var CaSinDetector;
|
|
4147
|
+
var init_sin = __esm({ "src/regex/detectors/ca/sin.ts"() {
|
|
4148
|
+
init_base();
|
|
4149
|
+
init_entities();
|
|
4150
|
+
init_registry();
|
|
4151
|
+
init_validators();
|
|
4152
|
+
CaSinDetector = class extends RegexDetector {
|
|
4153
|
+
entityType = EntityType.CA_SIN;
|
|
4154
|
+
score = .85;
|
|
4155
|
+
contextKeywords = [
|
|
4156
|
+
"sin",
|
|
4157
|
+
"social insurance number",
|
|
4158
|
+
"numero assurance sociale",
|
|
4159
|
+
"nas"
|
|
4160
|
+
];
|
|
4161
|
+
contextRequired = true;
|
|
4162
|
+
pattern = /\b\d{3}[- ]?\d{3}[- ]?\d{3}\b/g;
|
|
4163
|
+
validator = luhnChecksum;
|
|
4164
|
+
};
|
|
4165
|
+
registerRegion("ca", CaSinDetector);
|
|
4166
|
+
} });
|
|
4167
|
+
|
|
4168
|
+
//#endregion
|
|
4169
|
+
//#region src/regex/detectors/ca/index.ts
|
|
4170
|
+
var init_ca = __esm({ "src/regex/detectors/ca/index.ts"() {
|
|
4171
|
+
init_sin();
|
|
4172
|
+
} });
|
|
4173
|
+
|
|
4174
|
+
//#endregion
|
|
4175
|
+
//#region src/regex/detectors/ch/ahv.ts
|
|
4176
|
+
var ChAhvDetector;
|
|
4177
|
+
var init_ahv = __esm({ "src/regex/detectors/ch/ahv.ts"() {
|
|
4178
|
+
init_base();
|
|
4179
|
+
init_entities();
|
|
4180
|
+
init_registry();
|
|
4181
|
+
init_validators();
|
|
4182
|
+
ChAhvDetector = class extends RegexDetector {
|
|
4183
|
+
entityType = EntityType.CH_AHV;
|
|
4184
|
+
score = .85;
|
|
4185
|
+
contextKeywords = [
|
|
4186
|
+
"ahv",
|
|
4187
|
+
"avs",
|
|
4188
|
+
"oasi",
|
|
4189
|
+
"sozialversicherungsnummer",
|
|
4190
|
+
"ahv-nr"
|
|
4191
|
+
];
|
|
4192
|
+
contextRequired = false;
|
|
4193
|
+
pattern = /\b756[. ]?\d{4}[. ]?\d{4}[. ]?\d{2}\b/g;
|
|
4194
|
+
validator = chAhvChecksum;
|
|
4195
|
+
};
|
|
4196
|
+
registerRegion("ch", ChAhvDetector);
|
|
4197
|
+
} });
|
|
4198
|
+
|
|
4199
|
+
//#endregion
|
|
4200
|
+
//#region src/regex/detectors/ch/index.ts
|
|
4201
|
+
var init_ch = __esm({ "src/regex/detectors/ch/index.ts"() {
|
|
4202
|
+
init_ahv();
|
|
4203
|
+
} });
|
|
4204
|
+
|
|
4205
|
+
//#endregion
|
|
4206
|
+
//#region src/regex/detectors/au/tfn.ts
|
|
4207
|
+
var AuTfnDetector;
|
|
4208
|
+
var init_tfn = __esm({ "src/regex/detectors/au/tfn.ts"() {
|
|
4209
|
+
init_base();
|
|
4210
|
+
init_entities();
|
|
4211
|
+
init_registry();
|
|
4212
|
+
init_validators();
|
|
4213
|
+
AuTfnDetector = class extends RegexDetector {
|
|
4214
|
+
entityType = EntityType.AU_TFN;
|
|
4215
|
+
score = .85;
|
|
4216
|
+
contextKeywords = [
|
|
4217
|
+
"tfn",
|
|
4218
|
+
"tax file number",
|
|
4219
|
+
"tax file no"
|
|
4220
|
+
];
|
|
4221
|
+
contextRequired = true;
|
|
4222
|
+
pattern = /\b\d{3}[- ]?\d{3}[- ]?\d{2,3}\b/g;
|
|
4223
|
+
validator = auTfnChecksum;
|
|
4224
|
+
};
|
|
4225
|
+
registerRegion("au", AuTfnDetector);
|
|
4226
|
+
} });
|
|
4227
|
+
|
|
4228
|
+
//#endregion
|
|
4229
|
+
//#region src/regex/detectors/au/medicare.ts
|
|
4230
|
+
var AuMedicareDetector;
|
|
4231
|
+
var init_medicare = __esm({ "src/regex/detectors/au/medicare.ts"() {
|
|
4232
|
+
init_base();
|
|
4233
|
+
init_entities();
|
|
4234
|
+
init_registry();
|
|
4235
|
+
init_validators();
|
|
4236
|
+
AuMedicareDetector = class extends RegexDetector {
|
|
4237
|
+
entityType = EntityType.AU_MEDICARE;
|
|
4238
|
+
score = .85;
|
|
4239
|
+
contextKeywords = [
|
|
4240
|
+
"medicare",
|
|
4241
|
+
"medicare card",
|
|
4242
|
+
"medicare number"
|
|
4243
|
+
];
|
|
4244
|
+
contextRequired = true;
|
|
4245
|
+
pattern = /\b\d{4}[- ]?\d{5}[- ]?\d[- ]?\d?\b/g;
|
|
4246
|
+
validator = auMedicareChecksum;
|
|
4247
|
+
};
|
|
4248
|
+
registerRegion("au", AuMedicareDetector);
|
|
4249
|
+
} });
|
|
4250
|
+
|
|
4251
|
+
//#endregion
|
|
4252
|
+
//#region src/regex/detectors/au/index.ts
|
|
4253
|
+
var init_au = __esm({ "src/regex/detectors/au/index.ts"() {
|
|
4254
|
+
init_tfn();
|
|
4255
|
+
init_medicare();
|
|
4256
|
+
} });
|
|
4257
|
+
|
|
4258
|
+
//#endregion
|
|
4259
|
+
//#region src/regex/detectors/nz/ird.ts
|
|
4260
|
+
var NzIrdDetector;
|
|
4261
|
+
var init_ird = __esm({ "src/regex/detectors/nz/ird.ts"() {
|
|
4262
|
+
init_base();
|
|
4263
|
+
init_entities();
|
|
4264
|
+
init_registry();
|
|
4265
|
+
init_validators();
|
|
4266
|
+
NzIrdDetector = class extends RegexDetector {
|
|
4267
|
+
entityType = EntityType.NZ_IRD;
|
|
4268
|
+
score = .85;
|
|
4269
|
+
contextKeywords = [
|
|
4270
|
+
"ird",
|
|
4271
|
+
"inland revenue",
|
|
4272
|
+
"tax number",
|
|
4273
|
+
"ird number"
|
|
4274
|
+
];
|
|
4275
|
+
contextRequired = true;
|
|
4276
|
+
pattern = /\b\d{2,3}[- ]?\d{3}[- ]?\d{3}\b/g;
|
|
4277
|
+
validator = nzIrdChecksum;
|
|
4278
|
+
};
|
|
4279
|
+
registerRegion("nz", NzIrdDetector);
|
|
4280
|
+
} });
|
|
4281
|
+
|
|
4282
|
+
//#endregion
|
|
4283
|
+
//#region src/regex/detectors/nz/index.ts
|
|
4284
|
+
var init_nz = __esm({ "src/regex/detectors/nz/index.ts"() {
|
|
4285
|
+
init_ird();
|
|
4286
|
+
} });
|
|
4287
|
+
|
|
4288
|
+
//#endregion
|
|
4289
|
+
//#region src/regex/detectors/in/aadhaar.ts
|
|
4290
|
+
var InAadhaarDetector;
|
|
4291
|
+
var init_aadhaar = __esm({ "src/regex/detectors/in/aadhaar.ts"() {
|
|
4292
|
+
init_base();
|
|
4293
|
+
init_entities();
|
|
4294
|
+
init_registry();
|
|
4295
|
+
init_validators();
|
|
4296
|
+
InAadhaarDetector = class extends RegexDetector {
|
|
4297
|
+
entityType = EntityType.IN_AADHAAR;
|
|
4298
|
+
score = .85;
|
|
4299
|
+
contextKeywords = [
|
|
4300
|
+
"aadhaar",
|
|
4301
|
+
"aadhar",
|
|
4302
|
+
"uidai",
|
|
4303
|
+
"unique identification"
|
|
4304
|
+
];
|
|
4305
|
+
contextRequired = true;
|
|
4306
|
+
pattern = /\b[2-9]\d{3}[- ]?\d{4}[- ]?\d{4}\b/g;
|
|
4307
|
+
validator = inAadhaarChecksum;
|
|
4308
|
+
};
|
|
4309
|
+
registerRegion("in", InAadhaarDetector);
|
|
4310
|
+
} });
|
|
4311
|
+
|
|
4312
|
+
//#endregion
|
|
4313
|
+
//#region src/regex/detectors/in/pan.ts
|
|
4314
|
+
var InPanDetector;
|
|
4315
|
+
var init_pan = __esm({ "src/regex/detectors/in/pan.ts"() {
|
|
4316
|
+
init_base();
|
|
4317
|
+
init_entities();
|
|
4318
|
+
init_registry();
|
|
4319
|
+
init_validators();
|
|
4320
|
+
InPanDetector = class extends RegexDetector {
|
|
4321
|
+
entityType = EntityType.IN_PAN;
|
|
4322
|
+
score = .85;
|
|
4323
|
+
contextKeywords = [
|
|
4324
|
+
"pan",
|
|
4325
|
+
"permanent account number",
|
|
4326
|
+
"income tax",
|
|
4327
|
+
"pan card"
|
|
4328
|
+
];
|
|
4329
|
+
contextRequired = false;
|
|
4330
|
+
pattern = /\b[A-Z]{3}[ABCFGHLJPT][A-Z]\d{4}[A-Z]\b/gi;
|
|
4331
|
+
validator = inPanValid;
|
|
4332
|
+
};
|
|
4333
|
+
registerRegion("in", InPanDetector);
|
|
4334
|
+
} });
|
|
4335
|
+
|
|
4336
|
+
//#endregion
|
|
4337
|
+
//#region src/regex/detectors/in/index.ts
|
|
4338
|
+
var init_in = __esm({ "src/regex/detectors/in/index.ts"() {
|
|
4339
|
+
init_aadhaar();
|
|
4340
|
+
init_pan();
|
|
4341
|
+
} });
|
|
4342
|
+
|
|
4343
|
+
//#endregion
|
|
4344
|
+
//#region src/regex/detectors/jp/my-number.ts
|
|
4345
|
+
var JpMyNumberDetector;
|
|
4346
|
+
var init_my_number = __esm({ "src/regex/detectors/jp/my-number.ts"() {
|
|
4347
|
+
init_base();
|
|
4348
|
+
init_entities();
|
|
4349
|
+
init_registry();
|
|
4350
|
+
init_validators();
|
|
4351
|
+
JpMyNumberDetector = class extends RegexDetector {
|
|
4352
|
+
entityType = EntityType.JP_MY_NUMBER;
|
|
4353
|
+
score = .85;
|
|
4354
|
+
contextKeywords = [
|
|
4355
|
+
"my number",
|
|
4356
|
+
"マイナンバー",
|
|
4357
|
+
"kojin bango",
|
|
4358
|
+
"individual number"
|
|
4359
|
+
];
|
|
4360
|
+
contextRequired = true;
|
|
4361
|
+
pattern = /\b\d{4}[- ]?\d{4}[- ]?\d{4}\b/g;
|
|
4362
|
+
validator = jpMyNumberChecksum;
|
|
4363
|
+
};
|
|
4364
|
+
registerRegion("jp", JpMyNumberDetector);
|
|
4365
|
+
} });
|
|
4366
|
+
|
|
4367
|
+
//#endregion
|
|
4368
|
+
//#region src/regex/detectors/jp/index.ts
|
|
4369
|
+
var init_jp = __esm({ "src/regex/detectors/jp/index.ts"() {
|
|
4370
|
+
init_my_number();
|
|
4371
|
+
} });
|
|
4372
|
+
|
|
4373
|
+
//#endregion
|
|
4374
|
+
//#region src/regex/detectors/kr/rrn.ts
|
|
4375
|
+
var KrRrnDetector;
|
|
4376
|
+
var init_rrn = __esm({ "src/regex/detectors/kr/rrn.ts"() {
|
|
4377
|
+
init_base();
|
|
4378
|
+
init_entities();
|
|
4379
|
+
init_registry();
|
|
4380
|
+
init_validators();
|
|
4381
|
+
KrRrnDetector = class extends RegexDetector {
|
|
4382
|
+
entityType = EntityType.KR_RRN;
|
|
4383
|
+
score = .85;
|
|
4384
|
+
contextKeywords = [
|
|
4385
|
+
"주민등록번호",
|
|
4386
|
+
"resident registration",
|
|
4387
|
+
"jumin",
|
|
4388
|
+
"rrn"
|
|
4389
|
+
];
|
|
4390
|
+
contextRequired = true;
|
|
4391
|
+
pattern = /\b\d{6}[- ]?\d{7}\b/g;
|
|
4392
|
+
validator = krRrnChecksum;
|
|
4393
|
+
};
|
|
4394
|
+
registerRegion("kr", KrRrnDetector);
|
|
4395
|
+
} });
|
|
4396
|
+
|
|
4397
|
+
//#endregion
|
|
4398
|
+
//#region src/regex/detectors/kr/index.ts
|
|
4399
|
+
var init_kr = __esm({ "src/regex/detectors/kr/index.ts"() {
|
|
4400
|
+
init_rrn();
|
|
4401
|
+
} });
|
|
4402
|
+
|
|
4403
|
+
//#endregion
|
|
4404
|
+
//#region src/regex/detectors/za/id.ts
|
|
4405
|
+
var ZaIdDetector;
|
|
4406
|
+
var init_id$1 = __esm({ "src/regex/detectors/za/id.ts"() {
|
|
4407
|
+
init_base();
|
|
4408
|
+
init_entities();
|
|
4409
|
+
init_registry();
|
|
4410
|
+
init_validators();
|
|
4411
|
+
ZaIdDetector = class extends RegexDetector {
|
|
4412
|
+
entityType = EntityType.ZA_ID;
|
|
4413
|
+
score = .85;
|
|
4414
|
+
contextKeywords = [
|
|
4415
|
+
"id number",
|
|
4416
|
+
"identity number",
|
|
4417
|
+
"south african id",
|
|
4418
|
+
"sa id"
|
|
4419
|
+
];
|
|
4420
|
+
contextRequired = true;
|
|
4421
|
+
pattern = /\b\d{13}\b/g;
|
|
4422
|
+
validator = luhnChecksum;
|
|
4423
|
+
};
|
|
4424
|
+
registerRegion("za", ZaIdDetector);
|
|
4425
|
+
} });
|
|
4426
|
+
|
|
4427
|
+
//#endregion
|
|
4428
|
+
//#region src/regex/detectors/za/index.ts
|
|
4429
|
+
var init_za = __esm({ "src/regex/detectors/za/index.ts"() {
|
|
4430
|
+
init_id$1();
|
|
4431
|
+
} });
|
|
4432
|
+
|
|
4433
|
+
//#endregion
|
|
4434
|
+
//#region src/regex/detectors/tr/kimlik.ts
|
|
4435
|
+
var TrKimlikDetector;
|
|
4436
|
+
var init_kimlik = __esm({ "src/regex/detectors/tr/kimlik.ts"() {
|
|
4437
|
+
init_base();
|
|
4438
|
+
init_entities();
|
|
4439
|
+
init_registry();
|
|
4440
|
+
init_validators();
|
|
4441
|
+
TrKimlikDetector = class extends RegexDetector {
|
|
4442
|
+
entityType = EntityType.TR_KIMLIK;
|
|
4443
|
+
score = .85;
|
|
4444
|
+
contextKeywords = [
|
|
4445
|
+
"tc kimlik",
|
|
4446
|
+
"kimlik no",
|
|
4447
|
+
"tckn",
|
|
4448
|
+
"vatandas",
|
|
4449
|
+
"nufus"
|
|
4450
|
+
];
|
|
4451
|
+
contextRequired = true;
|
|
4452
|
+
pattern = /\b[1-9]\d{10}\b/g;
|
|
4453
|
+
validator = trKimlikChecksum;
|
|
4454
|
+
};
|
|
4455
|
+
registerRegion("tr", TrKimlikDetector);
|
|
4456
|
+
} });
|
|
4457
|
+
|
|
4458
|
+
//#endregion
|
|
4459
|
+
//#region src/regex/detectors/tr/index.ts
|
|
4460
|
+
var init_tr = __esm({ "src/regex/detectors/tr/index.ts"() {
|
|
4461
|
+
init_kimlik();
|
|
4462
|
+
} });
|
|
4463
|
+
|
|
4464
|
+
//#endregion
|
|
4465
|
+
//#region src/regex/detectors/il/id.ts
|
|
4466
|
+
var IlIdDetector;
|
|
4467
|
+
var init_id = __esm({ "src/regex/detectors/il/id.ts"() {
|
|
4468
|
+
init_base();
|
|
4469
|
+
init_entities();
|
|
4470
|
+
init_registry();
|
|
4471
|
+
init_validators();
|
|
4472
|
+
IlIdDetector = class extends RegexDetector {
|
|
4473
|
+
entityType = EntityType.IL_ID;
|
|
4474
|
+
score = .85;
|
|
4475
|
+
contextKeywords = [
|
|
4476
|
+
"teudat zehut",
|
|
4477
|
+
"mispar zehut",
|
|
4478
|
+
"identity number",
|
|
4479
|
+
"ת.ז",
|
|
4480
|
+
"tz"
|
|
4481
|
+
];
|
|
4482
|
+
contextRequired = true;
|
|
4483
|
+
pattern = /\b\d{9}\b/g;
|
|
4484
|
+
validator = luhnChecksum;
|
|
4485
|
+
};
|
|
4486
|
+
registerRegion("il", IlIdDetector);
|
|
4487
|
+
} });
|
|
4488
|
+
|
|
4489
|
+
//#endregion
|
|
4490
|
+
//#region src/regex/detectors/il/index.ts
|
|
4491
|
+
var init_il = __esm({ "src/regex/detectors/il/index.ts"() {
|
|
4492
|
+
init_id();
|
|
4493
|
+
} });
|
|
4494
|
+
|
|
4495
|
+
//#endregion
|
|
4496
|
+
//#region src/regex/detectors/ar/cuit.ts
|
|
4497
|
+
var ArCuitDetector;
|
|
4498
|
+
var init_cuit = __esm({ "src/regex/detectors/ar/cuit.ts"() {
|
|
4499
|
+
init_base();
|
|
4500
|
+
init_entities();
|
|
4501
|
+
init_registry();
|
|
4502
|
+
init_validators();
|
|
4503
|
+
ArCuitDetector = class extends RegexDetector {
|
|
4504
|
+
entityType = EntityType.AR_CUIT;
|
|
4505
|
+
score = .85;
|
|
4506
|
+
contextKeywords = [
|
|
4507
|
+
"cuit",
|
|
4508
|
+
"cuil",
|
|
4509
|
+
"clave unica",
|
|
4510
|
+
"identificacion tributaria"
|
|
4511
|
+
];
|
|
4512
|
+
contextRequired = true;
|
|
4513
|
+
pattern = /\b\d{2}-?\d{8}-?\d\b/g;
|
|
4514
|
+
validator = arCuitChecksum;
|
|
4515
|
+
};
|
|
4516
|
+
registerRegion("ar", ArCuitDetector);
|
|
4517
|
+
} });
|
|
4518
|
+
|
|
4519
|
+
//#endregion
|
|
4520
|
+
//#region src/regex/detectors/ar/index.ts
|
|
4521
|
+
var init_ar = __esm({ "src/regex/detectors/ar/index.ts"() {
|
|
4522
|
+
init_cuit();
|
|
4523
|
+
} });
|
|
4524
|
+
|
|
4525
|
+
//#endregion
|
|
4526
|
+
//#region src/regex/detectors/cl/rut.ts
|
|
4527
|
+
var ClRutDetector;
|
|
4528
|
+
var init_rut = __esm({ "src/regex/detectors/cl/rut.ts"() {
|
|
4529
|
+
init_base();
|
|
4530
|
+
init_entities();
|
|
4531
|
+
init_registry();
|
|
4532
|
+
init_validators();
|
|
4533
|
+
ClRutDetector = class extends RegexDetector {
|
|
4534
|
+
entityType = EntityType.CL_RUT;
|
|
4535
|
+
score = .85;
|
|
4536
|
+
contextKeywords = [
|
|
4537
|
+
"rut",
|
|
4538
|
+
"run",
|
|
4539
|
+
"rol unico tributario",
|
|
4540
|
+
"rol unico nacional"
|
|
4541
|
+
];
|
|
4542
|
+
contextRequired = true;
|
|
4543
|
+
pattern = /\b\d{1,2}\.?\d{3}\.?\d{3}-?[\dkK]\b/g;
|
|
4544
|
+
validator = clRutChecksum;
|
|
4545
|
+
};
|
|
4546
|
+
registerRegion("cl", ClRutDetector);
|
|
4547
|
+
} });
|
|
4548
|
+
|
|
4549
|
+
//#endregion
|
|
4550
|
+
//#region src/regex/detectors/cl/index.ts
|
|
4551
|
+
var init_cl = __esm({ "src/regex/detectors/cl/index.ts"() {
|
|
4552
|
+
init_rut();
|
|
4553
|
+
} });
|
|
4554
|
+
|
|
4555
|
+
//#endregion
|
|
4556
|
+
//#region src/regex/detectors/co/nit.ts
|
|
4557
|
+
var CoNitDetector;
|
|
4558
|
+
var init_nit = __esm({ "src/regex/detectors/co/nit.ts"() {
|
|
4559
|
+
init_base();
|
|
4560
|
+
init_entities();
|
|
4561
|
+
init_registry();
|
|
4562
|
+
init_validators();
|
|
4563
|
+
CoNitDetector = class extends RegexDetector {
|
|
4564
|
+
entityType = EntityType.CO_NIT;
|
|
4565
|
+
score = .85;
|
|
4566
|
+
contextKeywords = [
|
|
4567
|
+
"nit",
|
|
4568
|
+
"numero de identificacion tributaria",
|
|
4569
|
+
"identificacion tributaria"
|
|
4570
|
+
];
|
|
4571
|
+
contextRequired = true;
|
|
4572
|
+
pattern = /\b\d{3}\.?\d{3}\.?\d{3}-?\d\b/g;
|
|
4573
|
+
validator = coNitChecksum;
|
|
4574
|
+
};
|
|
4575
|
+
registerRegion("co", CoNitDetector);
|
|
4576
|
+
} });
|
|
4577
|
+
|
|
4578
|
+
//#endregion
|
|
4579
|
+
//#region src/regex/detectors/co/index.ts
|
|
4580
|
+
var init_co = __esm({ "src/regex/detectors/co/index.ts"() {
|
|
4581
|
+
init_nit();
|
|
4582
|
+
} });
|
|
4583
|
+
|
|
4584
|
+
//#endregion
|
|
4585
|
+
//#region src/regex/detectors/index.ts
|
|
4586
|
+
var init_detectors = __esm({ "src/regex/detectors/index.ts"() {
|
|
4587
|
+
init_email();
|
|
4588
|
+
init_credit_card();
|
|
4589
|
+
init_phone();
|
|
4590
|
+
init_ip_address();
|
|
4591
|
+
init_url();
|
|
4592
|
+
init_mac_address();
|
|
4593
|
+
init_date_of_birth();
|
|
4594
|
+
init_cvv();
|
|
4595
|
+
init_us();
|
|
4596
|
+
init_eu();
|
|
4597
|
+
init_uk();
|
|
4598
|
+
init_de();
|
|
4599
|
+
init_fr();
|
|
4600
|
+
init_es();
|
|
4601
|
+
init_it();
|
|
4602
|
+
init_pt();
|
|
4603
|
+
init_pl();
|
|
4604
|
+
init_cz();
|
|
4605
|
+
init_ru();
|
|
4606
|
+
init_nl();
|
|
4607
|
+
init_ro();
|
|
4608
|
+
init_sk();
|
|
4609
|
+
init_dk();
|
|
4610
|
+
init_se();
|
|
4611
|
+
init_no();
|
|
4612
|
+
init_br();
|
|
4613
|
+
init_be();
|
|
4614
|
+
init_at();
|
|
4615
|
+
init_ie();
|
|
4616
|
+
init_fi();
|
|
4617
|
+
init_hu();
|
|
4618
|
+
init_bg();
|
|
4619
|
+
init_hr();
|
|
4620
|
+
init_si();
|
|
4621
|
+
init_lt();
|
|
4622
|
+
init_lv();
|
|
4623
|
+
init_ee();
|
|
4624
|
+
init_ca();
|
|
4625
|
+
init_ch();
|
|
4626
|
+
init_au();
|
|
4627
|
+
init_nz();
|
|
4628
|
+
init_in();
|
|
4629
|
+
init_jp();
|
|
4630
|
+
init_kr();
|
|
4631
|
+
init_za();
|
|
4632
|
+
init_tr();
|
|
4633
|
+
init_il();
|
|
4634
|
+
init_ar();
|
|
4635
|
+
init_cl();
|
|
4636
|
+
init_co();
|
|
4637
|
+
} });
|
|
4638
|
+
|
|
4639
|
+
//#endregion
|
|
4640
|
+
//#region src/regex/scanner.ts
|
|
4641
|
+
var PIIScanner;
|
|
4642
|
+
var init_scanner = __esm({ "src/regex/scanner.ts"() {
|
|
4643
|
+
init_registry();
|
|
4644
|
+
init_synthesizers();
|
|
4645
|
+
init_detectors();
|
|
4646
|
+
PIIScanner = class {
|
|
4647
|
+
registry;
|
|
4648
|
+
constructor(options) {
|
|
4649
|
+
this.registry = new DetectorRegistry(options?.locales);
|
|
4650
|
+
}
|
|
4651
|
+
/** Detect PII entities in text and return deduplicated matches. */
|
|
4652
|
+
detect(text, entities) {
|
|
4653
|
+
let detectors = this.registry.detectors;
|
|
4654
|
+
if (entities) {
|
|
4655
|
+
const entitySet = new Set(entities);
|
|
4656
|
+
detectors = detectors.filter((d) => entitySet.has(d.entityType));
|
|
4657
|
+
}
|
|
4658
|
+
const hasDigit = /\d/.test(text);
|
|
4659
|
+
const textLower = text.toLowerCase();
|
|
4660
|
+
const allMatches = [];
|
|
4661
|
+
for (const detector of detectors) {
|
|
4662
|
+
if (detector.needsDigit && !hasDigit) continue;
|
|
4663
|
+
detector._textLower = textLower;
|
|
4664
|
+
allMatches.push(...detector.iterMatches(text));
|
|
4665
|
+
detector._textLower = null;
|
|
4666
|
+
}
|
|
4667
|
+
return this.deduplicate(allMatches);
|
|
4668
|
+
}
|
|
4669
|
+
/**
|
|
4670
|
+
* Detect and remove PII from text.
|
|
4671
|
+
* Returns a tuple of [redactedText, detectedMatches].
|
|
4672
|
+
*/
|
|
4673
|
+
redact(text, entities) {
|
|
4674
|
+
const matches = this.detect(text, entities);
|
|
4675
|
+
if (matches.length === 0) return [text, []];
|
|
4676
|
+
const sortedMatches = [...matches].sort((a, b) => b.start - a.start);
|
|
4677
|
+
let result = text;
|
|
4678
|
+
for (const m of sortedMatches) {
|
|
4679
|
+
const start = m.start > 0 && result[m.start - 1] === " " ? m.start - 1 : m.start;
|
|
4680
|
+
result = result.slice(0, start) + result.slice(m.end);
|
|
4681
|
+
}
|
|
4682
|
+
return [result, matches];
|
|
4683
|
+
}
|
|
4684
|
+
/**
|
|
4685
|
+
* Detect PII and replace with numbered tokens like `<Email Address_1>`.
|
|
4686
|
+
* Returns tokenized text, a mapping from tokens to original values, and matches.
|
|
4687
|
+
*/
|
|
4688
|
+
tokenize(text, entities) {
|
|
4689
|
+
const matches = this.detect(text, entities);
|
|
4690
|
+
if (matches.length === 0) return {
|
|
4691
|
+
text,
|
|
4692
|
+
mapping: {},
|
|
4693
|
+
matches: []
|
|
4694
|
+
};
|
|
4695
|
+
const sortedAsc = [...matches].sort((a, b) => a.start - b.start);
|
|
4696
|
+
const counters = {};
|
|
4697
|
+
const tokenMap = new Map();
|
|
4698
|
+
const mapping = {};
|
|
4699
|
+
for (const m of sortedAsc) {
|
|
4700
|
+
const count = (counters[m.entityType] ?? 0) + 1;
|
|
4701
|
+
counters[m.entityType] = count;
|
|
4702
|
+
const token = `<${m.entityType}_${count}>`;
|
|
4703
|
+
tokenMap.set(m, token);
|
|
4704
|
+
mapping[token] = m.text;
|
|
4705
|
+
}
|
|
4706
|
+
const sortedDesc = [...matches].sort((a, b) => b.start - a.start);
|
|
4707
|
+
let result = text;
|
|
4708
|
+
for (const m of sortedDesc) {
|
|
4709
|
+
const token = tokenMap.get(m);
|
|
4710
|
+
result = result.slice(0, m.start) + token + result.slice(m.end);
|
|
4711
|
+
}
|
|
4712
|
+
return {
|
|
4713
|
+
text: result,
|
|
4714
|
+
mapping,
|
|
4715
|
+
matches
|
|
4716
|
+
};
|
|
4717
|
+
}
|
|
4718
|
+
/**
|
|
4719
|
+
* Detect PII and partially mask each match.
|
|
4720
|
+
*/
|
|
4721
|
+
mask(text, charsToShow = 3, fromEnd = false, maskingChar = "*", entities) {
|
|
4722
|
+
const matches = this.detect(text, entities);
|
|
4723
|
+
if (matches.length === 0) return {
|
|
4724
|
+
text,
|
|
4725
|
+
matches: []
|
|
4726
|
+
};
|
|
4727
|
+
const sortedMatches = [...matches].sort((a, b) => b.start - a.start);
|
|
4728
|
+
let result = text;
|
|
4729
|
+
for (const m of sortedMatches) {
|
|
4730
|
+
const original = m.text;
|
|
4731
|
+
const show = Math.min(charsToShow, original.length);
|
|
4732
|
+
const maskLen = original.length - show;
|
|
4733
|
+
let masked;
|
|
4734
|
+
if (fromEnd) masked = maskingChar.repeat(maskLen) + original.slice(maskLen);
|
|
4735
|
+
else masked = original.slice(0, show) + maskingChar.repeat(maskLen);
|
|
4736
|
+
result = result.slice(0, m.start) + masked + result.slice(m.end);
|
|
4737
|
+
}
|
|
4738
|
+
return {
|
|
4739
|
+
text: result,
|
|
4740
|
+
matches
|
|
4741
|
+
};
|
|
4742
|
+
}
|
|
4743
|
+
/**
|
|
4744
|
+
* Detect PII and replace each match with a deterministic hash.
|
|
4745
|
+
*/
|
|
4746
|
+
hash(text, hashType = "sha256", hashPrefix = "HASH_", hashLength = 16, entities) {
|
|
4747
|
+
const matches = this.detect(text, entities);
|
|
4748
|
+
if (matches.length === 0) return {
|
|
4749
|
+
text,
|
|
4750
|
+
matches: []
|
|
4751
|
+
};
|
|
4752
|
+
const sortedMatches = [...matches].sort((a, b) => b.start - a.start);
|
|
4753
|
+
let result = text;
|
|
4754
|
+
for (const m of sortedMatches) {
|
|
4755
|
+
const digest = crypto.createHash(hashType).update(m.text).digest("hex");
|
|
4756
|
+
const truncated = digest.slice(0, hashLength);
|
|
4757
|
+
const replacement = hashPrefix + truncated;
|
|
4758
|
+
result = result.slice(0, m.start) + replacement + result.slice(m.end);
|
|
4759
|
+
}
|
|
4760
|
+
return {
|
|
4761
|
+
text: result,
|
|
4762
|
+
matches
|
|
4763
|
+
};
|
|
4764
|
+
}
|
|
4765
|
+
/**
|
|
4766
|
+
* Detect PII and encrypt each match with AES-256-CBC.
|
|
4767
|
+
* @param encryptionKey - Required, minimum 16 characters.
|
|
4768
|
+
*/
|
|
4769
|
+
encrypt(text, encryptionKey, entities) {
|
|
4770
|
+
if (!encryptionKey || encryptionKey.length < 16) throw new Error("encryptionKey is required and must be at least 16 characters for local encryption");
|
|
4771
|
+
const matches = this.detect(text, entities);
|
|
4772
|
+
if (matches.length === 0) return {
|
|
4773
|
+
text,
|
|
4774
|
+
matches: []
|
|
4775
|
+
};
|
|
4776
|
+
const derivedKey = crypto.createHash("sha256").update(encryptionKey).digest();
|
|
4777
|
+
const sortedMatches = [...matches].sort((a, b) => b.start - a.start);
|
|
4778
|
+
let result = text;
|
|
4779
|
+
for (const m of sortedMatches) {
|
|
4780
|
+
const iv = crypto.randomBytes(16);
|
|
4781
|
+
const cipher = crypto.createCipheriv("aes-256-cbc", derivedKey, iv);
|
|
4782
|
+
const encrypted = Buffer.concat([cipher.update(m.text, "utf8"), cipher.final()]);
|
|
4783
|
+
const combined = Buffer.concat([iv, encrypted]);
|
|
4784
|
+
const replacement = combined.toString("base64");
|
|
4785
|
+
result = result.slice(0, m.start) + replacement + result.slice(m.end);
|
|
4786
|
+
}
|
|
4787
|
+
return {
|
|
4788
|
+
text: result,
|
|
4789
|
+
matches
|
|
4790
|
+
};
|
|
4791
|
+
}
|
|
4792
|
+
/**
|
|
4793
|
+
* Detect PII and replace each match with format-preserving synthetic data.
|
|
4794
|
+
* @param _language - Accepted for API compatibility but ignored locally.
|
|
4795
|
+
*/
|
|
4796
|
+
synthesize(text, _language, entities) {
|
|
4797
|
+
const matches = this.detect(text, entities);
|
|
4798
|
+
if (matches.length === 0) return {
|
|
4799
|
+
text,
|
|
4800
|
+
matches: []
|
|
4801
|
+
};
|
|
4802
|
+
const sortedMatches = [...matches].sort((a, b) => b.start - a.start);
|
|
4803
|
+
let result = text;
|
|
4804
|
+
for (const m of sortedMatches) {
|
|
4805
|
+
const replacement = synthesizeValue(m.entityType, m.text);
|
|
4806
|
+
result = result.slice(0, m.start) + replacement + result.slice(m.end);
|
|
4807
|
+
}
|
|
4808
|
+
return {
|
|
4809
|
+
text: result,
|
|
4810
|
+
matches
|
|
4811
|
+
};
|
|
4812
|
+
}
|
|
4813
|
+
/** Remove overlapping matches, preferring higher score then longer span. */
|
|
4814
|
+
deduplicate(matches) {
|
|
4815
|
+
if (matches.length === 0) return [];
|
|
4816
|
+
matches.sort((a, b) => {
|
|
4817
|
+
if (a.start !== b.start) return a.start - b.start;
|
|
4818
|
+
if (a.score !== b.score) return b.score - a.score;
|
|
4819
|
+
return b.end - b.start - (a.end - a.start);
|
|
4820
|
+
});
|
|
4821
|
+
const result = [];
|
|
4822
|
+
let lastEnd = -1;
|
|
4823
|
+
for (const m of matches) if (m.start >= lastEnd) {
|
|
4824
|
+
result.push(m);
|
|
4825
|
+
lastEnd = m.end;
|
|
4826
|
+
}
|
|
4827
|
+
return result;
|
|
4828
|
+
}
|
|
4829
|
+
};
|
|
4830
|
+
} });
|
|
4831
|
+
|
|
4832
|
+
//#endregion
|
|
4833
|
+
//#region src/regex/index.ts
|
|
4834
|
+
var regex_exports = {};
|
|
4835
|
+
__export(regex_exports, {
|
|
4836
|
+
EntityType: () => EntityType,
|
|
4837
|
+
PIIScanner: () => PIIScanner
|
|
4838
|
+
});
|
|
4839
|
+
var init_regex = __esm({ "src/regex/index.ts"() {
|
|
4840
|
+
init_scanner();
|
|
4841
|
+
init_entities();
|
|
4842
|
+
} });
|
|
4843
|
+
|
|
4844
|
+
//#endregion
|
|
4845
|
+
Object.defineProperty(exports, 'EntityType', {
|
|
4846
|
+
enumerable: true,
|
|
4847
|
+
get: function () {
|
|
4848
|
+
return EntityType;
|
|
4849
|
+
}
|
|
4850
|
+
});
|
|
4851
|
+
Object.defineProperty(exports, 'PIIScanner', {
|
|
4852
|
+
enumerable: true,
|
|
4853
|
+
get: function () {
|
|
4854
|
+
return PIIScanner;
|
|
4855
|
+
}
|
|
4856
|
+
});
|
|
4857
|
+
Object.defineProperty(exports, '__toCommonJS', {
|
|
4858
|
+
enumerable: true,
|
|
4859
|
+
get: function () {
|
|
4860
|
+
return __toCommonJS;
|
|
4861
|
+
}
|
|
4862
|
+
});
|
|
4863
|
+
Object.defineProperty(exports, '__toESM', {
|
|
4864
|
+
enumerable: true,
|
|
4865
|
+
get: function () {
|
|
4866
|
+
return __toESM;
|
|
4867
|
+
}
|
|
4868
|
+
});
|
|
4869
|
+
Object.defineProperty(exports, 'init_regex', {
|
|
4870
|
+
enumerable: true,
|
|
4871
|
+
get: function () {
|
|
4872
|
+
return init_regex;
|
|
4873
|
+
}
|
|
4874
|
+
});
|
|
4875
|
+
Object.defineProperty(exports, 'regex_exports', {
|
|
4876
|
+
enumerable: true,
|
|
4877
|
+
get: function () {
|
|
4878
|
+
return regex_exports;
|
|
4879
|
+
}
|
|
4880
|
+
});
|
|
4881
|
+
//# sourceMappingURL=regex-BEaK0E7Y.js.map
|