@metamask/snaps-utils 11.7.1 → 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 (98) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/dist/localization.d.cts +1 -0
  3. package/dist/localization.d.cts.map +1 -1
  4. package/dist/localization.d.mts +1 -0
  5. package/dist/localization.d.mts.map +1 -1
  6. package/dist/manifest/manifest.cjs +99 -27
  7. package/dist/manifest/manifest.cjs.map +1 -1
  8. package/dist/manifest/manifest.d.cts +18 -5
  9. package/dist/manifest/manifest.d.cts.map +1 -1
  10. package/dist/manifest/manifest.d.mts +18 -5
  11. package/dist/manifest/manifest.d.mts.map +1 -1
  12. package/dist/manifest/manifest.mjs +106 -28
  13. package/dist/manifest/manifest.mjs.map +1 -1
  14. package/dist/manifest/validation.cjs +1 -0
  15. package/dist/manifest/validation.cjs.map +1 -1
  16. package/dist/manifest/validation.d.cts +2 -0
  17. package/dist/manifest/validation.d.cts.map +1 -1
  18. package/dist/manifest/validation.d.mts +2 -0
  19. package/dist/manifest/validation.d.mts.map +1 -1
  20. package/dist/manifest/validation.mjs +1 -0
  21. package/dist/manifest/validation.mjs.map +1 -1
  22. package/dist/manifest/validator-types.cjs.map +1 -1
  23. package/dist/manifest/validator-types.d.cts +4 -5
  24. package/dist/manifest/validator-types.d.cts.map +1 -1
  25. package/dist/manifest/validator-types.d.mts +4 -5
  26. package/dist/manifest/validator-types.d.mts.map +1 -1
  27. package/dist/manifest/validator-types.mjs.map +1 -1
  28. package/dist/manifest/validator.cjs +1 -1
  29. package/dist/manifest/validator.cjs.map +1 -1
  30. package/dist/manifest/validator.d.cts +3 -3
  31. package/dist/manifest/validator.d.cts.map +1 -1
  32. package/dist/manifest/validator.d.mts +3 -3
  33. package/dist/manifest/validator.d.mts.map +1 -1
  34. package/dist/manifest/validator.mjs +1 -1
  35. package/dist/manifest/validator.mjs.map +1 -1
  36. package/dist/manifest/validators/checksum.cjs +11 -3
  37. package/dist/manifest/validators/checksum.cjs.map +1 -1
  38. package/dist/manifest/validators/checksum.d.cts.map +1 -1
  39. package/dist/manifest/validators/checksum.d.mts.map +1 -1
  40. package/dist/manifest/validators/checksum.mjs +11 -3
  41. package/dist/manifest/validators/checksum.mjs.map +1 -1
  42. package/dist/manifest/validators/icon-declared.cjs +1 -1
  43. package/dist/manifest/validators/icon-declared.cjs.map +1 -1
  44. package/dist/manifest/validators/icon-declared.mjs +1 -1
  45. package/dist/manifest/validators/icon-declared.mjs.map +1 -1
  46. package/dist/manifest/validators/icon-missing.cjs +1 -1
  47. package/dist/manifest/validators/icon-missing.cjs.map +1 -1
  48. package/dist/manifest/validators/icon-missing.d.cts.map +1 -1
  49. package/dist/manifest/validators/icon-missing.d.mts.map +1 -1
  50. package/dist/manifest/validators/icon-missing.mjs +1 -1
  51. package/dist/manifest/validators/icon-missing.mjs.map +1 -1
  52. package/dist/manifest/validators/is-snap-manifest.cjs +1 -1
  53. package/dist/manifest/validators/is-snap-manifest.cjs.map +1 -1
  54. package/dist/manifest/validators/is-snap-manifest.mjs +1 -1
  55. package/dist/manifest/validators/is-snap-manifest.mjs.map +1 -1
  56. package/dist/manifest/validators/manifest-localization.cjs +1 -1
  57. package/dist/manifest/validators/manifest-localization.cjs.map +1 -1
  58. package/dist/manifest/validators/manifest-localization.mjs +1 -1
  59. package/dist/manifest/validators/manifest-localization.mjs.map +1 -1
  60. package/dist/manifest/validators/package-name-match.cjs +6 -2
  61. package/dist/manifest/validators/package-name-match.cjs.map +1 -1
  62. package/dist/manifest/validators/package-name-match.d.cts.map +1 -1
  63. package/dist/manifest/validators/package-name-match.d.mts.map +1 -1
  64. package/dist/manifest/validators/package-name-match.mjs +6 -2
  65. package/dist/manifest/validators/package-name-match.mjs.map +1 -1
  66. package/dist/manifest/validators/platform-version.cjs +4 -4
  67. package/dist/manifest/validators/platform-version.cjs.map +1 -1
  68. package/dist/manifest/validators/platform-version.d.cts.map +1 -1
  69. package/dist/manifest/validators/platform-version.d.mts.map +1 -1
  70. package/dist/manifest/validators/platform-version.mjs +4 -4
  71. package/dist/manifest/validators/platform-version.mjs.map +1 -1
  72. package/dist/manifest/validators/production-platform-version.cjs +1 -1
  73. package/dist/manifest/validators/production-platform-version.cjs.map +1 -1
  74. package/dist/manifest/validators/production-platform-version.d.cts.map +1 -1
  75. package/dist/manifest/validators/production-platform-version.d.mts.map +1 -1
  76. package/dist/manifest/validators/production-platform-version.mjs +1 -1
  77. package/dist/manifest/validators/production-platform-version.mjs.map +1 -1
  78. package/dist/manifest/validators/repository-match.cjs +2 -2
  79. package/dist/manifest/validators/repository-match.cjs.map +1 -1
  80. package/dist/manifest/validators/repository-match.d.cts.map +1 -1
  81. package/dist/manifest/validators/repository-match.d.mts.map +1 -1
  82. package/dist/manifest/validators/repository-match.mjs +2 -2
  83. package/dist/manifest/validators/repository-match.mjs.map +1 -1
  84. package/dist/manifest/validators/unused-exports.cjs +3 -3
  85. package/dist/manifest/validators/unused-exports.cjs.map +1 -1
  86. package/dist/manifest/validators/unused-exports.mjs +3 -3
  87. package/dist/manifest/validators/unused-exports.mjs.map +1 -1
  88. package/dist/manifest/validators/version-match.cjs +2 -2
  89. package/dist/manifest/validators/version-match.cjs.map +1 -1
  90. package/dist/manifest/validators/version-match.mjs +2 -2
  91. package/dist/manifest/validators/version-match.mjs.map +1 -1
  92. package/dist/types.cjs.map +1 -1
  93. package/dist/types.d.cts +66 -1
  94. package/dist/types.d.cts.map +1 -1
  95. package/dist/types.d.mts +66 -1
  96. package/dist/types.d.mts.map +1 -1
  97. package/dist/types.mjs.map +1 -1
  98. package/package.json +3 -3
