@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.
Files changed (116) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/dist/checksum.cjs +1 -9
  3. package/dist/checksum.cjs.map +1 -1
  4. package/dist/checksum.d.cts.map +1 -1
  5. package/dist/checksum.d.mts.map +1 -1
  6. package/dist/checksum.mjs +2 -10
  7. package/dist/checksum.mjs.map +1 -1
  8. package/dist/handlers/assets-market-data.cjs +2 -2
  9. package/dist/handlers/assets-market-data.cjs.map +1 -1
  10. package/dist/handlers/assets-market-data.d.cts +2 -2
  11. package/dist/handlers/assets-market-data.d.mts +2 -2
  12. package/dist/handlers/assets-market-data.mjs +2 -2
  13. package/dist/handlers/assets-market-data.mjs.map +1 -1
  14. package/dist/iframe.cjs +1 -1
  15. package/dist/iframe.cjs.map +1 -1
  16. package/dist/iframe.d.cts.map +1 -1
  17. package/dist/iframe.d.mts.map +1 -1
  18. package/dist/iframe.mjs +1 -1
  19. package/dist/iframe.mjs.map +1 -1
  20. package/dist/localization.d.cts +1 -0
  21. package/dist/localization.d.cts.map +1 -1
  22. package/dist/localization.d.mts +1 -0
  23. package/dist/localization.d.mts.map +1 -1
  24. package/dist/manifest/manifest.cjs +99 -27
  25. package/dist/manifest/manifest.cjs.map +1 -1
  26. package/dist/manifest/manifest.d.cts +18 -5
  27. package/dist/manifest/manifest.d.cts.map +1 -1
  28. package/dist/manifest/manifest.d.mts +18 -5
  29. package/dist/manifest/manifest.d.mts.map +1 -1
  30. package/dist/manifest/manifest.mjs +106 -28
  31. package/dist/manifest/manifest.mjs.map +1 -1
  32. package/dist/manifest/validation.cjs +1 -0
  33. package/dist/manifest/validation.cjs.map +1 -1
  34. package/dist/manifest/validation.d.cts +2 -0
  35. package/dist/manifest/validation.d.cts.map +1 -1
  36. package/dist/manifest/validation.d.mts +2 -0
  37. package/dist/manifest/validation.d.mts.map +1 -1
  38. package/dist/manifest/validation.mjs +1 -0
  39. package/dist/manifest/validation.mjs.map +1 -1
  40. package/dist/manifest/validator-types.cjs.map +1 -1
  41. package/dist/manifest/validator-types.d.cts +4 -5
  42. package/dist/manifest/validator-types.d.cts.map +1 -1
  43. package/dist/manifest/validator-types.d.mts +4 -5
  44. package/dist/manifest/validator-types.d.mts.map +1 -1
  45. package/dist/manifest/validator-types.mjs.map +1 -1
  46. package/dist/manifest/validator.cjs +1 -1
  47. package/dist/manifest/validator.cjs.map +1 -1
  48. package/dist/manifest/validator.d.cts +3 -3
  49. package/dist/manifest/validator.d.cts.map +1 -1
  50. package/dist/manifest/validator.d.mts +3 -3
  51. package/dist/manifest/validator.d.mts.map +1 -1
  52. package/dist/manifest/validator.mjs +1 -1
  53. package/dist/manifest/validator.mjs.map +1 -1
  54. package/dist/manifest/validators/checksum.cjs +11 -3
  55. package/dist/manifest/validators/checksum.cjs.map +1 -1
  56. package/dist/manifest/validators/checksum.d.cts.map +1 -1
  57. package/dist/manifest/validators/checksum.d.mts.map +1 -1
  58. package/dist/manifest/validators/checksum.mjs +11 -3
  59. package/dist/manifest/validators/checksum.mjs.map +1 -1
  60. package/dist/manifest/validators/icon-declared.cjs +1 -1
  61. package/dist/manifest/validators/icon-declared.cjs.map +1 -1
  62. package/dist/manifest/validators/icon-declared.mjs +1 -1
  63. package/dist/manifest/validators/icon-declared.mjs.map +1 -1
  64. package/dist/manifest/validators/icon-missing.cjs +1 -1
  65. package/dist/manifest/validators/icon-missing.cjs.map +1 -1
  66. package/dist/manifest/validators/icon-missing.d.cts.map +1 -1
  67. package/dist/manifest/validators/icon-missing.d.mts.map +1 -1
  68. package/dist/manifest/validators/icon-missing.mjs +1 -1
  69. package/dist/manifest/validators/icon-missing.mjs.map +1 -1
  70. package/dist/manifest/validators/is-snap-manifest.cjs +1 -1
  71. package/dist/manifest/validators/is-snap-manifest.cjs.map +1 -1
  72. package/dist/manifest/validators/is-snap-manifest.mjs +1 -1
  73. package/dist/manifest/validators/is-snap-manifest.mjs.map +1 -1
  74. package/dist/manifest/validators/manifest-localization.cjs +1 -1
  75. package/dist/manifest/validators/manifest-localization.cjs.map +1 -1
  76. package/dist/manifest/validators/manifest-localization.mjs +1 -1
  77. package/dist/manifest/validators/manifest-localization.mjs.map +1 -1
  78. package/dist/manifest/validators/package-name-match.cjs +6 -2
  79. package/dist/manifest/validators/package-name-match.cjs.map +1 -1
  80. package/dist/manifest/validators/package-name-match.d.cts.map +1 -1
  81. package/dist/manifest/validators/package-name-match.d.mts.map +1 -1
  82. package/dist/manifest/validators/package-name-match.mjs +6 -2
  83. package/dist/manifest/validators/package-name-match.mjs.map +1 -1
  84. package/dist/manifest/validators/platform-version.cjs +4 -4
  85. package/dist/manifest/validators/platform-version.cjs.map +1 -1
  86. package/dist/manifest/validators/platform-version.d.cts.map +1 -1
  87. package/dist/manifest/validators/platform-version.d.mts.map +1 -1
  88. package/dist/manifest/validators/platform-version.mjs +4 -4
  89. package/dist/manifest/validators/platform-version.mjs.map +1 -1
  90. package/dist/manifest/validators/production-platform-version.cjs +1 -1
  91. package/dist/manifest/validators/production-platform-version.cjs.map +1 -1
  92. package/dist/manifest/validators/production-platform-version.d.cts.map +1 -1
  93. package/dist/manifest/validators/production-platform-version.d.mts.map +1 -1
  94. package/dist/manifest/validators/production-platform-version.mjs +1 -1
  95. package/dist/manifest/validators/production-platform-version.mjs.map +1 -1
  96. package/dist/manifest/validators/repository-match.cjs +2 -2
  97. package/dist/manifest/validators/repository-match.cjs.map +1 -1
  98. package/dist/manifest/validators/repository-match.d.cts.map +1 -1
  99. package/dist/manifest/validators/repository-match.d.mts.map +1 -1
  100. package/dist/manifest/validators/repository-match.mjs +2 -2
  101. package/dist/manifest/validators/repository-match.mjs.map +1 -1
  102. package/dist/manifest/validators/unused-exports.cjs +3 -3
  103. package/dist/manifest/validators/unused-exports.cjs.map +1 -1
  104. package/dist/manifest/validators/unused-exports.mjs +3 -3
  105. package/dist/manifest/validators/unused-exports.mjs.map +1 -1
  106. package/dist/manifest/validators/version-match.cjs +2 -2
  107. package/dist/manifest/validators/version-match.cjs.map +1 -1
  108. package/dist/manifest/validators/version-match.mjs +2 -2
  109. package/dist/manifest/validators/version-match.mjs.map +1 -1
  110. package/dist/types.cjs.map +1 -1
  111. package/dist/types.d.cts +66 -1
  112. package/dist/types.d.cts.map +1 -1
  113. package/dist/types.d.mts +66 -1
  114. package/dist/types.d.mts.map +1 -1
  115. package/dist/types.mjs.map +1 -1
  116. package/package.json +5 -6
