@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.
Files changed (526) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/dist/common/BaseSnapExecutor.cjs +436 -0
  3. package/dist/common/BaseSnapExecutor.cjs.map +1 -0
  4. package/dist/{types/common/BaseSnapExecutor.d.ts → common/BaseSnapExecutor.d.cts} +8 -6
  5. package/dist/common/BaseSnapExecutor.d.cts.map +1 -0
  6. package/dist/common/BaseSnapExecutor.d.mts +70 -0
  7. package/dist/common/BaseSnapExecutor.d.mts.map +1 -0
  8. package/dist/common/BaseSnapExecutor.mjs +430 -24
  9. package/dist/common/BaseSnapExecutor.mjs.map +1 -1
  10. package/dist/common/commands.cjs +95 -0
  11. package/dist/common/commands.cjs.map +1 -0
  12. package/dist/{types/common/commands.d.ts → common/commands.d.cts} +5 -4
  13. package/dist/common/commands.d.cts.map +1 -0
  14. package/dist/common/commands.d.mts +31 -0
  15. package/dist/common/commands.d.mts.map +1 -0
  16. package/dist/common/commands.mjs +89 -10
  17. package/dist/common/commands.mjs.map +1 -1
  18. package/dist/common/endowments/commonEndowmentFactory.cjs +76 -0
  19. package/dist/common/endowments/commonEndowmentFactory.cjs.map +1 -0
  20. package/dist/{types/common/endowments/commonEndowmentFactory.d.ts → common/endowments/commonEndowmentFactory.d.cts} +5 -4
  21. package/dist/common/endowments/commonEndowmentFactory.d.cts.map +1 -0
  22. package/dist/common/endowments/commonEndowmentFactory.d.mts +26 -0
  23. package/dist/common/endowments/commonEndowmentFactory.d.mts.map +1 -0
  24. package/dist/common/endowments/commonEndowmentFactory.mjs +69 -18
  25. package/dist/common/endowments/commonEndowmentFactory.mjs.map +1 -1
  26. package/dist/common/endowments/console.cjs +103 -0
  27. package/dist/common/endowments/console.cjs.map +1 -0
  28. package/dist/{types/common/endowments/console.d.ts → common/endowments/console.d.cts} +2 -1
  29. package/dist/common/endowments/console.d.cts.map +1 -0
  30. package/dist/common/endowments/console.d.mts +46 -0
  31. package/dist/common/endowments/console.d.mts.map +1 -0
  32. package/dist/common/endowments/console.mjs +98 -11
  33. package/dist/common/endowments/console.mjs.map +1 -1
  34. package/dist/common/endowments/crypto.cjs +30 -0
  35. package/dist/common/endowments/crypto.cjs.map +1 -0
  36. package/dist/{types/common/endowments/crypto.d.ts → common/endowments/crypto.d.cts} +1 -0
  37. package/dist/common/endowments/crypto.d.cts.map +1 -0
  38. package/dist/common/endowments/crypto.d.mts +13 -0
  39. package/dist/common/endowments/crypto.d.mts.map +1 -0
  40. package/dist/common/endowments/crypto.mjs +24 -9
  41. package/dist/common/endowments/crypto.mjs.map +1 -1
  42. package/dist/common/endowments/date.cjs +39 -0
  43. package/dist/common/endowments/date.cjs.map +1 -0
  44. package/dist/{types/common/endowments/date.d.ts → common/endowments/date.d.cts} +1 -0
  45. package/dist/common/endowments/date.d.cts.map +1 -0
  46. package/dist/common/endowments/date.d.mts +16 -0
  47. package/dist/common/endowments/date.d.mts.map +1 -0
  48. package/dist/common/endowments/date.mjs +35 -7
  49. package/dist/common/endowments/date.mjs.map +1 -1
  50. package/dist/common/endowments/index.cjs +93 -0
  51. package/dist/common/endowments/index.cjs.map +1 -0
  52. package/dist/{types/common/endowments/index.d.ts → common/endowments/index.d.cts} +4 -3
  53. package/dist/common/endowments/index.d.cts.map +1 -0
  54. package/dist/common/endowments/index.d.mts +29 -0
  55. package/dist/common/endowments/index.d.mts.map +1 -0
  56. package/dist/common/endowments/index.mjs +85 -20
  57. package/dist/common/endowments/index.mjs.map +1 -1
  58. package/dist/common/endowments/interval.cjs +51 -0
  59. package/dist/common/endowments/interval.cjs.map +1 -0
  60. package/dist/{types/common/endowments/interval.d.ts → common/endowments/interval.d.cts} +1 -0
  61. package/dist/common/endowments/interval.d.cts.map +1 -0
  62. package/dist/common/endowments/interval.d.mts +10 -0
  63. package/dist/common/endowments/interval.d.mts.map +1 -0
  64. package/dist/common/endowments/interval.mjs +47 -6
  65. package/dist/common/endowments/interval.mjs.map +1 -1
  66. package/dist/common/endowments/math.cjs +54 -0
  67. package/dist/common/endowments/math.cjs.map +1 -0
  68. package/dist/{types/common/endowments/math.d.ts → common/endowments/math.d.cts} +1 -0
  69. package/dist/common/endowments/math.d.cts.map +1 -0
  70. package/dist/common/endowments/math.d.mts +61 -0
  71. package/dist/common/endowments/math.d.mts.map +1 -0
  72. package/dist/common/endowments/math.mjs +50 -8
  73. package/dist/common/endowments/math.mjs.map +1 -1
  74. package/dist/common/endowments/network.cjs +255 -0
  75. package/dist/common/endowments/network.cjs.map +1 -0
  76. package/dist/{types/common/endowments/network.d.ts → common/endowments/network.d.cts} +4 -2
  77. package/dist/common/endowments/network.d.cts.map +1 -0
  78. package/dist/common/endowments/network.d.mts +25 -0
  79. package/dist/common/endowments/network.d.mts.map +1 -0
  80. package/dist/common/endowments/network.mjs +251 -8
  81. package/dist/common/endowments/network.mjs.map +1 -1
  82. package/dist/common/endowments/textDecoder.cjs +18 -0
  83. package/dist/common/endowments/textDecoder.cjs.map +1 -0
  84. package/dist/{types/common/endowments/textDecoder.d.ts → common/endowments/textDecoder.d.cts} +1 -0
  85. package/dist/common/endowments/textDecoder.d.cts.map +1 -0
  86. package/dist/common/endowments/textDecoder.d.mts +11 -0
  87. package/dist/common/endowments/textDecoder.d.mts.map +1 -0
  88. package/dist/common/endowments/textDecoder.mjs +14 -6
  89. package/dist/common/endowments/textDecoder.mjs.map +1 -1
  90. package/dist/common/endowments/textEncoder.cjs +18 -0
  91. package/dist/common/endowments/textEncoder.cjs.map +1 -0
  92. package/dist/{types/common/endowments/textEncoder.d.ts → common/endowments/textEncoder.d.cts} +1 -0
  93. package/dist/common/endowments/textEncoder.d.cts.map +1 -0
  94. package/dist/common/endowments/textEncoder.d.mts +11 -0
  95. package/dist/common/endowments/textEncoder.d.mts.map +1 -0
  96. package/dist/common/endowments/textEncoder.mjs +14 -6
  97. package/dist/common/endowments/textEncoder.mjs.map +1 -1
  98. package/dist/common/endowments/timeout.cjs +53 -0
  99. package/dist/common/endowments/timeout.cjs.map +1 -0
  100. package/dist/{types/common/endowments/timeout.d.ts → common/endowments/timeout.d.cts} +1 -0
  101. package/dist/common/endowments/timeout.d.cts.map +1 -0
  102. package/dist/common/endowments/timeout.d.mts +10 -0
  103. package/dist/common/endowments/timeout.d.mts.map +1 -0
  104. package/dist/common/endowments/timeout.mjs +49 -6
  105. package/dist/common/endowments/timeout.mjs.map +1 -1
  106. package/dist/common/globalEvents.cjs +48 -0
  107. package/dist/common/globalEvents.cjs.map +1 -0
  108. package/dist/{types/common/globalEvents.d.ts → common/globalEvents.d.cts} +1 -0
  109. package/dist/common/globalEvents.d.cts.map +1 -0
  110. package/dist/common/globalEvents.d.mts +21 -0
  111. package/dist/common/globalEvents.d.mts.map +1 -0
  112. package/dist/common/globalEvents.mjs +42 -10
  113. package/dist/common/globalEvents.mjs.map +1 -1
  114. package/dist/common/globalObject.cjs +50 -0
  115. package/dist/common/globalObject.cjs.map +1 -0
  116. package/dist/{types/common/globalObject.d.ts → common/globalObject.d.cts} +1 -0
  117. package/dist/common/globalObject.d.cts.map +1 -0
  118. package/dist/common/globalObject.d.mts +10 -0
  119. package/dist/common/globalObject.d.mts.map +1 -0
  120. package/dist/common/globalObject.mjs +45 -9
  121. package/dist/common/globalObject.mjs.map +1 -1
  122. package/dist/common/lockdown/lockdown-events.cjs +60 -0
  123. package/dist/common/lockdown/lockdown-events.cjs.map +1 -0
  124. package/dist/{types/common/lockdown/lockdown-events.d.ts → common/lockdown/lockdown-events.d.cts} +1 -0
  125. package/dist/common/lockdown/lockdown-events.d.cts.map +1 -0
  126. package/dist/common/lockdown/lockdown-events.d.mts +5 -0
  127. package/dist/common/lockdown/lockdown-events.d.mts.map +1 -0
  128. package/dist/common/lockdown/lockdown-events.mjs +55 -7
  129. package/dist/common/lockdown/lockdown-events.mjs.map +1 -1
  130. package/dist/common/lockdown/lockdown-more.cjs +89 -0
  131. package/dist/common/lockdown/lockdown-more.cjs.map +1 -0
  132. package/dist/{types/common/lockdown/lockdown-more.d.ts → common/lockdown/lockdown-more.d.cts} +1 -0
  133. package/dist/common/lockdown/lockdown-more.d.cts.map +1 -0
  134. package/dist/common/lockdown/lockdown-more.d.mts +23 -0
  135. package/dist/common/lockdown/lockdown-more.d.mts.map +1 -0
  136. package/dist/common/lockdown/lockdown-more.mjs +84 -7
  137. package/dist/common/lockdown/lockdown-more.mjs.map +1 -1
  138. package/dist/common/lockdown/lockdown.cjs +29 -0
  139. package/dist/common/lockdown/lockdown.cjs.map +1 -0
  140. package/dist/{types/common/lockdown/lockdown.d.ts → common/lockdown/lockdown.d.cts} +1 -0
  141. package/dist/common/lockdown/lockdown.d.cts.map +1 -0
  142. package/dist/common/lockdown/lockdown.d.mts +8 -0
  143. package/dist/common/lockdown/lockdown.d.mts.map +1 -0
  144. package/dist/common/lockdown/lockdown.mjs +22 -19
  145. package/dist/common/lockdown/lockdown.mjs.map +1 -1
  146. package/dist/common/sortParams.cjs +35 -0
  147. package/dist/common/sortParams.cjs.map +1 -0
  148. package/dist/{types/common/sortParams.d.ts → common/sortParams.d.cts} +2 -1
  149. package/dist/common/sortParams.d.cts.map +1 -0
  150. package/dist/common/sortParams.d.mts +17 -0
  151. package/dist/common/sortParams.d.mts.map +1 -0
  152. package/dist/common/sortParams.mjs +29 -6
  153. package/dist/common/sortParams.mjs.map +1 -1
  154. package/dist/common/utils.cjs +156 -0
  155. package/dist/common/utils.cjs.map +1 -0
  156. package/dist/{types/common/utils.d.ts → common/utils.d.cts} +2 -1
  157. package/dist/common/utils.d.cts.map +1 -0
  158. package/dist/common/utils.d.mts +50 -0
  159. package/dist/common/utils.d.mts.map +1 -0
  160. package/dist/common/utils.mjs +146 -20
  161. package/dist/common/utils.mjs.map +1 -1
  162. package/dist/common/validation.cjs +137 -0
  163. package/dist/common/validation.cjs.map +1 -0
  164. package/dist/{types/common/validation.d.ts → common/validation.d.cts} +37 -36
  165. package/dist/common/validation.d.cts.map +1 -0
  166. package/dist/common/validation.d.mts +199 -0
  167. package/dist/common/validation.d.mts.map +1 -0
  168. package/dist/common/validation.mjs +127 -37
  169. package/dist/common/validation.mjs.map +1 -1
  170. package/dist/iframe/IFrameSnapExecutor.cjs +42 -0
  171. package/dist/iframe/IFrameSnapExecutor.cjs.map +1 -0
  172. package/dist/{types/iframe/IFrameSnapExecutor.d.ts → iframe/IFrameSnapExecutor.d.cts} +3 -2
  173. package/dist/iframe/IFrameSnapExecutor.d.cts.map +1 -0
  174. package/dist/iframe/IFrameSnapExecutor.d.mts +14 -0
  175. package/dist/iframe/IFrameSnapExecutor.d.mts.map +1 -0
  176. package/dist/iframe/IFrameSnapExecutor.mjs +42 -26
  177. package/dist/iframe/IFrameSnapExecutor.mjs.map +1 -1
  178. package/dist/iframe/index.cjs +10 -0
  179. package/dist/iframe/index.cjs.map +1 -0
  180. package/dist/iframe/index.d.cts +2 -0
  181. package/dist/iframe/index.d.cts.map +1 -0
  182. package/dist/iframe/index.d.mts +2 -0
  183. package/dist/iframe/index.d.mts.map +1 -0
  184. package/dist/iframe/index.mjs +4 -31
  185. package/dist/iframe/index.mjs.map +1 -1
  186. package/dist/index.cjs +18 -0
  187. package/dist/index.cjs.map +1 -0
  188. package/dist/index.d.cts +2 -0
  189. package/dist/index.d.cts.map +1 -0
  190. package/dist/index.d.mts +2 -0
  191. package/dist/index.d.mts.map +1 -0
  192. package/dist/index.mjs +1 -8
  193. package/dist/index.mjs.map +1 -1
  194. package/dist/logging.cjs +13 -0
  195. package/dist/logging.cjs.map +1 -0
  196. package/dist/{types/logging.d.ts → logging.d.cts} +1 -0
  197. package/dist/logging.d.cts.map +1 -0
  198. package/dist/logging.d.mts +9 -0
  199. package/dist/logging.d.mts.map +1 -0
  200. package/dist/logging.mjs +9 -7
  201. package/dist/logging.mjs.map +1 -1
  202. package/dist/node-process/ChildProcessSnapExecutor.cjs +30 -0
  203. package/dist/node-process/ChildProcessSnapExecutor.cjs.map +1 -0
  204. package/dist/{types/node-process/ChildProcessSnapExecutor.d.ts → node-process/ChildProcessSnapExecutor.d.cts} +2 -1
  205. package/dist/node-process/ChildProcessSnapExecutor.d.cts.map +1 -0
  206. package/dist/node-process/ChildProcessSnapExecutor.d.mts +5 -0
  207. package/dist/node-process/ChildProcessSnapExecutor.d.mts.map +1 -0
  208. package/dist/node-process/ChildProcessSnapExecutor.mjs +30 -26
  209. package/dist/node-process/ChildProcessSnapExecutor.mjs.map +1 -1
  210. package/dist/node-process/index.cjs +8 -0
  211. package/dist/node-process/index.cjs.map +1 -0
  212. package/dist/node-process/index.d.cts +2 -0
  213. package/dist/node-process/index.d.cts.map +1 -0
  214. package/dist/node-process/index.d.mts +2 -0
  215. package/dist/node-process/index.d.mts.map +1 -0
  216. package/dist/node-process/index.mjs +3 -28
  217. package/dist/node-process/index.mjs.map +1 -1
  218. package/dist/node-thread/ThreadSnapExecutor.cjs +30 -0
  219. package/dist/node-thread/ThreadSnapExecutor.cjs.map +1 -0
  220. package/dist/node-thread/ThreadSnapExecutor.d.cts +5 -0
  221. package/dist/node-thread/ThreadSnapExecutor.d.cts.map +1 -0
  222. package/dist/node-thread/ThreadSnapExecutor.d.mts +5 -0
  223. package/dist/node-thread/ThreadSnapExecutor.d.mts.map +1 -0
  224. package/dist/node-thread/ThreadSnapExecutor.mjs +30 -26
  225. package/dist/node-thread/ThreadSnapExecutor.mjs.map +1 -1
  226. package/dist/node-thread/index.cjs +8 -0
  227. package/dist/node-thread/index.cjs.map +1 -0
  228. package/dist/node-thread/index.d.cts +2 -0
  229. package/dist/node-thread/index.d.cts.map +1 -0
  230. package/dist/node-thread/index.d.mts +2 -0
  231. package/dist/node-thread/index.d.mts.map +1 -0
  232. package/dist/node-thread/index.mjs +3 -28
  233. package/dist/node-thread/index.mjs.map +1 -1
  234. package/dist/proxy/ProxySnapExecutor.cjs +112 -0
  235. package/dist/proxy/ProxySnapExecutor.cjs.map +1 -0
  236. package/dist/{types/proxy/ProxySnapExecutor.d.ts → proxy/ProxySnapExecutor.d.cts} +4 -3
  237. package/dist/proxy/ProxySnapExecutor.d.cts.map +1 -0
  238. package/dist/proxy/ProxySnapExecutor.d.mts +36 -0
  239. package/dist/proxy/ProxySnapExecutor.d.mts.map +1 -0
  240. package/dist/proxy/ProxySnapExecutor.mjs +104 -6
  241. package/dist/proxy/ProxySnapExecutor.mjs.map +1 -1
  242. package/dist/proxy/index.cjs +18 -0
  243. package/dist/proxy/index.cjs.map +1 -0
  244. package/dist/proxy/index.d.cts +2 -0
  245. package/dist/proxy/index.d.cts.map +1 -0
  246. package/dist/proxy/index.d.mts +2 -0
  247. package/dist/proxy/index.d.mts.map +1 -0
  248. package/dist/proxy/index.mjs +1 -8
  249. package/dist/proxy/index.mjs.map +1 -1
  250. package/dist/webview/WebViewExecutorStream.cjs +79 -0
  251. package/dist/webview/WebViewExecutorStream.cjs.map +1 -0
  252. package/dist/{types/webview/WebViewExecutorStream.d.ts → webview/WebViewExecutorStream.d.cts} +3 -2
  253. package/dist/webview/WebViewExecutorStream.d.cts.map +1 -0
  254. package/dist/webview/WebViewExecutorStream.d.mts +33 -0
  255. package/dist/webview/WebViewExecutorStream.d.mts.map +1 -0
  256. package/dist/webview/WebViewExecutorStream.mjs +74 -6
  257. package/dist/webview/WebViewExecutorStream.mjs.map +1 -1
  258. package/dist/webview/index.cjs +16 -0
  259. package/dist/webview/index.cjs.map +1 -0
  260. package/dist/webview/index.d.cts +2 -0
  261. package/dist/webview/index.d.cts.map +1 -0
  262. package/dist/webview/index.d.mts +2 -0
  263. package/dist/webview/index.d.mts.map +1 -0
  264. package/dist/webview/index.mjs +9 -21
  265. package/dist/webview/index.mjs.map +1 -1
  266. package/dist/webworker/executor/WebWorkerSnapExecutor.cjs +37 -0
  267. package/dist/webworker/executor/WebWorkerSnapExecutor.cjs.map +1 -0
  268. package/dist/{types/webworker/executor/WebWorkerSnapExecutor.d.ts → webworker/executor/WebWorkerSnapExecutor.d.cts} +3 -2
  269. package/dist/webworker/executor/WebWorkerSnapExecutor.d.cts.map +1 -0
  270. package/dist/webworker/executor/WebWorkerSnapExecutor.d.mts +14 -0
  271. package/dist/webworker/executor/WebWorkerSnapExecutor.d.mts.map +1 -0
  272. package/dist/webworker/executor/WebWorkerSnapExecutor.mjs +37 -26
  273. package/dist/webworker/executor/WebWorkerSnapExecutor.mjs.map +1 -1
  274. package/dist/webworker/executor/index.cjs +10 -0
  275. package/dist/webworker/executor/index.cjs.map +1 -0
  276. package/dist/webworker/executor/index.d.cts +2 -0
  277. package/dist/webworker/executor/index.d.cts.map +1 -0
  278. package/dist/webworker/executor/index.d.mts +2 -0
  279. package/dist/webworker/executor/index.d.mts.map +1 -0
  280. package/dist/webworker/executor/index.mjs +4 -31
  281. package/dist/webworker/executor/index.mjs.map +1 -1
  282. package/dist/webworker/pool/WebWorkerPool.cjs +168 -0
  283. package/dist/webworker/pool/WebWorkerPool.cjs.map +1 -0
  284. package/dist/{types/webworker/pool/WebWorkerPool.d.ts → webworker/pool/WebWorkerPool.d.cts} +4 -3
  285. package/dist/webworker/pool/WebWorkerPool.d.cts.map +1 -0
  286. package/dist/webworker/pool/WebWorkerPool.d.mts +24 -0
  287. package/dist/webworker/pool/WebWorkerPool.d.mts.map +1 -0
  288. package/dist/webworker/pool/WebWorkerPool.mjs +163 -6
  289. package/dist/webworker/pool/WebWorkerPool.mjs.map +1 -1
  290. package/dist/webworker/pool/index.cjs +10 -0
  291. package/dist/webworker/pool/index.cjs.map +1 -0
  292. package/dist/webworker/pool/index.d.cts +2 -0
  293. package/dist/webworker/pool/index.d.cts.map +1 -0
  294. package/dist/webworker/pool/index.d.mts +2 -0
  295. package/dist/webworker/pool/index.d.mts.map +1 -0
  296. package/dist/webworker/pool/index.mjs +4 -12
  297. package/dist/webworker/pool/index.mjs.map +1 -1
  298. package/package.json +23 -20
  299. package/dist/browserify/iframe/bundle.js +0 -9
  300. package/dist/browserify/iframe/index.html +0 -13394
  301. package/dist/browserify/node-process/bundle.js +0 -13390
  302. package/dist/browserify/node-thread/bundle.js +0 -13390
  303. package/dist/browserify/webview/index.html +0 -13402
  304. package/dist/browserify/worker-executor/bundle.js +0 -13392
  305. package/dist/browserify/worker-pool/bundle.js +0 -9
  306. package/dist/browserify/worker-pool/index.html +0 -13394
  307. package/dist/chunk-2VA6RAEE.js +0 -30
  308. package/dist/chunk-2VA6RAEE.js.map +0 -1
  309. package/dist/chunk-3JCT4MWT.js +0 -108
  310. package/dist/chunk-3JCT4MWT.js.map +0 -1
  311. package/dist/chunk-46LW37FK.js +0 -144
  312. package/dist/chunk-46LW37FK.js.map +0 -1
  313. package/dist/chunk-4COIRXF5.js +0 -86
  314. package/dist/chunk-4COIRXF5.js.map +0 -1
  315. package/dist/chunk-4XRZLEKU.js +0 -49
  316. package/dist/chunk-4XRZLEKU.js.map +0 -1
  317. package/dist/chunk-53ZULHPK.mjs +0 -16
  318. package/dist/chunk-53ZULHPK.mjs.map +0 -1
  319. package/dist/chunk-5DEV3QQU.mjs +0 -12
  320. package/dist/chunk-5DEV3QQU.mjs.map +0 -1
  321. package/dist/chunk-5STN3QCA.js +0 -183
  322. package/dist/chunk-5STN3QCA.js.map +0 -1
  323. package/dist/chunk-72KFTWQZ.mjs +0 -45
  324. package/dist/chunk-72KFTWQZ.mjs.map +0 -1
  325. package/dist/chunk-75RCH4ZX.mjs +0 -151
  326. package/dist/chunk-75RCH4ZX.mjs.map +0 -1
  327. package/dist/chunk-7AJWXSDQ.mjs +0 -73
  328. package/dist/chunk-7AJWXSDQ.mjs.map +0 -1
  329. package/dist/chunk-7MMUJJQ2.js +0 -151
  330. package/dist/chunk-7MMUJJQ2.js.map +0 -1
  331. package/dist/chunk-BCBKEUCG.mjs +0 -38
  332. package/dist/chunk-BCBKEUCG.mjs.map +0 -1
  333. package/dist/chunk-BEJDC4XI.mjs +0 -40
  334. package/dist/chunk-BEJDC4XI.mjs.map +0 -1
  335. package/dist/chunk-BLHIYDO5.js +0 -40
  336. package/dist/chunk-BLHIYDO5.js.map +0 -1
  337. package/dist/chunk-BTEAZZKP.mjs +0 -24
  338. package/dist/chunk-BTEAZZKP.mjs.map +0 -1
  339. package/dist/chunk-BVRVUIJB.mjs +0 -67
  340. package/dist/chunk-BVRVUIJB.mjs.map +0 -1
  341. package/dist/chunk-CV5LC4PP.js +0 -24
  342. package/dist/chunk-CV5LC4PP.js.map +0 -1
  343. package/dist/chunk-DKDTGAFK.js +0 -67
  344. package/dist/chunk-DKDTGAFK.js.map +0 -1
  345. package/dist/chunk-DLLLH5HN.js +0 -26
  346. package/dist/chunk-DLLLH5HN.js.map +0 -1
  347. package/dist/chunk-EXN2TFDJ.js +0 -38
  348. package/dist/chunk-EXN2TFDJ.js.map +0 -1
  349. package/dist/chunk-FOEAIF5U.js +0 -16
  350. package/dist/chunk-FOEAIF5U.js.map +0 -1
  351. package/dist/chunk-FUPEJT7B.js +0 -82
  352. package/dist/chunk-FUPEJT7B.js.map +0 -1
  353. package/dist/chunk-HCXTK3PR.js +0 -472
  354. package/dist/chunk-HCXTK3PR.js.map +0 -1
  355. package/dist/chunk-HGLRZZ56.js +0 -32
  356. package/dist/chunk-HGLRZZ56.js.map +0 -1
  357. package/dist/chunk-HL2TTKF3.mjs +0 -144
  358. package/dist/chunk-HL2TTKF3.mjs.map +0 -1
  359. package/dist/chunk-HWS4QSOC.mjs +0 -16
  360. package/dist/chunk-HWS4QSOC.mjs.map +0 -1
  361. package/dist/chunk-HXKBUIYS.js +0 -262
  362. package/dist/chunk-HXKBUIYS.js.map +0 -1
  363. package/dist/chunk-HXUJHX3E.mjs +0 -33
  364. package/dist/chunk-HXUJHX3E.mjs.map +0 -1
  365. package/dist/chunk-I5G4YFHM.js +0 -73
  366. package/dist/chunk-I5G4YFHM.js.map +0 -1
  367. package/dist/chunk-IX5S3V47.mjs +0 -26
  368. package/dist/chunk-IX5S3V47.mjs.map +0 -1
  369. package/dist/chunk-JDWYJ5UI.mjs +0 -33
  370. package/dist/chunk-JDWYJ5UI.mjs.map +0 -1
  371. package/dist/chunk-JOT5JH42.js +0 -52
  372. package/dist/chunk-JOT5JH42.js.map +0 -1
  373. package/dist/chunk-KEAB7ZVV.js +0 -50
  374. package/dist/chunk-KEAB7ZVV.js.map +0 -1
  375. package/dist/chunk-LO5ORVRC.js +0 -16
  376. package/dist/chunk-LO5ORVRC.js.map +0 -1
  377. package/dist/chunk-M3OBSGHF.mjs +0 -472
  378. package/dist/chunk-M3OBSGHF.mjs.map +0 -1
  379. package/dist/chunk-MCXWFCGV.js +0 -1
  380. package/dist/chunk-MCXWFCGV.js.map +0 -1
  381. package/dist/chunk-MIWGLICQ.mjs +0 -108
  382. package/dist/chunk-MIWGLICQ.mjs.map +0 -1
  383. package/dist/chunk-MMYM63NH.mjs +0 -82
  384. package/dist/chunk-MMYM63NH.mjs.map +0 -1
  385. package/dist/chunk-MS2LQQYH.js +0 -38
  386. package/dist/chunk-MS2LQQYH.js.map +0 -1
  387. package/dist/chunk-MXNMMTJW.mjs +0 -51
  388. package/dist/chunk-MXNMMTJW.mjs.map +0 -1
  389. package/dist/chunk-OBT45IWW.js +0 -92
  390. package/dist/chunk-OBT45IWW.js.map +0 -1
  391. package/dist/chunk-OCNPLHS2.js +0 -51
  392. package/dist/chunk-OCNPLHS2.js.map +0 -1
  393. package/dist/chunk-ODICKSGZ.mjs +0 -86
  394. package/dist/chunk-ODICKSGZ.mjs.map +0 -1
  395. package/dist/chunk-Q42NNJFY.mjs +0 -32
  396. package/dist/chunk-Q42NNJFY.mjs.map +0 -1
  397. package/dist/chunk-QZC2X6NG.js +0 -44
  398. package/dist/chunk-QZC2X6NG.js.map +0 -1
  399. package/dist/chunk-RACRYFWM.js +0 -45
  400. package/dist/chunk-RACRYFWM.js.map +0 -1
  401. package/dist/chunk-RD2APLK5.js +0 -33
  402. package/dist/chunk-RD2APLK5.js.map +0 -1
  403. package/dist/chunk-S5NWI5Z7.mjs +0 -50
  404. package/dist/chunk-S5NWI5Z7.mjs.map +0 -1
  405. package/dist/chunk-S7257EN3.mjs +0 -49
  406. package/dist/chunk-S7257EN3.mjs.map +0 -1
  407. package/dist/chunk-TSEAPB7L.mjs +0 -1
  408. package/dist/chunk-TSEAPB7L.mjs.map +0 -1
  409. package/dist/chunk-UOPIRTJX.mjs +0 -44
  410. package/dist/chunk-UOPIRTJX.mjs.map +0 -1
  411. package/dist/chunk-V76DI2XM.mjs +0 -183
  412. package/dist/chunk-V76DI2XM.mjs.map +0 -1
  413. package/dist/chunk-W7EDURT5.mjs +0 -92
  414. package/dist/chunk-W7EDURT5.mjs.map +0 -1
  415. package/dist/chunk-XPCW7TKM.mjs +0 -262
  416. package/dist/chunk-XPCW7TKM.mjs.map +0 -1
  417. package/dist/chunk-Y7AK2VVC.mjs +0 -52
  418. package/dist/chunk-Y7AK2VVC.mjs.map +0 -1
  419. package/dist/chunk-YRZVIDCF.mjs +0 -38
  420. package/dist/chunk-YRZVIDCF.mjs.map +0 -1
  421. package/dist/chunk-Z7BOREC4.js +0 -12
  422. package/dist/chunk-Z7BOREC4.js.map +0 -1
  423. package/dist/chunk-ZAYDLP42.js +0 -33
  424. package/dist/chunk-ZAYDLP42.js.map +0 -1
  425. package/dist/chunk-ZNTCZK7J.mjs +0 -30
  426. package/dist/chunk-ZNTCZK7J.mjs.map +0 -1
  427. package/dist/common/BaseSnapExecutor.js +0 -26
  428. package/dist/common/BaseSnapExecutor.js.map +0 -1
  429. package/dist/common/commands.js +0 -11
  430. package/dist/common/commands.js.map +0 -1
  431. package/dist/common/endowments/commonEndowmentFactory.js +0 -20
  432. package/dist/common/endowments/commonEndowmentFactory.js.map +0 -1
  433. package/dist/common/endowments/console.js +0 -13
  434. package/dist/common/endowments/console.js.map +0 -1
  435. package/dist/common/endowments/crypto.js +0 -11
  436. package/dist/common/endowments/crypto.js.map +0 -1
  437. package/dist/common/endowments/date.js +0 -9
  438. package/dist/common/endowments/date.js.map +0 -1
  439. package/dist/common/endowments/index.js +0 -21
  440. package/dist/common/endowments/index.js.map +0 -1
  441. package/dist/common/endowments/interval.js +0 -8
  442. package/dist/common/endowments/interval.js.map +0 -1
  443. package/dist/common/endowments/math.js +0 -10
  444. package/dist/common/endowments/math.js.map +0 -1
  445. package/dist/common/endowments/network.js +0 -10
  446. package/dist/common/endowments/network.js.map +0 -1
  447. package/dist/common/endowments/textDecoder.js +0 -8
  448. package/dist/common/endowments/textDecoder.js.map +0 -1
  449. package/dist/common/endowments/textEncoder.js +0 -8
  450. package/dist/common/endowments/textEncoder.js.map +0 -1
  451. package/dist/common/endowments/timeout.js +0 -8
  452. package/dist/common/endowments/timeout.js.map +0 -1
  453. package/dist/common/globalEvents.js +0 -11
  454. package/dist/common/globalEvents.js.map +0 -1
  455. package/dist/common/globalObject.js +0 -10
  456. package/dist/common/globalObject.js.map +0 -1
  457. package/dist/common/lockdown/lockdown-events.js +0 -8
  458. package/dist/common/lockdown/lockdown-events.js.map +0 -1
  459. package/dist/common/lockdown/lockdown-more.js +0 -8
  460. package/dist/common/lockdown/lockdown-more.js.map +0 -1
  461. package/dist/common/lockdown/lockdown.js +0 -22
  462. package/dist/common/lockdown/lockdown.js.map +0 -1
  463. package/dist/common/sortParams.js +0 -8
  464. package/dist/common/sortParams.js.map +0 -1
  465. package/dist/common/utils.js +0 -21
  466. package/dist/common/utils.js.map +0 -1
  467. package/dist/common/validation.js +0 -38
  468. package/dist/common/validation.js.map +0 -1
  469. package/dist/globals.d.js +0 -1
  470. package/dist/globals.d.js.map +0 -1
  471. package/dist/globals.d.mjs +0 -1
  472. package/dist/globals.d.mjs.map +0 -1
  473. package/dist/iframe/IFrameSnapExecutor.js +0 -27
  474. package/dist/iframe/IFrameSnapExecutor.js.map +0 -1
  475. package/dist/iframe/index.js +0 -35
  476. package/dist/iframe/index.js.map +0 -1
  477. package/dist/index.js +0 -9
  478. package/dist/index.js.map +0 -1
  479. package/dist/logging.js +0 -8
  480. package/dist/logging.js.map +0 -1
  481. package/dist/node-process/ChildProcessSnapExecutor.js +0 -27
  482. package/dist/node-process/ChildProcessSnapExecutor.js.map +0 -1
  483. package/dist/node-process/index.js +0 -31
  484. package/dist/node-process/index.js.map +0 -1
  485. package/dist/node-thread/ThreadSnapExecutor.js +0 -27
  486. package/dist/node-thread/ThreadSnapExecutor.js.map +0 -1
  487. package/dist/node-thread/index.js +0 -31
  488. package/dist/node-thread/index.js.map +0 -1
  489. package/dist/proxy/ProxySnapExecutor.js +0 -8
  490. package/dist/proxy/ProxySnapExecutor.js.map +0 -1
  491. package/dist/proxy/index.js +0 -9
  492. package/dist/proxy/index.js.map +0 -1
  493. package/dist/tsconfig.build.tsbuildinfo +0 -1
  494. package/dist/types/iframe/index.d.ts +0 -1
  495. package/dist/types/index.d.ts +0 -1
  496. package/dist/types/node-process/index.d.ts +0 -1
  497. package/dist/types/node-thread/ThreadSnapExecutor.d.ts +0 -4
  498. package/dist/types/node-thread/index.d.ts +0 -1
  499. package/dist/types/proxy/index.d.ts +0 -1
  500. package/dist/types/vendor/global.d.js +0 -1
  501. package/dist/types/vendor/global.d.js.map +0 -1
  502. package/dist/types/vendor/global.d.mjs +0 -1
  503. package/dist/types/vendor/global.d.mjs.map +0 -1
  504. package/dist/types/vendor/providers.d.js +0 -1
  505. package/dist/types/vendor/providers.d.js.map +0 -1
  506. package/dist/types/vendor/providers.d.mjs +0 -1
  507. package/dist/types/vendor/providers.d.mjs.map +0 -1
  508. package/dist/types/vendor/readable-stream.d.js +0 -1
  509. package/dist/types/vendor/readable-stream.d.js.map +0 -1
  510. package/dist/types/vendor/readable-stream.d.mjs +0 -1
  511. package/dist/types/vendor/readable-stream.d.mjs.map +0 -1
  512. package/dist/types/webview/index.d.ts +0 -1
  513. package/dist/types/webworker/executor/index.d.ts +0 -1
  514. package/dist/types/webworker/pool/index.d.ts +0 -1
  515. package/dist/webview/WebViewExecutorStream.js +0 -8
  516. package/dist/webview/WebViewExecutorStream.js.map +0 -1
  517. package/dist/webview/index.js +0 -26
  518. package/dist/webview/index.js.map +0 -1
  519. package/dist/webworker/executor/WebWorkerSnapExecutor.js +0 -27
  520. package/dist/webworker/executor/WebWorkerSnapExecutor.js.map +0 -1
  521. package/dist/webworker/executor/index.js +0 -35
  522. package/dist/webworker/executor/index.js.map +0 -1
  523. package/dist/webworker/pool/WebWorkerPool.js +0 -8
  524. package/dist/webworker/pool/WebWorkerPool.js.map +0 -1
  525. package/dist/webworker/pool/index.js +0 -16
  526. package/dist/webworker/pool/index.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.cts","sourceRoot":"","sources":["../../src/common/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,8BAA8B;AAGpD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,+BAA2B;AACrE,OAAO,KAAK,EACV,WAAW,EACX,uBAAuB,EACvB,IAAI,EAEJ,OAAO,EACP,SAAS,EACV,yBAAqB;AAQtB,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,uBAAuB,GAC/B,cAAc,CA6DhB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,EAC9D,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,IAAI,GACtB,qBAAqB,CAuBvB"}
