@aztec/foundation 0.0.1-commit.d431d1c → 0.0.1-commit.d58ff9d0
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/dest/array/sorted_array.d.ts +6 -1
- package/dest/array/sorted_array.d.ts.map +1 -1
- package/dest/array/sorted_array.js +18 -15
- package/dest/bigint-buffer/index.d.ts +1 -1
- package/dest/bigint-buffer/index.d.ts.map +1 -1
- package/dest/bigint-buffer/index.js +6 -1
- package/dest/branded-types/block_number.d.ts +3 -3
- package/dest/branded-types/block_number.d.ts.map +1 -1
- package/dest/branded-types/block_number.js +15 -4
- package/dest/branded-types/buffer32_hash.d.ts +27 -0
- package/dest/branded-types/buffer32_hash.d.ts.map +1 -0
- package/dest/branded-types/buffer32_hash.js +12 -0
- package/dest/branded-types/checkpoint_number.d.ts +9 -3
- package/dest/branded-types/checkpoint_number.d.ts.map +1 -1
- package/dest/branded-types/checkpoint_number.js +11 -0
- package/dest/branded-types/epoch.d.ts +2 -2
- package/dest/branded-types/epoch.d.ts.map +1 -1
- package/dest/branded-types/index.d.ts +2 -1
- package/dest/branded-types/index.d.ts.map +1 -1
- package/dest/branded-types/index.js +1 -0
- package/dest/branded-types/index_within_checkpoint.d.ts +2 -2
- package/dest/branded-types/index_within_checkpoint.d.ts.map +1 -1
- package/dest/branded-types/slot.d.ts +5 -2
- package/dest/branded-types/slot.d.ts.map +1 -1
- package/dest/branded-types/slot.js +3 -0
- package/dest/buffer/buffer16.d.ts +3 -1
- package/dest/buffer/buffer16.d.ts.map +1 -1
- package/dest/buffer/buffer32.d.ts +28 -61
- package/dest/buffer/buffer32.d.ts.map +1 -1
- package/dest/buffer/buffer32.js +29 -63
- package/dest/buffer/index.d.ts +2 -1
- package/dest/buffer/index.d.ts.map +1 -1
- package/dest/buffer/index.js +1 -0
- package/dest/buffer/utils.d.ts +3 -0
- package/dest/buffer/utils.d.ts.map +1 -0
- package/dest/buffer/utils.js +7 -0
- package/dest/collection/array.d.ts +22 -1
- package/dest/collection/array.d.ts.map +1 -1
- package/dest/collection/array.js +84 -0
- package/dest/collection/index.d.ts +3 -1
- package/dest/collection/index.d.ts.map +1 -1
- package/dest/collection/index.js +2 -0
- package/dest/collection/lru_map.d.ts +41 -0
- package/dest/collection/lru_map.d.ts.map +1 -0
- package/dest/collection/lru_map.js +119 -0
- package/dest/collection/lru_set.d.ts +35 -0
- package/dest/collection/lru_set.d.ts.map +1 -0
- package/dest/collection/lru_set.js +95 -0
- package/dest/committable/committable.js +1 -1
- package/dest/config/env_var.d.ts +2 -2
- package/dest/config/env_var.d.ts.map +1 -1
- package/dest/config/index.d.ts +67 -37
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +86 -70
- package/dest/config/network_config.d.ts +15 -41
- package/dest/config/network_config.d.ts.map +1 -1
- package/dest/config/network_config.js +4 -1
- package/dest/config/network_name.d.ts +2 -2
- package/dest/config/network_name.d.ts.map +1 -1
- package/dest/config/network_name.js +3 -3
- package/dest/config/secret_value.d.ts +2 -2
- package/dest/config/secret_value.d.ts.map +1 -1
- package/dest/crypto/aes128/index.d.ts +2 -1
- package/dest/crypto/aes128/index.d.ts.map +1 -1
- package/dest/crypto/aes128/index.js +11 -2
- package/dest/crypto/bls/bn254_keystore.d.ts +10 -177
- package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -1
- package/dest/crypto/bls/bn254_keystore.js +22 -34
- package/dest/crypto/keys/index.d.ts +3 -2
- package/dest/crypto/keys/index.d.ts.map +1 -1
- package/dest/crypto/keys/index.js +30 -6
- package/dest/crypto/poseidon/index.d.ts +1 -2
- package/dest/crypto/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/poseidon/index.js +40 -42
- package/dest/crypto/random/randomness_singleton.d.ts +4 -3
- package/dest/crypto/random/randomness_singleton.d.ts.map +1 -1
- package/dest/crypto/random/randomness_singleton.js +4 -4
- package/dest/crypto/schnorr/index.d.ts +8 -7
- package/dest/crypto/schnorr/index.d.ts.map +1 -1
- package/dest/crypto/schnorr/index.js +6 -6
- package/dest/crypto/schnorr/signature.d.ts +9 -29
- package/dest/crypto/schnorr/signature.d.ts.map +1 -1
- package/dest/crypto/schnorr/signature.js +20 -36
- package/dest/crypto/secp256k1-signer/utils.d.ts +12 -1
- package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -1
- package/dest/crypto/secp256k1-signer/utils.js +26 -0
- package/dest/crypto/sync/poseidon/index.d.ts +1 -2
- package/dest/crypto/sync/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/sync/poseidon/index.js +0 -8
- package/dest/curves/bls12/field.d.ts +3 -3
- package/dest/curves/bls12/field.d.ts.map +1 -1
- package/dest/curves/bls12/field.js +0 -5
- package/dest/curves/bls12/point.d.ts +2 -2
- package/dest/curves/bls12/point.d.ts.map +1 -1
- package/dest/curves/bn254/field.d.ts +24 -19
- package/dest/curves/bn254/field.d.ts.map +1 -1
- package/dest/curves/bn254/field.js +28 -19
- package/dest/curves/grumpkin/point.d.ts +14 -28
- package/dest/curves/grumpkin/point.d.ts.map +1 -1
- package/dest/curves/grumpkin/point.js +29 -43
- package/dest/eth-address/index.d.ts +2 -2
- package/dest/eth-address/index.d.ts.map +1 -1
- package/dest/eth-address/index.js +0 -3
- package/dest/eth-signature/eth_signature.d.ts +3 -2
- package/dest/eth-signature/eth_signature.d.ts.map +1 -1
- package/dest/eth-signature/eth_signature.js +7 -2
- package/dest/fifo/fifo_frame_reader.d.ts +41 -0
- package/dest/fifo/fifo_frame_reader.d.ts.map +1 -0
- package/dest/fifo/fifo_frame_reader.js +91 -0
- package/dest/fifo/index.d.ts +2 -0
- package/dest/fifo/index.d.ts.map +1 -0
- package/dest/fifo/index.js +1 -0
- package/dest/fifo_set/fifo_set.d.ts +15 -0
- package/dest/fifo_set/fifo_set.d.ts.map +1 -0
- package/dest/fifo_set/fifo_set.js +39 -0
- package/dest/fifo_set/index.d.ts +2 -0
- package/dest/fifo_set/index.d.ts.map +1 -0
- package/dest/fifo_set/index.js +1 -0
- package/dest/jest/setup.js +28 -1
- package/dest/json-rpc/client/fetch.d.ts +1 -1
- package/dest/json-rpc/client/fetch.d.ts.map +1 -1
- package/dest/json-rpc/client/fetch.js +4 -3
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts +2 -1
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
- package/dest/json-rpc/client/safe_json_rpc_client.js +3 -3
- package/dest/json-rpc/client/undici.d.ts +1 -1
- package/dest/json-rpc/client/undici.d.ts.map +1 -1
- package/dest/json-rpc/client/undici.js +23 -4
- package/dest/json-rpc/fixtures/test_state.d.ts +4 -8
- package/dest/json-rpc/fixtures/test_state.d.ts.map +1 -1
- package/dest/json-rpc/fixtures/test_state.js +57 -17
- package/dest/json-rpc/server/api_key_auth.d.ts +19 -0
- package/dest/json-rpc/server/api_key_auth.d.ts.map +1 -0
- package/dest/json-rpc/server/api_key_auth.js +57 -0
- package/dest/json-rpc/server/index.d.ts +2 -1
- package/dest/json-rpc/server/index.d.ts.map +1 -1
- package/dest/json-rpc/server/index.js +1 -0
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts +8 -3
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts.map +1 -1
- package/dest/json-rpc/server/safe_json_rpc_server.js +28 -14
- package/dest/log/bigint-utils.d.ts +5 -0
- package/dest/log/bigint-utils.d.ts.map +1 -0
- package/dest/log/bigint-utils.js +21 -0
- package/dest/log/gcloud-logger-config.d.ts +1 -1
- package/dest/log/gcloud-logger-config.d.ts.map +1 -1
- package/dest/log/gcloud-logger-config.js +3 -0
- package/dest/log/libp2p_logger.d.ts +5 -2
- package/dest/log/libp2p_logger.d.ts.map +1 -1
- package/dest/log/libp2p_logger.js +14 -4
- package/dest/log/log-filters.d.ts +17 -4
- package/dest/log/log-filters.d.ts.map +1 -1
- package/dest/log/log-filters.js +26 -12
- package/dest/log/pino-logger-server.d.ts +9 -0
- package/dest/log/pino-logger-server.d.ts.map +1 -0
- package/dest/log/pino-logger-server.js +18 -0
- package/dest/log/pino-logger.d.ts +37 -8
- package/dest/log/pino-logger.d.ts.map +1 -1
- package/dest/log/pino-logger.js +137 -29
- package/dest/noir/noir_package_config.d.ts +19 -104
- package/dest/noir/noir_package_config.d.ts.map +1 -1
- package/dest/noir/noir_package_config.js +1 -1
- package/dest/promise/running-promise.d.ts +5 -4
- package/dest/promise/running-promise.d.ts.map +1 -1
- package/dest/promise/running-promise.js +7 -3
- package/dest/queue/base_memory_queue.d.ts +2 -2
- package/dest/queue/base_memory_queue.d.ts.map +1 -1
- package/dest/queue/batch_queue.d.ts +1 -1
- package/dest/queue/batch_queue.d.ts.map +1 -1
- package/dest/queue/batch_queue.js +1 -0
- package/dest/queue/semaphore.d.ts +5 -1
- package/dest/queue/semaphore.d.ts.map +1 -1
- package/dest/retry/index.d.ts +31 -3
- package/dest/retry/index.d.ts.map +1 -1
- package/dest/retry/index.js +44 -2
- package/dest/schemas/api.d.ts +12 -10
- package/dest/schemas/api.d.ts.map +1 -1
- package/dest/schemas/api.js +7 -1
- package/dest/schemas/parse.d.ts +4 -4
- package/dest/schemas/parse.d.ts.map +1 -1
- package/dest/schemas/parse.js +6 -5
- package/dest/schemas/schemas.d.ts +15 -15
- package/dest/schemas/types.d.ts +3 -3
- package/dest/schemas/types.d.ts.map +1 -1
- package/dest/schemas/utils.d.ts +7 -11
- package/dest/schemas/utils.d.ts.map +1 -1
- package/dest/schemas/utils.js +2 -18
- package/dest/serialize/buffer_reader.d.ts +8 -1
- package/dest/serialize/buffer_reader.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.js +13 -0
- package/dest/serialize/buffer_sink.d.ts +134 -0
- package/dest/serialize/buffer_sink.d.ts.map +1 -0
- package/dest/serialize/buffer_sink.js +297 -0
- package/dest/serialize/index.d.ts +2 -1
- package/dest/serialize/index.d.ts.map +1 -1
- package/dest/serialize/index.js +1 -0
- package/dest/serialize/serialize.d.ts +19 -1
- package/dest/serialize/serialize.d.ts.map +1 -1
- package/dest/serialize/serialize.js +31 -0
- package/dest/sleep/index.d.ts +2 -1
- package/dest/sleep/index.d.ts.map +1 -1
- package/dest/sleep/index.js +10 -1
- package/dest/string/index.js +1 -1
- package/dest/testing/files/index.d.ts +2 -3
- package/dest/testing/files/index.d.ts.map +1 -1
- package/dest/testing/files/index.js +1 -2
- package/dest/timer/date.d.ts +25 -1
- package/dest/timer/date.d.ts.map +1 -1
- package/dest/timer/date.js +33 -0
- package/dest/timer/index.d.ts +2 -2
- package/dest/timer/index.d.ts.map +1 -1
- package/dest/timer/index.js +1 -1
- package/dest/timer/timeout.d.ts +3 -1
- package/dest/timer/timeout.d.ts.map +1 -1
- package/dest/timer/timeout.js +26 -0
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts +11 -2
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts.map +1 -1
- package/dest/transport/index.d.ts +1 -2
- package/dest/transport/index.d.ts.map +1 -1
- package/dest/transport/index.js +0 -1
- package/dest/transport/transport_client.js +2 -2
- package/dest/trees/balanced_merkle_tree_root.d.ts +3 -5
- package/dest/trees/balanced_merkle_tree_root.d.ts.map +1 -1
- package/dest/trees/balanced_merkle_tree_root.js +3 -5
- package/dest/trees/hasher.d.ts +3 -3
- package/dest/trees/hasher.d.ts.map +1 -1
- package/dest/trees/hasher.js +5 -10
- package/dest/trees/indexed_merkle_tree_calculator.d.ts +1 -1
- package/dest/trees/indexed_merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/indexed_merkle_tree_calculator.js +5 -1
- package/dest/trees/membership_witness.d.ts +2 -2
- package/dest/trees/membership_witness.d.ts.map +1 -1
- package/dest/trees/merkle_tree_calculator.d.ts +4 -2
- package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/merkle_tree_calculator.js +1 -5
- package/dest/trees/sibling_path.d.ts +5 -4
- package/dest/trees/sibling_path.d.ts.map +1 -1
- package/dest/trees/sibling_path.js +10 -8
- package/dest/trees/unbalanced_merkle_tree_root.d.ts +2 -3
- package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree_root.js +2 -3
- package/dest/types/index.d.ts +25 -1
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +18 -0
- package/package.json +27 -4
- package/src/array/sorted_array.ts +22 -17
- package/src/bigint-buffer/index.ts +6 -1
- package/src/branded-types/block_number.ts +20 -2
- package/src/branded-types/buffer32_hash.ts +38 -0
- package/src/branded-types/checkpoint_number.ts +16 -1
- package/src/branded-types/epoch.ts +1 -1
- package/src/branded-types/index.ts +1 -0
- package/src/branded-types/index_within_checkpoint.ts +1 -1
- package/src/branded-types/slot.ts +6 -1
- package/src/buffer/buffer16.ts +3 -0
- package/src/buffer/buffer32.ts +39 -68
- package/src/buffer/index.ts +1 -0
- package/src/buffer/utils.ts +8 -0
- package/src/collection/array.ts +86 -0
- package/src/collection/index.ts +2 -0
- package/src/collection/lru_map.ts +143 -0
- package/src/collection/lru_set.ts +115 -0
- package/src/committable/committable.ts +1 -1
- package/src/config/env_var.ts +97 -23
- package/src/config/index.ts +157 -121
- package/src/config/network_config.ts +3 -0
- package/src/config/network_name.ts +6 -6
- package/src/config/secret_value.ts +1 -1
- package/src/crypto/aes128/index.ts +11 -2
- package/src/crypto/bls/bn254_keystore.ts +33 -43
- package/src/crypto/keys/index.ts +20 -4
- package/src/crypto/poseidon/index.ts +42 -44
- package/src/crypto/random/randomness_singleton.ts +9 -5
- package/src/crypto/schnorr/index.ts +9 -8
- package/src/crypto/schnorr/signature.ts +17 -46
- package/src/crypto/secp256k1-signer/utils.ts +32 -0
- package/src/crypto/sync/poseidon/index.ts +0 -9
- package/src/curves/bls12/field.ts +0 -7
- package/src/curves/bn254/field.ts +41 -36
- package/src/curves/grumpkin/point.ts +23 -40
- package/src/eth-address/index.ts +0 -4
- package/src/eth-signature/eth_signature.ts +7 -1
- package/src/fifo/fifo_frame_reader.ts +113 -0
- package/src/fifo/index.ts +1 -0
- package/src/fifo_set/fifo_set.ts +52 -0
- package/src/fifo_set/index.ts +1 -0
- package/src/jest/setup.mjs +31 -1
- package/src/json-rpc/client/fetch.ts +4 -3
- package/src/json-rpc/client/safe_json_rpc_client.ts +4 -2
- package/src/json-rpc/client/undici.ts +23 -3
- package/src/json-rpc/fixtures/test_state.ts +10 -10
- package/src/json-rpc/server/api_key_auth.ts +63 -0
- package/src/json-rpc/server/index.ts +1 -0
- package/src/json-rpc/server/safe_json_rpc_server.ts +32 -14
- package/src/log/bigint-utils.ts +25 -0
- package/src/log/gcloud-logger-config.ts +5 -0
- package/src/log/libp2p_logger.ts +12 -5
- package/src/log/log-filters.ts +29 -11
- package/src/log/pino-logger-server.ts +25 -0
- package/src/log/pino-logger.ts +160 -39
- package/src/noir/noir_package_config.ts +32 -20
- package/src/promise/running-promise.ts +8 -5
- package/src/queue/base_memory_queue.ts +1 -1
- package/src/queue/batch_queue.ts +1 -0
- package/src/queue/semaphore.ts +5 -0
- package/src/retry/index.ts +66 -4
- package/src/schemas/api.ts +25 -25
- package/src/schemas/parse.ts +9 -6
- package/src/schemas/schemas.ts +4 -4
- package/src/schemas/types.ts +2 -2
- package/src/schemas/utils.ts +4 -38
- package/src/serialize/buffer_reader.ts +15 -0
- package/src/serialize/buffer_sink.ts +350 -0
- package/src/serialize/index.ts +1 -0
- package/src/serialize/serialize.ts +32 -0
- package/src/sleep/index.ts +10 -1
- package/src/string/index.ts +1 -1
- package/src/testing/files/index.ts +1 -2
- package/src/timer/date.ts +48 -0
- package/src/timer/index.ts +1 -1
- package/src/timer/timeout.ts +31 -0
- package/src/transport/dispatch/create_dispatch_proxy.ts +11 -1
- package/src/transport/index.ts +0 -1
- package/src/transport/transport_client.ts +2 -2
- package/src/trees/balanced_merkle_tree_root.ts +3 -9
- package/src/trees/hasher.ts +6 -7
- package/src/trees/indexed_merkle_tree_calculator.ts +5 -1
- package/src/trees/merkle_tree_calculator.ts +4 -10
- package/src/trees/sibling_path.ts +11 -6
- package/src/trees/unbalanced_merkle_tree_root.ts +2 -5
- package/src/types/index.ts +52 -0
- package/dest/crypto/serialize.d.ts +0 -51
- package/dest/crypto/serialize.d.ts.map +0 -1
- package/dest/crypto/serialize.js +0 -68
- package/dest/transport/dispatch/create_dispatch_fn.d.ts +0 -25
- package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +0 -1
- package/dest/transport/dispatch/create_dispatch_fn.js +0 -17
- package/src/crypto/serialize.ts +0 -85
- package/src/transport/dispatch/create_dispatch_fn.ts +0 -35
package/dest/config/index.js
CHANGED
|
@@ -33,8 +33,8 @@ export function isBooleanConfigValue(obj, key) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
// Parse the value if needed
|
|
37
|
-
if (value !== undefined) {
|
|
36
|
+
// Parse the value if needed. Empty strings are treated as "not set".
|
|
37
|
+
if (value !== undefined && value !== '') {
|
|
38
38
|
return parseFunc ? parseFunc(value) : value;
|
|
39
39
|
}
|
|
40
40
|
// Return default if no env var found
|
|
@@ -43,23 +43,21 @@ export function isBooleanConfigValue(obj, key) {
|
|
|
43
43
|
export function getConfigFromMappings(configMappings) {
|
|
44
44
|
const config = {};
|
|
45
45
|
for(const key in configMappings){
|
|
46
|
-
const { env, parseEnv, defaultValue,
|
|
47
|
-
|
|
48
|
-
config[key] = getConfigFromMappings(nested);
|
|
49
|
-
} else {
|
|
50
|
-
// Use the shared utility function
|
|
46
|
+
const { env, parseEnv, defaultValue, fallback, deprecatedFallback } = configMappings[key];
|
|
47
|
+
try {
|
|
51
48
|
config[key] = getValueFromEnvWithFallback(env, parseEnv, defaultValue, fallback);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
} catch (e) {
|
|
50
|
+
throw new Error(`Failed to parse config '${key}' (env: ${env ?? 'none'}): ${e.message}`);
|
|
51
|
+
}
|
|
52
|
+
if (deprecatedFallback?.length) {
|
|
53
|
+
const userLog = createConsoleLogger('[DEPRECATED]');
|
|
54
|
+
for (const { env: deprecatedEnv, message } of deprecatedFallback){
|
|
55
|
+
if (process.env[deprecatedEnv]) {
|
|
56
|
+
const warningMessage = message ?? `Environment variable ${deprecatedEnv} is deprecated. Please use ${env} instead.`;
|
|
57
|
+
userLog(warningMessage, {
|
|
58
|
+
deprecatedEnvVar: deprecatedEnv,
|
|
59
|
+
newEnvVar: env
|
|
60
|
+
});
|
|
63
61
|
}
|
|
64
62
|
}
|
|
65
63
|
}
|
|
@@ -75,23 +73,31 @@ export function getConfigFromMappings(configMappings) {
|
|
|
75
73
|
return Object.fromEntries(Object.entries(configMappings).filter(([key])=>!keysToFilter.includes(key)));
|
|
76
74
|
}
|
|
77
75
|
/**
|
|
78
|
-
* Generates parseEnv and default values for
|
|
79
|
-
*
|
|
80
|
-
*
|
|
76
|
+
* Generates parseEnv and default values for an integer config value.
|
|
77
|
+
*
|
|
78
|
+
* The default is used only when the environment variable is unset or empty. A set-but-invalid
|
|
79
|
+
* value (non-numeric, fractional, or outside the safe-integer range) throws rather than silently
|
|
80
|
+
* falling back to the default.
|
|
81
|
+
* @param defaultVal - The default value to use when the environment variable is unset
|
|
82
|
+
* @returns Object with parseEnv and default values for an integer config value
|
|
81
83
|
*/ export function numberConfigHelper(defaultVal) {
|
|
82
84
|
return {
|
|
83
|
-
parseEnv: (val)=>
|
|
85
|
+
parseEnv: (val)=>parseSafeInteger(val),
|
|
84
86
|
defaultValue: defaultVal
|
|
85
87
|
};
|
|
86
88
|
}
|
|
87
89
|
/**
|
|
88
|
-
* Generates parseEnv and default values for a
|
|
89
|
-
*
|
|
90
|
-
*
|
|
90
|
+
* Generates parseEnv and default values for a floating-point config value.
|
|
91
|
+
*
|
|
92
|
+
* The default is used only when the environment variable is unset or empty. A set-but-invalid
|
|
93
|
+
* value (not a finite number) throws rather than silently falling back to the default.
|
|
94
|
+
* @param defaultVal - The default value to use when the environment variable is unset
|
|
95
|
+
* @param validationFn - Optional extra validation applied to the parsed value; should throw on invalid input
|
|
96
|
+
* @returns Object with parseEnv and default values for a floating-point config value
|
|
91
97
|
*/ export function floatConfigHelper(defaultVal, validationFn) {
|
|
92
98
|
return {
|
|
93
99
|
parseEnv: (val)=>{
|
|
94
|
-
const parsed =
|
|
100
|
+
const parsed = parseFiniteNumber(val);
|
|
95
101
|
validationFn?.(parsed);
|
|
96
102
|
return parsed;
|
|
97
103
|
},
|
|
@@ -99,11 +105,16 @@ export function getConfigFromMappings(configMappings) {
|
|
|
99
105
|
};
|
|
100
106
|
}
|
|
101
107
|
/**
|
|
102
|
-
*
|
|
108
|
+
* Generates parseEnv and default values for a 0-1 percentage config value.
|
|
109
|
+
*
|
|
110
|
+
* The default is used only when the environment variable is unset or empty. A set-but-invalid
|
|
111
|
+
* value (not a finite number, or outside the 0-1 range) throws rather than silently falling back
|
|
112
|
+
* to the default.
|
|
113
|
+
* @param defaultVal - The default value to use when the environment variable is unset
|
|
103
114
|
*/ export function percentageConfigHelper(defaultVal) {
|
|
104
115
|
return {
|
|
105
116
|
parseEnv: (val)=>{
|
|
106
|
-
const parsed =
|
|
117
|
+
const parsed = parseFiniteNumber(val);
|
|
107
118
|
if (parsed < 0 || parsed > 1) {
|
|
108
119
|
throw new TypeError(`Invalid percentage value: ${parsed} should be between 0 and 1`);
|
|
109
120
|
}
|
|
@@ -112,15 +123,23 @@ export function getConfigFromMappings(configMappings) {
|
|
|
112
123
|
defaultValue: defaultVal
|
|
113
124
|
};
|
|
114
125
|
}
|
|
115
|
-
|
|
116
|
-
* Generates parseEnv and default values for a numerical config value.
|
|
117
|
-
* @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
|
|
118
|
-
* @returns Object with parseEnv and default values for a numerical config value
|
|
119
|
-
*/ export function bigintConfigHelper(defaultVal) {
|
|
126
|
+
export function bigintConfigHelper(defaultVal) {
|
|
120
127
|
return {
|
|
121
128
|
parseEnv: (val)=>{
|
|
122
|
-
|
|
123
|
-
|
|
129
|
+
// Handle scientific notation (e.g. "1e+23", "2E23") which BigInt() doesn't accept directly.
|
|
130
|
+
// We parse it losslessly using bigint arithmetic instead of going through float64.
|
|
131
|
+
if (/[eE]/.test(val)) {
|
|
132
|
+
const match = val.match(/^(-?\d+(?:\.(\d+))?)[eE]([+-]?\d+)$/);
|
|
133
|
+
if (!match) {
|
|
134
|
+
throw new Error(`Cannot convert '${val}' to a BigInt`);
|
|
135
|
+
}
|
|
136
|
+
const digits = match[1].replace('.', '');
|
|
137
|
+
const decimalPlaces = match[2]?.length ?? 0;
|
|
138
|
+
const exponent = parseInt(match[3], 10) - decimalPlaces;
|
|
139
|
+
if (exponent < 0) {
|
|
140
|
+
throw new Error(`Cannot convert '${val}' to a BigInt: result is not an integer`);
|
|
141
|
+
}
|
|
142
|
+
return BigInt(digits) * 10n ** BigInt(exponent);
|
|
124
143
|
}
|
|
125
144
|
return BigInt(val);
|
|
126
145
|
},
|
|
@@ -129,26 +148,18 @@ export function getConfigFromMappings(configMappings) {
|
|
|
129
148
|
}
|
|
130
149
|
/**
|
|
131
150
|
* Generates parseEnv for an optional numerical config value.
|
|
151
|
+
* Empty strings are already handled by getValueFromEnvWithFallback.
|
|
132
152
|
*/ export function optionalNumberConfigHelper() {
|
|
133
153
|
return {
|
|
134
|
-
parseEnv: (val)=>
|
|
135
|
-
if (val !== undefined && val.length > 0) {
|
|
136
|
-
const parsedValue = parseInt(val);
|
|
137
|
-
return Number.isSafeInteger(parsedValue) ? parsedValue : undefined;
|
|
138
|
-
}
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
154
|
+
parseEnv: (val)=>parseSafeInteger(val)
|
|
141
155
|
};
|
|
142
156
|
}
|
|
143
|
-
|
|
157
|
+
export function enumConfigHelper(values, defaultValue) {
|
|
144
158
|
return {
|
|
145
159
|
parseEnv: (val)=>{
|
|
146
|
-
const sanitizedVal =
|
|
147
|
-
if (values.
|
|
148
|
-
return sanitizedVal;
|
|
149
|
-
}
|
|
150
|
-
if (!val && defaultValue) {
|
|
151
|
-
return defaultValue;
|
|
160
|
+
const sanitizedVal = val.trim().toLowerCase();
|
|
161
|
+
if (values.some((v)=>v.toLowerCase() === sanitizedVal)) {
|
|
162
|
+
return values.find((v)=>v.toLowerCase() === sanitizedVal);
|
|
152
163
|
}
|
|
153
164
|
throw new Error(`Invalid config value '${val}' (must be one of ${values.join(', ')})`);
|
|
154
165
|
},
|
|
@@ -173,8 +184,7 @@ export function secretValueConfigHelper(parse) {
|
|
|
173
184
|
return {
|
|
174
185
|
parseEnv: wrap,
|
|
175
186
|
parseVal: wrap,
|
|
176
|
-
defaultValue: new SecretValue(parse(undefined))
|
|
177
|
-
isBoolean: true
|
|
187
|
+
defaultValue: new SecretValue(parse(undefined))
|
|
178
188
|
};
|
|
179
189
|
}
|
|
180
190
|
export { parseBooleanEnv } from './parse-env.js';
|
|
@@ -183,8 +193,7 @@ export function secretStringConfigHelper(defaultValue) {
|
|
|
183
193
|
return {
|
|
184
194
|
parseEnv: parse,
|
|
185
195
|
parseVal: parse,
|
|
186
|
-
defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined
|
|
187
|
-
isBoolean: true
|
|
196
|
+
defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined
|
|
188
197
|
};
|
|
189
198
|
}
|
|
190
199
|
export function secretFrConfigHelper(defaultValue) {
|
|
@@ -192,8 +201,7 @@ export function secretFrConfigHelper(defaultValue) {
|
|
|
192
201
|
return {
|
|
193
202
|
parseEnv: parse,
|
|
194
203
|
parseVal: parse,
|
|
195
|
-
defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined
|
|
196
|
-
isBoolean: true
|
|
204
|
+
defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined
|
|
197
205
|
};
|
|
198
206
|
}
|
|
199
207
|
export function secretFqConfigHelper(defaultValue) {
|
|
@@ -201,29 +209,37 @@ export function secretFqConfigHelper(defaultValue) {
|
|
|
201
209
|
return {
|
|
202
210
|
parseEnv: parse,
|
|
203
211
|
parseVal: parse,
|
|
204
|
-
defaultValue:
|
|
205
|
-
isBoolean: true
|
|
212
|
+
defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined
|
|
206
213
|
};
|
|
207
214
|
}
|
|
208
215
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
216
|
+
* Parses a string into a safe integer, throwing if the value is numeric but not an integer.
|
|
217
|
+
*
|
|
218
|
+
* Unlike `parseInt`, this does not silently truncate decimals: `'0.8'` throws rather than
|
|
219
|
+
* becoming `0`. A fractional value indicates the caller intended a non-integer where only
|
|
220
|
+
* integers are supported (use `floatConfigHelper`/`percentageConfigHelper` for those).
|
|
211
221
|
* @param value - The string value to parse
|
|
212
|
-
* @
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
222
|
+
* @returns The parsed integer value
|
|
223
|
+
*/ function parseSafeInteger(value) {
|
|
224
|
+
const parsedValue = parseFloat(value);
|
|
225
|
+
if (!Number.isSafeInteger(parsedValue)) {
|
|
226
|
+
throw new Error(`Invalid integer config value '${value}'; expected a whole number`);
|
|
227
|
+
}
|
|
228
|
+
return parsedValue;
|
|
217
229
|
}
|
|
218
230
|
/**
|
|
219
|
-
*
|
|
220
|
-
*
|
|
231
|
+
* Parses a string into a finite floating-point number, throwing if the value is not a finite number.
|
|
232
|
+
*
|
|
233
|
+
* Invalid input (e.g. `'abc'`, or an overflow to `Infinity`) throws rather than being silently
|
|
234
|
+
* swallowed, so a misconfigured value fails loudly instead of falling back to the config default.
|
|
221
235
|
* @param value - The string value to parse
|
|
222
|
-
* @
|
|
223
|
-
|
|
224
|
-
*/ function safeParseFloat(value, defaultValue) {
|
|
236
|
+
* @returns The parsed number
|
|
237
|
+
*/ function parseFiniteNumber(value) {
|
|
225
238
|
const parsedValue = parseFloat(value);
|
|
226
|
-
|
|
239
|
+
if (!Number.isFinite(parsedValue)) {
|
|
240
|
+
throw new Error(`Invalid number config value '${value}'`);
|
|
241
|
+
}
|
|
242
|
+
return parsedValue;
|
|
227
243
|
}
|
|
228
244
|
/**
|
|
229
245
|
* Picks specific keys from the given configuration mappings.
|
|
@@ -1,54 +1,28 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const NetworkConfigSchema: z.ZodObject<{
|
|
3
|
-
bootnodes: z.ZodArray<z.ZodString
|
|
4
|
-
snapshots: z.ZodArray<z.ZodString
|
|
5
|
-
blobFileStoreUrls: z.ZodOptional<z.ZodArray<z.ZodString
|
|
3
|
+
bootnodes: z.ZodArray<z.ZodString>;
|
|
4
|
+
snapshots: z.ZodArray<z.ZodString>;
|
|
5
|
+
blobFileStoreUrls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
|
+
txCollectionFileStoreUrls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
7
|
registryAddress: z.ZodString;
|
|
7
8
|
feeAssetHandlerAddress: z.ZodOptional<z.ZodString>;
|
|
8
9
|
l1ChainId: z.ZodNumber;
|
|
9
10
|
blockDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
blobFileStoreUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
14
|
-
registryAddress: z.ZodString;
|
|
15
|
-
feeAssetHandlerAddress: z.ZodOptional<z.ZodString>;
|
|
16
|
-
l1ChainId: z.ZodNumber;
|
|
17
|
-
blockDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
18
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
19
|
-
bootnodes: z.ZodArray<z.ZodString, "many">;
|
|
20
|
-
snapshots: z.ZodArray<z.ZodString, "many">;
|
|
21
|
-
blobFileStoreUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
22
|
-
registryAddress: z.ZodString;
|
|
23
|
-
feeAssetHandlerAddress: z.ZodOptional<z.ZodString>;
|
|
24
|
-
l1ChainId: z.ZodNumber;
|
|
25
|
-
blockDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
26
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
11
|
+
txPublicSetupAllowListExtend: z.ZodOptional<z.ZodString>;
|
|
12
|
+
nodeVersion: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$loose>;
|
|
27
14
|
export declare const NetworkConfigMapSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
28
|
-
bootnodes: z.ZodArray<z.ZodString
|
|
29
|
-
snapshots: z.ZodArray<z.ZodString
|
|
30
|
-
blobFileStoreUrls: z.ZodOptional<z.ZodArray<z.ZodString
|
|
31
|
-
|
|
32
|
-
feeAssetHandlerAddress: z.ZodOptional<z.ZodString>;
|
|
33
|
-
l1ChainId: z.ZodNumber;
|
|
34
|
-
blockDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
35
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
36
|
-
bootnodes: z.ZodArray<z.ZodString, "many">;
|
|
37
|
-
snapshots: z.ZodArray<z.ZodString, "many">;
|
|
38
|
-
blobFileStoreUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
39
|
-
registryAddress: z.ZodString;
|
|
40
|
-
feeAssetHandlerAddress: z.ZodOptional<z.ZodString>;
|
|
41
|
-
l1ChainId: z.ZodNumber;
|
|
42
|
-
blockDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
43
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
44
|
-
bootnodes: z.ZodArray<z.ZodString, "many">;
|
|
45
|
-
snapshots: z.ZodArray<z.ZodString, "many">;
|
|
46
|
-
blobFileStoreUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
15
|
+
bootnodes: z.ZodArray<z.ZodString>;
|
|
16
|
+
snapshots: z.ZodArray<z.ZodString>;
|
|
17
|
+
blobFileStoreUrls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
|
+
txCollectionFileStoreUrls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
47
19
|
registryAddress: z.ZodString;
|
|
48
20
|
feeAssetHandlerAddress: z.ZodOptional<z.ZodString>;
|
|
49
21
|
l1ChainId: z.ZodNumber;
|
|
50
22
|
blockDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
51
|
-
|
|
23
|
+
txPublicSetupAllowListExtend: z.ZodOptional<z.ZodString>;
|
|
24
|
+
nodeVersion: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, z.core.$loose>>;
|
|
52
26
|
export type NetworkConfig = z.infer<typeof NetworkConfigSchema>;
|
|
53
27
|
export type NetworkConfigMap = z.infer<typeof NetworkConfigMapSchema>;
|
|
54
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV0d29ya19jb25maWcuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb25maWcvbmV0d29ya19jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLENBQUMsRUFBRSxNQUFNLEtBQUssQ0FBQztBQUV4QixlQUFPLE1BQU0sbUJBQW1COzs7Ozs7Ozs7OztpQkFhaEIsQ0FBQztBQUVqQixlQUFPLE1BQU0sc0JBQXNCOzs7Ozs7Ozs7OztrQkFBNEMsQ0FBQztBQUVoRixNQUFNLE1BQU0sYUFBYSxHQUFHLENBQUMsQ0FBQyxLQUFLLENBQUMsT0FBTyxtQkFBbUIsQ0FBQyxDQUFDO0FBQ2hFLE1BQU0sTUFBTSxnQkFBZ0IsR0FBRyxDQUFDLENBQUMsS0FBSyxDQUFDLE9BQU8sc0JBQXNCLENBQUMsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network_config.d.ts","sourceRoot":"","sources":["../../src/config/network_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"network_config.d.ts","sourceRoot":"","sources":["../../src/config/network_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,mBAAmB;;;;;;;;;;;iBAahB,CAAC;AAEjB,eAAO,MAAM,sBAAsB;;;;;;;;;;;kBAA4C,CAAC;AAEhF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -3,9 +3,12 @@ export const NetworkConfigSchema = z.object({
|
|
|
3
3
|
bootnodes: z.array(z.string()),
|
|
4
4
|
snapshots: z.array(z.string()),
|
|
5
5
|
blobFileStoreUrls: z.array(z.string()).optional(),
|
|
6
|
+
txCollectionFileStoreUrls: z.array(z.string()).optional(),
|
|
6
7
|
registryAddress: z.string(),
|
|
7
8
|
feeAssetHandlerAddress: z.string().optional(),
|
|
8
9
|
l1ChainId: z.number(),
|
|
9
|
-
blockDurationMs: z.number().positive().optional()
|
|
10
|
+
blockDurationMs: z.number().positive().optional(),
|
|
11
|
+
txPublicSetupAllowListExtend: z.string().optional(),
|
|
12
|
+
nodeVersion: z.string().optional()
|
|
10
13
|
}).passthrough(); // Allow additional unknown fields to pass through
|
|
11
14
|
export const NetworkConfigMapSchema = z.record(z.string(), NetworkConfigSchema);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type NetworkNames = 'local' | 'staging
|
|
1
|
+
export type NetworkNames = 'local' | 'staging' | 'testnet' | 'mainnet' | 'next-net' | 'devnet' | `v${number}-devnet-${number}`;
|
|
2
2
|
export declare function getActiveNetworkName(name?: string): NetworkNames;
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV0d29ya19uYW1lLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uZmlnL25ldHdvcmtfbmFtZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLE1BQU0sWUFBWSxHQUNwQixPQUFPLEdBQ1AsU0FBUyxHQUNULFNBQVMsR0FDVCxTQUFTLEdBQ1QsVUFBVSxHQUNWLFFBQVEsR0FDUixJQUFJLE1BQU0sV0FBVyxNQUFNLEVBQUUsQ0FBQztBQUVsQyx3QkFBZ0Isb0JBQW9CLENBQUMsSUFBSSxDQUFDLEVBQUUsTUFBTSxHQUFHLFlBQVksQ0FrQmhFIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network_name.d.ts","sourceRoot":"","sources":["../../src/config/network_name.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,
|
|
1
|
+
{"version":3,"file":"network_name.d.ts","sourceRoot":"","sources":["../../src/config/network_name.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,SAAS,GACT,SAAS,GACT,SAAS,GACT,UAAU,GACV,QAAQ,GACR,IAAI,MAAM,WAAW,MAAM,EAAE,CAAC;AAElC,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,CAkBhE"}
|
|
@@ -2,9 +2,7 @@ export function getActiveNetworkName(name) {
|
|
|
2
2
|
const network = name || process.env.NETWORK;
|
|
3
3
|
if (!network || network === '' || network === 'local') {
|
|
4
4
|
return 'local';
|
|
5
|
-
} else if (network === 'staging
|
|
6
|
-
return network;
|
|
7
|
-
} else if (network === 'staging-public') {
|
|
5
|
+
} else if (network === 'staging') {
|
|
8
6
|
return network;
|
|
9
7
|
} else if (network === 'testnet' || network === 'alpha-testnet') {
|
|
10
8
|
return 'testnet';
|
|
@@ -14,6 +12,8 @@ export function getActiveNetworkName(name) {
|
|
|
14
12
|
return 'next-net';
|
|
15
13
|
} else if (network === 'devnet') {
|
|
16
14
|
return 'devnet';
|
|
15
|
+
} else if (/^v\d+-devnet-\d+$/.test(network)) {
|
|
16
|
+
return network;
|
|
17
17
|
}
|
|
18
18
|
throw new Error(`Unknown network: ${network}`);
|
|
19
19
|
}
|
|
@@ -23,6 +23,6 @@ export declare class SecretValue<T> {
|
|
|
23
23
|
/**
|
|
24
24
|
* Returns a Zod schema
|
|
25
25
|
*/
|
|
26
|
-
static schema<O>(valueSchema: ZodType<O, any
|
|
26
|
+
static schema<O>(valueSchema: ZodType<O, any>): ZodType<SecretValue<O>, any>;
|
|
27
27
|
}
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VjcmV0X3ZhbHVlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uZmlnL3NlY3JldF92YWx1ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBQy9CLE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLEtBQUssQ0FBQztBQUVuQzs7R0FFRztBQUNILHFCQUFhLFdBQVcsQ0FBQyxDQUFDOztJQU10QixPQUFPLENBQUMsUUFBUSxDQUFDLGFBQWE7SUFGaEMsWUFDRSxLQUFLLEVBQUUsQ0FBQyxFQUNTLGFBQWEsU0FBZSxFQUc5QztJQUVEOztPQUVHO0lBQ0ksUUFBUSxJQUFJLENBQUMsQ0FFbkI7SUFFRDs7T0FFRztJQUNJLFFBQVEsSUFBSSxNQUFNLENBRXhCO0lBRUQ7O09BRUc7SUFDSSxNQUFNLElBQUksTUFBTSxDQUV0QjtJQUVNLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxXQUV0QjtJQUVEOztPQUVHO0lBQ0gsTUFBTSxDQUFDLE1BQU0sQ0FBQyxDQUFDLEVBQUUsV0FBVyxFQUFFLE9BQU8sQ0FBQyxDQUFDLEVBQUUsR0FBRyxDQUFDLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUMsRUFBRSxHQUFHLENBQUMsQ0FFM0U7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret_value.d.ts","sourceRoot":"","sources":["../../src/config/secret_value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC;;IAMtB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAFhC,YACE,KAAK,EAAE,CAAC,EACS,aAAa,SAAe,EAG9C;IAED;;OAEG;IACI,QAAQ,IAAI,CAAC,CAEnB;IAED;;OAEG;IACI,QAAQ,IAAI,MAAM,CAExB;IAED;;OAEG;IACI,MAAM,IAAI,MAAM,CAEtB;IAEM,CAAC,OAAO,CAAC,MAAM,CAAC,WAEtB;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"secret_value.d.ts","sourceRoot":"","sources":["../../src/config/secret_value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC;;IAMtB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAFhC,YACE,KAAK,EAAE,CAAC,EACS,aAAa,SAAe,EAG9C;IAED;;OAEG;IACI,QAAQ,IAAI,CAAC,CAEnB;IAED;;OAEG;IACI,QAAQ,IAAI,MAAM,CAExB;IAED;;OAEG;IACI,MAAM,IAAI,MAAM,CAEtB;IAEM,CAAC,OAAO,CAAC,MAAM,CAAC,WAEtB;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAE3E;CACF"}
|
|
@@ -26,7 +26,8 @@ export declare class Aes128 {
|
|
|
26
26
|
* @param iv - AES initialization vector.
|
|
27
27
|
* @param key - Key to decrypt with.
|
|
28
28
|
* @returns Decrypted data.
|
|
29
|
+
* @throws If the decrypted buffer has invalid PKCS#7 padding.
|
|
29
30
|
*/
|
|
30
31
|
decryptBufferCBC(data: Uint8Array, iv: Uint8Array, key: Uint8Array): Promise<Buffer<ArrayBufferLike>>;
|
|
31
32
|
}
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
33
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jcnlwdG8vYWVzMTI4L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxRQUFRLENBQUM7QUFFaEM7O0dBRUc7QUFDSCxxQkFBYSxNQUFNO0lBQ2pCOzs7Ozs7T0FNRztJQUNVLGdCQUFnQixDQUFDLElBQUksRUFBRSxVQUFVLEVBQUUsRUFBRSxFQUFFLFVBQVUsRUFBRSxHQUFHLEVBQUUsVUFBVSxnQ0FrQjlFO0lBRUQ7Ozs7Ozs7T0FPRztJQUNVLDJCQUEyQixDQUFDLElBQUksRUFBRSxVQUFVLEVBQUUsRUFBRSxFQUFFLFVBQVUsRUFBRSxHQUFHLEVBQUUsVUFBVSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FVM0c7SUFFRDs7Ozs7OztPQU9HO0lBQ1UsZ0JBQWdCLENBQUMsSUFBSSxFQUFFLFVBQVUsRUFBRSxFQUFFLEVBQUUsVUFBVSxFQUFFLEdBQUcsRUFBRSxVQUFVLG9DQVk5RTtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/aes128/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;GAEG;AACH,qBAAa,MAAM;IACjB;;;;;;OAMG;IACU,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,gCAkB9E;IAED;;;;;;;OAOG;IACU,2BAA2B,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAU3G;IAED
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/aes128/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;GAEG;AACH,qBAAa,MAAM;IACjB;;;;;;OAMG;IACU,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,gCAkB9E;IAED;;;;;;;OAOG;IACU,2BAA2B,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAU3G;IAED;;;;;;;OAOG;IACU,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,oCAY9E;CACF"}
|
|
@@ -54,9 +54,18 @@ import { Buffer } from 'buffer';
|
|
|
54
54
|
* @param iv - AES initialization vector.
|
|
55
55
|
* @param key - Key to decrypt with.
|
|
56
56
|
* @returns Decrypted data.
|
|
57
|
+
* @throws If the decrypted buffer has invalid PKCS#7 padding.
|
|
57
58
|
*/ async decryptBufferCBC(data, iv, key) {
|
|
58
59
|
const paddedBuffer = await this.decryptBufferCBCKeepPadding(data, iv, key);
|
|
59
|
-
const
|
|
60
|
-
|
|
60
|
+
const paddingLen = paddedBuffer[paddedBuffer.length - 1];
|
|
61
|
+
if (paddingLen === 0 || paddingLen > 16) {
|
|
62
|
+
throw new Error(`Invalid PKCS#7 padding length: ${paddingLen}`);
|
|
63
|
+
}
|
|
64
|
+
for(let i = paddedBuffer.length - paddingLen; i < paddedBuffer.length; i++){
|
|
65
|
+
if (paddedBuffer[i] !== paddingLen) {
|
|
66
|
+
throw new Error('Invalid PKCS#7 padding');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return paddedBuffer.subarray(0, paddedBuffer.length - paddingLen);
|
|
61
70
|
}
|
|
62
71
|
}
|