@metamask/snaps-rpc-methods 15.1.0 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/CHANGELOG.md +34 -4
  2. package/dist/endowments/keyring.cjs +2 -5
  3. package/dist/endowments/keyring.cjs.map +1 -1
  4. package/dist/endowments/keyring.d.cts +0 -2
  5. package/dist/endowments/keyring.d.cts.map +1 -1
  6. package/dist/endowments/keyring.d.mts +0 -2
  7. package/dist/endowments/keyring.d.mts.map +1 -1
  8. package/dist/endowments/keyring.mjs +3 -6
  9. package/dist/endowments/keyring.mjs.map +1 -1
  10. package/dist/index.cjs +1 -4
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +1 -2
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +1 -2
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +1 -2
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/permissions.cjs +18 -8
  19. package/dist/permissions.cjs.map +1 -1
  20. package/dist/permissions.d.cts +3 -2
  21. package/dist/permissions.d.cts.map +1 -1
  22. package/dist/permissions.d.mts +3 -2
  23. package/dist/permissions.d.mts.map +1 -1
  24. package/dist/permissions.mjs +17 -7
  25. package/dist/permissions.mjs.map +1 -1
  26. package/dist/permitted/cancelBackgroundEvent.cjs +10 -14
  27. package/dist/permitted/cancelBackgroundEvent.cjs.map +1 -1
  28. package/dist/permitted/cancelBackgroundEvent.d.cts +9 -12
  29. package/dist/permitted/cancelBackgroundEvent.d.cts.map +1 -1
  30. package/dist/permitted/cancelBackgroundEvent.d.mts +9 -12
  31. package/dist/permitted/cancelBackgroundEvent.d.mts.map +1 -1
  32. package/dist/permitted/cancelBackgroundEvent.mjs +10 -14
  33. package/dist/permitted/cancelBackgroundEvent.mjs.map +1 -1
  34. package/dist/permitted/clearState.cjs +10 -16
  35. package/dist/permitted/clearState.cjs.map +1 -1
  36. package/dist/permitted/clearState.d.cts +9 -23
  37. package/dist/permitted/clearState.d.cts.map +1 -1
  38. package/dist/permitted/clearState.d.mts +9 -23
  39. package/dist/permitted/clearState.d.mts.map +1 -1
  40. package/dist/permitted/clearState.mjs +10 -16
  41. package/dist/permitted/clearState.mjs.map +1 -1
  42. package/dist/permitted/closeWebSocket.cjs +7 -14
  43. package/dist/permitted/closeWebSocket.cjs.map +1 -1
  44. package/dist/permitted/closeWebSocket.d.cts +9 -12
  45. package/dist/permitted/closeWebSocket.d.cts.map +1 -1
  46. package/dist/permitted/closeWebSocket.d.mts +9 -12
  47. package/dist/permitted/closeWebSocket.d.mts.map +1 -1
  48. package/dist/permitted/closeWebSocket.mjs +7 -14
  49. package/dist/permitted/closeWebSocket.mjs.map +1 -1
  50. package/dist/permitted/createInterface.cjs +11 -15
  51. package/dist/permitted/createInterface.cjs.map +1 -1
  52. package/dist/permitted/createInterface.d.cts +23 -37
  53. package/dist/permitted/createInterface.d.cts.map +1 -1
  54. package/dist/permitted/createInterface.d.mts +23 -37
  55. package/dist/permitted/createInterface.d.mts.map +1 -1
  56. package/dist/permitted/createInterface.mjs +11 -15
  57. package/dist/permitted/createInterface.mjs.map +1 -1
  58. package/dist/permitted/endTrace.cjs +4 -6
  59. package/dist/permitted/endTrace.cjs.map +1 -1
  60. package/dist/permitted/endTrace.d.cts +8 -11
  61. package/dist/permitted/endTrace.d.cts.map +1 -1
  62. package/dist/permitted/endTrace.d.mts +8 -11
  63. package/dist/permitted/endTrace.d.mts.map +1 -1
  64. package/dist/permitted/endTrace.mjs +4 -6
  65. package/dist/permitted/endTrace.mjs.map +1 -1
  66. package/dist/permitted/getAllSnaps.cjs +5 -11
  67. package/dist/permitted/getAllSnaps.cjs.map +1 -1
  68. package/dist/permitted/getAllSnaps.d.cts +10 -14
  69. package/dist/permitted/getAllSnaps.d.cts.map +1 -1
  70. package/dist/permitted/getAllSnaps.d.mts +10 -14
  71. package/dist/permitted/getAllSnaps.d.mts.map +1 -1
  72. package/dist/permitted/getAllSnaps.mjs +5 -11
  73. package/dist/permitted/getAllSnaps.mjs.map +1 -1
  74. package/dist/permitted/getBackgroundEvents.cjs +8 -15
  75. package/dist/permitted/getBackgroundEvents.cjs.map +1 -1
  76. package/dist/permitted/getBackgroundEvents.d.cts +10 -13
  77. package/dist/permitted/getBackgroundEvents.d.cts.map +1 -1
  78. package/dist/permitted/getBackgroundEvents.d.mts +10 -13
  79. package/dist/permitted/getBackgroundEvents.d.mts.map +1 -1
  80. package/dist/permitted/getBackgroundEvents.mjs +8 -15
  81. package/dist/permitted/getBackgroundEvents.mjs.map +1 -1
  82. package/dist/permitted/getClientStatus.cjs +5 -6
  83. package/dist/permitted/getClientStatus.cjs.map +1 -1
  84. package/dist/permitted/getClientStatus.d.cts +17 -18
  85. package/dist/permitted/getClientStatus.d.cts.map +1 -1
  86. package/dist/permitted/getClientStatus.d.mts +17 -18
  87. package/dist/permitted/getClientStatus.d.mts.map +1 -1
  88. package/dist/permitted/getClientStatus.mjs +5 -6
  89. package/dist/permitted/getClientStatus.mjs.map +1 -1
  90. package/dist/permitted/getFile.cjs +7 -11
  91. package/dist/permitted/getFile.cjs.map +1 -1
  92. package/dist/permitted/getFile.d.cts +8 -10
  93. package/dist/permitted/getFile.d.cts.map +1 -1
  94. package/dist/permitted/getFile.d.mts +8 -10
  95. package/dist/permitted/getFile.d.mts.map +1 -1
  96. package/dist/permitted/getFile.mjs +7 -11
  97. package/dist/permitted/getFile.mjs.map +1 -1
  98. package/dist/permitted/getInterfaceContext.cjs +12 -15
  99. package/dist/permitted/getInterfaceContext.cjs.map +1 -1
  100. package/dist/permitted/getInterfaceContext.d.cts +9 -21
  101. package/dist/permitted/getInterfaceContext.d.cts.map +1 -1
  102. package/dist/permitted/getInterfaceContext.d.mts +9 -21
  103. package/dist/permitted/getInterfaceContext.d.mts.map +1 -1
  104. package/dist/permitted/getInterfaceContext.mjs +12 -15
  105. package/dist/permitted/getInterfaceContext.mjs.map +1 -1
  106. package/dist/permitted/getInterfaceState.cjs +11 -15
  107. package/dist/permitted/getInterfaceState.cjs.map +1 -1
  108. package/dist/permitted/getInterfaceState.d.cts +9 -21
  109. package/dist/permitted/getInterfaceState.d.cts.map +1 -1
  110. package/dist/permitted/getInterfaceState.d.mts +9 -21
  111. package/dist/permitted/getInterfaceState.d.mts.map +1 -1
  112. package/dist/permitted/getInterfaceState.mjs +11 -15
  113. package/dist/permitted/getInterfaceState.mjs.map +1 -1
  114. package/dist/permitted/getSnaps.cjs +6 -12
  115. package/dist/permitted/getSnaps.cjs.map +1 -1
  116. package/dist/permitted/getSnaps.d.cts +11 -14
  117. package/dist/permitted/getSnaps.d.cts.map +1 -1
  118. package/dist/permitted/getSnaps.d.mts +11 -14
  119. package/dist/permitted/getSnaps.d.mts.map +1 -1
  120. package/dist/permitted/getSnaps.mjs +6 -12
  121. package/dist/permitted/getSnaps.mjs.map +1 -1
  122. package/dist/permitted/getState.cjs +9 -11
  123. package/dist/permitted/getState.cjs.map +1 -1
  124. package/dist/permitted/getState.d.cts +17 -28
  125. package/dist/permitted/getState.d.cts.map +1 -1
  126. package/dist/permitted/getState.d.mts +17 -28
  127. package/dist/permitted/getState.d.mts.map +1 -1
  128. package/dist/permitted/getState.mjs +9 -11
  129. package/dist/permitted/getState.mjs.map +1 -1
  130. package/dist/permitted/getWebSockets.cjs +11 -14
  131. package/dist/permitted/getWebSockets.cjs.map +1 -1
  132. package/dist/permitted/getWebSockets.d.cts +10 -13
  133. package/dist/permitted/getWebSockets.d.cts.map +1 -1
  134. package/dist/permitted/getWebSockets.d.mts +10 -13
  135. package/dist/permitted/getWebSockets.d.mts.map +1 -1
  136. package/dist/permitted/getWebSockets.mjs +11 -14
  137. package/dist/permitted/getWebSockets.mjs.map +1 -1
  138. package/dist/permitted/index.cjs +0 -1
  139. package/dist/permitted/index.cjs.map +1 -1
  140. package/dist/permitted/index.d.cts +29 -25
  141. package/dist/permitted/index.d.cts.map +1 -1
  142. package/dist/permitted/index.d.mts +29 -25
  143. package/dist/permitted/index.d.mts.map +1 -1
  144. package/dist/permitted/index.mjs +0 -1
  145. package/dist/permitted/index.mjs.map +1 -1
  146. package/dist/permitted/invokeKeyring.cjs +12 -13
  147. package/dist/permitted/invokeKeyring.cjs.map +1 -1
  148. package/dist/permitted/invokeKeyring.d.cts +17 -16
  149. package/dist/permitted/invokeKeyring.d.cts.map +1 -1
  150. package/dist/permitted/invokeKeyring.d.mts +17 -16
  151. package/dist/permitted/invokeKeyring.d.mts.map +1 -1
  152. package/dist/permitted/invokeKeyring.mjs +12 -13
  153. package/dist/permitted/invokeKeyring.mjs.map +1 -1
  154. package/dist/permitted/invokeSnapSugar.cjs +6 -10
  155. package/dist/permitted/invokeSnapSugar.cjs.map +1 -1
  156. package/dist/permitted/invokeSnapSugar.d.cts +9 -12
  157. package/dist/permitted/invokeSnapSugar.d.cts.map +1 -1
  158. package/dist/permitted/invokeSnapSugar.d.mts +9 -12
  159. package/dist/permitted/invokeSnapSugar.d.mts.map +1 -1
  160. package/dist/permitted/invokeSnapSugar.mjs +6 -10
  161. package/dist/permitted/invokeSnapSugar.mjs.map +1 -1
  162. package/dist/permitted/listEntropySources.cjs +28 -12
  163. package/dist/permitted/listEntropySources.cjs.map +1 -1
  164. package/dist/permitted/listEntropySources.d.cts +12 -23
  165. package/dist/permitted/listEntropySources.d.cts.map +1 -1
  166. package/dist/permitted/listEntropySources.d.mts +12 -23
  167. package/dist/permitted/listEntropySources.d.mts.map +1 -1
  168. package/dist/permitted/listEntropySources.mjs +28 -12
  169. package/dist/permitted/listEntropySources.mjs.map +1 -1
  170. package/dist/permitted/middleware.cjs +70 -20
  171. package/dist/permitted/middleware.cjs.map +1 -1
  172. package/dist/permitted/middleware.d.cts +5 -2
  173. package/dist/permitted/middleware.d.cts.map +1 -1
  174. package/dist/permitted/middleware.d.mts +5 -2
  175. package/dist/permitted/middleware.d.mts.map +1 -1
  176. package/dist/permitted/middleware.mjs +70 -20
  177. package/dist/permitted/middleware.mjs.map +1 -1
  178. package/dist/permitted/openWebSocket.cjs +7 -14
  179. package/dist/permitted/openWebSocket.cjs.map +1 -1
  180. package/dist/permitted/openWebSocket.d.cts +9 -12
  181. package/dist/permitted/openWebSocket.d.cts.map +1 -1
  182. package/dist/permitted/openWebSocket.d.mts +9 -12
  183. package/dist/permitted/openWebSocket.d.mts.map +1 -1
  184. package/dist/permitted/openWebSocket.mjs +7 -14
  185. package/dist/permitted/openWebSocket.mjs.map +1 -1
  186. package/dist/permitted/requestSnaps.cjs +14 -19
  187. package/dist/permitted/requestSnaps.cjs.map +1 -1
  188. package/dist/permitted/requestSnaps.d.cts +9 -36
  189. package/dist/permitted/requestSnaps.d.cts.map +1 -1
  190. package/dist/permitted/requestSnaps.d.mts +9 -36
  191. package/dist/permitted/requestSnaps.d.mts.map +1 -1
  192. package/dist/permitted/requestSnaps.mjs +15 -20
  193. package/dist/permitted/requestSnaps.mjs.map +1 -1
  194. package/dist/permitted/resolveInterface.cjs +11 -15
  195. package/dist/permitted/resolveInterface.cjs.map +1 -1
  196. package/dist/permitted/resolveInterface.d.cts +12 -24
  197. package/dist/permitted/resolveInterface.d.cts.map +1 -1
  198. package/dist/permitted/resolveInterface.d.mts +12 -24
  199. package/dist/permitted/resolveInterface.d.mts.map +1 -1
  200. package/dist/permitted/resolveInterface.mjs +11 -15
  201. package/dist/permitted/resolveInterface.mjs.map +1 -1
  202. package/dist/permitted/scheduleBackgroundEvent.cjs +11 -14
  203. package/dist/permitted/scheduleBackgroundEvent.cjs.map +1 -1
  204. package/dist/permitted/scheduleBackgroundEvent.d.cts +10 -17
  205. package/dist/permitted/scheduleBackgroundEvent.d.cts.map +1 -1
  206. package/dist/permitted/scheduleBackgroundEvent.d.mts +10 -17
  207. package/dist/permitted/scheduleBackgroundEvent.d.mts.map +1 -1
  208. package/dist/permitted/scheduleBackgroundEvent.mjs +11 -14
  209. package/dist/permitted/scheduleBackgroundEvent.mjs.map +1 -1
  210. package/dist/permitted/sendWebSocketMessage.cjs +10 -14
  211. package/dist/permitted/sendWebSocketMessage.cjs.map +1 -1
  212. package/dist/permitted/sendWebSocketMessage.d.cts +9 -12
  213. package/dist/permitted/sendWebSocketMessage.d.cts.map +1 -1
  214. package/dist/permitted/sendWebSocketMessage.d.mts +9 -12
  215. package/dist/permitted/sendWebSocketMessage.d.mts.map +1 -1
  216. package/dist/permitted/sendWebSocketMessage.mjs +10 -14
  217. package/dist/permitted/sendWebSocketMessage.mjs.map +1 -1
  218. package/dist/permitted/setState.cjs +18 -21
  219. package/dist/permitted/setState.cjs.map +1 -1
  220. package/dist/permitted/setState.d.cts +18 -45
  221. package/dist/permitted/setState.d.cts.map +1 -1
  222. package/dist/permitted/setState.d.mts +18 -45
  223. package/dist/permitted/setState.d.mts.map +1 -1
  224. package/dist/permitted/setState.mjs +18 -21
  225. package/dist/permitted/setState.mjs.map +1 -1
  226. package/dist/permitted/startTrace.cjs +4 -6
  227. package/dist/permitted/startTrace.cjs.map +1 -1
  228. package/dist/permitted/startTrace.d.cts +8 -11
  229. package/dist/permitted/startTrace.d.cts.map +1 -1
  230. package/dist/permitted/startTrace.d.mts +8 -11
  231. package/dist/permitted/startTrace.d.mts.map +1 -1
  232. package/dist/permitted/startTrace.mjs +4 -6
  233. package/dist/permitted/startTrace.mjs.map +1 -1
  234. package/dist/permitted/trackError.cjs +4 -6
  235. package/dist/permitted/trackError.cjs.map +1 -1
  236. package/dist/permitted/trackError.d.cts +8 -11
  237. package/dist/permitted/trackError.d.cts.map +1 -1
  238. package/dist/permitted/trackError.d.mts +8 -11
  239. package/dist/permitted/trackError.d.mts.map +1 -1
  240. package/dist/permitted/trackError.mjs +4 -6
  241. package/dist/permitted/trackError.mjs.map +1 -1
  242. package/dist/permitted/trackEvent.cjs +4 -6
  243. package/dist/permitted/trackEvent.cjs.map +1 -1
  244. package/dist/permitted/trackEvent.d.cts +8 -11
  245. package/dist/permitted/trackEvent.d.cts.map +1 -1
  246. package/dist/permitted/trackEvent.d.mts +8 -11
  247. package/dist/permitted/trackEvent.d.mts.map +1 -1
  248. package/dist/permitted/trackEvent.mjs +4 -6
  249. package/dist/permitted/trackEvent.mjs.map +1 -1
  250. package/dist/permitted/updateInterface.cjs +11 -15
  251. package/dist/permitted/updateInterface.cjs.map +1 -1
  252. package/dist/permitted/updateInterface.d.cts +9 -22
  253. package/dist/permitted/updateInterface.d.cts.map +1 -1
  254. package/dist/permitted/updateInterface.d.mts +9 -22
  255. package/dist/permitted/updateInterface.d.mts.map +1 -1
  256. package/dist/permitted/updateInterface.mjs +11 -15
  257. package/dist/permitted/updateInterface.mjs.map +1 -1
  258. package/dist/restricted/dialog.cjs +23 -30
  259. package/dist/restricted/dialog.cjs.map +1 -1
  260. package/dist/restricted/dialog.d.cts +10 -58
  261. package/dist/restricted/dialog.d.cts.map +1 -1
  262. package/dist/restricted/dialog.d.mts +10 -58
  263. package/dist/restricted/dialog.d.mts.map +1 -1
  264. package/dist/restricted/dialog.mjs +23 -30
  265. package/dist/restricted/dialog.mjs.map +1 -1
  266. package/dist/restricted/getBip32Entropy.cjs +15 -12
  267. package/dist/restricted/getBip32Entropy.cjs.map +1 -1
  268. package/dist/restricted/getBip32Entropy.d.cts +11 -24
  269. package/dist/restricted/getBip32Entropy.d.cts.map +1 -1
  270. package/dist/restricted/getBip32Entropy.d.mts +11 -24
  271. package/dist/restricted/getBip32Entropy.d.mts.map +1 -1
  272. package/dist/restricted/getBip32Entropy.mjs +16 -13
  273. package/dist/restricted/getBip32Entropy.mjs.map +1 -1
  274. package/dist/restricted/getBip32PublicKey.cjs +15 -12
  275. package/dist/restricted/getBip32PublicKey.cjs.map +1 -1
  276. package/dist/restricted/getBip32PublicKey.d.cts +11 -24
  277. package/dist/restricted/getBip32PublicKey.d.cts.map +1 -1
  278. package/dist/restricted/getBip32PublicKey.d.mts +11 -24
  279. package/dist/restricted/getBip32PublicKey.d.mts.map +1 -1
  280. package/dist/restricted/getBip32PublicKey.mjs +16 -13
  281. package/dist/restricted/getBip32PublicKey.mjs.map +1 -1
  282. package/dist/restricted/getBip44Entropy.cjs +14 -10
  283. package/dist/restricted/getBip44Entropy.cjs.map +1 -1
  284. package/dist/restricted/getBip44Entropy.d.cts +11 -15
  285. package/dist/restricted/getBip44Entropy.d.cts.map +1 -1
  286. package/dist/restricted/getBip44Entropy.d.mts +11 -15
  287. package/dist/restricted/getBip44Entropy.d.mts.map +1 -1
  288. package/dist/restricted/getBip44Entropy.mjs +15 -11
  289. package/dist/restricted/getBip44Entropy.mjs.map +1 -1
  290. package/dist/restricted/getEntropy.cjs +10 -10
  291. package/dist/restricted/getEntropy.cjs.map +1 -1
  292. package/dist/restricted/getEntropy.d.cts +11 -15
  293. package/dist/restricted/getEntropy.d.cts.map +1 -1
  294. package/dist/restricted/getEntropy.d.mts +11 -15
  295. package/dist/restricted/getEntropy.d.mts.map +1 -1
  296. package/dist/restricted/getEntropy.mjs +11 -11
  297. package/dist/restricted/getEntropy.mjs.map +1 -1
  298. package/dist/restricted/index.cjs.map +1 -1
  299. package/dist/restricted/index.d.cts +20 -160
  300. package/dist/restricted/index.d.cts.map +1 -1
  301. package/dist/restricted/index.d.mts +20 -160
  302. package/dist/restricted/index.d.mts.map +1 -1
  303. package/dist/restricted/index.mjs.map +1 -1
  304. package/dist/restricted/invokeSnap.cjs +11 -12
  305. package/dist/restricted/invokeSnap.cjs.map +1 -1
  306. package/dist/restricted/invokeSnap.d.cts +9 -13
  307. package/dist/restricted/invokeSnap.d.cts.map +1 -1
  308. package/dist/restricted/invokeSnap.d.mts +9 -13
  309. package/dist/restricted/invokeSnap.d.mts.map +1 -1
  310. package/dist/restricted/invokeSnap.mjs +11 -12
  311. package/dist/restricted/invokeSnap.mjs.map +1 -1
  312. package/dist/restricted/manageState.cjs +21 -20
  313. package/dist/restricted/manageState.cjs.map +1 -1
  314. package/dist/restricted/manageState.d.cts +12 -34
  315. package/dist/restricted/manageState.d.cts.map +1 -1
  316. package/dist/restricted/manageState.d.mts +12 -34
  317. package/dist/restricted/manageState.d.mts.map +1 -1
  318. package/dist/restricted/manageState.mjs +21 -20
  319. package/dist/restricted/manageState.mjs.map +1 -1
  320. package/dist/restricted/notify.cjs +31 -24
  321. package/dist/restricted/notify.cjs.map +1 -1
  322. package/dist/restricted/notify.d.cts +16 -25
  323. package/dist/restricted/notify.d.cts.map +1 -1
  324. package/dist/restricted/notify.d.mts +16 -25
  325. package/dist/restricted/notify.d.mts.map +1 -1
  326. package/dist/restricted/notify.mjs +32 -25
  327. package/dist/restricted/notify.mjs.map +1 -1
  328. package/dist/types.cjs +3 -0
  329. package/dist/types.cjs.map +1 -0
  330. package/dist/types.d.cts +155 -0
  331. package/dist/types.d.cts.map +1 -0
  332. package/dist/types.d.mts +155 -0
  333. package/dist/types.d.mts.map +1 -0
  334. package/dist/types.mjs +2 -0
  335. package/dist/types.mjs.map +1 -0
  336. package/dist/utils.cjs +78 -24
  337. package/dist/utils.cjs.map +1 -1
  338. package/dist/utils.d.cts +21 -13
  339. package/dist/utils.d.cts.map +1 -1
  340. package/dist/utils.d.mts +21 -13
  341. package/dist/utils.d.mts.map +1 -1
  342. package/dist/utils.mjs +75 -22
  343. package/dist/utils.mjs.map +1 -1
  344. package/package.json +6 -6
  345. package/dist/permitted/handlers.cjs +0 -63
  346. package/dist/permitted/handlers.cjs.map +0 -1
  347. package/dist/permitted/handlers.d.cts +0 -299
  348. package/dist/permitted/handlers.d.cts.map +0 -1
  349. package/dist/permitted/handlers.d.mts +0 -299
  350. package/dist/permitted/handlers.d.mts.map +0 -1
  351. package/dist/permitted/handlers.mjs +0 -60
  352. package/dist/permitted/handlers.mjs.map +0 -1
