@metamask/snaps-utils 11.3.0 → 11.5.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 +29 -1
- package/dist/base64.cjs +3 -2
- package/dist/base64.cjs.map +1 -1
- package/dist/base64.d.cts.map +1 -1
- package/dist/base64.d.mts.map +1 -1
- package/dist/base64.mjs +3 -2
- package/dist/base64.mjs.map +1 -1
- package/dist/manifest/manifest.cjs +18 -11
- package/dist/manifest/manifest.cjs.map +1 -1
- package/dist/manifest/manifest.d.cts +10 -2
- package/dist/manifest/manifest.d.cts.map +1 -1
- package/dist/manifest/manifest.d.mts +10 -2
- package/dist/manifest/manifest.d.mts.map +1 -1
- package/dist/manifest/manifest.mjs +19 -12
- package/dist/manifest/manifest.mjs.map +1 -1
- package/dist/manifest/validation.cjs +8 -4
- package/dist/manifest/validation.cjs.map +1 -1
- package/dist/manifest/validation.d.cts +4 -0
- package/dist/manifest/validation.d.cts.map +1 -1
- package/dist/manifest/validation.d.mts +4 -0
- package/dist/manifest/validation.d.mts.map +1 -1
- package/dist/manifest/validation.mjs +7 -3
- 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 -2
- package/dist/manifest/validator-types.d.cts.map +1 -1
- package/dist/manifest/validator-types.d.mts +4 -2
- package/dist/manifest/validator-types.d.mts.map +1 -1
- package/dist/manifest/validator-types.mjs.map +1 -1
- package/dist/manifest/validator.cjs +26 -5
- package/dist/manifest/validator.cjs.map +1 -1
- package/dist/manifest/validator.d.cts +10 -1
- package/dist/manifest/validator.d.cts.map +1 -1
- package/dist/manifest/validator.d.mts +10 -1
- package/dist/manifest/validator.d.mts.map +1 -1
- package/dist/manifest/validator.mjs +24 -4
- package/dist/manifest/validator.mjs.map +1 -1
- package/dist/manifest/validators/checksum.cjs +1 -1
- 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 +1 -1
- package/dist/manifest/validators/checksum.mjs.map +1 -1
- package/dist/manifest/validators/expected-files.cjs +1 -1
- package/dist/manifest/validators/expected-files.cjs.map +1 -1
- package/dist/manifest/validators/expected-files.d.cts.map +1 -1
- package/dist/manifest/validators/expected-files.d.mts.map +1 -1
- package/dist/manifest/validators/expected-files.mjs +1 -1
- package/dist/manifest/validators/expected-files.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.d.cts.map +1 -1
- package/dist/manifest/validators/icon-declared.d.mts.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-dimensions.cjs +1 -1
- package/dist/manifest/validators/icon-dimensions.cjs.map +1 -1
- package/dist/manifest/validators/icon-dimensions.d.cts.map +1 -1
- package/dist/manifest/validators/icon-dimensions.d.mts.map +1 -1
- package/dist/manifest/validators/icon-dimensions.mjs +1 -1
- package/dist/manifest/validators/icon-dimensions.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.mjs +1 -1
- package/dist/manifest/validators/icon-missing.mjs.map +1 -1
- package/dist/manifest/validators/is-localization-file.cjs +1 -1
- package/dist/manifest/validators/is-localization-file.cjs.map +1 -1
- package/dist/manifest/validators/is-localization-file.d.cts.map +1 -1
- package/dist/manifest/validators/is-localization-file.d.mts.map +1 -1
- package/dist/manifest/validators/is-localization-file.mjs +1 -1
- package/dist/manifest/validators/is-localization-file.mjs.map +1 -1
- package/dist/manifest/validators/is-package-json.cjs +1 -1
- package/dist/manifest/validators/is-package-json.cjs.map +1 -1
- package/dist/manifest/validators/is-package-json.d.cts.map +1 -1
- package/dist/manifest/validators/is-package-json.d.mts.map +1 -1
- package/dist/manifest/validators/is-package-json.mjs +1 -1
- package/dist/manifest/validators/is-package-json.mjs.map +1 -1
- package/dist/manifest/validators/is-snap-icon.cjs +1 -1
- package/dist/manifest/validators/is-snap-icon.cjs.map +1 -1
- package/dist/manifest/validators/is-snap-icon.mjs +1 -1
- package/dist/manifest/validators/is-snap-icon.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.d.cts.map +1 -1
- package/dist/manifest/validators/is-snap-manifest.d.mts.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.d.cts.map +1 -1
- package/dist/manifest/validators/manifest-localization.d.mts.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-json-recommended-fields.cjs +1 -1
- package/dist/manifest/validators/package-json-recommended-fields.cjs.map +1 -1
- package/dist/manifest/validators/package-json-recommended-fields.d.cts.map +1 -1
- package/dist/manifest/validators/package-json-recommended-fields.d.mts.map +1 -1
- package/dist/manifest/validators/package-json-recommended-fields.mjs +1 -1
- package/dist/manifest/validators/package-json-recommended-fields.mjs.map +1 -1
- package/dist/manifest/validators/package-name-match.cjs +1 -1
- 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 +1 -1
- package/dist/manifest/validators/package-name-match.mjs.map +1 -1
- package/dist/manifest/validators/platform-version.cjs +2 -2
- 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 +2 -2
- 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 +1 -1
- 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 +1 -1
- package/dist/manifest/validators/repository-match.mjs.map +1 -1
- package/dist/manifest/validators/unused-exports.cjs +2 -2
- package/dist/manifest/validators/unused-exports.cjs.map +1 -1
- package/dist/manifest/validators/unused-exports.d.cts.map +1 -1
- package/dist/manifest/validators/unused-exports.d.mts.map +1 -1
- package/dist/manifest/validators/unused-exports.mjs +2 -2
- package/dist/manifest/validators/unused-exports.mjs.map +1 -1
- package/dist/manifest/validators/version-match.cjs +1 -1
- package/dist/manifest/validators/version-match.cjs.map +1 -1
- package/dist/manifest/validators/version-match.d.cts.map +1 -1
- package/dist/manifest/validators/version-match.d.mts.map +1 -1
- package/dist/manifest/validators/version-match.mjs +1 -1
- package/dist/manifest/validators/version-match.mjs.map +1 -1
- package/dist/platform-version.cjs.map +1 -1
- package/dist/platform-version.d.cts +2 -1
- package/dist/platform-version.d.cts.map +1 -1
- package/dist/platform-version.d.mts +2 -1
- package/dist/platform-version.d.mts.map +1 -1
- package/dist/platform-version.mjs.map +1 -1
- package/dist/snaps.cjs.map +1 -1
- package/dist/snaps.d.cts +6 -2
- package/dist/snaps.d.cts.map +1 -1
- package/dist/snaps.d.mts +6 -2
- package/dist/snaps.d.mts.map +1 -1
- package/dist/snaps.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -11,7 +11,7 @@ exports.packageNameMatch = {
|
|
|
11
11
|
const packageJsonName = files.packageJson.result.name;
|
|
12
12
|
const manifestPackageName = files.manifest.result.source.location.npm.packageName;
|
|
13
13
|
if (packageJsonName !== manifestPackageName) {
|
|
14
|
-
context.report(`"${types_1.NpmSnapFileNames.Manifest}" npm package name ("${manifestPackageName}") does not match the "${types_1.NpmSnapFileNames.PackageJson}" "name" field ("${packageJsonName}").`, ({ manifest }) => {
|
|
14
|
+
context.report('package-name-match', `"${types_1.NpmSnapFileNames.Manifest}" npm package name ("${manifestPackageName}") does not match the "${types_1.NpmSnapFileNames.PackageJson}" "name" field ("${packageJsonName}").`, ({ manifest }) => {
|
|
15
15
|
manifest.source.location.npm.packageName = packageJsonName;
|
|
16
16
|
return { manifest };
|
|
17
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-name-match.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/package-name-match.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAG/C;;GAEG;AACU,QAAA,gBAAgB,GAAkB;IAC7C,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;QACtD,MAAM,mBAAmB,GACvB,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC;QACxD,IAAI,eAAe,KAAK,mBAAmB,EAAE,CAAC;YAC5C,OAAO,CAAC,MAAM,CACZ,IAAI,wBAAgB,CAAC,QAAQ,wBAAwB,mBAAmB,0BAA0B,wBAAgB,CAAC,WAAW,oBAAoB,eAAe,KAAK,EACtK,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,GAAG,eAAe,CAAC;gBAC3D,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 package name in manifest matches package.json name.\n */\nexport const packageNameMatch: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const packageJsonName = files.packageJson.result.name;\n const manifestPackageName =\n files.manifest.result.source.location.npm.packageName;\n if (packageJsonName !== manifestPackageName) {\n context.report(\n `\"${NpmSnapFileNames.Manifest}\" npm package name (\"${manifestPackageName}\") does not match the \"${NpmSnapFileNames.PackageJson}\" \"name\" field (\"${packageJsonName}\").`,\n ({ manifest }) => {\n manifest.source.location.npm.packageName = packageJsonName;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"package-name-match.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/package-name-match.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAG/C;;GAEG;AACU,QAAA,gBAAgB,GAAkB;IAC7C,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;QACtD,MAAM,mBAAmB,GACvB,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC;QACxD,IAAI,eAAe,KAAK,mBAAmB,EAAE,CAAC;YAC5C,OAAO,CAAC,MAAM,CACZ,oBAAoB,EACpB,IAAI,wBAAgB,CAAC,QAAQ,wBAAwB,mBAAmB,0BAA0B,wBAAgB,CAAC,WAAW,oBAAoB,eAAe,KAAK,EACtK,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,GAAG,eAAe,CAAC;gBAC3D,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 package name in manifest matches package.json name.\n */\nexport const packageNameMatch: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const packageJsonName = files.packageJson.result.name;\n const manifestPackageName =\n files.manifest.result.source.location.npm.packageName;\n if (packageJsonName !== manifestPackageName) {\n context.report(\n 'package-name-match',\n `\"${NpmSnapFileNames.Manifest}\" npm package name (\"${manifestPackageName}\") does not match the \"${NpmSnapFileNames.PackageJson}\" \"name\" field (\"${packageJsonName}\").`,\n ({ manifest }) => {\n manifest.source.location.npm.packageName = packageJsonName;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-name-match.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/package-name-match.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"package-name-match.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/package-name-match.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAiB9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-name-match.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/package-name-match.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"package-name-match.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/package-name-match.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAiB9B,CAAC"}
|
|
@@ -8,7 +8,7 @@ export const packageNameMatch = {
|
|
|
8
8
|
const packageJsonName = files.packageJson.result.name;
|
|
9
9
|
const manifestPackageName = files.manifest.result.source.location.npm.packageName;
|
|
10
10
|
if (packageJsonName !== manifestPackageName) {
|
|
11
|
-
context.report(`"${NpmSnapFileNames.Manifest}" npm package name ("${manifestPackageName}") does not match the "${NpmSnapFileNames.PackageJson}" "name" field ("${packageJsonName}").`, ({ manifest }) => {
|
|
11
|
+
context.report('package-name-match', `"${NpmSnapFileNames.Manifest}" npm package name ("${manifestPackageName}") does not match the "${NpmSnapFileNames.PackageJson}" "name" field ("${packageJsonName}").`, ({ manifest }) => {
|
|
12
12
|
manifest.source.location.npm.packageName = packageJsonName;
|
|
13
13
|
return { manifest };
|
|
14
14
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-name-match.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/package-name-match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAG/C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAkB;IAC7C,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;QACtD,MAAM,mBAAmB,GACvB,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC;QACxD,IAAI,eAAe,KAAK,mBAAmB,EAAE,CAAC;YAC5C,OAAO,CAAC,MAAM,CACZ,IAAI,gBAAgB,CAAC,QAAQ,wBAAwB,mBAAmB,0BAA0B,gBAAgB,CAAC,WAAW,oBAAoB,eAAe,KAAK,EACtK,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,GAAG,eAAe,CAAC;gBAC3D,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 package name in manifest matches package.json name.\n */\nexport const packageNameMatch: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const packageJsonName = files.packageJson.result.name;\n const manifestPackageName =\n files.manifest.result.source.location.npm.packageName;\n if (packageJsonName !== manifestPackageName) {\n context.report(\n `\"${NpmSnapFileNames.Manifest}\" npm package name (\"${manifestPackageName}\") does not match the \"${NpmSnapFileNames.PackageJson}\" \"name\" field (\"${packageJsonName}\").`,\n ({ manifest }) => {\n manifest.source.location.npm.packageName = packageJsonName;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"package-name-match.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/package-name-match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAG/C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAkB;IAC7C,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;QACtD,MAAM,mBAAmB,GACvB,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC;QACxD,IAAI,eAAe,KAAK,mBAAmB,EAAE,CAAC;YAC5C,OAAO,CAAC,MAAM,CACZ,oBAAoB,EACpB,IAAI,gBAAgB,CAAC,QAAQ,wBAAwB,mBAAmB,0BAA0B,gBAAgB,CAAC,WAAW,oBAAoB,eAAe,KAAK,EACtK,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,GAAG,eAAe,CAAC;gBAC3D,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 package name in manifest matches package.json name.\n */\nexport const packageNameMatch: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const packageJsonName = files.packageJson.result.name;\n const manifestPackageName =\n files.manifest.result.source.location.npm.packageName;\n if (packageJsonName !== manifestPackageName) {\n context.report(\n 'package-name-match',\n `\"${NpmSnapFileNames.Manifest}\" npm package name (\"${manifestPackageName}\") does not match the \"${NpmSnapFileNames.PackageJson}\" \"name\" field (\"${packageJsonName}\").`,\n ({ manifest }) => {\n manifest.source.location.npm.packageName = packageJsonName;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
@@ -17,14 +17,14 @@ exports.platformVersion = {
|
|
|
17
17
|
// eslint-disable-next-line import-x/no-dynamic-require
|
|
18
18
|
const actualVersion = require(packageJson).version;
|
|
19
19
|
if (!manifestPlatformVersion) {
|
|
20
|
-
context.report('The "platformVersion" field is missing from the manifest.', ({ manifest }) => {
|
|
20
|
+
context.report('platform-version-missing', 'The "platformVersion" field is missing from the manifest.', ({ manifest }) => {
|
|
21
21
|
manifest.platformVersion = actualVersion;
|
|
22
22
|
return { manifest };
|
|
23
23
|
});
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
if (manifestPlatformVersion !== actualVersion) {
|
|
27
|
-
context.report(`The "platformVersion" field in the manifest must match the version of the Snaps SDK. Got "${manifestPlatformVersion}", expected "${actualVersion}".`, async ({ manifest }) => {
|
|
27
|
+
context.report('platform-version-mismatch', `The "platformVersion" field in the manifest must match the version of the Snaps SDK. Got "${manifestPlatformVersion}", expected "${actualVersion}".`, async ({ manifest }) => {
|
|
28
28
|
manifest.platformVersion = actualVersion;
|
|
29
29
|
return { manifest };
|
|
30
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-version.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/platform-version.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AAIvC;;;GAGG;AACU,QAAA,eAAe,GAAkB;IAC5C,QAAQ,EAAE,OAAO;IACjB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO;QAChC,MAAM,uBAAuB,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC;QAEtE,2EAA2E;QAC3E,wEAAwE;QACxE,MAAM,OAAO,GAAG,IAAA,sBAAa,EAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEnD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC;QACxE,uDAAuD;QACvD,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;QAEnD,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC7B,OAAO,CAAC,MAAM,CACZ,2DAA2D,EAC3D,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,eAAe,GAAG,aAAa,CAAC;gBACzC,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;YAEF,OAAO;QACT,CAAC;QAED,IAAI,uBAAuB,KAAK,aAAa,EAAE,CAAC;YAC9C,OAAO,CAAC,MAAM,CACZ,6FAA6F,uBAAuB,gBAAgB,aAAa,IAAI,EACrJ,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACrB,QAAQ,CAAC,eAAe,GAAG,aAAa,CAAC;gBACzC,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { createRequire } from 'module';\n\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the platform version in manifest matches the version of the Snaps\n * SDK.\n */\nexport const platformVersion: ValidatorMeta = {\n severity: 'error',\n async semanticCheck(files, context) {\n const manifestPlatformVersion = files.manifest.result.platformVersion;\n\n // Create a require function in the context of the location of the manifest\n // file to avoid potentially loading the wrong version of the Snaps SDK.\n const require = createRequire(files.manifest.path);\n\n const packageJson = require.resolve('@metamask/snaps-sdk/package.json');\n // eslint-disable-next-line import-x/no-dynamic-require\n const actualVersion = require(packageJson).version;\n\n if (!manifestPlatformVersion) {\n context.report(\n 'The \"platformVersion\" field is missing from the manifest.',\n ({ manifest }) => {\n manifest.platformVersion = actualVersion;\n return { manifest };\n },\n );\n\n return;\n }\n\n if (manifestPlatformVersion !== actualVersion) {\n context.report(\n `The \"platformVersion\" field in the manifest must match the version of the Snaps SDK. Got \"${manifestPlatformVersion}\", expected \"${actualVersion}\".`,\n async ({ manifest }) => {\n manifest.platformVersion = actualVersion;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"platform-version.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/platform-version.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AAIvC;;;GAGG;AACU,QAAA,eAAe,GAAkB;IAC5C,QAAQ,EAAE,OAAO;IACjB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO;QAChC,MAAM,uBAAuB,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC;QAEtE,2EAA2E;QAC3E,wEAAwE;QACxE,MAAM,OAAO,GAAG,IAAA,sBAAa,EAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEnD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC;QACxE,uDAAuD;QACvD,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;QAEnD,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC7B,OAAO,CAAC,MAAM,CACZ,0BAA0B,EAC1B,2DAA2D,EAC3D,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,eAAe,GAAG,aAAa,CAAC;gBACzC,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;YAEF,OAAO;QACT,CAAC;QAED,IAAI,uBAAuB,KAAK,aAAa,EAAE,CAAC;YAC9C,OAAO,CAAC,MAAM,CACZ,2BAA2B,EAC3B,6FAA6F,uBAAuB,gBAAgB,aAAa,IAAI,EACrJ,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACrB,QAAQ,CAAC,eAAe,GAAG,aAAa,CAAC;gBACzC,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { createRequire } from 'module';\n\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the platform version in manifest matches the version of the Snaps\n * SDK.\n */\nexport const platformVersion: ValidatorMeta = {\n severity: 'error',\n async semanticCheck(files, context) {\n const manifestPlatformVersion = files.manifest.result.platformVersion;\n\n // Create a require function in the context of the location of the manifest\n // file to avoid potentially loading the wrong version of the Snaps SDK.\n const require = createRequire(files.manifest.path);\n\n const packageJson = require.resolve('@metamask/snaps-sdk/package.json');\n // eslint-disable-next-line import-x/no-dynamic-require\n const actualVersion = require(packageJson).version;\n\n if (!manifestPlatformVersion) {\n context.report(\n 'platform-version-missing',\n 'The \"platformVersion\" field is missing from the manifest.',\n ({ manifest }) => {\n manifest.platformVersion = actualVersion;\n return { manifest };\n },\n );\n\n return;\n }\n\n if (manifestPlatformVersion !== actualVersion) {\n context.report(\n 'platform-version-mismatch',\n `The \"platformVersion\" field in the manifest must match the version of the Snaps SDK. Got \"${manifestPlatformVersion}\", expected \"${actualVersion}\".`,\n async ({ manifest }) => {\n manifest.platformVersion = actualVersion;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-version.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/platform-version.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"platform-version.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/platform-version.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,aAqC7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-version.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/platform-version.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"platform-version.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/platform-version.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,aAqC7B,CAAC"}
|
|
@@ -14,14 +14,14 @@ export const platformVersion = {
|
|
|
14
14
|
// eslint-disable-next-line import-x/no-dynamic-require
|
|
15
15
|
const actualVersion = require(packageJson).version;
|
|
16
16
|
if (!manifestPlatformVersion) {
|
|
17
|
-
context.report('The "platformVersion" field is missing from the manifest.', ({ manifest }) => {
|
|
17
|
+
context.report('platform-version-missing', 'The "platformVersion" field is missing from the manifest.', ({ manifest }) => {
|
|
18
18
|
manifest.platformVersion = actualVersion;
|
|
19
19
|
return { manifest };
|
|
20
20
|
});
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
if (manifestPlatformVersion !== actualVersion) {
|
|
24
|
-
context.report(`The "platformVersion" field in the manifest must match the version of the Snaps SDK. Got "${manifestPlatformVersion}", expected "${actualVersion}".`, async ({ manifest }) => {
|
|
24
|
+
context.report('platform-version-mismatch', `The "platformVersion" field in the manifest must match the version of the Snaps SDK. Got "${manifestPlatformVersion}", expected "${actualVersion}".`, async ({ manifest }) => {
|
|
25
25
|
manifest.platformVersion = actualVersion;
|
|
26
26
|
return { manifest };
|
|
27
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-version.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/platform-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe;AAIvC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAkB;IAC5C,QAAQ,EAAE,OAAO;IACjB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO;QAChC,MAAM,uBAAuB,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC;QAEtE,2EAA2E;QAC3E,wEAAwE;QACxE,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEnD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC;QACxE,uDAAuD;QACvD,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;QAEnD,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC7B,OAAO,CAAC,MAAM,CACZ,2DAA2D,EAC3D,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,eAAe,GAAG,aAAa,CAAC;gBACzC,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;YAEF,OAAO;QACT,CAAC;QAED,IAAI,uBAAuB,KAAK,aAAa,EAAE,CAAC;YAC9C,OAAO,CAAC,MAAM,CACZ,6FAA6F,uBAAuB,gBAAgB,aAAa,IAAI,EACrJ,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACrB,QAAQ,CAAC,eAAe,GAAG,aAAa,CAAC;gBACzC,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { createRequire } from 'module';\n\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the platform version in manifest matches the version of the Snaps\n * SDK.\n */\nexport const platformVersion: ValidatorMeta = {\n severity: 'error',\n async semanticCheck(files, context) {\n const manifestPlatformVersion = files.manifest.result.platformVersion;\n\n // Create a require function in the context of the location of the manifest\n // file to avoid potentially loading the wrong version of the Snaps SDK.\n const require = createRequire(files.manifest.path);\n\n const packageJson = require.resolve('@metamask/snaps-sdk/package.json');\n // eslint-disable-next-line import-x/no-dynamic-require\n const actualVersion = require(packageJson).version;\n\n if (!manifestPlatformVersion) {\n context.report(\n 'The \"platformVersion\" field is missing from the manifest.',\n ({ manifest }) => {\n manifest.platformVersion = actualVersion;\n return { manifest };\n },\n );\n\n return;\n }\n\n if (manifestPlatformVersion !== actualVersion) {\n context.report(\n `The \"platformVersion\" field in the manifest must match the version of the Snaps SDK. Got \"${manifestPlatformVersion}\", expected \"${actualVersion}\".`,\n async ({ manifest }) => {\n manifest.platformVersion = actualVersion;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"platform-version.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/platform-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe;AAIvC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAkB;IAC5C,QAAQ,EAAE,OAAO;IACjB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO;QAChC,MAAM,uBAAuB,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC;QAEtE,2EAA2E;QAC3E,wEAAwE;QACxE,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEnD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC;QACxE,uDAAuD;QACvD,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;QAEnD,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC7B,OAAO,CAAC,MAAM,CACZ,0BAA0B,EAC1B,2DAA2D,EAC3D,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,eAAe,GAAG,aAAa,CAAC;gBACzC,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;YAEF,OAAO;QACT,CAAC;QAED,IAAI,uBAAuB,KAAK,aAAa,EAAE,CAAC;YAC9C,OAAO,CAAC,MAAM,CACZ,2BAA2B,EAC3B,6FAA6F,uBAAuB,gBAAgB,aAAa,IAAI,EACrJ,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACrB,QAAQ,CAAC,eAAe,GAAG,aAAa,CAAC;gBACzC,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { createRequire } from 'module';\n\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the platform version in manifest matches the version of the Snaps\n * SDK.\n */\nexport const platformVersion: ValidatorMeta = {\n severity: 'error',\n async semanticCheck(files, context) {\n const manifestPlatformVersion = files.manifest.result.platformVersion;\n\n // Create a require function in the context of the location of the manifest\n // file to avoid potentially loading the wrong version of the Snaps SDK.\n const require = createRequire(files.manifest.path);\n\n const packageJson = require.resolve('@metamask/snaps-sdk/package.json');\n // eslint-disable-next-line import-x/no-dynamic-require\n const actualVersion = require(packageJson).version;\n\n if (!manifestPlatformVersion) {\n context.report(\n 'platform-version-missing',\n 'The \"platformVersion\" field is missing from the manifest.',\n ({ manifest }) => {\n manifest.platformVersion = actualVersion;\n return { manifest };\n },\n );\n\n return;\n }\n\n if (manifestPlatformVersion !== actualVersion) {\n context.report(\n 'platform-version-mismatch',\n `The \"platformVersion\" field in the manifest must match the version of the Snaps SDK. Got \"${manifestPlatformVersion}\", expected \"${actualVersion}\".`,\n async ({ manifest }) => {\n manifest.platformVersion = actualVersion;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
@@ -40,7 +40,7 @@ exports.productionPlatformVersion = {
|
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
if ((0, semver_1.gt)(manifestPlatformVersion, maximumVersion)) {
|
|
43
|
-
context.report(`The specified platform version "${manifestPlatformVersion}" is not supported in the production version of MetaMask. The current maximum supported version is "${maximumVersion}". To resolve this, downgrade \`@metamask/snaps-sdk\` to a compatible version.`);
|
|
43
|
+
context.report('production-platform-version', `The specified platform version "${manifestPlatformVersion}" is not supported in the production version of MetaMask. The current maximum supported version is "${maximumVersion}". To resolve this, downgrade \`@metamask/snaps-sdk\` to a compatible version.`);
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"production-platform-version.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/production-platform-version.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAC3D,mCAAwC;AAExC,qCAA8C;AAG9C;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,IAAA,uBAAkB,EACnD,0BAA0B,EAC1B,IAAA,sBAAc,EAAC,CAAC,EAAE,gBAAQ,CAAC,GAAG,CAAC,EAC/B,KAAK,IAAI,EAAE;IACT,IAAI,CAAC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ion, gt } from 'semver';\n\nimport { useFileSystemCache } from '../../fs';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Determine the production version of the Snaps platform by inspecting\n * the latest GitHub release of the MetaMask extension.\n *\n * @returns The production version of the Snaps platform or null if any error occurred.\n */\nconst determineProductionVersion = useFileSystemCache(\n 'snaps-production-version',\n inMilliseconds(3, Duration.Day),\n async () => {\n try {\n const latestRelease = await fetch(\n 'https://api.github.com/repos/metamask/metamask-extension/releases/latest',\n );\n\n const latestReleaseJson = await latestRelease.json();\n\n const latestReleaseCommit = latestReleaseJson.target_commitish;\n\n const packageJsonResponse = await fetch(\n `https://api.github.com/repos/metamask/metamask-extension/contents/package.json?ref=${latestReleaseCommit}`,\n { headers: new Headers({ accept: 'application/vnd.github.raw+json' }) },\n );\n\n const packageJson = await packageJsonResponse.json();\n\n const versionRange = packageJson.dependencies['@metamask/snaps-sdk'];\n\n return minVersion(versionRange)?.format();\n } catch {\n return null;\n }\n },\n);\n\n/**\n * Check if the platform version in manifest exceeds the version\n * used in production.\n */\nexport const productionPlatformVersion: ValidatorMeta = {\n severity: 'warning',\n async semanticCheck(files, context) {\n const manifestPlatformVersion = files.manifest.result.platformVersion;\n\n if (!manifestPlatformVersion) {\n return;\n }\n\n const maximumVersion = await determineProductionVersion();\n\n if (!maximumVersion) {\n return;\n }\n\n if (gt(manifestPlatformVersion, maximumVersion)) {\n context.report(\n `The specified platform version \"${manifestPlatformVersion}\" is not supported in the production version of MetaMask. The current maximum supported version is \"${maximumVersion}\". To resolve this, downgrade \\`@metamask/snaps-sdk\\` to a compatible version.`,\n );\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"production-platform-version.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/production-platform-version.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAC3D,mCAAwC;AAExC,qCAA8C;AAG9C;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,IAAA,uBAAkB,EACnD,0BAA0B,EAC1B,IAAA,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AAc,gFAAgF,CAChQ,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { Duration, inMilliseconds } from '@metamask/utils';\nimport { minVersion, gt } from 'semver';\n\nimport { useFileSystemCache } from '../../fs';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Determine the production version of the Snaps platform by inspecting\n * the latest GitHub release of the MetaMask extension.\n *\n * @returns The production version of the Snaps platform or null if any error occurred.\n */\nconst determineProductionVersion = useFileSystemCache(\n 'snaps-production-version',\n inMilliseconds(3, Duration.Day),\n async () => {\n try {\n const latestRelease = await fetch(\n 'https://api.github.com/repos/metamask/metamask-extension/releases/latest',\n );\n\n const latestReleaseJson = await latestRelease.json();\n\n const latestReleaseCommit = latestReleaseJson.target_commitish;\n\n const packageJsonResponse = await fetch(\n `https://api.github.com/repos/metamask/metamask-extension/contents/package.json?ref=${latestReleaseCommit}`,\n { headers: new Headers({ accept: 'application/vnd.github.raw+json' }) },\n );\n\n const packageJson = await packageJsonResponse.json();\n\n const versionRange = packageJson.dependencies['@metamask/snaps-sdk'];\n\n return minVersion(versionRange)?.format();\n } catch {\n return null;\n }\n },\n);\n\n/**\n * Check if the platform version in manifest exceeds the version\n * used in production.\n */\nexport const productionPlatformVersion: ValidatorMeta = {\n severity: 'warning',\n async semanticCheck(files, context) {\n const manifestPlatformVersion = files.manifest.result.platformVersion;\n\n if (!manifestPlatformVersion) {\n return;\n }\n\n const maximumVersion = await determineProductionVersion();\n\n if (!maximumVersion) {\n return;\n }\n\n if (gt(manifestPlatformVersion, maximumVersion)) {\n context.report(\n 'production-platform-version',\n `The specified platform version \"${manifestPlatformVersion}\" is not supported in the production version of MetaMask. The current maximum supported version is \"${maximumVersion}\". To resolve this, downgrade \\`@metamask/snaps-sdk\\` to a compatible version.`,\n );\n }\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"production-platform-version.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/production-platform-version.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAqCxD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"production-platform-version.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/production-platform-version.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAqCxD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,aAsBvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"production-platform-version.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/production-platform-version.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAqCxD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"production-platform-version.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/production-platform-version.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAqCxD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,aAsBvC,CAAC"}
|
|
@@ -37,7 +37,7 @@ export const productionPlatformVersion = {
|
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
if (gt(manifestPlatformVersion, maximumVersion)) {
|
|
40
|
-
context.report(`The specified platform version "${manifestPlatformVersion}" is not supported in the production version of MetaMask. The current maximum supported version is "${maximumVersion}". To resolve this, downgrade \`@metamask/snaps-sdk\` to a compatible version.`);
|
|
40
|
+
context.report('production-platform-version', `The specified platform version "${manifestPlatformVersion}" is not supported in the production version of MetaMask. The current maximum supported version is "${maximumVersion}". To resolve this, downgrade \`@metamask/snaps-sdk\` to a compatible version.`);
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"production-platform-version.mjs","sourceRoot":"","sources":["../../../src/manifest/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AED,MAAM,cAAc,GAAG,MAAM,0BAA0B,EAAE,CAAC;QAE1D,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QAED,IAAI,EAAE,CAAC,uBAAuB,EAAE,cAAc,CAAC,EAAE,CAAC;YAChD,OAAO,CAAC,MAAM,CACZ,mCAAmC,uBAAuB,uGAAuG,cAAc,gFAAgF,CAChQ,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { Duration, inMilliseconds } from '@metamask/utils';\nimport { minVersion, gt } from 'semver';\n\nimport { useFileSystemCache } from '../../fs';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Determine the production version of the Snaps platform by inspecting\n * the latest GitHub release of the MetaMask extension.\n *\n * @returns The production version of the Snaps platform or null if any error occurred.\n */\nconst determineProductionVersion = useFileSystemCache(\n 'snaps-production-version',\n inMilliseconds(3, Duration.Day),\n async () => {\n try {\n const latestRelease = await fetch(\n 'https://api.github.com/repos/metamask/metamask-extension/releases/latest',\n );\n\n const latestReleaseJson = await latestRelease.json();\n\n const latestReleaseCommit = latestReleaseJson.target_commitish;\n\n const packageJsonResponse = await fetch(\n `https://api.github.com/repos/metamask/metamask-extension/contents/package.json?ref=${latestReleaseCommit}`,\n { headers: new Headers({ accept: 'application/vnd.github.raw+json' }) },\n );\n\n const packageJson = await packageJsonResponse.json();\n\n const versionRange = packageJson.dependencies['@metamask/snaps-sdk'];\n\n return minVersion(versionRange)?.format();\n } catch {\n return null;\n }\n },\n);\n\n/**\n * Check if the platform version in manifest exceeds the version\n * used in production.\n */\nexport const productionPlatformVersion: ValidatorMeta = {\n severity: 'warning',\n async semanticCheck(files, context) {\n const manifestPlatformVersion = files.manifest.result.platformVersion;\n\n if (!manifestPlatformVersion) {\n return;\n }\n\n const maximumVersion = await determineProductionVersion();\n\n if (!maximumVersion) {\n return;\n }\n\n if (gt(manifestPlatformVersion, maximumVersion)) {\n context.report(\n `The specified platform version \"${manifestPlatformVersion}\" is not supported in the production version of MetaMask. The current maximum supported version is \"${maximumVersion}\". To resolve this, downgrade \\`@metamask/snaps-sdk\\` to a compatible version.`,\n );\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"production-platform-version.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/production-platform-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,wBAAwB;AAC3D,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,eAAe;AAExC,OAAO,EAAE,kBAAkB,EAAE,qBAAiB;AAG9C;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,kBAAkB,CACnD,0BAA0B,EAC1B,cAAc,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,EAC/B,KAAK,IAAI,EAAE;IACT,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,MAAM,KAAK,CAC/B,0EAA0E,CAC3E,CAAC;QAEF,MAAM,iBAAiB,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC;QAErD,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC;QAE/D,MAAM,mBAAmB,GAAG,MAAM,KAAK,CACrC,sFAAsF,mBAAmB,EAAE,EAC3G,EAAE,OAAO,EAAE,IAAI,OAAO,CAAC,EAAE,MAAM,EAAE,iCAAiC,EAAE,CAAC,EAAE,CACxE,CAAC;QAEF,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC,IAAI,EAAE,CAAC;QAErD,MAAM,YAAY,GAAG,WAAW,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;QAErE,OAAO,UAAU,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAkB;IACtD,QAAQ,EAAE,SAAS;IACnB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO;QAChC,MAAM,uBAAuB,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC;QAEtE,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC7B,OAAO;QACT,CAAC;QAED,MAAM,cAAc,GAAG,MAAM,0BAA0B,EAAE,CAAC;QAE1D,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QAED,IAAI,EAAE,CAAC,uBAAuB,EAAE,cAAc,CAAC,EAAE,CAAC;YAChD,OAAO,CAAC,MAAM,CACZ,6BAA6B,EAC7B,mCAAmC,uBAAuB,uGAAuG,cAAc,gFAAgF,CAChQ,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { Duration, inMilliseconds } from '@metamask/utils';\nimport { minVersion, gt } from 'semver';\n\nimport { useFileSystemCache } from '../../fs';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Determine the production version of the Snaps platform by inspecting\n * the latest GitHub release of the MetaMask extension.\n *\n * @returns The production version of the Snaps platform or null if any error occurred.\n */\nconst determineProductionVersion = useFileSystemCache(\n 'snaps-production-version',\n inMilliseconds(3, Duration.Day),\n async () => {\n try {\n const latestRelease = await fetch(\n 'https://api.github.com/repos/metamask/metamask-extension/releases/latest',\n );\n\n const latestReleaseJson = await latestRelease.json();\n\n const latestReleaseCommit = latestReleaseJson.target_commitish;\n\n const packageJsonResponse = await fetch(\n `https://api.github.com/repos/metamask/metamask-extension/contents/package.json?ref=${latestReleaseCommit}`,\n { headers: new Headers({ accept: 'application/vnd.github.raw+json' }) },\n );\n\n const packageJson = await packageJsonResponse.json();\n\n const versionRange = packageJson.dependencies['@metamask/snaps-sdk'];\n\n return minVersion(versionRange)?.format();\n } catch {\n return null;\n }\n },\n);\n\n/**\n * Check if the platform version in manifest exceeds the version\n * used in production.\n */\nexport const productionPlatformVersion: ValidatorMeta = {\n severity: 'warning',\n async semanticCheck(files, context) {\n const manifestPlatformVersion = files.manifest.result.platformVersion;\n\n if (!manifestPlatformVersion) {\n return;\n }\n\n const maximumVersion = await determineProductionVersion();\n\n if (!maximumVersion) {\n return;\n }\n\n if (gt(manifestPlatformVersion, maximumVersion)) {\n context.report(\n 'production-platform-version',\n `The specified platform version \"${manifestPlatformVersion}\" is not supported in the production version of MetaMask. The current maximum supported version is \"${maximumVersion}\". To resolve this, downgrade \\`@metamask/snaps-sdk\\` to a compatible version.`,\n );\n }\n },\n};\n"]}
|
|
@@ -17,7 +17,7 @@ exports.repositoryMatch = {
|
|
|
17
17
|
const manifestRepository = files.manifest.result.repository;
|
|
18
18
|
if ((packageJsonRepository || manifestRepository) &&
|
|
19
19
|
!(0, fast_deep_equal_1.default)(packageJsonRepository, manifestRepository)) {
|
|
20
|
-
context.report(`"${types_1.NpmSnapFileNames.Manifest}" "repository" field does not match the "${types_1.NpmSnapFileNames.PackageJson}" "repository" field.`, ({ manifest }) => {
|
|
20
|
+
context.report('repository-match', `"${types_1.NpmSnapFileNames.Manifest}" "repository" field does not match the "${types_1.NpmSnapFileNames.PackageJson}" "repository" field.`, ({ manifest }) => {
|
|
21
21
|
manifest.repository = packageJsonRepository
|
|
22
22
|
? (0, deep_clone_1.deepClone)(packageJsonRepository)
|
|
23
23
|
: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository-match.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/repository-match.ts"],"names":[],"mappings":";;;;;;AAAA,sEAAwC;AAExC,qDAA6C;AAC7C,2CAA+C;AAG/C;;GAEG;AACU,QAAA,eAAe,GAAkB;IAC5C,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC;QAClE,MAAM,kBAAkB,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC;QAC5D,IACE,CAAC,qBAAqB,IAAI,kBAAkB,CAAC;YAC7C,CAAC,IAAA,yBAAS,EAAC,qBAAqB,EAAE,kBAAkB,CAAC,EACrD,CAAC;YACD,OAAO,CAAC,MAAM,CACZ,IAAI,wBAAgB,CAAC,QAAQ,4CAA4C,wBAAgB,CAAC,WAAW,uBAAuB,EAC5H,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,UAAU,GAAG,qBAAqB;oBACzC,CAAC,CAAC,IAAA,sBAAS,EAAC,qBAAqB,CAAC;oBAClC,CAAC,CAAC,SAAS,CAAC;gBACd,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import deepEqual from 'fast-deep-equal';\n\nimport { deepClone } from '../../deep-clone';\nimport { NpmSnapFileNames } from '../../types';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the repository object in manifest is the same as in package.json.\n */\nexport const repositoryMatch: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const packageJsonRepository = files.packageJson.result.repository;\n const manifestRepository = files.manifest.result.repository;\n if (\n (packageJsonRepository || manifestRepository) &&\n !deepEqual(packageJsonRepository, manifestRepository)\n ) {\n context.report(\n `\"${NpmSnapFileNames.Manifest}\" \"repository\" field does not match the \"${NpmSnapFileNames.PackageJson}\" \"repository\" field.`,\n ({ manifest }) => {\n manifest.repository = packageJsonRepository\n ? deepClone(packageJsonRepository)\n : undefined;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"repository-match.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/repository-match.ts"],"names":[],"mappings":";;;;;;AAAA,sEAAwC;AAExC,qDAA6C;AAC7C,2CAA+C;AAG/C;;GAEG;AACU,QAAA,eAAe,GAAkB;IAC5C,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC;QAClE,MAAM,kBAAkB,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC;QAC5D,IACE,CAAC,qBAAqB,IAAI,kBAAkB,CAAC;YAC7C,CAAC,IAAA,yBAAS,EAAC,qBAAqB,EAAE,kBAAkB,CAAC,EACrD,CAAC;YACD,OAAO,CAAC,MAAM,CACZ,kBAAkB,EAClB,IAAI,wBAAgB,CAAC,QAAQ,4CAA4C,wBAAgB,CAAC,WAAW,uBAAuB,EAC5H,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,UAAU,GAAG,qBAAqB;oBACzC,CAAC,CAAC,IAAA,sBAAS,EAAC,qBAAqB,CAAC;oBAClC,CAAC,CAAC,SAAS,CAAC;gBACd,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import deepEqual from 'fast-deep-equal';\n\nimport { deepClone } from '../../deep-clone';\nimport { NpmSnapFileNames } from '../../types';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the repository object in manifest is the same as in package.json.\n */\nexport const repositoryMatch: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const packageJsonRepository = files.packageJson.result.repository;\n const manifestRepository = files.manifest.result.repository;\n if (\n (packageJsonRepository || manifestRepository) &&\n !deepEqual(packageJsonRepository, manifestRepository)\n ) {\n context.report(\n 'repository-match',\n `\"${NpmSnapFileNames.Manifest}\" \"repository\" field does not match the \"${NpmSnapFileNames.PackageJson}\" \"repository\" field.`,\n ({ manifest }) => {\n manifest.repository = packageJsonRepository\n ? deepClone(packageJsonRepository)\n : undefined;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository-match.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/repository-match.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"repository-match.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/repository-match.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,aAqB7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository-match.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/repository-match.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"repository-match.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/repository-match.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,aAqB7B,CAAC"}
|
|
@@ -18,7 +18,7 @@ export const repositoryMatch = {
|
|
|
18
18
|
const manifestRepository = files.manifest.result.repository;
|
|
19
19
|
if ((packageJsonRepository || manifestRepository) &&
|
|
20
20
|
!deepEqual(packageJsonRepository, manifestRepository)) {
|
|
21
|
-
context.report(`"${NpmSnapFileNames.Manifest}" "repository" field does not match the "${NpmSnapFileNames.PackageJson}" "repository" field.`, ({ manifest }) => {
|
|
21
|
+
context.report('repository-match', `"${NpmSnapFileNames.Manifest}" "repository" field does not match the "${NpmSnapFileNames.PackageJson}" "repository" field.`, ({ manifest }) => {
|
|
22
22
|
manifest.repository = packageJsonRepository
|
|
23
23
|
? deepClone(packageJsonRepository)
|
|
24
24
|
: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository-match.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/repository-match.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,UAAS,wBAAwB;;AAExC,OAAO,EAAE,SAAS,EAAE,6BAAyB;AAC7C,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAG/C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAkB;IAC5C,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC;QAClE,MAAM,kBAAkB,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC;QAC5D,IACE,CAAC,qBAAqB,IAAI,kBAAkB,CAAC;YAC7C,CAAC,SAAS,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,EACrD,CAAC;YACD,OAAO,CAAC,MAAM,CACZ,IAAI,gBAAgB,CAAC,QAAQ,4CAA4C,gBAAgB,CAAC,WAAW,uBAAuB,EAC5H,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,UAAU,GAAG,qBAAqB;oBACzC,CAAC,CAAC,SAAS,CAAC,qBAAqB,CAAC;oBAClC,CAAC,CAAC,SAAS,CAAC;gBACd,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import deepEqual from 'fast-deep-equal';\n\nimport { deepClone } from '../../deep-clone';\nimport { NpmSnapFileNames } from '../../types';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the repository object in manifest is the same as in package.json.\n */\nexport const repositoryMatch: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const packageJsonRepository = files.packageJson.result.repository;\n const manifestRepository = files.manifest.result.repository;\n if (\n (packageJsonRepository || manifestRepository) &&\n !deepEqual(packageJsonRepository, manifestRepository)\n ) {\n context.report(\n `\"${NpmSnapFileNames.Manifest}\" \"repository\" field does not match the \"${NpmSnapFileNames.PackageJson}\" \"repository\" field.`,\n ({ manifest }) => {\n manifest.repository = packageJsonRepository\n ? deepClone(packageJsonRepository)\n : undefined;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"repository-match.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/repository-match.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,UAAS,wBAAwB;;AAExC,OAAO,EAAE,SAAS,EAAE,6BAAyB;AAC7C,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAG/C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAkB;IAC5C,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC;QAClE,MAAM,kBAAkB,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC;QAC5D,IACE,CAAC,qBAAqB,IAAI,kBAAkB,CAAC;YAC7C,CAAC,SAAS,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,EACrD,CAAC;YACD,OAAO,CAAC,MAAM,CACZ,kBAAkB,EAClB,IAAI,gBAAgB,CAAC,QAAQ,4CAA4C,gBAAgB,CAAC,WAAW,uBAAuB,EAC5H,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,UAAU,GAAG,qBAAqB;oBACzC,CAAC,CAAC,SAAS,CAAC,qBAAqB,CAAC;oBAClC,CAAC,CAAC,SAAS,CAAC;gBACd,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import deepEqual from 'fast-deep-equal';\n\nimport { deepClone } from '../../deep-clone';\nimport { NpmSnapFileNames } from '../../types';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the repository object in manifest is the same as in package.json.\n */\nexport const repositoryMatch: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const packageJsonRepository = files.packageJson.result.repository;\n const manifestRepository = files.manifest.result.repository;\n if (\n (packageJsonRepository || manifestRepository) &&\n !deepEqual(packageJsonRepository, manifestRepository)\n ) {\n context.report(\n 'repository-match',\n `\"${NpmSnapFileNames.Manifest}\" \"repository\" field does not match the \"${NpmSnapFileNames.PackageJson}\" \"repository\" field.`,\n ({ manifest }) => {\n manifest.repository = packageJsonRepository\n ? deepClone(packageJsonRepository)\n : undefined;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
@@ -45,13 +45,13 @@ exports.unusedExports = {
|
|
|
45
45
|
// requires AST manipulation.
|
|
46
46
|
// 2. Adding the permission to the manifest is not always possible, as it
|
|
47
47
|
// may require additional configuration in the manifest.
|
|
48
|
-
context.report(`The Snap exports the following handlers, but does not request permission for them: ${unusedHandlers.join(', ')}.`);
|
|
48
|
+
context.report(`unused-exports`, `The Snap exports the following handlers, but does not request permission for them: ${unusedHandlers.join(', ')}.`);
|
|
49
49
|
}
|
|
50
50
|
if (unusedEndowments.length > 0) {
|
|
51
51
|
const formattedEndowments = unusedEndowments
|
|
52
52
|
.map(([handler, endowment]) => `${handler} (${endowment})`)
|
|
53
53
|
.join(', ');
|
|
54
|
-
context.report(`The Snap requests permission for the following handlers, but does not export them: ${formattedEndowments}.`, ({ manifest }) => {
|
|
54
|
+
context.report(`unused-endowments`, `The Snap requests permission for the following handlers, but does not export them: ${formattedEndowments}.`, ({ manifest }) => {
|
|
55
55
|
unusedEndowments.forEach(([, endowment]) => {
|
|
56
56
|
delete manifest.initialPermissions[endowment];
|
|
57
57
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unused-exports.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/unused-exports.ts"],"names":[],"mappings":";;;AAIA,kDAAkD;AAClD,MAAM,kBAAkB,GAAG,CAAC,0BAA0B,CAAC,CA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'../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.result.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.result.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 `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 `The Snap requests permission for the following handlers, but does not export them: ${formattedEndowments}.`,\n ({ manifest }) => {\n unusedEndowments.forEach(([, endowment]) => {\n delete manifest.initialPermissions[\n endowment as keyof InitialPermissions\n ];\n });\n\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"unused-exports.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/unused-exports.ts"],"names":[],"mappings":";;;AAIA,kDAAkD;AAClD,MAAM,kBAAkB,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAExD;;;GAGG;AACU,QAAA,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,MAAM,CAAC,kBAAkB,CACvC,SAAqC,CACtC,CACF,CAAC;QAC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AAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE;oBACzC,OAAO,QAAQ,CAAC,kBAAkB,CAChC,SAAqC,CACtC,CAAC;gBACJ,CAAC,CAAC,CAAC;gBAEH,OAAO,EAAE,QAAQ,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.result.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.result.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.initialPermissions[\n endowment as keyof InitialPermissions\n ];\n });\n\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unused-exports.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/unused-exports.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAKxD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"unused-exports.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/unused-exports.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAKxD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,aAsF3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unused-exports.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/unused-exports.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAKxD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"unused-exports.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/unused-exports.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAKxD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,aAsF3B,CAAC"}
|
|
@@ -42,13 +42,13 @@ export const unusedExports = {
|
|
|
42
42
|
// requires AST manipulation.
|
|
43
43
|
// 2. Adding the permission to the manifest is not always possible, as it
|
|
44
44
|
// may require additional configuration in the manifest.
|
|
45
|
-
context.report(`The Snap exports the following handlers, but does not request permission for them: ${unusedHandlers.join(', ')}.`);
|
|
45
|
+
context.report(`unused-exports`, `The Snap exports the following handlers, but does not request permission for them: ${unusedHandlers.join(', ')}.`);
|
|
46
46
|
}
|
|
47
47
|
if (unusedEndowments.length > 0) {
|
|
48
48
|
const formattedEndowments = unusedEndowments
|
|
49
49
|
.map(([handler, endowment]) => `${handler} (${endowment})`)
|
|
50
50
|
.join(', ');
|
|
51
|
-
context.report(`The Snap requests permission for the following handlers, but does not export them: ${formattedEndowments}.`, ({ manifest }) => {
|
|
51
|
+
context.report(`unused-endowments`, `The Snap requests permission for the following handlers, but does not export them: ${formattedEndowments}.`, ({ manifest }) => {
|
|
52
52
|
unusedEndowments.forEach(([, endowment]) => {
|
|
53
53
|
delete manifest.initialPermissions[endowment];
|
|
54
54
|
});
|
|
@@ -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,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AAC;YAC9B,iDAAiD;YACjD,oEAAoE;YACpE,gCAAgC;YAChC,yEAAyE;YACzE,2DAA2D;YAC3D,OAAO,CAAC,MAAM,CACZ,sFAAsF,cAAc,CAAC,IAAI,CACvG,IAAI,CACL,GAAG,CACL,CAAC;QACJ,CAAC;QAED,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,mBAAmB,GAAG,gBAAgB;iBACzC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,KAAK,SAAS,GAAG,CAAC;iBAC1D,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,OAAO,CAAC,MAAM,CACZ,sFAAsF,mBAAmB,GAAG,EAC5G,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE;oBACzC,OAAO,QAAQ,CAAC,kBAAkB,CAChC,SAAqC,CACtC,CAAC;gBACJ,CAAC,CAAC,CAAC;gBAEH,OAAO,EAAE,QAAQ,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.result.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.result.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 `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 `The Snap requests permission for the following handlers, but does not export them: ${formattedEndowments}.`,\n ({ manifest }) => {\n unusedEndowments.forEach(([, endowment]) => {\n delete manifest.initialPermissions[\n endowment as keyof InitialPermissions\n ];\n });\n\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
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,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AED,OAAO,CACL,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC;gBACnC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,kBAAkB,CACtC,SAAqC,CACtC;gBACD,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAC3B,CAAC;QACJ,CAAC,CACF,CAAC;QAEF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,iDAAiD;YACjD,oEAAoE;YACpE,gCAAgC;YAChC,yEAAyE;YACzE,2DAA2D;YAC3D,OAAO,CAAC,MAAM,CACZ,gBAAgB,EAChB,sFAAsF,cAAc,CAAC,IAAI,CACvG,IAAI,CACL,GAAG,CACL,CAAC;QACJ,CAAC;QAED,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,mBAAmB,GAAG,gBAAgB;iBACzC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,KAAK,SAAS,GAAG,CAAC;iBAC1D,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,OAAO,CAAC,MAAM,CACZ,mBAAmB,EACnB,sFAAsF,mBAAmB,GAAG,EAC5G,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE;oBACzC,OAAO,QAAQ,CAAC,kBAAkB,CAChC,SAAqC,CACtC,CAAC;gBACJ,CAAC,CAAC,CAAC;gBAEH,OAAO,EAAE,QAAQ,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.result.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.result.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.initialPermissions[\n endowment as keyof InitialPermissions\n ];\n });\n\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
@@ -11,7 +11,7 @@ exports.versionMatch = {
|
|
|
11
11
|
const packageJsonVersion = files.packageJson.result.version;
|
|
12
12
|
const manifestPackageVersion = files.manifest.result.version;
|
|
13
13
|
if (packageJsonVersion !== manifestPackageVersion) {
|
|
14
|
-
context.report(`"${types_1.NpmSnapFileNames.Manifest}" npm package version ("${manifestPackageVersion}") does not match the "${types_1.NpmSnapFileNames.PackageJson}" "version" field ("${packageJsonVersion}").`, ({ manifest }) => {
|
|
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
15
|
manifest.version = packageJsonVersion;
|
|
16
16
|
return { manifest };
|
|
17
17
|
});
|
|
@@ -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,MAAM,CAAC,OAAO,CAAC;QAC7D,IAAI,kBAAkB,KAAK,sBAAsB,EAAE,CAAC;YAClD,OAAO,CAAC,MAAM,CACZ,IAAI,wBAAgB,CAAC,QAAQ,2BAA2B,sBAAsB,0BAA0B,wBAAgB,CAAC,WAAW,uBAAuB,kBAAkB,KAAK,EAClL,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,OAAO,GAAG,kBAAkB,CAAC;gBACtC,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.result.version;\n if (packageJsonVersion !== manifestPackageVersion) {\n context.report(\n `\"${NpmSnapFileNames.Manifest}\" npm package version (\"${manifestPackageVersion}\") does not match the \"${NpmSnapFileNames.PackageJson}\" \"version\" field (\"${packageJsonVersion}\").`,\n ({ manifest }) => {\n manifest.version = packageJsonVersion;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
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,MAAM,CAAC,OAAO,CAAC;QAC7D,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,OAAO,GAAG,kBAAkB,CAAC;gBACtC,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.result.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.version = packageJsonVersion;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-match.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/version-match.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"version-match.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/version-match.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,aAgB1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-match.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/version-match.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"version-match.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/version-match.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,aAgB1B,CAAC"}
|
|
@@ -8,7 +8,7 @@ export const versionMatch = {
|
|
|
8
8
|
const packageJsonVersion = files.packageJson.result.version;
|
|
9
9
|
const manifestPackageVersion = files.manifest.result.version;
|
|
10
10
|
if (packageJsonVersion !== manifestPackageVersion) {
|
|
11
|
-
context.report(`"${NpmSnapFileNames.Manifest}" npm package version ("${manifestPackageVersion}") does not match the "${NpmSnapFileNames.PackageJson}" "version" field ("${packageJsonVersion}").`, ({ manifest }) => {
|
|
11
|
+
context.report('version-match', `"${NpmSnapFileNames.Manifest}" npm package version ("${manifestPackageVersion}") does not match the "${NpmSnapFileNames.PackageJson}" "version" field ("${packageJsonVersion}").`, ({ manifest }) => {
|
|
12
12
|
manifest.version = packageJsonVersion;
|
|
13
13
|
return { manifest };
|
|
14
14
|
});
|
|
@@ -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,MAAM,CAAC,OAAO,CAAC;QAC7D,IAAI,kBAAkB,KAAK,sBAAsB,EAAE,CAAC;YAClD,OAAO,CAAC,MAAM,CACZ,IAAI,gBAAgB,CAAC,QAAQ,2BAA2B,sBAAsB,0BAA0B,gBAAgB,CAAC,WAAW,uBAAuB,kBAAkB,KAAK,EAClL,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,QAAQ,CAAC,OAAO,GAAG,kBAAkB,CAAC;gBACtC,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.result.version;\n if (packageJsonVersion !== manifestPackageVersion) {\n context.report(\n `\"${NpmSnapFileNames.Manifest}\" npm package version (\"${manifestPackageVersion}\") does not match the \"${NpmSnapFileNames.PackageJson}\" \"version\" field (\"${packageJsonVersion}\").`,\n ({ manifest }) => {\n manifest.version = packageJsonVersion;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
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,MAAM,CAAC,OAAO,CAAC;QAC7D,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,OAAO,GAAG,kBAAkB,CAAC;gBACtC,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.result.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.version = packageJsonVersion;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-version.cjs","sourceRoot":"","sources":["../src/platform-version.ts"],"names":[],"mappings":";;;;;;AAAA,oFAA2D;
|
|
1
|
+
{"version":3,"file":"platform-version.cjs","sourceRoot":"","sources":["../src/platform-version.ts"],"names":[],"mappings":";;;;;;AAAA,oFAA2D;AAG3D;;;;;;;;GAQG;AACH,SAAgB,kBAAkB;IAChC,OAAO,sBAAW,CAAC,OAAwB,CAAC;AAC9C,CAAC;AAFD,gDAEC","sourcesContent":["import packageJson from '@metamask/snaps-sdk/package.json';\nimport type { SemVerVersion } from '@metamask/utils';\n\n/**\n * Get the current supported platform version.\n *\n * Note: This function assumes that the same SDK version is used across all\n * dependencies. If this is not the case, the version of the SDK that is\n * closest to the `snaps-utils` package will be returned.\n *\n * @returns The platform version.\n */\nexport function getPlatformVersion() {\n return packageJson.version as SemVerVersion;\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SemVerVersion } from "@metamask/utils";
|
|
1
2
|
/**
|
|
2
3
|
* Get the current supported platform version.
|
|
3
4
|
*
|
|
@@ -7,5 +8,5 @@
|
|
|
7
8
|
*
|
|
8
9
|
* @returns The platform version.
|
|
9
10
|
*/
|
|
10
|
-
export declare function getPlatformVersion():
|
|
11
|
+
export declare function getPlatformVersion(): SemVerVersion;
|
|
11
12
|
//# sourceMappingURL=platform-version.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-version.d.cts","sourceRoot":"","sources":["../src/platform-version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platform-version.d.cts","sourceRoot":"","sources":["../src/platform-version.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,kBAEjC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SemVerVersion } from "@metamask/utils";
|
|
1
2
|
/**
|
|
2
3
|
* Get the current supported platform version.
|
|
3
4
|
*
|
|
@@ -7,5 +8,5 @@
|
|
|
7
8
|
*
|
|
8
9
|
* @returns The platform version.
|
|
9
10
|
*/
|
|
10
|
-
export declare function getPlatformVersion():
|
|
11
|
+
export declare function getPlatformVersion(): SemVerVersion;
|
|
11
12
|
//# sourceMappingURL=platform-version.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-version.d.mts","sourceRoot":"","sources":["../src/platform-version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platform-version.d.mts","sourceRoot":"","sources":["../src/platform-version.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,kBAEjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-version.mjs","sourceRoot":"","sources":["../src/platform-version.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,+DAAyC;
|
|
1
|
+
{"version":3,"file":"platform-version.mjs","sourceRoot":"","sources":["../src/platform-version.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,+DAAyC;AAG3D;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,WAAW,CAAC,OAAwB,CAAC;AAC9C,CAAC","sourcesContent":["import packageJson from '@metamask/snaps-sdk/package.json';\nimport type { SemVerVersion } from '@metamask/utils';\n\n/**\n * Get the current supported platform version.\n *\n * Note: This function assumes that the same SDK version is used across all\n * dependencies. If this is not the case, the version of the SDK that is\n * closest to the `snaps-utils` package will be returned.\n *\n * @returns The platform version.\n */\nexport function getPlatformVersion() {\n return packageJson.version as SemVerVersion;\n}\n"]}
|