@metamask/snaps-utils 11.4.0 → 11.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -1
- package/dist/base64.cjs +3 -2
- package/dist/base64.cjs.map +1 -1
- package/dist/base64.d.cts.map +1 -1
- package/dist/base64.d.mts.map +1 -1
- package/dist/base64.mjs +3 -2
- package/dist/base64.mjs.map +1 -1
- package/dist/derivation-paths.cjs +5 -0
- package/dist/derivation-paths.cjs.map +1 -1
- package/dist/derivation-paths.d.cts.map +1 -1
- package/dist/derivation-paths.d.mts.map +1 -1
- package/dist/derivation-paths.mjs +5 -0
- package/dist/derivation-paths.mjs.map +1 -1
- package/dist/json.cjs +5 -4
- package/dist/json.cjs.map +1 -1
- package/dist/json.d.cts +3 -2
- package/dist/json.d.cts.map +1 -1
- package/dist/json.d.mts +3 -2
- package/dist/json.d.mts.map +1 -1
- package/dist/json.mjs +5 -4
- package/dist/json.mjs.map +1 -1
- package/dist/manifest/manifest.cjs +9 -5
- package/dist/manifest/manifest.cjs.map +1 -1
- package/dist/manifest/manifest.d.cts.map +1 -1
- package/dist/manifest/manifest.d.mts.map +1 -1
- package/dist/manifest/manifest.mjs +9 -5
- package/dist/manifest/manifest.mjs.map +1 -1
- package/dist/manifest/validator-types.cjs.map +1 -1
- package/dist/manifest/validator-types.d.cts +4 -2
- package/dist/manifest/validator-types.d.cts.map +1 -1
- package/dist/manifest/validator-types.d.mts +4 -2
- package/dist/manifest/validator-types.d.mts.map +1 -1
- package/dist/manifest/validator-types.mjs.map +1 -1
- package/dist/manifest/validator.cjs +11 -2
- package/dist/manifest/validator.cjs.map +1 -1
- package/dist/manifest/validator.d.cts.map +1 -1
- package/dist/manifest/validator.d.mts.map +1 -1
- package/dist/manifest/validator.mjs +11 -2
- package/dist/manifest/validator.mjs.map +1 -1
- package/dist/manifest/validators/checksum.cjs +1 -1
- package/dist/manifest/validators/checksum.cjs.map +1 -1
- package/dist/manifest/validators/checksum.d.cts.map +1 -1
- package/dist/manifest/validators/checksum.d.mts.map +1 -1
- package/dist/manifest/validators/checksum.mjs +1 -1
- package/dist/manifest/validators/checksum.mjs.map +1 -1
- package/dist/manifest/validators/expected-files.cjs +1 -1
- package/dist/manifest/validators/expected-files.cjs.map +1 -1
- package/dist/manifest/validators/expected-files.d.cts.map +1 -1
- package/dist/manifest/validators/expected-files.d.mts.map +1 -1
- package/dist/manifest/validators/expected-files.mjs +1 -1
- package/dist/manifest/validators/expected-files.mjs.map +1 -1
- package/dist/manifest/validators/icon-declared.cjs +1 -1
- package/dist/manifest/validators/icon-declared.cjs.map +1 -1
- package/dist/manifest/validators/icon-declared.d.cts.map +1 -1
- package/dist/manifest/validators/icon-declared.d.mts.map +1 -1
- package/dist/manifest/validators/icon-declared.mjs +1 -1
- package/dist/manifest/validators/icon-declared.mjs.map +1 -1
- package/dist/manifest/validators/icon-dimensions.cjs +1 -1
- package/dist/manifest/validators/icon-dimensions.cjs.map +1 -1
- package/dist/manifest/validators/icon-dimensions.d.cts.map +1 -1
- package/dist/manifest/validators/icon-dimensions.d.mts.map +1 -1
- package/dist/manifest/validators/icon-dimensions.mjs +1 -1
- package/dist/manifest/validators/icon-dimensions.mjs.map +1 -1
- package/dist/manifest/validators/icon-missing.cjs +1 -1
- package/dist/manifest/validators/icon-missing.cjs.map +1 -1
- package/dist/manifest/validators/icon-missing.mjs +1 -1
- package/dist/manifest/validators/icon-missing.mjs.map +1 -1
- package/dist/manifest/validators/is-localization-file.cjs +1 -1
- package/dist/manifest/validators/is-localization-file.cjs.map +1 -1
- package/dist/manifest/validators/is-localization-file.d.cts.map +1 -1
- package/dist/manifest/validators/is-localization-file.d.mts.map +1 -1
- package/dist/manifest/validators/is-localization-file.mjs +1 -1
- package/dist/manifest/validators/is-localization-file.mjs.map +1 -1
- package/dist/manifest/validators/is-package-json.cjs +1 -1
- package/dist/manifest/validators/is-package-json.cjs.map +1 -1
- package/dist/manifest/validators/is-package-json.d.cts.map +1 -1
- package/dist/manifest/validators/is-package-json.d.mts.map +1 -1
- package/dist/manifest/validators/is-package-json.mjs +1 -1
- package/dist/manifest/validators/is-package-json.mjs.map +1 -1
- package/dist/manifest/validators/is-snap-icon.cjs +1 -1
- package/dist/manifest/validators/is-snap-icon.cjs.map +1 -1
- package/dist/manifest/validators/is-snap-icon.mjs +1 -1
- package/dist/manifest/validators/is-snap-icon.mjs.map +1 -1
- package/dist/manifest/validators/is-snap-manifest.cjs +1 -1
- package/dist/manifest/validators/is-snap-manifest.cjs.map +1 -1
- package/dist/manifest/validators/is-snap-manifest.d.cts.map +1 -1
- package/dist/manifest/validators/is-snap-manifest.d.mts.map +1 -1
- package/dist/manifest/validators/is-snap-manifest.mjs +1 -1
- package/dist/manifest/validators/is-snap-manifest.mjs.map +1 -1
- package/dist/manifest/validators/manifest-localization.cjs +1 -1
- package/dist/manifest/validators/manifest-localization.cjs.map +1 -1
- package/dist/manifest/validators/manifest-localization.d.cts.map +1 -1
- package/dist/manifest/validators/manifest-localization.d.mts.map +1 -1
- package/dist/manifest/validators/manifest-localization.mjs +1 -1
- package/dist/manifest/validators/manifest-localization.mjs.map +1 -1
- package/dist/manifest/validators/package-json-recommended-fields.cjs +1 -1
- package/dist/manifest/validators/package-json-recommended-fields.cjs.map +1 -1
- package/dist/manifest/validators/package-json-recommended-fields.d.cts.map +1 -1
- package/dist/manifest/validators/package-json-recommended-fields.d.mts.map +1 -1
- package/dist/manifest/validators/package-json-recommended-fields.mjs +1 -1
- package/dist/manifest/validators/package-json-recommended-fields.mjs.map +1 -1
- package/dist/manifest/validators/package-name-match.cjs +1 -1
- package/dist/manifest/validators/package-name-match.cjs.map +1 -1
- package/dist/manifest/validators/package-name-match.d.cts.map +1 -1
- package/dist/manifest/validators/package-name-match.d.mts.map +1 -1
- package/dist/manifest/validators/package-name-match.mjs +1 -1
- package/dist/manifest/validators/package-name-match.mjs.map +1 -1
- package/dist/manifest/validators/platform-version.cjs +2 -2
- package/dist/manifest/validators/platform-version.cjs.map +1 -1
- package/dist/manifest/validators/platform-version.d.cts.map +1 -1
- package/dist/manifest/validators/platform-version.d.mts.map +1 -1
- package/dist/manifest/validators/platform-version.mjs +2 -2
- package/dist/manifest/validators/platform-version.mjs.map +1 -1
- package/dist/manifest/validators/production-platform-version.cjs +1 -1
- package/dist/manifest/validators/production-platform-version.cjs.map +1 -1
- package/dist/manifest/validators/production-platform-version.d.cts.map +1 -1
- package/dist/manifest/validators/production-platform-version.d.mts.map +1 -1
- package/dist/manifest/validators/production-platform-version.mjs +1 -1
- package/dist/manifest/validators/production-platform-version.mjs.map +1 -1
- package/dist/manifest/validators/repository-match.cjs +1 -1
- package/dist/manifest/validators/repository-match.cjs.map +1 -1
- package/dist/manifest/validators/repository-match.d.cts.map +1 -1
- package/dist/manifest/validators/repository-match.d.mts.map +1 -1
- package/dist/manifest/validators/repository-match.mjs +1 -1
- package/dist/manifest/validators/repository-match.mjs.map +1 -1
- package/dist/manifest/validators/unused-exports.cjs +2 -2
- package/dist/manifest/validators/unused-exports.cjs.map +1 -1
- package/dist/manifest/validators/unused-exports.d.cts.map +1 -1
- package/dist/manifest/validators/unused-exports.d.mts.map +1 -1
- package/dist/manifest/validators/unused-exports.mjs +2 -2
- package/dist/manifest/validators/unused-exports.mjs.map +1 -1
- package/dist/manifest/validators/version-match.cjs +1 -1
- package/dist/manifest/validators/version-match.cjs.map +1 -1
- package/dist/manifest/validators/version-match.d.cts.map +1 -1
- package/dist/manifest/validators/version-match.d.mts.map +1 -1
- package/dist/manifest/validators/version-match.mjs +1 -1
- package/dist/manifest/validators/version-match.mjs.map +1 -1
- package/dist/platform-version.cjs.map +1 -1
- package/dist/platform-version.d.cts +2 -1
- package/dist/platform-version.d.cts.map +1 -1
- package/dist/platform-version.d.mts +2 -1
- package/dist/platform-version.d.mts.map +1 -1
- package/dist/platform-version.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest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K,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAC3B,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAC9D,CACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,8BAA8B,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAsB;IACxD,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,EAAE,GAAG,QAAQ,CAAC;IAE9C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CACtB,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAC5B,CAAC;IAE5B,MAAM,gBAAgB,GAAG,IAAI;SAC1B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC;SAC/D,MAAM,CACL,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QAChB,GAAG,MAAM;QACT,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC;KACrB,CAAC,EACF,EAAE,CACH,CAAC;IAEJ,OAAO,gBAAgC,CAAC;AAC1C,CAAC","sourcesContent":["import { getErrorMessage } from '@metamask/snaps-sdk';\nimport type { Json } from '@metamask/utils';\nimport { assert, isPlainObject } from '@metamask/utils';\nimport { promises as fs } from 'fs';\nimport pathUtils from 'path';\n\nimport type { SnapManifest } from './validation';\nimport type { ValidatorResults } from './validator';\nimport { isReportFixable, hasFixes, runValidators } from './validator';\nimport type { ValidatorMeta, ValidatorReport } from './validator-types';\nimport * as defaultValidators from './validators';\nimport { deepClone } from '../deep-clone';\nimport { readJsonFile } from '../fs';\nimport { parseJson } from '../json';\nimport type { SnapFiles, UnvalidatedSnapFiles } from '../types';\nimport { NpmSnapFileNames } from '../types';\nimport { readVirtualFile, VirtualFile } from '../virtual-file/node';\n\nconst MANIFEST_SORT_ORDER: Record<keyof SnapManifest, number> = {\n $schema: 1,\n version: 2,\n description: 3,\n proposedName: 4,\n repository: 5,\n source: 6,\n initialConnections: 7,\n initialPermissions: 8,\n platformVersion: 9,\n manifestVersion: 10,\n};\n\nexport type CheckManifestReport = Omit<ValidatorReport, 'fix'> & {\n wasFixed?: boolean;\n};\n\n/**\n * The options for the `checkManifest` function.\n */\nexport type CheckManifestOptions = {\n /**\n * Whether to auto-magically try to fix errors and then write the manifest to\n * disk.\n */\n updateAndWriteManifest?: boolean;\n\n /**\n * The source code of the Snap.\n */\n sourceCode?: string;\n\n /**\n * The function to use to write the manifest to disk.\n */\n writeFileFn?: WriteFileFunction;\n\n /**\n * The exports detected by evaluating the bundle. This may be used by one or\n * more validators to determine whether the Snap is valid.\n */\n exports?: string[];\n\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 * Whether the compiler is running in watch mode. This is used to determine\n * whether to fix warnings or errors only.\n */\n watchMode?: boolean;\n};\n\n/**\n * The result from the `checkManifest` function.\n *\n * @property manifest - The fixed manifest object.\n * @property updated - Whether the manifest was written and updated.\n */\nexport type CheckManifestResult = {\n files?: SnapFiles;\n updated: boolean;\n reports: CheckManifestReport[];\n};\n\nexport type WriteFileFunction = (path: string, data: string) => Promise<void>;\n\n/**\n * Validates a snap.manifest.json file. Attempts to fix the manifest and write\n * the fixed version to disk if `writeManifest` is true. Throws if validation\n * fails.\n *\n * @param basePath - The path to the folder with the manifest files.\n * @param options - Additional options for the function.\n * @param options.sourceCode - The source code of the Snap.\n * @param options.writeFileFn - The function to use to write the manifest to\n * disk.\n * @param options.updateAndWriteManifest - Whether to auto-magically try to fix\n * errors and then write the manifest to disk.\n * @param options.exports - The exports detected by evaluating the bundle. This\n * may be used by one or more validators to determine whether the Snap is valid.\n * @param options.handlerEndowments - An object containing the names of the\n * handlers and their respective permission name. This must be provided to avoid\n * circular dependencies between `@metamask/snaps-utils` and\n * `@metamask/snaps-rpc-methods`.\n * @param options.watchMode - Whether the compiler is running in watch mode.\n * This is used to determine whether to fix warnings or errors only.\n * @returns Whether the manifest was updated, and an array of warnings that\n * were encountered during processing of the manifest files.\n */\nexport async function checkManifest(\n basePath: string,\n {\n updateAndWriteManifest = true,\n sourceCode,\n writeFileFn = fs.writeFile,\n exports,\n handlerEndowments,\n watchMode = false,\n }: CheckManifestOptions = {},\n): Promise<CheckManifestResult> {\n const manifestPath = pathUtils.join(basePath, NpmSnapFileNames.Manifest);\n const manifestFile = await readJsonFile(manifestPath);\n const unvalidatedManifest = manifestFile.result;\n\n const packageFile = await readJsonFile(\n pathUtils.join(basePath, NpmSnapFileNames.PackageJson),\n );\n\n const auxiliaryFilePaths = getSnapFilePaths(\n unvalidatedManifest,\n (manifest) => manifest?.source?.files,\n );\n\n const localizationFilePaths = getSnapFilePaths(\n unvalidatedManifest,\n (manifest) => manifest?.source?.locales,\n );\n const localizationFiles =\n (await getSnapFiles(basePath, localizationFilePaths)) ?? [];\n for (const localization of localizationFiles) {\n try {\n localization.result = parseJson(localization.toString());\n } catch (error) {\n assert(error instanceof SyntaxError, error);\n throw new Error(\n `Failed to parse localization file \"${localization.path}\" as JSON.`,\n );\n }\n }\n\n const snapFiles: UnvalidatedSnapFiles = {\n manifest: manifestFile,\n packageJson: packageFile,\n sourceCode: await getSnapSourceCode(\n basePath,\n unvalidatedManifest,\n sourceCode,\n ),\n svgIcon: await getSnapIcon(basePath, unvalidatedManifest),\n // Intentionally pass null as the encoding here since the files may be binary\n auxiliaryFiles:\n (await getSnapFiles(basePath, auxiliaryFilePaths, null)) ?? [],\n localizationFiles,\n };\n\n const validatorResults = await runValidators(\n snapFiles,\n Object.values(defaultValidators),\n { exports, handlerEndowments },\n );\n\n let manifestResults: CheckManifestResult = {\n updated: false,\n files: validatorResults.files,\n reports: validatorResults.reports,\n };\n\n if (updateAndWriteManifest && hasFixes(manifestResults, watchMode)) {\n const fixedResults = await runFixes(validatorResults, undefined, watchMode);\n\n if (fixedResults.updated) {\n manifestResults = fixedResults;\n\n assert(manifestResults.files);\n\n try {\n await writeFileFn(\n pathUtils.join(basePath, NpmSnapFileNames.Manifest),\n manifestResults.files.manifest.toString(),\n );\n } catch (error) {\n // Note: This error isn't pushed to the errors array, because it's not an\n // error in the manifest itself.\n throw new Error(\n `Failed to update \"snap.manifest.json\": ${getErrorMessage(error)}`,\n );\n }\n }\n }\n\n return manifestResults;\n}\n\n/**\n * Run the algorithm for automatically fixing errors in manifest.\n *\n * The algorithm updates the manifest by fixing all fixable problems,\n * and then run validation again to check if the new manifest is now correct.\n * If not correct, the algorithm will use the manifest from previous iteration\n * and try again `MAX_ATTEMPTS` times to update it before bailing and\n * resulting in failure.\n *\n * @param results - Results of the initial run of validation.\n * @param rules - Optional list of rules to run the fixes with.\n * @param errorsOnly - Whether to only run fixes for errors, not warnings.\n * @returns The updated manifest and whether it was updated.\n */\nexport async function runFixes(\n results: ValidatorResults,\n rules?: ValidatorMeta[],\n errorsOnly = false,\n): Promise<CheckManifestResult> {\n let shouldRunFixes = true;\n const MAX_ATTEMPTS = 10;\n\n assert(results.files);\n\n let fixResults: ValidatorResults = results;\n assert(fixResults.files);\n fixResults.files.manifest = fixResults.files.manifest.clone();\n\n for (\n let attempts = 1;\n shouldRunFixes && attempts <= MAX_ATTEMPTS;\n attempts++\n ) {\n assert(fixResults.files);\n\n let manifest = fixResults.files.manifest.result;\n\n const fixable = fixResults.reports.filter((report) =>\n isReportFixable(report, errorsOnly),\n );\n\n for (const report of fixable) {\n assert(report.fix);\n ({ manifest } = await report.fix({ manifest }));\n }\n\n fixResults.files.manifest.value = `${JSON.stringify(\n getWritableManifest(manifest),\n null,\n 2,\n )}\\n`;\n fixResults.files.manifest.result = manifest;\n\n fixResults = await runValidators(fixResults.files, rules);\n shouldRunFixes = hasFixes(fixResults, errorsOnly);\n }\n\n const initialReports: (CheckManifestReport & ValidatorReport)[] = deepClone(\n results.reports,\n );\n\n // Was fixed\n if (!shouldRunFixes) {\n for (const report of initialReports) {\n if (report.fix) {\n report.wasFixed = true;\n delete report.fix;\n }\n }\n\n return {\n files: fixResults.files,\n updated: true,\n reports: initialReports,\n };\n }\n\n for (const report of initialReports) {\n delete report.fix;\n }\n\n return {\n files: results.files,\n updated: false,\n reports: initialReports,\n };\n}\n\n/**\n * Given an unvalidated Snap manifest, attempts to extract the location of the\n * bundle source file location and read the file.\n *\n * @param basePath - The path to the folder with the manifest files.\n * @param manifest - The unvalidated Snap manifest file contents.\n * @param sourceCode - Override source code for plugins.\n * @returns The contents of the bundle file, if any.\n */\nexport async function getSnapSourceCode(\n basePath: string,\n manifest: Json,\n sourceCode?: string,\n): Promise<VirtualFile | undefined> {\n if (!isPlainObject(manifest)) {\n return undefined;\n }\n\n const sourceFilePath = (manifest as Partial<SnapManifest>).source?.location\n ?.npm?.filePath;\n\n if (!sourceFilePath) {\n return undefined;\n }\n\n if (sourceCode) {\n return new VirtualFile({\n path: pathUtils.join(basePath, sourceFilePath),\n value: sourceCode,\n });\n }\n\n try {\n const virtualFile = await readVirtualFile(\n pathUtils.join(basePath, sourceFilePath),\n 'utf8',\n );\n return virtualFile;\n } catch (error) {\n throw new Error(\n `Failed to read snap bundle file: ${getErrorMessage(error)}`,\n );\n }\n}\n\n/**\n * Given an unvalidated Snap manifest, attempts to extract the location of the\n * icon and read the file.\n *\n * @param basePath - The path to the folder with the manifest files.\n * @param manifest - The unvalidated Snap manifest file contents.\n * @returns The contents of the icon, if any.\n */\nexport async function getSnapIcon(\n basePath: string,\n manifest: Json,\n): Promise<VirtualFile | undefined> {\n if (!isPlainObject(manifest)) {\n return undefined;\n }\n\n const iconPath = (manifest as Partial<SnapManifest>).source?.location?.npm\n ?.iconPath;\n\n if (!iconPath) {\n return undefined;\n }\n\n try {\n const virtualFile = await readVirtualFile(\n pathUtils.join(basePath, iconPath),\n 'utf8',\n );\n return virtualFile;\n } catch (error) {\n throw new Error(`Failed to read snap icon file: ${getErrorMessage(error)}`);\n }\n}\n\n/**\n * Get an array of paths from an unvalidated Snap manifest.\n *\n * @param manifest - The unvalidated Snap manifest file contents.\n * @param selector - A function that returns the paths to the files.\n * @returns The paths to the files, if any.\n */\nexport function getSnapFilePaths(\n manifest: Json,\n selector: (manifest: Partial<SnapManifest>) => string[] | undefined,\n) {\n if (!isPlainObject(manifest)) {\n return undefined;\n }\n\n const snapManifest = manifest as Partial<SnapManifest>;\n const paths = selector(snapManifest);\n\n if (!Array.isArray(paths)) {\n return undefined;\n }\n\n return paths;\n}\n\n/**\n * Given an unvalidated Snap manifest, attempts to extract the files with the\n * given paths and read them.\n *\n * @param basePath - The path to the folder with the manifest files.\n * @param paths - The paths to the files.\n * @param encoding - An optional encoding to pass down to readVirtualFile.\n * @returns A list of auxiliary files and their contents, if any.\n */\nexport async function getSnapFiles(\n basePath: string,\n paths: string[] | undefined,\n encoding: BufferEncoding | null = 'utf8',\n): Promise<VirtualFile[] | undefined> {\n if (!paths) {\n return undefined;\n }\n\n try {\n return await Promise.all(\n paths.map(async (filePath) =>\n readVirtualFile(pathUtils.join(basePath, filePath), encoding),\n ),\n );\n } catch (error) {\n throw new Error(`Failed to read snap files: ${getErrorMessage(error)}`);\n }\n}\n\n/**\n * Sorts the given manifest in our preferred sort order and removes the\n * `repository` field if it is falsy (it may be `null`).\n *\n * @param manifest - The manifest to sort and modify.\n * @returns The disk-ready manifest.\n */\nexport function getWritableManifest(manifest: SnapManifest): SnapManifest {\n const { repository, ...remaining } = manifest;\n\n const keys = Object.keys(\n repository ? { ...remaining, repository } : remaining,\n ) as (keyof SnapManifest)[];\n\n const writableManifest = keys\n .sort((a, b) => MANIFEST_SORT_ORDER[a] - MANIFEST_SORT_ORDER[b])\n .reduce<Partial<SnapManifest>>(\n (result, key) => ({\n ...result,\n [key]: manifest[key],\n }),\n {},\n );\n\n return writableManifest as SnapManifest;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"manifest.mjs","sourceRoot":"","sources":["../../src/manifest/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,4BAA4B;AAEtD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,wBAAwB;AACxD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,WAAW;AACpC,OAAO,SAAS,aAAa;AAI7B,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,aAAa,EAAE,wBAAoB;AAEvE,OAAO,KAAK,iBAAiB,+BAAqB;AAClD,OAAO,EAAE,SAAS,EAAE,0BAAsB;AAC1C,OAAO,EAAE,YAAY,EAAE,kBAAc;AACrC,OAAO,EAAE,SAAS,EAAE,oBAAgB;AAEpC,OAAO,EAAE,gBAAgB,EAAE,qBAAiB;AAC5C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,iCAA6B;AAEpE,MAAM,mBAAmB,GAAuC;IAC9D,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,CAAC;IACf,UAAU,EAAE,CAAC;IACb,MAAM,EAAE,CAAC;IACT,kBAAkB,EAAE,CAAC;IACrB,kBAAkB,EAAE,CAAC;IACrB,eAAe,EAAE,CAAC;IAClB,eAAe,EAAE,EAAE;CACpB,CAAC;AA4DF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAgB,EAChB,EACE,sBAAsB,GAAG,IAAI,EAC7B,UAAU,EACV,WAAW,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AAG,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAC5B,CAAC;IAE5B,MAAM,gBAAgB,GAAG,IAAI;SAC1B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC;SAC/D,MAAM,CACL,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QAChB,GAAG,MAAM;QACT,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC;KACrB,CAAC,EACF,EAAE,CACH,CAAC;IAEJ,OAAO,gBAAgC,CAAC;AAC1C,CAAC","sourcesContent":["import { getErrorMessage } from '@metamask/snaps-sdk';\nimport type { Json } from '@metamask/utils';\nimport { assert, isPlainObject } from '@metamask/utils';\nimport { promises as fs } from 'fs';\nimport pathUtils from 'path';\n\nimport type { SnapManifest } from './validation';\nimport type { ValidatorResults } from './validator';\nimport { isReportFixable, hasFixes, runValidators } from './validator';\nimport type { ValidatorMeta, ValidatorReport } from './validator-types';\nimport * as defaultValidators from './validators';\nimport { deepClone } from '../deep-clone';\nimport { readJsonFile } from '../fs';\nimport { parseJson } from '../json';\nimport type { SnapFiles, UnvalidatedSnapFiles } from '../types';\nimport { NpmSnapFileNames } from '../types';\nimport { readVirtualFile, VirtualFile } from '../virtual-file/node';\n\nconst MANIFEST_SORT_ORDER: Record<keyof SnapManifest, number> = {\n $schema: 1,\n version: 2,\n description: 3,\n proposedName: 4,\n repository: 5,\n source: 6,\n initialConnections: 7,\n initialPermissions: 8,\n platformVersion: 9,\n manifestVersion: 10,\n};\n\nexport type CheckManifestReport = Omit<ValidatorReport, 'fix'> & {\n wasFixed?: boolean;\n};\n\n/**\n * The options for the `checkManifest` function.\n */\nexport type CheckManifestOptions = {\n /**\n * Whether to auto-magically try to fix errors and then write the manifest to\n * disk.\n */\n updateAndWriteManifest?: boolean;\n\n /**\n * The source code of the Snap.\n */\n sourceCode?: string;\n\n /**\n * The function to use to write the manifest to disk.\n */\n writeFileFn?: WriteFileFunction;\n\n /**\n * The exports detected by evaluating the bundle. This may be used by one or\n * more validators to determine whether the Snap is valid.\n */\n exports?: string[];\n\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 * Whether the compiler is running in watch mode. This is used to determine\n * whether to fix warnings or errors only.\n */\n watchMode?: boolean;\n};\n\n/**\n * The result from the `checkManifest` function.\n *\n * @property manifest - The fixed manifest object.\n * @property updated - Whether the manifest was written and updated.\n */\nexport type CheckManifestResult = {\n files?: SnapFiles;\n updated: boolean;\n reports: CheckManifestReport[];\n};\n\nexport type WriteFileFunction = (path: string, data: string) => Promise<void>;\n\n/**\n * Validates a snap.manifest.json file. Attempts to fix the manifest and write\n * the fixed version to disk if `writeManifest` is true. Throws if validation\n * fails.\n *\n * @param basePath - The path to the folder with the manifest files.\n * @param options - Additional options for the function.\n * @param options.sourceCode - The source code of the Snap.\n * @param options.writeFileFn - The function to use to write the manifest to\n * disk.\n * @param options.updateAndWriteManifest - Whether to auto-magically try to fix\n * errors and then write the manifest to disk.\n * @param options.exports - The exports detected by evaluating the bundle. This\n * may be used by one or more validators to determine whether the Snap is valid.\n * @param options.handlerEndowments - An object containing the names of the\n * handlers and their respective permission name. This must be provided to avoid\n * circular dependencies between `@metamask/snaps-utils` and\n * `@metamask/snaps-rpc-methods`.\n * @param options.watchMode - Whether the compiler is running in watch mode.\n * This is used to determine whether to fix warnings or errors only.\n * @returns Whether the manifest was updated, and an array of warnings that\n * were encountered during processing of the manifest files.\n */\nexport async function checkManifest(\n basePath: string,\n {\n updateAndWriteManifest = true,\n sourceCode,\n writeFileFn = fs.writeFile,\n exports,\n handlerEndowments,\n watchMode = false,\n }: CheckManifestOptions = {},\n): Promise<CheckManifestResult> {\n const manifestPath = pathUtils.join(basePath, NpmSnapFileNames.Manifest);\n const manifestFile = await readJsonFile(manifestPath);\n const unvalidatedManifest = manifestFile.result;\n\n const packageFile = await readJsonFile(\n pathUtils.join(basePath, NpmSnapFileNames.PackageJson),\n );\n\n const auxiliaryFilePaths = getSnapFilePaths(\n unvalidatedManifest,\n (manifest) => manifest?.source?.files,\n );\n\n const localizationFilePaths = getSnapFilePaths(\n unvalidatedManifest,\n (manifest) => manifest?.source?.locales,\n );\n const localizationFiles =\n (await getSnapFiles(basePath, localizationFilePaths)) ?? [];\n for (const localization of localizationFiles) {\n try {\n localization.result = parseJson(localization.toString());\n } catch (error) {\n assert(error instanceof SyntaxError, error);\n throw new Error(\n `Failed to parse localization file \"${localization.path}\" as JSON.`,\n );\n }\n }\n\n const snapFiles: UnvalidatedSnapFiles = {\n manifest: manifestFile,\n packageJson: packageFile,\n sourceCode: await getSnapSourceCode(\n basePath,\n unvalidatedManifest,\n sourceCode,\n ),\n svgIcon: await getSnapIcon(basePath, unvalidatedManifest),\n // Intentionally pass null as the encoding here since the files may be binary\n auxiliaryFiles:\n (await getSnapFiles(basePath, auxiliaryFilePaths, null)) ?? [],\n localizationFiles,\n };\n\n const validatorResults = await runValidators(\n snapFiles,\n Object.values(defaultValidators),\n { exports, handlerEndowments },\n );\n\n let manifestResults: CheckManifestResult = {\n updated: false,\n files: validatorResults.files,\n reports: validatorResults.reports,\n };\n\n if (updateAndWriteManifest && hasFixes(manifestResults, watchMode)) {\n const fixedResults = await runFixes(validatorResults, undefined, watchMode);\n\n if (fixedResults.updated) {\n manifestResults = fixedResults;\n\n assert(manifestResults.files);\n\n try {\n await writeFileFn(\n pathUtils.join(basePath, NpmSnapFileNames.Manifest),\n manifestResults.files.manifest.toString(),\n );\n } catch (error) {\n // Note: This error isn't pushed to the errors array, because it's not an\n // error in the manifest itself.\n throw new Error(\n `Failed to update \"snap.manifest.json\": ${getErrorMessage(error)}`,\n );\n }\n }\n }\n\n return manifestResults;\n}\n\n/**\n * Run the algorithm for automatically fixing errors in manifest.\n *\n * The algorithm updates the manifest by fixing all fixable problems,\n * and then run validation again to check if the new manifest is now correct.\n * If not correct, the algorithm will use the manifest from previous iteration\n * and try again `MAX_ATTEMPTS` times to update it before bailing and\n * resulting in failure.\n *\n * @param results - Results of the initial run of validation.\n * @param rules - Optional list of rules to run the fixes with.\n * @param errorsOnly - Whether to only run fixes for errors, not warnings.\n * @returns The updated manifest and whether it was updated.\n */\nexport async function runFixes(\n results: ValidatorResults,\n rules?: ValidatorMeta[],\n errorsOnly = false,\n): Promise<CheckManifestResult> {\n let shouldRunFixes = true;\n const MAX_ATTEMPTS = 10;\n\n assert(results.files);\n\n let fixResults: ValidatorResults = results;\n assert(fixResults.files);\n fixResults.files.manifest = fixResults.files.manifest.clone();\n\n const mergedReports: ValidatorReport[] = deepClone(fixResults.reports);\n\n for (\n let attempts = 1;\n shouldRunFixes && attempts <= MAX_ATTEMPTS;\n attempts++\n ) {\n assert(fixResults.files);\n\n let manifest = fixResults.files.manifest.result;\n\n const fixable = fixResults.reports.filter((report) =>\n isReportFixable(report, errorsOnly),\n );\n\n for (const report of fixable) {\n assert(report.fix);\n ({ manifest } = await report.fix({ manifest }));\n }\n\n fixResults.files.manifest.value = `${JSON.stringify(\n getWritableManifest(manifest),\n null,\n 2,\n )}\\n`;\n fixResults.files.manifest.result = manifest;\n\n fixResults = await runValidators(fixResults.files, rules);\n shouldRunFixes = hasFixes(fixResults, errorsOnly);\n\n fixResults.reports\n .filter(\n (report) =>\n !mergedReports.some((mergedReport) => mergedReport.id === report.id),\n )\n .forEach((report) => mergedReports.push(report));\n }\n\n const allReports: (CheckManifestReport & ValidatorReport)[] =\n deepClone(mergedReports);\n\n // Was fixed\n if (!shouldRunFixes) {\n for (const report of allReports) {\n if (report.fix) {\n report.wasFixed = true;\n delete report.fix;\n }\n }\n\n return {\n files: fixResults.files,\n updated: true,\n reports: allReports,\n };\n }\n\n for (const report of allReports) {\n delete report.fix;\n }\n\n return {\n files: results.files,\n updated: false,\n reports: allReports,\n };\n}\n\n/**\n * Given an unvalidated Snap manifest, attempts to extract the location of the\n * bundle source file location and read the file.\n *\n * @param basePath - The path to the folder with the manifest files.\n * @param manifest - The unvalidated Snap manifest file contents.\n * @param sourceCode - Override source code for plugins.\n * @returns The contents of the bundle file, if any.\n */\nexport async function getSnapSourceCode(\n basePath: string,\n manifest: Json,\n sourceCode?: string,\n): Promise<VirtualFile | undefined> {\n if (!isPlainObject(manifest)) {\n return undefined;\n }\n\n const sourceFilePath = (manifest as Partial<SnapManifest>).source?.location\n ?.npm?.filePath;\n\n if (!sourceFilePath) {\n return undefined;\n }\n\n if (sourceCode) {\n return new VirtualFile({\n path: pathUtils.join(basePath, sourceFilePath),\n value: sourceCode,\n });\n }\n\n try {\n const virtualFile = await readVirtualFile(\n pathUtils.join(basePath, sourceFilePath),\n 'utf8',\n );\n return virtualFile;\n } catch (error) {\n throw new Error(\n `Failed to read snap bundle file: ${getErrorMessage(error)}`,\n );\n }\n}\n\n/**\n * Given an unvalidated Snap manifest, attempts to extract the location of the\n * icon and read the file.\n *\n * @param basePath - The path to the folder with the manifest files.\n * @param manifest - The unvalidated Snap manifest file contents.\n * @returns The contents of the icon, if any.\n */\nexport async function getSnapIcon(\n basePath: string,\n manifest: Json,\n): Promise<VirtualFile | undefined> {\n if (!isPlainObject(manifest)) {\n return undefined;\n }\n\n const iconPath = (manifest as Partial<SnapManifest>).source?.location?.npm\n ?.iconPath;\n\n if (!iconPath) {\n return undefined;\n }\n\n try {\n const virtualFile = await readVirtualFile(\n pathUtils.join(basePath, iconPath),\n 'utf8',\n );\n return virtualFile;\n } catch (error) {\n throw new Error(`Failed to read snap icon file: ${getErrorMessage(error)}`);\n }\n}\n\n/**\n * Get an array of paths from an unvalidated Snap manifest.\n *\n * @param manifest - The unvalidated Snap manifest file contents.\n * @param selector - A function that returns the paths to the files.\n * @returns The paths to the files, if any.\n */\nexport function getSnapFilePaths(\n manifest: Json,\n selector: (manifest: Partial<SnapManifest>) => string[] | undefined,\n) {\n if (!isPlainObject(manifest)) {\n return undefined;\n }\n\n const snapManifest = manifest as Partial<SnapManifest>;\n const paths = selector(snapManifest);\n\n if (!Array.isArray(paths)) {\n return undefined;\n }\n\n return paths;\n}\n\n/**\n * Given an unvalidated Snap manifest, attempts to extract the files with the\n * given paths and read them.\n *\n * @param basePath - The path to the folder with the manifest files.\n * @param paths - The paths to the files.\n * @param encoding - An optional encoding to pass down to readVirtualFile.\n * @returns A list of auxiliary files and their contents, if any.\n */\nexport async function getSnapFiles(\n basePath: string,\n paths: string[] | undefined,\n encoding: BufferEncoding | null = 'utf8',\n): Promise<VirtualFile[] | undefined> {\n if (!paths) {\n return undefined;\n }\n\n try {\n return await Promise.all(\n paths.map(async (filePath) =>\n readVirtualFile(pathUtils.join(basePath, filePath), encoding),\n ),\n );\n } catch (error) {\n throw new Error(`Failed to read snap files: ${getErrorMessage(error)}`);\n }\n}\n\n/**\n * Sorts the given manifest in our preferred sort order and removes the\n * `repository` field if it is falsy (it may be `null`).\n *\n * @param manifest - The manifest to sort and modify.\n * @returns The disk-ready manifest.\n */\nexport function getWritableManifest(manifest: SnapManifest): SnapManifest {\n const { repository, ...remaining } = manifest;\n\n const keys = Object.keys(\n repository ? { ...remaining, repository } : remaining,\n ) as (keyof SnapManifest)[];\n\n const writableManifest = keys\n .sort((a, b) => MANIFEST_SORT_ORDER[a] - MANIFEST_SORT_ORDER[b])\n .reduce<Partial<SnapManifest>>(\n (result, key) => ({\n ...result,\n [key]: manifest[key],\n }),\n {},\n );\n\n return writableManifest as SnapManifest;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator-types.cjs","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: (message: string, fix?: ValidatorFix) => void;\n readonly options?: ValidatorContextOptions;\n};\n\nexport type ValidatorReport = {\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 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.cjs","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"]}
|
|
@@ -24,10 +24,11 @@ export type ValidatorContextOptions = {
|
|
|
24
24
|
};
|
|
25
25
|
export type ValidatorSeverity = 'error' | 'warning';
|
|
26
26
|
export type ValidatorContext = {
|
|
27
|
-
readonly report: (message: string, fix?: ValidatorFix) => void;
|
|
27
|
+
readonly report: (id: string, message: string, fix?: ValidatorFix) => void;
|
|
28
28
|
readonly options?: ValidatorContextOptions;
|
|
29
29
|
};
|
|
30
30
|
export type ValidatorReport = {
|
|
31
|
+
id: string;
|
|
31
32
|
severity: ValidatorSeverity;
|
|
32
33
|
message: string;
|
|
33
34
|
fix?: ValidatorFix;
|
|
@@ -35,7 +36,8 @@ export type ValidatorReport = {
|
|
|
35
36
|
export type ValidatorMeta = {
|
|
36
37
|
severity: ValidatorSeverity;
|
|
37
38
|
/**
|
|
38
|
-
* 1. Run the validator on unverified files to ensure that the files are
|
|
39
|
+
* 1. Run the validator on unverified files to ensure that the files are
|
|
40
|
+
* structurally sound.
|
|
39
41
|
*
|
|
40
42
|
* @param files - Files to be verified
|
|
41
43
|
* @param context - Validator context to report errors
|
|
@@ -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,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;
|
|
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,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,SAAS,EAChB,OAAO,EAAE,gBAAgB,KACtB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B,CAAC"}
|
|
@@ -24,10 +24,11 @@ export type ValidatorContextOptions = {
|
|
|
24
24
|
};
|
|
25
25
|
export type ValidatorSeverity = 'error' | 'warning';
|
|
26
26
|
export type ValidatorContext = {
|
|
27
|
-
readonly report: (message: string, fix?: ValidatorFix) => void;
|
|
27
|
+
readonly report: (id: string, message: string, fix?: ValidatorFix) => void;
|
|
28
28
|
readonly options?: ValidatorContextOptions;
|
|
29
29
|
};
|
|
30
30
|
export type ValidatorReport = {
|
|
31
|
+
id: string;
|
|
31
32
|
severity: ValidatorSeverity;
|
|
32
33
|
message: string;
|
|
33
34
|
fix?: ValidatorFix;
|
|
@@ -35,7 +36,8 @@ export type ValidatorReport = {
|
|
|
35
36
|
export type ValidatorMeta = {
|
|
36
37
|
severity: ValidatorSeverity;
|
|
37
38
|
/**
|
|
38
|
-
* 1. Run the validator on unverified files to ensure that the files are
|
|
39
|
+
* 1. Run the validator on unverified files to ensure that the files are
|
|
40
|
+
* structurally sound.
|
|
39
41
|
*
|
|
40
42
|
* @param files - Files to be verified
|
|
41
43
|
* @param context - Validator context to report errors
|
|
@@ -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,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,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B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CACd,KAAK,EAAE,SAAS,EAChB,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: (message: string, fix?: ValidatorFix) => void;\n readonly options?: ValidatorContextOptions;\n};\n\nexport type ValidatorReport = {\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 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 { 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"]}
|
|
@@ -39,12 +39,21 @@ class Context {
|
|
|
39
39
|
constructor(options) {
|
|
40
40
|
this.#options = options;
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Report a validation error or warning.
|
|
44
|
+
*
|
|
45
|
+
* @param id - The unique identifier for the report.
|
|
46
|
+
* @param message - The message describing the validation issue.
|
|
47
|
+
* @param fix - An optional fix function that can be used to automatically
|
|
48
|
+
* resolve the issue.
|
|
49
|
+
*/
|
|
50
|
+
report(id, message, fix) {
|
|
43
51
|
(0, utils_1.assert)(this.#nextSeverity !== undefined);
|
|
44
52
|
this.reports.push({
|
|
45
|
-
|
|
53
|
+
id,
|
|
46
54
|
message,
|
|
47
55
|
fix,
|
|
56
|
+
severity: this.#nextSeverity,
|
|
48
57
|
});
|
|
49
58
|
}
|
|
50
59
|
prepareForValidator(settings) {
|
|
@@ -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,MAAM,CAAC,OAAe,EAAE,GAAkB;
|
|
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,CAA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,EAAE,KAAkB;QACzB,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;AACJ,CAAC;AAjCD,sCAiCC;AAED;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,MAAuB,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 { 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 +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;
|
|
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 +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;
|
|
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"}
|
|
@@ -13,12 +13,21 @@ class Context {
|
|
|
13
13
|
constructor(options) {
|
|
14
14
|
this.#options = options;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Report a validation error or warning.
|
|
18
|
+
*
|
|
19
|
+
* @param id - The unique identifier for the report.
|
|
20
|
+
* @param message - The message describing the validation issue.
|
|
21
|
+
* @param fix - An optional fix function that can be used to automatically
|
|
22
|
+
* resolve the issue.
|
|
23
|
+
*/
|
|
24
|
+
report(id, message, fix) {
|
|
17
25
|
assert(this.#nextSeverity !== undefined);
|
|
18
26
|
this.reports.push({
|
|
19
|
-
|
|
27
|
+
id,
|
|
20
28
|
message,
|
|
21
29
|
fix,
|
|
30
|
+
severity: this.#nextSeverity,
|
|
22
31
|
});
|
|
23
32
|
}
|
|
24
33
|
prepareForValidator(settings) {
|
|
@@ -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,MAAM,CAAC,OAAe,EAAE,GAAkB;
|
|
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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U,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 { 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"]}
|
|
@@ -13,7 +13,7 @@ exports.checksum = {
|
|
|
13
13
|
const gotChecksum = files.manifest.result.source.shasum;
|
|
14
14
|
const expectedChecksum = await (0, snaps_1.getSnapChecksum)(fetchedFiles);
|
|
15
15
|
if (gotChecksum !== expectedChecksum) {
|
|
16
|
-
context.report(`"${types_1.NpmSnapFileNames.Manifest}" "shasum" field does not match computed shasum. Got "${gotChecksum}", expected "${expectedChecksum}".`, async ({ manifest }) => {
|
|
16
|
+
context.report('checksum', `"${types_1.NpmSnapFileNames.Manifest}" "shasum" field does not match computed shasum. Got "${gotChecksum}", expected "${expectedChecksum}".`, async ({ manifest }) => {
|
|
17
17
|
manifest.source.shasum = expectedChecksum;
|
|
18
18
|
return { manifest };
|
|
19
19
|
});
|
|
@@ -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,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 `\"${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;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 +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,
|
|
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 +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,
|
|
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"}
|
|
@@ -10,7 +10,7 @@ export const checksum = {
|
|
|
10
10
|
const gotChecksum = files.manifest.result.source.shasum;
|
|
11
11
|
const expectedChecksum = await getSnapChecksum(fetchedFiles);
|
|
12
12
|
if (gotChecksum !== expectedChecksum) {
|
|
13
|
-
context.report(`"${NpmSnapFileNames.Manifest}" "shasum" field does not match computed shasum. Got "${gotChecksum}", expected "${expectedChecksum}".`, async ({ manifest }) => {
|
|
13
|
+
context.report('checksum', `"${NpmSnapFileNames.Manifest}" "shasum" field does not match computed shasum. Got "${gotChecksum}", expected "${expectedChecksum}".`, async ({ manifest }) => {
|
|
14
14
|
manifest.source.shasum = expectedChecksum;
|
|
15
15
|
return { manifest };
|
|
16
16
|
});
|
|
@@ -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,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 `\"${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;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"]}
|
|
@@ -16,7 +16,7 @@ exports.expectedFiles = {
|
|
|
16
16
|
structureCheck(files, context) {
|
|
17
17
|
for (const expectedFile of EXPECTED_SNAP_FILES) {
|
|
18
18
|
if (!files[expectedFile]) {
|
|
19
|
-
context.report(`Missing file "${SnapFileNameFromKey[expectedFile]}".`);
|
|
19
|
+
context.report(`expected-files-${expectedFile}`, `Missing file "${SnapFileNameFromKey[expectedFile]}".`);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expected-files.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/expected-files.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAG/C,MAAM,mBAAmB,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,YAAY,CAAU,CAAC;AAE/E,MAAM,mBAAmB,GAAG;IAC1B,QAAQ,EAAE,wBAAgB,CAAC,QAAQ;IACnC,WAAW,EAAE,wBAAgB,CAAC,WAAW;IACzC,UAAU,EAAE,oBAAoB;CACxB,CAAC;AAEX;;GAEG;AACU,QAAA,aAAa,GAAkB;IAC1C,QAAQ,EAAE,OAAO;IACjB,cAAc,CAAC,KAAK,EAAE,OAAO;QAC3B,KAAK,MAAM,YAAY,IAAI,mBAAmB,EAAE,CAAC;YAC/C,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;gBACzB,OAAO,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"expected-files.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/expected-files.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAG/C,MAAM,mBAAmB,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,YAAY,CAAU,CAAC;AAE/E,MAAM,mBAAmB,GAAG;IAC1B,QAAQ,EAAE,wBAAgB,CAAC,QAAQ;IACnC,WAAW,EAAE,wBAAgB,CAAC,WAAW;IACzC,UAAU,EAAE,oBAAoB;CACxB,CAAC;AAEX;;GAEG;AACU,QAAA,aAAa,GAAkB;IAC1C,QAAQ,EAAE,OAAO;IACjB,cAAc,CAAC,KAAK,EAAE,OAAO;QAC3B,KAAK,MAAM,YAAY,IAAI,mBAAmB,EAAE,CAAC;YAC/C,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;gBACzB,OAAO,CAAC,MAAM,CACZ,kBAAkB,YAAY,EAAE,EAChC,iBAAiB,mBAAmB,CAAC,YAAY,CAAC,IAAI,CACvD,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { NpmSnapFileNames } from '../../types';\nimport type { ValidatorMeta } from '../validator-types';\n\nconst EXPECTED_SNAP_FILES = ['manifest', 'packageJson', 'sourceCode'] as const;\n\nconst SnapFileNameFromKey = {\n manifest: NpmSnapFileNames.Manifest,\n packageJson: NpmSnapFileNames.PackageJson,\n sourceCode: 'source code bundle',\n} as const;\n\n/**\n * Check if all the required files are included.\n */\nexport const expectedFiles: ValidatorMeta = {\n severity: 'error',\n structureCheck(files, context) {\n for (const expectedFile of EXPECTED_SNAP_FILES) {\n if (!files[expectedFile]) {\n context.report(\n `expected-files-${expectedFile}`,\n `Missing file \"${SnapFileNameFromKey[expectedFile]}\".`,\n );\n }\n }\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expected-files.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/expected-files.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAUxD;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"expected-files.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/expected-files.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAUxD;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,aAY3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expected-files.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/expected-files.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAUxD;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"expected-files.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/expected-files.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAUxD;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,aAY3B,CAAC"}
|
|
@@ -13,7 +13,7 @@ export const expectedFiles = {
|
|
|
13
13
|
structureCheck(files, context) {
|
|
14
14
|
for (const expectedFile of EXPECTED_SNAP_FILES) {
|
|
15
15
|
if (!files[expectedFile]) {
|
|
16
|
-
context.report(`Missing file "${SnapFileNameFromKey[expectedFile]}".`);
|
|
16
|
+
context.report(`expected-files-${expectedFile}`, `Missing file "${SnapFileNameFromKey[expectedFile]}".`);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expected-files.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/expected-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAG/C,MAAM,mBAAmB,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,YAAY,CAAU,CAAC;AAE/E,MAAM,mBAAmB,GAAG;IAC1B,QAAQ,EAAE,gBAAgB,CAAC,QAAQ;IACnC,WAAW,EAAE,gBAAgB,CAAC,WAAW;IACzC,UAAU,EAAE,oBAAoB;CACxB,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,QAAQ,EAAE,OAAO;IACjB,cAAc,CAAC,KAAK,EAAE,OAAO;QAC3B,KAAK,MAAM,YAAY,IAAI,mBAAmB,EAAE,CAAC;YAC/C,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;gBACzB,OAAO,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"expected-files.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/expected-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAG/C,MAAM,mBAAmB,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,YAAY,CAAU,CAAC;AAE/E,MAAM,mBAAmB,GAAG;IAC1B,QAAQ,EAAE,gBAAgB,CAAC,QAAQ;IACnC,WAAW,EAAE,gBAAgB,CAAC,WAAW;IACzC,UAAU,EAAE,oBAAoB;CACxB,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,QAAQ,EAAE,OAAO;IACjB,cAAc,CAAC,KAAK,EAAE,OAAO;QAC3B,KAAK,MAAM,YAAY,IAAI,mBAAmB,EAAE,CAAC;YAC/C,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;gBACzB,OAAO,CAAC,MAAM,CACZ,kBAAkB,YAAY,EAAE,EAChC,iBAAiB,mBAAmB,CAAC,YAAY,CAAC,IAAI,CACvD,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { NpmSnapFileNames } from '../../types';\nimport type { ValidatorMeta } from '../validator-types';\n\nconst EXPECTED_SNAP_FILES = ['manifest', 'packageJson', 'sourceCode'] as const;\n\nconst SnapFileNameFromKey = {\n manifest: NpmSnapFileNames.Manifest,\n packageJson: NpmSnapFileNames.PackageJson,\n sourceCode: 'source code bundle',\n} as const;\n\n/**\n * Check if all the required files are included.\n */\nexport const expectedFiles: ValidatorMeta = {\n severity: 'error',\n structureCheck(files, context) {\n for (const expectedFile of EXPECTED_SNAP_FILES) {\n if (!files[expectedFile]) {\n context.report(\n `expected-files-${expectedFile}`,\n `Missing file \"${SnapFileNameFromKey[expectedFile]}\".`,\n );\n }\n }\n },\n};\n"]}
|
|
@@ -8,7 +8,7 @@ exports.iconDeclared = {
|
|
|
8
8
|
severity: 'warning',
|
|
9
9
|
semanticCheck(files, context) {
|
|
10
10
|
if (!files.manifest.result.source.location.npm.iconPath) {
|
|
11
|
-
context.report('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.');
|
|
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
|
},
|
|
14
14
|
};
|
|
@@ -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,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 '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,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-declared.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/icon-declared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"icon-declared.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/icon-declared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,aAU1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-declared.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/icon-declared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"icon-declared.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/icon-declared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,aAU1B,CAAC"}
|
|
@@ -5,7 +5,7 @@ export const iconDeclared = {
|
|
|
5
5
|
severity: 'warning',
|
|
6
6
|
semanticCheck(files, context) {
|
|
7
7
|
if (!files.manifest.result.source.location.npm.iconPath) {
|
|
8
|
-
context.report('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.');
|
|
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
|
},
|
|
11
11
|
};
|
|
@@ -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,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 '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,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"]}
|
|
@@ -13,7 +13,7 @@ exports.iconDimensions = {
|
|
|
13
13
|
}
|
|
14
14
|
const dimensions = (0, icon_1.getSvgDimensions)(files.svgIcon.toString());
|
|
15
15
|
if (dimensions && dimensions?.height !== dimensions.width) {
|
|
16
|
-
context.report('The icon in the Snap manifest is not square. It is recommended to use a square icon for the Snap.');
|
|
16
|
+
context.report('icon-dimensions', 'The icon in the Snap manifest is not square. It is recommended to use a square icon for the Snap.');
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-dimensions.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/icon-dimensions.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAG9C;;GAEG;AACU,QAAA,cAAc,GAAkB;IAC3C,QAAQ,EAAE,SAAS;IACnB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,IAAA,uBAAgB,EAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9D,IAAI,UAAU,IAAI,UAAU,EAAE,MAAM,KAAK,UAAU,CAAC,KAAK,EAAE,CAAC;YAC1D,OAAO,CAAC,MAAM,CACZ,mGAAmG,CACpG,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { getSvgDimensions } from '../../icon';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify the icon is square.\n */\nexport const iconDimensions: ValidatorMeta = {\n severity: 'warning',\n semanticCheck(files, context) {\n if (!files.svgIcon) {\n return;\n }\n\n const dimensions = getSvgDimensions(files.svgIcon.toString());\n if (dimensions && dimensions?.height !== dimensions.width) {\n context.report(\n 'The icon in the Snap manifest is not square. It is recommended to use a square icon for the Snap.',\n );\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"icon-dimensions.cjs","sourceRoot":"","sources":["../../../src/manifest/validators/icon-dimensions.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAG9C;;GAEG;AACU,QAAA,cAAc,GAAkB;IAC3C,QAAQ,EAAE,SAAS;IACnB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,IAAA,uBAAgB,EAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9D,IAAI,UAAU,IAAI,UAAU,EAAE,MAAM,KAAK,UAAU,CAAC,KAAK,EAAE,CAAC;YAC1D,OAAO,CAAC,MAAM,CACZ,iBAAiB,EACjB,mGAAmG,CACpG,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { getSvgDimensions } from '../../icon';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify the icon is square.\n */\nexport const iconDimensions: ValidatorMeta = {\n severity: 'warning',\n semanticCheck(files, context) {\n if (!files.svgIcon) {\n return;\n }\n\n const dimensions = getSvgDimensions(files.svgIcon.toString());\n if (dimensions && dimensions?.height !== dimensions.width) {\n context.report(\n 'icon-dimensions',\n 'The icon in the Snap manifest is not square. It is recommended to use a square icon for the Snap.',\n );\n }\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-dimensions.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/icon-dimensions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"icon-dimensions.d.cts","sourceRoot":"","sources":["../../../src/manifest/validators/icon-dimensions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,aAe5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-dimensions.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/icon-dimensions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"icon-dimensions.d.mts","sourceRoot":"","sources":["../../../src/manifest/validators/icon-dimensions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA2B;AAExD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,aAe5B,CAAC"}
|
|
@@ -10,7 +10,7 @@ export const iconDimensions = {
|
|
|
10
10
|
}
|
|
11
11
|
const dimensions = getSvgDimensions(files.svgIcon.toString());
|
|
12
12
|
if (dimensions && dimensions?.height !== dimensions.width) {
|
|
13
|
-
context.report('The icon in the Snap manifest is not square. It is recommended to use a square icon for the Snap.');
|
|
13
|
+
context.report('icon-dimensions', 'The icon in the Snap manifest is not square. It is recommended to use a square icon for the Snap.');
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-dimensions.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/icon-dimensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,uBAAmB;AAG9C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB;IAC3C,QAAQ,EAAE,SAAS;IACnB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9D,IAAI,UAAU,IAAI,UAAU,EAAE,MAAM,KAAK,UAAU,CAAC,KAAK,EAAE,CAAC;YAC1D,OAAO,CAAC,MAAM,CACZ,mGAAmG,CACpG,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { getSvgDimensions } from '../../icon';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify the icon is square.\n */\nexport const iconDimensions: ValidatorMeta = {\n severity: 'warning',\n semanticCheck(files, context) {\n if (!files.svgIcon) {\n return;\n }\n\n const dimensions = getSvgDimensions(files.svgIcon.toString());\n if (dimensions && dimensions?.height !== dimensions.width) {\n context.report(\n 'The icon in the Snap manifest is not square. It is recommended to use a square icon for the Snap.',\n );\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"icon-dimensions.mjs","sourceRoot":"","sources":["../../../src/manifest/validators/icon-dimensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,uBAAmB;AAG9C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB;IAC3C,QAAQ,EAAE,SAAS;IACnB,aAAa,CAAC,KAAK,EAAE,OAAO;QAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9D,IAAI,UAAU,IAAI,UAAU,EAAE,MAAM,KAAK,UAAU,CAAC,KAAK,EAAE,CAAC;YAC1D,OAAO,CAAC,MAAM,CACZ,iBAAiB,EACjB,mGAAmG,CACpG,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { getSvgDimensions } from '../../icon';\nimport type { ValidatorMeta } from '../validator-types';\n\n/**\n * Verify the icon is square.\n */\nexport const iconDimensions: ValidatorMeta = {\n severity: 'warning',\n semanticCheck(files, context) {\n if (!files.svgIcon) {\n return;\n }\n\n const dimensions = getSvgDimensions(files.svgIcon.toString());\n if (dimensions && dimensions?.height !== dimensions.width) {\n context.report(\n 'icon-dimensions',\n 'The icon in the Snap manifest is not square. It is recommended to use a square icon for the Snap.',\n );\n }\n },\n};\n"]}
|
|
@@ -9,7 +9,7 @@ exports.iconMissing = {
|
|
|
9
9
|
semanticCheck(files, context) {
|
|
10
10
|
const { iconPath } = files.manifest.result.source.location.npm;
|
|
11
11
|
if (iconPath && !files.svgIcon) {
|
|
12
|
-
context.report(`Could not find icon "${iconPath}".`);
|
|
12
|
+
context.report('icon-missing', `Could not find icon "${iconPath}".`);
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
};
|
|
@@ -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,wBAAwB,QAAQ,IAAI,CAAC,CAAC;
|
|
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"]}
|
|
@@ -6,7 +6,7 @@ export const iconMissing = {
|
|
|
6
6
|
semanticCheck(files, context) {
|
|
7
7
|
const { iconPath } = files.manifest.result.source.location.npm;
|
|
8
8
|
if (iconPath && !files.svgIcon) {
|
|
9
|
-
context.report(`Could not find icon "${iconPath}".`);
|
|
9
|
+
context.report('icon-missing', `Could not find icon "${iconPath}".`);
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
};
|
|
@@ -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,wBAAwB,QAAQ,IAAI,CAAC,CAAC;
|
|
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"]}
|
|
@@ -14,7 +14,7 @@ exports.isLocalizationFile = {
|
|
|
14
14
|
const [error] = (0, superstruct_1.validate)(file.result, localization_1.LocalizationFileStruct);
|
|
15
15
|
if (error) {
|
|
16
16
|
for (const failure of error.failures()) {
|
|
17
|
-
context.report(`Failed to validate localization file "${file.path}": ${(0, structs_1.getStructFailureMessage)(localization_1.LocalizationFileStruct, failure, false)}`);
|
|
17
|
+
context.report(`is-localization-file-${file.path}-${failure.type}-${failure.path.join('-')}`, `Failed to validate localization file "${file.path}": ${(0, structs_1.getStructFailureMessage)(localization_1.LocalizationFileStruct, failure, false)}`);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
}
|