@@ -1,169 +1,29 @@
1
- import type { DialogMethodHooks } from "./dialog.cjs";
2
- import type { GetBip32EntropyMethodHooks } from "./getBip32Entropy.cjs";
3
- import type { GetBip32PublicKeyMethodHooks } from "./getBip32PublicKey.cjs";
4
- import type { GetBip44EntropyMethodHooks } from "./getBip44Entropy.cjs";
5
- import type { GetEntropyHooks } from "./getEntropy.cjs";
1
+ import type { Messenger } from "@metamask/messenger";
2
+ import type { PermissionSpecificationBuilder, PermissionType, RestrictedMethodSpecificationConstraint } from "@metamask/permission-controller";
3
+ import type { DialogMessengerActions } from "./dialog.cjs";
4
+ import type { GetBip32EntropyMessengerActions, GetBip32EntropyMethodHooks } from "./getBip32Entropy.cjs";
5
+ import type { GetBip32PublicKeyMessengerActions, GetBip32PublicKeyMethodHooks } from "./getBip32PublicKey.cjs";
6
+ import type { GetBip44EntropyMessengerActions, GetBip44EntropyMethodHooks } from "./getBip44Entropy.cjs";
7
+ import type { GetEntropyHooks, GetEntropyMessengerActions } from "./getEntropy.cjs";
6
8
  import type { GetLocaleMethodHooks } from "./getLocale.cjs";