@@ -1,10 +1,9 @@
1
- import type { SnapManifest } from "./validation.cjs";
2
1
  import type { Promisable } from "../promise.cjs";
3
- import type { SnapFiles, UnvalidatedSnapFiles } from "../types.cjs";
2
+ import type { ExtendableManifest, ExtendableSnapFiles, UnvalidatedSnapFiles } from "../types.cjs";
4
3
  export type ValidatorFix = (files: {
5
- manifest: SnapManifest;
4
+ manifest: ExtendableManifest;
6
5
  }) => Promisable<{
7
- manifest: SnapManifest;
6
+ manifest: ExtendableManifest;
8
7
  }>;
9
8
  /**
10
9
  * The options for the validator context.
@@ -49,6 +48,6 @@ export type ValidatorMeta = {
49
48
  * @param files - Files to be verified
50
49
  * @param context - Validator context to report errors
51
50
  */
52
- semanticCheck?: (files: SnapFiles, context: ValidatorContext) => void | Promise<void>;
51
+ semanticCheck?: (files: ExtendableSnapFiles, context: ValidatorContext) => void | Promise<void>;
53
52
  };
54
53
  //# sourceMappingURL=validator-types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validator-types.d.cts","sourceRoot":"","sources":["../../src/manifest/validator-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAqB;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAmB;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,qBAAiB;AAEhE,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE;IACjC,QAAQ,EAAE,YAAY,CAAC;CACxB,KAAK,UAAU,CAAC;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,CAAC,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAElD;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3E,QAAQ,CAAC,OAAO,CAAC,EAAE,uBAAuB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MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3E,QAAQ,CAAC,OAAO,CAAC,EAAE,uBAAuB,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,iBAAiB,CAAC;IAE5B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CACf,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,gBAAgB,KACtB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CACd,KAAK,EAAE,mBAAmB,EAC1B,OAAO,EAAE,gBAAgB,KACtB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B,CAAC"}
@@ -1,10 +1,9 @@
1
- import type { SnapManifest } from "./validation.mjs";
2
1
  import type { Promisable } from "../promise.mjs";
3
- import type { SnapFiles, UnvalidatedSnapFiles } from "../types.mjs";
2
+ import type { ExtendableManifest, ExtendableSnapFiles, UnvalidatedSnapFiles } from "../types.mjs";
4
3
  export type ValidatorFix = (files: {
5
- manifest: SnapManifest;
4
+ manifest: ExtendableManifest;
6
5
  }) => Promisable<{
7
- manifest: SnapManifest;
6
+ manifest: ExtendableManifest;
8
7
  }>;
9
8
  /**
10
9
  * The options for the validator context.
@@ -49,6 +48,6 @@ export type ValidatorMeta = {
49
48
  * @param files - Files to be verified
50
49
  * @param context - Validator context to report errors
51
50
  */
52
- semanticCheck?: (files: SnapFiles, context: ValidatorContext) => void | Promise<void>;
51
+ semanticCheck?: (files: ExtendableSnapFiles, context: ValidatorContext) => void | Promise<void>;
53
52
  };
54
53
  //# sourceMappingURL=validator-types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validator-types.d.mts","sourceRoot":"","sources":["../../src/manifest/validator-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAqB;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAmB;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,qBAAiB;AAEhE,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE;IACjC,QAAQ,EAAE,YAAY,CAAC;CACxB,KAAK,UAAU,CAAC;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,CAAC,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAElD;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3E,QAAQ,CAAC,OAAO,CAAC,EAAE,uBAAuB,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,iBAAiB,CAAC;IAE5B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,C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ChB,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,iBAAiB,CAAC;IAE5B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CACf,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,gBAAgB,KACtB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CACd,KAAK,EAAE,mBAAmB,EAC1B,OAAO,EAAE,gBAAgB,KACtB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"validator-types.mjs","sourceRoot":"","sources":["../../src/manifest/validator-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SnapManifest } from './validation';\nimport type { Promisable } from '../promise';\nimport type { SnapFiles, UnvalidatedSnapFiles } from '../types';\n\nexport type ValidatorFix = (files: {\n manifest: SnapManifest;\n}) => Promisable<{ manifest: SnapManifest }>;\n\n/**\n * The options for the validator context.\n */\nexport type ValidatorContextOptions = {\n /**\n * An object containing the names of the handlers and their respective\n * permission name. This must be provided to avoid circular dependencies\n * between `@metamask/snaps-utils` and `@metamask/snaps-rpc-methods`.\n */\n handlerEndowments?: Record<string, string | null>;\n\n /**\n * Exports detected by evaluating the bundle. This may be used by one or more\n * validators to determine whether the snap is valid.\n */\n exports?: string[];\n};\n\nexport type ValidatorSeverity = 'error' | 'warning';\n\nexport type ValidatorContext = {\n readonly report: (id: string, message: string, fix?: ValidatorFix) => void;\n readonly options?: ValidatorContextOptions;\n};\n\nexport type ValidatorReport = {\n id: string;\n severity: ValidatorSeverity;\n message: string;\n fix?: ValidatorFix;\n};\n\nexport type ValidatorMeta = {\n severity: ValidatorSeverity;\n\n /**\n * 1. Run the validator on unverified files to ensure that the files are\n * structurally sound.\n *\n * @param files - Files to be verified\n * @param context - Validator context to report errors\n */\n structureCheck?: (\n files: UnvalidatedSnapFiles,\n context: ValidatorContext,\n ) => void | Promise<void>;\n\n /**\n * 2. Run the validator after the files were checked to be structurally sound.\n *\n * @param files - Files to be verified\n * @param context - Validator context to report errors\n */\n semanticCheck?: (\n files: SnapFiles,\n context: ValidatorContext,\n ) => void | Promise<void>;\n};\n"]}
