@metamask/snaps-rpc-methods 6.0.0 → 7.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 (559) hide show
  1. package/CHANGELOG.md +8 -2
  2. package/dist/chunk-2A5M65V3.js +21 -0
  3. package/dist/chunk-2A5M65V3.js.map +1 -0
  4. package/dist/chunk-2IL6T3EX.js +18 -0
  5. package/dist/chunk-2IL6T3EX.js.map +1 -0
  6. package/dist/chunk-2N2PZJDJ.mjs +105 -0
  7. package/dist/chunk-2N2PZJDJ.mjs.map +1 -0
  8. package/dist/chunk-2QEA2YZM.mjs +23 -0
  9. package/dist/chunk-2QEA2YZM.mjs.map +1 -0
  10. package/dist/chunk-2TYDIMR6.js +78 -0
  11. package/dist/chunk-2TYDIMR6.js.map +1 -0
  12. package/dist/chunk-2WCLK3LN.mjs +115 -0
  13. package/dist/chunk-2WCLK3LN.mjs.map +1 -0
  14. package/dist/chunk-3CSLIOIY.mjs +43 -0
  15. package/dist/chunk-3CSLIOIY.mjs.map +1 -0
  16. package/dist/chunk-3DWRS3YG.mjs +49 -0
  17. package/dist/chunk-3DWRS3YG.mjs.map +1 -0
  18. package/dist/chunk-3FKD2O7M.js +151 -0
  19. package/dist/chunk-3FKD2O7M.js.map +1 -0
  20. package/dist/chunk-4ALFLY5D.js +105 -0
  21. package/dist/chunk-4ALFLY5D.js.map +1 -0
  22. package/dist/chunk-4Z4X6EJP.mjs +67 -0
  23. package/dist/chunk-4Z4X6EJP.mjs.map +1 -0
  24. package/dist/chunk-5HIIIAIS.mjs +57 -0
  25. package/dist/chunk-5HIIIAIS.mjs.map +1 -0
  26. package/dist/chunk-632BZ6JY.js +83 -0
  27. package/dist/{cjs/utils.js.map → chunk-632BZ6JY.js.map} +1 -1
  28. package/dist/chunk-6DUTJBD2.mjs +82 -0
  29. package/dist/chunk-6DUTJBD2.mjs.map +1 -0
  30. package/dist/chunk-6PXDUIXN.js +67 -0
  31. package/dist/chunk-6PXDUIXN.js.map +1 -0
  32. package/dist/chunk-72V4CPGO.mjs +23 -0
  33. package/dist/chunk-72V4CPGO.mjs.map +1 -0
  34. package/dist/chunk-7O63CIBT.js +42 -0
  35. package/dist/chunk-7O63CIBT.js.map +1 -0
  36. package/dist/chunk-ABFJRV6Q.js +68 -0
  37. package/dist/chunk-ABFJRV6Q.js.map +1 -0
  38. package/dist/chunk-BZIPLSKM.mjs +39 -0
  39. package/dist/chunk-BZIPLSKM.mjs.map +1 -0
  40. package/dist/chunk-CIIMO4C2.js +45 -0
  41. package/dist/chunk-CIIMO4C2.js.map +1 -0
  42. package/dist/chunk-DBYI25UR.js +23 -0
  43. package/dist/chunk-DBYI25UR.js.map +1 -0
  44. package/dist/chunk-DDGDVWAW.js +45 -0
  45. package/dist/chunk-DDGDVWAW.js.map +1 -0
  46. package/dist/chunk-DR63Z4PV.mjs +83 -0
  47. package/dist/chunk-DR63Z4PV.mjs.map +1 -0
  48. package/dist/chunk-E2G25QVG.js +119 -0
  49. package/dist/chunk-E2G25QVG.js.map +1 -0
  50. package/dist/chunk-E4HGQWSS.js +43 -0
  51. package/dist/chunk-E4HGQWSS.js.map +1 -0
  52. package/dist/chunk-EAL6AH74.js +67 -0
  53. package/dist/chunk-EAL6AH74.js.map +1 -0
  54. package/dist/chunk-EB6OXVFN.mjs +52 -0
  55. package/dist/chunk-EB6OXVFN.mjs.map +1 -0
  56. package/dist/chunk-EKB7QNFO.mjs +54 -0
  57. package/dist/chunk-EKB7QNFO.mjs.map +1 -0
  58. package/dist/chunk-EPNGNDRH.mjs +80 -0
  59. package/dist/chunk-EPNGNDRH.mjs.map +1 -0
  60. package/dist/chunk-F5BEVZOB.js +47 -0
  61. package/dist/chunk-F5BEVZOB.js.map +1 -0
  62. package/dist/chunk-FMUQOZIO.js +57 -0
  63. package/dist/chunk-FMUQOZIO.js.map +1 -0
  64. package/dist/chunk-H45CGE4Z.js +23 -0
  65. package/dist/chunk-H45CGE4Z.js.map +1 -0
  66. package/dist/chunk-HIYXSQ6K.mjs +188 -0
  67. package/dist/chunk-HIYXSQ6K.mjs.map +1 -0
  68. package/dist/chunk-HLF4WCE4.mjs +20 -0
  69. package/dist/chunk-HLF4WCE4.mjs.map +1 -0
  70. package/dist/chunk-HODDBRLQ.js +75 -0
  71. package/dist/chunk-HODDBRLQ.js.map +1 -0
  72. package/dist/chunk-HOXOD5RL.mjs +68 -0
  73. package/dist/chunk-HOXOD5RL.mjs.map +1 -0
  74. package/dist/chunk-I5H5ZZRC.js +80 -0
  75. package/dist/chunk-I5H5ZZRC.js.map +1 -0
  76. package/dist/chunk-IDRDPYAN.js +70 -0
  77. package/dist/chunk-IDRDPYAN.js.map +1 -0
  78. package/dist/chunk-JEEKFTAL.mjs +59 -0
  79. package/dist/chunk-JEEKFTAL.mjs.map +1 -0
  80. package/dist/chunk-JPUJWFBS.js +115 -0
  81. package/dist/chunk-JPUJWFBS.js.map +1 -0
  82. package/dist/chunk-JURJUHQB.mjs +70 -0
  83. package/dist/chunk-JURJUHQB.mjs.map +1 -0
  84. package/dist/chunk-JV26U22G.js +52 -0
  85. package/dist/chunk-JV26U22G.js.map +1 -0
  86. package/dist/chunk-K73RKHXA.js +20 -0
  87. package/dist/chunk-K73RKHXA.js.map +1 -0
  88. package/dist/chunk-KDLWQGV3.js +74 -0
  89. package/dist/chunk-KDLWQGV3.js.map +1 -0
  90. package/dist/chunk-KE74K2JM.js +59 -0
  91. package/dist/chunk-KE74K2JM.js.map +1 -0
  92. package/dist/chunk-KVHYDTGR.js +1 -0
  93. package/dist/chunk-KVHYDTGR.js.map +1 -0
  94. package/dist/chunk-L7MGGL7Q.mjs +43 -0
  95. package/dist/chunk-L7MGGL7Q.mjs.map +1 -0
  96. package/dist/chunk-LITIVHN4.js +73 -0
  97. package/dist/chunk-LITIVHN4.js.map +1 -0
  98. package/dist/chunk-LU3J2EYE.js +51 -0
  99. package/dist/chunk-LU3J2EYE.js.map +1 -0
  100. package/dist/chunk-LX37AMSK.mjs +78 -0
  101. package/dist/chunk-LX37AMSK.mjs.map +1 -0
  102. package/dist/chunk-LYOKCYHO.mjs +1 -0
  103. package/dist/chunk-LYOKCYHO.mjs.map +1 -0
  104. package/dist/chunk-MDJZ4K3U.mjs +45 -0
  105. package/dist/chunk-MDJZ4K3U.mjs.map +1 -0
  106. package/dist/chunk-MVPKNRLA.mjs +21 -0
  107. package/dist/chunk-MVPKNRLA.mjs.map +1 -0
  108. package/dist/chunk-MYMH4S2N.mjs +23 -0
  109. package/dist/chunk-MYMH4S2N.mjs.map +1 -0
  110. package/dist/chunk-NE2GDZGZ.mjs +67 -0
  111. package/dist/chunk-NE2GDZGZ.mjs.map +1 -0
  112. package/dist/chunk-NTDD6M3B.mjs +32 -0
  113. package/dist/chunk-NTDD6M3B.mjs.map +1 -0
  114. package/dist/chunk-NUKEBOOL.js +78 -0
  115. package/dist/chunk-NUKEBOOL.js.map +1 -0
  116. package/dist/chunk-OMP4SFLK.js +1 -0
  117. package/dist/chunk-OMP4SFLK.js.map +1 -0
  118. package/dist/chunk-OU3QPU6E.mjs +45 -0
  119. package/dist/chunk-OU3QPU6E.mjs.map +1 -0
  120. package/dist/chunk-OUD66G6O.mjs +74 -0
  121. package/dist/chunk-OUD66G6O.mjs.map +1 -0
  122. package/dist/chunk-PEMZWIHQ.js +39 -0
  123. package/dist/chunk-PEMZWIHQ.js.map +1 -0
  124. package/dist/chunk-PSAM7MJM.mjs +78 -0
  125. package/dist/chunk-PSAM7MJM.mjs.map +1 -0
  126. package/dist/chunk-RC7LBS3H.js +35 -0
  127. package/dist/chunk-RC7LBS3H.js.map +1 -0
  128. package/dist/chunk-RHGOSBUT.js +21 -0
  129. package/dist/chunk-RHGOSBUT.js.map +1 -0
  130. package/dist/chunk-RKCEAMYH.mjs +18 -0
  131. package/dist/chunk-RKCEAMYH.mjs.map +1 -0
  132. package/dist/chunk-RWLBQVYX.mjs +73 -0
  133. package/dist/chunk-RWLBQVYX.mjs.map +1 -0
  134. package/dist/chunk-RZDRHJXI.js +23 -0
  135. package/dist/{cjs/endowments/web-assembly.js.map → chunk-RZDRHJXI.js.map} +1 -1
  136. package/dist/chunk-SCXW3FQO.js +49 -0
  137. package/dist/chunk-SCXW3FQO.js.map +1 -0
  138. package/dist/chunk-SMWKMPHG.mjs +35 -0
  139. package/dist/chunk-SMWKMPHG.mjs.map +1 -0
  140. package/dist/chunk-SXSNJEE7.js +18 -0
  141. package/dist/chunk-SXSNJEE7.js.map +1 -0
  142. package/dist/chunk-TNIGT6KN.js +32 -0
  143. package/dist/chunk-TNIGT6KN.js.map +1 -0
  144. package/dist/chunk-TRB2LS4N.js +54 -0
  145. package/dist/chunk-TRB2LS4N.js.map +1 -0
  146. package/dist/chunk-TZRCALSV.mjs +54 -0
  147. package/dist/chunk-TZRCALSV.mjs.map +1 -0
  148. package/dist/chunk-UJZ3HNXS.mjs +23 -0
  149. package/dist/chunk-UJZ3HNXS.mjs.map +1 -0
  150. package/dist/chunk-UXVJ7HYO.js +78 -0
  151. package/dist/{cjs/restricted/getBip32PublicKey.js.map → chunk-UXVJ7HYO.js.map} +1 -1
  152. package/dist/chunk-UYSXSKML.js +82 -0
  153. package/dist/chunk-UYSXSKML.js.map +1 -0
  154. package/dist/chunk-VFI5FR5U.mjs +119 -0
  155. package/dist/chunk-VFI5FR5U.mjs.map +1 -0
  156. package/dist/chunk-VRDGSBXX.mjs +78 -0
  157. package/dist/chunk-VRDGSBXX.mjs.map +1 -0
  158. package/dist/chunk-VSVVWO3W.mjs +42 -0
  159. package/dist/chunk-VSVVWO3W.mjs.map +1 -0
  160. package/dist/chunk-VZBSLVVA.js +23 -0
  161. package/dist/{cjs/endowments/ethereum-provider.js.map → chunk-VZBSLVVA.js.map} +1 -1
  162. package/dist/chunk-W2VJ5TWL.js +54 -0
  163. package/dist/chunk-W2VJ5TWL.js.map +1 -0
  164. package/dist/chunk-WHWFVRFH.js +69 -0
  165. package/dist/chunk-WHWFVRFH.js.map +1 -0
  166. package/dist/chunk-WI23VKOX.mjs +21 -0
  167. package/dist/chunk-WI23VKOX.mjs.map +1 -0
  168. package/dist/chunk-XAQ2P3BY.js +188 -0
  169. package/dist/chunk-XAQ2P3BY.js.map +1 -0
  170. package/dist/chunk-Y5ENHOIY.mjs +47 -0
  171. package/dist/chunk-Y5ENHOIY.mjs.map +1 -0
  172. package/dist/chunk-Y6EL5DBH.mjs +75 -0
  173. package/dist/chunk-Y6EL5DBH.mjs.map +1 -0
  174. package/dist/chunk-Y7DF3ZHO.mjs +1 -0
  175. package/dist/chunk-Y7DF3ZHO.mjs.map +1 -0
  176. package/dist/chunk-YJ3ZFIA7.mjs +51 -0
  177. package/dist/chunk-YJ3ZFIA7.mjs.map +1 -0
  178. package/dist/chunk-YK6IFDRN.mjs +151 -0
  179. package/dist/chunk-YK6IFDRN.mjs.map +1 -0
  180. package/dist/chunk-YN3OMGA5.mjs +69 -0
  181. package/dist/chunk-YN3OMGA5.mjs.map +1 -0
  182. package/dist/chunk-ZLLV3F4G.js +43 -0
  183. package/dist/chunk-ZLLV3F4G.js.map +1 -0
  184. package/dist/chunk-ZP3L7LAQ.mjs +18 -0
  185. package/dist/chunk-ZP3L7LAQ.mjs.map +1 -0
  186. package/dist/endowments/caveats/generic.js +7 -0
  187. package/dist/endowments/caveats/generic.js.map +1 -0
  188. package/dist/endowments/caveats/generic.mjs +7 -0
  189. package/dist/endowments/caveats/generic.mjs.map +1 -0
  190. package/dist/endowments/caveats/index.js +18 -0
  191. package/dist/endowments/caveats/index.js.map +1 -0
  192. package/dist/endowments/caveats/index.mjs +18 -0
  193. package/dist/endowments/caveats/index.mjs.map +1 -0
  194. package/dist/endowments/caveats/requestTime.js +13 -0
  195. package/dist/endowments/caveats/requestTime.js.map +1 -0
  196. package/dist/endowments/caveats/requestTime.mjs +13 -0
  197. package/dist/endowments/caveats/requestTime.mjs.map +1 -0
  198. package/dist/endowments/cronjob.js +16 -0
  199. package/dist/endowments/cronjob.js.map +1 -0
  200. package/dist/endowments/cronjob.mjs +16 -0
  201. package/dist/endowments/cronjob.mjs.map +1 -0
  202. package/dist/endowments/enum.js +7 -0
  203. package/dist/endowments/enum.js.map +1 -0
  204. package/dist/endowments/enum.mjs +7 -0
  205. package/dist/endowments/enum.mjs.map +1 -0
  206. package/dist/endowments/ethereum-provider.js +8 -0
  207. package/dist/endowments/ethereum-provider.js.map +1 -0
  208. package/dist/endowments/ethereum-provider.mjs +8 -0
  209. package/dist/endowments/ethereum-provider.mjs.map +1 -0
  210. package/dist/endowments/home-page.js +8 -0
  211. package/dist/endowments/home-page.js.map +1 -0
  212. package/dist/endowments/home-page.mjs +8 -0
  213. package/dist/endowments/home-page.mjs.map +1 -0
  214. package/dist/endowments/index.js +54 -0
  215. package/dist/endowments/index.js.map +1 -0
  216. package/dist/endowments/index.mjs +54 -0
  217. package/dist/endowments/index.mjs.map +1 -0
  218. package/dist/endowments/keyring.js +17 -0
  219. package/dist/endowments/keyring.js.map +1 -0
  220. package/dist/endowments/keyring.mjs +17 -0
  221. package/dist/endowments/keyring.mjs.map +1 -0
  222. package/dist/endowments/lifecycle-hooks.js +8 -0
  223. package/dist/endowments/lifecycle-hooks.js.map +1 -0
  224. package/dist/endowments/lifecycle-hooks.mjs +8 -0
  225. package/dist/endowments/lifecycle-hooks.mjs.map +1 -0
  226. package/dist/endowments/name-lookup.js +19 -0
  227. package/dist/endowments/name-lookup.js.map +1 -0
  228. package/dist/endowments/name-lookup.mjs +19 -0
  229. package/dist/endowments/name-lookup.mjs.map +1 -0
  230. package/dist/endowments/network-access.js +8 -0
  231. package/dist/endowments/network-access.js.map +1 -0
  232. package/dist/endowments/network-access.mjs +8 -0
  233. package/dist/endowments/network-access.mjs.map +1 -0
  234. package/dist/endowments/rpc.js +17 -0
  235. package/dist/endowments/rpc.js.map +1 -0
  236. package/dist/endowments/rpc.mjs +17 -0
  237. package/dist/endowments/rpc.mjs.map +1 -0
  238. package/dist/endowments/signature-insight.js +17 -0
  239. package/dist/endowments/signature-insight.js.map +1 -0
  240. package/dist/endowments/signature-insight.mjs +17 -0
  241. package/dist/endowments/signature-insight.mjs.map +1 -0
  242. package/dist/endowments/transaction-insight.js +17 -0
  243. package/dist/endowments/transaction-insight.js.map +1 -0
  244. package/dist/endowments/transaction-insight.mjs +17 -0
  245. package/dist/endowments/transaction-insight.mjs.map +1 -0
  246. package/dist/endowments/web-assembly.js +8 -0
  247. package/dist/endowments/web-assembly.js.map +1 -0
  248. package/dist/endowments/web-assembly.mjs +8 -0
  249. package/dist/endowments/web-assembly.mjs.map +1 -0
  250. package/dist/index.js +118 -0
  251. package/dist/index.js.map +1 -0
  252. package/dist/index.mjs +118 -0
  253. package/dist/index.mjs.map +1 -0
  254. package/dist/permissions.js +43 -0
  255. package/dist/permissions.js.map +1 -0
  256. package/dist/permissions.mjs +43 -0
  257. package/dist/permissions.mjs.map +1 -0
  258. package/dist/permitted/createInterface.js +7 -0
  259. package/dist/permitted/createInterface.js.map +1 -0
  260. package/dist/permitted/createInterface.mjs +7 -0
  261. package/dist/permitted/createInterface.mjs.map +1 -0
  262. package/dist/permitted/getAllSnaps.js +7 -0
  263. package/dist/permitted/getAllSnaps.js.map +1 -0
  264. package/dist/permitted/getAllSnaps.mjs +7 -0
  265. package/dist/permitted/getAllSnaps.mjs.map +1 -0
  266. package/dist/permitted/getClientStatus.js +7 -0
  267. package/dist/permitted/getClientStatus.js.map +1 -0
  268. package/dist/permitted/getClientStatus.mjs +7 -0
  269. package/dist/permitted/getClientStatus.mjs.map +1 -0
  270. package/dist/permitted/getFile.js +9 -0
  271. package/dist/permitted/getFile.js.map +1 -0
  272. package/dist/permitted/getFile.mjs +9 -0
  273. package/dist/permitted/getFile.mjs.map +1 -0
  274. package/dist/permitted/getInterfaceState.js +7 -0
  275. package/dist/permitted/getInterfaceState.js.map +1 -0
  276. package/dist/permitted/getInterfaceState.mjs +7 -0
  277. package/dist/permitted/getInterfaceState.mjs.map +1 -0
  278. package/dist/permitted/getSnaps.js +7 -0
  279. package/dist/permitted/getSnaps.js.map +1 -0
  280. package/dist/permitted/getSnaps.mjs +7 -0
  281. package/dist/permitted/getSnaps.mjs.map +1 -0
  282. package/dist/permitted/handlers.js +20 -0
  283. package/dist/permitted/handlers.js.map +1 -0
  284. package/dist/permitted/handlers.mjs +20 -0
  285. package/dist/permitted/handlers.mjs.map +1 -0
  286. package/dist/permitted/index.js +26 -0
  287. package/dist/permitted/index.js.map +1 -0
  288. package/dist/permitted/index.mjs +26 -0
  289. package/dist/permitted/index.mjs.map +1 -0
  290. package/dist/permitted/invokeKeyring.js +8 -0
  291. package/dist/permitted/invokeKeyring.js.map +1 -0
  292. package/dist/permitted/invokeKeyring.mjs +8 -0
  293. package/dist/permitted/invokeKeyring.mjs.map +1 -0
  294. package/dist/permitted/invokeSnapSugar.js +11 -0
  295. package/dist/permitted/invokeSnapSugar.js.map +1 -0
  296. package/dist/permitted/invokeSnapSugar.mjs +11 -0
  297. package/dist/permitted/invokeSnapSugar.mjs.map +1 -0
  298. package/dist/permitted/middleware.js +20 -0
  299. package/dist/permitted/middleware.js.map +1 -0
  300. package/dist/permitted/middleware.mjs +20 -0
  301. package/dist/permitted/middleware.mjs.map +1 -0
  302. package/dist/permitted/requestSnaps.js +12 -0
  303. package/dist/permitted/requestSnaps.js.map +1 -0
  304. package/dist/permitted/requestSnaps.mjs +12 -0
  305. package/dist/permitted/requestSnaps.mjs.map +1 -0
  306. package/dist/permitted/updateInterface.js +7 -0
  307. package/dist/permitted/updateInterface.js.map +1 -0
  308. package/dist/permitted/updateInterface.mjs +7 -0
  309. package/dist/permitted/updateInterface.mjs.map +1 -0
  310. package/dist/restricted/caveats/index.js +17 -0
  311. package/dist/restricted/caveats/index.js.map +1 -0
  312. package/dist/restricted/caveats/index.mjs +17 -0
  313. package/dist/restricted/caveats/index.mjs.map +1 -0
  314. package/dist/restricted/caveats/permittedCoinTypes.js +13 -0
  315. package/dist/restricted/caveats/permittedCoinTypes.js.map +1 -0
  316. package/dist/restricted/caveats/permittedCoinTypes.mjs +13 -0
  317. package/dist/restricted/caveats/permittedCoinTypes.mjs.map +1 -0
  318. package/dist/restricted/caveats/permittedDerivationPaths.js +13 -0
  319. package/dist/restricted/caveats/permittedDerivationPaths.js.map +1 -0
  320. package/dist/restricted/caveats/permittedDerivationPaths.mjs +13 -0
  321. package/dist/restricted/caveats/permittedDerivationPaths.mjs.map +1 -0
  322. package/dist/restricted/caveats/snapIds.js +11 -0
  323. package/dist/restricted/caveats/snapIds.js.map +1 -0
  324. package/dist/restricted/caveats/snapIds.mjs +11 -0
  325. package/dist/restricted/caveats/snapIds.mjs.map +1 -0
  326. package/dist/restricted/dialog.js +9 -0
  327. package/dist/restricted/dialog.js.map +1 -0
  328. package/dist/restricted/dialog.mjs +9 -0
  329. package/dist/restricted/dialog.mjs.map +1 -0
  330. package/dist/restricted/getBip32Entropy.js +10 -0
  331. package/dist/restricted/getBip32Entropy.js.map +1 -0
  332. package/dist/restricted/getBip32Entropy.mjs +10 -0
  333. package/dist/restricted/getBip32Entropy.mjs.map +1 -0
  334. package/dist/restricted/getBip32PublicKey.js +12 -0
  335. package/dist/restricted/getBip32PublicKey.js.map +1 -0
  336. package/dist/restricted/getBip32PublicKey.mjs +12 -0
  337. package/dist/restricted/getBip32PublicKey.mjs.map +1 -0
  338. package/dist/restricted/getBip44Entropy.js +9 -0
  339. package/dist/restricted/getBip44Entropy.js.map +1 -0
  340. package/dist/restricted/getBip44Entropy.mjs +9 -0
  341. package/dist/restricted/getBip44Entropy.mjs.map +1 -0
  342. package/dist/restricted/getEntropy.js +10 -0
  343. package/dist/restricted/getEntropy.js.map +1 -0
  344. package/dist/restricted/getEntropy.mjs +10 -0
  345. package/dist/restricted/getEntropy.mjs.map +1 -0
  346. package/dist/restricted/getLocale.js +11 -0
  347. package/dist/restricted/getLocale.js.map +1 -0
  348. package/dist/restricted/getLocale.mjs +11 -0
  349. package/dist/restricted/getLocale.mjs.map +1 -0
  350. package/dist/restricted/index.js +33 -0
  351. package/dist/restricted/index.js.map +1 -0
  352. package/dist/restricted/index.mjs +33 -0
  353. package/dist/restricted/index.mjs.map +1 -0
  354. package/dist/restricted/invokeSnap.js +13 -0
  355. package/dist/restricted/invokeSnap.js.map +1 -0
  356. package/dist/restricted/invokeSnap.mjs +13 -0
  357. package/dist/restricted/invokeSnap.mjs.map +1 -0
  358. package/dist/restricted/manageAccounts.js +13 -0
  359. package/dist/restricted/manageAccounts.js.map +1 -0
  360. package/dist/restricted/manageAccounts.mjs +13 -0
  361. package/dist/restricted/manageAccounts.mjs.map +1 -0
  362. package/dist/restricted/manageState.js +20 -0
  363. package/dist/restricted/manageState.js.map +1 -0
  364. package/dist/restricted/manageState.mjs +20 -0
  365. package/dist/restricted/manageState.mjs.map +1 -0
  366. package/dist/restricted/notify.js +13 -0
  367. package/dist/restricted/notify.js.map +1 -0
  368. package/dist/restricted/notify.mjs +13 -0
  369. package/dist/restricted/notify.mjs.map +1 -0
  370. package/dist/tsconfig.build.tsbuildinfo +1 -0
  371. package/dist/utils.js +13 -0
  372. package/dist/utils.js.map +1 -0
  373. package/dist/utils.mjs +13 -0
  374. package/dist/utils.mjs.map +1 -0
  375. package/package.json +21 -18
  376. package/dist/cjs/endowments/caveats/generic.js +0 -40
  377. package/dist/cjs/endowments/caveats/generic.js.map +0 -1
  378. package/dist/cjs/endowments/caveats/index.js +0 -21
  379. package/dist/cjs/endowments/caveats/index.js.map +0 -1
  380. package/dist/cjs/endowments/caveats/requestTime.js +0 -99
  381. package/dist/cjs/endowments/caveats/requestTime.js.map +0 -1
  382. package/dist/cjs/endowments/cronjob.js +0 -100
  383. package/dist/cjs/endowments/cronjob.js.map +0 -1
  384. package/dist/cjs/endowments/enum.js +0 -26
  385. package/dist/cjs/endowments/enum.js.map +0 -1
  386. package/dist/cjs/endowments/ethereum-provider.js +0 -43
  387. package/dist/cjs/endowments/home-page.js +0 -37
  388. package/dist/cjs/endowments/home-page.js.map +0 -1
  389. package/dist/cjs/endowments/index.js +0 -121
  390. package/dist/cjs/endowments/index.js.map +0 -1
  391. package/dist/cjs/endowments/keyring.js +0 -104
  392. package/dist/cjs/endowments/keyring.js.map +0 -1
  393. package/dist/cjs/endowments/lifecycle-hooks.js +0 -37
  394. package/dist/cjs/endowments/lifecycle-hooks.js.map +0 -1
  395. package/dist/cjs/endowments/name-lookup.js +0 -148
  396. package/dist/cjs/endowments/name-lookup.js.map +0 -1
  397. package/dist/cjs/endowments/network-access.js +0 -44
  398. package/dist/cjs/endowments/network-access.js.map +0 -1
  399. package/dist/cjs/endowments/rpc.js +0 -103
  400. package/dist/cjs/endowments/rpc.js.map +0 -1
  401. package/dist/cjs/endowments/signature-insight.js +0 -110
  402. package/dist/cjs/endowments/signature-insight.js.map +0 -1
  403. package/dist/cjs/endowments/transaction-insight.js +0 -111
  404. package/dist/cjs/endowments/transaction-insight.js.map +0 -1
  405. package/dist/cjs/endowments/web-assembly.js +0 -42
  406. package/dist/cjs/index.js +0 -45
  407. package/dist/cjs/index.js.map +0 -1
  408. package/dist/cjs/permissions.js +0 -62
  409. package/dist/cjs/permissions.js.map +0 -1
  410. package/dist/cjs/permitted/createInterface.js +0 -68
  411. package/dist/cjs/permitted/createInterface.js.map +0 -1
  412. package/dist/cjs/permitted/getAllSnaps.js +0 -44
  413. package/dist/cjs/permitted/getAllSnaps.js.map +0 -1
  414. package/dist/cjs/permitted/getClientStatus.js +0 -40
  415. package/dist/cjs/permitted/getClientStatus.js.map +0 -1
  416. package/dist/cjs/permitted/getFile.js +0 -63
  417. package/dist/cjs/permitted/getFile.js.map +0 -1
  418. package/dist/cjs/permitted/getInterfaceState.js +0 -67
  419. package/dist/cjs/permitted/getInterfaceState.js.map +0 -1
  420. package/dist/cjs/permitted/getSnaps.js +0 -39
  421. package/dist/cjs/permitted/getSnaps.js.map +0 -1
  422. package/dist/cjs/permitted/handlers.js +0 -43
  423. package/dist/cjs/permitted/handlers.js.map +0 -1
  424. package/dist/cjs/permitted/index.js +0 -21
  425. package/dist/cjs/permitted/index.js.map +0 -1
  426. package/dist/cjs/permitted/invokeKeyring.js +0 -87
  427. package/dist/cjs/permitted/invokeKeyring.js.map +0 -1
  428. package/dist/cjs/permitted/invokeSnapSugar.js +0 -62
  429. package/dist/cjs/permitted/invokeSnapSugar.js.map +0 -1
  430. package/dist/cjs/permitted/middleware.js +0 -38
  431. package/dist/cjs/permitted/middleware.js.map +0 -1
  432. package/dist/cjs/permitted/requestSnaps.js +0 -123
  433. package/dist/cjs/permitted/requestSnaps.js.map +0 -1
  434. package/dist/cjs/permitted/updateInterface.js +0 -70
  435. package/dist/cjs/permitted/updateInterface.js.map +0 -1
  436. package/dist/cjs/restricted/caveats/index.js +0 -38
  437. package/dist/cjs/restricted/caveats/index.js.map +0 -1
  438. package/dist/cjs/restricted/caveats/permittedCoinTypes.js +0 -83
  439. package/dist/cjs/restricted/caveats/permittedCoinTypes.js.map +0 -1
  440. package/dist/cjs/restricted/caveats/permittedDerivationPaths.js +0 -67
  441. package/dist/cjs/restricted/caveats/permittedDerivationPaths.js.map +0 -1
  442. package/dist/cjs/restricted/caveats/snapIds.js +0 -59
  443. package/dist/cjs/restricted/caveats/snapIds.js.map +0 -1
  444. package/dist/cjs/restricted/dialog.js +0 -172
  445. package/dist/cjs/restricted/dialog.js.map +0 -1
  446. package/dist/cjs/restricted/getBip32Entropy.js +0 -76
  447. package/dist/cjs/restricted/getBip32Entropy.js.map +0 -1
  448. package/dist/cjs/restricted/getBip32PublicKey.js +0 -91
  449. package/dist/cjs/restricted/getBip44Entropy.js +0 -76
  450. package/dist/cjs/restricted/getBip44Entropy.js.map +0 -1
  451. package/dist/cjs/restricted/getEntropy.js +0 -76
  452. package/dist/cjs/restricted/getEntropy.js.map +0 -1
  453. package/dist/cjs/restricted/getLocale.js +0 -49
  454. package/dist/cjs/restricted/getLocale.js.map +0 -1
  455. package/dist/cjs/restricted/index.js +0 -59
  456. package/dist/cjs/restricted/index.js.map +0 -1
  457. package/dist/cjs/restricted/invokeSnap.js +0 -99
  458. package/dist/cjs/restricted/invokeSnap.js.map +0 -1
  459. package/dist/cjs/restricted/manageAccounts.js +0 -68
  460. package/dist/cjs/restricted/manageAccounts.js.map +0 -1
  461. package/dist/cjs/restricted/manageState.js +0 -208
  462. package/dist/cjs/restricted/manageState.js.map +0 -1
  463. package/dist/cjs/restricted/notify.js +0 -92
  464. package/dist/cjs/restricted/notify.js.map +0 -1
  465. package/dist/cjs/utils.js +0 -98
  466. package/dist/esm/endowments/caveats/generic.js +0 -40
  467. package/dist/esm/endowments/caveats/generic.js.map +0 -1
  468. package/dist/esm/endowments/caveats/index.js +0 -4
  469. package/dist/esm/endowments/caveats/index.js.map +0 -1
  470. package/dist/esm/endowments/caveats/requestTime.js +0 -93
  471. package/dist/esm/endowments/caveats/requestTime.js.map +0 -1
  472. package/dist/esm/endowments/cronjob.js +0 -99
  473. package/dist/esm/endowments/cronjob.js.map +0 -1
  474. package/dist/esm/endowments/enum.js +0 -16
  475. package/dist/esm/endowments/enum.js.map +0 -1
  476. package/dist/esm/endowments/ethereum-provider.js +0 -33
  477. package/dist/esm/endowments/ethereum-provider.js.map +0 -1
  478. package/dist/esm/endowments/home-page.js +0 -27
  479. package/dist/esm/endowments/home-page.js.map +0 -1
  480. package/dist/esm/endowments/index.js +0 -68
  481. package/dist/esm/endowments/index.js.map +0 -1
  482. package/dist/esm/endowments/keyring.js +0 -95
  483. package/dist/esm/endowments/keyring.js.map +0 -1
  484. package/dist/esm/endowments/lifecycle-hooks.js +0 -27
  485. package/dist/esm/endowments/lifecycle-hooks.js.map +0 -1
  486. package/dist/esm/endowments/name-lookup.js +0 -146
  487. package/dist/esm/endowments/name-lookup.js.map +0 -1
  488. package/dist/esm/endowments/network-access.js +0 -34
  489. package/dist/esm/endowments/network-access.js.map +0 -1
  490. package/dist/esm/endowments/rpc.js +0 -92
  491. package/dist/esm/endowments/rpc.js.map +0 -1
  492. package/dist/esm/endowments/signature-insight.js +0 -103
  493. package/dist/esm/endowments/signature-insight.js.map +0 -1
  494. package/dist/esm/endowments/transaction-insight.js +0 -104
  495. package/dist/esm/endowments/transaction-insight.js.map +0 -1
  496. package/dist/esm/endowments/web-assembly.js +0 -32
  497. package/dist/esm/endowments/web-assembly.js.map +0 -1
  498. package/dist/esm/index.js +0 -8
  499. package/dist/esm/index.js.map +0 -1
  500. package/dist/esm/permissions.js +0 -51
  501. package/dist/esm/permissions.js.map +0 -1
  502. package/dist/esm/permitted/createInterface.js +0 -58
  503. package/dist/esm/permitted/createInterface.js.map +0 -1
  504. package/dist/esm/permitted/getAllSnaps.js +0 -37
  505. package/dist/esm/permitted/getAllSnaps.js.map +0 -1
  506. package/dist/esm/permitted/getClientStatus.js +0 -32
  507. package/dist/esm/permitted/getClientStatus.js.map +0 -1
  508. package/dist/esm/permitted/getFile.js +0 -45
  509. package/dist/esm/permitted/getFile.js.map +0 -1
  510. package/dist/esm/permitted/getInterfaceState.js +0 -57
  511. package/dist/esm/permitted/getInterfaceState.js.map +0 -1
  512. package/dist/esm/permitted/getSnaps.js +0 -31
  513. package/dist/esm/permitted/getSnaps.js.map +0 -1
  514. package/dist/esm/permitted/handlers.js +0 -25
  515. package/dist/esm/permitted/handlers.js.map +0 -1
  516. package/dist/esm/permitted/index.js +0 -4
  517. package/dist/esm/permitted/index.js.map +0 -1
  518. package/dist/esm/permitted/invokeKeyring.js +0 -79
  519. package/dist/esm/permitted/invokeKeyring.js.map +0 -1
  520. package/dist/esm/permitted/invokeSnapSugar.js +0 -60
  521. package/dist/esm/permitted/invokeSnapSugar.js.map +0 -1
  522. package/dist/esm/permitted/middleware.js +0 -34
  523. package/dist/esm/permitted/middleware.js.map +0 -1
  524. package/dist/esm/permitted/requestSnaps.js +0 -118
  525. package/dist/esm/permitted/requestSnaps.js.map +0 -1
  526. package/dist/esm/permitted/updateInterface.js +0 -60
  527. package/dist/esm/permitted/updateInterface.js.map +0 -1
  528. package/dist/esm/restricted/caveats/index.js +0 -20
  529. package/dist/esm/restricted/caveats/index.js.map +0 -1
  530. package/dist/esm/restricted/caveats/permittedCoinTypes.js +0 -77
  531. package/dist/esm/restricted/caveats/permittedCoinTypes.js.map +0 -1
  532. package/dist/esm/restricted/caveats/permittedDerivationPaths.js +0 -64
  533. package/dist/esm/restricted/caveats/permittedDerivationPaths.js.map +0 -1
  534. package/dist/esm/restricted/caveats/snapIds.js +0 -50
  535. package/dist/esm/restricted/caveats/snapIds.js.map +0 -1
  536. package/dist/esm/restricted/dialog.js +0 -164
  537. package/dist/esm/restricted/dialog.js.map +0 -1
  538. package/dist/esm/restricted/getBip32Entropy.js +0 -67
  539. package/dist/esm/restricted/getBip32Entropy.js.map +0 -1
  540. package/dist/esm/restricted/getBip32PublicKey.js +0 -79
  541. package/dist/esm/restricted/getBip32PublicKey.js.map +0 -1
  542. package/dist/esm/restricted/getBip44Entropy.js +0 -69
  543. package/dist/esm/restricted/getBip44Entropy.js.map +0 -1
  544. package/dist/esm/restricted/getEntropy.js +0 -58
  545. package/dist/esm/restricted/getEntropy.js.map +0 -1
  546. package/dist/esm/restricted/getLocale.js +0 -42
  547. package/dist/esm/restricted/getLocale.js.map +0 -1
  548. package/dist/esm/restricted/index.js +0 -27
  549. package/dist/esm/restricted/index.js.map +0 -1
  550. package/dist/esm/restricted/invokeSnap.js +0 -89
  551. package/dist/esm/restricted/invokeSnap.js.map +0 -1
  552. package/dist/esm/restricted/manageAccounts.js +0 -60
  553. package/dist/esm/restricted/manageAccounts.js.map +0 -1
  554. package/dist/esm/restricted/manageState.js +0 -225
  555. package/dist/esm/restricted/manageState.js.map +0 -1
  556. package/dist/esm/restricted/notify.js +0 -92
  557. package/dist/esm/restricted/notify.js.map +0 -1
  558. package/dist/esm/utils.js +0 -124
  559. package/dist/esm/utils.js.map +0 -1
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- GetEntropyArgsStruct: function() {
13
- return GetEntropyArgsStruct;
14
- },
15
- getEntropyBuilder: function() {
16
- return getEntropyBuilder;
17
- }
18
- });
19
- const _permissioncontroller = require("@metamask/permission-controller");
20
- const _rpcerrors = require("@metamask/rpc-errors");
21
- const _snapsutils = require("@metamask/snaps-utils");
22
- const _utils = require("@metamask/utils");
23
- const _superstruct = require("superstruct");
24
- const _utils1 = require("../utils");
25
- const targetName = 'snap_getEntropy';
26
- const GetEntropyArgsStruct = (0, _superstruct.object)({
27
- version: (0, _superstruct.literal)(1),
28
- salt: (0, _superstruct.optional)((0, _superstruct.string)())
29
- });
30
- const specificationBuilder = ({ allowedCaveats = null, methodHooks })=>{
31
- return {
32
- permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
33
- targetName,
34
- allowedCaveats,
35
- methodImplementation: getEntropyImplementation(methodHooks),
36
- subjectTypes: [
37
- _permissioncontroller.SubjectType.Snap
38
- ]
39
- };
40
- };
41
- const methodHooks = {
42
- getMnemonic: true,
43
- getUnlockPromise: true
44
- };
45
- const getEntropyBuilder = Object.freeze({
46
- targetName,
47
- specificationBuilder,
48
- methodHooks
49
- });
50
- /**
51
- * Builds the method implementation for `snap_getEntropy`. The implementation
52
- * is based on the reference implementation of
53
- * [SIP-6](https://metamask.github.io/SIPs/SIPS/sip-6).
54
- *
55
- * @param hooks - The RPC method hooks.
56
- * @param hooks.getMnemonic - The method to get the mnemonic of the user's
57
- * primary keyring.
58
- * @param hooks.getUnlockPromise - The method to get a promise that resolves
59
- * once the extension is unlocked.
60
- * @returns The method implementation.
61
- */ function getEntropyImplementation({ getMnemonic, getUnlockPromise }) {
62
- return async function getEntropy(options) {
63
- const { params, context: { origin } } = options;
64
- (0, _utils.assertStruct)(params, GetEntropyArgsStruct, 'Invalid "snap_getEntropy" parameters', _rpcerrors.rpcErrors.invalidParams);
65
- await getUnlockPromise(true);
66
- const mnemonicPhrase = await getMnemonic();
67
- return (0, _utils1.deriveEntropy)({
68
- input: origin,
69
- salt: params.salt,
70
- mnemonicPhrase,
71
- magic: _snapsutils.SIP_6_MAGIC_VALUE
72
- });
73
- };
74
- }
75
-
76
- //# sourceMappingURL=getEntropy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/restricted/getEntropy.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { GetEntropyParams, GetEntropyResult } from '@metamask/snaps-sdk';\nimport { SIP_6_MAGIC_VALUE } from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\nimport type { Infer } from 'superstruct';\nimport { literal, object, optional, string } from 'superstruct';\n\nimport type { MethodHooksObject } from '../utils';\nimport { deriveEntropy } from '../utils';\n\nconst targetName = 'snap_getEntropy';\n\ntype GetEntropySpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetEntropyHooks;\n};\n\ntype GetEntropySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getEntropyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\nexport const GetEntropyArgsStruct = object({\n version: literal(1),\n salt: optional(string()),\n});\n\n/**\n * @property version - The version of the `snap_getEntropy` method. This must be\n * the numeric literal `1`.\n * @property salt - A string to use as the salt when deriving the entropy. If\n * omitted, the salt will be an empty string.\n */\nexport type GetEntropyArgs = Infer<typeof GetEntropyArgsStruct>;\n\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetEntropySpecificationBuilderOptions,\n GetEntropySpecification\n> = ({\n allowedCaveats = null,\n methodHooks,\n}: GetEntropySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats,\n methodImplementation: getEntropyImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetEntropyHooks> = {\n getMnemonic: true,\n getUnlockPromise: true,\n};\n\nexport const getEntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\nexport type GetEntropyHooks = {\n /**\n * @returns The mnemonic of the user's primary keyring.\n */\n getMnemonic: () => Promise<Uint8Array>;\n\n /**\n * Waits for the extension to be unlocked.\n *\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n};\n\n/**\n * Builds the method implementation for `snap_getEntropy`. The implementation\n * is based on the reference implementation of\n * [SIP-6](https://metamask.github.io/SIPs/SIPS/sip-6).\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getMnemonic - The method to get the mnemonic of the user's\n * primary keyring.\n * @param hooks.getUnlockPromise - The method to get a promise that resolves\n * once the extension is unlocked.\n * @returns The method implementation.\n */\nfunction getEntropyImplementation({\n getMnemonic,\n getUnlockPromise,\n}: GetEntropyHooks) {\n return async function getEntropy(\n options: RestrictedMethodOptions<GetEntropyParams>,\n ): Promise<GetEntropyResult> {\n const {\n params,\n context: { origin },\n } = options;\n\n assertStruct(\n params,\n GetEntropyArgsStruct,\n 'Invalid \"snap_getEntropy\" parameters',\n rpcErrors.invalidParams,\n );\n\n await getUnlockPromise(true);\n const mnemonicPhrase = await getMnemonic();\n\n return deriveEntropy({\n input: origin,\n salt: params.salt,\n mnemonicPhrase,\n magic: SIP_6_MAGIC_VALUE,\n });\n };\n}\n"],"names":["GetEntropyArgsStruct","getEntropyBuilder","targetName","object","version","literal","salt","optional","string","specificationBuilder","allowedCaveats","methodHooks","permissionType","PermissionType","RestrictedMethod","methodImplementation","getEntropyImplementation","subjectTypes","SubjectType","Snap","getMnemonic","getUnlockPromise","Object","freeze","getEntropy","options","params","context","origin","assertStruct","rpcErrors","invalidParams","mnemonicPhrase","deriveEntropy","input","magic","SIP_6_MAGIC_VALUE"],"mappings":";;;;;;;;;;;IA+BaA,oBAAoB;eAApBA;;IAmCAC,iBAAiB;eAAjBA;;;sCA7D+B;2BAClB;4BAEQ;uBAEL;6BAEqB;wBAGpB;AAE9B,MAAMC,aAAa;AAcZ,MAAMF,uBAAuBG,IAAAA,mBAAM,EAAC;IACzCC,SAASC,IAAAA,oBAAO,EAAC;IACjBC,MAAMC,IAAAA,qBAAQ,EAACC,IAAAA,mBAAM;AACvB;AAUA,MAAMC,uBAIF,CAAC,EACHC,iBAAiB,IAAI,EACrBC,WAAW,EAC2B;IACtC,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CZ;QACAQ;QACAK,sBAAsBC,yBAAyBL;QAC/CM,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAEA,MAAMR,cAAkD;IACtDS,aAAa;IACbC,kBAAkB;AACpB;AAEO,MAAMpB,oBAAoBqB,OAAOC,MAAM,CAAC;IAC7CrB;IACAO;IACAE;AACF;AAgBA;;;;;;;;;;;CAWC,GACD,SAASK,yBAAyB,EAChCI,WAAW,EACXC,gBAAgB,EACA;IAChB,OAAO,eAAeG,WACpBC,OAAkD;QAElD,MAAM,EACJC,MAAM,EACNC,SAAS,EAAEC,MAAM,EAAE,EACpB,GAAGH;QAEJI,IAAAA,mBAAY,EACVH,QACA1B,sBACA,wCACA8B,oBAAS,CAACC,aAAa;QAGzB,MAAMV,iBAAiB;QACvB,MAAMW,iBAAiB,MAAMZ;QAE7B,OAAOa,IAAAA,qBAAa,EAAC;YACnBC,OAAON;YACPtB,MAAMoB,OAAOpB,IAAI;YACjB0B;YACAG,OAAOC,6BAAiB;QAC1B;IACF;AACF"}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- specificationBuilder: function() {
13
- return specificationBuilder;
14
- },
15
- getLocaleBuilder: function() {
16
- return getLocaleBuilder;
17
- },
18
- getImplementation: function() {
19
- return getImplementation;
20
- }
21
- });
22
- const _permissioncontroller = require("@metamask/permission-controller");
23
- const methodName = 'snap_getLocale';
24
- const specificationBuilder = ({ allowedCaveats = null, methodHooks })=>{
25
- return {
26
- permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
27
- targetName: methodName,
28
- allowedCaveats,
29
- methodImplementation: getImplementation(methodHooks),
30
- subjectTypes: [
31
- _permissioncontroller.SubjectType.Snap
32
- ]
33
- };
34
- };
35
- const methodHooks = {
36
- getLocale: true
37
- };
38
- const getLocaleBuilder = Object.freeze({
39
- targetName: methodName,
40
- specificationBuilder,
41
- methodHooks
42
- });
43
- function getImplementation({ getLocale }) {
44
- return async function implementation(_args) {
45
- return getLocale();
46
- };
47
- }
48
-
49
- //# sourceMappingURL=getLocale.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/restricted/getLocale.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n ValidPermissionSpecification,\n RestrictedMethodOptions,\n RestrictedMethodParameters,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport type { GetLocaleResult } from '@metamask/snaps-sdk';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_getLocale';\n\nexport type GetLocaleMethodHooks = {\n getLocale: () => Promise<string>;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetLocaleMethodHooks;\n};\n\ntype Specification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_getLocale` permission.\n * `snap_getLocale` allows snaps to get the user selected locale.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the permission.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getLocale` permission.\n */\nexport const specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n SpecificationBuilderOptions,\n Specification\n> = ({ allowedCaveats = null, methodHooks }: SpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetLocaleMethodHooks> = {\n getLocale: true,\n};\n\nexport const getLocaleBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getLocale`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getLocale - A function that returns the user selected locale.\n * @returns The user selected locale.\n */\nexport function getImplementation({ getLocale }: GetLocaleMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetLocaleResult> {\n return getLocale();\n };\n}\n"],"names":["specificationBuilder","getLocaleBuilder","getImplementation","methodName","allowedCaveats","methodHooks","permissionType","PermissionType","RestrictedMethod","targetName","methodImplementation","subjectTypes","SubjectType","Snap","getLocale","Object","freeze","implementation","_args"],"mappings":";;;;;;;;;;;IAuCaA,oBAAoB;eAApBA;;IAkBAC,gBAAgB;eAAhBA;;IAaGC,iBAAiB;eAAjBA;;;sCAhE4B;AAM5C,MAAMC,aAAa;AA2BZ,MAAMH,uBAIT,CAAC,EAAEI,iBAAiB,IAAI,EAAEC,WAAW,EAA+B;IACtE,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CC,YAAYN;QACZC;QACAM,sBAAsBR,kBAAkBG;QACxCM,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAEA,MAAMR,cAAuD;IAC3DS,WAAW;AACb;AAEO,MAAMb,mBAAmBc,OAAOC,MAAM,CAAC;IAC5CP,YAAYN;IACZH;IACAK;AACF;AASO,SAASH,kBAAkB,EAAEY,SAAS,EAAwB;IACnE,OAAO,eAAeG,eACpBC,KAA0D;QAE1D,OAAOJ;IACT;AACF"}
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- WALLET_SNAP_PERMISSION_KEY: function() {
13
- return _invokeSnap.WALLET_SNAP_PERMISSION_KEY;
14
- },
15
- getEncryptionKey: function() {
16
- return _manageState.getEncryptionKey;
17
- },
18
- restrictedMethodPermissionBuilders: function() {
19
- return restrictedMethodPermissionBuilders;
20
- }
21
- });
22
- const _dialog = require("./dialog");
23
- const _getBip32Entropy = require("./getBip32Entropy");
24
- const _getBip32PublicKey = require("./getBip32PublicKey");
25
- const _getBip44Entropy = require("./getBip44Entropy");
26
- const _getEntropy = require("./getEntropy");
27
- const _getLocale = require("./getLocale");
28
- const _invokeSnap = require("./invokeSnap");
29
- const _manageAccounts = require("./manageAccounts");
30
- const _manageState = require("./manageState");
31
- const _notify = require("./notify");
32
- _export_star(require("./caveats"), exports);
33
- function _export_star(from, to) {
34
- Object.keys(from).forEach(function(k) {
35
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
36
- Object.defineProperty(to, k, {
37
- enumerable: true,
38
- get: function() {
39
- return from[k];
40
- }
41
- });
42
- }
43
- });
44
- return from;
45
- }
46
- const restrictedMethodPermissionBuilders = {
47
- [_dialog.dialogBuilder.targetName]: _dialog.dialogBuilder,
48
- [_getBip32Entropy.getBip32EntropyBuilder.targetName]: _getBip32Entropy.getBip32EntropyBuilder,
49
- [_getBip32PublicKey.getBip32PublicKeyBuilder.targetName]: _getBip32PublicKey.getBip32PublicKeyBuilder,
50
- [_getBip44Entropy.getBip44EntropyBuilder.targetName]: _getBip44Entropy.getBip44EntropyBuilder,
51
- [_getEntropy.getEntropyBuilder.targetName]: _getEntropy.getEntropyBuilder,
52
- [_invokeSnap.invokeSnapBuilder.targetName]: _invokeSnap.invokeSnapBuilder,
53
- [_manageState.manageStateBuilder.targetName]: _manageState.manageStateBuilder,
54
- [_notify.notifyBuilder.targetName]: _notify.notifyBuilder,
55
- [_manageAccounts.manageAccountsBuilder.targetName]: _manageAccounts.manageAccountsBuilder,
56
- [_getLocale.getLocaleBuilder.targetName]: _getLocale.getLocaleBuilder
57
- };
58
-
59
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/restricted/index.ts"],"sourcesContent":["import type { DialogMethodHooks } from './dialog';\nimport { dialogBuilder } from './dialog';\nimport type { GetBip32EntropyMethodHooks } from './getBip32Entropy';\nimport { getBip32EntropyBuilder } from './getBip32Entropy';\nimport type { GetBip32PublicKeyMethodHooks } from './getBip32PublicKey';\nimport { getBip32PublicKeyBuilder } from './getBip32PublicKey';\nimport type { GetBip44EntropyMethodHooks } from './getBip44Entropy';\nimport { getBip44EntropyBuilder } from './getBip44Entropy';\nimport type { GetEntropyHooks } from './getEntropy';\nimport { getEntropyBuilder } from './getEntropy';\nimport type { GetLocaleMethodHooks } from './getLocale';\nimport { getLocaleBuilder } from './getLocale';\nimport type { InvokeSnapMethodHooks } from './invokeSnap';\nimport { invokeSnapBuilder } from './invokeSnap';\nimport type { ManageAccountsMethodHooks } from './manageAccounts';\nimport { manageAccountsBuilder } from './manageAccounts';\nimport type { ManageStateMethodHooks } from './manageState';\nimport { manageStateBuilder } from './manageState';\nimport type { NotifyMethodHooks } from './notify';\nimport { notifyBuilder } from './notify';\n\nexport { WALLET_SNAP_PERMISSION_KEY } from './invokeSnap';\nexport { getEncryptionKey } from './manageState';\n\nexport type RestrictedMethodHooks = DialogMethodHooks &\n GetBip32EntropyMethodHooks &\n GetBip32PublicKeyMethodHooks &\n GetBip44EntropyMethodHooks &\n GetEntropyHooks &\n InvokeSnapMethodHooks &\n ManageStateMethodHooks &\n NotifyMethodHooks &\n ManageAccountsMethodHooks &\n GetLocaleMethodHooks;\n\nexport const restrictedMethodPermissionBuilders = {\n [dialogBuilder.targetName]: dialogBuilder,\n [getBip32EntropyBuilder.targetName]: getBip32EntropyBuilder,\n [getBip32PublicKeyBuilder.targetName]: getBip32PublicKeyBuilder,\n [getBip44EntropyBuilder.targetName]: getBip44EntropyBuilder,\n [getEntropyBuilder.targetName]: getEntropyBuilder,\n [invokeSnapBuilder.targetName]: invokeSnapBuilder,\n [manageStateBuilder.targetName]: manageStateBuilder,\n [notifyBuilder.targetName]: notifyBuilder,\n [manageAccountsBuilder.targetName]: manageAccountsBuilder,\n [getLocaleBuilder.targetName]: getLocaleBuilder,\n} as const;\n\nexport * from './caveats';\n"],"names":["WALLET_SNAP_PERMISSION_KEY","getEncryptionKey","restrictedMethodPermissionBuilders","dialogBuilder","targetName","getBip32EntropyBuilder","getBip32PublicKeyBuilder","getBip44EntropyBuilder","getEntropyBuilder","invokeSnapBuilder","manageStateBuilder","notifyBuilder","manageAccountsBuilder","getLocaleBuilder"],"mappings":";;;;;;;;;;;IAqBSA,0BAA0B;eAA1BA,sCAA0B;;IAC1BC,gBAAgB;eAAhBA,6BAAgB;;IAaZC,kCAAkC;eAAlCA;;;wBAlCiB;iCAES;mCAEE;iCAEF;4BAEL;2BAED;4BAEC;gCAEI;6BAEH;wBAEL;qBA6BhB;;;;;;;;;;;;;;AAbP,MAAMA,qCAAqC;IAChD,CAACC,qBAAa,CAACC,UAAU,CAAC,EAAED,qBAAa;IACzC,CAACE,uCAAsB,CAACD,UAAU,CAAC,EAAEC,uCAAsB;IAC3D,CAACC,2CAAwB,CAACF,UAAU,CAAC,EAAEE,2CAAwB;IAC/D,CAACC,uCAAsB,CAACH,UAAU,CAAC,EAAEG,uCAAsB;IAC3D,CAACC,6BAAiB,CAACJ,UAAU,CAAC,EAAEI,6BAAiB;IACjD,CAACC,6BAAiB,CAACL,UAAU,CAAC,EAAEK,6BAAiB;IACjD,CAACC,+BAAkB,CAACN,UAAU,CAAC,EAAEM,+BAAkB;IACnD,CAACC,qBAAa,CAACP,UAAU,CAAC,EAAEO,qBAAa;IACzC,CAACC,qCAAqB,CAACR,UAAU,CAAC,EAAEQ,qCAAqB;IACzD,CAACC,2BAAgB,CAACT,UAAU,CAAC,EAAES,2BAAgB;AACjD"}
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- WALLET_SNAP_PERMISSION_KEY: function() {
13
- return WALLET_SNAP_PERMISSION_KEY;
14
- },
15
- handleSnapInstall: function() {
16
- return handleSnapInstall;
17
- },
18
- invokeSnapBuilder: function() {
19
- return invokeSnapBuilder;
20
- },
21
- getInvokeSnapImplementation: function() {
22
- return getInvokeSnapImplementation;
23
- }
24
- });
25
- const _permissioncontroller = require("@metamask/permission-controller");
26
- const _rpcerrors = require("@metamask/rpc-errors");
27
- const _snapsutils = require("@metamask/snaps-utils");
28
- const WALLET_SNAP_PERMISSION_KEY = 'wallet_snap';
29
- const handleSnapInstall = async ({ requestData, messagingSystem })=>{
30
- const snaps = requestData.permissions[WALLET_SNAP_PERMISSION_KEY].caveats?.[0].value;
31
- const permittedSnaps = messagingSystem.call(`SnapController:getPermitted`, requestData.metadata.origin);
32
- const dedupedSnaps = Object.keys(snaps).reduce((filteredSnaps, snap)=>{
33
- if (!permittedSnaps[snap]) {
34
- filteredSnaps[snap] = snaps[snap];
35
- }
36
- return filteredSnaps;
37
- }, {});
38
- return messagingSystem.call(`SnapController:install`, requestData.metadata.origin, dedupedSnaps);
39
- };
40
- /**
41
- * The specification builder for the `wallet_snap_*` permission.
42
- *
43
- * `wallet_snap_*` attempts to invoke an RPC method of the specified Snap.
44
- *
45
- * Requesting its corresponding permission will attempt to connect to the Snap,
46
- * and install it if it's not available yet.
47
- *
48
- * @param options - The specification builder options.
49
- * @param options.methodHooks - The RPC method hooks needed by the method implementation.
50
- * @returns The specification for the `wallet_snap_*` permission.
51
- */ const specificationBuilder = ({ methodHooks })=>{
52
- return {
53
- permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
54
- targetName: WALLET_SNAP_PERMISSION_KEY,
55
- allowedCaveats: [
56
- _snapsutils.SnapCaveatType.SnapIds
57
- ],
58
- methodImplementation: getInvokeSnapImplementation(methodHooks),
59
- validator: ({ caveats })=>{
60
- if (caveats?.length !== 1 || caveats[0].type !== _snapsutils.SnapCaveatType.SnapIds) {
61
- throw _rpcerrors.rpcErrors.invalidParams({
62
- message: `Expected a single "${_snapsutils.SnapCaveatType.SnapIds}" caveat.`
63
- });
64
- }
65
- },
66
- sideEffect: {
67
- onPermitted: handleSnapInstall
68
- }
69
- };
70
- };
71
- const methodHooks = {
72
- getSnap: true,
73
- handleSnapRpcRequest: true
74
- };
75
- const invokeSnapBuilder = Object.freeze({
76
- targetName: WALLET_SNAP_PERMISSION_KEY,
77
- specificationBuilder,
78
- methodHooks
79
- });
80
- function getInvokeSnapImplementation({ getSnap, handleSnapRpcRequest }) {
81
- return async function invokeSnap(options) {
82
- const { params = {}, context } = options;
83
- const { snapId, request } = params;
84
- if (!getSnap(snapId)) {
85
- throw _rpcerrors.rpcErrors.invalidRequest({
86
- message: `The snap "${snapId}" is not installed. Please install it first, before invoking the snap.`
87
- });
88
- }
89
- const { origin } = context;
90
- return await handleSnapRpcRequest({
91
- snapId,
92
- origin,
93
- request,
94
- handler: _snapsutils.HandlerType.OnRpcRequest
95
- });
96
- };
97
- }
98
-
99
- //# sourceMappingURL=invokeSnap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/restricted/invokeSnap.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n PermissionValidatorConstraint,\n PermissionSideEffect,\n} from '@metamask/permission-controller';\nimport { PermissionType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n InvokeSnapResult,\n RequestSnapsParams,\n RequestSnapsResult,\n} from '@metamask/snaps-sdk';\nimport type { Snap, SnapRpcHookArgs } from '@metamask/snaps-utils';\nimport { HandlerType, SnapCaveatType } from '@metamask/snaps-utils';\nimport type { Json, NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nexport const WALLET_SNAP_PERMISSION_KEY = 'wallet_snap';\n\n// Redeclare installSnaps action type to avoid circular dependencies\nexport type InstallSnaps = {\n type: `SnapController:install`;\n handler: (\n origin: string,\n requestedSnaps: RequestSnapsParams,\n ) => Promise<RequestSnapsResult>;\n};\n\nexport type GetPermittedSnaps = {\n type: `SnapController:getPermitted`;\n handler: (origin: string) => RequestSnapsResult;\n};\n\ntype AllowedActions = InstallSnaps | GetPermittedSnaps;\n\nexport type InvokeSnapMethodHooks = {\n getSnap: (snapId: string) => Snap | undefined;\n handleSnapRpcRequest: ({\n snapId,\n origin,\n handler,\n request,\n }: SnapRpcHookArgs & { snapId: string }) => Promise<unknown>;\n};\n\ntype InvokeSnapSpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: InvokeSnapMethodHooks;\n};\n\ntype InvokeSnapSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof WALLET_SNAP_PERMISSION_KEY;\n methodImplementation: ReturnType<typeof getInvokeSnapImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n sideEffect: {\n onPermitted: PermissionSideEffect<AllowedActions, never>['onPermitted'];\n };\n}>;\n\nexport type InvokeSnapParams = {\n snapId: string;\n request: Record<string, Json>;\n};\n\n/**\n * The side-effect method to handle the snap install.\n *\n * @param params - The side-effect params.\n * @param params.requestData - The request data associated to the requested permission.\n * @param params.messagingSystem - The messenger to call an action.\n */\nexport const handleSnapInstall: PermissionSideEffect<\n AllowedActions,\n never\n>['onPermitted'] = async ({ requestData, messagingSystem }) => {\n const snaps = requestData.permissions[WALLET_SNAP_PERMISSION_KEY].caveats?.[0]\n .value as RequestSnapsParams;\n\n const permittedSnaps = messagingSystem.call(\n `SnapController:getPermitted`,\n requestData.metadata.origin,\n );\n\n const dedupedSnaps = Object.keys(snaps).reduce<RequestSnapsParams>(\n (filteredSnaps, snap) => {\n if (!permittedSnaps[snap]) {\n filteredSnaps[snap] = snaps[snap];\n }\n return filteredSnaps;\n },\n {},\n );\n\n return messagingSystem.call(\n `SnapController:install`,\n requestData.metadata.origin,\n dedupedSnaps,\n );\n};\n/**\n * The specification builder for the `wallet_snap_*` permission.\n *\n * `wallet_snap_*` attempts to invoke an RPC method of the specified Snap.\n *\n * Requesting its corresponding permission will attempt to connect to the Snap,\n * and install it if it's not available yet.\n *\n * @param options - The specification builder options.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `wallet_snap_*` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n InvokeSnapSpecificationBuilderOptions,\n InvokeSnapSpecification\n> = ({ methodHooks }: InvokeSnapSpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: WALLET_SNAP_PERMISSION_KEY,\n allowedCaveats: [SnapCaveatType.SnapIds],\n methodImplementation: getInvokeSnapImplementation(methodHooks),\n validator: ({ caveats }) => {\n if (caveats?.length !== 1 || caveats[0].type !== SnapCaveatType.SnapIds) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.SnapIds}\" caveat.`,\n });\n }\n },\n sideEffect: {\n onPermitted: handleSnapInstall,\n },\n };\n};\n\nconst methodHooks: MethodHooksObject<InvokeSnapMethodHooks> = {\n getSnap: true,\n handleSnapRpcRequest: true,\n};\n\nexport const invokeSnapBuilder = Object.freeze({\n targetName: WALLET_SNAP_PERMISSION_KEY,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `wallet_snap_*`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getSnap - A function that retrieves all information stored about a snap.\n * @param hooks.handleSnapRpcRequest - A function that sends an RPC request to a snap's RPC handler or throws if that fails.\n * @returns The method implementation which returns the result of `handleSnapRpcRequest`.\n * @throws If the params are invalid.\n */\nexport function getInvokeSnapImplementation({\n getSnap,\n handleSnapRpcRequest,\n}: InvokeSnapMethodHooks) {\n return async function invokeSnap(\n options: RestrictedMethodOptions<InvokeSnapParams>,\n ): Promise<InvokeSnapResult> {\n const { params = {}, context } = options;\n\n const { snapId, request } = params as InvokeSnapParams;\n\n if (!getSnap(snapId)) {\n throw rpcErrors.invalidRequest({\n message: `The snap \"${snapId}\" is not installed. Please install it first, before invoking the snap.`,\n });\n }\n\n const { origin } = context;\n\n return (await handleSnapRpcRequest({\n snapId,\n origin,\n request,\n handler: HandlerType.OnRpcRequest,\n })) as Json;\n };\n}\n"],"names":["WALLET_SNAP_PERMISSION_KEY","handleSnapInstall","invokeSnapBuilder","getInvokeSnapImplementation","requestData","messagingSystem","snaps","permissions","caveats","value","permittedSnaps","call","metadata","origin","dedupedSnaps","Object","keys","reduce","filteredSnaps","snap","specificationBuilder","methodHooks","permissionType","PermissionType","RestrictedMethod","targetName","allowedCaveats","SnapCaveatType","SnapIds","methodImplementation","validator","length","type","rpcErrors","invalidParams","message","sideEffect","onPermitted","getSnap","handleSnapRpcRequest","freeze","invokeSnap","options","params","context","snapId","request","invalidRequest","handler","HandlerType","OnRpcRequest"],"mappings":";;;;;;;;;;;IAoBaA,0BAA0B;eAA1BA;;IAwDAC,iBAAiB;eAAjBA;;IAoEAC,iBAAiB;eAAjBA;;IAeGC,2BAA2B;eAA3BA;;;sCAxJe;2BACL;4BAOkB;AAKrC,MAAMH,6BAA6B;AAwDnC,MAAMC,oBAGM,OAAO,EAAEG,WAAW,EAAEC,eAAe,EAAE;IACxD,MAAMC,QAAQF,YAAYG,WAAW,CAACP,2BAA2B,CAACQ,OAAO,EAAE,CAAC,EAAE,CAC3EC;IAEH,MAAMC,iBAAiBL,gBAAgBM,IAAI,CACzC,CAAC,2BAA2B,CAAC,EAC7BP,YAAYQ,QAAQ,CAACC,MAAM;IAG7B,MAAMC,eAAeC,OAAOC,IAAI,CAACV,OAAOW,MAAM,CAC5C,CAACC,eAAeC;QACd,IAAI,CAACT,cAAc,CAACS,KAAK,EAAE;YACzBD,aAAa,CAACC,KAAK,GAAGb,KAAK,CAACa,KAAK;QACnC;QACA,OAAOD;IACT,GACA,CAAC;IAGH,OAAOb,gBAAgBM,IAAI,CACzB,CAAC,sBAAsB,CAAC,EACxBP,YAAYQ,QAAQ,CAACC,MAAM,EAC3BC;AAEJ;AACA;;;;;;;;;;;CAWC,GACD,MAAMM,uBAIF,CAAC,EAAEC,WAAW,EAAyC;IACzD,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CC,YAAYzB;QACZ0B,gBAAgB;YAACC,0BAAc,CAACC,OAAO;SAAC;QACxCC,sBAAsB1B,4BAA4BkB;QAClDS,WAAW,CAAC,EAAEtB,OAAO,EAAE;YACrB,IAAIA,SAASuB,WAAW,KAAKvB,OAAO,CAAC,EAAE,CAACwB,IAAI,KAAKL,0BAAc,CAACC,OAAO,EAAE;gBACvE,MAAMK,oBAAS,CAACC,aAAa,CAAC;oBAC5BC,SAAS,CAAC,mBAAmB,EAAER,0BAAc,CAACC,OAAO,CAAC,SAAS,CAAC;gBAClE;YACF;QACF;QACAQ,YAAY;YACVC,aAAapC;QACf;IACF;AACF;AAEA,MAAMoB,cAAwD;IAC5DiB,SAAS;IACTC,sBAAsB;AACxB;AAEO,MAAMrC,oBAAoBa,OAAOyB,MAAM,CAAC;IAC7Cf,YAAYzB;IACZoB;IACAC;AACF;AAWO,SAASlB,4BAA4B,EAC1CmC,OAAO,EACPC,oBAAoB,EACE;IACtB,OAAO,eAAeE,WACpBC,OAAkD;QAElD,MAAM,EAAEC,SAAS,CAAC,CAAC,EAAEC,OAAO,EAAE,GAAGF;QAEjC,MAAM,EAAEG,MAAM,EAAEC,OAAO,EAAE,GAAGH;QAE5B,IAAI,CAACL,QAAQO,SAAS;YACpB,MAAMZ,oBAAS,CAACc,cAAc,CAAC;gBAC7BZ,SAAS,CAAC,UAAU,EAAEU,OAAO,sEAAsE,CAAC;YACtG;QACF;QAEA,MAAM,EAAEhC,MAAM,EAAE,GAAG+B;QAEnB,OAAQ,MAAML,qBAAqB;YACjCM;YACAhC;YACAiC;YACAE,SAASC,uBAAW,CAACC,YAAY;QACnC;IACF;AACF"}
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- methodName: function() {
13
- return methodName;
14
- },
15
- specificationBuilder: function() {
16
- return specificationBuilder;
17
- },
18
- manageAccountsImplementation: function() {
19
- return manageAccountsImplementation;
20
- },
21
- manageAccountsBuilder: function() {
22
- return manageAccountsBuilder;
23
- }
24
- });
25
- const _permissioncontroller = require("@metamask/permission-controller");
26
- const _utils = require("@metamask/utils");
27
- const _superstruct = require("superstruct");
28
- const SnapMessageStruct = (0, _superstruct.union)([
29
- (0, _superstruct.object)({
30
- method: (0, _superstruct.string)()
31
- }),
32
- (0, _superstruct.object)({
33
- method: (0, _superstruct.string)(),
34
- params: (0, _superstruct.union)([
35
- (0, _superstruct.array)(_utils.JsonStruct),
36
- (0, _superstruct.record)((0, _superstruct.string)(), _utils.JsonStruct)
37
- ])
38
- })
39
- ]);
40
- const methodName = 'snap_manageAccounts';
41
- const specificationBuilder = ({ allowedCaveats = null, methodHooks })=>{
42
- return {
43
- permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
44
- targetName: methodName,
45
- allowedCaveats,
46
- methodImplementation: manageAccountsImplementation(methodHooks),
47
- subjectTypes: [
48
- _permissioncontroller.SubjectType.Snap
49
- ]
50
- };
51
- };
52
- function manageAccountsImplementation({ getSnapKeyring }) {
53
- return async function manageAccounts(options) {
54
- const { context: { origin }, params } = options;
55
- (0, _superstruct.assert)(params, SnapMessageStruct);
56
- const keyring = await getSnapKeyring(origin);
57
- return await keyring.handleKeyringSnapMessage(origin, params);
58
- };
59
- }
60
- const manageAccountsBuilder = Object.freeze({
61
- targetName: methodName,
62
- specificationBuilder,
63
- methodHooks: {
64
- getSnapKeyring: true
65
- }
66
- });
67
-
68
- //# sourceMappingURL=manageAccounts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/restricted/manageAccounts.ts"],"sourcesContent":["import type {\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n PermissionSpecificationBuilder,\n} from '@metamask/permission-controller';\nimport { SubjectType, PermissionType } from '@metamask/permission-controller';\nimport type {\n ManageAccountsParams,\n ManageAccountsResult,\n} from '@metamask/snaps-sdk';\nimport type { InferMatching } from '@metamask/snaps-utils';\nimport type { Json, NonEmptyArray } from '@metamask/utils';\nimport { JsonStruct } from '@metamask/utils';\nimport { assert, string, object, union, array, record } from 'superstruct';\n\nconst SnapMessageStruct = union([\n object({\n method: string(),\n }),\n object({\n method: string(),\n params: union([array(JsonStruct), record(string(), JsonStruct)]),\n }),\n]);\n\ntype Message = InferMatching<typeof SnapMessageStruct, ManageAccountsParams>;\n\nexport const methodName = 'snap_manageAccounts';\n\nexport type ManageAccountsMethodHooks = {\n /**\n * Gets the snap keyring implementation.\n */\n getSnapKeyring: (snapOrigin: string) => Promise<{\n handleKeyringSnapMessage: (\n snapId: string,\n message: Message,\n ) => Promise<Json>;\n }>;\n};\n\ntype ManageAccountsSpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: ManageAccountsMethodHooks;\n};\n\ntype ManageAccountsSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof manageAccountsImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_manageAccounts` permission.\n * `snap_manageAccounts` lets the Snap manage a set of accounts via a custom keyring.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the permission.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_manageAccounts` permission.\n */\nexport const specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n ManageAccountsSpecificationBuilderOptions,\n ManageAccountsSpecification\n> = ({\n allowedCaveats = null,\n methodHooks,\n}: ManageAccountsSpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: manageAccountsImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\n/**\n * Builds the method implementation for `snap_manageAccounts`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getSnapKeyring - A function to get the snap keyring.\n * @returns The method implementation which either returns `null` for a\n * successful state update/deletion or returns the decrypted state.\n * @throws If the params are invalid.\n */\nexport function manageAccountsImplementation({\n getSnapKeyring,\n}: ManageAccountsMethodHooks) {\n return async function manageAccounts(\n options: RestrictedMethodOptions<ManageAccountsParams>,\n ): Promise<ManageAccountsResult> {\n const {\n context: { origin },\n params,\n } = options;\n\n assert(params, SnapMessageStruct);\n const keyring = await getSnapKeyring(origin);\n return await keyring.handleKeyringSnapMessage(origin, params);\n };\n}\n\nexport const manageAccountsBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks: {\n getSnapKeyring: true,\n },\n} as const);\n"],"names":["methodName","specificationBuilder","manageAccountsImplementation","manageAccountsBuilder","SnapMessageStruct","union","object","method","string","params","array","JsonStruct","record","allowedCaveats","methodHooks","permissionType","PermissionType","RestrictedMethod","targetName","methodImplementation","subjectTypes","SubjectType","Snap","getSnapKeyring","manageAccounts","options","context","origin","assert","keyring","handleKeyringSnapMessage","Object","freeze"],"mappings":";;;;;;;;;;;IA2BaA,UAAU;eAAVA;;IAmCAC,oBAAoB;eAApBA;;IA0BGC,4BAA4B;eAA5BA;;IAiBHC,qBAAqB;eAArBA;;;sCApG+B;uBAOjB;6BACkC;AAE7D,MAAMC,oBAAoBC,IAAAA,kBAAK,EAAC;IAC9BC,IAAAA,mBAAM,EAAC;QACLC,QAAQC,IAAAA,mBAAM;IAChB;IACAF,IAAAA,mBAAM,EAAC;QACLC,QAAQC,IAAAA,mBAAM;QACdC,QAAQJ,IAAAA,kBAAK,EAAC;YAACK,IAAAA,kBAAK,EAACC,iBAAU;YAAGC,IAAAA,mBAAM,EAACJ,IAAAA,mBAAM,KAAIG,iBAAU;SAAE;IACjE;CACD;AAIM,MAAMX,aAAa;AAmCnB,MAAMC,uBAIT,CAAC,EACHY,iBAAiB,IAAI,EACrBC,WAAW,EAC+B;IAC1C,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CC,YAAYlB;QACZa;QACAM,sBAAsBjB,6BAA6BY;QACnDM,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAWO,SAASpB,6BAA6B,EAC3CqB,cAAc,EACY;IAC1B,OAAO,eAAeC,eACpBC,OAAsD;QAEtD,MAAM,EACJC,SAAS,EAAEC,MAAM,EAAE,EACnBlB,MAAM,EACP,GAAGgB;QAEJG,IAAAA,mBAAM,EAACnB,QAAQL;QACf,MAAMyB,UAAU,MAAMN,eAAeI;QACrC,OAAO,MAAME,QAAQC,wBAAwB,CAACH,QAAQlB;IACxD;AACF;AAEO,MAAMN,wBAAwB4B,OAAOC,MAAM,CAAC;IACjDd,YAAYlB;IACZC;IACAa,aAAa;QACXS,gBAAgB;IAClB;AACF"}
@@ -1,208 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- STATE_ENCRYPTION_SALT: function() {
13
- return STATE_ENCRYPTION_SALT;
14
- },
15
- specificationBuilder: function() {
16
- return specificationBuilder;
17
- },
18
- manageStateBuilder: function() {
19
- return manageStateBuilder;
20
- },
21
- STORAGE_SIZE_LIMIT: function() {
22
- return STORAGE_SIZE_LIMIT;
23
- },
24
- getEncryptionKey: function() {
25
- return getEncryptionKey;
26
- },
27
- getManageStateImplementation: function() {
28
- return getManageStateImplementation;
29
- },
30
- getValidatedParams: function() {
31
- return getValidatedParams;
32
- }
33
- });
34
- const _permissioncontroller = require("@metamask/permission-controller");
35
- const _rpcerrors = require("@metamask/rpc-errors");
36
- const _snapssdk = require("@metamask/snaps-sdk");
37
- const _snapsutils = require("@metamask/snaps-utils");
38
- const _utils = require("@metamask/utils");
39
- const _utils1 = require("../utils");
40
- const STATE_ENCRYPTION_SALT = 'snap_manageState encryption';
41
- const methodName = 'snap_manageState';
42
- const specificationBuilder = ({ allowedCaveats = null, methodHooks })=>{
43
- return {
44
- permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
45
- targetName: methodName,
46
- allowedCaveats,
47
- methodImplementation: getManageStateImplementation(methodHooks),
48
- subjectTypes: [
49
- _permissioncontroller.SubjectType.Snap
50
- ]
51
- };
52
- };
53
- const methodHooks = {
54
- getMnemonic: true,
55
- getUnlockPromise: true,
56
- clearSnapState: true,
57
- getSnapState: true,
58
- updateSnapState: true,
59
- encrypt: true,
60
- decrypt: true
61
- };
62
- const manageStateBuilder = Object.freeze({
63
- targetName: methodName,
64
- specificationBuilder,
65
- methodHooks
66
- });
67
- const STORAGE_SIZE_LIMIT = 104857600; // In bytes (100MB)
68
- async function getEncryptionKey({ mnemonicPhrase, snapId }) {
69
- return await (0, _utils1.deriveEntropy)({
70
- mnemonicPhrase,
71
- input: snapId,
72
- salt: STATE_ENCRYPTION_SALT,
73
- magic: _snapsutils.STATE_ENCRYPTION_MAGIC_VALUE
74
- });
75
- }
76
- /**
77
- * Encrypt the state using a deterministic encryption algorithm, based on the
78
- * snap ID and mnemonic phrase.
79
- *
80
- * @param args - The encryption args.
81
- * @param args.state - The state to encrypt.
82
- * @param args.encryptFunction - The function to use for encrypting the state.
83
- * @param args.snapId - The ID of the snap to get the encryption key for.
84
- * @param args.mnemonicPhrase - The mnemonic phrase to derive the encryption key
85
- * from.
86
- * @returns The encrypted state.
87
- */ async function encryptState({ state, encryptFunction, ...keyArgs }) {
88
- const encryptionKey = await getEncryptionKey(keyArgs);
89
- return await encryptFunction(encryptionKey, state);
90
- }
91
- /**
92
- * Decrypt the state using a deterministic decryption algorithm, based on the
93
- * snap ID and mnemonic phrase.
94
- *
95
- * @param args - The encryption args.
96
- * @param args.state - The state to decrypt.
97
- * @param args.decryptFunction - The function to use for decrypting the state.
98
- * @param args.snapId - The ID of the snap to get the encryption key for.
99
- * @param args.mnemonicPhrase - The mnemonic phrase to derive the encryption key
100
- * from.
101
- * @returns The encrypted state.
102
- */ async function decryptState({ state, decryptFunction, ...keyArgs }) {
103
- try {
104
- const encryptionKey = await getEncryptionKey(keyArgs);
105
- const decryptedState = await decryptFunction(encryptionKey, state);
106
- (0, _utils.assert)((0, _utils.isValidJson)(decryptedState));
107
- return decryptedState;
108
- } catch {
109
- throw _rpcerrors.rpcErrors.internal({
110
- message: 'Failed to decrypt snap state, the state must be corrupted.'
111
- });
112
- }
113
- }
114
- function getManageStateImplementation({ getMnemonic, getUnlockPromise, clearSnapState, getSnapState, updateSnapState, encrypt, decrypt }) {
115
- return async function manageState(options) {
116
- const { params = {}, method, context: { origin } } = options;
117
- const validatedParams = getValidatedParams(params, method);
118
- // If the encrypted param is undefined or null we default to true.
119
- const shouldEncrypt = validatedParams.encrypted ?? true;
120
- // We only need to prompt the user when the mnemonic is needed
121
- // which it isn't for the clear operation or unencrypted storage.
122
- if (shouldEncrypt && validatedParams.operation !== _snapssdk.ManageStateOperation.ClearState) {
123
- await getUnlockPromise(true);
124
- }
125
- switch(validatedParams.operation){
126
- case _snapssdk.ManageStateOperation.ClearState:
127
- clearSnapState(origin, shouldEncrypt);
128
- return null;
129
- case _snapssdk.ManageStateOperation.GetState:
130
- {
131
- const state = getSnapState(origin, shouldEncrypt);
132
- if (state === null) {
133
- return state;
134
- }
135
- return shouldEncrypt ? await decryptState({
136
- state,
137
- decryptFunction: decrypt,
138
- mnemonicPhrase: await getMnemonic(),
139
- snapId: origin
140
- }) : (0, _snapsutils.parseJson)(state);
141
- }
142
- case _snapssdk.ManageStateOperation.UpdateState:
143
- {
144
- const finalizedState = shouldEncrypt ? await encryptState({
145
- state: validatedParams.newState,
146
- encryptFunction: encrypt,
147
- mnemonicPhrase: await getMnemonic(),
148
- snapId: origin
149
- }) : JSON.stringify(validatedParams.newState);
150
- updateSnapState(origin, finalizedState, shouldEncrypt);
151
- return null;
152
- }
153
- default:
154
- throw _rpcerrors.rpcErrors.invalidParams(`Invalid ${method} operation: "${validatedParams.operation}"`);
155
- }
156
- };
157
- }
158
- function getValidatedParams(params, method, storageSizeLimit = STORAGE_SIZE_LIMIT) {
159
- if (!(0, _utils.isObject)(params)) {
160
- throw _rpcerrors.rpcErrors.invalidParams({
161
- message: 'Expected params to be a single object.'
162
- });
163
- }
164
- const { operation, newState, encrypted } = params;
165
- if (!operation || typeof operation !== 'string' || !Object.values(_snapssdk.ManageStateOperation).includes(operation)) {
166
- throw _rpcerrors.rpcErrors.invalidParams({
167
- message: 'Must specify a valid manage state "operation".'
168
- });
169
- }
170
- if (encrypted !== undefined && typeof encrypted !== 'boolean') {
171
- throw _rpcerrors.rpcErrors.invalidParams({
172
- message: '"encrypted" parameter must be a boolean if specified.'
173
- });
174
- }
175
- if (operation === _snapssdk.ManageStateOperation.UpdateState) {
176
- if (!(0, _utils.isObject)(newState)) {
177
- throw _rpcerrors.rpcErrors.invalidParams({
178
- message: `Invalid ${method} "updateState" parameter: The new state must be a plain object.`,
179
- data: {
180
- receivedNewState: typeof newState === 'undefined' ? 'undefined' : newState
181
- }
182
- });
183
- }
184
- let size;
185
- try {
186
- // `getJsonSize` will throw if the state is not JSON serializable.
187
- size = (0, _utils.getJsonSize)(newState);
188
- } catch {
189
- throw _rpcerrors.rpcErrors.invalidParams({
190
- message: `Invalid ${method} "updateState" parameter: The new state must be JSON serializable.`,
191
- data: {
192
- receivedNewState: typeof newState === 'undefined' ? 'undefined' : newState
193
- }
194
- });
195
- }
196
- if (size > storageSizeLimit) {
197
- throw _rpcerrors.rpcErrors.invalidParams({
198
- message: `Invalid ${method} "updateState" parameter: The new state must not exceed ${storageSizeLimit} bytes in size.`,
199
- data: {
200
- receivedNewState: typeof newState === 'undefined' ? 'undefined' : newState
201
- }
202
- });
203
- }
204
- }
205
- return params;
206
- }
207
-
208
- //# sourceMappingURL=manageState.js.map