7
9
  import type { GetPreferencesMethodHooks } from "./getPreferences.cjs";
8
- import type { InvokeSnapMethodHooks } from "./invokeSnap.cjs";
10
+ import type { InvokeSnapMessengerActions } from "./invokeSnap.cjs";
9
11
  import type { ManageAccountsMethodHooks } from "./manageAccounts.cjs";
10
- import type { ManageStateMethodHooks } from "./manageState.cjs";
11
- import type { NotifyMethodHooks } from "./notify.cjs";
12
+ import type { ManageStateMessengerActions, ManageStateMethodHooks } from "./manageState.cjs";
13
+ import type { NotifyMessengerActions, NotifyMethodHooks } from "./notify.cjs";
14
+ import type { MethodHooksObject } from "../utils.cjs";
12
15
  export { WALLET_SNAP_PERMISSION_KEY } from "./invokeSnap.cjs";
13
16
  export { getEncryptionEntropy } from "./manageState.cjs";
14
- export type RestrictedMethodHooks = DialogMethodHooks & GetBip32EntropyMethodHooks & GetBip32PublicKeyMethodHooks & GetBip44EntropyMethodHooks & GetEntropyHooks & InvokeSnapMethodHooks & ManageStateMethodHooks & NotifyMethodHooks & ManageAccountsMethodHooks & GetLocaleMethodHooks & GetPreferencesMethodHooks;
15
- export declare const restrictedMethodPermissionBuilders: {
16
- readonly snap_dialog: Readonly<{
17
- readonly targetName: "snap_dialog";
18
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
19
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
20
- methodHooks: DialogMethodHooks;
21
- }, {
22
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
23
- targetName: "snap_dialog";
24
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").DialogParams>) => Promise<import("@metamask/utils").Json>;
25
- allowedCaveats: readonly [string, ...string[]] | null;
26
- }>;
27
- readonly methodHooks: import("../utils.cjs").MethodHooksObject<DialogMethodHooks>;
28
- }>;
29
- readonly snap_getBip32Entropy: Readonly<{
30
- readonly targetName: "snap_getBip32Entropy";
31
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
32
- methodHooks: GetBip32EntropyMethodHooks;
33
- }, {
34
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
35
- targetName: "snap_getBip32Entropy";
36
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").GetBip32EntropyParams>) => Promise<import("@metamask/key-tree").JsonSLIP10Node>;
37
- allowedCaveats: readonly [string, ...string[]] | null;
38
- validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
39
- }>;
40
- readonly methodHooks: import("../utils.cjs").MethodHooksObject<GetBip32EntropyMethodHooks>;
41
- }>;
42
- readonly snap_getBip32PublicKey: Readonly<{
43
- readonly targetName: "snap_getBip32PublicKey";
44
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
45
- methodHooks: GetBip32PublicKeyMethodHooks;
46
- }, {
47
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
48
- targetName: "snap_getBip32PublicKey";
49
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").GetBip32PublicKeyParams>) => Promise<string>;
50
- allowedCaveats: readonly [string, ...string[]] | null;
51
- validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
52
- }>;
53
- readonly methodHooks: import("../utils.cjs").MethodHooksObject<GetBip32PublicKeyMethodHooks>;
54
- }>;
55
- readonly snap_getBip44Entropy: Readonly<{
56
- readonly targetName: "snap_getBip44Entropy";
57
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
58
- methodHooks: GetBip44EntropyMethodHooks;
59
- }, {
60
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
61
- targetName: "snap_getBip44Entropy";
62
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").GetBip44EntropyParams>) => Promise<import("@metamask/key-tree").JsonBIP44CoinTypeNode>;
63
- allowedCaveats: readonly [string, ...string[]] | null;
64
- validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
65
- }>;
66
- readonly methodHooks: import("../utils.cjs").MethodHooksObject<GetBip44EntropyMethodHooks>;
67
- }>;
68
- readonly snap_getEntropy: Readonly<{
69
- readonly targetName: "snap_getEntropy";
70
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
71
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
72
- methodHooks: GetEntropyHooks;
73
- }, {
74
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
75
- targetName: "snap_getEntropy";
76
- methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").GetEntropyParams>) => Promise<`0x${string}`>;
77
- allowedCaveats: readonly [string, ...string[]] | null;
78
- }>;
79
- readonly methodHooks: import("../utils.cjs").MethodHooksObject<GetEntropyHooks>;
80
- }>;
81
- readonly wallet_snap: Readonly<{
82
- readonly targetName: "wallet_snap";
83
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
84
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
85
- methodHooks: InvokeSnapMethodHooks;
86
- }, {
87
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
88
- targetName: "wallet_snap";
89
- methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").InvokeSnapParams>) => Promise<import("@metamask/utils").Json>;
90
- allowedCaveats: readonly [string, ...string[]] | null;
91
- validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
92
- sideEffect: {
93
- onPermitted: import("@metamask/permission-controller").SideEffectHandler<import("./invokeSnap.cjs").SnapControllerInstallSnapsAction | import("./invokeSnap.cjs").SnapControllerGetPermittedSnapsAction, never>;
94
- };
95
- }>;
96
- readonly methodHooks: import("../utils.cjs").MethodHooksObject<InvokeSnapMethodHooks>;
97
- }>;
98
- readonly snap_manageState: Readonly<{
99
- readonly targetName: "snap_manageState";
100
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
101
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
102
- methodHooks: ManageStateMethodHooks;
103
- }, {
104
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
105
- targetName: "snap_manageState";
106
- methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").ManageStateParams>) => Promise<import("@metamask/snaps-sdk").ManageStateResult>;
107
- allowedCaveats: readonly [string, ...string[]] | null;
108
- }>;
109
- readonly methodHooks: import("../utils.cjs").MethodHooksObject<ManageStateMethodHooks>;
110
- }>;
111
- readonly snap_notify: Readonly<{
112
- readonly targetName: "snap_notify";
113
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
114
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
115
- methodHooks: NotifyMethodHooks;
116
- }, {
117
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
118
- targetName: "snap_notify";
119
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").NotifyParams>) => Promise<null>;
120
- allowedCaveats: readonly [string, ...string[]] | null;
121
- }>;
122
- readonly methodHooks: import("../utils.cjs").MethodHooksObject<NotifyMethodHooks>;
123
- }>;
124
- readonly snap_manageAccounts: Readonly<{
125
- readonly targetName: "snap_manageAccounts";
126
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
127
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
128
- methodHooks: ManageAccountsMethodHooks;
129
- }, {
130
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
131
- targetName: "snap_manageAccounts";
132
- methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").ManageAccountsParams>) => Promise<import("@metamask/utils").Json>;
133
- allowedCaveats: readonly [string, ...string[]] | null;
134
- }>;
135
- readonly methodHooks: {
136
- readonly getSnapKeyring: true;
137
- readonly getUnlockPromise: true;
138
- };
139
- }>;
140
- readonly snap_getLocale: Readonly<{
141
- readonly targetName: "snap_getLocale";
142
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
143
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
144
- methodHooks: GetLocaleMethodHooks;
145
- }, {
146
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
147
- targetName: "snap_getLocale";
148
- methodImplementation: (_args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/permission-controller").RestrictedMethodParameters>) => Promise<string>;
149
- allowedCaveats: readonly [string, ...string[]] | null;
150
- }>;
151
- readonly methodHooks: import("../utils.cjs").MethodHooksObject<GetLocaleMethodHooks>;
152
- }>;
153
- readonly snap_getPreferences: Readonly<{
154
- readonly targetName: "snap_getPreferences";
155
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
156
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
157
- methodHooks: GetPreferencesMethodHooks;
158
- }, {
159
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
160
- targetName: "snap_getPreferences";
161
- methodImplementation: (_args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/permission-controller").RestrictedMethodParameters>) => Promise<import("@metamask/snaps-sdk").GetPreferencesResult>;
162
- allowedCaveats: readonly [string, ...string[]] | null;
163
- }>;
164
- readonly methodHooks: import("../utils.cjs").MethodHooksObject<GetPreferencesMethodHooks>;
165
- }>;
17
+ export type RestrictedMethodActions = DialogMessengerActions | GetBip32EntropyMessengerActions | GetBip32PublicKeyMessengerActions | GetBip44EntropyMessengerActions | GetEntropyMessengerActions | InvokeSnapMessengerActions | ManageStateMessengerActions | NotifyMessengerActions;
18
+ export type RestrictedMethodMessenger = Messenger<string, RestrictedMethodActions>;
19
+ export type RestrictedMethodHooks = GetBip32EntropyMethodHooks & GetBip32PublicKeyMethodHooks & GetBip44EntropyMethodHooks & GetEntropyHooks & ManageStateMethodHooks & NotifyMethodHooks & ManageAccountsMethodHooks & GetLocaleMethodHooks & GetPreferencesMethodHooks;
20
+ type RestrictedMethodPermissionBuilder = {
21
+ targetName: string;
22
+ specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, any, RestrictedMethodSpecificationConstraint>;
23
+ actionNames?: readonly RestrictedMethodActions['type'][];
24
+ methodHooks?: MethodHooksObject<Record<string, unknown>>;
166
25
  };
