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 756f130fc8..0000000000 Binary files a/packages/snaps-execution-environments/lavamoat-webpack-0.0.1-beta.0.tgz and /dev/null differ 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