@@ -4,7 +4,7 @@
4
4
  export const iconDeclared = {
5
5
  severity: 'warning',
6
6
  semanticCheck(files, context) {
7
- if (!files.manifest.result.source.location.npm.iconPath) {
7
+ if (!files.manifest.mergedManifest.source?.location?.npm?.iconPath) {
8
8
  context.report('icon-declared', 'No icon found in the Snap manifest. It is recommended to include an icon for the Snap. See https://docs.metamask.io/snaps/how-to/design-a-snap/#guidelines-at-a-glance for more information.');
9
9
  }
10
10
  },
@@ -1 +1 @@
1
- {"version":3,"file":"icon-declared.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/icon-declared.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB;IACzC,QAAQ,EAAE,SAAS;IACnB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YACxD,OAAO,CAAC,MAAM,CACZ,eAAe,EACf,8LAA8L,CAC/L,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type { ValidatorMeta } from '../validator-types';\n\n/**\n * Suggest including an icon if not found in manifest.\n */\nexport const iconDeclared: ValidatorMeta = {\n severity: 'warning',\n semanticCheck(files, context) {\n if (!files.manifest.result.source.location.npm.iconPath) {\n context.report(\n 'icon-declared',\n 'No icon found in the Snap manifest. It is recommended to include an icon for the Snap. See https://docs.metamask.io/snaps/how-to/design-a-snap/#guidelines-at-a-glance for more information.',\n );\n }\n },\n};\n"]}
1
+ {"version":3,"file":"icon-declared.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/icon-declared.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB;IACzC,QAAQ,EAAE,SAAS;IACnB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;YACnE,OAAO,CAAC,MAAM,CACZ,eAAe,EACf,8LAA8L,CAC/L,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type { ValidatorMeta } from '../validator-types';\n\n/**\n * Suggest including an icon if not found in manifest.\n */\nexport const iconDeclared: ValidatorMeta = {\n severity: 'warning',\n semanticCheck(files, context) {\n if (!files.manifest.mergedManifest.source?.location?.npm?.iconPath) {\n context.report(\n 'icon-declared',\n 'No icon found in the Snap manifest. It is recommended to include an icon for the Snap. See https://docs.metamask.io/snaps/how-to/design-a-snap/#guidelines-at-a-glance for more information.',\n );\n }\n },\n};\n"]}
@@ -7,7 +7,7 @@ exports.iconMissing = void 0;
7
7
  exports.iconMissing = {
8
8
  severity: 'error',
9
9
  semanticCheck(files, context) {
10
- const { iconPath } = files.manifest.result.source.location.npm;
10
+ const iconPath = files.manifest.mergedManifest.source?.location?.npm?.iconPath;
11
11
  if (iconPath && !files.svgIcon) {
12
12
  context.report('icon-missing', `Could not find icon "${iconPath}".`);
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"icon-missing.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/icon-missing.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACU,QAAA,WAAW,GAAkB;IACxC,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC/D,IAAI,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/B,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,wBAAwB,QAAQ,IAAI,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if declared icon exists on filesystem.\n */\nexport const iconMissing: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const { iconPath } = files.manifest.result.source.location.npm;\n if (iconPath && !files.svgIcon) {\n context.report('icon-missing', `Could not find icon \"${iconPath}\".`);\n }\n },\n};\n"]}
1
+ {"version":3,"file":"icon-missing.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/icon-missing.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACU,QAAA,WAAW,GAAkB;IACxC,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,QAAQ,GACZ,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,CAAC;QAEhE,IAAI,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/B,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,wBAAwB,QAAQ,IAAI,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if declared icon exists on filesystem.\n */\nexport const iconMissing: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const iconPath =\n files.manifest.mergedManifest.source?.location?.npm?.iconPath;\n\n if (iconPath && !files.svgIcon) {\n context.report('icon-missing', `Could not find icon \"${iconPath}\".`);\n }\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"icon-missing.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/icon-missing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,aAQzB,CAAC"}
1
+ {"version":3,"file":"icon-missing.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/icon-missing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,aAUzB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"icon-missing.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/icon-missing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,aAQzB,CAAC"}
1
+ {"version":3,"file":"icon-missing.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/icon-missing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,aAUzB,CAAC"}
@@ -4,7 +4,7 @@
4
4
  export const iconMissing = {
5
5
  severity: 'error',
6
6
  semanticCheck(files, context) {
7
- const { iconPath } = files.manifest.result.source.location.npm;
7
+ const iconPath = files.manifest.mergedManifest.source?.location?.npm?.iconPath;
8
8
  if (iconPath && !files.svgIcon) {
9
9
  context.report('icon-missing', `Could not find icon "${iconPath}".`);
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"icon-missing.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/icon-missing.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAkB;IACxC,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC/D,IAAI,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/B,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,wBAAwB,QAAQ,IAAI,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if declared icon exists on filesystem.\n */\nexport const iconMissing: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const { iconPath } = files.manifest.result.source.location.npm;\n if (iconPath && !files.svgIcon) {\n context.report('icon-missing', `Could not find icon \"${iconPath}\".`);\n }\n },\n};\n"]}
1
+ {"version":3,"file":"icon-missing.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/icon-missing.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAkB;IACxC,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,QAAQ,GACZ,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,CAAC;QAEhE,IAAI,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/B,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,wBAAwB,QAAQ,IAAI,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if declared icon exists on filesystem.\n */\nexport const iconMissing: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const iconPath =\n files.manifest.mergedManifest.source?.location?.npm?.iconPath;\n\n if (iconPath && !files.svgIcon) {\n context.report('icon-missing', `Could not find icon \"${iconPath}\".`);\n }\n },\n};\n"]}
@@ -14,7 +14,7 @@ exports.isSnapManifest = {
14
14
  if (!files.manifest) {
15
15
  return;
16
16
  }
17
- const [error] = (0, superstruct_1.validate)(files.manifest.result, validation_1.SnapManifestStruct);
17
+ const [error] = (0, superstruct_1.validate)(files.manifest.mergedManifest, validation_1.SnapManifestStruct);
18
18
  if (error) {
19
19
  for (const failure of error.failures()) {
20
20
  context.report(`is-snap-manifest-${failure.type}-${failure.path.join('-')}`, `"${types_1.NpmSnapFileNames.Manifest}" is invalid: ${(0, structs_1.getStructFailureMessage)(validation_1.SnapManifestStruct, failure, false)}`);
@@ -1 +1 @@
1
- {"version":3,"file":"is-snap-manifest.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/is-snap-manifest.ts"],"names":[],"mappings":";;;AAAA,uDAAiD;AAEjD,+CAAwD;AACxD,2CAA+C;AAC/C,kDAAmD;AAGnD;;GAEG;AACU,QAAA,cAAc,GAAkB;IAC3C,QAAQ,EAAE,OAAO;IACjB,cAAc,CAAC,KAAK,EAAE,OAAO;QAC3B,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAA,sBAAQ,EAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,+BAAkB,CAAC,CAAC;QACpE,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;gBACvC,OAAO,CAAC,MAAM,CACZ,oBAAoB,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAC5D,IAAI,wBAAgB,CAAC,QAAQ,iBAAiB,IAAA,iCAAuB,EACnE,+BAAkB,EAClB,OAAO,EACP,KAAK,CACN,EAAE,CACJ,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { validate } from '@metamask/superstruct';\n\nimport { getStructFailureMessage } from '../../structs';\nimport { NpmSnapFileNames } from '../../types';\nimport { SnapManifestStruct } from '../validation';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify the structure of snap.manifest.json.\n */\nexport const isSnapManifest: ValidatorMeta = {\n severity: 'error',\n structureCheck(files, context) {\n if (!files.manifest) {\n return;\n }\n const [error] = validate(files.manifest.result, SnapManifestStruct);\n if (error) {\n for (const failure of error.failures()) {\n context.report(\n `is-snap-manifest-${failure.type}-${failure.path.join('-')}`,\n `\"${NpmSnapFileNames.Manifest}\" is invalid: ${getStructFailureMessage(\n SnapManifestStruct,\n failure,\n false,\n )}`,\n );\n }\n }\n },\n};\n"]}
1
+ {"version":3,"file":"is-snap-manifest.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/is-snap-manifest.ts"],"names":[],"mappings":";;;AAAA,uDAAiD;AAEjD,+CAAwD;AACxD,2CAA+C;AAC/C,kDAAmD;AAGnD;;GAEG;AACU,QAAA,cAAc,GAAkB;IAC3C,QAAQ,EAAE,OAAO;IACjB,cAAc,CAAC,KAAK,EAAE,OAAO;QAC3B,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAA,sBAAQ,EAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,EAAE,+BAAkB,CAAC,CAAC;QAC5E,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;gBACvC,OAAO,CAAC,MAAM,CACZ,oBAAoB,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAC5D,IAAI,wBAAgB,CAAC,QAAQ,iBAAiB,IAAA,iCAAuB,EACnE,+BAAkB,EAClB,OAAO,EACP,KAAK,CACN,EAAE,CACJ,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { validate } from '@metamask/superstruct';\n\nimport { getStructFailureMessage } from '../../structs';\nimport { NpmSnapFileNames } from '../../types';\nimport { SnapManifestStruct } from '../validation';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify the structure of snap.manifest.json.\n */\nexport const isSnapManifest: ValidatorMeta = {\n severity: 'error',\n structureCheck(files, context) {\n if (!files.manifest) {\n return;\n }\n const [error] = validate(files.manifest.mergedManifest, SnapManifestStruct);\n if (error) {\n for (const failure of error.failures()) {\n context.report(\n `is-snap-manifest-${failure.type}-${failure.path.join('-')}`,\n `\"${NpmSnapFileNames.Manifest}\" is invalid: ${getStructFailureMessage(\n SnapManifestStruct,\n failure,\n false,\n )}`,\n );\n }\n }\n },\n};\n"]}
@@ -11,7 +11,7 @@ export const isSnapManifest = {
11
11
  if (!files.manifest) {
12
12
  return;
13
13
  }
14
- const [error] = validate(files.manifest.result, SnapManifestStruct);
14
+ const [error] = validate(files.manifest.mergedManifest, SnapManifestStruct);
15
15
  if (error) {
16
16
  for (const failure of error.failures()) {
17
17
  context.report(`is-snap-manifest-${failure.type}-${failure.path.join('-')}`, `"${NpmSnapFileNames.Manifest}" is invalid: ${getStructFailureMessage(SnapManifestStruct, failure, false)}`);
@@ -1 +1 @@
1
- {"version":3,"file":"is-snap-manifest.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/is-snap-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AAEjD,OAAO,EAAE,uBAAuB,EAAE,0BAAsB;AACxD,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAC/C,OAAO,EAAE,kBAAkB,EAAE,0BAAsB;AAGnD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB;IAC3C,QAAQ,EAAE,OAAO;IACjB,cAAc,CAAC,KAAK,EAAE,OAAO;QAC3B,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;QACpE,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;gBACvC,OAAO,CAAC,MAAM,CACZ,oBAAoB,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAC5D,IAAI,gBAAgB,CAAC,QAAQ,iBAAiB,uBAAuB,CACnE,kBAAkB,EAClB,OAAO,EACP,KAAK,CACN,EAAE,CACJ,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { validate } from '@metamask/superstruct';\n\nimport { getStructFailureMessage } from '../../structs';\nimport { NpmSnapFileNames } from '../../types';\nimport { SnapManifestStruct } from '../validation';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify the structure of snap.manifest.json.\n */\nexport const isSnapManifest: ValidatorMeta = {\n severity: 'error',\n structureCheck(files, context) {\n if (!files.manifest) {\n return;\n }\n const [error] = validate(files.manifest.result, SnapManifestStruct);\n if (error) {\n for (const failure of error.failures()) {\n context.report(\n `is-snap-manifest-${failure.type}-${failure.path.join('-')}`,\n `\"${NpmSnapFileNames.Manifest}\" is invalid: ${getStructFailureMessage(\n SnapManifestStruct,\n failure,\n false,\n )}`,\n );\n }\n }\n },\n};\n"]}
1
+ {"version":3,"file":"is-snap-manifest.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/is-snap-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AAEjD,OAAO,EAAE,uBAAuB,EAAE,0BAAsB;AACxD,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAC/C,OAAO,EAAE,kBAAkB,EAAE,0BAAsB;AAGnD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB;IAC3C,QAAQ,EAAE,OAAO;IACjB,cAAc,CAAC,KAAK,EAAE,OAAO;QAC3B,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAC5E,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;gBACvC,OAAO,CAAC,MAAM,CACZ,oBAAoB,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAC5D,IAAI,gBAAgB,CAAC,QAAQ,iBAAiB,uBAAuB,CACnE,kBAAkB,EAClB,OAAO,EACP,KAAK,CACN,EAAE,CACJ,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { validate } from '@metamask/superstruct';\n\nimport { getStructFailureMessage } from '../../structs';\nimport { NpmSnapFileNames } from '../../types';\nimport { SnapManifestStruct } from '../validation';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify the structure of snap.manifest.json.\n */\nexport const isSnapManifest: ValidatorMeta = {\n severity: 'error',\n structureCheck(files, context) {\n if (!files.manifest) {\n return;\n }\n const [error] = validate(files.manifest.mergedManifest, SnapManifestStruct);\n if (error) {\n for (const failure of error.failures()) {\n context.report(\n `is-snap-manifest-${failure.type}-${failure.path.join('-')}`,\n `\"${NpmSnapFileNames.Manifest}\" is invalid: ${getStructFailureMessage(\n SnapManifestStruct,\n failure,\n false,\n )}`,\n );\n }\n }\n },\n};\n"]}
@@ -9,7 +9,7 @@ const localization_1 = require("../../localization.cjs");
9
9
  exports.manifestLocalization = {
10
10
  severity: 'error',
11
11
  semanticCheck(files, context) {
12
- const manifest = files.manifest.result;
12
+ const manifest = files.manifest.mergedManifest;
13
13
  const localizations = files.localizationFiles.map((file) => file.result);
14
14
  const locales = [
15
15
  'en', // The manifest must be able to be localized in English.
@@ -1 +1 @@
1
- {"version":3,"file":"manifest-localization.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/manifest-localization.ts"],"names":[],"mappings":";;;AAAA,mDAAsD;AAGtD,yDAA8D;AAG9D;;GAEG;AACU,QAAA,oBAAoB,GAAkB;IACjD,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QACvC,MAAM,aAAa,GAAuB,KAAK,CAAC,iBAAiB,CAAC,GAAG,CACnE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CACtB,CAAC;QACF,MAAM,OAAO,GAAG;YACd,IAAI,EAAE,wDAAwD;YAC9D,GAAG,aAAa;iBACb,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC;iBAC3B,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC;SACvC,CAAC;QAEF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACH,IAAA,uCAAwB,EAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;YAC5D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,MAAM,CACZ,uBAAuB,EACvB,qCAAqC,IAAA,2BAAe,EAAC,KAAK,CAAC,EAAE,CAC9D,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { getErrorMessage } from '@metamask/snaps-sdk';\n\nimport type { LocalizationFile } from '../../localization';\nimport { getLocalizedSnapManifest } from '../../localization';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify whether the localization files localize the manifest correctly.\n */\nexport const manifestLocalization: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const manifest = files.manifest.result;\n const localizations: LocalizationFile[] = files.localizationFiles.map(\n (file) => file.result,\n );\n const locales = [\n 'en', // The manifest must be able to be localized in English.\n ...localizations\n .map(({ locale }) => locale)\n .filter((locale) => locale !== 'en'),\n ];\n\n for (const locale of locales) {\n try {\n getLocalizedSnapManifest(manifest, locale, localizations);\n } catch (error) {\n context.report(\n 'manifest-localization',\n `Failed to localize Snap manifest: ${getErrorMessage(error)}`,\n );\n }\n }\n },\n};\n"]}
1
+ {"version":3,"file":"manifest-localization.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/manifest-localization.ts"],"names":[],"mappings":";;;AAAA,mDAAsD;AAGtD,yDAA8D;AAG9D;;GAEG;AACU,QAAA,oBAAoB,GAAkB;IACjD,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC/C,MAAM,aAAa,GAAuB,KAAK,CAAC,iBAAiB,CAAC,GAAG,CACnE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CACtB,CAAC;QACF,MAAM,OAAO,GAAG;YACd,IAAI,EAAE,wDAAwD;YAC9D,GAAG,aAAa;iBACb,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC;iBAC3B,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC;SACvC,CAAC;QAEF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACH,IAAA,uCAAwB,EAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;YAC5D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,MAAM,CACZ,uBAAuB,EACvB,qCAAqC,IAAA,2BAAe,EAAC,KAAK,CAAC,EAAE,CAC9D,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { getErrorMessage } from '@metamask/snaps-sdk';\n\nimport type { LocalizationFile } from '../../localization';\nimport { getLocalizedSnapManifest } from '../../localization';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify whether the localization files localize the manifest correctly.\n */\nexport const manifestLocalization: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const manifest = files.manifest.mergedManifest;\n const localizations: LocalizationFile[] = files.localizationFiles.map(\n (file) => file.result,\n );\n const locales = [\n 'en', // The manifest must be able to be localized in English.\n ...localizations\n .map(({ locale }) => locale)\n .filter((locale) => locale !== 'en'),\n ];\n\n for (const locale of locales) {\n try {\n getLocalizedSnapManifest(manifest, locale, localizations);\n } catch (error) {\n context.report(\n 'manifest-localization',\n `Failed to localize Snap manifest: ${getErrorMessage(error)}`,\n );\n }\n }\n },\n};\n"]}
@@ -6,7 +6,7 @@ import { getLocalizedSnapManifest } from "../../localization.mjs";
6
6
  export const manifestLocalization = {
7
7
  severity: 'error',
8
8
  semanticCheck(files, context) {
9
- const manifest = files.manifest.result;
9
+ const manifest = files.manifest.mergedManifest;
10
10
  const localizations = files.localizationFiles.map((file) => file.result);
11
11
  const locales = [
12
12
  'en', // The manifest must be able to be localized in English.
@@ -1 +1 @@
1
- {"version":3,"file":"manifest-localization.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/manifest-localization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,4BAA4B;AAGtD,OAAO,EAAE,wBAAwB,EAAE,+BAA2B;AAG9D;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAkB;IACjD,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QACvC,MAAM,aAAa,GAAuB,KAAK,CAAC,iBAAiB,CAAC,GAAG,CACnE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CACtB,CAAC;QACF,MAAM,OAAO,GAAG;YACd,IAAI,EAAE,wDAAwD;YAC9D,GAAG,aAAa;iBACb,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC;iBAC3B,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC;SACvC,CAAC;QAEF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACH,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;YAC5D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,MAAM,CACZ,uBAAuB,EACvB,qCAAqC,eAAe,CAAC,KAAK,CAAC,EAAE,CAC9D,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { getErrorMessage } from '@metamask/snaps-sdk';\n\nimport type { LocalizationFile } from '../../localization';\nimport { getLocalizedSnapManifest } from '../../localization';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify whether the localization files localize the manifest correctly.\n */\nexport const manifestLocalization: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const manifest = files.manifest.result;\n const localizations: LocalizationFile[] = files.localizationFiles.map(\n (file) => file.result,\n );\n const locales = [\n 'en', // The manifest must be able to be localized in English.\n ...localizations\n .map(({ locale }) => locale)\n .filter((locale) => locale !== 'en'),\n ];\n\n for (const locale of locales) {\n try {\n getLocalizedSnapManifest(manifest, locale, localizations);\n } catch (error) {\n context.report(\n 'manifest-localization',\n `Failed to localize Snap manifest: ${getErrorMessage(error)}`,\n );\n }\n }\n },\n};\n"]}
1
+ {"version":3,"file":"manifest-localization.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/manifest-localization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,4BAA4B;AAGtD,OAAO,EAAE,wBAAwB,EAAE,+BAA2B;AAG9D;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAkB;IACjD,QAAQ,EAAE,OAAO;IACjB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC/C,MAAM,aAAa,GAAuB,KAAK,CAAC,iBAAiB,CAAC,GAAG,CACnE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CACtB,CAAC;QACF,MAAM,OAAO,GAAG;YACd,IAAI,EAAE,wDAAwD;YAC9D,GAAG,aAAa;iBACb,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC;iBAC3B,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC;SACvC,CAAC;QAEF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACH,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;YAC5D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,MAAM,CACZ,uBAAuB,EACvB,qCAAqC,eAAe,CAAC,KAAK,CAAC,EAAE,CAC9D,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { getErrorMessage } from '@metamask/snaps-sdk';\n\nimport type { LocalizationFile } from '../../localization';\nimport { getLocalizedSnapManifest } from '../../localization';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify whether the localization files localize the manifest correctly.\n */\nexport const manifestLocalization: ValidatorMeta = {\n severity: 'error',\n semanticCheck(files, context) {\n const manifest = files.manifest.mergedManifest;\n const localizations: LocalizationFile[] = files.localizationFiles.map(\n (file) => file.result,\n );\n const locales = [\n 'en', // The manifest must be able to be localized in English.\n ...localizations\n .map(({ locale }) => locale)\n .filter((locale) => locale !== 'en'),\n ];\n\n for (const locale of locales) {\n try {\n getLocalizedSnapManifest(manifest, locale, localizations);\n } catch (error) {\n context.report(\n 'manifest-localization',\n `Failed to localize Snap manifest: ${getErrorMessage(error)}`,\n );\n }\n }\n },\n};\n"]}
@@ -9,10 +9,14 @@ exports.packageNameMatch = {
9
9
  severity: 'error',
10
10
  semanticCheck(files, context) {
11
11
  const packageJsonName = files.packageJson.result.name;
12
- const manifestPackageName = files.manifest.result.source.location.npm.packageName;
12
+ const manifestPackageName = files.manifest.mergedManifest.source?.location?.npm?.packageName;
13
13
  if (packageJsonName !== manifestPackageName) {
14
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
- manifest.source.location.npm.packageName = packageJsonName;
15
+ manifest.mainManifest.result.source ??= {};
16
+ manifest.mainManifest.result.source.location ??= {};
17
+ manifest.mainManifest.result.source.location.npm ??= {};
18
+ manifest.mainManifest.result.source.location.npm.packageName =
19
+ packageJsonName;
16
20
  return { manifest };
17
21
  });
18
22
  }
@@ -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,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
+ {"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,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,CAAC;QACnE,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,YAAY,CAAC,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC;gBAC3C,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,KAAK,EAAE,CAAC;gBACpD,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,KAAK,EAAE,CAAC;gBACxD,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW;oBAC1D,eAAe,CAAC;gBAElB,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.mergedManifest.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.mainManifest.result.source ??= {};\n manifest.mainManifest.result.source.location ??= {};\n manifest.mainManifest.result.source.location.npm ??= {};\n manifest.mainManifest.result.source.location.npm.packageName =\n packageJsonName;\n\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,aAiB9B,CAAC"}
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,aAsB9B,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,aAiB9B,CAAC"}
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,aAsB9B,CAAC"}
@@ -6,10 +6,14 @@ export const packageNameMatch = {
6
6
  severity: 'error',
7
7
  semanticCheck(files, context) {
8
8
  const packageJsonName = files.packageJson.result.name;
9
- const manifestPackageName = files.manifest.result.source.location.npm.packageName;
9
+ const manifestPackageName = files.manifest.mergedManifest.source?.location?.npm?.packageName;
10
10
  if (packageJsonName !== manifestPackageName) {
11
11
  context.report('package-name-match', `"${NpmSnapFileNames.Manifest}" npm package name ("${manifestPackageName}") does not match the "${NpmSnapFileNames.PackageJson}" "name" field ("${packageJsonName}").`, ({ manifest }) => {
12
- manifest.source.location.npm.packageName = packageJsonName;
12
+ manifest.mainManifest.result.source ??= {};
13
+ manifest.mainManifest.result.source.location ??= {};
14
+ manifest.mainManifest.result.source.location.npm ??= {};
15
+ manifest.mainManifest.result.source.location.npm.packageName =
16
+ packageJsonName;
13
17
  return { manifest };
14
18
  });
15
19
  }
@@ -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,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"]}
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,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,CAAC;QACnE,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,YAAY,CAAC,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC;gBAC3C,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,KAAK,EAAE,CAAC;gBACpD,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,KAAK,EAAE,CAAC;gBACxD,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW;oBAC1D,eAAe,CAAC;gBAElB,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.mergedManifest.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.mainManifest.result.source ??= {};\n manifest.mainManifest.result.source.location ??= {};\n manifest.mainManifest.result.source.location.npm ??= {};\n manifest.mainManifest.result.source.location.npm.packageName =\n packageJsonName;\n\n return { manifest };\n },\n );\n }\n },\n};\n"]}
@@ -9,23 +9,23 @@ const module_1 = require("module");
9
9
  exports.platformVersion = {
10
10
  severity: 'error',
11
11
  async semanticCheck(files, context) {
12
- const manifestPlatformVersion = files.manifest.result.platformVersion;
12
+ const manifestPlatformVersion = files.manifest.mergedManifest.platformVersion;
13
13
  // Create a require function in the context of the location of the manifest
14
14
  // file to avoid potentially loading the wrong version of the Snaps SDK.
15
- const require = (0, module_1.createRequire)(files.manifest.path);
15
+ const require = (0, module_1.createRequire)(files.manifest.mainManifest.path);
16
16
  const packageJson = require.resolve('@metamask/snaps-sdk/package.json');
17
17
  // eslint-disable-next-line import-x/no-dynamic-require
18
18
  const actualVersion = require(packageJson).version;
19
19
  if (!manifestPlatformVersion) {
20
20
  context.report('platform-version-missing', 'The "platformVersion" field is missing from the manifest.', ({ manifest }) => {
21
- manifest.platformVersion = actualVersion;
21
+ manifest.mainManifest.result.platformVersion = actualVersion;
22
22
  return { manifest };
23
23
  });
24
24
  return;
25
25
  }
26
26
  if (manifestPlatformVersion !== actualVersion) {
27
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
- manifest.platformVersion = actualVersion;
28
+ manifest.mainManifest.result.platformVersion = actualVersion;
29
29
  return { manifest };
30
30
  });
31
31
  }