26
+ export declare const restrictedMethodPermissionBuilders: Record<string, RestrictedMethodPermissionBuilder>;
167
27
  export * from "./caveats/index.cjs";
168
28
  export type { DialogApprovalTypes } from "./dialog.cjs";
169
29
  export { DIALOG_APPROVAL_TYPES } from "./dialog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BAAsB,GACtB,iBAAiB,GACjB,yBAAyB,GACzB,oBAAoB,GACpB,yBAAyB,CAAC;AAE5B,KAAK,iCAAiC,GAAG;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,8BAA8B,CAClD,cAAc,CAAC,gBAAgB,EAC/B,GAAG,EACH,uCAAuC,CACxC,CAAC;IACF,WAAW,CAAC,EAAE,SAAS,uBAAuB,CAAC,MAAM,CAAC,EAAE,CAAC;IACzD,WAAW,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF,eAAO,MAAM,kCAAkC,EAAE,MAAM,CACrD,MAAM,EACN,iCAAiC,CAazB,CAAC;AAEX,oCAA0B;AAC1B,YAAY,EAAE,mBAAmB,EAAE,qBAAiB;AACpD,OAAO,EAAE,qBAAqB,EAAE,qBAAiB"}
@@ -1,169 +1,29 @@
1
- import type { DialogMethodHooks } from "./dialog.mjs";
2
- import type { GetBip32EntropyMethodHooks } from "./getBip32Entropy.mjs";
3
- import type { GetBip32PublicKeyMethodHooks } from "./getBip32PublicKey.mjs";
4
- import type { GetBip44EntropyMethodHooks } from "./getBip44Entropy.mjs";
5
- import type { GetEntropyHooks } from "./getEntropy.mjs";
1
+ import type { Messenger } from "@metamask/messenger";
2
+ import type { PermissionSpecificationBuilder, PermissionType, RestrictedMethodSpecificationConstraint } from "@metamask/permission-controller";
3
+ import type { DialogMessengerActions } from "./dialog.mjs";
4
+ import type { GetBip32EntropyMessengerActions, GetBip32EntropyMethodHooks } from "./getBip32Entropy.mjs";
5
+ import type { GetBip32PublicKeyMessengerActions, GetBip32PublicKeyMethodHooks } from "./getBip32PublicKey.mjs";
6
+ import type { GetBip44EntropyMessengerActions, GetBip44EntropyMethodHooks } from "./getBip44Entropy.mjs";
7
+ import type { GetEntropyHooks, GetEntropyMessengerActions } from "./getEntropy.mjs";
6
8
  import type { GetLocaleMethodHooks } from "./getLocale.mjs";
7
9
  import type { GetPreferencesMethodHooks } from "./getPreferences.mjs";
8
- import type { InvokeSnapMethodHooks } from "./invokeSnap.mjs";
10
+ import type { InvokeSnapMessengerActions } from "./invokeSnap.mjs";
9
11
  import type { ManageAccountsMethodHooks } from "./manageAccounts.mjs";
10
- import type { ManageStateMethodHooks } from "./manageState.mjs";
11
- import type { NotifyMethodHooks } from "./notify.mjs";
12
+ import type { ManageStateMessengerActions, ManageStateMethodHooks } from "./manageState.mjs";
13
+ import type { NotifyMessengerActions, NotifyMethodHooks } from "./notify.mjs";
14
+ import type { MethodHooksObject } from "../utils.mjs";
12
15
  export { WALLET_SNAP_PERMISSION_KEY } from "./invokeSnap.mjs";
13
16
  export { getEncryptionEntropy } from "./manageState.mjs";
