@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,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* protect.ts — the one-call entry point: text in, masked text and a report out.
|
|
3
|
+
*
|
|
4
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
5
|
+
* WHY THIS EXISTS (M12)
|
|
6
|
+
*
|
|
7
|
+
* Every stage of the pipeline was already exported, and that is not the same
|
|
8
|
+
* as being usable. Getting from a string to "here is the masked text and what
|
|
9
|
+
* was found" meant composing eight core calls in a specific order, holding an
|
|
10
|
+
* identity map between two of them, and importing the fitted calibration model
|
|
11
|
+
* from a SECOND package through an unchecked cast. The extension's
|
|
12
|
+
* `analyzeText` does exactly that in about ninety lines.
|
|
13
|
+
*
|
|
14
|
+
* SPEC's M12 acceptance test is that "a developer who has never seen this repo
|
|
15
|
+
* can npm install the package and run detection and masking from the docs
|
|
16
|
+
* alone". Documenting those ninety lines would satisfy the letter of it and
|
|
17
|
+
* miss the point: the order matters for correctness, not just for convenience,
|
|
18
|
+
* and a consumer who gets it wrong gets quietly worse results rather than an
|
|
19
|
+
* error. Two of the orderings below were bugs found in earlier milestones.
|
|
20
|
+
*
|
|
21
|
+
* The individual stages remain exported. This is the supported path, not the
|
|
22
|
+
* only one.
|
|
23
|
+
*
|
|
24
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
25
|
+
* WHAT `mask()` IS, AND WHY IT IS NOT THIS
|
|
26
|
+
*
|
|
27
|
+
* `mask()` in `mask/masker.ts` also takes a string and returns masked text,
|
|
28
|
+
* and it looks like this function's smaller sibling. It runs STAGE 1 ONLY —
|
|
29
|
+
* no context scoring, no calibration, no profile decision, no NER. It exists
|
|
30
|
+
* for tests and for the playground's Stage-1 baseline. A consumer who reached
|
|
31
|
+
* for it expecting the full engine would get uncalibrated confidences and none
|
|
32
|
+
* of Stage 3's false-positive suppression, with nothing to indicate the
|
|
33
|
+
* difference. `stagesRun` on this function's result is what makes the
|
|
34
|
+
* distinction legible.
|
|
35
|
+
*
|
|
36
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
37
|
+
* FAIL-CLOSED IS THE CALLER'S JOB, AND THIS FUNCTION PRESERVES IT
|
|
38
|
+
*
|
|
39
|
+
* Nothing here catches an error from a stage. `detect` propagates
|
|
40
|
+
* `DetectionTimeoutError` and `DetectorError` deliberately, and so does this.
|
|
41
|
+
* A caller that wrapped it in a try/catch and treated the failure as "nothing
|
|
42
|
+
* found" would have built the exact failure SPEC.md calls a critical bug, so
|
|
43
|
+
* the failure is left where it cannot be mistaken for a result.
|
|
44
|
+
*/
|
|
45
|
+
import { type CalibrationModel } from './fuse/calibrate.js';
|
|
46
|
+
import { type ProfileName, type SensitivityProfile, type UserLists } from './fuse/profiles.js';
|
|
47
|
+
import { Vault } from './mask/vault.js';
|
|
48
|
+
import type { ExposureReport } from './exposure/index.js';
|
|
49
|
+
import type { NerRecognizer } from './ner/types.js';
|
|
50
|
+
import type { DetectionStage, EntityExplanation, EntityType, SubstitutionMode } from './types.js';
|
|
51
|
+
export interface ProtectOptions {
|
|
52
|
+
/**
|
|
53
|
+
* Which findings are worth reporting. A `ProfileName` selects one of the
|
|
54
|
+
* three SPEC profiles; a `SensitivityProfile` supplies your own.
|
|
55
|
+
* Default: `'balanced'`.
|
|
56
|
+
*/
|
|
57
|
+
readonly profile?: ProfileName | SensitivityProfile;
|
|
58
|
+
/** Values to always report (`deny`) or never report (`allow`). */
|
|
59
|
+
readonly lists?: UserLists;
|
|
60
|
+
/**
|
|
61
|
+
* The region used for identifiers that are ambiguous without one.
|
|
62
|
+
*
|
|
63
|
+
* Not a tie-breaker: a phone number written in national form cannot be
|
|
64
|
+
* validated at all without a region, so leaving this unset does not lower
|
|
65
|
+
* its confidence — the detector reports nothing.
|
|
66
|
+
*/
|
|
67
|
+
readonly defaultRegion?: string;
|
|
68
|
+
/** Per-type opt-out, applied before a surrogate is minted. */
|
|
69
|
+
readonly typeAllowed?: (type: EntityType) => boolean;
|
|
70
|
+
/** `'surrogate'` (realistic stand-ins, default) or `'token'` (`[EMAIL_1]`). */
|
|
71
|
+
readonly mode?: SubstitutionMode;
|
|
72
|
+
/** Varies surrogate selection. Fixed input plus fixed seed is reproducible. */
|
|
73
|
+
readonly seed?: number;
|
|
74
|
+
/**
|
|
75
|
+
* The vault that remembers which surrogate stood in for which value.
|
|
76
|
+
*
|
|
77
|
+
* REQUIRED FOR RESTORATION, and required for consistency across calls: pass
|
|
78
|
+
* the same vault to every `protect()` in a conversation and a value seen
|
|
79
|
+
* twice gets the same surrogate. Omit it and a fresh vault is created for
|
|
80
|
+
* this call alone, which is correct for one-shot masking and wrong for
|
|
81
|
+
* anything that restores a reply later.
|
|
82
|
+
*/
|
|
83
|
+
readonly vault?: Vault;
|
|
84
|
+
/**
|
|
85
|
+
* Stage 2. Omit to run Stages 0, 1, 3 and 4 only.
|
|
86
|
+
*
|
|
87
|
+
* Not defaulted to a model on purpose: the recogniser pulls in the ONNX
|
|
88
|
+
* runtime, which this package does not depend on. See the "Stage 2" section
|
|
89
|
+
* of the usage guide.
|
|
90
|
+
*/
|
|
91
|
+
readonly ner?: NerRecognizer;
|
|
92
|
+
/** Overrides the shipped calibration model. For eval work, not for use. */
|
|
93
|
+
readonly calibration?: CalibrationModel;
|
|
94
|
+
}
|
|
95
|
+
/** One finding, with everything needed to show it and nothing that leaks it. */
|
|
96
|
+
export interface ProtectedEntity {
|
|
97
|
+
/**
|
|
98
|
+
* The vault id, stable across re-analyses of the same value.
|
|
99
|
+
*
|
|
100
|
+
* Derived from the value rather than from position, so a caller tracking a
|
|
101
|
+
* user's per-item decisions keeps them when text is edited earlier in the
|
|
102
|
+
* document. An index-based id would silently move the decision.
|
|
103
|
+
*/
|
|
104
|
+
readonly id: string;
|
|
105
|
+
readonly type: EntityType;
|
|
106
|
+
/** Calibrated, comparable across types. Never the raw detector score. */
|
|
107
|
+
readonly confidence: number;
|
|
108
|
+
/** Which evidence fired. Structured, so callers can render it in any language. */
|
|
109
|
+
readonly explanation: EntityExplanation;
|
|
110
|
+
/** What replaced it in `maskedText`. */
|
|
111
|
+
readonly surrogate: string;
|
|
112
|
+
/** Offsets into the ORIGINAL text, not the normalized text. */
|
|
113
|
+
readonly originalStart: number;
|
|
114
|
+
readonly originalEnd: number;
|
|
115
|
+
}
|
|
116
|
+
export interface ProtectResult {
|
|
117
|
+
/** The input with every reported value replaced. Safe to send. */
|
|
118
|
+
readonly maskedText: string;
|
|
119
|
+
readonly entities: readonly ProtectedEntity[];
|
|
120
|
+
/** How exposed the document was, before masking. */
|
|
121
|
+
readonly exposure: ExposureReport;
|
|
122
|
+
/**
|
|
123
|
+
* Which stages actually ran.
|
|
124
|
+
*
|
|
125
|
+
* DERIVED from the options, never declared, so "Stage 2 ran" is a claim the
|
|
126
|
+
* code supports rather than a comment. Absence of `'stage2-ner'` is how a
|
|
127
|
+
* caller knows names were not looked for.
|
|
128
|
+
*/
|
|
129
|
+
readonly stagesRun: readonly DetectionStage[];
|
|
130
|
+
/**
|
|
131
|
+
* The vault holding the originals. Pass it to `restore()` to reverse this.
|
|
132
|
+
*
|
|
133
|
+
* The same instance passed in `options.vault`, or the one created for this
|
|
134
|
+
* call. It holds plaintext originals in memory: SPEC.md forbids persisting
|
|
135
|
+
* it, and the extension clears it per tab session.
|
|
136
|
+
*/
|
|
137
|
+
readonly vault: Vault;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Detect sensitive values in `text` and replace them with stand-ins.
|
|
141
|
+
*
|
|
142
|
+
* Throws on any stage failure rather than returning an empty result. See the
|
|
143
|
+
* fail-closed note in this file's header.
|
|
144
|
+
*/
|
|
145
|
+
export declare function protect(text: string, options?: ProtectOptions): Promise<ProtectResult>;
|
|
146
|
+
//# sourceMappingURL=protect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protect.d.ts","sourceRoot":"","sources":["../../src/protect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAKH,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvE,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGjH,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAIxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB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,kEAAkE;IAClE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;IAC9C,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;IAC9C;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACvB;AAaD;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAyGhG"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* protect.ts — the one-call entry point: text in, masked text and a report out.
|
|
3
|
+
*
|
|
4
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
5
|
+
* WHY THIS EXISTS (M12)
|
|
6
|
+
*
|
|
7
|
+
* Every stage of the pipeline was already exported, and that is not the same
|
|
8
|
+
* as being usable. Getting from a string to "here is the masked text and what
|
|
9
|
+
* was found" meant composing eight core calls in a specific order, holding an
|
|
10
|
+
* identity map between two of them, and importing the fitted calibration model
|
|
11
|
+
* from a SECOND package through an unchecked cast. The extension's
|
|
12
|
+
* `analyzeText` does exactly that in about ninety lines.
|
|
13
|
+
*
|
|
14
|
+
* SPEC's M12 acceptance test is that "a developer who has never seen this repo
|
|
15
|
+
* can npm install the package and run detection and masking from the docs
|
|
16
|
+
* alone". Documenting those ninety lines would satisfy the letter of it and
|
|
17
|
+
* miss the point: the order matters for correctness, not just for convenience,
|
|
18
|
+
* and a consumer who gets it wrong gets quietly worse results rather than an
|
|
19
|
+
* error. Two of the orderings below were bugs found in earlier milestones.
|
|
20
|
+
*
|
|
21
|
+
* The individual stages remain exported. This is the supported path, not the
|
|
22
|
+
* only one.
|
|
23
|
+
*
|
|
24
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
25
|
+
* WHAT `mask()` IS, AND WHY IT IS NOT THIS
|
|
26
|
+
*
|
|
27
|
+
* `mask()` in `mask/masker.ts` also takes a string and returns masked text,
|
|
28
|
+
* and it looks like this function's smaller sibling. It runs STAGE 1 ONLY —
|
|
29
|
+
* no context scoring, no calibration, no profile decision, no NER. It exists
|
|
30
|
+
* for tests and for the playground's Stage-1 baseline. A consumer who reached
|
|
31
|
+
* for it expecting the full engine would get uncalibrated confidences and none
|
|
32
|
+
* of Stage 3's false-positive suppression, with nothing to indicate the
|
|
33
|
+
* difference. `stagesRun` on this function's result is what makes the
|
|
34
|
+
* distinction legible.
|
|
35
|
+
*
|
|
36
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
37
|
+
* FAIL-CLOSED IS THE CALLER'S JOB, AND THIS FUNCTION PRESERVES IT
|
|
38
|
+
*
|
|
39
|
+
* Nothing here catches an error from a stage. `detect` propagates
|
|
40
|
+
* `DetectionTimeoutError` and `DetectorError` deliberately, and so does this.
|
|
41
|
+
* A caller that wrapped it in a try/catch and treated the failure as "nothing
|
|
42
|
+
* found" would have built the exact failure SPEC.md calls a critical bug, so
|
|
43
|
+
* the failure is left where it cannot be mistaken for a result.
|
|
44
|
+
*/
|
|
45
|
+
import { CALIBRATION_MODEL } from '@discretion/data';
|
|
46
|
+
import { computeExposure } from './exposure/index.js';
|
|
47
|
+
import { calibrate } from './fuse/calibrate.js';
|
|
48
|
+
import { toCalibrationModel } from './fuse/defaultCalibration.js';
|
|
49
|
+
import { toDetectedEntity } from './fuse/explain.js';
|
|
50
|
+
import { PROFILES, decide } from './fuse/profiles.js';
|
|
51
|
+
import { resolveOverlaps } from './fuse/resolve.js';
|
|
52
|
+
import { maskOriginal } from './mask/masker.js';
|
|
53
|
+
import { Vault } from './mask/vault.js';
|
|
54
|
+
import { normalize } from './normalization.js';
|
|
55
|
+
import { detect } from './pipeline.js';
|
|
56
|
+
/** The shipped model, converted once and checked rather than cast. */
|
|
57
|
+
const DEFAULT_CALIBRATION = toCalibrationModel(CALIBRATION_MODEL).model;
|
|
58
|
+
function resolveProfile(profile) {
|
|
59
|
+
if (profile === undefined)
|
|
60
|
+
return PROFILES.balanced;
|
|
61
|
+
if (typeof profile !== 'string')
|
|
62
|
+
return profile;
|
|
63
|
+
if (profile === 'custom') {
|
|
64
|
+
throw new Error("protect: profile 'custom' names a shape, not a policy - pass a SensitivityProfile");
|
|
65
|
+
}
|
|
66
|
+
return PROFILES[profile];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Detect sensitive values in `text` and replace them with stand-ins.
|
|
70
|
+
*
|
|
71
|
+
* Throws on any stage failure rather than returning an empty result. See the
|
|
72
|
+
* fail-closed note in this file's header.
|
|
73
|
+
*/
|
|
74
|
+
export async function protect(text, options = {}) {
|
|
75
|
+
const profile = resolveProfile(options.profile);
|
|
76
|
+
const calibration = options.calibration ?? DEFAULT_CALIBRATION;
|
|
77
|
+
const vault = options.vault ?? new Vault();
|
|
78
|
+
const normalization = normalize(text);
|
|
79
|
+
const outcome = await detect(normalization, {
|
|
80
|
+
...(options.ner === undefined ? {} : { ner: options.ner }),
|
|
81
|
+
...(options.defaultRegion === undefined
|
|
82
|
+
? {}
|
|
83
|
+
: { stage1: { defaultRegion: options.defaultRegion } }),
|
|
84
|
+
});
|
|
85
|
+
// Resolve overlaps BEFORE calibrating or scoring exposure. An unresolved set
|
|
86
|
+
// double-counts every overlap, so one credential matched by three detectors
|
|
87
|
+
// would appear three times and inflate the exposure score threefold.
|
|
88
|
+
const resolution = resolveOverlaps(outcome.emitted
|
|
89
|
+
.filter((scored) => scored.candidate.sensitive)
|
|
90
|
+
.map((scored) => ({ candidate: scored.candidate, confidence: scored.contextConfidence })));
|
|
91
|
+
// Keyed by object identity: `resolveOverlaps` returns the same candidate
|
|
92
|
+
// objects it was given, and the scored record carries the Stage 3
|
|
93
|
+
// contributions the explanation needs.
|
|
94
|
+
const scoredByCandidate = new Map();
|
|
95
|
+
for (const scored of outcome.emitted)
|
|
96
|
+
scoredByCandidate.set(scored.candidate, scored);
|
|
97
|
+
const reported = [];
|
|
98
|
+
for (const item of resolution.emitted) {
|
|
99
|
+
const scored = scoredByCandidate.get(item.candidate);
|
|
100
|
+
if (scored === undefined)
|
|
101
|
+
continue;
|
|
102
|
+
const confidence = calibrate(calibration, item.candidate.type, item.confidence);
|
|
103
|
+
const decision = decide({ type: item.candidate.type, text: item.candidate.text, calibratedConfidence: confidence }, profile, options.lists ?? {});
|
|
104
|
+
if (!decision.report)
|
|
105
|
+
continue;
|
|
106
|
+
if (options.typeAllowed?.(item.candidate.type) === false)
|
|
107
|
+
continue;
|
|
108
|
+
reported.push({ scored, confidence });
|
|
109
|
+
}
|
|
110
|
+
// Surrogates come from the masker rather than from `chooseSurrogate`
|
|
111
|
+
// directly, because the masker enforces the properties a surrogate must
|
|
112
|
+
// have before it is shown: consistency through the vault, and the collision
|
|
113
|
+
// check that stops a surrogate from containing the very value it replaces.
|
|
114
|
+
// Computing them any other way shows the user one string and substitutes
|
|
115
|
+
// another.
|
|
116
|
+
const masked = maskOriginal(text, reported.map((entry) => entry.scored.candidate), vault, {
|
|
117
|
+
...(options.mode === undefined ? {} : { mode: options.mode }),
|
|
118
|
+
...(options.seed === undefined ? {} : { seed: options.seed }),
|
|
119
|
+
});
|
|
120
|
+
const surrogateAt = new Map();
|
|
121
|
+
for (const entity of masked.entities) {
|
|
122
|
+
surrogateAt.set(entity.originalStart, {
|
|
123
|
+
replacement: entity.replacement,
|
|
124
|
+
vaultId: entity.vaultId,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const entities = [];
|
|
128
|
+
for (const { scored, confidence } of reported) {
|
|
129
|
+
const candidate = scored.candidate;
|
|
130
|
+
const surrogate = surrogateAt.get(candidate.originalStart);
|
|
131
|
+
if (surrogate === undefined)
|
|
132
|
+
continue;
|
|
133
|
+
entities.push({
|
|
134
|
+
id: surrogate.vaultId,
|
|
135
|
+
type: candidate.type,
|
|
136
|
+
confidence,
|
|
137
|
+
explanation: toDetectedEntity({ scored, calibratedConfidence: confidence }).explanation,
|
|
138
|
+
surrogate: surrogate.replacement,
|
|
139
|
+
originalStart: candidate.originalStart,
|
|
140
|
+
originalEnd: candidate.originalEnd,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
// Not a warning. A reported detection with no surrogate is one the caller
|
|
144
|
+
// cannot show and cannot let the user revert, while the masker substitutes
|
|
145
|
+
// it anyway.
|
|
146
|
+
if (entities.length !== reported.length) {
|
|
147
|
+
throw new Error(`protect: masking produced ${String(entities.length)} surrogates for ${String(reported.length)} reported detections`);
|
|
148
|
+
}
|
|
149
|
+
const stagesRun = ['stage1-validated-identifier'];
|
|
150
|
+
if (options.ner !== undefined)
|
|
151
|
+
stagesRun.push('stage2-ner');
|
|
152
|
+
stagesRun.push('stage3-context', 'stage4-fusion');
|
|
153
|
+
return {
|
|
154
|
+
maskedText: masked.maskedText,
|
|
155
|
+
entities,
|
|
156
|
+
exposure: computeExposure(entities.map((entity) => ({ type: entity.type, calibratedConfidence: entity.confidence }))),
|
|
157
|
+
stagesRun,
|
|
158
|
+
vault,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=protect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protect.js","sourceRoot":"","sources":["../../src/protect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAyB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAA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QACD,SAAS;QACT,KAAK;KACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script detection using native Unicode property escapes (\p{Script=...}).
|
|
3
|
+
* No external library.
|
|
4
|
+
*
|
|
5
|
+
* Characters are classified by CODE POINT (never by UTF-16 code unit), so
|
|
6
|
+
* astral-plane characters — e.g. CJK Extension B ideographs — are handled
|
|
7
|
+
* correctly.
|
|
8
|
+
*/
|
|
9
|
+
import type { ScriptInfo, ScriptName } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Classification of one code point:
|
|
12
|
+
* - 'neutral' — not a letter (whitespace, digits, punctuation, symbols,
|
|
13
|
+
* combining marks, controls). Ignored for dominance because
|
|
14
|
+
* it would skew the result.
|
|
15
|
+
* - a ScriptName — a letter of that script ('other' for unsupported scripts).
|
|
16
|
+
*/
|
|
17
|
+
export type CodePointClass = ScriptName | 'neutral';
|
|
18
|
+
/** Classify a single code point. Exported for use by the fold transform. */
|
|
19
|
+
export declare function classifyCodePoint(cp: number): CodePointClass;
|
|
20
|
+
/**
|
|
21
|
+
* The ScriptName for a single character (the first code point of `char`).
|
|
22
|
+
* Script-neutral characters and letters of unsupported scripts both report
|
|
23
|
+
* 'other'.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getCharScript(char: string): ScriptName;
|
|
26
|
+
/**
|
|
27
|
+
* Whether two scripts may legitimately co-occur in one token (same script,
|
|
28
|
+
* or both members of a compatibility group).
|
|
29
|
+
*/
|
|
30
|
+
export declare function scriptsCompatible(a: ScriptName, b: ScriptName): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Per-script letter counts, the dominant script, and whether the text mixes
|
|
33
|
+
* scripts. Whitespace, digits, and punctuation are ignored — they are
|
|
34
|
+
* script-neutral and would skew dominance.
|
|
35
|
+
*/
|
|
36
|
+
export declare function detectScripts(text: string): ScriptInfo;
|
|
37
|
+
//# sourceMappingURL=scripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../src/scripts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAkCzD;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,SAAS,CAAC;AAYpD,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,CAsB5D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAKtD;AAeD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAIvE;AASD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CA8BtD"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script membership tests, checked in this order. Kana merges Hiragana and
|
|
3
|
+
* Katakana into one bucket because the pipeline treats Japanese syllabaries
|
|
4
|
+
* as a unit.
|
|
5
|
+
*/
|
|
6
|
+
const SCRIPT_PATTERNS = [
|
|
7
|
+
['latin', /\p{Script=Latin}/u],
|
|
8
|
+
['cyrillic', /\p{Script=Cyrillic}/u],
|
|
9
|
+
['greek', /\p{Script=Greek}/u],
|
|
10
|
+
['arabic', /\p{Script=Arabic}/u],
|
|
11
|
+
['hebrew', /\p{Script=Hebrew}/u],
|
|
12
|
+
// Han and Kana use Script_Extensions, not Script: CJK letters like ー
|
|
13
|
+
// (U+30FC, the prolonged sound mark) and 々 (U+3005, the iteration mark)
|
|
14
|
+
// have Script=Common but scx of {Hiragana,Katakana} / {Han}. Classifying
|
|
15
|
+
// them 'other' made them look script-anomalous inside ordinary Japanese
|
|
16
|
+
// words — and anomalous letters are folding candidates, which is exactly
|
|
17
|
+
// wrong for these.
|
|
18
|
+
['han', /\p{Script_Extensions=Han}/u],
|
|
19
|
+
['kana', /[\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}]/u],
|
|
20
|
+
['hangul', /\p{Script=Hangul}/u],
|
|
21
|
+
['devanagari', /\p{Script=Devanagari}/u],
|
|
22
|
+
['thai', /\p{Script=Thai}/u],
|
|
23
|
+
['armenian', /\p{Script=Armenian}/u],
|
|
24
|
+
['georgian', /\p{Script=Georgian}/u],
|
|
25
|
+
['ethiopic', /\p{Script=Ethiopic}/u],
|
|
26
|
+
];
|
|
27
|
+
const LETTER = /\p{L}/u;
|
|
28
|
+
/** All supported scripts, i.e. every ScriptName except 'other'. */
|
|
29
|
+
const REAL_SCRIPTS = SCRIPT_PATTERNS.map(([name]) => name);
|
|
30
|
+
/**
|
|
31
|
+
* Memo of code point → class. Script property lookups go through regexes,
|
|
32
|
+
* which is too slow to repeat per character on large inputs; real-world text
|
|
33
|
+
* has few distinct code points, so a memo makes classification ~O(1).
|
|
34
|
+
* Capped so adversarial input (e.g. fuzzing across the whole Unicode range)
|
|
35
|
+
* cannot grow it without bound.
|
|
36
|
+
*/
|
|
37
|
+
const classMemo = new Map();
|
|
38
|
+
const CLASS_MEMO_MAX = 0x10000;
|
|
39
|
+
/** Classify a single code point. Exported for use by the fold transform. */
|
|
40
|
+
export function classifyCodePoint(cp) {
|
|
41
|
+
// ASCII fast path — the overwhelmingly common case.
|
|
42
|
+
if (cp < 0x80) {
|
|
43
|
+
if ((cp >= 0x41 && cp <= 0x5a) || (cp >= 0x61 && cp <= 0x7a))
|
|
44
|
+
return 'latin';
|
|
45
|
+
return 'neutral';
|
|
46
|
+
}
|
|
47
|
+
const memoized = classMemo.get(cp);
|
|
48
|
+
if (memoized !== undefined)
|
|
49
|
+
return memoized;
|
|
50
|
+
const char = String.fromCodePoint(cp);
|
|
51
|
+
let result = 'neutral';
|
|
52
|
+
if (LETTER.test(char)) {
|
|
53
|
+
result = 'other';
|
|
54
|
+
for (const [name, pattern] of SCRIPT_PATTERNS) {
|
|
55
|
+
if (pattern.test(char)) {
|
|
56
|
+
result = name;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (classMemo.size < CLASS_MEMO_MAX)
|
|
62
|
+
classMemo.set(cp, result);
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The ScriptName for a single character (the first code point of `char`).
|
|
67
|
+
* Script-neutral characters and letters of unsupported scripts both report
|
|
68
|
+
* 'other'.
|
|
69
|
+
*/
|
|
70
|
+
export function getCharScript(char) {
|
|
71
|
+
const cp = char.codePointAt(0);
|
|
72
|
+
if (cp === undefined)
|
|
73
|
+
return 'other';
|
|
74
|
+
const cls = classifyCodePoint(cp);
|
|
75
|
+
return cls === 'neutral' ? 'other' : cls;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Script compatibility groups for token-level dominance decisions (ratified):
|
|
79
|
+
* ordinary Japanese prose freely mixes Han, Hiragana/Katakana, and embedded
|
|
80
|
+
* Latin (acronyms, romaji), and Korean prose mixes Hangul with Han (hanja).
|
|
81
|
+
* Characters of co-occurring scripts within one group are NEVER treated as
|
|
82
|
+
* script-anomalous with respect to each other, so such text is never a
|
|
83
|
+
* homoglyph-folding candidate.
|
|
84
|
+
*/
|
|
85
|
+
const COMPATIBLE_GROUPS = [
|
|
86
|
+
new Set(['han', 'kana', 'latin']),
|
|
87
|
+
new Set(['hangul', 'han']),
|
|
88
|
+
];
|
|
89
|
+
/**
|
|
90
|
+
* Whether two scripts may legitimately co-occur in one token (same script,
|
|
91
|
+
* or both members of a compatibility group).
|
|
92
|
+
*/
|
|
93
|
+
export function scriptsCompatible(a, b) {
|
|
94
|
+
if (a === b)
|
|
95
|
+
return true;
|
|
96
|
+
if (a === 'other' || b === 'other')
|
|
97
|
+
return false;
|
|
98
|
+
return COMPATIBLE_GROUPS.some((group) => group.has(a) && group.has(b));
|
|
99
|
+
}
|
|
100
|
+
function emptyCounts() {
|
|
101
|
+
const counts = {};
|
|
102
|
+
for (const name of REAL_SCRIPTS)
|
|
103
|
+
counts[name] = 0;
|
|
104
|
+
counts.other = 0;
|
|
105
|
+
return counts;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Per-script letter counts, the dominant script, and whether the text mixes
|
|
109
|
+
* scripts. Whitespace, digits, and punctuation are ignored — they are
|
|
110
|
+
* script-neutral and would skew dominance.
|
|
111
|
+
*/
|
|
112
|
+
export function detectScripts(text) {
|
|
113
|
+
const counts = emptyCounts();
|
|
114
|
+
// for..of iterates CODE POINTS, so surrogate pairs are never split.
|
|
115
|
+
for (const char of text) {
|
|
116
|
+
const cls = classifyCodePoint(char.codePointAt(0));
|
|
117
|
+
if (cls === 'neutral')
|
|
118
|
+
continue;
|
|
119
|
+
counts[cls] += 1;
|
|
120
|
+
}
|
|
121
|
+
let dominant = null;
|
|
122
|
+
let best = 0;
|
|
123
|
+
let tied = false;
|
|
124
|
+
let present = 0;
|
|
125
|
+
for (const name of REAL_SCRIPTS) {
|
|
126
|
+
const count = counts[name];
|
|
127
|
+
if (count > 0)
|
|
128
|
+
present += 1;
|
|
129
|
+
if (count > best) {
|
|
130
|
+
best = count;
|
|
131
|
+
dominant = name;
|
|
132
|
+
tied = false;
|
|
133
|
+
}
|
|
134
|
+
else if (count === best && count > 0) {
|
|
135
|
+
tied = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
counts,
|
|
140
|
+
// Dominance requires a strict maximum; a tie means "no dominant script".
|
|
141
|
+
dominant: tied ? null : dominant,
|
|
142
|
+
mixed: present > 1,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=scripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../src/scripts.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,MAAM,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AI,CAAC;YAChB,IAAI,GAAG,KAAK,CAAC;QACf,CAAC;aAAM,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACvC,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO;QACL,MAAM;QACN,yEAAyE;QACzE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ;QAChC,KAAK,EAAE,OAAO,GAAG,CAAC;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform 5: DECIMAL DIGIT FOLDING.
|
|
3
|
+
*
|
|
4
|
+
* Every Unicode decimal digit is folded to its ASCII equivalent: Arabic-Indic
|
|
5
|
+
* ٠١٢, Extended Arabic-Indic ۰۱۲, Devanagari ०१२, Bengali ০১২, Thai ๐๑๒,
|
|
6
|
+
* Tamil, Telugu, Myanmar, Khmer, and the rest.
|
|
7
|
+
*
|
|
8
|
+
* WHY THIS EXISTS. NFKC folds FULLWIDTH digits, because those are
|
|
9
|
+
* compatibility variants of ASCII — but Arabic-Indic and Devanagari digits are
|
|
10
|
+
* not compatibility variants of anything. They are the ordinary digits of
|
|
11
|
+
* living scripts, and NFKC leaves them exactly as they are, correctly.
|
|
12
|
+
*
|
|
13
|
+
* The consequence for this pipeline was silent un-redaction. Every Stage 1
|
|
14
|
+
* detector matches `\d` or an explicit `[0-9]` class, so before this transform
|
|
15
|
+
* existed a Turkish national identity number written `٣٠٢١٤٥٦٤٦٤١٢`, an
|
|
16
|
+
* Iranian phone number in Extended Arabic-Indic, a Hindi Aadhaar number in
|
|
17
|
+
* Devanagari, a Thai national ID and a Bengali credit card were ALL reported
|
|
18
|
+
* as clean documents — measured, not assumed. That is the same class of
|
|
19
|
+
* failure as an identifier hidden inside HTML markup, and it landed on
|
|
20
|
+
* precisely the Arabic, Persian, Urdu, Hindi, Bengali and Thai users the
|
|
21
|
+
* multilingual work exists to serve.
|
|
22
|
+
*
|
|
23
|
+
* WHERE IT RUNS, and why last. After homoglyph folding, not before. Folding
|
|
24
|
+
* digits changes a token's script census — Arabic-Indic digits are Arabic,
|
|
25
|
+
* ASCII digits are not — so folding them earlier would alter the
|
|
26
|
+
* dominant-script decision that homoglyph folding depends on, and could flip
|
|
27
|
+
* a fold that D3 deliberately declines to make. Running afterwards leaves
|
|
28
|
+
* that decision on the original scripts. ASCII digits are NFKC-stable, so no
|
|
29
|
+
* further normalization pass is owed.
|
|
30
|
+
*
|
|
31
|
+
* THE USER'S TEXT IS NOT REWRITTEN. Folding happens in the NORMALIZED text
|
|
32
|
+
* only; masking edits the ORIGINAL through the offset map, so a Persian user
|
|
33
|
+
* sees their own digits back. That separation is the entire point of the
|
|
34
|
+
* offset-map contract.
|
|
35
|
+
*/
|
|
36
|
+
import { type TransformStepResult } from '../offsetMap.js';
|
|
37
|
+
/** The ASCII digit for a code point, or undefined if it is not a decimal digit. */
|
|
38
|
+
export declare function asciiDigitFor(codePoint: number): string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Fold every non-ASCII decimal digit to ASCII.
|
|
41
|
+
*
|
|
42
|
+
* Most blocks are BMP and fold one code unit to one, leaving offsets
|
|
43
|
+
* untouched. A few are astral (Osmanya, Brahmi, mathematical digits) and fold
|
|
44
|
+
* a surrogate PAIR to a single character, so this is not a 1:1 transform and
|
|
45
|
+
* goes through `MappedTextBuilder` rather than assuming equal lengths — the
|
|
46
|
+
* same machinery NFKC's expansions use.
|
|
47
|
+
*/
|
|
48
|
+
export declare function foldDigits(text: string): TransformStepResult | null;
|
|
49
|
+
//# sourceMappingURL=foldDigits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foldDigits.d.ts","sourceRoot":"","sources":["../../../src/transforms/foldDigits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAsC,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AA0C/F,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAInE;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CA2CnE"}
|