@metamask/snaps-execution-environments 4.0.1 → 5.0.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 +10 -1
- package/dist/browserify/iframe/bundle.js +4 -4
- package/dist/browserify/node-process/bundle.js +3 -3
- package/dist/browserify/node-thread/bundle.js +3 -3
- package/dist/browserify/webview/bundle.js +4 -4
- package/dist/browserify/worker-executor/bundle.js +4 -4
- package/dist/browserify/worker-pool/bundle.js +4 -4
- package/dist/chunk-26EFJQDW.mjs +49 -0
- package/dist/chunk-26EFJQDW.mjs.map +1 -0
- package/dist/chunk-4NOF6TN6.js +51 -0
- package/dist/chunk-4NOF6TN6.js.map +1 -0
- package/dist/chunk-5DIRYAYO.js +30 -0
- package/dist/chunk-5DIRYAYO.js.map +1 -0
- package/dist/chunk-5RKYO2Y5.js +33 -0
- package/dist/chunk-5RKYO2Y5.js.map +1 -0
- package/dist/chunk-6GHFAQ54.mjs +44 -0
- package/dist/chunk-6GHFAQ54.mjs.map +1 -0
- package/dist/chunk-A7NJQLUA.mjs +32 -0
- package/dist/chunk-A7NJQLUA.mjs.map +1 -0
- package/dist/chunk-AJFPA6MI.js +81 -0
- package/dist/chunk-AJFPA6MI.js.map +1 -0
- package/dist/chunk-AQNACKO6.js +1 -0
- package/dist/chunk-AQNACKO6.js.map +1 -0
- package/dist/chunk-AZCRNZ5W.js +49 -0
- package/dist/chunk-AZCRNZ5W.js.map +1 -0
- package/dist/chunk-B3ASGNVQ.mjs +45 -0
- package/dist/chunk-B3ASGNVQ.mjs.map +1 -0
- package/dist/chunk-BE4YFFMX.js +49 -0
- package/dist/chunk-BE4YFFMX.js.map +1 -0
- package/dist/chunk-BOCIYCLE.mjs +30 -0
- package/dist/chunk-BOCIYCLE.mjs.map +1 -0
- package/dist/chunk-CCBKFCGG.js +147 -0
- package/dist/chunk-CCBKFCGG.js.map +1 -0
- package/dist/chunk-CINBMYIQ.mjs +183 -0
- package/dist/chunk-CINBMYIQ.mjs.map +1 -0
- package/dist/chunk-EBECHU6M.js +92 -0
- package/dist/chunk-EBECHU6M.js.map +1 -0
- package/dist/chunk-ETXAWW65.mjs +86 -0
- package/dist/chunk-ETXAWW65.mjs.map +1 -0
- package/dist/chunk-EXN2TFDJ.js +38 -0
- package/dist/chunk-EXN2TFDJ.js.map +1 -0
- package/dist/chunk-FNRATYYY.mjs +24 -0
- package/dist/chunk-FNRATYYY.mjs.map +1 -0
- package/dist/chunk-FQBU72MW.mjs +16 -0
- package/dist/chunk-FQBU72MW.mjs.map +1 -0
- package/dist/chunk-G3NCGVCC.mjs +33 -0
- package/dist/chunk-G3NCGVCC.mjs.map +1 -0
- package/dist/chunk-GH6FPDY5.mjs +147 -0
- package/dist/chunk-GH6FPDY5.mjs.map +1 -0
- package/dist/chunk-HSZIPZHO.js +183 -0
- package/dist/chunk-HSZIPZHO.js.map +1 -0
- package/dist/chunk-IU54VPNO.js +67 -0
- package/dist/chunk-IU54VPNO.js.map +1 -0
- package/dist/chunk-IXYNAYMQ.js +33 -0
- package/dist/chunk-IXYNAYMQ.js.map +1 -0
- package/dist/chunk-IY3CYGH7.js +44 -0
- package/dist/chunk-IY3CYGH7.js.map +1 -0
- package/dist/chunk-KQNKD7G5.mjs +40 -0
- package/dist/chunk-KQNKD7G5.mjs.map +1 -0
- package/dist/chunk-KWFB2KH2.mjs +73 -0
- package/dist/chunk-KWFB2KH2.mjs.map +1 -0
- package/dist/chunk-L4G6IIWG.js +484 -0
- package/dist/chunk-L4G6IIWG.js.map +1 -0
- package/dist/chunk-L5U2LMZR.js +26 -0
- package/dist/chunk-L5U2LMZR.js.map +1 -0
- package/dist/chunk-LGC7HQR4.js +32 -0
- package/dist/chunk-LGC7HQR4.js.map +1 -0
- package/dist/chunk-LX5LQXYU.js +16 -0
- package/dist/chunk-LX5LQXYU.js.map +1 -0
- package/dist/chunk-M2OYI2NS.js +108 -0
- package/dist/chunk-M2OYI2NS.js.map +1 -0
- package/dist/chunk-MOWPAP2K.mjs +92 -0
- package/dist/chunk-MOWPAP2K.mjs.map +1 -0
- package/dist/chunk-N7URTBJV.js +73 -0
- package/dist/chunk-N7URTBJV.js.map +1 -0
- package/dist/chunk-OW4IXJ5J.mjs +484 -0
- package/dist/chunk-OW4IXJ5J.mjs.map +1 -0
- package/dist/chunk-OWG545LQ.js +45 -0
- package/dist/chunk-OWG545LQ.js.map +1 -0
- package/dist/chunk-QYFJ2LLW.js +86 -0
- package/dist/chunk-QYFJ2LLW.js.map +1 -0
- package/dist/chunk-RCPCISJD.mjs +16 -0
- package/dist/chunk-RCPCISJD.mjs.map +1 -0
- package/dist/chunk-RDFGQYG6.mjs +147 -0
- package/dist/chunk-RDFGQYG6.mjs.map +1 -0
- package/dist/chunk-RO347OMD.js +16 -0
- package/dist/chunk-RO347OMD.js.map +1 -0
- package/dist/chunk-RWBJNNGH.js +24 -0
- package/dist/chunk-RWBJNNGH.js.map +1 -0
- package/dist/chunk-S7LRB72P.js +38 -0
- package/dist/chunk-S7LRB72P.js.map +1 -0
- package/dist/chunk-SWINKAMI.js +147 -0
- package/dist/chunk-SWINKAMI.js.map +1 -0
- package/dist/chunk-TVV27HGP.mjs +81 -0
- package/dist/chunk-TVV27HGP.mjs.map +1 -0
- package/dist/chunk-TWF4RAXL.mjs +49 -0
- package/dist/chunk-TWF4RAXL.mjs.map +1 -0
- package/dist/chunk-VL3VNUT4.mjs +12 -0
- package/dist/chunk-VL3VNUT4.mjs.map +1 -0
- package/dist/chunk-VZS2LXDP.mjs +108 -0
- package/dist/chunk-VZS2LXDP.mjs.map +1 -0
- package/dist/chunk-WA7K3P4D.js +40 -0
- package/dist/chunk-WA7K3P4D.js.map +1 -0
- package/dist/chunk-XBKAIK2K.mjs +67 -0
- package/dist/chunk-XBKAIK2K.mjs.map +1 -0
- package/dist/chunk-XGCWN6ZD.mjs +262 -0
- package/dist/chunk-XGCWN6ZD.mjs.map +1 -0
- package/dist/chunk-XKY46YTJ.js +12 -0
- package/dist/chunk-XKY46YTJ.js.map +1 -0
- package/dist/chunk-XL5BQOEI.mjs +33 -0
- package/dist/chunk-XL5BQOEI.mjs.map +1 -0
- package/dist/chunk-XMCETCVM.js +48 -0
- package/dist/chunk-XMCETCVM.js.map +1 -0
- package/dist/chunk-XYRWHY3K.mjs +51 -0
- package/dist/chunk-XYRWHY3K.mjs.map +1 -0
- package/dist/chunk-Y7IEFWZU.mjs +26 -0
- package/dist/chunk-Y7IEFWZU.mjs.map +1 -0
- package/dist/chunk-YC3HWHJV.mjs +48 -0
- package/dist/chunk-YC3HWHJV.mjs.map +1 -0
- package/dist/chunk-YMAK7TUO.mjs +1 -0
- package/dist/chunk-YMAK7TUO.mjs.map +1 -0
- package/dist/chunk-YRZVIDCF.mjs +38 -0
- package/dist/chunk-YRZVIDCF.mjs.map +1 -0
- package/dist/chunk-Z7FBBBME.mjs +38 -0
- package/dist/chunk-Z7FBBBME.mjs.map +1 -0
- package/dist/chunk-ZMDJRC2Z.js +262 -0
- package/dist/chunk-ZMDJRC2Z.js.map +1 -0
- package/dist/common/BaseSnapExecutor.js +26 -0
- package/dist/common/BaseSnapExecutor.js.map +1 -0
- package/dist/common/BaseSnapExecutor.mjs +26 -0
- package/dist/common/BaseSnapExecutor.mjs.map +1 -0
- package/dist/common/commands.js +11 -0
- package/dist/common/commands.js.map +1 -0
- package/dist/common/commands.mjs +11 -0
- package/dist/common/commands.mjs.map +1 -0
- package/dist/common/endowments/commonEndowmentFactory.js +20 -0
- package/dist/common/endowments/commonEndowmentFactory.js.map +1 -0
- package/dist/common/endowments/commonEndowmentFactory.mjs +20 -0
- package/dist/common/endowments/commonEndowmentFactory.mjs.map +1 -0
- package/dist/common/endowments/console.js +13 -0
- package/dist/common/endowments/console.js.map +1 -0
- package/dist/common/endowments/console.mjs +13 -0
- package/dist/common/endowments/console.mjs.map +1 -0
- package/dist/common/endowments/crypto.js +11 -0
- package/dist/common/endowments/crypto.js.map +1 -0
- package/dist/common/endowments/crypto.mjs +11 -0
- package/dist/common/endowments/crypto.mjs.map +1 -0
- package/dist/common/endowments/date.js +9 -0
- package/dist/common/endowments/date.js.map +1 -0
- package/dist/common/endowments/date.mjs +9 -0
- package/dist/common/endowments/date.mjs.map +1 -0
- package/dist/common/endowments/index.js +21 -0
- package/dist/common/endowments/index.js.map +1 -0
- package/dist/common/endowments/index.mjs +21 -0
- package/dist/common/endowments/index.mjs.map +1 -0
- package/dist/common/endowments/interval.js +8 -0
- package/dist/common/endowments/interval.js.map +1 -0
- package/dist/common/endowments/interval.mjs +8 -0
- package/dist/common/endowments/interval.mjs.map +1 -0
- package/dist/common/endowments/math.js +10 -0
- package/dist/common/endowments/math.js.map +1 -0
- package/dist/common/endowments/math.mjs +10 -0
- package/dist/common/endowments/math.mjs.map +1 -0
- package/dist/common/endowments/network.js +10 -0
- package/dist/common/endowments/network.js.map +1 -0
- package/dist/common/endowments/network.mjs +10 -0
- package/dist/common/endowments/network.mjs.map +1 -0
- package/dist/common/endowments/textDecoder.js +8 -0
- package/dist/common/endowments/textDecoder.js.map +1 -0
- package/dist/common/endowments/textDecoder.mjs +8 -0
- package/dist/common/endowments/textDecoder.mjs.map +1 -0
- package/dist/common/endowments/textEncoder.js +8 -0
- package/dist/common/endowments/textEncoder.js.map +1 -0
- package/dist/common/endowments/textEncoder.mjs +8 -0
- package/dist/common/endowments/textEncoder.mjs.map +1 -0
- package/dist/common/endowments/timeout.js +8 -0
- package/dist/common/endowments/timeout.js.map +1 -0
- package/dist/common/endowments/timeout.mjs +8 -0
- package/dist/common/endowments/timeout.mjs.map +1 -0
- package/dist/common/globalEvents.js +11 -0
- package/dist/common/globalEvents.js.map +1 -0
- package/dist/common/globalEvents.mjs +11 -0
- package/dist/common/globalEvents.mjs.map +1 -0
- package/dist/common/globalObject.js +10 -0
- package/dist/common/globalObject.js.map +1 -0
- package/dist/common/globalObject.mjs +10 -0
- package/dist/common/globalObject.mjs.map +1 -0
- package/dist/common/lockdown/lockdown-events.js +8 -0
- package/dist/common/lockdown/lockdown-events.js.map +1 -0
- package/dist/common/lockdown/lockdown-events.mjs +8 -0
- package/dist/common/lockdown/lockdown-events.mjs.map +1 -0
- package/dist/common/lockdown/lockdown-more.js +8 -0
- package/dist/common/lockdown/lockdown-more.js.map +1 -0
- package/dist/common/lockdown/lockdown-more.mjs +8 -0
- package/dist/common/lockdown/lockdown-more.mjs.map +1 -0
- package/dist/common/lockdown/lockdown.js +22 -0
- package/dist/common/lockdown/lockdown.js.map +1 -0
- package/dist/common/lockdown/lockdown.mjs +22 -0
- package/dist/common/lockdown/lockdown.mjs.map +1 -0
- package/dist/common/sortParams.js +8 -0
- package/dist/common/sortParams.js.map +1 -0
- package/dist/common/sortParams.mjs +8 -0
- package/dist/common/sortParams.mjs.map +1 -0
- package/dist/common/utils.js +21 -0
- package/dist/common/utils.js.map +1 -0
- package/dist/common/utils.mjs +21 -0
- package/dist/common/utils.mjs.map +1 -0
- package/dist/common/validation.js +38 -0
- package/dist/common/validation.js.map +1 -0
- package/dist/common/validation.mjs +38 -0
- package/dist/common/validation.mjs.map +1 -0
- package/dist/globals.d.js +1 -0
- package/dist/globals.d.js.map +1 -0
- package/dist/globals.d.mjs +1 -0
- package/dist/globals.d.mjs.map +1 -0
- package/dist/iframe/IFrameSnapExecutor.js +27 -0
- package/dist/iframe/IFrameSnapExecutor.js.map +1 -0
- package/dist/iframe/IFrameSnapExecutor.mjs +27 -0
- package/dist/iframe/IFrameSnapExecutor.mjs.map +1 -0
- package/dist/iframe/index.js +35 -0
- package/dist/iframe/index.js.map +1 -0
- package/dist/iframe/index.mjs +35 -0
- package/dist/iframe/index.mjs.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +9 -0
- package/dist/index.mjs.map +1 -0
- package/dist/logging.js +8 -0
- package/dist/logging.js.map +1 -0
- package/dist/logging.mjs +8 -0
- package/dist/logging.mjs.map +1 -0
- package/dist/node-process/ChildProcessSnapExecutor.js +27 -0
- package/dist/node-process/ChildProcessSnapExecutor.js.map +1 -0
- package/dist/node-process/ChildProcessSnapExecutor.mjs +27 -0
- package/dist/node-process/ChildProcessSnapExecutor.mjs.map +1 -0
- package/dist/node-process/index.js +31 -0
- package/dist/node-process/index.js.map +1 -0
- package/dist/node-process/index.mjs +31 -0
- package/dist/node-process/index.mjs.map +1 -0
- package/dist/node-thread/ThreadSnapExecutor.js +27 -0
- package/dist/node-thread/ThreadSnapExecutor.js.map +1 -0
- package/dist/node-thread/ThreadSnapExecutor.mjs +27 -0
- package/dist/node-thread/ThreadSnapExecutor.mjs.map +1 -0
- package/dist/node-thread/index.js +31 -0
- package/dist/node-thread/index.js.map +1 -0
- package/dist/node-thread/index.mjs +31 -0
- package/dist/node-thread/index.mjs.map +1 -0
- package/dist/proxy/ProxySnapExecutor.js +8 -0
- package/dist/proxy/ProxySnapExecutor.js.map +1 -0
- package/dist/proxy/ProxySnapExecutor.mjs +8 -0
- package/dist/proxy/ProxySnapExecutor.mjs.map +1 -0
- package/dist/proxy/index.js +9 -0
- package/dist/proxy/index.js.map +1 -0
- package/dist/proxy/index.mjs +9 -0
- package/dist/proxy/index.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/common/utils.d.ts +7 -0
- package/dist/types/vendor/global.d.js +1 -0
- package/dist/types/vendor/global.d.js.map +1 -0
- package/dist/types/vendor/global.d.mjs +1 -0
- package/dist/types/vendor/global.d.mjs.map +1 -0
- package/dist/types/vendor/readable-stream.d.js +1 -0
- package/dist/types/vendor/readable-stream.d.js.map +1 -0
- package/dist/types/vendor/readable-stream.d.mjs +1 -0
- package/dist/types/vendor/readable-stream.d.mjs.map +1 -0
- package/dist/webview/WebViewExecutorStream.js +8 -0
- package/dist/webview/WebViewExecutorStream.js.map +1 -0
- package/dist/webview/WebViewExecutorStream.mjs +8 -0
- package/dist/webview/WebViewExecutorStream.mjs.map +1 -0
- package/dist/webview/index.js +26 -0
- package/dist/webview/index.js.map +1 -0
- package/dist/webview/index.mjs +26 -0
- package/dist/webview/index.mjs.map +1 -0
- package/dist/webworker/executor/WebWorkerSnapExecutor.js +27 -0
- package/dist/webworker/executor/WebWorkerSnapExecutor.js.map +1 -0
- package/dist/webworker/executor/WebWorkerSnapExecutor.mjs +27 -0
- package/dist/webworker/executor/WebWorkerSnapExecutor.mjs.map +1 -0
- package/dist/webworker/executor/index.js +35 -0
- package/dist/webworker/executor/index.js.map +1 -0
- package/dist/webworker/executor/index.mjs +35 -0
- package/dist/webworker/executor/index.mjs.map +1 -0
- package/dist/webworker/pool/WebWorkerPool.js +8 -0
- package/dist/webworker/pool/WebWorkerPool.js.map +1 -0
- package/dist/webworker/pool/WebWorkerPool.mjs +8 -0
- package/dist/webworker/pool/WebWorkerPool.mjs.map +1 -0
- package/dist/webworker/pool/index.js +16 -0
- package/dist/webworker/pool/index.js.map +1 -0
- package/dist/webworker/pool/index.mjs +16 -0
- package/dist/webworker/pool/index.mjs.map +1 -0
- package/package.json +25 -18
- package/dist/cjs/common/BaseSnapExecutor.js +0 -496
- package/dist/cjs/common/BaseSnapExecutor.js.map +0 -1
- package/dist/cjs/common/commands.js +0 -102
- package/dist/cjs/common/commands.js.map +0 -1
- package/dist/cjs/common/endowments/commonEndowmentFactory.js +0 -147
- package/dist/cjs/common/endowments/commonEndowmentFactory.js.map +0 -1
- package/dist/cjs/common/endowments/console.js +0 -134
- package/dist/cjs/common/endowments/console.js.map +0 -1
- package/dist/cjs/common/endowments/crypto.js +0 -44
- package/dist/cjs/common/endowments/crypto.js.map +0 -1
- package/dist/cjs/common/endowments/date.js +0 -53
- package/dist/cjs/common/endowments/date.js.map +0 -1
- package/dist/cjs/common/endowments/index.js +0 -93
- package/dist/cjs/common/endowments/index.js.map +0 -1
- package/dist/cjs/common/endowments/interval.js +0 -62
- package/dist/cjs/common/endowments/interval.js.map +0 -1
- package/dist/cjs/common/endowments/math.js +0 -67
- package/dist/cjs/common/endowments/math.js.map +0 -1
- package/dist/cjs/common/endowments/network.js +0 -303
- package/dist/cjs/common/endowments/network.js.map +0 -1
- package/dist/cjs/common/endowments/textDecoder.js +0 -28
- package/dist/cjs/common/endowments/textDecoder.js.map +0 -1
- package/dist/cjs/common/endowments/textEncoder.js +0 -28
- package/dist/cjs/common/endowments/textEncoder.js.map +0 -1
- package/dist/cjs/common/endowments/timeout.js +0 -64
- package/dist/cjs/common/endowments/timeout.js.map +0 -1
- package/dist/cjs/common/globalEvents.js +0 -40
- package/dist/cjs/common/globalEvents.js.map +0 -1
- package/dist/cjs/common/globalObject.js +0 -53
- package/dist/cjs/common/globalObject.js.map +0 -1
- package/dist/cjs/common/lockdown/lockdown-events.js +0 -74
- package/dist/cjs/common/lockdown/lockdown-events.js.map +0 -1
- package/dist/cjs/common/lockdown/lockdown-more.js +0 -73
- package/dist/cjs/common/lockdown/lockdown-more.js.map +0 -1
- package/dist/cjs/common/lockdown/lockdown.js +0 -30
- package/dist/cjs/common/lockdown/lockdown.js.map +0 -1
- package/dist/cjs/common/sortParams.js +0 -26
- package/dist/cjs/common/sortParams.js.map +0 -1
- package/dist/cjs/common/utils.js +0 -128
- package/dist/cjs/common/utils.js.map +0 -1
- package/dist/cjs/common/validation.js +0 -149
- package/dist/cjs/common/validation.js.map +0 -1
- package/dist/cjs/iframe/IFrameSnapExecutor.js +0 -50
- package/dist/cjs/iframe/IFrameSnapExecutor.js.map +0 -1
- package/dist/cjs/iframe/index.js +0 -13
- package/dist/cjs/iframe/index.js.map +0 -1
- package/dist/cjs/index.js +0 -20
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/logging.js +0 -15
- package/dist/cjs/logging.js.map +0 -1
- package/dist/cjs/node-process/ChildProcessSnapExecutor.js +0 -39
- package/dist/cjs/node-process/ChildProcessSnapExecutor.js.map +0 -1
- package/dist/cjs/node-process/index.js +0 -11
- package/dist/cjs/node-process/index.js.map +0 -1
- package/dist/cjs/node-thread/ThreadSnapExecutor.js +0 -39
- package/dist/cjs/node-thread/ThreadSnapExecutor.js.map +0 -1
- package/dist/cjs/node-thread/index.js +0 -11
- package/dist/cjs/node-thread/index.js.map +0 -1
- package/dist/cjs/proxy/ProxySnapExecutor.js +0 -183
- package/dist/cjs/proxy/ProxySnapExecutor.js.map +0 -1
- package/dist/cjs/proxy/index.js +0 -20
- package/dist/cjs/proxy/index.js.map +0 -1
- package/dist/cjs/webview/WebViewExecutorStream.js +0 -121
- package/dist/cjs/webview/WebViewExecutorStream.js.map +0 -1
- package/dist/cjs/webview/index.js +0 -19
- package/dist/cjs/webview/index.js.map +0 -1
- package/dist/cjs/webworker/executor/WebWorkerSnapExecutor.js +0 -45
- package/dist/cjs/webworker/executor/WebWorkerSnapExecutor.js.map +0 -1
- package/dist/cjs/webworker/executor/index.js +0 -13
- package/dist/cjs/webworker/executor/index.js.map +0 -1
- package/dist/cjs/webworker/pool/WebWorkerPool.js +0 -248
- package/dist/cjs/webworker/pool/WebWorkerPool.js.map +0 -1
- package/dist/cjs/webworker/pool/index.js +0 -13
- package/dist/cjs/webworker/pool/index.js.map +0 -1
- package/dist/esm/common/BaseSnapExecutor.js +0 -486
- package/dist/esm/common/BaseSnapExecutor.js.map +0 -1
- package/dist/esm/common/commands.js +0 -101
- package/dist/esm/common/commands.js.map +0 -1
- package/dist/esm/common/endowments/commonEndowmentFactory.js +0 -132
- package/dist/esm/common/endowments/commonEndowmentFactory.js.map +0 -1
- package/dist/esm/common/endowments/console.js +0 -116
- package/dist/esm/common/endowments/console.js.map +0 -1
- package/dist/esm/common/endowments/crypto.js +0 -26
- package/dist/esm/common/endowments/crypto.js.map +0 -1
- package/dist/esm/common/endowments/date.js +0 -43
- package/dist/esm/common/endowments/date.js.map +0 -1
- package/dist/esm/common/endowments/index.js +0 -92
- package/dist/esm/common/endowments/index.js.map +0 -1
- package/dist/esm/common/endowments/interval.js +0 -52
- package/dist/esm/common/endowments/interval.js.map +0 -1
- package/dist/esm/common/endowments/math.js +0 -57
- package/dist/esm/common/endowments/math.js.map +0 -1
- package/dist/esm/common/endowments/network.js +0 -293
- package/dist/esm/common/endowments/network.js.map +0 -1
- package/dist/esm/common/endowments/textDecoder.js +0 -18
- package/dist/esm/common/endowments/textDecoder.js.map +0 -1
- package/dist/esm/common/endowments/textEncoder.js +0 -18
- package/dist/esm/common/endowments/textEncoder.js.map +0 -1
- package/dist/esm/common/endowments/timeout.js +0 -54
- package/dist/esm/common/endowments/timeout.js.map +0 -1
- package/dist/esm/common/globalEvents.js +0 -36
- package/dist/esm/common/globalEvents.js.map +0 -1
- package/dist/esm/common/globalObject.js +0 -36
- package/dist/esm/common/globalObject.js.map +0 -1
- package/dist/esm/common/lockdown/lockdown-events.js +0 -66
- package/dist/esm/common/lockdown/lockdown-events.js.map +0 -1
- package/dist/esm/common/lockdown/lockdown-more.js +0 -82
- package/dist/esm/common/lockdown/lockdown-more.js.map +0 -1
- package/dist/esm/common/lockdown/lockdown.js +0 -24
- package/dist/esm/common/lockdown/lockdown.js.map +0 -1
- package/dist/esm/common/sortParams.js +0 -29
- package/dist/esm/common/sortParams.js.map +0 -1
- package/dist/esm/common/utils.js +0 -128
- package/dist/esm/common/utils.js.map +0 -1
- package/dist/esm/common/validation.js +0 -127
- package/dist/esm/common/validation.js.map +0 -1
- package/dist/esm/iframe/IFrameSnapExecutor.js +0 -35
- package/dist/esm/iframe/IFrameSnapExecutor.js.map +0 -1
- package/dist/esm/iframe/index.js +0 -9
- package/dist/esm/iframe/index.js.map +0 -1
- package/dist/esm/index.js +0 -3
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/logging.js +0 -10
- package/dist/esm/logging.js.map +0 -1
- package/dist/esm/node-process/ChildProcessSnapExecutor.js +0 -24
- package/dist/esm/node-process/ChildProcessSnapExecutor.js.map +0 -1
- package/dist/esm/node-process/index.js +0 -7
- package/dist/esm/node-process/index.js.map +0 -1
- package/dist/esm/node-thread/ThreadSnapExecutor.js +0 -24
- package/dist/esm/node-thread/ThreadSnapExecutor.js.map +0 -1
- package/dist/esm/node-thread/index.js +0 -7
- package/dist/esm/node-thread/index.js.map +0 -1
- package/dist/esm/proxy/ProxySnapExecutor.js +0 -181
- package/dist/esm/proxy/ProxySnapExecutor.js.map +0 -1
- package/dist/esm/proxy/index.js +0 -3
- package/dist/esm/proxy/index.js.map +0 -1
- package/dist/esm/webview/WebViewExecutorStream.js +0 -111
- package/dist/esm/webview/WebViewExecutorStream.js.map +0 -1
- package/dist/esm/webview/index.js +0 -15
- package/dist/esm/webview/index.js.map +0 -1
- package/dist/esm/webworker/executor/WebWorkerSnapExecutor.js +0 -30
- package/dist/esm/webworker/executor/WebWorkerSnapExecutor.js.map +0 -1
- package/dist/esm/webworker/executor/index.js +0 -9
- package/dist/esm/webworker/executor/index.js.map +0 -1
- package/dist/esm/webworker/pool/WebWorkerPool.js +0 -245
- package/dist/esm/webworker/pool/WebWorkerPool.js.map +0 -1
- package/dist/esm/webworker/pool/index.js +0 -9
- package/dist/esm/webworker/pool/index.js.map +0 -1
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment
|
|
2
|
-
/// <reference path="../../../../../node_modules/ses/types.d.ts" />
|
|
3
|
-
import { logError } from '@metamask/snaps-utils';
|
|
4
|
-
/**
|
|
5
|
-
* The SES `lockdown` function only hardens the properties enumerated by the
|
|
6
|
-
* universalPropertyNames constant specified in 'ses/src/whitelist'. This
|
|
7
|
-
* function makes all function and object properties on the start compartment
|
|
8
|
-
* global non-configurable and non-writable, unless they are already
|
|
9
|
-
* non-configurable.
|
|
10
|
-
*
|
|
11
|
-
* It is critical that this function runs at the right time during
|
|
12
|
-
* initialization, which should always be immediately after `lockdown` has been
|
|
13
|
-
* called. At the time of writing, the modifications this function makes to the
|
|
14
|
-
* runtime environment appear to be non-breaking, but that could change with
|
|
15
|
-
* the addition of dependencies, or the order of our scripts in our HTML files.
|
|
16
|
-
* Exercise caution.
|
|
17
|
-
*
|
|
18
|
-
* See inline comments for implementation details.
|
|
19
|
-
*
|
|
20
|
-
* We write this function in IIFE format to avoid polluting global scope.
|
|
21
|
-
*
|
|
22
|
-
* @throws If the lockdown failed.
|
|
23
|
-
*/ export function executeLockdownMore() {
|
|
24
|
-
// Make all "object" and "function" own properties of globalThis
|
|
25
|
-
// non-configurable and non-writable, when possible.
|
|
26
|
-
// We call a property that is non-configurable and non-writable,
|
|
27
|
-
// "non-modifiable".
|
|
28
|
-
try {
|
|
29
|
-
const namedIntrinsics = Reflect.ownKeys(new Compartment().globalThis);
|
|
30
|
-
// These named intrinsics are not automatically hardened by `lockdown`
|
|
31
|
-
const shouldHardenManually = new Set([
|
|
32
|
-
'eval',
|
|
33
|
-
'Function'
|
|
34
|
-
]);
|
|
35
|
-
const globalProperties = new Set([
|
|
36
|
-
// universalPropertyNames is a constant added by lockdown to global scope
|
|
37
|
-
// at the time of writing, it is initialized in 'ses/src/whitelist'.
|
|
38
|
-
// These properties tend to be non-enumerable.
|
|
39
|
-
...namedIntrinsics
|
|
40
|
-
]);
|
|
41
|
-
globalProperties.forEach((propertyName)=>{
|
|
42
|
-
const descriptor = Reflect.getOwnPropertyDescriptor(globalThis, propertyName);
|
|
43
|
-
if (descriptor) {
|
|
44
|
-
if (descriptor.configurable) {
|
|
45
|
-
// If the property on globalThis is configurable, make it
|
|
46
|
-
// non-configurable. If it has no accessor properties, also make it
|
|
47
|
-
// non-writable.
|
|
48
|
-
if (hasAccessor(descriptor)) {
|
|
49
|
-
Object.defineProperty(globalThis, propertyName, {
|
|
50
|
-
configurable: false
|
|
51
|
-
});
|
|
52
|
-
} else {
|
|
53
|
-
Object.defineProperty(globalThis, propertyName, {
|
|
54
|
-
configurable: false,
|
|
55
|
-
writable: false
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (shouldHardenManually.has(propertyName)) {
|
|
60
|
-
harden(globalThis[propertyName]);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
} catch (error) {
|
|
65
|
-
logError('Protecting intrinsics failed:', error);
|
|
66
|
-
throw error;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Checks whether the given propertyName descriptor has any accessors, i.e. the
|
|
71
|
-
* properties `get` or `set`.
|
|
72
|
-
*
|
|
73
|
-
* We want to make globals non-writable, and we can't set the `writable`
|
|
74
|
-
* property and accessor properties at the same time.
|
|
75
|
-
*
|
|
76
|
-
* @param descriptor - The propertyName descriptor to check.
|
|
77
|
-
* @returns Whether the propertyName descriptor has any accessors.
|
|
78
|
-
*/ function hasAccessor(descriptor) {
|
|
79
|
-
return 'set' in descriptor || 'get' in descriptor;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
//# sourceMappingURL=lockdown-more.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/common/lockdown/lockdown-more.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment\n/// <reference path=\"../../../../../node_modules/ses/types.d.ts\" />\n\nimport { logError } from '@metamask/snaps-utils';\n\n/**\n * The SES `lockdown` function only hardens the properties enumerated by the\n * universalPropertyNames constant specified in 'ses/src/whitelist'. This\n * function makes all function and object properties on the start compartment\n * global non-configurable and non-writable, unless they are already\n * non-configurable.\n *\n * It is critical that this function runs at the right time during\n * initialization, which should always be immediately after `lockdown` has been\n * called. At the time of writing, the modifications this function makes to the\n * runtime environment appear to be non-breaking, but that could change with\n * the addition of dependencies, or the order of our scripts in our HTML files.\n * Exercise caution.\n *\n * See inline comments for implementation details.\n *\n * We write this function in IIFE format to avoid polluting global scope.\n *\n * @throws If the lockdown failed.\n */\nexport function executeLockdownMore() {\n // Make all \"object\" and \"function\" own properties of globalThis\n // non-configurable and non-writable, when possible.\n // We call a property that is non-configurable and non-writable,\n // \"non-modifiable\".\n try {\n const namedIntrinsics = Reflect.ownKeys(new Compartment().globalThis);\n\n // These named intrinsics are not automatically hardened by `lockdown`\n const shouldHardenManually = new Set<symbol | string>(['eval', 'Function']);\n\n const globalProperties = new Set([\n // universalPropertyNames is a constant added by lockdown to global scope\n // at the time of writing, it is initialized in 'ses/src/whitelist'.\n // These properties tend to be non-enumerable.\n ...namedIntrinsics,\n\n // TODO: Also include the named platform globals\n // This grabs every enumerable property on globalThis.\n // ...Object.keys(globalThis),\n ]);\n\n globalProperties.forEach((propertyName) => {\n const descriptor = Reflect.getOwnPropertyDescriptor(\n globalThis,\n propertyName,\n );\n\n if (descriptor) {\n if (descriptor.configurable) {\n // If the property on globalThis is configurable, make it\n // non-configurable. If it has no accessor properties, also make it\n // non-writable.\n if (hasAccessor(descriptor)) {\n Object.defineProperty(globalThis, propertyName, {\n configurable: false,\n });\n } else {\n Object.defineProperty(globalThis, propertyName, {\n configurable: false,\n writable: false,\n });\n }\n }\n\n if (shouldHardenManually.has(propertyName)) {\n harden((globalThis as any)[propertyName]);\n }\n }\n });\n } catch (error) {\n logError('Protecting intrinsics failed:', error);\n throw error;\n }\n}\n\n/**\n * Checks whether the given propertyName descriptor has any accessors, i.e. the\n * properties `get` or `set`.\n *\n * We want to make globals non-writable, and we can't set the `writable`\n * property and accessor properties at the same time.\n *\n * @param descriptor - The propertyName descriptor to check.\n * @returns Whether the propertyName descriptor has any accessors.\n */\nfunction hasAccessor(descriptor: any): boolean {\n return 'set' in descriptor || 'get' in descriptor;\n}\n"],"names":["logError","executeLockdownMore","namedIntrinsics","Reflect","ownKeys","Compartment","globalThis","shouldHardenManually","Set","globalProperties","forEach","propertyName","descriptor","getOwnPropertyDescriptor","configurable","hasAccessor","Object","defineProperty","writable","has","harden","error"],"mappings":"AAAA,qFAAqF;AACrF,mEAAmE;AAEnE,SAASA,QAAQ,QAAQ,wBAAwB;AAEjD;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASC;IACd,gEAAgE;IAChE,oDAAoD;IACpD,gEAAgE;IAChE,oBAAoB;IACpB,IAAI;QACF,MAAMC,kBAAkBC,QAAQC,OAAO,CAAC,IAAIC,cAAcC,UAAU;QAEpE,sEAAsE;QACtE,MAAMC,uBAAuB,IAAIC,IAAqB;YAAC;YAAQ;SAAW;QAE1E,MAAMC,mBAAmB,IAAID,IAAI;YAC/B,yEAAyE;YACzE,oEAAoE;YACpE,8CAA8C;eAC3CN;SAKJ;QAEDO,iBAAiBC,OAAO,CAAC,CAACC;YACxB,MAAMC,aAAaT,QAAQU,wBAAwB,CACjDP,YACAK;YAGF,IAAIC,YAAY;gBACd,IAAIA,WAAWE,YAAY,EAAE;oBAC3B,yDAAyD;oBACzD,mEAAmE;oBACnE,gBAAgB;oBAChB,IAAIC,YAAYH,aAAa;wBAC3BI,OAAOC,cAAc,CAACX,YAAYK,cAAc;4BAC9CG,cAAc;wBAChB;oBACF,OAAO;wBACLE,OAAOC,cAAc,CAACX,YAAYK,cAAc;4BAC9CG,cAAc;4BACdI,UAAU;wBACZ;oBACF;gBACF;gBAEA,IAAIX,qBAAqBY,GAAG,CAACR,eAAe;oBAC1CS,OAAO,AAACd,UAAkB,CAACK,aAAa;gBAC1C;YACF;QACF;IACF,EAAE,OAAOU,OAAO;QACdrB,SAAS,iCAAiCqB;QAC1C,MAAMA;IACR;AACF;AAEA;;;;;;;;;CASC,GACD,SAASN,YAAYH,UAAe;IAClC,OAAO,SAASA,cAAc,SAASA;AACzC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment
|
|
2
|
-
/// <reference path="../../../../../node_modules/ses/types.d.ts" />
|
|
3
|
-
import { logError } from '@metamask/snaps-utils';
|
|
4
|
-
/**
|
|
5
|
-
* Execute SES lockdown in the current context, i.e., the current iframe.
|
|
6
|
-
*
|
|
7
|
-
* @throws If the SES lockdown failed.
|
|
8
|
-
*/ export function executeLockdown() {
|
|
9
|
-
try {
|
|
10
|
-
lockdown({
|
|
11
|
-
consoleTaming: 'unsafe',
|
|
12
|
-
errorTaming: 'unsafe',
|
|
13
|
-
mathTaming: 'unsafe',
|
|
14
|
-
dateTaming: 'unsafe',
|
|
15
|
-
overrideTaming: 'severe'
|
|
16
|
-
});
|
|
17
|
-
} catch (error) {
|
|
18
|
-
// If the `lockdown` call throws an exception, it should not be able to continue
|
|
19
|
-
logError('Lockdown failed:', error);
|
|
20
|
-
throw error;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=lockdown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/common/lockdown/lockdown.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment\n/// <reference path=\"../../../../../node_modules/ses/types.d.ts\" />\n\nimport { logError } from '@metamask/snaps-utils';\n\n/**\n * Execute SES lockdown in the current context, i.e., the current iframe.\n *\n * @throws If the SES lockdown failed.\n */\nexport function executeLockdown() {\n try {\n lockdown({\n consoleTaming: 'unsafe',\n errorTaming: 'unsafe',\n mathTaming: 'unsafe',\n dateTaming: 'unsafe',\n overrideTaming: 'severe',\n });\n } catch (error) {\n // If the `lockdown` call throws an exception, it should not be able to continue\n logError('Lockdown failed:', error);\n throw error;\n }\n}\n"],"names":["logError","executeLockdown","lockdown","consoleTaming","errorTaming","mathTaming","dateTaming","overrideTaming","error"],"mappings":"AAAA,qFAAqF;AACrF,mEAAmE;AAEnE,SAASA,QAAQ,QAAQ,wBAAwB;AAEjD;;;;CAIC,GACD,OAAO,SAASC;IACd,IAAI;QACFC,SAAS;YACPC,eAAe;YACfC,aAAa;YACbC,YAAY;YACZC,YAAY;YACZC,gBAAgB;QAClB;IACF,EAAE,OAAOC,OAAO;QACd,gFAAgF;QAChFR,SAAS,oBAAoBQ;QAC7B,MAAMA;IACR;AACF"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// original source sortParamKeys from: https://github.com/etclabscore/sig.tools/blob/master/src/postMessageServer/postMessageServer.ts#L75-L77
|
|
2
|
-
/**
|
|
3
|
-
* Deterministically sort JSON-RPC parameter keys. This makes it possible to
|
|
4
|
-
* support both arrays and objects as parameters. Objects are sorted and turned
|
|
5
|
-
* into arrays, for easier consumption by the snap.
|
|
6
|
-
*
|
|
7
|
-
* The order is defined by the `method` parameter.
|
|
8
|
-
*
|
|
9
|
-
* @param methodParams - The parameters of the JSON-RPC method, which
|
|
10
|
-
* determines the ordering for the parameters.
|
|
11
|
-
* @param params - JSON-RPC parameters as object or array.
|
|
12
|
-
* @returns The values for the sorted keys. If `params` is not provided, this
|
|
13
|
-
* returns an empty array. If `params` is an array, this returns the same
|
|
14
|
-
* `params`.
|
|
15
|
-
*/ export const sortParamKeys = (methodParams, params)=>{
|
|
16
|
-
if (!params) {
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
19
|
-
if (params instanceof Array) {
|
|
20
|
-
return params;
|
|
21
|
-
}
|
|
22
|
-
const methodParamsOrder = methodParams.reduce((paramsOrderObj, paramsName, i)=>({
|
|
23
|
-
...paramsOrderObj,
|
|
24
|
-
[paramsName]: i
|
|
25
|
-
}), {});
|
|
26
|
-
return Object.entries(params).sort(([name1, _1], [name2, _2])=>methodParamsOrder[name1] - methodParamsOrder[name2]).map(([_, val])=>val);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=sortParams.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/common/sortParams.ts"],"sourcesContent":["// original source sortParamKeys from: https://github.com/etclabscore/sig.tools/blob/master/src/postMessageServer/postMessageServer.ts#L75-L77\n\nimport type { JsonRpcParams } from '@metamask/utils';\n\n/**\n * Deterministically sort JSON-RPC parameter keys. This makes it possible to\n * support both arrays and objects as parameters. Objects are sorted and turned\n * into arrays, for easier consumption by the snap.\n *\n * The order is defined by the `method` parameter.\n *\n * @param methodParams - The parameters of the JSON-RPC method, which\n * determines the ordering for the parameters.\n * @param params - JSON-RPC parameters as object or array.\n * @returns The values for the sorted keys. If `params` is not provided, this\n * returns an empty array. If `params` is an array, this returns the same\n * `params`.\n */\nexport const sortParamKeys = (\n methodParams: string[],\n params?: JsonRpcParams,\n) => {\n if (!params) {\n return [];\n }\n\n if (params instanceof Array) {\n return params;\n }\n\n const methodParamsOrder: { [k: string]: number } = methodParams.reduce(\n (paramsOrderObj, paramsName, i) => ({\n ...paramsOrderObj,\n [paramsName]: i,\n }),\n {},\n );\n\n return Object.entries(params)\n .sort(\n ([name1, _1], [name2, _2]) =>\n methodParamsOrder[name1] - methodParamsOrder[name2],\n )\n .map(([_, val]) => val);\n};\n"],"names":["sortParamKeys","methodParams","params","Array","methodParamsOrder","reduce","paramsOrderObj","paramsName","i","Object","entries","sort","name1","_1","name2","_2","map","_","val"],"mappings":"AAAA,8IAA8I;AAI9I;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMA,gBAAgB,CAC3BC,cACAC;IAEA,IAAI,CAACA,QAAQ;QACX,OAAO,EAAE;IACX;IAEA,IAAIA,kBAAkBC,OAAO;QAC3B,OAAOD;IACT;IAEA,MAAME,oBAA6CH,aAAaI,MAAM,CACpE,CAACC,gBAAgBC,YAAYC,IAAO,CAAA;YAClC,GAAGF,cAAc;YACjB,CAACC,WAAW,EAAEC;QAChB,CAAA,GACA,CAAC;IAGH,OAAOC,OAAOC,OAAO,CAACR,QACnBS,IAAI,CACH,CAAC,CAACC,OAAOC,GAAG,EAAE,CAACC,OAAOC,GAAG,GACvBX,iBAAiB,CAACQ,MAAM,GAAGR,iBAAiB,CAACU,MAAM,EAEtDE,GAAG,CAAC,CAAC,CAACC,GAAGC,IAAI,GAAKA;AACvB,EAAE"}
|
package/dist/esm/common/utils.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { rpcErrors } from '@metamask/rpc-errors';
|
|
2
|
-
import { assert, assertStruct, getSafeJson, JsonStruct } from '@metamask/utils';
|
|
3
|
-
import { log } from '../logging';
|
|
4
|
-
/**
|
|
5
|
-
* Make proxy for Promise and handle the teardown process properly.
|
|
6
|
-
* If the teardown is called in the meanwhile, Promise result will not be
|
|
7
|
-
* exposed to the snap anymore and warning will be logged to the console.
|
|
8
|
-
*
|
|
9
|
-
* @param originalPromise - Original promise.
|
|
10
|
-
* @param teardownRef - Reference containing teardown count.
|
|
11
|
-
* @param teardownRef.lastTeardown - Number of the last teardown.
|
|
12
|
-
* @returns New proxy promise.
|
|
13
|
-
*/ export async function withTeardown(originalPromise, teardownRef) {
|
|
14
|
-
const myTeardown = teardownRef.lastTeardown;
|
|
15
|
-
return new Promise((resolve, reject)=>{
|
|
16
|
-
originalPromise.then((value)=>{
|
|
17
|
-
if (teardownRef.lastTeardown === myTeardown) {
|
|
18
|
-
resolve(value);
|
|
19
|
-
} else {
|
|
20
|
-
log('Late promise received after Snap finished execution. Promise will be dropped.');
|
|
21
|
-
}
|
|
22
|
-
}).catch((reason)=>{
|
|
23
|
-
if (teardownRef.lastTeardown === myTeardown) {
|
|
24
|
-
reject(reason);
|
|
25
|
-
} else {
|
|
26
|
-
log('Late promise received after Snap finished execution. Promise will be dropped.');
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Returns a Proxy that narrows down (attenuates) the fields available on
|
|
33
|
-
* the StreamProvider and replaces the request implementation.
|
|
34
|
-
*
|
|
35
|
-
* @param provider - Instance of a StreamProvider to be limited.
|
|
36
|
-
* @param request - Custom attenuated request object.
|
|
37
|
-
* @returns Proxy to the StreamProvider instance.
|
|
38
|
-
*/ export function proxyStreamProvider(provider, request) {
|
|
39
|
-
// Proxy target is intentionally set to be an empty object, to ensure
|
|
40
|
-
// that access to the prototype chain is not possible.
|
|
41
|
-
const proxy = new Proxy({}, {
|
|
42
|
-
has (_target, prop) {
|
|
43
|
-
return typeof prop === 'string' && [
|
|
44
|
-
'request',
|
|
45
|
-
'on',
|
|
46
|
-
'removeListener'
|
|
47
|
-
].includes(prop);
|
|
48
|
-
},
|
|
49
|
-
get (_target, prop) {
|
|
50
|
-
if (prop === 'request') {
|
|
51
|
-
return request;
|
|
52
|
-
} else if ([
|
|
53
|
-
'on',
|
|
54
|
-
'removeListener'
|
|
55
|
-
].includes(prop)) {
|
|
56
|
-
return provider[prop];
|
|
57
|
-
}
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return proxy;
|
|
62
|
-
}
|
|
63
|
-
// We're blocking these RPC methods for v1, will revisit later.
|
|
64
|
-
export const BLOCKED_RPC_METHODS = Object.freeze([
|
|
65
|
-
'wallet_requestSnaps',
|
|
66
|
-
'wallet_requestPermissions',
|
|
67
|
-
'wallet_revokePermissions',
|
|
68
|
-
// We disallow all of these confirmations for now, since the screens are not ready for Snaps.
|
|
69
|
-
'eth_sendRawTransaction',
|
|
70
|
-
'eth_sendTransaction',
|
|
71
|
-
'eth_sign',
|
|
72
|
-
'eth_signTypedData',
|
|
73
|
-
'eth_signTypedData_v1',
|
|
74
|
-
'eth_signTypedData_v3',
|
|
75
|
-
'eth_signTypedData_v4',
|
|
76
|
-
'eth_decrypt',
|
|
77
|
-
'eth_getEncryptionPublicKey',
|
|
78
|
-
'wallet_addEthereumChain',
|
|
79
|
-
'wallet_switchEthereumChain',
|
|
80
|
-
'wallet_watchAsset',
|
|
81
|
-
'wallet_registerOnboarding',
|
|
82
|
-
'wallet_scanQRCode'
|
|
83
|
-
]);
|
|
84
|
-
/**
|
|
85
|
-
* Asserts the validity of request arguments for a snap outbound request using the `snap.request` API.
|
|
86
|
-
*
|
|
87
|
-
* @param args - The arguments to validate.
|
|
88
|
-
*/ export function assertSnapOutboundRequest(args) {
|
|
89
|
-
// Disallow any non `wallet_` or `snap_` methods for separation of concerns.
|
|
90
|
-
assert(String.prototype.startsWith.call(args.method, 'wallet_') || String.prototype.startsWith.call(args.method, 'snap_'), 'The global Snap API only allows RPC methods starting with `wallet_*` and `snap_*`.', rpcErrors.methodNotSupported);
|
|
91
|
-
assert(!BLOCKED_RPC_METHODS.includes(args.method), rpcErrors.methodNotFound({
|
|
92
|
-
data: {
|
|
93
|
-
method: args.method
|
|
94
|
-
}
|
|
95
|
-
}));
|
|
96
|
-
assertStruct(args, JsonStruct, 'Provided value is not JSON-RPC compatible', rpcErrors.invalidParams);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Asserts the validity of request arguments for an ethereum outbound request using the `ethereum.request` API.
|
|
100
|
-
*
|
|
101
|
-
* @param args - The arguments to validate.
|
|
102
|
-
*/ export function assertEthereumOutboundRequest(args) {
|
|
103
|
-
// Disallow snaps methods for separation of concerns.
|
|
104
|
-
assert(!String.prototype.startsWith.call(args.method, 'snap_'), rpcErrors.methodNotFound({
|
|
105
|
-
data: {
|
|
106
|
-
method: args.method
|
|
107
|
-
}
|
|
108
|
-
}));
|
|
109
|
-
assert(!BLOCKED_RPC_METHODS.includes(args.method), rpcErrors.methodNotFound({
|
|
110
|
-
data: {
|
|
111
|
-
method: args.method
|
|
112
|
-
}
|
|
113
|
-
}));
|
|
114
|
-
assertStruct(args, JsonStruct, 'Provided value is not JSON-RPC compatible', rpcErrors.invalidParams);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Gets a sanitized value to be used for passing to the underlying MetaMask provider.
|
|
118
|
-
*
|
|
119
|
-
* @param value - An unsanitized value from a snap.
|
|
120
|
-
* @returns A sanitized value ready to be passed to a MetaMask provider.
|
|
121
|
-
*/ export function sanitizeRequestArguments(value) {
|
|
122
|
-
// Before passing to getSafeJson we run the value through JSON serialization.
|
|
123
|
-
// This lets request arguments contain undefined which is normally disallowed.
|
|
124
|
-
const json = JSON.parse(JSON.stringify(value));
|
|
125
|
-
return getSafeJson(json);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/common/utils.ts"],"sourcesContent":["import type { StreamProvider } from '@metamask/providers';\nimport type { RequestArguments } from '@metamask/providers/dist/BaseProvider';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { assert, assertStruct, getSafeJson, JsonStruct } from '@metamask/utils';\n\nimport { log } from '../logging';\n/**\n * Make proxy for Promise and handle the teardown process properly.\n * If the teardown is called in the meanwhile, Promise result will not be\n * exposed to the snap anymore and warning will be logged to the console.\n *\n * @param originalPromise - Original promise.\n * @param teardownRef - Reference containing teardown count.\n * @param teardownRef.lastTeardown - Number of the last teardown.\n * @returns New proxy promise.\n */\nexport async function withTeardown<Type>(\n originalPromise: Promise<Type>,\n teardownRef: { lastTeardown: number },\n): Promise<Type> {\n const myTeardown = teardownRef.lastTeardown;\n return new Promise<Type>((resolve, reject) => {\n originalPromise\n .then((value) => {\n if (teardownRef.lastTeardown === myTeardown) {\n resolve(value);\n } else {\n log(\n 'Late promise received after Snap finished execution. Promise will be dropped.',\n );\n }\n })\n .catch((reason) => {\n if (teardownRef.lastTeardown === myTeardown) {\n reject(reason);\n } else {\n log(\n 'Late promise received after Snap finished execution. Promise will be dropped.',\n );\n }\n });\n });\n}\n\n/**\n * Returns a Proxy that narrows down (attenuates) the fields available on\n * the StreamProvider and replaces the request implementation.\n *\n * @param provider - Instance of a StreamProvider to be limited.\n * @param request - Custom attenuated request object.\n * @returns Proxy to the StreamProvider instance.\n */\nexport function proxyStreamProvider(\n provider: StreamProvider,\n request: unknown,\n): StreamProvider {\n // Proxy target is intentionally set to be an empty object, to ensure\n // that access to the prototype chain is not possible.\n const proxy = new Proxy(\n {},\n {\n has(_target: object, prop: string | symbol) {\n return (\n typeof prop === 'string' &&\n ['request', 'on', 'removeListener'].includes(prop)\n );\n },\n get(_target, prop: keyof StreamProvider) {\n if (prop === 'request') {\n return request;\n } else if (['on', 'removeListener'].includes(prop)) {\n return provider[prop];\n }\n\n return undefined;\n },\n },\n );\n\n return proxy as StreamProvider;\n}\n\n// We're blocking these RPC methods for v1, will revisit later.\nexport const BLOCKED_RPC_METHODS = Object.freeze([\n 'wallet_requestSnaps',\n 'wallet_requestPermissions',\n 'wallet_revokePermissions',\n // We disallow all of these confirmations for now, since the screens are not ready for Snaps.\n 'eth_sendRawTransaction',\n 'eth_sendTransaction',\n 'eth_sign',\n 'eth_signTypedData',\n 'eth_signTypedData_v1',\n 'eth_signTypedData_v3',\n 'eth_signTypedData_v4',\n 'eth_decrypt',\n 'eth_getEncryptionPublicKey',\n 'wallet_addEthereumChain',\n 'wallet_switchEthereumChain',\n 'wallet_watchAsset',\n 'wallet_registerOnboarding',\n 'wallet_scanQRCode',\n]);\n\n/**\n * Asserts the validity of request arguments for a snap outbound request using the `snap.request` API.\n *\n * @param args - The arguments to validate.\n */\nexport function assertSnapOutboundRequest(args: RequestArguments) {\n // Disallow any non `wallet_` or `snap_` methods for separation of concerns.\n assert(\n String.prototype.startsWith.call(args.method, 'wallet_') ||\n String.prototype.startsWith.call(args.method, 'snap_'),\n 'The global Snap API only allows RPC methods starting with `wallet_*` and `snap_*`.',\n rpcErrors.methodNotSupported,\n );\n assert(\n !BLOCKED_RPC_METHODS.includes(args.method),\n rpcErrors.methodNotFound({\n data: {\n method: args.method,\n },\n }),\n );\n assertStruct(\n args,\n JsonStruct,\n 'Provided value is not JSON-RPC compatible',\n rpcErrors.invalidParams,\n );\n}\n\n/**\n * Asserts the validity of request arguments for an ethereum outbound request using the `ethereum.request` API.\n *\n * @param args - The arguments to validate.\n */\nexport function assertEthereumOutboundRequest(args: RequestArguments) {\n // Disallow snaps methods for separation of concerns.\n assert(\n !String.prototype.startsWith.call(args.method, 'snap_'),\n rpcErrors.methodNotFound({\n data: {\n method: args.method,\n },\n }),\n );\n assert(\n !BLOCKED_RPC_METHODS.includes(args.method),\n rpcErrors.methodNotFound({\n data: {\n method: args.method,\n },\n }),\n );\n assertStruct(\n args,\n JsonStruct,\n 'Provided value is not JSON-RPC compatible',\n rpcErrors.invalidParams,\n );\n}\n\n/**\n * Gets a sanitized value to be used for passing to the underlying MetaMask provider.\n *\n * @param value - An unsanitized value from a snap.\n * @returns A sanitized value ready to be passed to a MetaMask provider.\n */\nexport function sanitizeRequestArguments(value: unknown): RequestArguments {\n // Before passing to getSafeJson we run the value through JSON serialization.\n // This lets request arguments contain undefined which is normally disallowed.\n const json = JSON.parse(JSON.stringify(value));\n return getSafeJson(json) as RequestArguments;\n}\n"],"names":["rpcErrors","assert","assertStruct","getSafeJson","JsonStruct","log","withTeardown","originalPromise","teardownRef","myTeardown","lastTeardown","Promise","resolve","reject","then","value","catch","reason","proxyStreamProvider","provider","request","proxy","Proxy","has","_target","prop","includes","get","undefined","BLOCKED_RPC_METHODS","Object","freeze","assertSnapOutboundRequest","args","String","prototype","startsWith","call","method","methodNotSupported","methodNotFound","data","invalidParams","assertEthereumOutboundRequest","sanitizeRequestArguments","json","JSON","parse","stringify"],"mappings":"AAEA,SAASA,SAAS,QAAQ,uBAAuB;AACjD,SAASC,MAAM,EAAEC,YAAY,EAAEC,WAAW,EAAEC,UAAU,QAAQ,kBAAkB;AAEhF,SAASC,GAAG,QAAQ,aAAa;AACjC;;;;;;;;;CASC,GACD,OAAO,eAAeC,aACpBC,eAA8B,EAC9BC,WAAqC;IAErC,MAAMC,aAAaD,YAAYE,YAAY;IAC3C,OAAO,IAAIC,QAAc,CAACC,SAASC;QACjCN,gBACGO,IAAI,CAAC,CAACC;YACL,IAAIP,YAAYE,YAAY,KAAKD,YAAY;gBAC3CG,QAAQG;YACV,OAAO;gBACLV,IACE;YAEJ;QACF,GACCW,KAAK,CAAC,CAACC;YACN,IAAIT,YAAYE,YAAY,KAAKD,YAAY;gBAC3CI,OAAOI;YACT,OAAO;gBACLZ,IACE;YAEJ;QACF;IACJ;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,SAASa,oBACdC,QAAwB,EACxBC,OAAgB;IAEhB,qEAAqE;IACrE,sDAAsD;IACtD,MAAMC,QAAQ,IAAIC,MAChB,CAAC,GACD;QACEC,KAAIC,OAAe,EAAEC,IAAqB;YACxC,OACE,OAAOA,SAAS,YAChB;gBAAC;gBAAW;gBAAM;aAAiB,CAACC,QAAQ,CAACD;QAEjD;QACAE,KAAIH,OAAO,EAAEC,IAA0B;YACrC,IAAIA,SAAS,WAAW;gBACtB,OAAOL;YACT,OAAO,IAAI;gBAAC;gBAAM;aAAiB,CAACM,QAAQ,CAACD,OAAO;gBAClD,OAAON,QAAQ,CAACM,KAAK;YACvB;YAEA,OAAOG;QACT;IACF;IAGF,OAAOP;AACT;AAEA,+DAA+D;AAC/D,OAAO,MAAMQ,sBAAsBC,OAAOC,MAAM,CAAC;IAC/C;IACA;IACA;IACA,6FAA6F;IAC7F;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,SAASC,0BAA0BC,IAAsB;IAC9D,4EAA4E;IAC5EhC,OACEiC,OAAOC,SAAS,CAACC,UAAU,CAACC,IAAI,CAACJ,KAAKK,MAAM,EAAE,cAC5CJ,OAAOC,SAAS,CAACC,UAAU,CAACC,IAAI,CAACJ,KAAKK,MAAM,EAAE,UAChD,sFACAtC,UAAUuC,kBAAkB;IAE9BtC,OACE,CAAC4B,oBAAoBH,QAAQ,CAACO,KAAKK,MAAM,GACzCtC,UAAUwC,cAAc,CAAC;QACvBC,MAAM;YACJH,QAAQL,KAAKK,MAAM;QACrB;IACF;IAEFpC,aACE+B,MACA7B,YACA,6CACAJ,UAAU0C,aAAa;AAE3B;AAEA;;;;CAIC,GACD,OAAO,SAASC,8BAA8BV,IAAsB;IAClE,qDAAqD;IACrDhC,OACE,CAACiC,OAAOC,SAAS,CAACC,UAAU,CAACC,IAAI,CAACJ,KAAKK,MAAM,EAAE,UAC/CtC,UAAUwC,cAAc,CAAC;QACvBC,MAAM;YACJH,QAAQL,KAAKK,MAAM;QACrB;IACF;IAEFrC,OACE,CAAC4B,oBAAoBH,QAAQ,CAACO,KAAKK,MAAM,GACzCtC,UAAUwC,cAAc,CAAC;QACvBC,MAAM;YACJH,QAAQL,KAAKK,MAAM;QACrB;IACF;IAEFpC,aACE+B,MACA7B,YACA,6CACAJ,UAAU0C,aAAa;AAE3B;AAEA;;;;;CAKC,GACD,OAAO,SAASE,yBAAyB7B,KAAc;IACrD,6EAA6E;IAC7E,8EAA8E;IAC9E,MAAM8B,OAAOC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACjC;IACvC,OAAOZ,YAAY0C;AACrB"}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { rpcErrors } from '@metamask/rpc-errors';
|
|
2
|
-
import { UserInputEventStruct } from '@metamask/snaps-sdk';
|
|
3
|
-
import { ChainIdStruct, HandlerType } from '@metamask/snaps-utils';
|
|
4
|
-
import { assertStruct, JsonRpcIdStruct, JsonRpcParamsStruct, JsonRpcSuccessStruct, JsonRpcVersionStruct, JsonStruct } from '@metamask/utils';
|
|
5
|
-
import { array, assign, enums, is, literal, nullable, object, optional, record, string, tuple, union } from 'superstruct';
|
|
6
|
-
export const JsonRpcRequestWithoutIdStruct = object({
|
|
7
|
-
jsonrpc: optional(JsonRpcVersionStruct),
|
|
8
|
-
id: optional(JsonRpcIdStruct),
|
|
9
|
-
method: string(),
|
|
10
|
-
params: optional(JsonRpcParamsStruct)
|
|
11
|
-
});
|
|
12
|
-
export const EndowmentStruct = string();
|
|
13
|
-
/**
|
|
14
|
-
* Check if the given value is an endowment.
|
|
15
|
-
*
|
|
16
|
-
* @param value - The value to check.
|
|
17
|
-
* @returns Whether the value is an endowment.
|
|
18
|
-
*/ export function isEndowment(value) {
|
|
19
|
-
return is(value, EndowmentStruct);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Check if the given value is an array of endowments.
|
|
23
|
-
*
|
|
24
|
-
* @param value - The value to check.
|
|
25
|
-
* @returns Whether the value is an array of endowments.
|
|
26
|
-
*/ export function isEndowmentsArray(value) {
|
|
27
|
-
return Array.isArray(value) && value.every(isEndowment);
|
|
28
|
-
}
|
|
29
|
-
const OkStruct = literal('OK');
|
|
30
|
-
export const PingRequestArgumentsStruct = optional(union([
|
|
31
|
-
literal(undefined),
|
|
32
|
-
array()
|
|
33
|
-
]));
|
|
34
|
-
export const TerminateRequestArgumentsStruct = union([
|
|
35
|
-
literal(undefined),
|
|
36
|
-
array()
|
|
37
|
-
]);
|
|
38
|
-
export const ExecuteSnapRequestArgumentsStruct = tuple([
|
|
39
|
-
string(),
|
|
40
|
-
string(),
|
|
41
|
-
array(EndowmentStruct)
|
|
42
|
-
]);
|
|
43
|
-
export const SnapRpcRequestArgumentsStruct = tuple([
|
|
44
|
-
string(),
|
|
45
|
-
enums(Object.values(HandlerType)),
|
|
46
|
-
string(),
|
|
47
|
-
assign(JsonRpcRequestWithoutIdStruct, object({
|
|
48
|
-
params: optional(record(string(), JsonStruct))
|
|
49
|
-
}))
|
|
50
|
-
]);
|
|
51
|
-
export const OnTransactionRequestArgumentsStruct = object({
|
|
52
|
-
// TODO: Improve `transaction` type.
|
|
53
|
-
transaction: record(string(), JsonStruct),
|
|
54
|
-
chainId: ChainIdStruct,
|
|
55
|
-
transactionOrigin: nullable(string())
|
|
56
|
-
});
|
|
57
|
-
/**
|
|
58
|
-
* Asserts that the given value is a valid {@link OnTransactionRequestArguments}
|
|
59
|
-
* object.
|
|
60
|
-
*
|
|
61
|
-
* @param value - The value to validate.
|
|
62
|
-
* @throws If the value is not a valid {@link OnTransactionRequestArguments}
|
|
63
|
-
* object.
|
|
64
|
-
*/ export function assertIsOnTransactionRequestArguments(value) {
|
|
65
|
-
assertStruct(value, OnTransactionRequestArgumentsStruct, 'Invalid request params', rpcErrors.invalidParams);
|
|
66
|
-
}
|
|
67
|
-
export const OnSignatureRequestArgumentsStruct = object({
|
|
68
|
-
signature: record(string(), JsonStruct),
|
|
69
|
-
signatureOrigin: nullable(string())
|
|
70
|
-
});
|
|
71
|
-
/**
|
|
72
|
-
* Asserts that the given value is a valid {@link OnSignatureRequestArguments}
|
|
73
|
-
* object.
|
|
74
|
-
*
|
|
75
|
-
* @param value - The value to validate.
|
|
76
|
-
* @throws If the value is not a valid {@link OnSignatureRequestArguments}
|
|
77
|
-
* object.
|
|
78
|
-
*/ export function assertIsOnSignatureRequestArguments(value) {
|
|
79
|
-
assertStruct(value, OnSignatureRequestArgumentsStruct, 'Invalid request params', rpcErrors.invalidParams);
|
|
80
|
-
}
|
|
81
|
-
const baseNameLookupArgs = {
|
|
82
|
-
chainId: ChainIdStruct
|
|
83
|
-
};
|
|
84
|
-
const domainRequestStruct = object({
|
|
85
|
-
...baseNameLookupArgs,
|
|
86
|
-
address: string()
|
|
87
|
-
});
|
|
88
|
-
const addressRequestStruct = object({
|
|
89
|
-
...baseNameLookupArgs,
|
|
90
|
-
domain: string()
|
|
91
|
-
});
|
|
92
|
-
export const OnNameLookupRequestArgumentsStruct = union([
|
|
93
|
-
domainRequestStruct,
|
|
94
|
-
addressRequestStruct
|
|
95
|
-
]);
|
|
96
|
-
/**
|
|
97
|
-
* Asserts that the given value is a valid {@link OnNameLookupRequestArguments}
|
|
98
|
-
* object.
|
|
99
|
-
*
|
|
100
|
-
* @param value - The value to validate.
|
|
101
|
-
* @throws If the value is not a valid {@link OnNameLookupRequestArguments}
|
|
102
|
-
* object.
|
|
103
|
-
*/ export function assertIsOnNameLookupRequestArguments(value) {
|
|
104
|
-
assertStruct(value, OnNameLookupRequestArgumentsStruct, 'Invalid request params', rpcErrors.invalidParams);
|
|
105
|
-
}
|
|
106
|
-
export const OnUserInputArgumentsStruct = object({
|
|
107
|
-
id: string(),
|
|
108
|
-
event: UserInputEventStruct
|
|
109
|
-
});
|
|
110
|
-
/**
|
|
111
|
-
* Asserts that the given value is a valid {@link OnUserInputArguments}
|
|
112
|
-
* object.
|
|
113
|
-
*
|
|
114
|
-
* @param value - The value to validate.
|
|
115
|
-
* @throws If the value is not a valid {@link OnUserInputArguments}
|
|
116
|
-
* object.
|
|
117
|
-
*/ export function assertIsOnUserInputRequestArguments(value) {
|
|
118
|
-
assertStruct(value, OnUserInputArgumentsStruct, 'Invalid request params', rpcErrors.invalidParams);
|
|
119
|
-
}
|
|
120
|
-
const OkResponseStruct = object({
|
|
121
|
-
id: JsonRpcIdStruct,
|
|
122
|
-
jsonrpc: JsonRpcVersionStruct,
|
|
123
|
-
result: OkStruct
|
|
124
|
-
});
|
|
125
|
-
const SnapRpcResponse = JsonRpcSuccessStruct;
|
|
126
|
-
|
|
127
|
-
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/common/validation.ts"],"sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport { UserInputEventStruct } from '@metamask/snaps-sdk';\nimport { ChainIdStruct, HandlerType } from '@metamask/snaps-utils';\nimport type { Json, JsonRpcSuccess } from '@metamask/utils';\nimport {\n assertStruct,\n JsonRpcIdStruct,\n JsonRpcParamsStruct,\n JsonRpcSuccessStruct,\n JsonRpcVersionStruct,\n JsonStruct,\n} from '@metamask/utils';\nimport type { Infer } from 'superstruct';\nimport {\n array,\n assign,\n enums,\n is,\n literal,\n nullable,\n object,\n optional,\n record,\n string,\n tuple,\n union,\n} from 'superstruct';\n\nexport const JsonRpcRequestWithoutIdStruct = object({\n jsonrpc: optional(JsonRpcVersionStruct),\n id: optional(JsonRpcIdStruct),\n method: string(),\n params: optional(JsonRpcParamsStruct),\n});\n\nexport type JsonRpcRequestWithoutId = Infer<\n typeof JsonRpcRequestWithoutIdStruct\n>;\n\nexport const EndowmentStruct = string();\nexport type Endowment = Infer<typeof EndowmentStruct>;\n\n/**\n * Check if the given value is an endowment.\n *\n * @param value - The value to check.\n * @returns Whether the value is an endowment.\n */\nexport function isEndowment(value: unknown): value is Endowment {\n return is(value, EndowmentStruct);\n}\n\n/**\n * Check if the given value is an array of endowments.\n *\n * @param value - The value to check.\n * @returns Whether the value is an array of endowments.\n */\nexport function isEndowmentsArray(value: unknown): value is Endowment[] {\n return Array.isArray(value) && value.every(isEndowment);\n}\n\nconst OkStruct = literal('OK');\n\nexport const PingRequestArgumentsStruct = optional(\n union([literal(undefined), array()]),\n);\n\nexport const TerminateRequestArgumentsStruct = union([\n literal(undefined),\n array(),\n]);\n\nexport const ExecuteSnapRequestArgumentsStruct = tuple([\n string(),\n string(),\n array(EndowmentStruct),\n]);\n\nexport const SnapRpcRequestArgumentsStruct = tuple([\n string(),\n enums(Object.values(HandlerType)),\n string(),\n assign(\n JsonRpcRequestWithoutIdStruct,\n object({\n params: optional(record(string(), JsonStruct)),\n }),\n ),\n]);\n\nexport type PingRequestArguments = Infer<typeof PingRequestArgumentsStruct>;\nexport type TerminateRequestArguments = Infer<\n typeof TerminateRequestArgumentsStruct\n>;\n\nexport type ExecuteSnapRequestArguments = Infer<\n typeof ExecuteSnapRequestArgumentsStruct\n>;\n\nexport type SnapRpcRequestArguments = Infer<\n typeof SnapRpcRequestArgumentsStruct\n>;\n\nexport type RequestArguments =\n | PingRequestArguments\n | TerminateRequestArguments\n | ExecuteSnapRequestArguments\n | SnapRpcRequestArguments;\n\nexport const OnTransactionRequestArgumentsStruct = object({\n // TODO: Improve `transaction` type.\n transaction: record(string(), JsonStruct),\n chainId: ChainIdStruct,\n transactionOrigin: nullable(string()),\n});\n\nexport type OnTransactionRequestArguments = Infer<\n typeof OnTransactionRequestArgumentsStruct\n>;\n\n/**\n * Asserts that the given value is a valid {@link OnTransactionRequestArguments}\n * object.\n *\n * @param value - The value to validate.\n * @throws If the value is not a valid {@link OnTransactionRequestArguments}\n * object.\n */\nexport function assertIsOnTransactionRequestArguments(\n value: unknown,\n): asserts value is OnTransactionRequestArguments {\n assertStruct(\n value,\n OnTransactionRequestArgumentsStruct,\n 'Invalid request params',\n rpcErrors.invalidParams,\n );\n}\n\nexport const OnSignatureRequestArgumentsStruct = object({\n signature: record(string(), JsonStruct),\n signatureOrigin: nullable(string()),\n});\n\nexport type OnSignatureRequestArguments = Infer<\n typeof OnSignatureRequestArgumentsStruct\n>;\n\n/**\n * Asserts that the given value is a valid {@link OnSignatureRequestArguments}\n * object.\n *\n * @param value - The value to validate.\n * @throws If the value is not a valid {@link OnSignatureRequestArguments}\n * object.\n */\nexport function assertIsOnSignatureRequestArguments(\n value: unknown,\n): asserts value is OnSignatureRequestArguments {\n assertStruct(\n value,\n OnSignatureRequestArgumentsStruct,\n 'Invalid request params',\n rpcErrors.invalidParams,\n );\n}\n\nconst baseNameLookupArgs = { chainId: ChainIdStruct };\nconst domainRequestStruct = object({\n ...baseNameLookupArgs,\n address: string(),\n});\nconst addressRequestStruct = object({\n ...baseNameLookupArgs,\n domain: string(),\n});\n\nexport const OnNameLookupRequestArgumentsStruct = union([\n domainRequestStruct,\n addressRequestStruct,\n]);\n\nexport type OnNameLookupRequestArguments = Infer<\n typeof OnNameLookupRequestArgumentsStruct\n>;\n\nexport type PossibleLookupRequestArgs = typeof baseNameLookupArgs & {\n address?: string;\n domain?: string;\n};\n\n/**\n * Asserts that the given value is a valid {@link OnNameLookupRequestArguments}\n * object.\n *\n * @param value - The value to validate.\n * @throws If the value is not a valid {@link OnNameLookupRequestArguments}\n * object.\n */\nexport function assertIsOnNameLookupRequestArguments(\n value: unknown,\n): asserts value is OnNameLookupRequestArguments {\n assertStruct(\n value,\n OnNameLookupRequestArgumentsStruct,\n 'Invalid request params',\n rpcErrors.invalidParams,\n );\n}\n\nexport const OnUserInputArgumentsStruct = object({\n id: string(),\n event: UserInputEventStruct,\n});\n\nexport type OnUserInputArguments = Infer<typeof OnUserInputArgumentsStruct>;\n\n/**\n * Asserts that the given value is a valid {@link OnUserInputArguments}\n * object.\n *\n * @param value - The value to validate.\n * @throws If the value is not a valid {@link OnUserInputArguments}\n * object.\n */\nexport function assertIsOnUserInputRequestArguments(\n value: unknown,\n): asserts value is OnUserInputArguments {\n assertStruct(\n value,\n OnUserInputArgumentsStruct,\n 'Invalid request params',\n rpcErrors.invalidParams,\n );\n}\n\nconst OkResponseStruct = object({\n id: JsonRpcIdStruct,\n jsonrpc: JsonRpcVersionStruct,\n result: OkStruct,\n});\n\nconst SnapRpcResponse = JsonRpcSuccessStruct;\n\nexport type OkResponse = Infer<typeof OkResponseStruct>;\nexport type SnapRpcResponse = Infer<typeof SnapRpcResponse>;\n\nexport type Response = OkResponse | SnapRpcResponse;\n\ntype RequestParams<Params extends unknown[] | undefined> =\n Params extends undefined ? [] : Params;\n\ntype RequestFunction<\n Args extends RequestArguments,\n ResponseType extends JsonRpcSuccess<Json>,\n> = (...args: RequestParams<Args>) => Promise<ResponseType['result']>;\n\nexport type Ping = RequestFunction<PingRequestArguments, OkResponse>;\nexport type Terminate = RequestFunction<TerminateRequestArguments, OkResponse>;\nexport type ExecuteSnap = RequestFunction<\n ExecuteSnapRequestArguments,\n OkResponse\n>;\nexport type SnapRpc = RequestFunction<SnapRpcRequestArguments, SnapRpcResponse>;\n"],"names":["rpcErrors","UserInputEventStruct","ChainIdStruct","HandlerType","assertStruct","JsonRpcIdStruct","JsonRpcParamsStruct","JsonRpcSuccessStruct","JsonRpcVersionStruct","JsonStruct","array","assign","enums","is","literal","nullable","object","optional","record","string","tuple","union","JsonRpcRequestWithoutIdStruct","jsonrpc","id","method","params","EndowmentStruct","isEndowment","value","isEndowmentsArray","Array","isArray","every","OkStruct","PingRequestArgumentsStruct","undefined","TerminateRequestArgumentsStruct","ExecuteSnapRequestArgumentsStruct","SnapRpcRequestArgumentsStruct","Object","values","OnTransactionRequestArgumentsStruct","transaction","chainId","transactionOrigin","assertIsOnTransactionRequestArguments","invalidParams","OnSignatureRequestArgumentsStruct","signature","signatureOrigin","assertIsOnSignatureRequestArguments","baseNameLookupArgs","domainRequestStruct","address","addressRequestStruct","domain","OnNameLookupRequestArgumentsStruct","assertIsOnNameLookupRequestArguments","OnUserInputArgumentsStruct","event","assertIsOnUserInputRequestArguments","OkResponseStruct","result","SnapRpcResponse"],"mappings":"AAAA,SAASA,SAAS,QAAQ,uBAAuB;AACjD,SAASC,oBAAoB,QAAQ,sBAAsB;AAC3D,SAASC,aAAa,EAAEC,WAAW,QAAQ,wBAAwB;AAEnE,SACEC,YAAY,EACZC,eAAe,EACfC,mBAAmB,EACnBC,oBAAoB,EACpBC,oBAAoB,EACpBC,UAAU,QACL,kBAAkB;AAEzB,SACEC,KAAK,EACLC,MAAM,EACNC,KAAK,EACLC,EAAE,EACFC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,KAAK,QACA,cAAc;AAErB,OAAO,MAAMC,gCAAgCN,OAAO;IAClDO,SAASN,SAAST;IAClBgB,IAAIP,SAASZ;IACboB,QAAQN;IACRO,QAAQT,SAASX;AACnB,GAAG;AAMH,OAAO,MAAMqB,kBAAkBR,SAAS;AAGxC;;;;;CAKC,GACD,OAAO,SAASS,YAAYC,KAAc;IACxC,OAAOhB,GAAGgB,OAAOF;AACnB;AAEA;;;;;CAKC,GACD,OAAO,SAASG,kBAAkBD,KAAc;IAC9C,OAAOE,MAAMC,OAAO,CAACH,UAAUA,MAAMI,KAAK,CAACL;AAC7C;AAEA,MAAMM,WAAWpB,QAAQ;AAEzB,OAAO,MAAMqB,6BAA6BlB,SACxCI,MAAM;IAACP,QAAQsB;IAAY1B;CAAQ,GACnC;AAEF,OAAO,MAAM2B,kCAAkChB,MAAM;IACnDP,QAAQsB;IACR1B;CACD,EAAE;AAEH,OAAO,MAAM4B,oCAAoClB,MAAM;IACrDD;IACAA;IACAT,MAAMiB;CACP,EAAE;AAEH,OAAO,MAAMY,gCAAgCnB,MAAM;IACjDD;IACAP,MAAM4B,OAAOC,MAAM,CAACtC;IACpBgB;IACAR,OACEW,+BACAN,OAAO;QACLU,QAAQT,SAASC,OAAOC,UAAUV;IACpC;CAEH,EAAE;AAqBH,OAAO,MAAMiC,sCAAsC1B,OAAO;IACxD,oCAAoC;IACpC2B,aAAazB,OAAOC,UAAUV;IAC9BmC,SAAS1C;IACT2C,mBAAmB9B,SAASI;AAC9B,GAAG;AAMH;;;;;;;CAOC,GACD,OAAO,SAAS2B,sCACdjB,KAAc;IAEdzB,aACEyB,OACAa,qCACA,0BACA1C,UAAU+C,aAAa;AAE3B;AAEA,OAAO,MAAMC,oCAAoChC,OAAO;IACtDiC,WAAW/B,OAAOC,UAAUV;IAC5ByC,iBAAiBnC,SAASI;AAC5B,GAAG;AAMH;;;;;;;CAOC,GACD,OAAO,SAASgC,oCACdtB,KAAc;IAEdzB,aACEyB,OACAmB,mCACA,0BACAhD,UAAU+C,aAAa;AAE3B;AAEA,MAAMK,qBAAqB;IAAER,SAAS1C;AAAc;AACpD,MAAMmD,sBAAsBrC,OAAO;IACjC,GAAGoC,kBAAkB;IACrBE,SAASnC;AACX;AACA,MAAMoC,uBAAuBvC,OAAO;IAClC,GAAGoC,kBAAkB;IACrBI,QAAQrC;AACV;AAEA,OAAO,MAAMsC,qCAAqCpC,MAAM;IACtDgC;IACAE;CACD,EAAE;AAWH;;;;;;;CAOC,GACD,OAAO,SAASG,qCACd7B,KAAc;IAEdzB,aACEyB,OACA4B,oCACA,0BACAzD,UAAU+C,aAAa;AAE3B;AAEA,OAAO,MAAMY,6BAA6B3C,OAAO;IAC/CQ,IAAIL;IACJyC,OAAO3D;AACT,GAAG;AAIH;;;;;;;CAOC,GACD,OAAO,SAAS4D,oCACdhC,KAAc;IAEdzB,aACEyB,OACA8B,4BACA,0BACA3D,UAAU+C,aAAa;AAE3B;AAEA,MAAMe,mBAAmB9C,OAAO;IAC9BQ,IAAInB;IACJkB,SAASf;IACTuD,QAAQ7B;AACV;AAEA,MAAM8B,kBAAkBzD"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import ObjectMultiplex from '@metamask/object-multiplex';
|
|
2
|
-
import { WindowPostMessageStream } from '@metamask/post-message-stream';
|
|
3
|
-
import { logError, SNAP_STREAM_NAMES } from '@metamask/snaps-utils';
|
|
4
|
-
import { pipeline } from 'readable-stream';
|
|
5
|
-
import { BaseSnapExecutor } from '../common/BaseSnapExecutor';
|
|
6
|
-
import { log } from '../logging';
|
|
7
|
-
export class IFrameSnapExecutor extends BaseSnapExecutor {
|
|
8
|
-
/**
|
|
9
|
-
* Initialize the IFrameSnapExecutor. This creates a post message stream from
|
|
10
|
-
* and to the parent window, for two-way communication with the iframe.
|
|
11
|
-
*
|
|
12
|
-
* @param stream - The stream to use for communication.
|
|
13
|
-
* @returns An instance of `IFrameSnapExecutor`, with the initialized post
|
|
14
|
-
* message streams.
|
|
15
|
-
*/ static initialize(stream = new WindowPostMessageStream({
|
|
16
|
-
name: 'child',
|
|
17
|
-
target: 'parent',
|
|
18
|
-
targetWindow: self.parent,
|
|
19
|
-
targetOrigin: '*'
|
|
20
|
-
})) {
|
|
21
|
-
log('Worker: Connecting to parent.');
|
|
22
|
-
const mux = new ObjectMultiplex();
|
|
23
|
-
pipeline(stream, mux, stream, (error)=>{
|
|
24
|
-
if (error) {
|
|
25
|
-
logError(`Parent stream failure, closing worker.`, error);
|
|
26
|
-
}
|
|
27
|
-
self.close();
|
|
28
|
-
});
|
|
29
|
-
const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);
|
|
30
|
-
const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC);
|
|
31
|
-
return new IFrameSnapExecutor(commandStream, rpcStream);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=IFrameSnapExecutor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/iframe/IFrameSnapExecutor.ts"],"sourcesContent":["import ObjectMultiplex from '@metamask/object-multiplex';\nimport type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { WindowPostMessageStream } from '@metamask/post-message-stream';\nimport { logError, SNAP_STREAM_NAMES } from '@metamask/snaps-utils';\nimport { pipeline } from 'readable-stream';\n\nimport { BaseSnapExecutor } from '../common/BaseSnapExecutor';\nimport { log } from '../logging';\n\nexport class IFrameSnapExecutor extends BaseSnapExecutor {\n /**\n * Initialize the IFrameSnapExecutor. This creates a post message stream from\n * and to the parent window, for two-way communication with the iframe.\n *\n * @param stream - The stream to use for communication.\n * @returns An instance of `IFrameSnapExecutor`, with the initialized post\n * message streams.\n */\n static initialize(\n stream: BasePostMessageStream = new WindowPostMessageStream({\n name: 'child',\n target: 'parent',\n targetWindow: self.parent,\n targetOrigin: '*',\n }),\n ) {\n log('Worker: Connecting to parent.');\n\n const mux = new ObjectMultiplex();\n pipeline(stream, mux, stream, (error) => {\n if (error) {\n logError(`Parent stream failure, closing worker.`, error);\n }\n self.close();\n });\n\n const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);\n const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC);\n\n return new IFrameSnapExecutor(commandStream, rpcStream);\n }\n}\n"],"names":["ObjectMultiplex","WindowPostMessageStream","logError","SNAP_STREAM_NAMES","pipeline","BaseSnapExecutor","log","IFrameSnapExecutor","initialize","stream","name","target","targetWindow","self","parent","targetOrigin","mux","error","close","commandStream","createStream","COMMAND","rpcStream","JSON_RPC"],"mappings":"AAAA,OAAOA,qBAAqB,6BAA6B;AAEzD,SAASC,uBAAuB,QAAQ,gCAAgC;AACxE,SAASC,QAAQ,EAAEC,iBAAiB,QAAQ,wBAAwB;AACpE,SAASC,QAAQ,QAAQ,kBAAkB;AAE3C,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,GAAG,QAAQ,aAAa;AAEjC,OAAO,MAAMC,2BAA2BF;IACtC;;;;;;;GAOC,GACD,OAAOG,WACLC,SAAgC,IAAIR,wBAAwB;QAC1DS,MAAM;QACNC,QAAQ;QACRC,cAAcC,KAAKC,MAAM;QACzBC,cAAc;IAChB,EAAE,EACF;QACAT,IAAI;QAEJ,MAAMU,MAAM,IAAIhB;QAChBI,SAASK,QAAQO,KAAKP,QAAQ,CAACQ;YAC7B,IAAIA,OAAO;gBACTf,SAAS,CAAC,sCAAsC,CAAC,EAAEe;YACrD;YACAJ,KAAKK,KAAK;QACZ;QAEA,MAAMC,gBAAgBH,IAAII,YAAY,CAACjB,kBAAkBkB,OAAO;QAChE,MAAMC,YAAYN,IAAII,YAAY,CAACjB,kBAAkBoB,QAAQ;QAE7D,OAAO,IAAIhB,mBAAmBY,eAAeG;IAC/C;AACF"}
|
package/dist/esm/iframe/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { executeLockdownEvents } from '../common/lockdown/lockdown-events';
|
|
2
|
-
import { executeLockdownMore } from '../common/lockdown/lockdown-more';
|
|
3
|
-
import { IFrameSnapExecutor } from './IFrameSnapExecutor';
|
|
4
|
-
// Lockdown is already applied in LavaMoat
|
|
5
|
-
executeLockdownMore();
|
|
6
|
-
executeLockdownEvents();
|
|
7
|
-
IFrameSnapExecutor.initialize();
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/iframe/index.ts"],"sourcesContent":["import { executeLockdownEvents } from '../common/lockdown/lockdown-events';\nimport { executeLockdownMore } from '../common/lockdown/lockdown-more';\nimport { IFrameSnapExecutor } from './IFrameSnapExecutor';\n\n// Lockdown is already applied in LavaMoat\nexecuteLockdownMore();\nexecuteLockdownEvents();\n\nIFrameSnapExecutor.initialize();\n"],"names":["executeLockdownEvents","executeLockdownMore","IFrameSnapExecutor","initialize"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,qCAAqC;AAC3E,SAASC,mBAAmB,QAAQ,mCAAmC;AACvE,SAASC,kBAAkB,QAAQ,uBAAuB;AAE1D,0CAA0C;AAC1CD;AACAD;AAEAE,mBAAmBC,UAAU"}
|
package/dist/esm/index.js
DELETED
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './proxy';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU"}
|
package/dist/esm/logging.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { snapsLogger } from '@metamask/snaps-utils';
|
|
2
|
-
import { createModuleLogger } from '@metamask/utils';
|
|
3
|
-
/**
|
|
4
|
-
* A logging function specific to this package. The log messages don't show up
|
|
5
|
-
* by default, but they can be enabled by setting the environment variable:
|
|
6
|
-
* - `DEBUG=metamask:snaps:snaps-execution-environments`, or
|
|
7
|
-
* - `DEBUG=metamask:snaps:*` to enable all logs from `@metamask/snaps-*`.
|
|
8
|
-
*/ export const log = createModuleLogger(snapsLogger, 'snaps-execution-environments');
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=logging.js.map
|
package/dist/esm/logging.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/logging.ts"],"sourcesContent":["import { snapsLogger } from '@metamask/snaps-utils';\nimport { createModuleLogger } from '@metamask/utils';\n\n/**\n * A logging function specific to this package. The log messages don't show up\n * by default, but they can be enabled by setting the environment variable:\n * - `DEBUG=metamask:snaps:snaps-execution-environments`, or\n * - `DEBUG=metamask:snaps:*` to enable all logs from `@metamask/snaps-*`.\n */\nexport const log = createModuleLogger(\n snapsLogger,\n 'snaps-execution-environments',\n);\n"],"names":["snapsLogger","createModuleLogger","log"],"mappings":"AAAA,SAASA,WAAW,QAAQ,wBAAwB;AACpD,SAASC,kBAAkB,QAAQ,kBAAkB;AAErD;;;;;CAKC,GACD,OAAO,MAAMC,MAAMD,mBACjBD,aACA,gCACA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import ObjectMultiplex from '@metamask/object-multiplex';
|
|
2
|
-
import { ProcessMessageStream } from '@metamask/post-message-stream';
|
|
3
|
-
import { logError, SNAP_STREAM_NAMES } from '@metamask/snaps-utils';
|
|
4
|
-
import { pipeline } from 'readable-stream';
|
|
5
|
-
import { BaseSnapExecutor } from '../common/BaseSnapExecutor';
|
|
6
|
-
import { log } from '../logging';
|
|
7
|
-
export class ChildProcessSnapExecutor extends BaseSnapExecutor {
|
|
8
|
-
static initialize() {
|
|
9
|
-
log('Worker: Connecting to parent.');
|
|
10
|
-
const parentStream = new ProcessMessageStream();
|
|
11
|
-
const mux = new ObjectMultiplex();
|
|
12
|
-
pipeline(parentStream, mux, parentStream, (error)=>{
|
|
13
|
-
if (error) {
|
|
14
|
-
logError(`Parent stream failure, closing worker.`, error);
|
|
15
|
-
}
|
|
16
|
-
self.close();
|
|
17
|
-
});
|
|
18
|
-
const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);
|
|
19
|
-
const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC);
|
|
20
|
-
return new ChildProcessSnapExecutor(commandStream, rpcStream);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=ChildProcessSnapExecutor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/node-process/ChildProcessSnapExecutor.ts"],"sourcesContent":["import ObjectMultiplex from '@metamask/object-multiplex';\nimport { ProcessMessageStream } from '@metamask/post-message-stream';\nimport { logError, SNAP_STREAM_NAMES } from '@metamask/snaps-utils';\nimport { pipeline } from 'readable-stream';\n\nimport { BaseSnapExecutor } from '../common/BaseSnapExecutor';\nimport { log } from '../logging';\n\nexport class ChildProcessSnapExecutor extends BaseSnapExecutor {\n static initialize() {\n log('Worker: Connecting to parent.');\n\n const parentStream = new ProcessMessageStream();\n const mux = new ObjectMultiplex();\n pipeline(parentStream, mux as any, parentStream, (error) => {\n if (error) {\n logError(`Parent stream failure, closing worker.`, error);\n }\n self.close();\n });\n\n const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);\n const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC) as any;\n return new ChildProcessSnapExecutor(commandStream, rpcStream);\n }\n}\n"],"names":["ObjectMultiplex","ProcessMessageStream","logError","SNAP_STREAM_NAMES","pipeline","BaseSnapExecutor","log","ChildProcessSnapExecutor","initialize","parentStream","mux","error","self","close","commandStream","createStream","COMMAND","rpcStream","JSON_RPC"],"mappings":"AAAA,OAAOA,qBAAqB,6BAA6B;AACzD,SAASC,oBAAoB,QAAQ,gCAAgC;AACrE,SAASC,QAAQ,EAAEC,iBAAiB,QAAQ,wBAAwB;AACpE,SAASC,QAAQ,QAAQ,kBAAkB;AAE3C,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,GAAG,QAAQ,aAAa;AAEjC,OAAO,MAAMC,iCAAiCF;IAC5C,OAAOG,aAAa;QAClBF,IAAI;QAEJ,MAAMG,eAAe,IAAIR;QACzB,MAAMS,MAAM,IAAIV;QAChBI,SAASK,cAAcC,KAAYD,cAAc,CAACE;YAChD,IAAIA,OAAO;gBACTT,SAAS,CAAC,sCAAsC,CAAC,EAAES;YACrD;YACAC,KAAKC,KAAK;QACZ;QAEA,MAAMC,gBAAgBJ,IAAIK,YAAY,CAACZ,kBAAkBa,OAAO;QAChE,MAAMC,YAAYP,IAAIK,YAAY,CAACZ,kBAAkBe,QAAQ;QAC7D,OAAO,IAAIX,yBAAyBO,eAAeG;IACrD;AACF"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { executeLockdownMore } from '../common/lockdown/lockdown-more';
|
|
2
|
-
import { ChildProcessSnapExecutor } from './ChildProcessSnapExecutor';
|
|
3
|
-
// Lockdown is already applied in LavaMoat
|
|
4
|
-
executeLockdownMore();
|
|
5
|
-
ChildProcessSnapExecutor.initialize();
|
|
6
|
-
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/node-process/index.ts"],"sourcesContent":["import { executeLockdownMore } from '../common/lockdown/lockdown-more';\nimport { ChildProcessSnapExecutor } from './ChildProcessSnapExecutor';\n\n// Lockdown is already applied in LavaMoat\nexecuteLockdownMore();\n\nChildProcessSnapExecutor.initialize();\n"],"names":["executeLockdownMore","ChildProcessSnapExecutor","initialize"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,mCAAmC;AACvE,SAASC,wBAAwB,QAAQ,6BAA6B;AAEtE,0CAA0C;AAC1CD;AAEAC,yBAAyBC,UAAU"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import ObjectMultiplex from '@metamask/object-multiplex';
|
|
2
|
-
import { ThreadMessageStream } from '@metamask/post-message-stream';
|
|
3
|
-
import { logError, SNAP_STREAM_NAMES } from '@metamask/snaps-utils';
|
|
4
|
-
import { pipeline } from 'readable-stream';
|
|
5
|
-
import { BaseSnapExecutor } from '../common/BaseSnapExecutor';
|
|
6
|
-
import { log } from '../logging';
|
|
7
|
-
export class ThreadSnapExecutor extends BaseSnapExecutor {
|
|
8
|
-
static initialize() {
|
|
9
|
-
log('Worker: Connecting to parent.');
|
|
10
|
-
const parentStream = new ThreadMessageStream();
|
|
11
|
-
const mux = new ObjectMultiplex();
|
|
12
|
-
pipeline(parentStream, mux, parentStream, (error)=>{
|
|
13
|
-
if (error) {
|
|
14
|
-
logError(`Parent stream failure, closing worker.`, error);
|
|
15
|
-
}
|
|
16
|
-
self.close();
|
|
17
|
-
});
|
|
18
|
-
const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);
|
|
19
|
-
const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC);
|
|
20
|
-
return new ThreadSnapExecutor(commandStream, rpcStream);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=ThreadSnapExecutor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/node-thread/ThreadSnapExecutor.ts"],"sourcesContent":["import ObjectMultiplex from '@metamask/object-multiplex';\nimport { ThreadMessageStream } from '@metamask/post-message-stream';\nimport { logError, SNAP_STREAM_NAMES } from '@metamask/snaps-utils';\nimport { pipeline } from 'readable-stream';\n\nimport { BaseSnapExecutor } from '../common/BaseSnapExecutor';\nimport { log } from '../logging';\n\nexport class ThreadSnapExecutor extends BaseSnapExecutor {\n static initialize() {\n log('Worker: Connecting to parent.');\n\n const parentStream = new ThreadMessageStream();\n const mux = new ObjectMultiplex();\n pipeline(parentStream, mux as any, parentStream, (error) => {\n if (error) {\n logError(`Parent stream failure, closing worker.`, error);\n }\n self.close();\n });\n\n const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);\n const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC) as any;\n return new ThreadSnapExecutor(commandStream, rpcStream);\n }\n}\n"],"names":["ObjectMultiplex","ThreadMessageStream","logError","SNAP_STREAM_NAMES","pipeline","BaseSnapExecutor","log","ThreadSnapExecutor","initialize","parentStream","mux","error","self","close","commandStream","createStream","COMMAND","rpcStream","JSON_RPC"],"mappings":"AAAA,OAAOA,qBAAqB,6BAA6B;AACzD,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,QAAQ,EAAEC,iBAAiB,QAAQ,wBAAwB;AACpE,SAASC,QAAQ,QAAQ,kBAAkB;AAE3C,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,GAAG,QAAQ,aAAa;AAEjC,OAAO,MAAMC,2BAA2BF;IACtC,OAAOG,aAAa;QAClBF,IAAI;QAEJ,MAAMG,eAAe,IAAIR;QACzB,MAAMS,MAAM,IAAIV;QAChBI,SAASK,cAAcC,KAAYD,cAAc,CAACE;YAChD,IAAIA,OAAO;gBACTT,SAAS,CAAC,sCAAsC,CAAC,EAAES;YACrD;YACAC,KAAKC,KAAK;QACZ;QAEA,MAAMC,gBAAgBJ,IAAIK,YAAY,CAACZ,kBAAkBa,OAAO;QAChE,MAAMC,YAAYP,IAAIK,YAAY,CAACZ,kBAAkBe,QAAQ;QAC7D,OAAO,IAAIX,mBAAmBO,eAAeG;IAC/C;AACF"}
|