14
- export type RestrictedMethodHooks = DialogMethodHooks & GetBip32EntropyMethodHooks & GetBip32PublicKeyMethodHooks & GetBip44EntropyMethodHooks & GetEntropyHooks & InvokeSnapMethodHooks & ManageStateMethodHooks & NotifyMethodHooks & ManageAccountsMethodHooks & GetLocaleMethodHooks & GetPreferencesMethodHooks;
15
- export declare const restrictedMethodPermissionBuilders: {
16
- readonly snap_dialog: Readonly<{
17
- readonly targetName: "snap_dialog";
18
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
19
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
20
- methodHooks: DialogMethodHooks;
21
- }, {
22
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
23
- targetName: "snap_dialog";
24
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").DialogParams>) => Promise<import("@metamask/utils").Json>;
25
- allowedCaveats: readonly [string, ...string[]] | null;
26
- }>;
27
- readonly methodHooks: import("../utils.mjs").MethodHooksObject<DialogMethodHooks>;
28
- }>;
29
- readonly snap_getBip32Entropy: Readonly<{
30
- readonly targetName: "snap_getBip32Entropy";
31
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
32
- methodHooks: GetBip32EntropyMethodHooks;
33
- }, {
34
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
35
- targetName: "snap_getBip32Entropy";
36
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").GetBip32EntropyParams>) => Promise<import("@metamask/key-tree").JsonSLIP10Node>;
37
- allowedCaveats: readonly [string, ...string[]] | null;
38
- validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
39
- }>;
40
- readonly methodHooks: import("../utils.mjs").MethodHooksObject<GetBip32EntropyMethodHooks>;
41
- }>;
42
- readonly snap_getBip32PublicKey: Readonly<{
43
- readonly targetName: "snap_getBip32PublicKey";
44
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
45
- methodHooks: GetBip32PublicKeyMethodHooks;
46
- }, {
47
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
48
- targetName: "snap_getBip32PublicKey";
49
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").GetBip32PublicKeyParams>) => Promise<string>;
50
- allowedCaveats: readonly [string, ...string[]] | null;
51
- validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
52
- }>;
53
- readonly methodHooks: import("../utils.mjs").MethodHooksObject<GetBip32PublicKeyMethodHooks>;
54
- }>;
55
- readonly snap_getBip44Entropy: Readonly<{
56
- readonly targetName: "snap_getBip44Entropy";
57
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
58
- methodHooks: GetBip44EntropyMethodHooks;
59
- }, {
60
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
61
- targetName: "snap_getBip44Entropy";
62
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").GetBip44EntropyParams>) => Promise<import("@metamask/key-tree").JsonBIP44CoinTypeNode>;
63
- allowedCaveats: readonly [string, ...string[]] | null;
64
- validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
65
- }>;
66
- readonly methodHooks: import("../utils.mjs").MethodHooksObject<GetBip44EntropyMethodHooks>;
67
- }>;
68
- readonly snap_getEntropy: Readonly<{
69
- readonly targetName: "snap_getEntropy";
70
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
71
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
72
- methodHooks: GetEntropyHooks;
73
- }, {
74
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
75
- targetName: "snap_getEntropy";
76
- methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").GetEntropyParams>) => Promise<`0x${string}`>;
77
- allowedCaveats: readonly [string, ...string[]] | null;
78
- }>;
79
- readonly methodHooks: import("../utils.mjs").MethodHooksObject<GetEntropyHooks>;
80
- }>;
81
- readonly wallet_snap: Readonly<{
82
- readonly targetName: "wallet_snap";
83
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
84
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
85
- methodHooks: InvokeSnapMethodHooks;
86
- }, {
87
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
88
- targetName: "wallet_snap";
89
- methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").InvokeSnapParams>) => Promise<import("@metamask/utils").Json>;
90
- allowedCaveats: readonly [string, ...string[]] | null;
91
- validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
92
- sideEffect: {
93
- onPermitted: import("@metamask/permission-controller").SideEffectHandler<import("./invokeSnap.mjs").SnapControllerInstallSnapsAction | import("./invokeSnap.mjs").SnapControllerGetPermittedSnapsAction, never>;
94
- };
95
- }>;
96
- readonly methodHooks: import("../utils.mjs").MethodHooksObject<InvokeSnapMethodHooks>;
97
- }>;
98
- readonly snap_manageState: Readonly<{
99
- readonly targetName: "snap_manageState";
100
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
101
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
102
- methodHooks: ManageStateMethodHooks;
103
- }, {
104
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
105
- targetName: "snap_manageState";
106
- methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").ManageStateParams>) => Promise<import("@metamask/snaps-sdk").ManageStateResult>;
107
- allowedCaveats: readonly [string, ...string[]] | null;
108
- }>;
109
- readonly methodHooks: import("../utils.mjs").MethodHooksObject<ManageStateMethodHooks>;
110
- }>;
111
- readonly snap_notify: Readonly<{
112
- readonly targetName: "snap_notify";
113
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
114
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
115
- methodHooks: NotifyMethodHooks;
116
- }, {
117
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
118
- targetName: "snap_notify";
119
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").NotifyParams>) => Promise<null>;
120
- allowedCaveats: readonly [string, ...string[]] | null;
121
- }>;
122
- readonly methodHooks: import("../utils.mjs").MethodHooksObject<NotifyMethodHooks>;
123
- }>;
124
- readonly snap_manageAccounts: Readonly<{
125
- readonly targetName: "snap_manageAccounts";
126
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
127
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
128
- methodHooks: ManageAccountsMethodHooks;
129
- }, {
130
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
131
- targetName: "snap_manageAccounts";
132
- methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").ManageAccountsParams>) => Promise<import("@metamask/utils").Json>;
133
- allowedCaveats: readonly [string, ...string[]] | null;
134
- }>;
135
- readonly methodHooks: {
136
- readonly getSnapKeyring: true;
137
- readonly getUnlockPromise: true;
138
- };
139
- }>;
140
- readonly snap_getLocale: Readonly<{
141
- readonly targetName: "snap_getLocale";
142
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
143
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
144
- methodHooks: GetLocaleMethodHooks;
145
- }, {
146
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
147
- targetName: "snap_getLocale";
148
- methodImplementation: (_args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/permission-controller").RestrictedMethodParameters>) => Promise<string>;
149
- allowedCaveats: readonly [string, ...string[]] | null;
150
- }>;
151
- readonly methodHooks: import("../utils.mjs").MethodHooksObject<GetLocaleMethodHooks>;
152
- }>;
153
- readonly snap_getPreferences: Readonly<{
154
- readonly targetName: "snap_getPreferences";
155
- readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
156
- allowedCaveats?: readonly [string, ...string[]] | null | undefined;
157
- methodHooks: GetPreferencesMethodHooks;
158
- }, {
159
- permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
160
- targetName: "snap_getPreferences";
161
- methodImplementation: (_args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/permission-controller").RestrictedMethodParameters>) => Promise<import("@metamask/snaps-sdk").GetPreferencesResult>;
162
- allowedCaveats: readonly [string, ...string[]] | null;
163
- }>;
164
- readonly methodHooks: import("../utils.mjs").MethodHooksObject<GetPreferencesMethodHooks>;
165
- }>;
17
+ export type RestrictedMethodActions = DialogMessengerActions | GetBip32EntropyMessengerActions | GetBip32PublicKeyMessengerActions | GetBip44EntropyMessengerActions | GetEntropyMessengerActions | InvokeSnapMessengerActions | ManageStateMessengerActions | NotifyMessengerActions;
18
+ export type RestrictedMethodMessenger = Messenger<string, RestrictedMethodActions>;
19
+ export type RestrictedMethodHooks = GetBip32EntropyMethodHooks & GetBip32PublicKeyMethodHooks & GetBip44EntropyMethodHooks & GetEntropyHooks & ManageStateMethodHooks & NotifyMethodHooks & ManageAccountsMethodHooks & GetLocaleMethodHooks & GetPreferencesMethodHooks;
20
+ type RestrictedMethodPermissionBuilder = {
21
+ targetName: string;
22
+ specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, any, RestrictedMethodSpecificationConstraint>;
23
+ actionNames?: readonly RestrictedMethodActions['type'][];
24
+ methodHooks?: MethodHooksObject<Record<string, unknown>>;
166
25
  };
26
+ export declare const restrictedMethodPermissionBuilders: Record<string, RestrictedMethodPermissionBuilder>;
167
27
  export * from "./caveats/index.mjs";
168
28
  export type { DialogApprovalTypes } from "./dialog.mjs";
