@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,8 +1,9 @@
1
1
  import type { JsonRpcEngineEndCallback } from "@metamask/json-rpc-engine";
2
+ import type { Messenger } from "@metamask/messenger";
2
3
  import type { GetFileParams, GetFileResult } from "@metamask/snaps-sdk";
3
4
  import type { InferMatching } from "@metamask/snaps-utils";
4
- import type { PendingJsonRpcResponse, JsonRpcRequest } from "@metamask/utils";
5
- import type { MethodHooksObject } from "../utils.mjs";
5
+ import type { PendingJsonRpcResponse } from "@metamask/utils";
6
+ import type { JsonRpcRequestWithOrigin, SnapControllerGetSnapFileAction } from "../types.mjs";
6
7
  export declare const GetFileArgsStruct: import("@metamask/superstruct").Struct<{
7
8
  path: string;
8
9
  encoding?: "base64" | "hex" | "utf8" | undefined;
@@ -11,6 +12,7 @@ export declare const GetFileArgsStruct: import("@metamask/superstruct").Struct<{
11
12
  encoding: import("@metamask/superstruct").Struct<"base64" | "hex" | "utf8" | undefined, null>;
12
13
  }>;
13
14
  export type InferredGetFileParams = InferMatching<typeof GetFileArgsStruct, GetFileParams>;
15
+ export type GetFileMethodActions = SnapControllerGetSnapFileAction;
14
16
  /**
15
17
  * Gets a static file's content in UTF-8, Base64, or hexadecimal.
16
18
  *
@@ -38,12 +40,8 @@ export type InferredGetFileParams = InferMatching<typeof GetFileArgsStruct, GetF
38
40
  * ```
39
41
  */
40
42
  export declare const getFileHandler: {
41
- methodNames: ["snap_getFile"];
42
43
  implementation: typeof implementation;
43
- hookNames: MethodHooksObject<GetFileHooks>;
44
- };
45
- export type GetFileHooks = {
46
- getSnapFile: (path: InferredGetFileParams['path'], encoding: InferredGetFileParams['encoding']) => Promise<string>;
44
+ actionNames: "SnapController:getSnapFile"[];
47
45
  };
48
46
  /**
49
47
  * The `snap_getFile` method implementation.
@@ -53,10 +51,10 @@ export type GetFileHooks = {
53
51
  * @param _next - The `json-rpc-engine` "next" callback. Not used by this
54
52
  * function.
55
53
  * @param end - The `json-rpc-engine` "end" callback.
56
- * @param hooks - The RPC method hooks.
57
- * @param hooks.getSnapFile - The function to load a static snap file.
54
+ * @param _hooks - The RPC method hooks. Not used by this function.
55
+ * @param messenger - The messenger used to call controller actions.
58
56
  * @returns Nothing.
59
57
  */
60
- declare function implementation(req: JsonRpcRequest<InferredGetFileParams>, res: PendingJsonRpcResponse<GetFileResult>, _next: unknown, end: JsonRpcEngineEndCallback, { getSnapFile }: GetFileHooks): Promise<void>;
58
+ declare function implementation(req: JsonRpcRequestWithOrigin<InferredGetFileParams>, res: PendingJsonRpcResponse<GetFileResult>, _next: unknown, end: JsonRpcEngineEndCallback, _hooks: never, messenger: Messenger<string, GetFileMethodActions>): Promise<void>;
61
59
  export {};
62
60
  //# sourceMappingURL=getFile.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getFile.d.mts","sourceRoot":"","sources":["../../src/permitted/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAkC;AAG1E,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,4BAA4B;AAExE,OAAO,KAAK,EAAE,aAAa,EAAE,8BAA8B;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,wBAAwB;AAG9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAElD,eAAO,MAAM,iBAAiB;;;;;;EAS5B,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,aAAa,CAC/C,OAAO,iBAAiB,EACxB,aAAa,CACd,CAAC;AAQF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,cAAc;;;;CAIoD,CAAC;AAEhF,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,CACX,IAAI,EAAE,qBAAqB,CAAC,MAAM,CAAC,EACnC,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC,KACxC,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,iBAAe,cAAc,CAC3B,GAAG,EAAE,cAAc,CAAC,qBAAqB,CAAC,EAC1C,GAAG,EAAE,sBAAsB,CAAC,aAAa,CAAC,EAC1C,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,wBAAwB,EAC7B,EAAE,WAAW,EAAE,EAAE,YAAY,GAC5B,OAAO,CAAC,IAAI,CAAC,CAoBf"}
1
+ {"version":3,"file":"getFile.d.mts","sourceRoot":"","sources":["../../src/permitted/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EAEzB,kCAAkC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,4BAA4B;AAExE,OAAO,KAAK,EAAE,aAAa,EAAE,8BAA8B;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB;AAG9D,OAAO,KAAK,EACV,wBAAwB,EACxB,+BAA+B,EAChC,qBAAiB;AAElB,eAAO,MAAM,iBAAiB;;;;;;EAS5B,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,aAAa,CAC/C,OAAO,iBAAiB,EACxB,aAAa,CACd,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,cAAc;;;CAS1B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,iBAAe,cAAc,CAC3B,GAAG,EAAE,wBAAwB,CAAC,qBAAqB,CAAC,EACpD,GAAG,EAAE,sBAAsB,CAAC,aAAa,CAAC,EAC1C,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,wBAAwB,EAC7B,MAAM,EAAE,KAAK,EACb,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,oBAAoB,CAAC,GACjD,OAAO,CAAC,IAAI,CAAC,CAuBf"}
@@ -10,10 +10,6 @@ export const GetFileArgsStruct = object({
10
10
  enumValue(AuxiliaryFileEncoding.Utf8),
11
11
  ])),
12
12
  });
13
- const methodName = 'snap_getFile';
14
- const hookNames = {
15
- getSnapFile: true,
16
- };
17
13
  /**
18
14
  * Gets a static file's content in UTF-8, Base64, or hexadecimal.
19
15
  *
@@ -41,9 +37,8 @@ const hookNames = {
41
37
  * ```
42
38
  */
43
39
  export const getFileHandler = {
44
- methodNames: [methodName],
45
40
  implementation,
46
- hookNames,
41
+ actionNames: ['SnapController:getSnapFile'],
47
42
  };
48
43
  /**
49
44
  * The `snap_getFile` method implementation.
@@ -53,15 +48,16 @@ export const getFileHandler = {
53
48
  * @param _next - The `json-rpc-engine` "next" callback. Not used by this
54
49
  * function.
55
50
  * @param end - The `json-rpc-engine` "end" callback.
56
- * @param hooks - The RPC method hooks.
57
- * @param hooks.getSnapFile - The function to load a static snap file.
51
+ * @param _hooks - The RPC method hooks. Not used by this function.
52
+ * @param messenger - The messenger used to call controller actions.
58
53
  * @returns Nothing.
59
54
  */