@@ -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,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
+ {"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,GAC3B,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,eAAe,CAAC;QAEhD,2EAA2E;QAC3E,wEAAwE;QACxE,MAAM,OAAO,GAAG,IAAA,sBAAa,EAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAEhE,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,YAAY,CAAC,MAAM,CAAC,eAAe,GAAG,aAAa,CAAC;gBAC7D,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,YAAY,CAAC,MAAM,CAAC,eAAe,GAAG,aAAa,CAAC;gBAC7D,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 =\n files.manifest.mergedManifest.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.mainManifest.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.mainManifest.result.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.mainManifest.result.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,aAqC7B,CAAC"}
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,aAsC7B,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,aAqC7B,CAAC"}
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,aAsC7B,CAAC"}
@@ -6,23 +6,23 @@ import { createRequire } from "module";
6
6
  export const platformVersion = {
7
7
  severity: 'error',
8
8
  async semanticCheck(files, context) {
9
- const manifestPlatformVersion = files.manifest.result.platformVersion;
9
+ const manifestPlatformVersion = files.manifest.mergedManifest.platformVersion;
10
10
  // Create a require function in the context of the location of the manifest
11
11
  // file to avoid potentially loading the wrong version of the Snaps SDK.
12
- const require = createRequire(files.manifest.path);
12
+ const require = createRequire(files.manifest.mainManifest.path);
13
13
  const packageJson = require.resolve('@metamask/snaps-sdk/package.json');
14
14
  // eslint-disable-next-line import-x/no-dynamic-require
15
15
  const actualVersion = require(packageJson).version;
16
16
  if (!manifestPlatformVersion) {
17
17
  context.report('platform-version-missing', 'The "platformVersion" field is missing from the manifest.', ({ manifest }) => {
18
- manifest.platformVersion = actualVersion;
18
+ manifest.mainManifest.result.platformVersion = actualVersion;
19
19
  return { manifest };
20
20
  });
21
21
  return;
22
22
  }
23
23
  if (manifestPlatformVersion !== actualVersion) {
24
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
- manifest.platformVersion = actualVersion;
25
+ manifest.mainManifest.result.platformVersion = actualVersion;
26
26
  return { manifest };
27
27
  });
28
28
  }