1
+ {"version":3,"file":"validator-types.mjs","sourceRoot":"","sources":["../../src/manifest/validator-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Promisable } from '../promise';\nimport type {\n ExtendableManifest,\n ExtendableSnapFiles,\n UnvalidatedSnapFiles,\n} from '../types';\n\nexport type ValidatorFix = (files: {\n manifest: ExtendableManifest;\n}) => Promisable<{ manifest: ExtendableManifest }>;\n\n/**\n * The options for the validator context.\n */\nexport type ValidatorContextOptions = {\n /**\n * An object containing the names of the handlers and their respective\n * permission name. This must be provided to avoid circular dependencies\n * between `@metamask/snaps-utils` and `@metamask/snaps-rpc-methods`.\n */\n handlerEndowments?: Record<string, string | null>;\n\n /**\n * Exports detected by evaluating the bundle. This may be used by one or more\n * validators to determine whether the snap is valid.\n */\n exports?: string[];\n};\n\nexport type ValidatorSeverity = 'error' | 'warning';\n\nexport type ValidatorContext = {\n readonly report: (id: string, message: string, fix?: ValidatorFix) => void;\n readonly options?: ValidatorContextOptions;\n};\n\nexport type ValidatorReport = {\n id: string;\n severity: ValidatorSeverity;\n message: string;\n fix?: ValidatorFix;\n};\n\nexport type ValidatorMeta = {\n severity: ValidatorSeverity;\n\n /**\n * 1. Run the validator on unverified files to ensure that the files are\n * structurally sound.\n *\n * @param files - Files to be verified\n * @param context - Validator context to report errors\n */\n structureCheck?: (\n files: UnvalidatedSnapFiles,\n context: ValidatorContext,\n ) => void | Promise<void>;\n\n /**\n * 2. Run the validator after the files were checked to be structurally sound.\n *\n * @param files - Files to be verified\n * @param context - Validator context to report errors\n */\n semanticCheck?: (\n files: ExtendableSnapFiles,\n context: ValidatorContext,\n ) => void | Promise<void>;\n};\n"]}
@@ -117,7 +117,7 @@ function isReportFixable(report, errorsOnly) {
117
117
  }
118
118
  exports.isReportFixable = isReportFixable;
