@metamask/snaps-cli 7.0.0 → 7.2.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 +22 -1
- package/README.md +1 -0
- package/dist/builders.cjs +9 -0
- package/dist/builders.cjs.map +1 -1
- package/dist/builders.d.cts +9 -0
- package/dist/builders.d.cts.map +1 -1
- package/dist/builders.d.mts +9 -0
- package/dist/builders.d.mts.map +1 -1
- package/dist/builders.mjs +9 -0
- package/dist/builders.mjs.map +1 -1
- package/dist/commands/build/build.cjs +12 -23
- package/dist/commands/build/build.cjs.map +1 -1
- package/dist/commands/build/build.d.cts +9 -0
- package/dist/commands/build/build.d.cts.map +1 -1
- package/dist/commands/build/build.d.mts +9 -0
- package/dist/commands/build/build.d.mts.map +1 -1
- package/dist/commands/build/build.mjs +11 -22
- package/dist/commands/build/build.mjs.map +1 -1
- package/dist/commands/build/implementation.cjs.map +1 -1
- package/dist/commands/build/implementation.d.cts.map +1 -1
- package/dist/commands/build/implementation.d.mts.map +1 -1
- package/dist/commands/build/implementation.mjs.map +1 -1
- package/dist/commands/build/index.cjs +4 -2
- package/dist/commands/build/index.cjs.map +1 -1
- package/dist/commands/build/index.d.cts +1 -0
- package/dist/commands/build/index.d.cts.map +1 -1
- package/dist/commands/build/index.d.mts +1 -0
- package/dist/commands/build/index.d.mts.map +1 -1
- package/dist/commands/build/index.mjs +2 -2
- package/dist/commands/build/index.mjs.map +1 -1
- package/dist/commands/index.cjs +2 -0
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts.map +1 -1
- package/dist/commands/index.d.mts.map +1 -1
- package/dist/commands/index.mjs +2 -0
- package/dist/commands/index.mjs.map +1 -1
- package/dist/commands/manifest/implementation.cjs +8 -4
- package/dist/commands/manifest/implementation.cjs.map +1 -1
- package/dist/commands/manifest/implementation.d.cts +2 -1
- package/dist/commands/manifest/implementation.d.cts.map +1 -1
- package/dist/commands/manifest/implementation.d.mts +2 -1
- package/dist/commands/manifest/implementation.d.mts.map +1 -1
- package/dist/commands/manifest/implementation.mjs +8 -4
- package/dist/commands/manifest/implementation.mjs.map +1 -1
- package/dist/commands/manifest/index.cjs +5 -1
- package/dist/commands/manifest/index.cjs.map +1 -1
- package/dist/commands/manifest/index.d.cts.map +1 -1
- package/dist/commands/manifest/index.d.mts.map +1 -1
- package/dist/commands/manifest/index.mjs +5 -1
- package/dist/commands/manifest/index.mjs.map +1 -1
- package/dist/commands/manifest/manifest.cjs +20 -4
- package/dist/commands/manifest/manifest.cjs.map +1 -1
- package/dist/commands/manifest/manifest.d.cts +1 -0
- package/dist/commands/manifest/manifest.d.cts.map +1 -1
- package/dist/commands/manifest/manifest.d.mts +1 -0
- package/dist/commands/manifest/manifest.d.mts.map +1 -1
- package/dist/commands/manifest/manifest.mjs +21 -5
- package/dist/commands/manifest/manifest.mjs.map +1 -1
- package/dist/commands/sandbox/index.cjs +17 -0
- package/dist/commands/sandbox/index.cjs.map +1 -0
- package/dist/commands/sandbox/index.d.cts +10 -0
- package/dist/commands/sandbox/index.d.cts.map +1 -0
- package/dist/commands/sandbox/index.d.mts +10 -0
- package/dist/commands/sandbox/index.d.mts.map +1 -0
- package/dist/commands/sandbox/index.mjs +12 -0
- package/dist/commands/sandbox/index.mjs.map +1 -0
- package/dist/commands/sandbox/sandbox.cjs +33 -0
- package/dist/commands/sandbox/sandbox.cjs.map +1 -0
- package/dist/commands/sandbox/sandbox.d.cts +14 -0
- package/dist/commands/sandbox/sandbox.d.cts.map +1 -0
- package/dist/commands/sandbox/sandbox.d.mts +14 -0
- package/dist/commands/sandbox/sandbox.d.mts.map +1 -0
- package/dist/commands/sandbox/sandbox.mjs +29 -0
- package/dist/commands/sandbox/sandbox.mjs.map +1 -0
- package/dist/commands/sandbox/server.cjs +27 -0
- package/dist/commands/sandbox/server.cjs.map +1 -0
- package/dist/commands/sandbox/server.d.cts +14 -0
- package/dist/commands/sandbox/server.d.cts.map +1 -0
- package/dist/commands/sandbox/server.d.mts +14 -0
- package/dist/commands/sandbox/server.d.mts.map +1 -0
- package/dist/commands/sandbox/server.mjs +25 -0
- package/dist/commands/sandbox/server.mjs.map +1 -0
- package/dist/commands/watch/watch.cjs +1 -1
- package/dist/commands/watch/watch.cjs.map +1 -1
- package/dist/commands/watch/watch.mjs +1 -1
- package/dist/commands/watch/watch.mjs.map +1 -1
- package/dist/webpack/config.cjs +1 -1
- package/dist/webpack/config.cjs.map +1 -1
- package/dist/webpack/config.d.cts.map +1 -1
- package/dist/webpack/config.d.mts.map +1 -1
- package/dist/webpack/config.mjs +1 -1
- package/dist/webpack/config.mjs.map +1 -1
- package/dist/webpack/plugins.cjs +2 -2
- package/dist/webpack/plugins.cjs.map +1 -1
- package/dist/webpack/plugins.d.cts.map +1 -1
- package/dist/webpack/plugins.d.mts.map +1 -1
- package/dist/webpack/plugins.mjs +2 -2
- package/dist/webpack/plugins.mjs.map +1 -1
- package/dist/webpack/server.cjs +83 -72
- package/dist/webpack/server.cjs.map +1 -1
- package/dist/webpack/server.d.cts +6 -1
- package/dist/webpack/server.d.cts.map +1 -1
- package/dist/webpack/server.d.mts +6 -1
- package/dist/webpack/server.d.mts.map +1 -1
- package/dist/webpack/server.mjs +63 -72
- package/dist/webpack/server.mjs.map +1 -1
- package/package.json +11 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["../../src/webpack/server.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["../../src/webpack/server.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,mCAAmC;AAE5E,OAAO,UAAS,EAAE,MAAM,IAAI,aAAa,EAAE,yBAAgB;;AAG3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa;AAI1E;;;;;;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CAAC,OAAO,EAAiB,CAAC;gBAChD,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;YACjD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC","sourcesContent":["import type { SnapManifest } from '@metamask/snaps-utils';\nimport { NpmSnapFileNames, readJsonFile } from '@metamask/snaps-utils/node';\nimport type { Express, Request } from 'express';\nimport express, { static as expressStatic } from 'express';\nimport type { Server } from 'http';\nimport type { AddressInfo } from 'net';\nimport { join, relative, resolve as resolvePath, sep, posix } from 'path';\n\nimport type { ProcessedConfig } from '../config';\n\n/**\n * Get the relative path from one path to another.\n *\n * Note: This is a modified version of `path.relative` that uses Posix\n * separators for URL-compatibility.\n *\n * @param from - The path to start from.\n * @param to - The path to end at.\n * @returns The relative path.\n */\nfunction getRelativePath(from: string, to: string) {\n return relative(from, to).split(sep).join(posix.sep);\n}\n\n/**\n * Get the allowed paths for the static server. This includes the output file,\n * the manifest file, and any auxiliary/localization files.\n *\n * @param config - The config object.\n * @param manifest - The Snap manifest object.\n * @returns An array of allowed paths.\n */\nexport function getAllowedPaths(\n config: ProcessedConfig,\n manifest: SnapManifest,\n) {\n const auxiliaryFiles =\n manifest.source.files?.map((file) =>\n getRelativePath(\n config.server.root,\n resolvePath(config.server.root, file),\n ),\n ) ?? [];\n\n const localizationFiles =\n manifest.source.locales?.map((localization) =>\n getRelativePath(\n config.server.root,\n resolvePath(config.server.root, localization),\n ),\n ) ?? [];\n\n const otherFiles = manifest.source.location.npm.iconPath\n ? [\n getRelativePath(\n config.server.root,\n resolvePath(\n config.server.root,\n manifest.source.location.npm.iconPath,\n ),\n ),\n ]\n : [];\n\n return [\n getRelativePath(\n config.server.root,\n resolvePath(\n config.server.root,\n config.output.path,\n config.output.filename,\n ),\n ),\n getRelativePath(\n config.server.root,\n resolvePath(config.server.root, NpmSnapFileNames.Manifest),\n ),\n ...auxiliaryFiles,\n ...localizationFiles,\n ...otherFiles,\n ];\n}\n\n/**\n * Get whether the request path is allowed. This is used to check if the request\n * path is in the list of allowed paths for the static server.\n *\n * @param request - The request object.\n * @param config - The config object.\n * @returns A promise that resolves to `true` if the path is allowed, or\n * `false` if it is not.\n */\nasync function isAllowedPath(request: Request, config: ProcessedConfig) {\n const manifestPath = join(config.server.root, NpmSnapFileNames.Manifest);\n const { result } = await readJsonFile<SnapManifest>(manifestPath);\n const allowedPaths = getAllowedPaths(config, result);\n\n const path = request.path.slice(1);\n return allowedPaths.some((allowedPath) => path === allowedPath);\n}\n\ntype Middleware = (app: Express) => void;\n\n/**\n * Get a static server for development purposes.\n *\n * Note: We're intentionally not using `webpack-dev-server` here because it\n * adds a lot of extra stuff to the output that we don't need, and it's\n * difficult to customize.\n *\n * @param config - The config object.\n * @param middleware - An array of middleware functions to run before serving\n * the static files.\n * @returns An object with a `listen` method that returns a promise that\n * resolves when the server is listening.\n */\nexport function getServer(\n config: ProcessedConfig,\n middleware: Middleware[] = [],\n) {\n const app = express();\n\n // Run \"middleware\" functions before serving the static files.\n middleware.forEach((fn) => fn(app));\n\n // Check for allowed paths in the request URL.\n app.use((request, response, next) => {\n isAllowedPath(request, config)\n .then((allowed) => {\n if (allowed) {\n // eslint-disable-next-line promise/no-callback-in-promise\n next();\n return;\n }\n\n response.status(404);\n response.end();\n })\n // eslint-disable-next-line promise/no-callback-in-promise\n .catch(next);\n });\n\n // Serve the static files.\n app.use(\n expressStatic(config.server.root, {\n dotfiles: 'deny',\n setHeaders: (res) => {\n res.setHeader('Cache-Control', 'no-cache');\n res.setHeader('Access-Control-Allow-Origin', '*');\n },\n }),\n );\n\n /**\n * Start the server on the port specified in the config.\n *\n * @param port - The port to listen on.\n * @returns A promise that resolves when the server is listening. The promise\n * resolves to an object with the port and the server instance. Note that if\n * the `config.server.port` is `0`, the OS will choose a random port for us,\n * so we need to get the port from the server after it starts.\n */\n const listen = async (port = config.server.port) => {\n return new Promise<{\n port: number;\n server: Server;\n close: () => Promise<void>;\n }>((resolve, reject) => {\n // eslint-disable-next-line consistent-return\n const server = app.listen(port, (error) => {\n if (error) {\n return reject(error);\n }\n\n const close = async () => {\n await new Promise<void>((resolveClose, rejectClose) => {\n server.close((closeError) => {\n if (closeError) {\n return rejectClose(closeError);\n }\n\n return resolveClose();\n });\n });\n };\n\n const address = server.address() as AddressInfo;\n resolve({ port: address.port, server, close });\n });\n });\n };\n\n return { listen };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-cli",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "A CLI for developing MetaMask Snaps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -64,11 +64,13 @@
|
|
|
64
64
|
"test:watch": "jest --watch"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@metamask/snaps-
|
|
68
|
-
"@metamask/snaps-
|
|
69
|
-
"@metamask/snaps-
|
|
67
|
+
"@metamask/snaps-rpc-methods": "^12.4.0",
|
|
68
|
+
"@metamask/snaps-sandbox": "^1.0.0",
|
|
69
|
+
"@metamask/snaps-sdk": "^7.1.0",
|
|
70
|
+
"@metamask/snaps-utils": "^9.4.0",
|
|
71
|
+
"@metamask/snaps-webpack-plugin": "^4.3.0",
|
|
70
72
|
"@metamask/superstruct": "^3.2.1",
|
|
71
|
-
"@metamask/utils": "^11.
|
|
73
|
+
"@metamask/utils": "^11.4.0",
|
|
72
74
|
"@swc/core": "1.3.78",
|
|
73
75
|
"assert": "^2.0.0",
|
|
74
76
|
"browserify-zlib": "^0.2.0",
|
|
@@ -79,6 +81,7 @@
|
|
|
79
81
|
"crypto-browserify": "^3.12.0",
|
|
80
82
|
"domain-browser": "^4.22.0",
|
|
81
83
|
"events": "^3.3.0",
|
|
84
|
+
"express": "^5.1.0",
|
|
82
85
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
83
86
|
"https-browserify": "^1.0.0",
|
|
84
87
|
"ora": "^5.4.1",
|
|
@@ -89,7 +92,6 @@
|
|
|
89
92
|
"querystring-es3": "^0.2.1",
|
|
90
93
|
"readable-stream": "^3.6.2",
|
|
91
94
|
"semver": "^7.5.4",
|
|
92
|
-
"serve-handler": "^6.1.5",
|
|
93
95
|
"stream-browserify": "^3.0.0",
|
|
94
96
|
"stream-http": "^3.2.0",
|
|
95
97
|
"string_decoder": "^1.3.0",
|
|
@@ -107,13 +109,13 @@
|
|
|
107
109
|
"yargs": "^17.7.1"
|
|
108
110
|
},
|
|
109
111
|
"devDependencies": {
|
|
110
|
-
"@lavamoat/allow-scripts": "^3.
|
|
111
|
-
"@metamask/auto-changelog": "^5.0.
|
|
112
|
+
"@lavamoat/allow-scripts": "^3.3.3",
|
|
113
|
+
"@metamask/auto-changelog": "^5.0.2",
|
|
112
114
|
"@swc/jest": "^0.2.26",
|
|
113
115
|
"@ts-bridge/cli": "^0.6.1",
|
|
116
|
+
"@types/express": "^5.0.1",
|
|
114
117
|
"@types/jest": "^27.5.1",
|
|
115
118
|
"@types/node": "18.14.2",
|
|
116
|
-
"@types/serve-handler": "^6.1.0",
|
|
117
119
|
"@types/yargs": "^17.0.24",
|
|
118
120
|
"cross-fetch": "^3.1.5",
|
|
119
121
|
"deepmerge": "^4.2.2",
|