@@ -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,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};\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AC","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 =\n files.manifest.mergedManifest.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.mainManifest.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.mainManifest.result.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.mainManifest.result.platformVersion = actualVersion;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
@@ -31,7 +31,7 @@ const determineProductionVersion = (0, fs_1.useFileSystemCache)('snaps-productio
31
31
  exports.productionPlatformVersion = {
32
32
  severity: 'warning',
33
33
  async semanticCheck(files, context) {
34
- const manifestPlatformVersion = files.manifest.result.platformVersion;
34
+ const manifestPlatformVersion = files.manifest.mergedManifest.platformVersion;
35
35
  if (!manifestPlatformVersion) {
36
36
  return;
37
37
  }
@@ -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,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AAgF,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
+ {"version":3,"file":"production-platform-version.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/production-platform-version.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAC3D,m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AAuB,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 =\n files.manifest.mergedManifest.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,aAsBvC,CAAC"}
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,aAuBvC,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,aAsBvC,CAAC"}
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,aAuBvC,CAAC"}
@@ -28,7 +28,7 @@ const determineProductionVersion = useFileSystemCache('snaps-production-version'
28
28
  export const productionPlatformVersion = {
29
29
  severity: 'warning',
30
30
  async semanticCheck(files, context) {
31
- const manifestPlatformVersion = files.manifest.result.platformVersion;
31
+ const manifestPlatformVersion = files.manifest.mergedManifest.platformVersion;
32
32
  if (!manifestPlatformVersion) {
33
33
  return;
34
34
  }
@@ -1 +1 @@
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,E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;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"]}
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,GAC3B,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,eAAe,CAAC;QAEhD,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 =\n files.manifest.mergedManifest.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"]}
@@ -14,11 +14,11 @@ exports.repositoryMatch = {
14
14
  severity: 'error',
15
15
  semanticCheck(files, context) {
16
16
  const packageJsonRepository = files.packageJson.result.repository;
17
- const manifestRepository = files.manifest.result.repository;
17
+ const manifestRepository = files.manifest.mergedManifest.repository;
18
18
  if ((packageJsonRepository || manifestRepository) &&
19
19
  !(0, fast_deep_equal_1.default)(packageJsonRepository, manifestRepository)) {
20
20
  context.report('repository-match', `"${types_1.NpmSnapFileNames.Manifest}" "repository" field does not match the "${types_1.NpmSnapFileNames.PackageJson}" "repository" field.`, ({ manifest }) => {
21
- manifest.repository = packageJsonRepository
21
+ manifest.mainManifest.result.repository = packageJsonRepository
22
22
  ? (0, deep_clone_1.deepClone)(packageJsonRepository)
23
23
  : undefined;
24
24
  return { manifest };
@@ -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,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
+ {"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,cAAc,CAAC,UAAU,CAAC;QAEpE,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,YAAY,CAAC,MAAM,CAAC,UAAU,GAAG,qBAAqB;oBAC7D,CAAC,CAAC,IAAA,sBAAS,EAAC,qBAAqB,CAAC;oBAClC,CAAC,CAAC,SAAS,CAAC;gBAEd,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.mergedManifest.repository;\n\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.mainManifest.result.repository = packageJsonRepository\n ? deepClone(packageJsonRepository)\n : undefined;\n\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,aAqB7B,CAAC"}
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,aAuB7B,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,aAqB7B,CAAC"}
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,aAuB7B,CAAC"}
@@ -15,11 +15,11 @@ export const repositoryMatch = {
15
15
  severity: 'error',
16
16
  semanticCheck(files, context) {
17
17
  const packageJsonRepository = files.packageJson.result.repository;
18
- const manifestRepository = files.manifest.result.repository;
18
+ const manifestRepository = files.manifest.mergedManifest.repository;
19
19
  if ((packageJsonRepository || manifestRepository) &&
20
20
  !deepEqual(packageJsonRepository, manifestRepository)) {
21
21
  context.report('repository-match', `"${NpmSnapFileNames.Manifest}" "repository" field does not match the "${NpmSnapFileNames.PackageJson}" "repository" field.`, ({ manifest }) => {
22
- manifest.repository = packageJsonRepository
22
+ manifest.mainManifest.result.repository = packageJsonRepository
23
23
  ? deepClone(packageJsonRepository)
24
24
  : undefined;
25
25
  return { manifest };
@@ -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,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"]}
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,cAAc,CAAC,UAAU,CAAC;QAEpE,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,YAAY,CAAC,MAAM,CAAC,UAAU,GAAG,qBAAqB;oBAC7D,CAAC,CAAC,SAAS,CAAC,qBAAqB,CAAC;oBAClC,CAAC,CAAC,SAAS,CAAC;gBAEd,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.mergedManifest.repository;\n\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.mainManifest.result.repository = packageJsonRepository\n ? deepClone(packageJsonRepository)\n : undefined;\n\n return { manifest };\n },\n );\n }\n },\n};\n"]}
@@ -28,7 +28,7 @@ exports.unusedExports = {
28
28
  return false;
29
29
  }
30
30
  return (exports.includes(handler) &&
31
- !files.manifest.result.initialPermissions[endowment]);
31
+ !files.manifest.mergedManifest.initialPermissions[endowment]);
32
32
  })
33
33
  .map(([handler, endowment]) => `${handler} (${endowment})`);
34
34
  const unusedEndowments = Object.entries(handlerEndowments).filter(([handler, endowment]) => {
@@ -36,7 +36,7 @@ exports.unusedExports = {
36
36
  return false;
37
37
  }
38
38
  return (!usedEndowments.includes(endowment) &&
39
- files.manifest.result.initialPermissions[endowment] &&
39
+ files.manifest.mergedManifest.initialPermissions[endowment] &&
40
40
  !exports.includes(handler));
41
41
  });
42
42
  if (unusedHandlers.length > 0) {
@@ -53,7 +53,7 @@ exports.unusedExports = {
53
53
  .join(', ');
54
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
- delete manifest.initialPermissions[endowment];
56
+ delete manifest.mainManifest.result.initialPermissions?.[endowment];
57
57
  });
58
58
  return { manifest };
59
59
  });
@@ -1 +1 @@
1
- {"version":3,"file":"unused-exports.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/unused-exports.ts"],"names":[],"mappings":";;;AAIA,kDAAkD;AAClD,MAAM,kBAAkB,G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ent":["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
+ {"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,KAA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AC5G,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE;oBACzC,OAAO,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,kBAAkB,EAAE,CACtD,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.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"]}
@@ -25,7 +25,7 @@ export const unusedExports = {
25
25
  return false;
26
26
  }
27
27
  return (exports.includes(handler) &&
28
- !files.manifest.result.initialPermissions[endowment]);
28
+ !files.manifest.mergedManifest.initialPermissions[endowment]);
29
29
  })
30
30
  .map(([handler, endowment]) => `${handler} (${endowment})`);
31
31
  const unusedEndowments = Object.entries(handlerEndowments).filter(([handler, endowment]) => {
@@ -33,7 +33,7 @@ export const unusedExports = {
33
33
  return false;
34
34
  }
35
35
  return (!usedEndowments.includes(endowment) &&
36
- files.manifest.result.initialPermissions[endowment] &&
36
+ files.manifest.mergedManifest.initialPermissions[endowment] &&
37
37
  !exports.includes(handler));
38
38
  });
39
39
  if (unusedHandlers.length > 0) {
@@ -50,7 +50,7 @@ export const unusedExports = {
50
50
  .join(', ');
51
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
- delete manifest.initialPermissions[endowment];
53
+ delete manifest.mainManifest.result.initialPermissions?.[endowment];
54
54
  });
55
55
  return { manifest };
56
56
  });