@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
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common/validation.ts"],"names":[],"mappings":";AAAA,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe,mBAAmB;AAE3C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,gCAAgC,OAAO;AAAA,EAClD,SAAS,SAAS,oBAAoB;AAAA,EACtC,IAAI,SAAS,eAAe;AAAA,EAC5B,QAAQ,OAAO;AAAA,EACf,QAAQ,SAAS,mBAAmB;AACtC,CAAC;AAMM,IAAM,kBAAkB,OAAO;AAS/B,SAAS,YAAY,OAAoC;AAC9D,SAAO,GAAG,OAAO,eAAe;AAClC;AAQO,SAAS,kBAAkB,OAAsC;AACtE,SAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAM,WAAW;AACxD;AAEA,IAAM,WAAW,QAAQ,IAAI;AAEtB,IAAM,6BAA6B;AAAA,EACxC,MAAM,CAAC,QAAQ,MAAS,GAAG,MAAM,CAAC,CAAC;AACrC;AAEO,IAAM,kCAAkC,MAAM;AAAA,EACnD,QAAQ,MAAS;AAAA,EACjB,MAAM;AACR,CAAC;AAEM,IAAM,oCAAoC,MAAM;AAAA,EACrD,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM,eAAe;AACvB,CAAC;AAEM,IAAM,gCAAgC,MAAM;AAAA,EACjD,OAAO;AAAA,EACP,MAAM,OAAO,OAAO,WAAW,CAAC;AAAA,EAChC,OAAO;AAAA,EACP;AAAA,IACE;AAAA,IACA,OAAO;AAAA,MACL,QAAQ,SAAS,OAAO,OAAO,GAAG,UAAU,CAAC;AAAA,IAC/C,CAAC;AAAA,EACH;AACF,CAAC;AAqBM,IAAM,sCAAsC,OAAO;AAAA;AAAA,EAExD,aAAa,OAAO,OAAO,GAAG,UAAU;AAAA,EACxC,SAAS;AAAA,EACT,mBAAmB,SAAS,OAAO,CAAC;AACtC,CAAC;AAcM,SAAS,sCACd,OACgD;AAChD;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,EACZ;AACF;AAEO,IAAM,oCAAoC,OAAO;AAAA,EACtD,WAAW,OAAO,OAAO,GAAG,UAAU;AAAA,EACtC,iBAAiB,SAAS,OAAO,CAAC;AACpC,CAAC;AAcM,SAAS,oCACd,OAC8C;AAC9C;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,EACZ;AACF;AAEA,IAAM,qBAAqB,EAAE,SAAS,cAAc;AACpD,IAAM,sBAAsB,OAAO;AAAA,EACjC,GAAG;AAAA,EACH,SAAS,OAAO;AAClB,CAAC;AACD,IAAM,uBAAuB,OAAO;AAAA,EAClC,GAAG;AAAA,EACH,QAAQ,OAAO;AACjB,CAAC;AAEM,IAAM,qCAAqC,MAAM;AAAA,EACtD;AAAA,EACA;AACF,CAAC;AAmBM,SAAS,qCACd,OAC+C;AAC/C;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,EACZ;AACF;AAEO,IAAM,6BAA6B,OAAO;AAAA,EAC/C,IAAI,OAAO;AAAA,EACX,OAAO;AAAA,EACP,SAAS,SAAS,SAAS,sBAAsB,CAAC;AACpD,CAAC;AAYM,SAAS,oCACd,OACuC;AACvC;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,EACZ;AACF;AAEA,IAAM,mBAAmB,OAAO;AAAA,EAC9B,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,QAAQ;AACV,CAAC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport {\n InterfaceContextStruct,\n UserInputEventStruct,\n} from '@metamask/snaps-sdk';\nimport { ChainIdStruct, HandlerType } from '@metamask/snaps-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n array,\n assign,\n enums,\n is,\n literal,\n nullable,\n object,\n optional,\n record,\n string,\n tuple,\n union,\n} from '@metamask/superstruct';\nimport type { Json, JsonRpcSuccess } from '@metamask/utils';\nimport {\n assertStruct,\n JsonRpcIdStruct,\n JsonRpcParamsStruct,\n JsonRpcSuccessStruct,\n JsonRpcVersionStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nexport const JsonRpcRequestWithoutIdStruct = object({\n jsonrpc: optional(JsonRpcVersionStruct),\n id: optional(JsonRpcIdStruct),\n method: string(),\n params: optional(JsonRpcParamsStruct),\n});\n\nexport type JsonRpcRequestWithoutId = Infer<\n typeof JsonRpcRequestWithoutIdStruct\n>;\n\nexport const EndowmentStruct = string();\nexport type Endowment = Infer<typeof EndowmentStruct>;\n\n/**\n * Check if the given value is an endowment.\n *\n * @param value - The value to check.\n * @returns Whether the value is an endowment.\n */\nexport function isEndowment(value: unknown): value is Endowment {\n return is(value, EndowmentStruct);\n}\n\n/**\n * Check if the given value is an array of endowments.\n *\n * @param value - The value to check.\n * @returns Whether the value is an array of endowments.\n */\nexport function isEndowmentsArray(value: unknown): value is Endowment[] {\n return Array.isArray(value) && value.every(isEndowment);\n}\n\nconst OkStruct = literal('OK');\n\nexport const PingRequestArgumentsStruct = optional(\n union([literal(undefined), array()]),\n);\n\nexport const TerminateRequestArgumentsStruct = union([\n literal(undefined),\n array(),\n]);\n\nexport const ExecuteSnapRequestArgumentsStruct = tuple([\n string(),\n string(),\n array(EndowmentStruct),\n]);\n\nexport const SnapRpcRequestArgumentsStruct = tuple([\n string(),\n enums(Object.values(HandlerType)),\n string(),\n assign(\n JsonRpcRequestWithoutIdStruct,\n object({\n params: optional(record(string(), JsonStruct)),\n }),\n ),\n]);\n\nexport type PingRequestArguments = Infer<typeof PingRequestArgumentsStruct>;\nexport type TerminateRequestArguments = Infer<\n typeof TerminateRequestArgumentsStruct\n>;\n\nexport type ExecuteSnapRequestArguments = Infer<\n typeof ExecuteSnapRequestArgumentsStruct\n>;\n\nexport type SnapRpcRequestArguments = Infer<\n typeof SnapRpcRequestArgumentsStruct\n>;\n\nexport type RequestArguments =\n | PingRequestArguments\n | TerminateRequestArguments\n | ExecuteSnapRequestArguments\n | SnapRpcRequestArguments;\n\nexport const OnTransactionRequestArgumentsStruct = object({\n // TODO: Improve `transaction` type.\n transaction: record(string(), JsonStruct),\n chainId: ChainIdStruct,\n transactionOrigin: nullable(string()),\n});\n\nexport type OnTransactionRequestArguments = Infer<\n typeof OnTransactionRequestArgumentsStruct\n>;\n\n/**\n * Asserts that the given value is a valid {@link OnTransactionRequestArguments}\n * object.\n *\n * @param value - The value to validate.\n * @throws If the value is not a valid {@link OnTransactionRequestArguments}\n * object.\n */\nexport function assertIsOnTransactionRequestArguments(\n value: unknown,\n): asserts value is OnTransactionRequestArguments {\n assertStruct(\n value,\n OnTransactionRequestArgumentsStruct,\n 'Invalid request params',\n rpcErrors.invalidParams,\n );\n}\n\nexport const OnSignatureRequestArgumentsStruct = object({\n signature: record(string(), JsonStruct),\n signatureOrigin: nullable(string()),\n});\n\nexport type OnSignatureRequestArguments = Infer<\n typeof OnSignatureRequestArgumentsStruct\n>;\n\n/**\n * Asserts that the given value is a valid {@link OnSignatureRequestArguments}\n * object.\n *\n * @param value - The value to validate.\n * @throws If the value is not a valid {@link OnSignatureRequestArguments}\n * object.\n */\nexport function assertIsOnSignatureRequestArguments(\n value: unknown,\n): asserts value is OnSignatureRequestArguments {\n assertStruct(\n value,\n OnSignatureRequestArgumentsStruct,\n 'Invalid request params',\n rpcErrors.invalidParams,\n );\n}\n\nconst baseNameLookupArgs = { chainId: ChainIdStruct };\nconst domainRequestStruct = object({\n ...baseNameLookupArgs,\n address: string(),\n});\nconst addressRequestStruct = object({\n ...baseNameLookupArgs,\n domain: string(),\n});\n\nexport const OnNameLookupRequestArgumentsStruct = union([\n domainRequestStruct,\n addressRequestStruct,\n]);\n\nexport type OnNameLookupRequestArguments = Infer<\n typeof OnNameLookupRequestArgumentsStruct\n>;\n\nexport type PossibleLookupRequestArgs = typeof baseNameLookupArgs & {\n address?: string;\n domain?: string;\n};\n\n/**\n * Asserts that the given value is a valid {@link OnNameLookupRequestArguments}\n * object.\n *\n * @param value - The value to validate.\n * @throws If the value is not a valid {@link OnNameLookupRequestArguments}\n * object.\n */\nexport function assertIsOnNameLookupRequestArguments(\n value: unknown,\n): asserts value is OnNameLookupRequestArguments {\n assertStruct(\n value,\n OnNameLookupRequestArgumentsStruct,\n 'Invalid request params',\n rpcErrors.invalidParams,\n );\n}\n\nexport const OnUserInputArgumentsStruct = object({\n id: string(),\n event: UserInputEventStruct,\n context: optional(nullable(InterfaceContextStruct)),\n});\n\nexport type OnUserInputArguments = Infer<typeof OnUserInputArgumentsStruct>;\n\n/**\n * Asserts that the given value is a valid {@link OnUserInputArguments}\n * object.\n *\n * @param value - The value to validate.\n * @throws If the value is not a valid {@link OnUserInputArguments}\n * object.\n */\nexport function assertIsOnUserInputRequestArguments(\n value: unknown,\n): asserts value is OnUserInputArguments {\n assertStruct(\n value,\n OnUserInputArgumentsStruct,\n 'Invalid request params',\n rpcErrors.invalidParams,\n );\n}\n\nconst OkResponseStruct = object({\n id: JsonRpcIdStruct,\n jsonrpc: JsonRpcVersionStruct,\n result: OkStruct,\n});\n\nconst SnapRpcResponse = JsonRpcSuccessStruct;\n\nexport type OkResponse = Infer<typeof OkResponseStruct>;\nexport type SnapRpcResponse = Infer<typeof SnapRpcResponse>;\n\nexport type Response = OkResponse | SnapRpcResponse;\n\ntype RequestParams<Params extends unknown[] | undefined> =\n Params extends undefined ? [] : Params;\n\ntype RequestFunction<\n Args extends RequestArguments,\n ResponseType extends JsonRpcSuccess<Json>,\n> = (...args: RequestParams<Args>) => Promise<ResponseType['result']>;\n\nexport type Ping = RequestFunction<PingRequestArguments, OkResponse>;\nexport type Terminate = RequestFunction<TerminateRequestArguments, OkResponse>;\nexport type ExecuteSnap = RequestFunction<\n ExecuteSnapRequestArguments,\n OkResponse\n>;\nexport type SnapRpc = RequestFunction<SnapRpcRequestArguments, SnapRpcResponse>;\n"]}
@@ -1,38 +0,0 @@
1
- import {
2
- createCrypto
3
- } from "./chunk-Q42NNJFY.mjs";
4
- import {
5
- rootRealmGlobal
6
- } from "./chunk-IX5S3V47.mjs";
7
-
8
- // src/common/endowments/math.ts
9
- function createMath() {
10
- const keys = Object.getOwnPropertyNames(
11
- rootRealmGlobal.Math
12
- );
13
- const math = keys.reduce((target, key) => {
14
- if (key === "random") {
15
- return target;
16
- }
17
- return { ...target, [key]: rootRealmGlobal.Math[key] };
18
- }, {});
19
- const { crypto: hardenedCrypto } = createCrypto();
20
- return harden({
21
- Math: {
22
- ...math,
23
- random: () => {
24
- return hardenedCrypto.getRandomValues(new Uint32Array(1))[0] / 2 ** 32;
25
- }
26
- }
27
- });
28
- }
29
- var endowmentModule = {
30
- names: ["Math"],
31
- factory: createMath
32
- };
33
- var math_default = endowmentModule;
34
-
35
- export {
36
- math_default
37
- };
38
- //# sourceMappingURL=chunk-BCBKEUCG.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common/endowments/math.ts"],"sourcesContent":["import { rootRealmGlobal } from '../globalObject';\nimport { createCrypto } from './crypto';\n\n/**\n * Create a {@link Math} object, with the same properties as the global\n * {@link Math} object, but with the {@link Math.random} method replaced.\n *\n * @returns The {@link Math} object with the {@link Math.random} method\n * replaced.\n */\nfunction createMath() {\n // `Math` does not work with `Object.keys`, `Object.entries`, etc., so we\n // need to create a new object with the same properties.\n const keys = Object.getOwnPropertyNames(\n rootRealmGlobal.Math,\n ) as (keyof typeof Math)[];\n\n const math = keys.reduce<Partial<Math>>((target, key) => {\n if (key === 'random') {\n return target;\n }\n\n return { ...target, [key]: rootRealmGlobal.Math[key] };\n }, {});\n\n // Since the math endowment requires crypto, we can leverage the crypto endowment factory to get a hardened and platform agnostic instance of webcrypto\n const { crypto: hardenedCrypto } = createCrypto();\n\n return harden({\n Math: {\n ...math,\n random: () => {\n // NOTE: This is not intended to be a secure replacement for the weak\n // random number generator used by `Math.random`. It is only intended to\n // prevent side channel attacks of `Math.random` by replacing it with an\n // alternative implementation that is not vulnerable to the same\n // attacks.\n //\n // This does not mean that this implementation is secure. It is not\n // intended to be used in a security context, and this implementation\n // may change at any time.\n //\n // To securely generate random numbers, use a cryptographically secure\n // random number generator, such as the one provided by the Web Crypto\n // API:\n //\n // - https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey\n // - https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues\n return hardenedCrypto.getRandomValues(new Uint32Array(1))[0] / 2 ** 32;\n },\n },\n });\n}\n\nconst endowmentModule = {\n names: ['Math'] as const,\n factory: createMath,\n};\n\nexport default endowmentModule;\n"],"mappings":";;;;;;;;AAUA,SAAS,aAAa;AAGpB,QAAM,OAAO,OAAO;AAAA,IAClB,gBAAgB;AAAA,EAClB;AAEA,QAAM,OAAO,KAAK,OAAsB,CAAC,QAAQ,QAAQ;AACvD,QAAI,QAAQ,UAAU;AACpB,aAAO;AAAA,IACT;AAEA,WAAO,EAAE,GAAG,QAAQ,CAAC,GAAG,GAAG,gBAAgB,KAAK,GAAG,EAAE;AAAA,EACvD,GAAG,CAAC,CAAC;AAGL,QAAM,EAAE,QAAQ,eAAe,IAAI,aAAa;AAEhD,SAAO,OAAO;AAAA,IACZ,MAAM;AAAA,MACJ,GAAG;AAAA,MACH,QAAQ,MAAM;AAiBZ,eAAO,eAAe,gBAAgB,IAAI,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK;AAAA,MACtE;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEA,IAAM,kBAAkB;AAAA,EACtB,OAAO,CAAC,MAAM;AAAA,EACd,SAAS;AACX;AAEA,IAAO,eAAQ;","names":[]}
@@ -1,40 +0,0 @@
1
- import {
2
- BaseSnapExecutor
3
- } from "./chunk-M3OBSGHF.mjs";
4
- import {
5
- log
6
- } from "./chunk-5DEV3QQU.mjs";
7
-
8
- // src/webworker/executor/WebWorkerSnapExecutor.ts
9
- import ObjectMultiplex from "@metamask/object-multiplex";
10
- import { WebWorkerPostMessageStream } from "@metamask/post-message-stream";
11
- import { logError, SNAP_STREAM_NAMES } from "@metamask/snaps-utils";
12
- import { pipeline } from "readable-stream";
13
- var WebWorkerSnapExecutor = class _WebWorkerSnapExecutor extends BaseSnapExecutor {
14
- /**
15
- * Initialize the WebWorkerSnapExecutor. This creates a post message stream
16
- * from and to the parent window, for two-way communication with the iframe.
17
- *
18
- * @param stream - The stream to use for communication.
19
- * @returns An instance of `WebWorkerSnapExecutor`, with the initialized post
20
- * message streams.
21
- */
22
- static initialize(stream = new WebWorkerPostMessageStream()) {
23
- log("Worker: Connecting to parent.");
24
- const mux = new ObjectMultiplex();
25
- pipeline(stream, mux, stream, (error) => {
26
- if (error) {
27
- logError(`Parent stream failure, closing worker.`, error);
28
- }
29
- self.close();
30
- });
31
- const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);
32
- const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC);
33
- return new _WebWorkerSnapExecutor(commandStream, rpcStream);
34
- }
35
- };
36
-
37
- export {
38
- WebWorkerSnapExecutor
39
- };
40
- //# sourceMappingURL=chunk-BEJDC4XI.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/webworker/executor/WebWorkerSnapExecutor.ts"],"sourcesContent":["import ObjectMultiplex from '@metamask/object-multiplex';\nimport type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { WebWorkerPostMessageStream } from '@metamask/post-message-stream';\nimport { logError, SNAP_STREAM_NAMES } from '@metamask/snaps-utils';\nimport { pipeline } from 'readable-stream';\n\nimport { BaseSnapExecutor } from '../../common/BaseSnapExecutor';\nimport { log } from '../../logging';\n\nexport class WebWorkerSnapExecutor extends BaseSnapExecutor {\n /**\n * Initialize the WebWorkerSnapExecutor. This creates a post message stream\n * from and to the parent window, for two-way communication with the iframe.\n *\n * @param stream - The stream to use for communication.\n * @returns An instance of `WebWorkerSnapExecutor`, with the initialized post\n * message streams.\n */\n static initialize(\n stream: BasePostMessageStream = new WebWorkerPostMessageStream(),\n ) {\n log('Worker: Connecting to parent.');\n\n const mux = new ObjectMultiplex();\n pipeline(stream, mux, stream, (error) => {\n if (error) {\n logError(`Parent stream failure, closing worker.`, error);\n }\n self.close();\n });\n\n const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);\n const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC);\n\n return new WebWorkerSnapExecutor(commandStream, rpcStream);\n }\n}\n"],"mappings":";;;;;;;;AAAA,OAAO,qBAAqB;AAE5B,SAAS,kCAAkC;AAC3C,SAAS,UAAU,yBAAyB;AAC5C,SAAS,gBAAgB;AAKlB,IAAM,wBAAN,MAAM,+BAA8B,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS1D,OAAO,WACL,SAAgC,IAAI,2BAA2B,GAC/D;AACA,QAAI,+BAA+B;AAEnC,UAAM,MAAM,IAAI,gBAAgB;AAChC,aAAS,QAAQ,KAAK,QAAQ,CAAC,UAAU;AACvC,UAAI,OAAO;AACT,iBAAS,0CAA0C,KAAK;AAAA,MAC1D;AACA,WAAK,MAAM;AAAA,IACb,CAAC;AAED,UAAM,gBAAgB,IAAI,aAAa,kBAAkB,OAAO;AAChE,UAAM,YAAY,IAAI,aAAa,kBAAkB,QAAQ;AAE7D,WAAO,IAAI,uBAAsB,eAAe,SAAS;AAAA,EAC3D;AACF;","names":[]}
@@ -1,40 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
-
3
- var _chunkHCXTK3PRjs = require('./chunk-HCXTK3PR.js');
4
-
5
-
6
- var _chunkZ7BOREC4js = require('./chunk-Z7BOREC4.js');
7
-
8
- // src/webworker/executor/WebWorkerSnapExecutor.ts
9
- var _objectmultiplex = require('@metamask/object-multiplex'); var _objectmultiplex2 = _interopRequireDefault(_objectmultiplex);
10
- var _postmessagestream = require('@metamask/post-message-stream');
11
- var _snapsutils = require('@metamask/snaps-utils');
12
- var _readablestream = require('readable-stream');
13
- var WebWorkerSnapExecutor = class _WebWorkerSnapExecutor extends _chunkHCXTK3PRjs.BaseSnapExecutor {
14
- /**
15
- * Initialize the WebWorkerSnapExecutor. This creates a post message stream
16
- * from and to the parent window, for two-way communication with the iframe.
17
- *
18
- * @param stream - The stream to use for communication.
19
- * @returns An instance of `WebWorkerSnapExecutor`, with the initialized post
20
- * message streams.
21
- */
22
- static initialize(stream = new (0, _postmessagestream.WebWorkerPostMessageStream)()) {
23
- _chunkZ7BOREC4js.log.call(void 0, "Worker: Connecting to parent.");
24
- const mux = new (0, _objectmultiplex2.default)();
25
- _readablestream.pipeline.call(void 0, stream, mux, stream, (error) => {
26
- if (error) {
27
- _snapsutils.logError.call(void 0, `Parent stream failure, closing worker.`, error);
28
- }
29
- self.close();
30
- });
31
- const commandStream = mux.createStream(_snapsutils.SNAP_STREAM_NAMES.COMMAND);
32
- const rpcStream = mux.createStream(_snapsutils.SNAP_STREAM_NAMES.JSON_RPC);
33
- return new _WebWorkerSnapExecutor(commandStream, rpcStream);
34
- }
35
- };
36
-
37
-
38
-
39
- exports.WebWorkerSnapExecutor = WebWorkerSnapExecutor;
40
- //# sourceMappingURL=chunk-BLHIYDO5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/webworker/executor/WebWorkerSnapExecutor.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,qBAAqB;AAE5B,SAAS,kCAAkC;AAC3C,SAAS,UAAU,yBAAyB;AAC5C,SAAS,gBAAgB;AAKlB,IAAM,wBAAN,MAAM,+BAA8B,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS1D,OAAO,WACL,SAAgC,IAAI,2BAA2B,GAC/D;AACA,QAAI,+BAA+B;AAEnC,UAAM,MAAM,IAAI,gBAAgB;AAChC,aAAS,QAAQ,KAAK,QAAQ,CAAC,UAAU;AACvC,UAAI,OAAO;AACT,iBAAS,0CAA0C,KAAK;AAAA,MAC1D;AACA,WAAK,MAAM;AAAA,IACb,CAAC;AAED,UAAM,gBAAgB,IAAI,aAAa,kBAAkB,OAAO;AAChE,UAAM,YAAY,IAAI,aAAa,kBAAkB,QAAQ;AAE7D,WAAO,IAAI,uBAAsB,eAAe,SAAS;AAAA,EAC3D;AACF","sourcesContent":["import ObjectMultiplex from '@metamask/object-multiplex';\nimport type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { WebWorkerPostMessageStream } from '@metamask/post-message-stream';\nimport { logError, SNAP_STREAM_NAMES } from '@metamask/snaps-utils';\nimport { pipeline } from 'readable-stream';\n\nimport { BaseSnapExecutor } from '../../common/BaseSnapExecutor';\nimport { log } from '../../logging';\n\nexport class WebWorkerSnapExecutor extends BaseSnapExecutor {\n /**\n * Initialize the WebWorkerSnapExecutor. This creates a post message stream\n * from and to the parent window, for two-way communication with the iframe.\n *\n * @param stream - The stream to use for communication.\n * @returns An instance of `WebWorkerSnapExecutor`, with the initialized post\n * message streams.\n */\n static initialize(\n stream: BasePostMessageStream = new WebWorkerPostMessageStream(),\n ) {\n log('Worker: Connecting to parent.');\n\n const mux = new ObjectMultiplex();\n pipeline(stream, mux, stream, (error) => {\n if (error) {\n logError(`Parent stream failure, closing worker.`, error);\n }\n self.close();\n });\n\n const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);\n const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC);\n\n return new WebWorkerSnapExecutor(commandStream, rpcStream);\n }\n}\n"]}
@@ -1,24 +0,0 @@
1
- // src/common/sortParams.ts
2
- var sortParamKeys = (methodParams, params) => {
3
- if (!params) {
4
- return [];
5
- }
6
- if (params instanceof Array) {
7
- return params;
8
- }
9
- const methodParamsOrder = methodParams.reduce(
10
- (paramsOrderObj, paramsName, i) => ({
11
- ...paramsOrderObj,
12
- [paramsName]: i
13
- }),
14
- {}
15
- );
16
- return Object.entries(params).sort(
17
- ([name1, _1], [name2, _2]) => methodParamsOrder[name1] - methodParamsOrder[name2]
18
- ).map(([_, val]) => val);
19
- };
20
-
21
- export {
22
- sortParamKeys
23
- };
24
- //# sourceMappingURL=chunk-BTEAZZKP.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common/sortParams.ts"],"sourcesContent":["// original source sortParamKeys from: https://github.com/etclabscore/sig.tools/blob/master/src/postMessageServer/postMessageServer.ts#L75-L77\n\nimport type { JsonRpcParams } from '@metamask/utils';\n\n/**\n * Deterministically sort JSON-RPC parameter keys. This makes it possible to\n * support both arrays and objects as parameters. Objects are sorted and turned\n * into arrays, for easier consumption by the snap.\n *\n * The order is defined by the `method` parameter.\n *\n * @param methodParams - The parameters of the JSON-RPC method, which\n * determines the ordering for the parameters.\n * @param params - JSON-RPC parameters as object or array.\n * @returns The values for the sorted keys. If `params` is not provided, this\n * returns an empty array. If `params` is an array, this returns the same\n * `params`.\n */\nexport const sortParamKeys = (\n methodParams: string[],\n params?: JsonRpcParams,\n) => {\n if (!params) {\n return [];\n }\n\n if (params instanceof Array) {\n return params;\n }\n\n const methodParamsOrder: { [k: string]: number } = methodParams.reduce(\n (paramsOrderObj, paramsName, i) => ({\n ...paramsOrderObj,\n [paramsName]: i,\n }),\n {},\n );\n\n return Object.entries(params)\n .sort(\n ([name1, _1], [name2, _2]) =>\n methodParamsOrder[name1] - methodParamsOrder[name2],\n )\n .map(([_, val]) => val);\n};\n"],"mappings":";AAkBO,IAAM,gBAAgB,CAC3B,cACA,WACG;AACH,MAAI,CAAC,QAAQ;AACX,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,kBAAkB,OAAO;AAC3B,WAAO;AAAA,EACT;AAEA,QAAM,oBAA6C,aAAa;AAAA,IAC9D,CAAC,gBAAgB,YAAY,OAAO;AAAA,MAClC,GAAG;AAAA,MACH,CAAC,UAAU,GAAG;AAAA,IAChB;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO,OAAO,QAAQ,MAAM,EACzB;AAAA,IACC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,MACtB,kBAAkB,KAAK,IAAI,kBAAkB,KAAK;AAAA,EACtD,EACC,IAAI,CAAC,CAAC,GAAG,GAAG,MAAM,GAAG;AAC1B;","names":[]}
@@ -1,67 +0,0 @@
1
- import {
2
- commonEndowmentFactory_default
3
- } from "./chunk-ODICKSGZ.mjs";
4
- import {
5
- rootRealmGlobal
6
- } from "./chunk-IX5S3V47.mjs";
7
-
8
- // src/common/endowments/index.ts
9
- import { rpcErrors } from "@metamask/rpc-errors";
10
- import { logWarning } from "@metamask/snaps-utils";
11
- import { hasProperty } from "@metamask/utils";
12
- var registeredEndowments = commonEndowmentFactory_default();
13
- var endowmentFactories = registeredEndowments.reduce((factories, builder) => {
14
- builder.names.forEach((name) => {
15
- factories.set(name, builder.factory);
16
- });
17
- return factories;
18
- }, /* @__PURE__ */ new Map());
19
- function createEndowments({
20
- snap,
21
- ethereum,
22
- snapId,
23
- endowments,
24
- notify
25
- }) {
26
- const attenuatedEndowments = {};
27
- const result = endowments.reduce(
28
- ({ allEndowments, teardowns }, endowmentName) => {
29
- if (endowmentFactories.has(endowmentName)) {
30
- if (!hasProperty(attenuatedEndowments, endowmentName)) {
31
- const { teardownFunction, ...endowment } = endowmentFactories.get(
32
- endowmentName
33
- )({ snapId, notify });
34
- Object.assign(attenuatedEndowments, endowment);
35
- if (teardownFunction) {
36
- teardowns.push(teardownFunction);
37
- }
38
- }
39
- allEndowments[endowmentName] = attenuatedEndowments[endowmentName];
40
- } else if (endowmentName === "ethereum") {
41
- allEndowments[endowmentName] = ethereum;
42
- } else if (endowmentName in rootRealmGlobal) {
43
- logWarning(`Access to unhardened global ${endowmentName}.`);
44
- const globalValue = rootRealmGlobal[endowmentName];
45
- allEndowments[endowmentName] = globalValue;
46
- } else {
47
- throw rpcErrors.internal(`Unknown endowment: "${endowmentName}".`);
48
- }
49
- return { allEndowments, teardowns };
50
- },
51
- {
52
- allEndowments: { snap },
53
- teardowns: []
54
- }
55
- );
56
- const teardown = async () => {
57
- await Promise.all(
58
- result.teardowns.map((teardownFunction) => teardownFunction())
59
- );
60
- };
61
- return { endowments: result.allEndowments, teardown };
62
- }
63
-
64
- export {
65
- createEndowments
66
- };
67
- //# sourceMappingURL=chunk-BVRVUIJB.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common/endowments/index.ts"],"sourcesContent":["import type { StreamProvider } from '@metamask/providers';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { SnapsProvider } from '@metamask/snaps-sdk';\nimport { logWarning } from '@metamask/snaps-utils';\nimport { hasProperty } from '@metamask/utils';\n\nimport type { NotifyFunction } from '../BaseSnapExecutor';\nimport { rootRealmGlobal } from '../globalObject';\nimport type { EndowmentFactoryOptions } from './commonEndowmentFactory';\nimport buildCommonEndowments from './commonEndowmentFactory';\n\ntype EndowmentFactoryResult = {\n /**\n * A function that performs any necessary teardown when the snap becomes idle.\n *\n * NOTE:** The endowments are not reconstructed if the snap is re-invoked\n * before being terminated, so the teardown operation must not render the\n * endowments unusable; it should simply restore the endowments to their\n * original state.\n */\n teardownFunction?: () => Promise<void> | void;\n [key: string]: unknown;\n};\n\n/**\n * Retrieve consolidated endowment factories for common endowments.\n */\nconst registeredEndowments = buildCommonEndowments();\n\n/**\n * A map of endowment names to their factory functions. Some endowments share\n * the same factory function, but we only call each factory once for each snap.\n * See {@link createEndowments} for details.\n */\nconst endowmentFactories = registeredEndowments.reduce((factories, builder) => {\n builder.names.forEach((name) => {\n factories.set(name, builder.factory);\n });\n return factories;\n}, new Map<string, (options?: EndowmentFactoryOptions) => EndowmentFactoryResult>());\n\n/**\n * Gets the endowments for a particular Snap. Some endowments, like `setTimeout`\n * and `clearTimeout`, must be attenuated so that they can only affect behavior\n * within the Snap's own realm. Therefore, we use factory functions to create\n * such attenuated / modified endowments. Otherwise, the value that's on the\n * root realm global will be used.\n *\n * @param options - An options bag.\n * @param options.snap - The Snaps global API object.\n * @param options.ethereum - The Snap's EIP-1193 provider object.\n * @param options.snapId - The id of the snap that will use the created endowments.\n * @param options.endowments - The list of endowments to provide to the snap.\n * @param options.notify - A reference to the notify function of the snap executor.\n * @returns An object containing the Snap's endowments.\n */\nexport function createEndowments({\n snap,\n ethereum,\n snapId,\n endowments,\n notify,\n}: {\n snap: SnapsProvider;\n ethereum: StreamProvider;\n snapId: string;\n endowments: string[];\n notify: NotifyFunction;\n}): { endowments: Record<string, unknown>; teardown: () => Promise<void> } {\n const attenuatedEndowments: Record<string, unknown> = {};\n\n // TODO: All endowments should be hardened to prevent covert communication\n // channels. Hardening the returned objects breaks tests elsewhere in the\n // monorepo, so further research is needed.\n const result = endowments.reduce<{\n allEndowments: Record<string, unknown>;\n teardowns: (() => Promise<void> | void)[];\n }>(\n ({ allEndowments, teardowns }, endowmentName) => {\n // First, check if the endowment has a factory, and default to that.\n if (endowmentFactories.has(endowmentName)) {\n if (!hasProperty(attenuatedEndowments, endowmentName)) {\n // Call the endowment factory for the current endowment. If the factory\n // creates multiple endowments, they will all be assigned to the\n // `attenuatedEndowments` object, but will only be passed on to the snap\n // if explicitly listed among its endowment.\n // This may not have an actual use case, but, safety first.\n\n // We just confirmed that endowmentFactories has the specified key.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { teardownFunction, ...endowment } = endowmentFactories.get(\n endowmentName,\n )!({ snapId, notify });\n Object.assign(attenuatedEndowments, endowment);\n if (teardownFunction) {\n teardowns.push(teardownFunction);\n }\n }\n allEndowments[endowmentName] = attenuatedEndowments[endowmentName];\n } else if (endowmentName === 'ethereum') {\n // Special case for adding the EIP-1193 provider.\n allEndowments[endowmentName] = ethereum;\n } else if (endowmentName in rootRealmGlobal) {\n logWarning(`Access to unhardened global ${endowmentName}.`);\n // If the endowment doesn't have a factory, just use whatever is on the\n // global object.\n const globalValue = (rootRealmGlobal as Record<string, unknown>)[\n endowmentName\n ];\n allEndowments[endowmentName] = globalValue;\n } else {\n // If we get to this point, we've been passed an endowment that doesn't\n // exist in our current environment.\n throw rpcErrors.internal(`Unknown endowment: \"${endowmentName}\".`);\n }\n return { allEndowments, teardowns };\n },\n {\n allEndowments: { snap },\n teardowns: [],\n },\n );\n\n const teardown = async () => {\n await Promise.all(\n result.teardowns.map((teardownFunction) => teardownFunction()),\n );\n };\n return { endowments: result.allEndowments, teardown };\n}\n"],"mappings":";;;;;;;;AACA,SAAS,iBAAiB;AAE1B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAuB5B,IAAM,uBAAuB,+BAAsB;AAOnD,IAAM,qBAAqB,qBAAqB,OAAO,CAAC,WAAW,YAAY;AAC7E,UAAQ,MAAM,QAAQ,CAAC,SAAS;AAC9B,cAAU,IAAI,MAAM,QAAQ,OAAO;AAAA,EACrC,CAAC;AACD,SAAO;AACT,GAAG,oBAAI,IAA2E,CAAC;AAiB5E,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAM2E;AACzE,QAAM,uBAAgD,CAAC;AAKvD,QAAM,SAAS,WAAW;AAAA,IAIxB,CAAC,EAAE,eAAe,UAAU,GAAG,kBAAkB;AAE/C,UAAI,mBAAmB,IAAI,aAAa,GAAG;AACzC,YAAI,CAAC,YAAY,sBAAsB,aAAa,GAAG;AASrD,gBAAM,EAAE,kBAAkB,GAAG,UAAU,IAAI,mBAAmB;AAAA,YAC5D;AAAA,UACF,EAAG,EAAE,QAAQ,OAAO,CAAC;AACrB,iBAAO,OAAO,sBAAsB,SAAS;AAC7C,cAAI,kBAAkB;AACpB,sBAAU,KAAK,gBAAgB;AAAA,UACjC;AAAA,QACF;AACA,sBAAc,aAAa,IAAI,qBAAqB,aAAa;AAAA,MACnE,WAAW,kBAAkB,YAAY;AAEvC,sBAAc,aAAa,IAAI;AAAA,MACjC,WAAW,iBAAiB,iBAAiB;AAC3C,mBAAW,+BAA+B,aAAa,GAAG;AAG1D,cAAM,cAAe,gBACnB,aACF;AACA,sBAAc,aAAa,IAAI;AAAA,MACjC,OAAO;AAGL,cAAM,UAAU,SAAS,uBAAuB,aAAa,IAAI;AAAA,MACnE;AACA,aAAO,EAAE,eAAe,UAAU;AAAA,IACpC;AAAA,IACA;AAAA,MACE,eAAe,EAAE,KAAK;AAAA,MACtB,WAAW,CAAC;AAAA,IACd;AAAA,EACF;AAEA,QAAM,WAAW,YAAY;AAC3B,UAAM,QAAQ;AAAA,MACZ,OAAO,UAAU,IAAI,CAAC,qBAAqB,iBAAiB,CAAC;AAAA,IAC/D;AAAA,EACF;AACA,SAAO,EAAE,YAAY,OAAO,eAAe,SAAS;AACtD;","names":[]}
@@ -1,24 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/common/sortParams.ts
2
- var sortParamKeys = (methodParams, params) => {
3
- if (!params) {
4
- return [];
5
- }
6
- if (params instanceof Array) {
7
- return params;
8
- }
9
- const methodParamsOrder = methodParams.reduce(
10
- (paramsOrderObj, paramsName, i) => ({
11
- ...paramsOrderObj,
12
- [paramsName]: i
13
- }),
14
- {}
15
- );
16
- return Object.entries(params).sort(
17
- ([name1, _1], [name2, _2]) => methodParamsOrder[name1] - methodParamsOrder[name2]
18
- ).map(([_, val]) => val);
19
- };
20
-
21
-
22
-
23
- exports.sortParamKeys = sortParamKeys;
24
- //# sourceMappingURL=chunk-CV5LC4PP.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common/sortParams.ts"],"names":[],"mappings":";AAkBO,IAAM,gBAAgB,CAC3B,cACA,WACG;AACH,MAAI,CAAC,QAAQ;AACX,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,kBAAkB,OAAO;AAC3B,WAAO;AAAA,EACT;AAEA,QAAM,oBAA6C,aAAa;AAAA,IAC9D,CAAC,gBAAgB,YAAY,OAAO;AAAA,MAClC,GAAG;AAAA,MACH,CAAC,UAAU,GAAG;AAAA,IAChB;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO,OAAO,QAAQ,MAAM,EACzB;AAAA,IACC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,MACtB,kBAAkB,KAAK,IAAI,kBAAkB,KAAK;AAAA,EACtD,EACC,IAAI,CAAC,CAAC,GAAG,GAAG,MAAM,GAAG;AAC1B","sourcesContent":["// original source sortParamKeys from: https://github.com/etclabscore/sig.tools/blob/master/src/postMessageServer/postMessageServer.ts#L75-L77\n\nimport type { JsonRpcParams } from '@metamask/utils';\n\n/**\n * Deterministically sort JSON-RPC parameter keys. This makes it possible to\n * support both arrays and objects as parameters. Objects are sorted and turned\n * into arrays, for easier consumption by the snap.\n *\n * The order is defined by the `method` parameter.\n *\n * @param methodParams - The parameters of the JSON-RPC method, which\n * determines the ordering for the parameters.\n * @param params - JSON-RPC parameters as object or array.\n * @returns The values for the sorted keys. If `params` is not provided, this\n * returns an empty array. If `params` is an array, this returns the same\n * `params`.\n */\nexport const sortParamKeys = (\n methodParams: string[],\n params?: JsonRpcParams,\n) => {\n if (!params) {\n return [];\n }\n\n if (params instanceof Array) {\n return params;\n }\n\n const methodParamsOrder: { [k: string]: number } = methodParams.reduce(\n (paramsOrderObj, paramsName, i) => ({\n ...paramsOrderObj,\n [paramsName]: i,\n }),\n {},\n );\n\n return Object.entries(params)\n .sort(\n ([name1, _1], [name2, _2]) =>\n methodParamsOrder[name1] - methodParamsOrder[name2],\n )\n .map(([_, val]) => val);\n};\n"]}
@@ -1,67 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunk4COIRXF5js = require('./chunk-4COIRXF5.js');
4
-
5
-
6
- var _chunkDLLLH5HNjs = require('./chunk-DLLLH5HN.js');
7
-
8
- // src/common/endowments/index.ts
9
- var _rpcerrors = require('@metamask/rpc-errors');
10
- var _snapsutils = require('@metamask/snaps-utils');
11
- var _utils = require('@metamask/utils');
12
- var registeredEndowments = _chunk4COIRXF5js.commonEndowmentFactory_default.call(void 0, );
13
- var endowmentFactories = registeredEndowments.reduce((factories, builder) => {
14
- builder.names.forEach((name) => {
15
- factories.set(name, builder.factory);
16
- });
17
- return factories;
18
- }, /* @__PURE__ */ new Map());
19
- function createEndowments({
20
- snap,
21
- ethereum,
22
- snapId,
23
- endowments,
24
- notify
25
- }) {
26
- const attenuatedEndowments = {};
27
- const result = endowments.reduce(
28
- ({ allEndowments, teardowns }, endowmentName) => {
29
- if (endowmentFactories.has(endowmentName)) {
30
- if (!_utils.hasProperty.call(void 0, attenuatedEndowments, endowmentName)) {
31
- const { teardownFunction, ...endowment } = endowmentFactories.get(
32
- endowmentName
33
- )({ snapId, notify });
34
- Object.assign(attenuatedEndowments, endowment);
35
- if (teardownFunction) {
36
- teardowns.push(teardownFunction);
37
- }
38
- }
39
- allEndowments[endowmentName] = attenuatedEndowments[endowmentName];
40
- } else if (endowmentName === "ethereum") {
41
- allEndowments[endowmentName] = ethereum;
42
- } else if (endowmentName in _chunkDLLLH5HNjs.rootRealmGlobal) {
43
- _snapsutils.logWarning.call(void 0, `Access to unhardened global ${endowmentName}.`);
44
- const globalValue = _chunkDLLLH5HNjs.rootRealmGlobal[endowmentName];
45
- allEndowments[endowmentName] = globalValue;
46
- } else {
47
- throw _rpcerrors.rpcErrors.internal(`Unknown endowment: "${endowmentName}".`);
48
- }
49
- return { allEndowments, teardowns };
50
- },
51
- {
52
- allEndowments: { snap },
53
- teardowns: []
54
- }
55
- );
56
- const teardown = async () => {
57
- await Promise.all(
58
- result.teardowns.map((teardownFunction) => teardownFunction())
59
- );
60
- };
61
- return { endowments: result.allEndowments, teardown };
62
- }
63
-
64
-
65
-
66
- exports.createEndowments = createEndowments;
67
- //# sourceMappingURL=chunk-DKDTGAFK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common/endowments/index.ts"],"names":[],"mappings":";;;;;;;;AACA,SAAS,iBAAiB;AAE1B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAuB5B,IAAM,uBAAuB,+BAAsB;AAOnD,IAAM,qBAAqB,qBAAqB,OAAO,CAAC,WAAW,YAAY;AAC7E,UAAQ,MAAM,QAAQ,CAAC,SAAS;AAC9B,cAAU,IAAI,MAAM,QAAQ,OAAO;AAAA,EACrC,CAAC;AACD,SAAO;AACT,GAAG,oBAAI,IAA2E,CAAC;AAiB5E,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAM2E;AACzE,QAAM,uBAAgD,CAAC;AAKvD,QAAM,SAAS,WAAW;AAAA,IAIxB,CAAC,EAAE,eAAe,UAAU,GAAG,kBAAkB;AAE/C,UAAI,mBAAmB,IAAI,aAAa,GAAG;AACzC,YAAI,CAAC,YAAY,sBAAsB,aAAa,GAAG;AASrD,gBAAM,EAAE,kBAAkB,GAAG,UAAU,IAAI,mBAAmB;AAAA,YAC5D;AAAA,UACF,EAAG,EAAE,QAAQ,OAAO,CAAC;AACrB,iBAAO,OAAO,sBAAsB,SAAS;AAC7C,cAAI,kBAAkB;AACpB,sBAAU,KAAK,gBAAgB;AAAA,UACjC;AAAA,QACF;AACA,sBAAc,aAAa,IAAI,qBAAqB,aAAa;AAAA,MACnE,WAAW,kBAAkB,YAAY;AAEvC,sBAAc,aAAa,IAAI;AAAA,MACjC,WAAW,iBAAiB,iBAAiB;AAC3C,mBAAW,+BAA+B,aAAa,GAAG;AAG1D,cAAM,cAAe,gBACnB,aACF;AACA,sBAAc,aAAa,IAAI;AAAA,MACjC,OAAO;AAGL,cAAM,UAAU,SAAS,uBAAuB,aAAa,IAAI;AAAA,MACnE;AACA,aAAO,EAAE,eAAe,UAAU;AAAA,IACpC;AAAA,IACA;AAAA,MACE,eAAe,EAAE,KAAK;AAAA,MACtB,WAAW,CAAC;AAAA,IACd;AAAA,EACF;AAEA,QAAM,WAAW,YAAY;AAC3B,UAAM,QAAQ;AAAA,MACZ,OAAO,UAAU,IAAI,CAAC,qBAAqB,iBAAiB,CAAC;AAAA,IAC/D;AAAA,EACF;AACA,SAAO,EAAE,YAAY,OAAO,eAAe,SAAS;AACtD","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,26 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/common/globalObject.ts
2
- var _rootRealmGlobal;
3
- var _rootRealmGlobalName;
4
- if (typeof globalThis !== "undefined") {
5
- _rootRealmGlobal = globalThis;
6
- _rootRealmGlobalName = "globalThis" /* globalThis */;
7
- } else if (typeof self !== "undefined") {
8
- _rootRealmGlobal = self;
9
- _rootRealmGlobalName = "self" /* self */;
10
- } else if (typeof window !== "undefined") {
11
- _rootRealmGlobal = window;
12
- _rootRealmGlobalName = "window" /* window */;
13
- } else if (typeof global !== "undefined") {
14
- _rootRealmGlobal = global;
15
- _rootRealmGlobalName = "global" /* global */;
16
- } else {
17
- throw new Error("Unknown realm type; failed to identify global object.");
18
- }
19
- var rootRealmGlobal = _rootRealmGlobal;
20
- var rootRealmGlobalName = _rootRealmGlobalName;
21
-
22
-
23
-
24
-
25
- exports.rootRealmGlobal = rootRealmGlobal; exports.rootRealmGlobalName = rootRealmGlobalName;
26
- //# sourceMappingURL=chunk-DLLLH5HN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common/globalObject.ts"],"names":[],"mappings":";AAYA,IAAI;AACJ,IAAI;AAIJ,IAAI,OAAO,eAAe,aAAa;AACrC,qBAAmB;AACnB,yBAAuB;AACzB,WAAW,OAAO,SAAS,aAAa;AACtC,qBAAmB;AACnB,yBAAuB;AACzB,WAAW,OAAO,WAAW,aAAa;AACxC,qBAAmB;AACnB,yBAAuB;AACzB,WAAW,OAAO,WAAW,aAAa;AACxC,qBAAmB;AACnB,yBAAuB;AACzB,OAAO;AACL,QAAM,IAAI,MAAM,uDAAuD;AACzE;AAMA,IAAM,kBAAkB;AAKxB,IAAM,sBAAsB","sourcesContent":["enum GlobalObjectNames {\n // The globalThis entry is incorrectly identified as shadowing the global\n // globalThis.\n /* eslint-disable @typescript-eslint/naming-convention */\n // eslint-disable-next-line @typescript-eslint/no-shadow\n globalThis = 'globalThis',\n global = 'global',\n self = 'self',\n window = 'window',\n /* eslint-enable @typescript-eslint/naming-convention */\n}\n\nlet _rootRealmGlobal: typeof globalThis;\nlet _rootRealmGlobalName: string;\n\n/* istanbul ignore next */\n/* eslint-disable no-negated-condition */\nif (typeof globalThis !== 'undefined') {\n _rootRealmGlobal = globalThis;\n _rootRealmGlobalName = GlobalObjectNames.globalThis;\n} else if (typeof self !== 'undefined') {\n _rootRealmGlobal = self;\n _rootRealmGlobalName = GlobalObjectNames.self;\n} else if (typeof window !== 'undefined') {\n _rootRealmGlobal = window;\n _rootRealmGlobalName = GlobalObjectNames.window;\n} else if (typeof global !== 'undefined') {\n _rootRealmGlobal = global;\n _rootRealmGlobalName = GlobalObjectNames.global;\n} else {\n throw new Error('Unknown realm type; failed to identify global object.');\n}\n/* eslint-enable no-negated-condition */\n\n/**\n * A platform-agnostic alias for the root realm global object.\n */\nconst rootRealmGlobal = _rootRealmGlobal;\n\n/**\n * The string literal corresponding to the name of the root realm global object.\n */\nconst rootRealmGlobalName = _rootRealmGlobalName;\n\nexport { rootRealmGlobal, rootRealmGlobalName };\n"]}
@@ -1,38 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined")
5
- return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
- var __accessCheck = (obj, member, msg) => {
9
- if (!member.has(obj))
10
- throw TypeError("Cannot " + msg);
11
- };
12
- var __privateGet = (obj, member, getter) => {
13
- __accessCheck(obj, member, "read from private field");
14
- return getter ? getter.call(obj) : member.get(obj);
15
- };
16
- var __privateAdd = (obj, member, value) => {
17
- if (member.has(obj))
18
- throw TypeError("Cannot add the same private member more than once");
19
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
20
- };
21
- var __privateSet = (obj, member, value, setter) => {
22
- __accessCheck(obj, member, "write to private field");
23
- setter ? setter.call(obj, value) : member.set(obj, value);
24
- return value;
25
- };
26
- var __privateMethod = (obj, member, method) => {
27
- __accessCheck(obj, member, "access private method");
28
- return method;
29
- };
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
- exports.__require = __require; exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet; exports.__privateMethod = __privateMethod;
38
- //# sourceMappingURL=chunk-EXN2TFDJ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,16 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/common/endowments/textDecoder.ts
2
- var createTextDecoder = () => {
3
- return {
4
- TextDecoder: harden(TextDecoder)
5
- };
6
- };
7
- var endowmentModule = {
8
- names: ["TextDecoder"],
9
- factory: createTextDecoder
10
- };
11
- var textDecoder_default = endowmentModule;
12
-
13
-
14
-
15
- exports.textDecoder_default = textDecoder_default;
16
- //# sourceMappingURL=chunk-FOEAIF5U.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common/endowments/textDecoder.ts"],"names":[],"mappings":";AAKA,IAAM,oBAAoB,MAAM;AAC9B,SAAO;AAAA,IACL,aAAa,OAAO,WAAW;AAAA,EACjC;AACF;AAEA,IAAM,kBAAkB;AAAA,EACtB,OAAO,CAAC,aAAa;AAAA,EACrB,SAAS;AACX;AACA,IAAO,sBAAQ","sourcesContent":["/**\n * Creates TextDecoder function hardened by SES.\n *\n * @returns An object with the attenuated `TextDecoder` function.\n */\nconst createTextDecoder = () => {\n return {\n TextDecoder: harden(TextDecoder),\n } as const;\n};\n\nconst endowmentModule = {\n names: ['TextDecoder'] as const,\n factory: createTextDecoder,\n};\nexport default endowmentModule;\n"]}
@@ -1,82 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
- var _chunk7MMUJJQ2js = require('./chunk-7MMUJJQ2.js');
7
-
8
- // src/common/commands.ts
9
- var _snapsutils = require('@metamask/snaps-utils');
10
- var _utils = require('@metamask/utils');
11
- function getHandlerArguments(origin, handler, request) {
12
- switch (handler) {
13
- case _snapsutils.HandlerType.OnTransaction: {
14
- _chunk7MMUJJQ2js.assertIsOnTransactionRequestArguments.call(void 0, request.params);
15
- const { transaction, chainId, transactionOrigin } = request.params;
16
- return {
17
- transaction,
18
- chainId,
19
- transactionOrigin
20
- };
21
- }
22
- case _snapsutils.HandlerType.OnSignature: {
23
- _chunk7MMUJJQ2js.assertIsOnSignatureRequestArguments.call(void 0, request.params);
24
- const { signature, signatureOrigin } = request.params;
25
- return { signature, signatureOrigin };
26
- }
27
- case _snapsutils.HandlerType.OnNameLookup: {
28
- _chunk7MMUJJQ2js.assertIsOnNameLookupRequestArguments.call(void 0, request.params);
29
- const { chainId, domain, address } = request.params;
30
- return domain ? {
31
- chainId,
32
- domain
33
- } : {
34
- chainId,
35
- address
36
- };
37
- }
38
- case _snapsutils.HandlerType.OnRpcRequest:
39
- case _snapsutils.HandlerType.OnKeyringRequest:
40
- return { origin, request };
41
- case _snapsutils.HandlerType.OnCronjob:
42
- return { request };
43
- case _snapsutils.HandlerType.OnInstall:
44
- case _snapsutils.HandlerType.OnUpdate:
45
- return { origin };
46
- case _snapsutils.HandlerType.OnHomePage:
47
- return {};
48
- case _snapsutils.HandlerType.OnUserInput: {
49
- _chunk7MMUJJQ2js.assertIsOnUserInputRequestArguments.call(void 0, request.params);
50
- const { id, event, context } = request.params;
51
- return { id, event, context };
52
- }
53
- default:
54
- return _utils.assertExhaustive.call(void 0, handler);
55
- }
56
- }
57
- function getCommandMethodImplementations(startSnap, invokeSnap, onTerminate) {
58
- return {
59
- ping: async () => Promise.resolve("OK"),
60
- terminate: async () => {
61
- onTerminate();
62
- return Promise.resolve("OK");
63
- },
64
- executeSnap: async (snapId, sourceCode, endowments) => {
65
- await startSnap(snapId, sourceCode, endowments);
66
- return "OK";
67
- },
68
- snapRpc: async (target, handler, origin, request) => {
69
- return await invokeSnap(
70
- target,
71
- handler,
72
- getHandlerArguments(origin, handler, request)
73
- ) ?? null;
74
- }
75
- };
76
- }
77
-
78
-
79
-
80
-
81
- exports.getHandlerArguments = getHandlerArguments; exports.getCommandMethodImplementations = getCommandMethodImplementations;
82
- //# sourceMappingURL=chunk-FUPEJT7B.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common/commands.ts"],"names":[],"mappings":";;;;;;;;AAAA,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AAiC1B,SAAS,oBACd,QACA,SACA,SACgB;AAGhB,UAAQ,SAAS;AAAA,IACf,KAAK,YAAY,eAAe;AAC9B,4CAAsC,QAAQ,MAAM;AAEpD,YAAM,EAAE,aAAa,SAAS,kBAAkB,IAAI,QAAQ;AAC5D,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA,KAAK,YAAY,aAAa;AAC5B,0CAAoC,QAAQ,MAAM;AAElD,YAAM,EAAE,WAAW,gBAAgB,IAAI,QAAQ;AAC/C,aAAO,EAAE,WAAW,gBAAgB;AAAA,IACtC;AAAA,IACA,KAAK,YAAY,cAAc;AAC7B,2CAAqC,QAAQ,MAAM;AAInD,YAAM,EAAE,SAAS,QAAQ,QAAQ,IAC/B,QAAQ;AAEV,aAAO,SACH;AAAA,QACE;AAAA,QACA;AAAA,MACF,IACA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AAAA,IACN;AAAA,IACA,KAAK,YAAY;AAAA,IACjB,KAAK,YAAY;AACf,aAAO,EAAE,QAAQ,QAAQ;AAAA,IAE3B,KAAK,YAAY;AACf,aAAO,EAAE,QAAQ;AAAA,IAEnB,KAAK,YAAY;AAAA,IACjB,KAAK,YAAY;AACf,aAAO,EAAE,OAAO;AAAA,IAElB,KAAK,YAAY;AACf,aAAO,CAAC;AAAA,IACV,KAAK,YAAY,aAAa;AAC5B,0CAAoC,QAAQ,MAAM;AAElD,YAAM,EAAE,IAAI,OAAO,QAAQ,IAAI,QAAQ;AACvC,aAAO,EAAE,IAAI,OAAO,QAAQ;AAAA,IAC9B;AAAA,IAEA;AACE,aAAO,iBAAiB,OAAO;AAAA,EACnC;AACF;AAaO,SAAS,gCACd,WACA,YACA,aACuB;AACvB,SAAO;AAAA,IACL,MAAM,YAAY,QAAQ,QAAQ,IAAI;AAAA,IACtC,WAAW,YAAY;AACrB,kBAAY;AACZ,aAAO,QAAQ,QAAQ,IAAI;AAAA,IAC7B;AAAA,IAEA,aAAa,OAAO,QAAQ,YAAY,eAAe;AACrD,YAAM,UAAU,QAAQ,YAAY,UAAU;AAC9C,aAAO;AAAA,IACT;AAAA,IAEA,SAAS,OAAO,QAAQ,SAAS,QAAQ,YAAY;AACnD,aACG,MAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA,oBAAoB,QAAQ,SAAS,OAAO;AAAA,MAC9C,KAAM;AAAA,IAEV;AAAA,EACF;AACF","sourcesContent":["import { HandlerType } from '@metamask/snaps-utils';\nimport { 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"]}