169
29
  export { DIALOG_APPROVAL_TYPES } from "./dialog.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/restricted/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAElD,OAAO,KAAK,EAAE,0BAA0B,EAAE,8BAA0B;AAEpE,OAAO,KAAK,EAAE,4BAA4B,EAAE,gCAA4B;AAExE,OAAO,KAAK,EAAE,0BAA0B,EAAE,8BAA0B;AAEpE,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAqB;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAoB;AAExD,OAAO,KAAK,EAAE,yBAAyB,EAAE,6BAAyB;AAElE,O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AAqB,CAAC,UAAU,CAAC,EAAE,qBAAqB;IACzD,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,gBAAgB;IAC/C,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE,qBAAqB;CACjD,CAAC;AAEX,oCAA0B;AAE1B,OAAO,EAAE,qBAAqB,EAAE,qBAAiB","sourcesContent":["import type { DialogMethodHooks } from './dialog';\nimport { dialogBuilder } from './dialog';\nimport type { GetBip32EntropyMethodHooks } from './getBip32Entropy';\nimport { getBip32EntropyBuilder } from './getBip32Entropy';\nimport type { GetBip32PublicKeyMethodHooks } from './getBip32PublicKey';\nimport { getBip32PublicKeyBuilder } from './getBip32PublicKey';\nimport type { GetBip44EntropyMethodHooks } from './getBip44Entropy';\nimport { getBip44EntropyBuilder } from './getBip44Entropy';\nimport type { GetEntropyHooks } from './getEntropy';\nimport { getEntropyBuilder } from './getEntropy';\nimport type { GetLocaleMethodHooks } from './getLocale';\nimport { getLocaleBuilder } from './getLocale';\nimport type { GetPreferencesMethodHooks } from './getPreferences';\nimport { getPreferencesBuilder } from './getPreferences';\nimport type { InvokeSnapMethodHooks } from './invokeSnap';\nimport { invokeSnapBuilder } from './invokeSnap';\nimport type { ManageAccountsMethodHooks } from './manageAccounts';\nimport { manageAccountsBuilder } from './manageAccounts';\nimport type { ManageStateMethodHooks } from './manageState';\nimport { manageStateBuilder } from './manageState';\nimport type { NotifyMethodHooks } from './notify';\nimport { notifyBuilder } from './notify';\n\nexport { WALLET_SNAP_PERMISSION_KEY } from './invokeSnap';\nexport { getEncryptionEntropy } from './manageState';\n\nexport type RestrictedMethodHooks = DialogMethodHooks &\n GetBip32EntropyMethodHooks &\n GetBip32PublicKeyMethodHooks &\n GetBip44EntropyMethodHooks &\n GetEntropyHooks &\n InvokeSnapMethodHooks &\n ManageStateMethodHooks &\n NotifyMethodHooks &\n ManageAccountsMethodHooks &\n GetLocaleMethodHooks &\n GetPreferencesMethodHooks;\n\nexport const restrictedMethodPermissionBuilders = {\n [dialogBuilder.targetName]: dialogBuilder,\n [getBip32EntropyBuilder.targetName]: getBip32EntropyBuilder,\n [getBip32PublicKeyBuilder.targetName]: getBip32PublicKeyBuilder,\n [getBip44EntropyBuilder.targetName]: getBip44EntropyBuilder,\n [getEntropyBuilder.targetName]: getEntropyBuilder,\n [invokeSnapBuilder.targetName]: invokeSnapBuilder,\n [manageStateBuilder.targetName]: manageStateBuilder,\n [notifyBuilder.targetName]: notifyBuilder,\n [manageAccountsBuilder.targetName]: manageAccountsBuilder,\n [getLocaleBuilder.targetName]: getLocaleBuilder,\n [getPreferencesBuilder.targetName]: getPreferencesBuilder,\n} as const;\n\nexport * from './caveats';\nexport type { DialogApprovalTypes } from './dialog';\nexport { DIALOG_APPROVAL_TYPES } from './dialog';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/restricted/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,qBAAiB;AAKzC,OAAO,EAAE,sBAAsB,EAAE,8BAA0B;AAK3D,OAAO,EAAE,wBAAwB,EAAE,gCAA4B;AAK/D,OAAO,EAAE,sBAAsB,EAAE,8BAA0B;AAE3D,OAAO,EAAE,iBAAiB,EAAE,yBAAqB;AAEjD,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAE/C,OAAO,EAAE,qBAAqB,EAAE,6BAAyB;AAEzD,OAAO,EAAE,iBAAiB,EAAE,yBAAqB;AAEjD,OAAO,EAAE,qBAAqB,EAAE,6BAAyB;AAKzD,OAAO,EAAE,kBAAkB,EAAE,0BAAsB;AAEnD,OAAO,EAAE,aAAa,EAAE,qBAAiB;AAGzC,OAAO,EAAE,0BAA0B,EAAE,yBAAqB;AAC1D,OAAO,EAAE,oBAAoB,EAAE,0BAAsB;AAsCrD,MAAM,CAAC,MAAM,kCAAkC,GAG3C;IACF,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,aAAa;IACzC,CAAC,sBAAsB,CAAC,UAAU,CAAC,EAAE,sBAAsB;IAC3D,CAAC,wBAAwB,CAAC,UAAU,CAAC,EAAE,wBAAwB;IAC/D,CAAC,sBAAsB,CAAC,UAAU,CAAC,EAAE,sBAAsB;IAC3D,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,iBAAiB;IACjD,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,iBAAiB;IACjD,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,kBAAkB;IACnD,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,aAAa;IACzC,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE,qBAAqB;IACzD,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,gBAAgB;IAC/C,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE,qBAAqB;CACjD,CAAC;AAEX,oCAA0B;AAE1B,OAAO,EAAE,qBAAqB,EAAE,qBAAiB","sourcesContent":["import type { Messenger } from '@metamask/messenger';\nimport type {\n PermissionSpecificationBuilder,\n PermissionType,\n RestrictedMethodSpecificationConstraint,\n} from '@metamask/permission-controller';\n\nimport type { DialogMessengerActions } from './dialog';\nimport { dialogBuilder } from './dialog';\nimport type {\n GetBip32EntropyMessengerActions,\n GetBip32EntropyMethodHooks,\n} from './getBip32Entropy';\nimport { getBip32EntropyBuilder } from './getBip32Entropy';\nimport type {\n GetBip32PublicKeyMessengerActions,\n GetBip32PublicKeyMethodHooks,\n} from './getBip32PublicKey';\nimport { getBip32PublicKeyBuilder } from './getBip32PublicKey';\nimport type {\n GetBip44EntropyMessengerActions,\n GetBip44EntropyMethodHooks,\n} from './getBip44Entropy';\nimport { getBip44EntropyBuilder } from './getBip44Entropy';\nimport type { GetEntropyHooks, GetEntropyMessengerActions } from './getEntropy';\nimport { getEntropyBuilder } from './getEntropy';\nimport type { GetLocaleMethodHooks } from './getLocale';\nimport { getLocaleBuilder } from './getLocale';\nimport type { GetPreferencesMethodHooks } from './getPreferences';\nimport { getPreferencesBuilder } from './getPreferences';\nimport type { InvokeSnapMessengerActions } from './invokeSnap';\nimport { invokeSnapBuilder } from './invokeSnap';\nimport type { ManageAccountsMethodHooks } from './manageAccounts';\nimport { manageAccountsBuilder } from './manageAccounts';\nimport type {\n ManageStateMessengerActions,\n ManageStateMethodHooks,\n} from './manageState';\nimport { manageStateBuilder } from './manageState';\nimport type { NotifyMessengerActions, NotifyMethodHooks } from './notify';\nimport { notifyBuilder } from './notify';\nimport type { MethodHooksObject } from '../utils';\n\nexport { WALLET_SNAP_PERMISSION_KEY } from './invokeSnap';\nexport { getEncryptionEntropy } from './manageState';\n\nexport type RestrictedMethodActions =\n | DialogMessengerActions\n | GetBip32EntropyMessengerActions\n | GetBip32PublicKeyMessengerActions\n | GetBip44EntropyMessengerActions\n | GetEntropyMessengerActions\n | InvokeSnapMessengerActions\n | ManageStateMessengerActions\n | NotifyMessengerActions;\n\nexport type RestrictedMethodMessenger = Messenger<\n string,\n RestrictedMethodActions\n>;\n\nexport type RestrictedMethodHooks = GetBip32EntropyMethodHooks &\n GetBip32PublicKeyMethodHooks &\n GetBip44EntropyMethodHooks &\n GetEntropyHooks &\n ManageStateMethodHooks &\n NotifyMethodHooks &\n ManageAccountsMethodHooks &\n GetLocaleMethodHooks &\n GetPreferencesMethodHooks;\n\ntype RestrictedMethodPermissionBuilder = {\n targetName: string;\n specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n any,\n RestrictedMethodSpecificationConstraint\n >;\n actionNames?: readonly RestrictedMethodActions['type'][];\n methodHooks?: MethodHooksObject<Record<string, unknown>>;\n};\n\nexport const restrictedMethodPermissionBuilders: Record<\n string,\n RestrictedMethodPermissionBuilder\n> = {\n [dialogBuilder.targetName]: dialogBuilder,\n [getBip32EntropyBuilder.targetName]: getBip32EntropyBuilder,\n [getBip32PublicKeyBuilder.targetName]: getBip32PublicKeyBuilder,\n [getBip44EntropyBuilder.targetName]: getBip44EntropyBuilder,\n [getEntropyBuilder.targetName]: getEntropyBuilder,\n [invokeSnapBuilder.targetName]: invokeSnapBuilder,\n [manageStateBuilder.targetName]: manageStateBuilder,\n [notifyBuilder.targetName]: notifyBuilder,\n [manageAccountsBuilder.targetName]: manageAccountsBuilder,\n [getLocaleBuilder.targetName]: getLocaleBuilder,\n [getPreferencesBuilder.targetName]: getPreferencesBuilder,\n} as const;\n\nexport * from './caveats';\nexport type { DialogApprovalTypes } from './dialog';\nexport { DIALOG_APPROVAL_TYPES } from './dialog';\n"]}
@@ -35,15 +35,17 @@ exports.handleSnapInstall = handleSnapInstall;
35
35
  * and install it if it's not available yet.
36
36
  *
37
37
  * @param options - The specification builder options.
38
- * @param options.methodHooks - The RPC method hooks needed by the method implementation.
38
+ * @param options.messenger - The messenger.
39
39
  * @returns The specification for the `wallet_snap_*` permission.
40
40
  */
