@metamask/snaps-execution-environments 6.6.1 → 6.7.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 +19 -1
- package/dist/common/BaseSnapExecutor.cjs +436 -0
- package/dist/common/BaseSnapExecutor.cjs.map +1 -0
- package/dist/{types/common/BaseSnapExecutor.d.ts → common/BaseSnapExecutor.d.cts} +8 -6
- package/dist/common/BaseSnapExecutor.d.cts.map +1 -0
- package/dist/common/BaseSnapExecutor.d.mts +70 -0
- package/dist/common/BaseSnapExecutor.d.mts.map +1 -0
- package/dist/common/BaseSnapExecutor.mjs +430 -24
- package/dist/common/BaseSnapExecutor.mjs.map +1 -1
- package/dist/common/commands.cjs +95 -0
- package/dist/common/commands.cjs.map +1 -0
- package/dist/{types/common/commands.d.ts → common/commands.d.cts} +5 -4
- package/dist/common/commands.d.cts.map +1 -0
- package/dist/common/commands.d.mts +31 -0
- package/dist/common/commands.d.mts.map +1 -0
- package/dist/common/commands.mjs +89 -10
- package/dist/common/commands.mjs.map +1 -1
- package/dist/common/endowments/commonEndowmentFactory.cjs +76 -0
- package/dist/common/endowments/commonEndowmentFactory.cjs.map +1 -0
- package/dist/{types/common/endowments/commonEndowmentFactory.d.ts → common/endowments/commonEndowmentFactory.d.cts} +5 -4
- package/dist/common/endowments/commonEndowmentFactory.d.cts.map +1 -0
- package/dist/common/endowments/commonEndowmentFactory.d.mts +26 -0
- package/dist/common/endowments/commonEndowmentFactory.d.mts.map +1 -0
- package/dist/common/endowments/commonEndowmentFactory.mjs +69 -18
- package/dist/common/endowments/commonEndowmentFactory.mjs.map +1 -1
- package/dist/common/endowments/console.cjs +103 -0
- package/dist/common/endowments/console.cjs.map +1 -0
- package/dist/{types/common/endowments/console.d.ts → common/endowments/console.d.cts} +2 -1
- package/dist/common/endowments/console.d.cts.map +1 -0
- package/dist/common/endowments/console.d.mts +46 -0
- package/dist/common/endowments/console.d.mts.map +1 -0
- package/dist/common/endowments/console.mjs +98 -11
- package/dist/common/endowments/console.mjs.map +1 -1
- package/dist/common/endowments/crypto.cjs +30 -0
- package/dist/common/endowments/crypto.cjs.map +1 -0
- package/dist/{types/common/endowments/crypto.d.ts → common/endowments/crypto.d.cts} +1 -0
- package/dist/common/endowments/crypto.d.cts.map +1 -0
- package/dist/common/endowments/crypto.d.mts +13 -0
- package/dist/common/endowments/crypto.d.mts.map +1 -0
- package/dist/common/endowments/crypto.mjs +24 -9
- package/dist/common/endowments/crypto.mjs.map +1 -1
- package/dist/common/endowments/date.cjs +39 -0
- package/dist/common/endowments/date.cjs.map +1 -0
- package/dist/{types/common/endowments/date.d.ts → common/endowments/date.d.cts} +1 -0
- package/dist/common/endowments/date.d.cts.map +1 -0
- package/dist/common/endowments/date.d.mts +16 -0
- package/dist/common/endowments/date.d.mts.map +1 -0
- package/dist/common/endowments/date.mjs +35 -7
- package/dist/common/endowments/date.mjs.map +1 -1
- package/dist/common/endowments/index.cjs +93 -0
- package/dist/common/endowments/index.cjs.map +1 -0
- package/dist/{types/common/endowments/index.d.ts → common/endowments/index.d.cts} +4 -3
- package/dist/common/endowments/index.d.cts.map +1 -0
- package/dist/common/endowments/index.d.mts +29 -0
- package/dist/common/endowments/index.d.mts.map +1 -0
- package/dist/common/endowments/index.mjs +85 -20
- package/dist/common/endowments/index.mjs.map +1 -1
- package/dist/common/endowments/interval.cjs +51 -0
- package/dist/common/endowments/interval.cjs.map +1 -0
- package/dist/{types/common/endowments/interval.d.ts → common/endowments/interval.d.cts} +1 -0
- package/dist/common/endowments/interval.d.cts.map +1 -0
- package/dist/common/endowments/interval.d.mts +10 -0
- package/dist/common/endowments/interval.d.mts.map +1 -0
- package/dist/common/endowments/interval.mjs +47 -6
- package/dist/common/endowments/interval.mjs.map +1 -1
- package/dist/common/endowments/math.cjs +54 -0
- package/dist/common/endowments/math.cjs.map +1 -0
- package/dist/{types/common/endowments/math.d.ts → common/endowments/math.d.cts} +1 -0
- package/dist/common/endowments/math.d.cts.map +1 -0
- package/dist/common/endowments/math.d.mts +61 -0
- package/dist/common/endowments/math.d.mts.map +1 -0
- package/dist/common/endowments/math.mjs +50 -8
- package/dist/common/endowments/math.mjs.map +1 -1
- package/dist/common/endowments/network.cjs +255 -0
- package/dist/common/endowments/network.cjs.map +1 -0
- package/dist/{types/common/endowments/network.d.ts → common/endowments/network.d.cts} +4 -2
- package/dist/common/endowments/network.d.cts.map +1 -0
- package/dist/common/endowments/network.d.mts +25 -0
- package/dist/common/endowments/network.d.mts.map +1 -0
- package/dist/common/endowments/network.mjs +251 -8
- package/dist/common/endowments/network.mjs.map +1 -1
- package/dist/common/endowments/textDecoder.cjs +18 -0
- package/dist/common/endowments/textDecoder.cjs.map +1 -0
- package/dist/{types/common/endowments/textDecoder.d.ts → common/endowments/textDecoder.d.cts} +1 -0
- package/dist/common/endowments/textDecoder.d.cts.map +1 -0
- package/dist/common/endowments/textDecoder.d.mts +11 -0
- package/dist/common/endowments/textDecoder.d.mts.map +1 -0
- package/dist/common/endowments/textDecoder.mjs +14 -6
- package/dist/common/endowments/textDecoder.mjs.map +1 -1
- package/dist/common/endowments/textEncoder.cjs +18 -0
- package/dist/common/endowments/textEncoder.cjs.map +1 -0
- package/dist/{types/common/endowments/textEncoder.d.ts → common/endowments/textEncoder.d.cts} +1 -0
- package/dist/common/endowments/textEncoder.d.cts.map +1 -0
- package/dist/common/endowments/textEncoder.d.mts +11 -0
- package/dist/common/endowments/textEncoder.d.mts.map +1 -0
- package/dist/common/endowments/textEncoder.mjs +14 -6
- package/dist/common/endowments/textEncoder.mjs.map +1 -1
- package/dist/common/endowments/timeout.cjs +53 -0
- package/dist/common/endowments/timeout.cjs.map +1 -0
- package/dist/{types/common/endowments/timeout.d.ts → common/endowments/timeout.d.cts} +1 -0
- package/dist/common/endowments/timeout.d.cts.map +1 -0
- package/dist/common/endowments/timeout.d.mts +10 -0
- package/dist/common/endowments/timeout.d.mts.map +1 -0
- package/dist/common/endowments/timeout.mjs +49 -6
- package/dist/common/endowments/timeout.mjs.map +1 -1
- package/dist/common/globalEvents.cjs +48 -0
- package/dist/common/globalEvents.cjs.map +1 -0
- package/dist/{types/common/globalEvents.d.ts → common/globalEvents.d.cts} +1 -0
- package/dist/common/globalEvents.d.cts.map +1 -0
- package/dist/common/globalEvents.d.mts +21 -0
- package/dist/common/globalEvents.d.mts.map +1 -0
- package/dist/common/globalEvents.mjs +42 -10
- package/dist/common/globalEvents.mjs.map +1 -1
- package/dist/common/globalObject.cjs +50 -0
- package/dist/common/globalObject.cjs.map +1 -0
- package/dist/{types/common/globalObject.d.ts → common/globalObject.d.cts} +1 -0
- package/dist/common/globalObject.d.cts.map +1 -0
- package/dist/common/globalObject.d.mts +10 -0
- package/dist/common/globalObject.d.mts.map +1 -0
- package/dist/common/globalObject.mjs +45 -9
- package/dist/common/globalObject.mjs.map +1 -1
- package/dist/common/lockdown/lockdown-events.cjs +60 -0
- package/dist/common/lockdown/lockdown-events.cjs.map +1 -0
- package/dist/{types/common/lockdown/lockdown-events.d.ts → common/lockdown/lockdown-events.d.cts} +1 -0
- package/dist/common/lockdown/lockdown-events.d.cts.map +1 -0
- package/dist/common/lockdown/lockdown-events.d.mts +5 -0
- package/dist/common/lockdown/lockdown-events.d.mts.map +1 -0
- package/dist/common/lockdown/lockdown-events.mjs +55 -7
- package/dist/common/lockdown/lockdown-events.mjs.map +1 -1
- package/dist/common/lockdown/lockdown-more.cjs +89 -0
- package/dist/common/lockdown/lockdown-more.cjs.map +1 -0
- package/dist/{types/common/lockdown/lockdown-more.d.ts → common/lockdown/lockdown-more.d.cts} +1 -0
- package/dist/common/lockdown/lockdown-more.d.cts.map +1 -0
- package/dist/common/lockdown/lockdown-more.d.mts +23 -0
- package/dist/common/lockdown/lockdown-more.d.mts.map +1 -0
- package/dist/common/lockdown/lockdown-more.mjs +84 -7
- package/dist/common/lockdown/lockdown-more.mjs.map +1 -1
- package/dist/common/lockdown/lockdown.cjs +29 -0
- package/dist/common/lockdown/lockdown.cjs.map +1 -0
- package/dist/{types/common/lockdown/lockdown.d.ts → common/lockdown/lockdown.d.cts} +1 -0
- package/dist/common/lockdown/lockdown.d.cts.map +1 -0
- package/dist/common/lockdown/lockdown.d.mts +8 -0
- package/dist/common/lockdown/lockdown.d.mts.map +1 -0
- package/dist/common/lockdown/lockdown.mjs +22 -19
- package/dist/common/lockdown/lockdown.mjs.map +1 -1
- package/dist/common/sortParams.cjs +35 -0
- package/dist/common/sortParams.cjs.map +1 -0
- package/dist/{types/common/sortParams.d.ts → common/sortParams.d.cts} +2 -1
- package/dist/common/sortParams.d.cts.map +1 -0
- package/dist/common/sortParams.d.mts +17 -0
- package/dist/common/sortParams.d.mts.map +1 -0
- package/dist/common/sortParams.mjs +29 -6
- package/dist/common/sortParams.mjs.map +1 -1
- package/dist/common/utils.cjs +156 -0
- package/dist/common/utils.cjs.map +1 -0
- package/dist/{types/common/utils.d.ts → common/utils.d.cts} +2 -1
- package/dist/common/utils.d.cts.map +1 -0
- package/dist/common/utils.d.mts +50 -0
- package/dist/common/utils.d.mts.map +1 -0
- package/dist/common/utils.mjs +146 -20
- package/dist/common/utils.mjs.map +1 -1
- package/dist/common/validation.cjs +137 -0
- package/dist/common/validation.cjs.map +1 -0
- package/dist/{types/common/validation.d.ts → common/validation.d.cts} +37 -36
- package/dist/common/validation.d.cts.map +1 -0
- package/dist/common/validation.d.mts +199 -0
- package/dist/common/validation.d.mts.map +1 -0
- package/dist/common/validation.mjs +127 -37
- package/dist/common/validation.mjs.map +1 -1
- package/dist/iframe/IFrameSnapExecutor.cjs +42 -0
- package/dist/iframe/IFrameSnapExecutor.cjs.map +1 -0
- package/dist/{types/iframe/IFrameSnapExecutor.d.ts → iframe/IFrameSnapExecutor.d.cts} +3 -2
- package/dist/iframe/IFrameSnapExecutor.d.cts.map +1 -0
- package/dist/iframe/IFrameSnapExecutor.d.mts +14 -0
- package/dist/iframe/IFrameSnapExecutor.d.mts.map +1 -0
- package/dist/iframe/IFrameSnapExecutor.mjs +42 -26
- package/dist/iframe/IFrameSnapExecutor.mjs.map +1 -1
- package/dist/iframe/index.cjs +10 -0
- package/dist/iframe/index.cjs.map +1 -0
- package/dist/iframe/index.d.cts +2 -0
- package/dist/iframe/index.d.cts.map +1 -0
- package/dist/iframe/index.d.mts +2 -0
- package/dist/iframe/index.d.mts.map +1 -0
- package/dist/iframe/index.mjs +4 -31
- package/dist/iframe/index.mjs.map +1 -1
- package/dist/index.cjs +18 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1 -8
- package/dist/index.mjs.map +1 -1
- package/dist/logging.cjs +13 -0
- package/dist/logging.cjs.map +1 -0
- package/dist/{types/logging.d.ts → logging.d.cts} +1 -0
- package/dist/logging.d.cts.map +1 -0
- package/dist/logging.d.mts +9 -0
- package/dist/logging.d.mts.map +1 -0
- package/dist/logging.mjs +9 -7
- package/dist/logging.mjs.map +1 -1
- package/dist/node-process/ChildProcessSnapExecutor.cjs +30 -0
- package/dist/node-process/ChildProcessSnapExecutor.cjs.map +1 -0
- package/dist/{types/node-process/ChildProcessSnapExecutor.d.ts → node-process/ChildProcessSnapExecutor.d.cts} +2 -1
- package/dist/node-process/ChildProcessSnapExecutor.d.cts.map +1 -0
- package/dist/node-process/ChildProcessSnapExecutor.d.mts +5 -0
- package/dist/node-process/ChildProcessSnapExecutor.d.mts.map +1 -0
- package/dist/node-process/ChildProcessSnapExecutor.mjs +30 -26
- package/dist/node-process/ChildProcessSnapExecutor.mjs.map +1 -1
- package/dist/node-process/index.cjs +8 -0
- package/dist/node-process/index.cjs.map +1 -0
- package/dist/node-process/index.d.cts +2 -0
- package/dist/node-process/index.d.cts.map +1 -0
- package/dist/node-process/index.d.mts +2 -0
- package/dist/node-process/index.d.mts.map +1 -0
- package/dist/node-process/index.mjs +3 -28
- package/dist/node-process/index.mjs.map +1 -1
- package/dist/node-thread/ThreadSnapExecutor.cjs +30 -0
- package/dist/node-thread/ThreadSnapExecutor.cjs.map +1 -0
- package/dist/node-thread/ThreadSnapExecutor.d.cts +5 -0
- package/dist/node-thread/ThreadSnapExecutor.d.cts.map +1 -0
- package/dist/node-thread/ThreadSnapExecutor.d.mts +5 -0
- package/dist/node-thread/ThreadSnapExecutor.d.mts.map +1 -0
- package/dist/node-thread/ThreadSnapExecutor.mjs +30 -26
- package/dist/node-thread/ThreadSnapExecutor.mjs.map +1 -1
- package/dist/node-thread/index.cjs +8 -0
- package/dist/node-thread/index.cjs.map +1 -0
- package/dist/node-thread/index.d.cts +2 -0
- package/dist/node-thread/index.d.cts.map +1 -0
- package/dist/node-thread/index.d.mts +2 -0
- package/dist/node-thread/index.d.mts.map +1 -0
- package/dist/node-thread/index.mjs +3 -28
- package/dist/node-thread/index.mjs.map +1 -1
- package/dist/proxy/ProxySnapExecutor.cjs +112 -0
- package/dist/proxy/ProxySnapExecutor.cjs.map +1 -0
- package/dist/{types/proxy/ProxySnapExecutor.d.ts → proxy/ProxySnapExecutor.d.cts} +4 -3
- package/dist/proxy/ProxySnapExecutor.d.cts.map +1 -0
- package/dist/proxy/ProxySnapExecutor.d.mts +36 -0
- package/dist/proxy/ProxySnapExecutor.d.mts.map +1 -0
- package/dist/proxy/ProxySnapExecutor.mjs +104 -6
- package/dist/proxy/ProxySnapExecutor.mjs.map +1 -1
- package/dist/proxy/index.cjs +18 -0
- package/dist/proxy/index.cjs.map +1 -0
- package/dist/proxy/index.d.cts +2 -0
- package/dist/proxy/index.d.cts.map +1 -0
- package/dist/proxy/index.d.mts +2 -0
- package/dist/proxy/index.d.mts.map +1 -0
- package/dist/proxy/index.mjs +1 -8
- package/dist/proxy/index.mjs.map +1 -1
- package/dist/webview/WebViewExecutorStream.cjs +79 -0
- package/dist/webview/WebViewExecutorStream.cjs.map +1 -0
- package/dist/{types/webview/WebViewExecutorStream.d.ts → webview/WebViewExecutorStream.d.cts} +3 -2
- package/dist/webview/WebViewExecutorStream.d.cts.map +1 -0
- package/dist/webview/WebViewExecutorStream.d.mts +33 -0
- package/dist/webview/WebViewExecutorStream.d.mts.map +1 -0
- package/dist/webview/WebViewExecutorStream.mjs +74 -6
- package/dist/webview/WebViewExecutorStream.mjs.map +1 -1
- package/dist/webview/index.cjs +16 -0
- package/dist/webview/index.cjs.map +1 -0
- package/dist/webview/index.d.cts +2 -0
- package/dist/webview/index.d.cts.map +1 -0
- package/dist/webview/index.d.mts +2 -0
- package/dist/webview/index.d.mts.map +1 -0
- package/dist/webview/index.mjs +9 -21
- package/dist/webview/index.mjs.map +1 -1
- package/dist/webworker/executor/WebWorkerSnapExecutor.cjs +37 -0
- package/dist/webworker/executor/WebWorkerSnapExecutor.cjs.map +1 -0
- package/dist/{types/webworker/executor/WebWorkerSnapExecutor.d.ts → webworker/executor/WebWorkerSnapExecutor.d.cts} +3 -2
- package/dist/webworker/executor/WebWorkerSnapExecutor.d.cts.map +1 -0
- package/dist/webworker/executor/WebWorkerSnapExecutor.d.mts +14 -0
- package/dist/webworker/executor/WebWorkerSnapExecutor.d.mts.map +1 -0
- package/dist/webworker/executor/WebWorkerSnapExecutor.mjs +37 -26
- package/dist/webworker/executor/WebWorkerSnapExecutor.mjs.map +1 -1
- package/dist/webworker/executor/index.cjs +10 -0
- package/dist/webworker/executor/index.cjs.map +1 -0
- package/dist/webworker/executor/index.d.cts +2 -0
- package/dist/webworker/executor/index.d.cts.map +1 -0
- package/dist/webworker/executor/index.d.mts +2 -0
- package/dist/webworker/executor/index.d.mts.map +1 -0
- package/dist/webworker/executor/index.mjs +4 -31
- package/dist/webworker/executor/index.mjs.map +1 -1
- package/dist/webworker/pool/WebWorkerPool.cjs +168 -0
- package/dist/webworker/pool/WebWorkerPool.cjs.map +1 -0
- package/dist/{types/webworker/pool/WebWorkerPool.d.ts → webworker/pool/WebWorkerPool.d.cts} +4 -3
- package/dist/webworker/pool/WebWorkerPool.d.cts.map +1 -0
- package/dist/webworker/pool/WebWorkerPool.d.mts +24 -0
- package/dist/webworker/pool/WebWorkerPool.d.mts.map +1 -0
- package/dist/webworker/pool/WebWorkerPool.mjs +163 -6
- package/dist/webworker/pool/WebWorkerPool.mjs.map +1 -1
- package/dist/webworker/pool/index.cjs +10 -0
- package/dist/webworker/pool/index.cjs.map +1 -0
- package/dist/webworker/pool/index.d.cts +2 -0
- package/dist/webworker/pool/index.d.cts.map +1 -0
- package/dist/webworker/pool/index.d.mts +2 -0
- package/dist/webworker/pool/index.d.mts.map +1 -0
- package/dist/webworker/pool/index.mjs +4 -12
- package/dist/webworker/pool/index.mjs.map +1 -1
- package/package.json +23 -20
- package/dist/browserify/iframe/bundle.js +0 -9
- package/dist/browserify/iframe/index.html +0 -13394
- package/dist/browserify/node-process/bundle.js +0 -13390
- package/dist/browserify/node-thread/bundle.js +0 -13390
- package/dist/browserify/webview/index.html +0 -13402
- package/dist/browserify/worker-executor/bundle.js +0 -13392
- package/dist/browserify/worker-pool/bundle.js +0 -9
- package/dist/browserify/worker-pool/index.html +0 -13394
- package/dist/chunk-2VA6RAEE.js +0 -30
- package/dist/chunk-2VA6RAEE.js.map +0 -1
- package/dist/chunk-3JCT4MWT.js +0 -108
- package/dist/chunk-3JCT4MWT.js.map +0 -1
- package/dist/chunk-46LW37FK.js +0 -144
- package/dist/chunk-46LW37FK.js.map +0 -1
- package/dist/chunk-4COIRXF5.js +0 -86
- package/dist/chunk-4COIRXF5.js.map +0 -1
- package/dist/chunk-4XRZLEKU.js +0 -49
- package/dist/chunk-4XRZLEKU.js.map +0 -1
- package/dist/chunk-53ZULHPK.mjs +0 -16
- package/dist/chunk-53ZULHPK.mjs.map +0 -1
- package/dist/chunk-5DEV3QQU.mjs +0 -12
- package/dist/chunk-5DEV3QQU.mjs.map +0 -1
- package/dist/chunk-5STN3QCA.js +0 -183
- package/dist/chunk-5STN3QCA.js.map +0 -1
- package/dist/chunk-72KFTWQZ.mjs +0 -45
- package/dist/chunk-72KFTWQZ.mjs.map +0 -1
- package/dist/chunk-75RCH4ZX.mjs +0 -151
- package/dist/chunk-75RCH4ZX.mjs.map +0 -1
- package/dist/chunk-7AJWXSDQ.mjs +0 -73
- package/dist/chunk-7AJWXSDQ.mjs.map +0 -1
- package/dist/chunk-7MMUJJQ2.js +0 -151
- package/dist/chunk-7MMUJJQ2.js.map +0 -1
- package/dist/chunk-BCBKEUCG.mjs +0 -38
- package/dist/chunk-BCBKEUCG.mjs.map +0 -1
- package/dist/chunk-BEJDC4XI.mjs +0 -40
- package/dist/chunk-BEJDC4XI.mjs.map +0 -1
- package/dist/chunk-BLHIYDO5.js +0 -40
- package/dist/chunk-BLHIYDO5.js.map +0 -1
- package/dist/chunk-BTEAZZKP.mjs +0 -24
- package/dist/chunk-BTEAZZKP.mjs.map +0 -1
- package/dist/chunk-BVRVUIJB.mjs +0 -67
- package/dist/chunk-BVRVUIJB.mjs.map +0 -1
- package/dist/chunk-CV5LC4PP.js +0 -24
- package/dist/chunk-CV5LC4PP.js.map +0 -1
- package/dist/chunk-DKDTGAFK.js +0 -67
- package/dist/chunk-DKDTGAFK.js.map +0 -1
- package/dist/chunk-DLLLH5HN.js +0 -26
- package/dist/chunk-DLLLH5HN.js.map +0 -1
- package/dist/chunk-EXN2TFDJ.js +0 -38
- package/dist/chunk-EXN2TFDJ.js.map +0 -1
- package/dist/chunk-FOEAIF5U.js +0 -16
- package/dist/chunk-FOEAIF5U.js.map +0 -1
- package/dist/chunk-FUPEJT7B.js +0 -82
- package/dist/chunk-FUPEJT7B.js.map +0 -1
- package/dist/chunk-HCXTK3PR.js +0 -472
- package/dist/chunk-HCXTK3PR.js.map +0 -1
- package/dist/chunk-HGLRZZ56.js +0 -32
- package/dist/chunk-HGLRZZ56.js.map +0 -1
- package/dist/chunk-HL2TTKF3.mjs +0 -144
- package/dist/chunk-HL2TTKF3.mjs.map +0 -1
- package/dist/chunk-HWS4QSOC.mjs +0 -16
- package/dist/chunk-HWS4QSOC.mjs.map +0 -1
- package/dist/chunk-HXKBUIYS.js +0 -262
- package/dist/chunk-HXKBUIYS.js.map +0 -1
- package/dist/chunk-HXUJHX3E.mjs +0 -33
- package/dist/chunk-HXUJHX3E.mjs.map +0 -1
- package/dist/chunk-I5G4YFHM.js +0 -73
- package/dist/chunk-I5G4YFHM.js.map +0 -1
- package/dist/chunk-IX5S3V47.mjs +0 -26
- package/dist/chunk-IX5S3V47.mjs.map +0 -1
- package/dist/chunk-JDWYJ5UI.mjs +0 -33
- package/dist/chunk-JDWYJ5UI.mjs.map +0 -1
- package/dist/chunk-JOT5JH42.js +0 -52
- package/dist/chunk-JOT5JH42.js.map +0 -1
- package/dist/chunk-KEAB7ZVV.js +0 -50
- package/dist/chunk-KEAB7ZVV.js.map +0 -1
- package/dist/chunk-LO5ORVRC.js +0 -16
- package/dist/chunk-LO5ORVRC.js.map +0 -1
- package/dist/chunk-M3OBSGHF.mjs +0 -472
- package/dist/chunk-M3OBSGHF.mjs.map +0 -1
- package/dist/chunk-MCXWFCGV.js +0 -1
- package/dist/chunk-MCXWFCGV.js.map +0 -1
- package/dist/chunk-MIWGLICQ.mjs +0 -108
- package/dist/chunk-MIWGLICQ.mjs.map +0 -1
- package/dist/chunk-MMYM63NH.mjs +0 -82
- package/dist/chunk-MMYM63NH.mjs.map +0 -1
- package/dist/chunk-MS2LQQYH.js +0 -38
- package/dist/chunk-MS2LQQYH.js.map +0 -1
- package/dist/chunk-MXNMMTJW.mjs +0 -51
- package/dist/chunk-MXNMMTJW.mjs.map +0 -1
- package/dist/chunk-OBT45IWW.js +0 -92
- package/dist/chunk-OBT45IWW.js.map +0 -1
- package/dist/chunk-OCNPLHS2.js +0 -51
- package/dist/chunk-OCNPLHS2.js.map +0 -1
- package/dist/chunk-ODICKSGZ.mjs +0 -86
- package/dist/chunk-ODICKSGZ.mjs.map +0 -1
- package/dist/chunk-Q42NNJFY.mjs +0 -32
- package/dist/chunk-Q42NNJFY.mjs.map +0 -1
- package/dist/chunk-QZC2X6NG.js +0 -44
- package/dist/chunk-QZC2X6NG.js.map +0 -1
- package/dist/chunk-RACRYFWM.js +0 -45
- package/dist/chunk-RACRYFWM.js.map +0 -1
- package/dist/chunk-RD2APLK5.js +0 -33
- package/dist/chunk-RD2APLK5.js.map +0 -1
- package/dist/chunk-S5NWI5Z7.mjs +0 -50
- package/dist/chunk-S5NWI5Z7.mjs.map +0 -1
- package/dist/chunk-S7257EN3.mjs +0 -49
- package/dist/chunk-S7257EN3.mjs.map +0 -1
- package/dist/chunk-TSEAPB7L.mjs +0 -1
- package/dist/chunk-TSEAPB7L.mjs.map +0 -1
- package/dist/chunk-UOPIRTJX.mjs +0 -44
- package/dist/chunk-UOPIRTJX.mjs.map +0 -1
- package/dist/chunk-V76DI2XM.mjs +0 -183
- package/dist/chunk-V76DI2XM.mjs.map +0 -1
- package/dist/chunk-W7EDURT5.mjs +0 -92
- package/dist/chunk-W7EDURT5.mjs.map +0 -1
- package/dist/chunk-XPCW7TKM.mjs +0 -262
- package/dist/chunk-XPCW7TKM.mjs.map +0 -1
- package/dist/chunk-Y7AK2VVC.mjs +0 -52
- package/dist/chunk-Y7AK2VVC.mjs.map +0 -1
- package/dist/chunk-YRZVIDCF.mjs +0 -38
- package/dist/chunk-YRZVIDCF.mjs.map +0 -1
- package/dist/chunk-Z7BOREC4.js +0 -12
- package/dist/chunk-Z7BOREC4.js.map +0 -1
- package/dist/chunk-ZAYDLP42.js +0 -33
- package/dist/chunk-ZAYDLP42.js.map +0 -1
- package/dist/chunk-ZNTCZK7J.mjs +0 -30
- package/dist/chunk-ZNTCZK7J.mjs.map +0 -1
- package/dist/common/BaseSnapExecutor.js +0 -26
- package/dist/common/BaseSnapExecutor.js.map +0 -1
- package/dist/common/commands.js +0 -11
- package/dist/common/commands.js.map +0 -1
- package/dist/common/endowments/commonEndowmentFactory.js +0 -20
- package/dist/common/endowments/commonEndowmentFactory.js.map +0 -1
- package/dist/common/endowments/console.js +0 -13
- package/dist/common/endowments/console.js.map +0 -1
- package/dist/common/endowments/crypto.js +0 -11
- package/dist/common/endowments/crypto.js.map +0 -1
- package/dist/common/endowments/date.js +0 -9
- package/dist/common/endowments/date.js.map +0 -1
- package/dist/common/endowments/index.js +0 -21
- package/dist/common/endowments/index.js.map +0 -1
- package/dist/common/endowments/interval.js +0 -8
- package/dist/common/endowments/interval.js.map +0 -1
- package/dist/common/endowments/math.js +0 -10
- package/dist/common/endowments/math.js.map +0 -1
- package/dist/common/endowments/network.js +0 -10
- package/dist/common/endowments/network.js.map +0 -1
- package/dist/common/endowments/textDecoder.js +0 -8
- package/dist/common/endowments/textDecoder.js.map +0 -1
- package/dist/common/endowments/textEncoder.js +0 -8
- package/dist/common/endowments/textEncoder.js.map +0 -1
- package/dist/common/endowments/timeout.js +0 -8
- package/dist/common/endowments/timeout.js.map +0 -1
- package/dist/common/globalEvents.js +0 -11
- package/dist/common/globalEvents.js.map +0 -1
- package/dist/common/globalObject.js +0 -10
- package/dist/common/globalObject.js.map +0 -1
- package/dist/common/lockdown/lockdown-events.js +0 -8
- package/dist/common/lockdown/lockdown-events.js.map +0 -1
- package/dist/common/lockdown/lockdown-more.js +0 -8
- package/dist/common/lockdown/lockdown-more.js.map +0 -1
- package/dist/common/lockdown/lockdown.js +0 -22
- package/dist/common/lockdown/lockdown.js.map +0 -1
- package/dist/common/sortParams.js +0 -8
- package/dist/common/sortParams.js.map +0 -1
- package/dist/common/utils.js +0 -21
- package/dist/common/utils.js.map +0 -1
- package/dist/common/validation.js +0 -38
- package/dist/common/validation.js.map +0 -1
- package/dist/globals.d.js +0 -1
- package/dist/globals.d.js.map +0 -1
- package/dist/globals.d.mjs +0 -1
- package/dist/globals.d.mjs.map +0 -1
- package/dist/iframe/IFrameSnapExecutor.js +0 -27
- package/dist/iframe/IFrameSnapExecutor.js.map +0 -1
- package/dist/iframe/index.js +0 -35
- package/dist/iframe/index.js.map +0 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +0 -1
- package/dist/logging.js +0 -8
- package/dist/logging.js.map +0 -1
- package/dist/node-process/ChildProcessSnapExecutor.js +0 -27
- package/dist/node-process/ChildProcessSnapExecutor.js.map +0 -1
- package/dist/node-process/index.js +0 -31
- package/dist/node-process/index.js.map +0 -1
- package/dist/node-thread/ThreadSnapExecutor.js +0 -27
- package/dist/node-thread/ThreadSnapExecutor.js.map +0 -1
- package/dist/node-thread/index.js +0 -31
- package/dist/node-thread/index.js.map +0 -1
- package/dist/proxy/ProxySnapExecutor.js +0 -8
- package/dist/proxy/ProxySnapExecutor.js.map +0 -1
- package/dist/proxy/index.js +0 -9
- package/dist/proxy/index.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/iframe/index.d.ts +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/node-process/index.d.ts +0 -1
- package/dist/types/node-thread/ThreadSnapExecutor.d.ts +0 -4
- package/dist/types/node-thread/index.d.ts +0 -1
- package/dist/types/proxy/index.d.ts +0 -1
- package/dist/types/vendor/global.d.js +0 -1
- package/dist/types/vendor/global.d.js.map +0 -1
- package/dist/types/vendor/global.d.mjs +0 -1
- package/dist/types/vendor/global.d.mjs.map +0 -1
- package/dist/types/vendor/providers.d.js +0 -1
- package/dist/types/vendor/providers.d.js.map +0 -1
- package/dist/types/vendor/providers.d.mjs +0 -1
- package/dist/types/vendor/providers.d.mjs.map +0 -1
- package/dist/types/vendor/readable-stream.d.js +0 -1
- package/dist/types/vendor/readable-stream.d.js.map +0 -1
- package/dist/types/vendor/readable-stream.d.mjs +0 -1
- package/dist/types/vendor/readable-stream.d.mjs.map +0 -1
- package/dist/types/webview/index.d.ts +0 -1
- package/dist/types/webworker/executor/index.d.ts +0 -1
- package/dist/types/webworker/pool/index.d.ts +0 -1
- package/dist/webview/WebViewExecutorStream.js +0 -8
- package/dist/webview/WebViewExecutorStream.js.map +0 -1
- package/dist/webview/index.js +0 -26
- package/dist/webview/index.js.map +0 -1
- package/dist/webworker/executor/WebWorkerSnapExecutor.js +0 -27
- package/dist/webworker/executor/WebWorkerSnapExecutor.js.map +0 -1
- package/dist/webworker/executor/index.js +0 -35
- package/dist/webworker/executor/index.js.map +0 -1
- package/dist/webworker/pool/WebWorkerPool.js +0 -8
- package/dist/webworker/pool/WebWorkerPool.js.map +0 -1
- package/dist/webworker/pool/index.js +0 -16
- package/dist/webworker/pool/index.js.map +0 -1
|
@@ -1,13 +1,100 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { assert } from "@metamask/utils";
|
|
2
|
+
import { rootRealmGlobal } from "../globalObject.mjs";
|
|
3
|
+
export const consoleAttenuatedMethods = new Set([
|
|
4
|
+
'log',
|
|
5
|
+
'assert',
|
|
6
|
+
'error',
|
|
7
|
+
'debug',
|
|
8
|
+
'info',
|
|
9
|
+
'warn',
|
|
10
|
+
]);
|
|
11
|
+
/**
|
|
12
|
+
* A set of all the `console` values that will be passed to the snap. This has
|
|
13
|
+
* all the values that are available in both the browser and Node.js.
|
|
14
|
+
*/
|
|
15
|
+
export const consoleMethods = new Set([
|
|
16
|
+
'debug',
|
|
17
|
+
'error',
|
|
18
|
+
'info',
|
|
19
|
+
'log',
|
|
20
|
+
'warn',
|
|
21
|
+
'dir',
|
|
22
|
+
'dirxml',
|
|
23
|
+
'table',
|
|
24
|
+
'trace',
|
|
25
|
+
'group',
|
|
26
|
+
'groupCollapsed',
|
|
27
|
+
'groupEnd',
|
|
28
|
+
'clear',
|
|
29
|
+
'count',
|
|
30
|
+
'countReset',
|
|
31
|
+
'assert',
|
|
32
|
+
'profile',
|
|
33
|
+
'profileEnd',
|
|
34
|
+
'time',
|
|
35
|
+
'timeLog',
|
|
36
|
+
'timeEnd',
|
|
37
|
+
'timeStamp',
|
|
38
|
+
'context',
|
|
39
|
+
]);
|
|
40
|
+
const consoleFunctions = ['log', 'error', 'debug', 'info', 'warn'];
|
|
41
|
+
/**
|
|
42
|
+
* Gets the appropriate (prepended) message to pass to one of the attenuated
|
|
43
|
+
* method calls.
|
|
44
|
+
*
|
|
45
|
+
* @param snapId - Id of the snap that we're getting a message for.
|
|
46
|
+
* @param message - The id of the snap that will interact with the endowment.
|
|
47
|
+
* @param args - The array of additional arguments.
|
|
48
|
+
* @returns An array of arguments to be passed into an attenuated console method call.
|
|
49
|
+
*/
|
|
50
|
+
function getMessage(snapId, message, ...args) {
|
|
51
|
+
const prefix = `[Snap: ${snapId}]`;
|
|
52
|
+
// If the first argument is a string, prepend the prefix to the message, and keep the
|
|
53
|
+
// rest of the arguments as-is.
|
|
54
|
+
if (typeof message === 'string') {
|
|
55
|
+
return [`${prefix} ${message}`, ...args];
|
|
56
|
+
}
|
|
57
|
+
// Otherwise, the `message` is an object, array, etc., so add the prefix as a separate
|
|
58
|
+
// message to the arguments.
|
|
59
|
+
return [prefix, message, ...args];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a a {@link console} object, with the same properties as the global
|
|
63
|
+
* {@link console} object, but with some methods replaced.
|
|
64
|
+
*
|
|
65
|
+
* @param options - Factory options used in construction of the endowment.
|
|
66
|
+
* @param options.snapId - The id of the snap that will interact with the endowment.
|
|
67
|
+
* @returns The {@link console} object with the replaced methods.
|
|
68
|
+
*/
|
|
69
|
+
function createConsole({ snapId } = {}) {
|
|
70
|
+
assert(snapId !== undefined);
|
|
71
|
+
const keys = Object.getOwnPropertyNames(rootRealmGlobal.console);
|
|
72
|
+
const attenuatedConsole = keys.reduce((target, key) => {
|
|
73
|
+
if (consoleMethods.has(key) && !consoleAttenuatedMethods.has(key)) {
|
|
74
|
+
return { ...target, [key]: rootRealmGlobal.console[key] };
|
|
75
|
+
}
|
|
76
|
+
return target;
|
|
77
|
+
}, {});
|
|
78
|
+
return harden({
|
|
79
|
+
console: {
|
|
80
|
+
...attenuatedConsole,
|
|
81
|
+
assert: (value, message, ...optionalParams) => {
|
|
82
|
+
rootRealmGlobal.console.assert(value, ...getMessage(snapId, message, ...optionalParams));
|
|
83
|
+
},
|
|
84
|
+
...consoleFunctions.reduce((target, key) => {
|
|
85
|
+
return {
|
|
86
|
+
...target,
|
|
87
|
+
[key]: (message, ...optionalParams) => {
|
|
88
|
+
rootRealmGlobal.console[key](...getMessage(snapId, message, ...optionalParams));
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}, {}),
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const endowmentModule = {
|
|
96
|
+
names: ['console'],
|
|
97
|
+
factory: createConsole,
|
|
12
98
|
};
|
|
99
|
+
export default endowmentModule;
|
|
13
100
|
//# sourceMappingURL=console.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"console.mjs","sourceRoot":"","sources":["../../../src/common/endowments/console.ts"],"names":[],"mappings":"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","sourcesContent":["import { assert } from '@metamask/utils';\n\nimport { rootRealmGlobal } from '../globalObject';\nimport type { EndowmentFactoryOptions } from './commonEndowmentFactory';\n\nexport const consoleAttenuatedMethods = new Set([\n 'log',\n 'assert',\n 'error',\n 'debug',\n 'info',\n 'warn',\n]);\n\n/**\n * A set of all the `console` values that will be passed to the snap. This has\n * all the values that are available in both the browser and Node.js.\n */\nexport const consoleMethods = new Set([\n 'debug',\n 'error',\n 'info',\n 'log',\n 'warn',\n 'dir',\n 'dirxml',\n 'table',\n 'trace',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'clear',\n 'count',\n 'countReset',\n 'assert',\n 'profile',\n 'profileEnd',\n 'time',\n 'timeLog',\n 'timeEnd',\n 'timeStamp',\n 'context',\n]);\n\nconst consoleFunctions = ['log', 'error', 'debug', 'info', 'warn'] as const;\n\ntype ConsoleFunctions = {\n [Key in (typeof consoleFunctions)[number]]: (typeof rootRealmGlobal.console)[Key];\n};\n\n/**\n * Gets the appropriate (prepended) message to pass to one of the attenuated\n * method calls.\n *\n * @param snapId - Id of the snap that we're getting a message for.\n * @param message - The id of the snap that will interact with the endowment.\n * @param args - The array of additional arguments.\n * @returns An array of arguments to be passed into an attenuated console method call.\n */\nfunction getMessage(snapId: string, message: unknown, ...args: unknown[]) {\n const prefix = `[Snap: ${snapId}]`;\n\n // If the first argument is a string, prepend the prefix to the message, and keep the\n // rest of the arguments as-is.\n if (typeof message === 'string') {\n return [`${prefix} ${message}`, ...args];\n }\n\n // Otherwise, the `message` is an object, array, etc., so add the prefix as a separate\n // message to the arguments.\n return [prefix, message, ...args];\n}\n\n/**\n * Create a a {@link console} object, with the same properties as the global\n * {@link console} object, but with some methods replaced.\n *\n * @param options - Factory options used in construction of the endowment.\n * @param options.snapId - The id of the snap that will interact with the endowment.\n * @returns The {@link console} object with the replaced methods.\n */\nfunction createConsole({ snapId }: EndowmentFactoryOptions = {}) {\n assert(snapId !== undefined);\n const keys = Object.getOwnPropertyNames(\n rootRealmGlobal.console,\n ) as (keyof typeof console)[];\n\n const attenuatedConsole = keys.reduce((target, key) => {\n if (consoleMethods.has(key) && !consoleAttenuatedMethods.has(key)) {\n return { ...target, [key]: rootRealmGlobal.console[key] };\n }\n\n return target;\n }, {});\n\n return harden({\n console: {\n ...attenuatedConsole,\n assert: (\n value: any,\n message?: string | undefined,\n ...optionalParams: any[]\n ) => {\n rootRealmGlobal.console.assert(\n value,\n ...getMessage(snapId, message, ...optionalParams),\n );\n },\n ...consoleFunctions.reduce<ConsoleFunctions>((target, key) => {\n return {\n ...target,\n [key]: (message?: unknown, ...optionalParams: any[]) => {\n rootRealmGlobal.console[key](\n ...getMessage(snapId, message, ...optionalParams),\n );\n },\n };\n }, {} as ConsoleFunctions),\n },\n });\n}\n\nconst endowmentModule = {\n names: ['console'] as const,\n factory: createConsole,\n};\n\nexport default endowmentModule;\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCrypto = void 0;
|
|
4
|
+
const globalObject_1 = require("../globalObject.cjs");
|
|
5
|
+
const createCrypto = () => {
|
|
6
|
+
if ('crypto' in globalObject_1.rootRealmGlobal &&
|
|
7
|
+
typeof globalObject_1.rootRealmGlobal.crypto === 'object' &&
|
|
8
|
+
'SubtleCrypto' in globalObject_1.rootRealmGlobal &&
|
|
9
|
+
typeof globalObject_1.rootRealmGlobal.SubtleCrypto === 'function') {
|
|
10
|
+
return {
|
|
11
|
+
crypto: harden(globalObject_1.rootRealmGlobal.crypto),
|
|
12
|
+
SubtleCrypto: harden(globalObject_1.rootRealmGlobal.SubtleCrypto),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
// For now, we expose the experimental webcrypto API for Node.js execution environments
|
|
16
|
+
// TODO: Figure out if this is enough long-term or if we should use a polyfill.
|
|
17
|
+
/* eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */
|
|
18
|
+
const crypto = require('crypto').webcrypto;
|
|
19
|
+
return {
|
|
20
|
+
crypto: harden(crypto),
|
|
21
|
+
SubtleCrypto: harden(crypto.subtle.constructor),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.createCrypto = createCrypto;
|
|
25
|
+
const endowmentModule = {
|
|
26
|
+
names: ['crypto', 'SubtleCrypto'],
|
|
27
|
+
factory: exports.createCrypto,
|
|
28
|
+
};
|
|
29
|
+
exports.default = endowmentModule;
|
|
30
|
+
//# sourceMappingURL=crypto.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.cjs","sourceRoot":"","sources":["../../../src/common/endowments/crypto.ts"],"names":[],"mappings":";;;AAAA,sDAAkD;AAE3C,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,IACE,QAAQ,IAAI,8BAAe;QAC3B,OAAO,8BAAe,CAAC,MAAM,KAAK,QAAQ;QAC1C,cAAc,IAAI,8BAAe;QACjC,OAAO,8BAAe,CAAC,YAAY,KAAK,UAAU,EAClD,CAAC;QACD,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,8BAAe,CAAC,MAAM,CAAC;YACtC,YAAY,EAAE,MAAM,CAAC,8BAAe,CAAC,YAAY,CAAC;SACnD,CAAC;IACJ,CAAC;IACD,uFAAuF;IACvF,+EAA+E;IAC/E,0HAA0H;IAC1H,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC;IAC3C,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;KACvC,CAAC;AACb,CAAC,CAAC;AApBW,QAAA,YAAY,gBAoBvB;AAEF,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAU;IAC1C,OAAO,EAAE,oBAAY;CACtB,CAAC;AACF,kBAAe,eAAe,CAAC","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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.cts","sourceRoot":"","sources":["../../../src/common/endowments/crypto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;CAoBxB,CAAC;AAEF,QAAA,MAAM,eAAe;;;;;;CAGpB,CAAC;AACF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const createCrypto: () => {
|
|
2
|
+
readonly crypto: any;
|
|
3
|
+
readonly SubtleCrypto: any;
|
|
4
|
+
};
|
|
5
|
+
declare const endowmentModule: {
|
|
6
|
+
names: readonly ["crypto", "SubtleCrypto"];
|
|
7
|
+
factory: () => {
|
|
8
|
+
readonly crypto: any;
|
|
9
|
+
readonly SubtleCrypto: any;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export default endowmentModule;
|
|
13
|
+
//# sourceMappingURL=crypto.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.mts","sourceRoot":"","sources":["../../../src/common/endowments/crypto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;CAoBxB,CAAC;AAEF,QAAA,MAAM,eAAe;;;;;;CAGpB,CAAC;AACF,eAAe,eAAe,CAAC"}
|
|
@@ -1,11 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { rootRealmGlobal } from "../globalObject.mjs";
|
|
2
|
+
export const createCrypto = () => {
|
|
3
|
+
if ('crypto' in rootRealmGlobal &&
|
|
4
|
+
typeof rootRealmGlobal.crypto === 'object' &&
|
|
5
|
+
'SubtleCrypto' in rootRealmGlobal &&
|
|
6
|
+
typeof rootRealmGlobal.SubtleCrypto === 'function') {
|
|
7
|
+
return {
|
|
8
|
+
crypto: harden(rootRealmGlobal.crypto),
|
|
9
|
+
SubtleCrypto: harden(rootRealmGlobal.SubtleCrypto),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
// For now, we expose the experimental webcrypto API for Node.js execution environments
|
|
13
|
+
// TODO: Figure out if this is enough long-term or if we should use a polyfill.
|
|
14
|
+
/* eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */
|
|
15
|
+
const crypto = require('crypto').webcrypto;
|
|
16
|
+
return {
|
|
17
|
+
crypto: harden(crypto),
|
|
18
|
+
SubtleCrypto: harden(crypto.subtle.constructor),
|
|
19
|
+
};
|
|
10
20
|
};
|
|
21
|
+
const endowmentModule = {
|
|
22
|
+
names: ['crypto', 'SubtleCrypto'],
|
|
23
|
+
factory: createCrypto,
|
|
24
|
+
};
|
|
25
|
+
export default endowmentModule;
|
|
11
26
|
//# sourceMappingURL=crypto.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"crypto.mjs","sourceRoot":"","sources":["../../../src/common/endowments/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,4BAAwB;AAElD,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,IACE,QAAQ,IAAI,eAAe;QAC3B,OAAO,eAAe,CAAC,MAAM,KAAK,QAAQ;QAC1C,cAAc,IAAI,eAAe;QACjC,OAAO,eAAe,CAAC,YAAY,KAAK,UAAU,EAClD,CAAC;QACD,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC;YACtC,YAAY,EAAE,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC;SACnD,CAAC;IACJ,CAAC;IACD,uFAAuF;IACvF,+EAA+E;IAC/E,0HAA0H;IAC1H,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC;IAC3C,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;KACvC,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAU;IAC1C,OAAO,EAAE,YAAY;CACtB,CAAC;AACF,eAAe,eAAe,CAAC","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"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const globalObject_1 = require("../globalObject.cjs");
|
|
4
|
+
/**
|
|
5
|
+
* Creates a {@link Date} constructor, with most of the same properties as the global object.
|
|
6
|
+
* The Date.now() function has added noise as to limit its precision and prevent potential timing attacks.
|
|
7
|
+
* The Date constructor uses this now() function to seed itself if no arguments are given to the constructor.
|
|
8
|
+
*
|
|
9
|
+
* @returns A modified {@link Date} constructor with limited precision.
|
|
10
|
+
*/
|
|
11
|
+
function createDate() {
|
|
12
|
+
const keys = Object.getOwnPropertyNames(globalObject_1.rootRealmGlobal.Date);
|
|
13
|
+
let currentTime = 0;
|
|
14
|
+
const now = () => {
|
|
15
|
+
const actual = globalObject_1.rootRealmGlobal.Date.now();
|
|
16
|
+
const newTime = Math.round(actual + Math.random());
|
|
17
|
+
if (newTime > currentTime) {
|
|
18
|
+
currentTime = newTime;
|
|
19
|
+
}
|
|
20
|
+
return currentTime;
|
|
21
|
+
};
|
|
22
|
+
const NewDate = function (...args) {
|
|
23
|
+
return Reflect.construct(globalObject_1.rootRealmGlobal.Date, args.length === 0 ? [now()] : args, new.target);
|
|
24
|
+
};
|
|
25
|
+
keys.forEach((key) => {
|
|
26
|
+
Reflect.defineProperty(NewDate, key, {
|
|
27
|
+
configurable: false,
|
|
28
|
+
writable: false,
|
|
29
|
+
value: key === 'now' ? now : globalObject_1.rootRealmGlobal.Date[key],
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
return { Date: harden(NewDate) };
|
|
33
|
+
}
|
|
34
|
+
const endowmentModule = {
|
|
35
|
+
names: ['Date'],
|
|
36
|
+
factory: createDate,
|
|
37
|
+
};
|
|
38
|
+
exports.default = endowmentModule;
|
|
39
|
+
//# sourceMappingURL=date.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.cjs","sourceRoot":"","sources":["../../../src/common/endowments/date.ts"],"names":[],"mappings":";;AAAA,sDAAkD;AAElD;;;;;;GAMG;AACH,SAAS,UAAU;IACjB,MAAM,IAAI,GAAG,MAAM,CAAC,mBAAmB,CACrC,8BAAe,CAAC,IAAI,CACI,CAAC;IAE3B,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,MAAM,GAAG,GAAG,GAAG,EAAE;QACf,MAAM,MAAM,GAAG,8BAAe,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,IAAI,OAAO,GAAG,WAAW,EAAE,CAAC;YAC1B,WAAW,GAAG,OAAO,CAAC;QACxB,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,UAAU,GAAG,IAAe;QAC1C,OAAO,OAAO,CAAC,SAAS,CACtB,8BAAe,CAAC,IAAI,EACpB,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAClC,GAAG,CAAC,MAAM,CACX,CAAC;IACJ,CAAoB,CAAC;IAErB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACnB,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE;YACnC,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,8BAAe,CAAC,IAAI,CAAC,GAAG,CAAC;SACvD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;AACnC,CAAC;AAED,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,CAAC,MAAM,CAAU;IACxB,OAAO,EAAE,UAAU;CACpB,CAAC;AAEF,kBAAe,eAAe,CAAC","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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.cts","sourceRoot":"","sources":["../../../src/common/endowments/date.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,iBAAS,UAAU;;EAgClB;AAED,QAAA,MAAM,eAAe;;;CAGpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a {@link Date} constructor, with most of the same properties as the global object.
|
|
3
|
+
* The Date.now() function has added noise as to limit its precision and prevent potential timing attacks.
|
|
4
|
+
* The Date constructor uses this now() function to seed itself if no arguments are given to the constructor.
|
|
5
|
+
*
|
|
6
|
+
* @returns A modified {@link Date} constructor with limited precision.
|
|
7
|
+
*/
|
|
8
|
+
declare function createDate(): {
|
|
9
|
+
Date: DateConstructor;
|
|
10
|
+
};
|
|
11
|
+
declare const endowmentModule: {
|
|
12
|
+
names: readonly ["Date"];
|
|
13
|
+
factory: typeof createDate;
|
|
14
|
+
};
|
|
15
|
+
export default endowmentModule;
|
|
16
|
+
//# sourceMappingURL=date.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.mts","sourceRoot":"","sources":["../../../src/common/endowments/date.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,iBAAS,UAAU;;EAgClB;AAED,QAAA,MAAM,eAAe;;;CAGpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,9 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { rootRealmGlobal } from "../globalObject.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a {@link Date} constructor, with most of the same properties as the global object.
|
|
4
|
+
* The Date.now() function has added noise as to limit its precision and prevent potential timing attacks.
|
|
5
|
+
* The Date constructor uses this now() function to seed itself if no arguments are given to the constructor.
|
|
6
|
+
*
|
|
7
|
+
* @returns A modified {@link Date} constructor with limited precision.
|
|
8
|
+
*/
|
|
9
|
+
function createDate() {
|
|
10
|
+
const keys = Object.getOwnPropertyNames(rootRealmGlobal.Date);
|
|
11
|
+
let currentTime = 0;
|
|
12
|
+
const now = () => {
|
|
13
|
+
const actual = rootRealmGlobal.Date.now();
|
|
14
|
+
const newTime = Math.round(actual + Math.random());
|
|
15
|
+
if (newTime > currentTime) {
|
|
16
|
+
currentTime = newTime;
|
|
17
|
+
}
|
|
18
|
+
return currentTime;
|
|
19
|
+
};
|
|
20
|
+
const NewDate = function (...args) {
|
|
21
|
+
return Reflect.construct(rootRealmGlobal.Date, args.length === 0 ? [now()] : args, new.target);
|
|
22
|
+
};
|
|
23
|
+
keys.forEach((key) => {
|
|
24
|
+
Reflect.defineProperty(NewDate, key, {
|
|
25
|
+
configurable: false,
|
|
26
|
+
writable: false,
|
|
27
|
+
value: key === 'now' ? now : rootRealmGlobal.Date[key],
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
return { Date: harden(NewDate) };
|
|
31
|
+
}
|
|
32
|
+
const endowmentModule = {
|
|
33
|
+
names: ['Date'],
|
|
34
|
+
factory: createDate,
|
|
8
35
|
};
|
|
36
|
+
export default endowmentModule;
|
|
9
37
|
//# sourceMappingURL=date.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"date.mjs","sourceRoot":"","sources":["../../../src/common/endowments/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,4BAAwB;AAElD;;;;;;GAMG;AACH,SAAS,UAAU;IACjB,MAAM,IAAI,GAAG,MAAM,CAAC,mBAAmB,CACrC,eAAe,CAAC,IAAI,CACI,CAAC;IAE3B,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,MAAM,GAAG,GAAG,GAAG,EAAE;QACf,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,IAAI,OAAO,GAAG,WAAW,EAAE,CAAC;YAC1B,WAAW,GAAG,OAAO,CAAC;QACxB,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,UAAU,GAAG,IAAe;QAC1C,OAAO,OAAO,CAAC,SAAS,CACtB,eAAe,CAAC,IAAI,EACpB,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAClC,GAAG,CAAC,MAAM,CACX,CAAC;IACJ,CAAoB,CAAC;IAErB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACnB,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE;YACnC,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC;SACvD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;AACnC,CAAC;AAED,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,CAAC,MAAM,CAAU;IACxB,OAAO,EAAE,UAAU;CACpB,CAAC;AAEF,eAAe,eAAe,CAAC","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"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createEndowments = void 0;
|
|
7
|
+
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
8
|
+
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
9
|
+
const utils_1 = require("@metamask/utils");
|
|
10
|
+
const globalObject_1 = require("../globalObject.cjs");
|
|
11
|
+
const commonEndowmentFactory_1 = __importDefault(require("./commonEndowmentFactory.cjs"));
|
|
12
|
+
/**
|
|
13
|
+
* Retrieve consolidated endowment factories for common endowments.
|
|
14
|
+
*/
|
|
15
|
+
const registeredEndowments = (0, commonEndowmentFactory_1.default)();
|
|
16
|
+
/**
|
|
17
|
+
* A map of endowment names to their factory functions. Some endowments share
|
|
18
|
+
* the same factory function, but we only call each factory once for each snap.
|
|
19
|
+
* See {@link createEndowments} for details.
|
|
20
|
+
*/
|
|
21
|
+
const endowmentFactories = registeredEndowments.reduce((factories, builder) => {
|
|
22
|
+
builder.names.forEach((name) => {
|
|
23
|
+
factories.set(name, builder.factory);
|
|
24
|
+
});
|
|
25
|
+
return factories;
|
|
26
|
+
}, new Map());
|
|
27
|
+
/**
|
|
28
|
+
* Gets the endowments for a particular Snap. Some endowments, like `setTimeout`
|
|
29
|
+
* and `clearTimeout`, must be attenuated so that they can only affect behavior
|
|
30
|
+
* within the Snap's own realm. Therefore, we use factory functions to create
|
|
31
|
+
* such attenuated / modified endowments. Otherwise, the value that's on the
|
|
32
|
+
* root realm global will be used.
|
|
33
|
+
*
|
|
34
|
+
* @param options - An options bag.
|
|
35
|
+
* @param options.snap - The Snaps global API object.
|
|
36
|
+
* @param options.ethereum - The Snap's EIP-1193 provider object.
|
|
37
|
+
* @param options.snapId - The id of the snap that will use the created endowments.
|
|
38
|
+
* @param options.endowments - The list of endowments to provide to the snap.
|
|
39
|
+
* @param options.notify - A reference to the notify function of the snap executor.
|
|
40
|
+
* @returns An object containing the Snap's endowments.
|
|
41
|
+
*/
|
|
42
|
+
function createEndowments({ snap, ethereum, snapId, endowments, notify, }) {
|
|
43
|
+
const attenuatedEndowments = {};
|
|
44
|
+
// TODO: All endowments should be hardened to prevent covert communication
|
|
45
|
+
// channels. Hardening the returned objects breaks tests elsewhere in the
|
|
46
|
+
// monorepo, so further research is needed.
|
|
47
|
+
const result = endowments.reduce(({ allEndowments, teardowns }, endowmentName) => {
|
|
48
|
+
// First, check if the endowment has a factory, and default to that.
|
|
49
|
+
if (endowmentFactories.has(endowmentName)) {
|
|
50
|
+
if (!(0, utils_1.hasProperty)(attenuatedEndowments, endowmentName)) {
|
|
51
|
+
// Call the endowment factory for the current endowment. If the factory
|
|
52
|
+
// creates multiple endowments, they will all be assigned to the
|
|
53
|
+
// `attenuatedEndowments` object, but will only be passed on to the snap
|
|
54
|
+
// if explicitly listed among its endowment.
|
|
55
|
+
// This may not have an actual use case, but, safety first.
|
|
56
|
+
// We just confirmed that endowmentFactories has the specified key.
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
58
|
+
const { teardownFunction, ...endowment } = endowmentFactories.get(endowmentName)({ snapId, notify });
|
|
59
|
+
Object.assign(attenuatedEndowments, endowment);
|
|
60
|
+
if (teardownFunction) {
|
|
61
|
+
teardowns.push(teardownFunction);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
allEndowments[endowmentName] = attenuatedEndowments[endowmentName];
|
|
65
|
+
}
|
|
66
|
+
else if (endowmentName === 'ethereum') {
|
|
67
|
+
// Special case for adding the EIP-1193 provider.
|
|
68
|
+
allEndowments[endowmentName] = ethereum;
|
|
69
|
+
}
|
|
70
|
+
else if (endowmentName in globalObject_1.rootRealmGlobal) {
|
|
71
|
+
(0, snaps_utils_1.logWarning)(`Access to unhardened global ${endowmentName}.`);
|
|
72
|
+
// If the endowment doesn't have a factory, just use whatever is on the
|
|
73
|
+
// global object.
|
|
74
|
+
const globalValue = globalObject_1.rootRealmGlobal[endowmentName];
|
|
75
|
+
allEndowments[endowmentName] = globalValue;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// If we get to this point, we've been passed an endowment that doesn't
|
|
79
|
+
// exist in our current environment.
|
|
80
|
+
throw rpc_errors_1.rpcErrors.internal(`Unknown endowment: "${endowmentName}".`);
|
|
81
|
+
}
|
|
82
|
+
return { allEndowments, teardowns };
|
|
83
|
+
}, {
|
|
84
|
+
allEndowments: { snap },
|
|
85
|
+
teardowns: [],
|
|
86
|
+
});
|
|
87
|
+
const teardown = async () => {
|
|
88
|
+
await Promise.all(result.teardowns.map((teardownFunction) => teardownFunction()));
|
|
89
|
+
};
|
|
90
|
+
return { endowments: result.allEndowments, teardown };
|
|
91
|
+
}
|
|
92
|
+
exports.createEndowments = createEndowments;
|
|
93
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/common/endowments/index.ts"],"names":[],"mappings":"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","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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { StreamProvider } from
|
|
2
|
-
import type { SnapsProvider } from
|
|
3
|
-
import type { NotifyFunction } from
|
|
1
|
+
import type { StreamProvider } from "@metamask/providers";
|
|
2
|
+
import type { SnapsProvider } from "@metamask/snaps-sdk";
|
|
3
|
+
import type { NotifyFunction } from "../BaseSnapExecutor.cjs";
|
|
4
4
|
/**
|
|
5
5
|
* Gets the endowments for a particular Snap. Some endowments, like `setTimeout`
|
|
6
6
|
* and `clearTimeout`, must be attenuated so that they can only affect behavior
|
|
@@ -26,3 +26,4 @@ export declare function createEndowments({ snap, ethereum, snapId, endowments, n
|
|
|
26
26
|
endowments: Record<string, unknown>;
|
|
27
27
|
teardown: () => Promise<void>;
|
|
28
28
|
};
|
|
29
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/common/endowments/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,4BAA4B;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,4BAA4B;AAIzD,OAAO,KAAK,EAAE,cAAc,EAAE,gCAA4B;AAmC1D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,UAAU,EACV,MAAM,GACP,EAAE;IACD,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;CACxB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CA6DzE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { StreamProvider } from "@metamask/providers";
|
|
2
|
+
import type { SnapsProvider } from "@metamask/snaps-sdk";
|
|
3
|
+
import type { NotifyFunction } from "../BaseSnapExecutor.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Gets the endowments for a particular Snap. Some endowments, like `setTimeout`
|
|
6
|
+
* and `clearTimeout`, must be attenuated so that they can only affect behavior
|
|
7
|
+
* within the Snap's own realm. Therefore, we use factory functions to create
|
|
8
|
+
* such attenuated / modified endowments. Otherwise, the value that's on the
|
|
9
|
+
* root realm global will be used.
|
|
10
|
+
*
|
|
11
|
+
* @param options - An options bag.
|
|
12
|
+
* @param options.snap - The Snaps global API object.
|
|
13
|
+
* @param options.ethereum - The Snap's EIP-1193 provider object.
|
|
14
|
+
* @param options.snapId - The id of the snap that will use the created endowments.
|
|
15
|
+
* @param options.endowments - The list of endowments to provide to the snap.
|
|
16
|
+
* @param options.notify - A reference to the notify function of the snap executor.
|
|
17
|
+
* @returns An object containing the Snap's endowments.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createEndowments({ snap, ethereum, snapId, endowments, notify, }: {
|
|
20
|
+
snap: SnapsProvider;
|
|
21
|
+
ethereum: StreamProvider;
|
|
22
|
+
snapId: string;
|
|
23
|
+
endowments: string[];
|
|
24
|
+
notify: NotifyFunction;
|
|
25
|
+
}): {
|
|
26
|
+
endowments: Record<string, unknown>;
|
|
27
|
+
teardown: () => Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/common/endowments/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,4BAA4B;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,4BAA4B;AAIzD,OAAO,KAAK,EAAE,cAAc,EAAE,gCAA4B;AAmC1D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,UAAU,EACV,MAAM,GACP,EAAE;IACD,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;CACxB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CA6DzE"}
|