@@ -0,0 +1,31 @@
1
+ import { HandlerType } from "@metamask/snaps-utils";
2
+ import type { InvokeSnap, InvokeSnapArgs } from "./BaseSnapExecutor.mjs";
3
+ import type { ExecuteSnap, JsonRpcRequestWithoutId, Ping, SnapRpc, Terminate } from "./validation.mjs";
4
+ export type CommandMethodsMapping = {
5
+ ping: Ping;
6
+ terminate: Terminate;
7
+ executeSnap: ExecuteSnap;
8
+ snapRpc: SnapRpc;
9
+ };
10
+ /**
11
+ * Formats the arguments for the given handler.
12
+ *
13
+ * @param origin - The origin of the request.
14
+ * @param handler - The handler to pass the request to.
15
+ * @param request - The request object.
16
+ * @returns The formatted arguments.
17
+ */
18
+ export declare function getHandlerArguments(origin: string, handler: HandlerType, request: JsonRpcRequestWithoutId): InvokeSnapArgs;
19
+ /**
20
+ * Gets an object mapping internal, "command" JSON-RPC method names to their
21
+ * implementations.
22
+ *
23
+ * @param startSnap - A function that starts a snap.
24
+ * @param invokeSnap - A function that invokes the RPC method handler of a
25
+ * snap.
26
+ * @param onTerminate - A function that will be called when this executor is
27
+ * terminated in order to handle cleanup tasks.
28
+ * @returns An object containing the "command" method implementations.
29
+ */
30
+ export declare function getCommandMethodImplementations(startSnap: (...args: Parameters<ExecuteSnap>) => Promise<void>, invokeSnap: InvokeSnap, onTerminate: () => void): CommandMethodsMapping;
31
+ //# sourceMappingURL=commands.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.mts","sourceRoot":"","sources":["../../src/common/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,8BAA8B;AAGpD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,+BAA2B;AACrE,OAAO,KAAK,EACV,WAAW,EACX,uBAAuB,EACvB,IAAI,EAEJ,OAAO,EACP,SAAS,EACV,yBAAqB;AAQtB,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,uBAAuB,GAC/B,cAAc,CA6DhB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,EAC9D,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,IAAI,GACtB,qBAAqB,CAuBvB"}
@@ -1,11 +1,90 @@
1
- import {
2
- getCommandMethodImplementations,
3
- getHandlerArguments
4
- } from "../chunk-MMYM63NH.mjs";
5
- import "../chunk-75RCH4ZX.mjs";
6
- import "../chunk-YRZVIDCF.mjs";
7
- export {
8
- getCommandMethodImplementations,
9
- getHandlerArguments
10
- };
1
+ import { HandlerType } from "@metamask/snaps-utils";
2
+ import { assertExhaustive } from "@metamask/utils";
3
+ import { assertIsOnTransactionRequestArguments, assertIsOnSignatureRequestArguments, assertIsOnNameLookupRequestArguments, assertIsOnUserInputRequestArguments } from "./validation.mjs";
4
+ /**
5
+ * Formats the arguments for the given handler.
6
+ *
7
+ * @param origin - The origin of the request.
8
+ * @param handler - The handler to pass the request to.
9
+ * @param request - The request object.
10
+ * @returns The formatted arguments.
11
+ */
12
+ export function getHandlerArguments(origin, handler, request) {
13
+ // `request` is already validated by the time this function is called.
14
+ switch (handler) {
15
+ case HandlerType.OnTransaction: {
16
+ assertIsOnTransactionRequestArguments(request.params);
17
+ const { transaction, chainId, transactionOrigin } = request.params;
18
+ return {
19
+ transaction,
20
+ chainId,
21
+ transactionOrigin,
22
+ };
23
+ }
24
+ case HandlerType.OnSignature: {
25
+ assertIsOnSignatureRequestArguments(request.params);
26
+ const { signature, signatureOrigin } = request.params;
27
+ return { signature, signatureOrigin };
28
+ }
29
+ case HandlerType.OnNameLookup: {
30
+ assertIsOnNameLookupRequestArguments(request.params);
31
+ // TS complains that domain/address are not part of the type
32
+ // casting here as we've already validated the request args in the above step.
33
+ const { chainId, domain, address } = request.params;
34
+ return domain
35
+ ? {
36
+ chainId,
37
+ domain,
38
+ }
39
+ : {
40
+ chainId,
41
+ address,
42
+ };
43
+ }
44
+ case HandlerType.OnRpcRequest:
45
+ case HandlerType.OnKeyringRequest:
46
+ return { origin, request };
47
+ case HandlerType.OnCronjob:
48
+ return { request };
49
+ case HandlerType.OnInstall:
50
+ case HandlerType.OnUpdate:
51
+ return { origin };
52
+ case HandlerType.OnHomePage:
53
+ return {};
54
+ case HandlerType.OnUserInput: {
55
+ assertIsOnUserInputRequestArguments(request.params);
56
+ const { id, event, context } = request.params;
57
+ return { id, event, context };
58
+ }
59
+ default:
60
+ return assertExhaustive(handler);
61
+ }
62
+ }
63
+ /**
64
+ * Gets an object mapping internal, "command" JSON-RPC method names to their
65
+ * implementations.
66
+ *
67
+ * @param startSnap - A function that starts a snap.
68
+ * @param invokeSnap - A function that invokes the RPC method handler of a
69
+ * snap.
70
+ * @param onTerminate - A function that will be called when this executor is
71
+ * terminated in order to handle cleanup tasks.
72
+ * @returns An object containing the "command" method implementations.
73
+ */
74
+ export function getCommandMethodImplementations(startSnap, invokeSnap, onTerminate) {
75
+ return {
76
+ ping: async () => Promise.resolve('OK'),
77
+ terminate: async () => {
78
+ onTerminate();
79
+ return Promise.resolve('OK');
80
+ },
81
+ executeSnap: async (snapId, sourceCode, endowments) => {
82
+ await startSnap(snapId, sourceCode, endowments);
83
+ return 'OK';
84
+ },
85
+ snapRpc: async (target, handler, origin, request) => {
86
+ return ((await invokeSnap(target, handler, getHandlerArguments(origin, handler, request))) ?? null);
87
+ },
88
+ };
89
+ }
11
90
  //# sourceMappingURL=commands.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"commands.mjs","sourceRoot":"","sources":["../../src/common/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,8BAA8B;AACpD,OAAO,EAAE,gBAAgB,EAAE,wBAAwB;AAWnD,OAAO,EACL,qCAAqC,EACrC,mCAAmC,EACnC,oCA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port { assertExhaustive } from '@metamask/utils';\n\nimport type { InvokeSnap, InvokeSnapArgs } from './BaseSnapExecutor';\nimport type {\n ExecuteSnap,\n JsonRpcRequestWithoutId,\n Ping,\n PossibleLookupRequestArgs,\n SnapRpc,\n Terminate,\n} from './validation';\nimport {\n assertIsOnTransactionRequestArguments,\n assertIsOnSignatureRequestArguments,\n assertIsOnNameLookupRequestArguments,\n assertIsOnUserInputRequestArguments,\n} from './validation';\n\nexport type CommandMethodsMapping = {\n ping: Ping;\n terminate: Terminate;\n executeSnap: ExecuteSnap;\n snapRpc: SnapRpc;\n};\n\n/**\n * Formats the arguments for the given handler.\n *\n * @param origin - The origin of the request.\n * @param handler - The handler to pass the request to.\n * @param request - The request object.\n * @returns The formatted arguments.\n */\nexport function getHandlerArguments(\n origin: string,\n handler: HandlerType,\n request: JsonRpcRequestWithoutId,\n): InvokeSnapArgs {\n // `request` is already validated by the time this function is called.\n\n switch (handler) {\n case HandlerType.OnTransaction: {\n assertIsOnTransactionRequestArguments(request.params);\n\n const { transaction, chainId, transactionOrigin } = request.params;\n return {\n transaction,\n chainId,\n transactionOrigin,\n };\n }\n case HandlerType.OnSignature: {\n assertIsOnSignatureRequestArguments(request.params);\n\n const { signature, signatureOrigin } = request.params;\n return { signature, signatureOrigin };\n }\n case HandlerType.OnNameLookup: {\n assertIsOnNameLookupRequestArguments(request.params);\n\n // TS complains that domain/address are not part of the type\n // casting here as we've already validated the request args in the above step.\n const { chainId, domain, address } =\n request.params as unknown as PossibleLookupRequestArgs;\n\n return domain\n ? {\n chainId,\n domain,\n }\n : {\n chainId,\n address,\n };\n }\n case HandlerType.OnRpcRequest:\n case HandlerType.OnKeyringRequest:\n return { origin, request };\n\n case HandlerType.OnCronjob:\n return { request };\n\n case HandlerType.OnInstall:\n case HandlerType.OnUpdate:\n return { origin };\n\n case HandlerType.OnHomePage:\n return {};\n case HandlerType.OnUserInput: {\n assertIsOnUserInputRequestArguments(request.params);\n\n const { id, event, context } = request.params;\n return { id, event, context };\n }\n\n default:\n return assertExhaustive(handler);\n }\n}\n\n/**\n * Gets an object mapping internal, \"command\" JSON-RPC method names to their\n * implementations.\n *\n * @param startSnap - A function that starts a snap.\n * @param invokeSnap - A function that invokes the RPC method handler of a\n * snap.\n * @param onTerminate - A function that will be called when this executor is\n * terminated in order to handle cleanup tasks.\n * @returns An object containing the \"command\" method implementations.\n */\nexport function getCommandMethodImplementations(\n startSnap: (...args: Parameters<ExecuteSnap>) => Promise<void>,\n invokeSnap: InvokeSnap,\n onTerminate: () => void,\n): CommandMethodsMapping {\n return {\n ping: async () => Promise.resolve('OK'),\n terminate: async () => {\n onTerminate();\n return Promise.resolve('OK');\n },\n\n executeSnap: async (snapId, sourceCode, endowments) => {\n await startSnap(snapId, sourceCode, endowments);\n return 'OK';\n },\n\n snapRpc: async (target, handler, origin, request) => {\n return (\n (await invokeSnap(\n target,\n handler,\n getHandlerArguments(origin, handler, request),\n )) ?? null\n );\n },\n };\n}\n"]}
