@metamask/snaps-utils 11.7.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -1
- package/dist/checksum.cjs +1 -9
- package/dist/checksum.cjs.map +1 -1
- package/dist/checksum.d.cts.map +1 -1
- package/dist/checksum.d.mts.map +1 -1
- package/dist/checksum.mjs +2 -10
- package/dist/checksum.mjs.map +1 -1
- package/dist/handlers/assets-market-data.cjs +2 -2
- package/dist/handlers/assets-market-data.cjs.map +1 -1
- package/dist/handlers/assets-market-data.d.cts +2 -2
- package/dist/handlers/assets-market-data.d.mts +2 -2
- package/dist/handlers/assets-market-data.mjs +2 -2
- package/dist/handlers/assets-market-data.mjs.map +1 -1
- package/dist/iframe.cjs +1 -1
- package/dist/iframe.cjs.map +1 -1
- package/dist/iframe.d.cts.map +1 -1
- package/dist/iframe.d.mts.map +1 -1
- package/dist/iframe.mjs +1 -1
- package/dist/iframe.mjs.map +1 -1
- package/dist/localization.d.cts +1 -0
- package/dist/localization.d.cts.map +1 -1
- package/dist/localization.d.mts +1 -0
- package/dist/localization.d.mts.map +1 -1
- package/dist/manifest/manifest.cjs +99 -27
- package/dist/manifest/manifest.cjs.map +1 -1
- package/dist/manifest/manifest.d.cts +18 -5
- package/dist/manifest/manifest.d.cts.map +1 -1
- package/dist/manifest/manifest.d.mts +18 -5
- package/dist/manifest/manifest.d.mts.map +1 -1
- package/dist/manifest/manifest.mjs +106 -28
- package/dist/manifest/manifest.mjs.map +1 -1
- package/dist/manifest/validation.cjs +1 -0
- package/dist/manifest/validation.cjs.map +1 -1
- package/dist/manifest/validation.d.cts +2 -0
- package/dist/manifest/validation.d.cts.map +1 -1
- package/dist/manifest/validation.d.mts +2 -0
- package/dist/manifest/validation.d.mts.map +1 -1
- package/dist/manifest/validation.mjs +1 -0
- package/dist/manifest/validation.mjs.map +1 -1
- package/dist/manifest/validator-types.cjs.map +1 -1
- package/dist/manifest/validator-types.d.cts +4 -5
- package/dist/manifest/validator-types.d.cts.map +1 -1
- package/dist/manifest/validator-types.d.mts +4 -5
- package/dist/manifest/validator-types.d.mts.map +1 -1
- package/dist/manifest/validator-types.mjs.map +1 -1
- package/dist/manifest/validator.cjs +1 -1
- package/dist/manifest/validator.cjs.map +1 -1
- package/dist/manifest/validator.d.cts +3 -3
- package/dist/manifest/validator.d.cts.map +1 -1
- package/dist/manifest/validator.d.mts +3 -3
- package/dist/manifest/validator.d.mts.map +1 -1
- package/dist/manifest/validator.mjs +1 -1
- package/dist/manifest/validator.mjs.map +1 -1
- package/dist/manifest/validators/checksum.cjs +11 -3
- package/dist/manifest/validators/checksum.cjs.map +1 -1
- package/dist/manifest/validators/checksum.d.cts.map +1 -1
- package/dist/manifest/validators/checksum.d.mts.map +1 -1
- package/dist/manifest/validators/checksum.mjs +11 -3
- package/dist/manifest/validators/checksum.mjs.map +1 -1
- package/dist/manifest/validators/icon-declared.cjs +1 -1
- package/dist/manifest/validators/icon-declared.cjs.map +1 -1
- package/dist/manifest/validators/icon-declared.mjs +1 -1
- package/dist/manifest/validators/icon-declared.mjs.map +1 -1
- package/dist/manifest/validators/icon-missing.cjs +1 -1
- package/dist/manifest/validators/icon-missing.cjs.map +1 -1
- package/dist/manifest/validators/icon-missing.d.cts.map +1 -1
- package/dist/manifest/validators/icon-missing.d.mts.map +1 -1
- package/dist/manifest/validators/icon-missing.mjs +1 -1
- package/dist/manifest/validators/icon-missing.mjs.map +1 -1
- package/dist/manifest/validators/is-snap-manifest.cjs +1 -1
- package/dist/manifest/validators/is-snap-manifest.cjs.map +1 -1
- package/dist/manifest/validators/is-snap-manifest.mjs +1 -1
- package/dist/manifest/validators/is-snap-manifest.mjs.map +1 -1
- package/dist/manifest/validators/manifest-localization.cjs +1 -1
- package/dist/manifest/validators/manifest-localization.cjs.map +1 -1
- package/dist/manifest/validators/manifest-localization.mjs +1 -1
- package/dist/manifest/validators/manifest-localization.mjs.map +1 -1
- package/dist/manifest/validators/package-name-match.cjs +6 -2
- package/dist/manifest/validators/package-name-match.cjs.map +1 -1
- package/dist/manifest/validators/package-name-match.d.cts.map +1 -1
- package/dist/manifest/validators/package-name-match.d.mts.map +1 -1
- package/dist/manifest/validators/package-name-match.mjs +6 -2
- package/dist/manifest/validators/package-name-match.mjs.map +1 -1
- package/dist/manifest/validators/platform-version.cjs +4 -4
- package/dist/manifest/validators/platform-version.cjs.map +1 -1
- package/dist/manifest/validators/platform-version.d.cts.map +1 -1
- package/dist/manifest/validators/platform-version.d.mts.map +1 -1
- package/dist/manifest/validators/platform-version.mjs +4 -4
- package/dist/manifest/validators/platform-version.mjs.map +1 -1
- package/dist/manifest/validators/production-platform-version.cjs +1 -1
- package/dist/manifest/validators/production-platform-version.cjs.map +1 -1
- package/dist/manifest/validators/production-platform-version.d.cts.map +1 -1
- package/dist/manifest/validators/production-platform-version.d.mts.map +1 -1
- package/dist/manifest/validators/production-platform-version.mjs +1 -1
- package/dist/manifest/validators/production-platform-version.mjs.map +1 -1
- package/dist/manifest/validators/repository-match.cjs +2 -2
- package/dist/manifest/validators/repository-match.cjs.map +1 -1
- package/dist/manifest/validators/repository-match.d.cts.map +1 -1
- package/dist/manifest/validators/repository-match.d.mts.map +1 -1
- package/dist/manifest/validators/repository-match.mjs +2 -2
- package/dist/manifest/validators/repository-match.mjs.map +1 -1
- package/dist/manifest/validators/unused-exports.cjs +3 -3
- package/dist/manifest/validators/unused-exports.cjs.map +1 -1
- package/dist/manifest/validators/unused-exports.mjs +3 -3
- package/dist/manifest/validators/unused-exports.mjs.map +1 -1
- package/dist/manifest/validators/version-match.cjs +2 -2
- package/dist/manifest/validators/version-match.cjs.map +1 -1
- package/dist/manifest/validators/version-match.mjs +2 -2
- package/dist/manifest/validators/version-match.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +66 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +66 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +5 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unused-exports.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/unused-exports.ts"],"names":[],"mappings":"AAIA,kDAAkD;AAClD,MAAM,kBAAkB,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAExD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,QAAQ,EAAE,SAAS;IACnB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QAE7D,0EAA0E;QAC1E,aAAa;QACb,IAAI,CAAC,iBAAiB,IAAI,CAAC,OAAO,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QAED,sEAAsE;QACtE,4EAA4E;QAC5E,YAAY;QACZ,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;aACrD,MAAM,CACL,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,CACvB,SAAS,KAAK,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAClD;aACA,GAAG,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;QAErC,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;aACrD,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE;YAC/B,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;gBACvB,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAAO,CACL,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;gBACzB,CAAC,KAAK,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"unused-exports.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/unused-exports.ts"],"names":[],"mappings":"A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AQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type { InitialPermissions } from '@metamask/snaps-sdk';\n\nimport type { ValidatorMeta } from '../validator-types';\n\n// Special case endowments that should be ignored.\nconst IGNORED_ENDOWMENTS = ['endowment:network-access'];\n\n/**\n * Check if the Snap exports handlers that are not requested in the manifest, or\n * if the Snap requests permissions for handlers that are not exported.\n */\nexport const unusedExports: ValidatorMeta = {\n severity: 'warning',\n semanticCheck(files, context) {\n const { handlerEndowments, exports } = context.options ?? {};\n\n // The handler endowments or exports must be provided for this check to be\n // performed.\n if (!handlerEndowments || !exports) {\n return;\n }\n\n // Endowments used based on the exports from the Snap. This is used to\n // filter endowments that are used by multiple handlers, e.g., the lifecycle\n // handlers.\n const usedEndowments = Object.entries(handlerEndowments)\n .filter(\n ([handler, endowment]) =>\n endowment === null || exports.includes(handler),\n )\n .map(([, endowment]) => endowment);\n\n const unusedHandlers = Object.entries(handlerEndowments)\n .filter(([handler, endowment]) => {\n if (endowment === null) {\n return false;\n }\n\n return (\n exports.includes(handler) &&\n !files.manifest.mergedManifest.initialPermissions[\n endowment as keyof InitialPermissions\n ]\n );\n })\n .map(([handler, endowment]) => `${handler} (${endowment})`);\n\n const unusedEndowments = Object.entries(handlerEndowments).filter(\n ([handler, endowment]) => {\n if (endowment === null || IGNORED_ENDOWMENTS.includes(endowment)) {\n return false;\n }\n\n return (\n !usedEndowments.includes(endowment) &&\n files.manifest.mergedManifest.initialPermissions[\n endowment as keyof InitialPermissions\n ] &&\n !exports.includes(handler)\n );\n },\n );\n\n if (unusedHandlers.length > 0) {\n // We don't specify a fix function here, because:\n // 1. Removing the export from the Snap bundle is complicated, as it\n // requires AST manipulation.\n // 2. Adding the permission to the manifest is not always possible, as it\n // may require additional configuration in the manifest.\n context.report(\n `unused-exports`,\n `The Snap exports the following handlers, but does not request permission for them: ${unusedHandlers.join(\n ', ',\n )}.`,\n );\n }\n\n if (unusedEndowments.length > 0) {\n const formattedEndowments = unusedEndowments\n .map(([handler, endowment]) => `${handler} (${endowment})`)\n .join(', ');\n\n context.report(\n `unused-endowments`,\n `The Snap requests permission for the following handlers, but does not export them: ${formattedEndowments}.`,\n ({ manifest }) => {\n unusedEndowments.forEach(([, endowment]) => {\n delete manifest.mainManifest.result.initialPermissions?.[\n endowment as keyof InitialPermissions\n ];\n });\n\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
@@ -9,10 +9,10 @@ exports.versionMatch = {
|
|
|
9
9
|
severity: 'error',
|
|
10
10
|
semanticCheck(files, context) {
|
|
11
11
|
const packageJsonVersion = files.packageJson.result.version;
|
|
12
|
-
const manifestPackageVersion = files.manifest.
|
|
12
|
+
const manifestPackageVersion = files.manifest.mergedManifest.version;
|
|
13
13
|
if (packageJsonVersion !== manifestPackageVersion) {
|
|
14
14
|
context.report('version-match', `"${types_1.NpmSnapFileNames.Manifest}" npm package version ("${manifestPackageVersion}") does not match the "${types_1.NpmSnapFileNames.PackageJson}" "version" field ("${packageJsonVersion}").`, ({ manifest }) => {
|
|
15
|
-
manifest.version = packageJsonVersion;
|
|
15
|
+
manifest.mainManifest.result.version = packageJsonVersion;
|
|
16
16
|
return { manifest };
|
|
17
17
|
});
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-match.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/version-match.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAG/C;;GAEG;AACU,QAAA,YAAY,GAAkB;IACzC,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,kBAAkB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;QAC5D,MAAM,sBAAsB,GAAG,KAAK,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"version-match.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/version-match.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAG/C;;GAEG;AACU,QAAA,YAAY,GAAkB;IACzC,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,kBAAkB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;QAC5D,MAAM,sBAAsB,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC;QACrE,IAAI,kBAAkB,KAAK,sBAAsB,EAAE,CAAC;YAClD,OAAO,CAAC,MAAM,CACZ,eAAe,EACf,IAAI,wBAAgB,CAAC,QAAQ,2BAA2B,sBAAsB,0BAA0B,wBAAgB,CAAC,WAAW,uBAAuB,kBAAkB,KAAK,EAClL,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,GAAG,kBAAkB,CAAC;gBAC1D,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { NpmSnapFileNames } from '../../types';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the version in manifest is the same as in package.json.\n */\nexport const versionMatch: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const packageJsonVersion = files.packageJson.result.version;\n const manifestPackageVersion = files.manifest.mergedManifest.version;\n if (packageJsonVersion !== manifestPackageVersion) {\n context.report(\n 'version-match',\n `\"${NpmSnapFileNames.Manifest}\" npm package version (\"${manifestPackageVersion}\") does not match the \"${NpmSnapFileNames.PackageJson}\" \"version\" field (\"${packageJsonVersion}\").`,\n ({ manifest }) => {\n manifest.mainManifest.result.version = packageJsonVersion;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
@@ -6,10 +6,10 @@ export const versionMatch = {
|
|
|
6
6
|
severity: 'error',
|
|
7
7
|
semanticCheck(files, context) {
|
|
8
8
|
const packageJsonVersion = files.packageJson.result.version;
|
|
9
|
-
const manifestPackageVersion = files.manifest.
|
|
9
|
+
const manifestPackageVersion = files.manifest.mergedManifest.version;
|
|
10
10
|
if (packageJsonVersion !== manifestPackageVersion) {
|
|
11
11
|
context.report('version-match', `"${NpmSnapFileNames.Manifest}" npm package version ("${manifestPackageVersion}") does not match the "${NpmSnapFileNames.PackageJson}" "version" field ("${packageJsonVersion}").`, ({ manifest }) => {
|
|
12
|
-
manifest.version = packageJsonVersion;
|
|
12
|
+
manifest.mainManifest.result.version = packageJsonVersion;
|
|
13
13
|
return { manifest };
|
|
14
14
|
});
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-match.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/version-match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAG/C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB;IACzC,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,kBAAkB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;QAC5D,MAAM,sBAAsB,GAAG,KAAK,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"version-match.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/version-match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAG/C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB;IACzC,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,kBAAkB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;QAC5D,MAAM,sBAAsB,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC;QACrE,IAAI,kBAAkB,KAAK,sBAAsB,EAAE,CAAC;YAClD,OAAO,CAAC,MAAM,CACZ,eAAe,EACf,IAAI,gBAAgB,CAAC,QAAQ,2BAA2B,sBAAsB,0BAA0B,gBAAgB,CAAC,WAAW,uBAAuB,kBAAkB,KAAK,EAClL,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,GAAG,kBAAkB,CAAC;gBAC1D,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { NpmSnapFileNames } from '../../types';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the version in manifest is the same as in package.json.\n */\nexport const versionMatch: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const packageJsonVersion = files.packageJson.result.version;\n const manifestPackageVersion = files.manifest.mergedManifest.version;\n if (packageJsonVersion !== manifestPackageVersion) {\n context.report(\n 'version-match',\n `\"${NpmSnapFileNames.Manifest}\" npm package version (\"${manifestPackageVersion}\") does not match the \"${NpmSnapFileNames.PackageJson}\" \"version\" field (\"${packageJsonVersion}\").`,\n ({ manifest }) => {\n manifest.mainManifest.result.version = packageJsonVersion;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AACA,mDAA0C;AAC1C,uDAAyE;AAGzE,2CAA+D;AAQ/D,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,gDAA4B,CAAA;IAC5B,mDAA+B,CAAA;AACjC,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAEY,QAAA,UAAU,GAAG,IAAA,kBAAI,EAC5B,IAAA,qBAAa,EACX,WAAW,EACX,6DAA6D,CAC9D,EACD,CAAC,EACD,GAAG,CACJ,CAAC;AAEF,2EAA2E;AAC3E,sBAAsB;AACT,Q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AC;QACjC,GAAG,EAAE,IAAA,kBAAI,EAAC,IAAA,oBAAM,GAAE,EAAE,CAAC,EAAE,QAAQ,CAAC;KACjC,CAAC,CACH;CACF,CAAC,CAAC;AAyHH;;GAEG;AACH,yDAAyD;AACzD,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,8BAAY,CAAA;IACZ,kCAAgB,CAAA;AAClB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AACD,wDAAwD;AAExD,yDAAyD;AACzD,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,yCAAoB,CAAA;IACpB,wCAAmB,CAAA;AACrB,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B;AAYD,iDAA0C;AAAjC,gGAAA,GAAG,OAAA;AAEZ;;;;;;GAMG;AACH,SAAgB,UAAU,CACxB,GAAY,EACZ,OAAwB,EAAE;IAE1B,OAAO,IAAA,gBAAE,EAAC,GAAG,EAAE,IAAA,eAAG,EAAC,IAAI,CAAC,CAAC,CAAC;AAC5B,CAAC;AALD,gCAKC;AAED,+CAA+C;AAClC,QAAA,0BAA0B,GAAG,aAAa,CAAC","sourcesContent":["import type { UriOptions } from '@metamask/snaps-sdk';\nimport { uri } from '@metamask/snaps-sdk';\nimport { is, optional, size, string, type } from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { definePattern, VersionStruct } from '@metamask/utils';\n\nimport type { SnapCaveatType } from './caveats';\nimport type { SnapFunctionExports, SnapRpcHookArgs } from './handlers';\nimport type { LocalizationFile } from './localization';\nimport type { SnapManifest } from './manifest';\nimport type { VirtualFile } from './virtual-file';\n\nexport enum NpmSnapFileNames {\n PackageJson = 'package.json',\n Manifest = 'snap.manifest.json',\n}\n\nexport const NameStruct = size(\n definePattern(\n 'Snap Name',\n /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/u,\n ),\n 1,\n 214,\n);\n\n// Note we use `type` instead of `object` here, because the latter does not\n// allow unknown keys.\nexport const NpmSnapPackageJsonStruct = type({\n version: VersionStruct,\n name: NameStruct,\n main: optional(size(string(), 1, Infinity)),\n repository: optional(\n type({\n type: size(string(), 1, Infinity),\n url: size(string(), 1, Infinity),\n }),\n ),\n});\n\nexport type NpmSnapPackageJson = Infer<typeof NpmSnapPackageJsonStruct> &\n Record<string, any>;\n\n/**\n * An extendable manifest, which consists of a base manifest, an optional\n * extended manifest, and the merged manifest, all unvalidated.\n */\nexport type UnvalidatedExtendableManifest = {\n /**\n * The main manifest, i.e., the manifest at the given path. This may extend\n * another manifest, and can be partial.\n */\n mainManifest: VirtualFile<Json>;\n\n /**\n * The extended manifest, if any. This is the manifest that the main manifest\n * extends. This can be partial.\n */\n extendedManifest?: Json;\n\n /**\n * The result of deep merging the main and extended manifests. This should\n * always be a complete manifest.\n */\n mergedManifest: Json;\n\n /**\n * The set of file paths that were involved in creating this extendable\n * manifest, including the main and extended manifests.\n */\n files: Set<string>;\n};\n\n/**\n * A utility type that makes all properties of a type optional, recursively.\n */\nexport type DeepPartial<Type> = Type extends string\n ? Type\n : {\n [Property in keyof Type]?: Type[Property] extends (infer Value)[]\n ? DeepPartial<Value>[]\n : Type[Property] extends readonly (infer Value)[]\n ? readonly DeepPartial<Value>[]\n : Type[Property] extends object\n ? DeepPartial<Type[Property]>\n : Type[Property];\n };\n\n/**\n * An extendable manifest, which consists of a main manifest, an optional\n * extended manifest, and the merged manifest.\n */\nexport type ExtendableManifest = {\n /**\n * The main manifest, i.e., the manifest at the given path. This may extend\n * another manifest, and can be partial.\n */\n mainManifest: VirtualFile<DeepPartial<SnapManifest>>;\n\n /**\n * The extended manifest, if any. This is the manifest that the main manifest\n * extends. This can be partial.\n */\n extendedManifest?: DeepPartial<SnapManifest>;\n\n /**\n * The result of deep merging the main and extended manifests. This should\n * always be a complete manifest.\n */\n mergedManifest: SnapManifest;\n\n /**\n * The set of file paths that were involved in creating this extendable\n * manifest, including the main and extended manifests.\n */\n files: Set<string>;\n};\n\n/**\n * An object for storing parsed but unvalidated Snap file contents.\n */\nexport type UnvalidatedSnapFiles = {\n manifest?: UnvalidatedExtendableManifest;\n packageJson?: VirtualFile<Json>;\n sourceCode?: VirtualFile;\n svgIcon?: VirtualFile;\n auxiliaryFiles: VirtualFile[];\n localizationFiles: VirtualFile[];\n};\n\n/**\n * An object for storing the contents of Snap files that have passed JSON\n * Schema validation, or are non-empty if they are strings.\n */\nexport type SnapFiles = {\n manifest: VirtualFile<SnapManifest>;\n packageJson: VirtualFile<NpmSnapPackageJson>;\n sourceCode: VirtualFile;\n svgIcon?: VirtualFile;\n auxiliaryFiles: VirtualFile[];\n localizationFiles: VirtualFile<LocalizationFile>[];\n};\n\n/**\n * The same as {@link SnapFiles} except that the manifest is an\n * {@link ExtendableManifest}.\n */\nexport type ExtendableSnapFiles = Omit<SnapFiles, 'manifest'> & {\n manifest: ExtendableManifest;\n};\n\n/**\n * A subset of snap files extracted from a fetched snap.\n */\nexport type FetchedSnapFiles = Pick<\n SnapFiles,\n 'manifest' | 'sourceCode' | 'svgIcon' | 'auxiliaryFiles' | 'localizationFiles'\n>;\n\n/**\n * The possible prefixes for snap ids.\n */\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum SnapIdPrefixes {\n npm = 'npm:',\n local = 'local:',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum SNAP_STREAM_NAMES {\n JSON_RPC = 'jsonRpc',\n COMMAND = 'command',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\n// The snap is the callee\nexport type SnapRpcHook = (options: SnapRpcHookArgs) => Promise<unknown>;\n\ntype ObjectParameters<\n Type extends Record<string, (...args: any[]) => unknown>,\n> = Parameters<Type[keyof Type]>;\n\nexport type SnapExportsParameters = ObjectParameters<SnapFunctionExports>;\n\nexport { uri } from '@metamask/snaps-sdk';\n\n/**\n * Returns whether a given value is a valid URL.\n *\n * @param url - The value to check.\n * @param opts - Optional constraints for url checking.\n * @returns Whether `url` is valid URL or not.\n */\nexport function isValidUrl(\n url: unknown,\n opts: UriOptions<any> = {},\n): url is string {\n return is(url, uri(opts));\n}\n\n// redefining here to avoid circular dependency\nexport const WALLET_SNAP_PERMISSION_KEY = 'wallet_snap';\n\nexport type SnapsPermissionRequest = {\n [WALLET_SNAP_PERMISSION_KEY]: {\n caveats: [\n {\n type: SnapCaveatType.SnapIds;\n value: Record<string, Json>;\n },\n ];\n };\n};\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -32,11 +32,69 @@ export declare const NpmSnapPackageJsonStruct: import("@metamask/superstruct").S
|
|
|
32
32
|
}>;
|
|
33
33
|
}>;
|
|
34
34
|
export type NpmSnapPackageJson = Infer<typeof NpmSnapPackageJsonStruct> & Record<string, any>;
|
|
35
|
+
/**
|
|
36
|
+
* An extendable manifest, which consists of a base manifest, an optional
|
|
37
|
+
* extended manifest, and the merged manifest, all unvalidated.
|
|
38
|
+
*/
|
|
39
|
+
export type UnvalidatedExtendableManifest = {
|
|
40
|
+
/**
|
|
41
|
+
* The main manifest, i.e., the manifest at the given path. This may extend
|
|
42
|
+
* another manifest, and can be partial.
|
|
43
|
+
*/
|
|
44
|
+
mainManifest: VirtualFile<Json>;
|
|
45
|
+
/**
|
|
46
|
+
* The extended manifest, if any. This is the manifest that the main manifest
|
|
47
|
+
* extends. This can be partial.
|
|
48
|
+
*/
|
|
49
|
+
extendedManifest?: Json;
|
|
50
|
+
/**
|
|
51
|
+
* The result of deep merging the main and extended manifests. This should
|
|
52
|
+
* always be a complete manifest.
|
|
53
|
+
*/
|
|
54
|
+
mergedManifest: Json;
|
|
55
|
+
/**
|
|
56
|
+
* The set of file paths that were involved in creating this extendable
|
|
57
|
+
* manifest, including the main and extended manifests.
|
|
58
|
+
*/
|
|
59
|
+
files: Set<string>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* A utility type that makes all properties of a type optional, recursively.
|
|
63
|
+
*/
|
|
64
|
+
export type DeepPartial<Type> = Type extends string ? Type : {
|
|
65
|
+
[Property in keyof Type]?: Type[Property] extends (infer Value)[] ? DeepPartial<Value>[] : Type[Property] extends readonly (infer Value)[] ? readonly DeepPartial<Value>[] : Type[Property] extends object ? DeepPartial<Type[Property]> : Type[Property];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* An extendable manifest, which consists of a main manifest, an optional
|
|
69
|
+
* extended manifest, and the merged manifest.
|
|
70
|
+
*/
|
|
71
|
+
export type ExtendableManifest = {
|
|
72
|
+
/**
|
|
73
|
+
* The main manifest, i.e., the manifest at the given path. This may extend
|
|
74
|
+
* another manifest, and can be partial.
|
|
75
|
+
*/
|
|
76
|
+
mainManifest: VirtualFile<DeepPartial<SnapManifest>>;
|
|
77
|
+
/**
|
|
78
|
+
* The extended manifest, if any. This is the manifest that the main manifest
|
|
79
|
+
* extends. This can be partial.
|
|
80
|
+
*/
|
|
81
|
+
extendedManifest?: DeepPartial<SnapManifest>;
|
|
82
|
+
/**
|
|
83
|
+
* The result of deep merging the main and extended manifests. This should
|
|
84
|
+
* always be a complete manifest.
|
|
85
|
+
*/
|
|
86
|
+
mergedManifest: SnapManifest;
|
|
87
|
+
/**
|
|
88
|
+
* The set of file paths that were involved in creating this extendable
|
|
89
|
+
* manifest, including the main and extended manifests.
|
|
90
|
+
*/
|
|
91
|
+
files: Set<string>;
|
|
92
|
+
};
|
|
35
93
|
/**
|
|
36
94
|
* An object for storing parsed but unvalidated Snap file contents.
|
|
37
95
|
*/
|
|
38
96
|
export type UnvalidatedSnapFiles = {
|
|
39
|
-
manifest?:
|
|
97
|
+
manifest?: UnvalidatedExtendableManifest;
|
|
40
98
|
packageJson?: VirtualFile<Json>;
|
|
41
99
|
sourceCode?: VirtualFile;
|
|
42
100
|
svgIcon?: VirtualFile;
|
|
@@ -55,6 +113,13 @@ export type SnapFiles = {
|
|
|
55
113
|
auxiliaryFiles: VirtualFile[];
|
|
56
114
|
localizationFiles: VirtualFile<LocalizationFile>[];
|
|
57
115
|
};
|
|
116
|
+
/**
|
|
117
|
+
* The same as {@link SnapFiles} except that the manifest is an
|
|
118
|
+
* {@link ExtendableManifest}.
|
|
119
|
+
*/
|
|
120
|
+
export type ExtendableSnapFiles = Omit<SnapFiles, 'manifest'> & {
|
|
121
|
+
manifest: ExtendableManifest;
|
|
122
|
+
};
|
|
58
123
|
/**
|
|
59
124
|
* A subset of snap files extracted from a fetched snap.
|
|
60
125
|
*/
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,4BAA4B;AAGtD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAkB;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,6BAAmB;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,2BAAuB;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,6BAAmB;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,iCAAuB;AAElD,oBAAY,gBAAgB;IAC1B,WAAW,iBAAiB;IAC5B,QAAQ,uBAAuB;CAChC;AAED,eAAO,MAAM,UAAU,sDAOtB,CAAC;AAIF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;EAUnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,wBAAwB,CAAC,GACrE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEtB;;GAEG;AACH,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,4BAA4B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;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,SAAS,EACT,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,gBAAgB,GAAG,mBAAmB,CAC/E,CAAC;AAEF;;GAEG;AAEH,oBAAY,cAAc;IACxB,GAAG,SAAS;IACZ,KAAK,WAAW;CACjB;AAID,oBAAY,iBAAiB;IAC3B,QAAQ,YAAY;IACpB,OAAO,YAAY;CACpB;AAID,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEzE,KAAK,gBAAgB,CACnB,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,IACtD,UAAU,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;AAEjC,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;AAE1E,OAAO,EAAE,GAAG,EAAE,4BAA4B;AAE1C;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,OAAO,EACZ,IAAI,GAAE,UAAU,CAAC,GAAG,CAAM,GACzB,GAAG,IAAI,MAAM,CAEf;AAGD,eAAO,MAAM,0BAA0B,gBAAgB,CAAC;AAExD,MAAM,MAAM,sBAAsB,GAAG;IACnC,CAAC,0BAA0B,CAAC,EAAE;QAC5B,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC;gBAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aAC7B;SACF,CAAC;KACH,CAAC;CACH,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -32,11 +32,69 @@ export declare const NpmSnapPackageJsonStruct: import("@metamask/superstruct").S
|
|
|
32
32
|
}>;
|
|
33
33
|
}>;
|
|
34
34
|
export type NpmSnapPackageJson = Infer<typeof NpmSnapPackageJsonStruct> & Record<string, any>;
|
|
35
|
+
/**
|
|
36
|
+
* An extendable manifest, which consists of a base manifest, an optional
|
|
37
|
+
* extended manifest, and the merged manifest, all unvalidated.
|
|
38
|
+
*/
|
|
39
|
+
export type UnvalidatedExtendableManifest = {
|
|
40
|
+
/**
|
|
41
|
+
* The main manifest, i.e., the manifest at the given path. This may extend
|
|
42
|
+
* another manifest, and can be partial.
|
|
43
|
+
*/
|
|
44
|
+
mainManifest: VirtualFile<Json>;
|
|
45
|
+
/**
|
|
46
|
+
* The extended manifest, if any. This is the manifest that the main manifest
|
|
47
|
+
* extends. This can be partial.
|
|
48
|
+
*/
|
|
49
|
+
extendedManifest?: Json;
|
|
50
|
+
/**
|
|
51
|
+
* The result of deep merging the main and extended manifests. This should
|
|
52
|
+
* always be a complete manifest.
|
|
53
|
+
*/
|
|
54
|
+
mergedManifest: Json;
|
|
55
|
+
/**
|
|
56
|
+
* The set of file paths that were involved in creating this extendable
|
|
57
|
+
* manifest, including the main and extended manifests.
|
|
58
|
+
*/
|
|
59
|
+
files: Set<string>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* A utility type that makes all properties of a type optional, recursively.
|
|
63
|
+
*/
|
|
64
|
+
export type DeepPartial<Type> = Type extends string ? Type : {
|
|
65
|
+
[Property in keyof Type]?: Type[Property] extends (infer Value)[] ? DeepPartial<Value>[] : Type[Property] extends readonly (infer Value)[] ? readonly DeepPartial<Value>[] : Type[Property] extends object ? DeepPartial<Type[Property]> : Type[Property];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* An extendable manifest, which consists of a main manifest, an optional
|
|
69
|
+
* extended manifest, and the merged manifest.
|
|
70
|
+
*/
|
|
71
|
+
export type ExtendableManifest = {
|
|
72
|
+
/**
|
|
73
|
+
* The main manifest, i.e., the manifest at the given path. This may extend
|
|
74
|
+
* another manifest, and can be partial.
|
|
75
|
+
*/
|
|
76
|
+
mainManifest: VirtualFile<DeepPartial<SnapManifest>>;
|
|
77
|
+
/**
|
|
78
|
+
* The extended manifest, if any. This is the manifest that the main manifest
|
|
79
|
+
* extends. This can be partial.
|
|
80
|
+
*/
|
|
81
|
+
extendedManifest?: DeepPartial<SnapManifest>;
|
|
82
|
+
/**
|
|
83
|
+
* The result of deep merging the main and extended manifests. This should
|
|
84
|
+
* always be a complete manifest.
|
|
85
|
+
*/
|
|
86
|
+
mergedManifest: SnapManifest;
|
|
87
|
+
/**
|
|
88
|
+
* The set of file paths that were involved in creating this extendable
|
|
89
|
+
* manifest, including the main and extended manifests.
|
|
90
|
+
*/
|
|
91
|
+
files: Set<string>;
|
|
92
|
+
};
|
|
35
93
|
/**
|
|
36
94
|
* An object for storing parsed but unvalidated Snap file contents.
|
|
37
95
|
*/
|
|
38
96
|
export type UnvalidatedSnapFiles = {
|
|
39
|
-
manifest?:
|
|
97
|
+
manifest?: UnvalidatedExtendableManifest;
|
|
40
98
|
packageJson?: VirtualFile<Json>;
|
|
41
99
|
sourceCode?: VirtualFile;
|
|
42
100
|
svgIcon?: VirtualFile;
|
|
@@ -55,6 +113,13 @@ export type SnapFiles = {
|
|
|
55
113
|
auxiliaryFiles: VirtualFile[];
|
|
56
114
|
localizationFiles: VirtualFile<LocalizationFile>[];
|
|
57
115
|
};
|
|
116
|
+
/**
|
|
117
|
+
* The same as {@link SnapFiles} except that the manifest is an
|
|
118
|
+
* {@link ExtendableManifest}.
|
|
119
|
+
*/
|
|
120
|
+
export type ExtendableSnapFiles = Omit<SnapFiles, 'manifest'> & {
|
|
121
|
+
manifest: ExtendableManifest;
|
|
122
|
+
};
|
|
58
123
|
/**
|
|
59
124
|
* A subset of snap files extracted from a fetched snap.
|
|
60
125
|
*/
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,4BAA4B;AAGtD,OAAO,KAAK,EAA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AM,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC;KACjC,CAAC,CACH;CACF,CAAC,CAAC;AAyHH;;GAEG;AACH,yDAAyD;AACzD,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,8BAAY,CAAA;IACZ,kCAAgB,CAAA;AAClB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AACD,wDAAwD;AAExD,yDAAyD;AACzD,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,yCAAoB,CAAA;IACpB,wCAAmB,CAAA;AACrB,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,QAG5B;AAYD,OAAO,EAAE,GAAG,EAAE,4BAA4B;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,GAAY,EACZ,OAAwB,EAAE;IAE1B,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5B,CAAC;AAED,+CAA+C;AAC/C,MAAM,CAAC,MAAM,0BAA0B,GAAG,aAAa,CAAC","sourcesContent":["import type { UriOptions } from '@metamask/snaps-sdk';\nimport { uri } from '@metamask/snaps-sdk';\nimport { is, optional, size, string, type } from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { definePattern, VersionStruct } from '@metamask/utils';\n\nimport type { SnapCaveatType } from './caveats';\nimport type { SnapFunctionExports, SnapRpcHookArgs } from './handlers';\nimport type { LocalizationFile } from './localization';\nimport type { SnapManifest } from './manifest';\nimport type { VirtualFile } from './virtual-file';\n\nexport enum NpmSnapFileNames {\n PackageJson = 'package.json',\n Manifest = 'snap.manifest.json',\n}\n\nexport const NameStruct = size(\n definePattern(\n 'Snap Name',\n /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/u,\n ),\n 1,\n 214,\n);\n\n// Note we use `type` instead of `object` here, because the latter does not\n// allow unknown keys.\nexport const NpmSnapPackageJsonStruct = type({\n version: VersionStruct,\n name: NameStruct,\n main: optional(size(string(), 1, Infinity)),\n repository: optional(\n type({\n type: size(string(), 1, Infinity),\n url: size(string(), 1, Infinity),\n }),\n ),\n});\n\nexport type NpmSnapPackageJson = Infer<typeof NpmSnapPackageJsonStruct> &\n Record<string, any>;\n\n/**\n * An extendable manifest, which consists of a base manifest, an optional\n * extended manifest, and the merged manifest, all unvalidated.\n */\nexport type UnvalidatedExtendableManifest = {\n /**\n * The main manifest, i.e., the manifest at the given path. This may extend\n * another manifest, and can be partial.\n */\n mainManifest: VirtualFile<Json>;\n\n /**\n * The extended manifest, if any. This is the manifest that the main manifest\n * extends. This can be partial.\n */\n extendedManifest?: Json;\n\n /**\n * The result of deep merging the main and extended manifests. This should\n * always be a complete manifest.\n */\n mergedManifest: Json;\n\n /**\n * The set of file paths that were involved in creating this extendable\n * manifest, including the main and extended manifests.\n */\n files: Set<string>;\n};\n\n/**\n * A utility type that makes all properties of a type optional, recursively.\n */\nexport type DeepPartial<Type> = Type extends string\n ? Type\n : {\n [Property in keyof Type]?: Type[Property] extends (infer Value)[]\n ? DeepPartial<Value>[]\n : Type[Property] extends readonly (infer Value)[]\n ? readonly DeepPartial<Value>[]\n : Type[Property] extends object\n ? DeepPartial<Type[Property]>\n : Type[Property];\n };\n\n/**\n * An extendable manifest, which consists of a main manifest, an optional\n * extended manifest, and the merged manifest.\n */\nexport type ExtendableManifest = {\n /**\n * The main manifest, i.e., the manifest at the given path. This may extend\n * another manifest, and can be partial.\n */\n mainManifest: VirtualFile<DeepPartial<SnapManifest>>;\n\n /**\n * The extended manifest, if any. This is the manifest that the main manifest\n * extends. This can be partial.\n */\n extendedManifest?: DeepPartial<SnapManifest>;\n\n /**\n * The result of deep merging the main and extended manifests. This should\n * always be a complete manifest.\n */\n mergedManifest: SnapManifest;\n\n /**\n * The set of file paths that were involved in creating this extendable\n * manifest, including the main and extended manifests.\n */\n files: Set<string>;\n};\n\n/**\n * An object for storing parsed but unvalidated Snap file contents.\n */\nexport type UnvalidatedSnapFiles = {\n manifest?: UnvalidatedExtendableManifest;\n packageJson?: VirtualFile<Json>;\n sourceCode?: VirtualFile;\n svgIcon?: VirtualFile;\n auxiliaryFiles: VirtualFile[];\n localizationFiles: VirtualFile[];\n};\n\n/**\n * An object for storing the contents of Snap files that have passed JSON\n * Schema validation, or are non-empty if they are strings.\n */\nexport type SnapFiles = {\n manifest: VirtualFile<SnapManifest>;\n packageJson: VirtualFile<NpmSnapPackageJson>;\n sourceCode: VirtualFile;\n svgIcon?: VirtualFile;\n auxiliaryFiles: VirtualFile[];\n localizationFiles: VirtualFile<LocalizationFile>[];\n};\n\n/**\n * The same as {@link SnapFiles} except that the manifest is an\n * {@link ExtendableManifest}.\n */\nexport type ExtendableSnapFiles = Omit<SnapFiles, 'manifest'> & {\n manifest: ExtendableManifest;\n};\n\n/**\n * A subset of snap files extracted from a fetched snap.\n */\nexport type FetchedSnapFiles = Pick<\n SnapFiles,\n 'manifest' | 'sourceCode' | 'svgIcon' | 'auxiliaryFiles' | 'localizationFiles'\n>;\n\n/**\n * The possible prefixes for snap ids.\n */\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum SnapIdPrefixes {\n npm = 'npm:',\n local = 'local:',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum SNAP_STREAM_NAMES {\n JSON_RPC = 'jsonRpc',\n COMMAND = 'command',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\n// The snap is the callee\nexport type SnapRpcHook = (options: SnapRpcHookArgs) => Promise<unknown>;\n\ntype ObjectParameters<\n Type extends Record<string, (...args: any[]) => unknown>,\n> = Parameters<Type[keyof Type]>;\n\nexport type SnapExportsParameters = ObjectParameters<SnapFunctionExports>;\n\nexport { uri } from '@metamask/snaps-sdk';\n\n/**\n * Returns whether a given value is a valid URL.\n *\n * @param url - The value to check.\n * @param opts - Optional constraints for url checking.\n * @returns Whether `url` is valid URL or not.\n */\nexport function isValidUrl(\n url: unknown,\n opts: UriOptions<any> = {},\n): url is string {\n return is(url, uri(opts));\n}\n\n// redefining here to avoid circular dependency\nexport const WALLET_SNAP_PERMISSION_KEY = 'wallet_snap';\n\nexport type SnapsPermissionRequest = {\n [WALLET_SNAP_PERMISSION_KEY]: {\n caveats: [\n {\n type: SnapCaveatType.SnapIds;\n value: Record<string, Json>;\n },\n ];\n };\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "A collection of utilities for MetaMask Snaps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -82,14 +82,13 @@
|
|
|
82
82
|
"@babel/types": "^7.23.0",
|
|
83
83
|
"@metamask/key-tree": "^10.1.1",
|
|
84
84
|
"@metamask/messenger": "^0.3.0",
|
|
85
|
-
"@metamask/permission-controller": "^12.
|
|
85
|
+
"@metamask/permission-controller": "^12.2.0",
|
|
86
86
|
"@metamask/rpc-errors": "^7.0.3",
|
|
87
87
|
"@metamask/slip44": "^4.3.0",
|
|
88
88
|
"@metamask/snaps-registry": "^4.0.0",
|
|
89
|
-
"@metamask/snaps-sdk": "^10.
|
|
89
|
+
"@metamask/snaps-sdk": "^10.4.0",
|
|
90
90
|
"@metamask/superstruct": "^3.2.1",
|
|
91
|
-
"@metamask/utils": "^11.
|
|
92
|
-
"@noble/hashes": "^1.7.1",
|
|
91
|
+
"@metamask/utils": "^11.9.0",
|
|
93
92
|
"@scure/base": "^1.1.1",
|
|
94
93
|
"chalk": "^4.1.2",
|
|
95
94
|
"cron-parser": "^4.5.0",
|
|
@@ -104,7 +103,7 @@
|
|
|
104
103
|
"validate-npm-package-name": "^5.0.0"
|
|
105
104
|
},
|
|
106
105
|
"devDependencies": {
|
|
107
|
-
"@lavamoat/allow-scripts": "^3.4.
|
|
106
|
+
"@lavamoat/allow-scripts": "^3.4.2",
|
|
108
107
|
"@metamask/auto-changelog": "^5.0.2",
|
|
109
108
|
"@metamask/post-message-stream": "^10.0.0",
|
|
110
109
|
"@swc/core": "1.11.31",
|