41
- const specificationBuilder = ({ methodHooks }) => {
41
+ const specificationBuilder = ({ messenger }) => {
42
42
  return {
43
43
  permissionType: permission_controller_1.PermissionType.RestrictedMethod,
44
44
  targetName: exports.WALLET_SNAP_PERMISSION_KEY,
45
45
  allowedCaveats: [snaps_utils_1.SnapCaveatType.SnapIds],
46
- methodImplementation: getInvokeSnapImplementation(methodHooks),
46
+ methodImplementation: getInvokeSnapImplementation({
47
+ messenger,
48
+ }),
47
49
  validator: ({ caveats }) => {
48
50
  if (caveats?.length !== 1 || caveats[0].type !== snaps_utils_1.SnapCaveatType.SnapIds) {
49
51
  throw rpc_errors_1.rpcErrors.invalidParams({
@@ -56,9 +58,6 @@ const specificationBuilder = ({ methodHooks }) => {
56
58
  },
57
59
  };
58
60
  };
59
- const methodHooks = {
60
- handleSnapRpcRequest: true,
61
- };
62
61
  /**
63
62
  * Calls the specified JSON-RPC API method of the specified Snap. The Snap
64
63
  * must be installed and the dapp must have permission to communicate with the
@@ -84,22 +83,22 @@ const methodHooks = {
84
83
  exports.invokeSnapBuilder = Object.freeze({
85
84
  targetName: exports.WALLET_SNAP_PERMISSION_KEY,
86
85
  specificationBuilder,
87
- methodHooks,
86
+ actionNames: ['SnapController:handleRequest'],
88
87
  });
89
88
  /**
90
89
  * Builds the method implementation for `wallet_snap_*`.
91
90
  *
92
- * @param hooks - The RPC method hooks.
93
- * @param hooks.handleSnapRpcRequest - A function that sends an RPC request to a snap's RPC handler or throws if that fails.
94
- * @returns The method implementation which returns the result of `handleSnapRpcRequest`.
91
+ * @param options - The options.
92
+ * @param options.messenger - The messenger.
93
+ * @returns The method implementation which returns the result of `SnapController:handleRequest`.
95
94
  * @throws If the params are invalid.
96
95
  */
97
- function getInvokeSnapImplementation({ handleSnapRpcRequest, }) {
96
+ function getInvokeSnapImplementation({ messenger, }) {
98
97
  return async function invokeSnap(options) {
99
98
  const { params = {}, context } = options;
100
99
  const { snapId, request } = params;
101
100
  const { origin } = context;
102
- return (await handleSnapRpcRequest({
101
+ return (await messenger.call('SnapController:handleRequest', {
103
102
  snapId,
104
103
  origin,
105
104
  request,
@@ -1 +1 @@
1
- {"version":3,"file":"invokeSnap.cjs","sourceRoot":"","sources":["../../src/restricted/invokeSnap.ts"],"names":[],"mappings":";;;AAOA,2EAAiE;AACjE,qDAAiD;AAQjD,uDAAoE;AAKvD,QAAA,0BAA0B,GAAG,aAAa,CAAC;AA6CxD;;;;;;;GAOG;AACI,MAAM,iBAAiB,GAGX,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,EAAE;IACtD,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,kCAA0B,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;SAC3E,KAA2B,CAAC;IAE/B,MAAM,cAAc,GAAG,SAAS,CAAC,IAAI,CACnC,kCAAkC,EAClC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAC5B,CAAC;IAEF,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAC5C,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE;QACtB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;YAC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tB,OAAO,KAAK,UAAU,UAAU,CAC9B,OAAkD;QAElD,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAEzC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAA0B,CAAC;QAEvD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAE3B,OAAO,CAAC,MAAM,oBAAoB,CAAC;YACjC,MAAM;YACN,MAAM;YACN,OAAO;YACP,OAAO,EAAE,yBAAW,CAAC,YAAY;SAClC,CAAC,CAAS,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAnBD,kEAmBC","sourcesContent":["import type {\n PermissionSpecificationBuilder,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n PermissionValidatorConstraint,\n PermissionSideEffect,\n} from '@metamask/permission-controller';\nimport { PermissionType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n InvokeSnapParams,\n InvokeSnapResult,\n RequestSnapsParams,\n RequestSnapsResult,\n} from '@metamask/snaps-sdk';\nimport type { SnapRpcHookArgs } from '@metamask/snaps-utils';\nimport { HandlerType, SnapCaveatType } from '@metamask/snaps-utils';\nimport type { Json, NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nexport const WALLET_SNAP_PERMISSION_KEY = 'wallet_snap';\n\n// Redeclare installSnaps action type to avoid circular dependencies\nexport type SnapControllerInstallSnapsAction = {\n type: `SnapController:installSnaps`;\n handler: (\n origin: string,\n requestedSnaps: RequestSnapsParams,\n ) => Promise<RequestSnapsResult>;\n};\n\nexport type SnapControllerGetPermittedSnapsAction = {\n type: `SnapController:getPermittedSnaps`;\n handler: (origin: string) => RequestSnapsResult;\n};\n\ntype AllowedActions =\n | SnapControllerInstallSnapsAction\n | SnapControllerGetPermittedSnapsAction;\n\nexport type InvokeSnapMethodHooks = {\n handleSnapRpcRequest: ({\n snapId,\n origin,\n handler,\n request,\n }: SnapRpcHookArgs & { snapId: string }) => Promise<unknown>;\n};\n\ntype InvokeSnapSpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: InvokeSnapMethodHooks;\n};\n\ntype InvokeSnapSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof WALLET_SNAP_PERMISSION_KEY;\n methodImplementation: ReturnType<typeof getInvokeSnapImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n sideEffect: {\n onPermitted: PermissionSideEffect<AllowedActions, never>['onPermitted'];\n };\n}>;\n\n/**\n * The side-effect method to handle the snap install.\n *\n * @param params - The side-effect params.\n * @param params.requestData - The request data associated to the requested permission.\n * @param params.messenger - The messenger to call an action.\n * @returns The result of the Snap installation.\n */\nexport const handleSnapInstall: PermissionSideEffect<\n AllowedActions,\n never\n>['onPermitted'] = async ({ requestData, messenger }) => {\n const snaps = requestData.permissions[WALLET_SNAP_PERMISSION_KEY].caveats?.[0]\n .value as RequestSnapsParams;\n\n const permittedSnaps = messenger.call(\n `SnapController:getPermittedSnaps`,\n requestData.metadata.origin,\n );\n\n const dedupedSnaps = Object.keys(snaps).reduce<RequestSnapsParams>(\n (filteredSnaps, snap) => {\n if (!permittedSnaps[snap]) {\n filteredSnaps[snap] = snaps[snap];\n }\n return filteredSnaps;\n },\n {},\n );\n\n return messenger.call(\n `SnapController:installSnaps`,\n requestData.metadata.origin,\n dedupedSnaps,\n );\n};\n/**\n * The specification builder for the `wallet_snap_*` permission.\n *\n * `wallet_snap_*` attempts to invoke an RPC method of the specified Snap.\n *\n * Requesting its corresponding permission will attempt to connect to the Snap,\n * and install it if it's not available yet.\n *\n * @param options - The specification builder options.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `wallet_snap_*` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n InvokeSnapSpecificationBuilderOptions,\n InvokeSnapSpecification\n> = ({ methodHooks }: InvokeSnapSpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: WALLET_SNAP_PERMISSION_KEY,\n allowedCaveats: [SnapCaveatType.SnapIds],\n methodImplementation: getInvokeSnapImplementation(methodHooks),\n validator: ({ caveats }) => {\n if (caveats?.length !== 1 || caveats[0].type !== SnapCaveatType.SnapIds) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.SnapIds}\" caveat.`,\n });\n }\n },\n sideEffect: {\n onPermitted: handleSnapInstall,\n },\n };\n};\n\nconst methodHooks: MethodHooksObject<InvokeSnapMethodHooks> = {\n handleSnapRpcRequest: true,\n};\n\n/**\n * Calls the specified JSON-RPC API method of the specified Snap. The Snap\n * must be installed and the dapp must have permission to communicate with the\n * Snap, or the request is rejected. The dapp can install the Snap and request\n * permission to communicate with it using\n * [`wallet_requestSnaps`](http://docs.metamask.io/snaps/reference/snaps-api/wallet_requestsnaps).\n *\n * @example\n * ```ts\n * const result = await ethereum.request({\n * method: 'wallet_snap',\n * params: {\n * snapId: 'npm:my-snap',\n * request: {\n * method: 'hello',\n * params: { name: 'world' },\n * },\n * },\n * });\n * console.log(result); // \"Hello, world!\"\n * ```\n */\nexport const invokeSnapBuilder = Object.freeze({\n targetName: WALLET_SNAP_PERMISSION_KEY,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `wallet_snap_*`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.handleSnapRpcRequest - A function that sends an RPC request to a snap's RPC handler or throws if that fails.\n * @returns The method implementation which returns the result of `handleSnapRpcRequest`.\n * @throws If the params are invalid.\n */\nexport function getInvokeSnapImplementation({\n handleSnapRpcRequest,\n}: InvokeSnapMethodHooks) {\n return async function invokeSnap(\n options: RestrictedMethodOptions<InvokeSnapParams>,\n ): Promise<InvokeSnapResult> {\n const { params = {}, context } = options;\n\n const { snapId, request } = params as InvokeSnapParams;\n\n const { origin } = context;\n\n return (await handleSnapRpcRequest({\n snapId,\n origin,\n request,\n handler: HandlerType.OnRpcRequest,\n })) as Json;\n };\n}\n"]}
1
+ {"version":3,"file":"invokeSnap.cjs","sourceRoot":"","sources":["../../src/restricted/invokeSnap.ts"],"names":[],"mappings":";;;AAQA,2EAAiE;AACjE,qDAAiD;AAOjD,uDAAoE;AAKvD,QAAA,0BAA0B,GAAG,aAAa,CAAC;AAsCxD;;;;;;;GAOG;AACI,MAAM,iBAAiB,GAGX,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,EAAE;IACtD,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,kCAA0B,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;SAC3E,KAA2B,CAAC;IAE/B,MAAM,cAAc,GAAG,SAAS,CAAC,IAAI,CACnC,kCAAkC,EAClC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAC5B,CAAC;IAEF,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAC5C,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE;QACtB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,aAAa,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC,EACD,EAAE,CACH,CAAC;IAEF,OAAO,SAAS,CAAC,IAAI,CACnB,6BAA6B,EAC7B,WAAW,CAAC,QAAQ,CAAC,MAAM,EAC3B,YAAY,CACb,CAAC;AACJ,CAAC,CAAC;AA3BW,QAAA,iBAAiB,qBA2B5B;AACF;;;;;;;;;;;GAWG;AACH,MAAM,oBAAoB,GAItB,CAAC,EAAE,SAAS,EAAyC,EAAE,EAAE;IAC3D,OAAO;QACL,cAAc,EAAE,sCAAc,CAAC,gBAAgB;QAC/C,UAAU,EAAE,kCAA0B;QACtC,cAAc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ictedMethodOptions,\n ValidPermissionSpecification,\n PermissionValidatorConstraint,\n PermissionSideEffect,\n} from '@metamask/permission-controller';\nimport { PermissionType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n InvokeSnapParams,\n InvokeSnapResult,\n RequestSnapsParams,\n RequestSnapsResult,\n} from '@metamask/snaps-sdk';\nimport { HandlerType, SnapCaveatType } from '@metamask/snaps-utils';\nimport type { Json, NonEmptyArray } from '@metamask/utils';\n\nimport type { SnapControllerHandleRequestAction } from '../types';\n\nexport const WALLET_SNAP_PERMISSION_KEY = 'wallet_snap';\n\n// Redeclare installSnaps action type to avoid circular dependencies\nexport type SnapControllerInstallSnapsAction = {\n type: `SnapController:installSnaps`;\n handler: (\n origin: string,\n requestedSnaps: RequestSnapsParams,\n ) => Promise<RequestSnapsResult>;\n};\n\nexport type SnapControllerGetPermittedSnapsAction = {\n type: `SnapController:getPermittedSnaps`;\n handler: (origin: string) => RequestSnapsResult;\n};\n\ntype AllowedActions =\n | SnapControllerInstallSnapsAction\n | SnapControllerGetPermittedSnapsAction;\n\nexport type InvokeSnapMessengerActions = SnapControllerHandleRequestAction;\n\ntype InvokeSnapSpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n messenger: Messenger<string, InvokeSnapMessengerActions>;\n};\n\ntype InvokeSnapSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof WALLET_SNAP_PERMISSION_KEY;\n methodImplementation: ReturnType<typeof getInvokeSnapImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n sideEffect: {\n onPermitted: PermissionSideEffect<AllowedActions, never>['onPermitted'];\n };\n}>;\n\n/**\n * The side-effect method to handle the snap install.\n *\n * @param params - The side-effect params.\n * @param params.requestData - The request data associated to the requested permission.\n * @param params.messenger - The messenger to call an action.\n * @returns The result of the Snap installation.\n */\nexport const handleSnapInstall: PermissionSideEffect<\n AllowedActions,\n never\n>['onPermitted'] = async ({ requestData, messenger }) => {\n const snaps = requestData.permissions[WALLET_SNAP_PERMISSION_KEY].caveats?.[0]\n .value as RequestSnapsParams;\n\n const permittedSnaps = messenger.call(\n `SnapController:getPermittedSnaps`,\n requestData.metadata.origin,\n );\n\n const dedupedSnaps = Object.keys(snaps).reduce<RequestSnapsParams>(\n (filteredSnaps, snap) => {\n if (!permittedSnaps[snap]) {\n filteredSnaps[snap] = snaps[snap];\n }\n return filteredSnaps;\n },\n {},\n );\n\n return messenger.call(\n `SnapController:installSnaps`,\n requestData.metadata.origin,\n dedupedSnaps,\n );\n};\n/**\n * The specification builder for the `wallet_snap_*` permission.\n *\n * `wallet_snap_*` attempts to invoke an RPC method of the specified Snap.\n *\n * Requesting its corresponding permission will attempt to connect to the Snap,\n * and install it if it's not available yet.\n *\n * @param options - The specification builder options.\n * @param options.messenger - The messenger.\n * @returns The specification for the `wallet_snap_*` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n InvokeSnapSpecificationBuilderOptions,\n InvokeSnapSpecification\n> = ({ messenger }: InvokeSnapSpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: WALLET_SNAP_PERMISSION_KEY,\n allowedCaveats: [SnapCaveatType.SnapIds],\n methodImplementation: getInvokeSnapImplementation({\n messenger,\n }),\n validator: ({ caveats }) => {\n if (caveats?.length !== 1 || caveats[0].type !== SnapCaveatType.SnapIds) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.SnapIds}\" caveat.`,\n });\n }\n },\n sideEffect: {\n onPermitted: handleSnapInstall,\n },\n };\n};\n\n/**\n * Calls the specified JSON-RPC API method of the specified Snap. The Snap\n * must be installed and the dapp must have permission to communicate with the\n * Snap, or the request is rejected. The dapp can install the Snap and request\n * permission to communicate with it using\n * [`wallet_requestSnaps`](http://docs.metamask.io/snaps/reference/snaps-api/wallet_requestsnaps).\n *\n * @example\n * ```ts\n * const result = await ethereum.request({\n * method: 'wallet_snap',\n * params: {\n * snapId: 'npm:my-snap',\n * request: {\n * method: 'hello',\n * params: { name: 'world' },\n * },\n * },\n * });\n * console.log(result); // \"Hello, world!\"\n * ```\n */\nexport const invokeSnapBuilder = Object.freeze({\n targetName: WALLET_SNAP_PERMISSION_KEY,\n specificationBuilder,\n actionNames: ['SnapController:handleRequest'],\n} as const);\n\n/**\n * Builds the method implementation for `wallet_snap_*`.\n *\n * @param options - The options.\n * @param options.messenger - The messenger.\n * @returns The method implementation which returns the result of `SnapController:handleRequest`.\n * @throws If the params are invalid.\n */\nexport function getInvokeSnapImplementation({\n messenger,\n}: InvokeSnapSpecificationBuilderOptions) {\n return async function invokeSnap(\n options: RestrictedMethodOptions<InvokeSnapParams>,\n ): Promise<InvokeSnapResult> {\n const { params = {}, context } = options;\n\n const { snapId, request } = params as InvokeSnapParams;\n\n const { origin } = context;\n\n return (await messenger.call('SnapController:handleRequest', {\n snapId,\n origin,\n request,\n handler: HandlerType.OnRpcRequest,\n })) as Json;\n };\n}\n"]}
@@ -1,9 +1,9 @@
1
+ import type { Messenger } from "@metamask/messenger";
1
2
  import type { PermissionSpecificationBuilder, RestrictedMethodOptions, PermissionValidatorConstraint, PermissionSideEffect } from "@metamask/permission-controller";
2
3
  import { PermissionType } from "@metamask/permission-controller";
3
4
  import type { InvokeSnapParams, InvokeSnapResult, RequestSnapsParams, RequestSnapsResult } from "@metamask/snaps-sdk";
4
- import type { SnapRpcHookArgs } from "@metamask/snaps-utils";
5
5
  import type { NonEmptyArray } from "@metamask/utils";
6
- import type { MethodHooksObject } from "../utils.cjs";
6
+ import type { SnapControllerHandleRequestAction } from "../types.cjs";
7
7
  export declare const WALLET_SNAP_PERMISSION_KEY = "wallet_snap";
8
8
  export type SnapControllerInstallSnapsAction = {
9
9
  type: `SnapController:installSnaps`;
@@ -14,14 +14,10 @@ export type SnapControllerGetPermittedSnapsAction = {
14
14
  handler: (origin: string) => RequestSnapsResult;
15
15
  };
16
16
  type AllowedActions = SnapControllerInstallSnapsAction | SnapControllerGetPermittedSnapsAction;
17
- export type InvokeSnapMethodHooks = {
18
- handleSnapRpcRequest: ({ snapId, origin, handler, request, }: SnapRpcHookArgs & {
19
- snapId: string;
20
- }) => Promise<unknown>;
21
- };
17
+ export type InvokeSnapMessengerActions = SnapControllerHandleRequestAction;
22
18
  type InvokeSnapSpecificationBuilderOptions = {
23
19
  allowedCaveats?: Readonly<NonEmptyArray<string>> | null;
24
- methodHooks: InvokeSnapMethodHooks;
20
+ messenger: Messenger<string, InvokeSnapMessengerActions>;
25
21
  };
26
22
  /**
27
23
  * The side-effect method to handle the snap install.
@@ -66,16 +62,16 @@ export declare const invokeSnapBuilder: Readonly<{
66
62
  onPermitted: PermissionSideEffect<AllowedActions, never>['onPermitted'];
67
63
  };
68
64
  }>;
69
- readonly methodHooks: MethodHooksObject<InvokeSnapMethodHooks>;
65
+ readonly actionNames: readonly ["SnapController:handleRequest"];
70
66
  }>;
71
67
  /**
72
68
  * Builds the method implementation for `wallet_snap_*`.
73
69
  *
74
- * @param hooks - The RPC method hooks.
75
- * @param hooks.handleSnapRpcRequest - A function that sends an RPC request to a snap's RPC handler or throws if that fails.
76
- * @returns The method implementation which returns the result of `handleSnapRpcRequest`.
70
+ * @param options - The options.
71
+ * @param options.messenger - The messenger.
72
+ * @returns The method implementation which returns the result of `SnapController:handleRequest`.
77
73
  * @throws If the params are invalid.
78
74
  */
79
- export declare function getInvokeSnapImplementation({ handleSnapRpcRequest, }: InvokeSnapMethodHooks): (options: RestrictedMethodOptions<InvokeSnapParams>) => Promise<InvokeSnapResult>;
75
+ export declare function getInvokeSnapImplementation({ messenger, }: InvokeSnapSpecificationBuilderOptions): (options: RestrictedMethodOptions<InvokeSnapParams>) => Promise<InvokeSnapResult>;
80
76
  export {};
81
77
  //# sourceMappingURL=invokeSnap.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"invokeSnap.d.cts","sourceRo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