@@ -0,0 +1,76 @@
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
+ const globalObject_1 = require("../globalObject.cjs");
7
+ const console_1 = __importDefault(require("./console.cjs"));
8
+ const crypto_1 = __importDefault(require("./crypto.cjs"));
9
+ const date_1 = __importDefault(require("./date.cjs"));
10
+ const interval_1 = __importDefault(require("./interval.cjs"));
11
+ const math_1 = __importDefault(require("./math.cjs"));
12
+ const network_1 = __importDefault(require("./network.cjs"));
13
+ const textDecoder_1 = __importDefault(require("./textDecoder.cjs"));
14
+ const textEncoder_1 = __importDefault(require("./textEncoder.cjs"));
15
+ const timeout_1 = __importDefault(require("./timeout.cjs"));
16
+ // Array of common endowments
17
+ const commonEndowments = [
18
+ { endowment: AbortController, name: 'AbortController' },
19
+ { endowment: AbortSignal, name: 'AbortSignal' },
20
+ { endowment: ArrayBuffer, name: 'ArrayBuffer' },
21
+ { endowment: atob, name: 'atob', bind: true },
22
+ { endowment: BigInt, name: 'BigInt' },
23
+ { endowment: BigInt64Array, name: 'BigInt64Array' },
24
+ { endowment: BigUint64Array, name: 'BigUint64Array' },
25
+ { endowment: btoa, name: 'btoa', bind: true },
26
+ { endowment: DataView, name: 'DataView' },
27
+ { endowment: Float32Array, name: 'Float32Array' },
28
+ { endowment: Float64Array, name: 'Float64Array' },
29
+ { endowment: Int8Array, name: 'Int8Array' },
30
+ { endowment: Int16Array, name: 'Int16Array' },
31
+ { endowment: Int32Array, name: 'Int32Array' },
32
+ { endowment: Uint8Array, name: 'Uint8Array' },
33
+ { endowment: Uint8ClampedArray, name: 'Uint8ClampedArray' },
34
+ { endowment: Uint16Array, name: 'Uint16Array' },
35
+ { endowment: Uint32Array, name: 'Uint32Array' },
36
+ { endowment: URL, name: 'URL' },
37
+ { endowment: WebAssembly, name: 'WebAssembly' },
38
+ ];
39
+ /**
40
+ * Creates a consolidated collection of common endowments.
41
+ * This function will return factories for all common endowments including
42
+ * the additionally attenuated. All hardened with SES.
43
+ *
44
+ * @returns An object with common endowments.
45
+ */
46
+ const buildCommonEndowments = () => {
47
+ const endowmentFactories = [
48
+ crypto_1.default,
49
+ interval_1.default,
50
+ math_1.default,
51
+ network_1.default,
52
+ timeout_1.default,
53
+ textDecoder_1.default,
54
+ textEncoder_1.default,
55
+ date_1.default,
56
+ console_1.default,
57
+ ];
58
+ commonEndowments.forEach((endowmentSpecification) => {
59
+ const endowment = {
60
+ names: [endowmentSpecification.name],
61
+ factory: () => {
62
+ const boundEndowment = typeof endowmentSpecification.endowment === 'function' &&
63
+ endowmentSpecification.bind
64
+ ? endowmentSpecification.endowment.bind(globalObject_1.rootRealmGlobal)
65
+ : endowmentSpecification.endowment;
66
+ return {
67
+ [endowmentSpecification.name]: harden(boundEndowment),
68
+ };
69
+ },
70
+ };
71
+ endowmentFactories.push(endowment);
72
+ });
73
+ return endowmentFactories;
74
+ };
75
+ exports.default = buildCommonEndowments;
76
+ //# sourceMappingURL=commonEndowmentFactory.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commonEndowmentFactory.cjs","sourceRoot":"","sources":["../../../src/common/endowments/commonEndowmentFactory.ts"],"names":[],"mappings":";;;;;AACA,sDAAkD;AAClD,4DAAyC;AACzC,0DAA8B;AAC9B,sDAA0B;AAC1B,8DAAkC;AAClC,sDAA0B;AAC1B,4DAAgC;AAChC,oEAAwC;AACxC,oEAAwC;AACxC,4DAAgC;AAkBhC,6BAA6B;AAC7B,MAAM,gBAAgB,GAAmC;IACvD,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACvD,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE;IAC/C,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE;IAC/C,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;IAC7C,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;IACrC,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,eAAe,EAAE;IACnD,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,EAAE;IACrD,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;IAC7C,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE;IACzC,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE;IACjD,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE;IACjD,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE;IAC3C,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE;IAC7C,EAAE,SAAS,EAAE,UA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CAAC;AAEF,kBAAe,qBAAqB,CAAC","sourcesContent":["import type { NotifyFunction } from '../BaseSnapExecutor';\nimport { rootRealmGlobal } from '../globalObject';\nimport consoleEndowment from './console';\nimport crypto from './crypto';\nimport date from './date';\nimport interval from './interval';\nimport math from './math';\nimport network from './network';\nimport textDecoder from './textDecoder';\nimport textEncoder from './textEncoder';\nimport timeout from './timeout';\n\nexport type EndowmentFactoryOptions = {\n snapId?: string;\n notify?: NotifyFunction;\n};\n\nexport type EndowmentFactory = {\n names: readonly string[];\n factory: (options?: EndowmentFactoryOptions) => { [key: string]: unknown };\n};\n\nexport type CommonEndowmentSpecification = {\n endowment: unknown;\n name: string;\n bind?: boolean;\n};\n\n// Array of common endowments\nconst commonEndowments: CommonEndowmentSpecification[] = [\n { endowment: AbortController, name: 'AbortController' },\n { endowment: AbortSignal, name: 'AbortSignal' },\n { endowment: ArrayBuffer, name: 'ArrayBuffer' },\n { endowment: atob, name: 'atob', bind: true },\n { endowment: BigInt, name: 'BigInt' },\n { endowment: BigInt64Array, name: 'BigInt64Array' },\n { endowment: BigUint64Array, name: 'BigUint64Array' },\n { endowment: btoa, name: 'btoa', bind: true },\n { endowment: DataView, name: 'DataView' },\n { endowment: Float32Array, name: 'Float32Array' },\n { endowment: Float64Array, name: 'Float64Array' },\n { endowment: Int8Array, name: 'Int8Array' },\n { endowment: Int16Array, name: 'Int16Array' },\n { endowment: Int32Array, name: 'Int32Array' },\n { endowment: Uint8Array, name: 'Uint8Array' },\n { endowment: Uint8ClampedArray, name: 'Uint8ClampedArray' },\n { endowment: Uint16Array, name: 'Uint16Array' },\n { endowment: Uint32Array, name: 'Uint32Array' },\n { endowment: URL, name: 'URL' },\n { endowment: WebAssembly, name: 'WebAssembly' },\n];\n\n/**\n * Creates a consolidated collection of common endowments.\n * This function will return factories for all common endowments including\n * the additionally attenuated. All hardened with SES.\n *\n * @returns An object with common endowments.\n */\nconst buildCommonEndowments = (): EndowmentFactory[] => {\n const endowmentFactories: EndowmentFactory[] = [\n crypto,\n interval,\n math,\n network,\n timeout,\n textDecoder,\n textEncoder,\n date,\n consoleEndowment,\n ];\n\n commonEndowments.forEach((endowmentSpecification) => {\n const endowment = {\n names: [endowmentSpecification.name] as const,\n factory: () => {\n const boundEndowment =\n typeof endowmentSpecification.endowment === 'function' &&\n endowmentSpecification.bind\n ? endowmentSpecification.endowment.bind(rootRealmGlobal)\n : endowmentSpecification.endowment;\n return {\n [endowmentSpecification.name]: harden(boundEndowment),\n } as const;\n },\n };\n endowmentFactories.push(endowment);\n });\n\n return endowmentFactories;\n};\n\nexport default buildCommonEndowments;\n"]}
@@ -1,15 +1,15 @@
1
- import type { NotifyFunction } from '../BaseSnapExecutor';
2
- export declare type EndowmentFactoryOptions = {
1
+ import type { NotifyFunction } from "../BaseSnapExecutor.cjs";
2
+ export type EndowmentFactoryOptions = {
3
3
  snapId?: string;
4
4
  notify?: NotifyFunction;
5
5
  };
6
- export declare type EndowmentFactory = {
6
+ export type EndowmentFactory = {
7
7
  names: readonly string[];
8
8
  factory: (options?: EndowmentFactoryOptions) => {
9
9
  [key: string]: unknown;
10
10
  };
11
11
  };
12
- export declare type CommonEndowmentSpecification = {
12
+ export type CommonEndowmentSpecification = {
13
13
  endowment: unknown;
14
14
  name: string;
15
15
  bind?: boolean;
@@ -23,3 +23,4 @@ export declare type CommonEndowmentSpecification = {
23
23
  */
24
24
  declare const buildCommonEndowments: () => EndowmentFactory[];
25
25
  export default buildCommonEndowments;
26
+ //# sourceMappingURL=commonEndowmentFactory.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commonEndowmentFactory.d.cts","sourceRoot":"","sources":["../../../src/common/endowments/commonEndowmentFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gCAA4B;AAY1D,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,uBAAuB,KAAK;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CAC5E,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AA0BF;;;;;;GAMG;AACH,QAAA,MAAM,qBAAqB,QAAO,gBAAgB,EA+BjD,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { NotifyFunction } from "../BaseSnapExecutor.mjs";
2
+ export type EndowmentFactoryOptions = {
3
+ snapId?: string;
4
+ notify?: NotifyFunction;
5
+ };
6
+ export type EndowmentFactory = {
7
+ names: readonly string[];
8
+ factory: (options?: EndowmentFactoryOptions) => {
9
+ [key: string]: unknown;
10
+ };
11
+ };
12
+ export type CommonEndowmentSpecification = {
13
+ endowment: unknown;
14
+ name: string;
15
+ bind?: boolean;
16
+ };
17
+ /**
18
+ * Creates a consolidated collection of common endowments.
19
+ * This function will return factories for all common endowments including
20
+ * the additionally attenuated. All hardened with SES.
21
+ *
22
+ * @returns An object with common endowments.
23
+ */
24
+ declare const buildCommonEndowments: () => EndowmentFactory[];
25
+ export default buildCommonEndowments;
26
+ //# sourceMappingURL=commonEndowmentFactory.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commonEndowmentFactory.d.mts","sourceRoot":"","sources":["../../../src/common/endowments/commonEndowmentFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gCAA4B;AAY1D,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,uBAAuB,KAAK;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CAC5E,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AA0BF;;;;;;GAMG;AACH,QAAA,MAAM,qBAAqB,QAAO,gBAAgB,EA+BjD,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -1,20 +1,71 @@
1
- import {
2
- commonEndowmentFactory_default
3
- } from "../../chunk-ODICKSGZ.mjs";
4
- import "../../chunk-S5NWI5Z7.mjs";
5
- import "../../chunk-BCBKEUCG.mjs";
6
- import "../../chunk-XPCW7TKM.mjs";
7
- import "../../chunk-53ZULHPK.mjs";
8
- import "../../chunk-HWS4QSOC.mjs";
9
- import "../../chunk-Y7AK2VVC.mjs";
10
- import "../../chunk-W7EDURT5.mjs";
11
- import "../../chunk-Q42NNJFY.mjs";
12
- import "../../chunk-UOPIRTJX.mjs";
13
- import "../../chunk-HL2TTKF3.mjs";
14
- import "../../chunk-5DEV3QQU.mjs";
15
- import "../../chunk-IX5S3V47.mjs";
16
- import "../../chunk-YRZVIDCF.mjs";
17
- export {
18
- commonEndowmentFactory_default as default
1
+ import { rootRealmGlobal } from "../globalObject.mjs";
2
+ import consoleEndowment from "./console.mjs";
3
+ import crypto from "./crypto.mjs";
4
+ import date from "./date.mjs";
5
+ import interval from "./interval.mjs";
6
+ import math from "./math.mjs";
7
+ import network from "./network.mjs";
8
+ import textDecoder from "./textDecoder.mjs";
9
+ import textEncoder from "./textEncoder.mjs";
10
+ import timeout from "./timeout.mjs";
11
+ // Array of common endowments
12
+ const commonEndowments = [
13
+ { endowment: AbortController, name: 'AbortController' },
14
+ { endowment: AbortSignal, name: 'AbortSignal' },
15
+ { endowment: ArrayBuffer, name: 'ArrayBuffer' },
16
+ { endowment: atob, name: 'atob', bind: true },
17
+ { endowment: BigInt, name: 'BigInt' },
18
+ { endowment: BigInt64Array, name: 'BigInt64Array' },
19
+ { endowment: BigUint64Array, name: 'BigUint64Array' },
20
+ { endowment: btoa, name: 'btoa', bind: true },
21
+ { endowment: DataView, name: 'DataView' },
22
+ { endowment: Float32Array, name: 'Float32Array' },
23
+ { endowment: Float64Array, name: 'Float64Array' },
24
+ { endowment: Int8Array, name: 'Int8Array' },
25
+ { endowment: Int16Array, name: 'Int16Array' },
26
+ { endowment: Int32Array, name: 'Int32Array' },
27
+ { endowment: Uint8Array, name: 'Uint8Array' },
28
+ { endowment: Uint8ClampedArray, name: 'Uint8ClampedArray' },
29
+ { endowment: Uint16Array, name: 'Uint16Array' },
30
+ { endowment: Uint32Array, name: 'Uint32Array' },
31
+ { endowment: URL, name: 'URL' },
32
+ { endowment: WebAssembly, name: 'WebAssembly' },
33
+ ];
34
+ /**
35
+ * Creates a consolidated collection of common endowments.
36
+ * This function will return factories for all common endowments including
37
+ * the additionally attenuated. All hardened with SES.
38
+ *
39
+ * @returns An object with common endowments.
40
+ */
41
+ const buildCommonEndowments = () => {
42
+ const endowmentFactories = [
43
+ crypto,
44
+ interval,
45
+ math,
46
+ network,
47
+ timeout,
48
+ textDecoder,
49
+ textEncoder,
50
+ date,
51
+ consoleEndowment,
52
+ ];
53
+ commonEndowments.forEach((endowmentSpecification) => {
54
+ const endowment = {
55
+ names: [endowmentSpecification.name],
56
+ factory: () => {
57
+ const boundEndowment = typeof endowmentSpecification.endowment === 'function' &&
58
+ endowmentSpecification.bind
59
+ ? endowmentSpecification.endowment.bind(rootRealmGlobal)
60
+ : endowmentSpecification.endowment;
61
+ return {
62
+ [endowmentSpecification.name]: harden(boundEndowment),
63
+ };
64
+ },
65
+ };
66
+ endowmentFactories.push(endowment);
67
+ });
68
+ return endowmentFactories;
19
69
  };
70
+ export default buildCommonEndowments;
20
71
  //# sourceMappingURL=commonEndowmentFactory.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"commonEndowmentFactory.mjs","sourceRoot":"","sources":["../../../src/common/endowments/commonEndowmentFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,4BAAwB;AAClD,OAAO,gBAAgB,sBAAkB;AACzC,OAAO,MAAM,qBAAiB;AAC9B,OAAO,IAAI,mBAAe;AAC1B,OAAO,QAAQ,uBAAmB;AAClC,OAAO,IAAI,mBAAe;AAC1B,OAAO,OAAO,sBAAkB;AAChC,OAAO,WAAW,0BAAsB;AACxC,OAAO,WAAW,0BAAsB;AACxC,OAAO,OAAO,sBAAkB;AAkBhC,6BAA6B;AAC7B,MAAM,gBAAgB,GAAmC;IACvD,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACvD,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE;IAC/C,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE;IAC/C,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;IAC7C,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;IACrC,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,eAAe,EAAE;IACnD,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,EAAE;IACrD,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;IAC7C,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE;IACzC,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc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C,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;iBAC7C,CAAC;YACb,CAAC;SACF,CAAC;QACF,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC;AAEF,eAAe,qBAAqB,CAAC","sourcesContent":["import type { NotifyFunction } from '../BaseSnapExecutor';\nimport { rootRealmGlobal } from '../globalObject';\nimport consoleEndowment from './console';\nimport crypto from './crypto';\nimport date from './date';\nimport interval from './interval';\nimport math from './math';\nimport network from './network';\nimport textDecoder from './textDecoder';\nimport textEncoder from './textEncoder';\nimport timeout from './timeout';\n\nexport type EndowmentFactoryOptions = {\n snapId?: string;\n notify?: NotifyFunction;\n};\n\nexport type EndowmentFactory = {\n names: readonly string[];\n factory: (options?: EndowmentFactoryOptions) => { [key: string]: unknown };\n};\n\nexport type CommonEndowmentSpecification = {\n endowment: unknown;\n name: string;\n bind?: boolean;\n};\n\n// Array of common endowments\nconst commonEndowments: CommonEndowmentSpecification[] = [\n { endowment: AbortController, name: 'AbortController' },\n { endowment: AbortSignal, name: 'AbortSignal' },\n { endowment: ArrayBuffer, name: 'ArrayBuffer' },\n { endowment: atob, name: 'atob', bind: true },\n { endowment: BigInt, name: 'BigInt' },\n { endowment: BigInt64Array, name: 'BigInt64Array' },\n { endowment: BigUint64Array, name: 'BigUint64Array' },\n { endowment: btoa, name: 'btoa', bind: true },\n { endowment: DataView, name: 'DataView' },\n { endowment: Float32Array, name: 'Float32Array' },\n { endowment: Float64Array, name: 'Float64Array' },\n { endowment: Int8Array, name: 'Int8Array' },\n { endowment: Int16Array, name: 'Int16Array' },\n { endowment: Int32Array, name: 'Int32Array' },\n { endowment: Uint8Array, name: 'Uint8Array' },\n { endowment: Uint8ClampedArray, name: 'Uint8ClampedArray' },\n { endowment: Uint16Array, name: 'Uint16Array' },\n { endowment: Uint32Array, name: 'Uint32Array' },\n { endowment: URL, name: 'URL' },\n { endowment: WebAssembly, name: 'WebAssembly' },\n];\n\n/**\n * Creates a consolidated collection of common endowments.\n * This function will return factories for all common endowments including\n * the additionally attenuated. All hardened with SES.\n *\n * @returns An object with common endowments.\n */\nconst buildCommonEndowments = (): EndowmentFactory[] => {\n const endowmentFactories: EndowmentFactory[] = [\n crypto,\n interval,\n math,\n network,\n timeout,\n textDecoder,\n textEncoder,\n date,\n consoleEndowment,\n ];\n\n commonEndowments.forEach((endowmentSpecification) => {\n const endowment = {\n names: [endowmentSpecification.name] as const,\n factory: () => {\n const boundEndowment =\n typeof endowmentSpecification.endowment === 'function' &&\n endowmentSpecification.bind\n ? endowmentSpecification.endowment.bind(rootRealmGlobal)\n : endowmentSpecification.endowment;\n return {\n [endowmentSpecification.name]: harden(boundEndowment),\n } as const;\n },\n };\n endowmentFactories.push(endowment);\n });\n\n return endowmentFactories;\n};\n\nexport default buildCommonEndowments;\n"]}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.consoleMethods = exports.consoleAttenuatedMethods = void 0;
4
+ const utils_1 = require("@metamask/utils");
5
+ const globalObject_1 = require("../globalObject.cjs");
6
+ exports.consoleAttenuatedMethods = new Set([
7
+ 'log',
8
+ 'assert',
9
+ 'error',
10
+ 'debug',
11
+ 'info',
12
+ 'warn',
13
+ ]);
14
+ /**
15
+ * A set of all the `console` values that will be passed to the snap. This has
16
+ * all the values that are available in both the browser and Node.js.
17
+ */
18
+ exports.consoleMethods = new Set([
19
+ 'debug',
20
+ 'error',
21
+ 'info',
22
+ 'log',
23
+ 'warn',
24
+ 'dir',
25
+ 'dirxml',
26
+ 'table',
27
+ 'trace',
28
+ 'group',
29
+ 'groupCollapsed',
30
+ 'groupEnd',
31
+ 'clear',
32
+ 'count',
33
+ 'countReset',
34
+ 'assert',
35
+ 'profile',
36
+ 'profileEnd',
37
+ 'time',
38
+ 'timeLog',
39
+ 'timeEnd',
40
+ 'timeStamp',
41
+ 'context',
42
+ ]);
43
+ const consoleFunctions = ['log', 'error', 'debug', 'info', 'warn'];
44
+ /**
45
+ * Gets the appropriate (prepended) message to pass to one of the attenuated
46
+ * method calls.
47
+ *
48
+ * @param snapId - Id of the snap that we're getting a message for.
49
+ * @param message - The id of the snap that will interact with the endowment.
50
+ * @param args - The array of additional arguments.
51
+ * @returns An array of arguments to be passed into an attenuated console method call.
52
+ */
53
+ function getMessage(snapId, message, ...args) {
54
+ const prefix = `[Snap: ${snapId}]`;
55
+ // If the first argument is a string, prepend the prefix to the message, and keep the
56
+ // rest of the arguments as-is.
57
+ if (typeof message === 'string') {
58
+ return [`${prefix} ${message}`, ...args];
59
+ }
60
+ // Otherwise, the `message` is an object, array, etc., so add the prefix as a separate
61
+ // message to the arguments.
62
+ return [prefix, message, ...args];
63
+ }
64
+ /**
65
+ * Create a a {@link console} object, with the same properties as the global
66
+ * {@link console} object, but with some methods replaced.
67
+ *
68
+ * @param options - Factory options used in construction of the endowment.
69
+ * @param options.snapId - The id of the snap that will interact with the endowment.
70
+ * @returns The {@link console} object with the replaced methods.
71
+ */
72
+ function createConsole({ snapId } = {}) {
73
+ (0, utils_1.assert)(snapId !== undefined);
74
+ const keys = Object.getOwnPropertyNames(globalObject_1.rootRealmGlobal.console);
75
+ const attenuatedConsole = keys.reduce((target, key) => {
76
+ if (exports.consoleMethods.has(key) && !exports.consoleAttenuatedMethods.has(key)) {
77
+ return { ...target, [key]: globalObject_1.rootRealmGlobal.console[key] };
78
+ }
79
+ return target;
80
+ }, {});
81
+ return harden({
82
+ console: {
83
+ ...attenuatedConsole,
84
+ assert: (value, message, ...optionalParams) => {
85
+ globalObject_1.rootRealmGlobal.console.assert(value, ...getMessage(snapId, message, ...optionalParams));
86
+ },
87
+ ...consoleFunctions.reduce((target, key) => {
88
+ return {
89
+ ...target,
90
+ [key]: (message, ...optionalParams) => {
91
+ globalObject_1.rootRealmGlobal.console[key](...getMessage(snapId, message, ...optionalParams));
92
+ },
93
+ };
94
+ }, {}),
95
+ },
96
+ });
97
+ }
98
+ const endowmentModule = {
99
+ names: ['console'],
100
+ factory: createConsole,
101
+ };
102
+ exports.default = endowmentModule;
103
+ //# sourceMappingURL=console.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.cjs","sourceRoot":"","sources":["../../../src/common/endowments/console.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAEzC,sDAAkD;AAGrC,QAAA,wBAAwB,GAAG,IAAI,GAAG,CAAC;IAC9C,KAAK;IACL,QAAQ;IACR,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;CACP,CAAC,CAAC;AAEH;;;GAGG;AACU,QAAA,cAAc,GAAG,IAAI,GAAG,CAAC;IACpC,OAAO;IACP,OAAO;IACP,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,QAAQ;IACR,OAAO;IACP,OAAO;IACP,OAAO;IACP,gBAAgB;IAChB,UAAU;IACV,OAAO;IACP,OAAO;IACP,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,YAAY;IACZ,MAAM;IACN,SAAS;IACT,SAAS;IACT,WAAW;IACX,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAM5E;;;;;;;;GAQG;AACH,SAAS,UAAU,CAAC,MAAc,EAAE,OAAgB,EAAE,GAAG,IAAe;IACtE,MAAM,MAAM,GAAG,UAAU,MAAM,GAAG,CAAC;IAEnC,qFAAqF;IACrF,+BAA+B;IAC/B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,MAAM,IAAI,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,sFAAsF;IACtF,4BAA4B;IAC5B,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;AAC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AC3B;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,CAAC,SAAS,CAAU;IAC3B,OAAO,EAAE,aAAa;CACvB,CAAC;AAEF,kBAAe,eAAe,CAAC","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"]}
@@ -1,4 +1,4 @@
1
- import type { EndowmentFactoryOptions } from './commonEndowmentFactory';
1
+ import type { EndowmentFactoryOptions } from "./commonEndowmentFactory.cjs";
2
2
  export declare const consoleAttenuatedMethods: Set<string>;
3
3
  /**
4
4
  * A set of all the `console` values that will be passed to the snap. This has
@@ -43,3 +43,4 @@ declare const endowmentModule: {
43
43
  factory: typeof createConsole;
44
44
  };
45
45
  export default endowmentModule;
46
+ //# sourceMappingURL=console.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.d.cts","sourceRoot":"","sources":["../../../src/common/endowments/console.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,qCAAiC;AAExE,eAAO,MAAM,wBAAwB,aAOnC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,aAwBzB,CAAC;AA+BH;;;;;;;GAOG;AACH,iBAAS,aAAa,CAAC,EAAE,MAAM,EAAE,GAAE,uBAA4B;;;;;;;;;;;;;;;;;;;;;;wBAkBhD,GAAG,YACA,MAAM,GAAG,SAAS,qBACT,GAAG,EAAE;;EAmB/B;AAED,QAAA,MAAM,eAAe;;;CAGpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { EndowmentFactoryOptions } from "./commonEndowmentFactory.mjs";
2
+ export declare const consoleAttenuatedMethods: Set<string>;
3
+ /**
4
+ * A set of all the `console` values that will be passed to the snap. This has
5
+ * all the values that are available in both the browser and Node.js.
6
+ */
7
+ export declare const consoleMethods: Set<string>;
8
+ /**
9
+ * Create a a {@link console} object, with the same properties as the global
10
+ * {@link console} object, but with some methods replaced.
11
+ *
12
+ * @param options - Factory options used in construction of the endowment.
13
+ * @param options.snapId - The id of the snap that will interact with the endowment.
14
+ * @returns The {@link console} object with the replaced methods.
15
+ */
16
+ declare function createConsole({ snapId }?: EndowmentFactoryOptions): {
17
+ console: {
18
+ error: {
19
+ (...data: any[]): void;
20
+ (message?: any, ...optionalParams: any[]): void;
21
+ };
22
+ log: {
23
+ (...data: any[]): void;
24
+ (message?: any, ...optionalParams: any[]): void;
25
+ };
26
+ warn: {
27
+ (...data: any[]): void;
28
+ (message?: any, ...optionalParams: any[]): void;
29
+ };
30
+ debug: {
31
+ (...data: any[]): void;
32
+ (message?: any, ...optionalParams: any[]): void;
33
+ };
34
+ info: {
35
+ (...data: any[]): void;
36
+ (message?: any, ...optionalParams: any[]): void;
37
+ };
38
+ assert: (value: any, message?: string | undefined, ...optionalParams: any[]) => void;
39
+ };
40
+ };
41
+ declare const endowmentModule: {
42
+ names: readonly ["console"];
43
+ factory: typeof createConsole;
44
+ };
45
+ export default endowmentModule;
46
+ //# sourceMappingURL=console.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.d.mts","sourceRoot":"","sources":["../../../src/common/endowments/console.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,qCAAiC;AAExE,eAAO,MAAM,wBAAwB,aAOnC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,aAwBzB,CAAC;AA+BH;;;;;;;GAOG;AACH,iBAAS,aAAa,CAAC,EAAE,MAAM,EAAE,GAAE,uBAA4B;;;;;;;;;;;;;;;;;;;;;;wBAkBhD,GAAG,YACA,MAAM,GAAG,SAAS,qBACT,GAAG,EAAE;;EAmB/B;AAED,QAAA,MAAM,eAAe;;;CAGpB,CAAC;AAEF,eAAe,eAAe,CAAC"}