@zudojs/crypto 0.0.1 → 1.0.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/README.md +43 -14
- package/dist/compare/compare.helper.d.ts +10 -2
- package/dist/compare/compare.helper.js +22 -6
- package/dist/cryptoCipher/cryptoCipher.core.d.ts +11 -1
- package/dist/cryptoCipher/cryptoCipher.core.js +19 -3
- package/dist/cryptoCipher/cryptoCipher.envelope.d.ts +7 -2
- package/dist/cryptoCipher/cryptoCipher.envelope.js +33 -14
- package/dist/cryptoCipher/cryptoCipher.string.d.ts +2 -1
- package/dist/cryptoCipher/cryptoCipher.string.js +2 -2
- package/dist/cryptoConstants/cryptoConstants.guard.d.ts +9 -0
- package/dist/cryptoConstants/cryptoConstants.guard.js +16 -1
- package/dist/cryptoConstants/cryptoConstants.security.d.ts +34 -1
- package/dist/cryptoConstants/cryptoConstants.security.js +34 -1
- package/dist/cryptoConstants/cryptoConstants.token.d.ts +2 -0
- package/dist/cryptoConstants/cryptoConstants.token.js +2 -0
- package/dist/cryptoConstants/cryptoConstants.type.d.ts +36 -14
- package/dist/cryptoConstants/cryptoConstants.type.js +36 -14
- package/dist/cryptoEncoding/cryptoEncoding.compare.d.ts +4 -1
- package/dist/cryptoEncoding/cryptoEncoding.compare.js +11 -4
- package/dist/cryptoEncoding/cryptoEncoding.core.d.ts +22 -0
- package/dist/cryptoEncoding/cryptoEncoding.core.js +41 -3
- package/dist/cryptoEncoding/encoding/cryptoEncoding.base64.d.ts +10 -2
- package/dist/cryptoEncoding/encoding/cryptoEncoding.base64.js +24 -16
- package/dist/cryptoEncoding/encoding/cryptoEncoding.base64url.d.ts +9 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.base64url.js +23 -20
- package/dist/cryptoEncoding/encoding/cryptoEncoding.hex.d.ts +9 -2
- package/dist/cryptoEncoding/encoding/cryptoEncoding.hex.js +17 -11
- package/dist/cryptoErrors/cryptoErrors.helper.d.ts +30 -0
- package/dist/cryptoErrors/cryptoErrors.helper.js +72 -0
- package/dist/cryptoFactory/cryptoFactory.core.d.ts +37 -6
- package/dist/cryptoFactory/cryptoFactory.core.js +56 -30
- package/dist/cryptoFactory/cryptoFactory.password.d.ts +4 -3
- package/dist/cryptoFactory/cryptoFactory.password.js +4 -4
- package/dist/cryptoFactory/cryptoFactory.token.d.ts +9 -8
- package/dist/cryptoFactory/cryptoFactory.token.js +16 -15
- package/dist/cryptoHash/cryptoHash.codec.d.ts +2 -0
- package/dist/cryptoHash/cryptoHash.codec.js +12 -12
- package/dist/cryptoHash/cryptoHash.compare.d.ts +3 -1
- package/dist/cryptoHash/cryptoHash.compare.js +5 -9
- package/dist/cryptoHash/cryptoHash.core.d.ts +6 -2
- package/dist/cryptoHash/cryptoHash.core.js +9 -2
- package/dist/cryptoHash/cryptoHmac.core.d.ts +8 -5
- package/dist/cryptoHash/cryptoHmac.core.js +22 -9
- package/dist/cryptoKey/cryptoKey.factory.d.ts +29 -2
- package/dist/cryptoKey/cryptoKey.factory.js +82 -18
- package/dist/cryptoKey/cryptoKey.utils.d.ts +5 -3
- package/dist/cryptoKey/cryptoKey.utils.js +5 -3
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.core.d.ts +7 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.core.js +40 -15
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.salt.d.ts +2 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.salt.js +2 -3
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.type.d.ts +5 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.validate.d.ts +2 -2
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.validate.js +16 -6
- package/dist/cryptoPassword/cryptoPassword.codec.d.ts +15 -1
- package/dist/cryptoPassword/cryptoPassword.codec.js +127 -56
- package/dist/cryptoPassword/cryptoPassword.core.d.ts +17 -3
- package/dist/cryptoPassword/cryptoPassword.core.js +29 -21
- package/dist/cryptoPassword/cryptoPassword.helper.js +6 -5
- package/dist/cryptoPassword/cryptoPassword.type.d.ts +33 -5
- package/dist/cryptoPassword/cryptoPassword.validate.d.ts +14 -3
- package/dist/cryptoPassword/cryptoPassword.validate.js +51 -20
- package/dist/cryptoProvider/cryptoProvider.default.d.ts +18 -0
- package/dist/cryptoProvider/cryptoProvider.default.js +31 -0
- package/dist/cryptoProvider/cryptoProvider.interface.d.ts +9 -34
- package/dist/cryptoProvider/cryptoProvider.type.d.ts +32 -3
- package/dist/cryptoProvider/cryptoProvider.type.js +40 -1
- package/dist/cryptoProvider/index.d.ts +5 -2
- package/dist/cryptoProvider/index.js +2 -0
- package/dist/cryptoProvider/types/cryptoCipher.type.d.ts +11 -6
- package/dist/cryptoProvider/types/cryptoKeyDerivation.type.d.ts +39 -3
- package/dist/cryptoProvider/types/cryptoSignature.type.d.ts +5 -5
- package/dist/cryptoProvider/types/index.d.ts +1 -1
- package/dist/cryptoRandom/cryptoRandom.choice.d.ts +6 -3
- package/dist/cryptoRandom/cryptoRandom.choice.js +10 -6
- package/dist/cryptoRandom/cryptoRandom.core.d.ts +8 -5
- package/dist/cryptoRandom/cryptoRandom.core.js +8 -7
- package/dist/cryptoRandom/cryptoRandom.string.d.ts +11 -9
- package/dist/cryptoRandom/cryptoRandom.string.js +28 -29
- package/dist/cryptoService/cryptoService.core.d.ts +47 -9
- package/dist/cryptoService/cryptoService.core.js +65 -33
- package/dist/cryptoService/cryptoService.derivation.d.ts +3 -3
- package/dist/cryptoService/cryptoService.derivation.js +8 -6
- package/dist/cryptoService/cryptoService.encoding.js +6 -5
- package/dist/cryptoService/index.d.ts +1 -5
- package/dist/cryptoService/index.js +1 -5
- package/dist/cryptoService/operations/cryptoService.cipher.d.ts +3 -2
- package/dist/cryptoService/operations/cryptoService.cipher.js +13 -9
- package/dist/cryptoService/operations/cryptoService.hash.d.ts +3 -2
- package/dist/cryptoService/operations/cryptoService.hash.js +7 -8
- package/dist/cryptoService/operations/cryptoService.password.d.ts +7 -2
- package/dist/cryptoService/operations/cryptoService.password.js +20 -9
- package/dist/cryptoService/operations/cryptoService.token.d.ts +9 -4
- package/dist/cryptoService/operations/cryptoService.token.js +31 -17
- package/dist/cryptoSignature/cryptoSignature.core.d.ts +10 -2
- package/dist/cryptoSignature/cryptoSignature.core.js +7 -3
- package/dist/cryptoToken/cryptoToken.core.d.ts +15 -9
- package/dist/cryptoToken/cryptoToken.core.js +63 -38
- package/dist/cryptoToken/cryptoToken.hash.d.ts +9 -7
- package/dist/cryptoToken/cryptoToken.hash.js +19 -43
- package/dist/cryptoUtils/cryptoUtils.compare.d.ts +3 -1
- package/dist/cryptoUtils/cryptoUtils.compare.js +5 -14
- package/dist/cryptoUtils/cryptoUtils.number.d.ts +3 -0
- package/dist/cryptoUtils/cryptoUtils.number.js +12 -6
- package/dist/cryptoUtils/cryptoUtils.validation.d.ts +2 -2
- package/dist/cryptoUtils/cryptoUtils.validation.js +6 -8
- package/dist/cryptoUtils/encoding/cryptoUtils.base64.d.ts +4 -4
- package/dist/cryptoUtils/encoding/cryptoUtils.base64.js +5 -23
- package/dist/cryptoUtils/encoding/cryptoUtils.base64url.d.ts +4 -4
- package/dist/cryptoUtils/encoding/cryptoUtils.base64url.js +5 -32
- package/dist/cryptoUtils/encoding/cryptoUtils.hex.d.ts +4 -4
- package/dist/cryptoUtils/encoding/cryptoUtils.hex.js +5 -20
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.core.d.ts +6 -29
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.core.js +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.helper.d.ts +9 -4
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.helper.js +25 -43
- package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.derivation.d.ts +7 -0
- package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.derivation.js +89 -30
- package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.password.d.ts +17 -10
- package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.password.js +112 -72
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.encryption.d.ts +3 -12
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.encryption.js +74 -25
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.hash.js +7 -2
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.random.d.ts +6 -0
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.random.js +18 -18
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.signing.d.ts +10 -12
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.signing.js +75 -20
- package/dist/node/signing/signing.conversion.d.ts +13 -3
- package/dist/node/signing/signing.conversion.js +35 -15
- package/dist/node/signing/signing.core.d.ts +2 -1
- package/dist/node/signing/signing.core.js +2 -3
- package/dist/node/signing/signing.utils.d.ts +10 -2
- package/dist/node/signing/signing.utils.js +26 -5
- package/package.json +18 -8
- package/dist/.tsbuildinfo +0 -1
- package/dist/compare/compare.helper.d.ts.map +0 -1
- package/dist/compare/compare.helper.js.map +0 -1
- package/dist/compare/index.d.ts.map +0 -1
- package/dist/compare/index.js.map +0 -1
- package/dist/cryptoAlgorithm/index.d.ts +0 -8
- package/dist/cryptoAlgorithm/index.d.ts.map +0 -1
- package/dist/cryptoAlgorithm/index.js +0 -8
- package/dist/cryptoAlgorithm/index.js.map +0 -1
- package/dist/cryptoCipher/cryptoCipher.core.d.ts.map +0 -1
- package/dist/cryptoCipher/cryptoCipher.core.js.map +0 -1
- package/dist/cryptoCipher/cryptoCipher.envelope.d.ts.map +0 -1
- package/dist/cryptoCipher/cryptoCipher.envelope.js.map +0 -1
- package/dist/cryptoCipher/cryptoCipher.string.d.ts.map +0 -1
- package/dist/cryptoCipher/cryptoCipher.string.js.map +0 -1
- package/dist/cryptoCipher/index.d.ts.map +0 -1
- package/dist/cryptoCipher/index.js.map +0 -1
- package/dist/cryptoConstants/cryptoConstants.config.d.ts.map +0 -1
- package/dist/cryptoConstants/cryptoConstants.config.js.map +0 -1
- package/dist/cryptoConstants/cryptoConstants.guard.d.ts.map +0 -1
- package/dist/cryptoConstants/cryptoConstants.guard.js.map +0 -1
- package/dist/cryptoConstants/cryptoConstants.security.d.ts.map +0 -1
- package/dist/cryptoConstants/cryptoConstants.security.js.map +0 -1
- package/dist/cryptoConstants/cryptoConstants.token.d.ts.map +0 -1
- package/dist/cryptoConstants/cryptoConstants.token.js.map +0 -1
- package/dist/cryptoConstants/cryptoConstants.type.d.ts.map +0 -1
- package/dist/cryptoConstants/cryptoConstants.type.js.map +0 -1
- package/dist/cryptoConstants/index.d.ts.map +0 -1
- package/dist/cryptoConstants/index.js.map +0 -1
- package/dist/cryptoEncoding/cryptoEncoding.arrayBuffer.d.ts.map +0 -1
- package/dist/cryptoEncoding/cryptoEncoding.arrayBuffer.js.map +0 -1
- package/dist/cryptoEncoding/cryptoEncoding.compare.d.ts.map +0 -1
- package/dist/cryptoEncoding/cryptoEncoding.compare.js.map +0 -1
- package/dist/cryptoEncoding/cryptoEncoding.core.d.ts.map +0 -1
- package/dist/cryptoEncoding/cryptoEncoding.core.js.map +0 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.base64.d.ts.map +0 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.base64.js.map +0 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.base64url.d.ts.map +0 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.base64url.js.map +0 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.hex.d.ts.map +0 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.hex.js.map +0 -1
- package/dist/cryptoEncoding/encoding/index.d.ts.map +0 -1
- package/dist/cryptoEncoding/encoding/index.js.map +0 -1
- package/dist/cryptoEncoding/index.d.ts.map +0 -1
- package/dist/cryptoEncoding/index.js.map +0 -1
- package/dist/cryptoErrors/index.d.ts.map +0 -1
- package/dist/cryptoErrors/index.js.map +0 -1
- package/dist/cryptoFactory/cryptoFactory.core.d.ts.map +0 -1
- package/dist/cryptoFactory/cryptoFactory.core.js.map +0 -1
- package/dist/cryptoFactory/cryptoFactory.encoding.d.ts.map +0 -1
- package/dist/cryptoFactory/cryptoFactory.encoding.js.map +0 -1
- package/dist/cryptoFactory/cryptoFactory.options.d.ts +0 -2
- package/dist/cryptoFactory/cryptoFactory.options.d.ts.map +0 -1
- package/dist/cryptoFactory/cryptoFactory.options.js +0 -6
- package/dist/cryptoFactory/cryptoFactory.options.js.map +0 -1
- package/dist/cryptoFactory/cryptoFactory.password.d.ts.map +0 -1
- package/dist/cryptoFactory/cryptoFactory.password.js.map +0 -1
- package/dist/cryptoFactory/cryptoFactory.token.d.ts.map +0 -1
- package/dist/cryptoFactory/cryptoFactory.token.js.map +0 -1
- package/dist/cryptoFactory/index.d.ts.map +0 -1
- package/dist/cryptoFactory/index.js.map +0 -1
- package/dist/cryptoHash/cryptoHash.codec.d.ts.map +0 -1
- package/dist/cryptoHash/cryptoHash.codec.js.map +0 -1
- package/dist/cryptoHash/cryptoHash.compare.d.ts.map +0 -1
- package/dist/cryptoHash/cryptoHash.compare.js.map +0 -1
- package/dist/cryptoHash/cryptoHash.convenience.d.ts.map +0 -1
- package/dist/cryptoHash/cryptoHash.convenience.js.map +0 -1
- package/dist/cryptoHash/cryptoHash.core.d.ts.map +0 -1
- package/dist/cryptoHash/cryptoHash.core.js.map +0 -1
- package/dist/cryptoHash/cryptoHmac.core.d.ts.map +0 -1
- package/dist/cryptoHash/cryptoHmac.core.js.map +0 -1
- package/dist/cryptoHash/index.d.ts.map +0 -1
- package/dist/cryptoHash/index.js.map +0 -1
- package/dist/cryptoKey/cryptoKey.factory.d.ts.map +0 -1
- package/dist/cryptoKey/cryptoKey.factory.js.map +0 -1
- package/dist/cryptoKey/cryptoKey.type.d.ts.map +0 -1
- package/dist/cryptoKey/cryptoKey.type.js.map +0 -1
- package/dist/cryptoKey/cryptoKey.utils.d.ts.map +0 -1
- package/dist/cryptoKey/cryptoKey.utils.js.map +0 -1
- package/dist/cryptoKey/index.d.ts.map +0 -1
- package/dist/cryptoKey/index.js.map +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.core.d.ts.map +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.core.js.map +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.salt.d.ts.map +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.salt.js.map +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.type.d.ts.map +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.type.js.map +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.validate.d.ts.map +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.validate.js.map +0 -1
- package/dist/cryptoKeyDerivation/index.d.ts.map +0 -1
- package/dist/cryptoKeyDerivation/index.js.map +0 -1
- package/dist/cryptoPassword/cryptoPassword.codec.d.ts.map +0 -1
- package/dist/cryptoPassword/cryptoPassword.codec.js.map +0 -1
- package/dist/cryptoPassword/cryptoPassword.core.d.ts.map +0 -1
- package/dist/cryptoPassword/cryptoPassword.core.js.map +0 -1
- package/dist/cryptoPassword/cryptoPassword.helper.d.ts.map +0 -1
- package/dist/cryptoPassword/cryptoPassword.helper.js.map +0 -1
- package/dist/cryptoPassword/cryptoPassword.type.d.ts.map +0 -1
- package/dist/cryptoPassword/cryptoPassword.type.js.map +0 -1
- package/dist/cryptoPassword/cryptoPassword.validate.d.ts.map +0 -1
- package/dist/cryptoPassword/cryptoPassword.validate.js.map +0 -1
- package/dist/cryptoPassword/index.d.ts.map +0 -1
- package/dist/cryptoPassword/index.js.map +0 -1
- package/dist/cryptoProvider/cryptoProvider.core.d.ts.map +0 -1
- package/dist/cryptoProvider/cryptoProvider.core.js.map +0 -1
- package/dist/cryptoProvider/cryptoProvider.interface.d.ts.map +0 -1
- package/dist/cryptoProvider/cryptoProvider.interface.js.map +0 -1
- package/dist/cryptoProvider/cryptoProvider.type.d.ts.map +0 -1
- package/dist/cryptoProvider/cryptoProvider.type.js.map +0 -1
- package/dist/cryptoProvider/index.d.ts.map +0 -1
- package/dist/cryptoProvider/index.js.map +0 -1
- package/dist/cryptoProvider/types/cryptoCipher.type.d.ts.map +0 -1
- package/dist/cryptoProvider/types/cryptoCipher.type.js.map +0 -1
- package/dist/cryptoProvider/types/cryptoHash.type.d.ts.map +0 -1
- package/dist/cryptoProvider/types/cryptoHash.type.js.map +0 -1
- package/dist/cryptoProvider/types/cryptoKeyDerivation.type.d.ts.map +0 -1
- package/dist/cryptoProvider/types/cryptoKeyDerivation.type.js.map +0 -1
- package/dist/cryptoProvider/types/cryptoRandom.type.d.ts.map +0 -1
- package/dist/cryptoProvider/types/cryptoRandom.type.js.map +0 -1
- package/dist/cryptoProvider/types/cryptoSignature.type.d.ts.map +0 -1
- package/dist/cryptoProvider/types/cryptoSignature.type.js.map +0 -1
- package/dist/cryptoProvider/types/index.d.ts.map +0 -1
- package/dist/cryptoProvider/types/index.js.map +0 -1
- package/dist/cryptoRandom/cryptoRandom.choice.d.ts.map +0 -1
- package/dist/cryptoRandom/cryptoRandom.choice.js.map +0 -1
- package/dist/cryptoRandom/cryptoRandom.core.d.ts.map +0 -1
- package/dist/cryptoRandom/cryptoRandom.core.js.map +0 -1
- package/dist/cryptoRandom/cryptoRandom.string.d.ts.map +0 -1
- package/dist/cryptoRandom/cryptoRandom.string.js.map +0 -1
- package/dist/cryptoRandom/index.d.ts.map +0 -1
- package/dist/cryptoRandom/index.js.map +0 -1
- package/dist/cryptoService/cryptoService.core.d.ts.map +0 -1
- package/dist/cryptoService/cryptoService.core.js.map +0 -1
- package/dist/cryptoService/cryptoService.derivation.d.ts.map +0 -1
- package/dist/cryptoService/cryptoService.derivation.js.map +0 -1
- package/dist/cryptoService/cryptoService.encoding.d.ts.map +0 -1
- package/dist/cryptoService/cryptoService.encoding.js.map +0 -1
- package/dist/cryptoService/index.d.ts.map +0 -1
- package/dist/cryptoService/index.js.map +0 -1
- package/dist/cryptoService/operations/cryptoService.cipher.d.ts.map +0 -1
- package/dist/cryptoService/operations/cryptoService.cipher.js.map +0 -1
- package/dist/cryptoService/operations/cryptoService.hash.d.ts.map +0 -1
- package/dist/cryptoService/operations/cryptoService.hash.js.map +0 -1
- package/dist/cryptoService/operations/cryptoService.password.d.ts.map +0 -1
- package/dist/cryptoService/operations/cryptoService.password.js.map +0 -1
- package/dist/cryptoService/operations/cryptoService.token.d.ts.map +0 -1
- package/dist/cryptoService/operations/cryptoService.token.js.map +0 -1
- package/dist/cryptoService/operations/index.d.ts.map +0 -1
- package/dist/cryptoService/operations/index.js.map +0 -1
- package/dist/cryptoSignature/cryptoSignature.core.d.ts.map +0 -1
- package/dist/cryptoSignature/cryptoSignature.core.js.map +0 -1
- package/dist/cryptoSignature/index.d.ts.map +0 -1
- package/dist/cryptoSignature/index.js.map +0 -1
- package/dist/cryptoToken/cryptoToken.core.d.ts.map +0 -1
- package/dist/cryptoToken/cryptoToken.core.js.map +0 -1
- package/dist/cryptoToken/cryptoToken.hash.d.ts.map +0 -1
- package/dist/cryptoToken/cryptoToken.hash.js.map +0 -1
- package/dist/cryptoToken/cryptoToken.utils.d.ts.map +0 -1
- package/dist/cryptoToken/cryptoToken.utils.js.map +0 -1
- package/dist/cryptoToken/index.d.ts.map +0 -1
- package/dist/cryptoToken/index.js.map +0 -1
- package/dist/cryptoUtils/cryptoUtils.compare.d.ts.map +0 -1
- package/dist/cryptoUtils/cryptoUtils.compare.js.map +0 -1
- package/dist/cryptoUtils/cryptoUtils.conversion.d.ts.map +0 -1
- package/dist/cryptoUtils/cryptoUtils.conversion.js.map +0 -1
- package/dist/cryptoUtils/cryptoUtils.number.d.ts.map +0 -1
- package/dist/cryptoUtils/cryptoUtils.number.js.map +0 -1
- package/dist/cryptoUtils/cryptoUtils.text.d.ts.map +0 -1
- package/dist/cryptoUtils/cryptoUtils.text.js.map +0 -1
- package/dist/cryptoUtils/cryptoUtils.validation.d.ts.map +0 -1
- package/dist/cryptoUtils/cryptoUtils.validation.js.map +0 -1
- package/dist/cryptoUtils/encoding/cryptoUtils.base64.d.ts.map +0 -1
- package/dist/cryptoUtils/encoding/cryptoUtils.base64.js.map +0 -1
- package/dist/cryptoUtils/encoding/cryptoUtils.base64url.d.ts.map +0 -1
- package/dist/cryptoUtils/encoding/cryptoUtils.base64url.js.map +0 -1
- package/dist/cryptoUtils/encoding/cryptoUtils.hex.d.ts.map +0 -1
- package/dist/cryptoUtils/encoding/cryptoUtils.hex.js.map +0 -1
- package/dist/cryptoUtils/encoding/index.d.ts.map +0 -1
- package/dist/cryptoUtils/encoding/index.js.map +0 -1
- package/dist/cryptoUtils/index.d.ts.map +0 -1
- package/dist/cryptoUtils/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/index.js.map +0 -1
- package/dist/node/nodeCryptoProvider/index.d.ts.map +0 -1
- package/dist/node/nodeCryptoProvider/index.js.map +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.core.d.ts.map +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.core.js.map +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.factory.d.ts.map +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.factory.js.map +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.helper.d.ts.map +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.helper.js.map +0 -1
- package/dist/node/nodeCryptoProvider/operations/index.d.ts.map +0 -1
- package/dist/node/nodeCryptoProvider/operations/index.js.map +0 -1
- package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.derivation.d.ts.map +0 -1
- package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.derivation.js.map +0 -1
- package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.password.d.ts.map +0 -1
- package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.password.js.map +0 -1
- package/dist/node/nodeCryptoProvider/primitives/index.d.ts.map +0 -1
- package/dist/node/nodeCryptoProvider/primitives/index.js.map +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.encryption.d.ts.map +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.encryption.js.map +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.hash.d.ts.map +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.hash.js.map +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.random.d.ts.map +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.random.js.map +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.signing.d.ts.map +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.signing.js.map +0 -1
- package/dist/node/signing/index.d.ts.map +0 -1
- package/dist/node/signing/index.js.map +0 -1
- package/dist/node/signing/signing.conversion.d.ts.map +0 -1
- package/dist/node/signing/signing.conversion.js.map +0 -1
- package/dist/node/signing/signing.core.d.ts.map +0 -1
- package/dist/node/signing/signing.core.js.map +0 -1
- package/dist/node/signing/signing.utils.d.ts.map +0 -1
- package/dist/node/signing/signing.utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @zudojs/crypto
|
|
2
2
|
|
|
3
|
-
Cryptographic primitives for hashing, encryption, tokens, and secure random generation.
|
|
3
|
+
Cryptographic primitives for hashing, authenticated encryption, password hashing, digital signatures, key derivation, opaque tokens, and secure random generation. Everything is backed by `node:crypto` through a swappable provider.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -11,25 +11,54 @@ npm install @zudojs/crypto
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
randomBytesSecure,
|
|
16
|
+
hash,
|
|
17
|
+
hashPassword,
|
|
18
|
+
verifyPassword,
|
|
19
|
+
encryptEnvelope,
|
|
20
|
+
decryptEnvelope,
|
|
21
|
+
generateToken,
|
|
22
|
+
} from "@zudojs/crypto";
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
// Hashing (SHA-2 / SHA-3 only; md5 and sha1 are rejected)
|
|
25
|
+
const digest = await hash("hello", { algorithm: "sha256", encoding: "hex" });
|
|
26
|
+
console.log(digest.encoded);
|
|
27
|
+
|
|
28
|
+
// Password hashing (scrypt, self-describing "v1$scrypt$..." string)
|
|
29
|
+
const stored = await hashPassword("correct horse battery staple");
|
|
30
|
+
const ok = await verifyPassword("correct horse battery staple", stored.encoded);
|
|
31
|
+
|
|
32
|
+
// Authenticated encryption (AES-256-GCM, 12-byte IV, 16-byte tag)
|
|
33
|
+
const key = await randomBytesSecure(32);
|
|
34
|
+
const envelope = await encryptEnvelope(new TextEncoder().encode("secret"), key);
|
|
35
|
+
const plaintext = await decryptEnvelope(envelope, key);
|
|
36
|
+
|
|
37
|
+
// Opaque tokens
|
|
38
|
+
const sessionToken = await generateToken({ bytes: 32, prefix: "sess_" });
|
|
20
39
|
```
|
|
21
40
|
|
|
22
41
|
## Features
|
|
23
42
|
|
|
24
|
-
- Hashing
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
43
|
+
- Hashing: SHA-256/384/512 and SHA3-256/384/512, HMAC (keys of at least 16 bytes)
|
|
44
|
+
- Authenticated encryption: AES-256-GCM with strict IV (12 bytes) and tag (16 bytes) validation, plus a versioned string envelope
|
|
45
|
+
- Password hashing: scrypt (default, OWASP parameters) and PBKDF2-HMAC (provider level), versioned self-describing encoding, bounded parameters on verification
|
|
46
|
+
- Key derivation: PBKDF2 (sha256/384/512, 600 000 iterations by default) and scrypt (cost, block size, parallelization, memory bound)
|
|
47
|
+
- Digital signatures: Ed25519, RSA-SHA256/384/512, ECDSA-SHA256/384/512; the algorithm label is bound to the key type
|
|
48
|
+
- Secure random: unbiased integers up to 2^48, UUID v4, bytes, alphabets, numeric codes
|
|
49
|
+
- Opaque tokens (API keys, sessions, refresh, CSRF, OTP) with SHA-256 storage hashes
|
|
50
|
+
- Encoding helpers (hex, base64, base64url, strict UTF-8) with canonical-form validation and constant-time comparison
|
|
51
|
+
- Provider injection: `setDefaultCryptoProvider`, `createCryptoService({ provider })`, `createCryptoFactory({ provider })`, or a `provider` option on any helper
|
|
52
|
+
|
|
53
|
+
Not implemented (and not advertised by the types): bcrypt, Argon2, ChaCha20-Poly1305, AES-CBC, X25519.
|
|
54
|
+
|
|
55
|
+
## Errors
|
|
56
|
+
|
|
57
|
+
Failures throw `CryptoError` from `@zudojs/errors` with a stable `code` (`ERR_CRYPTO_CIPHER`, `ERR_CRYPTO_HASH`, ...) and the underlying Node error as `cause`. `verifyPassword` and `verifyTokenHash` return `false` (never throw) for wrong or malformed inputs.
|
|
29
58
|
|
|
30
59
|
## Use Cases
|
|
31
60
|
|
|
32
|
-
- Password
|
|
33
|
-
- API token generation
|
|
61
|
+
- Password storage and login verification
|
|
62
|
+
- API token generation and storage
|
|
34
63
|
- Data encryption at rest
|
|
35
|
-
- Secure random values
|
|
64
|
+
- Secure random values and one-time codes
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Performs a constant-time comparison of two byte arrays.
|
|
3
3
|
*
|
|
4
|
-
* Returns false immediately if the lengths differ.
|
|
5
|
-
*
|
|
4
|
+
* Returns false immediately if the lengths differ. This leaks only the
|
|
5
|
+
* fact that the lengths differ, which is acceptable for fixed-size
|
|
6
|
+
* values such as digests, MACs and tokens; do not rely on this function
|
|
7
|
+
* to hide the length of variable-length secrets.
|
|
8
|
+
*
|
|
9
|
+
* The byte-wise comparison is delegated to `node:crypto.timingSafeEqual`.
|
|
6
10
|
*/
|
|
7
11
|
export declare function timingSafeEqual(left: Uint8Array, right: Uint8Array): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Performs a constant-time comparison of two strings by their UTF-8 bytes.
|
|
14
|
+
*/
|
|
15
|
+
export declare function timingSafeEqualString(left: string, right: string): boolean;
|
|
8
16
|
//# sourceMappingURL=compare.helper.d.ts.map
|
|
@@ -1,17 +1,33 @@
|
|
|
1
|
+
import { timingSafeEqual as nodeTimingSafeEqual } from "node:crypto";
|
|
1
2
|
/**
|
|
2
3
|
* Performs a constant-time comparison of two byte arrays.
|
|
3
4
|
*
|
|
4
|
-
* Returns false immediately if the lengths differ.
|
|
5
|
-
*
|
|
5
|
+
* Returns false immediately if the lengths differ. This leaks only the
|
|
6
|
+
* fact that the lengths differ, which is acceptable for fixed-size
|
|
7
|
+
* values such as digests, MACs and tokens; do not rely on this function
|
|
8
|
+
* to hide the length of variable-length secrets.
|
|
9
|
+
*
|
|
10
|
+
* The byte-wise comparison is delegated to `node:crypto.timingSafeEqual`.
|
|
6
11
|
*/
|
|
7
12
|
export function timingSafeEqual(left, right) {
|
|
13
|
+
if (!(left instanceof Uint8Array) || !(right instanceof Uint8Array)) {
|
|
14
|
+
throw new TypeError("timingSafeEqual arguments must be Uint8Array.");
|
|
15
|
+
}
|
|
8
16
|
if (left.byteLength !== right.byteLength) {
|
|
9
17
|
return false;
|
|
10
18
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
if (left.byteLength === 0) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return nodeTimingSafeEqual(left, right);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Performs a constant-time comparison of two strings by their UTF-8 bytes.
|
|
26
|
+
*/
|
|
27
|
+
export function timingSafeEqualString(left, right) {
|
|
28
|
+
if (typeof left !== "string" || typeof right !== "string") {
|
|
29
|
+
return false;
|
|
14
30
|
}
|
|
15
|
-
return
|
|
31
|
+
return timingSafeEqual(Buffer.from(left, "utf8"), Buffer.from(right, "utf8"));
|
|
16
32
|
}
|
|
17
33
|
//# sourceMappingURL=compare.helper.js.map
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import type { CryptoProvider } from "../cryptoProvider/index.js";
|
|
1
2
|
/**
|
|
2
3
|
* Options used when encrypting data.
|
|
4
|
+
*
|
|
5
|
+
* `iv`, when supplied, must be exactly 12 bytes and MUST be unique per
|
|
6
|
+
* key. Reusing an IV under the same key with AES-GCM leaks the XOR of the
|
|
7
|
+
* plaintexts and allows authentication-key recovery; omit it to have a
|
|
8
|
+
* fresh random IV drawn for every call.
|
|
3
9
|
*/
|
|
4
10
|
export interface CipherOptions {
|
|
5
11
|
readonly iv?: Uint8Array;
|
|
6
12
|
readonly aad?: Uint8Array;
|
|
13
|
+
readonly provider?: CryptoProvider;
|
|
7
14
|
}
|
|
8
15
|
/**
|
|
9
16
|
* Authenticated encryption result.
|
|
@@ -20,6 +27,9 @@ export interface CipherResult {
|
|
|
20
27
|
export declare function encrypt(plaintext: Uint8Array, key: Uint8Array, options?: CipherOptions): Promise<CipherResult>;
|
|
21
28
|
/**
|
|
22
29
|
* Decrypts AES-256-GCM ciphertext.
|
|
30
|
+
*
|
|
31
|
+
* The IV must be 12 bytes and the authentication tag 16 bytes; truncated
|
|
32
|
+
* tags are rejected before the cipher is touched.
|
|
23
33
|
*/
|
|
24
|
-
export declare function decrypt(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
|
|
34
|
+
export declare function decrypt(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array, aad?: Uint8Array, provider?: CryptoProvider): Promise<Uint8Array>;
|
|
25
35
|
//# sourceMappingURL=cryptoCipher.core.d.ts.map
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { getDefaultCryptoProvider } from "../cryptoProvider/cryptoProvider.default.js";
|
|
2
|
+
import { AES_GCM } from "../cryptoConstants/cryptoConstants.type.js";
|
|
3
|
+
import { CryptoOperation } from "@zudojs/errors";
|
|
4
|
+
import { cipherError } from "../cryptoErrors/cryptoErrors.helper.js";
|
|
3
5
|
/**
|
|
4
6
|
* Encrypts data using AES-256-GCM.
|
|
5
7
|
*/
|
|
6
8
|
export async function encrypt(plaintext, key, options = {}) {
|
|
9
|
+
if (options.iv !== undefined && options.iv.byteLength !== AES_GCM.IV_BYTES) {
|
|
10
|
+
throw cipherError(`AES-256-GCM iv must be ${AES_GCM.IV_BYTES} bytes.`, CryptoOperation.ENCRYPT, "aes-256-gcm");
|
|
11
|
+
}
|
|
12
|
+
const provider = options.provider ?? getDefaultCryptoProvider();
|
|
7
13
|
const encrypted = await provider.encrypt({
|
|
8
14
|
key,
|
|
9
15
|
plaintext,
|
|
@@ -19,8 +25,18 @@ export async function encrypt(plaintext, key, options = {}) {
|
|
|
19
25
|
}
|
|
20
26
|
/**
|
|
21
27
|
* Decrypts AES-256-GCM ciphertext.
|
|
28
|
+
*
|
|
29
|
+
* The IV must be 12 bytes and the authentication tag 16 bytes; truncated
|
|
30
|
+
* tags are rejected before the cipher is touched.
|
|
22
31
|
*/
|
|
23
|
-
export async function decrypt(ciphertext, key, iv, authTag, aad) {
|
|
32
|
+
export async function decrypt(ciphertext, key, iv, authTag, aad, provider = getDefaultCryptoProvider()) {
|
|
33
|
+
if (!(iv instanceof Uint8Array) || iv.byteLength !== AES_GCM.IV_BYTES) {
|
|
34
|
+
throw cipherError(`AES-256-GCM iv must be ${AES_GCM.IV_BYTES} bytes.`, CryptoOperation.DECRYPT, "aes-256-gcm");
|
|
35
|
+
}
|
|
36
|
+
if (!(authTag instanceof Uint8Array) ||
|
|
37
|
+
authTag.byteLength !== AES_GCM.AUTH_TAG_BYTES) {
|
|
38
|
+
throw cipherError(`AES-256-GCM authentication tag must be ${AES_GCM.AUTH_TAG_BYTES} bytes.`, CryptoOperation.DECRYPT, "aes-256-gcm");
|
|
39
|
+
}
|
|
24
40
|
return provider.decrypt({
|
|
25
41
|
key,
|
|
26
42
|
encrypted: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CryptoProvider } from "../cryptoProvider/index.js";
|
|
1
2
|
import type { CipherOptions } from "./cryptoCipher.core.js";
|
|
2
3
|
/**
|
|
3
4
|
* Creates an encrypted envelope suitable for storage or transport.
|
|
@@ -6,11 +7,15 @@ import type { CipherOptions } from "./cryptoCipher.core.js";
|
|
|
6
7
|
*
|
|
7
8
|
* version.algorithm.iv.authTag.ciphertext
|
|
8
9
|
*
|
|
9
|
-
* All binary fields are Base64URL encoded.
|
|
10
|
+
* All binary fields are canonical Base64URL encoded.
|
|
10
11
|
*/
|
|
11
12
|
export declare function encryptEnvelope(plaintext: Uint8Array, key: Uint8Array, options?: CipherOptions): Promise<string>;
|
|
12
13
|
/**
|
|
13
14
|
* Decrypts an encrypted envelope.
|
|
15
|
+
*
|
|
16
|
+
* Every field is validated (version, algorithm, canonical Base64URL, IV and
|
|
17
|
+
* tag lengths) before the cipher is invoked; malformed envelopes and failed
|
|
18
|
+
* authentication both surface as `CryptoError` with code `ERR_CRYPTO_CIPHER`.
|
|
14
19
|
*/
|
|
15
|
-
export declare function decryptEnvelope(envelope: string, key: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
|
|
20
|
+
export declare function decryptEnvelope(envelope: string, key: Uint8Array, aad?: Uint8Array, provider?: CryptoProvider): Promise<Uint8Array>;
|
|
16
21
|
//# sourceMappingURL=cryptoCipher.envelope.d.ts.map
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { encrypt, decrypt } from "./cryptoCipher.core.js";
|
|
2
|
+
import { AES_GCM } from "../cryptoConstants/cryptoConstants.type.js";
|
|
3
|
+
import { fromBase64Url } from "../cryptoEncoding/encoding/cryptoEncoding.base64url.js";
|
|
4
|
+
import { CryptoOperation } from "@zudojs/errors";
|
|
5
|
+
import { cipherError } from "../cryptoErrors/cryptoErrors.helper.js";
|
|
2
6
|
/**
|
|
3
7
|
* Creates an encrypted envelope suitable for storage or transport.
|
|
4
8
|
*
|
|
@@ -6,7 +10,7 @@ import { encrypt, decrypt } from "./cryptoCipher.core.js";
|
|
|
6
10
|
*
|
|
7
11
|
* version.algorithm.iv.authTag.ciphertext
|
|
8
12
|
*
|
|
9
|
-
* All binary fields are Base64URL encoded.
|
|
13
|
+
* All binary fields are canonical Base64URL encoded.
|
|
10
14
|
*/
|
|
11
15
|
export async function encryptEnvelope(plaintext, key, options = {}) {
|
|
12
16
|
const result = await encrypt(plaintext, key, options);
|
|
@@ -20,31 +24,46 @@ export async function encryptEnvelope(plaintext, key, options = {}) {
|
|
|
20
24
|
}
|
|
21
25
|
/**
|
|
22
26
|
* Decrypts an encrypted envelope.
|
|
27
|
+
*
|
|
28
|
+
* Every field is validated (version, algorithm, canonical Base64URL, IV and
|
|
29
|
+
* tag lengths) before the cipher is invoked; malformed envelopes and failed
|
|
30
|
+
* authentication both surface as `CryptoError` with code `ERR_CRYPTO_CIPHER`.
|
|
23
31
|
*/
|
|
24
|
-
export async function decryptEnvelope(envelope, key, aad) {
|
|
32
|
+
export async function decryptEnvelope(envelope, key, aad, provider) {
|
|
25
33
|
if (typeof envelope !== "string") {
|
|
26
|
-
throw
|
|
34
|
+
throw envelopeError("Encrypted envelope must be a string.");
|
|
27
35
|
}
|
|
28
36
|
const parts = envelope.split(".");
|
|
29
37
|
if (parts.length !== 5) {
|
|
30
|
-
throw
|
|
38
|
+
throw envelopeError("Invalid encrypted envelope.");
|
|
31
39
|
}
|
|
32
40
|
const [version, algorithm, encodedIv, encodedAuthTag, encodedCiphertext] = parts;
|
|
33
41
|
if (version !== "v1") {
|
|
34
|
-
throw
|
|
42
|
+
throw envelopeError(`Unsupported encrypted envelope version: ${version}.`);
|
|
35
43
|
}
|
|
36
44
|
if (algorithm !== "aes-256-gcm") {
|
|
37
|
-
throw
|
|
45
|
+
throw envelopeError(`Unsupported envelope algorithm: ${algorithm}.`);
|
|
46
|
+
}
|
|
47
|
+
const iv = decodeField(encodedIv, "iv");
|
|
48
|
+
const authTag = decodeField(encodedAuthTag, "authentication tag");
|
|
49
|
+
const ciphertext = decodeField(encodedCiphertext, "ciphertext");
|
|
50
|
+
if (iv.byteLength !== AES_GCM.IV_BYTES) {
|
|
51
|
+
throw envelopeError(`Encrypted envelope iv must be ${AES_GCM.IV_BYTES} bytes.`);
|
|
52
|
+
}
|
|
53
|
+
if (authTag.byteLength !== AES_GCM.AUTH_TAG_BYTES) {
|
|
54
|
+
throw envelopeError(`Encrypted envelope authentication tag must be ${AES_GCM.AUTH_TAG_BYTES} bytes.`);
|
|
38
55
|
}
|
|
39
|
-
|
|
40
|
-
const authTag = decodeBase64Url(encodedAuthTag);
|
|
41
|
-
const ciphertext = decodeBase64Url(encodedCiphertext);
|
|
42
|
-
return decrypt(ciphertext, key, iv, authTag, aad);
|
|
56
|
+
return decrypt(ciphertext, key, iv, authTag, aad, provider);
|
|
43
57
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
58
|
+
function decodeField(value, name) {
|
|
59
|
+
try {
|
|
60
|
+
return fromBase64Url(value);
|
|
47
61
|
}
|
|
48
|
-
|
|
62
|
+
catch (error) {
|
|
63
|
+
throw envelopeError(`Invalid encrypted envelope ${name}.`, error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function envelopeError(message, cause) {
|
|
67
|
+
return cipherError(message, CryptoOperation.DECRYPT, "aes-256-gcm", cause);
|
|
49
68
|
}
|
|
50
69
|
//# sourceMappingURL=cryptoCipher.envelope.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CryptoProvider } from "../cryptoProvider/index.js";
|
|
1
2
|
import type { CipherOptions, CipherResult } from "./cryptoCipher.core.js";
|
|
2
3
|
/**
|
|
3
4
|
* Encrypts a UTF-8 string using AES-256-GCM.
|
|
@@ -6,5 +7,5 @@ export declare function encryptString(plaintext: string, key: Uint8Array, option
|
|
|
6
7
|
/**
|
|
7
8
|
* Decrypts AES-256-GCM ciphertext into a UTF-8 string.
|
|
8
9
|
*/
|
|
9
|
-
export declare function decryptString(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array, aad?: Uint8Array): Promise<string>;
|
|
10
|
+
export declare function decryptString(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array, aad?: Uint8Array, provider?: CryptoProvider): Promise<string>;
|
|
10
11
|
//# sourceMappingURL=cryptoCipher.string.d.ts.map
|
|
@@ -8,8 +8,8 @@ export async function encryptString(plaintext, key, options = {}) {
|
|
|
8
8
|
/**
|
|
9
9
|
* Decrypts AES-256-GCM ciphertext into a UTF-8 string.
|
|
10
10
|
*/
|
|
11
|
-
export async function decryptString(ciphertext, key, iv, authTag, aad) {
|
|
12
|
-
const plaintext = await decrypt(ciphertext, key, iv, authTag, aad);
|
|
11
|
+
export async function decryptString(ciphertext, key, iv, authTag, aad, provider) {
|
|
12
|
+
const plaintext = await decrypt(ciphertext, key, iv, authTag, aad, provider);
|
|
13
13
|
return Buffer.from(plaintext).toString("utf8");
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=cryptoCipher.string.js.map
|
|
@@ -15,6 +15,15 @@ export declare function isKeyDerivationAlgorithm(algorithm: CryptoAlgorithm): bo
|
|
|
15
15
|
* Returns true when an algorithm is a message authentication algorithm.
|
|
16
16
|
*/
|
|
17
17
|
export declare function isMacAlgorithm(algorithm: CryptoAlgorithm): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Returns true when an algorithm is a digital signature algorithm.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isSignatureAlgorithm(algorithm: CryptoAlgorithm): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Returns true when an algorithm is a symmetric key algorithm
|
|
24
|
+
* (encryption, MAC or key derivation output).
|
|
25
|
+
*/
|
|
26
|
+
export declare function isSymmetricKeyAlgorithm(algorithm: CryptoAlgorithm): boolean;
|
|
18
27
|
/**
|
|
19
28
|
* Returns true when the supplied value is a supported algorithm.
|
|
20
29
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CryptoAlgorithm, AEAD_ALGORITHMS, HASH_ALGORITHMS, KEY_DERIVATION_ALGORITHMS, MAC_ALGORITHMS, } from "./cryptoConstants.type.js";
|
|
1
|
+
import { CryptoAlgorithm, AEAD_ALGORITHMS, HASH_ALGORITHMS, KEY_DERIVATION_ALGORITHMS, MAC_ALGORITHMS, SIGNATURE_ALGORITHMS, } from "./cryptoConstants.type.js";
|
|
2
2
|
/**
|
|
3
3
|
* Returns true when an algorithm provides authenticated encryption.
|
|
4
4
|
*/
|
|
@@ -23,6 +23,21 @@ export function isKeyDerivationAlgorithm(algorithm) {
|
|
|
23
23
|
export function isMacAlgorithm(algorithm) {
|
|
24
24
|
return MAC_ALGORITHMS.includes(algorithm);
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns true when an algorithm is a digital signature algorithm.
|
|
28
|
+
*/
|
|
29
|
+
export function isSignatureAlgorithm(algorithm) {
|
|
30
|
+
return SIGNATURE_ALGORITHMS.includes(algorithm);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns true when an algorithm is a symmetric key algorithm
|
|
34
|
+
* (encryption, MAC or key derivation output).
|
|
35
|
+
*/
|
|
36
|
+
export function isSymmetricKeyAlgorithm(algorithm) {
|
|
37
|
+
return (isAeadAlgorithm(algorithm) ||
|
|
38
|
+
isMacAlgorithm(algorithm) ||
|
|
39
|
+
isKeyDerivationAlgorithm(algorithm));
|
|
40
|
+
}
|
|
26
41
|
/**
|
|
27
42
|
* Returns true when the supplied value is a supported algorithm.
|
|
28
43
|
*/
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Password hashing constants.
|
|
3
|
+
*
|
|
4
|
+
* Defaults follow current OWASP Password Storage Cheat Sheet guidance:
|
|
5
|
+
* scrypt N=2^14, r=8, p=1 (minimum) and PBKDF2-HMAC-SHA256 with 600 000
|
|
6
|
+
* iterations. `LIMITS` bounds parameters that are read back from stored
|
|
7
|
+
* hashes so that a tampered or foreign record cannot force unbounded work.
|
|
3
8
|
*/
|
|
4
9
|
export declare const PASSWORD_HASH: Readonly<{
|
|
5
10
|
readonly SALT_BYTES: 16;
|
|
@@ -10,15 +15,43 @@ export declare const PASSWORD_HASH: Readonly<{
|
|
|
10
15
|
PARALLELIZATION: 1;
|
|
11
16
|
}>;
|
|
12
17
|
readonly PBKDF2: Readonly<{
|
|
13
|
-
ITERATIONS:
|
|
18
|
+
ITERATIONS: 600000;
|
|
19
|
+
/**
|
|
20
|
+
* Floor for stored or caller-supplied iteration counts. Kept below the
|
|
21
|
+
* default so hashes produced by other systems with older (but still
|
|
22
|
+
* NIST-compliant) parameters remain verifiable; new hashes always use
|
|
23
|
+
* `ITERATIONS`.
|
|
24
|
+
*/
|
|
25
|
+
MIN_ITERATIONS: 100000;
|
|
14
26
|
DIGEST: "sha256";
|
|
15
27
|
}>;
|
|
28
|
+
readonly LIMITS: Readonly<{
|
|
29
|
+
MIN_SALT_BYTES: 16;
|
|
30
|
+
MAX_SALT_BYTES: 64;
|
|
31
|
+
MIN_KEY_BYTES: 16;
|
|
32
|
+
MAX_KEY_BYTES: 64;
|
|
33
|
+
MIN_SCRYPT_COST: 2;
|
|
34
|
+
MAX_SCRYPT_COST: number;
|
|
35
|
+
MAX_SCRYPT_BLOCK_SIZE: 32;
|
|
36
|
+
MAX_SCRYPT_PARALLELIZATION: 16;
|
|
37
|
+
/**
|
|
38
|
+
* Upper bound on `128 * N * r` (the scrypt working memory in bytes) so
|
|
39
|
+
* that a stored hash cannot combine the individual maxima into a
|
|
40
|
+
* multi-gigabyte allocation.
|
|
41
|
+
*/
|
|
42
|
+
MAX_SCRYPT_MEMORY_BYTES: number;
|
|
43
|
+
MAX_PBKDF2_ITERATIONS: 10000000;
|
|
44
|
+
}>;
|
|
16
45
|
}>;
|
|
17
46
|
/**
|
|
18
47
|
* Password policy defaults.
|
|
19
48
|
*
|
|
20
49
|
* These values are intentionally conservative defaults.
|
|
21
50
|
* Applications may impose stricter requirements.
|
|
51
|
+
*
|
|
52
|
+
* `MAX_LENGTH` is measured in UTF-16 code units and is enforced by
|
|
53
|
+
* `hashPassword`/`verifyPassword` to bound the work an unauthenticated
|
|
54
|
+
* caller can trigger.
|
|
22
55
|
*/
|
|
23
56
|
export declare const PASSWORD_POLICY: Readonly<{
|
|
24
57
|
readonly MIN_LENGTH: 8;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { TimeMs } from "@zudojs/constants";
|
|
2
2
|
/**
|
|
3
3
|
* Password hashing constants.
|
|
4
|
+
*
|
|
5
|
+
* Defaults follow current OWASP Password Storage Cheat Sheet guidance:
|
|
6
|
+
* scrypt N=2^14, r=8, p=1 (minimum) and PBKDF2-HMAC-SHA256 with 600 000
|
|
7
|
+
* iterations. `LIMITS` bounds parameters that are read back from stored
|
|
8
|
+
* hashes so that a tampered or foreign record cannot force unbounded work.
|
|
4
9
|
*/
|
|
5
10
|
export const PASSWORD_HASH = Object.freeze({
|
|
6
11
|
SALT_BYTES: 16,
|
|
@@ -11,15 +16,43 @@ export const PASSWORD_HASH = Object.freeze({
|
|
|
11
16
|
PARALLELIZATION: 1,
|
|
12
17
|
}),
|
|
13
18
|
PBKDF2: Object.freeze({
|
|
14
|
-
ITERATIONS:
|
|
19
|
+
ITERATIONS: 600_000,
|
|
20
|
+
/**
|
|
21
|
+
* Floor for stored or caller-supplied iteration counts. Kept below the
|
|
22
|
+
* default so hashes produced by other systems with older (but still
|
|
23
|
+
* NIST-compliant) parameters remain verifiable; new hashes always use
|
|
24
|
+
* `ITERATIONS`.
|
|
25
|
+
*/
|
|
26
|
+
MIN_ITERATIONS: 100_000,
|
|
15
27
|
DIGEST: "sha256",
|
|
16
28
|
}),
|
|
29
|
+
LIMITS: Object.freeze({
|
|
30
|
+
MIN_SALT_BYTES: 16,
|
|
31
|
+
MAX_SALT_BYTES: 64,
|
|
32
|
+
MIN_KEY_BYTES: 16,
|
|
33
|
+
MAX_KEY_BYTES: 64,
|
|
34
|
+
MIN_SCRYPT_COST: 2,
|
|
35
|
+
MAX_SCRYPT_COST: 2 ** 20,
|
|
36
|
+
MAX_SCRYPT_BLOCK_SIZE: 32,
|
|
37
|
+
MAX_SCRYPT_PARALLELIZATION: 16,
|
|
38
|
+
/**
|
|
39
|
+
* Upper bound on `128 * N * r` (the scrypt working memory in bytes) so
|
|
40
|
+
* that a stored hash cannot combine the individual maxima into a
|
|
41
|
+
* multi-gigabyte allocation.
|
|
42
|
+
*/
|
|
43
|
+
MAX_SCRYPT_MEMORY_BYTES: 1024 * 1024 * 1024,
|
|
44
|
+
MAX_PBKDF2_ITERATIONS: 10_000_000,
|
|
45
|
+
}),
|
|
17
46
|
});
|
|
18
47
|
/**
|
|
19
48
|
* Password policy defaults.
|
|
20
49
|
*
|
|
21
50
|
* These values are intentionally conservative defaults.
|
|
22
51
|
* Applications may impose stricter requirements.
|
|
52
|
+
*
|
|
53
|
+
* `MAX_LENGTH` is measured in UTF-16 code units and is enforced by
|
|
54
|
+
* `hashPassword`/`verifyPassword` to bound the work an unauthenticated
|
|
55
|
+
* caller can trigger.
|
|
23
56
|
*/
|
|
24
57
|
export const PASSWORD_POLICY = Object.freeze({
|
|
25
58
|
MIN_LENGTH: 8,
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Cryptographic algorithms implemented by Zudojs.
|
|
3
|
+
*
|
|
4
|
+
* Every member listed here is implemented by the Node provider. Algorithms
|
|
5
|
+
* that are not implemented (AES-CBC, ChaCha20-Poly1305, Argon2id, X25519,
|
|
6
|
+
* bcrypt) are deliberately absent so that the type system and the runtime
|
|
7
|
+
* agree on what is supported.
|
|
3
8
|
*/
|
|
4
9
|
export declare enum CryptoAlgorithm {
|
|
5
10
|
AES_256_GCM = "aes-256-gcm",
|
|
6
|
-
AES_256_CBC = "aes-256-cbc",
|
|
7
|
-
CHACHA20_POLY1305 = "chacha20-poly1305",
|
|
8
11
|
SHA_256 = "sha256",
|
|
9
12
|
SHA_384 = "sha384",
|
|
10
13
|
SHA_512 = "sha512",
|
|
@@ -15,16 +18,15 @@ export declare enum CryptoAlgorithm {
|
|
|
15
18
|
HMAC_SHA384 = "hmac-sha384",
|
|
16
19
|
HMAC_SHA512 = "hmac-sha512",
|
|
17
20
|
PBKDF2_SHA256 = "pbkdf2-sha256",
|
|
21
|
+
PBKDF2_SHA384 = "pbkdf2-sha384",
|
|
18
22
|
PBKDF2_SHA512 = "pbkdf2-sha512",
|
|
19
23
|
SCRYPT = "scrypt",
|
|
20
|
-
|
|
21
|
-
ED25519 = "ed25519",
|
|
22
|
-
X25519 = "x25519"
|
|
24
|
+
ED25519 = "ed25519"
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* Algorithms that provide authenticated encryption.
|
|
26
28
|
*/
|
|
27
|
-
export declare const AEAD_ALGORITHMS: readonly [CryptoAlgorithm.AES_256_GCM
|
|
29
|
+
export declare const AEAD_ALGORITHMS: readonly [CryptoAlgorithm.AES_256_GCM];
|
|
28
30
|
/**
|
|
29
31
|
* Algorithms intended for hashing.
|
|
30
32
|
*/
|
|
@@ -32,13 +34,25 @@ export declare const HASH_ALGORITHMS: readonly [CryptoAlgorithm.SHA_256, CryptoA
|
|
|
32
34
|
/**
|
|
33
35
|
* Algorithms intended for password/key derivation.
|
|
34
36
|
*/
|
|
35
|
-
export declare const KEY_DERIVATION_ALGORITHMS: readonly [CryptoAlgorithm.PBKDF2_SHA256, CryptoAlgorithm.
|
|
37
|
+
export declare const KEY_DERIVATION_ALGORITHMS: readonly [CryptoAlgorithm.PBKDF2_SHA256, CryptoAlgorithm.PBKDF2_SHA384, CryptoAlgorithm.PBKDF2_SHA512, CryptoAlgorithm.SCRYPT];
|
|
36
38
|
/**
|
|
37
39
|
* Algorithms intended for message authentication.
|
|
38
40
|
*/
|
|
39
41
|
export declare const MAC_ALGORITHMS: readonly [CryptoAlgorithm.HMAC_SHA256, CryptoAlgorithm.HMAC_SHA384, CryptoAlgorithm.HMAC_SHA512];
|
|
42
|
+
/**
|
|
43
|
+
* Key algorithms intended for digital signatures.
|
|
44
|
+
*
|
|
45
|
+
* Only Ed25519 keys are representable as a `CryptoKey`. RSA and ECDSA
|
|
46
|
+
* signing is supported through `SignatureAlgorithm` with PEM/DER key
|
|
47
|
+
* material rather than through this enum.
|
|
48
|
+
*/
|
|
49
|
+
export declare const SIGNATURE_ALGORITHMS: readonly [CryptoAlgorithm.ED25519];
|
|
40
50
|
/**
|
|
41
51
|
* AES-GCM constants.
|
|
52
|
+
*
|
|
53
|
+
* The 96-bit IV and 128-bit authentication tag are the only sizes accepted
|
|
54
|
+
* by this package: shorter tags weaken forgery resistance and non-96-bit
|
|
55
|
+
* IVs are GHASH-derived, which shrinks the effective nonce space.
|
|
42
56
|
*/
|
|
43
57
|
export declare const AES_GCM: Readonly<{
|
|
44
58
|
readonly KEY_BYTES: 32;
|
|
@@ -66,6 +80,7 @@ export declare const KEY_SIZE: Readonly<{
|
|
|
66
80
|
readonly AES_256_BITS: 256;
|
|
67
81
|
readonly ED25519_BITS: 256;
|
|
68
82
|
readonly MIN_SYMMETRIC_KEY_BITS: 128;
|
|
83
|
+
readonly MIN_HMAC_KEY_BYTES: 16;
|
|
69
84
|
}>;
|
|
70
85
|
/**
|
|
71
86
|
* Encoding constants.
|
|
@@ -77,19 +92,26 @@ export declare const ENCODING: Readonly<{
|
|
|
77
92
|
readonly UTF8: "utf8";
|
|
78
93
|
}>;
|
|
79
94
|
/**
|
|
80
|
-
* Cryptographic algorithm identifiers.
|
|
95
|
+
* Cryptographic algorithm identifiers as a plain constant object.
|
|
96
|
+
*
|
|
97
|
+
* Mirrors `CryptoAlgorithm` exactly (same names and values) for callers
|
|
98
|
+
* that prefer `as const` objects over enums.
|
|
81
99
|
*/
|
|
82
100
|
export declare const CRYPTO_ALGORITHM: Readonly<{
|
|
83
|
-
readonly
|
|
84
|
-
readonly
|
|
85
|
-
readonly
|
|
101
|
+
readonly AES_256_GCM: "aes-256-gcm";
|
|
102
|
+
readonly SHA_256: "sha256";
|
|
103
|
+
readonly SHA_384: "sha384";
|
|
104
|
+
readonly SHA_512: "sha512";
|
|
86
105
|
readonly SHA3_256: "sha3-256";
|
|
87
106
|
readonly SHA3_384: "sha3-384";
|
|
88
107
|
readonly SHA3_512: "sha3-512";
|
|
89
|
-
readonly
|
|
90
|
-
readonly
|
|
108
|
+
readonly HMAC_SHA256: "hmac-sha256";
|
|
109
|
+
readonly HMAC_SHA384: "hmac-sha384";
|
|
110
|
+
readonly HMAC_SHA512: "hmac-sha512";
|
|
91
111
|
readonly PBKDF2_SHA256: "pbkdf2-sha256";
|
|
112
|
+
readonly PBKDF2_SHA384: "pbkdf2-sha384";
|
|
92
113
|
readonly PBKDF2_SHA512: "pbkdf2-sha512";
|
|
93
114
|
readonly SCRYPT: "scrypt";
|
|
115
|
+
readonly ED25519: "ed25519";
|
|
94
116
|
}>;
|
|
95
117
|
//# sourceMappingURL=cryptoConstants.type.d.ts.map
|