119
119
  /**
120
- * Get whether any reports has pending fixes.
120
+ * Get whether any reports have pending fixes.
121
121
  *
122
122
  * @param results - Results of the validation run.
123
123
  * @param errorsOnly - Whether to only consider errors for pending fixes.
@@ -1 +1 @@
1
- {"version":3,"file":"validator.cjs","sourceRoot":"","sources":["../../src/manifest/validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyC;AAUzC,0EAAkD;AAQlD,MAAM,OAAO;IACX,OAAO,GAAsB,EAAE,CAAC;IAEvB,QAAQ,GAA4B,EAAE,CAAC;IAEhD,aAAa,GAAuB,SAAS,CAAC;IAE9C;;;;;OAKG;IACH,YAAY,OAAgC;QAC1C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,OAAe,EAAE,GAAkB;QACpD,IAAA,cAAM,EAAC,IAAI,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC;QAEzC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,EAAE;YACF,OAAO;YACP,GAAG;YACH,QAAQ,EAAE,IAAI,CAAC,aAAa;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,mBAAmB,CAAC,QAAyC;QAC3D,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC;IACzC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,iEAAiE;AACjE,8DAA8D;AAC9D,+BAA+B;AACxB,KAAK,UAAU,aAAa,CACj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BAKC","sourcesContent":["import { assert } from '@metamask/utils';\n\nimport type {\n ValidatorContext,\n ValidatorContextOptions,\n ValidatorFix,\n ValidatorMeta,\n ValidatorReport,\n ValidatorSeverity,\n} from './validator-types';\nimport * as defaultValidators from './validators';\nimport type { SnapFiles, UnvalidatedSnapFiles } from '../types';\n\nexport type ValidatorResults = {\n files?: SnapFiles;\n reports: ValidatorReport[];\n};\n\nclass Context implements ValidatorContext {\n reports: ValidatorReport[] = [];\n\n readonly #options: ValidatorContextOptions = {};\n\n #nextSeverity?: ValidatorSeverity = undefined;\n\n /**\n * Construct a new validator context.\n *\n * @param options - The options for the validator context.\n * @param options.exports - Exports detected by evaluating the bundle.\n */\n constructor(options: ValidatorContextOptions) {\n this.#options = options;\n }\n\n /**\n * Report a validation error or warning.\n *\n * @param id - The unique identifier for the report.\n * @param message - The message describing the validation issue.\n * @param fix - An optional fix function that can be used to automatically\n * resolve the issue.\n */\n report(id: string, message: string, fix?: ValidatorFix): void {\n assert(this.#nextSeverity !== undefined);\n\n this.reports.push({\n id,\n message,\n fix,\n severity: this.#nextSeverity,\n });\n }\n\n prepareForValidator(settings: { severity: ValidatorSeverity }) {\n this.#nextSeverity = settings.severity;\n }\n\n get hasErrors() {\n return this.reports.some((report) => report.severity === 'error');\n }\n\n get options() {\n return this.#options;\n }\n}\n\n/**\n * Verify that snap files are completely valid.\n * First it runs validators on unparsed files to check structure.\n * Secondly it runs validators on parsed files to check semantics.\n *\n * @param files - All files required to run a snap.\n * @param rules - Validators to run.\n * @param options - Options for the validation.\n * @param options.exports - Exports detected by evaluating the bundle.\n * @returns The validation results.\n */\n// TODO(ritave): snap.manifest.json and package.json should check\n// json parsing as well instead of assuming it's\n// already parsed\nexport async function runValidators(\n files: UnvalidatedSnapFiles,\n rules: ValidatorMeta[] = Object.values(defaultValidators),\n options: ValidatorContextOptions = {},\n): Promise<ValidatorResults> {\n const context = new Context(options);\n\n for (const rule of rules) {\n context.prepareForValidator({\n severity: rule.severity,\n });\n\n await rule.structureCheck?.(files, context);\n }\n\n if (context.hasErrors) {\n return {\n reports: context.reports,\n };\n }\n\n for (const rule of rules) {\n context.prepareForValidator({\n severity: rule.severity,\n });\n\n await rule.semanticCheck?.(files as SnapFiles, context);\n }\n\n return {\n files: files as SnapFiles,\n reports: context.reports,\n };\n}\n\n/**\n * Check whether a report is fixable.\n *\n * @param report - The report to check.\n * @param errorsOnly - Whether to only consider errors for fixability.\n * @returns Whether the report is fixable.\n */\nexport function isReportFixable(report: ValidatorReport, errorsOnly?: boolean) {\n return Boolean(report.fix && (!errorsOnly || report.severity === 'error'));\n}\n\n/**\n * Get whether any reports has pending fixes.\n *\n * @param results - Results of the validation run.\n * @param errorsOnly - Whether to only consider errors for pending fixes.\n * @returns Whether there are fixes pending.\n */\nexport function hasFixes(\n results: ValidatorResults,\n errorsOnly?: boolean,\n): boolean {\n return results.reports.some((report) => isReportFixable(report, errorsOnly));\n}\n"]}
1
+ {"version":3,"file":"validator.cjs","sourceRoot":"","sources":["../../src/manifest/validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyC;AAUzC,0EAAkD;AAQlD,MAAM,OAAO;IACX,OAAO,GAAsB,EAAE,CAAC;IAEvB,QAAQ,GAA4B,EAAE,CAAC;IAEhD,aAAa,GAAuB,SAAS,CAAC;IAE9C;;;;;OAKG;IACH,YAAY,OAAgC;QAC1C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,OAAe,EAAE,GAAkB;QACpD,IAAA,cAAM,EAAC,IAAI,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC;QAEzC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,EAAE;YACF,OAAO;YACP,GAAG;YACH,QAAQ,EAAE,IAAI,CAAC,aAAa;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,mBAAmB,CAAC,QAAyC;QAC3D,I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EAAE,UAAoB;IAC3E,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,UAAU,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC;AAC7E,CAAC;AAFD,0CAEC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CACtB,OAAyB,EACzB,UAAoB;IAEpB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAC/E,CAAC;AALD,4BAKC","sourcesContent":["import { assert } from '@metamask/utils';\n\nimport type {\n ValidatorContext,\n ValidatorContextOptions,\n ValidatorFix,\n ValidatorMeta,\n ValidatorReport,\n ValidatorSeverity,\n} from './validator-types';\nimport * as defaultValidators from './validators';\nimport type { UnvalidatedSnapFiles, ExtendableSnapFiles } from '../types';\n\nexport type ValidatorResults = {\n files?: ExtendableSnapFiles;\n reports: ValidatorReport[];\n};\n\nclass Context implements ValidatorContext {\n reports: ValidatorReport[] = [];\n\n readonly #options: ValidatorContextOptions = {};\n\n #nextSeverity?: ValidatorSeverity = undefined;\n\n /**\n * Construct a new validator context.\n *\n * @param options - The options for the validator context.\n * @param options.exports - Exports detected by evaluating the bundle.\n */\n constructor(options: ValidatorContextOptions) {\n this.#options = options;\n }\n\n /**\n * Report a validation error or warning.\n *\n * @param id - The unique identifier for the report.\n * @param message - The message describing the validation issue.\n * @param fix - An optional fix function that can be used to automatically\n * resolve the issue.\n */\n report(id: string, message: string, fix?: ValidatorFix): void {\n assert(this.#nextSeverity !== undefined);\n\n this.reports.push({\n id,\n message,\n fix,\n severity: this.#nextSeverity,\n });\n }\n\n prepareForValidator(settings: { severity: ValidatorSeverity }) {\n this.#nextSeverity = settings.severity;\n }\n\n get hasErrors() {\n return this.reports.some((report) => report.severity === 'error');\n }\n\n get options() {\n return this.#options;\n }\n}\n\n/**\n * Verify that snap files are completely valid.\n * First it runs validators on unparsed files to check structure.\n * Secondly it runs validators on parsed files to check semantics.\n *\n * @param files - All files required to run a snap.\n * @param rules - Validators to run.\n * @param options - Options for the validation.\n * @param options.exports - Exports detected by evaluating the bundle.\n * @returns The validation results.\n */\n// TODO(ritave): snap.manifest.json and package.json should check\n// json parsing as well instead of assuming it's\n// already parsed\nexport async function runValidators(\n files: UnvalidatedSnapFiles,\n rules: ValidatorMeta[] = Object.values(defaultValidators),\n options: ValidatorContextOptions = {},\n): Promise<ValidatorResults> {\n const context = new Context(options);\n\n for (const rule of rules) {\n context.prepareForValidator({\n severity: rule.severity,\n });\n\n await rule.structureCheck?.(files, context);\n }\n\n if (context.hasErrors) {\n return {\n reports: context.reports,\n };\n }\n\n for (const rule of rules) {\n context.prepareForValidator({\n severity: rule.severity,\n });\n\n await rule.semanticCheck?.(files as ExtendableSnapFiles, context);\n }\n\n return {\n files: files as ExtendableSnapFiles,\n reports: context.reports,\n };\n}\n\n/**\n * Check whether a report is fixable.\n *\n * @param report - The report to check.\n * @param errorsOnly - Whether to only consider errors for fixability.\n * @returns Whether the report is fixable.\n */\nexport function isReportFixable(report: ValidatorReport, errorsOnly?: boolean) {\n return Boolean(report.fix && (!errorsOnly || report.severity === 'error'));\n}\n\n/**\n * Get whether any reports have pending fixes.\n *\n * @param results - Results of the validation run.\n * @param errorsOnly - Whether to only consider errors for pending fixes.\n * @returns Whether there are fixes pending.\n */\nexport function hasFixes(\n results: ValidatorResults,\n errorsOnly?: boolean,\n): boolean {\n return results.reports.some((report) => isReportFixable(report, errorsOnly));\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { ValidatorContextOptions, ValidatorMeta, ValidatorReport } from "./validator-types.cjs";
2
- import type { SnapFiles, UnvalidatedSnapFiles } from "../types.cjs";
2
+ import type { UnvalidatedSnapFiles, ExtendableSnapFiles } from "../types.cjs";
3
3
  export type ValidatorResults = {
4
- files?: SnapFiles;
4
+ files?: ExtendableSnapFiles;
5
5
  reports: ValidatorReport[];
6
6
  };
7
7
  /**
@@ -25,7 +25,7 @@ export declare function runValidators(files: UnvalidatedSnapFiles, rules?: Valid
25
25
  */
26
26
  export declare function isReportFixable(report: ValidatorReport, errorsOnly?: boolean): boolean;
27
27
  /**
28
- * Get whether any reports has pending fixes.
28
+ * Get whether any reports have pending fixes.
29
29
  *
30
30
  * @param results - Results of the validation run.
31
31
  * @param errorsOnly - Whether to only consider errors for pending fixes.
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.cts","sourceRoot":"","sources":["../../src/manifest/validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,uBAAuB,EAEvB,aAAa,EACb,eAAe,EAEhB,8BAA0B;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,qBAAiB;AAEhE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B,CAAC;AAmDF;;;;;;;;;;GAUG;AAIH,wBAAsB,aAAa,CACjC,KAAK,EAAE,oBAAoB,EAC3B,KAAK,GAAE,aAAa,EAAqC,EACzD,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,gBAAgB,CAAC,CA6B3B;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,OAAO,WAE5E;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAET"}
1
+ {"version":3,"file":"validator.d.cts","sourceRoot":"","sources":["../../src/manifest/validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,uBAAuB,EAEvB,aAAa,EACb,eAAe,EAEhB,8BAA0B;AAE3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,qBAAiB;AAE1E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B,CAAC;AAmDF;;;;;;;;;;GAUG;AAIH,wBAAsB,aAAa,CACjC,KAAK,EAAE,oBAAoB,EAC3B,KAAK,GAAE,aAAa,EAAqC,EACzD,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,gBAAgB,CAAC,CA6B3B;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,OAAO,WAE5E;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAET"}
@@ -1,7 +1,7 @@
1
1
  import type { ValidatorContextOptions, ValidatorMeta, ValidatorReport } from "./validator-types.mjs";
2
- import type { SnapFiles, UnvalidatedSnapFiles } from "../types.mjs";
2
+ import type { UnvalidatedSnapFiles, ExtendableSnapFiles } from "../types.mjs";
3
3
  export type ValidatorResults = {
4
- files?: SnapFiles;
4
+ files?: ExtendableSnapFiles;
5
5
  reports: ValidatorReport[];
6
6
  };
7
7
  /**
@@ -25,7 +25,7 @@ export declare function runValidators(files: UnvalidatedSnapFiles, rules?: Valid
25
25
  */
26
26
  export declare function isReportFixable(report: ValidatorReport, errorsOnly?: boolean): boolean;
27
27
  /**
28
- * Get whether any reports has pending fixes.
28
+ * Get whether any reports have pending fixes.
29
29
  *
30
30
  * @param results - Results of the validation run.
31
31
  * @param errorsOnly - Whether to only consider errors for pending fixes.
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.mts","sourceRoot":"","sources":["../../src/manifest/validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,uBAAuB,EAEvB,aAAa,EACb,eAAe,EAEhB,8BAA0B;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,qBAAiB;AAEhE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B,CAAC;AAmDF;;;;;;;;;;GAUG;AAIH,wBAAsB,aAAa,CACjC,KAAK,EAAE,oBAAoB,EAC3B,KAAK,GAAE,aAAa,EAAqC,EACzD,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,gBAAgB,CAAC,CA6B3B;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,OAAO,WAE5E;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAET"}
1
+ {"version":3,"file":"validator.d.mts","sourceRoot":"","sources":["../../src/manifest/validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,uBAAuB,EAEvB,aAAa,EACb,eAAe,EAEhB,8BAA0B;AAE3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,qBAAiB;AAE1E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B,CAAC;AAmDF;;;;;;;;;;GAUG;AAIH,wBAAsB,aAAa,CACjC,KAAK,EAAE,oBAAoB,EAC3B,KAAK,GAAE,aAAa,EAAqC,EACzD,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,gBAAgB,CAAC,CA6B3B;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,OAAO,WAE5E;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAET"}
@@ -89,7 +89,7 @@ export function isReportFixable(report, errorsOnly) {
89
89
  return Boolean(report.fix && (!errorsOnly || report.severity === 'error'));
90
90
  }
91
91
  /**
92
- * Get whether any reports has pending fixes.
92
+ * Get whether any reports have pending fixes.
93
93
  *
94
94
  * @param results - Results of the validation run.
95
95
  * @param errorsOnly - Whether to only consider errors for pending fixes.
@@ -1 +1 @@
1
- {"version":3,"file":"validator.mjs","sourceRoot":"","sources":["../../src/manifest/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,wBAAwB;AAUzC,OAAO,KAAK,iBAAiB,+BAAqB;AAQlD,MAAM,OAAO;IACX,OAAO,GAAsB,EAAE,CAAC;IAEvB,QAAQ,GAA4B,EAAE,CAAC;IAEhD,aAAa,GAAuB,SAAS,CAAC;IAE9C;;;;;OAKG;IACH,YAAY,OAAgC;QAC1C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,OAAe,EAAE,GAAkB;QACpD,MAAM,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC;QAEzC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,EAAE;YACF,OAAO;YACP,GAAG;YACH,QAAQ,EAAE,IAAI,CAAC,aAAa;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,mBAAmB,CAAC,QAAyC;QAC3D,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC;IACzC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,iEAAiE;AACjE,8DAA8D;AAC9D,+BAA+B;AAC/B,MAAM,CAAC,KAAK,UAAU,aA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@metamask/utils';\n\nimport type {\n ValidatorContext,\n ValidatorContextOptions,\n ValidatorFix,\n ValidatorMeta,\n ValidatorReport,\n ValidatorSeverity,\n} from './validator-types';\nimport * as defaultValidators from './validators';\nimport type { SnapFiles, UnvalidatedSnapFiles } from '../types';\n\nexport type ValidatorResults = {\n files?: SnapFiles;\n reports: ValidatorReport[];\n};\n\nclass Context implements ValidatorContext {\n reports: ValidatorReport[] = [];\n\n readonly #options: ValidatorContextOptions = {};\n\n #nextSeverity?: ValidatorSeverity = undefined;\n\n /**\n * Construct a new validator context.\n *\n * @param options - The options for the validator context.\n * @param options.exports - Exports detected by evaluating the bundle.\n */\n constructor(options: ValidatorContextOptions) {\n this.#options = options;\n }\n\n /**\n * Report a validation error or warning.\n *\n * @param id - The unique identifier for the report.\n * @param message - The message describing the validation issue.\n * @param fix - An optional fix function that can be used to automatically\n * resolve the issue.\n */\n report(id: string, message: string, fix?: ValidatorFix): void {\n assert(this.#nextSeverity !== undefined);\n\n this.reports.push({\n id,\n message,\n fix,\n severity: this.#nextSeverity,\n });\n }\n\n prepareForValidator(settings: { severity: ValidatorSeverity }) {\n this.#nextSeverity = settings.severity;\n }\n\n get hasErrors() {\n return this.reports.some((report) => report.severity === 'error');\n }\n\n get options() {\n return this.#options;\n }\n}\n\n/**\n * Verify that snap files are completely valid.\n * First it runs validators on unparsed files to check structure.\n * Secondly it runs validators on parsed files to check semantics.\n *\n * @param files - All files required to run a snap.\n * @param rules - Validators to run.\n * @param options - Options for the validation.\n * @param options.exports - Exports detected by evaluating the bundle.\n * @returns The validation results.\n */\n// TODO(ritave): snap.manifest.json and package.json should check\n// json parsing as well instead of assuming it's\n// already parsed\nexport async function runValidators(\n files: UnvalidatedSnapFiles,\n rules: ValidatorMeta[] = Object.values(defaultValidators),\n options: ValidatorContextOptions = {},\n): Promise<ValidatorResults> {\n const context = new Context(options);\n\n for (const rule of rules) {\n context.prepareForValidator({\n severity: rule.severity,\n });\n\n await rule.structureCheck?.(files, context);\n }\n\n if (context.hasErrors) {\n return {\n reports: context.reports,\n };\n }\n\n for (const rule of rules) {\n context.prepareForValidator({\n severity: rule.severity,\n });\n\n await rule.semanticCheck?.(files as SnapFiles, context);\n }\n\n return {\n files: files as SnapFiles,\n reports: context.reports,\n };\n}\n\n/**\n * Check whether a report is fixable.\n *\n * @param report - The report to check.\n * @param errorsOnly - Whether to only consider errors for fixability.\n * @returns Whether the report is fixable.\n */\nexport function isReportFixable(report: ValidatorReport, errorsOnly?: boolean) {\n return Boolean(report.fix && (!errorsOnly || report.severity === 'error'));\n}\n\n/**\n * Get whether any reports has pending fixes.\n *\n * @param results - Results of the validation run.\n * @param errorsOnly - Whether to only consider errors for pending fixes.\n * @returns Whether there are fixes pending.\n */\nexport function hasFixes(\n results: ValidatorResults,\n errorsOnly?: boolean,\n): boolean {\n return results.reports.some((report) => isReportFixable(report, errorsOnly));\n}\n"]}
1
+ {"version":3,"file":"validator.mjs","sourceRoot":"","sources":["../../src/manifest/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,wBAAwB;AAUzC,OAAO,KAAK,iBAAiB,+BAAqB;AAQlD,MAAM,OAAO;IACX,OAAO,GAAsB,EAAE,CAAC;IAEvB,QAAQ,GAA4B,EAAE,CAAC;IAEhD,aAAa,GAAuB,SAAS,CAAC;IAE9C;;;;;OAKG;IACH,YAAY,OAAgC;QAC1C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,OAAe,EAAE,GAAkB;QACpD,MAAM,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC;QAEzC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,EAAE;YACF,OAAO;YACP,GAAG;YACH,QAAQ,EAAE,IAAI,CAAC,aAAa;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,mBAAmB,CAAC,QAAyC;QAC3D,IAAI,CAAC,aAAa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IAC3E,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,UAAU,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,OAAyB,EACzB,UAAoB;IAEpB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["import { assert } from '@metamask/utils';\n\nimport type {\n ValidatorContext,\n ValidatorContextOptions,\n ValidatorFix,\n ValidatorMeta,\n ValidatorReport,\n ValidatorSeverity,\n} from './validator-types';\nimport * as defaultValidators from './validators';\nimport type { UnvalidatedSnapFiles, ExtendableSnapFiles } from '../types';\n\nexport type ValidatorResults = {\n files?: ExtendableSnapFiles;\n reports: ValidatorReport[];\n};\n\nclass Context implements ValidatorContext {\n reports: ValidatorReport[] = [];\n\n readonly #options: ValidatorContextOptions = {};\n\n #nextSeverity?: ValidatorSeverity = undefined;\n\n /**\n * Construct a new validator context.\n *\n * @param options - The options for the validator context.\n * @param options.exports - Exports detected by evaluating the bundle.\n */\n constructor(options: ValidatorContextOptions) {\n this.#options = options;\n }\n\n /**\n * Report a validation error or warning.\n *\n * @param id - The unique identifier for the report.\n * @param message - The message describing the validation issue.\n * @param fix - An optional fix function that can be used to automatically\n * resolve the issue.\n */\n report(id: string, message: string, fix?: ValidatorFix): void {\n assert(this.#nextSeverity !== undefined);\n\n this.reports.push({\n id,\n message,\n fix,\n severity: this.#nextSeverity,\n });\n }\n\n prepareForValidator(settings: { severity: ValidatorSeverity }) {\n this.#nextSeverity = settings.severity;\n }\n\n get hasErrors() {\n return this.reports.some((report) => report.severity === 'error');\n }\n\n get options() {\n return this.#options;\n }\n}\n\n/**\n * Verify that snap files are completely valid.\n * First it runs validators on unparsed files to check structure.\n * Secondly it runs validators on parsed files to check semantics.\n *\n * @param files - All files required to run a snap.\n * @param rules - Validators to run.\n * @param options - Options for the validation.\n * @param options.exports - Exports detected by evaluating the bundle.\n * @returns The validation results.\n */\n// TODO(ritave): snap.manifest.json and package.json should check\n// json parsing as well instead of assuming it's\n// already parsed\nexport async function runValidators(\n files: UnvalidatedSnapFiles,\n rules: ValidatorMeta[] = Object.values(defaultValidators),\n options: ValidatorContextOptions = {},\n): Promise<ValidatorResults> {\n const context = new Context(options);\n\n for (const rule of rules) {\n context.prepareForValidator({\n severity: rule.severity,\n });\n\n await rule.structureCheck?.(files, context);\n }\n\n if (context.hasErrors) {\n return {\n reports: context.reports,\n };\n }\n\n for (const rule of rules) {\n context.prepareForValidator({\n severity: rule.severity,\n });\n\n await rule.semanticCheck?.(files as ExtendableSnapFiles, context);\n }\n\n return {\n files: files as ExtendableSnapFiles,\n reports: context.reports,\n };\n}\n\n/**\n * Check whether a report is fixable.\n *\n * @param report - The report to check.\n * @param errorsOnly - Whether to only consider errors for fixability.\n * @returns Whether the report is fixable.\n */\nexport function isReportFixable(report: ValidatorReport, errorsOnly?: boolean) {\n return Boolean(report.fix && (!errorsOnly || report.severity === 'error'));\n}\n\n/**\n * Get whether any reports have pending fixes.\n *\n * @param results - Results of the validation run.\n * @param errorsOnly - Whether to only consider errors for pending fixes.\n * @returns Whether there are fixes pending.\n */\nexport function hasFixes(\n results: ValidatorResults,\n errorsOnly?: boolean,\n): boolean {\n return results.reports.some((report) => isReportFixable(report, errorsOnly));\n}\n"]}
@@ -9,12 +9,20 @@ const types_1 = require("../../types.cjs");
9
9
  exports.checksum = {
10
10
  severity: 'error',
11
11
  async semanticCheck(files, context) {
12
- const fetchedFiles = files;
13
- const gotChecksum = files.manifest.result.source.shasum;
12
+ const mergedManifest = files.manifest.mainManifest.clone();
13
+ mergedManifest.result = files.manifest.mergedManifest;
14
+ mergedManifest.value = JSON.stringify(files.manifest.mergedManifest);
15
+ const fetchedFiles = {
16
+ ...files,
17
+ manifest: mergedManifest,
18
+ };
19
+ const gotChecksum = files.manifest.mergedManifest.source.shasum;
14
20
  const expectedChecksum = await (0, snaps_1.getSnapChecksum)(fetchedFiles);
15
21
  if (gotChecksum !== expectedChecksum) {
16
22
  context.report('checksum', `"${types_1.NpmSnapFileNames.Manifest}" "shasum" field does not match computed shasum. Got "${gotChecksum}", expected "${expectedChecksum}".`, async ({ manifest }) => {
17
- manifest.source.shasum = expectedChecksum;
23
+ manifest.mainManifest.result ??= {};
24
+ manifest.mainManifest.result.source ??= {};
25
+ manifest.mainManifest.result.source.shasum = expectedChecksum;
18
26
  return { manifest };
19
27
  });
20
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"checksum.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/checksum.ts"],"names":[],"mappings":";;;AAAA,2CAA8C;AAE9C,2CAA+C;AAG/C;;GAEG;AACU,QAAA,QAAQ,GAAkB;IACrC,QAAQ,EAAE,OAAO;IACjB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO;QAChC,MAAM,YAAY,GAAqB,KAAK,CAAC;QAC7C,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;QACxD,MAAM,gBAAgB,GAAG,MAAM,IAAA,uBAAe,EAAC,YAAY,CAAC,CAAC;QAC7D,IAAI,WAAW,KAAK,gBAAgB,EAAE,CAAC;YACrC,OAAO,CAAC,MAAM,CACZ,UAAU,EACV,IAAI,wBAAgB,CAAC,QAAQ,yDAAyD,WAAW,gBAAgB,gBAAgB,IAAI,EACrI,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACrB,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,gBAAgB,CAAC;gBAC1C,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { getSnapChecksum } from '../../snaps';\nimport type { FetchedSnapFiles } from '../../types';\nimport { NpmSnapFileNames } from '../../types';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the checksum in manifest matches computed value.\n */\nexport const checksum: ValidatorMeta = {\n severity: 'error',\n async semanticCheck(files, context) {\n const fetchedFiles: FetchedSnapFiles = files;\n const gotChecksum = files.manifest.result.source.shasum;\n const expectedChecksum = await getSnapChecksum(fetchedFiles);\n if (gotChecksum !== expectedChecksum) {\n context.report(\n 'checksum',\n `\"${NpmSnapFileNames.Manifest}\" \"shasum\" field does not match computed shasum. Got \"${gotChecksum}\", expected \"${expectedChecksum}\".`,\n async ({ manifest }) => {\n manifest.source.shasum = expectedChecksum;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
1
+ {"version":3,"file":"checksum.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/checksum.ts"],"names":[],"mappings":";;;AAAA,2CAA8C;AAE9C,2CAA+C;AAK/C;;GAEG;AACU,QAAA,QAAQ,GAAkB;IACrC,QAAQ,EAAE,OAAO;IACjB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO;QAChC,MAAM,cAAc,GAClB,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,EAA+B,CAAC;QACnE,cAAc,CAAC,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC;QACtD,cAAc,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QAErE,MAAM,YAAY,GAAqB;YACrC,GAAG,KAAK;YACR,QAAQ,EAAE,cAAc;SACzB,CAAC;QAEF,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC;QAChE,MAAM,gBAAgB,GAAG,MAAM,IAAA,uBAAe,EAAC,YAAY,CAAC,CAAC;QAC7D,IAAI,WAAW,KAAK,gBAAgB,EAAE,CAAC;YACrC,OAAO,CAAC,MAAM,CACZ,UAAU,EACV,IAAI,wBAAgB,CAAC,QAAQ,yDAAyD,WAAW,gBAAgB,gBAAgB,IAAI,EACrI,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACrB,QAAQ,CAAC,YAAY,CAAC,MAAM,KAAK,EAAE,CAAC;gBACpC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC;gBAC3C,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,gBAAgB,CAAC;gBAC9D,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { getSnapChecksum } from '../../snaps';\nimport type { FetchedSnapFiles } from '../../types';\nimport { NpmSnapFileNames } from '../../types';\nimport type { VirtualFile } from '../../virtual-file';\nimport type { SnapManifest } from '../validation';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the checksum in manifest matches computed value.\n */\nexport const checksum: ValidatorMeta = {\n severity: 'error',\n async semanticCheck(files, context) {\n const mergedManifest =\n files.manifest.mainManifest.clone() as VirtualFile<SnapManifest>;\n mergedManifest.result = files.manifest.mergedManifest;\n mergedManifest.value = JSON.stringify(files.manifest.mergedManifest);\n\n const fetchedFiles: FetchedSnapFiles = {\n ...files,\n manifest: mergedManifest,\n };\n\n const gotChecksum = files.manifest.mergedManifest.source.shasum;\n const expectedChecksum = await getSnapChecksum(fetchedFiles);\n if (gotChecksum !== expectedChecksum) {\n context.report(\n 'checksum',\n `\"${NpmSnapFileNames.Manifest}\" \"shasum\" field does not match computed shasum. Got \"${gotChecksum}\", expected \"${expectedChecksum}\".`,\n async ({ manifest }) => {\n manifest.mainManifest.result ??= {};\n manifest.mainManifest.result.source ??= {};\n manifest.mainManifest.result.source.shasum = expectedChecksum;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"checksum.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/checksum.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,aAiBtB,CAAC"}
1
+ {"version":3,"file":"checksum.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/checksum.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,aA4BtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"checksum.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/checksum.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,aAiBtB,CAAC"}
1
+ {"version":3,"file":"checksum.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/checksum.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,aA4BtB,CAAC"}
@@ -6,12 +6,20 @@ import { NpmSnapFileNames } from "../../types.mjs";
6
6
  export const checksum = {
7
7
  severity: 'error',
8
8
  async semanticCheck(files, context) {
9
- const fetchedFiles = files;
10
- const gotChecksum = files.manifest.result.source.shasum;
9
+ const mergedManifest = files.manifest.mainManifest.clone();
10
+ mergedManifest.result = files.manifest.mergedManifest;
11
+ mergedManifest.value = JSON.stringify(files.manifest.mergedManifest);
12
+ const fetchedFiles = {
13
+ ...files,
14
+ manifest: mergedManifest,
15
+ };
16
+ const gotChecksum = files.manifest.mergedManifest.source.shasum;
11
17
  const expectedChecksum = await getSnapChecksum(fetchedFiles);
12
18
  if (gotChecksum !== expectedChecksum) {
13
19
  context.report('checksum', `"${NpmSnapFileNames.Manifest}" "shasum" field does not match computed shasum. Got "${gotChecksum}", expected "${expectedChecksum}".`, async ({ manifest }) => {
14
- manifest.source.shasum = expectedChecksum;
20
+ manifest.mainManifest.result ??= {};
21
+ manifest.mainManifest.result.source ??= {};
22
+ manifest.mainManifest.result.source.shasum = expectedChecksum;
15
23
  return { manifest };
16
24
  });
17
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"checksum.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/checksum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAE9C,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAG/C;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAkB;IACrC,QAAQ,EAAE,OAAO;IACjB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO;QAChC,MAAM,YAAY,GAAqB,KAAK,CAAC;QAC7C,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;QACxD,MAAM,gBAAgB,GAAG,MAAM,eAAe,CAAC,YAAY,CAAC,CAAC;QAC7D,IAAI,WAAW,KAAK,gBAAgB,EAAE,CAAC;YACrC,OAAO,CAAC,MAAM,CACZ,UAAU,EACV,IAAI,gBAAgB,CAAC,QAAQ,yDAAyD,WAAW,gBAAgB,gBAAgB,IAAI,EACrI,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACrB,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,gBAAgB,CAAC;gBAC1C,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { getSnapChecksum } from '../../snaps';\nimport type { FetchedSnapFiles } from '../../types';\nimport { NpmSnapFileNames } from '../../types';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the checksum in manifest matches computed value.\n */\nexport const checksum: ValidatorMeta = {\n severity: 'error',\n async semanticCheck(files, context) {\n const fetchedFiles: FetchedSnapFiles = files;\n const gotChecksum = files.manifest.result.source.shasum;\n const expectedChecksum = await getSnapChecksum(fetchedFiles);\n if (gotChecksum !== expectedChecksum) {\n context.report(\n 'checksum',\n `\"${NpmSnapFileNames.Manifest}\" \"shasum\" field does not match computed shasum. Got \"${gotChecksum}\", expected \"${expectedChecksum}\".`,\n async ({ manifest }) => {\n manifest.source.shasum = expectedChecksum;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
1
+ {"version":3,"file":"checksum.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/checksum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAE9C,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAK/C;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAkB;IACrC,QAAQ,EAAE,OAAO;IACjB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO;QAChC,MAAM,cAAc,GAClB,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,EAA+B,CAAC;QACnE,cAAc,CAAC,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC;QACtD,cAAc,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QAErE,MAAM,YAAY,GAAqB;YACrC,GAAG,KAAK;YACR,QAAQ,EAAE,cAAc;SACzB,CAAC;QAEF,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC;QAChE,MAAM,gBAAgB,GAAG,MAAM,eAAe,CAAC,YAAY,CAAC,CAAC;QAC7D,IAAI,WAAW,KAAK,gBAAgB,EAAE,CAAC;YACrC,OAAO,CAAC,MAAM,CACZ,UAAU,EACV,IAAI,gBAAgB,CAAC,QAAQ,yDAAyD,WAAW,gBAAgB,gBAAgB,IAAI,EACrI,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACrB,QAAQ,CAAC,YAAY,CAAC,MAAM,KAAK,EAAE,CAAC;gBACpC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC;gBAC3C,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,gBAAgB,CAAC;gBAC9D,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { getSnapChecksum } from '../../snaps';\nimport type { FetchedSnapFiles } from '../../types';\nimport { NpmSnapFileNames } from '../../types';\nimport type { VirtualFile } from '../../virtual-file';\nimport type { SnapManifest } from '../validation';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Check if the checksum in manifest matches computed value.\n */\nexport const checksum: ValidatorMeta = {\n severity: 'error',\n async semanticCheck(files, context) {\n const mergedManifest =\n files.manifest.mainManifest.clone() as VirtualFile<SnapManifest>;\n mergedManifest.result = files.manifest.mergedManifest;\n mergedManifest.value = JSON.stringify(files.manifest.mergedManifest);\n\n const fetchedFiles: FetchedSnapFiles = {\n ...files,\n manifest: mergedManifest,\n };\n\n const gotChecksum = files.manifest.mergedManifest.source.shasum;\n const expectedChecksum = await getSnapChecksum(fetchedFiles);\n if (gotChecksum !== expectedChecksum) {\n context.report(\n 'checksum',\n `\"${NpmSnapFileNames.Manifest}\" \"shasum\" field does not match computed shasum. Got \"${gotChecksum}\", expected \"${expectedChecksum}\".`,\n async ({ manifest }) => {\n manifest.mainManifest.result ??= {};\n manifest.mainManifest.result.source ??= {};\n manifest.mainManifest.result.source.shasum = expectedChecksum;\n return { manifest };\n },\n );\n }\n },\n};\n"]}
@@ -7,7 +7,7 @@ exports.iconDeclared = void 0;
7
7
  exports.iconDeclared = {
8
8
  severity: 'warning',
9
9
  semanticCheck(files, context) {
10
- if (!files.manifest.result.source.location.npm.iconPath) {
10
+ if (!files.manifest.mergedManifest.source?.location?.npm?.iconPath) {
11
11
  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.');
12
12
  }
13
13
  },
@@ -1 +1 @@
1
- {"version":3,"file":"icon-declared.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/icon-declared.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACU,QAAA,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.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/icon-declared.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACU,QAAA,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"]}
@@ -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"]}