From 2b9ac556f50c2a5ff3728abb23f465d705f8a933 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Tue, 9 Jul 2024 18:31:11 +0200 Subject: [PATCH 1/3] feat: Inline WebView bundle (#2528) Inline the Snaps execution bundle in the WebView index.html, this will get us closer to running Snaps without a remote execution environment on mobile. --- .../scripts/build.js | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/snaps-execution-environments/scripts/build.js b/packages/snaps-execution-environments/scripts/build.js index 9c4d0f90c9..ef4f1290fd 100644 --- a/packages/snaps-execution-environments/scripts/build.js +++ b/packages/snaps-execution-environments/scripts/build.js @@ -34,6 +34,7 @@ const ENTRY_POINTS = { webview: { entryPoint: './src/webview/index.ts', html: true, + inlineBundle: true, }, }; @@ -99,7 +100,7 @@ async function main() { - MetaMask Snaps Iframe Execution Environment + MetaMask Snaps Execution Environment @@ -107,10 +108,22 @@ async function main() { `; + const createInlinedHTML = (bundleSource) => ` + + + + MetaMask Snaps Execution Environment + + + + + +`; + await Promise.all( Object.entries(ENTRY_POINTS).map(async ([key, config]) => { console.log('Bundling', key); - const { html, node, worker, entryPoint } = config; + const { html, node, worker, entryPoint, inlineBundle } = config; const insertGlobalVars = node ? { process: undefined, ...LavaMoatBrowserify.args.insertGlobalVars } : LavaMoatBrowserify.args.insertGlobalVars; @@ -218,14 +231,19 @@ async function main() { outputBundle = `${runtime}\n${outputBundle}`; } - const bundlePath = path.join(OUTPUT_PATH, key, OUTPUT_BUNDLE); - await fs.mkdir(path.dirname(bundlePath), { recursive: true }); - await fs.writeFile(bundlePath, outputBundle); + if (!inlineBundle) { + const bundlePath = path.join(OUTPUT_PATH, key, OUTPUT_BUNDLE); + await fs.mkdir(path.dirname(bundlePath), { recursive: true }); + await fs.writeFile(bundlePath, outputBundle); + } if (html) { const htmlPath = path.join(OUTPUT_PATH, key, OUTPUT_HTML); await fs.mkdir(path.dirname(htmlPath), { recursive: true }); - await fs.writeFile(htmlPath, htmlFile); + await fs.writeFile( + htmlPath, + inlineBundle ? createInlinedHTML(outputBundle) : htmlFile, + ); } const outputBytes = stringToBytes(outputBundle); From 213275458b23bcbe04de43d94e8b30e79868f947 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Wed, 10 Jul 2024 10:22:30 +0200 Subject: [PATCH 2/3] Remove code duplication in LavaMoat build script (#2564) --- .../scripts/build.js | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/packages/snaps-execution-environments/scripts/build.js b/packages/snaps-execution-environments/scripts/build.js index ef4f1290fd..93a88b05ac 100644 --- a/packages/snaps-execution-environments/scripts/build.js +++ b/packages/snaps-execution-environments/scripts/build.js @@ -95,30 +95,23 @@ async function main() { JSON.stringify(lavamoatSecurityOptionsBrowser), ); - const htmlFile = ` - - - - - MetaMask Snaps Execution Environment - - - - - -`; - - const createInlinedHTML = (bundleSource) => ` - - - - MetaMask Snaps Execution Environment - - - - - -`; + const createHtml = (scriptTag) => ` + + + + + MetaMask Snaps Execution Environment + + + + ${scriptTag} + + `; + + const htmlFile = createHtml(''); + + const createInlinedHTML = (bundleSource) => + createHtml(``); await Promise.all( Object.entries(ENTRY_POINTS).map(async ([key, config]) => { From 14804595c0bfd2a539521716ac620fb1f146f2a0 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Wed, 10 Jul 2024 13:49:35 +0200 Subject: [PATCH 3/3] Release 55.0.0 (#2566) This is the release candidate for version `55.0.0`, which simply bumps `snaps-execution-environments`. --- package.json | 2 +- packages/snaps-execution-environments/CHANGELOG.md | 7 ++++++- packages/snaps-execution-environments/package.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index bc3679c970..4172649262 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "root", - "version": "54.0.0", + "version": "55.0.0", "private": true, "repository": { "type": "git", diff --git a/packages/snaps-execution-environments/CHANGELOG.md b/packages/snaps-execution-environments/CHANGELOG.md index 3102535711..8ac19bf85f 100644 --- a/packages/snaps-execution-environments/CHANGELOG.md +++ b/packages/snaps-execution-environments/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [6.6.0] +### Changed +- Inline LavaMoat in WebView bundle ([#2528](https://github.com/MetaMask/snaps/pull/2528), [#2564](https://github.com/MetaMask/snaps/pull/2564)) + ## [6.5.0] ### Added - Add `Checkbox` component ([#2501](https://github.com/MetaMask/snaps/pull/2501)) @@ -220,7 +224,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The version of the package no longer needs to match the version of all other MetaMask Snaps packages. -[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-execution-environments@6.5.0...HEAD +[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-execution-environments@6.6.0...HEAD +[6.6.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-execution-environments@6.5.0...@metamask/snaps-execution-environments@6.6.0 [6.5.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-execution-environments@6.4.0...@metamask/snaps-execution-environments@6.5.0 [6.4.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-execution-environments@6.3.0...@metamask/snaps-execution-environments@6.4.0 [6.3.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-execution-environments@6.2.0...@metamask/snaps-execution-environments@6.3.0 diff --git a/packages/snaps-execution-environments/package.json b/packages/snaps-execution-environments/package.json index a277a350a0..67bd69cfe5 100644 --- a/packages/snaps-execution-environments/package.json +++ b/packages/snaps-execution-environments/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/snaps-execution-environments", - "version": "6.5.0", + "version": "6.6.0", "description": "Snap sandbox environments for executing SES javascript", "repository": { "type": "git",