@deliverd/sdk 0.39.0 → 0.39.1

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.
@@ -75,6 +75,72 @@ export declare const DATA_KINDS: {
75
75
  readonly placeholder: "SSN";
76
76
  readonly redactable: true;
77
77
  };
78
+ readonly us_itin: {
79
+ readonly label: "US ITIN";
80
+ readonly category: "personal";
81
+ readonly placeholder: "ITIN";
82
+ readonly redactable: true;
83
+ };
84
+ readonly ca_sin: {
85
+ readonly label: "Canadian Social Insurance number";
86
+ readonly category: "personal";
87
+ readonly placeholder: "SIN";
88
+ readonly redactable: true;
89
+ };
90
+ readonly fr_nir: {
91
+ readonly label: "French social security number";
92
+ readonly category: "personal";
93
+ readonly placeholder: "NIR";
94
+ readonly redactable: true;
95
+ };
96
+ readonly es_dni: {
97
+ readonly label: "Spanish DNI or NIE";
98
+ readonly category: "personal";
99
+ readonly placeholder: "DNI";
100
+ readonly redactable: true;
101
+ };
102
+ readonly it_fiscal_code: {
103
+ readonly label: "Italian fiscal code";
104
+ readonly category: "personal";
105
+ readonly placeholder: "CF";
106
+ readonly redactable: true;
107
+ };
108
+ readonly nl_bsn: {
109
+ readonly label: "Dutch BSN";
110
+ readonly category: "personal";
111
+ readonly placeholder: "BSN";
112
+ readonly redactable: true;
113
+ };
114
+ readonly pl_pesel: {
115
+ readonly label: "Polish PESEL number";
116
+ readonly category: "personal";
117
+ readonly placeholder: "PESEL";
118
+ readonly redactable: true;
119
+ };
120
+ readonly de_tax_id: {
121
+ readonly label: "German tax ID";
122
+ readonly category: "personal";
123
+ readonly placeholder: "STEUERID";
124
+ readonly redactable: true;
125
+ };
126
+ readonly passport: {
127
+ readonly label: "Passport number";
128
+ readonly category: "personal";
129
+ readonly placeholder: "PASSPORT";
130
+ readonly redactable: true;
131
+ };
132
+ readonly vat_number: {
133
+ readonly label: "VAT number";
134
+ readonly category: "financial";
135
+ readonly placeholder: "VAT";
136
+ readonly redactable: true;
137
+ };
138
+ readonly bank_account: {
139
+ readonly label: "Bank account number";
140
+ readonly category: "financial";
141
+ readonly placeholder: "ACCOUNT";
142
+ readonly redactable: true;
143
+ };
78
144
  readonly ip_address: {
79
145
  readonly label: "IP address";
80
146
  readonly category: "personal";
@@ -1 +1 @@
1
- {"version":3,"file":"data-screen.d.ts","sourceRoot":"","sources":["../src/data-screen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,+DAAgE,CAAC;AACpG,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3E,eAAO,MAAM,iBAAiB,yEAA0E,CAAC;AACzG,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,eAAO,MAAM,eAAe,6CAA8C,CAAC;AAC3E,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,qEAAqE;AACrE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAerD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAUrB,6FAA6F;;;;;;;;;;;;;;;;;;;;;;;;;CAKlD,CAAC;AAE9C,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,UAAU,CAAC;AAC/C,eAAO,MAAM,cAAc,EAA8B,QAAQ,EAAE,CAAC;AAapE;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,cAAc,GAAG,YAAY,CAAC;CAChD;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,CAA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CAC1B,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,YAAY,GAAG,IAAI,EAC3B,MAAM,GAAE,YAAoC,EAC5C,kBAAkB,GAAE,oBAAqC,GACxD,gBAAgB,CAiDlB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,WAAW,CAAC,GAAG,SAAS,GAAG,IAAI,CAIzJ;AAED,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,oBAAoB,CAE7F"}
@@ -35,6 +35,17 @@ export const DATA_KINDS = {
35
35
  uk_national_insurance: { label: "UK National Insurance number", category: "personal", placeholder: "NINO", redactable: true },
36
36
  ie_pps: { label: "Irish PPS number", category: "personal", placeholder: "PPS", redactable: true },
37
37
  us_ssn: { label: "US Social Security number", category: "personal", placeholder: "SSN", redactable: true },
38
+ us_itin: { label: "US ITIN", category: "personal", placeholder: "ITIN", redactable: true },
39
+ ca_sin: { label: "Canadian Social Insurance number", category: "personal", placeholder: "SIN", redactable: true },
40
+ fr_nir: { label: "French social security number", category: "personal", placeholder: "NIR", redactable: true },
41
+ es_dni: { label: "Spanish DNI or NIE", category: "personal", placeholder: "DNI", redactable: true },
42
+ it_fiscal_code: { label: "Italian fiscal code", category: "personal", placeholder: "CF", redactable: true },
43
+ nl_bsn: { label: "Dutch BSN", category: "personal", placeholder: "BSN", redactable: true },
44
+ pl_pesel: { label: "Polish PESEL number", category: "personal", placeholder: "PESEL", redactable: true },
45
+ de_tax_id: { label: "German tax ID", category: "personal", placeholder: "STEUERID", redactable: true },
46
+ passport: { label: "Passport number", category: "personal", placeholder: "PASSPORT", redactable: true },
47
+ vat_number: { label: "VAT number", category: "financial", placeholder: "VAT", redactable: true },
48
+ bank_account: { label: "Bank account number", category: "financial", placeholder: "ACCOUNT", redactable: true },
38
49
  ip_address: { label: "IP address", category: "personal", placeholder: "IP", redactable: true },
39
50
  date_of_birth: { label: "Date of birth", category: "personal", placeholder: "DOB", redactable: true },
40
51
  /** Never found by a pattern here: only by a model detector the caller plugs in (`spans`). */
@@ -114,6 +125,99 @@ function ipv6Valid(raw) {
114
125
  const groups = raw.split(":").filter(Boolean).length;
115
126
  return compressed === 0 ? groups === 8 : compressed === 1 && groups >= 3 && groups <= 7;
116
127
  }
128
+ /** An ITIN: 9XX-XX-XXXX with a middle group the IRS issues (50-65, 70-88, 90-92, 94-99). */
129
+ function itinValid(raw) {
130
+ const g = Number(raw.slice(4, 6));
131
+ return (g >= 50 && g <= 65) || (g >= 70 && g <= 88) || (g >= 90 && g <= 92) || (g >= 94 && g <= 99);
132
+ }
133
+ /** A Canadian SIN: nine digits, Luhn-checked; none is issued starting with 0 or 8. */
134
+ function sinValid(raw) {
135
+ const d = digitsOf(raw);
136
+ return d.length === 9 && d[0] !== "0" && d[0] !== "8" && luhn(d);
137
+ }
138
+ /** An ABA routing number: weights 3, 7, 1 repeating, a multiple of 10. */
139
+ function abaValid(raw) {
140
+ const d = digitsOf(raw);
141
+ if (d.length !== 9 || /^0+$/.test(d))
142
+ return false;
143
+ let sum = 0;
144
+ for (let i = 0; i < 9; i++)
145
+ sum += (d.charCodeAt(i) - 48) * [3, 7, 1][i % 3];
146
+ return sum % 10 === 0;
147
+ }
148
+ /** A French NIR: thirteen digits (2A and 2B for Corsica) and a key, 97 minus the number mod 97. */
149
+ function nirValid(raw) {
150
+ const s = raw.replace(/ /g, "").toUpperCase();
151
+ if (s.length !== 15)
152
+ return false;
153
+ const body = s.slice(0, 13).replace("2A", "19").replace("2B", "18");
154
+ if (!/^\d{13}$/.test(body))
155
+ return false;
156
+ let mod = 0;
157
+ for (const ch of body)
158
+ mod = (mod * 10 + (ch.charCodeAt(0) - 48)) % 97;
159
+ return 97 - mod === Number(s.slice(13));
160
+ }
161
+ /** A Spanish DNI (eight digits) or NIE (X, Y or Z and seven), and its check letter. */
162
+ function dniValid(raw) {
163
+ const s = raw.replace("-", "").toUpperCase();
164
+ const n = Number(s.slice(0, -1).replace(/^X/, "0").replace(/^Y/, "1").replace(/^Z/, "2"));
165
+ return "TRWAGMYFPDXBNJZSQVHLCKE"[n % 23] === s.at(-1);
166
+ }
167
+ const CF_ODD = [1, 0, 5, 7, 9, 13, 15, 17, 19, 21, 2, 4, 18, 20, 11, 3, 6, 8, 12, 14, 16, 10, 22, 25, 24, 23];
168
+ /** An Italian codice fiscale and its check letter. */
169
+ function fiscalCodeValid(raw) {
170
+ const s = raw.toUpperCase();
171
+ let sum = 0;
172
+ for (let i = 0; i < 15; i++) {
173
+ const c = s.charCodeAt(i);
174
+ const v = c >= 65 ? c - 65 : c - 48;
175
+ sum += i % 2 === 0 ? CF_ODD[v] : v;
176
+ }
177
+ return String.fromCharCode(65 + (sum % 26)) === s[15];
178
+ }
179
+ /** A Dutch BSN: the eleven test, weights 9 to 2 and -1 on the last digit. */
180
+ function bsnValid(raw) {
181
+ const d = digitsOf(raw);
182
+ if (d.length !== 9 || /^0+$/.test(d))
183
+ return false;
184
+ let sum = 0;
185
+ for (let i = 0; i < 8; i++)
186
+ sum += (d.charCodeAt(i) - 48) * (9 - i);
187
+ return (sum - (d.charCodeAt(8) - 48)) % 11 === 0;
188
+ }
189
+ /** A Polish PESEL: weights 1, 3, 7, 9 repeating, and a check digit. */
190
+ function peselValid(raw) {
191
+ if (!/^\d{11}$/.test(raw))
192
+ return false;
193
+ let sum = 0;
194
+ for (let i = 0; i < 10; i++)
195
+ sum += (raw.charCodeAt(i) - 48) * [1, 3, 7, 9][i % 4];
196
+ return (10 - (sum % 10)) % 10 === raw.charCodeAt(10) - 48;
197
+ }
198
+ /** A German Steuer-ID: eleven digits, not starting with 0, ISO 7064 MOD 11,10. */
199
+ function steuerIdValid(raw) {
200
+ const d = digitsOf(raw);
201
+ if (d.length !== 11 || d[0] === "0")
202
+ return false;
203
+ let product = 10;
204
+ for (let i = 0; i < 10; i++) {
205
+ let sum = (d.charCodeAt(i) - 48 + product) % 10;
206
+ if (sum === 0)
207
+ sum = 10;
208
+ product = (2 * sum) % 11;
209
+ }
210
+ const check = 11 - product;
211
+ return (check === 10 ? 0 : check) === d.charCodeAt(10) - 48;
212
+ }
213
+ /** A passport number after the word: some digits in it, so "passport holder" is not one. */
214
+ function passportValid(raw) {
215
+ return digitsOf(raw).length >= 4;
216
+ }
217
+ /** A VAT number after the word: written in capitals, as issued, with digits in it. */
218
+ function vatValid(raw) {
219
+ return raw === raw.toUpperCase() && digitsOf(raw).length >= 6;
220
+ }
117
221
  /** A value in a .env line that is a placeholder, not a credential. */
118
222
  function envSecretValid(value) {
119
223
  return !/^[<{%(]/.test(value) && !/your|example|placeholder|changeme|xxxx/i.test(value);
@@ -169,6 +273,33 @@ const DETECTORS = [
169
273
  pattern: /\b(?!BG|GB|NK|KN|TN|NT|ZZ)[A-CEGHJ-PR-TW-Z][A-CEGHJ-NPR-TW-Z] ?\d{2} ?\d{2} ?\d{2} ?[A-D]\b/g,
170
274
  },
171
275
  { kind: "ie_pps", pattern: /\b\d{7}[A-W][A-IW]?\b/g, valid: ppsValid },
276
+ { kind: "us_itin", pattern: /\b9\d{2}-\d{2}-\d{4}\b/g, valid: itinValid },
277
+ // Written in groups of three, or as nine digits after the words.
278
+ { kind: "ca_sin", pattern: /\b\d{3}[ -]\d{3}[ -]\d{3}\b/g, valid: sinValid },
279
+ { kind: "ca_sin", pattern: /\b(?:SIN|social insurance (?:number|no\.?))[ \t:#]*(\d{9})\b/gi, valid: sinValid, group: 1 },
280
+ { kind: "fr_nir", pattern: /\b[12] ?\d{2} ?\d{2} ?(?:\d{2}|2[AB]) ?\d{3} ?\d{3} ?\d{2}\b/g, valid: nirValid },
281
+ { kind: "es_dni", pattern: /\b(?:\d{8}|[XYZ]\d{7})-?[A-Z]\b/g, valid: dniValid },
282
+ { kind: "it_fiscal_code", pattern: /\b[A-Z]{6}\d{2}[A-EHLMPRST]\d{2}[A-Z]\d{3}[A-Z]\b/g, valid: fiscalCodeValid },
283
+ // Nine or eleven bare digits are too often something else: these need the word before them.
284
+ { kind: "nl_bsn", pattern: /\b(?:BSN|burgerservicenummer)(?:-?nummer)?[ \t:#.]*(\d{9}|\d{4}\.\d{2}\.\d{3}|\d{3}[ .]\d{3}[ .]\d{3})\b/gi, valid: bsnValid, group: 1 },
285
+ { kind: "pl_pesel", pattern: /\bPESEL[ \t:#.]*(\d{11})\b/gi, valid: peselValid, group: 1 },
286
+ {
287
+ kind: "de_tax_id",
288
+ pattern: /\b(?:steuer-?id(?:entifikationsnummer)?|steuerliche identifikationsnummer|idnr\.?|tax id)[ \t:#.]*(\d{2} ?\d{3} ?\d{3} ?\d{3})\b/gi,
289
+ valid: steuerIdValid,
290
+ group: 1,
291
+ },
292
+ { kind: "passport", pattern: /\bpassport(?: (?:no\.?|number|#))?[ \t:#]*([A-Z0-9]{6,9})\b/gi, valid: passportValid, group: 1 },
293
+ {
294
+ kind: "vat_number",
295
+ pattern: /\b(?:VAT|BTW|TVA|IVA|USt-?IdNr\.?)(?: (?:no\.?|number|reg(?:istration)?(?: no\.?| number)?|id))?[ \t:#.]*((?:AT|BE|BG|CY|CZ|DE|DK|EE|EL|ES|FI|FR|GB|HR|HU|IE|IT|LT|LU|LV|MT|NL|PL|PT|RO|SE|SI|SK|XI) ?[0-9A-Z]{8,12})\b/gi,
296
+ valid: vatValid,
297
+ group: 1,
298
+ },
299
+ // Bank details after the words: a US routing number, a UK sort code, an account number.
300
+ { kind: "bank_account", pattern: /\b(?:routing|ABA|RTN)(?: (?:no\.?|number|#))?[ \t:#]*(\d{9})\b/gi, valid: abaValid, group: 1 },
301
+ { kind: "bank_account", pattern: /\bsort code[ \t:#]*(\d{2}[- ]?\d{2}[- ]?\d{2})\b/gi, group: 1 },
302
+ { kind: "bank_account", pattern: /\b(?:account|acct|a\/c)(?: (?:no\.?|number|#))?[ \t:#]*(\d{8,17})\b/gi, group: 1 },
172
303
  { kind: "email", pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}\b/g },
173
304
  {
174
305
  kind: "date_of_birth",
@@ -195,7 +326,7 @@ const DETECTORS = [
195
326
  { kind: "special_category", pattern: SPECIAL_PATTERN },
196
327
  ];
197
328
  /** Earlier wins an overlap: a card number is not also a phone number. */
198
- const PRIORITY = Object.fromEntries(["secret", "iban", "payment_card", "us_ssn", "uk_national_insurance", "ie_pps", "email", "date_of_birth", "phone", "ip_address", "term", "person_name", "special_category"].map((k, i) => [k, i]));
329
+ const PRIORITY = Object.fromEntries(["secret", "iban", "payment_card", "us_ssn", "uk_national_insurance", "ie_pps", "us_itin", "ca_sin", "fr_nir", "es_dni", "it_fiscal_code", "nl_bsn", "pl_pesel", "de_tax_id", "passport", "vat_number", "bank_account", "email", "date_of_birth", "phone", "ip_address", "term", "person_name", "special_category"].map((k, i) => [k, i]));
199
330
  const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
200
331
  /** Terms past this are ignored, so a pasted list cannot make every screen slow. */
201
332
  export const MAX_SCREEN_TERMS = 500;
@@ -327,6 +458,8 @@ export function readScreenPolicy(raw) {
327
458
  },
328
459
  };
329
460
  }
461
+ /** Labels that start with a proper name, so they keep their capitals in a sentence. */
462
+ const KEEP_CASE = new Set(["ca_sin", "fr_nir", "it_fiscal_code", "nl_bsn", "pl_pesel", "de_tax_id"]);
330
463
  const plural = (n, label) => `${n} ${label.toLowerCase()}${n === 1 ? "" : "s"}`;
331
464
  /** "2 email addresses and 1 IBAN", for a reason or an approval's title. */
332
465
  export function describeCounts(counts) {
@@ -349,6 +482,10 @@ export function describeCounts(counts) {
349
482
  return `${n} date${n === 1 ? "" : "s"} of birth`;
350
483
  if (k === "ie_pps")
351
484
  return `${n} Irish PPS number${n === 1 ? "" : "s"}`;
485
+ if (k === "es_dni")
486
+ return `${n} Spanish ${n === 1 ? "DNI or NIE" : "DNIs or NIEs"}`;
487
+ if (KEEP_CASE.has(k))
488
+ return `${n} ${label}${n === 1 ? "" : "s"}`;
352
489
  return /^[A-Z]{2,}/.test(label) ? `${n} ${label}${n === 1 ? "" : "s"}` : plural(n, label);
353
490
  });
354
491
  if (parts.length <= 1)
@@ -43,7 +43,7 @@
43
43
  * **Add the version here when you publish it, not before.** An entry is a
44
44
  * claim that `npm install @deliverd/sdk@x` works today.
45
45
  */
46
- export declare const PUBLISHED_TO_NPM: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.6.2", "0.7.0", "0.7.1", "0.8.0", "0.8.1", "0.8.2", "0.9.0", "0.10.0", "0.11.0", "0.11.1", "0.12.0", "0.13.0", "0.14.0", "0.15.0", "0.16.0", "0.17.0", "0.18.0", "0.19.0", "0.20.0", "0.21.0", "0.22.0", "0.23.0", "0.24.0", "0.24.1", "0.25.0", "0.25.1", "0.26.0", "0.27.0", "0.28.0", "0.29.0", "0.30.0", "0.31.0", "0.32.0", "0.33.0", "0.34.0", "0.35.0", "0.36.0", "0.37.0", "0.38.0"];
46
+ export declare const PUBLISHED_TO_NPM: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.6.2", "0.7.0", "0.7.1", "0.8.0", "0.8.1", "0.8.2", "0.9.0", "0.10.0", "0.11.0", "0.11.1", "0.12.0", "0.13.0", "0.14.0", "0.15.0", "0.16.0", "0.17.0", "0.18.0", "0.19.0", "0.20.0", "0.21.0", "0.22.0", "0.23.0", "0.24.0", "0.24.1", "0.25.0", "0.25.1", "0.26.0", "0.27.0", "0.28.0", "0.29.0", "0.30.0", "0.31.0", "0.32.0", "0.33.0", "0.34.0", "0.35.0", "0.36.0", "0.37.0", "0.38.0", "0.39.0"];
47
47
  /**
48
48
  * A fingerprint of what each *published* version recorded.
49
49
  *
@@ -1 +1 @@
1
- {"version":3,"file":"released.d.ts","sourceRoot":"","sources":["../src/released.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,ycA+CnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2HzC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAg9sCtD,CAAC"}
1
+ {"version":3,"file":"released.d.ts","sourceRoot":"","sources":["../src/released.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,mdAgDnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA6HzC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CA49vCtD,CAAC"}