@zudojs/crypto 1.3.2 → 1.4.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 +5 -5
- package/dist/compare/compare.helper.d.ts +0 -1
- package/dist/compare/compare.helper.js +0 -1
- package/dist/compare/index.d.ts +0 -1
- package/dist/compare/index.js +0 -1
- package/dist/cryptoCipher/cryptoCipher.core.d.ts +12 -1
- package/dist/cryptoCipher/cryptoCipher.core.js +9 -1
- package/dist/cryptoCipher/cryptoCipher.envelope.d.ts +0 -1
- package/dist/cryptoCipher/cryptoCipher.envelope.js +0 -1
- package/dist/cryptoCipher/cryptoCipher.nonceGuard.d.ts +24 -0
- package/dist/cryptoCipher/cryptoCipher.nonceGuard.js +50 -0
- package/dist/cryptoCipher/cryptoCipher.string.d.ts +0 -1
- package/dist/cryptoCipher/cryptoCipher.string.js +0 -1
- package/dist/cryptoCipher/index.d.ts +1 -1
- package/dist/cryptoCipher/index.js +1 -1
- package/dist/cryptoConstants/cryptoConstants.config.d.ts +0 -1
- package/dist/cryptoConstants/cryptoConstants.config.js +0 -1
- package/dist/cryptoConstants/cryptoConstants.guard.d.ts +0 -1
- package/dist/cryptoConstants/cryptoConstants.guard.js +0 -1
- package/dist/cryptoConstants/cryptoConstants.security.d.ts +0 -1
- package/dist/cryptoConstants/cryptoConstants.security.js +0 -1
- package/dist/cryptoConstants/cryptoConstants.token.d.ts +0 -1
- package/dist/cryptoConstants/cryptoConstants.token.js +0 -1
- package/dist/cryptoConstants/cryptoConstants.type.d.ts +0 -1
- package/dist/cryptoConstants/cryptoConstants.type.js +0 -1
- package/dist/cryptoConstants/index.d.ts +0 -1
- package/dist/cryptoConstants/index.js +0 -1
- package/dist/cryptoEncoding/cryptoEncoding.arrayBuffer.d.ts +0 -1
- package/dist/cryptoEncoding/cryptoEncoding.arrayBuffer.js +0 -1
- package/dist/cryptoEncoding/cryptoEncoding.compare.d.ts +0 -1
- package/dist/cryptoEncoding/cryptoEncoding.compare.js +0 -1
- package/dist/cryptoEncoding/cryptoEncoding.core.d.ts +0 -1
- package/dist/cryptoEncoding/cryptoEncoding.core.js +0 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.base64.d.ts +0 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.base64.js +0 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.base64url.d.ts +0 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.base64url.js +0 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.hex.d.ts +0 -1
- package/dist/cryptoEncoding/encoding/cryptoEncoding.hex.js +0 -1
- package/dist/cryptoEncoding/encoding/index.d.ts +0 -1
- package/dist/cryptoEncoding/encoding/index.js +0 -1
- package/dist/cryptoEncoding/index.d.ts +0 -1
- package/dist/cryptoEncoding/index.js +0 -1
- package/dist/cryptoErrors/cryptoErrors.helper.d.ts +13 -1
- package/dist/cryptoErrors/cryptoErrors.helper.js +18 -1
- package/dist/cryptoErrors/index.d.ts +0 -1
- package/dist/cryptoErrors/index.js +0 -1
- package/dist/cryptoFactory/cryptoFactory.core.d.ts +0 -1
- package/dist/cryptoFactory/cryptoFactory.core.js +0 -1
- package/dist/cryptoFactory/cryptoFactory.encoding.d.ts +0 -1
- package/dist/cryptoFactory/cryptoFactory.encoding.js +0 -1
- package/dist/cryptoFactory/cryptoFactory.password.d.ts +0 -1
- package/dist/cryptoFactory/cryptoFactory.password.js +0 -1
- package/dist/cryptoFactory/cryptoFactory.token.d.ts +0 -1
- package/dist/cryptoFactory/cryptoFactory.token.js +0 -1
- package/dist/cryptoFactory/index.d.ts +0 -1
- package/dist/cryptoFactory/index.js +0 -1
- package/dist/cryptoHash/cryptoHash.codec.d.ts +0 -1
- package/dist/cryptoHash/cryptoHash.codec.js +0 -1
- package/dist/cryptoHash/cryptoHash.compare.d.ts +0 -1
- package/dist/cryptoHash/cryptoHash.compare.js +0 -1
- package/dist/cryptoHash/cryptoHash.convenience.d.ts +0 -1
- package/dist/cryptoHash/cryptoHash.convenience.js +0 -1
- package/dist/cryptoHash/cryptoHash.core.d.ts +0 -1
- package/dist/cryptoHash/cryptoHash.core.js +0 -1
- package/dist/cryptoHash/cryptoHmac.core.d.ts +9 -3
- package/dist/cryptoHash/cryptoHmac.core.js +15 -5
- package/dist/cryptoHash/index.d.ts +0 -1
- package/dist/cryptoHash/index.js +0 -1
- package/dist/cryptoKey/cryptoKey.factory.d.ts +6 -1
- package/dist/cryptoKey/cryptoKey.factory.js +8 -2
- package/dist/cryptoKey/cryptoKey.type.d.ts +12 -1
- package/dist/cryptoKey/cryptoKey.type.js +0 -1
- package/dist/cryptoKey/cryptoKey.utils.d.ts +0 -1
- package/dist/cryptoKey/cryptoKey.utils.js +0 -1
- package/dist/cryptoKey/index.d.ts +0 -1
- package/dist/cryptoKey/index.js +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.core.d.ts +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.core.js +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.salt.d.ts +4 -2
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.salt.js +6 -3
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.type.d.ts +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.type.js +0 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.validate.d.ts +6 -1
- package/dist/cryptoKeyDerivation/cryptoKeyDerivation.validate.js +17 -11
- package/dist/cryptoKeyDerivation/index.d.ts +0 -1
- package/dist/cryptoKeyDerivation/index.js +0 -1
- package/dist/cryptoPassword/cryptoPassword.codec.d.ts +0 -1
- package/dist/cryptoPassword/cryptoPassword.codec.js +0 -1
- package/dist/cryptoPassword/cryptoPassword.core.d.ts +10 -1
- package/dist/cryptoPassword/cryptoPassword.core.js +13 -4
- package/dist/cryptoPassword/cryptoPassword.helper.d.ts +10 -2
- package/dist/cryptoPassword/cryptoPassword.helper.js +26 -4
- package/dist/cryptoPassword/cryptoPassword.type.d.ts +0 -1
- package/dist/cryptoPassword/cryptoPassword.type.js +0 -1
- package/dist/cryptoPassword/cryptoPassword.validate.d.ts +4 -6
- package/dist/cryptoPassword/cryptoPassword.validate.js +13 -24
- package/dist/cryptoPassword/index.d.ts +0 -1
- package/dist/cryptoPassword/index.js +0 -1
- package/dist/cryptoProvider/cryptoProvider.capability.d.ts +0 -1
- package/dist/cryptoProvider/cryptoProvider.capability.js +0 -1
- package/dist/cryptoProvider/cryptoProvider.core.d.ts +0 -1
- package/dist/cryptoProvider/cryptoProvider.core.js +0 -1
- package/dist/cryptoProvider/cryptoProvider.default.d.ts +0 -1
- package/dist/cryptoProvider/cryptoProvider.default.js +0 -1
- package/dist/cryptoProvider/cryptoProvider.interface.d.ts +0 -1
- package/dist/cryptoProvider/cryptoProvider.interface.js +0 -1
- package/dist/cryptoProvider/cryptoProvider.type.d.ts +0 -1
- package/dist/cryptoProvider/cryptoProvider.type.js +0 -1
- package/dist/cryptoProvider/index.d.ts +0 -1
- package/dist/cryptoProvider/index.js +0 -1
- package/dist/cryptoProvider/types/cryptoCipher.type.d.ts +0 -1
- package/dist/cryptoProvider/types/cryptoCipher.type.js +0 -1
- package/dist/cryptoProvider/types/cryptoHash.type.d.ts +0 -1
- package/dist/cryptoProvider/types/cryptoHash.type.js +0 -1
- package/dist/cryptoProvider/types/cryptoKeyDerivation.type.d.ts +0 -1
- package/dist/cryptoProvider/types/cryptoKeyDerivation.type.js +0 -1
- package/dist/cryptoProvider/types/cryptoRandom.type.d.ts +0 -1
- package/dist/cryptoProvider/types/cryptoRandom.type.js +0 -1
- package/dist/cryptoProvider/types/cryptoSignature.type.d.ts +9 -3
- package/dist/cryptoProvider/types/cryptoSignature.type.js +0 -1
- package/dist/cryptoProvider/types/index.d.ts +1 -2
- package/dist/cryptoProvider/types/index.js +0 -1
- package/dist/cryptoRandom/cryptoRandom.choice.d.ts +0 -1
- package/dist/cryptoRandom/cryptoRandom.choice.js +0 -1
- package/dist/cryptoRandom/cryptoRandom.core.d.ts +0 -1
- package/dist/cryptoRandom/cryptoRandom.core.js +0 -1
- package/dist/cryptoRandom/cryptoRandom.string.d.ts +7 -1
- package/dist/cryptoRandom/cryptoRandom.string.js +7 -1
- package/dist/cryptoRandom/index.d.ts +0 -1
- package/dist/cryptoRandom/index.js +0 -1
- package/dist/cryptoService/cryptoService.core.d.ts +0 -1
- package/dist/cryptoService/cryptoService.core.js +0 -1
- package/dist/cryptoService/cryptoService.derivation.d.ts +0 -1
- package/dist/cryptoService/cryptoService.derivation.js +0 -1
- package/dist/cryptoService/cryptoService.encoding.d.ts +0 -1
- package/dist/cryptoService/cryptoService.encoding.js +0 -1
- package/dist/cryptoService/index.d.ts +0 -1
- package/dist/cryptoService/index.js +0 -1
- package/dist/cryptoService/operations/cryptoService.cipher.d.ts +0 -1
- package/dist/cryptoService/operations/cryptoService.cipher.js +0 -1
- package/dist/cryptoService/operations/cryptoService.hash.d.ts +0 -1
- package/dist/cryptoService/operations/cryptoService.hash.js +0 -1
- package/dist/cryptoService/operations/cryptoService.password.d.ts +0 -1
- package/dist/cryptoService/operations/cryptoService.password.js +0 -1
- package/dist/cryptoService/operations/cryptoService.token.d.ts +0 -1
- package/dist/cryptoService/operations/cryptoService.token.js +0 -1
- package/dist/cryptoService/operations/index.d.ts +0 -1
- package/dist/cryptoService/operations/index.js +0 -1
- package/dist/cryptoSignature/cryptoSignature.core.d.ts +5 -6
- package/dist/cryptoSignature/cryptoSignature.core.js +0 -1
- package/dist/cryptoSignature/index.d.ts +0 -1
- package/dist/cryptoSignature/index.js +0 -1
- package/dist/cryptoToken/cryptoToken.core.d.ts +0 -1
- package/dist/cryptoToken/cryptoToken.core.js +0 -1
- package/dist/cryptoToken/cryptoToken.hash.d.ts +0 -1
- package/dist/cryptoToken/cryptoToken.hash.js +0 -1
- package/dist/cryptoToken/cryptoToken.utils.d.ts +0 -1
- package/dist/cryptoToken/cryptoToken.utils.js +0 -1
- package/dist/cryptoToken/index.d.ts +0 -1
- package/dist/cryptoToken/index.js +0 -1
- package/dist/cryptoUtils/cryptoUtils.compare.d.ts +0 -1
- package/dist/cryptoUtils/cryptoUtils.compare.js +0 -1
- package/dist/cryptoUtils/cryptoUtils.conversion.d.ts +0 -1
- package/dist/cryptoUtils/cryptoUtils.conversion.js +0 -1
- package/dist/cryptoUtils/cryptoUtils.number.d.ts +0 -1
- package/dist/cryptoUtils/cryptoUtils.number.js +0 -1
- package/dist/cryptoUtils/cryptoUtils.text.d.ts +0 -1
- package/dist/cryptoUtils/cryptoUtils.text.js +0 -1
- package/dist/cryptoUtils/cryptoUtils.validation.d.ts +0 -1
- package/dist/cryptoUtils/cryptoUtils.validation.js +0 -1
- package/dist/cryptoUtils/encoding/cryptoUtils.base64.d.ts +0 -1
- package/dist/cryptoUtils/encoding/cryptoUtils.base64.js +0 -1
- package/dist/cryptoUtils/encoding/cryptoUtils.base64url.d.ts +0 -1
- package/dist/cryptoUtils/encoding/cryptoUtils.base64url.js +0 -1
- package/dist/cryptoUtils/encoding/cryptoUtils.hex.d.ts +0 -1
- package/dist/cryptoUtils/encoding/cryptoUtils.hex.js +0 -1
- package/dist/cryptoUtils/encoding/index.d.ts +0 -1
- package/dist/cryptoUtils/encoding/index.js +0 -1
- package/dist/cryptoUtils/index.d.ts +0 -1
- package/dist/cryptoUtils/index.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/node/index.d.ts +0 -1
- package/dist/node/index.js +0 -1
- package/dist/node/nodeCryptoProvider/index.d.ts +0 -1
- package/dist/node/nodeCryptoProvider/index.js +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.core.d.ts +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.core.js +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.factory.d.ts +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.factory.js +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.helper.d.ts +0 -1
- package/dist/node/nodeCryptoProvider/nodeCryptoProvider.helper.js +0 -1
- package/dist/node/nodeCryptoProvider/operations/index.d.ts +0 -1
- package/dist/node/nodeCryptoProvider/operations/index.js +0 -1
- package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.derivation.d.ts +0 -1
- package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.derivation.js +0 -1
- package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.password.d.ts +0 -1
- package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.password.js +0 -1
- package/dist/node/nodeCryptoProvider/primitives/index.d.ts +0 -1
- package/dist/node/nodeCryptoProvider/primitives/index.js +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.encryption.d.ts +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.encryption.js +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.hash.d.ts +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.hash.js +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.random.d.ts +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.random.js +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.signing.d.ts +0 -1
- package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.signing.js +0 -1
- package/dist/node/signing/index.d.ts +0 -1
- package/dist/node/signing/index.js +0 -1
- package/dist/node/signing/signing.conversion.d.ts +0 -1
- package/dist/node/signing/signing.conversion.js +0 -1
- package/dist/node/signing/signing.core.d.ts +0 -1
- package/dist/node/signing/signing.core.js +0 -1
- package/dist/node/signing/signing.utils.d.ts +0 -1
- package/dist/node/signing/signing.utils.js +0 -1
- package/package.json +3 -3
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { PASSWORD_HASH
|
|
1
|
+
import { PASSWORD_HASH } from "../cryptoConstants/cryptoConstants.security.js";
|
|
2
2
|
import { fromBase64Url } from "../cryptoEncoding/encoding/cryptoEncoding.base64url.js";
|
|
3
|
+
import { passwordHashError } from "../cryptoErrors/cryptoErrors.helper.js";
|
|
3
4
|
const LIMITS = PASSWORD_HASH.LIMITS;
|
|
4
5
|
/**
|
|
5
6
|
* Validates the structural constraints of scrypt password hashing
|
|
6
7
|
* parameters, including upper bounds so that parameters read back from a
|
|
7
8
|
* stored hash cannot force unbounded CPU or memory usage.
|
|
9
|
+
*
|
|
10
|
+
* @throws {CryptoError} `CRYPTO_HASH` for any parameter outside its bound.
|
|
8
11
|
*/
|
|
9
12
|
export function validateParameters(parameters) {
|
|
10
13
|
validateSaltAndKeyBytes(parameters.saltBytes, parameters.keyBytes);
|
|
@@ -12,43 +15,45 @@ export function validateParameters(parameters) {
|
|
|
12
15
|
parameters.cost < LIMITS.MIN_SCRYPT_COST ||
|
|
13
16
|
parameters.cost > LIMITS.MAX_SCRYPT_COST ||
|
|
14
17
|
(parameters.cost & (parameters.cost - 1)) !== 0) {
|
|
15
|
-
throw
|
|
18
|
+
throw passwordHashError(`cost must be a power of two between ${LIMITS.MIN_SCRYPT_COST} and ${LIMITS.MAX_SCRYPT_COST}.`);
|
|
16
19
|
}
|
|
17
20
|
if (!Number.isInteger(parameters.blockSize) ||
|
|
18
21
|
parameters.blockSize <= 0 ||
|
|
19
22
|
parameters.blockSize > LIMITS.MAX_SCRYPT_BLOCK_SIZE) {
|
|
20
|
-
throw
|
|
23
|
+
throw passwordHashError(`blockSize must be an integer between 1 and ${LIMITS.MAX_SCRYPT_BLOCK_SIZE}.`);
|
|
21
24
|
}
|
|
22
25
|
if (!Number.isInteger(parameters.parallelization) ||
|
|
23
26
|
parameters.parallelization <= 0 ||
|
|
24
27
|
parameters.parallelization > LIMITS.MAX_SCRYPT_PARALLELIZATION) {
|
|
25
|
-
throw
|
|
28
|
+
throw passwordHashError(`parallelization must be an integer between 1 and ${LIMITS.MAX_SCRYPT_PARALLELIZATION}.`);
|
|
26
29
|
}
|
|
27
30
|
if (128 * parameters.cost * parameters.blockSize > LIMITS.MAX_SCRYPT_MEMORY_BYTES) {
|
|
28
|
-
throw
|
|
31
|
+
throw passwordHashError(`cost * blockSize exceeds the scrypt memory bound of ${LIMITS.MAX_SCRYPT_MEMORY_BYTES} bytes.`);
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
/**
|
|
32
35
|
* Validates PBKDF2 password hashing parameters, including upper bounds.
|
|
36
|
+
*
|
|
37
|
+
* @throws {CryptoError} `CRYPTO_HASH` for any parameter outside its bound.
|
|
33
38
|
*/
|
|
34
39
|
export function validatePbkdf2Parameters(parameters) {
|
|
35
40
|
validateSaltAndKeyBytes(parameters.saltBytes, parameters.keyBytes);
|
|
36
41
|
if (!Number.isInteger(parameters.iterations) ||
|
|
37
42
|
parameters.iterations < PASSWORD_HASH.PBKDF2.MIN_ITERATIONS ||
|
|
38
43
|
parameters.iterations > LIMITS.MAX_PBKDF2_ITERATIONS) {
|
|
39
|
-
throw
|
|
44
|
+
throw passwordHashError(`iterations must be an integer between ${PASSWORD_HASH.PBKDF2.MIN_ITERATIONS} and ${LIMITS.MAX_PBKDF2_ITERATIONS}.`);
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
47
|
function validateSaltAndKeyBytes(saltBytes, keyBytes) {
|
|
43
48
|
if (!Number.isInteger(saltBytes) ||
|
|
44
49
|
saltBytes < LIMITS.MIN_SALT_BYTES ||
|
|
45
50
|
saltBytes > LIMITS.MAX_SALT_BYTES) {
|
|
46
|
-
throw
|
|
51
|
+
throw passwordHashError(`saltBytes must be an integer between ${LIMITS.MIN_SALT_BYTES} and ${LIMITS.MAX_SALT_BYTES}.`);
|
|
47
52
|
}
|
|
48
53
|
if (!Number.isInteger(keyBytes) ||
|
|
49
54
|
keyBytes < LIMITS.MIN_KEY_BYTES ||
|
|
50
55
|
keyBytes > LIMITS.MAX_KEY_BYTES) {
|
|
51
|
-
throw
|
|
56
|
+
throw passwordHashError(`keyBytes must be an integer between ${LIMITS.MIN_KEY_BYTES} and ${LIMITS.MAX_KEY_BYTES}.`);
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
59
|
/**
|
|
@@ -73,19 +78,3 @@ export function decodeBase64Url(value) {
|
|
|
73
78
|
}
|
|
74
79
|
return fromBase64Url(value);
|
|
75
80
|
}
|
|
76
|
-
/**
|
|
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).
|
|
79
|
-
*/
|
|
80
|
-
export function assertPassword(password) {
|
|
81
|
-
if (typeof password !== "string") {
|
|
82
|
-
throw new TypeError("Password must be a string.");
|
|
83
|
-
}
|
|
84
|
-
if (password.length === 0) {
|
|
85
|
-
throw new TypeError("Password cannot be empty.");
|
|
86
|
-
}
|
|
87
|
-
if (password.length > PASSWORD_POLICY.MAX_LENGTH) {
|
|
88
|
-
throw new RangeError(`Password must not exceed ${PASSWORD_POLICY.MAX_LENGTH} characters.`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=cryptoPassword.validate.js.map
|
|
@@ -45,4 +45,3 @@ export declare function assertHmacCapability(provider: CryptoProvider): void;
|
|
|
45
45
|
* configuration failure, and it throws.
|
|
46
46
|
*/
|
|
47
47
|
export declare function assertPasswordHashingCapability(provider: CryptoProvider): void;
|
|
48
|
-
//# sourceMappingURL=cryptoProvider.capability.d.ts.map
|
|
@@ -67,4 +67,3 @@ export declare function isPbkdf2Digest(value: unknown): value is Pbkdf2Digest;
|
|
|
67
67
|
* Returns whether a value names a supported signature algorithm.
|
|
68
68
|
*/
|
|
69
69
|
export declare function isSignatureAlgorithmName(value: unknown): value is SignatureAlgorithm;
|
|
70
|
-
//# sourceMappingURL=cryptoProvider.type.d.ts.map
|
|
@@ -13,4 +13,3 @@ export type { RandomProvider, HashProvider, HmacProvider, EncryptionProvider, Si
|
|
|
13
13
|
export { getDefaultCryptoProvider, setDefaultCryptoProvider, resetDefaultCryptoProvider, assertCryptoProvider, CRYPTO_PROVIDER_METHODS, } from "./cryptoProvider.default.js";
|
|
14
14
|
export { assertProviderCapability, assertRandomCapability, assertHashCapability, assertHmacCapability, assertPasswordHashingCapability, } from "./cryptoProvider.capability.js";
|
|
15
15
|
export * from "./types/index.js";
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,4 +2,3 @@ export { isHashAlgorithmName, isHmacAlgorithmName, isPbkdf2Digest, isSignatureAl
|
|
|
2
2
|
export { getDefaultCryptoProvider, setDefaultCryptoProvider, resetDefaultCryptoProvider, assertCryptoProvider, CRYPTO_PROVIDER_METHODS, } from "./cryptoProvider.default.js";
|
|
3
3
|
export { assertProviderCapability, assertRandomCapability, assertHashCapability, assertHmacCapability, assertPasswordHashingCapability, } from "./cryptoProvider.capability.js";
|
|
4
4
|
export * from "./types/index.js";
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import type { KeyObject } from "node:crypto";
|
|
1
2
|
import type { CryptoInput, SignatureAlgorithm } from "../cryptoProvider.type.js";
|
|
3
|
+
/**
|
|
4
|
+
* Key material accepted by `sign`/`verify`: PEM text, DER bytes (PKCS#8 for
|
|
5
|
+
* private keys, SPKI for public keys) or a Node `KeyObject` such as the ones
|
|
6
|
+
* `generateEd25519KeyPair()` returns.
|
|
7
|
+
*/
|
|
8
|
+
export type SignatureKeyMaterial = CryptoInput | KeyObject;
|
|
2
9
|
/**
|
|
3
10
|
* Options for signing.
|
|
4
11
|
*/
|
|
5
12
|
export interface SignOptions {
|
|
6
|
-
readonly key:
|
|
13
|
+
readonly key: SignatureKeyMaterial;
|
|
7
14
|
readonly data: CryptoInput;
|
|
8
15
|
readonly algorithm?: SignatureAlgorithm;
|
|
9
16
|
}
|
|
@@ -11,9 +18,8 @@ export interface SignOptions {
|
|
|
11
18
|
* Options for verification.
|
|
12
19
|
*/
|
|
13
20
|
export interface VerifyOptions {
|
|
14
|
-
readonly key:
|
|
21
|
+
readonly key: SignatureKeyMaterial;
|
|
15
22
|
readonly data: CryptoInput;
|
|
16
23
|
readonly signature: Uint8Array;
|
|
17
24
|
readonly algorithm?: SignatureAlgorithm;
|
|
18
25
|
}
|
|
19
|
-
//# sourceMappingURL=cryptoSignature.type.d.ts.map
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export type { HashResult, HashEncoding } from "./cryptoHash.type.js";
|
|
8
8
|
export type { EncryptedData, EncryptOptions, DecryptOptions, } from "./cryptoCipher.type.js";
|
|
9
|
-
export type { SignOptions, VerifyOptions } from "./cryptoSignature.type.js";
|
|
9
|
+
export type { SignOptions, VerifyOptions, SignatureKeyMaterial, } from "./cryptoSignature.type.js";
|
|
10
10
|
export type { DerivedKeyResult, DerivedKeyAlgorithm, DeriveKeyOptions, PasswordHashProviderOptions, } from "./cryptoKeyDerivation.type.js";
|
|
11
11
|
export type { RandomTokenOptions } from "./cryptoRandom.type.js";
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { CryptoProvider } from "../cryptoProvider/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Generates a cryptographically secure random hexadecimal string.
|
|
4
|
+
*
|
|
5
|
+
* `length` counts output **characters**, not bytes: `randomHex(32)` is 32
|
|
6
|
+
* hex digits carrying 16 bytes (128 bits) of entropy. `randomBase64` and
|
|
7
|
+
* `randomBase64Url` take a byte count instead.
|
|
4
8
|
*/
|
|
5
9
|
export declare function randomHex(length: number, provider?: CryptoProvider): Promise<string>;
|
|
6
10
|
/**
|
|
@@ -9,6 +13,9 @@ export declare function randomHex(length: number, provider?: CryptoProvider): Pr
|
|
|
9
13
|
export declare function randomBase64(byteLength: number, provider?: CryptoProvider): Promise<string>;
|
|
10
14
|
/**
|
|
11
15
|
* Generates a cryptographically secure URL-safe random string.
|
|
16
|
+
*
|
|
17
|
+
* `byteLength` counts random **bytes**; the output is about 4/3 as many
|
|
18
|
+
* characters (`randomBase64Url(32)` is 43 characters of 256-bit entropy).
|
|
12
19
|
*/
|
|
13
20
|
export declare function randomBase64Url(byteLength: number, provider?: CryptoProvider): Promise<string>;
|
|
14
21
|
/**
|
|
@@ -34,4 +41,3 @@ export declare function randomAlphanumeric(length: number, provider?: CryptoProv
|
|
|
34
41
|
* the alphabet must not be empty, and each character is drawn uniformly.
|
|
35
42
|
*/
|
|
36
43
|
export declare function randomFromAlphabet(length: number, alphabet: string, provider?: CryptoProvider): Promise<string>;
|
|
37
|
-
//# sourceMappingURL=cryptoRandom.string.d.ts.map
|
|
@@ -7,6 +7,10 @@ function assertLength(length, name = "length") {
|
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Generates a cryptographically secure random hexadecimal string.
|
|
10
|
+
*
|
|
11
|
+
* `length` counts output **characters**, not bytes: `randomHex(32)` is 32
|
|
12
|
+
* hex digits carrying 16 bytes (128 bits) of entropy. `randomBase64` and
|
|
13
|
+
* `randomBase64Url` take a byte count instead.
|
|
10
14
|
*/
|
|
11
15
|
export async function randomHex(length, provider = getDefaultCryptoProvider()) {
|
|
12
16
|
assertLength(length);
|
|
@@ -25,6 +29,9 @@ export async function randomBase64(byteLength, provider = getDefaultCryptoProvid
|
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* Generates a cryptographically secure URL-safe random string.
|
|
32
|
+
*
|
|
33
|
+
* `byteLength` counts random **bytes**; the output is about 4/3 as many
|
|
34
|
+
* characters (`randomBase64Url(32)` is 43 characters of 256-bit entropy).
|
|
28
35
|
*/
|
|
29
36
|
export async function randomBase64Url(byteLength, provider = getDefaultCryptoProvider()) {
|
|
30
37
|
assertLength(byteLength, "byteLength");
|
|
@@ -75,4 +82,3 @@ export async function randomFromAlphabet(length, alphabet, provider = getDefault
|
|
|
75
82
|
}
|
|
76
83
|
return result.join("");
|
|
77
84
|
}
|
|
78
|
-
//# sourceMappingURL=cryptoRandom.string.js.map
|
|
@@ -3,4 +3,3 @@ import type { Pbkdf2Options, ScryptOptions } from "../cryptoKeyDerivation/crypto
|
|
|
3
3
|
import type { CryptoAlgorithm } from "../cryptoConstants/cryptoConstants.type.js";
|
|
4
4
|
export type { DerivedKeyResult, Pbkdf2Options, ScryptOptions };
|
|
5
5
|
export declare function serviceDeriveKey(password: string | Uint8Array, algorithm: CryptoAlgorithm, options?: Pbkdf2Options | ScryptOptions, provider?: CryptoProvider): Promise<DerivedKeyResult>;
|
|
6
|
-
//# sourceMappingURL=cryptoService.derivation.d.ts.map
|
|
@@ -2,4 +2,3 @@ import type { CryptoEncoding } from "../cryptoEncoding/cryptoEncoding.core.js";
|
|
|
2
2
|
export type { CryptoEncoding };
|
|
3
3
|
export declare function serviceEncode(value: Uint8Array, encoding?: CryptoEncoding): string;
|
|
4
4
|
export declare function serviceDecode(value: string, encoding?: CryptoEncoding): Uint8Array;
|
|
5
|
-
//# sourceMappingURL=cryptoService.encoding.d.ts.map
|
|
@@ -3,4 +3,3 @@ import type { CipherOptions, CipherResult } from "../../cryptoCipher/cryptoCiphe
|
|
|
3
3
|
export type { CipherOptions, CipherResult };
|
|
4
4
|
export declare function serviceEncrypt(plaintext: Uint8Array, key: Uint8Array, options?: CipherOptions, provider?: CryptoProvider): Promise<CipherResult>;
|
|
5
5
|
export declare function serviceDecrypt(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array, aad?: Uint8Array, provider?: CryptoProvider): Promise<Uint8Array>;
|
|
6
|
-
//# sourceMappingURL=cryptoService.cipher.d.ts.map
|
|
@@ -20,4 +20,3 @@ export async function serviceDecrypt(ciphertext, key, iv, authTag, aad, provider
|
|
|
20
20
|
return rethrowAsCryptoError(error, (cause) => cipherError("Decryption failed.", CryptoOperation.DECRYPT, "aes-256-gcm", cause));
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
//# sourceMappingURL=cryptoService.cipher.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { CryptoProvider } from "../../cryptoProvider/index.js";
|
|
2
2
|
export declare function serviceHash(value: string | Uint8Array, provider?: CryptoProvider): Promise<Uint8Array>;
|
|
3
3
|
export declare function serviceHashHex(value: string | Uint8Array, provider?: CryptoProvider): Promise<string>;
|
|
4
|
-
//# sourceMappingURL=cryptoService.hash.d.ts.map
|
|
@@ -7,4 +7,3 @@ export declare function serviceHashPassword(password: string, options?: Password
|
|
|
7
7
|
* non-string arguments are programmer errors and throw.
|
|
8
8
|
*/
|
|
9
9
|
export declare function serviceVerifyPassword(password: string, encodedHash: string, provider?: CryptoProvider): Promise<boolean>;
|
|
10
|
-
//# sourceMappingURL=cryptoService.password.d.ts.map
|
|
@@ -27,4 +27,3 @@ export async function serviceVerifyPassword(password, encodedHash, provider) {
|
|
|
27
27
|
return rethrowAsCryptoError(error, (cause) => operationError("Password verification failed.", CryptoOperation.VERIFY_HASH, cause));
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
//# sourceMappingURL=cryptoService.password.js.map
|
|
@@ -9,4 +9,3 @@ export declare function serviceHashToken(token: string, provider?: CryptoProvide
|
|
|
9
9
|
* hashes yield false; non-string arguments throw.
|
|
10
10
|
*/
|
|
11
11
|
export declare function serviceVerifyToken(token: string, expectedHash: string, provider?: CryptoProvider): Promise<boolean>;
|
|
12
|
-
//# sourceMappingURL=cryptoService.token.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CryptoProvider } from "../cryptoProvider/index.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SignatureKeyMaterial } from "../cryptoProvider/index.js";
|
|
3
3
|
import type { SignatureAlgorithm } from "../cryptoProvider/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Signature options.
|
|
@@ -14,20 +14,19 @@ export type SignatureOptions = {
|
|
|
14
14
|
/**
|
|
15
15
|
* Signs arbitrary data using a private key (PEM text, DER bytes or KeyObject).
|
|
16
16
|
*/
|
|
17
|
-
export declare function sign(data: Uint8Array, privateKey:
|
|
17
|
+
export declare function sign(data: Uint8Array, privateKey: SignatureKeyMaterial, options?: SignatureOptions): Promise<Uint8Array>;
|
|
18
18
|
/**
|
|
19
19
|
* Verifies a signature using a public key.
|
|
20
20
|
*
|
|
21
21
|
* Returns false for malformed keys or signatures; throws only when the
|
|
22
22
|
* algorithm is unsupported or incompatible with the key type.
|
|
23
23
|
*/
|
|
24
|
-
export declare function verify(data: Uint8Array, signature: Uint8Array, publicKey:
|
|
24
|
+
export declare function verify(data: Uint8Array, signature: Uint8Array, publicKey: SignatureKeyMaterial, options?: SignatureOptions): Promise<boolean>;
|
|
25
25
|
/**
|
|
26
26
|
* Signs UTF-8 text.
|
|
27
27
|
*/
|
|
28
|
-
export declare function signString(data: string, privateKey:
|
|
28
|
+
export declare function signString(data: string, privateKey: SignatureKeyMaterial, options?: SignatureOptions): Promise<Uint8Array>;
|
|
29
29
|
/**
|
|
30
30
|
* Verifies a signature against UTF-8 text.
|
|
31
31
|
*/
|
|
32
|
-
export declare function verifyString(data: string, signature: Uint8Array, publicKey:
|
|
33
|
-
//# sourceMappingURL=cryptoSignature.core.d.ts.map
|
|
32
|
+
export declare function verifyString(data: string, signature: Uint8Array, publicKey: SignatureKeyMaterial, options?: SignatureOptions): Promise<boolean>;
|
|
@@ -41,4 +41,3 @@ export async function signString(data, privateKey, options = {}) {
|
|
|
41
41
|
export async function verifyString(data, signature, publicKey, options = {}) {
|
|
42
42
|
return verify(Buffer.from(data, "utf8"), signature, publicKey, options);
|
|
43
43
|
}
|
|
44
|
-
//# sourceMappingURL=cryptoSignature.core.js.map
|
|
@@ -58,4 +58,3 @@ export declare function generateEmailVerificationCode(digits?: number, provider?
|
|
|
58
58
|
* Generates a short-lived login verification code.
|
|
59
59
|
*/
|
|
60
60
|
export declare function generateLoginCode(digits?: number, provider?: CryptoProvider): Promise<string>;
|
|
61
|
-
//# sourceMappingURL=cryptoToken.core.d.ts.map
|
|
@@ -23,4 +23,3 @@ export declare function verifyTokenHash(token: string, expectedHash: string, pro
|
|
|
23
23
|
* This is useful when a raw bearer token must never be persisted.
|
|
24
24
|
*/
|
|
25
25
|
export declare function hashTokenForStorage(token: string, provider?: CryptoProvider): Promise<string>;
|
|
26
|
-
//# sourceMappingURL=cryptoToken.hash.d.ts.map
|
|
@@ -10,4 +10,3 @@ export declare function hasTokenPrefix(token: string, prefix: string): boolean;
|
|
|
10
10
|
* Validates the basic shape of an opaque token.
|
|
11
11
|
*/
|
|
12
12
|
export declare function isValidToken(token: string, minimumLength?: number): boolean;
|
|
13
|
-
//# sourceMappingURL=cryptoToken.utils.d.ts.map
|