@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,271 @@
1
+ /**
2
+ * Offset-map machinery for Stage 0 normalization.
3
+ *
4
+ * WHY THIS EXISTS
5
+ * ───────────────
6
+ * Detection runs on normalized text; substitution edits the ORIGINAL text.
7
+ * Every transform therefore produces, alongside its output text, an exact map
8
+ * back to its input. The final map for a whole pipeline is the composition of
9
+ * each stage's map — composing small verified maps is far easier to get right
10
+ * than building one map through four simultaneous transforms.
11
+ *
12
+ * MAP REPRESENTATION
13
+ * ──────────────────
14
+ * A map for a transform `input → output` is an Int32Array of length
15
+ * output.length + 1 (all indices are UTF-16 code units):
16
+ *
17
+ * map[i] = input index where the cluster that produced output
18
+ * index i begins
19
+ * map[output.length] = input.length (sentinel)
20
+ *
21
+ * The sentinel entry is the classic off-by-one: without it, the end of a span
22
+ * covering the last character could not be mapped. With it, an output span
23
+ * [s, e) maps to the input span [map[s], map[e]).
24
+ *
25
+ * DELETION ATTRIBUTION (a deliberate choice — read before editing)
26
+ * ───────────────────────────────────────────────────────────────
27
+ * Deleted input (stripped invisibles) produces no output index, so it cannot
28
+ * appear in the map directly. Each deleted run is attributed to the cluster
29
+ * that FOLLOWS it; a deleted run at the very end of the input falls under the
30
+ * sentinel. Consequences:
31
+ * • map[0] === 0 always holds when the output is non-empty, even if the
32
+ * input began with deleted characters — a stated invariant of the format.
33
+ * • A mapped span silently includes any deleted (invisible) characters
34
+ * immediately before the characters it covers, and — via the sentinel —
35
+ * any deleted characters at the end of the input. Substituting such a
36
+ * span removes those invisibles along with it, which is exactly what a
37
+ * masking pipeline wants: they are noise we would strip anyway.
38
+ * • Values are STRICTLY increasing across real cluster boundaries; equal
39
+ * adjacent values occur only inside a single cluster's multi-unit output
40
+ * (an expansion). mapNormalizedSpan() relies on this.
41
+ *
42
+ * EDGE CASE — everything deleted: when the output is empty the map is the
43
+ * single sentinel entry [inputLength], so map[0] === inputLength, not 0.
44
+ * That is the one place the "map[0] === 0" invariant cannot hold; every
45
+ * consumer and test conditions that invariant on a non-empty output.
46
+ */
47
+
48
+ import type { TransformKind } from './types.js';
49
+
50
+ /** The identity map for a text of the given length: [0, 1, …, length]. */
51
+ export function identityMap(length: number): Int32Array {
52
+ const map = new Int32Array(length + 1);
53
+ for (let i = 0; i <= length; i++) map[i] = i;
54
+ return map;
55
+ }
56
+
57
+ /**
58
+ * Compose two offset maps.
59
+ *
60
+ * outer: maps indices of text B to indices of text A (length |B| + 1)
61
+ * inner: maps indices of text C to indices of text B (length |C| + 1)
62
+ * result: maps indices of text C to indices of text A (length |C| + 1)
63
+ *
64
+ * Because inner[|C|] = |B| and outer[|B|] = |A|, the sentinel composes for
65
+ * free, and the composition of monotone maps is monotone — both facts are
66
+ * covered by tests.
67
+ */
68
+ export function composeMaps(outer: Int32Array, inner: Int32Array): Int32Array {
69
+ const result = new Int32Array(inner.length);
70
+ const outerMax = outer.length - 1;
71
+ for (let i = 0; i < inner.length; i++) {
72
+ const via = inner[i]!;
73
+ if (via < 0 || via > outerMax) {
74
+ throw new Error(
75
+ `composeMaps: inner map value ${via} at index ${i} is outside the outer map's domain [0, ${outerMax}]`,
76
+ );
77
+ }
78
+ result[i] = outer[via]!;
79
+ }
80
+ return result;
81
+ }
82
+
83
+ /**
84
+ * Build the reverse map (original index → normalized index) from a forward
85
+ * map.
86
+ *
87
+ * reverseMap[j] = normalized index of the start of the cluster
88
+ * whose original extent contains j; for a
89
+ * deleted character this is the normalized
90
+ * position where it was removed
91
+ * reverseMap[originalLength] = normalizedLength (sentinel)
92
+ *
93
+ * "Extent" is the half-open range [offsetMap[i], nextDistinctValue), i.e. it
94
+ * includes any deleted characters attributed to the cluster. The walk below
95
+ * precomputes each cluster's extent end (`ends`), then assigns every original
96
+ * index the FIRST normalized index whose extent reaches past it — which lands
97
+ * on the first unit of the covering cluster, also for expansions where several
98
+ * normalized units share one original cluster.
99
+ */
100
+ export function buildReverseMap(offsetMap: Int32Array, originalLength: number): Int32Array {
101
+ const normalizedLength = offsetMap.length - 1;
102
+ const reverse = new Int32Array(originalLength + 1);
103
+
104
+ // ends[i] = original index one past the extent of the cluster covering
105
+ // normalized index i (= the next distinct map value, or originalLength).
106
+ const ends = new Int32Array(normalizedLength);
107
+ let nextDistinct = originalLength;
108
+ for (let i = normalizedLength - 1; i >= 0; i--) {
109
+ ends[i] = nextDistinct;
110
+ if (i === 0 || offsetMap[i - 1]! !== offsetMap[i]!) {
111
+ nextDistinct = offsetMap[i]!;
112
+ }
113
+ }
114
+
115
+ let i = 0;
116
+ for (let j = 0; j < originalLength; j++) {
117
+ while (i < normalizedLength && ends[i]! <= j) i++;
118
+ // If every cluster ends at or before j (possible only when the trailing
119
+ // input was deleted and absorbed by the sentinel), i === normalizedLength,
120
+ // which is exactly "the position where it was removed".
121
+ reverse[j] = i;
122
+ }
123
+ reverse[originalLength] = normalizedLength;
124
+ return reverse;
125
+ }
126
+
127
+ /**
128
+ * Map a normalized span [start, end) to the original span it covers.
129
+ *
130
+ * For spans whose endpooints sit on cluster boundaries this is exactly
131
+ * [offsetMap[start], offsetMap[end]). When an endpoint lands INSIDE an
132
+ * expansion (one original cluster → several normalized units — e.g. matching
133
+ * only the "f" of the "fi" produced by the ligature U+FB01), the span is
134
+ * widened to cover the WHOLE original cluster: you cannot substitute half a
135
+ * ligature. Widening is the only sound choice for masking — the alternative,
136
+ * an empty or truncated original span, would silently leave sensitive
137
+ * characters behind.
138
+ *
139
+ * NOTE: two non-overlapping normalized spans that split the same expansion
140
+ * both widen to the same original cluster, so mapped spans can overlap in
141
+ * that one case. Substitution must merge overlapping original spans before
142
+ * splicing (covered by the substitution-safety property test).
143
+ */
144
+ export function mapNormalizedSpan(
145
+ offsetMap: Int32Array,
146
+ start: number,
147
+ end: number,
148
+ ): { start: number; end: number } {
149
+ const normalizedLength = offsetMap.length - 1;
150
+ if (!(start >= 0 && start <= end && end <= normalizedLength)) {
151
+ throw new Error(
152
+ `mapNormalizedSpan: invalid span [${start}, ${end}) for normalized length ${normalizedLength}`,
153
+ );
154
+ }
155
+ if (start === end) {
156
+ const at = offsetMap[start]!;
157
+ return { start: at, end: at };
158
+ }
159
+ const origStart = offsetMap[start]!;
160
+ // Find the original end of the cluster containing normalized index end-1:
161
+ // advance past normalized units that still share that cluster's start value.
162
+ // (Equal adjacent values occur only within one cluster — see header.)
163
+ const lastClusterStart = offsetMap[end - 1]!;
164
+ let k = end;
165
+ while (k < normalizedLength && offsetMap[k]! === lastClusterStart) k++;
166
+ return { start: origStart, end: offsetMap[k]! };
167
+ }
168
+
169
+ // ─────────────────────────────────────────────────────────────────────────────
170
+ // Transform plumbing shared by the individual transforms
171
+ // ─────────────────────────────────────────────────────────────────────────────
172
+
173
+ /**
174
+ * One change made by a single transform, in coordinates of THAT TRANSFORM'S
175
+ * INPUT. normalize() re-maps these to original-text coordinates before
176
+ * exposing them as TransformationRecord.
177
+ */
178
+ export interface StepChange {
179
+ kind: TransformKind;
180
+ /** Range in the transform's input text. */
181
+ start: number;
182
+ end: number;
183
+ /** input.slice(start, end) — what was there. */
184
+ before: string;
185
+ /** What the transform emitted instead ('' for deletions). */
186
+ after: string;
187
+ }
188
+
189
+ /** What every transform returns; null means "nothing to do" (identity). */
190
+ export interface TransformStepResult {
191
+ text: string;
192
+ /** output index → input index, with sentinel (length text.length + 1). */
193
+ map: Int32Array;
194
+ changes: StepChange[];
195
+ }
196
+
197
+ /**
198
+ * Streaming builder used by every transform to produce output text and its
199
+ * offset map in one left-to-right pass. It enforces the deletion-attribution
200
+ * convention documented in the file header, so transforms cannot get it wrong
201
+ * individually.
202
+ *
203
+ * Usage contract: calls must cover the input strictly left to right —
204
+ * copyVerbatim / replaceRange / deleteRange with monotonically increasing,
205
+ * non-overlapping [start, end) ranges, then finish(inputLength) exactly once.
206
+ */
207
+ export class MappedTextBuilder {
208
+ private readonly parts: string[] = [];
209
+ private readonly map: number[] = [];
210
+ /** Start of the input region not yet attributed to any output. */
211
+ private claimFrom = 0;
212
+ /** How far the input has been consumed (for misuse detection). */
213
+ private cursor = 0;
214
+
215
+ private advance(start: number, end: number): void {
216
+ if (start !== this.cursor || end < start) {
217
+ throw new Error(
218
+ `MappedTextBuilder: ranges must be contiguous and left-to-right ` +
219
+ `(cursor ${this.cursor}, got [${start}, ${end}))`,
220
+ );
221
+ }
222
+ this.cursor = end;
223
+ }
224
+
225
+ /**
226
+ * Copy input.slice(start, end) through unchanged. Mapping is fine-grained
227
+ * (each output unit → its own input position), except that the first unit
228
+ * claims any pending deleted region before it.
229
+ */
230
+ copyVerbatim(input: string, start: number, end: number): void {
231
+ this.advance(start, end);
232
+ if (start === end) return;
233
+ this.parts.push(input.slice(start, end));
234
+ this.map.push(this.claimFrom);
235
+ for (let k = start + 1; k < end; k++) this.map.push(k);
236
+ this.claimFrom = end;
237
+ }
238
+
239
+ /**
240
+ * Replace input.slice(start, end) with `replacement`. Every output unit
241
+ * maps to the start of the input cluster (including any pending deleted
242
+ * region before it) — a span covering part of the replacement covers the
243
+ * whole original cluster.
244
+ */
245
+ replaceRange(replacement: string, start: number, end: number): void {
246
+ this.advance(start, end);
247
+ const base = this.claimFrom;
248
+ for (let i = 0; i < replacement.length; i++) this.map.push(base);
249
+ if (replacement.length > 0) this.parts.push(replacement);
250
+ this.claimFrom = end;
251
+ }
252
+
253
+ /**
254
+ * Delete input.slice(start, end): emits nothing. The region stays
255
+ * unclaimed and will be attributed to the next output (or the sentinel).
256
+ */
257
+ deleteRange(start: number, end: number): void {
258
+ this.advance(start, end);
259
+ }
260
+
261
+ /** Finish the map with its sentinel entry and assemble the output text. */
262
+ finish(inputLength: number): { text: string; map: Int32Array } {
263
+ if (this.cursor !== inputLength) {
264
+ throw new Error(
265
+ `MappedTextBuilder: input not fully consumed (cursor ${this.cursor} of ${inputLength})`,
266
+ );
267
+ }
268
+ this.map.push(inputLength);
269
+ return { text: this.parts.join(''), map: Int32Array.from(this.map) };
270
+ }
271
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * The composed detection pipeline.
3
+ *
4
+ * Stages 0–3 in one supported entry point. Before this existed a caller had
5
+ * to run `runStage1`, then `runStage2`, then score the result — and Stage 3's
6
+ * evidence had to be threaded into Stage 1's validators by hand. That is not a
7
+ * detail a consumer should be trusted with: a caller who forgets the context
8
+ * hook silently gets a weaker pipeline, and one who forgets Stage 3 gets every
9
+ * false positive Stage 3 exists to remove.
10
+ *
11
+ * SPEC.md's non-negotiable applies to the whole composition: any detection
12
+ * error, timeout, or adapter failure must BLOCK, never degrade. Nothing here
13
+ * catches an error from a stage — a thrown `DetectionTimeoutError` or
14
+ * `DetectorError` propagates to the caller, which is what fail-closed means.
15
+ *
16
+ * The lower-level stage functions remain exported for tests and tooling that
17
+ * genuinely want one stage; `detect` is what consumers should use.
18
+ */
19
+
20
+ import { DOMAIN_LEXICONS, TRIGGER_LEXICONS } from '@discretion/data';
21
+
22
+ import type { NormalizationResult } from './types.js';
23
+ import { runStage1, type Stage1Options } from './detect/runner.js';
24
+ import { runStage2 } from './ner/runStage2.js';
25
+ import type { NerRecognizer } from './ner/types.js';
26
+ import { analyzeContext, type ContextOptions } from './context/score.js';
27
+ import type { ContextScoredCandidate, DocumentProfile, PipelineCandidate } from './context/types.js';
28
+
29
+ export interface DetectOptions {
30
+ /** Stage 1 configuration. The context hook is supplied automatically. */
31
+ readonly stage1?: Omit<Stage1Options, 'contextFor'>;
32
+ /**
33
+ * Stage 2 engine. Omit to run without named-entity recognition — the
34
+ * playground and the Stage-1 eval baseline both do.
35
+ */
36
+ readonly ner?: NerRecognizer;
37
+ /** Stage 3 configuration. Defaults to the bundled trigger lexicons. */
38
+ readonly context?: ContextOptions;
39
+ }
40
+
41
+ export interface DetectionOutcome {
42
+ /** Candidates Stage 3 kept, with their adjusted confidence and reasons. */
43
+ readonly emitted: readonly ContextScoredCandidate[];
44
+ /**
45
+ * Candidates Stage 3 suppressed, retained for eval and explanation.
46
+ *
47
+ * Kept rather than discarded because a suppression is a decision the
48
+ * pipeline must be able to justify: the review UI explains why something
49
+ * was NOT reported, and the eval measures whether a suppression rule is
50
+ * removing errors or removing detections.
51
+ */
52
+ readonly suppressed: readonly ContextScoredCandidate[];
53
+ readonly profile: DocumentProfile;
54
+ }
55
+
56
+ /**
57
+ * Run Stages 0–3 over an already-normalized document.
58
+ *
59
+ * Takes the `NormalizationResult` rather than a string for the same reason
60
+ * `runStage1` does: without the offset map a candidate cannot be mapped back
61
+ * to the original text, and accepting a bare string would let a caller lose
62
+ * it silently.
63
+ */
64
+ export async function detect(
65
+ normalization: NormalizationResult,
66
+ options: DetectOptions = {},
67
+ ): Promise<DetectionOutcome> {
68
+ const analysis = analyzeContext(normalization.normalizedText, {
69
+ triggerLexicons: TRIGGER_LEXICONS,
70
+ domainLexicon: DOMAIN_LEXICONS,
71
+ ...options.context,
72
+ });
73
+
74
+ // Stage 1 validators receive Stage 3 evidence inline, which is what lets a
75
+ // detector that SPEC.md marks "requires context" see the signal at the
76
+ // moment it decides.
77
+ const stage1 = runStage1(normalization, {
78
+ ...options.stage1,
79
+ contextFor: (start, end) => analysis.signalAt(start, end),
80
+ });
81
+
82
+ const stage2 = options.ner === undefined ? [] : await runStage2(normalization, options.ner);
83
+
84
+ const candidates: PipelineCandidate[] = [...stage1, ...stage2];
85
+ const scored = analysis.score(candidates);
86
+
87
+ // NO STAGE 2C. SPEC.md asks for a verification pass over an ambiguous
88
+ // confidence band, and requires it be removed if the eval shows it does not
89
+ // improve results. It was built, measured, and removed — see ARCHITECTURE.md
90
+ // D20 and the BENCHMARKS.md M7 section for the numbers.
91
+ return {
92
+ emitted: scored.filter((c) => !c.suppressed),
93
+ suppressed: scored.filter((c) => c.suppressed),
94
+ profile: analysis.profile,
95
+ };
96
+ }
package/src/protect.ts ADDED
@@ -0,0 +1,284 @@
1
+ /**
2
+ * protect.ts — the one-call entry point: text in, masked text and a report out.
3
+ *
4
+ * ─────────────────────────────────────────────────────────────────────────
5
+ * WHY THIS EXISTS (M12)
6
+ *
7
+ * Every stage of the pipeline was already exported, and that is not the same
8
+ * as being usable. Getting from a string to "here is the masked text and what
9
+ * was found" meant composing eight core calls in a specific order, holding an
10
+ * identity map between two of them, and importing the fitted calibration model
11
+ * from a SECOND package through an unchecked cast. The extension's
12
+ * `analyzeText` does exactly that in about ninety lines.
13
+ *
14
+ * SPEC's M12 acceptance test is that "a developer who has never seen this repo
15
+ * can npm install the package and run detection and masking from the docs
16
+ * alone". Documenting those ninety lines would satisfy the letter of it and
17
+ * miss the point: the order matters for correctness, not just for convenience,
18
+ * and a consumer who gets it wrong gets quietly worse results rather than an
19
+ * error. Two of the orderings below were bugs found in earlier milestones.
20
+ *
21
+ * The individual stages remain exported. This is the supported path, not the
22
+ * only one.
23
+ *
24
+ * ─────────────────────────────────────────────────────────────────────────
25
+ * WHAT `mask()` IS, AND WHY IT IS NOT THIS
26
+ *
27
+ * `mask()` in `mask/masker.ts` also takes a string and returns masked text,
28
+ * and it looks like this function's smaller sibling. It runs STAGE 1 ONLY —
29
+ * no context scoring, no calibration, no profile decision, no NER. It exists
30
+ * for tests and for the playground's Stage-1 baseline. A consumer who reached
31
+ * for it expecting the full engine would get uncalibrated confidences and none
32
+ * of Stage 3's false-positive suppression, with nothing to indicate the
33
+ * difference. `stagesRun` on this function's result is what makes the
34
+ * distinction legible.
35
+ *
36
+ * ─────────────────────────────────────────────────────────────────────────
37
+ * FAIL-CLOSED IS THE CALLER'S JOB, AND THIS FUNCTION PRESERVES IT
38
+ *
39
+ * Nothing here catches an error from a stage. `detect` propagates
40
+ * `DetectionTimeoutError` and `DetectorError` deliberately, and so does this.
41
+ * A caller that wrapped it in a try/catch and treated the failure as "nothing
42
+ * found" would have built the exact failure SPEC.md calls a critical bug, so
43
+ * the failure is left where it cannot be mistaken for a result.
44
+ */
45
+
46
+ import { CALIBRATION_MODEL } from '@discretion/data';
47
+
48
+ import { computeExposure } from './exposure/index.js';
49
+ import { calibrate, type CalibrationModel } from './fuse/calibrate.js';
50
+ import { toCalibrationModel } from './fuse/defaultCalibration.js';
51
+ import { toDetectedEntity } from './fuse/explain.js';
52
+ import { PROFILES, decide, type ProfileName, type SensitivityProfile, type UserLists } from './fuse/profiles.js';
53
+ import { resolveOverlaps } from './fuse/resolve.js';
54
+ import { maskOriginal } from './mask/masker.js';
55
+ import { Vault } from './mask/vault.js';
56
+ import { normalize } from './normalization.js';
57
+ import { detect } from './pipeline.js';
58
+ import type { ContextScoredCandidate, PipelineCandidate } from './context/types.js';
59
+ import type { ExposureReport } from './exposure/index.js';
60
+ import type { NerRecognizer } from './ner/types.js';
61
+ import type {
62
+ DetectionStage,
63
+ EntityExplanation,
64
+ EntityType,
65
+ SubstitutionMode,
66
+ } from './types.js';
67
+
68
+ /** The shipped model, converted once and checked rather than cast. */
69
+ const DEFAULT_CALIBRATION: CalibrationModel = toCalibrationModel(CALIBRATION_MODEL).model;
70
+
71
+ export interface ProtectOptions {
72
+ /**
73
+ * Which findings are worth reporting. A `ProfileName` selects one of the
74
+ * three SPEC profiles; a `SensitivityProfile` supplies your own.
75
+ * Default: `'balanced'`.
76
+ */
77
+ readonly profile?: ProfileName | SensitivityProfile;
78
+ /** Values to always report (`deny`) or never report (`allow`). */
79
+ readonly lists?: UserLists;
80
+ /**
81
+ * The region used for identifiers that are ambiguous without one.
82
+ *
83
+ * Not a tie-breaker: a phone number written in national form cannot be
84
+ * validated at all without a region, so leaving this unset does not lower
85
+ * its confidence — the detector reports nothing.
86
+ */
87
+ readonly defaultRegion?: string;
88
+ /** Per-type opt-out, applied before a surrogate is minted. */
89
+ readonly typeAllowed?: (type: EntityType) => boolean;
90
+ /** `'surrogate'` (realistic stand-ins, default) or `'token'` (`[EMAIL_1]`). */
91
+ readonly mode?: SubstitutionMode;
92
+ /** Varies surrogate selection. Fixed input plus fixed seed is reproducible. */
93
+ readonly seed?: number;
94
+ /**
95
+ * The vault that remembers which surrogate stood in for which value.
96
+ *
97
+ * REQUIRED FOR RESTORATION, and required for consistency across calls: pass
98
+ * the same vault to every `protect()` in a conversation and a value seen
99
+ * twice gets the same surrogate. Omit it and a fresh vault is created for
100
+ * this call alone, which is correct for one-shot masking and wrong for
101
+ * anything that restores a reply later.
102
+ */
103
+ readonly vault?: Vault;
104
+ /**
105
+ * Stage 2. Omit to run Stages 0, 1, 3 and 4 only.
106
+ *
107
+ * Not defaulted to a model on purpose: the recogniser pulls in the ONNX
108
+ * runtime, which this package does not depend on. See the "Stage 2" section
109
+ * of the usage guide.
110
+ */
111
+ readonly ner?: NerRecognizer;
112
+ /** Overrides the shipped calibration model. For eval work, not for use. */
113
+ readonly calibration?: CalibrationModel;
114
+ }
115
+
116
+ /** One finding, with everything needed to show it and nothing that leaks it. */
117
+ export interface ProtectedEntity {
118
+ /**
119
+ * The vault id, stable across re-analyses of the same value.
120
+ *
121
+ * Derived from the value rather than from position, so a caller tracking a
122
+ * user's per-item decisions keeps them when text is edited earlier in the
123
+ * document. An index-based id would silently move the decision.
124
+ */
125
+ readonly id: string;
126
+ readonly type: EntityType;
127
+ /** Calibrated, comparable across types. Never the raw detector score. */
128
+ readonly confidence: number;
129
+ /** Which evidence fired. Structured, so callers can render it in any language. */
130
+ readonly explanation: EntityExplanation;
131
+ /** What replaced it in `maskedText`. */
132
+ readonly surrogate: string;
133
+ /** Offsets into the ORIGINAL text, not the normalized text. */
134
+ readonly originalStart: number;
135
+ readonly originalEnd: number;
136
+ }
137
+
138
+ export interface ProtectResult {
139
+ /** The input with every reported value replaced. Safe to send. */
140
+ readonly maskedText: string;
141
+ readonly entities: readonly ProtectedEntity[];
142
+ /** How exposed the document was, before masking. */
143
+ readonly exposure: ExposureReport;
144
+ /**
145
+ * Which stages actually ran.
146
+ *
147
+ * DERIVED from the options, never declared, so "Stage 2 ran" is a claim the
148
+ * code supports rather than a comment. Absence of `'stage2-ner'` is how a
149
+ * caller knows names were not looked for.
150
+ */
151
+ readonly stagesRun: readonly DetectionStage[];
152
+ /**
153
+ * The vault holding the originals. Pass it to `restore()` to reverse this.
154
+ *
155
+ * The same instance passed in `options.vault`, or the one created for this
156
+ * call. It holds plaintext originals in memory: SPEC.md forbids persisting
157
+ * it, and the extension clears it per tab session.
158
+ */
159
+ readonly vault: Vault;
160
+ }
161
+
162
+ function resolveProfile(profile: ProtectOptions['profile']): SensitivityProfile {
163
+ if (profile === undefined) return PROFILES.balanced;
164
+ if (typeof profile !== 'string') return profile;
165
+ if (profile === 'custom') {
166
+ throw new Error(
167
+ "protect: profile 'custom' names a shape, not a policy - pass a SensitivityProfile",
168
+ );
169
+ }
170
+ return PROFILES[profile];
171
+ }
172
+
173
+ /**
174
+ * Detect sensitive values in `text` and replace them with stand-ins.
175
+ *
176
+ * Throws on any stage failure rather than returning an empty result. See the
177
+ * fail-closed note in this file's header.
178
+ */
179
+ export async function protect(text: string, options: ProtectOptions = {}): Promise<ProtectResult> {
180
+ const profile = resolveProfile(options.profile);
181
+ const calibration = options.calibration ?? DEFAULT_CALIBRATION;
182
+ const vault = options.vault ?? new Vault();
183
+
184
+ const normalization = normalize(text);
185
+ const outcome = await detect(normalization, {
186
+ ...(options.ner === undefined ? {} : { ner: options.ner }),
187
+ ...(options.defaultRegion === undefined
188
+ ? {}
189
+ : { stage1: { defaultRegion: options.defaultRegion } }),
190
+ });
191
+
192
+ // Resolve overlaps BEFORE calibrating or scoring exposure. An unresolved set
193
+ // double-counts every overlap, so one credential matched by three detectors
194
+ // would appear three times and inflate the exposure score threefold.
195
+ const resolution = resolveOverlaps(
196
+ outcome.emitted
197
+ .filter((scored) => scored.candidate.sensitive)
198
+ .map((scored) => ({ candidate: scored.candidate, confidence: scored.contextConfidence })),
199
+ );
200
+
201
+ // Keyed by object identity: `resolveOverlaps` returns the same candidate
202
+ // objects it was given, and the scored record carries the Stage 3
203
+ // contributions the explanation needs.
204
+ const scoredByCandidate = new Map<PipelineCandidate, ContextScoredCandidate>();
205
+ for (const scored of outcome.emitted) scoredByCandidate.set(scored.candidate, scored);
206
+
207
+ const reported: { scored: ContextScoredCandidate; confidence: number }[] = [];
208
+ for (const item of resolution.emitted) {
209
+ const scored = scoredByCandidate.get(item.candidate);
210
+ if (scored === undefined) continue;
211
+ const confidence = calibrate(calibration, item.candidate.type, item.confidence);
212
+ const decision = decide(
213
+ { type: item.candidate.type, text: item.candidate.text, calibratedConfidence: confidence },
214
+ profile,
215
+ options.lists ?? {},
216
+ );
217
+ if (!decision.report) continue;
218
+ if (options.typeAllowed?.(item.candidate.type) === false) continue;
219
+ reported.push({ scored, confidence });
220
+ }
221
+
222
+ // Surrogates come from the masker rather than from `chooseSurrogate`
223
+ // directly, because the masker enforces the properties a surrogate must
224
+ // have before it is shown: consistency through the vault, and the collision
225
+ // check that stops a surrogate from containing the very value it replaces.
226
+ // Computing them any other way shows the user one string and substitutes
227
+ // another.
228
+ const masked = maskOriginal(
229
+ text,
230
+ reported.map((entry) => entry.scored.candidate),
231
+ vault,
232
+ {
233
+ ...(options.mode === undefined ? {} : { mode: options.mode }),
234
+ ...(options.seed === undefined ? {} : { seed: options.seed }),
235
+ },
236
+ );
237
+
238
+ const surrogateAt = new Map<number, { replacement: string; vaultId: string }>();
239
+ for (const entity of masked.entities) {
240
+ surrogateAt.set(entity.originalStart, {
241
+ replacement: entity.replacement,
242
+ vaultId: entity.vaultId,
243
+ });
244
+ }
245
+
246
+ const entities: ProtectedEntity[] = [];
247
+ for (const { scored, confidence } of reported) {
248
+ const candidate = scored.candidate;
249
+ const surrogate = surrogateAt.get(candidate.originalStart);
250
+ if (surrogate === undefined) continue;
251
+ entities.push({
252
+ id: surrogate.vaultId,
253
+ type: candidate.type,
254
+ confidence,
255
+ explanation: toDetectedEntity({ scored, calibratedConfidence: confidence }).explanation,
256
+ surrogate: surrogate.replacement,
257
+ originalStart: candidate.originalStart,
258
+ originalEnd: candidate.originalEnd,
259
+ });
260
+ }
261
+
262
+ // Not a warning. A reported detection with no surrogate is one the caller
263
+ // cannot show and cannot let the user revert, while the masker substitutes
264
+ // it anyway.
265
+ if (entities.length !== reported.length) {
266
+ throw new Error(
267
+ `protect: masking produced ${String(entities.length)} surrogates for ${String(reported.length)} reported detections`,
268
+ );
269
+ }
270
+
271
+ const stagesRun: DetectionStage[] = ['stage1-validated-identifier'];
272
+ if (options.ner !== undefined) stagesRun.push('stage2-ner');
273
+ stagesRun.push('stage3-context', 'stage4-fusion');
274
+
275
+ return {
276
+ maskedText: masked.maskedText,
277
+ entities,
278
+ exposure: computeExposure(
279
+ entities.map((entity) => ({ type: entity.type, calibratedConfidence: entity.confidence })),
280
+ ),
281
+ stagesRun,
282
+ vault,
283
+ };
284
+ }