@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
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
import type { CryptoProvider } from "../cryptoProvider/index.js";
|
|
1
2
|
import type { PasswordHashOptions, PasswordHashResult } from "./cryptoPassword.type.js";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Options for `hashPassword` including an optional provider override.
|
|
4
5
|
*/
|
|
5
|
-
export
|
|
6
|
+
export interface HashPasswordOptions extends PasswordHashOptions {
|
|
7
|
+
readonly provider?: CryptoProvider;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Hashes a password using scrypt.
|
|
11
|
+
*
|
|
12
|
+
* `saltBytes` and `keyBytes` are honoured, and the returned `salt`/`hash`
|
|
13
|
+
* are exactly the values inside `encoded`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function hashPassword(password: string, options?: HashPasswordOptions): Promise<PasswordHashResult>;
|
|
6
16
|
/**
|
|
7
17
|
* Verifies a password against an encoded password hash.
|
|
18
|
+
*
|
|
19
|
+
* Returns false (never throws) for wrong passwords and for malformed,
|
|
20
|
+
* foreign or out-of-bounds hash strings. A non-string or over-long
|
|
21
|
+
* password also yields false.
|
|
8
22
|
*/
|
|
9
|
-
export declare function verifyPassword(password: string, encoded: string): Promise<boolean>;
|
|
23
|
+
export declare function verifyPassword(password: string, encoded: string, provider?: CryptoProvider): Promise<boolean>;
|
|
10
24
|
//# sourceMappingURL=cryptoPassword.core.d.ts.map
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getDefaultCryptoProvider } from "../cryptoProvider/cryptoProvider.default.js";
|
|
2
2
|
import { CryptoAlgorithm } from "../cryptoConstants/cryptoConstants.type.js";
|
|
3
|
+
import { PASSWORD_HASH } from "../cryptoConstants/cryptoConstants.security.js";
|
|
3
4
|
import { assertPassword, validateParameters, } from "./cryptoPassword.validate.js";
|
|
4
5
|
import { decodePasswordHash, PASSWORD_FORMAT_VERSION, } from "./cryptoPassword.codec.js";
|
|
5
|
-
const provider = createNodeCryptoProvider();
|
|
6
6
|
/**
|
|
7
|
-
* Hashes a password using
|
|
7
|
+
* Hashes a password using scrypt.
|
|
8
|
+
*
|
|
9
|
+
* `saltBytes` and `keyBytes` are honoured, and the returned `salt`/`hash`
|
|
10
|
+
* are exactly the values inside `encoded`.
|
|
8
11
|
*/
|
|
9
12
|
export async function hashPassword(password, options = {}) {
|
|
10
13
|
assertPassword(password);
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const keyBytes = options.keyBytes ?? 32;
|
|
18
|
-
const cost = options.cost ?? 16_384;
|
|
19
|
-
const blockSize = options.blockSize ?? 8;
|
|
20
|
-
const parallelization = options.parallelization ?? 1;
|
|
14
|
+
const provider = options.provider ?? getDefaultCryptoProvider();
|
|
15
|
+
const saltBytes = options.saltBytes ?? PASSWORD_HASH.SALT_BYTES;
|
|
16
|
+
const keyBytes = options.keyBytes ?? PASSWORD_HASH.KEY_BYTES;
|
|
17
|
+
const cost = options.cost ?? PASSWORD_HASH.SCRYPT.COST;
|
|
18
|
+
const blockSize = options.blockSize ?? PASSWORD_HASH.SCRYPT.BLOCK_SIZE;
|
|
19
|
+
const parallelization = options.parallelization ?? PASSWORD_HASH.SCRYPT.PARALLELIZATION;
|
|
21
20
|
validateParameters({
|
|
22
21
|
saltBytes,
|
|
23
22
|
keyBytes,
|
|
@@ -31,26 +30,35 @@ export async function hashPassword(password, options = {}) {
|
|
|
31
30
|
memoryCost: cost,
|
|
32
31
|
blockSize,
|
|
33
32
|
parallelism: parallelization,
|
|
33
|
+
keyBytes,
|
|
34
|
+
salt,
|
|
34
35
|
});
|
|
35
|
-
const
|
|
36
|
+
const decoded = decodePasswordHash(encoded);
|
|
37
|
+
if (decoded.algorithm !== CryptoAlgorithm.SCRYPT) {
|
|
38
|
+
throw new TypeError("Provider returned a non-scrypt password hash.");
|
|
39
|
+
}
|
|
36
40
|
return Object.freeze({
|
|
37
41
|
algorithm: CryptoAlgorithm.SCRYPT,
|
|
38
42
|
version: PASSWORD_FORMAT_VERSION,
|
|
39
|
-
salt,
|
|
40
|
-
hash,
|
|
43
|
+
salt: decoded.salt,
|
|
44
|
+
hash: decoded.hash,
|
|
41
45
|
encoded,
|
|
42
|
-
cost,
|
|
43
|
-
blockSize,
|
|
44
|
-
parallelization,
|
|
46
|
+
cost: decoded.cost,
|
|
47
|
+
blockSize: decoded.blockSize,
|
|
48
|
+
parallelization: decoded.parallelization,
|
|
45
49
|
});
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* Verifies a password against an encoded password hash.
|
|
53
|
+
*
|
|
54
|
+
* Returns false (never throws) for wrong passwords and for malformed,
|
|
55
|
+
* foreign or out-of-bounds hash strings. A non-string or over-long
|
|
56
|
+
* password also yields false.
|
|
49
57
|
*/
|
|
50
|
-
export async function verifyPassword(password, encoded) {
|
|
58
|
+
export async function verifyPassword(password, encoded, provider = getDefaultCryptoProvider()) {
|
|
51
59
|
try {
|
|
52
60
|
assertPassword(password);
|
|
53
|
-
return provider.verifyPassword(password, encoded);
|
|
61
|
+
return await provider.verifyPassword(password, encoded);
|
|
54
62
|
}
|
|
55
63
|
catch {
|
|
56
64
|
return false;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PASSWORD_HASH } from "../cryptoConstants/cryptoConstants.security.js";
|
|
1
2
|
import { decodePasswordHash } from "./cryptoPassword.codec.js";
|
|
2
3
|
const PASSWORD_MINIMUM_DEFAULT_LENGTH = 8;
|
|
3
4
|
/**
|
|
@@ -5,11 +6,11 @@ const PASSWORD_MINIMUM_DEFAULT_LENGTH = 8;
|
|
|
5
6
|
*/
|
|
6
7
|
export function getDefaultPasswordHashOptions() {
|
|
7
8
|
return {
|
|
8
|
-
saltBytes:
|
|
9
|
-
keyBytes:
|
|
10
|
-
cost:
|
|
11
|
-
blockSize:
|
|
12
|
-
parallelization:
|
|
9
|
+
saltBytes: PASSWORD_HASH.SALT_BYTES,
|
|
10
|
+
keyBytes: PASSWORD_HASH.KEY_BYTES,
|
|
11
|
+
cost: PASSWORD_HASH.SCRYPT.COST,
|
|
12
|
+
blockSize: PASSWORD_HASH.SCRYPT.BLOCK_SIZE,
|
|
13
|
+
parallelization: PASSWORD_HASH.SCRYPT.PARALLELIZATION,
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CryptoAlgorithm } from "../cryptoConstants/cryptoConstants.type.js";
|
|
2
|
+
import type { Pbkdf2Digest } from "../cryptoProvider/cryptoProvider.type.js";
|
|
2
3
|
/**
|
|
3
|
-
* Options used for password hashing.
|
|
4
|
+
* Options used for password hashing (scrypt).
|
|
4
5
|
*/
|
|
5
6
|
export interface PasswordHashOptions {
|
|
6
7
|
readonly saltBytes?: number;
|
|
@@ -11,9 +12,13 @@ export interface PasswordHashOptions {
|
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* Result returned by password hashing.
|
|
15
|
+
*
|
|
16
|
+
* `salt` and `hash` are exactly the values encoded in `encoded`, so a
|
|
17
|
+
* record that stores them in separate columns can be re-encoded with
|
|
18
|
+
* `encodePasswordHash` and verified.
|
|
14
19
|
*/
|
|
15
20
|
export interface PasswordHashResult {
|
|
16
|
-
readonly algorithm: CryptoAlgorithm;
|
|
21
|
+
readonly algorithm: CryptoAlgorithm.SCRYPT;
|
|
17
22
|
readonly version: string;
|
|
18
23
|
readonly salt: Uint8Array;
|
|
19
24
|
readonly hash: Uint8Array;
|
|
@@ -23,15 +28,38 @@ export interface PasswordHashResult {
|
|
|
23
28
|
readonly parallelization: number;
|
|
24
29
|
}
|
|
25
30
|
/**
|
|
26
|
-
* Parameters encoded into a password hash
|
|
31
|
+
* Parameters encoded into a scrypt password hash
|
|
32
|
+
* (`v1$scrypt$N$r$p$salt.hash`).
|
|
27
33
|
*/
|
|
28
|
-
export interface
|
|
34
|
+
export interface ScryptPasswordHashParameters {
|
|
29
35
|
readonly version: string;
|
|
30
|
-
readonly algorithm: CryptoAlgorithm;
|
|
36
|
+
readonly algorithm: CryptoAlgorithm.SCRYPT;
|
|
31
37
|
readonly salt: Uint8Array;
|
|
32
38
|
readonly hash: Uint8Array;
|
|
33
39
|
readonly cost: number;
|
|
34
40
|
readonly blockSize: number;
|
|
35
41
|
readonly parallelization: number;
|
|
36
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Algorithm labels used for PBKDF2 password hashes.
|
|
45
|
+
*/
|
|
46
|
+
export type Pbkdf2PasswordAlgorithm = CryptoAlgorithm.PBKDF2_SHA256 | CryptoAlgorithm.PBKDF2_SHA384 | CryptoAlgorithm.PBKDF2_SHA512;
|
|
47
|
+
/**
|
|
48
|
+
* Parameters encoded into a PBKDF2 password hash
|
|
49
|
+
* (`v1$pbkdf2-<digest>$iterations$salt.hash`).
|
|
50
|
+
*/
|
|
51
|
+
export interface Pbkdf2PasswordHashParameters {
|
|
52
|
+
readonly version: string;
|
|
53
|
+
readonly algorithm: Pbkdf2PasswordAlgorithm;
|
|
54
|
+
readonly digest: Pbkdf2Digest;
|
|
55
|
+
readonly salt: Uint8Array;
|
|
56
|
+
readonly hash: Uint8Array;
|
|
57
|
+
readonly iterations: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Parameters decoded from any supported password hash string.
|
|
61
|
+
*
|
|
62
|
+
* Discriminate on `algorithm` to access algorithm-specific fields.
|
|
63
|
+
*/
|
|
64
|
+
export type PasswordHashParameters = ScryptPasswordHashParameters | Pbkdf2PasswordHashParameters;
|
|
37
65
|
//# sourceMappingURL=cryptoPassword.type.d.ts.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Validates the structural constraints of password hashing
|
|
2
|
+
* Validates the structural constraints of scrypt password hashing
|
|
3
|
+
* parameters, including upper bounds so that parameters read back from a
|
|
4
|
+
* stored hash cannot force unbounded CPU or memory usage.
|
|
3
5
|
*/
|
|
4
6
|
export declare function validateParameters(parameters: {
|
|
5
7
|
readonly saltBytes: number;
|
|
@@ -8,16 +10,25 @@ export declare function validateParameters(parameters: {
|
|
|
8
10
|
readonly blockSize: number;
|
|
9
11
|
readonly parallelization: number;
|
|
10
12
|
}): void;
|
|
13
|
+
/**
|
|
14
|
+
* Validates PBKDF2 password hashing parameters, including upper bounds.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validatePbkdf2Parameters(parameters: {
|
|
17
|
+
readonly saltBytes: number;
|
|
18
|
+
readonly keyBytes: number;
|
|
19
|
+
readonly iterations: number;
|
|
20
|
+
}): void;
|
|
11
21
|
/**
|
|
12
22
|
* Parses a string into a positive safe integer.
|
|
13
23
|
*/
|
|
14
24
|
export declare function parsePositiveInteger(value: string, name: string): number;
|
|
15
25
|
/**
|
|
16
|
-
* Decodes a Base64URL string into bytes.
|
|
26
|
+
* Decodes a non-empty, canonical Base64URL string into bytes.
|
|
17
27
|
*/
|
|
18
28
|
export declare function decodeBase64Url(value: string): Uint8Array;
|
|
19
29
|
/**
|
|
20
|
-
* Asserts that a value is a
|
|
30
|
+
* Asserts that a value is a password string within the policy length
|
|
31
|
+
* bounds (non-empty, at most `PASSWORD_POLICY.MAX_LENGTH` code units).
|
|
21
32
|
*/
|
|
22
33
|
export declare function assertPassword(password: string): void;
|
|
23
34
|
//# sourceMappingURL=cryptoPassword.validate.d.ts.map
|
|
@@ -1,24 +1,54 @@
|
|
|
1
|
+
import { PASSWORD_HASH, PASSWORD_POLICY, } from "../cryptoConstants/cryptoConstants.security.js";
|
|
2
|
+
import { fromBase64Url } from "../cryptoEncoding/encoding/cryptoEncoding.base64url.js";
|
|
3
|
+
const LIMITS = PASSWORD_HASH.LIMITS;
|
|
1
4
|
/**
|
|
2
|
-
* Validates the structural constraints of password hashing
|
|
5
|
+
* Validates the structural constraints of scrypt password hashing
|
|
6
|
+
* parameters, including upper bounds so that parameters read back from a
|
|
7
|
+
* stored hash cannot force unbounded CPU or memory usage.
|
|
3
8
|
*/
|
|
4
9
|
export function validateParameters(parameters) {
|
|
5
|
-
|
|
6
|
-
throw new RangeError("saltBytes must be an integer of at least 16.");
|
|
7
|
-
}
|
|
8
|
-
if (!Number.isInteger(parameters.keyBytes) || parameters.keyBytes < 16) {
|
|
9
|
-
throw new RangeError("keyBytes must be an integer of at least 16.");
|
|
10
|
-
}
|
|
10
|
+
validateSaltAndKeyBytes(parameters.saltBytes, parameters.keyBytes);
|
|
11
11
|
if (!Number.isInteger(parameters.cost) ||
|
|
12
|
-
parameters.cost <
|
|
12
|
+
parameters.cost < LIMITS.MIN_SCRYPT_COST ||
|
|
13
|
+
parameters.cost > LIMITS.MAX_SCRYPT_COST ||
|
|
13
14
|
(parameters.cost & (parameters.cost - 1)) !== 0) {
|
|
14
|
-
throw new RangeError(
|
|
15
|
+
throw new RangeError(`cost must be a power of two between ${LIMITS.MIN_SCRYPT_COST} and ${LIMITS.MAX_SCRYPT_COST}.`);
|
|
15
16
|
}
|
|
16
|
-
if (!Number.isInteger(parameters.blockSize) ||
|
|
17
|
-
|
|
17
|
+
if (!Number.isInteger(parameters.blockSize) ||
|
|
18
|
+
parameters.blockSize <= 0 ||
|
|
19
|
+
parameters.blockSize > LIMITS.MAX_SCRYPT_BLOCK_SIZE) {
|
|
20
|
+
throw new RangeError(`blockSize must be an integer between 1 and ${LIMITS.MAX_SCRYPT_BLOCK_SIZE}.`);
|
|
18
21
|
}
|
|
19
22
|
if (!Number.isInteger(parameters.parallelization) ||
|
|
20
|
-
parameters.parallelization <= 0
|
|
21
|
-
|
|
23
|
+
parameters.parallelization <= 0 ||
|
|
24
|
+
parameters.parallelization > LIMITS.MAX_SCRYPT_PARALLELIZATION) {
|
|
25
|
+
throw new RangeError(`parallelization must be an integer between 1 and ${LIMITS.MAX_SCRYPT_PARALLELIZATION}.`);
|
|
26
|
+
}
|
|
27
|
+
if (128 * parameters.cost * parameters.blockSize > LIMITS.MAX_SCRYPT_MEMORY_BYTES) {
|
|
28
|
+
throw new RangeError(`cost * blockSize exceeds the scrypt memory bound of ${LIMITS.MAX_SCRYPT_MEMORY_BYTES} bytes.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validates PBKDF2 password hashing parameters, including upper bounds.
|
|
33
|
+
*/
|
|
34
|
+
export function validatePbkdf2Parameters(parameters) {
|
|
35
|
+
validateSaltAndKeyBytes(parameters.saltBytes, parameters.keyBytes);
|
|
36
|
+
if (!Number.isInteger(parameters.iterations) ||
|
|
37
|
+
parameters.iterations < PASSWORD_HASH.PBKDF2.MIN_ITERATIONS ||
|
|
38
|
+
parameters.iterations > LIMITS.MAX_PBKDF2_ITERATIONS) {
|
|
39
|
+
throw new RangeError(`iterations must be an integer between ${PASSWORD_HASH.PBKDF2.MIN_ITERATIONS} and ${LIMITS.MAX_PBKDF2_ITERATIONS}.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function validateSaltAndKeyBytes(saltBytes, keyBytes) {
|
|
43
|
+
if (!Number.isInteger(saltBytes) ||
|
|
44
|
+
saltBytes < LIMITS.MIN_SALT_BYTES ||
|
|
45
|
+
saltBytes > LIMITS.MAX_SALT_BYTES) {
|
|
46
|
+
throw new RangeError(`saltBytes must be an integer between ${LIMITS.MIN_SALT_BYTES} and ${LIMITS.MAX_SALT_BYTES}.`);
|
|
47
|
+
}
|
|
48
|
+
if (!Number.isInteger(keyBytes) ||
|
|
49
|
+
keyBytes < LIMITS.MIN_KEY_BYTES ||
|
|
50
|
+
keyBytes > LIMITS.MAX_KEY_BYTES) {
|
|
51
|
+
throw new RangeError(`keyBytes must be an integer between ${LIMITS.MIN_KEY_BYTES} and ${LIMITS.MAX_KEY_BYTES}.`);
|
|
22
52
|
}
|
|
23
53
|
}
|
|
24
54
|
/**
|
|
@@ -35,19 +65,17 @@ export function parsePositiveInteger(value, name) {
|
|
|
35
65
|
return parsed;
|
|
36
66
|
}
|
|
37
67
|
/**
|
|
38
|
-
* Decodes a Base64URL string into bytes.
|
|
68
|
+
* Decodes a non-empty, canonical Base64URL string into bytes.
|
|
39
69
|
*/
|
|
40
70
|
export function decodeBase64Url(value) {
|
|
41
|
-
if (value.length === 0
|
|
71
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
42
72
|
throw new TypeError("Invalid Base64URL value.");
|
|
43
73
|
}
|
|
44
|
-
|
|
45
|
-
throw new TypeError("Invalid Base64URL length.");
|
|
46
|
-
}
|
|
47
|
-
return new Uint8Array(Buffer.from(value, "base64url"));
|
|
74
|
+
return fromBase64Url(value);
|
|
48
75
|
}
|
|
49
76
|
/**
|
|
50
|
-
* Asserts that a value is a
|
|
77
|
+
* Asserts that a value is a password string within the policy length
|
|
78
|
+
* bounds (non-empty, at most `PASSWORD_POLICY.MAX_LENGTH` code units).
|
|
51
79
|
*/
|
|
52
80
|
export function assertPassword(password) {
|
|
53
81
|
if (typeof password !== "string") {
|
|
@@ -56,5 +84,8 @@ export function assertPassword(password) {
|
|
|
56
84
|
if (password.length === 0) {
|
|
57
85
|
throw new TypeError("Password cannot be empty.");
|
|
58
86
|
}
|
|
87
|
+
if (password.length > PASSWORD_POLICY.MAX_LENGTH) {
|
|
88
|
+
throw new RangeError(`Password must not exceed ${PASSWORD_POLICY.MAX_LENGTH} characters.`);
|
|
89
|
+
}
|
|
59
90
|
}
|
|
60
91
|
//# sourceMappingURL=cryptoPassword.validate.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CryptoProvider } from "./cryptoProvider.core.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the process-wide default crypto provider, creating the Node
|
|
4
|
+
* provider lazily on first use.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getDefaultCryptoProvider(): CryptoProvider;
|
|
7
|
+
/**
|
|
8
|
+
* Replaces the process-wide default crypto provider.
|
|
9
|
+
*
|
|
10
|
+
* Every module-level helper (hash, encrypt, hashPassword, generateToken,
|
|
11
|
+
* ...) that is not given an explicit provider uses this one.
|
|
12
|
+
*/
|
|
13
|
+
export declare function setDefaultCryptoProvider(provider: CryptoProvider): void;
|
|
14
|
+
/**
|
|
15
|
+
* Restores the built-in Node provider as the default.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resetDefaultCryptoProvider(): void;
|
|
18
|
+
//# sourceMappingURL=cryptoProvider.default.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createNodeCryptoProvider } from "../node/nodeCryptoProvider/nodeCryptoProvider.factory.js";
|
|
2
|
+
let defaultProvider;
|
|
3
|
+
/**
|
|
4
|
+
* Returns the process-wide default crypto provider, creating the Node
|
|
5
|
+
* provider lazily on first use.
|
|
6
|
+
*/
|
|
7
|
+
export function getDefaultCryptoProvider() {
|
|
8
|
+
if (defaultProvider === undefined) {
|
|
9
|
+
defaultProvider = createNodeCryptoProvider();
|
|
10
|
+
}
|
|
11
|
+
return defaultProvider;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Replaces the process-wide default crypto provider.
|
|
15
|
+
*
|
|
16
|
+
* Every module-level helper (hash, encrypt, hashPassword, generateToken,
|
|
17
|
+
* ...) that is not given an explicit provider uses this one.
|
|
18
|
+
*/
|
|
19
|
+
export function setDefaultCryptoProvider(provider) {
|
|
20
|
+
if (typeof provider !== "object" || provider === null) {
|
|
21
|
+
throw new TypeError("Crypto provider must be an object.");
|
|
22
|
+
}
|
|
23
|
+
defaultProvider = provider;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Restores the built-in Node provider as the default.
|
|
27
|
+
*/
|
|
28
|
+
export function resetDefaultCryptoProvider() {
|
|
29
|
+
defaultProvider = undefined;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=cryptoProvider.default.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { HashAlgorithm, HmacAlgorithm,
|
|
2
|
-
import type { EncryptedData } from "./types/cryptoCipher.type.js";
|
|
3
|
-
import type {
|
|
1
|
+
import type { HashAlgorithm, HmacAlgorithm, CryptoInput, CryptoCapabilities } from "./cryptoProvider.type.js";
|
|
2
|
+
import type { EncryptedData, EncryptOptions, DecryptOptions } from "./types/cryptoCipher.type.js";
|
|
3
|
+
import type { SignOptions, VerifyOptions } from "./types/cryptoSignature.type.js";
|
|
4
|
+
import type { DeriveKeyOptions, PasswordHashProviderOptions } from "./types/cryptoKeyDerivation.type.js";
|
|
4
5
|
/**
|
|
5
6
|
* Provider for cryptographically secure random bytes.
|
|
6
7
|
*/
|
|
@@ -33,17 +34,8 @@ export interface HmacProvider {
|
|
|
33
34
|
export interface EncryptionProvider {
|
|
34
35
|
readonly name: string;
|
|
35
36
|
readonly capabilities: CryptoCapabilities;
|
|
36
|
-
encrypt(options:
|
|
37
|
-
|
|
38
|
-
plaintext: CryptoInput;
|
|
39
|
-
associatedData?: CryptoInput;
|
|
40
|
-
nonce?: Uint8Array;
|
|
41
|
-
}): Promise<EncryptedData>;
|
|
42
|
-
decrypt(options: {
|
|
43
|
-
key: CryptoInput;
|
|
44
|
-
encrypted: EncryptedData;
|
|
45
|
-
associatedData?: CryptoInput;
|
|
46
|
-
}): Promise<Uint8Array>;
|
|
37
|
+
encrypt(options: EncryptOptions): Promise<EncryptedData>;
|
|
38
|
+
decrypt(options: DecryptOptions): Promise<Uint8Array>;
|
|
47
39
|
}
|
|
48
40
|
/**
|
|
49
41
|
* Provider for digital signing.
|
|
@@ -51,17 +43,8 @@ export interface EncryptionProvider {
|
|
|
51
43
|
export interface SigningProvider {
|
|
52
44
|
readonly name: string;
|
|
53
45
|
readonly capabilities: CryptoCapabilities;
|
|
54
|
-
sign(options:
|
|
55
|
-
|
|
56
|
-
data: CryptoInput;
|
|
57
|
-
algorithm?: SignatureAlgorithm;
|
|
58
|
-
}): Promise<Uint8Array>;
|
|
59
|
-
verify(options: {
|
|
60
|
-
key: CryptoInput;
|
|
61
|
-
data: CryptoInput;
|
|
62
|
-
signature: Uint8Array;
|
|
63
|
-
algorithm?: SignatureAlgorithm;
|
|
64
|
-
}): Promise<boolean>;
|
|
46
|
+
sign(options: SignOptions): Promise<Uint8Array>;
|
|
47
|
+
verify(options: VerifyOptions): Promise<boolean>;
|
|
65
48
|
}
|
|
66
49
|
/**
|
|
67
50
|
* Provider for key derivation.
|
|
@@ -77,15 +60,7 @@ export interface KeyDerivationProvider {
|
|
|
77
60
|
export interface PasswordProvider {
|
|
78
61
|
readonly name: string;
|
|
79
62
|
readonly capabilities: CryptoCapabilities;
|
|
80
|
-
hashPassword(password: CryptoInput, options?:
|
|
81
|
-
algorithm?: KeyDerivationAlgorithm;
|
|
82
|
-
memoryCost?: number;
|
|
83
|
-
timeCost?: number;
|
|
84
|
-
blockSize?: number;
|
|
85
|
-
parallelism?: number;
|
|
86
|
-
keyBytes?: number;
|
|
87
|
-
salt?: Uint8Array;
|
|
88
|
-
}): Promise<string>;
|
|
63
|
+
hashPassword(password: CryptoInput, options?: PasswordHashProviderOptions): Promise<string>;
|
|
89
64
|
verifyPassword(password: CryptoInput, hash: string): Promise<boolean>;
|
|
90
65
|
}
|
|
91
66
|
//# sourceMappingURL=cryptoProvider.interface.d.ts.map
|
|
@@ -6,24 +6,33 @@ export type HashAlgorithm = "sha256" | "sha384" | "sha512" | "sha3-256" | "sha3-
|
|
|
6
6
|
* Supported HMAC algorithm identifiers.
|
|
7
7
|
*/
|
|
8
8
|
export type HmacAlgorithm = "sha256" | "sha384" | "sha512";
|
|
9
|
+
/**
|
|
10
|
+
* Supported PBKDF2 digest identifiers.
|
|
11
|
+
*/
|
|
12
|
+
export type Pbkdf2Digest = "sha256" | "sha384" | "sha512";
|
|
9
13
|
/**
|
|
10
14
|
* Supported encryption algorithm identifiers.
|
|
15
|
+
*
|
|
16
|
+
* Only AES-256-GCM is implemented.
|
|
11
17
|
*/
|
|
12
|
-
export type EncryptionAlgorithm = "aes-256-gcm"
|
|
18
|
+
export type EncryptionAlgorithm = "aes-256-gcm";
|
|
13
19
|
/**
|
|
14
20
|
* Supported signature algorithm identifiers.
|
|
15
21
|
*/
|
|
16
22
|
export type SignatureAlgorithm = "ed25519" | "rsa-sha256" | "rsa-sha384" | "rsa-sha512" | "ecdsa-sha256" | "ecdsa-sha384" | "ecdsa-sha512";
|
|
17
23
|
/**
|
|
18
|
-
* Supported key derivation algorithm identifiers.
|
|
24
|
+
* Supported key derivation algorithm identifiers at the provider level.
|
|
19
25
|
*/
|
|
20
|
-
export type KeyDerivationAlgorithm = "pbkdf2" | "scrypt"
|
|
26
|
+
export type KeyDerivationAlgorithm = "pbkdf2" | "scrypt";
|
|
21
27
|
/**
|
|
22
28
|
* Supported encoding formats.
|
|
23
29
|
*/
|
|
24
30
|
export type EncodingFormat = "hex" | "base64" | "base64url" | "utf8";
|
|
25
31
|
/**
|
|
26
32
|
* Normalized cryptographic input.
|
|
33
|
+
*
|
|
34
|
+
* For keys, a `string` is interpreted as PEM text and a `Uint8Array` as
|
|
35
|
+
* either PEM text (when it starts with `-----BEGIN`) or DER bytes.
|
|
27
36
|
*/
|
|
28
37
|
export type CryptoInput = string | Uint8Array | ArrayBuffer;
|
|
29
38
|
/**
|
|
@@ -38,4 +47,24 @@ export interface CryptoCapabilities {
|
|
|
38
47
|
readonly passwordHashing: boolean;
|
|
39
48
|
readonly keyDerivation: boolean;
|
|
40
49
|
}
|
|
50
|
+
export declare const HASH_ALGORITHM_NAMES: ReadonlySet<string>;
|
|
51
|
+
export declare const HMAC_ALGORITHM_NAMES: ReadonlySet<string>;
|
|
52
|
+
export declare const PBKDF2_DIGEST_NAMES: ReadonlySet<string>;
|
|
53
|
+
export declare const SIGNATURE_ALGORITHM_NAMES: ReadonlySet<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Returns whether a value names a supported hash algorithm.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isHashAlgorithmName(value: unknown): value is HashAlgorithm;
|
|
58
|
+
/**
|
|
59
|
+
* Returns whether a value names a supported HMAC algorithm.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isHmacAlgorithmName(value: unknown): value is HmacAlgorithm;
|
|
62
|
+
/**
|
|
63
|
+
* Returns whether a value names a supported PBKDF2 digest.
|
|
64
|
+
*/
|
|
65
|
+
export declare function isPbkdf2Digest(value: unknown): value is Pbkdf2Digest;
|
|
66
|
+
/**
|
|
67
|
+
* Returns whether a value names a supported signature algorithm.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isSignatureAlgorithmName(value: unknown): value is SignatureAlgorithm;
|
|
41
70
|
//# sourceMappingURL=cryptoProvider.type.d.ts.map
|
|
@@ -1,2 +1,41 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const HASH_ALGORITHM_NAMES = new Set(["sha256", "sha384", "sha512", "sha3-256", "sha3-384", "sha3-512"]);
|
|
2
|
+
export const HMAC_ALGORITHM_NAMES = new Set(["sha256", "sha384", "sha512"]);
|
|
3
|
+
export const PBKDF2_DIGEST_NAMES = new Set([
|
|
4
|
+
"sha256",
|
|
5
|
+
"sha384",
|
|
6
|
+
"sha512",
|
|
7
|
+
]);
|
|
8
|
+
export const SIGNATURE_ALGORITHM_NAMES = new Set([
|
|
9
|
+
"ed25519",
|
|
10
|
+
"rsa-sha256",
|
|
11
|
+
"rsa-sha384",
|
|
12
|
+
"rsa-sha512",
|
|
13
|
+
"ecdsa-sha256",
|
|
14
|
+
"ecdsa-sha384",
|
|
15
|
+
"ecdsa-sha512",
|
|
16
|
+
]);
|
|
17
|
+
/**
|
|
18
|
+
* Returns whether a value names a supported hash algorithm.
|
|
19
|
+
*/
|
|
20
|
+
export function isHashAlgorithmName(value) {
|
|
21
|
+
return typeof value === "string" && HASH_ALGORITHM_NAMES.has(value);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns whether a value names a supported HMAC algorithm.
|
|
25
|
+
*/
|
|
26
|
+
export function isHmacAlgorithmName(value) {
|
|
27
|
+
return typeof value === "string" && HMAC_ALGORITHM_NAMES.has(value);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns whether a value names a supported PBKDF2 digest.
|
|
31
|
+
*/
|
|
32
|
+
export function isPbkdf2Digest(value) {
|
|
33
|
+
return typeof value === "string" && PBKDF2_DIGEST_NAMES.has(value);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns whether a value names a supported signature algorithm.
|
|
37
|
+
*/
|
|
38
|
+
export function isSignatureAlgorithmName(value) {
|
|
39
|
+
return typeof value === "string" && SIGNATURE_ALGORITHM_NAMES.has(value);
|
|
40
|
+
}
|
|
2
41
|
//# sourceMappingURL=cryptoProvider.type.js.map
|
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides capability-based provider interfaces for all
|
|
5
5
|
* cryptographic operations, enabling testability and
|
|
6
|
-
* runtime provider selection
|
|
6
|
+
* runtime provider selection via `setDefaultCryptoProvider`
|
|
7
|
+
* or per-call `provider` options.
|
|
7
8
|
*/
|
|
8
9
|
export type { CryptoProvider } from "./cryptoProvider.core.js";
|
|
9
|
-
export type { CryptoCapabilities, HashAlgorithm, HmacAlgorithm, EncryptionAlgorithm, SignatureAlgorithm, KeyDerivationAlgorithm, EncodingFormat, CryptoInput, } from "./cryptoProvider.type.js";
|
|
10
|
+
export type { CryptoCapabilities, HashAlgorithm, HmacAlgorithm, Pbkdf2Digest, EncryptionAlgorithm, SignatureAlgorithm, KeyDerivationAlgorithm, EncodingFormat, CryptoInput, } from "./cryptoProvider.type.js";
|
|
11
|
+
export { isHashAlgorithmName, isHmacAlgorithmName, isPbkdf2Digest, isSignatureAlgorithmName, } from "./cryptoProvider.type.js";
|
|
10
12
|
export type { RandomProvider, HashProvider, HmacProvider, EncryptionProvider, SigningProvider, KeyDerivationProvider, PasswordProvider, } from "./cryptoProvider.interface.js";
|
|
13
|
+
export { getDefaultCryptoProvider, setDefaultCryptoProvider, resetDefaultCryptoProvider, } from "./cryptoProvider.default.js";
|
|
11
14
|
export * from "./types/index.js";
|
|
12
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export { isHashAlgorithmName, isHmacAlgorithmName, isPbkdf2Digest, isSignatureAlgorithmName, } from "./cryptoProvider.type.js";
|
|
2
|
+
export { getDefaultCryptoProvider, setDefaultCryptoProvider, resetDefaultCryptoProvider, } from "./cryptoProvider.default.js";
|
|
1
3
|
export * from "./types/index.js";
|
|
2
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EncryptionAlgorithm } from "../cryptoProvider.type.js";
|
|
1
|
+
import type { CryptoInput, EncryptionAlgorithm } from "../cryptoProvider.type.js";
|
|
2
2
|
/**
|
|
3
3
|
* Result of an encryption operation.
|
|
4
4
|
*/
|
|
@@ -10,19 +10,24 @@ export interface EncryptedData {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Options for encryption.
|
|
13
|
+
*
|
|
14
|
+
* When `nonce` is supplied it must be exactly 12 bytes and MUST be unique
|
|
15
|
+
* per key: reusing a nonce under the same key with AES-GCM leaks the XOR
|
|
16
|
+
* of the plaintexts and allows authentication-key recovery. Omit it to
|
|
17
|
+
* have the provider draw a fresh random nonce.
|
|
13
18
|
*/
|
|
14
19
|
export interface EncryptOptions {
|
|
15
|
-
readonly key:
|
|
16
|
-
readonly plaintext:
|
|
17
|
-
readonly associatedData?:
|
|
20
|
+
readonly key: CryptoInput;
|
|
21
|
+
readonly plaintext: CryptoInput;
|
|
22
|
+
readonly associatedData?: CryptoInput;
|
|
18
23
|
readonly nonce?: Uint8Array;
|
|
19
24
|
}
|
|
20
25
|
/**
|
|
21
26
|
* Options for decryption.
|
|
22
27
|
*/
|
|
23
28
|
export interface DecryptOptions {
|
|
24
|
-
readonly key:
|
|
29
|
+
readonly key: CryptoInput;
|
|
25
30
|
readonly encrypted: EncryptedData;
|
|
26
|
-
readonly associatedData?:
|
|
31
|
+
readonly associatedData?: CryptoInput;
|
|
27
32
|
}
|
|
28
33
|
//# sourceMappingURL=cryptoCipher.type.d.ts.map
|