@metamask-previews/snap-networks-utils 1.0.0-preview-afa1ddd5 → 1.0.0-preview-dc363bbc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/index.cjs +13 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -1
- package/dist/utils/config/BaseConfigProvider.cjs +62 -0
- package/dist/utils/config/BaseConfigProvider.cjs.map +1 -0
- package/dist/utils/config/BaseConfigProvider.d.cts +54 -0
- package/dist/utils/config/BaseConfigProvider.d.cts.map +1 -0
- package/dist/utils/config/BaseConfigProvider.d.mts +54 -0
- package/dist/utils/config/BaseConfigProvider.d.mts.map +1 -0
- package/dist/utils/config/BaseConfigProvider.mjs +58 -0
- package/dist/utils/config/BaseConfigProvider.mjs.map +1 -0
- package/dist/utils/config/envStructs.cjs +51 -0
- package/dist/utils/config/envStructs.cjs.map +1 -0
- package/dist/utils/config/envStructs.d.cts +44 -0
- package/dist/utils/config/envStructs.d.cts.map +1 -0
- package/dist/utils/config/envStructs.d.mts +44 -0
- package/dist/utils/config/envStructs.d.mts.map +1 -0
- package/dist/utils/config/envStructs.mjs +44 -0
- package/dist/utils/config/envStructs.mjs.map +1 -0
- package/dist/utils/config/logLevelStruct.cjs +14 -0
- package/dist/utils/config/logLevelStruct.cjs.map +1 -0
- package/dist/utils/config/logLevelStruct.d.cts +17 -0
- package/dist/utils/config/logLevelStruct.d.cts.map +1 -0
- package/dist/utils/config/logLevelStruct.d.mts +17 -0
- package/dist/utils/config/logLevelStruct.d.mts.map +1 -0
- package/dist/utils/config/logLevelStruct.mjs +11 -0
- package/dist/utils/config/logLevelStruct.mjs.map +1 -0
- package/dist/utils/config/parseEnv.cjs +30 -0
- package/dist/utils/config/parseEnv.cjs.map +1 -0
- package/dist/utils/config/parseEnv.d.cts +19 -0
- package/dist/utils/config/parseEnv.d.cts.map +1 -0
- package/dist/utils/config/parseEnv.d.mts +19 -0
- package/dist/utils/config/parseEnv.d.mts.map +1 -0
- package/dist/utils/config/parseEnv.mjs +26 -0
- package/dist/utils/config/parseEnv.mjs.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
+
- Add shared configuration utilities for network snaps ([#309](https://github.com/MetaMask/internal-snaps/pull/309))
|
|
13
|
+
- `BaseConfigProvider`, a base class owning the configuration lifecycle (parse the explicitly passed environment once against a Superstruct, frozen config, fail-fast on invalid environments)
|
|
14
|
+
- `parseEnv` for fail-fast parsing of raw environment records against a struct
|
|
15
|
+
- `emptyToUndefined`, `commaSeparatedListOf`, `parseIntegerStruct`, and `parseFloatStruct` structs for parsing environment variables
|
|
16
|
+
- `LogLevelStruct` for parsing a `LogLevel` from an environment variable
|
|
12
17
|
- Add `ExtendedKeyringAccount`, `KeyringAccountExtension`, and `asStrictKeyringAccount` for snap keyring accounts that persist `entropySource`, `derivationPath`, and `index`. ([#300](https://github.com/MetaMask/internal-snaps/pull/300))
|
|
13
18
|
- Add shared snap state helpers `IStateManager`, `State`, and `InMemoryState` (Tron-style write mutex plus blob/path locking). ([#288](https://github.com/MetaMask/internal-snaps/pull/288))
|
|
14
19
|
- Add shared caching utilities for network snaps ([#287](https://github.com/MetaMask/internal-snaps/pull/287))
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.InMemoryCache = exports.InFlightCoalescer = exports.normalizeError = exports.isSnapRpcError = exports.createWithCatchAndThrowSnapError = exports.createTrackError = exports.createSnapErrorHandling = exports.InMemoryState = exports.State = exports.validateOrigin = exports.DEFAULT_METAMASK_ORIGIN = exports.DEFAULT_DEV_ORIGINS = exports.DEFAULT_PROD_ORIGINS = exports.createOriginPermissions = exports.PROOF_OF_OWNERSHIP_MESSAGE_PREFIX = exports.ProofOfOwnershipMessageStruct = exports.ProofOfOwnershipBatchSuccessStruct = exports.ProofOfOwnershipBatchResponseStruct = exports.ProofOfOwnershipBatchRequestParamsStruct = exports.ProofOfOwnershipBatchRequestItemStruct = exports.ProofOfOwnershipBatchItemResponseStruct = exports.ProofOfOwnershipBatchErrorStruct = exports.parseProofOfOwnershipMessage = exports.deserialize = exports.serialize = exports.LogLevel = exports.Logger = exports.chunks = exports.batchesAllWithChunks = exports.batchesAllSettledWithChunks = exports.batchesAllSettled = exports.batchesAll = exports.LogLevelStruct = exports.parseFloatStruct = exports.parseIntegerStruct = exports.emptyToUndefined = exports.commaSeparatedListOf = exports.BaseConfigProvider = exports.parseEnv = exports.asStrictKeyringAccount = exports.UuidStruct = exports.UrlStruct = exports.sanitizeUri = exports.sanitizeControlCharacters = exports.buildUrl = exports.safeMerge = exports.RemoteFeatureFlagsProvider = exports.REMOTE_FEATURE_FLAGS_PROVIDER_NAME = exports.AssetsProvider = exports.ASSETS_PROVIDER_NAME = void 0;
|
|
4
|
+
exports.useCacheUntil = exports.useCache = exports.StateCache = void 0;
|
|
4
5
|
var AssetsProvider_1 = require("./providers/assets/AssetsProvider.cjs");
|
|
5
6
|
Object.defineProperty(exports, "ASSETS_PROVIDER_NAME", { enumerable: true, get: function () { return AssetsProvider_1.ASSETS_PROVIDER_NAME; } });
|
|
6
7
|
Object.defineProperty(exports, "AssetsProvider", { enumerable: true, get: function () { return AssetsProvider_1.AssetsProvider; } });
|
|
@@ -20,6 +21,17 @@ var uuidStruct_1 = require("./utils/uuidStruct/uuidStruct.cjs");
|
|
|
20
21
|
Object.defineProperty(exports, "UuidStruct", { enumerable: true, get: function () { return uuidStruct_1.UuidStruct; } });
|
|
21
22
|
var keyringAccount_1 = require("./utils/keyringAccount/keyringAccount.cjs");
|
|
22
23
|
Object.defineProperty(exports, "asStrictKeyringAccount", { enumerable: true, get: function () { return keyringAccount_1.asStrictKeyringAccount; } });
|
|
24
|
+
var parseEnv_1 = require("./utils/config/parseEnv.cjs");
|
|
25
|
+
Object.defineProperty(exports, "parseEnv", { enumerable: true, get: function () { return parseEnv_1.parseEnv; } });
|
|
26
|
+
var BaseConfigProvider_1 = require("./utils/config/BaseConfigProvider.cjs");
|
|
27
|
+
Object.defineProperty(exports, "BaseConfigProvider", { enumerable: true, get: function () { return BaseConfigProvider_1.BaseConfigProvider; } });
|
|
28
|
+
var envStructs_1 = require("./utils/config/envStructs.cjs");
|
|
29
|
+
Object.defineProperty(exports, "commaSeparatedListOf", { enumerable: true, get: function () { return envStructs_1.commaSeparatedListOf; } });
|
|
30
|
+
Object.defineProperty(exports, "emptyToUndefined", { enumerable: true, get: function () { return envStructs_1.emptyToUndefined; } });
|
|
31
|
+
Object.defineProperty(exports, "parseIntegerStruct", { enumerable: true, get: function () { return envStructs_1.parseIntegerStruct; } });
|
|
32
|
+
Object.defineProperty(exports, "parseFloatStruct", { enumerable: true, get: function () { return envStructs_1.parseFloatStruct; } });
|
|
33
|
+
var logLevelStruct_1 = require("./utils/config/logLevelStruct.cjs");
|
|
34
|
+
Object.defineProperty(exports, "LogLevelStruct", { enumerable: true, get: function () { return logLevelStruct_1.LogLevelStruct; } });
|
|
23
35
|
var async_1 = require("./utils/async/async.cjs");
|
|
24
36
|
Object.defineProperty(exports, "batchesAll", { enumerable: true, get: function () { return async_1.batchesAll; } });
|
|
25
37
|
Object.defineProperty(exports, "batchesAllSettled", { enumerable: true, get: function () { return async_1.batchesAllSettled; } });
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,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AA,6BAA6B,OAAA;AAC7B,qIAAA,iCAAiC,OAAA;AAWnC,iGAK2D;AAJzD,kIAAA,uBAAuB,OAAA;AACvB,+HAAA,oBAAoB,OAAA;AACpB,8HAAA,mBAAmB,OAAA;AACnB,kIAAA,uBAAuB,OAAA;AAGzB,+EAA0E;AAAjE,gHAAA,cAAc,OAAA;AACvB,iDAA4C;AAAnC,8FAAA,KAAK,OAAA;AAEd,iEAA4D;AAAnD,8GAAA,aAAa,OAAA;AAEtB,mDAMwB;AALtB,iHAAA,uBAAuB,OAAA;AACvB,0GAAA,gBAAgB,OAAA;AAChB,0HAAA,gCAAgC,OAAA;AAChC,wGAAA,cAAc,OAAA;AACd,wGAAA,cAAc,OAAA;AAEhB,0EAAqE;AAA5D,sHAAA,iBAAiB,OAAA;AAC1B,iEAA4D;AAAnD,8GAAA,aAAa,OAAA;AACtB,2DAAsD;AAA7C,wGAAA,UAAU,OAAA;AACnB,uDAAkD;AAAzC,oGAAA,QAAQ,OAAA;AACjB,iEAA4D;AAAnD,8GAAA,aAAa,OAAA","sourcesContent":["export {\n ASSETS_PROVIDER_NAME,\n AssetsProvider,\n type AssetsProviderMessenger,\n} from './providers/assets/AssetsProvider';\nexport {\n REMOTE_FEATURE_FLAGS_PROVIDER_NAME,\n RemoteFeatureFlagsProvider,\n type RemoteFeatureFlagsProviderMessenger,\n} from './providers/remote-feature-flags/RemoteFeatureFlagsProvider';\nexport { safeMerge } from './utils/safeMerge/safeMerge';\nexport { buildUrl } from './utils/buildUrl/buildUrl';\nexport type { BuildUrlParams } from './utils/buildUrl/buildUrl';\nexport {\n sanitizeControlCharacters,\n sanitizeUri,\n} from './utils/sanitize/sanitize';\nexport { UrlStruct } from './utils/urlStruct/urlStruct';\nexport { UuidStruct } from './utils/uuidStruct/uuidStruct';\nexport { asStrictKeyringAccount } from './utils/keyringAccount/keyringAccount';\nexport type {\n ExtendedKeyringAccount,\n KeyringAccountExtension,\n} from './utils/keyringAccount/keyringAccount';\nexport { parseEnv } from './utils/config/parseEnv';\nexport { BaseConfigProvider } from './utils/config/BaseConfigProvider';\nexport {\n commaSeparatedListOf,\n emptyToUndefined,\n parseIntegerStruct,\n parseFloatStruct,\n} from './utils/config/envStructs';\nexport { LogLevelStruct } from './utils/config/logLevelStruct';\nexport {\n batchesAll,\n batchesAllSettled,\n batchesAllSettledWithChunks,\n batchesAllWithChunks,\n chunks,\n} from './utils/async/async';\nexport { Logger, LogLevel } from './utils/logger/Logger';\nexport type {\n LoggerOptions,\n LoggerMethod,\n LogMethod,\n LogMethodDecorator,\n LoggerDecorators,\n} from './utils/logger/Logger';\nexport { serialize, deserialize } from './utils/serialization/serialization';\nexport type { Serializable } from './utils/serialization/types';\nexport {\n parseProofOfOwnershipMessage,\n ProofOfOwnershipBatchErrorStruct,\n ProofOfOwnershipBatchItemResponseStruct,\n ProofOfOwnershipBatchRequestItemStruct,\n ProofOfOwnershipBatchRequestParamsStruct,\n ProofOfOwnershipBatchResponseStruct,\n ProofOfOwnershipBatchSuccessStruct,\n ProofOfOwnershipMessageStruct,\n PROOF_OF_OWNERSHIP_MESSAGE_PREFIX,\n} from './utils/proofOfOwnership/proofOfOwnership';\nexport type {\n ProofOfOwnershipBatchError,\n ProofOfOwnershipBatchItemResponse,\n ProofOfOwnershipBatchRequestItem,\n ProofOfOwnershipBatchRequestParams,\n ProofOfOwnershipBatchResponse,\n ProofOfOwnershipBatchSuccess,\n ProofOfOwnershipMessage,\n} from './utils/proofOfOwnership/proofOfOwnership';\nexport {\n createOriginPermissions,\n DEFAULT_PROD_ORIGINS,\n DEFAULT_DEV_ORIGINS,\n DEFAULT_METAMASK_ORIGIN,\n} from './utils/originPermissions/createOriginPermissions';\nexport type { CreateOriginPermissionsParams } from './utils/originPermissions/createOriginPermissions';\nexport { validateOrigin } from './utils/originPermissions/validateOrigin';\nexport { State } from './utils/state/State';\nexport type { StateConfig } from './utils/state/State';\nexport { InMemoryState } from './utils/state/InMemoryState';\nexport type { IStateManager } from './utils/state/IStateManager';\nexport {\n createSnapErrorHandling,\n createTrackError,\n createWithCatchAndThrowSnapError,\n isSnapRpcError,\n normalizeError,\n} from './utils/errors';\nexport { InFlightCoalescer } from './utils/dedupe/InFlightCoalescer';\nexport { InMemoryCache } from './utils/cache/InMemoryCache';\nexport { StateCache } from './utils/cache/StateCache';\nexport { useCache } from './utils/cache/useCache';\nexport { useCacheUntil } from './utils/cache/useCacheUntil';\nexport type { CacheOptions } from './utils/cache/useCache';\nexport type {\n CacheUntilOptions,\n ResultWithExpiry,\n} from './utils/cache/useCacheUntil';\nexport type {\n ICache,\n CacheEntry,\n TimestampMilliseconds,\n} from './utils/cache/types';\nexport type {\n CacheStateManager,\n CacheStore,\n CachePrefix,\n StateValue,\n} from './utils/cache/StateCache';\nexport type {\n CreateSnapErrorHandlingOptions,\n CreateTrackErrorOptions,\n CreateWithCatchAndThrowSnapErrorOptions,\n LogErrorFn,\n NormalizeErrorFn,\n PrepareErrorForTrackingFn,\n ShouldTrackErrorFn,\n SnapRpcError,\n SnapTrackErrorRequest,\n TrackErrorCapableProvider,\n TrackErrorFn,\n} from './utils/errors';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -8,6 +8,10 @@ export { UrlStruct } from "./utils/urlStruct/urlStruct.cjs";
|
|
|
8
8
|
export { UuidStruct } from "./utils/uuidStruct/uuidStruct.cjs";
|
|
9
9
|
export { asStrictKeyringAccount } from "./utils/keyringAccount/keyringAccount.cjs";
|
|
10
10
|
export type { ExtendedKeyringAccount, KeyringAccountExtension, } from "./utils/keyringAccount/keyringAccount.cjs";
|
|
11
|
+
export { parseEnv } from "./utils/config/parseEnv.cjs";
|
|
12
|
+
export { BaseConfigProvider } from "./utils/config/BaseConfigProvider.cjs";
|
|
13
|
+
export { commaSeparatedListOf, emptyToUndefined, parseIntegerStruct, parseFloatStruct, } from "./utils/config/envStructs.cjs";
|
|
14
|
+
export { LogLevelStruct } from "./utils/config/logLevelStruct.cjs";
|
|
11
15
|
export { batchesAll, batchesAllSettled, batchesAllSettledWithChunks, batchesAllWithChunks, chunks, } from "./utils/async/async.cjs";
|
|
12
16
|
export { Logger, LogLevel } from "./utils/logger/Logger.cjs";
|
|
13
17
|
export type { LoggerOptions, LoggerMethod, LogMethod, LogMethodDecorator, LoggerDecorators, } from "./utils/logger/Logger.cjs";
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,KAAK,uBAAuB,GAC7B,8CAA0C;AAC3C,OAAO,EACL,kCAAkC,EAClC,0BAA0B,EAC1B,KAAK,mCAAmC,GACzC,wEAAoE;AACrE,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,QAAQ,EAAE,sCAAkC;AACrD,YAAY,EAAE,cAAc,EAAE,sCAAkC;AAChE,OAAO,EACL,yBAAyB,EACzB,WAAW,GACZ,sCAAkC;AACnC,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,UAAU,EAAE,0CAAsC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,kDAA8C;AAC/E,YAAY,EACV,sBAAsB,EACtB,uBAAuB,GACxB,kDAA8C;AAC/C,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,oBAAoB,EACpB,MAAM,GACP,gCAA4B;AAC7B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,kCAA8B;AACzD,YAAY,EACV,aAAa,EACb,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,gBAAgB,GACjB,kCAA8B;AAC/B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,gDAA4C;AAC7E,YAAY,EAAE,YAAY,EAAE,wCAAoC;AAChE,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,EAChC,uCAAuC,EACvC,sCAAsC,EACtC,wCAAwC,EACxC,mCAAmC,EAC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|
export { UuidStruct } from "./utils/uuidStruct/uuidStruct.mjs";
|
|
9
9
|
export { asStrictKeyringAccount } from "./utils/keyringAccount/keyringAccount.mjs";
|
|
10
10
|
export type { ExtendedKeyringAccount, KeyringAccountExtension, } from "./utils/keyringAccount/keyringAccount.mjs";
|
|
11
|
+
export { parseEnv } from "./utils/config/parseEnv.mjs";
|
|
12
|
+
export { BaseConfigProvider } from "./utils/config/BaseConfigProvider.mjs";
|
|
13
|
+
export { commaSeparatedListOf, emptyToUndefined, parseIntegerStruct, parseFloatStruct, } from "./utils/config/envStructs.mjs";
|
|
14
|
+
export { LogLevelStruct } from "./utils/config/logLevelStruct.mjs";
|
|
11
15
|
export { batchesAll, batchesAllSettled, batchesAllSettledWithChunks, batchesAllWithChunks, chunks, } from "./utils/async/async.mjs";
|
|
12
16
|
export { Logger, LogLevel } from "./utils/logger/Logger.mjs";
|
|
13
17
|
export type { LoggerOptions, LoggerMethod, LogMethod, LogMethodDecorator, LoggerDecorators, } from "./utils/logger/Logger.mjs";
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,KAAK,uBAAuB,GAC7B,8CAA0C;AAC3C,OAAO,EACL,kCAAkC,EAClC,0BAA0B,EAC1B,KAAK,mCAAmC,GACzC,wEAAoE;AACrE,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,QAAQ,EAAE,sCAAkC;AACrD,YAAY,EAAE,cAAc,EAAE,sCAAkC;AAChE,OAAO,EACL,yBAAyB,EACzB,WAAW,GACZ,sCAAkC;AACnC,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,UAAU,EAAE,0CAAsC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,kDAA8C;AAC/E,YAAY,EACV,sBAAsB,EACtB,uBAAuB,GAC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;AAC5D,YAAY,EAAE,YAAY,EAAE,mCAA+B;AAC3D,YAAY,EACV,iBAAiB,EACjB,gBAAgB,GACjB,wCAAoC;AACrC,YAAY,EACV,MAAM,EACN,UAAU,EACV,qBAAqB,GACtB,gCAA4B;AAC7B,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,UAAU,GACX,qCAAiC;AAClC,YAAY,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,uCAAuC,EACvC,UAAU,EACV,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,YAAY,GACb,iCAAuB"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,KAAK,uBAAuB,GAC7B,8CAA0C;AAC3C,OAAO,EACL,kCAAkC,EAClC,0BAA0B,EAC1B,KAAK,mCAAmC,GACzC,wEAAoE;AACrE,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,QAAQ,EAAE,sCAAkC;AACrD,YAAY,EAAE,cAAc,EAAE,sCAAkC;AAChE,OAAO,EACL,yBAAyB,EACzB,WAAW,GACZ,sCAAkC;AACnC,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,UAAU,EAAE,0CAAsC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,kDAA8C;AAC/E,YAAY,EACV,sBAAsB,EACtB,uBAAuB,GACxB,kDAA8C;AAC/C,OAAO,EAAE,QAAQ,EAAE,oCAAgC;AACnD,OAAO,EAAE,kBAAkB,EAAE,8CAA0C;AACvE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,GACjB,sCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,0CAAsC;AAC/D,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,2BAA2B,EAC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EACjB,gBAAgB,GACjB,wCAAoC;AACrC,YAAY,EACV,MAAM,EACN,UAAU,EACV,qBAAqB,GACtB,gCAA4B;AAC7B,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,UAAU,GACX,qCAAiC;AAClC,YAAY,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,uCAAuC,EACvC,UAAU,EACV,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,YAAY,GACb,iCAAuB"}
|
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,10 @@ export { sanitizeControlCharacters, sanitizeUri } from "./utils/sanitize/sanitiz
|
|
|
6
6
|
export { UrlStruct } from "./utils/urlStruct/urlStruct.mjs";
|
|
7
7
|
export { UuidStruct } from "./utils/uuidStruct/uuidStruct.mjs";
|
|
8
8
|
export { asStrictKeyringAccount } from "./utils/keyringAccount/keyringAccount.mjs";
|
|
9
|
+
export { parseEnv } from "./utils/config/parseEnv.mjs";
|
|
10
|
+
export { BaseConfigProvider } from "./utils/config/BaseConfigProvider.mjs";
|
|
11
|
+
export { commaSeparatedListOf, emptyToUndefined, parseIntegerStruct, parseFloatStruct } from "./utils/config/envStructs.mjs";
|
|
12
|
+
export { LogLevelStruct } from "./utils/config/logLevelStruct.mjs";
|
|
9
13
|
export { batchesAll, batchesAllSettled, batchesAllSettledWithChunks, batchesAllWithChunks, chunks } from "./utils/async/async.mjs";
|
|
10
14
|
export { Logger, LogLevel } from "./utils/logger/Logger.mjs";
|
|
11
15
|
export { serialize, deserialize } from "./utils/serialization/serialization.mjs";
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EAEf,8CAA0C;AAC3C,OAAO,EACL,kCAAkC,EAClC,0BAA0B,EAE3B,wEAAoE;AACrE,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,QAAQ,EAAE,sCAAkC;AAErD,OAAO,EACL,yBAAyB,EACzB,WAAW,EACZ,sCAAkC;AACnC,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,UAAU,EAAE,0CAAsC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,kDAA8C;AAK/E,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,oBAAoB,EACpB,MAAM,EACP,gCAA4B;AAC7B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,kCAA8B;AAQzD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,gDAA4C;AAE7E,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,EAChC,uCAAuC,EACvC,sCAAsC,EACtC,wCAAwC,EACxC,mCAAmC,EACnC,kCAAkC,EAClC,6BAA6B,EAC7B,iCAAiC,EAClC,sDAAkD;AAUnD,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,EACxB,8DAA0D;AAE3D,OAAO,EAAE,cAAc,EAAE,qDAAiD;AAC1E,OAAO,EAAE,KAAK,EAAE,gCAA4B;AAE5C,OAAO,EAAE,aAAa,EAAE,wCAAoC;AAE5D,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,gCAAgC,EAChC,cAAc,EACd,cAAc,EACf,iCAAuB;AACxB,OAAO,EAAE,iBAAiB,EAAE,6CAAyC;AACrE,OAAO,EAAE,aAAa,EAAE,wCAAoC;AAC5D,OAAO,EAAE,UAAU,EAAE,qCAAiC;AACtD,OAAO,EAAE,QAAQ,EAAE,mCAA+B;AAClD,OAAO,EAAE,aAAa,EAAE,wCAAoC","sourcesContent":["export {\n ASSETS_PROVIDER_NAME,\n AssetsProvider,\n type AssetsProviderMessenger,\n} from './providers/assets/AssetsProvider';\nexport {\n REMOTE_FEATURE_FLAGS_PROVIDER_NAME,\n RemoteFeatureFlagsProvider,\n type RemoteFeatureFlagsProviderMessenger,\n} from './providers/remote-feature-flags/RemoteFeatureFlagsProvider';\nexport { safeMerge } from './utils/safeMerge/safeMerge';\nexport { buildUrl } from './utils/buildUrl/buildUrl';\nexport type { BuildUrlParams } from './utils/buildUrl/buildUrl';\nexport {\n sanitizeControlCharacters,\n sanitizeUri,\n} from './utils/sanitize/sanitize';\nexport { UrlStruct } from './utils/urlStruct/urlStruct';\nexport { UuidStruct } from './utils/uuidStruct/uuidStruct';\nexport { asStrictKeyringAccount } from './utils/keyringAccount/keyringAccount';\nexport type {\n ExtendedKeyringAccount,\n KeyringAccountExtension,\n} from './utils/keyringAccount/keyringAccount';\nexport {\n batchesAll,\n batchesAllSettled,\n batchesAllSettledWithChunks,\n batchesAllWithChunks,\n chunks,\n} from './utils/async/async';\nexport { Logger, LogLevel } from './utils/logger/Logger';\nexport type {\n LoggerOptions,\n LoggerMethod,\n LogMethod,\n LogMethodDecorator,\n LoggerDecorators,\n} from './utils/logger/Logger';\nexport { serialize, deserialize } from './utils/serialization/serialization';\nexport type { Serializable } from './utils/serialization/types';\nexport {\n parseProofOfOwnershipMessage,\n ProofOfOwnershipBatchErrorStruct,\n ProofOfOwnershipBatchItemResponseStruct,\n ProofOfOwnershipBatchRequestItemStruct,\n ProofOfOwnershipBatchRequestParamsStruct,\n ProofOfOwnershipBatchResponseStruct,\n ProofOfOwnershipBatchSuccessStruct,\n ProofOfOwnershipMessageStruct,\n PROOF_OF_OWNERSHIP_MESSAGE_PREFIX,\n} from './utils/proofOfOwnership/proofOfOwnership';\nexport type {\n ProofOfOwnershipBatchError,\n ProofOfOwnershipBatchItemResponse,\n ProofOfOwnershipBatchRequestItem,\n ProofOfOwnershipBatchRequestParams,\n ProofOfOwnershipBatchResponse,\n ProofOfOwnershipBatchSuccess,\n ProofOfOwnershipMessage,\n} from './utils/proofOfOwnership/proofOfOwnership';\nexport {\n createOriginPermissions,\n DEFAULT_PROD_ORIGINS,\n DEFAULT_DEV_ORIGINS,\n DEFAULT_METAMASK_ORIGIN,\n} from './utils/originPermissions/createOriginPermissions';\nexport type { CreateOriginPermissionsParams } from './utils/originPermissions/createOriginPermissions';\nexport { validateOrigin } from './utils/originPermissions/validateOrigin';\nexport { State } from './utils/state/State';\nexport type { StateConfig } from './utils/state/State';\nexport { InMemoryState } from './utils/state/InMemoryState';\nexport type { IStateManager } from './utils/state/IStateManager';\nexport {\n createSnapErrorHandling,\n createTrackError,\n createWithCatchAndThrowSnapError,\n isSnapRpcError,\n normalizeError,\n} from './utils/errors';\nexport { InFlightCoalescer } from './utils/dedupe/InFlightCoalescer';\nexport { InMemoryCache } from './utils/cache/InMemoryCache';\nexport { StateCache } from './utils/cache/StateCache';\nexport { useCache } from './utils/cache/useCache';\nexport { useCacheUntil } from './utils/cache/useCacheUntil';\nexport type { CacheOptions } from './utils/cache/useCache';\nexport type {\n CacheUntilOptions,\n ResultWithExpiry,\n} from './utils/cache/useCacheUntil';\nexport type {\n ICache,\n CacheEntry,\n TimestampMilliseconds,\n} from './utils/cache/types';\nexport type {\n CacheStateManager,\n CacheStore,\n CachePrefix,\n StateValue,\n} from './utils/cache/StateCache';\nexport type {\n CreateSnapErrorHandlingOptions,\n CreateTrackErrorOptions,\n CreateWithCatchAndThrowSnapErrorOptions,\n LogErrorFn,\n NormalizeErrorFn,\n PrepareErrorForTrackingFn,\n ShouldTrackErrorFn,\n SnapRpcError,\n SnapTrackErrorRequest,\n TrackErrorCapableProvider,\n TrackErrorFn,\n} from './utils/errors';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EAEf,8CAA0C;AAC3C,OAAO,EACL,kCAAkC,EAClC,0BAA0B,EAE3B,wEAAoE;AACrE,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,QAAQ,EAAE,sCAAkC;AAErD,OAAO,EACL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IDER_NAME,\n AssetsProvider,\n type AssetsProviderMessenger,\n} from './providers/assets/AssetsProvider';\nexport {\n REMOTE_FEATURE_FLAGS_PROVIDER_NAME,\n RemoteFeatureFlagsProvider,\n type RemoteFeatureFlagsProviderMessenger,\n} from './providers/remote-feature-flags/RemoteFeatureFlagsProvider';\nexport { safeMerge } from './utils/safeMerge/safeMerge';\nexport { buildUrl } from './utils/buildUrl/buildUrl';\nexport type { BuildUrlParams } from './utils/buildUrl/buildUrl';\nexport {\n sanitizeControlCharacters,\n sanitizeUri,\n} from './utils/sanitize/sanitize';\nexport { UrlStruct } from './utils/urlStruct/urlStruct';\nexport { UuidStruct } from './utils/uuidStruct/uuidStruct';\nexport { asStrictKeyringAccount } from './utils/keyringAccount/keyringAccount';\nexport type {\n ExtendedKeyringAccount,\n KeyringAccountExtension,\n} from './utils/keyringAccount/keyringAccount';\nexport { parseEnv } from './utils/config/parseEnv';\nexport { BaseConfigProvider } from './utils/config/BaseConfigProvider';\nexport {\n commaSeparatedListOf,\n emptyToUndefined,\n parseIntegerStruct,\n parseFloatStruct,\n} from './utils/config/envStructs';\nexport { LogLevelStruct } from './utils/config/logLevelStruct';\nexport {\n batchesAll,\n batchesAllSettled,\n batchesAllSettledWithChunks,\n batchesAllWithChunks,\n chunks,\n} from './utils/async/async';\nexport { Logger, LogLevel } from './utils/logger/Logger';\nexport type {\n LoggerOptions,\n LoggerMethod,\n LogMethod,\n LogMethodDecorator,\n LoggerDecorators,\n} from './utils/logger/Logger';\nexport { serialize, deserialize } from './utils/serialization/serialization';\nexport type { Serializable } from './utils/serialization/types';\nexport {\n parseProofOfOwnershipMessage,\n ProofOfOwnershipBatchErrorStruct,\n ProofOfOwnershipBatchItemResponseStruct,\n ProofOfOwnershipBatchRequestItemStruct,\n ProofOfOwnershipBatchRequestParamsStruct,\n ProofOfOwnershipBatchResponseStruct,\n ProofOfOwnershipBatchSuccessStruct,\n ProofOfOwnershipMessageStruct,\n PROOF_OF_OWNERSHIP_MESSAGE_PREFIX,\n} from './utils/proofOfOwnership/proofOfOwnership';\nexport type {\n ProofOfOwnershipBatchError,\n ProofOfOwnershipBatchItemResponse,\n ProofOfOwnershipBatchRequestItem,\n ProofOfOwnershipBatchRequestParams,\n ProofOfOwnershipBatchResponse,\n ProofOfOwnershipBatchSuccess,\n ProofOfOwnershipMessage,\n} from './utils/proofOfOwnership/proofOfOwnership';\nexport {\n createOriginPermissions,\n DEFAULT_PROD_ORIGINS,\n DEFAULT_DEV_ORIGINS,\n DEFAULT_METAMASK_ORIGIN,\n} from './utils/originPermissions/createOriginPermissions';\nexport type { CreateOriginPermissionsParams } from './utils/originPermissions/createOriginPermissions';\nexport { validateOrigin } from './utils/originPermissions/validateOrigin';\nexport { State } from './utils/state/State';\nexport type { StateConfig } from './utils/state/State';\nexport { InMemoryState } from './utils/state/InMemoryState';\nexport type { IStateManager } from './utils/state/IStateManager';\nexport {\n createSnapErrorHandling,\n createTrackError,\n createWithCatchAndThrowSnapError,\n isSnapRpcError,\n normalizeError,\n} from './utils/errors';\nexport { InFlightCoalescer } from './utils/dedupe/InFlightCoalescer';\nexport { InMemoryCache } from './utils/cache/InMemoryCache';\nexport { StateCache } from './utils/cache/StateCache';\nexport { useCache } from './utils/cache/useCache';\nexport { useCacheUntil } from './utils/cache/useCacheUntil';\nexport type { CacheOptions } from './utils/cache/useCache';\nexport type {\n CacheUntilOptions,\n ResultWithExpiry,\n} from './utils/cache/useCacheUntil';\nexport type {\n ICache,\n CacheEntry,\n TimestampMilliseconds,\n} from './utils/cache/types';\nexport type {\n CacheStateManager,\n CacheStore,\n CachePrefix,\n StateValue,\n} from './utils/cache/StateCache';\nexport type {\n CreateSnapErrorHandlingOptions,\n CreateTrackErrorOptions,\n CreateWithCatchAndThrowSnapErrorOptions,\n LogErrorFn,\n NormalizeErrorFn,\n PrepareErrorForTrackingFn,\n ShouldTrackErrorFn,\n SnapRpcError,\n SnapTrackErrorRequest,\n TrackErrorCapableProvider,\n TrackErrorFn,\n} from './utils/errors';\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseConfigProvider = void 0;
|
|
4
|
+
const parseEnv_1 = require("./parseEnv.cjs");
|
|
5
|
+
/**
|
|
6
|
+
* A base class that provides the configuration of a snap.
|
|
7
|
+
*
|
|
8
|
+
* The environment is parsed and validated once, when the provider is
|
|
9
|
+
* constructed; an invalid environment throws. Subclasses pass the raw
|
|
10
|
+
* environment and the struct describing it to the base constructor. Use it
|
|
11
|
+
* directly when the snap needs no extra config helpers, or extend it to add
|
|
12
|
+
* them.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const config = {
|
|
16
|
+
* environment: process.env.ENVIRONMENT,
|
|
17
|
+
* };
|
|
18
|
+
*
|
|
19
|
+
* const ConfigStruct = object({
|
|
20
|
+
* environment: enums(Object.values(Environment)),
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // When no extra helpers are needed, use the base class directly:
|
|
24
|
+
* const configProvider = new BaseConfigProvider(config, ConfigStruct);
|
|
25
|
+
* const { environment } = configProvider.config;
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Otherwise, extend it:
|
|
29
|
+
* export class ConfigProvider extends BaseConfigProvider<typeof ConfigStruct> {
|
|
30
|
+
* constructor() {
|
|
31
|
+
* super(config, ConfigStruct);
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* const configProvider = new ConfigProvider();
|
|
36
|
+
* const { environment } = configProvider.config;
|
|
37
|
+
*/
|
|
38
|
+
class BaseConfigProvider {
|
|
39
|
+
#config;
|
|
40
|
+
/**
|
|
41
|
+
* Construct the provider, parsing the environment once.
|
|
42
|
+
*
|
|
43
|
+
* @param configJson - The configuration JSON for the snap: an object literal referencing
|
|
44
|
+
* the `process.env` variables consumed by the snap, nested to mirror the
|
|
45
|
+
* struct where needed.
|
|
46
|
+
* @param configStruct - The struct describing the configuration, including
|
|
47
|
+
* coercions from raw strings to typed values.
|
|
48
|
+
*/
|
|
49
|
+
constructor(configJson, configStruct) {
|
|
50
|
+
this.#config = (0, parseEnv_1.parseEnv)(configJson, configStruct);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Retrieves configuration of the snap.
|
|
54
|
+
*
|
|
55
|
+
* @returns The configuration, built once from the environment.
|
|
56
|
+
*/
|
|
57
|
+
get config() {
|
|
58
|
+
return this.#config;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.BaseConfigProvider = BaseConfigProvider;
|
|
62
|
+
//# sourceMappingURL=BaseConfigProvider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseConfigProvider.cjs","sourceRoot":"","sources":["../../../src/utils/config/BaseConfigProvider.ts"],"names":[],"mappings":";;;AAEA,6CAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAa,kBAAkB;IACpB,OAAO,CAAsB;IAEtC;;;;;;;;OAQG;IACH,YAAY,UAAmC,EAAE,YAA0B;QACzE,IAAI,CAAC,OAAO,GAAG,IAAA,mBAAQ,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAxBD,gDAwBC","sourcesContent":["import type { AnyStruct, Infer } from '@metamask/superstruct';\n\nimport { parseEnv } from './parseEnv';\n\n/**\n * A base class that provides the configuration of a snap.\n *\n * The environment is parsed and validated once, when the provider is\n * constructed; an invalid environment throws. Subclasses pass the raw\n * environment and the struct describing it to the base constructor. Use it\n * directly when the snap needs no extra config helpers, or extend it to add\n * them.\n *\n * @example\n * const config = {\n * environment: process.env.ENVIRONMENT,\n * };\n *\n * const ConfigStruct = object({\n * environment: enums(Object.values(Environment)),\n * });\n *\n * // When no extra helpers are needed, use the base class directly:\n * const configProvider = new BaseConfigProvider(config, ConfigStruct);\n * const { environment } = configProvider.config;\n *\n * @example\n * // Otherwise, extend it:\n * export class ConfigProvider extends BaseConfigProvider<typeof ConfigStruct> {\n * constructor() {\n * super(config, ConfigStruct);\n * }\n * }\n *\n * const configProvider = new ConfigProvider();\n * const { environment } = configProvider.config;\n */\nexport class BaseConfigProvider<ConfigStruct extends AnyStruct> {\n readonly #config: Infer<ConfigStruct>;\n\n /**\n * Construct the provider, parsing the environment once.\n *\n * @param configJson - The configuration JSON for the snap: an object literal referencing\n * the `process.env` variables consumed by the snap, nested to mirror the\n * struct where needed.\n * @param configStruct - The struct describing the configuration, including\n * coercions from raw strings to typed values.\n */\n constructor(configJson: Record<string, unknown>, configStruct: ConfigStruct) {\n this.#config = parseEnv(configJson, configStruct);\n }\n\n /**\n * Retrieves configuration of the snap.\n *\n * @returns The configuration, built once from the environment.\n */\n get config(): Infer<ConfigStruct> {\n return this.#config;\n }\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AnyStruct, Infer } from "@metamask/superstruct";
|
|
2
|
+
/**
|
|
3
|
+
* A base class that provides the configuration of a snap.
|
|
4
|
+
*
|
|
5
|
+
* The environment is parsed and validated once, when the provider is
|
|
6
|
+
* constructed; an invalid environment throws. Subclasses pass the raw
|
|
7
|
+
* environment and the struct describing it to the base constructor. Use it
|
|
8
|
+
* directly when the snap needs no extra config helpers, or extend it to add
|
|
9
|
+
* them.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const config = {
|
|
13
|
+
* environment: process.env.ENVIRONMENT,
|
|
14
|
+
* };
|
|
15
|
+
*
|
|
16
|
+
* const ConfigStruct = object({
|
|
17
|
+
* environment: enums(Object.values(Environment)),
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // When no extra helpers are needed, use the base class directly:
|
|
21
|
+
* const configProvider = new BaseConfigProvider(config, ConfigStruct);
|
|
22
|
+
* const { environment } = configProvider.config;
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Otherwise, extend it:
|
|
26
|
+
* export class ConfigProvider extends BaseConfigProvider<typeof ConfigStruct> {
|
|
27
|
+
* constructor() {
|
|
28
|
+
* super(config, ConfigStruct);
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* const configProvider = new ConfigProvider();
|
|
33
|
+
* const { environment } = configProvider.config;
|
|
34
|
+
*/
|
|
35
|
+
export declare class BaseConfigProvider<ConfigStruct extends AnyStruct> {
|
|
36
|
+
#private;
|
|
37
|
+
/**
|
|
38
|
+
* Construct the provider, parsing the environment once.
|
|
39
|
+
*
|
|
40
|
+
* @param configJson - The configuration JSON for the snap: an object literal referencing
|
|
41
|
+
* the `process.env` variables consumed by the snap, nested to mirror the
|
|
42
|
+
* struct where needed.
|
|
43
|
+
* @param configStruct - The struct describing the configuration, including
|
|
44
|
+
* coercions from raw strings to typed values.
|
|
45
|
+
*/
|
|
46
|
+
constructor(configJson: Record<string, unknown>, configStruct: ConfigStruct);
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves configuration of the snap.
|
|
49
|
+
*
|
|
50
|
+
* @returns The configuration, built once from the environment.
|
|
51
|
+
*/
|
|
52
|
+
get config(): Infer<ConfigStruct>;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=BaseConfigProvider.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseConfigProvider.d.cts","sourceRoot":"","sources":["../../../src/utils/config/BaseConfigProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,8BAA8B;AAI9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,kBAAkB,CAAC,YAAY,SAAS,SAAS;;IAG5D;;;;;;;;OAQG;gBACS,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,YAAY;IAI3E;;;;OAIG;IACH,IAAI,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAEhC;CACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AnyStruct, Infer } from "@metamask/superstruct";
|
|
2
|
+
/**
|
|
3
|
+
* A base class that provides the configuration of a snap.
|
|
4
|
+
*
|
|
5
|
+
* The environment is parsed and validated once, when the provider is
|
|
6
|
+
* constructed; an invalid environment throws. Subclasses pass the raw
|
|
7
|
+
* environment and the struct describing it to the base constructor. Use it
|
|
8
|
+
* directly when the snap needs no extra config helpers, or extend it to add
|
|
9
|
+
* them.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const config = {
|
|
13
|
+
* environment: process.env.ENVIRONMENT,
|
|
14
|
+
* };
|
|
15
|
+
*
|
|
16
|
+
* const ConfigStruct = object({
|
|
17
|
+
* environment: enums(Object.values(Environment)),
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // When no extra helpers are needed, use the base class directly:
|
|
21
|
+
* const configProvider = new BaseConfigProvider(config, ConfigStruct);
|
|
22
|
+
* const { environment } = configProvider.config;
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Otherwise, extend it:
|
|
26
|
+
* export class ConfigProvider extends BaseConfigProvider<typeof ConfigStruct> {
|
|
27
|
+
* constructor() {
|
|
28
|
+
* super(config, ConfigStruct);
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* const configProvider = new ConfigProvider();
|
|
33
|
+
* const { environment } = configProvider.config;
|
|
34
|
+
*/
|
|
35
|
+
export declare class BaseConfigProvider<ConfigStruct extends AnyStruct> {
|
|
36
|
+
#private;
|
|
37
|
+
/**
|
|
38
|
+
* Construct the provider, parsing the environment once.
|
|
39
|
+
*
|
|
40
|
+
* @param configJson - The configuration JSON for the snap: an object literal referencing
|
|
41
|
+
* the `process.env` variables consumed by the snap, nested to mirror the
|
|
42
|
+
* struct where needed.
|
|
43
|
+
* @param configStruct - The struct describing the configuration, including
|
|
44
|
+
* coercions from raw strings to typed values.
|
|
45
|
+
*/
|
|
46
|
+
constructor(configJson: Record<string, unknown>, configStruct: ConfigStruct);
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves configuration of the snap.
|
|
49
|
+
*
|
|
50
|
+
* @returns The configuration, built once from the environment.
|
|
51
|
+
*/
|
|
52
|
+
get config(): Infer<ConfigStruct>;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=BaseConfigProvider.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseConfigProvider.d.mts","sourceRoot":"","sources":["../../../src/utils/config/BaseConfigProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,8BAA8B;AAI9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,kBAAkB,CAAC,YAAY,SAAS,SAAS;;IAG5D;;;;;;;;OAQG;gBACS,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,YAAY;IAI3E;;;;OAIG;IACH,IAAI,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAEhC;CACF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { parseEnv } from "./parseEnv.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* A base class that provides the configuration of a snap.
|
|
4
|
+
*
|
|
5
|
+
* The environment is parsed and validated once, when the provider is
|
|
6
|
+
* constructed; an invalid environment throws. Subclasses pass the raw
|
|
7
|
+
* environment and the struct describing it to the base constructor. Use it
|
|
8
|
+
* directly when the snap needs no extra config helpers, or extend it to add
|
|
9
|
+
* them.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const config = {
|
|
13
|
+
* environment: process.env.ENVIRONMENT,
|
|
14
|
+
* };
|
|
15
|
+
*
|
|
16
|
+
* const ConfigStruct = object({
|
|
17
|
+
* environment: enums(Object.values(Environment)),
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // When no extra helpers are needed, use the base class directly:
|
|
21
|
+
* const configProvider = new BaseConfigProvider(config, ConfigStruct);
|
|
22
|
+
* const { environment } = configProvider.config;
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Otherwise, extend it:
|
|
26
|
+
* export class ConfigProvider extends BaseConfigProvider<typeof ConfigStruct> {
|
|
27
|
+
* constructor() {
|
|
28
|
+
* super(config, ConfigStruct);
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* const configProvider = new ConfigProvider();
|
|
33
|
+
* const { environment } = configProvider.config;
|
|
34
|
+
*/
|
|
35
|
+
export class BaseConfigProvider {
|
|
36
|
+
#config;
|
|
37
|
+
/**
|
|
38
|
+
* Construct the provider, parsing the environment once.
|
|
39
|
+
*
|
|
40
|
+
* @param configJson - The configuration JSON for the snap: an object literal referencing
|
|
41
|
+
* the `process.env` variables consumed by the snap, nested to mirror the
|
|
42
|
+
* struct where needed.
|
|
43
|
+
* @param configStruct - The struct describing the configuration, including
|
|
44
|
+
* coercions from raw strings to typed values.
|
|
45
|
+
*/
|
|
46
|
+
constructor(configJson, configStruct) {
|
|
47
|
+
this.#config = parseEnv(configJson, configStruct);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves configuration of the snap.
|
|
51
|
+
*
|
|
52
|
+
* @returns The configuration, built once from the environment.
|
|
53
|
+
*/
|
|
54
|
+
get config() {
|
|
55
|
+
return this.#config;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=BaseConfigProvider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseConfigProvider.mjs","sourceRoot":"","sources":["../../../src/utils/config/BaseConfigProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,uBAAmB;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,OAAO,kBAAkB;IACpB,OAAO,CAAsB;IAEtC;;;;;;;;OAQG;IACH,YAAY,UAAmC,EAAE,YAA0B;QACzE,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF","sourcesContent":["import type { AnyStruct, Infer } from '@metamask/superstruct';\n\nimport { parseEnv } from './parseEnv';\n\n/**\n * A base class that provides the configuration of a snap.\n *\n * The environment is parsed and validated once, when the provider is\n * constructed; an invalid environment throws. Subclasses pass the raw\n * environment and the struct describing it to the base constructor. Use it\n * directly when the snap needs no extra config helpers, or extend it to add\n * them.\n *\n * @example\n * const config = {\n * environment: process.env.ENVIRONMENT,\n * };\n *\n * const ConfigStruct = object({\n * environment: enums(Object.values(Environment)),\n * });\n *\n * // When no extra helpers are needed, use the base class directly:\n * const configProvider = new BaseConfigProvider(config, ConfigStruct);\n * const { environment } = configProvider.config;\n *\n * @example\n * // Otherwise, extend it:\n * export class ConfigProvider extends BaseConfigProvider<typeof ConfigStruct> {\n * constructor() {\n * super(config, ConfigStruct);\n * }\n * }\n *\n * const configProvider = new ConfigProvider();\n * const { environment } = configProvider.config;\n */\nexport class BaseConfigProvider<ConfigStruct extends AnyStruct> {\n readonly #config: Infer<ConfigStruct>;\n\n /**\n * Construct the provider, parsing the environment once.\n *\n * @param configJson - The configuration JSON for the snap: an object literal referencing\n * the `process.env` variables consumed by the snap, nested to mirror the\n * struct where needed.\n * @param configStruct - The struct describing the configuration, including\n * coercions from raw strings to typed values.\n */\n constructor(configJson: Record<string, unknown>, configStruct: ConfigStruct) {\n this.#config = parseEnv(configJson, configStruct);\n }\n\n /**\n * Retrieves configuration of the snap.\n *\n * @returns The configuration, built once from the environment.\n */\n get config(): Infer<ConfigStruct> {\n return this.#config;\n }\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFloatStruct = exports.parseIntegerStruct = exports.commaSeparatedListOf = exports.emptyToUndefined = void 0;
|
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
+
/**
|
|
6
|
+
* Create a struct for environment variables validated against the given
|
|
7
|
+
* struct, where unset and empty strings (the build-time injection default)
|
|
8
|
+
* mean the variable is not set.
|
|
9
|
+
*
|
|
10
|
+
* @param item - The struct to validate the value against when it is set,
|
|
11
|
+
* e.g. `UrlStruct`.
|
|
12
|
+
* @returns A struct that parses to the value or `undefined`.
|
|
13
|
+
* @example
|
|
14
|
+
* const PriceApiBaseUrlStruct = emptyToUndefined(UrlStruct);
|
|
15
|
+
*/
|
|
16
|
+
const emptyToUndefined = (item) => (0, superstruct_1.coerce)((0, superstruct_1.optional)(item), (0, superstruct_1.string)(), (value) => value === '' ? undefined : value);
|
|
17
|
+
exports.emptyToUndefined = emptyToUndefined;
|
|
18
|
+
/**
|
|
19
|
+
* Create a struct for comma-separated list environment variables.
|
|
20
|
+
*
|
|
21
|
+
* The raw string is split on commas and each item is validated against the
|
|
22
|
+
* given item struct.
|
|
23
|
+
*
|
|
24
|
+
* @param item - The struct to validate each list item against.
|
|
25
|
+
* @returns A struct that parses a comma-separated string into an array.
|
|
26
|
+
* @example
|
|
27
|
+
* const RpcUrlListStruct = commaSeparatedListOf(UrlStruct);
|
|
28
|
+
*/
|
|
29
|
+
const commaSeparatedListOf = (item) => (0, superstruct_1.coerce)((0, superstruct_1.array)(item), (0, superstruct_1.string)(), (value) => value.split(','));
|
|
30
|
+
exports.commaSeparatedListOf = commaSeparatedListOf;
|
|
31
|
+
/**
|
|
32
|
+
* Create a struct that parses an integer from a string, with a minimum value
|
|
33
|
+
* and a default for unset variables.
|
|
34
|
+
*
|
|
35
|
+
* @param minValue - The minimum value for the integer.
|
|
36
|
+
* @param defaultValue - The default value for the integer.
|
|
37
|
+
* @returns A struct that parses an integer from a string.
|
|
38
|
+
*/
|
|
39
|
+
const parseIntegerStruct = (minValue, defaultValue) => (0, superstruct_1.coerce)((0, superstruct_1.defaulted)((0, superstruct_1.min)((0, superstruct_1.number)(), minValue), defaultValue), (0, superstruct_1.string)(), (value) => (value === '' ? undefined : parseInt(value, 10)));
|
|
40
|
+
exports.parseIntegerStruct = parseIntegerStruct;
|
|
41
|
+
/**
|
|
42
|
+
* Create a struct that parses a float from a string, with a minimum value and
|
|
43
|
+
* a default for unset variables.
|
|
44
|
+
*
|
|
45
|
+
* @param minValue - The minimum value for the float.
|
|
46
|
+
* @param defaultValue - The default value for the float.
|
|
47
|
+
* @returns A struct that parses a float from a string.
|
|
48
|
+
*/
|
|
49
|
+
const parseFloatStruct = (minValue, defaultValue) => (0, superstruct_1.coerce)((0, superstruct_1.defaulted)((0, superstruct_1.min)((0, superstruct_1.number)(), minValue), defaultValue), (0, superstruct_1.string)(), (value) => (value === '' ? undefined : parseFloat(value)));
|
|
50
|
+
exports.parseFloatStruct = parseFloatStruct;
|
|
51
|
+
//# sourceMappingURL=envStructs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envStructs.cjs","sourceRoot":"","sources":["../../../src/utils/config/envStructs.ts"],"names":[],"mappings":";;;AACA,uDAQ+B;AAE/B;;;;;;;;;;GAUG;AACI,MAAM,gBAAgB,GAAG,CAC9B,IAAkB,EACQ,EAAE,CAC5B,IAAA,oBAAM,EAAC,IAAA,sBAAQ,EAAC,IAAI,CAAC,EAAE,IAAA,oBAAM,GAAE,EAAE,CAAC,KAAa,EAAE,EAAE,CACjD,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CACjC,CAAC;AALS,QAAA,gBAAgB,oBAKzB;AAEJ;;;;;;;;;;GAUG;AACI,MAAM,oBAAoB,GAAG,CAClC,IAAkB,EACF,EAAE,CAClB,IAAA,oBAAM,EAAC,IAAA,mBAAK,EAAC,IAAI,CAAC,EAAE,IAAA,oBAAM,GAAE,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAHxD,QAAA,oBAAoB,wBAGoC;AAErE;;;;;;;GAOG;AACI,MAAM,kBAAkB,GAAG,CAChC,QAAgB,EAChB,YAAoB,EACJ,EAAE,CAClB,IAAA,oBAAM,EACJ,IAAA,uBAAS,EAAC,IAAA,iBAAG,EAAC,IAAA,oBAAM,GAAE,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,EAChD,IAAA,oBAAM,GAAE,EACR,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CACpE,CAAC;AARS,QAAA,kBAAkB,sBAQ3B;AAEJ;;;;;;;GAOG;AACI,MAAM,gBAAgB,GAAG,CAC9B,QAAgB,EAChB,YAAoB,EACJ,EAAE,CAClB,IAAA,oBAAM,EACJ,IAAA,uBAAS,EAAC,IAAA,iBAAG,EAAC,IAAA,oBAAM,GAAE,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,EAChD,IAAA,oBAAM,GAAE,EACR,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAClE,CAAC;AARS,QAAA,gBAAgB,oBAQzB","sourcesContent":["import type { Struct } from '@metamask/superstruct';\nimport {\n array,\n coerce,\n defaulted,\n min,\n number,\n optional,\n string,\n} from '@metamask/superstruct';\n\n/**\n * Create a struct for environment variables validated against the given\n * struct, where unset and empty strings (the build-time injection default)\n * mean the variable is not set.\n *\n * @param item - The struct to validate the value against when it is set,\n * e.g. `UrlStruct`.\n * @returns A struct that parses to the value or `undefined`.\n * @example\n * const PriceApiBaseUrlStruct = emptyToUndefined(UrlStruct);\n */\nexport const emptyToUndefined = <Type>(\n item: Struct<Type>,\n): Struct<Type | undefined> =>\n coerce(optional(item), string(), (value: string) =>\n value === '' ? undefined : value,\n );\n\n/**\n * Create a struct for comma-separated list environment variables.\n *\n * The raw string is split on commas and each item is validated against the\n * given item struct.\n *\n * @param item - The struct to validate each list item against.\n * @returns A struct that parses a comma-separated string into an array.\n * @example\n * const RpcUrlListStruct = commaSeparatedListOf(UrlStruct);\n */\nexport const commaSeparatedListOf = <Type>(\n item: Struct<Type>,\n): Struct<Type[]> =>\n coerce(array(item), string(), (value: string) => value.split(','));\n\n/**\n * Create a struct that parses an integer from a string, with a minimum value\n * and a default for unset variables.\n *\n * @param minValue - The minimum value for the integer.\n * @param defaultValue - The default value for the integer.\n * @returns A struct that parses an integer from a string.\n */\nexport const parseIntegerStruct = (\n minValue: number,\n defaultValue: number,\n): Struct<number> =>\n coerce(\n defaulted(min(number(), minValue), defaultValue),\n string(),\n (value: string) => (value === '' ? undefined : parseInt(value, 10)),\n );\n\n/**\n * Create a struct that parses a float from a string, with a minimum value and\n * a default for unset variables.\n *\n * @param minValue - The minimum value for the float.\n * @param defaultValue - The default value for the float.\n * @returns A struct that parses a float from a string.\n */\nexport const parseFloatStruct = (\n minValue: number,\n defaultValue: number,\n): Struct<number> =>\n coerce(\n defaulted(min(number(), minValue), defaultValue),\n string(),\n (value: string) => (value === '' ? undefined : parseFloat(value)),\n );\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Struct } from "@metamask/superstruct";
|
|
2
|
+
/**
|
|
3
|
+
* Create a struct for environment variables validated against the given
|
|
4
|
+
* struct, where unset and empty strings (the build-time injection default)
|
|
5
|
+
* mean the variable is not set.
|
|
6
|
+
*
|
|
7
|
+
* @param item - The struct to validate the value against when it is set,
|
|
8
|
+
* e.g. `UrlStruct`.
|
|
9
|
+
* @returns A struct that parses to the value or `undefined`.
|
|
10
|
+
* @example
|
|
11
|
+
* const PriceApiBaseUrlStruct = emptyToUndefined(UrlStruct);
|
|
12
|
+
*/
|
|
13
|
+
export declare const emptyToUndefined: <Type>(item: Struct<Type>) => Struct<Type | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Create a struct for comma-separated list environment variables.
|
|
16
|
+
*
|
|
17
|
+
* The raw string is split on commas and each item is validated against the
|
|
18
|
+
* given item struct.
|
|
19
|
+
*
|
|
20
|
+
* @param item - The struct to validate each list item against.
|
|
21
|
+
* @returns A struct that parses a comma-separated string into an array.
|
|
22
|
+
* @example
|
|
23
|
+
* const RpcUrlListStruct = commaSeparatedListOf(UrlStruct);
|
|
24
|
+
*/
|
|
25
|
+
export declare const commaSeparatedListOf: <Type>(item: Struct<Type>) => Struct<Type[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Create a struct that parses an integer from a string, with a minimum value
|
|
28
|
+
* and a default for unset variables.
|
|
29
|
+
*
|
|
30
|
+
* @param minValue - The minimum value for the integer.
|
|
31
|
+
* @param defaultValue - The default value for the integer.
|
|
32
|
+
* @returns A struct that parses an integer from a string.
|
|
33
|
+
*/
|
|
34
|
+
export declare const parseIntegerStruct: (minValue: number, defaultValue: number) => Struct<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Create a struct that parses a float from a string, with a minimum value and
|
|
37
|
+
* a default for unset variables.
|
|
38
|
+
*
|
|
39
|
+
* @param minValue - The minimum value for the float.
|
|
40
|
+
* @param defaultValue - The default value for the float.
|
|
41
|
+
* @returns A struct that parses a float from a string.
|
|
42
|
+
*/
|
|
43
|
+
export declare const parseFloatStruct: (minValue: number, defaultValue: number) => Struct<number>;
|
|
44
|
+
//# sourceMappingURL=envStructs.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envStructs.d.cts","sourceRoot":"","sources":["../../../src/utils/config/envStructs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAWpD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,GAAI,IAAI,EACnC,MAAM,MAAM,CAAC,IAAI,CAAC,KACjB,MAAM,CAAC,IAAI,GAAG,SAAS,CAGvB,CAAC;AAEJ;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,IAAI,EACvC,MAAM,MAAM,CAAC,IAAI,CAAC,KACjB,MAAM,CAAC,IAAI,EAAE,CACoD,CAAC;AAErE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,cAAc,MAAM,KACnB,MAAM,CAAC,MAAM,CAKb,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,cAAc,MAAM,KACnB,MAAM,CAAC,MAAM,CAKb,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Struct } from "@metamask/superstruct";
|
|
2
|
+
/**
|
|
3
|
+
* Create a struct for environment variables validated against the given
|
|
4
|
+
* struct, where unset and empty strings (the build-time injection default)
|
|
5
|
+
* mean the variable is not set.
|
|
6
|
+
*
|
|
7
|
+
* @param item - The struct to validate the value against when it is set,
|
|
8
|
+
* e.g. `UrlStruct`.
|
|
9
|
+
* @returns A struct that parses to the value or `undefined`.
|
|
10
|
+
* @example
|
|
11
|
+
* const PriceApiBaseUrlStruct = emptyToUndefined(UrlStruct);
|
|
12
|
+
*/
|
|
13
|
+
export declare const emptyToUndefined: <Type>(item: Struct<Type>) => Struct<Type | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Create a struct for comma-separated list environment variables.
|
|
16
|
+
*
|
|
17
|
+
* The raw string is split on commas and each item is validated against the
|
|
18
|
+
* given item struct.
|
|
19
|
+
*
|
|
20
|
+
* @param item - The struct to validate each list item against.
|
|
21
|
+
* @returns A struct that parses a comma-separated string into an array.
|
|
22
|
+
* @example
|
|
23
|
+
* const RpcUrlListStruct = commaSeparatedListOf(UrlStruct);
|
|
24
|
+
*/
|
|
25
|
+
export declare const commaSeparatedListOf: <Type>(item: Struct<Type>) => Struct<Type[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Create a struct that parses an integer from a string, with a minimum value
|
|
28
|
+
* and a default for unset variables.
|
|
29
|
+
*
|
|
30
|
+
* @param minValue - The minimum value for the integer.
|
|
31
|
+
* @param defaultValue - The default value for the integer.
|
|
32
|
+
* @returns A struct that parses an integer from a string.
|
|
33
|
+
*/
|
|
34
|
+
export declare const parseIntegerStruct: (minValue: number, defaultValue: number) => Struct<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Create a struct that parses a float from a string, with a minimum value and
|
|
37
|
+
* a default for unset variables.
|
|
38
|
+
*
|
|
39
|
+
* @param minValue - The minimum value for the float.
|
|
40
|
+
* @param defaultValue - The default value for the float.
|
|
41
|
+
* @returns A struct that parses a float from a string.
|
|
42
|
+
*/
|
|
43
|
+
export declare const parseFloatStruct: (minValue: number, defaultValue: number) => Struct<number>;
|
|
44
|
+
//# sourceMappingURL=envStructs.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envStructs.d.mts","sourceRoot":"","sources":["../../../src/utils/config/envStructs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAWpD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,GAAI,IAAI,EACnC,MAAM,MAAM,CAAC,IAAI,CAAC,KACjB,MAAM,CAAC,IAAI,GAAG,SAAS,CAGvB,CAAC;AAEJ;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,IAAI,EACvC,MAAM,MAAM,CAAC,IAAI,CAAC,KACjB,MAAM,CAAC,IAAI,EAAE,CACoD,CAAC;AAErE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,cAAc,MAAM,KACnB,MAAM,CAAC,MAAM,CAKb,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,cAAc,MAAM,KACnB,MAAM,CAAC,MAAM,CAKb,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { array, coerce, defaulted, min, number, optional, string } from "@metamask/superstruct";
|
|
2
|
+
/**
|
|
3
|
+
* Create a struct for environment variables validated against the given
|
|
4
|
+
* struct, where unset and empty strings (the build-time injection default)
|
|
5
|
+
* mean the variable is not set.
|
|
6
|
+
*
|
|
7
|
+
* @param item - The struct to validate the value against when it is set,
|
|
8
|
+
* e.g. `UrlStruct`.
|
|
9
|
+
* @returns A struct that parses to the value or `undefined`.
|
|
10
|
+
* @example
|
|
11
|
+
* const PriceApiBaseUrlStruct = emptyToUndefined(UrlStruct);
|
|
12
|
+
*/
|
|
13
|
+
export const emptyToUndefined = (item) => coerce(optional(item), string(), (value) => value === '' ? undefined : value);
|
|
14
|
+
/**
|
|
15
|
+
* Create a struct for comma-separated list environment variables.
|
|
16
|
+
*
|
|
17
|
+
* The raw string is split on commas and each item is validated against the
|
|
18
|
+
* given item struct.
|
|
19
|
+
*
|
|
20
|
+
* @param item - The struct to validate each list item against.
|
|
21
|
+
* @returns A struct that parses a comma-separated string into an array.
|
|
22
|
+
* @example
|
|
23
|
+
* const RpcUrlListStruct = commaSeparatedListOf(UrlStruct);
|
|
24
|
+
*/
|
|
25
|
+
export const commaSeparatedListOf = (item) => coerce(array(item), string(), (value) => value.split(','));
|
|
26
|
+
/**
|
|
27
|
+
* Create a struct that parses an integer from a string, with a minimum value
|
|
28
|
+
* and a default for unset variables.
|
|
29
|
+
*
|
|
30
|
+
* @param minValue - The minimum value for the integer.
|
|
31
|
+
* @param defaultValue - The default value for the integer.
|
|
32
|
+
* @returns A struct that parses an integer from a string.
|
|
33
|
+
*/
|
|
34
|
+
export const parseIntegerStruct = (minValue, defaultValue) => coerce(defaulted(min(number(), minValue), defaultValue), string(), (value) => (value === '' ? undefined : parseInt(value, 10)));
|
|
35
|
+
/**
|
|
36
|
+
* Create a struct that parses a float from a string, with a minimum value and
|
|
37
|
+
* a default for unset variables.
|
|
38
|
+
*
|
|
39
|
+
* @param minValue - The minimum value for the float.
|
|
40
|
+
* @param defaultValue - The default value for the float.
|
|
41
|
+
* @returns A struct that parses a float from a string.
|
|
42
|
+
*/
|
|
43
|
+
export const parseFloatStruct = (minValue, defaultValue) => coerce(defaulted(min(number(), minValue), defaultValue), string(), (value) => (value === '' ? undefined : parseFloat(value)));
|
|
44
|
+
//# sourceMappingURL=envStructs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envStructs.mjs","sourceRoot":"","sources":["../../../src/utils/config/envStructs.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,MAAM,EACN,SAAS,EACT,GAAG,EACH,MAAM,EACN,QAAQ,EACR,MAAM,EACP,8BAA8B;AAE/B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAkB,EACQ,EAAE,CAC5B,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,KAAa,EAAE,EAAE,CACjD,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CACjC,CAAC;AAEJ;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,IAAkB,EACF,EAAE,CAClB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,QAAgB,EAChB,YAAoB,EACJ,EAAE,CAClB,MAAM,CACJ,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,EAChD,MAAM,EAAE,EACR,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CACpE,CAAC;AAEJ;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAgB,EAChB,YAAoB,EACJ,EAAE,CAClB,MAAM,CACJ,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,EAChD,MAAM,EAAE,EACR,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAClE,CAAC","sourcesContent":["import type { Struct } from '@metamask/superstruct';\nimport {\n array,\n coerce,\n defaulted,\n min,\n number,\n optional,\n string,\n} from '@metamask/superstruct';\n\n/**\n * Create a struct for environment variables validated against the given\n * struct, where unset and empty strings (the build-time injection default)\n * mean the variable is not set.\n *\n * @param item - The struct to validate the value against when it is set,\n * e.g. `UrlStruct`.\n * @returns A struct that parses to the value or `undefined`.\n * @example\n * const PriceApiBaseUrlStruct = emptyToUndefined(UrlStruct);\n */\nexport const emptyToUndefined = <Type>(\n item: Struct<Type>,\n): Struct<Type | undefined> =>\n coerce(optional(item), string(), (value: string) =>\n value === '' ? undefined : value,\n );\n\n/**\n * Create a struct for comma-separated list environment variables.\n *\n * The raw string is split on commas and each item is validated against the\n * given item struct.\n *\n * @param item - The struct to validate each list item against.\n * @returns A struct that parses a comma-separated string into an array.\n * @example\n * const RpcUrlListStruct = commaSeparatedListOf(UrlStruct);\n */\nexport const commaSeparatedListOf = <Type>(\n item: Struct<Type>,\n): Struct<Type[]> =>\n coerce(array(item), string(), (value: string) => value.split(','));\n\n/**\n * Create a struct that parses an integer from a string, with a minimum value\n * and a default for unset variables.\n *\n * @param minValue - The minimum value for the integer.\n * @param defaultValue - The default value for the integer.\n * @returns A struct that parses an integer from a string.\n */\nexport const parseIntegerStruct = (\n minValue: number,\n defaultValue: number,\n): Struct<number> =>\n coerce(\n defaulted(min(number(), minValue), defaultValue),\n string(),\n (value: string) => (value === '' ? undefined : parseInt(value, 10)),\n );\n\n/**\n * Create a struct that parses a float from a string, with a minimum value and\n * a default for unset variables.\n *\n * @param minValue - The minimum value for the float.\n * @param defaultValue - The default value for the float.\n * @returns A struct that parses a float from a string.\n */\nexport const parseFloatStruct = (\n minValue: number,\n defaultValue: number,\n): Struct<number> =>\n coerce(\n defaulted(min(number(), minValue), defaultValue),\n string(),\n (value: string) => (value === '' ? undefined : parseFloat(value)),\n );\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogLevelStruct = void 0;
|
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
+
const Logger_1 = require("../logger/Logger.cjs");
|
|
6
|
+
/**
|
|
7
|
+
* A struct for parsing a log level from an environment variable.
|
|
8
|
+
*
|
|
9
|
+
* Log levels are tunables, so the value is case-insensitive and defaults to
|
|
10
|
+
* {@link LogLevel.SILENT} when the variable is unset or empty (the build-time
|
|
11
|
+
* injection default). Unknown values are rejected.
|
|
12
|
+
*/
|
|
13
|
+
exports.LogLevelStruct = (0, superstruct_1.coerce)((0, superstruct_1.defaulted)((0, superstruct_1.enums)(Object.values(Logger_1.LogLevel)), Logger_1.LogLevel.SILENT), (0, superstruct_1.string)(), (value) => (value === '' ? undefined : value.toLowerCase()));
|
|
14
|
+
//# sourceMappingURL=logLevelStruct.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logLevelStruct.cjs","sourceRoot":"","sources":["../../../src/utils/config/logLevelStruct.ts"],"names":[],"mappings":";;;AAAA,uDAAyE;AAEzE,iDAA4C;AAE5C;;;;;;GAMG;AACU,QAAA,cAAc,GAAG,IAAA,oBAAM,EAClC,IAAA,uBAAS,EACP,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,iBAAQ,CAA8B,CAAC,EAC3D,iBAAQ,CAAC,MAAM,CAChB,EACD,IAAA,oBAAM,GAAE,EACR,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CACpE,CAAC","sourcesContent":["import { coerce, defaulted, enums, string } from '@metamask/superstruct';\n\nimport { LogLevel } from '../logger/Logger';\n\n/**\n * A struct for parsing a log level from an environment variable.\n *\n * Log levels are tunables, so the value is case-insensitive and defaults to\n * {@link LogLevel.SILENT} when the variable is unset or empty (the build-time\n * injection default). Unknown values are rejected.\n */\nexport const LogLevelStruct = coerce(\n defaulted(\n enums(Object.values(LogLevel) as [LogLevel, ...LogLevel[]]),\n LogLevel.SILENT,\n ),\n string(),\n (value: string) => (value === '' ? undefined : value.toLowerCase()),\n);\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LogLevel } from "../logger/Logger.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* A struct for parsing a log level from an environment variable.
|
|
4
|
+
*
|
|
5
|
+
* Log levels are tunables, so the value is case-insensitive and defaults to
|
|
6
|
+
* {@link LogLevel.SILENT} when the variable is unset or empty (the build-time
|
|
7
|
+
* injection default). Unknown values are rejected.
|
|
8
|
+
*/
|
|
9
|
+
export declare const LogLevelStruct: import("@metamask/superstruct").Struct<LogLevel, {
|
|
10
|
+
silent: "silent";
|
|
11
|
+
error: "error";
|
|
12
|
+
warn: "warn";
|
|
13
|
+
info: "info";
|
|
14
|
+
debug: "debug";
|
|
15
|
+
trace: "trace";
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=logLevelStruct.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logLevelStruct.d.cts","sourceRoot":"","sources":["../../../src/utils/config/logLevelStruct.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,6BAAyB;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;EAO1B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LogLevel } from "../logger/Logger.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* A struct for parsing a log level from an environment variable.
|
|
4
|
+
*
|
|
5
|
+
* Log levels are tunables, so the value is case-insensitive and defaults to
|
|
6
|
+
* {@link LogLevel.SILENT} when the variable is unset or empty (the build-time
|
|
7
|
+
* injection default). Unknown values are rejected.
|
|
8
|
+
*/
|
|
9
|
+
export declare const LogLevelStruct: import("@metamask/superstruct").Struct<LogLevel, {
|
|
10
|
+
silent: "silent";
|
|
11
|
+
error: "error";
|
|
12
|
+
warn: "warn";
|
|
13
|
+
info: "info";
|
|
14
|
+
debug: "debug";
|
|
15
|
+
trace: "trace";
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=logLevelStruct.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logLevelStruct.d.mts","sourceRoot":"","sources":["../../../src/utils/config/logLevelStruct.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,6BAAyB;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;EAO1B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { coerce, defaulted, enums, string } from "@metamask/superstruct";
|
|
2
|
+
import { LogLevel } from "../logger/Logger.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* A struct for parsing a log level from an environment variable.
|
|
5
|
+
*
|
|
6
|
+
* Log levels are tunables, so the value is case-insensitive and defaults to
|
|
7
|
+
* {@link LogLevel.SILENT} when the variable is unset or empty (the build-time
|
|
8
|
+
* injection default). Unknown values are rejected.
|
|
9
|
+
*/
|
|
10
|
+
export const LogLevelStruct = coerce(defaulted(enums(Object.values(LogLevel)), LogLevel.SILENT), string(), (value) => (value === '' ? undefined : value.toLowerCase()));
|
|
11
|
+
//# sourceMappingURL=logLevelStruct.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logLevelStruct.mjs","sourceRoot":"","sources":["../../../src/utils/config/logLevelStruct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAEzE,OAAO,EAAE,QAAQ,EAAE,6BAAyB;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAClC,SAAS,CACP,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAA8B,CAAC,EAC3D,QAAQ,CAAC,MAAM,CAChB,EACD,MAAM,EAAE,EACR,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CACpE,CAAC","sourcesContent":["import { coerce, defaulted, enums, string } from '@metamask/superstruct';\n\nimport { LogLevel } from '../logger/Logger';\n\n/**\n * A struct for parsing a log level from an environment variable.\n *\n * Log levels are tunables, so the value is case-insensitive and defaults to\n * {@link LogLevel.SILENT} when the variable is unset or empty (the build-time\n * injection default). Unknown values are rejected.\n */\nexport const LogLevelStruct = coerce(\n defaulted(\n enums(Object.values(LogLevel) as [LogLevel, ...LogLevel[]]),\n LogLevel.SILENT,\n ),\n string(),\n (value: string) => (value === '' ? undefined : value.toLowerCase()),\n);\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseEnv = void 0;
|
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
+
/**
|
|
6
|
+
* Parse and validate a raw environment record against a struct.
|
|
7
|
+
*
|
|
8
|
+
* This is the fail-fast entry point for building a snap configuration from
|
|
9
|
+
* build-time injected environment variables. Parsing happens once, when the
|
|
10
|
+
* configuration provider is constructed; an invalid environment stops the
|
|
11
|
+
* snap at startup instead of producing undefined behaviour later.
|
|
12
|
+
*
|
|
13
|
+
* @param value - The raw environment record, e.g. `process.env` values
|
|
14
|
+
* collected into an object.
|
|
15
|
+
* @param struct - The struct describing the expected environment.
|
|
16
|
+
* @returns The parsed and validated environment.
|
|
17
|
+
* @throws If the environment does not match the struct.
|
|
18
|
+
* @example
|
|
19
|
+
* const env = parseEnv({ RPC_URL: process.env.RPC_URL }, EnvStruct);
|
|
20
|
+
*/
|
|
21
|
+
const parseEnv = (value, struct) => {
|
|
22
|
+
try {
|
|
23
|
+
return (0, superstruct_1.create)(value, struct);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw new Error(`Invalid environment configuration: ${error.message}`);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.parseEnv = parseEnv;
|
|
30
|
+
//# sourceMappingURL=parseEnv.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseEnv.cjs","sourceRoot":"","sources":["../../../src/utils/config/parseEnv.ts"],"names":[],"mappings":";;;AAAA,uDAA+C;AAG/C;;;;;;;;;;;;;;;GAeG;AACI,MAAM,QAAQ,GAAG,CACtB,KAA8B,EAC9B,MAAoB,EACd,EAAE;IACR,IAAI,CAAC;QACH,OAAO,IAAA,oBAAM,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,sCAAuC,KAAe,CAAC,OAAO,EAAE,CACjE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAXW,QAAA,QAAQ,YAWnB","sourcesContent":["import { create } from '@metamask/superstruct';\nimport type { Struct } from '@metamask/superstruct';\n\n/**\n * Parse and validate a raw environment record against a struct.\n *\n * This is the fail-fast entry point for building a snap configuration from\n * build-time injected environment variables. Parsing happens once, when the\n * configuration provider is constructed; an invalid environment stops the\n * snap at startup instead of producing undefined behaviour later.\n *\n * @param value - The raw environment record, e.g. `process.env` values\n * collected into an object.\n * @param struct - The struct describing the expected environment.\n * @returns The parsed and validated environment.\n * @throws If the environment does not match the struct.\n * @example\n * const env = parseEnv({ RPC_URL: process.env.RPC_URL }, EnvStruct);\n */\nexport const parseEnv = <Type>(\n value: Record<string, unknown>,\n struct: Struct<Type>,\n): Type => {\n try {\n return create(value, struct);\n } catch (error) {\n throw new Error(\n `Invalid environment configuration: ${(error as Error).message}`,\n );\n }\n};\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Struct } from "@metamask/superstruct";
|
|
2
|
+
/**
|
|
3
|
+
* Parse and validate a raw environment record against a struct.
|
|
4
|
+
*
|
|
5
|
+
* This is the fail-fast entry point for building a snap configuration from
|
|
6
|
+
* build-time injected environment variables. Parsing happens once, when the
|
|
7
|
+
* configuration provider is constructed; an invalid environment stops the
|
|
8
|
+
* snap at startup instead of producing undefined behaviour later.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The raw environment record, e.g. `process.env` values
|
|
11
|
+
* collected into an object.
|
|
12
|
+
* @param struct - The struct describing the expected environment.
|
|
13
|
+
* @returns The parsed and validated environment.
|
|
14
|
+
* @throws If the environment does not match the struct.
|
|
15
|
+
* @example
|
|
16
|
+
* const env = parseEnv({ RPC_URL: process.env.RPC_URL }, EnvStruct);
|
|
17
|
+
*/
|
|
18
|
+
export declare const parseEnv: <Type>(value: Record<string, unknown>, struct: Struct<Type>) => Type;
|
|
19
|
+
//# sourceMappingURL=parseEnv.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseEnv.d.cts","sourceRoot":"","sources":["../../../src/utils/config/parseEnv.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAEpD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,EAC3B,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,QAAQ,MAAM,CAAC,IAAI,CAAC,KACnB,IAQF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Struct } from "@metamask/superstruct";
|
|
2
|
+
/**
|
|
3
|
+
* Parse and validate a raw environment record against a struct.
|
|
4
|
+
*
|
|
5
|
+
* This is the fail-fast entry point for building a snap configuration from
|
|
6
|
+
* build-time injected environment variables. Parsing happens once, when the
|
|
7
|
+
* configuration provider is constructed; an invalid environment stops the
|
|
8
|
+
* snap at startup instead of producing undefined behaviour later.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The raw environment record, e.g. `process.env` values
|
|
11
|
+
* collected into an object.
|
|
12
|
+
* @param struct - The struct describing the expected environment.
|
|
13
|
+
* @returns The parsed and validated environment.
|
|
14
|
+
* @throws If the environment does not match the struct.
|
|
15
|
+
* @example
|
|
16
|
+
* const env = parseEnv({ RPC_URL: process.env.RPC_URL }, EnvStruct);
|
|
17
|
+
*/
|
|
18
|
+
export declare const parseEnv: <Type>(value: Record<string, unknown>, struct: Struct<Type>) => Type;
|
|
19
|
+
//# sourceMappingURL=parseEnv.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseEnv.d.mts","sourceRoot":"","sources":["../../../src/utils/config/parseEnv.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAEpD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,EAC3B,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,QAAQ,MAAM,CAAC,IAAI,CAAC,KACnB,IAQF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { create } from "@metamask/superstruct";
|
|
2
|
+
/**
|
|
3
|
+
* Parse and validate a raw environment record against a struct.
|
|
4
|
+
*
|
|
5
|
+
* This is the fail-fast entry point for building a snap configuration from
|
|
6
|
+
* build-time injected environment variables. Parsing happens once, when the
|
|
7
|
+
* configuration provider is constructed; an invalid environment stops the
|
|
8
|
+
* snap at startup instead of producing undefined behaviour later.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The raw environment record, e.g. `process.env` values
|
|
11
|
+
* collected into an object.
|
|
12
|
+
* @param struct - The struct describing the expected environment.
|
|
13
|
+
* @returns The parsed and validated environment.
|
|
14
|
+
* @throws If the environment does not match the struct.
|
|
15
|
+
* @example
|
|
16
|
+
* const env = parseEnv({ RPC_URL: process.env.RPC_URL }, EnvStruct);
|
|
17
|
+
*/
|
|
18
|
+
export const parseEnv = (value, struct) => {
|
|
19
|
+
try {
|
|
20
|
+
return create(value, struct);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new Error(`Invalid environment configuration: ${error.message}`);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=parseEnv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseEnv.mjs","sourceRoot":"","sources":["../../../src/utils/config/parseEnv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAG/C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,KAA8B,EAC9B,MAAoB,EACd,EAAE;IACR,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,sCAAuC,KAAe,CAAC,OAAO,EAAE,CACjE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { create } from '@metamask/superstruct';\nimport type { Struct } from '@metamask/superstruct';\n\n/**\n * Parse and validate a raw environment record against a struct.\n *\n * This is the fail-fast entry point for building a snap configuration from\n * build-time injected environment variables. Parsing happens once, when the\n * configuration provider is constructed; an invalid environment stops the\n * snap at startup instead of producing undefined behaviour later.\n *\n * @param value - The raw environment record, e.g. `process.env` values\n * collected into an object.\n * @param struct - The struct describing the expected environment.\n * @returns The parsed and validated environment.\n * @throws If the environment does not match the struct.\n * @example\n * const env = parseEnv({ RPC_URL: process.env.RPC_URL }, EnvStruct);\n */\nexport const parseEnv = <Type>(\n value: Record<string, unknown>,\n struct: Struct<Type>,\n): Type => {\n try {\n return create(value, struct);\n } catch (error) {\n throw new Error(\n `Invalid environment configuration: ${(error as Error).message}`,\n );\n }\n};\n"]}
|