@metamask/snaps-execution-environments 4.0.0 → 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 +15 -1
- package/dist/browserify/iframe/bundle.js +4 -4
- package/dist/browserify/iframe/index.html +201 -110
- package/dist/browserify/node-process/bundle.js +204 -113
- package/dist/browserify/node-thread/bundle.js +204 -113
- package/dist/browserify/webview/bundle.js +4 -4
- package/dist/browserify/webview/index.html +201 -110
- package/dist/browserify/worker-executor/bundle.js +205 -114
- package/dist/browserify/worker-pool/bundle.js +4 -4
- package/dist/browserify/worker-pool/index.html +201 -110
- 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 +29 -22
- 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,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return _default;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _rpcerrors = require("@metamask/rpc-errors");
|
|
12
|
-
const MINIMUM_TIMEOUT = 10;
|
|
13
|
-
/**
|
|
14
|
-
* Creates a pair of `setTimeout` and `clearTimeout` functions attenuated such
|
|
15
|
-
* that:
|
|
16
|
-
* - `setTimeout` throws if its "handler" parameter is not a function.
|
|
17
|
-
* - `clearTimeout` only clears timeouts created by its sibling `setTimeout`,
|
|
18
|
-
* or else no-ops.
|
|
19
|
-
*
|
|
20
|
-
* @returns An object with the attenuated `setTimeout` and `clearTimeout`
|
|
21
|
-
* functions.
|
|
22
|
-
*/ const createTimeout = ()=>{
|
|
23
|
-
const registeredHandles = new Map();
|
|
24
|
-
const _setTimeout = (handler, timeout)=>{
|
|
25
|
-
if (typeof handler !== 'function') {
|
|
26
|
-
throw _rpcerrors.rpcErrors.internal(`The timeout handler must be a function. Received: ${typeof handler}.`);
|
|
27
|
-
}
|
|
28
|
-
harden(handler);
|
|
29
|
-
const handle = Object.freeze(Object.create(null));
|
|
30
|
-
const platformHandle = setTimeout(()=>{
|
|
31
|
-
registeredHandles.delete(handle);
|
|
32
|
-
handler();
|
|
33
|
-
}, Math.max(MINIMUM_TIMEOUT, timeout ?? 0));
|
|
34
|
-
registeredHandles.set(handle, platformHandle);
|
|
35
|
-
return handle;
|
|
36
|
-
};
|
|
37
|
-
const _clearTimeout = (handle)=>{
|
|
38
|
-
const platformHandle = registeredHandles.get(handle);
|
|
39
|
-
if (platformHandle !== undefined) {
|
|
40
|
-
clearTimeout(platformHandle);
|
|
41
|
-
registeredHandles.delete(handle);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const teardownFunction = ()=>{
|
|
45
|
-
for (const handle of registeredHandles.keys()){
|
|
46
|
-
_clearTimeout(handle);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
return {
|
|
50
|
-
setTimeout: harden(_setTimeout),
|
|
51
|
-
clearTimeout: harden(_clearTimeout),
|
|
52
|
-
teardownFunction
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
const endowmentModule = {
|
|
56
|
-
names: [
|
|
57
|
-
'setTimeout',
|
|
58
|
-
'clearTimeout'
|
|
59
|
-
],
|
|
60
|
-
factory: createTimeout
|
|
61
|
-
};
|
|
62
|
-
const _default = endowmentModule;
|
|
63
|
-
|
|
64
|
-
//# sourceMappingURL=timeout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/common/endowments/timeout.ts"],"sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\n\nconst MINIMUM_TIMEOUT = 10;\n\n/**\n * Creates a pair of `setTimeout` and `clearTimeout` functions attenuated such\n * that:\n * - `setTimeout` throws if its \"handler\" parameter is not a function.\n * - `clearTimeout` only clears timeouts created by its sibling `setTimeout`,\n * or else no-ops.\n *\n * @returns An object with the attenuated `setTimeout` and `clearTimeout`\n * functions.\n */\nconst createTimeout = () => {\n const registeredHandles = new Map<unknown, unknown>();\n const _setTimeout = (handler: TimerHandler, timeout?: number): unknown => {\n if (typeof handler !== 'function') {\n throw rpcErrors.internal(\n `The timeout handler must be a function. Received: ${typeof handler}.`,\n );\n }\n harden(handler);\n const handle = Object.freeze(Object.create(null));\n const platformHandle = setTimeout(() => {\n registeredHandles.delete(handle);\n handler();\n }, Math.max(MINIMUM_TIMEOUT, timeout ?? 0));\n\n registeredHandles.set(handle, platformHandle);\n return handle;\n };\n\n const _clearTimeout = (handle: unknown): void => {\n const platformHandle = registeredHandles.get(handle);\n if (platformHandle !== undefined) {\n clearTimeout(platformHandle as any);\n registeredHandles.delete(handle);\n }\n };\n\n const teardownFunction = (): void => {\n for (const handle of registeredHandles.keys()) {\n _clearTimeout(handle);\n }\n };\n\n return {\n setTimeout: harden(_setTimeout),\n clearTimeout: harden(_clearTimeout),\n teardownFunction,\n } as const;\n};\n\nconst endowmentModule = {\n names: ['setTimeout', 'clearTimeout'] as const,\n factory: createTimeout,\n};\nexport default endowmentModule;\n"],"names":["MINIMUM_TIMEOUT","createTimeout","registeredHandles","Map","_setTimeout","handler","timeout","rpcErrors","internal","harden","handle","Object","freeze","create","platformHandle","setTimeout","delete","Math","max","set","_clearTimeout","get","undefined","clearTimeout","teardownFunction","keys","endowmentModule","names","factory"],"mappings":";;;;+BA0DA;;;eAAA;;;2BA1D0B;AAE1B,MAAMA,kBAAkB;AAExB;;;;;;;;;CASC,GACD,MAAMC,gBAAgB;IACpB,MAAMC,oBAAoB,IAAIC;IAC9B,MAAMC,cAAc,CAACC,SAAuBC;QAC1C,IAAI,OAAOD,YAAY,YAAY;YACjC,MAAME,oBAAS,CAACC,QAAQ,CACtB,CAAC,kDAAkD,EAAE,OAAOH,QAAQ,CAAC,CAAC;QAE1E;QACAI,OAAOJ;QACP,MAAMK,SAASC,OAAOC,MAAM,CAACD,OAAOE,MAAM,CAAC;QAC3C,MAAMC,iBAAiBC,WAAW;YAChCb,kBAAkBc,MAAM,CAACN;YACzBL;QACF,GAAGY,KAAKC,GAAG,CAAClB,iBAAiBM,WAAW;QAExCJ,kBAAkBiB,GAAG,CAACT,QAAQI;QAC9B,OAAOJ;IACT;IAEA,MAAMU,gBAAgB,CAACV;QACrB,MAAMI,iBAAiBZ,kBAAkBmB,GAAG,CAACX;QAC7C,IAAII,mBAAmBQ,WAAW;YAChCC,aAAaT;YACbZ,kBAAkBc,MAAM,CAACN;QAC3B;IACF;IAEA,MAAMc,mBAAmB;QACvB,KAAK,MAAMd,UAAUR,kBAAkBuB,IAAI,GAAI;YAC7CL,cAAcV;QAChB;IACF;IAEA,OAAO;QACLK,YAAYN,OAAOL;QACnBmB,cAAcd,OAAOW;QACrBI;IACF;AACF;AAEA,MAAME,kBAAkB;IACtBC,OAAO;QAAC;QAAc;KAAe;IACrCC,SAAS3B;AACX;MACA,WAAeyB"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
addEventListener: function() {
|
|
13
|
-
return addEventListener;
|
|
14
|
-
},
|
|
15
|
-
removeEventListener: function() {
|
|
16
|
-
return removeEventListener;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _rpcerrors = require("@metamask/rpc-errors");
|
|
20
|
-
const _globalObject = require("./globalObject");
|
|
21
|
-
function addEventListener(event, listener) {
|
|
22
|
-
if ('addEventListener' in _globalObject.rootRealmGlobal && typeof _globalObject.rootRealmGlobal.addEventListener === 'function') {
|
|
23
|
-
return _globalObject.rootRealmGlobal.addEventListener(event.toLowerCase(), listener);
|
|
24
|
-
}
|
|
25
|
-
if (_globalObject.rootRealmGlobal.process && 'on' in _globalObject.rootRealmGlobal.process && typeof _globalObject.rootRealmGlobal.process.on === 'function') {
|
|
26
|
-
return _globalObject.rootRealmGlobal.process.on(event, listener);
|
|
27
|
-
}
|
|
28
|
-
throw _rpcerrors.rpcErrors.internal('Platform agnostic addEventListener failed.');
|
|
29
|
-
}
|
|
30
|
-
function removeEventListener(event, listener) {
|
|
31
|
-
if ('removeEventListener' in _globalObject.rootRealmGlobal && typeof _globalObject.rootRealmGlobal.removeEventListener === 'function') {
|
|
32
|
-
return _globalObject.rootRealmGlobal.removeEventListener(event.toLowerCase(), listener);
|
|
33
|
-
}
|
|
34
|
-
if (_globalObject.rootRealmGlobal.process && 'removeListener' in _globalObject.rootRealmGlobal.process && typeof _globalObject.rootRealmGlobal.process.removeListener === 'function') {
|
|
35
|
-
return _globalObject.rootRealmGlobal.process.removeListener(event, listener);
|
|
36
|
-
}
|
|
37
|
-
throw new Error('Platform agnostic removeEventListener failed');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=globalEvents.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/common/globalEvents.ts"],"sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\n\nimport { rootRealmGlobal } from './globalObject';\n\n/**\n * Adds an event listener platform agnostically, trying both `globalThis.addEventListener` and `globalThis.process.on`\n *\n * @param event - The event to listen for.\n * @param listener - The listener to be triggered when the event occurs.\n * @returns The result of the platform agnostic operation if any.\n * @throws If none of the platform options are present.\n */\nexport function addEventListener(\n event: string,\n listener: (...args: any[]) => void,\n) {\n if (\n 'addEventListener' in rootRealmGlobal &&\n typeof rootRealmGlobal.addEventListener === 'function'\n ) {\n return rootRealmGlobal.addEventListener(event.toLowerCase(), listener);\n }\n\n if (\n rootRealmGlobal.process &&\n 'on' in rootRealmGlobal.process &&\n typeof rootRealmGlobal.process.on === 'function'\n ) {\n return rootRealmGlobal.process.on(event, listener);\n }\n\n throw rpcErrors.internal('Platform agnostic addEventListener failed.');\n}\n\n/**\n * Removes an event listener platform agnostically, trying both `globalThis.removeEventListener` and `globalThis.process.removeListener`\n *\n * @param event - The event to remove the listener for.\n * @param listener - The currently attached listener.\n * @returns The result of the platform agnostic operation if any.\n * @throws If none of the platform options are present.\n */\nexport function removeEventListener(\n event: string,\n listener: (...args: any[]) => void,\n) {\n if (\n 'removeEventListener' in rootRealmGlobal &&\n typeof rootRealmGlobal.removeEventListener === 'function'\n ) {\n return rootRealmGlobal.removeEventListener(event.toLowerCase(), listener);\n }\n\n if (\n rootRealmGlobal.process &&\n 'removeListener' in rootRealmGlobal.process &&\n typeof rootRealmGlobal.process.removeListener === 'function'\n ) {\n return rootRealmGlobal.process.removeListener(event, listener);\n }\n\n throw new Error('Platform agnostic removeEventListener failed');\n}\n"],"names":["addEventListener","removeEventListener","event","listener","rootRealmGlobal","toLowerCase","process","on","rpcErrors","internal","removeListener","Error"],"mappings":";;;;;;;;;;;IAYgBA,gBAAgB;eAAhBA;;IA8BAC,mBAAmB;eAAnBA;;;2BA1CU;8BAEM;AAUzB,SAASD,iBACdE,KAAa,EACbC,QAAkC;IAElC,IACE,sBAAsBC,6BAAe,IACrC,OAAOA,6BAAe,CAACJ,gBAAgB,KAAK,YAC5C;QACA,OAAOI,6BAAe,CAACJ,gBAAgB,CAACE,MAAMG,WAAW,IAAIF;IAC/D;IAEA,IACEC,6BAAe,CAACE,OAAO,IACvB,QAAQF,6BAAe,CAACE,OAAO,IAC/B,OAAOF,6BAAe,CAACE,OAAO,CAACC,EAAE,KAAK,YACtC;QACA,OAAOH,6BAAe,CAACE,OAAO,CAACC,EAAE,CAACL,OAAOC;IAC3C;IAEA,MAAMK,oBAAS,CAACC,QAAQ,CAAC;AAC3B;AAUO,SAASR,oBACdC,KAAa,EACbC,QAAkC;IAElC,IACE,yBAAyBC,6BAAe,IACxC,OAAOA,6BAAe,CAACH,mBAAmB,KAAK,YAC/C;QACA,OAAOG,6BAAe,CAACH,mBAAmB,CAACC,MAAMG,WAAW,IAAIF;IAClE;IAEA,IACEC,6BAAe,CAACE,OAAO,IACvB,oBAAoBF,6BAAe,CAACE,OAAO,IAC3C,OAAOF,6BAAe,CAACE,OAAO,CAACI,cAAc,KAAK,YAClD;QACA,OAAON,6BAAe,CAACE,OAAO,CAACI,cAAc,CAACR,OAAOC;IACvD;IAEA,MAAM,IAAIQ,MAAM;AAClB"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
rootRealmGlobal: function() {
|
|
13
|
-
return rootRealmGlobal;
|
|
14
|
-
},
|
|
15
|
-
rootRealmGlobalName: function() {
|
|
16
|
-
return rootRealmGlobalName;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
var GlobalObjectNames;
|
|
20
|
-
(function(GlobalObjectNames) {
|
|
21
|
-
GlobalObjectNames[// The globalThis entry is incorrectly identified as shadowing the global
|
|
22
|
-
// globalThis.
|
|
23
|
-
/* eslint-disable @typescript-eslint/naming-convention */ // eslint-disable-next-line @typescript-eslint/no-shadow
|
|
24
|
-
"globalThis"] = "globalThis";
|
|
25
|
-
GlobalObjectNames["global"] = "global";
|
|
26
|
-
GlobalObjectNames["self"] = "self";
|
|
27
|
-
GlobalObjectNames["window"] = "window";
|
|
28
|
-
})(GlobalObjectNames || (GlobalObjectNames = {}));
|
|
29
|
-
let _rootRealmGlobal;
|
|
30
|
-
let _rootRealmGlobalName;
|
|
31
|
-
/* istanbul ignore next */ /* eslint-disable no-negated-condition */ if (typeof globalThis !== 'undefined') {
|
|
32
|
-
_rootRealmGlobal = globalThis;
|
|
33
|
-
_rootRealmGlobalName = GlobalObjectNames.globalThis;
|
|
34
|
-
} else if (typeof self !== 'undefined') {
|
|
35
|
-
_rootRealmGlobal = self;
|
|
36
|
-
_rootRealmGlobalName = GlobalObjectNames.self;
|
|
37
|
-
} else if (typeof window !== 'undefined') {
|
|
38
|
-
_rootRealmGlobal = window;
|
|
39
|
-
_rootRealmGlobalName = GlobalObjectNames.window;
|
|
40
|
-
} else if (typeof global !== 'undefined') {
|
|
41
|
-
_rootRealmGlobal = global;
|
|
42
|
-
_rootRealmGlobalName = GlobalObjectNames.global;
|
|
43
|
-
} else {
|
|
44
|
-
throw new Error('Unknown realm type; failed to identify global object.');
|
|
45
|
-
}
|
|
46
|
-
/* eslint-enable no-negated-condition */ /**
|
|
47
|
-
* A platform-agnostic alias for the root realm global object.
|
|
48
|
-
*/ const rootRealmGlobal = _rootRealmGlobal;
|
|
49
|
-
/**
|
|
50
|
-
* The string literal corresponding to the name of the root realm global object.
|
|
51
|
-
*/ const rootRealmGlobalName = _rootRealmGlobalName;
|
|
52
|
-
|
|
53
|
-
//# sourceMappingURL=globalObject.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/common/globalObject.ts"],"sourcesContent":["enum GlobalObjectNames {\n // The globalThis entry is incorrectly identified as shadowing the global\n // globalThis.\n /* eslint-disable @typescript-eslint/naming-convention */\n // eslint-disable-next-line @typescript-eslint/no-shadow\n globalThis = 'globalThis',\n global = 'global',\n self = 'self',\n window = 'window',\n /* eslint-enable @typescript-eslint/naming-convention */\n}\n\nlet _rootRealmGlobal: typeof globalThis;\nlet _rootRealmGlobalName: string;\n\n/* istanbul ignore next */\n/* eslint-disable no-negated-condition */\nif (typeof globalThis !== 'undefined') {\n _rootRealmGlobal = globalThis;\n _rootRealmGlobalName = GlobalObjectNames.globalThis;\n} else if (typeof self !== 'undefined') {\n _rootRealmGlobal = self;\n _rootRealmGlobalName = GlobalObjectNames.self;\n} else if (typeof window !== 'undefined') {\n _rootRealmGlobal = window;\n _rootRealmGlobalName = GlobalObjectNames.window;\n} else if (typeof global !== 'undefined') {\n _rootRealmGlobal = global;\n _rootRealmGlobalName = GlobalObjectNames.global;\n} else {\n throw new Error('Unknown realm type; failed to identify global object.');\n}\n/* eslint-enable no-negated-condition */\n\n/**\n * A platform-agnostic alias for the root realm global object.\n */\nconst rootRealmGlobal = _rootRealmGlobal;\n\n/**\n * The string literal corresponding to the name of the root realm global object.\n */\nconst rootRealmGlobalName = _rootRealmGlobalName;\n\nexport { rootRealmGlobal, rootRealmGlobalName };\n"],"names":["rootRealmGlobal","rootRealmGlobalName","GlobalObjectNames","globalThis","global","self","window","_rootRealmGlobal","_rootRealmGlobalName","Error"],"mappings":";;;;;;;;;;;IA4CSA,eAAe;eAAfA;;IAAiBC,mBAAmB;eAAnBA;;;IA5C1B;UAAKC,iBAAiB;IAAjBA,kBACH,yEAAyE;IACzE,cAAc;IACd,uDAAuD,GACvD,wDAAwD;IACxDC,gBAAAA;IALGD,kBAMHE,YAAAA;IANGF,kBAOHG,UAAAA;IAPGH,kBAQHI,YAAAA;GARGJ,sBAAAA;AAYL,IAAIK;AACJ,IAAIC;AAEJ,wBAAwB,GACxB,uCAAuC,GACvC,IAAI,OAAOL,eAAe,aAAa;IACrCI,mBAAmBJ;IACnBK,uBAAuBN,kBAAkBC,UAAU;AACrD,OAAO,IAAI,OAAOE,SAAS,aAAa;IACtCE,mBAAmBF;IACnBG,uBAAuBN,kBAAkBG,IAAI;AAC/C,OAAO,IAAI,OAAOC,WAAW,aAAa;IACxCC,mBAAmBD;IACnBE,uBAAuBN,kBAAkBI,MAAM;AACjD,OAAO,IAAI,OAAOF,WAAW,aAAa;IACxCG,mBAAmBH;IACnBI,uBAAuBN,kBAAkBE,MAAM;AACjD,OAAO;IACL,MAAM,IAAIK,MAAM;AAClB;AACA,sCAAsC,GAEtC;;CAEC,GACD,MAAMT,kBAAkBO;AAExB;;CAEC,GACD,MAAMN,sBAAsBO"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// When creating a sandbox, limitation of the events from leaking
|
|
2
|
-
// sensitive objects is required. This is done by overriding own properties
|
|
3
|
-
// of prototypes of all existing events.
|
|
4
|
-
"use strict";
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
Object.defineProperty(exports, "executeLockdownEvents", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function() {
|
|
11
|
-
return executeLockdownEvents;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
const _utils = require("@metamask/utils");
|
|
15
|
-
/**
|
|
16
|
-
* Targeted Event objects and properties.
|
|
17
|
-
* Note: This is a map of the prototypes that inherit from Events with
|
|
18
|
-
* properties that are identified to leak sensitive objects.
|
|
19
|
-
* Not all browsers support all event types, so checking its existence is required.
|
|
20
|
-
*/ const targetEvents = new Map();
|
|
21
|
-
if ((0, _utils.hasProperty)(globalThis, 'UIEvent')) {
|
|
22
|
-
targetEvents.set(UIEvent.prototype, [
|
|
23
|
-
'view'
|
|
24
|
-
]);
|
|
25
|
-
}
|
|
26
|
-
if ((0, _utils.hasProperty)(globalThis, 'MutationEvent')) {
|
|
27
|
-
targetEvents.set(MutationEvent.prototype, [
|
|
28
|
-
'relatedNode'
|
|
29
|
-
]);
|
|
30
|
-
}
|
|
31
|
-
if ((0, _utils.hasProperty)(globalThis, 'MessageEvent')) {
|
|
32
|
-
targetEvents.set(MessageEvent.prototype, [
|
|
33
|
-
'source'
|
|
34
|
-
]);
|
|
35
|
-
}
|
|
36
|
-
if ((0, _utils.hasProperty)(globalThis, 'FocusEvent')) {
|
|
37
|
-
targetEvents.set(FocusEvent.prototype, [
|
|
38
|
-
'relatedTarget'
|
|
39
|
-
]);
|
|
40
|
-
}
|
|
41
|
-
if ((0, _utils.hasProperty)(globalThis, 'MouseEvent')) {
|
|
42
|
-
targetEvents.set(MouseEvent.prototype, [
|
|
43
|
-
'relatedTarget',
|
|
44
|
-
'fromElement',
|
|
45
|
-
'toElement'
|
|
46
|
-
]);
|
|
47
|
-
}
|
|
48
|
-
if ((0, _utils.hasProperty)(globalThis, 'TouchEvent')) {
|
|
49
|
-
targetEvents.set(TouchEvent.prototype, [
|
|
50
|
-
'targetTouches',
|
|
51
|
-
'touches'
|
|
52
|
-
]);
|
|
53
|
-
}
|
|
54
|
-
if ((0, _utils.hasProperty)(globalThis, 'Event')) {
|
|
55
|
-
targetEvents.set(Event.prototype, [
|
|
56
|
-
'target',
|
|
57
|
-
'currentTarget',
|
|
58
|
-
'srcElement',
|
|
59
|
-
'composedPath'
|
|
60
|
-
]);
|
|
61
|
-
}
|
|
62
|
-
function executeLockdownEvents() {
|
|
63
|
-
targetEvents.forEach((properties, prototype)=>{
|
|
64
|
-
for (const property of properties){
|
|
65
|
-
Object.defineProperty(prototype, property, {
|
|
66
|
-
value: undefined,
|
|
67
|
-
configurable: false,
|
|
68
|
-
writable: false
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
//# sourceMappingURL=lockdown-events.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/common/lockdown/lockdown-events.ts"],"sourcesContent":["// When creating a sandbox, limitation of the events from leaking\n// sensitive objects is required. This is done by overriding own properties\n// of prototypes of all existing events.\nimport { hasProperty } from '@metamask/utils';\n\n/**\n * Targeted Event objects and properties.\n * Note: This is a map of the prototypes that inherit from Events with\n * properties that are identified to leak sensitive objects.\n * Not all browsers support all event types, so checking its existence is required.\n */\nconst targetEvents = new Map();\nif (hasProperty(globalThis, 'UIEvent')) {\n targetEvents.set(UIEvent.prototype, ['view']);\n}\nif (hasProperty(globalThis, 'MutationEvent')) {\n targetEvents.set(MutationEvent.prototype, ['relatedNode']);\n}\nif (hasProperty(globalThis, 'MessageEvent')) {\n targetEvents.set(MessageEvent.prototype, ['source']);\n}\nif (hasProperty(globalThis, 'FocusEvent')) {\n targetEvents.set(FocusEvent.prototype, ['relatedTarget']);\n}\nif (hasProperty(globalThis, 'MouseEvent')) {\n targetEvents.set(MouseEvent.prototype, [\n 'relatedTarget',\n 'fromElement',\n 'toElement',\n ]);\n}\nif (hasProperty(globalThis, 'TouchEvent')) {\n targetEvents.set(TouchEvent.prototype, ['targetTouches', 'touches']);\n}\nif (hasProperty(globalThis, 'Event')) {\n targetEvents.set(Event.prototype, [\n 'target',\n 'currentTarget',\n 'srcElement',\n 'composedPath',\n ]);\n}\n\n/**\n * Attenuate Event objects by replacing its own properties.\n */\nexport function executeLockdownEvents() {\n targetEvents.forEach((properties, prototype) => {\n for (const property of properties) {\n Object.defineProperty(prototype, property, {\n value: undefined,\n configurable: false,\n writable: false,\n });\n }\n });\n}\n"],"names":["executeLockdownEvents","targetEvents","Map","hasProperty","globalThis","set","UIEvent","prototype","MutationEvent","MessageEvent","FocusEvent","MouseEvent","TouchEvent","Event","forEach","properties","property","Object","defineProperty","value","undefined","configurable","writable"],"mappings":"AAAA,iEAAiE;AACjE,2EAA2E;AAC3E,wCAAwC;;;;;+BA4CxBA;;;eAAAA;;;uBA3CY;AAE5B;;;;;CAKC,GACD,MAAMC,eAAe,IAAIC;AACzB,IAAIC,IAAAA,kBAAW,EAACC,YAAY,YAAY;IACtCH,aAAaI,GAAG,CAACC,QAAQC,SAAS,EAAE;QAAC;KAAO;AAC9C;AACA,IAAIJ,IAAAA,kBAAW,EAACC,YAAY,kBAAkB;IAC5CH,aAAaI,GAAG,CAACG,cAAcD,SAAS,EAAE;QAAC;KAAc;AAC3D;AACA,IAAIJ,IAAAA,kBAAW,EAACC,YAAY,iBAAiB;IAC3CH,aAAaI,GAAG,CAACI,aAAaF,SAAS,EAAE;QAAC;KAAS;AACrD;AACA,IAAIJ,IAAAA,kBAAW,EAACC,YAAY,eAAe;IACzCH,aAAaI,GAAG,CAACK,WAAWH,SAAS,EAAE;QAAC;KAAgB;AAC1D;AACA,IAAIJ,IAAAA,kBAAW,EAACC,YAAY,eAAe;IACzCH,aAAaI,GAAG,CAACM,WAAWJ,SAAS,EAAE;QACrC;QACA;QACA;KACD;AACH;AACA,IAAIJ,IAAAA,kBAAW,EAACC,YAAY,eAAe;IACzCH,aAAaI,GAAG,CAACO,WAAWL,SAAS,EAAE;QAAC;QAAiB;KAAU;AACrE;AACA,IAAIJ,IAAAA,kBAAW,EAACC,YAAY,UAAU;IACpCH,aAAaI,GAAG,CAACQ,MAAMN,SAAS,EAAE;QAChC;QACA;QACA;QACA;KACD;AACH;AAKO,SAASP;IACdC,aAAaa,OAAO,CAAC,CAACC,YAAYR;QAChC,KAAK,MAAMS,YAAYD,WAAY;YACjCE,OAAOC,cAAc,CAACX,WAAWS,UAAU;gBACzCG,OAAOC;gBACPC,cAAc;gBACdC,UAAU;YACZ;QACF;IACF;AACF"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment
|
|
2
|
-
/// <reference path="../../../../../node_modules/ses/types.d.ts" />
|
|
3
|
-
"use strict";
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
Object.defineProperty(exports, "executeLockdownMore", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function() {
|
|
10
|
-
return executeLockdownMore;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
const _snapsutils = require("@metamask/snaps-utils");
|
|
14
|
-
function executeLockdownMore() {
|
|
15
|
-
// Make all "object" and "function" own properties of globalThis
|
|
16
|
-
// non-configurable and non-writable, when possible.
|
|
17
|
-
// We call a property that is non-configurable and non-writable,
|
|
18
|
-
// "non-modifiable".
|
|
19
|
-
try {
|
|
20
|
-
const namedIntrinsics = Reflect.ownKeys(new Compartment().globalThis);
|
|
21
|
-
// These named intrinsics are not automatically hardened by `lockdown`
|
|
22
|
-
const shouldHardenManually = new Set([
|
|
23
|
-
'eval',
|
|
24
|
-
'Function'
|
|
25
|
-
]);
|
|
26
|
-
const globalProperties = new Set([
|
|
27
|
-
// universalPropertyNames is a constant added by lockdown to global scope
|
|
28
|
-
// at the time of writing, it is initialized in 'ses/src/whitelist'.
|
|
29
|
-
// These properties tend to be non-enumerable.
|
|
30
|
-
...namedIntrinsics
|
|
31
|
-
]);
|
|
32
|
-
globalProperties.forEach((propertyName)=>{
|
|
33
|
-
const descriptor = Reflect.getOwnPropertyDescriptor(globalThis, propertyName);
|
|
34
|
-
if (descriptor) {
|
|
35
|
-
if (descriptor.configurable) {
|
|
36
|
-
// If the property on globalThis is configurable, make it
|
|
37
|
-
// non-configurable. If it has no accessor properties, also make it
|
|
38
|
-
// non-writable.
|
|
39
|
-
if (hasAccessor(descriptor)) {
|
|
40
|
-
Object.defineProperty(globalThis, propertyName, {
|
|
41
|
-
configurable: false
|
|
42
|
-
});
|
|
43
|
-
} else {
|
|
44
|
-
Object.defineProperty(globalThis, propertyName, {
|
|
45
|
-
configurable: false,
|
|
46
|
-
writable: false
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (shouldHardenManually.has(propertyName)) {
|
|
51
|
-
harden(globalThis[propertyName]);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
} catch (error) {
|
|
56
|
-
(0, _snapsutils.logError)('Protecting intrinsics failed:', error);
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Checks whether the given propertyName descriptor has any accessors, i.e. the
|
|
62
|
-
* properties `get` or `set`.
|
|
63
|
-
*
|
|
64
|
-
* We want to make globals non-writable, and we can't set the `writable`
|
|
65
|
-
* property and accessor properties at the same time.
|
|
66
|
-
*
|
|
67
|
-
* @param descriptor - The propertyName descriptor to check.
|
|
68
|
-
* @returns Whether the propertyName descriptor has any accessors.
|
|
69
|
-
*/ function hasAccessor(descriptor) {
|
|
70
|
-
return 'set' in descriptor || 'get' in descriptor;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
//# 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":["executeLockdownMore","namedIntrinsics","Reflect","ownKeys","Compartment","globalThis","shouldHardenManually","Set","globalProperties","forEach","propertyName","descriptor","getOwnPropertyDescriptor","configurable","hasAccessor","Object","defineProperty","writable","has","harden","error","logError"],"mappings":"AAAA,qFAAqF;AACrF,mEAAmE;;;;;+BAwBnDA;;;eAAAA;;;4BAtBS;AAsBlB,SAASA;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;QACdC,IAAAA,oBAAQ,EAAC,iCAAiCD;QAC1C,MAAMA;IACR;AACF;AAEA;;;;;;;;;CASC,GACD,SAASN,YAAYH,UAAe;IAClC,OAAO,SAASA,cAAc,SAASA;AACzC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment
|
|
2
|
-
/// <reference path="../../../../../node_modules/ses/types.d.ts" />
|
|
3
|
-
"use strict";
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
Object.defineProperty(exports, "executeLockdown", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function() {
|
|
10
|
-
return executeLockdown;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
const _snapsutils = require("@metamask/snaps-utils");
|
|
14
|
-
function executeLockdown() {
|
|
15
|
-
try {
|
|
16
|
-
lockdown({
|
|
17
|
-
consoleTaming: 'unsafe',
|
|
18
|
-
errorTaming: 'unsafe',
|
|
19
|
-
mathTaming: 'unsafe',
|
|
20
|
-
dateTaming: 'unsafe',
|
|
21
|
-
overrideTaming: 'severe'
|
|
22
|
-
});
|
|
23
|
-
} catch (error) {
|
|
24
|
-
// If the `lockdown` call throws an exception, it should not be able to continue
|
|
25
|
-
(0, _snapsutils.logError)('Lockdown failed:', error);
|
|
26
|
-
throw error;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//# 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":["executeLockdown","lockdown","consoleTaming","errorTaming","mathTaming","dateTaming","overrideTaming","error","logError"],"mappings":"AAAA,qFAAqF;AACrF,mEAAmE;;;;;+BASnDA;;;eAAAA;;;4BAPS;AAOlB,SAASA;IACd,IAAI;QACFC,SAAS;YACPC,eAAe;YACfC,aAAa;YACbC,YAAY;YACZC,YAAY;YACZC,gBAAgB;QAClB;IACF,EAAE,OAAOC,OAAO;QACd,gFAAgF;QAChFC,IAAAA,oBAAQ,EAAC,oBAAoBD;QAC7B,MAAMA;IACR;AACF"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// original source sortParamKeys from: https://github.com/etclabscore/sig.tools/blob/master/src/postMessageServer/postMessageServer.ts#L75-L77
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "sortParamKeys", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function() {
|
|
9
|
-
return sortParamKeys;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
const sortParamKeys = (methodParams, params)=>{
|
|
13
|
-
if (!params) {
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
16
|
-
if (params instanceof Array) {
|
|
17
|
-
return params;
|
|
18
|
-
}
|
|
19
|
-
const methodParamsOrder = methodParams.reduce((paramsOrderObj, paramsName, i)=>({
|
|
20
|
-
...paramsOrderObj,
|
|
21
|
-
[paramsName]: i
|
|
22
|
-
}), {});
|
|
23
|
-
return Object.entries(params).sort(([name1, _1], [name2, _2])=>methodParamsOrder[name1] - methodParamsOrder[name2]).map(([_, val])=>val);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//# 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;;;;;+BAkBjIA;;;eAAAA;;;AAAN,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"}
|
package/dist/cjs/common/utils.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
withTeardown: function() {
|
|
13
|
-
return withTeardown;
|
|
14
|
-
},
|
|
15
|
-
proxyStreamProvider: function() {
|
|
16
|
-
return proxyStreamProvider;
|
|
17
|
-
},
|
|
18
|
-
BLOCKED_RPC_METHODS: function() {
|
|
19
|
-
return BLOCKED_RPC_METHODS;
|
|
20
|
-
},
|
|
21
|
-
assertSnapOutboundRequest: function() {
|
|
22
|
-
return assertSnapOutboundRequest;
|
|
23
|
-
},
|
|
24
|
-
assertEthereumOutboundRequest: function() {
|
|
25
|
-
return assertEthereumOutboundRequest;
|
|
26
|
-
},
|
|
27
|
-
sanitizeRequestArguments: function() {
|
|
28
|
-
return sanitizeRequestArguments;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const _rpcerrors = require("@metamask/rpc-errors");
|
|
32
|
-
const _utils = require("@metamask/utils");
|
|
33
|
-
const _logging = require("../logging");
|
|
34
|
-
async function withTeardown(originalPromise, teardownRef) {
|
|
35
|
-
const myTeardown = teardownRef.lastTeardown;
|
|
36
|
-
return new Promise((resolve, reject)=>{
|
|
37
|
-
originalPromise.then((value)=>{
|
|
38
|
-
if (teardownRef.lastTeardown === myTeardown) {
|
|
39
|
-
resolve(value);
|
|
40
|
-
} else {
|
|
41
|
-
(0, _logging.log)('Late promise received after Snap finished execution. Promise will be dropped.');
|
|
42
|
-
}
|
|
43
|
-
}).catch((reason)=>{
|
|
44
|
-
if (teardownRef.lastTeardown === myTeardown) {
|
|
45
|
-
reject(reason);
|
|
46
|
-
} else {
|
|
47
|
-
(0, _logging.log)('Late promise received after Snap finished execution. Promise will be dropped.');
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function proxyStreamProvider(provider, request) {
|
|
53
|
-
// Proxy target is intentionally set to be an empty object, to ensure
|
|
54
|
-
// that access to the prototype chain is not possible.
|
|
55
|
-
const proxy = new Proxy({}, {
|
|
56
|
-
has (_target, prop) {
|
|
57
|
-
return typeof prop === 'string' && [
|
|
58
|
-
'request',
|
|
59
|
-
'on',
|
|
60
|
-
'removeListener'
|
|
61
|
-
].includes(prop);
|
|
62
|
-
},
|
|
63
|
-
get (_target, prop) {
|
|
64
|
-
if (prop === 'request') {
|
|
65
|
-
return request;
|
|
66
|
-
} else if ([
|
|
67
|
-
'on',
|
|
68
|
-
'removeListener'
|
|
69
|
-
].includes(prop)) {
|
|
70
|
-
return provider[prop];
|
|
71
|
-
}
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
return proxy;
|
|
76
|
-
}
|
|
77
|
-
const BLOCKED_RPC_METHODS = Object.freeze([
|
|
78
|
-
'wallet_requestSnaps',
|
|
79
|
-
'wallet_requestPermissions',
|
|
80
|
-
'wallet_revokePermissions',
|
|
81
|
-
// We disallow all of these confirmations for now, since the screens are not ready for Snaps.
|
|
82
|
-
'eth_sendRawTransaction',
|
|
83
|
-
'eth_sendTransaction',
|
|
84
|
-
'eth_sign',
|
|
85
|
-
'eth_signTypedData',
|
|
86
|
-
'eth_signTypedData_v1',
|
|
87
|
-
'eth_signTypedData_v3',
|
|
88
|
-
'eth_signTypedData_v4',
|
|
89
|
-
'eth_decrypt',
|
|
90
|
-
'eth_getEncryptionPublicKey',
|
|
91
|
-
'wallet_addEthereumChain',
|
|
92
|
-
'wallet_switchEthereumChain',
|
|
93
|
-
'wallet_watchAsset',
|
|
94
|
-
'wallet_registerOnboarding',
|
|
95
|
-
'wallet_scanQRCode'
|
|
96
|
-
]);
|
|
97
|
-
function assertSnapOutboundRequest(args) {
|
|
98
|
-
// Disallow any non `wallet_` or `snap_` methods for separation of concerns.
|
|
99
|
-
(0, _utils.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.rpcErrors.methodNotSupported);
|
|
100
|
-
(0, _utils.assert)(!BLOCKED_RPC_METHODS.includes(args.method), _rpcerrors.rpcErrors.methodNotFound({
|
|
101
|
-
data: {
|
|
102
|
-
method: args.method
|
|
103
|
-
}
|
|
104
|
-
}));
|
|
105
|
-
(0, _utils.assertStruct)(args, _utils.JsonStruct, 'Provided value is not JSON-RPC compatible', _rpcerrors.rpcErrors.invalidParams);
|
|
106
|
-
}
|
|
107
|
-
function assertEthereumOutboundRequest(args) {
|
|
108
|
-
// Disallow snaps methods for separation of concerns.
|
|
109
|
-
(0, _utils.assert)(!String.prototype.startsWith.call(args.method, 'snap_'), _rpcerrors.rpcErrors.methodNotFound({
|
|
110
|
-
data: {
|
|
111
|
-
method: args.method
|
|
112
|
-
}
|
|
113
|
-
}));
|
|
114
|
-
(0, _utils.assert)(!BLOCKED_RPC_METHODS.includes(args.method), _rpcerrors.rpcErrors.methodNotFound({
|
|
115
|
-
data: {
|
|
116
|
-
method: args.method
|
|
117
|
-
}
|
|
118
|
-
}));
|
|
119
|
-
(0, _utils.assertStruct)(args, _utils.JsonStruct, 'Provided value is not JSON-RPC compatible', _rpcerrors.rpcErrors.invalidParams);
|
|
120
|
-
}
|
|
121
|
-
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 (0, _utils.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":["withTeardown","proxyStreamProvider","BLOCKED_RPC_METHODS","assertSnapOutboundRequest","assertEthereumOutboundRequest","sanitizeRequestArguments","originalPromise","teardownRef","myTeardown","lastTeardown","Promise","resolve","reject","then","value","log","catch","reason","provider","request","proxy","Proxy","has","_target","prop","includes","get","undefined","Object","freeze","args","assert","String","prototype","startsWith","call","method","rpcErrors","methodNotSupported","methodNotFound","data","assertStruct","JsonStruct","invalidParams","json","JSON","parse","stringify","getSafeJson"],"mappings":";;;;;;;;;;;IAgBsBA,YAAY;eAAZA;;IAoCNC,mBAAmB;eAAnBA;;IA+BHC,mBAAmB;eAAnBA;;IA0BGC,yBAAyB;eAAzBA;;IA6BAC,6BAA6B;eAA7BA;;IAgCAC,wBAAwB;eAAxBA;;;2BAxKU;uBACoC;yBAE1C;AAWb,eAAeL,aACpBM,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;gBACLC,IAAAA,YAAG,EACD;YAEJ;QACF,GACCC,KAAK,CAAC,CAACC;YACN,IAAIV,YAAYE,YAAY,KAAKD,YAAY;gBAC3CI,OAAOK;YACT,OAAO;gBACLF,IAAAA,YAAG,EACD;YAEJ;QACF;IACJ;AACF;AAUO,SAASd,oBACdiB,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;AAGO,MAAMlB,sBAAsB0B,OAAOC,MAAM,CAAC;IAC/C;IACA;IACA;IACA,6FAA6F;IAC7F;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAOM,SAAS1B,0BAA0B2B,IAAsB;IAC9D,4EAA4E;IAC5EC,IAAAA,aAAM,EACJC,OAAOC,SAAS,CAACC,UAAU,CAACC,IAAI,CAACL,KAAKM,MAAM,EAAE,cAC5CJ,OAAOC,SAAS,CAACC,UAAU,CAACC,IAAI,CAACL,KAAKM,MAAM,EAAE,UAChD,sFACAC,oBAAS,CAACC,kBAAkB;IAE9BP,IAAAA,aAAM,EACJ,CAAC7B,oBAAoBuB,QAAQ,CAACK,KAAKM,MAAM,GACzCC,oBAAS,CAACE,cAAc,CAAC;QACvBC,MAAM;YACJJ,QAAQN,KAAKM,MAAM;QACrB;IACF;IAEFK,IAAAA,mBAAY,EACVX,MACAY,iBAAU,EACV,6CACAL,oBAAS,CAACM,aAAa;AAE3B;AAOO,SAASvC,8BAA8B0B,IAAsB;IAClE,qDAAqD;IACrDC,IAAAA,aAAM,EACJ,CAACC,OAAOC,SAAS,CAACC,UAAU,CAACC,IAAI,CAACL,KAAKM,MAAM,EAAE,UAC/CC,oBAAS,CAACE,cAAc,CAAC;QACvBC,MAAM;YACJJ,QAAQN,KAAKM,MAAM;QACrB;IACF;IAEFL,IAAAA,aAAM,EACJ,CAAC7B,oBAAoBuB,QAAQ,CAACK,KAAKM,MAAM,GACzCC,oBAAS,CAACE,cAAc,CAAC;QACvBC,MAAM;YACJJ,QAAQN,KAAKM,MAAM;QACrB;IACF;IAEFK,IAAAA,mBAAY,EACVX,MACAY,iBAAU,EACV,6CACAL,oBAAS,CAACM,aAAa;AAE3B;AAQO,SAAStC,yBAAyBS,KAAc;IACrD,6EAA6E;IAC7E,8EAA8E;IAC9E,MAAM8B,OAAOC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACjC;IACvC,OAAOkC,IAAAA,kBAAW,EAACJ;AACrB"}
|