From 8163a46473282ebf98a1a4e02221d1221e307c6e Mon Sep 17 00:00:00 2001 From: naugtur Date: Mon, 4 Mar 2024 11:03:39 +0100 Subject: [PATCH] webpack build with working lavamoat policy generation --- .../lavamoat-webpack-0.0.1-beta.0.tgz | Bin 18005 -> 0 bytes .../lavamoat/webpack/edit.js | 93 ---- .../lavamoat/webpack/policy-override.json | 3 + .../lavamoat/webpack/policy.json | 417 +++--------------- .../lavamoat/webpack/policy2.json | 284 ------------ .../snaps-execution-environments/package.json | 2 +- .../src/iframe/template.html | 9 + .../webpack.config.ts | 17 +- yarn.lock | 36 +- 9 files changed, 113 insertions(+), 748 deletions(-) delete mode 100644 packages/snaps-execution-environments/lavamoat-webpack-0.0.1-beta.0.tgz delete mode 100644 packages/snaps-execution-environments/lavamoat/webpack/edit.js create mode 100644 packages/snaps-execution-environments/lavamoat/webpack/policy-override.json delete mode 100644 packages/snaps-execution-environments/lavamoat/webpack/policy2.json create mode 100644 packages/snaps-execution-environments/src/iframe/template.html diff --git a/packages/snaps-execution-environments/lavamoat-webpack-0.0.1-beta.0.tgz b/packages/snaps-execution-environments/lavamoat-webpack-0.0.1-beta.0.tgz deleted file mode 100644 index 756f130fc8356b213b7f97d1270a225c17872beb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18005 zcmV((K;XY0iwFP!00002|LuKgR~y;2Xg=##oTj}Z$q^+y=i#$U2C9p#D-`}3jP=mlu+`hT@nU%Dms?NO6o`+dDdLN$aex8l`!+8{si)gC* zVHo_D|KW4}Y;0^ie)v!|J>S^4w{h>@1NDaoj~>G>j~{QqcN_QaKY6$T|Nh|%{LJ$r z%wQ^?VUh5o?7#m*e)@g&mm*&uUFgyK)+kN#LS3tKUA$qq*bk@rMVh@%$Maaf35yH0 zRL@kV|2~g0-D&?N4ll!L8WsRC?XI*RN8!2uQP9UHNtzeYD2K1)v%`af`+k6qH>HD`cc+p9;9>=<;F2V&I*XVs$J$tUMTT1bVmtj2D@SS;m z!r!052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qh{Q8x`1P`%E zn!vdQ$(ZtKmwbsxrqwz~w8S+KxVWsEg(MhZhNp?Yi-bXqkY46|F^QdmF_EYz@PDow zlrtkWjsC&YaLG&po5t0I;=9J=^vVfyN3EA1X7ntMq4>Q=#9dS+~VMR;L6pp zjUzIZVKOd|jmwz@2r*tVvVsLCF&zOsAdAP1JNENKeZKo)X10RMNQ^o6 zJo&H7elW=7cx}CBu)TR#lIAc=X@JPg)%XfhwH!tDzl0;jyMmcPkgf_TjU`%#3X+m& zEohkX25Vv?VGPa~1WXm~w)BQ4W73CGz(;dcoqj}eK)|^lq#(?gNFO!)cuNn@4IkmM@3$) zwI~#iK84?jQXFZR=Rot;SSxxUuz>0hDle^UN^JR5aP-R*Fi4owAK$7yNdfB+_PXV< z5ao!)qw!nHk9D(tbE(HL2w_e+nVAL=6d>KnP~U=xX<(#Sz@2-EkV#|!p=l%% zuq4Sbsk^CT)?ct(EOm*EeugPQ1X3hNR_7X}Z4l~1N5c;IyVD~LMT{}8BaLEYS+zjC5(90EymB`kJzrP5Ak@#1 zk%18`0#%XH{Zr3_5h=vc7fR5$8r`7a zJx(YW>j?#t2!ApGGA6Xfp=Qdk%>ZPhP12;uQs8ai=!x|}KohkwX@{`(^@`ck9jcrV zUSN=#1=nuJVKjwPyL;Cm;xlw@JA=7!v3Z=VO*?FE4%)EK=OJ0Sb^cU#@L?;0BIp)x7rUXP`N7+250$b~93x#M&?}+T#a6vjS^%()5nnc_m|ZdRO0&&-`XGt0K@{4_+;lFoCl1Os3crjdYCv++7|j|;muPD)oD z&YJv?-;f&L>B5z%(^;@i}91eI|Eqr zSd+ZcY8}oKG$l=m3mj0wQ><`7eTvMFeZWhWY1Qj60da<&PzUR3AEd)`A{41*!}DNp5_2=u)*PpLH|EWL!4-FEB`v3?5068X3*8l(j diff --git a/packages/snaps-execution-environments/lavamoat/webpack/edit.js b/packages/snaps-execution-environments/lavamoat/webpack/edit.js deleted file mode 100644 index fe52963b63..0000000000 --- a/packages/snaps-execution-environments/lavamoat/webpack/edit.js +++ /dev/null @@ -1,93 +0,0 @@ -const fs = require('fs'); -const p = require('./policy.json'); -const path = require('path'); -const { - loadCanonicalNameMap, - getPackageNameForModulePath, -} = require('@lavamoat/aa'); - -async function run() { - const cmap = await loadCanonicalNameMap({ - rootDir: path.resolve(__dirname, '../..'), - }); - const cindex = new Set(cmap.values()); - const cinverseNameLookup = {}; - cindex.forEach((a) => { - const k = a.split('>').reverse()[0]; - if (cinverseNameLookup[k]) { - if (cinverseNameLookup[k].length < a.length) return; - } - - cinverseNameLookup[k] = a; - }); - - // console.log(cindex, cindex.has('@swc/cli>semver')); - - function filterOutItems(obj, selfName) { - if (!obj) return {}; - return Object.fromEntries( - Object.entries(obj) - .map(([k, v]) => { - if (k.startsWith('external:../snaps-')) { - const snapPkg = `@metamask/${k.split('/')[1]}`; - if (snapPkg === selfName) return; - return [snapPkg, v]; - } - return [k, v]; - }) - .filter((a) => a) - .map(([k, v]) => { - if (!cindex.has(k)) { - const newk = cinverseNameLookup[k.split('>').reverse()[0]]; - console.log('translating', k, newk); - return [newk, v]; - } - return [k, v]; - }), - ); - } - function merge(a, b, selfName) { - a = a || { packages: {}, globals: {} }; - Object.assign(a.packages, filterOutItems(b.packages, selfName)); - Object.assign(a.globals, b.globals); - return a; - } - - const discoveredResources = {}; - const entries = Object.entries(p.resources) - .map(([k, v]) => { - if (v.packages) { - v.packages = filterOutItems(v.packages, null); - } - if (k.startsWith('external:../snaps-')) { - const snapPkg = `@metamask/${k.split('/')[1]}`; - discoveredResources[snapPkg] = merge( - discoveredResources[snapPkg], - v, - snapPkg, - ); - return; - } - if (!cindex.has(k)) { - const newk = cinverseNameLookup[k.split('>').reverse()[0]]; - console.log('translating', k, newk); - return [newk, v]; - } - - return [k, v]; - }) - .filter((a) => a); - - p.resources = Object.fromEntries([ - ...entries, - ...Object.entries(discoveredResources), - ]); - p['//'] = 'This file was modified by edit.js'; - - fs.writeFileSync( - path.resolve(__dirname, './policy2.json'), - JSON.stringify(p, null, 2), - ); -} - -run(); diff --git a/packages/snaps-execution-environments/lavamoat/webpack/policy-override.json b/packages/snaps-execution-environments/lavamoat/webpack/policy-override.json new file mode 100644 index 0000000000..0ab2f2951f --- /dev/null +++ b/packages/snaps-execution-environments/lavamoat/webpack/policy-override.json @@ -0,0 +1,3 @@ +{ + "resources": {} +} \ No newline at end of file diff --git a/packages/snaps-execution-environments/lavamoat/webpack/policy.json b/packages/snaps-execution-environments/lavamoat/webpack/policy.json index ee6b097b67..caf0733c0b 100644 --- a/packages/snaps-execution-environments/lavamoat/webpack/policy.json +++ b/packages/snaps-execution-environments/lavamoat/webpack/policy.json @@ -1,5 +1,4 @@ { - "//": "this is a copy of browserify/iframe/policy.json with a bunch of edits", "resources": { "@metamask/json-rpc-engine": { "packages": { @@ -34,47 +33,21 @@ "removeEventListener": true }, "packages": { - "@metamask/post-message-stream>@metamask/utils": true, + "@metamask/utils": true, "readable-stream": true } }, - "@metamask/post-message-stream>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@swc/cli>semver": true, - "browserify>buffer": true, - "eslint>debug": true, - "superstruct": true - } - }, "@metamask/providers": { "globals": { - "CustomEvent": true, - "Event": true, - "addEventListener": true, - "chrome.runtime.connect": true, - "console": true, - "dispatchEvent": true, - "document.createElement": true, - "document.readyState": true, - "ethereum": "write", - "location.hostname": true, - "removeEventListener": true, - "web3": true + "console": true }, "packages": { "@metamask/json-rpc-engine": true, "@metamask/object-multiplex": true, "@metamask/providers>@metamask/safe-event-emitter": true, - "@metamask/providers>detect-browser": true, - "@metamask/providers>extension-port-stream": true, "@metamask/providers>is-stream": true, "@metamask/providers>json-rpc-middleware-stream": true, "@metamask/rpc-errors": true, - "@metamask/utils": true, "eslint>fast-deep-equal": true, "readable-stream": true } @@ -84,38 +57,16 @@ "setTimeout": true }, "packages": { - "browserify>events": true + "webpack>events": true } }, - "@metamask/providers>detect-browser": { + "@metamask/providers>extension-port-stream>readable-stream>buffer": { "globals": { - "document": true, - "navigator": true - }, - "packages": { - "browserify>process": true - } - }, - "@metamask/providers>extension-port-stream": { - "packages": { - "@metamask/providers>extension-port-stream>readable-stream": true, - "browserify>buffer": true - } - }, - "@metamask/providers>extension-port-stream>readable-stream": { - "globals": { - "AbortController": true, - "AggregateError": true, - "Blob": true, - "new": true, - "target": true + "console": true }, "packages": { - "@metamask/providers>extension-port-stream>readable-stream>abort-controller": true, - "browserify>buffer": true, - "browserify>events": true, - "browserify>process": true, - "browserify>string_decoder": true + "browserify>buffer>base64-js": true, + "browserify>buffer>ieee754": true } }, "@metamask/providers>json-rpc-middleware-stream": { @@ -134,22 +85,39 @@ "@metamask/utils": true } }, - "@metamask/snaps-sdk>is-svg": { + "@metamask/snaps-sdk": { "packages": { - "@metamask/snaps-sdk>is-svg>fast-xml-parser": true + "@metamask/snaps-sdk>fast-xml-parser": true, + "@metamask/utils": true, + "superstruct": true } }, - "@metamask/snaps-sdk>is-svg>fast-xml-parser": { + "@metamask/snaps-sdk>fast-xml-parser": { "globals": { "entityName": true, "val": true }, "packages": { - "@metamask/snaps-sdk>is-svg>fast-xml-parser>strnum": true + "@metamask/snaps-sdk>fast-xml-parser>strnum": true + } + }, + "@metamask/snaps-utils": { + "globals": { + "URL": true, + "console.error": true, + "console.log": true, + "console.warn": true + }, + "packages": { + "@metamask/rpc-errors": true, + "@metamask/snaps-sdk": true, + "@metamask/utils": true, + "superstruct": true } }, "@metamask/utils": { "globals": { + "Buffer": true, "TextDecoder": true, "TextEncoder": true }, @@ -157,10 +125,9 @@ "@metamask/utils>@noble/hashes": true, "@metamask/utils>@scure/base": true, "@metamask/utils>pony-cause": true, - "@swc/cli>semver": true, - "browserify>buffer": true, - "eslint>debug": true, - "superstruct": true + "depcheck>semver": true, + "superstruct": true, + "tsup>debug": true } }, "@metamask/utils>@noble/hashes": { @@ -175,43 +142,9 @@ "TextEncoder": true } }, - "@swc/cli>semver": { - "globals": { - "console.error": true - }, - "packages": { - "@swc/cli>semver>lru-cache": true, - "browserify>process": true - } - }, - "@swc/cli>semver>lru-cache": { - "packages": { - "@swc/cli>semver>lru-cache>yallist": true - } - }, "browserify>browser-pack>safe-buffer": { "packages": { - "browserify>buffer": true - } - }, - "browserify>buffer": { - "globals": { - "console": true - }, - "packages": { - "browserify>buffer>base64-js": true, - "browserify>buffer>ieee754": true - } - }, - "browserify>events": { - "globals": { - "console": true - } - }, - "browserify>process": { - "globals": { - "clearTimeout": true, - "setTimeout": true + "@metamask/providers>extension-port-stream>readable-stream>buffer": true } }, "browserify>string_decoder": { @@ -219,271 +152,40 @@ "browserify>browser-pack>safe-buffer": true } }, - "eslint>debug": { + "depcheck>semver": { "globals": { - "console": true, - "document": true, - "localStorage": true, - "navigator": true, + "console.error": true, "process": true }, "packages": { - "browserify>process": true, - "eslint>debug>ms": true - } - }, - "external:../snaps-sdk/src/errors.ts": { - "packages": { - "external:../snaps-sdk/src/internals/index.ts": true - } - }, - "external:../snaps-sdk/src/index.ts": { - "packages": { - "external:../snaps-sdk/src/errors.ts": true, - "external:../snaps-sdk/src/internals/index.ts": true, - "external:../snaps-sdk/src/types/index.ts": true, - "external:../snaps-sdk/src/ui/index.ts": true - } - }, - "external:../snaps-sdk/src/internals/error-wrappers.ts": { - "packages": { - "external:../snaps-sdk/src/errors.ts": true - } - }, - "external:../snaps-sdk/src/internals/errors.ts": { - "packages": { - "@metamask/utils": true - } - }, - "external:../snaps-sdk/src/internals/index.ts": { - "packages": { - "external:../snaps-sdk/src/internals/error-wrappers.ts": true, - "external:../snaps-sdk/src/internals/errors.ts": true, - "external:../snaps-sdk/src/internals/helpers.ts": true, - "external:../snaps-sdk/src/internals/structs.ts": true - } - }, - "external:../snaps-sdk/src/internals/structs.ts": { - "packages": { - "superstruct": true - } - }, - "external:../snaps-sdk/src/types/handlers/index.ts": { - "packages": { - "external:../snaps-sdk/src/types/handlers/cronjob.ts": true, - "external:../snaps-sdk/src/types/handlers/home-page.ts": true, - "external:../snaps-sdk/src/types/handlers/keyring.ts": true, - "external:../snaps-sdk/src/types/handlers/lifecycle.ts": true, - "external:../snaps-sdk/src/types/handlers/name-lookup.ts": true, - "external:../snaps-sdk/src/types/handlers/rpc-request.ts": true, - "external:../snaps-sdk/src/types/handlers/transaction.ts": true - } - }, - "external:../snaps-sdk/src/types/index.ts": { - "packages": { - "external:../snaps-sdk/src/types/caip.ts": true, - "external:../snaps-sdk/src/types/global.ts": true, - "external:../snaps-sdk/src/types/handlers/index.ts": true, - "external:../snaps-sdk/src/types/methods/index.ts": true, - "external:../snaps-sdk/src/types/permissions.ts": true, - "external:../snaps-sdk/src/types/provider.ts": true, - "external:../snaps-sdk/src/types/snap.ts": true - } - }, - "external:../snaps-sdk/src/types/methods/index.ts": { - "packages": { - "external:../snaps-sdk/src/types/methods/dialog.ts": true, - "external:../snaps-sdk/src/types/methods/get-bip32-entropy.ts": true, - "external:../snaps-sdk/src/types/methods/get-bip32-public-key.ts": true, - "external:../snaps-sdk/src/types/methods/get-bip44-entropy.ts": true, - "external:../snaps-sdk/src/types/methods/get-entropy.ts": true, - "external:../snaps-sdk/src/types/methods/get-file.ts": true, - "external:../snaps-sdk/src/types/methods/get-locale.ts": true, - "external:../snaps-sdk/src/types/methods/get-snaps.ts": true, - "external:../snaps-sdk/src/types/methods/invoke-keyring.ts": true, - "external:../snaps-sdk/src/types/methods/invoke-snap.ts": true, - "external:../snaps-sdk/src/types/methods/manage-accounts.ts": true, - "external:../snaps-sdk/src/types/methods/manage-state.ts": true, - "external:../snaps-sdk/src/types/methods/methods.ts": true, - "external:../snaps-sdk/src/types/methods/notify.ts": true, - "external:../snaps-sdk/src/types/methods/request-snaps.ts": true - } - }, - "external:../snaps-sdk/src/ui/builder.ts": { - "packages": { - "@metamask/utils": true - } - }, - "external:../snaps-sdk/src/ui/component.ts": { - "packages": { - "@metamask/utils": true, - "external:../snaps-sdk/src/ui/components/index.ts": true, - "superstruct": true - } - }, - "external:../snaps-sdk/src/ui/components/address.ts": { - "packages": { - "external:../snaps-sdk/src/ui/builder.ts": true, - "external:../snaps-sdk/src/ui/nodes.ts": true, - "superstruct": true - } - }, - "external:../snaps-sdk/src/ui/components/copyable.ts": { - "packages": { - "external:../snaps-sdk/src/ui/builder.ts": true, - "external:../snaps-sdk/src/ui/nodes.ts": true, - "superstruct": true - } - }, - "external:../snaps-sdk/src/ui/components/divider.ts": { - "packages": { - "external:../snaps-sdk/src/ui/builder.ts": true, - "external:../snaps-sdk/src/ui/nodes.ts": true, - "superstruct": true - } - }, - "external:../snaps-sdk/src/ui/components/heading.ts": { - "packages": { - "external:../snaps-sdk/src/ui/builder.ts": true, - "external:../snaps-sdk/src/ui/nodes.ts": true, - "superstruct": true - } - }, - "external:../snaps-sdk/src/ui/components/image.ts": { - "packages": { - "@metamask/snaps-sdk>is-svg": true, - "external:../snaps-sdk/src/ui/builder.ts": true, - "external:../snaps-sdk/src/ui/nodes.ts": true, - "superstruct": true - } - }, - "external:../snaps-sdk/src/ui/components/index.ts": { - "packages": { - "external:../snaps-sdk/src/ui/components/address.ts": true, - "external:../snaps-sdk/src/ui/components/copyable.ts": true, - "external:../snaps-sdk/src/ui/components/divider.ts": true, - "external:../snaps-sdk/src/ui/components/heading.ts": true, - "external:../snaps-sdk/src/ui/components/image.ts": true, - "external:../snaps-sdk/src/ui/components/panel.ts": true, - "external:../snaps-sdk/src/ui/components/row.ts": true, - "external:../snaps-sdk/src/ui/components/spinner.ts": true, - "external:../snaps-sdk/src/ui/components/text.ts": true - } - }, - "external:../snaps-sdk/src/ui/components/panel.ts": { - "packages": { - "external:../snaps-sdk/src/ui/builder.ts": true, - "external:../snaps-sdk/src/ui/components/address.ts": true, - "external:../snaps-sdk/src/ui/components/copyable.ts": true, - "external:../snaps-sdk/src/ui/components/divider.ts": true, - "external:../snaps-sdk/src/ui/components/heading.ts": true, - "external:../snaps-sdk/src/ui/components/image.ts": true, - "external:../snaps-sdk/src/ui/components/row.ts": true, - "external:../snaps-sdk/src/ui/components/spinner.ts": true, - "external:../snaps-sdk/src/ui/components/text.ts": true, - "external:../snaps-sdk/src/ui/nodes.ts": true, - "superstruct": true - } - }, - "external:../snaps-sdk/src/ui/components/row.ts": { - "packages": { - "external:../snaps-sdk/src/internals/index.ts": true, - "external:../snaps-sdk/src/ui/builder.ts": true, - "external:../snaps-sdk/src/ui/components/address.ts": true, - "external:../snaps-sdk/src/ui/components/image.ts": true, - "external:../snaps-sdk/src/ui/components/text.ts": true, - "external:../snaps-sdk/src/ui/nodes.ts": true, - "superstruct": true - } - }, - "external:../snaps-sdk/src/ui/components/spinner.ts": { - "packages": { - "external:../snaps-sdk/src/ui/builder.ts": true, - "external:../snaps-sdk/src/ui/nodes.ts": true, - "superstruct": true - } - }, - "external:../snaps-sdk/src/ui/components/text.ts": { - "packages": { - "external:../snaps-sdk/src/ui/builder.ts": true, - "external:../snaps-sdk/src/ui/nodes.ts": true, - "superstruct": true - } - }, - "external:../snaps-sdk/src/ui/index.ts": { - "packages": { - "external:../snaps-sdk/src/ui/component.ts": true, - "external:../snaps-sdk/src/ui/components/index.ts": true, - "external:../snaps-sdk/src/ui/nodes.ts": true - } - }, - "external:../snaps-sdk/src/ui/nodes.ts": { - "packages": { - "superstruct": true - } - }, - "external:../snaps-utils/src/errors.ts": { - "packages": { - "@metamask/rpc-errors": true, - "@metamask/utils": true, - "external:../snaps-sdk/src/index.ts": true - } - }, - "external:../snaps-utils/src/handlers.ts": { - "packages": { - "external:../snaps-sdk/src/index.ts": true, - "external:../snaps-utils/src/handler-types.ts": true, - "superstruct": true - } - }, - "external:../snaps-utils/src/icon.ts": { - "builtin": { - "buffer": true + "depcheck>semver>lru-cache": true, + "process": true } }, - "external:../snaps-utils/src/index.executionenv.ts": { + "depcheck>semver>lru-cache": { "packages": { - "external:../snaps-utils/src/errors.ts": true, - "external:../snaps-utils/src/handler-types.ts": true, - "external:../snaps-utils/src/handlers.ts": true, - "external:../snaps-utils/src/logging.ts": true, - "external:../snaps-utils/src/namespace.ts": true, - "external:../snaps-utils/src/types.ts": true + "depcheck>semver>lru-cache>yallist": true } }, - "external:../snaps-utils/src/logging.ts": { + "process": { "globals": { - "console.error": true, - "console.log": true, - "console.warn": true - }, - "packages": { - "@metamask/utils": true - } - }, - "external:../snaps-utils/src/namespace.ts": { - "packages": { - "superstruct": true + "clearTimeout": true, + "setTimeout": true } }, - "external:../snaps-utils/src/types.ts": { + "readable-stream": { "globals": { - "URL": true + "process.nextTick": true, + "process.stderr": true, + "process.stdout": true }, "packages": { - "@metamask/utils": true, - "superstruct": true - } - }, - "readable-stream": { - "packages": { - "browserify>browser-resolve": true, - "browserify>buffer": true, - "browserify>events": true, + "@metamask/providers>extension-port-stream>readable-stream>buffer": true, "browserify>inherits": true, - "browserify>process": true, "browserify>string_decoder": true, - "readable-stream>util-deprecate": true + "process": true, + "readable-stream>util-deprecate": true, + "webpack>events": true } }, "readable-stream>util-deprecate": { @@ -495,8 +197,25 @@ }, "superstruct": { "globals": { - "console.warn": true, - "define": true + "console.warn": true + } + }, + "tsup>debug": { + "globals": { + "console": true, + "document": true, + "localStorage": true, + "navigator": true, + "process": true + }, + "packages": { + "process": true, + "tsup>debug>ms": true + } + }, + "webpack>events": { + "globals": { + "console": true } } } diff --git a/packages/snaps-execution-environments/lavamoat/webpack/policy2.json b/packages/snaps-execution-environments/lavamoat/webpack/policy2.json deleted file mode 100644 index 5cb0bd9701..0000000000 --- a/packages/snaps-execution-environments/lavamoat/webpack/policy2.json +++ /dev/null @@ -1,284 +0,0 @@ -{ - "//": "This file was modified by edit.js", - "resources": { - "@metamask/json-rpc-engine": { - "packages": { - "@metamask/providers>@metamask/safe-event-emitter": true, - "@metamask/rpc-errors": true, - "@metamask/utils": true - } - }, - "@metamask/object-multiplex": { - "globals": { - "console.warn": true - }, - "packages": { - "@metamask/object-multiplex>once": true, - "readable-stream": true - } - }, - "@metamask/object-multiplex>once": { - "packages": { - "@metamask/object-multiplex>once>wrappy": true - } - }, - "@metamask/post-message-stream": { - "globals": { - "MessageEvent.prototype": true, - "WorkerGlobalScope": true, - "addEventListener": true, - "browser": true, - "chrome": true, - "location.origin": true, - "postMessage": true, - "removeEventListener": true - }, - "packages": { - "@metamask/post-message-stream>@metamask/utils": true, - "readable-stream": true - } - }, - "@metamask/post-message-stream>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>semver": true, - "@metamask/providers>extension-port-stream>readable-stream>buffer": true, - "@metamask/utils>debug": true, - "superstruct": true - } - }, - "@metamask/providers": { - "globals": { - "CustomEvent": true, - "Event": true, - "addEventListener": true, - "chrome.runtime.connect": true, - "console": true, - "dispatchEvent": true, - "document.createElement": true, - "document.readyState": true, - "ethereum": "write", - "location.hostname": true, - "removeEventListener": true, - "web3": true - }, - "packages": { - "@metamask/json-rpc-engine": true, - "@metamask/object-multiplex": true, - "@metamask/providers>@metamask/safe-event-emitter": true, - "@metamask/providers>detect-browser": true, - "@metamask/providers>extension-port-stream": true, - "@metamask/providers>is-stream": true, - "@metamask/providers>json-rpc-middleware-stream": true, - "@metamask/rpc-errors": true, - "@metamask/utils": true, - "@metamask/providers>fast-deep-equal": true, - "readable-stream": true - } - }, - "@metamask/providers>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "@metamask/providers>extension-port-stream>readable-stream>events": true - } - }, - "@metamask/providers>detect-browser": { - "globals": { - "document": true, - "navigator": true - }, - "packages": { - "@metamask/providers>extension-port-stream>readable-stream>process": true - } - }, - "@metamask/providers>extension-port-stream": { - "packages": { - "@metamask/providers>extension-port-stream>readable-stream": true, - "@metamask/providers>extension-port-stream>readable-stream>buffer": true - } - }, - "@metamask/providers>extension-port-stream>readable-stream": { - "globals": { - "AbortController": true, - "AggregateError": true, - "Blob": true, - "new": true, - "target": true - }, - "packages": { - "@metamask/providers>extension-port-stream>readable-stream>abort-controller": true, - "@metamask/providers>extension-port-stream>readable-stream>buffer": true, - "@metamask/providers>extension-port-stream>readable-stream>events": true, - "@metamask/providers>extension-port-stream>readable-stream>process": true, - "readable-stream>string_decoder": true - } - }, - "@metamask/providers>json-rpc-middleware-stream": { - "globals": { - "console.warn": true, - "setTimeout": true - }, - "packages": { - "@metamask/providers>@metamask/safe-event-emitter": true, - "readable-stream": true - } - }, - "@metamask/rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/utils": true - } - }, - "@metamask/snaps-sdk>is-svg": { - "packages": { - "@metamask/snaps-sdk>is-svg>fast-xml-parser": true - } - }, - "@metamask/snaps-sdk>is-svg>fast-xml-parser": { - "globals": { - "entityName": true, - "val": true - }, - "packages": { - "@metamask/snaps-sdk>is-svg>fast-xml-parser>strnum": true - } - }, - "@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@noble/hashes": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@metamask/utils>semver": true, - "@metamask/providers>extension-port-stream>readable-stream>buffer": true, - "@metamask/utils>debug": true, - "superstruct": true - } - }, - "@metamask/utils>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true - } - }, - "@metamask/utils>@scure/base": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - } - }, - "@metamask/utils>semver": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/utils>semver>lru-cache": true, - "@metamask/providers>extension-port-stream>readable-stream>process": true - } - }, - "@metamask/utils>semver>lru-cache": { - "packages": { - "@metamask/utils>semver>lru-cache>yallist": true - } - }, - "readable-stream>string_decoder>safe-buffer": { - "packages": { - "@metamask/providers>extension-port-stream>readable-stream>buffer": true - } - }, - "@metamask/providers>extension-port-stream>readable-stream>buffer": { - "globals": { - "console": true - }, - "packages": { - "@metamask/providers>extension-port-stream>readable-stream>buffer>base64-js": true, - "@metamask/providers>extension-port-stream>readable-stream>buffer>ieee754": true - } - }, - "@metamask/providers>extension-port-stream>readable-stream>events": { - "globals": { - "console": true - } - }, - "@metamask/providers>extension-port-stream>readable-stream>process": { - "globals": { - "clearTimeout": true, - "setTimeout": true - } - }, - "readable-stream>string_decoder": { - "packages": { - "readable-stream>string_decoder>safe-buffer": true - } - }, - "@metamask/utils>debug": { - "globals": { - "console": true, - "document": true, - "localStorage": true, - "navigator": true, - "process": true - }, - "packages": { - "@metamask/providers>extension-port-stream>readable-stream>process": true, - "@metamask/utils>debug>ms": true - } - }, - "readable-stream": { - "packages": { - "undefined": true, - "@metamask/providers>extension-port-stream>readable-stream>buffer": true, - "@metamask/providers>extension-port-stream>readable-stream>events": true, - "readable-stream>inherits": true, - "@metamask/providers>extension-port-stream>readable-stream>process": true, - "readable-stream>string_decoder": true, - "readable-stream>util-deprecate": true - } - }, - "readable-stream>util-deprecate": { - "globals": { - "console.trace": true, - "console.warn": true, - "localStorage": true - } - }, - "superstruct": { - "globals": { - "console.warn": true, - "define": true - } - }, - "@metamask/snaps-sdk": { - "packages": { - "@metamask/snaps-sdk": true, - "@metamask/utils": true, - "superstruct": true, - "@metamask/snaps-sdk>is-svg": true - }, - "globals": {} - }, - "@metamask/snaps-utils": { - "packages": { - "@metamask/rpc-errors": true, - "@metamask/utils": true, - "@metamask/snaps-sdk": true, - "@metamask/snaps-utils": true, - "superstruct": true - }, - "globals": { - "console.error": true, - "console.log": true, - "console.warn": true, - "URL": true - } - } - } -} \ No newline at end of file diff --git a/packages/snaps-execution-environments/package.json b/packages/snaps-execution-environments/package.json index 7d993b2848..02e74703fc 100644 --- a/packages/snaps-execution-environments/package.json +++ b/packages/snaps-execution-environments/package.json @@ -73,7 +73,7 @@ "@lavamoat/allow-scripts": "^3.0.4", "@lavamoat/lavapack": "^6.1.1", "@lavamoat/lavatube": "^1.0.0", - "@lavamoat/webpack": "./lavamoat-webpack-0.0.1-beta.0.tgz", + "@lavamoat/webpack": "0.3.0-beta.0", "@metamask/auto-changelog": "^3.4.4", "@metamask/eslint-config": "^12.1.0", "@metamask/eslint-config-jest": "^12.1.0", diff --git a/packages/snaps-execution-environments/src/iframe/template.html b/packages/snaps-execution-environments/src/iframe/template.html new file mode 100644 index 0000000000..4a062740b5 --- /dev/null +++ b/packages/snaps-execution-environments/src/iframe/template.html @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/packages/snaps-execution-environments/webpack.config.ts b/packages/snaps-execution-environments/webpack.config.ts index 2d56809562..29519e80a0 100644 --- a/packages/snaps-execution-environments/webpack.config.ts +++ b/packages/snaps-execution-environments/webpack.config.ts @@ -1,5 +1,6 @@ -// @ts-expect-error - no type declaration +// @ts-expect-error - types coming soon import LavaMoatPlugin from '@lavamoat/webpack'; +import { readFileSync } from 'fs'; import HtmlWebpackPlugin from 'html-webpack-plugin'; import { resolve } from 'path'; import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin'; @@ -11,7 +12,6 @@ import { merge } from 'webpack-merge'; // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires const swc = require('../../.swcrc.build.json'); // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires -const policy = require('./lavamoat/webpack/policy2.json'); const baseConfig: Configuration = { mode: 'production', @@ -60,7 +60,6 @@ const baseConfig: Configuration = { }, }, plugins: [ - new HtmlWebpackPlugin(), new ProvidePlugin({ process: 'process/browser', }), @@ -77,11 +76,19 @@ const iframeConfig: Configuration = merge(baseConfig, { path: resolve(__dirname, 'dist/webpack/iframe'), }, plugins: [ + // You may randomly need @ts-expect-error here, depending how dependencies resolve. If semver is a smart idea, typescript for webpack config is not new LavaMoatPlugin({ - policy, + // lockdown: {}, // override lockdown options here if you want + generatePolicy: true, diagnosticsVerbosity: 1, readableResourceIds: true, - HtmlWebpackPluginInterop: true, + emitPolicySnapshot: true, // puts the result of merging policy with override that was used for the bundle alongside the bundle for human review + }), + new HtmlWebpackPlugin({ + template: './src/iframe/template.html', + templateParameters: { + lockdownScript: readFileSync(require.resolve('ses')), // this could be provided as a static field on the plugin reference + }, }), ], }); diff --git a/yarn.lock b/yarn.lock index 2755207d55..2bd7ff6124 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2838,10 +2838,10 @@ __metadata: languageName: node linkType: hard -"@endo/env-options@npm:^1.1.0": - version: 1.1.0 - resolution: "@endo/env-options@npm:1.1.0" - checksum: 799ec765791ed69dd099a998fedb9a6a415236ce45748b06f097973542b133e3c3a296f61f0404a79119c6ae92a3f7fbc12d2cc10b1b07901bc64d4ae4d3b6ee +"@endo/env-options@npm:^1.1.2": + version: 1.1.5 + resolution: "@endo/env-options@npm:1.1.5" + checksum: ce8869cf089025c8e4c28e58763ad12e03cd34384025beeaa5642a12e8645c31959221eaf7aabe7a84edc2bc7a909ddffa6343c2578901a67138dbb079f7a0ba languageName: node linkType: hard @@ -3826,14 +3826,18 @@ __metadata: languageName: node linkType: hard -"@lavamoat/webpack@file:./lavamoat-webpack-0.0.1-beta.0.tgz::locator=%40metamask%2Fsnaps-execution-environments%40workspace%3Apackages%2Fsnaps-execution-environments": - version: 0.0.1-beta.0 - resolution: "@lavamoat/webpack@file:./lavamoat-webpack-0.0.1-beta.0.tgz::locator=%40metamask%2Fsnaps-execution-environments%40workspace%3Apackages%2Fsnaps-execution-environments" +"@lavamoat/webpack@npm:0.3.0-beta.0": + version: 0.3.0-beta.0 + resolution: "@lavamoat/webpack@npm:0.3.0-beta.0" dependencies: - lavamoat-core: ^15.0.0 + "@lavamoat/aa": ^4.2.0 + browser-resolve: 2.0.0 + json-stable-stringify: 1.1.1 + lavamoat-core: ^15.3.0 + ses: 1.4.0 peerDependencies: webpack: ^5.80.2 - checksum: 742bb94d9b8d060a283b6462e805a09ab2d14dbf28fbcc6b91e3c3fc1cf4863d66c210e64081700a8eb4886623c95380630289480898307077373e2c78459c9f + checksum: c0836b0a58d41227dc9123e5ea26d4efd65a6b0dd33569f65ce8505df24b3de19c65133eccf397efd6a7e5a2379527afd00b2416d1f22250312af6f8009a3c95 languageName: node linkType: hard @@ -5700,7 +5704,7 @@ __metadata: "@lavamoat/allow-scripts": ^3.0.4 "@lavamoat/lavapack": ^6.1.1 "@lavamoat/lavatube": ^1.0.0 - "@lavamoat/webpack": ./lavamoat-webpack-0.0.1-beta.0.tgz + "@lavamoat/webpack": 0.3.0-beta.0 "@metamask/auto-changelog": ^3.4.4 "@metamask/eslint-config": ^12.1.0 "@metamask/eslint-config-jest": ^12.1.0 @@ -16590,7 +16594,7 @@ __metadata: languageName: node linkType: hard -"lavamoat-core@npm:^15.0.0, lavamoat-core@npm:^15.2.0": +"lavamoat-core@npm:^15.2.0, lavamoat-core@npm:^15.3.0": version: 15.4.0 resolution: "lavamoat-core@npm:15.4.0" dependencies: @@ -20700,12 +20704,12 @@ __metadata: languageName: node linkType: hard -"ses@npm:^1.1.0": - version: 1.1.0 - resolution: "ses@npm:1.1.0" +"ses@npm:1.4.0, ses@npm:^1.1.0": + version: 1.4.0 + resolution: "ses@npm:1.4.0" dependencies: - "@endo/env-options": ^1.1.0 - checksum: 20f69f610febba3c53144ae2cf5cb4c932212c17994fe84a2864634a24104675a4ee2498482b74f8a468e0e25d92fd104c8b45b1ab2c7029255221797db979be + "@endo/env-options": ^1.1.2 + checksum: a0c9ac1a3b8ba9d20f2afbf8bf193c6ff08088e7ae429487c1eeeafc1ec14a58882f1ed3248aa17315c53fff78ba659157cd5bccedce91207aa7767d87a6ec53 languageName: node linkType: hard