@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.
- package/CHANGELOG.md +117 -0
- package/LICENSE +21 -0
- package/README.md +319 -0
- package/dist/src/checksums/aba.d.ts +25 -0
- package/dist/src/checksums/aba.d.ts.map +1 -0
- package/dist/src/checksums/aba.js +47 -0
- package/dist/src/checksums/aba.js.map +1 -0
- package/dist/src/checksums/digits.d.ts +55 -0
- package/dist/src/checksums/digits.d.ts.map +1 -0
- package/dist/src/checksums/digits.js +114 -0
- package/dist/src/checksums/digits.js.map +1 -0
- package/dist/src/checksums/icao9303.d.ts +29 -0
- package/dist/src/checksums/icao9303.d.ts.map +1 -0
- package/dist/src/checksums/icao9303.js +56 -0
- package/dist/src/checksums/icao9303.js.map +1 -0
- package/dist/src/checksums/index.d.ts +21 -0
- package/dist/src/checksums/index.d.ts.map +1 -0
- package/dist/src/checksums/index.js +21 -0
- package/dist/src/checksums/index.js.map +1 -0
- package/dist/src/checksums/iso7064.d.ts +67 -0
- package/dist/src/checksums/iso7064.d.ts.map +1 -0
- package/dist/src/checksums/iso7064.js +159 -0
- package/dist/src/checksums/iso7064.js.map +1 -0
- package/dist/src/checksums/luhn.d.ts +32 -0
- package/dist/src/checksums/luhn.d.ts.map +1 -0
- package/dist/src/checksums/luhn.js +66 -0
- package/dist/src/checksums/luhn.js.map +1 -0
- package/dist/src/checksums/mod97.d.ts +55 -0
- package/dist/src/checksums/mod97.d.ts.map +1 -0
- package/dist/src/checksums/mod97.js +94 -0
- package/dist/src/checksums/mod97.js.map +1 -0
- package/dist/src/checksums/verhoeff.d.ts +28 -0
- package/dist/src/checksums/verhoeff.d.ts.map +1 -0
- package/dist/src/checksums/verhoeff.js +80 -0
- package/dist/src/checksums/verhoeff.js.map +1 -0
- package/dist/src/checksums/weighted.d.ts +64 -0
- package/dist/src/checksums/weighted.d.ts.map +1 -0
- package/dist/src/checksums/weighted.js +97 -0
- package/dist/src/checksums/weighted.js.map +1 -0
- package/dist/src/context/documentProfile.d.ts +34 -0
- package/dist/src/context/documentProfile.d.ts.map +1 -0
- package/dist/src/context/documentProfile.js +253 -0
- package/dist/src/context/documentProfile.js.map +1 -0
- package/dist/src/context/negativeRules.d.ts +60 -0
- package/dist/src/context/negativeRules.d.ts.map +1 -0
- package/dist/src/context/negativeRules.js +696 -0
- package/dist/src/context/negativeRules.js.map +1 -0
- package/dist/src/context/score.d.ts +52 -0
- package/dist/src/context/score.d.ts.map +1 -0
- package/dist/src/context/score.js +346 -0
- package/dist/src/context/score.js.map +1 -0
- package/dist/src/context/structure.d.ts +46 -0
- package/dist/src/context/structure.d.ts.map +1 -0
- package/dist/src/context/structure.js +528 -0
- package/dist/src/context/structure.js.map +1 -0
- package/dist/src/context/triggers.d.ts +73 -0
- package/dist/src/context/triggers.d.ts.map +1 -0
- package/dist/src/context/triggers.js +172 -0
- package/dist/src/context/triggers.js.map +1 -0
- package/dist/src/context/types.d.ts +137 -0
- package/dist/src/context/types.d.ts.map +1 -0
- package/dist/src/context/types.js +25 -0
- package/dist/src/context/types.js.map +1 -0
- package/dist/src/crypto/keccak256.d.ts +15 -0
- package/dist/src/crypto/keccak256.d.ts.map +1 -0
- package/dist/src/crypto/keccak256.js +89 -0
- package/dist/src/crypto/keccak256.js.map +1 -0
- package/dist/src/crypto/sha256.d.ts +16 -0
- package/dist/src/crypto/sha256.d.ts.map +1 -0
- package/dist/src/crypto/sha256.js +81 -0
- package/dist/src/crypto/sha256.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/auBsb.d.ts +11 -0
- package/dist/src/detect/detectors/bankcodes/auBsb.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/auBsb.js +34 -0
- package/dist/src/detect/detectors/bankcodes/auBsb.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/brAgencia.d.ts +15 -0
- package/dist/src/detect/detectors/bankcodes/brAgencia.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/brAgencia.js +43 -0
- package/dist/src/detect/detectors/bankcodes/brAgencia.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/caTransit.d.ts +13 -0
- package/dist/src/detect/detectors/bankcodes/caTransit.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/caTransit.js +86 -0
- package/dist/src/detect/detectors/bankcodes/caTransit.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/inIfsc.d.ts +13 -0
- package/dist/src/detect/detectors/bankcodes/inIfsc.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/inIfsc.js +37 -0
- package/dist/src/detect/detectors/bankcodes/inIfsc.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/index.d.ts +10 -0
- package/dist/src/detect/detectors/bankcodes/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/index.js +10 -0
- package/dist/src/detect/detectors/bankcodes/index.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/ukSortCode.d.ts +13 -0
- package/dist/src/detect/detectors/bankcodes/ukSortCode.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/ukSortCode.js +36 -0
- package/dist/src/detect/detectors/bankcodes/ukSortCode.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/usRouting.d.ts +12 -0
- package/dist/src/detect/detectors/bankcodes/usRouting.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/usRouting.js +45 -0
- package/dist/src/detect/detectors/bankcodes/usRouting.js.map +1 -0
- package/dist/src/detect/detectors/contact/email.d.ts +16 -0
- package/dist/src/detect/detectors/contact/email.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/email.js +111 -0
- package/dist/src/detect/detectors/contact/email.js.map +1 -0
- package/dist/src/detect/detectors/contact/index.d.ts +11 -0
- package/dist/src/detect/detectors/contact/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/index.js +11 -0
- package/dist/src/detect/detectors/contact/index.js.map +1 -0
- package/dist/src/detect/detectors/contact/ipv4.d.ts +12 -0
- package/dist/src/detect/detectors/contact/ipv4.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/ipv4.js +109 -0
- package/dist/src/detect/detectors/contact/ipv4.js.map +1 -0
- package/dist/src/detect/detectors/contact/ipv6.d.ts +16 -0
- package/dist/src/detect/detectors/contact/ipv6.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/ipv6.js +187 -0
- package/dist/src/detect/detectors/contact/ipv6.js.map +1 -0
- package/dist/src/detect/detectors/contact/mac.d.ts +14 -0
- package/dist/src/detect/detectors/contact/mac.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/mac.js +64 -0
- package/dist/src/detect/detectors/contact/mac.js.map +1 -0
- package/dist/src/detect/detectors/contact/phone.d.ts +21 -0
- package/dist/src/detect/detectors/contact/phone.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/phone.js +76 -0
- package/dist/src/detect/detectors/contact/phone.js.map +1 -0
- package/dist/src/detect/detectors/contact/urlCredentials.d.ts +23 -0
- package/dist/src/detect/detectors/contact/urlCredentials.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/urlCredentials.js +123 -0
- package/dist/src/detect/detectors/contact/urlCredentials.js.map +1 -0
- package/dist/src/detect/detectors/crypto/ada.d.ts +13 -0
- package/dist/src/detect/detectors/crypto/ada.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/ada.js +51 -0
- package/dist/src/detect/detectors/crypto/ada.js.map +1 -0
- package/dist/src/detect/detectors/crypto/btc.d.ts +15 -0
- package/dist/src/detect/detectors/crypto/btc.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/btc.js +78 -0
- package/dist/src/detect/detectors/crypto/btc.js.map +1 -0
- package/dist/src/detect/detectors/crypto/dot.d.ts +13 -0
- package/dist/src/detect/detectors/crypto/dot.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/dot.js +41 -0
- package/dist/src/detect/detectors/crypto/dot.js.map +1 -0
- package/dist/src/detect/detectors/crypto/eth.d.ts +15 -0
- package/dist/src/detect/detectors/crypto/eth.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/eth.js +63 -0
- package/dist/src/detect/detectors/crypto/eth.js.map +1 -0
- package/dist/src/detect/detectors/crypto/index.d.ts +12 -0
- package/dist/src/detect/detectors/crypto/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/index.js +12 -0
- package/dist/src/detect/detectors/crypto/index.js.map +1 -0
- package/dist/src/detect/detectors/crypto/ltc.d.ts +12 -0
- package/dist/src/detect/detectors/crypto/ltc.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/ltc.js +71 -0
- package/dist/src/detect/detectors/crypto/ltc.js.map +1 -0
- package/dist/src/detect/detectors/crypto/sol.d.ts +13 -0
- package/dist/src/detect/detectors/crypto/sol.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/sol.js +39 -0
- package/dist/src/detect/detectors/crypto/sol.js.map +1 -0
- package/dist/src/detect/detectors/crypto/trx.d.ts +8 -0
- package/dist/src/detect/detectors/crypto/trx.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/trx.js +34 -0
- package/dist/src/detect/detectors/crypto/trx.js.map +1 -0
- package/dist/src/detect/detectors/crypto/xmr.d.ts +10 -0
- package/dist/src/detect/detectors/crypto/xmr.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/xmr.js +51 -0
- package/dist/src/detect/detectors/crypto/xmr.js.map +1 -0
- package/dist/src/detect/detectors/documents/driversLicense.d.ts +24 -0
- package/dist/src/detect/detectors/documents/driversLicense.d.ts.map +1 -0
- package/dist/src/detect/detectors/documents/driversLicense.js +79 -0
- package/dist/src/detect/detectors/documents/driversLicense.js.map +1 -0
- package/dist/src/detect/detectors/documents/healthData.d.ts +23 -0
- package/dist/src/detect/detectors/documents/healthData.d.ts.map +1 -0
- package/dist/src/detect/detectors/documents/healthData.js +78 -0
- package/dist/src/detect/detectors/documents/healthData.js.map +1 -0
- package/dist/src/detect/detectors/documents/index.d.ts +9 -0
- package/dist/src/detect/detectors/documents/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/documents/index.js +9 -0
- package/dist/src/detect/detectors/documents/index.js.map +1 -0
- package/dist/src/detect/detectors/documents/passportMrz.d.ts +20 -0
- package/dist/src/detect/detectors/documents/passportMrz.d.ts.map +1 -0
- package/dist/src/detect/detectors/documents/passportMrz.js +194 -0
- package/dist/src/detect/detectors/documents/passportMrz.js.map +1 -0
- package/dist/src/detect/detectors/documents/usNpi.d.ts +16 -0
- package/dist/src/detect/detectors/documents/usNpi.d.ts.map +1 -0
- package/dist/src/detect/detectors/documents/usNpi.js +48 -0
- package/dist/src/detect/detectors/documents/usNpi.js.map +1 -0
- package/dist/src/detect/detectors/documents/vin.d.ts +15 -0
- package/dist/src/detect/detectors/documents/vin.d.ts.map +1 -0
- package/dist/src/detect/detectors/documents/vin.js +64 -0
- package/dist/src/detect/detectors/documents/vin.js.map +1 -0
- package/dist/src/detect/detectors/financial/creditCard.d.ts +23 -0
- package/dist/src/detect/detectors/financial/creditCard.d.ts.map +1 -0
- package/dist/src/detect/detectors/financial/creditCard.js +157 -0
- package/dist/src/detect/detectors/financial/creditCard.js.map +1 -0
- package/dist/src/detect/detectors/financial/iban.d.ts +18 -0
- package/dist/src/detect/detectors/financial/iban.d.ts.map +1 -0
- package/dist/src/detect/detectors/financial/iban.js +80 -0
- package/dist/src/detect/detectors/financial/iban.js.map +1 -0
- package/dist/src/detect/detectors/financial/ibanRegistry.d.ts +35 -0
- package/dist/src/detect/detectors/financial/ibanRegistry.d.ts.map +1 -0
- package/dist/src/detect/detectors/financial/ibanRegistry.js +92 -0
- package/dist/src/detect/detectors/financial/ibanRegistry.js.map +1 -0
- package/dist/src/detect/detectors/financial/index.d.ts +7 -0
- package/dist/src/detect/detectors/financial/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/financial/index.js +7 -0
- package/dist/src/detect/detectors/financial/index.js.map +1 -0
- package/dist/src/detect/detectors/financial/swiftBic.d.ts +17 -0
- package/dist/src/detect/detectors/financial/swiftBic.d.ts.map +1 -0
- package/dist/src/detect/detectors/financial/swiftBic.js +55 -0
- package/dist/src/detect/detectors/financial/swiftBic.js.map +1 -0
- package/dist/src/detect/detectors/index.d.ts +15 -0
- package/dist/src/detect/detectors/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/index.js +15 -0
- package/dist/src/detect/detectors/index.js.map +1 -0
- package/dist/src/detect/detectors/location/coordinates.d.ts +14 -0
- package/dist/src/detect/detectors/location/coordinates.d.ts.map +1 -0
- package/dist/src/detect/detectors/location/coordinates.js +79 -0
- package/dist/src/detect/detectors/location/coordinates.js.map +1 -0
- package/dist/src/detect/detectors/location/index.d.ts +7 -0
- package/dist/src/detect/detectors/location/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/location/index.js +7 -0
- package/dist/src/detect/detectors/location/index.js.map +1 -0
- package/dist/src/detect/detectors/location/postalCode.d.ts +13 -0
- package/dist/src/detect/detectors/location/postalCode.d.ts.map +1 -0
- package/dist/src/detect/detectors/location/postalCode.js +53 -0
- package/dist/src/detect/detectors/location/postalCode.js.map +1 -0
- package/dist/src/detect/detectors/location/postalRegistry.d.ts +19 -0
- package/dist/src/detect/detectors/location/postalRegistry.d.ts.map +1 -0
- package/dist/src/detect/detectors/location/postalRegistry.js +73 -0
- package/dist/src/detect/detectors/location/postalRegistry.js.map +1 -0
- package/dist/src/detect/detectors/location/streetAddress.d.ts +21 -0
- package/dist/src/detect/detectors/location/streetAddress.d.ts.map +1 -0
- package/dist/src/detect/detectors/location/streetAddress.js +70 -0
- package/dist/src/detect/detectors/location/streetAddress.js.map +1 -0
- package/dist/src/detect/detectors/natid/africa.d.ts +17 -0
- package/dist/src/detect/detectors/natid/africa.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/africa.js +106 -0
- package/dist/src/detect/detectors/natid/africa.js.map +1 -0
- package/dist/src/detect/detectors/natid/ar.d.ts +14 -0
- package/dist/src/detect/detectors/natid/ar.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/ar.js +62 -0
- package/dist/src/detect/detectors/natid/ar.js.map +1 -0
- package/dist/src/detect/detectors/natid/au.d.ts +13 -0
- package/dist/src/detect/detectors/natid/au.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/au.js +100 -0
- package/dist/src/detect/detectors/natid/au.js.map +1 -0
- package/dist/src/detect/detectors/natid/be.d.ts +8 -0
- package/dist/src/detect/detectors/natid/be.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/be.js +44 -0
- package/dist/src/detect/detectors/natid/be.js.map +1 -0
- package/dist/src/detect/detectors/natid/bg.d.ts +7 -0
- package/dist/src/detect/detectors/natid/bg.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/bg.js +44 -0
- package/dist/src/detect/detectors/natid/bg.js.map +1 -0
- package/dist/src/detect/detectors/natid/br.d.ts +8 -0
- package/dist/src/detect/detectors/natid/br.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/br.js +85 -0
- package/dist/src/detect/detectors/natid/br.js.map +1 -0
- package/dist/src/detect/detectors/natid/ca.d.ts +8 -0
- package/dist/src/detect/detectors/natid/ca.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/ca.js +41 -0
- package/dist/src/detect/detectors/natid/ca.js.map +1 -0
- package/dist/src/detect/detectors/natid/cl.d.ts +9 -0
- package/dist/src/detect/detectors/natid/cl.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/cl.js +47 -0
- package/dist/src/detect/detectors/natid/cl.js.map +1 -0
- package/dist/src/detect/detectors/natid/cn.d.ts +9 -0
- package/dist/src/detect/detectors/natid/cn.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/cn.js +49 -0
- package/dist/src/detect/detectors/natid/cn.js.map +1 -0
- package/dist/src/detect/detectors/natid/co.d.ts +10 -0
- package/dist/src/detect/detectors/natid/co.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/co.js +43 -0
- package/dist/src/detect/detectors/natid/co.js.map +1 -0
- package/dist/src/detect/detectors/natid/cz.d.ts +11 -0
- package/dist/src/detect/detectors/natid/cz.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/cz.js +44 -0
- package/dist/src/detect/detectors/natid/cz.js.map +1 -0
- package/dist/src/detect/detectors/natid/de.d.ts +16 -0
- package/dist/src/detect/detectors/natid/de.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/de.js +77 -0
- package/dist/src/detect/detectors/natid/de.js.map +1 -0
- package/dist/src/detect/detectors/natid/dk.d.ts +9 -0
- package/dist/src/detect/detectors/natid/dk.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/dk.js +31 -0
- package/dist/src/detect/detectors/natid/dk.js.map +1 -0
- package/dist/src/detect/detectors/natid/es.d.ts +12 -0
- package/dist/src/detect/detectors/natid/es.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/es.js +96 -0
- package/dist/src/detect/detectors/natid/es.js.map +1 -0
- package/dist/src/detect/detectors/natid/fi.d.ts +10 -0
- package/dist/src/detect/detectors/natid/fi.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/fi.js +40 -0
- package/dist/src/detect/detectors/natid/fi.js.map +1 -0
- package/dist/src/detect/detectors/natid/fr.d.ts +12 -0
- package/dist/src/detect/detectors/natid/fr.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/fr.js +61 -0
- package/dist/src/detect/detectors/natid/fr.js.map +1 -0
- package/dist/src/detect/detectors/natid/gb.d.ts +10 -0
- package/dist/src/detect/detectors/natid/gb.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/gb.js +72 -0
- package/dist/src/detect/detectors/natid/gb.js.map +1 -0
- package/dist/src/detect/detectors/natid/gr.d.ts +7 -0
- package/dist/src/detect/detectors/natid/gr.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/gr.js +36 -0
- package/dist/src/detect/detectors/natid/gr.js.map +1 -0
- package/dist/src/detect/detectors/natid/gulf.d.ts +16 -0
- package/dist/src/detect/detectors/natid/gulf.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/gulf.js +121 -0
- package/dist/src/detect/detectors/natid/gulf.js.map +1 -0
- package/dist/src/detect/detectors/natid/hk.d.ts +9 -0
- package/dist/src/detect/detectors/natid/hk.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/hk.js +41 -0
- package/dist/src/detect/detectors/natid/hk.js.map +1 -0
- package/dist/src/detect/detectors/natid/hr.d.ts +6 -0
- package/dist/src/detect/detectors/natid/hr.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/hr.js +32 -0
- package/dist/src/detect/detectors/natid/hr.js.map +1 -0
- package/dist/src/detect/detectors/natid/hu.d.ts +7 -0
- package/dist/src/detect/detectors/natid/hu.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/hu.js +37 -0
- package/dist/src/detect/detectors/natid/hu.js.map +1 -0
- package/dist/src/detect/detectors/natid/ie.d.ts +9 -0
- package/dist/src/detect/detectors/natid/ie.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/ie.js +36 -0
- package/dist/src/detect/detectors/natid/ie.js.map +1 -0
- package/dist/src/detect/detectors/natid/il.d.ts +10 -0
- package/dist/src/detect/detectors/natid/il.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/il.js +38 -0
- package/dist/src/detect/detectors/natid/il.js.map +1 -0
- package/dist/src/detect/detectors/natid/in.d.ts +17 -0
- package/dist/src/detect/detectors/natid/in.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/in.js +67 -0
- package/dist/src/detect/detectors/natid/in.js.map +1 -0
- package/dist/src/detect/detectors/natid/index.d.ts +55 -0
- package/dist/src/detect/detectors/natid/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/index.js +55 -0
- package/dist/src/detect/detectors/natid/index.js.map +1 -0
- package/dist/src/detect/detectors/natid/is.d.ts +8 -0
- package/dist/src/detect/detectors/natid/is.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/is.js +42 -0
- package/dist/src/detect/detectors/natid/is.js.map +1 -0
- package/dist/src/detect/detectors/natid/it.d.ts +12 -0
- package/dist/src/detect/detectors/natid/it.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/it.js +62 -0
- package/dist/src/detect/detectors/natid/it.js.map +1 -0
- package/dist/src/detect/detectors/natid/jp.d.ts +9 -0
- package/dist/src/detect/detectors/natid/jp.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/jp.js +46 -0
- package/dist/src/detect/detectors/natid/jp.js.map +1 -0
- package/dist/src/detect/detectors/natid/kr.d.ts +11 -0
- package/dist/src/detect/detectors/natid/kr.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/kr.js +40 -0
- package/dist/src/detect/detectors/natid/kr.js.map +1 -0
- package/dist/src/detect/detectors/natid/kz.d.ts +8 -0
- package/dist/src/detect/detectors/natid/kz.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/kz.js +46 -0
- package/dist/src/detect/detectors/natid/kz.js.map +1 -0
- package/dist/src/detect/detectors/natid/mx.d.ts +16 -0
- package/dist/src/detect/detectors/natid/mx.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/mx.js +82 -0
- package/dist/src/detect/detectors/natid/mx.js.map +1 -0
- package/dist/src/detect/detectors/natid/nl.d.ts +8 -0
- package/dist/src/detect/detectors/natid/nl.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/nl.js +40 -0
- package/dist/src/detect/detectors/natid/nl.js.map +1 -0
- package/dist/src/detect/detectors/natid/no.d.ts +9 -0
- package/dist/src/detect/detectors/natid/no.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/no.js +52 -0
- package/dist/src/detect/detectors/natid/no.js.map +1 -0
- package/dist/src/detect/detectors/natid/nz.d.ts +9 -0
- package/dist/src/detect/detectors/natid/nz.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/nz.js +52 -0
- package/dist/src/detect/detectors/natid/nz.js.map +1 -0
- package/dist/src/detect/detectors/natid/pe.d.ts +7 -0
- package/dist/src/detect/detectors/natid/pe.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/pe.js +26 -0
- package/dist/src/detect/detectors/natid/pe.js.map +1 -0
- package/dist/src/detect/detectors/natid/pl.d.ts +11 -0
- package/dist/src/detect/detectors/natid/pl.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/pl.js +105 -0
- package/dist/src/detect/detectors/natid/pl.js.map +1 -0
- package/dist/src/detect/detectors/natid/pt.d.ts +6 -0
- package/dist/src/detect/detectors/natid/pt.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/pt.js +35 -0
- package/dist/src/detect/detectors/natid/pt.js.map +1 -0
- package/dist/src/detect/detectors/natid/ro.d.ts +8 -0
- package/dist/src/detect/detectors/natid/ro.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/ro.js +48 -0
- package/dist/src/detect/detectors/natid/ro.js.map +1 -0
- package/dist/src/detect/detectors/natid/ru.d.ts +11 -0
- package/dist/src/detect/detectors/natid/ru.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/ru.js +86 -0
- package/dist/src/detect/detectors/natid/ru.js.map +1 -0
- package/dist/src/detect/detectors/natid/se.d.ts +9 -0
- package/dist/src/detect/detectors/natid/se.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/se.js +43 -0
- package/dist/src/detect/detectors/natid/se.js.map +1 -0
- package/dist/src/detect/detectors/natid/seasia.d.ts +19 -0
- package/dist/src/detect/detectors/natid/seasia.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/seasia.js +182 -0
- package/dist/src/detect/detectors/natid/seasia.js.map +1 -0
- package/dist/src/detect/detectors/natid/sg.d.ts +8 -0
- package/dist/src/detect/detectors/natid/sg.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/sg.js +39 -0
- package/dist/src/detect/detectors/natid/sg.js.map +1 -0
- package/dist/src/detect/detectors/natid/si.d.ts +8 -0
- package/dist/src/detect/detectors/natid/si.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/si.js +44 -0
- package/dist/src/detect/detectors/natid/si.js.map +1 -0
- package/dist/src/detect/detectors/natid/tr.d.ts +14 -0
- package/dist/src/detect/detectors/natid/tr.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/tr.js +79 -0
- package/dist/src/detect/detectors/natid/tr.js.map +1 -0
- package/dist/src/detect/detectors/natid/tw.d.ts +9 -0
- package/dist/src/detect/detectors/natid/tw.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/tw.js +40 -0
- package/dist/src/detect/detectors/natid/tw.js.map +1 -0
- package/dist/src/detect/detectors/natid/ua.d.ts +7 -0
- package/dist/src/detect/detectors/natid/ua.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/ua.js +38 -0
- package/dist/src/detect/detectors/natid/ua.js.map +1 -0
- package/dist/src/detect/detectors/natid/us.d.ts +15 -0
- package/dist/src/detect/detectors/natid/us.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/us.js +119 -0
- package/dist/src/detect/detectors/natid/us.js.map +1 -0
- package/dist/src/detect/detectors/natid/za.d.ts +9 -0
- package/dist/src/detect/detectors/natid/za.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/za.js +44 -0
- package/dist/src/detect/detectors/natid/za.js.map +1 -0
- package/dist/src/detect/detectors/secrets/apiKey.d.ts +14 -0
- package/dist/src/detect/detectors/secrets/apiKey.d.ts.map +1 -0
- package/dist/src/detect/detectors/secrets/apiKey.js +103 -0
- package/dist/src/detect/detectors/secrets/apiKey.js.map +1 -0
- package/dist/src/detect/detectors/secrets/connectionString.d.ts +12 -0
- package/dist/src/detect/detectors/secrets/connectionString.d.ts.map +1 -0
- package/dist/src/detect/detectors/secrets/connectionString.js +70 -0
- package/dist/src/detect/detectors/secrets/connectionString.js.map +1 -0
- package/dist/src/detect/detectors/secrets/genericSecret.d.ts +22 -0
- package/dist/src/detect/detectors/secrets/genericSecret.d.ts.map +1 -0
- package/dist/src/detect/detectors/secrets/genericSecret.js +77 -0
- package/dist/src/detect/detectors/secrets/genericSecret.js.map +1 -0
- package/dist/src/detect/detectors/secrets/index.d.ts +9 -0
- package/dist/src/detect/detectors/secrets/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/secrets/index.js +9 -0
- package/dist/src/detect/detectors/secrets/index.js.map +1 -0
- package/dist/src/detect/detectors/secrets/jwt.d.ts +11 -0
- package/dist/src/detect/detectors/secrets/jwt.d.ts.map +1 -0
- package/dist/src/detect/detectors/secrets/jwt.js +111 -0
- package/dist/src/detect/detectors/secrets/jwt.js.map +1 -0
- package/dist/src/detect/detectors/secrets/pemPrivateKey.d.ts +16 -0
- package/dist/src/detect/detectors/secrets/pemPrivateKey.d.ts.map +1 -0
- package/dist/src/detect/detectors/secrets/pemPrivateKey.js +56 -0
- package/dist/src/detect/detectors/secrets/pemPrivateKey.js.map +1 -0
- package/dist/src/detect/detectors/vat/euVat.d.ts +17 -0
- package/dist/src/detect/detectors/vat/euVat.d.ts.map +1 -0
- package/dist/src/detect/detectors/vat/euVat.js +293 -0
- package/dist/src/detect/detectors/vat/euVat.js.map +1 -0
- package/dist/src/detect/detectors/vat/index.d.ts +5 -0
- package/dist/src/detect/detectors/vat/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/vat/index.js +5 -0
- package/dist/src/detect/detectors/vat/index.js.map +1 -0
- package/dist/src/detect/entropy.d.ts +28 -0
- package/dist/src/detect/entropy.d.ts.map +1 -0
- package/dist/src/detect/entropy.js +64 -0
- package/dist/src/detect/entropy.js.map +1 -0
- package/dist/src/detect/isoCountries.d.ts +10 -0
- package/dist/src/detect/isoCountries.d.ts.map +1 -0
- package/dist/src/detect/isoCountries.js +25 -0
- package/dist/src/detect/isoCountries.js.map +1 -0
- package/dist/src/detect/registry.d.ts +50 -0
- package/dist/src/detect/registry.d.ts.map +1 -0
- package/dist/src/detect/registry.js +110 -0
- package/dist/src/detect/registry.js.map +1 -0
- package/dist/src/detect/runner.d.ts +64 -0
- package/dist/src/detect/runner.d.ts.map +1 -0
- package/dist/src/detect/runner.js +142 -0
- package/dist/src/detect/runner.js.map +1 -0
- package/dist/src/detect/types.d.ts +251 -0
- package/dist/src/detect/types.d.ts.map +1 -0
- package/dist/src/detect/types.js +59 -0
- package/dist/src/detect/types.js.map +1 -0
- package/dist/src/encoding/base58.d.ts +26 -0
- package/dist/src/encoding/base58.d.ts.map +1 -0
- package/dist/src/encoding/base58.js +77 -0
- package/dist/src/encoding/base58.js.map +1 -0
- package/dist/src/encoding/base58monero.d.ts +15 -0
- package/dist/src/encoding/base58monero.d.ts.map +1 -0
- package/dist/src/encoding/base58monero.js +87 -0
- package/dist/src/encoding/base58monero.js.map +1 -0
- package/dist/src/encoding/bech32.d.ts +28 -0
- package/dist/src/encoding/bech32.d.ts.map +1 -0
- package/dist/src/encoding/bech32.js +108 -0
- package/dist/src/encoding/bech32.js.map +1 -0
- package/dist/src/encoding/bytes.d.ts +15 -0
- package/dist/src/encoding/bytes.d.ts.map +1 -0
- package/dist/src/encoding/bytes.js +46 -0
- package/dist/src/encoding/bytes.js.map +1 -0
- package/dist/src/entityFamily.d.ts +18 -0
- package/dist/src/entityFamily.d.ts.map +1 -0
- package/dist/src/entityFamily.js +54 -0
- package/dist/src/entityFamily.js.map +1 -0
- package/dist/src/entityLabel.d.ts +18 -0
- package/dist/src/entityLabel.d.ts.map +1 -0
- package/dist/src/entityLabel.js +53 -0
- package/dist/src/entityLabel.js.map +1 -0
- package/dist/src/entityTypes.d.ts +64 -0
- package/dist/src/entityTypes.d.ts.map +1 -0
- package/dist/src/entityTypes.js +94 -0
- package/dist/src/entityTypes.js.map +1 -0
- package/dist/src/exposure/index.d.ts +86 -0
- package/dist/src/exposure/index.d.ts.map +1 -0
- package/dist/src/exposure/index.js +134 -0
- package/dist/src/exposure/index.js.map +1 -0
- package/dist/src/fuse/calibrate.d.ts +95 -0
- package/dist/src/fuse/calibrate.d.ts.map +1 -0
- package/dist/src/fuse/calibrate.js +165 -0
- package/dist/src/fuse/calibrate.js.map +1 -0
- package/dist/src/fuse/defaultCalibration.d.ts +52 -0
- package/dist/src/fuse/defaultCalibration.d.ts.map +1 -0
- package/dist/src/fuse/defaultCalibration.js +41 -0
- package/dist/src/fuse/defaultCalibration.js.map +1 -0
- package/dist/src/fuse/explain.d.ts +55 -0
- package/dist/src/fuse/explain.d.ts.map +1 -0
- package/dist/src/fuse/explain.js +91 -0
- package/dist/src/fuse/explain.js.map +1 -0
- package/dist/src/fuse/profiles.d.ts +80 -0
- package/dist/src/fuse/profiles.d.ts.map +1 -0
- package/dist/src/fuse/profiles.js +126 -0
- package/dist/src/fuse/profiles.js.map +1 -0
- package/dist/src/fuse/resolve.d.ts +73 -0
- package/dist/src/fuse/resolve.d.ts.map +1 -0
- package/dist/src/fuse/resolve.js +206 -0
- package/dist/src/fuse/resolve.js.map +1 -0
- package/dist/src/gazetteer/index.d.ts +41 -0
- package/dist/src/gazetteer/index.d.ts.map +1 -0
- package/dist/src/gazetteer/index.js +117 -0
- package/dist/src/gazetteer/index.js.map +1 -0
- package/dist/src/generate/bankcodes.d.ts +20 -0
- package/dist/src/generate/bankcodes.d.ts.map +1 -0
- package/dist/src/generate/bankcodes.js +71 -0
- package/dist/src/generate/bankcodes.js.map +1 -0
- package/dist/src/generate/contact.d.ts +31 -0
- package/dist/src/generate/contact.d.ts.map +1 -0
- package/dist/src/generate/contact.js +139 -0
- package/dist/src/generate/contact.js.map +1 -0
- package/dist/src/generate/crypto.d.ts +27 -0
- package/dist/src/generate/crypto.d.ts.map +1 -0
- package/dist/src/generate/crypto.js +88 -0
- package/dist/src/generate/crypto.js.map +1 -0
- package/dist/src/generate/documents.d.ts +24 -0
- package/dist/src/generate/documents.d.ts.map +1 -0
- package/dist/src/generate/documents.js +124 -0
- package/dist/src/generate/documents.js.map +1 -0
- package/dist/src/generate/financial.d.ts +26 -0
- package/dist/src/generate/financial.d.ts.map +1 -0
- package/dist/src/generate/financial.js +136 -0
- package/dist/src/generate/financial.js.map +1 -0
- package/dist/src/generate/index.d.ts +23 -0
- package/dist/src/generate/index.d.ts.map +1 -0
- package/dist/src/generate/index.js +23 -0
- package/dist/src/generate/index.js.map +1 -0
- package/dist/src/generate/location.d.ts +12 -0
- package/dist/src/generate/location.d.ts.map +1 -0
- package/dist/src/generate/location.js +75 -0
- package/dist/src/generate/location.js.map +1 -0
- package/dist/src/generate/natidAmOc.d.ts +22 -0
- package/dist/src/generate/natidAmOc.d.ts.map +1 -0
- package/dist/src/generate/natidAmOc.js +181 -0
- package/dist/src/generate/natidAmOc.js.map +1 -0
- package/dist/src/generate/natidAsia.d.ts +20 -0
- package/dist/src/generate/natidAsia.d.ts.map +1 -0
- package/dist/src/generate/natidAsia.js +147 -0
- package/dist/src/generate/natidAsia.js.map +1 -0
- package/dist/src/generate/natidCee.d.ts +21 -0
- package/dist/src/generate/natidCee.d.ts.map +1 -0
- package/dist/src/generate/natidCee.js +181 -0
- package/dist/src/generate/natidCee.js.map +1 -0
- package/dist/src/generate/natidMeCis.d.ts +17 -0
- package/dist/src/generate/natidMeCis.d.ts.map +1 -0
- package/dist/src/generate/natidMeCis.js +121 -0
- package/dist/src/generate/natidMeCis.js.map +1 -0
- package/dist/src/generate/natidWest.d.ts +32 -0
- package/dist/src/generate/natidWest.d.ts.map +1 -0
- package/dist/src/generate/natidWest.js +187 -0
- package/dist/src/generate/natidWest.js.map +1 -0
- package/dist/src/generate/prng.d.ts +10 -0
- package/dist/src/generate/prng.d.ts.map +1 -0
- package/dist/src/generate/prng.js +18 -0
- package/dist/src/generate/prng.js.map +1 -0
- package/dist/src/generate/secrets.d.ts +23 -0
- package/dist/src/generate/secrets.d.ts.map +1 -0
- package/dist/src/generate/secrets.js +126 -0
- package/dist/src/generate/secrets.js.map +1 -0
- package/dist/src/generate/vat.d.ts +11 -0
- package/dist/src/generate/vat.d.ts.map +1 -0
- package/dist/src/generate/vat.js +233 -0
- package/dist/src/generate/vat.js.map +1 -0
- package/dist/src/index.d.ts +81 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +76 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mask/egressGuard.d.ts +54 -0
- package/dist/src/mask/egressGuard.d.ts.map +1 -0
- package/dist/src/mask/egressGuard.js +67 -0
- package/dist/src/mask/egressGuard.js.map +1 -0
- package/dist/src/mask/masker.d.ts +76 -0
- package/dist/src/mask/masker.d.ts.map +1 -0
- package/dist/src/mask/masker.js +201 -0
- package/dist/src/mask/masker.js.map +1 -0
- package/dist/src/mask/restorer.d.ts +96 -0
- package/dist/src/mask/restorer.d.ts.map +1 -0
- package/dist/src/mask/restorer.js +263 -0
- package/dist/src/mask/restorer.js.map +1 -0
- package/dist/src/mask/surrogatePools.d.ts +33 -0
- package/dist/src/mask/surrogatePools.d.ts.map +1 -0
- package/dist/src/mask/surrogatePools.js +81 -0
- package/dist/src/mask/surrogatePools.js.map +1 -0
- package/dist/src/mask/surrogates.d.ts +45 -0
- package/dist/src/mask/surrogates.d.ts.map +1 -0
- package/dist/src/mask/surrogates.js +241 -0
- package/dist/src/mask/surrogates.js.map +1 -0
- package/dist/src/mask/vault.d.ts +76 -0
- package/dist/src/mask/vault.d.ts.map +1 -0
- package/dist/src/mask/vault.js +141 -0
- package/dist/src/mask/vault.js.map +1 -0
- package/dist/src/ner/align.d.ts +36 -0
- package/dist/src/ner/align.d.ts.map +1 -0
- package/dist/src/ner/align.js +73 -0
- package/dist/src/ner/align.js.map +1 -0
- package/dist/src/ner/chunk.d.ts +27 -0
- package/dist/src/ner/chunk.d.ts.map +1 -0
- package/dist/src/ner/chunk.js +55 -0
- package/dist/src/ner/chunk.js.map +1 -0
- package/dist/src/ner/chunkCache.d.ts +63 -0
- package/dist/src/ner/chunkCache.d.ts.map +1 -0
- package/dist/src/ner/chunkCache.js +99 -0
- package/dist/src/ner/chunkCache.js.map +1 -0
- package/dist/src/ner/engine.d.ts +53 -0
- package/dist/src/ner/engine.d.ts.map +1 -0
- package/dist/src/ner/engine.js +113 -0
- package/dist/src/ner/engine.js.map +1 -0
- package/dist/src/ner/merge.d.ts +26 -0
- package/dist/src/ner/merge.d.ts.map +1 -0
- package/dist/src/ner/merge.js +108 -0
- package/dist/src/ner/merge.js.map +1 -0
- package/dist/src/ner/runStage2.d.ts +17 -0
- package/dist/src/ner/runStage2.d.ts.map +1 -0
- package/dist/src/ner/runStage2.js +43 -0
- package/dist/src/ner/runStage2.js.map +1 -0
- package/dist/src/ner/stage2b.d.ts +59 -0
- package/dist/src/ner/stage2b.d.ts.map +1 -0
- package/dist/src/ner/stage2b.js +51 -0
- package/dist/src/ner/stage2b.js.map +1 -0
- package/dist/src/ner/transformersClassifier.d.ts +45 -0
- package/dist/src/ner/transformersClassifier.d.ts.map +1 -0
- package/dist/src/ner/transformersClassifier.js +40 -0
- package/dist/src/ner/transformersClassifier.js.map +1 -0
- package/dist/src/ner/types.d.ts +93 -0
- package/dist/src/ner/types.d.ts.map +1 -0
- package/dist/src/ner/types.js +12 -0
- package/dist/src/ner/types.js.map +1 -0
- package/dist/src/normalization.d.ts +24 -0
- package/dist/src/normalization.d.ts.map +1 -0
- package/dist/src/normalization.js +92 -0
- package/dist/src/normalization.js.map +1 -0
- package/dist/src/offsetMap.d.ts +165 -0
- package/dist/src/offsetMap.d.ts.map +1 -0
- package/dist/src/offsetMap.js +225 -0
- package/dist/src/offsetMap.js.map +1 -0
- package/dist/src/pipeline.d.ts +58 -0
- package/dist/src/pipeline.d.ts.map +1 -0
- package/dist/src/pipeline.js +57 -0
- package/dist/src/pipeline.js.map +1 -0
- package/dist/src/protect.d.ts +146 -0
- package/dist/src/protect.d.ts.map +1 -0
- package/dist/src/protect.js +161 -0
- package/dist/src/protect.js.map +1 -0
- package/dist/src/scripts.d.ts +37 -0
- package/dist/src/scripts.d.ts.map +1 -0
- package/dist/src/scripts.js +145 -0
- package/dist/src/scripts.js.map +1 -0
- package/dist/src/transforms/foldDigits.d.ts +49 -0
- package/dist/src/transforms/foldDigits.d.ts.map +1 -0
- package/dist/src/transforms/foldDigits.js +135 -0
- package/dist/src/transforms/foldDigits.js.map +1 -0
- package/dist/src/transforms/graphemes.d.ts +6 -0
- package/dist/src/transforms/graphemes.d.ts.map +1 -0
- package/dist/src/transforms/graphemes.js +6 -0
- package/dist/src/transforms/graphemes.js.map +1 -0
- package/dist/src/transforms/homoglyphFold.d.ts +5 -0
- package/dist/src/transforms/homoglyphFold.d.ts.map +1 -0
- package/dist/src/transforms/homoglyphFold.js +214 -0
- package/dist/src/transforms/homoglyphFold.js.map +1 -0
- package/dist/src/transforms/nfkc.d.ts +20 -0
- package/dist/src/transforms/nfkc.d.ts.map +1 -0
- package/dist/src/transforms/nfkc.js +48 -0
- package/dist/src/transforms/nfkc.js.map +1 -0
- package/dist/src/transforms/stripInvisibles.d.ts +37 -0
- package/dist/src/transforms/stripInvisibles.d.ts.map +1 -0
- package/dist/src/transforms/stripInvisibles.js +151 -0
- package/dist/src/transforms/stripInvisibles.js.map +1 -0
- package/dist/src/transforms/whitespacePunct.d.ts +21 -0
- package/dist/src/transforms/whitespacePunct.d.ts.map +1 -0
- package/dist/src/transforms/whitespacePunct.js +100 -0
- package/dist/src/transforms/whitespacePunct.js.map +1 -0
- package/dist/src/types.d.ts +212 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +14 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +67 -0
- package/src/checksums/aba.ts +45 -0
- package/src/checksums/digits.ts +108 -0
- package/src/checksums/icao9303.ts +53 -0
- package/src/checksums/index.ts +36 -0
- package/src/checksums/iso7064.ts +168 -0
- package/src/checksums/luhn.ts +66 -0
- package/src/checksums/mod97.ts +91 -0
- package/src/checksums/verhoeff.ts +84 -0
- package/src/checksums/weighted.ts +108 -0
- package/src/context/documentProfile.ts +293 -0
- package/src/context/negativeRules.ts +765 -0
- package/src/context/score.ts +430 -0
- package/src/context/structure.ts +611 -0
- package/src/context/triggers.ts +266 -0
- package/src/context/types.ts +150 -0
- package/src/crypto/keccak256.ts +98 -0
- package/src/crypto/sha256.ts +76 -0
- package/src/detect/AUTHORING.md +50 -0
- package/src/detect/detectors/bankcodes/auBsb.ts +36 -0
- package/src/detect/detectors/bankcodes/brAgencia.ts +46 -0
- package/src/detect/detectors/bankcodes/caTransit.ts +89 -0
- package/src/detect/detectors/bankcodes/inIfsc.ts +40 -0
- package/src/detect/detectors/bankcodes/index.ts +9 -0
- package/src/detect/detectors/bankcodes/ukSortCode.ts +38 -0
- package/src/detect/detectors/bankcodes/usRouting.ts +47 -0
- package/src/detect/detectors/contact/email.ts +113 -0
- package/src/detect/detectors/contact/index.ts +10 -0
- package/src/detect/detectors/contact/ipv4.ts +112 -0
- package/src/detect/detectors/contact/ipv6.ts +188 -0
- package/src/detect/detectors/contact/mac.ts +68 -0
- package/src/detect/detectors/contact/phone.ts +81 -0
- package/src/detect/detectors/contact/urlCredentials.ts +124 -0
- package/src/detect/detectors/crypto/ada.ts +52 -0
- package/src/detect/detectors/crypto/btc.ts +77 -0
- package/src/detect/detectors/crypto/dot.ts +42 -0
- package/src/detect/detectors/crypto/eth.ts +70 -0
- package/src/detect/detectors/crypto/index.ts +11 -0
- package/src/detect/detectors/crypto/ltc.ts +69 -0
- package/src/detect/detectors/crypto/sol.ts +41 -0
- package/src/detect/detectors/crypto/trx.ts +35 -0
- package/src/detect/detectors/crypto/xmr.ts +54 -0
- package/src/detect/detectors/documents/driversLicense.ts +83 -0
- package/src/detect/detectors/documents/healthData.ts +88 -0
- package/src/detect/detectors/documents/index.ts +8 -0
- package/src/detect/detectors/documents/passportMrz.ts +203 -0
- package/src/detect/detectors/documents/usNpi.ts +50 -0
- package/src/detect/detectors/documents/vin.ts +67 -0
- package/src/detect/detectors/financial/creditCard.ts +167 -0
- package/src/detect/detectors/financial/iban.ts +82 -0
- package/src/detect/detectors/financial/ibanRegistry.ts +112 -0
- package/src/detect/detectors/financial/index.ts +6 -0
- package/src/detect/detectors/financial/swiftBic.ts +61 -0
- package/src/detect/detectors/index.ts +14 -0
- package/src/detect/detectors/location/coordinates.ts +84 -0
- package/src/detect/detectors/location/index.ts +6 -0
- package/src/detect/detectors/location/postalCode.ts +56 -0
- package/src/detect/detectors/location/postalRegistry.ts +74 -0
- package/src/detect/detectors/location/streetAddress.ts +84 -0
- package/src/detect/detectors/natid/africa.ts +108 -0
- package/src/detect/detectors/natid/ar.ts +62 -0
- package/src/detect/detectors/natid/au.ts +99 -0
- package/src/detect/detectors/natid/be.ts +45 -0
- package/src/detect/detectors/natid/bg.ts +44 -0
- package/src/detect/detectors/natid/br.ts +81 -0
- package/src/detect/detectors/natid/ca.ts +40 -0
- package/src/detect/detectors/natid/cl.ts +47 -0
- package/src/detect/detectors/natid/cn.ts +48 -0
- package/src/detect/detectors/natid/co.ts +46 -0
- package/src/detect/detectors/natid/cz.ts +44 -0
- package/src/detect/detectors/natid/de.ts +75 -0
- package/src/detect/detectors/natid/dk.ts +31 -0
- package/src/detect/detectors/natid/es.ts +95 -0
- package/src/detect/detectors/natid/fi.ts +41 -0
- package/src/detect/detectors/natid/fr.ts +63 -0
- package/src/detect/detectors/natid/gb.ts +70 -0
- package/src/detect/detectors/natid/gr.ts +35 -0
- package/src/detect/detectors/natid/gulf.ts +116 -0
- package/src/detect/detectors/natid/hk.ts +42 -0
- package/src/detect/detectors/natid/hr.ts +32 -0
- package/src/detect/detectors/natid/hu.ts +36 -0
- package/src/detect/detectors/natid/ie.ts +37 -0
- package/src/detect/detectors/natid/il.ts +37 -0
- package/src/detect/detectors/natid/in.ts +67 -0
- package/src/detect/detectors/natid/index.ts +54 -0
- package/src/detect/detectors/natid/is.ts +42 -0
- package/src/detect/detectors/natid/it.ts +65 -0
- package/src/detect/detectors/natid/jp.ts +48 -0
- package/src/detect/detectors/natid/kr.ts +41 -0
- package/src/detect/detectors/natid/kz.ts +44 -0
- package/src/detect/detectors/natid/mx.ts +83 -0
- package/src/detect/detectors/natid/nl.ts +38 -0
- package/src/detect/detectors/natid/no.ts +50 -0
- package/src/detect/detectors/natid/nz.ts +53 -0
- package/src/detect/detectors/natid/pe.ts +28 -0
- package/src/detect/detectors/natid/pl.ts +100 -0
- package/src/detect/detectors/natid/pt.ts +36 -0
- package/src/detect/detectors/natid/ro.ts +47 -0
- package/src/detect/detectors/natid/ru.ts +82 -0
- package/src/detect/detectors/natid/se.ts +42 -0
- package/src/detect/detectors/natid/seasia.ts +174 -0
- package/src/detect/detectors/natid/sg.ts +39 -0
- package/src/detect/detectors/natid/si.ts +42 -0
- package/src/detect/detectors/natid/tr.ts +76 -0
- package/src/detect/detectors/natid/tw.ts +41 -0
- package/src/detect/detectors/natid/ua.ts +38 -0
- package/src/detect/detectors/natid/us.ts +118 -0
- package/src/detect/detectors/natid/za.ts +42 -0
- package/src/detect/detectors/secrets/apiKey.ts +115 -0
- package/src/detect/detectors/secrets/connectionString.ts +71 -0
- package/src/detect/detectors/secrets/genericSecret.ts +81 -0
- package/src/detect/detectors/secrets/index.ts +8 -0
- package/src/detect/detectors/secrets/jwt.ts +101 -0
- package/src/detect/detectors/secrets/pemPrivateKey.ts +59 -0
- package/src/detect/detectors/vat/euVat.ts +280 -0
- package/src/detect/detectors/vat/index.ts +4 -0
- package/src/detect/entropy.ts +60 -0
- package/src/detect/isoCountries.ts +30 -0
- package/src/detect/registry.ts +134 -0
- package/src/detect/runner.ts +187 -0
- package/src/detect/types.ts +296 -0
- package/src/encoding/base58.ts +85 -0
- package/src/encoding/base58monero.ts +90 -0
- package/src/encoding/bech32.ts +125 -0
- package/src/encoding/bytes.ts +48 -0
- package/src/entityFamily.ts +70 -0
- package/src/entityLabel.ts +56 -0
- package/src/entityTypes.ts +107 -0
- package/src/exposure/index.ts +189 -0
- package/src/fuse/calibrate.ts +224 -0
- package/src/fuse/defaultCalibration.ts +71 -0
- package/src/fuse/explain.ts +114 -0
- package/src/fuse/profiles.ts +187 -0
- package/src/fuse/resolve.ts +237 -0
- package/src/gazetteer/index.ts +139 -0
- package/src/generate/bankcodes.ts +82 -0
- package/src/generate/contact.ts +147 -0
- package/src/generate/crypto.ts +91 -0
- package/src/generate/documents.ts +142 -0
- package/src/generate/financial.ts +149 -0
- package/src/generate/index.ts +22 -0
- package/src/generate/location.ts +80 -0
- package/src/generate/natidAmOc.ts +198 -0
- package/src/generate/natidAsia.ts +162 -0
- package/src/generate/natidCee.ts +196 -0
- package/src/generate/natidMeCis.ts +131 -0
- package/src/generate/natidWest.ts +208 -0
- package/src/generate/prng.ts +17 -0
- package/src/generate/secrets.ts +141 -0
- package/src/generate/vat.ts +239 -0
- package/src/index.ts +186 -0
- package/src/mask/egressGuard.ts +88 -0
- package/src/mask/masker.ts +276 -0
- package/src/mask/restorer.ts +284 -0
- package/src/mask/surrogatePools.ts +96 -0
- package/src/mask/surrogates.ts +248 -0
- package/src/mask/vault.ts +153 -0
- package/src/ner/align.ts +86 -0
- package/src/ner/chunk.ts +65 -0
- package/src/ner/chunkCache.ts +110 -0
- package/src/ner/engine.ts +141 -0
- package/src/ner/merge.ts +123 -0
- package/src/ner/runStage2.ts +51 -0
- package/src/ner/stage2b.ts +73 -0
- package/src/ner/transformersClassifier.ts +79 -0
- package/src/ner/types.ts +99 -0
- package/src/normalization.ts +119 -0
- package/src/offsetMap.ts +271 -0
- package/src/pipeline.ts +96 -0
- package/src/protect.ts +284 -0
- package/src/scripts.ts +164 -0
- package/src/transforms/foldDigits.ts +138 -0
- package/src/transforms/graphemes.ts +5 -0
- package/src/transforms/homoglyphFold.ts +221 -0
- package/src/transforms/nfkc.ts +48 -0
- package/src/transforms/stripInvisibles.ts +158 -0
- package/src/transforms/whitespacePunct.ts +100 -0
- 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
|
+
}
|