@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,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "createEndowments", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return createEndowments;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _rpcerrors = require("@metamask/rpc-errors");
|
|
12
|
-
const _snapsutils = require("@metamask/snaps-utils");
|
|
13
|
-
const _utils = require("@metamask/utils");
|
|
14
|
-
const _globalObject = require("../globalObject");
|
|
15
|
-
const _commonEndowmentFactory = /*#__PURE__*/ _interop_require_default(require("./commonEndowmentFactory"));
|
|
16
|
-
function _interop_require_default(obj) {
|
|
17
|
-
return obj && obj.__esModule ? obj : {
|
|
18
|
-
default: obj
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Retrieve consolidated endowment factories for common endowments.
|
|
23
|
-
*/ const registeredEndowments = (0, _commonEndowmentFactory.default)();
|
|
24
|
-
/**
|
|
25
|
-
* A map of endowment names to their factory functions. Some endowments share
|
|
26
|
-
* the same factory function, but we only call each factory once for each snap.
|
|
27
|
-
* See {@link createEndowments} for details.
|
|
28
|
-
*/ const endowmentFactories = registeredEndowments.reduce((factories, builder)=>{
|
|
29
|
-
builder.names.forEach((name)=>{
|
|
30
|
-
factories.set(name, builder.factory);
|
|
31
|
-
});
|
|
32
|
-
return factories;
|
|
33
|
-
}, new Map());
|
|
34
|
-
function createEndowments({ snap, ethereum, snapId, endowments, notify }) {
|
|
35
|
-
const attenuatedEndowments = {};
|
|
36
|
-
// TODO: All endowments should be hardened to prevent covert communication
|
|
37
|
-
// channels. Hardening the returned objects breaks tests elsewhere in the
|
|
38
|
-
// monorepo, so further research is needed.
|
|
39
|
-
const result = endowments.reduce(({ allEndowments, teardowns }, endowmentName)=>{
|
|
40
|
-
// First, check if the endowment has a factory, and default to that.
|
|
41
|
-
if (endowmentFactories.has(endowmentName)) {
|
|
42
|
-
if (!(0, _utils.hasProperty)(attenuatedEndowments, endowmentName)) {
|
|
43
|
-
// Call the endowment factory for the current endowment. If the factory
|
|
44
|
-
// creates multiple endowments, they will all be assigned to the
|
|
45
|
-
// `attenuatedEndowments` object, but will only be passed on to the snap
|
|
46
|
-
// if explicitly listed among its endowment.
|
|
47
|
-
// This may not have an actual use case, but, safety first.
|
|
48
|
-
// We just confirmed that endowmentFactories has the specified key.
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
50
|
-
const { teardownFunction, ...endowment } = endowmentFactories.get(endowmentName)({
|
|
51
|
-
snapId,
|
|
52
|
-
notify
|
|
53
|
-
});
|
|
54
|
-
Object.assign(attenuatedEndowments, endowment);
|
|
55
|
-
if (teardownFunction) {
|
|
56
|
-
teardowns.push(teardownFunction);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
allEndowments[endowmentName] = attenuatedEndowments[endowmentName];
|
|
60
|
-
} else if (endowmentName === 'ethereum') {
|
|
61
|
-
// Special case for adding the EIP-1193 provider.
|
|
62
|
-
allEndowments[endowmentName] = ethereum;
|
|
63
|
-
} else if (endowmentName in _globalObject.rootRealmGlobal) {
|
|
64
|
-
(0, _snapsutils.logWarning)(`Access to unhardened global ${endowmentName}.`);
|
|
65
|
-
// If the endowment doesn't have a factory, just use whatever is on the
|
|
66
|
-
// global object.
|
|
67
|
-
const globalValue = _globalObject.rootRealmGlobal[endowmentName];
|
|
68
|
-
allEndowments[endowmentName] = globalValue;
|
|
69
|
-
} else {
|
|
70
|
-
// If we get to this point, we've been passed an endowment that doesn't
|
|
71
|
-
// exist in our current environment.
|
|
72
|
-
throw _rpcerrors.rpcErrors.internal(`Unknown endowment: "${endowmentName}".`);
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
allEndowments,
|
|
76
|
-
teardowns
|
|
77
|
-
};
|
|
78
|
-
}, {
|
|
79
|
-
allEndowments: {
|
|
80
|
-
snap
|
|
81
|
-
},
|
|
82
|
-
teardowns: []
|
|
83
|
-
});
|
|
84
|
-
const teardown = async ()=>{
|
|
85
|
-
await Promise.all(result.teardowns.map((teardownFunction)=>teardownFunction()));
|
|
86
|
-
};
|
|
87
|
-
return {
|
|
88
|
-
endowments: result.allEndowments,
|
|
89
|
-
teardown
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/common/endowments/index.ts"],"sourcesContent":["import type { StreamProvider } from '@metamask/providers';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { SnapsProvider } from '@metamask/snaps-sdk';\nimport { logWarning } from '@metamask/snaps-utils';\nimport { hasProperty } from '@metamask/utils';\n\nimport type { NotifyFunction } from '../BaseSnapExecutor';\nimport { rootRealmGlobal } from '../globalObject';\nimport type { EndowmentFactoryOptions } from './commonEndowmentFactory';\nimport buildCommonEndowments from './commonEndowmentFactory';\n\ntype EndowmentFactoryResult = {\n /**\n * A function that performs any necessary teardown when the snap becomes idle.\n *\n * NOTE:** The endowments are not reconstructed if the snap is re-invoked\n * before being terminated, so the teardown operation must not render the\n * endowments unusable; it should simply restore the endowments to their\n * original state.\n */\n teardownFunction?: () => Promise<void> | void;\n [key: string]: unknown;\n};\n\n/**\n * Retrieve consolidated endowment factories for common endowments.\n */\nconst registeredEndowments = buildCommonEndowments();\n\n/**\n * A map of endowment names to their factory functions. Some endowments share\n * the same factory function, but we only call each factory once for each snap.\n * See {@link createEndowments} for details.\n */\nconst endowmentFactories = registeredEndowments.reduce((factories, builder) => {\n builder.names.forEach((name) => {\n factories.set(name, builder.factory);\n });\n return factories;\n}, new Map<string, (options?: EndowmentFactoryOptions) => EndowmentFactoryResult>());\n\n/**\n * Gets the endowments for a particular Snap. Some endowments, like `setTimeout`\n * and `clearTimeout`, must be attenuated so that they can only affect behavior\n * within the Snap's own realm. Therefore, we use factory functions to create\n * such attenuated / modified endowments. Otherwise, the value that's on the\n * root realm global will be used.\n *\n * @param options - An options bag.\n * @param options.snap - The Snaps global API object.\n * @param options.ethereum - The Snap's EIP-1193 provider object.\n * @param options.snapId - The id of the snap that will use the created endowments.\n * @param options.endowments - The list of endowments to provide to the snap.\n * @param options.notify - A reference to the notify function of the snap executor.\n * @returns An object containing the Snap's endowments.\n */\nexport function createEndowments({\n snap,\n ethereum,\n snapId,\n endowments,\n notify,\n}: {\n snap: SnapsProvider;\n ethereum: StreamProvider;\n snapId: string;\n endowments: string[];\n notify: NotifyFunction;\n}): { endowments: Record<string, unknown>; teardown: () => Promise<void> } {\n const attenuatedEndowments: Record<string, unknown> = {};\n\n // TODO: All endowments should be hardened to prevent covert communication\n // channels. Hardening the returned objects breaks tests elsewhere in the\n // monorepo, so further research is needed.\n const result = endowments.reduce<{\n allEndowments: Record<string, unknown>;\n teardowns: (() => Promise<void> | void)[];\n }>(\n ({ allEndowments, teardowns }, endowmentName) => {\n // First, check if the endowment has a factory, and default to that.\n if (endowmentFactories.has(endowmentName)) {\n if (!hasProperty(attenuatedEndowments, endowmentName)) {\n // Call the endowment factory for the current endowment. If the factory\n // creates multiple endowments, they will all be assigned to the\n // `attenuatedEndowments` object, but will only be passed on to the snap\n // if explicitly listed among its endowment.\n // This may not have an actual use case, but, safety first.\n\n // We just confirmed that endowmentFactories has the specified key.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { teardownFunction, ...endowment } = endowmentFactories.get(\n endowmentName,\n )!({ snapId, notify });\n Object.assign(attenuatedEndowments, endowment);\n if (teardownFunction) {\n teardowns.push(teardownFunction);\n }\n }\n allEndowments[endowmentName] = attenuatedEndowments[endowmentName];\n } else if (endowmentName === 'ethereum') {\n // Special case for adding the EIP-1193 provider.\n allEndowments[endowmentName] = ethereum;\n } else if (endowmentName in rootRealmGlobal) {\n logWarning(`Access to unhardened global ${endowmentName}.`);\n // If the endowment doesn't have a factory, just use whatever is on the\n // global object.\n const globalValue = (rootRealmGlobal as Record<string, unknown>)[\n endowmentName\n ];\n allEndowments[endowmentName] = globalValue;\n } else {\n // If we get to this point, we've been passed an endowment that doesn't\n // exist in our current environment.\n throw rpcErrors.internal(`Unknown endowment: \"${endowmentName}\".`);\n }\n return { allEndowments, teardowns };\n },\n {\n allEndowments: { snap },\n teardowns: [],\n },\n );\n\n const teardown = async () => {\n await Promise.all(\n result.teardowns.map((teardownFunction) => teardownFunction()),\n );\n };\n return { endowments: result.allEndowments, teardown };\n}\n"],"names":["createEndowments","registeredEndowments","buildCommonEndowments","endowmentFactories","reduce","factories","builder","names","forEach","name","set","factory","Map","snap","ethereum","snapId","endowments","notify","attenuatedEndowments","result","allEndowments","teardowns","endowmentName","has","hasProperty","teardownFunction","endowment","get","Object","assign","push","rootRealmGlobal","logWarning","globalValue","rpcErrors","internal","teardown","Promise","all","map"],"mappings":";;;;+BAwDgBA;;;eAAAA;;;2BAvDU;4BAEC;uBACC;8BAGI;+EAEE;;;;;;AAelC;;C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AAACF,6BAAe,AAA4B,CAC9DT,cACD;YACDF,aAAa,CAACE,cAAc,GAAGW;QACjC,OAAO;YACL,uEAAuE;YACvE,oCAAoC;YACpC,MAAMC,oBAAS,CAACC,QAAQ,CAAC,CAAC,oBAAoB,EAAEb,cAAc,EAAE,CAAC;QACnE;QACA,OAAO;YAAEF;YAAeC;QAAU;IACpC,GACA;QACED,eAAe;YAAEP;QAAK;QACtBQ,WAAW,EAAE;IACf;IAGF,MAAMe,WAAW;QACf,MAAMC,QAAQC,GAAG,CACfnB,OAAOE,SAAS,CAACkB,GAAG,CAAC,CAACd,mBAAqBA;IAE/C;IACA,OAAO;QAAET,YAAYG,OAAOC,aAAa;QAAEgB;IAAS;AACtD"}
|
|
@@ -1,62 +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_INTERVAL = 10;
|
|
13
|
-
/**
|
|
14
|
-
* Creates a pair of `setInterval` and `clearInterval` functions attenuated such
|
|
15
|
-
* that:
|
|
16
|
-
* - `setInterval` throws if its "handler" parameter is not a function.
|
|
17
|
-
* - `clearInterval` only clears timeouts created by its sibling `setInterval`,
|
|
18
|
-
* or else no-ops.
|
|
19
|
-
*
|
|
20
|
-
* @returns An object with the attenuated `setInterval` and `clearInterval`
|
|
21
|
-
* functions.
|
|
22
|
-
*/ const createInterval = ()=>{
|
|
23
|
-
const registeredHandles = new Map();
|
|
24
|
-
const _setInterval = (handler, timeout)=>{
|
|
25
|
-
if (typeof handler !== 'function') {
|
|
26
|
-
throw _rpcerrors.rpcErrors.invalidInput(`The interval handler must be a function. Received: ${typeof handler}.`);
|
|
27
|
-
}
|
|
28
|
-
harden(handler);
|
|
29
|
-
const handle = Object.freeze(Object.create(null));
|
|
30
|
-
const platformHandle = setInterval(handler, Math.max(MINIMUM_INTERVAL, timeout ?? 0));
|
|
31
|
-
registeredHandles.set(handle, platformHandle);
|
|
32
|
-
return handle;
|
|
33
|
-
};
|
|
34
|
-
const _clearInterval = (handle)=>{
|
|
35
|
-
harden(handle);
|
|
36
|
-
const platformHandle = registeredHandles.get(handle);
|
|
37
|
-
if (platformHandle !== undefined) {
|
|
38
|
-
clearInterval(platformHandle);
|
|
39
|
-
registeredHandles.delete(handle);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const teardownFunction = ()=>{
|
|
43
|
-
for (const handle of registeredHandles.keys()){
|
|
44
|
-
_clearInterval(handle);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
return {
|
|
48
|
-
setInterval: harden(_setInterval),
|
|
49
|
-
clearInterval: harden(_clearInterval),
|
|
50
|
-
teardownFunction
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
const endowmentModule = {
|
|
54
|
-
names: [
|
|
55
|
-
'setInterval',
|
|
56
|
-
'clearInterval'
|
|
57
|
-
],
|
|
58
|
-
factory: createInterval
|
|
59
|
-
};
|
|
60
|
-
const _default = endowmentModule;
|
|
61
|
-
|
|
62
|
-
//# sourceMappingURL=interval.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/common/endowments/interval.ts"],"sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\n\nconst MINIMUM_INTERVAL = 10;\n\n/**\n * Creates a pair of `setInterval` and `clearInterval` functions attenuated such\n * that:\n * - `setInterval` throws if its \"handler\" parameter is not a function.\n * - `clearInterval` only clears timeouts created by its sibling `setInterval`,\n * or else no-ops.\n *\n * @returns An object with the attenuated `setInterval` and `clearInterval`\n * functions.\n */\nconst createInterval = () => {\n const registeredHandles = new Map<unknown, unknown>();\n\n const _setInterval = (handler: TimerHandler, timeout?: number): unknown => {\n if (typeof handler !== 'function') {\n throw rpcErrors.invalidInput(\n `The interval handler must be a function. Received: ${typeof handler}.`,\n );\n }\n harden(handler);\n const handle = Object.freeze(Object.create(null));\n const platformHandle = setInterval(\n handler,\n Math.max(MINIMUM_INTERVAL, timeout ?? 0),\n );\n registeredHandles.set(handle, platformHandle);\n return handle;\n };\n\n const _clearInterval = (handle: unknown): void => {\n harden(handle);\n const platformHandle = registeredHandles.get(handle);\n if (platformHandle !== undefined) {\n clearInterval(platformHandle as any);\n registeredHandles.delete(handle);\n }\n };\n\n const teardownFunction = (): void => {\n for (const handle of registeredHandles.keys()) {\n _clearInterval(handle);\n }\n };\n\n return {\n setInterval: harden(_setInterval),\n clearInterval: harden(_clearInterval),\n teardownFunction,\n } as const;\n};\n\nconst endowmentModule = {\n names: ['setInterval', 'clearInterval'] as const,\n factory: createInterval,\n};\nexport default endowmentModule;\n"],"names":["MINIMUM_INTERVAL","createInterval","registeredHandles","Map","_setInterval","handler","timeout","rpcErrors","invalidInput","harden","handle","Object","freeze","create","platformHandle","setInterval","Math","max","set","_clearInterval","get","undefined","clearInterval","delete","teardownFunction","keys","endowmentModule","names","factory"],"mappings":";;;;+BA2DA;;;eAAA;;;2BA3D0B;AAE1B,MAAMA,mBAAmB;AAEzB;;;;;;;;;CASC,GACD,MAAMC,iBAAiB;IACrB,MAAMC,oBAAoB,IAAIC;IAE9B,MAAMC,eAAe,CAACC,SAAuBC;QAC3C,IAAI,OAAOD,YAAY,YAAY;YACjC,MAAME,oBAAS,CAACC,YAAY,CAC1B,CAAC,mDAAmD,EAAE,OAAOH,QAAQ,CAAC,CAAC;QAE3E;QACAI,OAAOJ;QACP,MAAMK,SAASC,OAAOC,MAAM,CAACD,OAAOE,MAAM,CAAC;QAC3C,MAAMC,iBAAiBC,YACrBV,SACAW,KAAKC,GAAG,CAACjB,kBAAkBM,WAAW;QAExCJ,kBAAkBgB,GAAG,CAACR,QAAQI;QAC9B,OAAOJ;IACT;IAEA,MAAMS,iBAAiB,CAACT;QACtBD,OAAOC;QACP,MAAMI,iBAAiBZ,kBAAkBkB,GAAG,CAACV;QAC7C,IAAII,mBAAmBO,WAAW;YAChCC,cAAcR;YACdZ,kBAAkBqB,MAAM,CAACb;QAC3B;IACF;IAEA,MAAMc,mBAAmB;QACvB,KAAK,MAAMd,UAAUR,kBAAkBuB,IAAI,GAAI;YAC7CN,eAAeT;QACjB;IACF;IAEA,OAAO;QACLK,aAAaN,OAAOL;QACpBkB,eAAeb,OAAOU;QACtBK;IACF;AACF;AAEA,MAAME,kBAAkB;IACtBC,OAAO;QAAC;QAAe;KAAgB;IACvCC,SAAS3B;AACX;MACA,WAAeyB"}
|
|
@@ -1,67 +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 _globalObject = require("../globalObject");
|
|
12
|
-
const _crypto = require("./crypto");
|
|
13
|
-
/**
|
|
14
|
-
* Create a {@link Math} object, with the same properties as the global
|
|
15
|
-
* {@link Math} object, but with the {@link Math.random} method replaced.
|
|
16
|
-
*
|
|
17
|
-
* @returns The {@link Math} object with the {@link Math.random} method
|
|
18
|
-
* replaced.
|
|
19
|
-
*/ function createMath() {
|
|
20
|
-
// `Math` does not work with `Object.keys`, `Object.entries`, etc., so we
|
|
21
|
-
// need to create a new object with the same properties.
|
|
22
|
-
const keys = Object.getOwnPropertyNames(_globalObject.rootRealmGlobal.Math);
|
|
23
|
-
const math = keys.reduce((target, key)=>{
|
|
24
|
-
if (key === 'random') {
|
|
25
|
-
return target;
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
...target,
|
|
29
|
-
[key]: _globalObject.rootRealmGlobal.Math[key]
|
|
30
|
-
};
|
|
31
|
-
}, {});
|
|
32
|
-
// Since the math endowment requires crypto, we can leverage the crypto endowment factory to get a hardened and platform agnostic instance of webcrypto
|
|
33
|
-
const { crypto: hardenedCrypto } = (0, _crypto.createCrypto)();
|
|
34
|
-
return harden({
|
|
35
|
-
Math: {
|
|
36
|
-
...math,
|
|
37
|
-
random: ()=>{
|
|
38
|
-
// NOTE: This is not intended to be a secure replacement for the weak
|
|
39
|
-
// random number generator used by `Math.random`. It is only intended to
|
|
40
|
-
// prevent side channel attacks of `Math.random` by replacing it with an
|
|
41
|
-
// alternative implementation that is not vulnerable to the same
|
|
42
|
-
// attacks.
|
|
43
|
-
//
|
|
44
|
-
// This does not mean that this implementation is secure. It is not
|
|
45
|
-
// intended to be used in a security context, and this implementation
|
|
46
|
-
// may change at any time.
|
|
47
|
-
//
|
|
48
|
-
// To securely generate random numbers, use a cryptographically secure
|
|
49
|
-
// random number generator, such as the one provided by the Web Crypto
|
|
50
|
-
// API:
|
|
51
|
-
//
|
|
52
|
-
// - https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey
|
|
53
|
-
// - https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
|
|
54
|
-
return hardenedCrypto.getRandomValues(new Uint32Array(1))[0] / 2 ** 32;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
const endowmentModule = {
|
|
60
|
-
names: [
|
|
61
|
-
'Math'
|
|
62
|
-
],
|
|
63
|
-
factory: createMath
|
|
64
|
-
};
|
|
65
|
-
const _default = endowmentModule;
|
|
66
|
-
|
|
67
|
-
//# sourceMappingURL=math.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/common/endowments/math.ts"],"sourcesContent":["import { rootRealmGlobal } from '../globalObject';\nimport { createCrypto } from './crypto';\n\n/**\n * Create a {@link Math} object, with the same properties as the global\n * {@link Math} object, but with the {@link Math.random} method replaced.\n *\n * @returns The {@link Math} object with the {@link Math.random} method\n * replaced.\n */\nfunction createMath() {\n // `Math` does not work with `Object.keys`, `Object.entries`, etc., so we\n // need to create a new object with the same properties.\n const keys = Object.getOwnPropertyNames(\n rootRealmGlobal.Math,\n ) as (keyof typeof Math)[];\n\n const math = keys.reduce<Partial<Math>>((target, key) => {\n if (key === 'random') {\n return target;\n }\n\n return { ...target, [key]: rootRealmGlobal.Math[key] };\n }, {});\n\n // Since the math endowment requires crypto, we can leverage the crypto endowment factory to get a hardened and platform agnostic instance of webcrypto\n const { crypto: hardenedCrypto } = createCrypto();\n\n return harden({\n Math: {\n ...math,\n random: () => {\n // NOTE: This is not intended to be a secure replacement for the weak\n // random number generator used by `Math.random`. It is only intended to\n // prevent side channel attacks of `Math.random` by replacing it with an\n // alternative implementation that is not vulnerable to the same\n // attacks.\n //\n // This does not mean that this implementation is secure. It is not\n // intended to be used in a security context, and this implementation\n // may change at any time.\n //\n // To securely generate random numbers, use a cryptographically secure\n // random number generator, such as the one provided by the Web Crypto\n // API:\n //\n // - https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey\n // - https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues\n return hardenedCrypto.getRandomValues(new Uint32Array(1))[0] / 2 ** 32;\n },\n },\n });\n}\n\nconst endowmentModule = {\n names: ['Math'] as const,\n factory: createMath,\n};\n\nexport default endowmentModule;\n"],"names":["createMath","keys","Object","getOwnPropertyNames","rootRealmGlobal","Math","math","reduce","target","key","crypto","hardenedCrypto","createCrypto","harden","random","getRandomValues","Uint32Array","endowmentModule","names","factory"],"mappings":";;;;+BA2DA;;;eAAA;;;8BA3DgC;wBACH;AAE7B;;;;;;CAMC,GACD,SAASA;IACP,yEAAyE;IACzE,wDAAwD;IACxD,MAAMC,OAAOC,OAAOC,mBAAmB,CACrCC,6BAAe,CAACC,IAAI;IAGtB,MAAMC,OAAOL,KAAKM,MAAM,CAAgB,CAACC,QAAQC;QAC/C,IAAIA,QAAQ,UAAU;YACpB,OAAOD;QACT;QAEA,OAAO;YAAE,GAAGA,MAAM;YAAE,CAACC,IAAI,EAAEL,6BAAe,CAACC,IAAI,CAACI,IAAI;QAAC;IACvD,GAAG,CAAC;IAEJ,uJAAuJ;IACvJ,MAAM,EAAEC,QAAQC,cAAc,EAAE,GAAGC,IAAAA,oBAAY;IAE/C,OAAOC,OAAO;QACZR,MAAM;YACJ,GAAGC,IAAI;YACPQ,QAAQ;gBACN,qEAAqE;gBACrE,wEAAwE;gBACxE,wEAAwE;gBACxE,gEAAgE;gBAChE,WAAW;gBACX,EAAE;gBACF,mEAAmE;gBACnE,qEAAqE;gBACrE,0BAA0B;gBAC1B,EAAE;gBACF,sEAAsE;gBACtE,sEAAsE;gBACtE,OAAO;gBACP,EAAE;gBACF,8EAA8E;gBAC9E,4EAA4E;gBAC5E,OAAOH,eAAeI,eAAe,CAAC,IAAIC,YAAY,GAAG,CAAC,EAAE,GAAG,KAAK;YACtE;QACF;IACF;AACF;AAEA,MAAMC,kBAAkB;IACtBC,OAAO;QAAC;KAAO;IACfC,SAASnB;AACX;MAEA,WAAeiB"}
|
|
@@ -1,303 +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 _utils = require("@metamask/utils");
|
|
12
|
-
const _utils1 = require("../utils");
|
|
13
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
14
|
-
if (privateCollection.has(obj)) {
|
|
15
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
19
|
-
if (descriptor.get) {
|
|
20
|
-
return descriptor.get.call(receiver);
|
|
21
|
-
}
|
|
22
|
-
return descriptor.value;
|
|
23
|
-
}
|
|
24
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
25
|
-
if (descriptor.set) {
|
|
26
|
-
descriptor.set.call(receiver, value);
|
|
27
|
-
} else {
|
|
28
|
-
if (!descriptor.writable) {
|
|
29
|
-
throw new TypeError("attempted to set read only private field");
|
|
30
|
-
}
|
|
31
|
-
descriptor.value = value;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
35
|
-
if (!privateMap.has(receiver)) {
|
|
36
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
37
|
-
}
|
|
38
|
-
return privateMap.get(receiver);
|
|
39
|
-
}
|
|
40
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
41
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
42
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
43
|
-
}
|
|
44
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
45
|
-
_check_private_redeclaration(obj, privateMap);
|
|
46
|
-
privateMap.set(obj, value);
|
|
47
|
-
}
|
|
48
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
49
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
50
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
var _teardownRef = /*#__PURE__*/ new WeakMap(), _ogResponse = /*#__PURE__*/ new WeakMap(), _onStart = /*#__PURE__*/ new WeakMap(), _onFinish = /*#__PURE__*/ new WeakMap();
|
|
54
|
-
/**
|
|
55
|
-
* This class wraps a Response object.
|
|
56
|
-
* That way, a teardown process can stop any processes left.
|
|
57
|
-
*/ class ResponseWrapper {
|
|
58
|
-
get body() {
|
|
59
|
-
return _class_private_field_get(this, _ogResponse).body;
|
|
60
|
-
}
|
|
61
|
-
get bodyUsed() {
|
|
62
|
-
return _class_private_field_get(this, _ogResponse).bodyUsed;
|
|
63
|
-
}
|
|
64
|
-
get headers() {
|
|
65
|
-
return _class_private_field_get(this, _ogResponse).headers;
|
|
66
|
-
}
|
|
67
|
-
get ok() {
|
|
68
|
-
return _class_private_field_get(this, _ogResponse).ok;
|
|
69
|
-
}
|
|
70
|
-
get redirected() {
|
|
71
|
-
return _class_private_field_get(this, _ogResponse).redirected;
|
|
72
|
-
}
|
|
73
|
-
get status() {
|
|
74
|
-
return _class_private_field_get(this, _ogResponse).status;
|
|
75
|
-
}
|
|
76
|
-
get statusText() {
|
|
77
|
-
return _class_private_field_get(this, _ogResponse).statusText;
|
|
78
|
-
}
|
|
79
|
-
get type() {
|
|
80
|
-
return _class_private_field_get(this, _ogResponse).type;
|
|
81
|
-
}
|
|
82
|
-
get url() {
|
|
83
|
-
return _class_private_field_get(this, _ogResponse).url;
|
|
84
|
-
}
|
|
85
|
-
async text() {
|
|
86
|
-
return await (0, _utils1.withTeardown)((async ()=>{
|
|
87
|
-
await _class_private_field_get(this, _onStart).call(this);
|
|
88
|
-
try {
|
|
89
|
-
return await _class_private_field_get(this, _ogResponse).text();
|
|
90
|
-
} finally{
|
|
91
|
-
await _class_private_field_get(this, _onFinish).call(this);
|
|
92
|
-
}
|
|
93
|
-
})(), _class_private_field_get(this, _teardownRef));
|
|
94
|
-
}
|
|
95
|
-
async arrayBuffer() {
|
|
96
|
-
return await (0, _utils1.withTeardown)((async ()=>{
|
|
97
|
-
await _class_private_field_get(this, _onStart).call(this);
|
|
98
|
-
try {
|
|
99
|
-
return await _class_private_field_get(this, _ogResponse).arrayBuffer();
|
|
100
|
-
} finally{
|
|
101
|
-
await _class_private_field_get(this, _onFinish).call(this);
|
|
102
|
-
}
|
|
103
|
-
})(), _class_private_field_get(this, _teardownRef));
|
|
104
|
-
}
|
|
105
|
-
async blob() {
|
|
106
|
-
return await (0, _utils1.withTeardown)((async ()=>{
|
|
107
|
-
await _class_private_field_get(this, _onStart).call(this);
|
|
108
|
-
try {
|
|
109
|
-
return await _class_private_field_get(this, _ogResponse).blob();
|
|
110
|
-
} finally{
|
|
111
|
-
await _class_private_field_get(this, _onFinish).call(this);
|
|
112
|
-
}
|
|
113
|
-
})(), _class_private_field_get(this, _teardownRef));
|
|
114
|
-
}
|
|
115
|
-
clone() {
|
|
116
|
-
const newResponse = _class_private_field_get(this, _ogResponse).clone();
|
|
117
|
-
return new ResponseWrapper(newResponse, _class_private_field_get(this, _teardownRef), _class_private_field_get(this, _onStart), _class_private_field_get(this, _onFinish));
|
|
118
|
-
}
|
|
119
|
-
async formData() {
|
|
120
|
-
return await (0, _utils1.withTeardown)((async ()=>{
|
|
121
|
-
await _class_private_field_get(this, _onStart).call(this);
|
|
122
|
-
try {
|
|
123
|
-
return await _class_private_field_get(this, _ogResponse).formData();
|
|
124
|
-
} finally{
|
|
125
|
-
await _class_private_field_get(this, _onFinish).call(this);
|
|
126
|
-
}
|
|
127
|
-
})(), _class_private_field_get(this, _teardownRef));
|
|
128
|
-
}
|
|
129
|
-
async json() {
|
|
130
|
-
return await (0, _utils1.withTeardown)((async ()=>{
|
|
131
|
-
await _class_private_field_get(this, _onStart).call(this);
|
|
132
|
-
try {
|
|
133
|
-
return await _class_private_field_get(this, _ogResponse).json();
|
|
134
|
-
} finally{
|
|
135
|
-
await _class_private_field_get(this, _onFinish).call(this);
|
|
136
|
-
}
|
|
137
|
-
})(), _class_private_field_get(this, _teardownRef));
|
|
138
|
-
}
|
|
139
|
-
constructor(ogResponse, teardownRef, onStart, onFinish){
|
|
140
|
-
_class_private_field_init(this, _teardownRef, {
|
|
141
|
-
writable: true,
|
|
142
|
-
value: void 0
|
|
143
|
-
});
|
|
144
|
-
_class_private_field_init(this, _ogResponse, {
|
|
145
|
-
writable: true,
|
|
146
|
-
value: void 0
|
|
147
|
-
});
|
|
148
|
-
_class_private_field_init(this, _onStart, {
|
|
149
|
-
writable: true,
|
|
150
|
-
value: void 0
|
|
151
|
-
});
|
|
152
|
-
_class_private_field_init(this, _onFinish, {
|
|
153
|
-
writable: true,
|
|
154
|
-
value: void 0
|
|
155
|
-
});
|
|
156
|
-
_class_private_field_set(this, _ogResponse, ogResponse);
|
|
157
|
-
_class_private_field_set(this, _teardownRef, teardownRef);
|
|
158
|
-
_class_private_field_set(this, _onStart, onStart);
|
|
159
|
-
_class_private_field_set(this, _onFinish, onFinish);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Create a network endowment, consisting of a `fetch` function.
|
|
164
|
-
* This allows us to provide a teardown function, so that we can cancel
|
|
165
|
-
* any pending requests, connections, streams, etc. that may be open when a snap
|
|
166
|
-
* is terminated.
|
|
167
|
-
*
|
|
168
|
-
* This wraps the original implementation of `fetch`,
|
|
169
|
-
* to ensure that a bad actor cannot get access to the original function, thus
|
|
170
|
-
* potentially preventing the network requests from being torn down.
|
|
171
|
-
*
|
|
172
|
-
* @param options - An options bag.
|
|
173
|
-
* @param options.notify - A reference to the notify function of the snap executor.
|
|
174
|
-
* @returns An object containing a wrapped `fetch`
|
|
175
|
-
* function, as well as a teardown function.
|
|
176
|
-
*/ const createNetwork = ({ notify } = {})=>{
|
|
177
|
-
(0, _utils.assert)(notify, 'Notify must be passed to network endowment factory');
|
|
178
|
-
// Open fetch calls or open body streams
|
|
179
|
-
const openConnections = new Set();
|
|
180
|
-
// Track last teardown count
|
|
181
|
-
const teardownRef = {
|
|
182
|
-
lastTeardown: 0
|
|
183
|
-
};
|
|
184
|
-
// Remove items from openConnections after they were garbage collected
|
|
185
|
-
const cleanup = new FinalizationRegistry(/* istanbul ignore next: can't test garbage collection without modifying node parameters */ (callback)=>callback());
|
|
186
|
-
const _fetch = async (input, init)=>{
|
|
187
|
-
const abortController = new AbortController();
|
|
188
|
-
if (init?.signal !== null && init?.signal !== undefined) {
|
|
189
|
-
const originalSignal = init.signal;
|
|
190
|
-
// Merge abort controllers
|
|
191
|
-
originalSignal.addEventListener('abort', ()=>{
|
|
192
|
-
abortController.abort(originalSignal.reason);
|
|
193
|
-
}, {
|
|
194
|
-
once: true
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
let started = false;
|
|
198
|
-
const onStart = async ()=>{
|
|
199
|
-
if (!started) {
|
|
200
|
-
started = true;
|
|
201
|
-
await notify({
|
|
202
|
-
method: 'OutboundRequest',
|
|
203
|
-
params: {
|
|
204
|
-
source: 'fetch'
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
let finished = false;
|
|
210
|
-
const onFinish = async ()=>{
|
|
211
|
-
if (!finished) {
|
|
212
|
-
finished = true;
|
|
213
|
-
await notify({
|
|
214
|
-
method: 'OutboundResponse',
|
|
215
|
-
params: {
|
|
216
|
-
source: 'fetch'
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
let res;
|
|
222
|
-
let openFetchConnection;
|
|
223
|
-
return await (0, _utils1.withTeardown)((async ()=>{
|
|
224
|
-
try {
|
|
225
|
-
await notify({
|
|
226
|
-
method: 'OutboundRequest',
|
|
227
|
-
params: {
|
|
228
|
-
source: 'fetch'
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
const fetchPromise = fetch(input, {
|
|
232
|
-
...init,
|
|
233
|
-
signal: abortController.signal
|
|
234
|
-
});
|
|
235
|
-
openFetchConnection = {
|
|
236
|
-
cancel: async ()=>{
|
|
237
|
-
abortController.abort();
|
|
238
|
-
try {
|
|
239
|
-
await fetchPromise;
|
|
240
|
-
} catch {
|
|
241
|
-
/* do nothing */ }
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
openConnections.add(openFetchConnection);
|
|
245
|
-
res = new ResponseWrapper(await fetchPromise, teardownRef, onStart, onFinish);
|
|
246
|
-
} finally{
|
|
247
|
-
if (openFetchConnection !== undefined) {
|
|
248
|
-
openConnections.delete(openFetchConnection);
|
|
249
|
-
}
|
|
250
|
-
await notify({
|
|
251
|
-
method: 'OutboundResponse',
|
|
252
|
-
params: {
|
|
253
|
-
source: 'fetch'
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
if (res.body !== null) {
|
|
258
|
-
const body = new WeakRef(res.body);
|
|
259
|
-
const openBodyConnection = {
|
|
260
|
-
cancel: /* istanbul ignore next: see it.todo('can be torn down during body read') test */ async ()=>{
|
|
261
|
-
try {
|
|
262
|
-
await body.deref()?.cancel();
|
|
263
|
-
} catch {
|
|
264
|
-
/* do nothing */ }
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
openConnections.add(openBodyConnection);
|
|
268
|
-
cleanup.register(res.body, /* istanbul ignore next: can't test garbage collection without modifying node parameters */ ()=>openConnections.delete(openBodyConnection));
|
|
269
|
-
}
|
|
270
|
-
return harden(res);
|
|
271
|
-
})(), teardownRef);
|
|
272
|
-
};
|
|
273
|
-
const teardownFunction = async ()=>{
|
|
274
|
-
teardownRef.lastTeardown += 1;
|
|
275
|
-
const promises = [];
|
|
276
|
-
openConnections.forEach(({ cancel })=>promises.push(cancel()));
|
|
277
|
-
openConnections.clear();
|
|
278
|
-
await Promise.all(promises);
|
|
279
|
-
};
|
|
280
|
-
return {
|
|
281
|
-
fetch: harden(_fetch),
|
|
282
|
-
// Request, Headers and Response are the endowments injected alongside fetch
|
|
283
|
-
// only when 'endowment:network-access' permission is requested,
|
|
284
|
-
// therefore these are hardened as part of fetch dependency injection within its factory.
|
|
285
|
-
// These endowments are not (and should never be) available by default.
|
|
286
|
-
Request: harden(Request),
|
|
287
|
-
Headers: harden(Headers),
|
|
288
|
-
Response: harden(Response),
|
|
289
|
-
teardownFunction
|
|
290
|
-
};
|
|
291
|
-
};
|
|
292
|
-
const endowmentModule = {
|
|
293
|
-
names: [
|
|
294
|
-
'fetch',
|
|
295
|
-
'Request',
|
|
296
|
-
'Headers',
|
|
297
|
-
'Response'
|
|
298
|
-
],
|
|
299
|
-
factory: createNetwork
|
|
300
|
-
};
|
|
301
|
-
const _default = endowmentModule;
|
|
302
|
-
|
|
303
|
-
//# sourceMappingURL=network.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/common/endowments/network.ts"],"sourcesContent":["import { assert } from '@metamask/utils';\n\nimport { withTeardown } from '../utils';\nimport type { EndowmentFactoryOptions } from './commonEndowmentFactory';\n\n/**\n * This class wraps a Response object.\n * That way, a teardown process can stop any processes left.\n */\nclass ResponseWrapper implements Response {\n readonly #teardownRef: { lastTeardown: number };\n\n #ogResponse: Response;\n\n #onStart: () => Promise<void>;\n\n #onFinish: () => Promise<void>;\n\n constructor(\n ogResponse: Response,\n teardownRef: { lastTeardown: number },\n onStart: () => Promise<void>,\n onFinish: () => Promise<void>,\n ) {\n this.#ogResponse = ogResponse;\n this.#teardownRef = teardownRef;\n this.#onStart = onStart;\n this.#onFinish = onFinish;\n }\n\n get body(): ReadableStream<Uint8Array> | null {\n return this.#ogResponse.body;\n }\n\n get bodyUsed() {\n return this.#ogResponse.bodyUsed;\n }\n\n get headers() {\n return this.#ogResponse.headers;\n }\n\n get ok() {\n return this.#ogResponse.ok;\n }\n\n get redirected() {\n return this.#ogResponse.redirected;\n }\n\n get status() {\n return this.#ogResponse.status;\n }\n\n get statusText() {\n return this.#ogResponse.statusText;\n }\n\n get type() {\n return this.#ogResponse.type;\n }\n\n get url() {\n return this.#ogResponse.url;\n }\n\n async text() {\n return await withTeardown<string>(\n (async () => {\n await this.#onStart();\n try {\n return await this.#ogResponse.text();\n } finally {\n await this.#onFinish();\n }\n })(),\n this.#teardownRef,\n );\n }\n\n async arrayBuffer(): Promise<ArrayBuffer> {\n return await withTeardown<ArrayBuffer>(\n (async () => {\n await this.#onStart();\n try {\n return await this.#ogResponse.arrayBuffer();\n } finally {\n await this.#onFinish();\n }\n })(),\n this.#teardownRef,\n );\n }\n\n async blob(): Promise<Blob> {\n return await withTeardown<Blob>(\n (async () => {\n await this.#onStart();\n try {\n return await this.#ogResponse.blob();\n } finally {\n await this.#onFinish();\n }\n })(),\n this.#teardownRef,\n );\n }\n\n clone(): Response {\n const newResponse = this.#ogResponse.clone();\n return new ResponseWrapper(\n newResponse,\n this.#teardownRef,\n this.#onStart,\n this.#onFinish,\n );\n }\n\n async formData(): Promise<FormData> {\n return await withTeardown<FormData>(\n (async () => {\n await this.#onStart();\n try {\n return await this.#ogResponse.formData();\n } finally {\n await this.#onFinish();\n }\n })(),\n this.#teardownRef,\n );\n }\n\n async json(): Promise<any> {\n return await withTeardown(\n (async () => {\n await this.#onStart();\n try {\n return await this.#ogResponse.json();\n } finally {\n await this.#onFinish();\n }\n })(),\n this.#teardownRef,\n );\n }\n}\n\n/**\n * Create a network endowment, consisting of a `fetch` function.\n * This allows us to provide a teardown function, so that we can cancel\n * any pending requests, connections, streams, etc. that may be open when a snap\n * is terminated.\n *\n * This wraps the original implementation of `fetch`,\n * to ensure that a bad actor cannot get access to the original function, thus\n * potentially preventing the network requests from being torn down.\n *\n * @param options - An options bag.\n * @param options.notify - A reference to the notify function of the snap executor.\n * @returns An object containing a wrapped `fetch`\n * function, as well as a teardown function.\n */\nconst createNetwork = ({ notify }: EndowmentFactoryOptions = {}) => {\n assert(notify, 'Notify must be passed to network endowment factory');\n // Open fetch calls or open body streams\n const openConnections = new Set<{ cancel: () => Promise<void> }>();\n // Track last teardown count\n const teardownRef = { lastTeardown: 0 };\n\n // Remove items from openConnections after they were garbage collected\n const cleanup = new FinalizationRegistry<() => void>(\n /* istanbul ignore next: can't test garbage collection without modifying node parameters */\n (callback) => callback(),\n );\n\n const _fetch: typeof fetch = async (\n input: RequestInfo | URL,\n init?: RequestInit,\n ): Promise<Response> => {\n const abortController = new AbortController();\n if (init?.signal !== null && init?.signal !== undefined) {\n const originalSignal = init.signal;\n // Merge abort controllers\n originalSignal.addEventListener(\n 'abort',\n () => {\n abortController.abort((originalSignal as any).reason);\n },\n { once: true },\n );\n }\n\n let started = false;\n const onStart = async () => {\n if (!started) {\n started = true;\n await notify({\n method: 'OutboundRequest',\n params: { source: 'fetch' },\n });\n }\n };\n\n let finished = false;\n const onFinish = async () => {\n if (!finished) {\n finished = true;\n await notify({\n method: 'OutboundResponse',\n params: { source: 'fetch' },\n });\n }\n };\n\n let res: Response;\n let openFetchConnection: { cancel: () => Promise<void> } | undefined;\n return await withTeardown(\n (async () => {\n try {\n await notify({\n method: 'OutboundRequest',\n params: { source: 'fetch' },\n });\n const fetchPromise = fetch(input, {\n ...init,\n signal: abortController.signal,\n });\n\n openFetchConnection = {\n cancel: async () => {\n abortController.abort();\n try {\n await fetchPromise;\n } catch {\n /* do nothing */\n }\n },\n };\n openConnections.add(openFetchConnection);\n\n res = new ResponseWrapper(\n await fetchPromise,\n teardownRef,\n onStart,\n onFinish,\n );\n } finally {\n if (openFetchConnection !== undefined) {\n openConnections.delete(openFetchConnection);\n }\n await notify({\n method: 'OutboundResponse',\n params: { source: 'fetch' },\n });\n }\n\n if (res.body !== null) {\n const body = new WeakRef<ReadableStream>(res.body);\n\n const openBodyConnection = {\n cancel:\n /* istanbul ignore next: see it.todo('can be torn down during body read') test */\n async () => {\n try {\n await body.deref()?.cancel();\n } catch {\n /* do nothing */\n }\n },\n };\n openConnections.add(openBodyConnection);\n cleanup.register(\n res.body,\n /* istanbul ignore next: can't test garbage collection without modifying node parameters */\n () => openConnections.delete(openBodyConnection),\n );\n }\n return harden(res);\n })(),\n teardownRef,\n );\n };\n\n const teardownFunction = async () => {\n teardownRef.lastTeardown += 1;\n const promises: Promise<void>[] = [];\n openConnections.forEach(({ cancel }) => promises.push(cancel()));\n openConnections.clear();\n await Promise.all(promises);\n };\n\n return {\n fetch: harden(_fetch),\n // Request, Headers and Response are the endowments injected alongside fetch\n // only when 'endowment:network-access' permission is requested,\n // therefore these are hardened as part of fetch dependency injection within its factory.\n // These endowments are not (and should never be) available by default.\n Request: harden(Request),\n Headers: harden(Headers),\n Response: harden(Response),\n teardownFunction,\n };\n};\n\nconst endowmentModule = {\n names: ['fetch', 'Request', 'Headers', 'Response'] as const,\n factory: createNetwork,\n};\nexport default endowmentModule;\n"],"names":["ResponseWrapper","body","ogResponse","bodyUsed","headers","ok","redirected","status","statusText","type","url","text","withTeardown","onStart","onFinish","teardownRef","arrayBuffer","blob","clone","newResponse","formData","json","constructor","createNetwork","notify","assert","openConnections","Set","lastTeardown","cleanup","FinalizationRegistry","callback","_fetch","input","init","abortController","AbortController","signal","undefined","originalSignal","addEventListener","abort","reason","once","started","method","params","source","finished","res","openFetchConnection","fetchPromise","fetch","cancel","add","delete","WeakRef","openBodyConnection","deref","register","harden","teardownFunction","promises","forEach","push","clear","Promise","all","Request","Headers","Response","endowmentModule","names","factory"],"mappings":";;;;+BAoTA;;;eAAA;;;uBApTuB;wBAEM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAQlB,4CAET,2CAEA,wCAEA;AAXF;;;CAGC,GACD,MAAMA;IAqBJ,IAAIC,OAA0C;QAC5C,OAAO,yBAAA,IAAI,EAAEC,aAAWD,IAAI;IAC9B;IAEA,IAAIE,WAAW;QACb,OAAO,yBAAA,IAAI,EAAED,aAAWC,QAAQ;IAClC;IAEA,IAAIC,UAAU;QACZ,OAAO,yBAAA,IAAI,EAAEF,aAAWE,OAAO;IACjC;IAEA,IAAIC,KAAK;QACP,OAAO,yBAAA,IAAI,EAAEH,aAAWG,EAAE;IAC5B;IAEA,IAAIC,aAAa;QACf,OAAO,yBAAA,IAAI,EAAEJ,aAAWI,UAAU;IACpC;IAEA,IAAIC,SAAS;QACX,OAAO,yBAAA,IAAI,EAAEL,aAAWK,MAAM;IAChC;IAEA,IAAIC,aAAa;QACf,OAAO,yBAAA,IAAI,EAAEN,aAAWM,UAAU;IACpC;IAEA,IAAIC,OAAO;QACT,OAAO,yBAAA,IAAI,EAAEP,aAAWO,IAAI;IAC9B;IAEA,IAAIC,MAAM;QACR,OAAO,yBAAA,IAAI,EAAER,aAAWQ,GAAG;IAC7B;IAEA,MAAMC,OAAO;QACX,OA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AAIhD,IAAI,EACR,yFAAyF,GACzF,IAAMyB,gBAAgB6B,MAAM,CAACE;YAEjC;YACA,OAAOG,OAAOX;QAChB,CAAA,KACAlC;IAEJ;IAEA,MAAM8C,mBAAmB;QACvB9C,YAAYa,YAAY,IAAI;QAC5B,MAAMkC,WAA4B,EAAE;QACpCpC,gBAAgBqC,OAAO,CAAC,CAAC,EAAEV,MAAM,EAAE,GAAKS,SAASE,IAAI,CAACX;QACtD3B,gBAAgBuC,KAAK;QACrB,MAAMC,QAAQC,GAAG,CAACL;IACpB;IAEA,OAAO;QACLV,OAAOQ,OAAO5B;QACd,4EAA4E;QAC5E,gEAAgE;QAChE,yFAAyF;QACzF,uEAAuE;QACvEoC,SAASR,OAAOQ;QAChBC,SAAST,OAAOS;QAChBC,UAAUV,OAAOU;QACjBT;IACF;AACF;AAEA,MAAMU,kBAAkB;IACtBC,OAAO;QAAC;QAAS;QAAW;QAAW;KAAW;IAClDC,SAASlD;AACX;MACA,WAAegD"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates TextDecoder function hardened by SES.
|
|
3
|
-
*
|
|
4
|
-
* @returns An object with the attenuated `TextDecoder` function.
|
|
5
|
-
*/ "use strict";
|
|
6
|
-
Object.defineProperty(exports, "__esModule", {
|
|
7
|
-
value: true
|
|
8
|
-
});
|
|
9
|
-
Object.defineProperty(exports, "default", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function() {
|
|
12
|
-
return _default;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
const createTextDecoder = ()=>{
|
|
16
|
-
return {
|
|
17
|
-
TextDecoder: harden(TextDecoder)
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
const endowmentModule = {
|
|
21
|
-
names: [
|
|
22
|
-
'TextDecoder'
|
|
23
|
-
],
|
|
24
|
-
factory: createTextDecoder
|
|
25
|
-
};
|
|
26
|
-
const _default = endowmentModule;
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=textDecoder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/common/endowments/textDecoder.ts"],"sourcesContent":["/**\n * Creates TextDecoder function hardened by SES.\n *\n * @returns An object with the attenuated `TextDecoder` function.\n */\nconst createTextDecoder = () => {\n return {\n TextDecoder: harden(TextDecoder),\n } as const;\n};\n\nconst endowmentModule = {\n names: ['TextDecoder'] as const,\n factory: createTextDecoder,\n};\nexport default endowmentModule;\n"],"names":["createTextDecoder","TextDecoder","harden","endowmentModule","names","factory"],"mappings":"AAAA;;;;CAIC;;;;+BAWD;;;eAAA;;;AAVA,MAAMA,oBAAoB;IACxB,OAAO;QACLC,aAAaC,OAAOD;IACtB;AACF;AAEA,MAAME,kBAAkB;IACtBC,OAAO;QAAC;KAAc;IACtBC,SAASL;AACX;MACA,WAAeG"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates TextEncoder function hardened by SES.
|
|
3
|
-
*
|
|
4
|
-
* @returns An object with the attenuated `TextEncoder` function.
|
|
5
|
-
*/ "use strict";
|
|
6
|
-
Object.defineProperty(exports, "__esModule", {
|
|
7
|
-
value: true
|
|
8
|
-
});
|
|
9
|
-
Object.defineProperty(exports, "default", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function() {
|
|
12
|
-
return _default;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
const createTextEncoder = ()=>{
|
|
16
|
-
return {
|
|
17
|
-
TextEncoder: harden(TextEncoder)
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
const endowmentModule = {
|
|
21
|
-
names: [
|
|
22
|
-
'TextEncoder'
|
|
23
|
-
],
|
|
24
|
-
factory: createTextEncoder
|
|
25
|
-
};
|
|
26
|
-
const _default = endowmentModule;
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=textEncoder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/common/endowments/textEncoder.ts"],"sourcesContent":["/**\n * Creates TextEncoder function hardened by SES.\n *\n * @returns An object with the attenuated `TextEncoder` function.\n */\nconst createTextEncoder = () => {\n return {\n TextEncoder: harden(TextEncoder),\n } as const;\n};\n\nconst endowmentModule = {\n names: ['TextEncoder'] as const,\n factory: createTextEncoder,\n};\nexport default endowmentModule;\n"],"names":["createTextEncoder","TextEncoder","harden","endowmentModule","names","factory"],"mappings":"AAAA;;;;CAIC;;;;+BAWD;;;eAAA;;;AAVA,MAAMA,oBAAoB;IACxB,OAAO;QACLC,aAAaC,OAAOD;IACtB;AACF;AAEA,MAAME,kBAAkB;IACtBC,OAAO;QAAC;KAAc;IACtBC,SAASL;AACX;MACA,WAAeG"}
|