@discretion/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (885) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/LICENSE +21 -0
  3. package/README.md +319 -0
  4. package/dist/src/checksums/aba.d.ts +25 -0
  5. package/dist/src/checksums/aba.d.ts.map +1 -0
  6. package/dist/src/checksums/aba.js +47 -0
  7. package/dist/src/checksums/aba.js.map +1 -0
  8. package/dist/src/checksums/digits.d.ts +55 -0
  9. package/dist/src/checksums/digits.d.ts.map +1 -0
  10. package/dist/src/checksums/digits.js +114 -0
  11. package/dist/src/checksums/digits.js.map +1 -0
  12. package/dist/src/checksums/icao9303.d.ts +29 -0
  13. package/dist/src/checksums/icao9303.d.ts.map +1 -0
  14. package/dist/src/checksums/icao9303.js +56 -0
  15. package/dist/src/checksums/icao9303.js.map +1 -0
  16. package/dist/src/checksums/index.d.ts +21 -0
  17. package/dist/src/checksums/index.d.ts.map +1 -0
  18. package/dist/src/checksums/index.js +21 -0
  19. package/dist/src/checksums/index.js.map +1 -0
  20. package/dist/src/checksums/iso7064.d.ts +67 -0
  21. package/dist/src/checksums/iso7064.d.ts.map +1 -0
  22. package/dist/src/checksums/iso7064.js +159 -0
  23. package/dist/src/checksums/iso7064.js.map +1 -0
  24. package/dist/src/checksums/luhn.d.ts +32 -0
  25. package/dist/src/checksums/luhn.d.ts.map +1 -0
  26. package/dist/src/checksums/luhn.js +66 -0
  27. package/dist/src/checksums/luhn.js.map +1 -0
  28. package/dist/src/checksums/mod97.d.ts +55 -0
  29. package/dist/src/checksums/mod97.d.ts.map +1 -0
  30. package/dist/src/checksums/mod97.js +94 -0
  31. package/dist/src/checksums/mod97.js.map +1 -0
  32. package/dist/src/checksums/verhoeff.d.ts +28 -0
  33. package/dist/src/checksums/verhoeff.d.ts.map +1 -0
  34. package/dist/src/checksums/verhoeff.js +80 -0
  35. package/dist/src/checksums/verhoeff.js.map +1 -0
  36. package/dist/src/checksums/weighted.d.ts +64 -0
  37. package/dist/src/checksums/weighted.d.ts.map +1 -0
  38. package/dist/src/checksums/weighted.js +97 -0
  39. package/dist/src/checksums/weighted.js.map +1 -0
  40. package/dist/src/context/documentProfile.d.ts +34 -0
  41. package/dist/src/context/documentProfile.d.ts.map +1 -0
  42. package/dist/src/context/documentProfile.js +253 -0
  43. package/dist/src/context/documentProfile.js.map +1 -0
  44. package/dist/src/context/negativeRules.d.ts +60 -0
  45. package/dist/src/context/negativeRules.d.ts.map +1 -0
  46. package/dist/src/context/negativeRules.js +696 -0
  47. package/dist/src/context/negativeRules.js.map +1 -0
  48. package/dist/src/context/score.d.ts +52 -0
  49. package/dist/src/context/score.d.ts.map +1 -0
  50. package/dist/src/context/score.js +346 -0
  51. package/dist/src/context/score.js.map +1 -0
  52. package/dist/src/context/structure.d.ts +46 -0
  53. package/dist/src/context/structure.d.ts.map +1 -0
  54. package/dist/src/context/structure.js +528 -0
  55. package/dist/src/context/structure.js.map +1 -0
  56. package/dist/src/context/triggers.d.ts +73 -0
  57. package/dist/src/context/triggers.d.ts.map +1 -0
  58. package/dist/src/context/triggers.js +172 -0
  59. package/dist/src/context/triggers.js.map +1 -0
  60. package/dist/src/context/types.d.ts +137 -0
  61. package/dist/src/context/types.d.ts.map +1 -0
  62. package/dist/src/context/types.js +25 -0
  63. package/dist/src/context/types.js.map +1 -0
  64. package/dist/src/crypto/keccak256.d.ts +15 -0
  65. package/dist/src/crypto/keccak256.d.ts.map +1 -0
  66. package/dist/src/crypto/keccak256.js +89 -0
  67. package/dist/src/crypto/keccak256.js.map +1 -0
  68. package/dist/src/crypto/sha256.d.ts +16 -0
  69. package/dist/src/crypto/sha256.d.ts.map +1 -0
  70. package/dist/src/crypto/sha256.js +81 -0
  71. package/dist/src/crypto/sha256.js.map +1 -0
  72. package/dist/src/detect/detectors/bankcodes/auBsb.d.ts +11 -0
  73. package/dist/src/detect/detectors/bankcodes/auBsb.d.ts.map +1 -0
  74. package/dist/src/detect/detectors/bankcodes/auBsb.js +34 -0
  75. package/dist/src/detect/detectors/bankcodes/auBsb.js.map +1 -0
  76. package/dist/src/detect/detectors/bankcodes/brAgencia.d.ts +15 -0
  77. package/dist/src/detect/detectors/bankcodes/brAgencia.d.ts.map +1 -0
  78. package/dist/src/detect/detectors/bankcodes/brAgencia.js +43 -0
  79. package/dist/src/detect/detectors/bankcodes/brAgencia.js.map +1 -0
  80. package/dist/src/detect/detectors/bankcodes/caTransit.d.ts +13 -0
  81. package/dist/src/detect/detectors/bankcodes/caTransit.d.ts.map +1 -0
  82. package/dist/src/detect/detectors/bankcodes/caTransit.js +86 -0
  83. package/dist/src/detect/detectors/bankcodes/caTransit.js.map +1 -0
  84. package/dist/src/detect/detectors/bankcodes/inIfsc.d.ts +13 -0
  85. package/dist/src/detect/detectors/bankcodes/inIfsc.d.ts.map +1 -0
  86. package/dist/src/detect/detectors/bankcodes/inIfsc.js +37 -0
  87. package/dist/src/detect/detectors/bankcodes/inIfsc.js.map +1 -0
  88. package/dist/src/detect/detectors/bankcodes/index.d.ts +10 -0
  89. package/dist/src/detect/detectors/bankcodes/index.d.ts.map +1 -0
  90. package/dist/src/detect/detectors/bankcodes/index.js +10 -0
  91. package/dist/src/detect/detectors/bankcodes/index.js.map +1 -0
  92. package/dist/src/detect/detectors/bankcodes/ukSortCode.d.ts +13 -0
  93. package/dist/src/detect/detectors/bankcodes/ukSortCode.d.ts.map +1 -0
  94. package/dist/src/detect/detectors/bankcodes/ukSortCode.js +36 -0
  95. package/dist/src/detect/detectors/bankcodes/ukSortCode.js.map +1 -0
  96. package/dist/src/detect/detectors/bankcodes/usRouting.d.ts +12 -0
  97. package/dist/src/detect/detectors/bankcodes/usRouting.d.ts.map +1 -0
  98. package/dist/src/detect/detectors/bankcodes/usRouting.js +45 -0
  99. package/dist/src/detect/detectors/bankcodes/usRouting.js.map +1 -0
  100. package/dist/src/detect/detectors/contact/email.d.ts +16 -0
  101. package/dist/src/detect/detectors/contact/email.d.ts.map +1 -0
  102. package/dist/src/detect/detectors/contact/email.js +111 -0
  103. package/dist/src/detect/detectors/contact/email.js.map +1 -0
  104. package/dist/src/detect/detectors/contact/index.d.ts +11 -0
  105. package/dist/src/detect/detectors/contact/index.d.ts.map +1 -0
  106. package/dist/src/detect/detectors/contact/index.js +11 -0
  107. package/dist/src/detect/detectors/contact/index.js.map +1 -0
  108. package/dist/src/detect/detectors/contact/ipv4.d.ts +12 -0
  109. package/dist/src/detect/detectors/contact/ipv4.d.ts.map +1 -0
  110. package/dist/src/detect/detectors/contact/ipv4.js +109 -0
  111. package/dist/src/detect/detectors/contact/ipv4.js.map +1 -0
  112. package/dist/src/detect/detectors/contact/ipv6.d.ts +16 -0
  113. package/dist/src/detect/detectors/contact/ipv6.d.ts.map +1 -0
  114. package/dist/src/detect/detectors/contact/ipv6.js +187 -0
  115. package/dist/src/detect/detectors/contact/ipv6.js.map +1 -0
  116. package/dist/src/detect/detectors/contact/mac.d.ts +14 -0
  117. package/dist/src/detect/detectors/contact/mac.d.ts.map +1 -0
  118. package/dist/src/detect/detectors/contact/mac.js +64 -0
  119. package/dist/src/detect/detectors/contact/mac.js.map +1 -0
  120. package/dist/src/detect/detectors/contact/phone.d.ts +21 -0
  121. package/dist/src/detect/detectors/contact/phone.d.ts.map +1 -0
  122. package/dist/src/detect/detectors/contact/phone.js +76 -0
  123. package/dist/src/detect/detectors/contact/phone.js.map +1 -0
  124. package/dist/src/detect/detectors/contact/urlCredentials.d.ts +23 -0
  125. package/dist/src/detect/detectors/contact/urlCredentials.d.ts.map +1 -0
  126. package/dist/src/detect/detectors/contact/urlCredentials.js +123 -0
  127. package/dist/src/detect/detectors/contact/urlCredentials.js.map +1 -0
  128. package/dist/src/detect/detectors/crypto/ada.d.ts +13 -0
  129. package/dist/src/detect/detectors/crypto/ada.d.ts.map +1 -0
  130. package/dist/src/detect/detectors/crypto/ada.js +51 -0
  131. package/dist/src/detect/detectors/crypto/ada.js.map +1 -0
  132. package/dist/src/detect/detectors/crypto/btc.d.ts +15 -0
  133. package/dist/src/detect/detectors/crypto/btc.d.ts.map +1 -0
  134. package/dist/src/detect/detectors/crypto/btc.js +78 -0
  135. package/dist/src/detect/detectors/crypto/btc.js.map +1 -0
  136. package/dist/src/detect/detectors/crypto/dot.d.ts +13 -0
  137. package/dist/src/detect/detectors/crypto/dot.d.ts.map +1 -0
  138. package/dist/src/detect/detectors/crypto/dot.js +41 -0
  139. package/dist/src/detect/detectors/crypto/dot.js.map +1 -0
  140. package/dist/src/detect/detectors/crypto/eth.d.ts +15 -0
  141. package/dist/src/detect/detectors/crypto/eth.d.ts.map +1 -0
  142. package/dist/src/detect/detectors/crypto/eth.js +63 -0
  143. package/dist/src/detect/detectors/crypto/eth.js.map +1 -0
  144. package/dist/src/detect/detectors/crypto/index.d.ts +12 -0
  145. package/dist/src/detect/detectors/crypto/index.d.ts.map +1 -0
  146. package/dist/src/detect/detectors/crypto/index.js +12 -0
  147. package/dist/src/detect/detectors/crypto/index.js.map +1 -0
  148. package/dist/src/detect/detectors/crypto/ltc.d.ts +12 -0
  149. package/dist/src/detect/detectors/crypto/ltc.d.ts.map +1 -0
  150. package/dist/src/detect/detectors/crypto/ltc.js +71 -0
  151. package/dist/src/detect/detectors/crypto/ltc.js.map +1 -0
  152. package/dist/src/detect/detectors/crypto/sol.d.ts +13 -0
  153. package/dist/src/detect/detectors/crypto/sol.d.ts.map +1 -0
  154. package/dist/src/detect/detectors/crypto/sol.js +39 -0
  155. package/dist/src/detect/detectors/crypto/sol.js.map +1 -0
  156. package/dist/src/detect/detectors/crypto/trx.d.ts +8 -0
  157. package/dist/src/detect/detectors/crypto/trx.d.ts.map +1 -0
  158. package/dist/src/detect/detectors/crypto/trx.js +34 -0
  159. package/dist/src/detect/detectors/crypto/trx.js.map +1 -0
  160. package/dist/src/detect/detectors/crypto/xmr.d.ts +10 -0
  161. package/dist/src/detect/detectors/crypto/xmr.d.ts.map +1 -0
  162. package/dist/src/detect/detectors/crypto/xmr.js +51 -0
  163. package/dist/src/detect/detectors/crypto/xmr.js.map +1 -0
  164. package/dist/src/detect/detectors/documents/driversLicense.d.ts +24 -0
  165. package/dist/src/detect/detectors/documents/driversLicense.d.ts.map +1 -0
  166. package/dist/src/detect/detectors/documents/driversLicense.js +79 -0
  167. package/dist/src/detect/detectors/documents/driversLicense.js.map +1 -0
  168. package/dist/src/detect/detectors/documents/healthData.d.ts +23 -0
  169. package/dist/src/detect/detectors/documents/healthData.d.ts.map +1 -0
  170. package/dist/src/detect/detectors/documents/healthData.js +78 -0
  171. package/dist/src/detect/detectors/documents/healthData.js.map +1 -0
  172. package/dist/src/detect/detectors/documents/index.d.ts +9 -0
  173. package/dist/src/detect/detectors/documents/index.d.ts.map +1 -0
  174. package/dist/src/detect/detectors/documents/index.js +9 -0
  175. package/dist/src/detect/detectors/documents/index.js.map +1 -0
  176. package/dist/src/detect/detectors/documents/passportMrz.d.ts +20 -0
  177. package/dist/src/detect/detectors/documents/passportMrz.d.ts.map +1 -0
  178. package/dist/src/detect/detectors/documents/passportMrz.js +194 -0
  179. package/dist/src/detect/detectors/documents/passportMrz.js.map +1 -0
  180. package/dist/src/detect/detectors/documents/usNpi.d.ts +16 -0
  181. package/dist/src/detect/detectors/documents/usNpi.d.ts.map +1 -0
  182. package/dist/src/detect/detectors/documents/usNpi.js +48 -0
  183. package/dist/src/detect/detectors/documents/usNpi.js.map +1 -0
  184. package/dist/src/detect/detectors/documents/vin.d.ts +15 -0
  185. package/dist/src/detect/detectors/documents/vin.d.ts.map +1 -0
  186. package/dist/src/detect/detectors/documents/vin.js +64 -0
  187. package/dist/src/detect/detectors/documents/vin.js.map +1 -0
  188. package/dist/src/detect/detectors/financial/creditCard.d.ts +23 -0
  189. package/dist/src/detect/detectors/financial/creditCard.d.ts.map +1 -0
  190. package/dist/src/detect/detectors/financial/creditCard.js +157 -0
  191. package/dist/src/detect/detectors/financial/creditCard.js.map +1 -0
  192. package/dist/src/detect/detectors/financial/iban.d.ts +18 -0
  193. package/dist/src/detect/detectors/financial/iban.d.ts.map +1 -0
  194. package/dist/src/detect/detectors/financial/iban.js +80 -0
  195. package/dist/src/detect/detectors/financial/iban.js.map +1 -0
  196. package/dist/src/detect/detectors/financial/ibanRegistry.d.ts +35 -0
  197. package/dist/src/detect/detectors/financial/ibanRegistry.d.ts.map +1 -0
  198. package/dist/src/detect/detectors/financial/ibanRegistry.js +92 -0
  199. package/dist/src/detect/detectors/financial/ibanRegistry.js.map +1 -0
  200. package/dist/src/detect/detectors/financial/index.d.ts +7 -0
  201. package/dist/src/detect/detectors/financial/index.d.ts.map +1 -0
  202. package/dist/src/detect/detectors/financial/index.js +7 -0
  203. package/dist/src/detect/detectors/financial/index.js.map +1 -0
  204. package/dist/src/detect/detectors/financial/swiftBic.d.ts +17 -0
  205. package/dist/src/detect/detectors/financial/swiftBic.d.ts.map +1 -0
  206. package/dist/src/detect/detectors/financial/swiftBic.js +55 -0
  207. package/dist/src/detect/detectors/financial/swiftBic.js.map +1 -0
  208. package/dist/src/detect/detectors/index.d.ts +15 -0
  209. package/dist/src/detect/detectors/index.d.ts.map +1 -0
  210. package/dist/src/detect/detectors/index.js +15 -0
  211. package/dist/src/detect/detectors/index.js.map +1 -0
  212. package/dist/src/detect/detectors/location/coordinates.d.ts +14 -0
  213. package/dist/src/detect/detectors/location/coordinates.d.ts.map +1 -0
  214. package/dist/src/detect/detectors/location/coordinates.js +79 -0
  215. package/dist/src/detect/detectors/location/coordinates.js.map +1 -0
  216. package/dist/src/detect/detectors/location/index.d.ts +7 -0
  217. package/dist/src/detect/detectors/location/index.d.ts.map +1 -0
  218. package/dist/src/detect/detectors/location/index.js +7 -0
  219. package/dist/src/detect/detectors/location/index.js.map +1 -0
  220. package/dist/src/detect/detectors/location/postalCode.d.ts +13 -0
  221. package/dist/src/detect/detectors/location/postalCode.d.ts.map +1 -0
  222. package/dist/src/detect/detectors/location/postalCode.js +53 -0
  223. package/dist/src/detect/detectors/location/postalCode.js.map +1 -0
  224. package/dist/src/detect/detectors/location/postalRegistry.d.ts +19 -0
  225. package/dist/src/detect/detectors/location/postalRegistry.d.ts.map +1 -0
  226. package/dist/src/detect/detectors/location/postalRegistry.js +73 -0
  227. package/dist/src/detect/detectors/location/postalRegistry.js.map +1 -0
  228. package/dist/src/detect/detectors/location/streetAddress.d.ts +21 -0
  229. package/dist/src/detect/detectors/location/streetAddress.d.ts.map +1 -0
  230. package/dist/src/detect/detectors/location/streetAddress.js +70 -0
  231. package/dist/src/detect/detectors/location/streetAddress.js.map +1 -0
  232. package/dist/src/detect/detectors/natid/africa.d.ts +17 -0
  233. package/dist/src/detect/detectors/natid/africa.d.ts.map +1 -0
  234. package/dist/src/detect/detectors/natid/africa.js +106 -0
  235. package/dist/src/detect/detectors/natid/africa.js.map +1 -0
  236. package/dist/src/detect/detectors/natid/ar.d.ts +14 -0
  237. package/dist/src/detect/detectors/natid/ar.d.ts.map +1 -0
  238. package/dist/src/detect/detectors/natid/ar.js +62 -0
  239. package/dist/src/detect/detectors/natid/ar.js.map +1 -0
  240. package/dist/src/detect/detectors/natid/au.d.ts +13 -0
  241. package/dist/src/detect/detectors/natid/au.d.ts.map +1 -0
  242. package/dist/src/detect/detectors/natid/au.js +100 -0
  243. package/dist/src/detect/detectors/natid/au.js.map +1 -0
  244. package/dist/src/detect/detectors/natid/be.d.ts +8 -0
  245. package/dist/src/detect/detectors/natid/be.d.ts.map +1 -0
  246. package/dist/src/detect/detectors/natid/be.js +44 -0
  247. package/dist/src/detect/detectors/natid/be.js.map +1 -0
  248. package/dist/src/detect/detectors/natid/bg.d.ts +7 -0
  249. package/dist/src/detect/detectors/natid/bg.d.ts.map +1 -0
  250. package/dist/src/detect/detectors/natid/bg.js +44 -0
  251. package/dist/src/detect/detectors/natid/bg.js.map +1 -0
  252. package/dist/src/detect/detectors/natid/br.d.ts +8 -0
  253. package/dist/src/detect/detectors/natid/br.d.ts.map +1 -0
  254. package/dist/src/detect/detectors/natid/br.js +85 -0
  255. package/dist/src/detect/detectors/natid/br.js.map +1 -0
  256. package/dist/src/detect/detectors/natid/ca.d.ts +8 -0
  257. package/dist/src/detect/detectors/natid/ca.d.ts.map +1 -0
  258. package/dist/src/detect/detectors/natid/ca.js +41 -0
  259. package/dist/src/detect/detectors/natid/ca.js.map +1 -0
  260. package/dist/src/detect/detectors/natid/cl.d.ts +9 -0
  261. package/dist/src/detect/detectors/natid/cl.d.ts.map +1 -0
  262. package/dist/src/detect/detectors/natid/cl.js +47 -0
  263. package/dist/src/detect/detectors/natid/cl.js.map +1 -0
  264. package/dist/src/detect/detectors/natid/cn.d.ts +9 -0
  265. package/dist/src/detect/detectors/natid/cn.d.ts.map +1 -0
  266. package/dist/src/detect/detectors/natid/cn.js +49 -0
  267. package/dist/src/detect/detectors/natid/cn.js.map +1 -0
  268. package/dist/src/detect/detectors/natid/co.d.ts +10 -0
  269. package/dist/src/detect/detectors/natid/co.d.ts.map +1 -0
  270. package/dist/src/detect/detectors/natid/co.js +43 -0
  271. package/dist/src/detect/detectors/natid/co.js.map +1 -0
  272. package/dist/src/detect/detectors/natid/cz.d.ts +11 -0
  273. package/dist/src/detect/detectors/natid/cz.d.ts.map +1 -0
  274. package/dist/src/detect/detectors/natid/cz.js +44 -0
  275. package/dist/src/detect/detectors/natid/cz.js.map +1 -0
  276. package/dist/src/detect/detectors/natid/de.d.ts +16 -0
  277. package/dist/src/detect/detectors/natid/de.d.ts.map +1 -0
  278. package/dist/src/detect/detectors/natid/de.js +77 -0
  279. package/dist/src/detect/detectors/natid/de.js.map +1 -0
  280. package/dist/src/detect/detectors/natid/dk.d.ts +9 -0
  281. package/dist/src/detect/detectors/natid/dk.d.ts.map +1 -0
  282. package/dist/src/detect/detectors/natid/dk.js +31 -0
  283. package/dist/src/detect/detectors/natid/dk.js.map +1 -0
  284. package/dist/src/detect/detectors/natid/es.d.ts +12 -0
  285. package/dist/src/detect/detectors/natid/es.d.ts.map +1 -0
  286. package/dist/src/detect/detectors/natid/es.js +96 -0
  287. package/dist/src/detect/detectors/natid/es.js.map +1 -0
  288. package/dist/src/detect/detectors/natid/fi.d.ts +10 -0
  289. package/dist/src/detect/detectors/natid/fi.d.ts.map +1 -0
  290. package/dist/src/detect/detectors/natid/fi.js +40 -0
  291. package/dist/src/detect/detectors/natid/fi.js.map +1 -0
  292. package/dist/src/detect/detectors/natid/fr.d.ts +12 -0
  293. package/dist/src/detect/detectors/natid/fr.d.ts.map +1 -0
  294. package/dist/src/detect/detectors/natid/fr.js +61 -0
  295. package/dist/src/detect/detectors/natid/fr.js.map +1 -0
  296. package/dist/src/detect/detectors/natid/gb.d.ts +10 -0
  297. package/dist/src/detect/detectors/natid/gb.d.ts.map +1 -0
  298. package/dist/src/detect/detectors/natid/gb.js +72 -0
  299. package/dist/src/detect/detectors/natid/gb.js.map +1 -0
  300. package/dist/src/detect/detectors/natid/gr.d.ts +7 -0
  301. package/dist/src/detect/detectors/natid/gr.d.ts.map +1 -0
  302. package/dist/src/detect/detectors/natid/gr.js +36 -0
  303. package/dist/src/detect/detectors/natid/gr.js.map +1 -0
  304. package/dist/src/detect/detectors/natid/gulf.d.ts +16 -0
  305. package/dist/src/detect/detectors/natid/gulf.d.ts.map +1 -0
  306. package/dist/src/detect/detectors/natid/gulf.js +121 -0
  307. package/dist/src/detect/detectors/natid/gulf.js.map +1 -0
  308. package/dist/src/detect/detectors/natid/hk.d.ts +9 -0
  309. package/dist/src/detect/detectors/natid/hk.d.ts.map +1 -0
  310. package/dist/src/detect/detectors/natid/hk.js +41 -0
  311. package/dist/src/detect/detectors/natid/hk.js.map +1 -0
  312. package/dist/src/detect/detectors/natid/hr.d.ts +6 -0
  313. package/dist/src/detect/detectors/natid/hr.d.ts.map +1 -0
  314. package/dist/src/detect/detectors/natid/hr.js +32 -0
  315. package/dist/src/detect/detectors/natid/hr.js.map +1 -0
  316. package/dist/src/detect/detectors/natid/hu.d.ts +7 -0
  317. package/dist/src/detect/detectors/natid/hu.d.ts.map +1 -0
  318. package/dist/src/detect/detectors/natid/hu.js +37 -0
  319. package/dist/src/detect/detectors/natid/hu.js.map +1 -0
  320. package/dist/src/detect/detectors/natid/ie.d.ts +9 -0
  321. package/dist/src/detect/detectors/natid/ie.d.ts.map +1 -0
  322. package/dist/src/detect/detectors/natid/ie.js +36 -0
  323. package/dist/src/detect/detectors/natid/ie.js.map +1 -0
  324. package/dist/src/detect/detectors/natid/il.d.ts +10 -0
  325. package/dist/src/detect/detectors/natid/il.d.ts.map +1 -0
  326. package/dist/src/detect/detectors/natid/il.js +38 -0
  327. package/dist/src/detect/detectors/natid/il.js.map +1 -0
  328. package/dist/src/detect/detectors/natid/in.d.ts +17 -0
  329. package/dist/src/detect/detectors/natid/in.d.ts.map +1 -0
  330. package/dist/src/detect/detectors/natid/in.js +67 -0
  331. package/dist/src/detect/detectors/natid/in.js.map +1 -0
  332. package/dist/src/detect/detectors/natid/index.d.ts +55 -0
  333. package/dist/src/detect/detectors/natid/index.d.ts.map +1 -0
  334. package/dist/src/detect/detectors/natid/index.js +55 -0
  335. package/dist/src/detect/detectors/natid/index.js.map +1 -0
  336. package/dist/src/detect/detectors/natid/is.d.ts +8 -0
  337. package/dist/src/detect/detectors/natid/is.d.ts.map +1 -0
  338. package/dist/src/detect/detectors/natid/is.js +42 -0
  339. package/dist/src/detect/detectors/natid/is.js.map +1 -0
  340. package/dist/src/detect/detectors/natid/it.d.ts +12 -0
  341. package/dist/src/detect/detectors/natid/it.d.ts.map +1 -0
  342. package/dist/src/detect/detectors/natid/it.js +62 -0
  343. package/dist/src/detect/detectors/natid/it.js.map +1 -0
  344. package/dist/src/detect/detectors/natid/jp.d.ts +9 -0
  345. package/dist/src/detect/detectors/natid/jp.d.ts.map +1 -0
  346. package/dist/src/detect/detectors/natid/jp.js +46 -0
  347. package/dist/src/detect/detectors/natid/jp.js.map +1 -0
  348. package/dist/src/detect/detectors/natid/kr.d.ts +11 -0
  349. package/dist/src/detect/detectors/natid/kr.d.ts.map +1 -0
  350. package/dist/src/detect/detectors/natid/kr.js +40 -0
  351. package/dist/src/detect/detectors/natid/kr.js.map +1 -0
  352. package/dist/src/detect/detectors/natid/kz.d.ts +8 -0
  353. package/dist/src/detect/detectors/natid/kz.d.ts.map +1 -0
  354. package/dist/src/detect/detectors/natid/kz.js +46 -0
  355. package/dist/src/detect/detectors/natid/kz.js.map +1 -0
  356. package/dist/src/detect/detectors/natid/mx.d.ts +16 -0
  357. package/dist/src/detect/detectors/natid/mx.d.ts.map +1 -0
  358. package/dist/src/detect/detectors/natid/mx.js +82 -0
  359. package/dist/src/detect/detectors/natid/mx.js.map +1 -0
  360. package/dist/src/detect/detectors/natid/nl.d.ts +8 -0
  361. package/dist/src/detect/detectors/natid/nl.d.ts.map +1 -0
  362. package/dist/src/detect/detectors/natid/nl.js +40 -0
  363. package/dist/src/detect/detectors/natid/nl.js.map +1 -0
  364. package/dist/src/detect/detectors/natid/no.d.ts +9 -0
  365. package/dist/src/detect/detectors/natid/no.d.ts.map +1 -0
  366. package/dist/src/detect/detectors/natid/no.js +52 -0
  367. package/dist/src/detect/detectors/natid/no.js.map +1 -0
  368. package/dist/src/detect/detectors/natid/nz.d.ts +9 -0
  369. package/dist/src/detect/detectors/natid/nz.d.ts.map +1 -0
  370. package/dist/src/detect/detectors/natid/nz.js +52 -0
  371. package/dist/src/detect/detectors/natid/nz.js.map +1 -0
  372. package/dist/src/detect/detectors/natid/pe.d.ts +7 -0
  373. package/dist/src/detect/detectors/natid/pe.d.ts.map +1 -0
  374. package/dist/src/detect/detectors/natid/pe.js +26 -0
  375. package/dist/src/detect/detectors/natid/pe.js.map +1 -0
  376. package/dist/src/detect/detectors/natid/pl.d.ts +11 -0
  377. package/dist/src/detect/detectors/natid/pl.d.ts.map +1 -0
  378. package/dist/src/detect/detectors/natid/pl.js +105 -0
  379. package/dist/src/detect/detectors/natid/pl.js.map +1 -0
  380. package/dist/src/detect/detectors/natid/pt.d.ts +6 -0
  381. package/dist/src/detect/detectors/natid/pt.d.ts.map +1 -0
  382. package/dist/src/detect/detectors/natid/pt.js +35 -0
  383. package/dist/src/detect/detectors/natid/pt.js.map +1 -0
  384. package/dist/src/detect/detectors/natid/ro.d.ts +8 -0
  385. package/dist/src/detect/detectors/natid/ro.d.ts.map +1 -0
  386. package/dist/src/detect/detectors/natid/ro.js +48 -0
  387. package/dist/src/detect/detectors/natid/ro.js.map +1 -0
  388. package/dist/src/detect/detectors/natid/ru.d.ts +11 -0
  389. package/dist/src/detect/detectors/natid/ru.d.ts.map +1 -0
  390. package/dist/src/detect/detectors/natid/ru.js +86 -0
  391. package/dist/src/detect/detectors/natid/ru.js.map +1 -0
  392. package/dist/src/detect/detectors/natid/se.d.ts +9 -0
  393. package/dist/src/detect/detectors/natid/se.d.ts.map +1 -0
  394. package/dist/src/detect/detectors/natid/se.js +43 -0
  395. package/dist/src/detect/detectors/natid/se.js.map +1 -0
  396. package/dist/src/detect/detectors/natid/seasia.d.ts +19 -0
  397. package/dist/src/detect/detectors/natid/seasia.d.ts.map +1 -0
  398. package/dist/src/detect/detectors/natid/seasia.js +182 -0
  399. package/dist/src/detect/detectors/natid/seasia.js.map +1 -0
  400. package/dist/src/detect/detectors/natid/sg.d.ts +8 -0
  401. package/dist/src/detect/detectors/natid/sg.d.ts.map +1 -0
  402. package/dist/src/detect/detectors/natid/sg.js +39 -0
  403. package/dist/src/detect/detectors/natid/sg.js.map +1 -0
  404. package/dist/src/detect/detectors/natid/si.d.ts +8 -0
  405. package/dist/src/detect/detectors/natid/si.d.ts.map +1 -0
  406. package/dist/src/detect/detectors/natid/si.js +44 -0
  407. package/dist/src/detect/detectors/natid/si.js.map +1 -0
  408. package/dist/src/detect/detectors/natid/tr.d.ts +14 -0
  409. package/dist/src/detect/detectors/natid/tr.d.ts.map +1 -0
  410. package/dist/src/detect/detectors/natid/tr.js +79 -0
  411. package/dist/src/detect/detectors/natid/tr.js.map +1 -0
  412. package/dist/src/detect/detectors/natid/tw.d.ts +9 -0
  413. package/dist/src/detect/detectors/natid/tw.d.ts.map +1 -0
  414. package/dist/src/detect/detectors/natid/tw.js +40 -0
  415. package/dist/src/detect/detectors/natid/tw.js.map +1 -0
  416. package/dist/src/detect/detectors/natid/ua.d.ts +7 -0
  417. package/dist/src/detect/detectors/natid/ua.d.ts.map +1 -0
  418. package/dist/src/detect/detectors/natid/ua.js +38 -0
  419. package/dist/src/detect/detectors/natid/ua.js.map +1 -0
  420. package/dist/src/detect/detectors/natid/us.d.ts +15 -0
  421. package/dist/src/detect/detectors/natid/us.d.ts.map +1 -0
  422. package/dist/src/detect/detectors/natid/us.js +119 -0
  423. package/dist/src/detect/detectors/natid/us.js.map +1 -0
  424. package/dist/src/detect/detectors/natid/za.d.ts +9 -0
  425. package/dist/src/detect/detectors/natid/za.d.ts.map +1 -0
  426. package/dist/src/detect/detectors/natid/za.js +44 -0
  427. package/dist/src/detect/detectors/natid/za.js.map +1 -0
  428. package/dist/src/detect/detectors/secrets/apiKey.d.ts +14 -0
  429. package/dist/src/detect/detectors/secrets/apiKey.d.ts.map +1 -0
  430. package/dist/src/detect/detectors/secrets/apiKey.js +103 -0
  431. package/dist/src/detect/detectors/secrets/apiKey.js.map +1 -0
  432. package/dist/src/detect/detectors/secrets/connectionString.d.ts +12 -0
  433. package/dist/src/detect/detectors/secrets/connectionString.d.ts.map +1 -0
  434. package/dist/src/detect/detectors/secrets/connectionString.js +70 -0
  435. package/dist/src/detect/detectors/secrets/connectionString.js.map +1 -0
  436. package/dist/src/detect/detectors/secrets/genericSecret.d.ts +22 -0
  437. package/dist/src/detect/detectors/secrets/genericSecret.d.ts.map +1 -0
  438. package/dist/src/detect/detectors/secrets/genericSecret.js +77 -0
  439. package/dist/src/detect/detectors/secrets/genericSecret.js.map +1 -0
  440. package/dist/src/detect/detectors/secrets/index.d.ts +9 -0
  441. package/dist/src/detect/detectors/secrets/index.d.ts.map +1 -0
  442. package/dist/src/detect/detectors/secrets/index.js +9 -0
  443. package/dist/src/detect/detectors/secrets/index.js.map +1 -0
  444. package/dist/src/detect/detectors/secrets/jwt.d.ts +11 -0
  445. package/dist/src/detect/detectors/secrets/jwt.d.ts.map +1 -0
  446. package/dist/src/detect/detectors/secrets/jwt.js +111 -0
  447. package/dist/src/detect/detectors/secrets/jwt.js.map +1 -0
  448. package/dist/src/detect/detectors/secrets/pemPrivateKey.d.ts +16 -0
  449. package/dist/src/detect/detectors/secrets/pemPrivateKey.d.ts.map +1 -0
  450. package/dist/src/detect/detectors/secrets/pemPrivateKey.js +56 -0
  451. package/dist/src/detect/detectors/secrets/pemPrivateKey.js.map +1 -0
  452. package/dist/src/detect/detectors/vat/euVat.d.ts +17 -0
  453. package/dist/src/detect/detectors/vat/euVat.d.ts.map +1 -0
  454. package/dist/src/detect/detectors/vat/euVat.js +293 -0
  455. package/dist/src/detect/detectors/vat/euVat.js.map +1 -0
  456. package/dist/src/detect/detectors/vat/index.d.ts +5 -0
  457. package/dist/src/detect/detectors/vat/index.d.ts.map +1 -0
  458. package/dist/src/detect/detectors/vat/index.js +5 -0
  459. package/dist/src/detect/detectors/vat/index.js.map +1 -0
  460. package/dist/src/detect/entropy.d.ts +28 -0
  461. package/dist/src/detect/entropy.d.ts.map +1 -0
  462. package/dist/src/detect/entropy.js +64 -0
  463. package/dist/src/detect/entropy.js.map +1 -0
  464. package/dist/src/detect/isoCountries.d.ts +10 -0
  465. package/dist/src/detect/isoCountries.d.ts.map +1 -0
  466. package/dist/src/detect/isoCountries.js +25 -0
  467. package/dist/src/detect/isoCountries.js.map +1 -0
  468. package/dist/src/detect/registry.d.ts +50 -0
  469. package/dist/src/detect/registry.d.ts.map +1 -0
  470. package/dist/src/detect/registry.js +110 -0
  471. package/dist/src/detect/registry.js.map +1 -0
  472. package/dist/src/detect/runner.d.ts +64 -0
  473. package/dist/src/detect/runner.d.ts.map +1 -0
  474. package/dist/src/detect/runner.js +142 -0
  475. package/dist/src/detect/runner.js.map +1 -0
  476. package/dist/src/detect/types.d.ts +251 -0
  477. package/dist/src/detect/types.d.ts.map +1 -0
  478. package/dist/src/detect/types.js +59 -0
  479. package/dist/src/detect/types.js.map +1 -0
  480. package/dist/src/encoding/base58.d.ts +26 -0
  481. package/dist/src/encoding/base58.d.ts.map +1 -0
  482. package/dist/src/encoding/base58.js +77 -0
  483. package/dist/src/encoding/base58.js.map +1 -0
  484. package/dist/src/encoding/base58monero.d.ts +15 -0
  485. package/dist/src/encoding/base58monero.d.ts.map +1 -0
  486. package/dist/src/encoding/base58monero.js +87 -0
  487. package/dist/src/encoding/base58monero.js.map +1 -0
  488. package/dist/src/encoding/bech32.d.ts +28 -0
  489. package/dist/src/encoding/bech32.d.ts.map +1 -0
  490. package/dist/src/encoding/bech32.js +108 -0
  491. package/dist/src/encoding/bech32.js.map +1 -0
  492. package/dist/src/encoding/bytes.d.ts +15 -0
  493. package/dist/src/encoding/bytes.d.ts.map +1 -0
  494. package/dist/src/encoding/bytes.js +46 -0
  495. package/dist/src/encoding/bytes.js.map +1 -0
  496. package/dist/src/entityFamily.d.ts +18 -0
  497. package/dist/src/entityFamily.d.ts.map +1 -0
  498. package/dist/src/entityFamily.js +54 -0
  499. package/dist/src/entityFamily.js.map +1 -0
  500. package/dist/src/entityLabel.d.ts +18 -0
  501. package/dist/src/entityLabel.d.ts.map +1 -0
  502. package/dist/src/entityLabel.js +53 -0
  503. package/dist/src/entityLabel.js.map +1 -0
  504. package/dist/src/entityTypes.d.ts +64 -0
  505. package/dist/src/entityTypes.d.ts.map +1 -0
  506. package/dist/src/entityTypes.js +94 -0
  507. package/dist/src/entityTypes.js.map +1 -0
  508. package/dist/src/exposure/index.d.ts +86 -0
  509. package/dist/src/exposure/index.d.ts.map +1 -0
  510. package/dist/src/exposure/index.js +134 -0
  511. package/dist/src/exposure/index.js.map +1 -0
  512. package/dist/src/fuse/calibrate.d.ts +95 -0
  513. package/dist/src/fuse/calibrate.d.ts.map +1 -0
  514. package/dist/src/fuse/calibrate.js +165 -0
  515. package/dist/src/fuse/calibrate.js.map +1 -0
  516. package/dist/src/fuse/defaultCalibration.d.ts +52 -0
  517. package/dist/src/fuse/defaultCalibration.d.ts.map +1 -0
  518. package/dist/src/fuse/defaultCalibration.js +41 -0
  519. package/dist/src/fuse/defaultCalibration.js.map +1 -0
  520. package/dist/src/fuse/explain.d.ts +55 -0
  521. package/dist/src/fuse/explain.d.ts.map +1 -0
  522. package/dist/src/fuse/explain.js +91 -0
  523. package/dist/src/fuse/explain.js.map +1 -0
  524. package/dist/src/fuse/profiles.d.ts +80 -0
  525. package/dist/src/fuse/profiles.d.ts.map +1 -0
  526. package/dist/src/fuse/profiles.js +126 -0
  527. package/dist/src/fuse/profiles.js.map +1 -0
  528. package/dist/src/fuse/resolve.d.ts +73 -0
  529. package/dist/src/fuse/resolve.d.ts.map +1 -0
  530. package/dist/src/fuse/resolve.js +206 -0
  531. package/dist/src/fuse/resolve.js.map +1 -0
  532. package/dist/src/gazetteer/index.d.ts +41 -0
  533. package/dist/src/gazetteer/index.d.ts.map +1 -0
  534. package/dist/src/gazetteer/index.js +117 -0
  535. package/dist/src/gazetteer/index.js.map +1 -0
  536. package/dist/src/generate/bankcodes.d.ts +20 -0
  537. package/dist/src/generate/bankcodes.d.ts.map +1 -0
  538. package/dist/src/generate/bankcodes.js +71 -0
  539. package/dist/src/generate/bankcodes.js.map +1 -0
  540. package/dist/src/generate/contact.d.ts +31 -0
  541. package/dist/src/generate/contact.d.ts.map +1 -0
  542. package/dist/src/generate/contact.js +139 -0
  543. package/dist/src/generate/contact.js.map +1 -0
  544. package/dist/src/generate/crypto.d.ts +27 -0
  545. package/dist/src/generate/crypto.d.ts.map +1 -0
  546. package/dist/src/generate/crypto.js +88 -0
  547. package/dist/src/generate/crypto.js.map +1 -0
  548. package/dist/src/generate/documents.d.ts +24 -0
  549. package/dist/src/generate/documents.d.ts.map +1 -0
  550. package/dist/src/generate/documents.js +124 -0
  551. package/dist/src/generate/documents.js.map +1 -0
  552. package/dist/src/generate/financial.d.ts +26 -0
  553. package/dist/src/generate/financial.d.ts.map +1 -0
  554. package/dist/src/generate/financial.js +136 -0
  555. package/dist/src/generate/financial.js.map +1 -0
  556. package/dist/src/generate/index.d.ts +23 -0
  557. package/dist/src/generate/index.d.ts.map +1 -0
  558. package/dist/src/generate/index.js +23 -0
  559. package/dist/src/generate/index.js.map +1 -0
  560. package/dist/src/generate/location.d.ts +12 -0
  561. package/dist/src/generate/location.d.ts.map +1 -0
  562. package/dist/src/generate/location.js +75 -0
  563. package/dist/src/generate/location.js.map +1 -0
  564. package/dist/src/generate/natidAmOc.d.ts +22 -0
  565. package/dist/src/generate/natidAmOc.d.ts.map +1 -0
  566. package/dist/src/generate/natidAmOc.js +181 -0
  567. package/dist/src/generate/natidAmOc.js.map +1 -0
  568. package/dist/src/generate/natidAsia.d.ts +20 -0
  569. package/dist/src/generate/natidAsia.d.ts.map +1 -0
  570. package/dist/src/generate/natidAsia.js +147 -0
  571. package/dist/src/generate/natidAsia.js.map +1 -0
  572. package/dist/src/generate/natidCee.d.ts +21 -0
  573. package/dist/src/generate/natidCee.d.ts.map +1 -0
  574. package/dist/src/generate/natidCee.js +181 -0
  575. package/dist/src/generate/natidCee.js.map +1 -0
  576. package/dist/src/generate/natidMeCis.d.ts +17 -0
  577. package/dist/src/generate/natidMeCis.d.ts.map +1 -0
  578. package/dist/src/generate/natidMeCis.js +121 -0
  579. package/dist/src/generate/natidMeCis.js.map +1 -0
  580. package/dist/src/generate/natidWest.d.ts +32 -0
  581. package/dist/src/generate/natidWest.d.ts.map +1 -0
  582. package/dist/src/generate/natidWest.js +187 -0
  583. package/dist/src/generate/natidWest.js.map +1 -0
  584. package/dist/src/generate/prng.d.ts +10 -0
  585. package/dist/src/generate/prng.d.ts.map +1 -0
  586. package/dist/src/generate/prng.js +18 -0
  587. package/dist/src/generate/prng.js.map +1 -0
  588. package/dist/src/generate/secrets.d.ts +23 -0
  589. package/dist/src/generate/secrets.d.ts.map +1 -0
  590. package/dist/src/generate/secrets.js +126 -0
  591. package/dist/src/generate/secrets.js.map +1 -0
  592. package/dist/src/generate/vat.d.ts +11 -0
  593. package/dist/src/generate/vat.d.ts.map +1 -0
  594. package/dist/src/generate/vat.js +233 -0
  595. package/dist/src/generate/vat.js.map +1 -0
  596. package/dist/src/index.d.ts +81 -0
  597. package/dist/src/index.d.ts.map +1 -0
  598. package/dist/src/index.js +76 -0
  599. package/dist/src/index.js.map +1 -0
  600. package/dist/src/mask/egressGuard.d.ts +54 -0
  601. package/dist/src/mask/egressGuard.d.ts.map +1 -0
  602. package/dist/src/mask/egressGuard.js +67 -0
  603. package/dist/src/mask/egressGuard.js.map +1 -0
  604. package/dist/src/mask/masker.d.ts +76 -0
  605. package/dist/src/mask/masker.d.ts.map +1 -0
  606. package/dist/src/mask/masker.js +201 -0
  607. package/dist/src/mask/masker.js.map +1 -0
  608. package/dist/src/mask/restorer.d.ts +96 -0
  609. package/dist/src/mask/restorer.d.ts.map +1 -0
  610. package/dist/src/mask/restorer.js +263 -0
  611. package/dist/src/mask/restorer.js.map +1 -0
  612. package/dist/src/mask/surrogatePools.d.ts +33 -0
  613. package/dist/src/mask/surrogatePools.d.ts.map +1 -0
  614. package/dist/src/mask/surrogatePools.js +81 -0
  615. package/dist/src/mask/surrogatePools.js.map +1 -0
  616. package/dist/src/mask/surrogates.d.ts +45 -0
  617. package/dist/src/mask/surrogates.d.ts.map +1 -0
  618. package/dist/src/mask/surrogates.js +241 -0
  619. package/dist/src/mask/surrogates.js.map +1 -0
  620. package/dist/src/mask/vault.d.ts +76 -0
  621. package/dist/src/mask/vault.d.ts.map +1 -0
  622. package/dist/src/mask/vault.js +141 -0
  623. package/dist/src/mask/vault.js.map +1 -0
  624. package/dist/src/ner/align.d.ts +36 -0
  625. package/dist/src/ner/align.d.ts.map +1 -0
  626. package/dist/src/ner/align.js +73 -0
  627. package/dist/src/ner/align.js.map +1 -0
  628. package/dist/src/ner/chunk.d.ts +27 -0
  629. package/dist/src/ner/chunk.d.ts.map +1 -0
  630. package/dist/src/ner/chunk.js +55 -0
  631. package/dist/src/ner/chunk.js.map +1 -0
  632. package/dist/src/ner/chunkCache.d.ts +63 -0
  633. package/dist/src/ner/chunkCache.d.ts.map +1 -0
  634. package/dist/src/ner/chunkCache.js +99 -0
  635. package/dist/src/ner/chunkCache.js.map +1 -0
  636. package/dist/src/ner/engine.d.ts +53 -0
  637. package/dist/src/ner/engine.d.ts.map +1 -0
  638. package/dist/src/ner/engine.js +113 -0
  639. package/dist/src/ner/engine.js.map +1 -0
  640. package/dist/src/ner/merge.d.ts +26 -0
  641. package/dist/src/ner/merge.d.ts.map +1 -0
  642. package/dist/src/ner/merge.js +108 -0
  643. package/dist/src/ner/merge.js.map +1 -0
  644. package/dist/src/ner/runStage2.d.ts +17 -0
  645. package/dist/src/ner/runStage2.d.ts.map +1 -0
  646. package/dist/src/ner/runStage2.js +43 -0
  647. package/dist/src/ner/runStage2.js.map +1 -0
  648. package/dist/src/ner/stage2b.d.ts +59 -0
  649. package/dist/src/ner/stage2b.d.ts.map +1 -0
  650. package/dist/src/ner/stage2b.js +51 -0
  651. package/dist/src/ner/stage2b.js.map +1 -0
  652. package/dist/src/ner/transformersClassifier.d.ts +45 -0
  653. package/dist/src/ner/transformersClassifier.d.ts.map +1 -0
  654. package/dist/src/ner/transformersClassifier.js +40 -0
  655. package/dist/src/ner/transformersClassifier.js.map +1 -0
  656. package/dist/src/ner/types.d.ts +93 -0
  657. package/dist/src/ner/types.d.ts.map +1 -0
  658. package/dist/src/ner/types.js +12 -0
  659. package/dist/src/ner/types.js.map +1 -0
  660. package/dist/src/normalization.d.ts +24 -0
  661. package/dist/src/normalization.d.ts.map +1 -0
  662. package/dist/src/normalization.js +92 -0
  663. package/dist/src/normalization.js.map +1 -0
  664. package/dist/src/offsetMap.d.ts +165 -0
  665. package/dist/src/offsetMap.d.ts.map +1 -0
  666. package/dist/src/offsetMap.js +225 -0
  667. package/dist/src/offsetMap.js.map +1 -0
  668. package/dist/src/pipeline.d.ts +58 -0
  669. package/dist/src/pipeline.d.ts.map +1 -0
  670. package/dist/src/pipeline.js +57 -0
  671. package/dist/src/pipeline.js.map +1 -0
  672. package/dist/src/protect.d.ts +146 -0
  673. package/dist/src/protect.d.ts.map +1 -0
  674. package/dist/src/protect.js +161 -0
  675. package/dist/src/protect.js.map +1 -0
  676. package/dist/src/scripts.d.ts +37 -0
  677. package/dist/src/scripts.d.ts.map +1 -0
  678. package/dist/src/scripts.js +145 -0
  679. package/dist/src/scripts.js.map +1 -0
  680. package/dist/src/transforms/foldDigits.d.ts +49 -0
  681. package/dist/src/transforms/foldDigits.d.ts.map +1 -0
  682. package/dist/src/transforms/foldDigits.js +135 -0
  683. package/dist/src/transforms/foldDigits.js.map +1 -0
  684. package/dist/src/transforms/graphemes.d.ts +6 -0
  685. package/dist/src/transforms/graphemes.d.ts.map +1 -0
  686. package/dist/src/transforms/graphemes.js +6 -0
  687. package/dist/src/transforms/graphemes.js.map +1 -0
  688. package/dist/src/transforms/homoglyphFold.d.ts +5 -0
  689. package/dist/src/transforms/homoglyphFold.d.ts.map +1 -0
  690. package/dist/src/transforms/homoglyphFold.js +214 -0
  691. package/dist/src/transforms/homoglyphFold.js.map +1 -0
  692. package/dist/src/transforms/nfkc.d.ts +20 -0
  693. package/dist/src/transforms/nfkc.d.ts.map +1 -0
  694. package/dist/src/transforms/nfkc.js +48 -0
  695. package/dist/src/transforms/nfkc.js.map +1 -0
  696. package/dist/src/transforms/stripInvisibles.d.ts +37 -0
  697. package/dist/src/transforms/stripInvisibles.d.ts.map +1 -0
  698. package/dist/src/transforms/stripInvisibles.js +151 -0
  699. package/dist/src/transforms/stripInvisibles.js.map +1 -0
  700. package/dist/src/transforms/whitespacePunct.d.ts +21 -0
  701. package/dist/src/transforms/whitespacePunct.d.ts.map +1 -0
  702. package/dist/src/transforms/whitespacePunct.js +100 -0
  703. package/dist/src/transforms/whitespacePunct.js.map +1 -0
  704. package/dist/src/types.d.ts +212 -0
  705. package/dist/src/types.d.ts.map +1 -0
  706. package/dist/src/types.js +14 -0
  707. package/dist/src/types.js.map +1 -0
  708. package/package.json +67 -0
  709. package/src/checksums/aba.ts +45 -0
  710. package/src/checksums/digits.ts +108 -0
  711. package/src/checksums/icao9303.ts +53 -0
  712. package/src/checksums/index.ts +36 -0
  713. package/src/checksums/iso7064.ts +168 -0
  714. package/src/checksums/luhn.ts +66 -0
  715. package/src/checksums/mod97.ts +91 -0
  716. package/src/checksums/verhoeff.ts +84 -0
  717. package/src/checksums/weighted.ts +108 -0
  718. package/src/context/documentProfile.ts +293 -0
  719. package/src/context/negativeRules.ts +765 -0
  720. package/src/context/score.ts +430 -0
  721. package/src/context/structure.ts +611 -0
  722. package/src/context/triggers.ts +266 -0
  723. package/src/context/types.ts +150 -0
  724. package/src/crypto/keccak256.ts +98 -0
  725. package/src/crypto/sha256.ts +76 -0
  726. package/src/detect/AUTHORING.md +50 -0
  727. package/src/detect/detectors/bankcodes/auBsb.ts +36 -0
  728. package/src/detect/detectors/bankcodes/brAgencia.ts +46 -0
  729. package/src/detect/detectors/bankcodes/caTransit.ts +89 -0
  730. package/src/detect/detectors/bankcodes/inIfsc.ts +40 -0
  731. package/src/detect/detectors/bankcodes/index.ts +9 -0
  732. package/src/detect/detectors/bankcodes/ukSortCode.ts +38 -0
  733. package/src/detect/detectors/bankcodes/usRouting.ts +47 -0
  734. package/src/detect/detectors/contact/email.ts +113 -0
  735. package/src/detect/detectors/contact/index.ts +10 -0
  736. package/src/detect/detectors/contact/ipv4.ts +112 -0
  737. package/src/detect/detectors/contact/ipv6.ts +188 -0
  738. package/src/detect/detectors/contact/mac.ts +68 -0
  739. package/src/detect/detectors/contact/phone.ts +81 -0
  740. package/src/detect/detectors/contact/urlCredentials.ts +124 -0
  741. package/src/detect/detectors/crypto/ada.ts +52 -0
  742. package/src/detect/detectors/crypto/btc.ts +77 -0
  743. package/src/detect/detectors/crypto/dot.ts +42 -0
  744. package/src/detect/detectors/crypto/eth.ts +70 -0
  745. package/src/detect/detectors/crypto/index.ts +11 -0
  746. package/src/detect/detectors/crypto/ltc.ts +69 -0
  747. package/src/detect/detectors/crypto/sol.ts +41 -0
  748. package/src/detect/detectors/crypto/trx.ts +35 -0
  749. package/src/detect/detectors/crypto/xmr.ts +54 -0
  750. package/src/detect/detectors/documents/driversLicense.ts +83 -0
  751. package/src/detect/detectors/documents/healthData.ts +88 -0
  752. package/src/detect/detectors/documents/index.ts +8 -0
  753. package/src/detect/detectors/documents/passportMrz.ts +203 -0
  754. package/src/detect/detectors/documents/usNpi.ts +50 -0
  755. package/src/detect/detectors/documents/vin.ts +67 -0
  756. package/src/detect/detectors/financial/creditCard.ts +167 -0
  757. package/src/detect/detectors/financial/iban.ts +82 -0
  758. package/src/detect/detectors/financial/ibanRegistry.ts +112 -0
  759. package/src/detect/detectors/financial/index.ts +6 -0
  760. package/src/detect/detectors/financial/swiftBic.ts +61 -0
  761. package/src/detect/detectors/index.ts +14 -0
  762. package/src/detect/detectors/location/coordinates.ts +84 -0
  763. package/src/detect/detectors/location/index.ts +6 -0
  764. package/src/detect/detectors/location/postalCode.ts +56 -0
  765. package/src/detect/detectors/location/postalRegistry.ts +74 -0
  766. package/src/detect/detectors/location/streetAddress.ts +84 -0
  767. package/src/detect/detectors/natid/africa.ts +108 -0
  768. package/src/detect/detectors/natid/ar.ts +62 -0
  769. package/src/detect/detectors/natid/au.ts +99 -0
  770. package/src/detect/detectors/natid/be.ts +45 -0
  771. package/src/detect/detectors/natid/bg.ts +44 -0
  772. package/src/detect/detectors/natid/br.ts +81 -0
  773. package/src/detect/detectors/natid/ca.ts +40 -0
  774. package/src/detect/detectors/natid/cl.ts +47 -0
  775. package/src/detect/detectors/natid/cn.ts +48 -0
  776. package/src/detect/detectors/natid/co.ts +46 -0
  777. package/src/detect/detectors/natid/cz.ts +44 -0
  778. package/src/detect/detectors/natid/de.ts +75 -0
  779. package/src/detect/detectors/natid/dk.ts +31 -0
  780. package/src/detect/detectors/natid/es.ts +95 -0
  781. package/src/detect/detectors/natid/fi.ts +41 -0
  782. package/src/detect/detectors/natid/fr.ts +63 -0
  783. package/src/detect/detectors/natid/gb.ts +70 -0
  784. package/src/detect/detectors/natid/gr.ts +35 -0
  785. package/src/detect/detectors/natid/gulf.ts +116 -0
  786. package/src/detect/detectors/natid/hk.ts +42 -0
  787. package/src/detect/detectors/natid/hr.ts +32 -0
  788. package/src/detect/detectors/natid/hu.ts +36 -0
  789. package/src/detect/detectors/natid/ie.ts +37 -0
  790. package/src/detect/detectors/natid/il.ts +37 -0
  791. package/src/detect/detectors/natid/in.ts +67 -0
  792. package/src/detect/detectors/natid/index.ts +54 -0
  793. package/src/detect/detectors/natid/is.ts +42 -0
  794. package/src/detect/detectors/natid/it.ts +65 -0
  795. package/src/detect/detectors/natid/jp.ts +48 -0
  796. package/src/detect/detectors/natid/kr.ts +41 -0
  797. package/src/detect/detectors/natid/kz.ts +44 -0
  798. package/src/detect/detectors/natid/mx.ts +83 -0
  799. package/src/detect/detectors/natid/nl.ts +38 -0
  800. package/src/detect/detectors/natid/no.ts +50 -0
  801. package/src/detect/detectors/natid/nz.ts +53 -0
  802. package/src/detect/detectors/natid/pe.ts +28 -0
  803. package/src/detect/detectors/natid/pl.ts +100 -0
  804. package/src/detect/detectors/natid/pt.ts +36 -0
  805. package/src/detect/detectors/natid/ro.ts +47 -0
  806. package/src/detect/detectors/natid/ru.ts +82 -0
  807. package/src/detect/detectors/natid/se.ts +42 -0
  808. package/src/detect/detectors/natid/seasia.ts +174 -0
  809. package/src/detect/detectors/natid/sg.ts +39 -0
  810. package/src/detect/detectors/natid/si.ts +42 -0
  811. package/src/detect/detectors/natid/tr.ts +76 -0
  812. package/src/detect/detectors/natid/tw.ts +41 -0
  813. package/src/detect/detectors/natid/ua.ts +38 -0
  814. package/src/detect/detectors/natid/us.ts +118 -0
  815. package/src/detect/detectors/natid/za.ts +42 -0
  816. package/src/detect/detectors/secrets/apiKey.ts +115 -0
  817. package/src/detect/detectors/secrets/connectionString.ts +71 -0
  818. package/src/detect/detectors/secrets/genericSecret.ts +81 -0
  819. package/src/detect/detectors/secrets/index.ts +8 -0
  820. package/src/detect/detectors/secrets/jwt.ts +101 -0
  821. package/src/detect/detectors/secrets/pemPrivateKey.ts +59 -0
  822. package/src/detect/detectors/vat/euVat.ts +280 -0
  823. package/src/detect/detectors/vat/index.ts +4 -0
  824. package/src/detect/entropy.ts +60 -0
  825. package/src/detect/isoCountries.ts +30 -0
  826. package/src/detect/registry.ts +134 -0
  827. package/src/detect/runner.ts +187 -0
  828. package/src/detect/types.ts +296 -0
  829. package/src/encoding/base58.ts +85 -0
  830. package/src/encoding/base58monero.ts +90 -0
  831. package/src/encoding/bech32.ts +125 -0
  832. package/src/encoding/bytes.ts +48 -0
  833. package/src/entityFamily.ts +70 -0
  834. package/src/entityLabel.ts +56 -0
  835. package/src/entityTypes.ts +107 -0
  836. package/src/exposure/index.ts +189 -0
  837. package/src/fuse/calibrate.ts +224 -0
  838. package/src/fuse/defaultCalibration.ts +71 -0
  839. package/src/fuse/explain.ts +114 -0
  840. package/src/fuse/profiles.ts +187 -0
  841. package/src/fuse/resolve.ts +237 -0
  842. package/src/gazetteer/index.ts +139 -0
  843. package/src/generate/bankcodes.ts +82 -0
  844. package/src/generate/contact.ts +147 -0
  845. package/src/generate/crypto.ts +91 -0
  846. package/src/generate/documents.ts +142 -0
  847. package/src/generate/financial.ts +149 -0
  848. package/src/generate/index.ts +22 -0
  849. package/src/generate/location.ts +80 -0
  850. package/src/generate/natidAmOc.ts +198 -0
  851. package/src/generate/natidAsia.ts +162 -0
  852. package/src/generate/natidCee.ts +196 -0
  853. package/src/generate/natidMeCis.ts +131 -0
  854. package/src/generate/natidWest.ts +208 -0
  855. package/src/generate/prng.ts +17 -0
  856. package/src/generate/secrets.ts +141 -0
  857. package/src/generate/vat.ts +239 -0
  858. package/src/index.ts +186 -0
  859. package/src/mask/egressGuard.ts +88 -0
  860. package/src/mask/masker.ts +276 -0
  861. package/src/mask/restorer.ts +284 -0
  862. package/src/mask/surrogatePools.ts +96 -0
  863. package/src/mask/surrogates.ts +248 -0
  864. package/src/mask/vault.ts +153 -0
  865. package/src/ner/align.ts +86 -0
  866. package/src/ner/chunk.ts +65 -0
  867. package/src/ner/chunkCache.ts +110 -0
  868. package/src/ner/engine.ts +141 -0
  869. package/src/ner/merge.ts +123 -0
  870. package/src/ner/runStage2.ts +51 -0
  871. package/src/ner/stage2b.ts +73 -0
  872. package/src/ner/transformersClassifier.ts +79 -0
  873. package/src/ner/types.ts +99 -0
  874. package/src/normalization.ts +119 -0
  875. package/src/offsetMap.ts +271 -0
  876. package/src/pipeline.ts +96 -0
  877. package/src/protect.ts +284 -0
  878. package/src/scripts.ts +164 -0
  879. package/src/transforms/foldDigits.ts +138 -0
  880. package/src/transforms/graphemes.ts +5 -0
  881. package/src/transforms/homoglyphFold.ts +221 -0
  882. package/src/transforms/nfkc.ts +48 -0
  883. package/src/transforms/stripInvisibles.ts +158 -0
  884. package/src/transforms/whitespacePunct.ts +100 -0
  885. package/src/types.ts +339 -0