60
- async function implementation(req, res, _next, end, { getSnapFile }) {
61
- const { params } = req;
55
+ async function implementation(req, res, _next, end, _hooks, messenger) {
56
+ const { params, origin } = req;
62
57
  assertStruct(params, GetFileArgsStruct, 'Invalid "snap_getFile" parameters', rpcErrors.invalidParams);
63
58
  try {
64
- res.result = await getSnapFile(params.path, params.encoding ?? AuxiliaryFileEncoding.Base64);
59
+ res.result = await messenger.call('SnapController:getSnapFile', origin, params.path, params.encoding ??
60
+ AuxiliaryFileEncoding.Base64);
65
61
  }
66
62
  catch (error) {
67
63
  return end(error);
@@ -1 +1 @@
1
- {"version":3,"file":"getFile.mjs","sourceRoot":"","sources":["../../src/permitted/getFile.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAEjD,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,4BAA4B;AAEvE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B;AAExE,OAAO,EAAE,YAAY,EAAE,wBAAwB;AAI/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;IACtC,IAAI,EAAE,MAAM,EAAE;IACd,QAAQ,EAAE,QAAQ,CAChB,KAAK,CAAC;QACJ,SAAS,CAAC,qBAAqB,CAAC,MAAM,CAAC;QACvC,SAAS,CAAC,qBAAqB,CAAC,GAAG,CAAC;QACpC,SAAS,CAAC,qBAAqB,CAAC,IAAI,CAAC;KACtC,CAAC,CACH;CACF,CAAC,CAAC;AAOH,MAAM,UAAU,GAAG,cAAc,CAAC;AAElC,MAAM,SAAS,GAAoC;IACjD,WAAW,EAAE,IAAI;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,WAAW,EAAE,CAAC,UAAU,CAAU;IAClC,cAAc;IACd,SAAS;CACoE,CAAC;AAShF;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,cAAc,CAC3B,GAA0C,EAC1C,GAA0C,EAC1C,KAAc,EACd,GAA6B,EAC7B,EAAE,WAAW,EAAgB;IAE7B,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAEvB,YAAY,CACV,MAAM,EACN,iBAAiB,EACjB,mCAAmC,EACnC,SAAS,CAAC,aAAa,CACxB,CAAC;IAEF,IAAI,CAAC;QACH,GAAG,CAAC,MAAM,GAAG,MAAM,WAAW,CAC5B,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,QAAQ,IAAI,qBAAqB,CAAC,MAAM,CAChD,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC;AACf,CAAC","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { GetFileParams, GetFileResult } from '@metamask/snaps-sdk';\nimport { AuxiliaryFileEncoding, enumValue } from '@metamask/snaps-sdk';\nimport type { InferMatching } from '@metamask/snaps-utils';\nimport { object, optional, string, union } from '@metamask/superstruct';\nimport type { PendingJsonRpcResponse, JsonRpcRequest } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nexport const GetFileArgsStruct = object({\n path: string(),\n encoding: optional(\n union([\n enumValue(AuxiliaryFileEncoding.Base64),\n enumValue(AuxiliaryFileEncoding.Hex),\n enumValue(AuxiliaryFileEncoding.Utf8),\n ]),\n ),\n});\n\nexport type InferredGetFileParams = InferMatching<\n typeof GetFileArgsStruct,\n GetFileParams\n>;\n\nconst methodName = 'snap_getFile';\n\nconst hookNames: MethodHooksObject<GetFileHooks> = {\n getSnapFile: true,\n};\n\n/**\n * Gets a static file's content in UTF-8, Base64, or hexadecimal.\n *\n * The file must be specified in [the Snap's manifest file](https://docs.metamask.io/snaps/features/static-files/).\n *\n * @example\n * ```json name=\"Manifest\"\n * {\n * \"source\": {\n * \"files\": [\"./files/my-file.bin\"]\n * }\n * }\n * ```\n * ```ts name=\"Usage\"\n * const contents = await snap.request({\n * method: 'snap_getFile',\n * params: {\n * path: './files/myfile.bin',\n * encoding: 'hex',\n * },\n * })\n *\n * // '0x...'\n * console.log(contents)\n * ```\n */\nexport const getFileHandler = {\n methodNames: [methodName] as const,\n implementation,\n hookNames,\n} satisfies PermittedHandlerExport<GetFileHooks, InferredGetFileParams, string>;\n\nexport type GetFileHooks = {\n getSnapFile: (\n path: InferredGetFileParams['path'],\n encoding: InferredGetFileParams['encoding'],\n ) => Promise<string>;\n};\n\n/**\n * The `snap_getFile` method implementation.\n *\n * @param req - The JSON-RPC request object.\n * @param res - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.getSnapFile - The function to load a static snap file.\n * @returns Nothing.\n */\nasync function implementation(\n req: JsonRpcRequest<InferredGetFileParams>,\n res: PendingJsonRpcResponse<GetFileResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { getSnapFile }: GetFileHooks,\n): Promise<void> {\n const { params } = req;\n\n assertStruct(\n params,\n GetFileArgsStruct,\n 'Invalid \"snap_getFile\" parameters',\n rpcErrors.invalidParams,\n );\n\n try {\n res.result = await getSnapFile(\n params.path,\n params.encoding ?? AuxiliaryFileEncoding.Base64,\n );\n } catch (error) {\n return end(error);\n }\n\n return end();\n}\n"]}
1
+ {"version":3,"file":"getFile.mjs","sourceRoot":"","sources":["../../src/permitted/getFile.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAEjD,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,4BAA4B;AAEvE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B;AAExE,OAAO,EAAE,YAAY,EAAE,wBAAwB;AAO/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;IACtC,IAAI,EAAE,MAAM,EAAE;IACd,QAAQ,EAAE,QAAQ,CAChB,KAAK,CAAC;QACJ,SAAS,CAAC,qBAAqB,CAAC,MAAM,CAAC;QACvC,SAAS,CAAC,qBAAqB,CAAC,GAAG,CAAC;QACpC,SAAS,CAAC,qBAAqB,CAAC,IAAI,CAAC;KACtC,CAAC,CACH;CACF,CAAC,CAAC;AASH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,cAAc;IACd,WAAW,EAAE,CAAC,4BAA4B,CAAC;CAO5C,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,cAAc,CAC3B,GAAoD,EACpD,GAA0C,EAC1C,KAAc,EACd,GAA6B,EAC7B,MAAa,EACb,SAAkD;IAElD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAE/B,YAAY,CACV,MAAM,EACN,iBAAiB,EACjB,mCAAmC,EACnC,SAAS,CAAC,aAAa,CACxB,CAAC;IAEF,IAAI,CAAC;QACH,GAAG,CAAC,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAC/B,4BAA4B,EAC5B,MAAM,EACN,MAAM,CAAC,IAAI,EACV,MAAM,CAAC,QAAkC;YACxC,qBAAqB,CAAC,MAAM,CAC/B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC;AACf,CAAC","sourcesContent":["import type {\n JsonRpcEngineEndCallback,\n MethodHandler,\n} from '@metamask/json-rpc-engine';\nimport type { Messenger } from '@metamask/messenger';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { GetFileParams, GetFileResult } from '@metamask/snaps-sdk';\nimport { AuxiliaryFileEncoding, enumValue } from '@metamask/snaps-sdk';\nimport type { InferMatching } from '@metamask/snaps-utils';\nimport { object, optional, string, union } from '@metamask/superstruct';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\n\nimport type {\n JsonRpcRequestWithOrigin,\n SnapControllerGetSnapFileAction,\n} from '../types';\n\nexport const GetFileArgsStruct = object({\n path: string(),\n encoding: optional(\n union([\n enumValue(AuxiliaryFileEncoding.Base64),\n enumValue(AuxiliaryFileEncoding.Hex),\n enumValue(AuxiliaryFileEncoding.Utf8),\n ]),\n ),\n});\n\nexport type InferredGetFileParams = InferMatching<\n typeof GetFileArgsStruct,\n GetFileParams\n>;\n\nexport type GetFileMethodActions = SnapControllerGetSnapFileAction;\n\n/**\n * Gets a static file's content in UTF-8, Base64, or hexadecimal.\n *\n * The file must be specified in [the Snap's manifest file](https://docs.metamask.io/snaps/features/static-files/).\n *\n * @example\n * ```json name=\"Manifest\"\n * {\n * \"source\": {\n * \"files\": [\"./files/my-file.bin\"]\n * }\n * }\n * ```\n * ```ts name=\"Usage\"\n * const contents = await snap.request({\n * method: 'snap_getFile',\n * params: {\n * path: './files/myfile.bin',\n * encoding: 'hex',\n * },\n * })\n *\n * // '0x...'\n * console.log(contents)\n * ```\n */\nexport const getFileHandler = {\n implementation,\n actionNames: ['SnapController:getSnapFile'],\n} satisfies MethodHandler<\n never,\n GetFileMethodActions,\n InferredGetFileParams,\n GetFileResult,\n { origin: string }\n>;\n\n/**\n * The `snap_getFile` method implementation.\n *\n * @param req - The JSON-RPC request object.\n * @param res - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param _hooks - The RPC method hooks. Not used by this function.\n * @param messenger - The messenger used to call controller actions.\n * @returns Nothing.\n */\nasync function implementation(\n req: JsonRpcRequestWithOrigin<InferredGetFileParams>,\n res: PendingJsonRpcResponse<GetFileResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n _hooks: never,\n messenger: Messenger<string, GetFileMethodActions>,\n): Promise<void> {\n const { params, origin } = req;\n\n assertStruct(\n params,\n GetFileArgsStruct,\n 'Invalid \"snap_getFile\" parameters',\n rpcErrors.invalidParams,\n );\n\n try {\n res.result = await messenger.call(\n 'SnapController:getSnapFile',\n origin,\n params.path,\n (params.encoding as AuxiliaryFileEncoding) ??\n AuxiliaryFileEncoding.Base64,\n );\n } catch (error) {\n return end(error);\n }\n\n return end();\n}\n"]}
@@ -4,11 +4,6 @@ exports.getInterfaceContextHandler = void 0;
4
4
  const rpc_errors_1 = require("@metamask/rpc-errors");
5
5
  const superstruct_1 = require("@metamask/superstruct");
6
6
  const utils_1 = require("../utils.cjs");
7
- const methodName = 'snap_getInterfaceContext';
8
- const hookNames = {
9
- hasPermission: true,
10
- getInterfaceContext: true,
11
- };
12
7
  /**
13
8
  * Get the context of an [interface](https://docs.metamask.io/snaps/features/custom-ui/interactive-ui/)
14
9
  * created by [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).
@@ -46,9 +41,11 @@ const hookNames = {
46
41
  * ```
47
42
  */
48
43
  exports.getInterfaceContextHandler = {
49
- methodNames: [methodName],
50
44
  implementation: getInterfaceContextImplementation,
51
- hookNames,
45
+ actionNames: [
46
+ 'PermissionController:hasPermission',
47
+ 'SnapInterfaceController:getInterface',
48
+ ],
52
49
  };
53
50
  const GetInterfaceContextParametersStruct = (0, superstruct_1.object)({
54
51
  id: (0, superstruct_1.string)(),
@@ -61,23 +58,23 @@ const GetInterfaceContextParametersStruct = (0, superstruct_1.object)({
61
58
  * @param _next - The `json-rpc-engine` "next" callback. Not used by this
62
59
  * function.
63
60
  * @param end - The `json-rpc-engine` "end" callback.
64
- * @param hooks - The RPC method hooks.
65
- * @param hooks.hasPermission - The function to check if the Snap has a given
66
- * permission.
67
- * @param hooks.getInterfaceContext - The function to get the interface context.
61
+ * @param _hooks - The RPC method hooks. Not used by this function.
62
+ * @param messenger - The messenger used to call controller actions.
68
63
  * @returns Nothing.
69
64
  */
70
- function getInterfaceContextImplementation(req, res, _next, end, { hasPermission, getInterfaceContext }) {
71
- if (!utils_1.UI_PERMISSIONS.some(hasPermission)) {
65
+ function getInterfaceContextImplementation(req, res, _next, end, _hooks, messenger) {
66
+ const { params, origin } = req;
67
+ const isPermitted = utils_1.UI_PERMISSIONS.some((permission) => messenger.call('PermissionController:hasPermission', origin, permission));
68
+ if (!isPermitted) {
72
69
  return end(rpc_errors_1.providerErrors.unauthorized({
73
70
  message: `This method can only be used if the Snap has one of the following permissions: ${utils_1.UI_PERMISSIONS.join(', ')}.`,
74
71
  }));
75
72
  }
76
- const { params } = req;
77
73
  try {
78
74
  const validatedParams = getValidatedParams(params);
79
75
  const { id } = validatedParams;
80
- res.result = getInterfaceContext(id);
76
+ const { context } = messenger.call('SnapInterfaceController:getInterface', origin, id);
77
+ res.result = context;
81
78
  }
82
79
  catch (error) {
83
80
  return end(error);
@@ -1 +1 @@
1
- {"version":3,"file":"getInterfaceContext.cjs","sourceRoot":"","sources":["../../src/permitted/getInterfaceContext.ts"],"names":[],"mappings":";;;AAEA,qDAAiE;AAQjE,uDAA4E;AAI5E,wCAA0C;AAE1C,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C,MAAM,SAAS,GAAsD;IACnE,aAAa,EAAE,IAAI;IACnB,mBAAmB,EAAE,IAAI;CAC1B,CAAC;AAgBF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACU,QAAA,0BAA0B,GAAG;IACxC,WAAW,EAAE,CAAC,UAAU,CAAU;IAClC,cAAc,EAAE,iCAAiC;IACjD,SAAS;CAKV,CAAC;AAEF,MAAM,mCAAmC,GAAG,IAAA,oBAAM,EAAC;IACjD,EAAE,EAAE,IAAA,oBAAM,GAAE;CACb,CAAC,CAAC;AAOH;;;;;;;;;;;;;GAaG;AACH,SAAS,iCAAiC,CACxC,GAAkD,EAClD,GAAsD,EACtD,KAAc,EACd,GAA6B,EAC7B,EAAE,aAAa,EAAE,mBAAmB,EAAkC;IAEtE,IAAI,CAAC,sBAAc,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACxC,OAAO,GAAG,CACR,2BAAc,CAAC,YAAY,CAAC;YAC1B,OAAO,EAAE,kFAAkF,sBAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;SACxH,CAAC,CACH,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAEvB,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAEnD,MAAM,EAAE,EAAE,EAAE,GAAG,eAAe,CAAC;QAE/B,GAAG,CAAC,MAAM,GAAG,mBAAmB,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,MAAe;IACzC,IAAI,CAAC;QACH,OAAO,IAAA,oBAAM,EAAC,MAAM,EAAE,mCAAmC,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,yBAAW,EAAE,CAAC;YACjC,MAAM,sBAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mBAAmB,KAAK,CAAC,OAAO,GAAG;aAC7C,CAAC,CAAC;QACL,CAAC;QACD,0BAA0B;QAC1B,MAAM,sBAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { providerErrors, rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetInterfaceContextParams,\n GetInterfaceContextResult,\n InterfaceContext,\n JsonRpcRequest,\n} from '@metamask/snaps-sdk';\nimport { type InferMatching } from '@metamask/snaps-utils';\nimport { StructError, create, object, string } from '@metamask/superstruct';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport { UI_PERMISSIONS } from '../utils';\n\nconst methodName = 'snap_getInterfaceContext';\n\nconst hookNames: MethodHooksObject<GetInterfaceContextMethodHooks> = {\n hasPermission: true,\n getInterfaceContext: true,\n};\n\nexport type GetInterfaceContextMethodHooks = {\n /**\n * @param permissionName - The name of the permission to check.\n * @returns Whether the Snap has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * @param id - The interface ID.\n * @returns The interface context.\n */\n getInterfaceContext: (id: string) => InterfaceContext | null;\n};\n\n/**\n * Get the context of an [interface](https://docs.metamask.io/snaps/features/custom-ui/interactive-ui/)\n * created by [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).\n *\n * @example\n * ```ts\n * import { Box, Heading, Text } from '@metamask/snaps-sdk/jsx';\n *\n * const interfaceId = await snap.request({\n * method: 'snap_createInterface',\n * params: {\n * ui: (\n * <Box>\n * <Heading>Hello, world!</Heading>\n * <Text>Welcome to my Snap homepage!</Text>\n * </Box>\n * ),\n * context: {\n * key: 'value'\n * }\n * },\n * })\n *\n * const context = await snap.request({\n * method: 'snap_getInterfaceContext',\n * params: {\n * id: interfaceId,\n * },\n * })\n *\n * console.log(context)\n * // {\n * // key: 'value'\n * // }\n * ```\n */\nexport const getInterfaceContextHandler = {\n methodNames: [methodName] as const,\n implementation: getInterfaceContextImplementation,\n hookNames,\n} satisfies PermittedHandlerExport<\n GetInterfaceContextMethodHooks,\n GetInterfaceContextParameters,\n GetInterfaceContextResult\n>;\n\nconst GetInterfaceContextParametersStruct = object({\n id: string(),\n});\n\nexport type GetInterfaceContextParameters = InferMatching<\n typeof GetInterfaceContextParametersStruct,\n GetInterfaceContextParams\n>;\n\n/**\n * The `snap_getInterfaceContext` method implementation.\n *\n * @param req - The JSON-RPC request object.\n * @param res - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.hasPermission - The function to check if the Snap has a given\n * permission.\n * @param hooks.getInterfaceContext - The function to get the interface context.\n * @returns Nothing.\n */\nfunction getInterfaceContextImplementation(\n req: JsonRpcRequest<GetInterfaceContextParameters>,\n res: PendingJsonRpcResponse<GetInterfaceContextResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { hasPermission, getInterfaceContext }: GetInterfaceContextMethodHooks,\n): void {\n if (!UI_PERMISSIONS.some(hasPermission)) {\n return end(\n providerErrors.unauthorized({\n message: `This method can only be used if the Snap has one of the following permissions: ${UI_PERMISSIONS.join(', ')}.`,\n }),\n );\n }\n\n const { params } = req;\n\n try {\n const validatedParams = getValidatedParams(params);\n\n const { id } = validatedParams;\n\n res.result = getInterfaceContext(id);\n } catch (error) {\n return end(error);\n }\n\n return end();\n}\n\n/**\n * Validate the getInterfaceContext method `params` and returns them cast to the correct\n * type. Throws if validation fails.\n *\n * @param params - The unvalidated params object from the method request.\n * @returns The validated getInterfaceContext method parameter object.\n */\nfunction getValidatedParams(params: unknown): GetInterfaceContextParameters {\n try {\n return create(params, GetInterfaceContextParametersStruct);\n } catch (error) {\n if (error instanceof StructError) {\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}.`,\n });\n }\n /* istanbul ignore next */\n throw rpcErrors.internal();\n }\n}\n"]}
1
+ {"version":3,"file":"getInterfaceContext.cjs","sourceRoot":"","sources":["../../src/permitted/getInterfaceContext.ts"],"names":[],"mappings":";;;AAMA,qDAAiE;AAMjE,uDAA4E;AAO5E,wCAA0C;AAM1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACU,QAAA,0BAA0B,GAAG;IACxC,cAAc,EAAE,iCAAiC;IACjD,WAAW,EAAE;QACX,oCAAoC;QACpC,sCAAsC;KACvC;CAOF,CAAC;AAEF,MAAM,mCAAmC,GAAG,IAAA,oBAAM,EAAC;IACjD,EAAE,EAAE,IAAA,oBAAM,GAAE;CACb,CAAC,CAAC;AAOH;;;;;;;;;;;GAWG;AACH,SAAS,iCAAiC,CACxC,GAA4D,EAC5D,GAAsD,EACtD,KAAc,EACd,GAA6B,EAC7B,MAAa,EACb,SAA8D;IAE9D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAE/B,MAAM,WAAW,GAAG,sBAAc,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CACrD,SAAS,CAAC,IAAI,CAAC,oCAAoC,EAAE,MAAM,EAAE,UAAU,CAAC,CACzE,CAAC;IAEF,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,GAAG,CACR,2BAAc,CAAC,YAAY,CAAC;YAC1B,OAAO,EAAE,kFAAkF,sBAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;SACxH,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAEnD,MAAM,EAAE,EAAE,EAAE,GAAG,eAAe,CAAC;QAE/B,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC,IAAI,CAChC,sCAAsC,EACtC,MAAM,EACN,EAAE,CACH,CAAC;QAEF,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,MAAe;IACzC,IAAI,CAAC;QACH,OAAO,IAAA,oBAAM,EAAC,MAAM,EAAE,mCAAmC,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,yBAAW,EAAE,CAAC;YACjC,MAAM,sBAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mBAAmB,KAAK,CAAC,OAAO,GAAG;aAC7C,CAAC,CAAC;QACL,CAAC;QACD,0BAA0B;QAC1B,MAAM,sBAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC","sourcesContent":["import type {\n JsonRpcEngineEndCallback,\n MethodHandler,\n} from '@metamask/json-rpc-engine';\nimport type { Messenger } from '@metamask/messenger';\nimport type { PermissionControllerHasPermissionAction } from '@metamask/permission-controller';\nimport { providerErrors, rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetInterfaceContextParams,\n GetInterfaceContextResult,\n} from '@metamask/snaps-sdk';\nimport { type InferMatching } from '@metamask/snaps-utils';\nimport { StructError, create, object, string } from '@metamask/superstruct';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport type {\n JsonRpcRequestWithOrigin,\n SnapInterfaceControllerGetInterfaceAction,\n} from '../types';\nimport { UI_PERMISSIONS } from '../utils';\n\nexport type GetInterfaceContextMethodActions =\n | PermissionControllerHasPermissionAction\n | SnapInterfaceControllerGetInterfaceAction;\n\n/**\n * Get the context of an [interface](https://docs.metamask.io/snaps/features/custom-ui/interactive-ui/)\n * created by [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).\n *\n * @example\n * ```ts\n * import { Box, Heading, Text } from '@metamask/snaps-sdk/jsx';\n *\n * const interfaceId = await snap.request({\n * method: 'snap_createInterface',\n * params: {\n * ui: (\n * <Box>\n * <Heading>Hello, world!</Heading>\n * <Text>Welcome to my Snap homepage!</Text>\n * </Box>\n * ),\n * context: {\n * key: 'value'\n * }\n * },\n * })\n *\n * const context = await snap.request({\n * method: 'snap_getInterfaceContext',\n * params: {\n * id: interfaceId,\n * },\n * })\n *\n * console.log(context)\n * // {\n * // key: 'value'\n * // }\n * ```\n */\nexport const getInterfaceContextHandler = {\n implementation: getInterfaceContextImplementation,\n actionNames: [\n 'PermissionController:hasPermission',\n 'SnapInterfaceController:getInterface',\n ],\n} satisfies MethodHandler<\n never,\n GetInterfaceContextMethodActions,\n GetInterfaceContextParameters,\n GetInterfaceContextResult,\n { origin: string }\n>;\n\nconst GetInterfaceContextParametersStruct = object({\n id: string(),\n});\n\nexport type GetInterfaceContextParameters = InferMatching<\n typeof GetInterfaceContextParametersStruct,\n GetInterfaceContextParams\n>;\n\n/**\n * The `snap_getInterfaceContext` method implementation.\n *\n * @param req - The JSON-RPC request object.\n * @param res - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param _hooks - The RPC method hooks. Not used by this function.\n * @param messenger - The messenger used to call controller actions.\n * @returns Nothing.\n */\nfunction getInterfaceContextImplementation(\n req: JsonRpcRequestWithOrigin<GetInterfaceContextParameters>,\n res: PendingJsonRpcResponse<GetInterfaceContextResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n _hooks: never,\n messenger: Messenger<string, GetInterfaceContextMethodActions>,\n): void {\n const { params, origin } = req;\n\n const isPermitted = UI_PERMISSIONS.some((permission) =>\n messenger.call('PermissionController:hasPermission', origin, permission),\n );\n\n if (!isPermitted) {\n return end(\n providerErrors.unauthorized({\n message: `This method can only be used if the Snap has one of the following permissions: ${UI_PERMISSIONS.join(', ')}.`,\n }),\n );\n }\n\n try {\n const validatedParams = getValidatedParams(params);\n\n const { id } = validatedParams;\n\n const { context } = messenger.call(\n 'SnapInterfaceController:getInterface',\n origin,\n id,\n );\n\n res.result = context;\n } catch (error) {\n return end(error);\n }\n\n return end();\n}\n\n/**\n * Validate the getInterfaceContext method `params` and returns them cast to the correct\n * type. Throws if validation fails.\n *\n * @param params - The unvalidated params object from the method request.\n * @returns The validated getInterfaceContext method parameter object.\n */\nfunction getValidatedParams(params: unknown): GetInterfaceContextParameters {\n try {\n return create(params, GetInterfaceContextParametersStruct);\n } catch (error) {\n if (error instanceof StructError) {\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}.`,\n });\n }\n /* istanbul ignore next */\n throw rpcErrors.internal();\n }\n}\n"]}
@@ -1,20 +1,11 @@
1
1
  import type { JsonRpcEngineEndCallback } from "@metamask/json-rpc-engine";
2
- import type { GetInterfaceContextParams, GetInterfaceContextResult, InterfaceContext, JsonRpcRequest } from "@metamask/snaps-sdk";
2
+ import type { Messenger } from "@metamask/messenger";
3
+ import type { PermissionControllerHasPermissionAction } from "@metamask/permission-controller";
4
+ import type { GetInterfaceContextParams, GetInterfaceContextResult } from "@metamask/snaps-sdk";
3
5
  import { type InferMatching } from "@metamask/snaps-utils";
4
6
  import type { PendingJsonRpcResponse } from "@metamask/utils";
5
- import type { MethodHooksObject } from "../utils.cjs";
6
- export type GetInterfaceContextMethodHooks = {
7
- /**
8
- * @param permissionName - The name of the permission to check.
9
- * @returns Whether the Snap has the permission.
10
- */
11
- hasPermission: (permissionName: string) => boolean;
12
- /**
13
- * @param id - The interface ID.
14
- * @returns The interface context.
15
- */
16
- getInterfaceContext: (id: string) => InterfaceContext | null;
17
- };
7
+ import type { JsonRpcRequestWithOrigin, SnapInterfaceControllerGetInterfaceAction } from "../types.cjs";
8
+ export type GetInterfaceContextMethodActions = PermissionControllerHasPermissionAction | SnapInterfaceControllerGetInterfaceAction;
18
9
  /**
19
10
  * Get the context of an [interface](https://docs.metamask.io/snaps/features/custom-ui/interactive-ui/)
20
11
  * created by [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).
@@ -52,9 +43,8 @@ export type GetInterfaceContextMethodHooks = {
52
43
  * ```
53
44
  */
54
45
  export declare const getInterfaceContextHandler: {
55
- methodNames: ["snap_getInterfaceContext"];
56
46
  implementation: typeof getInterfaceContextImplementation;
57
- hookNames: MethodHooksObject<GetInterfaceContextMethodHooks>;
47
+ actionNames: ("SnapInterfaceController:getInterface" | "PermissionController:hasPermission")[];
58
48
  };
59
49
  declare const GetInterfaceContextParametersStruct: import("@metamask/superstruct").Struct<{
60
50
  id: string;
@@ -70,12 +60,10 @@ export type GetInterfaceContextParameters = InferMatching<typeof GetInterfaceCon
70
60
  * @param _next - The `json-rpc-engine` "next" callback. Not used by this
71
61
  * function.
72
62
  * @param end - The `json-rpc-engine` "end" callback.
73
- * @param hooks - The RPC method hooks.
74
- * @param hooks.hasPermission - The function to check if the Snap has a given
75
- * permission.
76
- * @param hooks.getInterfaceContext - The function to get the interface context.
63
+ * @param _hooks - The RPC method hooks. Not used by this function.
64
+ * @param messenger - The messenger used to call controller actions.
77
65
  * @returns Nothing.
78
66
  */
79
- declare function getInterfaceContextImplementation(req: JsonRpcRequest<GetInterfaceContextParameters>, res: PendingJsonRpcResponse<GetInterfaceContextResult>, _next: unknown, end: JsonRpcEngineEndCallback, { hasPermission, getInterfaceContext }: GetInterfaceContextMethodHooks): void;
67
+ declare function getInterfaceContextImplementation(req: JsonRpcRequestWithOrigin<GetInterfaceContextParameters>, res: PendingJsonRpcResponse<GetInterfaceContextResult>, _next: unknown, end: JsonRpcEngineEndCallback, _hooks: never, messenger: Messenger<string, GetInterfaceContextMethodActions>): void;
80
68
  export {};
81
69
  //# sourceMappingURL=getInterfaceContext.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getInterfaceContext.d.cts","sourceRoot":"","sources":["../../src/permitted/getInterfaceContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAkC;AAG1E,OAAO,KAAK,EACV,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAChB,cAAc,EACf,4BAA4B;AAC7B,OAAO,EAAE,KAAK,aAAa,EAAE,8BAA8B;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAUlD,MAAM,MAAM,8BAA8B,GAAG;IAC3C;;;OAGG;IACH,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC;IAEnD;;;OAGG;IACH,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,gBAAgB,GAAG,IAAI,CAAC;CAC9D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,0BAA0B;;;;CAQtC,CAAC;AAEF,QAAA,MAAM,mCAAmC;;;;EAEvC,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,aAAa,CACvD,OAAO,mCAAmC,EAC1C,yBAAyB,CAC1B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,iBAAS,iCAAiC,CACxC,GAAG,EAAE,cAAc,CAAC,6BAA6B,CAAC,EAClD,GAAG,EAAE,sBAAsB,CAAC,yBAAyB,CAAC,EACtD,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,wBAAwB,EAC7B,EAAE,aAAa,EAAE,mBAAmB,EAAE,EAAE,8BAA8B,GACrE,IAAI,CAsBN"}
1
+ {"version":3,"file":"getInterfaceContext.d.cts","sourceRoot":"","sources":["../../src/permitted/getInterfaceContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EAEzB,kCAAkC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,uCAAuC,EAAE,wCAAwC;AAE/F,OAAO,KAAK,EACV,yBAAyB,EACzB,yBAAyB,EAC1B,4BAA4B;AAC7B,OAAO,EAAE,KAAK,aAAa,EAAE,8BAA8B;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB;AAE9D,OAAO,KAAK,EACV,wBAAwB,EACxB,yCAAyC,EAC1C,qBAAiB;AAGlB,MAAM,MAAM,gCAAgC,GACxC,uCAAuC,GACvC,yCAAyC,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,0BAA0B;;;CAYtC,CAAC;AAEF,QAAA,MAAM,mCAAmC;;;;EAEvC,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,aAAa,CACvD,OAAO,mCAAmC,EAC1C,yBAAyB,CAC1B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,iBAAS,iCAAiC,CACxC,GAAG,EAAE,wBAAwB,CAAC,6BAA6B,CAAC,EAC5D,GAAG,EAAE,sBAAsB,CAAC,yBAAyB,CAAC,EACtD,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,wBAAwB,EAC7B,MAAM,EAAE,KAAK,EACb,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,gCAAgC,CAAC,GAC7D,IAAI,CAgCN"}
@@ -1,20 +1,11 @@
1
1
  import type { JsonRpcEngineEndCallback } from "@metamask/json-rpc-engine";
2
- import type { GetInterfaceContextParams, GetInterfaceContextResult, InterfaceContext, JsonRpcRequest } from "@metamask/snaps-sdk";
2
+ import type { Messenger } from "@metamask/messenger";
3
+ import type { PermissionControllerHasPermissionAction } from "@metamask/permission-controller";
4
+ import type { GetInterfaceContextParams, GetInterfaceContextResult } from "@metamask/snaps-sdk";
3
5
  import { type InferMatching } from "@metamask/snaps-utils";
4
6
  import type { PendingJsonRpcResponse } from "@metamask/utils";
5
- import type { MethodHooksObject } from "../utils.mjs";
6
- export type GetInterfaceContextMethodHooks = {
7
- /**
8
- * @param permissionName - The name of the permission to check.
9
- * @returns Whether the Snap has the permission.
10
- */
11
- hasPermission: (permissionName: string) => boolean;
12
- /**
13
- * @param id - The interface ID.
14
- * @returns The interface context.
15
- */
16
- getInterfaceContext: (id: string) => InterfaceContext | null;
17
- };
7
+ import type { JsonRpcRequestWithOrigin, SnapInterfaceControllerGetInterfaceAction } from "../types.mjs";
8
+ export type GetInterfaceContextMethodActions = PermissionControllerHasPermissionAction | SnapInterfaceControllerGetInterfaceAction;
18
9
  /**
19
10
  * Get the context of an [interface](https://docs.metamask.io/snaps/features/custom-ui/interactive-ui/)
20
11
  * created by [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).
@@ -52,9 +43,8 @@ export type GetInterfaceContextMethodHooks = {
52
43
  * ```
53
44
  */
54
45
  export declare const getInterfaceContextHandler: {
55
- methodNames: ["snap_getInterfaceContext"];
56
46
  implementation: typeof getInterfaceContextImplementation;
57
- hookNames: MethodHooksObject<GetInterfaceContextMethodHooks>;
47
+ actionNames: ("SnapInterfaceController:getInterface" | "PermissionController:hasPermission")[];
58
48
  };
59
49
  declare const GetInterfaceContextParametersStruct: import("@metamask/superstruct").Struct<{
60
50
  id: string;
@@ -70,12 +60,10 @@ export type GetInterfaceContextParameters = InferMatching<typeof GetInterfaceCon
70
60
  * @param _next - The `json-rpc-engine` "next" callback. Not used by this
71
61
  * function.
72
62
  * @param end - The `json-rpc-engine` "end" callback.
73
- * @param hooks - The RPC method hooks.
74
- * @param hooks.hasPermission - The function to check if the Snap has a given
75
- * permission.
76
- * @param hooks.getInterfaceContext - The function to get the interface context.
63
+ * @param _hooks - The RPC method hooks. Not used by this function.
64
+ * @param messenger - The messenger used to call controller actions.
77
65
  * @returns Nothing.
78
66
  */
79
- declare function getInterfaceContextImplementation(req: JsonRpcRequest<GetInterfaceContextParameters>, res: PendingJsonRpcResponse<GetInterfaceContextResult>, _next: unknown, end: JsonRpcEngineEndCallback, { hasPermission, getInterfaceContext }: GetInterfaceContextMethodHooks): void;
67
+ declare function getInterfaceContextImplementation(req: JsonRpcRequestWithOrigin<GetInterfaceContextParameters>, res: PendingJsonRpcResponse<GetInterfaceContextResult>, _next: unknown, end: JsonRpcEngineEndCallback, _hooks: never, messenger: Messenger<string, GetInterfaceContextMethodActions>): void;
80
68
  export {};
81
69
  //# sourceMappingURL=getInterfaceContext.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getInterfaceContext.d.mts","sourceRoot":"","sources":["../../src/permitted/getInterfaceContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAkC;AAG1E,OAAO,KAAK,EACV,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAChB,cAAc,EACf,4BAA4B;AAC7B,OAAO,EAAE,KAAK,aAAa,EAAE,8BAA8B;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAUlD,MAAM,MAAM,8BAA8B,GAAG;IAC3C;;;OAGG;IACH,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC;IAEnD;;;OAGG;IACH,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,gBAAgB,GAAG,IAAI,CAAC;CAC9D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,0BAA0B;;;;CAQtC,CAAC;AAEF,QAAA,MAAM,mCAAmC;;;;EAEvC,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,aAAa,CACvD,OAAO,mCAAmC,EAC1C,yBAAyB,CAC1B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,iBAAS,iCAAiC,CACxC,GAAG,EAAE,cAAc,CAAC,6BAA6B,CAAC,EAClD,GAAG,EAAE,sBAAsB,CAAC,yBAAyB,CAAC,EACtD,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,wBAAwB,EAC7B,EAAE,aAAa,EAAE,mBAAmB,EAAE,EAAE,8BAA8B,GACrE,IAAI,CAsBN"}
1
+ {"version":3,"file":"getInterfaceContext.d.mts","sourceRoot":"","sources":["../../src/permitted/getInterfaceContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EAEzB,kCAAkC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,uCAAuC,EAAE,wCAAwC;AAE/F,OAAO,KAAK,EACV,yBAAyB,EACzB,yBAAyB,EAC1B,4BAA4B;AAC7B,OAAO,EAAE,KAAK,aAAa,EAAE,8BAA8B;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB;AAE9D,OAAO,KAAK,EACV,wBAAwB,EACxB,yCAAyC,EAC1C,qBAAiB;AAGlB,MAAM,MAAM,gCAAgC,GACxC,uCAAuC,GACvC,yCAAyC,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,0BAA0B;;;CAYtC,CAAC;AAEF,QAAA,MAAM,mCAAmC;;;;EAEvC,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,aAAa,CACvD,OAAO,mCAAmC,EAC1C,yBAAyB,CAC1B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,iBAAS,iCAAiC,CACxC,GAAG,EAAE,wBAAwB,CAAC,6BAA6B,CAAC,EAC5D,GAAG,EAAE,sBAAsB,CAAC,yBAAyB,CAAC,EACtD,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,wBAAwB,EAC7B,MAAM,EAAE,KAAK,EACb,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,gCAAgC,CAAC,GAC7D,IAAI,CAgCN"}
@@ -1,11 +1,6 @@
1
1
  import { providerErrors, rpcErrors } from "@metamask/rpc-errors";
2
2
  import { StructError, create, object, string } from "@metamask/superstruct";
3
3
  import { UI_PERMISSIONS } from "../utils.mjs";
4
- const methodName = 'snap_getInterfaceContext';
5
- const hookNames = {
6
- hasPermission: true,
7
- getInterfaceContext: true,
8
- };
9
4
  /**
10
5
  * Get the context of an [interface](https://docs.metamask.io/snaps/features/custom-ui/interactive-ui/)
11
6
  * created by [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).
@@ -43,9 +38,11 @@ const hookNames = {
43
38
  * ```
44
39
  */
45
40
  export const getInterfaceContextHandler = {
46
- methodNames: [methodName],
47
41
  implementation: getInterfaceContextImplementation,
48
- hookNames,
42
+ actionNames: [
43
+ 'PermissionController:hasPermission',
44
+ 'SnapInterfaceController:getInterface',
45
+ ],
49
46
  };
50
47
  const GetInterfaceContextParametersStruct = object({
51
48
  id: string(),
@@ -58,23 +55,23 @@ const GetInterfaceContextParametersStruct = object({
58
55
  * @param _next - The `json-rpc-engine` "next" callback. Not used by this
59
56
  * function.
60
57
  * @param end - The `json-rpc-engine` "end" callback.
61
- * @param hooks - The RPC method hooks.
62
- * @param hooks.hasPermission - The function to check if the Snap has a given
63
- * permission.
64
- * @param hooks.getInterfaceContext - The function to get the interface context.
58
+ * @param _hooks - The RPC method hooks. Not used by this function.
59
+ * @param messenger - The messenger used to call controller actions.
65
60
  * @returns Nothing.
66
61
  */
67
- function getInterfaceContextImplementation(req, res, _next, end, { hasPermission, getInterfaceContext }) {
68
- if (!UI_PERMISSIONS.some(hasPermission)) {
62
+ function getInterfaceContextImplementation(req, res, _next, end, _hooks, messenger) {
63
+ const { params, origin } = req;
64
+ const isPermitted = UI_PERMISSIONS.some((permission) => messenger.call('PermissionController:hasPermission', origin, permission));
65
+ if (!isPermitted) {
69
66
  return end(providerErrors.unauthorized({
70
67
  message: `This method can only be used if the Snap has one of the following permissions: ${UI_PERMISSIONS.join(', ')}.`,
71
68
  }));
72
69
  }
73
- const { params } = req;
74
70
  try {
75
71
  const validatedParams = getValidatedParams(params);
76
72
  const { id } = validatedParams;
77
- res.result = getInterfaceContext(id);
73
+ const { context } = messenger.call('SnapInterfaceController:getInterface', origin, id);
74
+ res.result = context;
78
75
  }
79
76
  catch (error) {
80
77
  return end(error);
@@ -1 +1 @@
1
- {"version":3,"file":"getInterfaceContext.mjs","sourceRoot":"","sources":["../../src/permitted/getInterfaceContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,6BAA6B;AAQjE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAI5E,OAAO,EAAE,cAAc,EAAE,qBAAiB;AAE1C,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C,MAAM,SAAS,GAAsD;IACnE,aAAa,EAAE,IAAI;IACnB,mBAAmB,EAAE,IAAI;CAC1B,CAAC;AAgBF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,WAAW,EAAE,CAAC,UAAU,CAAU;IAClC,cAAc,EAAE,iCAAiC;IACjD,SAAS;CAKV,CAAC;AAEF,MAAM,mCAAmC,GAAG,MAAM,CAAC;IACjD,EAAE,EAAE,MAAM,EAAE;CACb,CAAC,CAAC;AAOH;;;;;;;;;;;;;GAaG;AACH,SAAS,iCAAiC,CACxC,GAAkD,EAClD,GAAsD,EACtD,KAAc,EACd,GAA6B,EAC7B,EAAE,aAAa,EAAE,mBAAmB,EAAkC;IAEtE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACxC,OAAO,GAAG,CACR,cAAc,CAAC,YAAY,CAAC;YAC1B,OAAO,EAAE,kFAAkF,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;SACxH,CAAC,CACH,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAEvB,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAEnD,MAAM,EAAE,EAAE,EAAE,GAAG,eAAe,CAAC;QAE/B,GAAG,CAAC,MAAM,GAAG,mBAAmB,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,MAAe;IACzC,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,MAAM,EAAE,mCAAmC,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,MAAM,SAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mBAAmB,KAAK,CAAC,OAAO,GAAG;aAC7C,CAAC,CAAC;QACL,CAAC;QACD,0BAA0B;QAC1B,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { providerErrors, rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetInterfaceContextParams,\n GetInterfaceContextResult,\n InterfaceContext,\n JsonRpcRequest,\n} from '@metamask/snaps-sdk';\nimport { type InferMatching } from '@metamask/snaps-utils';\nimport { StructError, create, object, string } from '@metamask/superstruct';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport { UI_PERMISSIONS } from '../utils';\n\nconst methodName = 'snap_getInterfaceContext';\n\nconst hookNames: MethodHooksObject<GetInterfaceContextMethodHooks> = {\n hasPermission: true,\n getInterfaceContext: true,\n};\n\nexport type GetInterfaceContextMethodHooks = {\n /**\n * @param permissionName - The name of the permission to check.\n * @returns Whether the Snap has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * @param id - The interface ID.\n * @returns The interface context.\n */\n getInterfaceContext: (id: string) => InterfaceContext | null;\n};\n\n/**\n * Get the context of an [interface](https://docs.metamask.io/snaps/features/custom-ui/interactive-ui/)\n * created by [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).\n *\n * @example\n * ```ts\n * import { Box, Heading, Text } from '@metamask/snaps-sdk/jsx';\n *\n * const interfaceId = await snap.request({\n * method: 'snap_createInterface',\n * params: {\n * ui: (\n * <Box>\n * <Heading>Hello, world!</Heading>\n * <Text>Welcome to my Snap homepage!</Text>\n * </Box>\n * ),\n * context: {\n * key: 'value'\n * }\n * },\n * })\n *\n * const context = await snap.request({\n * method: 'snap_getInterfaceContext',\n * params: {\n * id: interfaceId,\n * },\n * })\n *\n * console.log(context)\n * // {\n * // key: 'value'\n * // }\n * ```\n */\nexport const getInterfaceContextHandler = {\n methodNames: [methodName] as const,\n implementation: getInterfaceContextImplementation,\n hookNames,\n} satisfies PermittedHandlerExport<\n GetInterfaceContextMethodHooks,\n GetInterfaceContextParameters,\n GetInterfaceContextResult\n>;\n\nconst GetInterfaceContextParametersStruct = object({\n id: string(),\n});\n\nexport type GetInterfaceContextParameters = InferMatching<\n typeof GetInterfaceContextParametersStruct,\n GetInterfaceContextParams\n>;\n\n/**\n * The `snap_getInterfaceContext` method implementation.\n *\n * @param req - The JSON-RPC request object.\n * @param res - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.hasPermission - The function to check if the Snap has a given\n * permission.\n * @param hooks.getInterfaceContext - The function to get the interface context.\n * @returns Nothing.\n */\nfunction getInterfaceContextImplementation(\n req: JsonRpcRequest<GetInterfaceContextParameters>,\n res: PendingJsonRpcResponse<GetInterfaceContextResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { hasPermission, getInterfaceContext }: GetInterfaceContextMethodHooks,\n): void {\n if (!UI_PERMISSIONS.some(hasPermission)) {\n return end(\n providerErrors.unauthorized({\n message: `This method can only be used if the Snap has one of the following permissions: ${UI_PERMISSIONS.join(', ')}.`,\n }),\n );\n }\n\n const { params } = req;\n\n try {\n const validatedParams = getValidatedParams(params);\n\n const { id } = validatedParams;\n\n res.result = getInterfaceContext(id);\n } catch (error) {\n return end(error);\n }\n\n return end();\n}\n\n/**\n * Validate the getInterfaceContext method `params` and returns them cast to the correct\n * type. Throws if validation fails.\n *\n * @param params - The unvalidated params object from the method request.\n * @returns The validated getInterfaceContext method parameter object.\n */\nfunction getValidatedParams(params: unknown): GetInterfaceContextParameters {\n try {\n return create(params, GetInterfaceContextParametersStruct);\n } catch (error) {\n if (error instanceof StructError) {\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}.`,\n });\n }\n /* istanbul ignore next */\n throw rpcErrors.internal();\n }\n}\n"]}
1
+ {"version":3,"file":"getInterfaceContext.mjs","sourceRoot":"","sources":["../../src/permitted/getInterfaceContext.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,6BAA6B;AAMjE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAO5E,OAAO,EAAE,cAAc,EAAE,qBAAiB;AAM1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,cAAc,EAAE,iCAAiC;IACjD,WAAW,EAAE;QACX,oCAAoC;QACpC,sCAAsC;KACvC;CAOF,CAAC;AAEF,MAAM,mCAAmC,GAAG,MAAM,CAAC;IACjD,EAAE,EAAE,MAAM,EAAE;CACb,CAAC,CAAC;AAOH;;;;;;;;;;;GAWG;AACH,SAAS,iCAAiC,CACxC,GAA4D,EAC5D,GAAsD,EACtD,KAAc,EACd,GAA6B,EAC7B,MAAa,EACb,SAA8D;IAE9D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAE/B,MAAM,WAAW,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CACrD,SAAS,CAAC,IAAI,CAAC,oCAAoC,EAAE,MAAM,EAAE,UAAU,CAAC,CACzE,CAAC;IAEF,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,GAAG,CACR,cAAc,CAAC,YAAY,CAAC;YAC1B,OAAO,EAAE,kFAAkF,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;SACxH,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAEnD,MAAM,EAAE,EAAE,EAAE,GAAG,eAAe,CAAC;QAE/B,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC,IAAI,CAChC,sCAAsC,EACtC,MAAM,EACN,EAAE,CACH,CAAC;QAEF,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,MAAe;IACzC,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,MAAM,EAAE,mCAAmC,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,MAAM,SAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mBAAmB,KAAK,CAAC,OAAO,GAAG;aAC7C,CAAC,CAAC;QACL,CAAC;QACD,0BAA0B;QAC1B,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC","sourcesContent":["import type {\n JsonRpcEngineEndCallback,\n MethodHandler,\n} from '@metamask/json-rpc-engine';\nimport type { Messenger } from '@metamask/messenger';\nimport type { PermissionControllerHasPermissionAction } from '@metamask/permission-controller';\nimport { providerErrors, rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetInterfaceContextParams,\n GetInterfaceContextResult,\n} from '@metamask/snaps-sdk';\nimport { type InferMatching } from '@metamask/snaps-utils';\nimport { StructError, create, object, string } from '@metamask/superstruct';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport type {\n JsonRpcRequestWithOrigin,\n SnapInterfaceControllerGetInterfaceAction,\n} from '../types';\nimport { UI_PERMISSIONS } from '../utils';\n\nexport type GetInterfaceContextMethodActions =\n | PermissionControllerHasPermissionAction\n | SnapInterfaceControllerGetInterfaceAction;\n\n/**\n * Get the context of an [interface](https://docs.metamask.io/snaps/features/custom-ui/interactive-ui/)\n * created by [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).\n *\n * @example\n * ```ts\n * import { Box, Heading, Text } from '@metamask/snaps-sdk/jsx';\n *\n * const interfaceId = await snap.request({\n * method: 'snap_createInterface',\n * params: {\n * ui: (\n * <Box>\n * <Heading>Hello, world!</Heading>\n * <Text>Welcome to my Snap homepage!</Text>\n * </Box>\n * ),\n * context: {\n * key: 'value'\n * }\n * },\n * })\n *\n * const context = await snap.request({\n * method: 'snap_getInterfaceContext',\n * params: {\n * id: interfaceId,\n * },\n * })\n *\n * console.log(context)\n * // {\n * // key: 'value'\n * // }\n * ```\n */\nexport const getInterfaceContextHandler = {\n implementation: getInterfaceContextImplementation,\n actionNames: [\n 'PermissionController:hasPermission',\n 'SnapInterfaceController:getInterface',\n ],\n} satisfies MethodHandler<\n never,\n GetInterfaceContextMethodActions,\n GetInterfaceContextParameters,\n GetInterfaceContextResult,\n { origin: string }\n>;\n\nconst GetInterfaceContextParametersStruct = object({\n id: string(),\n});\n\nexport type GetInterfaceContextParameters = InferMatching<\n typeof GetInterfaceContextParametersStruct,\n GetInterfaceContextParams\n>;\n\n/**\n * The `snap_getInterfaceContext` method implementation.\n *\n * @param req - The JSON-RPC request object.\n * @param res - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param _hooks - The RPC method hooks. Not used by this function.\n * @param messenger - The messenger used to call controller actions.\n * @returns Nothing.\n */\nfunction getInterfaceContextImplementation(\n req: JsonRpcRequestWithOrigin<GetInterfaceContextParameters>,\n res: PendingJsonRpcResponse<GetInterfaceContextResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n _hooks: never,\n messenger: Messenger<string, GetInterfaceContextMethodActions>,\n): void {\n const { params, origin } = req;\n\n const isPermitted = UI_PERMISSIONS.some((permission) =>\n messenger.call('PermissionController:hasPermission', origin, permission),\n );\n\n if (!isPermitted) {\n return end(\n providerErrors.unauthorized({\n message: `This method can only be used if the Snap has one of the following permissions: ${UI_PERMISSIONS.join(', ')}.`,\n }),\n );\n }\n\n try {\n const validatedParams = getValidatedParams(params);\n\n const { id } = validatedParams;\n\n const { context } = messenger.call(\n 'SnapInterfaceController:getInterface',\n origin,\n id,\n );\n\n res.result = context;\n } catch (error) {\n return end(error);\n }\n\n return end();\n}\n\n/**\n * Validate the getInterfaceContext method `params` and returns them cast to the correct\n * type. Throws if validation fails.\n *\n * @param params - The unvalidated params object from the method request.\n * @returns The validated getInterfaceContext method parameter object.\n */\nfunction getValidatedParams(params: unknown): GetInterfaceContextParameters {\n try {\n return create(params, GetInterfaceContextParametersStruct);\n } catch (error) {\n if (error instanceof StructError) {\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}.`,\n });\n }\n /* istanbul ignore next */\n throw rpcErrors.internal();\n }\n}\n"]}
@@ -4,11 +4,6 @@ exports.getInterfaceStateHandler = void 0;
4
4
  const rpc_errors_1 = require("@metamask/rpc-errors");
5
5
  const superstruct_1 = require("@metamask/superstruct");
6
6
  const utils_1 = require("../utils.cjs");
7
- const methodName = 'snap_getInterfaceState';
8
- const hookNames = {
9
- hasPermission: true,
10
- getInterfaceState: true,
11
- };
12
7
  /**
13
8
  * Get the form state of an [interface](https://docs.metamask.io/snaps/features/custom-ui/interactive-ui/)
14
9
  * created by [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).
@@ -24,9 +19,11 @@ const hookNames = {
24
19
  * ```
25
20
  */
26
21
  exports.getInterfaceStateHandler = {
27
- methodNames: [methodName],
28
22
  implementation: getGetInterfaceStateImplementation,
29
- hookNames,
23
+ actionNames: [
24
+ 'PermissionController:hasPermission',
25
+ 'SnapInterfaceController:getInterfaceState',
26
+ ],
30
27
  };
31
28
  const GetInterfaceStateParametersStruct = (0, superstruct_1.object)({
32
29
  id: (0, superstruct_1.string)(),
@@ -39,23 +36,22 @@ const GetInterfaceStateParametersStruct = (0, superstruct_1.object)({
39
36
  * @param _next - The `json-rpc-engine` "next" callback. Not used by this
40
37
  * function.
41
38
  * @param end - The `json-rpc-engine` "end" callback.
42
- * @param hooks - The RPC method hooks.
43
- * @param hooks.hasPermission - The function to check if the Snap has a given
44
- * permission.
45
- * @param hooks.getInterfaceState - The function to get the interface state.
39
+ * @param _hooks - The RPC method hooks. Not used by this function.
40
+ * @param messenger - The messenger used to call controller actions.
46
41
  * @returns Nothing.
47
42
  */
48
- function getGetInterfaceStateImplementation(req, res, _next, end, { hasPermission, getInterfaceState }) {
49
- if (!utils_1.UI_PERMISSIONS.some(hasPermission)) {
43
+ function getGetInterfaceStateImplementation(req, res, _next, end, _hooks, messenger) {
44
+ const { params, origin } = req;
45
+ const isPermitted = utils_1.UI_PERMISSIONS.some((permission) => messenger.call('PermissionController:hasPermission', origin, permission));
46
+ if (!isPermitted) {
50
47
  return end(rpc_errors_1.providerErrors.unauthorized({
51
48
  message: `This method can only be used if the Snap has one of the following permissions: ${utils_1.UI_PERMISSIONS.join(', ')}.`,
52
49
  }));
53
50
  }
54
- const { params } = req;
55
51
  try {
56
52
  const validatedParams = getValidatedParams(params);
57
53
  const { id } = validatedParams;
58
- res.result = getInterfaceState(id);
54
+ res.result = messenger.call('SnapInterfaceController:getInterfaceState', origin, id);
59
55
  }
60
56
  catch (error) {
61
57
  return end(error);
@@ -1 +1 @@
1
- {"version":3,"file":"getInterfaceState.cjs","sourceRoot":"","sources":["../../src/permitted/getInterfaceState.ts"],"names":[],"mappings":";;;AAEA,qDAAiE;AAQjE,uDAA4E;AAI5E,wCAA0C;AAE1C,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAE5C,MAAM,SAAS,GAAoD;IACjE,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAgBF;;;;;;;;;;;;;GAaG;AACU,QAAA,wBAAwB,GAAG;IACtC,WAAW,EAAE,CAAC,UAAU,CAAU;IAClC,cAAc,EAAE,kCAAkC;IAClD,SAAS;CAKV,CAAC;AAEF,MAAM,iCAAiC,GAAG,IAAA,oBAAM,EAAC;IAC/C,EAAE,EAAE,IAAA,oBAAM,GAAE;CACb,CAAC,CAAC;AAOH;;;;;;;;;;;;;GAaG;AACH,SAAS,kCAAkC,CACzC,GAAgD,EAChD,GAAoD,EACpD,KAAc,EACd,GAA6B,EAC7B,EAAE,aAAa,EAAE,iBAAiB,EAAgC;IAElE,IAAI,CAAC,sBAAc,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACxC,OAAO,GAAG,CACR,2BAAc,CAAC,YAAY,CAAC;YAC1B,OAAO,EAAE,kFAAkF,sBAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;SACxH,CAAC,CACH,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAEvB,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAEnD,MAAM,EAAE,EAAE,EAAE,GAAG,eAAe,CAAC;QAE/B,GAAG,CAAC,MAAM,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,MAAe;IACzC,IAAI,CAAC;QACH,OAAO,IAAA,oBAAM,EAAC,MAAM,EAAE,iCAAiC,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,yBAAW,EAAE,CAAC;YACjC,MAAM,sBAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mBAAmB,KAAK,CAAC,OAAO,GAAG;aAC7C,CAAC,CAAC;QACL,CAAC;QACD,0BAA0B;QAC1B,MAAM,sBAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { providerErrors, rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetInterfaceStateParams,\n GetInterfaceStateResult,\n InterfaceState,\n JsonRpcRequest,\n} from '@metamask/snaps-sdk';\nimport { type InferMatching } from '@metamask/snaps-utils';\nimport { StructError, create, object, string } from '@metamask/superstruct';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport { UI_PERMISSIONS } from '../utils';\n\nconst methodName = 'snap_getInterfaceState';\n\nconst hookNames: MethodHooksObject<GetInterfaceStateMethodHooks> = {\n hasPermission: true,\n getInterfaceState: true,\n};\n\nexport type GetInterfaceStateMethodHooks = {\n /**\n * @param permissionName - The name of the permission to check.\n * @returns Whether the Snap has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * @param id - The interface ID.\n * @returns The interface state.\n */\n getInterfaceState: (id: string) => InterfaceState;\n};\n\n/**\n * Get the form state of an [interface](https://docs.metamask.io/snaps/features/custom-ui/interactive-ui/)\n * created by [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).\n *\n * @example\n * ```ts\n * const state = await snap.request({\n * method: 'snap_getInterfaceState',\n * params: {\n * id: interfaceId,\n * },\n * });\n * ```\n */\nexport const getInterfaceStateHandler = {\n methodNames: [methodName] as const,\n implementation: getGetInterfaceStateImplementation,\n hookNames,\n} satisfies PermittedHandlerExport<\n GetInterfaceStateMethodHooks,\n GetInterfaceStateParameters,\n GetInterfaceStateResult\n>;\n\nconst GetInterfaceStateParametersStruct = object({\n id: string(),\n});\n\nexport type GetInterfaceStateParameters = InferMatching<\n typeof GetInterfaceStateParametersStruct,\n GetInterfaceStateParams\n>;\n\n/**\n * The `snap_getInterfaceState` method implementation.\n *\n * @param req - The JSON-RPC request object.\n * @param res - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.hasPermission - The function to check if the Snap has a given\n * permission.\n * @param hooks.getInterfaceState - The function to get the interface state.\n * @returns Nothing.\n */\nfunction getGetInterfaceStateImplementation(\n req: JsonRpcRequest<GetInterfaceStateParameters>,\n res: PendingJsonRpcResponse<GetInterfaceStateResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { hasPermission, getInterfaceState }: GetInterfaceStateMethodHooks,\n): void {\n if (!UI_PERMISSIONS.some(hasPermission)) {\n return end(\n providerErrors.unauthorized({\n message: `This method can only be used if the Snap has one of the following permissions: ${UI_PERMISSIONS.join(', ')}.`,\n }),\n );\n }\n\n const { params } = req;\n\n try {\n const validatedParams = getValidatedParams(params);\n\n const { id } = validatedParams;\n\n res.result = getInterfaceState(id);\n } catch (error) {\n return end(error);\n }\n\n return end();\n}\n\n/**\n * Validate the getInterfaceState method `params` and returns them cast to the correct\n * type. Throws if validation fails.\n *\n * @param params - The unvalidated params object from the method request.\n * @returns The validated getInterfaceState method parameter object.\n */\nfunction getValidatedParams(params: unknown): GetInterfaceStateParameters {\n try {\n return create(params, GetInterfaceStateParametersStruct);\n } catch (error) {\n if (error instanceof StructError) {\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}.`,\n });\n }\n /* istanbul ignore next */\n throw rpcErrors.internal();\n }\n}\n"]}
1
+ {"version":3,"file":"getInterfaceState.cjs","sourceRoot":"","sources":["../../src/permitted/getInterfaceState.ts"],"names":[],"mappings":";;;AAMA,qDAAiE;AAMjE,uDAA4E;AAO5E,wCAA0C;AAM1C;;;;;;;;;;;;;GAaG;AACU,QAAA,wBAAwB,GAAG;IACtC,cAAc,EAAE,kCAAkC;IAClD,WAAW,EAAE;QACX,oCAAoC;QACpC,2CAA2C;KAC5C;CAOF,CAAC;AAEF,MAAM,iCAAiC,GAAG,IAAA,oBAAM,EAAC;IAC/C,EAAE,EAAE,IAAA,oBAAM,GAAE;CACb,CAAC,CAAC;AAOH;;;;;;;;;;;GAWG;AACH,SAAS,kCAAkC,CACzC,GAA0D,EAC1D,GAAoD,EACpD,KAAc,EACd,GAA6B,EAC7B,MAAa,EACb,SAA4D;IAE5D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAE/B,MAAM,WAAW,GAAG,sBAAc,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CACrD,SAAS,CAAC,IAAI,CAAC,oCAAoC,EAAE,MAAM,EAAE,UAAU,CAAC,CACzE,CAAC;IAEF,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,GAAG,CACR,2BAAc,CAAC,YAAY,CAAC;YAC1B,OAAO,EAAE,kFAAkF,sBAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;SACxH,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAEnD,MAAM,EAAE,EAAE,EAAE,GAAG,eAAe,CAAC;QAE/B,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,IAAI,CACzB,2CAA2C,EAC3C,MAAM,EACN,EAAE,CACH,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,MAAe;IACzC,IAAI,CAAC;QACH,OAAO,IAAA,oBAAM,EAAC,MAAM,EAAE,iCAAiC,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,yBAAW,EAAE,CAAC;YACjC,MAAM,sBAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mBAAmB,KAAK,CAAC,OAAO,GAAG;aAC7C,CAAC,CAAC;QACL,CAAC;QACD,0BAA0B;QAC1B,MAAM,sBAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC","sourcesContent":["import type {\n JsonRpcEngineEndCallback,\n MethodHandler,\n} from '@metamask/json-rpc-engine';\nimport type { Messenger } from '@metamask/messenger';\nimport type { PermissionControllerHasPermissionAction } from '@metamask/permission-controller';\nimport { providerErrors, rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetInterfaceStateParams,\n GetInterfaceStateResult,\n} from '@metamask/snaps-sdk';\nimport { type InferMatching } from '@metamask/snaps-utils';\nimport { StructError, create, object, string } from '@metamask/superstruct';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport type {\n JsonRpcRequestWithOrigin,\n SnapInterfaceControllerGetInterfaceStateAction,\n} from '../types';\nimport { UI_PERMISSIONS } from '../utils';\n\nexport type GetInterfaceStateMethodActions =\n | PermissionControllerHasPermissionAction\n | SnapInterfaceControllerGetInterfaceStateAction;\n\n/**\n * Get the form state of an [interface](https://docs.metamask.io/snaps/features/custom-ui/interactive-ui/)\n * created by [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).\n *\n * @example\n * ```ts\n * const state = await snap.request({\n * method: 'snap_getInterfaceState',\n * params: {\n * id: interfaceId,\n * },\n * });\n * ```\n */\nexport const getInterfaceStateHandler = {\n implementation: getGetInterfaceStateImplementation,\n actionNames: [\n 'PermissionController:hasPermission',\n 'SnapInterfaceController:getInterfaceState',\n ],\n} satisfies MethodHandler<\n never,\n GetInterfaceStateMethodActions,\n GetInterfaceStateParameters,\n GetInterfaceStateResult,\n { origin: string }\n>;\n\nconst GetInterfaceStateParametersStruct = object({\n id: string(),\n});\n\nexport type GetInterfaceStateParameters = InferMatching<\n typeof GetInterfaceStateParametersStruct,\n GetInterfaceStateParams\n>;\n\n/**\n * The `snap_getInterfaceState` method implementation.\n *\n * @param req - The JSON-RPC request object.\n * @param res - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param _hooks - The RPC method hooks. Not used by this function.\n * @param messenger - The messenger used to call controller actions.\n * @returns Nothing.\n */\nfunction getGetInterfaceStateImplementation(\n req: JsonRpcRequestWithOrigin<GetInterfaceStateParameters>,\n res: PendingJsonRpcResponse<GetInterfaceStateResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n _hooks: never,\n messenger: Messenger<string, GetInterfaceStateMethodActions>,\n): void {\n const { params, origin } = req;\n\n const isPermitted = UI_PERMISSIONS.some((permission) =>\n messenger.call('PermissionController:hasPermission', origin, permission),\n );\n\n if (!isPermitted) {\n return end(\n providerErrors.unauthorized({\n message: `This method can only be used if the Snap has one of the following permissions: ${UI_PERMISSIONS.join(', ')}.`,\n }),\n );\n }\n\n try {\n const validatedParams = getValidatedParams(params);\n\n const { id } = validatedParams;\n\n res.result = messenger.call(\n 'SnapInterfaceController:getInterfaceState',\n origin,\n id,\n );\n } catch (error) {\n return end(error);\n }\n\n return end();\n}\n\n/**\n * Validate the getInterfaceState method `params` and returns them cast to the correct\n * type. Throws if validation fails.\n *\n * @param params - The unvalidated params object from the method request.\n * @returns The validated getInterfaceState method parameter object.\n */\nfunction getValidatedParams(params: unknown): GetInterfaceStateParameters {\n try {\n return create(params, GetInterfaceStateParametersStruct);\n } catch (error) {\n if (error instanceof StructError) {\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}.`,\n });\n }\n /* istanbul ignore next */\n throw rpcErrors.internal();\n }\n}\n"]}
@@ -1,20 +1,11 @@
1
1
  import type { JsonRpcEngineEndCallback } from "@metamask/json-rpc-engine";
2
- import type { GetInterfaceStateParams, GetInterfaceStateResult, InterfaceState, JsonRpcRequest } from "@metamask/snaps-sdk";
2
+ import type { Messenger } from "@metamask/messenger";
3
+ import type { PermissionControllerHasPermissionAction } from "@metamask/permission-controller";
4
+ import type { GetInterfaceStateParams, GetInterfaceStateResult } from "@metamask/snaps-sdk";
3
5
  import { type InferMatching } from "@metamask/snaps-utils";
4
6
  import type { PendingJsonRpcResponse } from "@metamask/utils";
5
- import type { MethodHooksObject } from "../utils.cjs";
6
- export type GetInterfaceStateMethodHooks = {
7
- /**
8
- * @param permissionName - The name of the permission to check.
9
- * @returns Whether the Snap has the permission.
10
- */
11
- hasPermission: (permissionName: string) => boolean;
12
- /**
13
- * @param id - The interface ID.
14
- * @returns The interface state.
15
- */
16
- getInterfaceState: (id: string) => InterfaceState;
17
- };
7
+ import type { JsonRpcRequestWithOrigin, SnapInterfaceControllerGetInterfaceStateAction } from "../types.cjs";
8
+ export type GetInterfaceStateMethodActions = PermissionControllerHasPermissionAction | SnapInterfaceControllerGetInterfaceStateAction;
18
9
  /**
19
10
  * Get the form state of an [interface](https://docs.metamask.io/snaps/features/custom-ui/interactive-ui/)
20
11
  * created by [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).
@@ -30,9 +21,8 @@ export type GetInterfaceStateMethodHooks = {
30
21
  * ```
31
22
  */
32
23
  export declare const getInterfaceStateHandler: {
33
- methodNames: ["snap_getInterfaceState"];
34
24
  implementation: typeof getGetInterfaceStateImplementation;
35
- hookNames: MethodHooksObject<GetInterfaceStateMethodHooks>;
25
+ actionNames: ("SnapInterfaceController:getInterfaceState" | "PermissionController:hasPermission")[];
36
26
  };
37
27
  declare const GetInterfaceStateParametersStruct: import("@metamask/superstruct").Struct<{
38
28
  id: string;
@@ -48,12 +38,10 @@ export type GetInterfaceStateParameters = InferMatching<typeof GetInterfaceState
48
38
  * @param _next - The `json-rpc-engine` "next" callback. Not used by this
49
39
  * function.
50
40
  * @param end - The `json-rpc-engine` "end" callback.
51
- * @param hooks - The RPC method hooks.
52
- * @param hooks.hasPermission - The function to check if the Snap has a given
53
- * permission.
54
- * @param hooks.getInterfaceState - The function to get the interface state.
41
+ * @param _hooks - The RPC method hooks. Not used by this function.
42
+ * @param messenger - The messenger used to call controller actions.
55
43
  * @returns Nothing.
56
44
  */
57
- declare function getGetInterfaceStateImplementation(req: JsonRpcRequest<GetInterfaceStateParameters>, res: PendingJsonRpcResponse<GetInterfaceStateResult>, _next: unknown, end: JsonRpcEngineEndCallback, { hasPermission, getInterfaceState }: GetInterfaceStateMethodHooks): void;
45
+ declare function getGetInterfaceStateImplementation(req: JsonRpcRequestWithOrigin<GetInterfaceStateParameters>, res: PendingJsonRpcResponse<GetInterfaceStateResult>, _next: unknown, end: JsonRpcEngineEndCallback, _hooks: never, messenger: Messenger<string, GetInterfaceStateMethodActions>): void;
58
46
  export {};
59
47
  //# sourceMappingURL=getInterfaceState.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getInterfaceState.d.cts","sourceRoot":"","sources":["../../src/permitted/getInterfaceState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAkC;AAG1E,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACf,4BAA4B;AAC7B,OAAO,EAAE,KAAK,aAAa,EAAE,8BAA8B;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAUlD,MAAM,MAAM,4BAA4B,GAAG;IACzC;;;OAGG;IACH,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC;IAEnD;;;OAGG;IACH,iBAAiB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,cAAc,CAAC;CACnD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB;;;;CAQpC,CAAC;AAEF,QAAA,MAAM,iCAAiC;;;;EAErC,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,aAAa,CACrD,OAAO,iCAAiC,EACxC,uBAAuB,CACxB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,iBAAS,kCAAkC,CACzC,GAAG,EAAE,cAAc,CAAC,2BAA2B,CAAC,EAChD,GAAG,EAAE,sBAAsB,CAAC,uBAAuB,CAAC,EACpD,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,wBAAwB,EAC7B,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,4BAA4B,GACjE,IAAI,CAsBN"}
1
+ {"version":3,"file":"getInterfaceState.d.cts","sourceRoot":"","sources":["../../src/permitted/getInterfaceState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EAEzB,kCAAkC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,uCAAuC,EAAE,wCAAwC;AAE/F,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,4BAA4B;AAC7B,OAAO,EAAE,KAAK,aAAa,EAAE,8BAA8B;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB;AAE9D,OAAO,KAAK,EACV,wBAAwB,EACxB,8CAA8C,EAC/C,qBAAiB;AAGlB,MAAM,MAAM,8BAA8B,GACtC,uCAAuC,GACvC,8CAA8C,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB;;;CAYpC,CAAC;AAEF,QAAA,MAAM,iCAAiC;;;;EAErC,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,aAAa,CACrD,OAAO,iCAAiC,EACxC,uBAAuB,CACxB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,iBAAS,kCAAkC,CACzC,GAAG,EAAE,wBAAwB,CAAC,2BAA2B,CAAC,EAC1D,GAAG,EAAE,sBAAsB,CAAC,uBAAuB,CAAC,EACpD,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,wBAAwB,EAC7B,MAAM,EAAE,KAAK,EACb,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,8BAA8B,CAAC,GAC3D,IAAI,CA8BN"}