@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,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The EXPOSURE SCORE.
|
|
3
|
+
*
|
|
4
|
+
* SPEC.md: "A document-level, user-facing sensitivity summary, computed in
|
|
5
|
+
* core … EXPLAINABLE BY CONSTRUCTION: a deterministic aggregation of
|
|
6
|
+
* calibrated confidence × category severity weight × per-type factors, and the
|
|
7
|
+
* report decomposes the total into named contributions. A score that cannot
|
|
8
|
+
* show its work is not acceptable."
|
|
9
|
+
*
|
|
10
|
+
* MONOTONICITY IS STRUCTURAL, NOT INCIDENTAL. SPEC requires that adding a
|
|
11
|
+
* detected entity never lowers the score and removing one never raises it. The
|
|
12
|
+
* aggregation below is a sum of non-negative per-entity contributions passed
|
|
13
|
+
* through a saturating transform that is strictly increasing. Both halves
|
|
14
|
+
* matter: if a contribution could be negative, or the transform could
|
|
15
|
+
* decrease, the property would fail. It is therefore not something to test for
|
|
16
|
+
* and hope — it holds because of the shape of the arithmetic, and the test
|
|
17
|
+
* exists to catch a future change that breaks the shape.
|
|
18
|
+
*
|
|
19
|
+
* WHY SATURATION AT ALL. A raw sum is unbounded and unreadable: a document
|
|
20
|
+
* with forty identifiers would score in the thousands and mean nothing to a
|
|
21
|
+
* user. The score is mapped into 0–100 by a saturating curve so that "how
|
|
22
|
+
* exposed is this document" stays comparable between a short message and a
|
|
23
|
+
* long one. Saturation is strictly increasing, so monotonicity survives it —
|
|
24
|
+
* a fortieth entity adds less than the first, but it never adds less than
|
|
25
|
+
* nothing.
|
|
26
|
+
*
|
|
27
|
+
* THE LIMITATION, which SPEC requires be stated wherever the score is shown,
|
|
28
|
+
* travels with the report itself rather than living only in the UI: see
|
|
29
|
+
* `ExposureReport.limitation`.
|
|
30
|
+
*/
|
|
31
|
+
import { CATEGORY_OF, SEVERITY_WEIGHTS, TYPE_FACTORS } from '@discretion/data';
|
|
32
|
+
/** The minimum an entity needs to contribute anything at all. */
|
|
33
|
+
const MIN_CONFIDENCE = 0.05;
|
|
34
|
+
/**
|
|
35
|
+
* Sum at which the score reaches ~63 of 100.
|
|
36
|
+
*
|
|
37
|
+
* Chosen so that ONE maximally severe, fully confident entity — a certain
|
|
38
|
+
* national identity number, contributing 100 — already lands near 63, i.e.
|
|
39
|
+
* "seriously exposed". A document does not need to be full of identifiers to
|
|
40
|
+
* read as dangerous, because it is not: one leaked identity number is the
|
|
41
|
+
* whole problem.
|
|
42
|
+
*/
|
|
43
|
+
const SATURATION_SCALE = 100;
|
|
44
|
+
export const EXPOSURE_LIMITATION = 'This score summarizes what detection found. It inherits every detection ' +
|
|
45
|
+
'limitation, and a low score is not a guarantee of safety.';
|
|
46
|
+
/** How many contributors the report highlights. */
|
|
47
|
+
const TOP_N = 5;
|
|
48
|
+
function contributionFor(entity) {
|
|
49
|
+
const confidence = Math.min(1, Math.max(0, entity.calibratedConfidence));
|
|
50
|
+
if (confidence < MIN_CONFIDENCE)
|
|
51
|
+
return undefined;
|
|
52
|
+
const category = CATEGORY_OF[entity.type];
|
|
53
|
+
if (category === undefined)
|
|
54
|
+
return undefined;
|
|
55
|
+
const weight = SEVERITY_WEIGHTS[category].weight;
|
|
56
|
+
const factor = TYPE_FACTORS[entity.type]?.factor ?? 1;
|
|
57
|
+
const points = confidence * weight * factor;
|
|
58
|
+
return {
|
|
59
|
+
type: entity.type,
|
|
60
|
+
category,
|
|
61
|
+
confidence,
|
|
62
|
+
weight,
|
|
63
|
+
factor,
|
|
64
|
+
points,
|
|
65
|
+
detail: `${entity.type} at ${(confidence * 100).toFixed(0)}% confidence × ${weight} (${category})${factor === 1 ? '' : ` × ${factor}`}`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Saturating map from an unbounded points sum to 0–100.
|
|
70
|
+
*
|
|
71
|
+
* `1 - e^(-x/scale)` is strictly increasing on x ≥ 0 and asymptotic to 1, so
|
|
72
|
+
* it bounds the score without ever letting an added entity reduce it. Strict
|
|
73
|
+
* increase is the property monotonicity depends on; a curve that plateaued
|
|
74
|
+
* exactly would satisfy "never lowers" but would stop distinguishing
|
|
75
|
+
* documents, and one that overshot would break it.
|
|
76
|
+
*/
|
|
77
|
+
function saturate(points) {
|
|
78
|
+
return 100 * (1 - Math.exp(-points / SATURATION_SCALE));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Compute a document's exposure.
|
|
82
|
+
*
|
|
83
|
+
* Deterministic: the same entities in any order produce the same score, which
|
|
84
|
+
* matters because the report is shown to a user and must not flicker as
|
|
85
|
+
* detection order changes.
|
|
86
|
+
*/
|
|
87
|
+
export function computeExposure(entities) {
|
|
88
|
+
const contributions = entities
|
|
89
|
+
.map(contributionFor)
|
|
90
|
+
.filter((c) => c !== undefined);
|
|
91
|
+
const rawPoints = contributions.reduce((sum, c) => sum + c.points, 0);
|
|
92
|
+
const byCategoryMap = new Map();
|
|
93
|
+
for (const c of contributions) {
|
|
94
|
+
const acc = byCategoryMap.get(c.category) ?? { entities: 0, points: 0 };
|
|
95
|
+
acc.entities += 1;
|
|
96
|
+
acc.points += c.points;
|
|
97
|
+
byCategoryMap.set(c.category, acc);
|
|
98
|
+
}
|
|
99
|
+
const byCategory = [...byCategoryMap.entries()]
|
|
100
|
+
.map(([category, acc]) => ({
|
|
101
|
+
category,
|
|
102
|
+
entities: acc.entities,
|
|
103
|
+
points: acc.points,
|
|
104
|
+
share: rawPoints === 0 ? 0 : acc.points / rawPoints,
|
|
105
|
+
}))
|
|
106
|
+
.sort((a, b) => b.points - a.points || a.category.localeCompare(b.category));
|
|
107
|
+
const topContributors = [...contributions]
|
|
108
|
+
.sort((a, b) => b.points - a.points || a.type.localeCompare(b.type))
|
|
109
|
+
.slice(0, TOP_N);
|
|
110
|
+
return {
|
|
111
|
+
score: saturate(rawPoints),
|
|
112
|
+
rawPoints,
|
|
113
|
+
byCategory,
|
|
114
|
+
topContributors,
|
|
115
|
+
contributions,
|
|
116
|
+
limitation: EXPOSURE_LIMITATION,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A band for presentation. Thresholds are presentational only — every decision
|
|
121
|
+
* the pipeline makes uses calibrated confidence, never this label.
|
|
122
|
+
*/
|
|
123
|
+
export function exposureBand(score) {
|
|
124
|
+
if (score <= 0)
|
|
125
|
+
return 'none';
|
|
126
|
+
if (score < 20)
|
|
127
|
+
return 'low';
|
|
128
|
+
if (score < 45)
|
|
129
|
+
return 'moderate';
|
|
130
|
+
if (score < 70)
|
|
131
|
+
return 'high';
|
|
132
|
+
return 'severe';
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exposure/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAyB,MAAM,kBAAkB,CAAC;AAGtG,iEAAiE;AACjE,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B;;;;;;;;GAQG;AACH,MAAM,gBAAgB,GAAG,GAAG,CAAC;AA6C7B,MAAM,CAAC,MAAM,mBAAmB,GAC9B,0EAA0E;IAC1E,2DAA2D,CAAC;AAE9D,mDAAmD;AACnD,MAAM,KAAK,GAAG,CAAC,CAAC;AAEhB,SAAS,eAAe,CAAC,MAAqB;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;IACzE,IAAI,UAAU,GAAG,cAAc;QAAE,OAAO,SAAS,CAAC;IAElD,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE7C,MAAM,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;IACjD,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;IAE5C,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,QAAQ;QACR,UAAU;QACV,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM,EAAE,GAAG,MAAM,CAAC,IAA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|
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
|
+
import type { EntityType } from '../types.js';
|
|
36
|
+
/** One step of a fitted curve: scores in [from, to) map to `precision`. */
|
|
37
|
+
export interface CalibrationBin {
|
|
38
|
+
readonly from: number;
|
|
39
|
+
readonly to: number;
|
|
40
|
+
/** Empirical precision of candidates whose raw score fell in this bin. */
|
|
41
|
+
readonly precision: number;
|
|
42
|
+
/** How many candidates the step was fitted on, for reporting weight. */
|
|
43
|
+
readonly samples: number;
|
|
44
|
+
}
|
|
45
|
+
export interface CalibrationCurve {
|
|
46
|
+
readonly bins: readonly CalibrationBin[];
|
|
47
|
+
readonly samples: number;
|
|
48
|
+
}
|
|
49
|
+
export interface CalibrationModel {
|
|
50
|
+
/** Per-type curves. Types absent here use `pooled`. */
|
|
51
|
+
readonly perType: Readonly<Partial<Record<EntityType, CalibrationCurve>>>;
|
|
52
|
+
/** Fallback for types with too little data to fit their own curve. */
|
|
53
|
+
readonly pooled: CalibrationCurve;
|
|
54
|
+
/** Documents the model was fitted on, for the split statement. */
|
|
55
|
+
readonly fittedOn: string;
|
|
56
|
+
}
|
|
57
|
+
/** One observation: a candidate's raw score and whether it was correct. */
|
|
58
|
+
export interface CalibrationSample {
|
|
59
|
+
readonly type: EntityType;
|
|
60
|
+
readonly score: number;
|
|
61
|
+
readonly correct: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** Fit a calibration model from labelled observations. */
|
|
64
|
+
export declare function fitCalibration(samples: readonly CalibrationSample[], fittedOn: string): CalibrationModel;
|
|
65
|
+
/**
|
|
66
|
+
* Map a raw score to a calibrated probability.
|
|
67
|
+
*
|
|
68
|
+
* PIECEWISE CONSTANT — the containing step's empirical precision, which is the
|
|
69
|
+
* standard prediction for an isotonic fit. An earlier revision interpolated
|
|
70
|
+
* between step midpoints to smooth the output, and that was an embellishment
|
|
71
|
+
* with no justification behind it: because the step function is coarse where
|
|
72
|
+
* data is sparse, interpolating systematically pulled predictions toward the
|
|
73
|
+
* step below and left the model under-confident through 0.7-0.8. Returning the
|
|
74
|
+
* step's own measured precision is both the standard method and the one whose
|
|
75
|
+
* meaning is readable — "candidates in this band were right this often".
|
|
76
|
+
*/
|
|
77
|
+
export declare function calibrate(model: CalibrationModel, type: EntityType, score: number): number;
|
|
78
|
+
/** A reliability-curve row: what the model promised versus what happened. */
|
|
79
|
+
export interface ReliabilityPoint {
|
|
80
|
+
readonly bucket: string;
|
|
81
|
+
readonly predicted: number;
|
|
82
|
+
readonly observed: number;
|
|
83
|
+
readonly samples: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Measure a fitted model against HELD-OUT observations.
|
|
87
|
+
*
|
|
88
|
+
* This is the number that means something: a curve scored on the documents it
|
|
89
|
+
* was fitted on measures memorisation, not calibration.
|
|
90
|
+
*/
|
|
91
|
+
export declare function reliability(model: CalibrationModel, heldOut: readonly CalibrationSample[], buckets?: number): {
|
|
92
|
+
readonly points: readonly ReliabilityPoint[];
|
|
93
|
+
readonly expectedCalibrationError: number;
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=calibrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calibrate.d.ts","sourceRoot":"","sources":["../../../src/fuse/calibrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,SAAS,cAAc,EAAE,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC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+
/**
|
|
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
|
+
/** Bins per curve. Ten keeps each step readable and populated. */
|
|
36
|
+
const BIN_COUNT = 10;
|
|
37
|
+
/**
|
|
38
|
+
* Minimum samples before a type gets its own curve.
|
|
39
|
+
*
|
|
40
|
+
* Below this the per-type curve would be fitted on noise, and a confidently
|
|
41
|
+
* wrong calibration is worse than an honest pooled one.
|
|
42
|
+
*/
|
|
43
|
+
const MIN_SAMPLES_PER_TYPE = 200;
|
|
44
|
+
/**
|
|
45
|
+
* Pool adjacent violators: the isotonic regression fit.
|
|
46
|
+
*
|
|
47
|
+
* Walks left to right merging any bin whose precision is below its left
|
|
48
|
+
* neighbour, which yields the closest non-decreasing sequence in least
|
|
49
|
+
* squares. The merge is sample-weighted, so a large well-measured bin is not
|
|
50
|
+
* dragged by a tiny noisy one.
|
|
51
|
+
*/
|
|
52
|
+
function poolAdjacentViolators(raw) {
|
|
53
|
+
const stack = [];
|
|
54
|
+
for (const bin of raw) {
|
|
55
|
+
if (bin.total === 0)
|
|
56
|
+
continue;
|
|
57
|
+
stack.push({ ...bin });
|
|
58
|
+
// Merge backwards while the sequence decreases.
|
|
59
|
+
while (stack.length > 1) {
|
|
60
|
+
const right = stack[stack.length - 1];
|
|
61
|
+
const left = stack[stack.length - 2];
|
|
62
|
+
if (left.correct / left.total <= right.correct / right.total)
|
|
63
|
+
break;
|
|
64
|
+
stack.splice(stack.length - 2, 2, {
|
|
65
|
+
from: left.from,
|
|
66
|
+
to: right.to,
|
|
67
|
+
correct: left.correct + right.correct,
|
|
68
|
+
total: left.total + right.total,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return stack.map((b) => ({
|
|
73
|
+
from: b.from,
|
|
74
|
+
to: b.to,
|
|
75
|
+
precision: b.correct / b.total,
|
|
76
|
+
samples: b.total,
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
function fitCurve(samples) {
|
|
80
|
+
const raw = Array.from({ length: BIN_COUNT }, (_, i) => ({
|
|
81
|
+
from: i / BIN_COUNT,
|
|
82
|
+
to: (i + 1) / BIN_COUNT,
|
|
83
|
+
correct: 0,
|
|
84
|
+
total: 0,
|
|
85
|
+
}));
|
|
86
|
+
for (const s of samples) {
|
|
87
|
+
const index = Math.min(BIN_COUNT - 1, Math.max(0, Math.floor(s.score * BIN_COUNT)));
|
|
88
|
+
const bin = raw[index];
|
|
89
|
+
bin.total += 1;
|
|
90
|
+
if (s.correct)
|
|
91
|
+
bin.correct += 1;
|
|
92
|
+
}
|
|
93
|
+
return { bins: poolAdjacentViolators(raw), samples: samples.length };
|
|
94
|
+
}
|
|
95
|
+
/** Fit a calibration model from labelled observations. */
|
|
96
|
+
export function fitCalibration(samples, fittedOn) {
|
|
97
|
+
const byType = new Map();
|
|
98
|
+
for (const s of samples) {
|
|
99
|
+
const list = byType.get(s.type) ?? [];
|
|
100
|
+
list.push(s);
|
|
101
|
+
byType.set(s.type, list);
|
|
102
|
+
}
|
|
103
|
+
const perType = {};
|
|
104
|
+
for (const [type, list] of byType) {
|
|
105
|
+
if (list.length >= MIN_SAMPLES_PER_TYPE)
|
|
106
|
+
perType[type] = fitCurve(list);
|
|
107
|
+
}
|
|
108
|
+
return { perType, pooled: fitCurve(samples), fittedOn };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Map a raw score to a calibrated probability.
|
|
112
|
+
*
|
|
113
|
+
* PIECEWISE CONSTANT — the containing step's empirical precision, which is the
|
|
114
|
+
* standard prediction for an isotonic fit. An earlier revision interpolated
|
|
115
|
+
* between step midpoints to smooth the output, and that was an embellishment
|
|
116
|
+
* with no justification behind it: because the step function is coarse where
|
|
117
|
+
* data is sparse, interpolating systematically pulled predictions toward the
|
|
118
|
+
* step below and left the model under-confident through 0.7-0.8. Returning the
|
|
119
|
+
* step's own measured precision is both the standard method and the one whose
|
|
120
|
+
* meaning is readable — "candidates in this band were right this often".
|
|
121
|
+
*/
|
|
122
|
+
export function calibrate(model, type, score) {
|
|
123
|
+
const curve = model.perType[type] ?? model.pooled;
|
|
124
|
+
if (curve.bins.length === 0)
|
|
125
|
+
return score;
|
|
126
|
+
const clamped = Math.min(1, Math.max(0, score));
|
|
127
|
+
const index = curve.bins.findIndex((b) => clamped < b.to);
|
|
128
|
+
const bin = curve.bins[index === -1 ? curve.bins.length - 1 : index];
|
|
129
|
+
return bin.precision;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Measure a fitted model against HELD-OUT observations.
|
|
133
|
+
*
|
|
134
|
+
* This is the number that means something: a curve scored on the documents it
|
|
135
|
+
* was fitted on measures memorisation, not calibration.
|
|
136
|
+
*/
|
|
137
|
+
export function reliability(model, heldOut, buckets = 10) {
|
|
138
|
+
const acc = Array.from({ length: buckets }, () => ({ predicted: 0, correct: 0, total: 0 }));
|
|
139
|
+
for (const s of heldOut) {
|
|
140
|
+
const p = calibrate(model, s.type, s.score);
|
|
141
|
+
const index = Math.min(buckets - 1, Math.max(0, Math.floor(p * buckets)));
|
|
142
|
+
const bucket = acc[index];
|
|
143
|
+
bucket.predicted += p;
|
|
144
|
+
bucket.total += 1;
|
|
145
|
+
if (s.correct)
|
|
146
|
+
bucket.correct += 1;
|
|
147
|
+
}
|
|
148
|
+
const points = [];
|
|
149
|
+
let error = 0;
|
|
150
|
+
for (const [i, b] of acc.entries()) {
|
|
151
|
+
if (b.total === 0)
|
|
152
|
+
continue;
|
|
153
|
+
const predicted = b.predicted / b.total;
|
|
154
|
+
const observed = b.correct / b.total;
|
|
155
|
+
points.push({
|
|
156
|
+
bucket: `${(i / buckets).toFixed(1)}–${((i + 1) / buckets).toFixed(1)}`,
|
|
157
|
+
predicted,
|
|
158
|
+
observed,
|
|
159
|
+
samples: b.total,
|
|
160
|
+
});
|
|
161
|
+
error += (b.total / heldOut.length) * Math.abs(predicted - observed);
|
|
162
|
+
}
|
|
163
|
+
return { points, expectedCalibrationError: error };
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=calibrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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AC,CAAC,KAAK,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC;YACV,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACvE,SAAS;YACT,QAAQ;YACR,OAAO,EAAE,CAAC,CAAC,KAAK;SACjB,CAAC,CAAC;QACH,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,wBAAwB,EAAE,KAAK,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
import type { CalibrationCurve, CalibrationModel } from './calibrate.js';
|
|
22
|
+
/**
|
|
23
|
+
* The generated shape, restated so this module does not depend on data's types.
|
|
24
|
+
*
|
|
25
|
+
* Exported because it is `toCalibrationModel`'s parameter type: a consumer who
|
|
26
|
+
* fits their own model needs to name what the function accepts. It was local
|
|
27
|
+
* when this file was written, and `public-api.test.ts` caught it on its first
|
|
28
|
+
* run - which is the whole reason that test exists.
|
|
29
|
+
*/
|
|
30
|
+
export interface GeneratedCalibrationModel {
|
|
31
|
+
readonly perType: Readonly<Record<string, CalibrationCurve>>;
|
|
32
|
+
readonly pooled: CalibrationCurve;
|
|
33
|
+
readonly fittedOn: string;
|
|
34
|
+
}
|
|
35
|
+
export interface CalibrationConversion {
|
|
36
|
+
readonly model: CalibrationModel;
|
|
37
|
+
/**
|
|
38
|
+
* Keys in the generated model that are not `EntityType` members.
|
|
39
|
+
*
|
|
40
|
+
* Non-empty means the committed model and the union have drifted apart. The
|
|
41
|
+
* conversion still succeeds — dropping an unusable curve is better than
|
|
42
|
+
* refusing to calibrate anything — but the caller can now see it, and
|
|
43
|
+
* `calibration-model.test.ts` asserts it is empty.
|
|
44
|
+
*/
|
|
45
|
+
readonly unknownTypes: readonly string[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Convert a generated calibration model to core's typed one, reporting any key
|
|
49
|
+
* that is not a known entity type instead of assuming there are none.
|
|
50
|
+
*/
|
|
51
|
+
export declare function toCalibrationModel(generated: GeneratedCalibrationModel): CalibrationConversion;
|
|
52
|
+
//# sourceMappingURL=defaultCalibration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultCalibration.d.ts","sourceRoot":"","sources":["../../../src/fuse/defaultCalibration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAC7D,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC;;;;;;;OAOG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,yBAAyB,GAAG,qBAAqB,CAc9F"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
import { ALL_ENTITY_TYPES } from '../entityTypes.js';
|
|
22
|
+
/**
|
|
23
|
+
* Convert a generated calibration model to core's typed one, reporting any key
|
|
24
|
+
* that is not a known entity type instead of assuming there are none.
|
|
25
|
+
*/
|
|
26
|
+
export function toCalibrationModel(generated) {
|
|
27
|
+
const known = new Set(ALL_ENTITY_TYPES);
|
|
28
|
+
const perType = {};
|
|
29
|
+
const unknownTypes = [];
|
|
30
|
+
for (const [key, curve] of Object.entries(generated.perType)) {
|
|
31
|
+
if (known.has(key))
|
|
32
|
+
perType[key] = curve;
|
|
33
|
+
else
|
|
34
|
+
unknownTypes.push(key);
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
model: { perType, pooled: generated.pooled, fittedOn: generated.fittedOn },
|
|
38
|
+
unknownTypes,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=defaultCalibration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultCalibration.js","sourceRoot":"","sources":["../../../src/fuse/defaultCalibration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AA+BrD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAoC;IACrE,MAAM,KAAK,GAAG,IAAI,GAAG,CAAS,gBAAgB,CAAC,CAAC;IAChD,MAAM,OAAO,GAAkD,EAAE,CAAC;IAClE,MAAM,YAAY,GAAa,EAAE,CAAC;IAElC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7D,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,CAAC,GAAiB,CAAC,GAAG,KAAK,CAAC;;YAClD,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE;QAC1E,YAAY;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
import type { DetectedEntity, EntityExplanation, EntityType } from '../types.js';
|
|
22
|
+
import type { ContextScoredCandidate } from '../context/types.js';
|
|
23
|
+
import type { ProfileDecision } from './profiles.js';
|
|
24
|
+
/** What Stage 4 knows about one candidate as it becomes an entity. */
|
|
25
|
+
export interface FusionInput {
|
|
26
|
+
readonly scored: ContextScoredCandidate;
|
|
27
|
+
/** Confidence after calibration; comparable across types. */
|
|
28
|
+
readonly calibratedConfidence: number;
|
|
29
|
+
/** Whether the entity's span was widened by overlap resolution. */
|
|
30
|
+
readonly absorbedOverlap?: boolean;
|
|
31
|
+
/** Types this candidate won an overlap against. */
|
|
32
|
+
readonly wonAgainst?: readonly EntityType[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build the explanation for one entity.
|
|
36
|
+
*
|
|
37
|
+
* `triggers` carries the Stage 3 signal names rather than only lexicon
|
|
38
|
+
* matches, because "why was this reported" is answered as much by
|
|
39
|
+
* `structure:key-names-API_KEY` as by a trigger word — and a reviewer chasing
|
|
40
|
+
* a false positive needs the negative signals too, which is why suppression
|
|
41
|
+
* and penalty signals appear with their sign rather than being filtered out.
|
|
42
|
+
*/
|
|
43
|
+
export declare function explain(input: FusionInput): EntityExplanation;
|
|
44
|
+
/** Assemble the entity a consumer actually receives. */
|
|
45
|
+
export declare function toDetectedEntity(input: FusionInput): DetectedEntity;
|
|
46
|
+
/**
|
|
47
|
+
* A one-line reason a candidate was NOT reported.
|
|
48
|
+
*
|
|
49
|
+
* SPEC's explanation requirement covers emitted entities, but the review UI
|
|
50
|
+
* has to answer "why did you miss this?" too, and a suppression with no
|
|
51
|
+
* recorded reason is exactly the failure D18 was written about. Kept in the
|
|
52
|
+
* same module so the two stay consistent.
|
|
53
|
+
*/
|
|
54
|
+
export declare function explainOmission(scored: ContextScoredCandidate, decision?: ProfileDecision): string;
|
|
55
|
+
//# sourceMappingURL=explain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../../../src/fuse/explain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAkB,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,sEAAsE;AACtE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IACxC,6DAA6D;IAC7D,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,mEAAmE;IACnE,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC,mDAAmD;IACnD,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,iBAAiB,CA4B7D;AAED,wDAAwD;AACxD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAUnE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,sBAAsB,EAC9B,QAAQ,CAAC,EAAE,eAAe,GACzB,MAAM,CAcR"}
|