@@ -0,0 +1,224 @@
1
+ /**
2
+ * Stage 4 — CALIBRATION.
3
+ *
4
+ * SPEC.md: "Combine scores from all stages into a single calibrated confidence
5
+ * per candidate. Calibrate against the eval corpus so that a confidence of 0.8
6
+ * empirically means roughly 80% precision. Document the calibration method and
7
+ * the resulting reliability curve."
8
+ *
9
+ * THE METHOD: ISOTONIC REGRESSION, fitted per entity type.
10
+ *
11
+ * Isotonic rather than Platt scaling (a fitted logistic) for two reasons that
12
+ * matter here. First, the raw scores are not a logistic function of the truth
13
+ * and there is no reason to expect them to be: they are a base confidence plus
14
+ * a handful of additive Stage 3 contributions, so the shape of the mapping is
15
+ * unknown and a two-parameter family would impose one. Second, isotonic
16
+ * regression is EXPLAINABLE — the fitted model is a step function over score
17
+ * bins whose steps are empirical precisions, so "0.8 means 80%" can be read
18
+ * directly off the table rather than inferred from coefficients.
19
+ *
20
+ * What isotonic buys over raw binned precision is MONOTONICITY. A bin with few
21
+ * samples can easily show lower precision than the bin below it, which would
22
+ * make calibrated confidence non-monotonic in the evidence and produce the
23
+ * absurd result that adding evidence lowers confidence. Pool-adjacent-
24
+ * violators merges such bins, so the mapping never decreases.
25
+ *
26
+ * PER TYPE, because the types are not comparable. A validated IBAN and a
27
+ * shape-only postal code can carry the same raw score and mean entirely
28
+ * different things — that non-comparability is stated in the eval's own
29
+ * header and is exactly what calibration exists to remove. Types with too few
30
+ * samples to fit fall back to a pooled curve rather than to an overfitted one.
31
+ *
32
+ * FITTED AND EVALUATED ON DISJOINT DOCUMENTS. A curve fitted and scored on the
33
+ * same corpus measures nothing; the split is stated in BENCHMARKS.md.
34
+ */
35
+
36
+ import type { EntityType } from '../types.js';
37
+
38
+ /** One step of a fitted curve: scores in [from, to) map to `precision`. */
39
+ export interface CalibrationBin {
40
+ readonly from: number;
41
+ readonly to: number;
42
+ /** Empirical precision of candidates whose raw score fell in this bin. */
43
+ readonly precision: number;
44
+ /** How many candidates the step was fitted on, for reporting weight. */
45
+ readonly samples: number;
46
+ }
47
+
48
+ export interface CalibrationCurve {
49
+ readonly bins: readonly CalibrationBin[];
50
+ readonly samples: number;
51
+ }
52
+
53
+ export interface CalibrationModel {
54
+ /** Per-type curves. Types absent here use `pooled`. */
55
+ readonly perType: Readonly<Partial<Record<EntityType, CalibrationCurve>>>;
56
+ /** Fallback for types with too little data to fit their own curve. */
57
+ readonly pooled: CalibrationCurve;
58
+ /** Documents the model was fitted on, for the split statement. */
59
+ readonly fittedOn: string;
60
+ }
61
+
62
+ /** One observation: a candidate's raw score and whether it was correct. */
63
+ export interface CalibrationSample {
64
+ readonly type: EntityType;
65
+ readonly score: number;
66
+ readonly correct: boolean;
67
+ }
68
+
69
+ /** Bins per curve. Ten keeps each step readable and populated. */
70
+ const BIN_COUNT = 10;
71
+
72
+ /**
73
+ * Minimum samples before a type gets its own curve.
74
+ *
75
+ * Below this the per-type curve would be fitted on noise, and a confidently
76
+ * wrong calibration is worse than an honest pooled one.
77
+ */
78
+ const MIN_SAMPLES_PER_TYPE = 200;
79
+
80
+ /**
81
+ * Pool adjacent violators: the isotonic regression fit.
82
+ *
83
+ * Walks left to right merging any bin whose precision is below its left
84
+ * neighbour, which yields the closest non-decreasing sequence in least
85
+ * squares. The merge is sample-weighted, so a large well-measured bin is not
86
+ * dragged by a tiny noisy one.
87
+ */
88
+ function poolAdjacentViolators(
89
+ raw: readonly { from: number; to: number; correct: number; total: number }[],
90
+ ): CalibrationBin[] {
91
+ const stack: { from: number; to: number; correct: number; total: number }[] = [];
92
+
93
+ for (const bin of raw) {
94
+ if (bin.total === 0) continue;
95
+ stack.push({ ...bin });
96
+ // Merge backwards while the sequence decreases.
97
+ while (stack.length > 1) {
98
+ const right = stack[stack.length - 1]!;
99
+ const left = stack[stack.length - 2]!;
100
+ if (left.correct / left.total <= right.correct / right.total) break;
101
+ stack.splice(stack.length - 2, 2, {
102
+ from: left.from,
103
+ to: right.to,
104
+ correct: left.correct + right.correct,
105
+ total: left.total + right.total,
106
+ });
107
+ }
108
+ }
109
+
110
+ return stack.map((b) => ({
111
+ from: b.from,
112
+ to: b.to,
113
+ precision: b.correct / b.total,
114
+ samples: b.total,
115
+ }));
116
+ }
117
+
118
+ function fitCurve(samples: readonly CalibrationSample[]): CalibrationCurve {
119
+ const raw = Array.from({ length: BIN_COUNT }, (_, i) => ({
120
+ from: i / BIN_COUNT,
121
+ to: (i + 1) / BIN_COUNT,
122
+ correct: 0,
123
+ total: 0,
124
+ }));
125
+
126
+ for (const s of samples) {
127
+ const index = Math.min(BIN_COUNT - 1, Math.max(0, Math.floor(s.score * BIN_COUNT)));
128
+ const bin = raw[index]!;
129
+ bin.total += 1;
130
+ if (s.correct) bin.correct += 1;
131
+ }
132
+
133
+ return { bins: poolAdjacentViolators(raw), samples: samples.length };
134
+ }
135
+
136
+ /** Fit a calibration model from labelled observations. */
137
+ export function fitCalibration(
138
+ samples: readonly CalibrationSample[],
139
+ fittedOn: string,
140
+ ): CalibrationModel {
141
+ const byType = new Map<EntityType, CalibrationSample[]>();
142
+ for (const s of samples) {
143
+ const list = byType.get(s.type) ?? [];
144
+ list.push(s);
145
+ byType.set(s.type, list);
146
+ }
147
+
148
+ const perType: Partial<Record<EntityType, CalibrationCurve>> = {};
149
+ for (const [type, list] of byType) {
150
+ if (list.length >= MIN_SAMPLES_PER_TYPE) perType[type] = fitCurve(list);
151
+ }
152
+
153
+ return { perType, pooled: fitCurve(samples), fittedOn };
154
+ }
155
+
156
+ /**
157
+ * Map a raw score to a calibrated probability.
158
+ *
159
+ * PIECEWISE CONSTANT — the containing step's empirical precision, which is the
160
+ * standard prediction for an isotonic fit. An earlier revision interpolated
161
+ * between step midpoints to smooth the output, and that was an embellishment
162
+ * with no justification behind it: because the step function is coarse where
163
+ * data is sparse, interpolating systematically pulled predictions toward the
164
+ * step below and left the model under-confident through 0.7-0.8. Returning the
165
+ * step's own measured precision is both the standard method and the one whose
166
+ * meaning is readable — "candidates in this band were right this often".
167
+ */
168
+ export function calibrate(model: CalibrationModel, type: EntityType, score: number): number {
169
+ const curve = model.perType[type] ?? model.pooled;
170
+ if (curve.bins.length === 0) return score;
171
+
172
+ const clamped = Math.min(1, Math.max(0, score));
173
+ const index = curve.bins.findIndex((b) => clamped < b.to);
174
+ const bin = curve.bins[index === -1 ? curve.bins.length - 1 : index]!;
175
+ return bin.precision;
176
+ }
177
+
178
+ /** A reliability-curve row: what the model promised versus what happened. */
179
+ export interface ReliabilityPoint {
180
+ readonly bucket: string;
181
+ readonly predicted: number;
182
+ readonly observed: number;
183
+ readonly samples: number;
184
+ }
185
+
186
+ /**
187
+ * Measure a fitted model against HELD-OUT observations.
188
+ *
189
+ * This is the number that means something: a curve scored on the documents it
190
+ * was fitted on measures memorisation, not calibration.
191
+ */
192
+ export function reliability(
193
+ model: CalibrationModel,
194
+ heldOut: readonly CalibrationSample[],
195
+ buckets = 10,
196
+ ): { readonly points: readonly ReliabilityPoint[]; readonly expectedCalibrationError: number } {
197
+ const acc = Array.from({ length: buckets }, () => ({ predicted: 0, correct: 0, total: 0 }));
198
+
199
+ for (const s of heldOut) {
200
+ const p = calibrate(model, s.type, s.score);
201
+ const index = Math.min(buckets - 1, Math.max(0, Math.floor(p * buckets)));
202
+ const bucket = acc[index]!;
203
+ bucket.predicted += p;
204
+ bucket.total += 1;
205
+ if (s.correct) bucket.correct += 1;
206
+ }
207
+
208
+ const points: ReliabilityPoint[] = [];
209
+ let error = 0;
210
+ for (const [i, b] of acc.entries()) {
211
+ if (b.total === 0) continue;
212
+ const predicted = b.predicted / b.total;
213
+ const observed = b.correct / b.total;
214
+ points.push({
215
+ bucket: `${(i / buckets).toFixed(1)}–${((i + 1) / buckets).toFixed(1)}`,
216
+ predicted,
217
+ observed,
218
+ samples: b.total,
219
+ });
220
+ error += (b.total / heldOut.length) * Math.abs(predicted - observed);
221
+ }
222
+
223
+ return { points, expectedCalibrationError: error };
224
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * defaultCalibration.ts — the shipped calibration model, checked rather than cast.
3
+ *
4
+ * ─────────────────────────────────────────────────────────────────────────
5
+ * THE CAST THIS REPLACES
6
+ *
7
+ * `@discretion/data` types the fitted model's `perType` as
8
+ * `Record<string, CalibrationCurveData>`, because it is generated from an eval
9
+ * run and the generator has no access to the `EntityType` union. Core's
10
+ * `CalibrationModel` wants `Partial<Record<EntityType, CalibrationCurve>>`.
11
+ *
12
+ * Every consumer so far bridged that with `as unknown as CalibrationModel`.
13
+ * The cast is not merely ugly: it asserts the keys are valid `EntityType`
14
+ * members without checking, so a model fitted before a type was renamed would
15
+ * carry a key that matches nothing. `calibrate()` would then fall through to
16
+ * the pooled curve for that type, forever, with no error and no warning — the
17
+ * numbers would just be quietly worse than the published ones.
18
+ *
19
+ * Converting with a check turns that into something observable.
20
+ */
21
+
22
+ import { ALL_ENTITY_TYPES } from '../entityTypes.js';
23
+ import type { EntityType } from '../types.js';
24
+ import type { CalibrationCurve, CalibrationModel } from './calibrate.js';
25
+
26
+ /**
27
+ * The generated shape, restated so this module does not depend on data's types.
28
+ *
29
+ * Exported because it is `toCalibrationModel`'s parameter type: a consumer who
30
+ * fits their own model needs to name what the function accepts. It was local
31
+ * when this file was written, and `public-api.test.ts` caught it on its first
32
+ * run - which is the whole reason that test exists.
33
+ */
34
+ export interface GeneratedCalibrationModel {
35
+ readonly perType: Readonly<Record<string, CalibrationCurve>>;
36
+ readonly pooled: CalibrationCurve;
37
+ readonly fittedOn: string;
38
+ }
39
+
40
+ export interface CalibrationConversion {
41
+ readonly model: CalibrationModel;
42
+ /**
43
+ * Keys in the generated model that are not `EntityType` members.
44
+ *
45
+ * Non-empty means the committed model and the union have drifted apart. The
46
+ * conversion still succeeds — dropping an unusable curve is better than
47
+ * refusing to calibrate anything — but the caller can now see it, and
48
+ * `calibration-model.test.ts` asserts it is empty.
49
+ */
50
+ readonly unknownTypes: readonly string[];
51
+ }
52
+
53
+ /**
54
+ * Convert a generated calibration model to core's typed one, reporting any key
55
+ * that is not a known entity type instead of assuming there are none.
56
+ */
57
+ export function toCalibrationModel(generated: GeneratedCalibrationModel): CalibrationConversion {
58
+ const known = new Set<string>(ALL_ENTITY_TYPES);
59
+ const perType: Partial<Record<EntityType, CalibrationCurve>> = {};
60
+ const unknownTypes: string[] = [];
61
+
62
+ for (const [key, curve] of Object.entries(generated.perType)) {
63
+ if (known.has(key)) perType[key as EntityType] = curve;
64
+ else unknownTypes.push(key);
65
+ }
66
+
67
+ return {
68
+ model: { perType, pooled: generated.pooled, fittedOn: generated.fittedOn },
69
+ unknownTypes,
70
+ };
71
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Stage 4 — EXPLANATIONS.
3
+ *
4
+ * SPEC.md: "Every emitted entity carries an EXPLANATION: which stages fired,
5
+ * which triggers were found, which validator passed. This drives the review UI
6
+ * and makes failures diagnosable."
7
+ *
8
+ * The last clause is the one that shapes this module. An explanation is not
9
+ * decoration for the UI — it is how a wrong detection gets diagnosed without
10
+ * re-running the pipeline under a debugger. So it records what actually
11
+ * happened rather than a summary of it: which stages contributed, which named
12
+ * Stage 3 signals fired and with what sign, and what the profile decided.
13
+ *
14
+ * NO PLAINTEXT IN EXPLANATIONS, which is why triggers are lexicon terms and
15
+ * signal names rather than document text. Explanations flow into eval reports,
16
+ * the review panel, and the popup; a value that reached any of those would
17
+ * breach SPEC's third non-negotiable. The one exception is the entity's own
18
+ * text, which the caller already holds and which `DetectedEntity` carries in
19
+ * its own field.
20
+ */
21
+
22
+ import type { DetectedEntity, DetectionStage, EntityExplanation, EntityType } from '../types.js';
23
+ import type { ContextScoredCandidate } from '../context/types.js';
24
+ import type { ProfileDecision } from './profiles.js';
25
+
26
+ /** What Stage 4 knows about one candidate as it becomes an entity. */
27
+ export interface FusionInput {
28
+ readonly scored: ContextScoredCandidate;
29
+ /** Confidence after calibration; comparable across types. */
30
+ readonly calibratedConfidence: number;
31
+ /** Whether the entity's span was widened by overlap resolution. */
32
+ readonly absorbedOverlap?: boolean;
33
+ /** Types this candidate won an overlap against. */
34
+ readonly wonAgainst?: readonly EntityType[];
35
+ }
36
+
37
+ /**
38
+ * Build the explanation for one entity.
39
+ *
40
+ * `triggers` carries the Stage 3 signal names rather than only lexicon
41
+ * matches, because "why was this reported" is answered as much by
42
+ * `structure:key-names-API_KEY` as by a trigger word — and a reviewer chasing
43
+ * a false positive needs the negative signals too, which is why suppression
44
+ * and penalty signals appear with their sign rather than being filtered out.
45
+ */
46
+ export function explain(input: FusionInput): EntityExplanation {
47
+ const { scored } = input;
48
+ const stages: DetectionStage[] = [scored.candidate.stage];
49
+
50
+ // Stage 3 fired if it contributed anything at all.
51
+ if (scored.contributions.length > 0) stages.push('stage3-context');
52
+ stages.push('stage4-fusion');
53
+
54
+ const triggers = scored.contributions.map((c) => {
55
+ const sign = c.delta >= 0 ? '+' : '';
56
+ const detail = c.detail === undefined ? '' : ` (${c.detail})`;
57
+ return `${c.signal}${detail} ${sign}${c.delta.toFixed(2)}`;
58
+ });
59
+
60
+ if (input.absorbedOverlap === true) {
61
+ triggers.push('stage4:absorbed-overlapping-span +0.00');
62
+ }
63
+ for (const type of input.wonAgainst ?? []) {
64
+ triggers.push(`stage4:more-specific-than-${type} +0.00`);
65
+ }
66
+
67
+ return {
68
+ stages,
69
+ triggers,
70
+ ...(scored.candidate.validatorPassed !== undefined
71
+ ? { validatorPassed: scored.candidate.validatorPassed }
72
+ : {}),
73
+ };
74
+ }
75
+
76
+ /** Assemble the entity a consumer actually receives. */
77
+ export function toDetectedEntity(input: FusionInput): DetectedEntity {
78
+ const { candidate } = input.scored;
79
+ return {
80
+ text: candidate.text,
81
+ type: candidate.type,
82
+ start: candidate.start,
83
+ end: candidate.end,
84
+ calibratedConfidence: input.calibratedConfidence,
85
+ explanation: explain(input),
86
+ };
87
+ }
88
+
89
+ /**
90
+ * A one-line reason a candidate was NOT reported.
91
+ *
92
+ * SPEC's explanation requirement covers emitted entities, but the review UI
93
+ * has to answer "why did you miss this?" too, and a suppression with no
94
+ * recorded reason is exactly the failure D18 was written about. Kept in the
95
+ * same module so the two stay consistent.
96
+ */
97
+ export function explainOmission(
98
+ scored: ContextScoredCandidate,
99
+ decision?: ProfileDecision,
100
+ ): string {
101
+ if (scored.suppressed) {
102
+ return `suppressed by ${scored.suppressionReason ?? 'an unnamed rule'}`;
103
+ }
104
+ switch (decision?.reason) {
105
+ case 'allowlist':
106
+ return 'on the user allowlist';
107
+ case 'type-out-of-profile':
108
+ return 'entity type is outside the active sensitivity profile';
109
+ case 'below-threshold':
110
+ return 'calibrated confidence below the profile threshold';
111
+ default:
112
+ return 'not reported';
113
+ }
114
+ }
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Stage 4 — SENSITIVITY PROFILES, allowlist and denylist.
3
+ *
4
+ * SPEC.md:
5
+ * "Apply the active SENSITIVITY PROFILE, which sets thresholds:
6
+ * Minimal — secrets and financial identifiers only.
7
+ * Balanced — default. Secrets, financial, national IDs, contact details,
8
+ * person names.
9
+ * Strict — adds health data, addresses, dates of birth, organizations,
10
+ * low-confidence candidates.
11
+ * Custom — per-entity-type threshold control."
12
+ * "Apply user allowlist (never mask …) and denylist (always mask …).
13
+ * Denylist beats everything."
14
+ *
15
+ * A profile does two things at once and it is worth separating them: it says
16
+ * WHICH TYPES are in scope, and it says HOW SURE the pipeline must be before
17
+ * reporting one. The second only became meaningful with calibration — before
18
+ * a confidence meant something comparable across types, a threshold was an
19
+ * arbitrary cut. That is why profiles land in the same milestone as the
20
+ * calibration curve rather than earlier.
21
+ *
22
+ * Thresholds are stated as CALIBRATED probabilities, so "0.5" reads as "report
23
+ * this when it is more likely right than wrong" rather than as a detector-local
24
+ * number whose meaning varies by type.
25
+ */
26
+
27
+ import type { EntityType } from '../types.js';
28
+
29
+ export type ProfileName = 'minimal' | 'balanced' | 'strict' | 'custom';
30
+
31
+ /** Broad families, used to state the profiles in SPEC's own vocabulary. */
32
+ const SECRETS: readonly EntityType[] = [
33
+ 'API_KEY',
34
+ 'PRIVATE_KEY',
35
+ 'JWT',
36
+ 'GENERIC_SECRET',
37
+ 'CONNECTION_STRING',
38
+ 'URL_WITH_CREDENTIALS',
39
+ ];
40
+
41
+ const FINANCIAL: readonly EntityType[] = [
42
+ 'CREDIT_CARD',
43
+ 'IBAN',
44
+ 'SWIFT_BIC',
45
+ 'US_ROUTING_NUMBER',
46
+ 'UK_SORT_CODE',
47
+ 'CA_TRANSIT_NUMBER',
48
+ 'AU_BSB',
49
+ 'IN_IFSC',
50
+ 'BR_AGENCIA',
51
+ 'CRYPTO_WALLET',
52
+ 'VAT_NUMBER',
53
+ ];
54
+
55
+ const GOVERNMENT_ID: readonly EntityType[] = [
56
+ 'NATIONAL_ID',
57
+ 'TAX_ID',
58
+ 'PASSPORT_MRZ',
59
+ 'DRIVERS_LICENSE',
60
+ 'VIN',
61
+ 'US_NPI',
62
+ ];
63
+
64
+ const CONTACT: readonly EntityType[] = ['EMAIL', 'PHONE', 'IP_ADDRESS', 'MAC_ADDRESS'];
65
+
66
+ const LOCATION_TYPES: readonly EntityType[] = ['STREET_ADDRESS', 'POSTAL_CODE', 'COORDINATES', 'LOCATION'];
67
+
68
+ const HEALTH: readonly EntityType[] = ['HEALTH_DATA'];
69
+
70
+ const PEOPLE: readonly EntityType[] = ['PERSON'];
71
+ const ORGS: readonly EntityType[] = ['ORG'];
72
+ const DATES: readonly EntityType[] = ['DATE_OF_BIRTH'];
73
+
74
+ export interface SensitivityProfile {
75
+ readonly name: ProfileName;
76
+ /** Types the profile reports at all. */
77
+ readonly types: ReadonlySet<EntityType>;
78
+ /**
79
+ * Minimum CALIBRATED confidence to report, per type, with a default.
80
+ * Meaningful only because Stage 4 calibrated the scale (D23).
81
+ */
82
+ readonly threshold: (type: EntityType) => number;
83
+ }
84
+
85
+ function profile(
86
+ name: ProfileName,
87
+ types: readonly (readonly EntityType[])[],
88
+ defaultThreshold: number,
89
+ overrides: Partial<Record<EntityType, number>> = {},
90
+ ): SensitivityProfile {
91
+ return {
92
+ name,
93
+ types: new Set(types.flat()),
94
+ threshold: (type) => overrides[type] ?? defaultThreshold,
95
+ };
96
+ }
97
+
98
+ /**
99
+ * The three named profiles.
100
+ *
101
+ * Thresholds differ by INTENT, not by tuning. Minimal exists for a developer
102
+ * who wants surgical protection and would rather miss a weak signal than see
103
+ * a spurious one, so it demands high confidence. Strict exists for someone who
104
+ * would rather over-mask, so it deliberately admits low-confidence candidates
105
+ * — SPEC names "low-confidence candidates" as part of what Strict adds.
106
+ */
107
+ export const PROFILES: Readonly<Record<Exclude<ProfileName, 'custom'>, SensitivityProfile>> = {
108
+ minimal: profile('minimal', [SECRETS, FINANCIAL], 0.7),
109
+ balanced: profile('balanced', [SECRETS, FINANCIAL, GOVERNMENT_ID, CONTACT, PEOPLE], 0.5, {
110
+ // A leaked credential is unrecoverable, so it is reported on weaker
111
+ // evidence than a name, which the user can dismiss at no cost.
112
+ API_KEY: 0.35,
113
+ PRIVATE_KEY: 0.35,
114
+ CONNECTION_STRING: 0.35,
115
+ }),
116
+ strict: profile(
117
+ 'strict',
118
+ [SECRETS, FINANCIAL, GOVERNMENT_ID, CONTACT, PEOPLE, HEALTH, LOCATION_TYPES, ORGS, DATES],
119
+ 0.25,
120
+ { API_KEY: 0.2, PRIVATE_KEY: 0.2, CONNECTION_STRING: 0.2 },
121
+ ),
122
+ };
123
+
124
+ /** A user's own additions to whatever profile is active. */
125
+ export interface UserLists {
126
+ /**
127
+ * Never mask these. Matched case- and whitespace-insensitively on the
128
+ * entity's text — a user's own employer name, say.
129
+ */
130
+ readonly allow?: readonly string[];
131
+ /** Always mask these, whatever the profile or confidence says. */
132
+ readonly deny?: readonly string[];
133
+ }
134
+
135
+ function fold(value: string): string {
136
+ return value.trim().toLowerCase().replace(/\s+/g, ' ');
137
+ }
138
+
139
+ export interface ProfileDecision {
140
+ readonly report: boolean;
141
+ /** Why, in one stable token, for the explanation and for tests. */
142
+ readonly reason: 'denylist' | 'allowlist' | 'type-out-of-profile' | 'below-threshold' | 'in-profile';
143
+ }
144
+
145
+ /**
146
+ * Decide whether one entity is reported under a profile.
147
+ *
148
+ * ORDER IS THE WHOLE CONTRACT, and it follows SPEC exactly: "Denylist beats
149
+ * everything." A denylisted value is reported even when its type is out of
150
+ * profile and even when confidence is far below threshold — it is the one
151
+ * override a user can state absolutely. The allowlist is checked next, before
152
+ * type and threshold, so that suppressing a value the user has vouched for
153
+ * does not depend on which profile happens to be active.
154
+ */
155
+ export function decide(
156
+ entity: { readonly type: EntityType; readonly text: string; readonly calibratedConfidence: number },
157
+ profileIn: SensitivityProfile,
158
+ lists: UserLists = {},
159
+ ): ProfileDecision {
160
+ const text = fold(entity.text);
161
+
162
+ if ((lists.deny ?? []).some((d) => fold(d) === text)) {
163
+ return { report: true, reason: 'denylist' };
164
+ }
165
+ if ((lists.allow ?? []).some((a) => fold(a) === text)) {
166
+ return { report: false, reason: 'allowlist' };
167
+ }
168
+ if (!profileIn.types.has(entity.type)) {
169
+ return { report: false, reason: 'type-out-of-profile' };
170
+ }
171
+ if (entity.calibratedConfidence < profileIn.threshold(entity.type)) {
172
+ return { report: false, reason: 'below-threshold' };
173
+ }
174
+ return { report: true, reason: 'in-profile' };
175
+ }
176
+
177
+ /** Build a custom profile from explicit per-type thresholds. */
178
+ export function customProfile(
179
+ thresholds: Partial<Record<EntityType, number>>,
180
+ defaultThreshold = 0.5,
181
+ ): SensitivityProfile {
182
+ return {
183
+ name: 'custom',
184
+ types: new Set(Object.keys(thresholds) as EntityType[]),
185
+ threshold: (type) => thresholds[type] ?? defaultThreshold,
186
+ };
187
+ }