@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
|
@@ -12741,8 +12741,207 @@ module.exports = {
|
|
|
12741
12741
|
})()
|
|
12742
12742
|
return module.exports
|
|
12743
12743
|
})()
|
|
12744
|
+
const { scuttle } = // define scuttle
|
|
12745
|
+
(function(){
|
|
12746
|
+
const global = globalRef
|
|
12747
|
+
const exports = {}
|
|
12748
|
+
const module = { exports }
|
|
12749
|
+
;(function(){
|
|
12750
|
+
// START of injected code from scuttle
|
|
12751
|
+
/**
|
|
12752
|
+
* @typedef {object} ScuttleOpts
|
|
12753
|
+
* @property {boolean} enabled - Whether scuttling is enabled or not.
|
|
12754
|
+
* @property {Array<string|RegExp>} exceptions - List of properties to exclude from scuttling.
|
|
12755
|
+
* @property {string} scuttlerName - Name of the scuttler function to use which is expected to be found as a
|
|
12756
|
+
* property on the global object (e.g. if scuttlerName is 'x', scuttler function is obtained from globalThis['x']).
|
|
12757
|
+
*/
|
|
12758
|
+
|
|
12759
|
+
/**
|
|
12760
|
+
* @typedef {object} GlobalRef
|
|
12761
|
+
* @property {Record<string, any>} [globalThis] - Reference to the global object.
|
|
12762
|
+
*/
|
|
12763
|
+
|
|
12764
|
+
const { Object, Array, Error, RegExp, Set, console, Proxy, Reflect } =
|
|
12765
|
+
globalThis
|
|
12766
|
+
|
|
12767
|
+
const {
|
|
12768
|
+
assign,
|
|
12769
|
+
getOwnPropertyNames,
|
|
12770
|
+
getOwnPropertyDescriptor,
|
|
12771
|
+
create,
|
|
12772
|
+
defineProperty,
|
|
12773
|
+
} = Object
|
|
12774
|
+
|
|
12775
|
+
const { isArray, from } = Array
|
|
12776
|
+
|
|
12777
|
+
const { getPrototypeOf } = Reflect
|
|
12778
|
+
|
|
12779
|
+
const { warn } = console
|
|
12780
|
+
|
|
12781
|
+
function generateInvokers(prop) {
|
|
12782
|
+
return { get, set }
|
|
12783
|
+
function set() {
|
|
12784
|
+
warn(
|
|
12785
|
+
`LavaMoat - property "${prop}" of globalThis cannot be set under scuttling mode. ` +
|
|
12786
|
+
'To learn more visit https://github.com/LavaMoat/LavaMoat/pull/360.'
|
|
12787
|
+
)
|
|
12788
|
+
}
|
|
12789
|
+
function get() {
|
|
12790
|
+
throw new Error(
|
|
12791
|
+
`LavaMoat - property "${prop}" of globalThis is inaccessible under scuttling mode. ` +
|
|
12792
|
+
'To learn more visit https://github.com/LavaMoat/LavaMoat/pull/360.'
|
|
12793
|
+
)
|
|
12794
|
+
}
|
|
12795
|
+
}
|
|
12796
|
+
|
|
12797
|
+
/**
|
|
12798
|
+
* Applies scuttling, with the default set of options, including using Snow if passed in as scuttlerFunc.
|
|
12799
|
+
* Scuttle globalThis right after we used it to create the root package compartment.
|
|
12800
|
+
*
|
|
12801
|
+
* @param {GlobalRef} globalRef - Reference to the global object.
|
|
12802
|
+
* @param {ScuttleOpts} opts - Scuttling options.
|
|
12803
|
+
*/
|
|
12804
|
+
function scuttle(globalRef, opts) {
|
|
12805
|
+
const scuttleOpts = generateScuttleOpts(globalRef, opts)
|
|
12806
|
+
|
|
12807
|
+
if (scuttleOpts.enabled) {
|
|
12808
|
+
if (!isArray(scuttleOpts.exceptions)) {
|
|
12809
|
+
throw new Error(
|
|
12810
|
+
`LavaMoat - exceptions must be an array, got ${typeof scuttleOpts.exceptions}`
|
|
12811
|
+
)
|
|
12812
|
+
}
|
|
12813
|
+
scuttleOpts.scuttlerFunc(globalRef, (realm) =>
|
|
12814
|
+
performScuttleGlobalThis(realm, scuttleOpts.exceptions)
|
|
12815
|
+
)
|
|
12816
|
+
}
|
|
12817
|
+
}
|
|
12818
|
+
|
|
12819
|
+
/**
|
|
12820
|
+
* @param {GlobalRef} globalRef - Reference to the global object.
|
|
12821
|
+
* @param {ScuttleOpts|boolean} originalOpts - Scuttling options. Accepts `true` for backwards compatibility.
|
|
12822
|
+
* @returns {ScuttleOpts} - Final scuttling options.
|
|
12823
|
+
*/
|
|
12824
|
+
function generateScuttleOpts(globalRef, originalOpts = create(null)) {
|
|
12825
|
+
const defaultOpts = {
|
|
12826
|
+
enabled: true,
|
|
12827
|
+
exceptions: [],
|
|
12828
|
+
scuttlerName: '',
|
|
12829
|
+
}
|
|
12830
|
+
const opts = assign(
|
|
12831
|
+
create(null),
|
|
12832
|
+
originalOpts === true ? defaultOpts : originalOpts,
|
|
12833
|
+
{
|
|
12834
|
+
scuttlerFunc: (globalRef, scuttle) => scuttle(globalRef),
|
|
12835
|
+
},
|
|
12836
|
+
{
|
|
12837
|
+
exceptions: (originalOpts?.exceptions || defaultOpts.exceptions).map(
|
|
12838
|
+
(e) => toRE(e)
|
|
12839
|
+
),
|
|
12840
|
+
}
|
|
12841
|
+
)
|
|
12842
|
+
if (opts.scuttlerName) {
|
|
12843
|
+
if (!globalRef[opts.scuttlerName]) {
|
|
12844
|
+
throw new Error(
|
|
12845
|
+
`LavaMoat - 'scuttlerName' function "${opts.scuttlerName}" expected on globalRef.` +
|
|
12846
|
+
'To learn more visit https://github.com/LavaMoat/LavaMoat/pull/462.'
|
|
12847
|
+
)
|
|
12848
|
+
}
|
|
12849
|
+
opts.scuttlerFunc = globalRef[opts.scuttlerName]
|
|
12850
|
+
}
|
|
12851
|
+
return opts
|
|
12852
|
+
|
|
12853
|
+
/**
|
|
12854
|
+
* @param {string|RegExp} except - Exception to convert to RegExp.
|
|
12855
|
+
* @returns {string|RegExp} - Converted exception.
|
|
12856
|
+
*/
|
|
12857
|
+
function toRE(except) {
|
|
12858
|
+
// turn scuttleGlobalThis.exceptions regexes strings to actual regexes
|
|
12859
|
+
if (!except.startsWith('/')) {
|
|
12860
|
+
return except
|
|
12861
|
+
}
|
|
12862
|
+
const parts = except.split('/')
|
|
12863
|
+
const pattern = parts.slice(1, -1).join('/')
|
|
12864
|
+
const flags = parts[parts.length - 1]
|
|
12865
|
+
return new RegExp(pattern, flags)
|
|
12866
|
+
}
|
|
12867
|
+
}
|
|
12868
|
+
|
|
12869
|
+
/**
|
|
12870
|
+
* Runs scuttling on the globalRef. Use applyDefaultScuttling for full scope of options.
|
|
12871
|
+
*
|
|
12872
|
+
* @param {GlobalRef} globalRef - Reference to the global object.
|
|
12873
|
+
* @param {Array<string|RegExp>} extraPropsToAvoid - List of additional properties to exclude from scuttling beyond the default ones.
|
|
12874
|
+
*/
|
|
12875
|
+
function performScuttleGlobalThis(globalRef, extraPropsToAvoid = []) {
|
|
12876
|
+
const props = []
|
|
12877
|
+
getPrototypeChain(globalRef).forEach((proto) =>
|
|
12878
|
+
props.push(...getOwnPropertyNames(proto))
|
|
12879
|
+
)
|
|
12880
|
+
|
|
12881
|
+
// support LM,SES exported APIs and polyfills
|
|
12882
|
+
const avoidForLavaMoatCompatibility = ['Compartment', 'Error', 'globalThis']
|
|
12883
|
+
const propsToAvoid = new Set([
|
|
12884
|
+
...avoidForLavaMoatCompatibility,
|
|
12885
|
+
...extraPropsToAvoid,
|
|
12886
|
+
])
|
|
12887
|
+
|
|
12888
|
+
const obj = create(null)
|
|
12889
|
+
props.forEach((prop) => {
|
|
12890
|
+
const { get, set } = generateInvokers(prop)
|
|
12891
|
+
if (shouldAvoidProp(propsToAvoid, prop)) {
|
|
12892
|
+
return
|
|
12893
|
+
}
|
|
12894
|
+
let desc = getOwnPropertyDescriptor(globalRef, prop)
|
|
12895
|
+
if (desc?.configurable === true) {
|
|
12896
|
+
desc = { configurable: false, set, get }
|
|
12897
|
+
} else if (desc?.writable === true) {
|
|
12898
|
+
const p = new Proxy(obj, { getPrototypeOf: get, get, set })
|
|
12899
|
+
desc = { configurable: false, writable: false, value: p }
|
|
12900
|
+
} else {
|
|
12901
|
+
return
|
|
12902
|
+
}
|
|
12903
|
+
defineProperty(globalRef, prop, desc)
|
|
12904
|
+
})
|
|
12905
|
+
}
|
|
12906
|
+
|
|
12907
|
+
/**
|
|
12908
|
+
* @param {Set<string|RegExp>} propsToAvoid - List of properties to exclude from scuttling.
|
|
12909
|
+
* @param {string} prop - Property to check.
|
|
12910
|
+
* @returns {boolean} - Whether the property should be avoided or not.
|
|
12911
|
+
*/
|
|
12912
|
+
const shouldAvoidProp = (propsToAvoid, prop) =>
|
|
12913
|
+
from(propsToAvoid).some(
|
|
12914
|
+
(avoid) =>
|
|
12915
|
+
(typeof avoid === 'string' && avoid === prop) ||
|
|
12916
|
+
(avoid instanceof RegExp && avoid.test(prop))
|
|
12917
|
+
)
|
|
12918
|
+
|
|
12919
|
+
/**
|
|
12920
|
+
* @param {object} value - object to get the prototype chain from.
|
|
12921
|
+
* @returns {Array<object>} - Prototype chain as an array.
|
|
12922
|
+
*/
|
|
12923
|
+
function getPrototypeChain(value) {
|
|
12924
|
+
const protoChain = []
|
|
12925
|
+
let current = value
|
|
12926
|
+
while (current) {
|
|
12927
|
+
if (typeof current !== 'object' && typeof current !== 'function') {
|
|
12928
|
+
break
|
|
12929
|
+
}
|
|
12930
|
+
protoChain.push(current)
|
|
12931
|
+
current = getPrototypeOf(current)
|
|
12932
|
+
}
|
|
12933
|
+
return protoChain
|
|
12934
|
+
}
|
|
12935
|
+
|
|
12936
|
+
module.exports = {
|
|
12937
|
+
scuttle,
|
|
12938
|
+
}
|
|
12939
|
+
|
|
12940
|
+
// END of injected code from scuttle
|
|
12941
|
+
})()
|
|
12942
|
+
return module.exports
|
|
12943
|
+
})()
|
|
12744
12944
|
|
|
12745
|
-
const scuttleOpts = generateScuttleOpts(scuttleGlobalThis)
|
|
12746
12945
|
const moduleCache = new Map()
|
|
12747
12946
|
const packageCompartmentCache = new Map()
|
|
12748
12947
|
const globalStore = new Map()
|
|
@@ -12750,13 +12949,7 @@ module.exports = {
|
|
|
12750
12949
|
const rootPackageName = '$root$'
|
|
12751
12950
|
const rootPackageCompartment = createRootPackageCompartment(globalRef)
|
|
12752
12951
|
|
|
12753
|
-
|
|
12754
|
-
if (scuttleOpts.enabled) {
|
|
12755
|
-
if (!Array.isArray(scuttleOpts.exceptions)) {
|
|
12756
|
-
throw new Error(`LavaMoat - scuttleGlobalThis.exceptions must be an array, got "${typeof scuttleOpts.exceptions}"`)
|
|
12757
|
-
}
|
|
12758
|
-
scuttleOpts.scuttlerFunc(globalRef, realm => performScuttleGlobalThis(realm, scuttleOpts.exceptions))
|
|
12759
|
-
}
|
|
12952
|
+
scuttle(globalRef, scuttleGlobalThis)
|
|
12760
12953
|
|
|
12761
12954
|
const kernel = {
|
|
12762
12955
|
internalRequire,
|
|
@@ -12768,85 +12961,6 @@ module.exports = {
|
|
|
12768
12961
|
Object.freeze(kernel)
|
|
12769
12962
|
return kernel
|
|
12770
12963
|
|
|
12771
|
-
// generate final scuttling options (1) by taking default
|
|
12772
|
-
// options into consideration, (2) turning RE strings into
|
|
12773
|
-
// actual REs and (3) without mutating original opts object
|
|
12774
|
-
function generateScuttleOpts(originalOpts) {
|
|
12775
|
-
const defaultOpts = {
|
|
12776
|
-
enabled: true,
|
|
12777
|
-
exceptions: [],
|
|
12778
|
-
scuttlerName: '',
|
|
12779
|
-
}
|
|
12780
|
-
const opts = Object.assign({},
|
|
12781
|
-
originalOpts === true ? { ... defaultOpts } : { ...originalOpts },
|
|
12782
|
-
{ scuttlerFunc: (globalRef, scuttle) => scuttle(globalRef) },
|
|
12783
|
-
{ exceptions: (originalOpts.exceptions || defaultOpts.exceptions).map(e => toRE(e)) },
|
|
12784
|
-
)
|
|
12785
|
-
if (opts.scuttlerName) {
|
|
12786
|
-
if (!globalRef[opts.scuttlerName]) {
|
|
12787
|
-
throw new Error(
|
|
12788
|
-
`LavaMoat - 'scuttlerName' function "${opts.scuttlerName}" expected on globalRef.` +
|
|
12789
|
-
'To learn more visit https://github.com/LavaMoat/LavaMoat/pull/462.',
|
|
12790
|
-
)
|
|
12791
|
-
}
|
|
12792
|
-
opts.scuttlerFunc = globalRef[opts.scuttlerName]
|
|
12793
|
-
}
|
|
12794
|
-
return opts
|
|
12795
|
-
|
|
12796
|
-
function toRE(except) {
|
|
12797
|
-
// turn scuttleGlobalThis.exceptions regexes strings to actual regexes
|
|
12798
|
-
if (!except.startsWith('/')) {
|
|
12799
|
-
return except
|
|
12800
|
-
}
|
|
12801
|
-
const parts = except.split('/')
|
|
12802
|
-
const pattern = parts.slice(1, -1).join('/')
|
|
12803
|
-
const flags = parts[parts.length - 1]
|
|
12804
|
-
return new RegExp(pattern, flags)
|
|
12805
|
-
}
|
|
12806
|
-
}
|
|
12807
|
-
|
|
12808
|
-
function performScuttleGlobalThis (globalRef, extraPropsToAvoid = []) {
|
|
12809
|
-
const props = []
|
|
12810
|
-
getPrototypeChain(globalRef)
|
|
12811
|
-
.forEach(proto =>
|
|
12812
|
-
props.push(...Object.getOwnPropertyNames(proto)))
|
|
12813
|
-
|
|
12814
|
-
// support LM,SES exported APIs and polyfills
|
|
12815
|
-
const avoidForLavaMoatCompatibility = ['Compartment', 'Error', 'globalThis']
|
|
12816
|
-
const propsToAvoid = new Set([...avoidForLavaMoatCompatibility, ...extraPropsToAvoid])
|
|
12817
|
-
|
|
12818
|
-
const obj = Object.create(null)
|
|
12819
|
-
for (const prop of props) {
|
|
12820
|
-
// eslint-disable-next-line no-inner-declarations
|
|
12821
|
-
function set() {
|
|
12822
|
-
console.warn(
|
|
12823
|
-
`LavaMoat - property "${prop}" of globalThis cannot be set under scuttling mode. ` +
|
|
12824
|
-
'To learn more visit https://github.com/LavaMoat/LavaMoat/pull/360.',
|
|
12825
|
-
)
|
|
12826
|
-
}
|
|
12827
|
-
// eslint-disable-next-line no-inner-declarations
|
|
12828
|
-
function get() {
|
|
12829
|
-
throw new Error(
|
|
12830
|
-
`LavaMoat - property "${prop}" of globalThis is inaccessible under scuttling mode. ` +
|
|
12831
|
-
'To learn more visit https://github.com/LavaMoat/LavaMoat/pull/360.',
|
|
12832
|
-
)
|
|
12833
|
-
}
|
|
12834
|
-
if (shouldAvoidProp(propsToAvoid, prop)) {
|
|
12835
|
-
continue
|
|
12836
|
-
}
|
|
12837
|
-
let desc = Object.getOwnPropertyDescriptor(globalRef, prop)
|
|
12838
|
-
if (desc?.configurable === true) {
|
|
12839
|
-
desc = { configurable: false, set, get }
|
|
12840
|
-
} else if (desc?.writable === true) {
|
|
12841
|
-
const p = new Proxy(obj, { getPrototypeOf: get, get, set } )
|
|
12842
|
-
desc = { configurable: false, writable: false, value: p }
|
|
12843
|
-
} else {
|
|
12844
|
-
continue
|
|
12845
|
-
}
|
|
12846
|
-
Object.defineProperty(globalRef, prop, desc)
|
|
12847
|
-
}
|
|
12848
|
-
}
|
|
12849
|
-
|
|
12850
12964
|
// this function instantiaties a module from a moduleId.
|
|
12851
12965
|
// 1. loads the module metadata and policy
|
|
12852
12966
|
// 2. prepares the execution environment
|
|
@@ -13131,29 +13245,6 @@ module.exports = {
|
|
|
13131
13245
|
return packageConfig
|
|
13132
13246
|
}
|
|
13133
13247
|
|
|
13134
|
-
// util for getting the prototype chain as an array
|
|
13135
|
-
// includes the provided value in the result
|
|
13136
|
-
function getPrototypeChain (value) {
|
|
13137
|
-
const protoChain = []
|
|
13138
|
-
let current = value
|
|
13139
|
-
while (current && (typeof current === 'object' || typeof current === 'function')) {
|
|
13140
|
-
protoChain.push(current)
|
|
13141
|
-
current = Reflect.getPrototypeOf(current)
|
|
13142
|
-
}
|
|
13143
|
-
return protoChain
|
|
13144
|
-
}
|
|
13145
|
-
|
|
13146
|
-
function shouldAvoidProp(propsToAvoid, prop) {
|
|
13147
|
-
for (const avoid of propsToAvoid) {
|
|
13148
|
-
if (avoid instanceof RegExp && avoid.test(prop)) {
|
|
13149
|
-
return true
|
|
13150
|
-
}
|
|
13151
|
-
if (propsToAvoid.has(prop)) {
|
|
13152
|
-
return true
|
|
13153
|
-
}
|
|
13154
|
-
}
|
|
13155
|
-
return false
|
|
13156
|
-
}
|
|
13157
13248
|
}
|
|
13158
13249
|
})()
|
|
13159
13250
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/common/endowments/interval.ts
|
|
2
|
+
import { rpcErrors } from "@metamask/rpc-errors";
|
|
3
|
+
var MINIMUM_INTERVAL = 10;
|
|
4
|
+
var createInterval = () => {
|
|
5
|
+
const registeredHandles = /* @__PURE__ */ new Map();
|
|
6
|
+
const _setInterval = (handler, timeout) => {
|
|
7
|
+
if (typeof handler !== "function") {
|
|
8
|
+
throw rpcErrors.invalidInput(
|
|
9
|
+
`The interval handler must be a function. Received: ${typeof handler}.`
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
harden(handler);
|
|
13
|
+
const handle = Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
14
|
+
const platformHandle = setInterval(
|
|
15
|
+
handler,
|
|
16
|
+
Math.max(MINIMUM_INTERVAL, timeout ?? 0)
|
|
17
|
+
);
|
|
18
|
+
registeredHandles.set(handle, platformHandle);
|
|
19
|
+
return handle;
|
|
20
|
+
};
|
|
21
|
+
const _clearInterval = (handle) => {
|
|
22
|
+
harden(handle);
|
|
23
|
+
const platformHandle = registeredHandles.get(handle);
|
|
24
|
+
if (platformHandle !== void 0) {
|
|
25
|
+
clearInterval(platformHandle);
|
|
26
|
+
registeredHandles.delete(handle);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const teardownFunction = () => {
|
|
30
|
+
for (const handle of registeredHandles.keys()) {
|
|
31
|
+
_clearInterval(handle);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
setInterval: harden(_setInterval),
|
|
36
|
+
clearInterval: harden(_clearInterval),
|
|
37
|
+
teardownFunction
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
var endowmentModule = {
|
|
41
|
+
names: ["setInterval", "clearInterval"],
|
|
42
|
+
factory: createInterval
|
|
43
|
+
};
|
|
44
|
+
var interval_default = endowmentModule;
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
interval_default
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=chunk-26EFJQDW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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"],"mappings":";AAAA,SAAS,iBAAiB;AAE1B,IAAM,mBAAmB;AAYzB,IAAM,iBAAiB,MAAM;AAC3B,QAAM,oBAAoB,oBAAI,IAAsB;AAEpD,QAAM,eAAe,CAAC,SAAuB,YAA8B;AACzE,QAAI,OAAO,YAAY,YAAY;AACjC,YAAM,UAAU;AAAA,QACd,sDAAsD,OAAO,OAAO;AAAA,MACtE;AAAA,IACF;AACA,WAAO,OAAO;AACd,UAAM,SAAS,OAAO,OAAO,uBAAO,OAAO,IAAI,CAAC;AAChD,UAAM,iBAAiB;AAAA,MACrB;AAAA,MACA,KAAK,IAAI,kBAAkB,WAAW,CAAC;AAAA,IACzC;AACA,sBAAkB,IAAI,QAAQ,cAAc;AAC5C,WAAO;AAAA,EACT;AAEA,QAAM,iBAAiB,CAAC,WAA0B;AAChD,WAAO,MAAM;AACb,UAAM,iBAAiB,kBAAkB,IAAI,MAAM;AACnD,QAAI,mBAAmB,QAAW;AAChC,oBAAc,cAAqB;AACnC,wBAAkB,OAAO,MAAM;AAAA,IACjC;AAAA,EACF;AAEA,QAAM,mBAAmB,MAAY;AACnC,eAAW,UAAU,kBAAkB,KAAK,GAAG;AAC7C,qBAAe,MAAM;AAAA,IACvB;AAAA,EACF;AAEA,SAAO;AAAA,IACL,aAAa,OAAO,YAAY;AAAA,IAChC,eAAe,OAAO,cAAc;AAAA,IACpC;AAAA,EACF;AACF;AAEA,IAAM,kBAAkB;AAAA,EACtB,OAAO,CAAC,eAAe,eAAe;AAAA,EACtC,SAAS;AACX;AACA,IAAO,mBAAQ;","names":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/common/lockdown/lockdown-more.ts
|
|
2
|
+
var _snapsutils = require('@metamask/snaps-utils');
|
|
3
|
+
function executeLockdownMore() {
|
|
4
|
+
try {
|
|
5
|
+
const namedIntrinsics = Reflect.ownKeys(new Compartment().globalThis);
|
|
6
|
+
const shouldHardenManually = /* @__PURE__ */ new Set(["eval", "Function"]);
|
|
7
|
+
const globalProperties = /* @__PURE__ */ new Set([
|
|
8
|
+
// universalPropertyNames is a constant added by lockdown to global scope
|
|
9
|
+
// at the time of writing, it is initialized in 'ses/src/whitelist'.
|
|
10
|
+
// These properties tend to be non-enumerable.
|
|
11
|
+
...namedIntrinsics
|
|
12
|
+
// TODO: Also include the named platform globals
|
|
13
|
+
// This grabs every enumerable property on globalThis.
|
|
14
|
+
// ...Object.keys(globalThis),
|
|
15
|
+
]);
|
|
16
|
+
globalProperties.forEach((propertyName) => {
|
|
17
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(
|
|
18
|
+
globalThis,
|
|
19
|
+
propertyName
|
|
20
|
+
);
|
|
21
|
+
if (descriptor) {
|
|
22
|
+
if (descriptor.configurable) {
|
|
23
|
+
if (hasAccessor(descriptor)) {
|
|
24
|
+
Object.defineProperty(globalThis, propertyName, {
|
|
25
|
+
configurable: false
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
Object.defineProperty(globalThis, propertyName, {
|
|
29
|
+
configurable: false,
|
|
30
|
+
writable: false
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (shouldHardenManually.has(propertyName)) {
|
|
35
|
+
harden(globalThis[propertyName]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
} catch (error) {
|
|
40
|
+
_snapsutils.logError.call(void 0, "Protecting intrinsics failed:", error);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function hasAccessor(descriptor) {
|
|
45
|
+
return "set" in descriptor || "get" in descriptor;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
exports.executeLockdownMore = executeLockdownMore;
|
|
51
|
+
//# sourceMappingURL=chunk-4NOF6TN6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common/lockdown/lockdown-more.ts"],"names":[],"mappings":";AAGA,SAAS,gBAAgB;AAsBlB,SAAS,sBAAsB;AAKpC,MAAI;AACF,UAAM,kBAAkB,QAAQ,QAAQ,IAAI,YAAY,EAAE,UAAU;AAGpE,UAAM,uBAAuB,oBAAI,IAAqB,CAAC,QAAQ,UAAU,CAAC;AAE1E,UAAM,mBAAmB,oBAAI,IAAI;AAAA;AAAA;AAAA;AAAA,MAI/B,GAAG;AAAA;AAAA;AAAA;AAAA,IAKL,CAAC;AAED,qBAAiB,QAAQ,CAAC,iBAAiB;AACzC,YAAM,aAAa,QAAQ;AAAA,QACzB;AAAA,QACA;AAAA,MACF;AAEA,UAAI,YAAY;AACd,YAAI,WAAW,cAAc;AAI3B,cAAI,YAAY,UAAU,GAAG;AAC3B,mBAAO,eAAe,YAAY,cAAc;AAAA,cAC9C,cAAc;AAAA,YAChB,CAAC;AAAA,UACH,OAAO;AACL,mBAAO,eAAe,YAAY,cAAc;AAAA,cAC9C,cAAc;AAAA,cACd,UAAU;AAAA,YACZ,CAAC;AAAA,UACH;AAAA,QACF;AAEA,YAAI,qBAAqB,IAAI,YAAY,GAAG;AAC1C,iBAAQ,WAAmB,YAAY,CAAC;AAAA,QAC1C;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,SAAS,OAAO;AACd,aAAS,iCAAiC,KAAK;AAC/C,UAAM;AAAA,EACR;AACF;AAYA,SAAS,YAAY,YAA0B;AAC7C,SAAO,SAAS,cAAc,SAAS;AACzC","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"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkL5U2LMZRjs = require('./chunk-L5U2LMZR.js');
|
|
4
|
+
|
|
5
|
+
// src/common/globalEvents.ts
|
|
6
|
+
var _rpcerrors = require('@metamask/rpc-errors');
|
|
7
|
+
function addEventListener(event, listener) {
|
|
8
|
+
if ("addEventListener" in _chunkL5U2LMZRjs.rootRealmGlobal && typeof _chunkL5U2LMZRjs.rootRealmGlobal.addEventListener === "function") {
|
|
9
|
+
return _chunkL5U2LMZRjs.rootRealmGlobal.addEventListener(event.toLowerCase(), listener);
|
|
10
|
+
}
|
|
11
|
+
if (_chunkL5U2LMZRjs.rootRealmGlobal.process && "on" in _chunkL5U2LMZRjs.rootRealmGlobal.process && typeof _chunkL5U2LMZRjs.rootRealmGlobal.process.on === "function") {
|
|
12
|
+
return _chunkL5U2LMZRjs.rootRealmGlobal.process.on(event, listener);
|
|
13
|
+
}
|
|
14
|
+
throw _rpcerrors.rpcErrors.internal("Platform agnostic addEventListener failed.");
|
|
15
|
+
}
|
|
16
|
+
function removeEventListener(event, listener) {
|
|
17
|
+
if ("removeEventListener" in _chunkL5U2LMZRjs.rootRealmGlobal && typeof _chunkL5U2LMZRjs.rootRealmGlobal.removeEventListener === "function") {
|
|
18
|
+
return _chunkL5U2LMZRjs.rootRealmGlobal.removeEventListener(event.toLowerCase(), listener);
|
|
19
|
+
}
|
|
20
|
+
if (_chunkL5U2LMZRjs.rootRealmGlobal.process && "removeListener" in _chunkL5U2LMZRjs.rootRealmGlobal.process && typeof _chunkL5U2LMZRjs.rootRealmGlobal.process.removeListener === "function") {
|
|
21
|
+
return _chunkL5U2LMZRjs.rootRealmGlobal.process.removeListener(event, listener);
|
|
22
|
+
}
|
|
23
|
+
throw new Error("Platform agnostic removeEventListener failed");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.addEventListener = addEventListener; exports.removeEventListener = removeEventListener;
|
|
30
|
+
//# sourceMappingURL=chunk-5DIRYAYO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common/globalEvents.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,iBAAiB;AAYnB,SAAS,iBACd,OACA,UACA;AACA,MACE,sBAAsB,mBACtB,OAAO,gBAAgB,qBAAqB,YAC5C;AACA,WAAO,gBAAgB,iBAAiB,MAAM,YAAY,GAAG,QAAQ;AAAA,EACvE;AAEA,MACE,gBAAgB,WAChB,QAAQ,gBAAgB,WACxB,OAAO,gBAAgB,QAAQ,OAAO,YACtC;AACA,WAAO,gBAAgB,QAAQ,GAAG,OAAO,QAAQ;AAAA,EACnD;AAEA,QAAM,UAAU,SAAS,4CAA4C;AACvE;AAUO,SAAS,oBACd,OACA,UACA;AACA,MACE,yBAAyB,mBACzB,OAAO,gBAAgB,wBAAwB,YAC/C;AACA,WAAO,gBAAgB,oBAAoB,MAAM,YAAY,GAAG,QAAQ;AAAA,EAC1E;AAEA,MACE,gBAAgB,WAChB,oBAAoB,gBAAgB,WACpC,OAAO,gBAAgB,QAAQ,mBAAmB,YAClD;AACA,WAAO,gBAAgB,QAAQ,eAAe,OAAO,QAAQ;AAAA,EAC/D;AAEA,QAAM,IAAI,MAAM,8CAA8C;AAChE","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"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkL4G6IIWGjs = require('./chunk-L4G6IIWG.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkXKY46YTJjs = require('./chunk-XKY46YTJ.js');
|
|
7
|
+
|
|
8
|
+
// src/node-process/ChildProcessSnapExecutor.ts
|
|
9
|
+
var _objectmultiplex = require('@metamask/object-multiplex'); var _objectmultiplex2 = _interopRequireDefault(_objectmultiplex);
|
|
10
|
+
var _postmessagestream = require('@metamask/post-message-stream');
|
|
11
|
+
var _snapsutils = require('@metamask/snaps-utils');
|
|
12
|
+
var _readablestream = require('readable-stream');
|
|
13
|
+
var ChildProcessSnapExecutor = class _ChildProcessSnapExecutor extends _chunkL4G6IIWGjs.BaseSnapExecutor {
|
|
14
|
+
static initialize() {
|
|
15
|
+
_chunkXKY46YTJjs.log.call(void 0, "Worker: Connecting to parent.");
|
|
16
|
+
const parentStream = new (0, _postmessagestream.ProcessMessageStream)();
|
|
17
|
+
const mux = new (0, _objectmultiplex2.default)();
|
|
18
|
+
_readablestream.pipeline.call(void 0, parentStream, mux, parentStream, (error) => {
|
|
19
|
+
if (error) {
|
|
20
|
+
_snapsutils.logError.call(void 0, `Parent stream failure, closing worker.`, error);
|
|
21
|
+
}
|
|
22
|
+
self.close();
|
|
23
|
+
});
|
|
24
|
+
const commandStream = mux.createStream(_snapsutils.SNAP_STREAM_NAMES.COMMAND);
|
|
25
|
+
const rpcStream = mux.createStream(_snapsutils.SNAP_STREAM_NAMES.JSON_RPC);
|
|
26
|
+
return new _ChildProcessSnapExecutor(commandStream, rpcStream);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
exports.ChildProcessSnapExecutor = ChildProcessSnapExecutor;
|
|
33
|
+
//# sourceMappingURL=chunk-5RKYO2Y5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node-process/ChildProcessSnapExecutor.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,qBAAqB;AAC5B,SAAS,4BAA4B;AACrC,SAAS,UAAU,yBAAyB;AAC5C,SAAS,gBAAgB;AAKlB,IAAM,2BAAN,MAAM,kCAAiC,iBAAiB;AAAA,EAC7D,OAAO,aAAa;AAClB,QAAI,+BAA+B;AAEnC,UAAM,eAAe,IAAI,qBAAqB;AAC9C,UAAM,MAAM,IAAI,gBAAgB;AAChC,aAAS,cAAc,KAAY,cAAc,CAAC,UAAU;AAC1D,UAAI,OAAO;AACT,iBAAS,0CAA0C,KAAK;AAAA,MAC1D;AACA,WAAK,MAAM;AAAA,IACb,CAAC;AAED,UAAM,gBAAgB,IAAI,aAAa,kBAAkB,OAAO;AAChE,UAAM,YAAY,IAAI,aAAa,kBAAkB,QAAQ;AAC7D,WAAO,IAAI,0BAAyB,eAAe,SAAS;AAAA,EAC9D;AACF","sourcesContent":["import ObjectMultiplex from '@metamask/object-multiplex';\nimport { ProcessMessageStream } from '@metamask/post-message-stream';\nimport { logError, SNAP_STREAM_NAMES } from '@metamask/snaps-utils';\nimport { pipeline } from 'readable-stream';\n\nimport { BaseSnapExecutor } from '../common/BaseSnapExecutor';\nimport { log } from '../logging';\n\nexport class ChildProcessSnapExecutor extends BaseSnapExecutor {\n static initialize() {\n log('Worker: Connecting to parent.');\n\n const parentStream = new ProcessMessageStream();\n const mux = new ObjectMultiplex();\n pipeline(parentStream, mux as any, parentStream, (error) => {\n if (error) {\n logError(`Parent stream failure, closing worker.`, error);\n }\n self.close();\n });\n\n const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);\n const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC) as any;\n return new ChildProcessSnapExecutor(commandStream, rpcStream);\n }\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rootRealmGlobal
|
|
3
|
+
} from "./chunk-Y7IEFWZU.mjs";
|
|
4
|
+
|
|
5
|
+
// src/common/endowments/date.ts
|
|
6
|
+
function createDate() {
|
|
7
|
+
const keys = Object.getOwnPropertyNames(
|
|
8
|
+
rootRealmGlobal.Date
|
|
9
|
+
);
|
|
10
|
+
let currentTime = 0;
|
|
11
|
+
const now = () => {
|
|
12
|
+
const actual = rootRealmGlobal.Date.now();
|
|
13
|
+
const newTime = Math.round(actual + Math.random());
|
|
14
|
+
if (newTime > currentTime) {
|
|
15
|
+
currentTime = newTime;
|
|
16
|
+
}
|
|
17
|
+
return currentTime;
|
|
18
|
+
};
|
|
19
|
+
const NewDate = function(...args) {
|
|
20
|
+
return Reflect.construct(
|
|
21
|
+
rootRealmGlobal.Date,
|
|
22
|
+
args.length === 0 ? [now()] : args,
|
|
23
|
+
new.target
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
keys.forEach((key) => {
|
|
27
|
+
Reflect.defineProperty(NewDate, key, {
|
|
28
|
+
configurable: false,
|
|
29
|
+
writable: false,
|
|
30
|
+
value: key === "now" ? now : rootRealmGlobal.Date[key]
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return { Date: harden(NewDate) };
|
|
34
|
+
}
|
|
35
|
+
var endowmentModule = {
|
|
36
|
+
names: ["Date"],
|
|
37
|
+
factory: createDate
|
|
38
|
+
};
|
|
39
|
+
var date_default = endowmentModule;
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
date_default
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=chunk-6GHFAQ54.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common/endowments/date.ts"],"sourcesContent":["import { rootRealmGlobal } from '../globalObject';\n\n/**\n * Creates a {@link Date} constructor, with most of the same properties as the global object.\n * The Date.now() function has added noise as to limit its precision and prevent potential timing attacks.\n * The Date constructor uses this now() function to seed itself if no arguments are given to the constructor.\n *\n * @returns A modified {@link Date} constructor with limited precision.\n */\nfunction createDate() {\n const keys = Object.getOwnPropertyNames(\n rootRealmGlobal.Date,\n ) as (keyof typeof Date)[];\n\n let currentTime = 0;\n const now = () => {\n const actual = rootRealmGlobal.Date.now();\n const newTime = Math.round(actual + Math.random());\n if (newTime > currentTime) {\n currentTime = newTime;\n }\n return currentTime;\n };\n\n const NewDate = function (...args: unknown[]) {\n return Reflect.construct(\n rootRealmGlobal.Date,\n args.length === 0 ? [now()] : args,\n new.target,\n );\n } as DateConstructor;\n\n keys.forEach((key) => {\n Reflect.defineProperty(NewDate, key, {\n configurable: false,\n writable: false,\n value: key === 'now' ? now : rootRealmGlobal.Date[key],\n });\n });\n\n return { Date: harden(NewDate) };\n}\n\nconst endowmentModule = {\n names: ['Date'] as const,\n factory: createDate,\n};\n\nexport default endowmentModule;\n"],"mappings":";;;;;AASA,SAAS,aAAa;AACpB,QAAM,OAAO,OAAO;AAAA,IAClB,gBAAgB;AAAA,EAClB;AAEA,MAAI,cAAc;AAClB,QAAM,MAAM,MAAM;AAChB,UAAM,SAAS,gBAAgB,KAAK,IAAI;AACxC,UAAM,UAAU,KAAK,MAAM,SAAS,KAAK,OAAO,CAAC;AACjD,QAAI,UAAU,aAAa;AACzB,oBAAc;AAAA,IAChB;AACA,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,YAAa,MAAiB;AAC5C,WAAO,QAAQ;AAAA,MACb,gBAAgB;AAAA,MAChB,KAAK,WAAW,IAAI,CAAC,IAAI,CAAC,IAAI;AAAA,MAC9B;AAAA,IACF;AAAA,EACF;AAEA,OAAK,QAAQ,CAAC,QAAQ;AACpB,YAAQ,eAAe,SAAS,KAAK;AAAA,MACnC,cAAc;AAAA,MACd,UAAU;AAAA,MACV,OAAO,QAAQ,QAAQ,MAAM,gBAAgB,KAAK,GAAG;AAAA,IACvD,CAAC;AAAA,EACH,CAAC;AAED,SAAO,EAAE,MAAM,OAAO,OAAO,EAAE;AACjC;AAEA,IAAM,kBAAkB;AAAA,EACtB,OAAO,CAAC,MAAM;AAAA,EACd,SAAS;AACX;AAEA,IAAO,eAAQ;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rootRealmGlobal
|
|
3
|
+
} from "./chunk-Y7IEFWZU.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__require
|
|
6
|
+
} from "./chunk-YRZVIDCF.mjs";
|
|
7
|
+
|
|
8
|
+
// src/common/endowments/crypto.ts
|
|
9
|
+
var createCrypto = () => {
|
|
10
|
+
if ("crypto" in rootRealmGlobal && typeof rootRealmGlobal.crypto === "object" && "SubtleCrypto" in rootRealmGlobal && typeof rootRealmGlobal.SubtleCrypto === "function") {
|
|
11
|
+
return {
|
|
12
|
+
crypto: harden(rootRealmGlobal.crypto),
|
|
13
|
+
SubtleCrypto: harden(rootRealmGlobal.SubtleCrypto)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const crypto = __require("crypto").webcrypto;
|
|
17
|
+
return {
|
|
18
|
+
crypto: harden(crypto),
|
|
19
|
+
SubtleCrypto: harden(crypto.subtle.constructor)
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
var endowmentModule = {
|
|
23
|
+
names: ["crypto", "SubtleCrypto"],
|
|
24
|
+
factory: createCrypto
|
|
25
|
+
};
|
|
26
|
+
var crypto_default = endowmentModule;
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
createCrypto,
|
|
30
|
+
crypto_default
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=chunk-A7NJQLUA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common/endowments/crypto.ts"],"sourcesContent":["import { rootRealmGlobal } from '../globalObject';\n\nexport const createCrypto = () => {\n if (\n 'crypto' in rootRealmGlobal &&\n typeof rootRealmGlobal.crypto === 'object' &&\n 'SubtleCrypto' in rootRealmGlobal &&\n typeof rootRealmGlobal.SubtleCrypto === 'function'\n ) {\n return {\n crypto: harden(rootRealmGlobal.crypto),\n SubtleCrypto: harden(rootRealmGlobal.SubtleCrypto),\n };\n }\n // For now, we expose the experimental webcrypto API for Node.js execution environments\n // TODO: Figure out if this is enough long-term or if we should use a polyfill.\n /* eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */\n const crypto = require('crypto').webcrypto;\n return {\n crypto: harden(crypto),\n SubtleCrypto: harden(crypto.subtle.constructor),\n } as const;\n};\n\nconst endowmentModule = {\n names: ['crypto', 'SubtleCrypto'] as const,\n factory: createCrypto,\n};\nexport default endowmentModule;\n"],"mappings":";;;;;;;;AAEO,IAAM,eAAe,MAAM;AAChC,MACE,YAAY,mBACZ,OAAO,gBAAgB,WAAW,YAClC,kBAAkB,mBAClB,OAAO,gBAAgB,iBAAiB,YACxC;AACA,WAAO;AAAA,MACL,QAAQ,OAAO,gBAAgB,MAAM;AAAA,MACrC,cAAc,OAAO,gBAAgB,YAAY;AAAA,IACnD;AAAA,EACF;AAIA,QAAM,SAAS,UAAQ,QAAQ,EAAE;AACjC,SAAO;AAAA,IACL,QAAQ,OAAO,MAAM;AAAA,IACrB,cAAc,OAAO,OAAO,OAAO,WAAW;AAAA,EAChD;AACF;AAEA,IAAM,kBAAkB;AAAA,EACtB,OAAO,CAAC,UAAU,cAAc;AAAA,EAChC,SAAS;AACX;AACA,IAAO,iBAAQ;","names":[]}
|