@metamask/snaps-rpc-methods 6.0.0 → 7.0.1

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 +13 -2
  2. package/dist/chunk-23XDKQW2.mjs +73 -0
  3. package/dist/chunk-23XDKQW2.mjs.map +1 -0
  4. package/dist/chunk-2KTJCF3C.js +68 -0
  5. package/dist/chunk-2KTJCF3C.js.map +1 -0
  6. package/dist/chunk-3DHVA2FY.js +21 -0
  7. package/dist/chunk-3DHVA2FY.js.map +1 -0
  8. package/dist/chunk-3LPBU737.js +43 -0
  9. package/dist/chunk-3LPBU737.js.map +1 -0
  10. package/dist/chunk-3S7DJI4I.mjs +49 -0
  11. package/dist/chunk-3S7DJI4I.mjs.map +1 -0
  12. package/dist/chunk-3UAWEHMF.js +18 -0
  13. package/dist/chunk-3UAWEHMF.js.map +1 -0
  14. package/dist/chunk-4D2B2UQ6.mjs +23 -0
  15. package/dist/chunk-4D2B2UQ6.mjs.map +1 -0
  16. package/dist/chunk-4LSOS7SM.js +23 -0
  17. package/dist/chunk-4LSOS7SM.js.map +1 -0
  18. package/dist/chunk-4SQWLI2S.mjs +151 -0
  19. package/dist/chunk-4SQWLI2S.mjs.map +1 -0
  20. package/dist/chunk-4W7U4OH6.js +42 -0
  21. package/dist/chunk-4W7U4OH6.js.map +1 -0
  22. package/dist/chunk-62URQ5VS.mjs +18 -0
  23. package/dist/chunk-62URQ5VS.mjs.map +1 -0
  24. package/dist/chunk-6TKD32TS.js +78 -0
  25. package/dist/chunk-6TKD32TS.js.map +1 -0
  26. package/dist/chunk-6UY23OOZ.js +39 -0
  27. package/dist/chunk-6UY23OOZ.js.map +1 -0
  28. package/dist/chunk-6WUIFFMQ.mjs +78 -0
  29. package/dist/chunk-6WUIFFMQ.mjs.map +1 -0
  30. package/dist/chunk-7NBRKDKJ.mjs +188 -0
  31. package/dist/chunk-7NBRKDKJ.mjs.map +1 -0
  32. package/dist/chunk-7OMVZR5X.mjs +39 -0
  33. package/dist/chunk-7OMVZR5X.mjs.map +1 -0
  34. package/dist/chunk-7TVJV425.js +1 -0
  35. package/dist/chunk-7TVJV425.js.map +1 -0
  36. package/dist/chunk-ADXH5C3U.mjs +119 -0
  37. package/dist/chunk-ADXH5C3U.mjs.map +1 -0
  38. package/dist/chunk-AKRFLGOS.mjs +59 -0
  39. package/dist/chunk-AKRFLGOS.mjs.map +1 -0
  40. package/dist/chunk-AOWUGDER.js +78 -0
  41. package/dist/chunk-AOWUGDER.js.map +1 -0
  42. package/dist/chunk-AWQ6HTAL.mjs +75 -0
  43. package/dist/chunk-AWQ6HTAL.mjs.map +1 -0
  44. package/dist/chunk-AYJK7MSH.js +43 -0
  45. package/dist/chunk-AYJK7MSH.js.map +1 -0
  46. package/dist/chunk-B3NIHNXW.js +23 -0
  47. package/dist/{cjs/endowments/ethereum-provider.js.map → chunk-B3NIHNXW.js.map} +1 -1
  48. package/dist/chunk-C6E6DI4I.mjs +115 -0
  49. package/dist/chunk-C6E6DI4I.mjs.map +1 -0
  50. package/dist/chunk-CD4OUHO5.mjs +20 -0
  51. package/dist/chunk-CD4OUHO5.mjs.map +1 -0
  52. package/dist/chunk-CH5O2YCX.mjs +18 -0
  53. package/dist/chunk-CH5O2YCX.mjs.map +1 -0
  54. package/dist/chunk-CVK2TYJX.mjs +54 -0
  55. package/dist/chunk-CVK2TYJX.mjs.map +1 -0
  56. package/dist/chunk-D6MUXDVI.js +51 -0
  57. package/dist/chunk-D6MUXDVI.js.map +1 -0
  58. package/dist/chunk-E6WUMFQT.mjs +54 -0
  59. package/dist/chunk-E6WUMFQT.mjs.map +1 -0
  60. package/dist/chunk-EEVEVBK6.mjs +78 -0
  61. package/dist/chunk-EEVEVBK6.mjs.map +1 -0
  62. package/dist/chunk-EKXDFYIX.mjs +68 -0
  63. package/dist/chunk-EKXDFYIX.mjs.map +1 -0
  64. package/dist/chunk-FBOZCV3C.js +59 -0
  65. package/dist/chunk-FBOZCV3C.js.map +1 -0
  66. package/dist/chunk-FCVWU5XH.js +73 -0
  67. package/dist/chunk-FCVWU5XH.js.map +1 -0
  68. package/dist/chunk-FFHVA6PP.js +82 -0
  69. package/dist/chunk-FFHVA6PP.js.map +1 -0
  70. package/dist/chunk-FMDV3RFT.js +21 -0
  71. package/dist/chunk-FMDV3RFT.js.map +1 -0
  72. package/dist/chunk-GP5KW5FU.js +45 -0
  73. package/dist/chunk-GP5KW5FU.js.map +1 -0
  74. package/dist/chunk-GYZV5UBD.js +151 -0
  75. package/dist/chunk-GYZV5UBD.js.map +1 -0
  76. package/dist/chunk-I6FU5MGE.mjs +47 -0
  77. package/dist/chunk-I6FU5MGE.mjs.map +1 -0
  78. package/dist/chunk-IBV23QOX.mjs +67 -0
  79. package/dist/chunk-IBV23QOX.mjs.map +1 -0
  80. package/dist/chunk-IDZGMGIB.js +45 -0
  81. package/dist/chunk-IDZGMGIB.js.map +1 -0
  82. package/dist/chunk-IEUCBULU.js +119 -0
  83. package/dist/chunk-IEUCBULU.js.map +1 -0
  84. package/dist/chunk-IZYMBIBD.mjs +32 -0
  85. package/dist/chunk-IZYMBIBD.mjs.map +1 -0
  86. package/dist/chunk-JQ456NCC.mjs +51 -0
  87. package/dist/chunk-JQ456NCC.mjs.map +1 -0
  88. package/dist/chunk-JRSPKOFG.js +115 -0
  89. package/dist/chunk-JRSPKOFG.js.map +1 -0
  90. package/dist/chunk-JWDQUKKU.mjs +80 -0
  91. package/dist/chunk-JWDQUKKU.mjs.map +1 -0
  92. package/dist/chunk-KO4MKRYZ.js +188 -0
  93. package/dist/chunk-KO4MKRYZ.js.map +1 -0
  94. package/dist/chunk-KSTF5JYB.mjs +23 -0
  95. package/dist/chunk-KSTF5JYB.mjs.map +1 -0
  96. package/dist/chunk-LGUJMQC7.js +78 -0
  97. package/dist/{cjs/restricted/getBip32PublicKey.js.map → chunk-LGUJMQC7.js.map} +1 -1
  98. package/dist/chunk-LIWV3FMY.js +69 -0
  99. package/dist/chunk-LIWV3FMY.js.map +1 -0
  100. package/dist/chunk-LR7UR4YU.mjs +52 -0
  101. package/dist/chunk-LR7UR4YU.mjs.map +1 -0
  102. package/dist/chunk-LVTN25J2.js +49 -0
  103. package/dist/chunk-LVTN25J2.js.map +1 -0
  104. package/dist/chunk-MVG4B2HM.mjs +21 -0
  105. package/dist/chunk-MVG4B2HM.mjs.map +1 -0
  106. package/dist/chunk-MXCJWR45.mjs +45 -0
  107. package/dist/chunk-MXCJWR45.mjs.map +1 -0
  108. package/dist/chunk-MXPVC2XP.mjs +105 -0
  109. package/dist/chunk-MXPVC2XP.mjs.map +1 -0
  110. package/dist/chunk-NP3KGMVC.js +47 -0
  111. package/dist/chunk-NP3KGMVC.js.map +1 -0
  112. package/dist/chunk-NU4NAAFG.js +1 -0
  113. package/dist/chunk-NU4NAAFG.js.map +1 -0
  114. package/dist/chunk-NWT2EXFD.js +18 -0
  115. package/dist/chunk-NWT2EXFD.js.map +1 -0
  116. package/dist/chunk-O66NZFSD.mjs +23 -0
  117. package/dist/chunk-O66NZFSD.mjs.map +1 -0
  118. package/dist/chunk-OQOTJFFV.js +74 -0
  119. package/dist/chunk-OQOTJFFV.js.map +1 -0
  120. package/dist/chunk-P74WXDY4.js +54 -0
  121. package/dist/chunk-P74WXDY4.js.map +1 -0
  122. package/dist/chunk-PCB6QOHL.mjs +21 -0
  123. package/dist/chunk-PCB6QOHL.mjs.map +1 -0
  124. package/dist/chunk-PS6OEQXL.js +105 -0
  125. package/dist/chunk-PS6OEQXL.js.map +1 -0
  126. package/dist/chunk-PWUEAR4H.js +70 -0
  127. package/dist/chunk-PWUEAR4H.js.map +1 -0
  128. package/dist/chunk-Q27K2I6Z.js +23 -0
  129. package/dist/{cjs/endowments/web-assembly.js.map → chunk-Q27K2I6Z.js.map} +1 -1
  130. package/dist/chunk-Q5W3YGEB.js +67 -0
  131. package/dist/chunk-Q5W3YGEB.js.map +1 -0
  132. package/dist/chunk-QDZAWH6F.js +80 -0
  133. package/dist/chunk-QDZAWH6F.js.map +1 -0
  134. package/dist/chunk-QMULJEYN.js +35 -0
  135. package/dist/chunk-QMULJEYN.js.map +1 -0
  136. package/dist/chunk-S7AR3ROH.js +57 -0
  137. package/dist/chunk-S7AR3ROH.js.map +1 -0
  138. package/dist/chunk-SGQXD5K7.mjs +83 -0
  139. package/dist/chunk-SGQXD5K7.mjs.map +1 -0
  140. package/dist/chunk-SYUGPLEP.js +32 -0
  141. package/dist/chunk-SYUGPLEP.js.map +1 -0
  142. package/dist/chunk-TEXEQGNZ.js +75 -0
  143. package/dist/chunk-TEXEQGNZ.js.map +1 -0
  144. package/dist/chunk-TG63GBK3.mjs +1 -0
  145. package/dist/chunk-TG63GBK3.mjs.map +1 -0
  146. package/dist/chunk-TJYMYQAB.mjs +42 -0
  147. package/dist/chunk-TJYMYQAB.mjs.map +1 -0
  148. package/dist/chunk-TKXU7ZXP.mjs +78 -0
  149. package/dist/chunk-TKXU7ZXP.mjs.map +1 -0
  150. package/dist/chunk-TNENASGX.mjs +1 -0
  151. package/dist/chunk-TNENASGX.mjs.map +1 -0
  152. package/dist/chunk-TNRH2LRU.mjs +57 -0
  153. package/dist/chunk-TNRH2LRU.mjs.map +1 -0
  154. package/dist/chunk-TOYWHUAS.mjs +70 -0
  155. package/dist/chunk-TOYWHUAS.mjs.map +1 -0
  156. package/dist/chunk-TT4DP2YW.mjs +35 -0
  157. package/dist/chunk-TT4DP2YW.mjs.map +1 -0
  158. package/dist/chunk-UB3733UY.mjs +23 -0
  159. package/dist/chunk-UB3733UY.mjs.map +1 -0
  160. package/dist/chunk-UBPHGXCO.mjs +74 -0
  161. package/dist/chunk-UBPHGXCO.mjs.map +1 -0
  162. package/dist/chunk-VCGZNL35.mjs +69 -0
  163. package/dist/chunk-VCGZNL35.mjs.map +1 -0
  164. package/dist/chunk-VHY3NATP.js +67 -0
  165. package/dist/chunk-VHY3NATP.js.map +1 -0
  166. package/dist/chunk-VUA6ICJO.js +52 -0
  167. package/dist/chunk-VUA6ICJO.js.map +1 -0
  168. package/dist/chunk-VVBTXSID.mjs +82 -0
  169. package/dist/chunk-VVBTXSID.mjs.map +1 -0
  170. package/dist/chunk-WFAY5FPP.mjs +67 -0
  171. package/dist/chunk-WFAY5FPP.mjs.map +1 -0
  172. package/dist/chunk-WLDEPJGG.mjs +43 -0
  173. package/dist/chunk-WLDEPJGG.mjs.map +1 -0
  174. package/dist/chunk-Y4LNTDZ2.mjs +43 -0
  175. package/dist/chunk-Y4LNTDZ2.mjs.map +1 -0
  176. package/dist/chunk-YG7W4CDT.js +83 -0
  177. package/dist/{cjs/utils.js.map → chunk-YG7W4CDT.js.map} +1 -1
  178. package/dist/chunk-YGKFOOWI.js +20 -0
  179. package/dist/chunk-YGKFOOWI.js.map +1 -0
  180. package/dist/chunk-YOHE52XB.js +23 -0
  181. package/dist/chunk-YOHE52XB.js.map +1 -0
  182. package/dist/chunk-YS6TYXCP.mjs +45 -0
  183. package/dist/chunk-YS6TYXCP.mjs.map +1 -0
  184. package/dist/chunk-ZPK4THX4.js +54 -0
  185. package/dist/chunk-ZPK4THX4.js.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,67 +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
- permittedDerivationPathsCaveatMapper: function() {
13
- return permittedDerivationPathsCaveatMapper;
14
- },
15
- validateBIP32Path: function() {
16
- return validateBIP32Path;
17
- },
18
- validateBIP32CaveatPaths: function() {
19
- return validateBIP32CaveatPaths;
20
- },
21
- PermittedDerivationPathsCaveatSpecification: function() {
22
- return PermittedDerivationPathsCaveatSpecification;
23
- }
24
- });
25
- const _rpcerrors = require("@metamask/rpc-errors");
26
- const _snapsutils = require("@metamask/snaps-utils");
27
- const _utils = require("@metamask/utils");
28
- const _superstruct = require("superstruct");
29
- function permittedDerivationPathsCaveatMapper(value) {
30
- return {
31
- caveats: [
32
- {
33
- type: _snapsutils.SnapCaveatType.PermittedDerivationPaths,
34
- value
35
- }
36
- ]
37
- };
38
- }
39
- function validateBIP32Path(value) {
40
- (0, _utils.assertStruct)(value, _snapsutils.Bip32EntropyStruct, 'Invalid BIP-32 entropy path definition', _rpcerrors.rpcErrors.invalidParams);
41
- }
42
- function validateBIP32CaveatPaths(caveat) {
43
- (0, _utils.assertStruct)(caveat, (0, _superstruct.type)({
44
- value: (0, _superstruct.size)((0, _superstruct.array)(_snapsutils.Bip32EntropyStruct), 1, Infinity)
45
- }), 'Invalid BIP-32 entropy caveat', _rpcerrors.rpcErrors.internal);
46
- }
47
- const PermittedDerivationPathsCaveatSpecification = {
48
- [_snapsutils.SnapCaveatType.PermittedDerivationPaths]: Object.freeze({
49
- type: _snapsutils.SnapCaveatType.PermittedDerivationPaths,
50
- decorator: (method, caveat)=>{
51
- return async (args)=>{
52
- const { params } = args;
53
- validateBIP32Path(params);
54
- const path = caveat.value.find((caveatPath)=>(0, _snapsutils.isEqual)(params.path.slice(0, caveatPath.path.length), caveatPath.path) && caveatPath.curve === params.curve);
55
- if (!path) {
56
- throw _rpcerrors.providerErrors.unauthorized({
57
- message: 'The requested path is not permitted. Allowed paths must be specified in the snap manifest.'
58
- });
59
- }
60
- return await method(args);
61
- };
62
- },
63
- validator: (caveat)=>validateBIP32CaveatPaths(caveat)
64
- })
65
- };
66
-
67
- //# sourceMappingURL=permittedDerivationPaths.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/restricted/caveats/permittedDerivationPaths.ts"],"sourcesContent":["import type {\n Caveat,\n PermissionConstraint,\n RestrictedMethodCaveatSpecificationConstraint,\n} from '@metamask/permission-controller';\nimport { providerErrors, rpcErrors } from '@metamask/rpc-errors';\nimport type { Bip32Entropy } from '@metamask/snaps-utils';\nimport {\n SnapCaveatType,\n Bip32EntropyStruct,\n isEqual,\n} from '@metamask/snaps-utils';\nimport type { Json } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\nimport { array, size, type } from 'superstruct';\n\n/**\n * Map a raw value from the `initialPermissions` to a caveat specification.\n * Note that this function does not do any validation, that's handled by the\n * PermissionsController when the permission is requested.\n *\n * @param value - The raw value from the `initialPermissions`.\n * @returns The caveat specification.\n */\nexport function permittedDerivationPathsCaveatMapper(\n value: Json,\n): Pick<PermissionConstraint, 'caveats'> {\n return {\n caveats: [\n {\n type: SnapCaveatType.PermittedDerivationPaths,\n value,\n },\n ],\n };\n}\n\n/**\n * Validate a caveat path object. The object must consist of a `path` array and\n * a `curve` string. Paths must start with `m`, and must contain at\n * least two indices. If `ed25519` is used, this checks if all the path indices\n * are hardened.\n *\n * @param value - The value to validate.\n * @throws If the value is invalid.\n */\nexport function validateBIP32Path(\n value: unknown,\n): asserts value is Bip32Entropy {\n assertStruct(\n value,\n Bip32EntropyStruct,\n 'Invalid BIP-32 entropy path definition',\n rpcErrors.invalidParams,\n );\n}\n\n/**\n * Validate the path values associated with a caveat. This validates that the\n * value is a non-empty array with valid derivation paths and curves.\n *\n * @param caveat - The caveat to validate.\n * @throws If the value is invalid.\n */\nexport function validateBIP32CaveatPaths(\n caveat: Caveat<string, any>,\n): asserts caveat is Caveat<string, Bip32Entropy[]> {\n assertStruct(\n caveat,\n type({ value: size(array(Bip32EntropyStruct), 1, Infinity) }),\n 'Invalid BIP-32 entropy caveat',\n rpcErrors.internal,\n );\n}\n\nexport const PermittedDerivationPathsCaveatSpecification: Record<\n SnapCaveatType.PermittedDerivationPaths,\n RestrictedMethodCaveatSpecificationConstraint\n> = {\n [SnapCaveatType.PermittedDerivationPaths]: Object.freeze({\n type: SnapCaveatType.PermittedDerivationPaths,\n decorator: (\n method,\n caveat: Caveat<SnapCaveatType.PermittedDerivationPaths, Bip32Entropy[]>,\n ) => {\n return async (args) => {\n const { params } = args;\n validateBIP32Path(params);\n\n const path = caveat.value.find(\n (caveatPath) =>\n isEqual(\n params.path.slice(0, caveatPath.path.length),\n caveatPath.path,\n ) && caveatPath.curve === params.curve,\n );\n\n if (!path) {\n throw providerErrors.unauthorized({\n message:\n 'The requested path is not permitted. Allowed paths must be specified in the snap manifest.',\n });\n }\n\n return await method(args);\n };\n },\n validator: (caveat) => validateBIP32CaveatPaths(caveat),\n }),\n};\n"],"names":["permittedDerivationPathsCaveatMapper","validateBIP32Path","validateBIP32CaveatPaths","PermittedDerivationPathsCaveatSpecification","value","caveats","type","SnapCaveatType","PermittedDerivationPaths","assertStruct","Bip32EntropyStruct","rpcErrors","invalidParams","caveat","size","array","Infinity","internal","Object","freeze","decorator","method","args","params","path","find","caveatPath","isEqual","slice","length","curve","providerErrors","unauthorized","message","validator"],"mappings":";;;;;;;;;;;IAwBgBA,oCAAoC;eAApCA;;IAsBAC,iBAAiB;eAAjBA;;IAkBAC,wBAAwB;eAAxBA;;IAWHC,2CAA2C;eAA3CA;;;2BAtE6B;4BAMnC;uBAEsB;6BACK;AAU3B,SAASH,qCACdI,KAAW;IAEX,OAAO;QACLC,SAAS;YACP;gBACEC,MAAMC,0BAAc,CAACC,wBAAwB;gBAC7CJ;YACF;SACD;IACH;AACF;AAWO,SAASH,kBACdG,KAAc;IAEdK,IAAAA,mBAAY,EACVL,OACAM,8BAAkB,EAClB,0CACAC,oBAAS,CAACC,aAAa;AAE3B;AASO,SAASV,yBACdW,MAA2B;IAE3BJ,IAAAA,mBAAY,EACVI,QACAP,IAAAA,iBAAI,EAAC;QAAEF,OAAOU,IAAAA,iBAAI,EAACC,IAAAA,kBAAK,EAACL,8BAAkB,GAAG,GAAGM;IAAU,IAC3D,iCACAL,oBAAS,CAACM,QAAQ;AAEtB;AAEO,MAAMd,8CAGT;IACF,CAACI,0BAAc,CAACC,wBAAwB,CAAC,EAAEU,OAAOC,MAAM,CAAC;QACvDb,MAAMC,0BAAc,CAACC,wBAAwB;QAC7CY,WAAW,CACTC,QACAR;YAEA,OAAO,OAAOS;gBACZ,MAAM,EAAEC,MAAM,EAAE,GAAGD;gBACnBrB,kBAAkBsB;gBAElB,MAAMC,OAAOX,OAAOT,KAAK,CAACqB,IAAI,CAC5B,CAACC,aACCC,IAAAA,mBAAO,EACLJ,OAAOC,IAAI,CAACI,KAAK,CAAC,GAAGF,WAAWF,IAAI,CAACK,MAAM,GAC3CH,WAAWF,IAAI,KACZE,WAAWI,KAAK,KAAKP,OAAOO,KAAK;gBAG1C,IAAI,CAACN,MAAM;oBACT,MAAMO,yBAAc,CAACC,YAAY,CAAC;wBAChCC,SACE;oBACJ;gBACF;gBAEA,OAAO,MAAMZ,OAAOC;YACtB;QACF;QACAY,WAAW,CAACrB,SAAWX,yBAAyBW;IAClD;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
- snapIdsCaveatMapper: function() {
13
- return snapIdsCaveatMapper;
14
- },
15
- validateSnapIdsCaveat: function() {
16
- return validateSnapIdsCaveat;
17
- },
18
- SnapIdsCaveatSpecification: function() {
19
- return SnapIdsCaveatSpecification;
20
- }
21
- });
22
- const _rpcerrors = require("@metamask/rpc-errors");
23
- const _snapsutils = require("@metamask/snaps-utils");
24
- const _utils = require("@metamask/utils");
25
- const _superstruct = require("superstruct");
26
- function snapIdsCaveatMapper(value) {
27
- return {
28
- caveats: [
29
- {
30
- type: _snapsutils.SnapCaveatType.SnapIds,
31
- value
32
- }
33
- ]
34
- };
35
- }
36
- function validateSnapIdsCaveat(caveat) {
37
- (0, _utils.assertStruct)(caveat, (0, _superstruct.type)({
38
- value: _snapsutils.SnapIdsStruct
39
- }), 'Expected caveat to have a value property of a non-empty object of snap IDs.', _rpcerrors.rpcErrors.invalidParams);
40
- }
41
- const SnapIdsCaveatSpecification = {
42
- [_snapsutils.SnapCaveatType.SnapIds]: Object.freeze({
43
- type: _snapsutils.SnapCaveatType.SnapIds,
44
- validator: (caveat)=>validateSnapIdsCaveat(caveat),
45
- decorator: (method, caveat)=>{
46
- return async (args)=>{
47
- const { params, context: { origin } } = args;
48
- const snapIds = caveat.value;
49
- const { snapId } = params;
50
- if (!(0, _utils.hasProperty)(snapIds, snapId)) {
51
- throw new Error(`${origin} does not have permission to invoke ${snapId} snap.`);
52
- }
53
- return await method(args);
54
- };
55
- }
56
- })
57
- };
58
-
59
- //# sourceMappingURL=snapIds.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/restricted/caveats/snapIds.ts"],"sourcesContent":["import type {\n Caveat,\n RestrictedMethodOptions,\n RestrictedMethodParameters,\n RestrictedMethodCaveatSpecificationConstraint,\n PermissionConstraint,\n} from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { SnapIds } from '@metamask/snaps-utils';\nimport { SnapCaveatType, SnapIdsStruct } from '@metamask/snaps-utils';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty, assertStruct } from '@metamask/utils';\nimport { type } from 'superstruct';\n\nimport type { InvokeSnapParams } from '../invokeSnap';\n\n/**\n * Map a raw value from the `initialPermissions` to a caveat specification.\n * Note that this function does not do any validation, that's handled by the\n * PermissionsController when the permission is requested.\n *\n * @param value - The raw value from the `initialPermissions`.\n * @returns The caveat specification.\n */\nexport function snapIdsCaveatMapper(\n value: Json,\n): Pick<PermissionConstraint, 'caveats'> {\n return {\n caveats: [\n {\n type: SnapCaveatType.SnapIds,\n value,\n },\n ],\n };\n}\n\n/**\n * Validates that the caveat value exists and is a non-empty object.\n *\n * @param caveat - The caveat to validate.\n * @throws If the caveat is invalid.\n */\nexport function validateSnapIdsCaveat(\n caveat: Caveat<string, any>,\n): asserts caveat is Caveat<string, SnapIds> {\n assertStruct(\n caveat,\n type({\n value: SnapIdsStruct,\n }),\n 'Expected caveat to have a value property of a non-empty object of snap IDs.',\n rpcErrors.invalidParams,\n );\n}\n\nexport const SnapIdsCaveatSpecification: Record<\n SnapCaveatType.SnapIds,\n RestrictedMethodCaveatSpecificationConstraint\n> = {\n [SnapCaveatType.SnapIds]: Object.freeze({\n type: SnapCaveatType.SnapIds,\n validator: (caveat) => validateSnapIdsCaveat(caveat),\n decorator: (method, caveat) => {\n return async (args) => {\n const {\n params,\n context: { origin },\n }: RestrictedMethodOptions<RestrictedMethodParameters> = args;\n const snapIds = caveat.value;\n const { snapId } = params as InvokeSnapParams;\n if (!hasProperty(snapIds, snapId)) {\n throw new Error(\n `${origin} does not have permission to invoke ${snapId} snap.`,\n );\n }\n return await method(args);\n };\n },\n }),\n};\n"],"names":["snapIdsCaveatMapper","validateSnapIdsCaveat","SnapIdsCaveatSpecification","value","caveats","type","SnapCaveatType","SnapIds","caveat","assertStruct","SnapIdsStruct","rpcErrors","invalidParams","Object","freeze","validator","decorator","method","args","params","context","origin","snapIds","snapId","hasProperty","Error"],"mappings":";;;;;;;;;;;IAwBgBA,mBAAmB;eAAnBA;;IAmBAC,qBAAqB;eAArBA;;IAaHC,0BAA0B;eAA1BA;;;2BAjDa;4BAEoB;uBAEJ;6BACrB;AAYd,SAASF,oBACdG,KAAW;IAEX,OAAO;QACLC,SAAS;YACP;gBACEC,MAAMC,0BAAc,CAACC,OAAO;gBAC5BJ;YACF;SACD;IACH;AACF;AAQO,SAASF,sBACdO,MAA2B;IAE3BC,IAAAA,mBAAY,EACVD,QACAH,IAAAA,iBAAI,EAAC;QACHF,OAAOO,yBAAa;IACtB,IACA,+EACAC,oBAAS,CAACC,aAAa;AAE3B;AAEO,MAAMV,6BAGT;IACF,CAACI,0BAAc,CAACC,OAAO,CAAC,EAAEM,OAAOC,MAAM,CAAC;QACtCT,MAAMC,0BAAc,CAACC,OAAO;QAC5BQ,WAAW,CAACP,SAAWP,sBAAsBO;QAC7CQ,WAAW,CAACC,QAAQT;YAClB,OAAO,OAAOU;gBACZ,MAAM,EACJC,MAAM,EACNC,SAAS,EAAEC,MAAM,EAAE,EACpB,GAAwDH;gBACzD,MAAMI,UAAUd,OAAOL,KAAK;gBAC5B,MAAM,EAAEoB,MAAM,EAAE,GAAGJ;gBACnB,IAAI,CAACK,IAAAA,kBAAW,EAACF,SAASC,SAAS;oBACjC,MAAM,IAAIE,MACR,CAAC,EAAEJ,OAAO,oCAAoC,EAAEE,OAAO,MAAM,CAAC;gBAElE;gBACA,OAAO,MAAMN,OAAOC;YACtB;QACF;IACF;AACF"}
@@ -1,172 +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
- dialogBuilder: function() {
13
- return dialogBuilder;
14
- },
15
- getDialogImplementation: function() {
16
- return getDialogImplementation;
17
- }
18
- });
19
- const _permissioncontroller = require("@metamask/permission-controller");
20
- const _rpcerrors = require("@metamask/rpc-errors");
21
- const _snapssdk = require("@metamask/snaps-sdk");
22
- const _snapsutils = require("@metamask/snaps-utils");
23
- const _utils = require("@metamask/utils");
24
- const _superstruct = require("superstruct");
25
- const methodName = 'snap_dialog';
26
- const PlaceholderStruct = (0, _superstruct.optional)((0, _superstruct.size)((0, _superstruct.string)(), 1, 40));
27
- /**
28
- * The specification builder for the `snap_dialog` permission. `snap_dialog`
29
- * lets the Snap display one of the following dialogs to the user:
30
- * - An alert, for displaying information.
31
- * - A confirmation, for accepting or rejecting some action.
32
- * - A prompt, for inputting some information.
33
- *
34
- * @param options - The specification builder options.
35
- * @param options.allowedCaveats - The optional allowed caveats for the
36
- * permission.
37
- * @param options.methodHooks - The RPC method hooks needed by the method
38
- * implementation.
39
- * @returns The specification for the `snap_dialog` permission.
40
- */ const specificationBuilder = ({ allowedCaveats = null, methodHooks })=>{
41
- return {
42
- permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
43
- targetName: methodName,
44
- allowedCaveats,
45
- methodImplementation: getDialogImplementation(methodHooks),
46
- subjectTypes: [
47
- _permissioncontroller.SubjectType.Snap
48
- ]
49
- };
50
- };
51
- const methodHooks = {
52
- showDialog: true,
53
- createInterface: true,
54
- getInterface: true
55
- };
56
- const dialogBuilder = Object.freeze({
57
- targetName: methodName,
58
- specificationBuilder,
59
- methodHooks
60
- });
61
- // Note: We use `type` here instead of `object` because `type` does not validate
62
- // the keys of the object, which is what we want.
63
- const BaseParamsStruct = (0, _superstruct.type)({
64
- type: (0, _superstruct.enums)([
65
- _snapssdk.DialogType.Alert,
66
- _snapssdk.DialogType.Confirmation,
67
- _snapssdk.DialogType.Prompt
68
- ])
69
- });
70
- const AlertParametersWithContentStruct = (0, _superstruct.object)({
71
- type: (0, _snapssdk.enumValue)(_snapssdk.DialogType.Alert),
72
- content: _snapssdk.ComponentStruct
73
- });
74
- const AlertParametersWithIdStruct = (0, _superstruct.object)({
75
- type: (0, _snapssdk.enumValue)(_snapssdk.DialogType.Alert),
76
- id: (0, _superstruct.string)()
77
- });
78
- const AlertParametersStruct = (0, _snapssdk.union)([
79
- AlertParametersWithContentStruct,
80
- AlertParametersWithIdStruct
81
- ]);
82
- const ConfirmationParametersWithContentStruct = (0, _superstruct.object)({
83
- type: (0, _snapssdk.enumValue)(_snapssdk.DialogType.Confirmation),
84
- content: _snapssdk.ComponentStruct
85
- });
86
- const ConfirmationParametersWithIdStruct = (0, _superstruct.object)({
87
- type: (0, _snapssdk.enumValue)(_snapssdk.DialogType.Confirmation),
88
- id: (0, _superstruct.string)()
89
- });
90
- const ConfirmationParametersStruct = (0, _snapssdk.union)([
91
- ConfirmationParametersWithContentStruct,
92
- ConfirmationParametersWithIdStruct
93
- ]);
94
- const PromptParametersWithContentStruct = (0, _superstruct.object)({
95
- type: (0, _snapssdk.enumValue)(_snapssdk.DialogType.Prompt),
96
- content: _snapssdk.ComponentStruct,
97
- placeholder: PlaceholderStruct
98
- });
99
- const PromptParametersWithIdStruct = (0, _superstruct.object)({
100
- type: (0, _snapssdk.enumValue)(_snapssdk.DialogType.Prompt),
101
- id: (0, _superstruct.string)(),
102
- placeholder: PlaceholderStruct
103
- });
104
- const PromptParametersStruct = (0, _snapssdk.union)([
105
- PromptParametersWithContentStruct,
106
- PromptParametersWithIdStruct
107
- ]);
108
- const DialogParametersStruct = (0, _snapssdk.union)([
109
- AlertParametersStruct,
110
- ConfirmationParametersStruct,
111
- PromptParametersStruct
112
- ]);
113
- const structs = {
114
- [_snapssdk.DialogType.Alert]: AlertParametersStruct,
115
- [_snapssdk.DialogType.Confirmation]: ConfirmationParametersStruct,
116
- [_snapssdk.DialogType.Prompt]: PromptParametersStruct
117
- };
118
- function getDialogImplementation({ showDialog, createInterface, getInterface }) {
119
- return async function dialogImplementation(args) {
120
- const { params, context: { origin } } = args;
121
- const validatedType = getValidatedType(params);
122
- const validatedParams = getValidatedParams(params, structs[validatedType]);
123
- const placeholder = validatedParams.type === _snapssdk.DialogType.Prompt ? validatedParams.placeholder : undefined;
124
- if ((0, _utils.hasProperty)(validatedParams, 'content')) {
125
- const id = await createInterface(origin, validatedParams.content);
126
- return showDialog(origin, validatedType, id, placeholder);
127
- }
128
- // Verify that the passed interface ID is valid.
129
- // This will throw if the interface ID is invalid (not created by the snap or doesn't exist)
130
- try {
131
- getInterface(origin, validatedParams.id);
132
- } catch (error) {
133
- throw _rpcerrors.rpcErrors.invalidParams({
134
- message: `Invalid params: ${error.message}`
135
- });
136
- }
137
- return showDialog(origin, validatedType, validatedParams.id, placeholder);
138
- };
139
- }
140
- /**
141
- * Get the validated type of the dialog parameters. Throws an error if the type
142
- * is invalid.
143
- *
144
- * @param params - The parameters to validate.
145
- * @returns The validated type of the dialog parameters.
146
- */ function getValidatedType(params) {
147
- try {
148
- return (0, _superstruct.create)(params, BaseParamsStruct).type;
149
- } catch (error) {
150
- throw _rpcerrors.rpcErrors.invalidParams({
151
- message: `The "type" property must be one of: ${Object.values(_snapssdk.DialogType).join(', ')}.`
152
- });
153
- }
154
- }
155
- /**
156
- * Validates the confirm method `params` and returns them cast to the correct
157
- * type. Throws if validation fails.
158
- *
159
- * @param params - The unvalidated params object from the method request.
160
- * @param struct - The struct to validate the params against.
161
- * @returns The validated confirm method parameter object.
162
- */ function getValidatedParams(params, struct) {
163
- try {
164
- return (0, _snapsutils.createUnion)(params, struct, 'type');
165
- } catch (error) {
166
- throw _rpcerrors.rpcErrors.invalidParams({
167
- message: `Invalid params: ${error.message}`
168
- });
169
- }
170
- }
171
-
172
- //# sourceMappingURL=dialog.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/restricted/dialog.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 {\n DialogType,\n ComponentStruct,\n enumValue,\n union,\n} from '@metamask/snaps-sdk';\nimport type {\n DialogParams,\n EnumToUnion,\n Component,\n InterfaceState,\n SnapId,\n} from '@metamask/snaps-sdk';\nimport { createUnion } from '@metamask/snaps-utils';\nimport type { InferMatching } from '@metamask/snaps-utils';\nimport { hasProperty, type NonEmptyArray } from '@metamask/utils';\nimport type { Infer, Struct } from 'superstruct';\nimport {\n create,\n enums,\n object,\n optional,\n size,\n string,\n type,\n} from 'superstruct';\n\nimport { type MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_dialog';\n\nconst PlaceholderStruct = optional(size(string(), 1, 40));\n\nexport type Placeholder = Infer<typeof PlaceholderStruct>;\n\ntype ShowDialog = (\n snapId: string,\n type: EnumToUnion<DialogType>,\n id: string,\n placeholder?: Placeholder,\n) => Promise<null | boolean | string>;\n\ntype CreateInterface = (snapId: string, content: Component) => Promise<string>;\ntype GetInterface = (\n snapId: string,\n id: string,\n) => { content: Component; snapId: SnapId; state: InterfaceState };\n\nexport type DialogMethodHooks = {\n /**\n * @param snapId - The ID of the Snap that created the alert.\n * @param type - The dialog type.\n * @param id - The interface ID.\n * @param placeholder - The placeholder for the Prompt dialog input.\n */\n showDialog: ShowDialog;\n\n /**\n * @param snapId - The Snap ID creating the interface.\n * @param content - The content of the interface.\n */\n createInterface: CreateInterface;\n /**\n * @param snapId - The SnapId requesting the interface.\n * @param id - The interface ID.\n */\n getInterface: GetInterface;\n};\n\ntype DialogSpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: DialogMethodHooks;\n};\n\ntype DialogSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getDialogImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_dialog` permission. `snap_dialog`\n * lets the Snap display one of the following dialogs to the user:\n * - An alert, for displaying information.\n * - A confirmation, for accepting or rejecting some action.\n * - A prompt, for inputting some information.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the\n * permission.\n * @param options.methodHooks - The RPC method hooks needed by the method\n * implementation.\n * @returns The specification for the `snap_dialog` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n DialogSpecificationBuilderOptions,\n DialogSpecification\n> = ({\n allowedCaveats = null,\n methodHooks,\n}: DialogSpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getDialogImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<DialogMethodHooks> = {\n showDialog: true,\n createInterface: true,\n getInterface: true,\n};\n\nexport const dialogBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n// Note: We use `type` here instead of `object` because `type` does not validate\n// the keys of the object, which is what we want.\nconst BaseParamsStruct = type({\n type: enums([DialogType.Alert, DialogType.Confirmation, DialogType.Prompt]),\n});\n\nconst AlertParametersWithContentStruct = object({\n type: enumValue(DialogType.Alert),\n content: ComponentStruct,\n});\nconst AlertParametersWithIdStruct = object({\n type: enumValue(DialogType.Alert),\n id: string(),\n});\n\nconst AlertParametersStruct = union([\n AlertParametersWithContentStruct,\n AlertParametersWithIdStruct,\n]);\n\nconst ConfirmationParametersWithContentStruct = object({\n type: enumValue(DialogType.Confirmation),\n content: ComponentStruct,\n});\n\nconst ConfirmationParametersWithIdStruct = object({\n type: enumValue(DialogType.Confirmation),\n id: string(),\n});\n\nconst ConfirmationParametersStruct = union([\n ConfirmationParametersWithContentStruct,\n ConfirmationParametersWithIdStruct,\n]);\n\nconst PromptParametersWithContentStruct = object({\n type: enumValue(DialogType.Prompt),\n content: ComponentStruct,\n placeholder: PlaceholderStruct,\n});\n\nconst PromptParametersWithIdStruct = object({\n type: enumValue(DialogType.Prompt),\n id: string(),\n placeholder: PlaceholderStruct,\n});\n\nconst PromptParametersStruct = union([\n PromptParametersWithContentStruct,\n PromptParametersWithIdStruct,\n]);\n\nconst DialogParametersStruct = union([\n AlertParametersStruct,\n ConfirmationParametersStruct,\n PromptParametersStruct,\n]);\n\nexport type DialogParameters = InferMatching<\n typeof DialogParametersStruct,\n DialogParams\n>;\n\nconst structs = {\n [DialogType.Alert]: AlertParametersStruct,\n [DialogType.Confirmation]: ConfirmationParametersStruct,\n [DialogType.Prompt]: PromptParametersStruct,\n};\n\n/**\n * Builds the method implementation for `snap_dialog`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.showDialog - A function that shows the specified dialog in the\n * MetaMask UI and returns the appropriate value for the dialog type.\n * @param hooks.createInterface - A function that creates the interface in SnapInterfaceController.\n * @param hooks.getInterface - A function that gets an interface from SnapInterfaceController.\n * @returns The method implementation which return value depends on the dialog\n * type, valid return types are: string, boolean, null.\n */\nexport function getDialogImplementation({\n showDialog,\n createInterface,\n getInterface,\n}: DialogMethodHooks) {\n return async function dialogImplementation(\n args: RestrictedMethodOptions<DialogParameters>,\n ): Promise<boolean | null | string> {\n const {\n params,\n context: { origin },\n } = args;\n\n const validatedType = getValidatedType(params);\n const validatedParams = getValidatedParams(params, structs[validatedType]);\n\n const placeholder =\n validatedParams.type === DialogType.Prompt\n ? validatedParams.placeholder\n : undefined;\n\n if (hasProperty(validatedParams, 'content')) {\n const id = await createInterface(\n origin,\n validatedParams.content as Component,\n );\n return showDialog(origin, validatedType, id, placeholder);\n }\n\n // Verify that the passed interface ID is valid.\n // This will throw if the interface ID is invalid (not created by the snap or doesn't exist)\n try {\n getInterface(origin, validatedParams.id);\n } catch (error) {\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}`,\n });\n }\n\n return showDialog(origin, validatedType, validatedParams.id, placeholder);\n };\n}\n\n/**\n * Get the validated type of the dialog parameters. Throws an error if the type\n * is invalid.\n *\n * @param params - The parameters to validate.\n * @returns The validated type of the dialog parameters.\n */\nfunction getValidatedType(params: unknown): DialogType {\n try {\n return create(params, BaseParamsStruct).type;\n } catch (error) {\n throw rpcErrors.invalidParams({\n message: `The \"type\" property must be one of: ${Object.values(\n DialogType,\n ).join(', ')}.`,\n });\n }\n}\n\n/**\n * Validates the confirm 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 * @param struct - The struct to validate the params against.\n * @returns The validated confirm method parameter object.\n */\nfunction getValidatedParams(\n params: unknown,\n struct: Struct<any, any>,\n): DialogParameters {\n try {\n return createUnion(params, struct, 'type');\n } catch (error) {\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}`,\n });\n }\n}\n"],"names":["dialogBuilder","getDialogImplementation","methodName","PlaceholderStruct","optional","size","string","specificationBuilder","allowedCaveats","methodHooks","permissionType","PermissionType","RestrictedMethod","targetName","methodImplementation","subjectTypes","SubjectType","Snap","showDialog","createInterface","getInterface","Object","freeze","BaseParamsStruct","type","enums","DialogType","Alert","Confirmation","Prompt","AlertParametersWithContentStruct","object","enumValue","content","ComponentStruct","AlertParametersWithIdStruct","id","AlertParametersStruct","union","ConfirmationParametersWithContentStruct","ConfirmationParametersWithIdStruct","ConfirmationParametersStruct","PromptParametersWithContentStruct","placeholder","PromptParametersWithIdStruct","PromptParametersStruct","DialogParametersStruct","structs","dialogImplementation","args","params","context","origin","validatedType","getValidatedType","validatedParams","getValidatedParams","undefined","hasProperty","error","rpcErrors","invalidParams","message","create","values","join","struct","createUnion"],"mappings":";;;;;;;;;;;IA6HaA,aAAa;eAAbA;;IAsFGC,uBAAuB;eAAvBA;;;sCA9M4B;2BAClB;0BAMnB;4BAQqB;uBAEoB;6BAUzC;AAIP,MAAMC,aAAa;AAEnB,MAAMC,oBAAoBC,IAAAA,qBAAQ,EAACC,IAAAA,iBAAI,EAACC,IAAAA,mBAAM,KAAI,GAAG;AAkDrD;;;;;;;;;;;;;CAaC,GACD,MAAMC,uBAIF,CAAC,EACHC,iBAAiB,IAAI,EACrBC,WAAW,EACuB;IAClC,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CC,YAAYX;QACZM;QACAM,sBAAsBb,wBAAwBQ;QAC9CM,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAEA,MAAMR,cAAoD;IACxDS,YAAY;IACZC,iBAAiB;IACjBC,cAAc;AAChB;AAEO,MAAMpB,gBAAgBqB,OAAOC,MAAM,CAAC;IACzCT,YAAYX;IACZK;IACAE;AACF;AAEA,gFAAgF;AAChF,iDAAiD;AACjD,MAAMc,mBAAmBC,IAAAA,iBAAI,EAAC;IAC5BA,MAAMC,IAAAA,kBAAK,EAAC;QAACC,oBAAU,CAACC,KAAK;QAAED,oBAAU,CAACE,YAAY;QAAEF,oBAAU,CAACG,MAAM;KAAC;AAC5E;AAEA,MAAMC,mCAAmCC,IAAAA,mBAAM,EAAC;IAC9CP,MAAMQ,IAAAA,mBAAS,EAACN,oBAAU,CAACC,KAAK;IAChCM,SAASC,yBAAe;AAC1B;AACA,MAAMC,8BAA8BJ,IAAAA,mBAAM,EAAC;IACzCP,MAAMQ,IAAAA,mBAAS,EAACN,oBAAU,CAACC,KAAK;IAChCS,IAAI9B,IAAAA,mBAAM;AACZ;AAEA,MAAM+B,wBAAwBC,IAAAA,eAAK,EAAC;IAClCR;IACAK;CACD;AAED,MAAMI,0CAA0CR,IAAAA,mBAAM,EAAC;IACrDP,MAAMQ,IAAAA,mBAAS,EAACN,oBAAU,CAACE,YAAY;IACvCK,SAASC,yBAAe;AAC1B;AAEA,MAAMM,qCAAqCT,IAAAA,mBAAM,EAAC;IAChDP,MAAMQ,IAAAA,mBAAS,EAACN,oBAAU,CAACE,YAAY;IACvCQ,IAAI9B,IAAAA,mBAAM;AACZ;AAEA,MAAMmC,+BAA+BH,IAAAA,eAAK,EAAC;IACzCC;IACAC;CACD;AAED,MAAME,oCAAoCX,IAAAA,mBAAM,EAAC;IAC/CP,MAAMQ,IAAAA,mBAAS,EAACN,oBAAU,CAACG,MAAM;IACjCI,SAASC,yBAAe;IACxBS,aAAaxC;AACf;AAEA,MAAMyC,+BAA+Bb,IAAAA,mBAAM,EAAC;IAC1CP,MAAMQ,IAAAA,mBAAS,EAACN,oBAAU,CAACG,MAAM;IACjCO,IAAI9B,IAAAA,mBAAM;IACVqC,aAAaxC;AACf;AAEA,MAAM0C,yBAAyBP,IAAAA,eAAK,EAAC;IACnCI;IACAE;CACD;AAED,MAAME,yBAAyBR,IAAAA,eAAK,EAAC;IACnCD;IACAI;IACAI;CACD;AAOD,MAAME,UAAU;IACd,CAACrB,oBAAU,CAACC,KAAK,CAAC,EAAEU;IACpB,CAACX,oBAAU,CAACE,YAAY,CAAC,EAAEa;IAC3B,CAACf,oBAAU,CAACG,MAAM,CAAC,EAAEgB;AACvB;AAaO,SAAS5C,wBAAwB,EACtCiB,UAAU,EACVC,eAAe,EACfC,YAAY,EACM;IAClB,OAAO,eAAe4B,qBACpBC,IAA+C;QAE/C,MAAM,EACJC,MAAM,EACNC,SAAS,EAAEC,MAAM,EAAE,EACpB,GAAGH;QAEJ,MAAMI,gBAAgBC,iBAAiBJ;QACvC,MAAMK,kBAAkBC,mBAAmBN,QAAQH,OAAO,CAACM,cAAc;QAEzE,MAAMV,cACJY,gBAAgB/B,IAAI,KAAKE,oBAAU,CAACG,MAAM,GACtC0B,gBAAgBZ,WAAW,GAC3Bc;QAEN,IAAIC,IAAAA,kBAAW,EAACH,iBAAiB,YAAY;YAC3C,MAAMnB,KAAK,MAAMjB,gBACfiC,QACAG,gBAAgBtB,OAAO;YAEzB,OAAOf,WAAWkC,QAAQC,eAAejB,IAAIO;QAC/C;QAEA,gDAAgD;QAChD,4FAA4F;QAC5F,IAAI;YACFvB,aAAagC,QAAQG,gBAAgBnB,EAAE;QACzC,EAAE,OAAOuB,OAAO;YACd,MAAMC,oBAAS,CAACC,aAAa,CAAC;gBAC5BC,SAAS,CAAC,gBAAgB,EAAEH,MAAMG,OAAO,CAAC,CAAC;YAC7C;QACF;QAEA,OAAO5C,WAAWkC,QAAQC,eAAeE,gBAAgBnB,EAAE,EAAEO;IAC/D;AACF;AAEA;;;;;;CAMC,GACD,SAASW,iBAAiBJ,MAAe;IACvC,IAAI;QACF,OAAOa,IAAAA,mBAAM,EAACb,QAAQ3B,kBAAkBC,IAAI;IAC9C,EAAE,OAAOmC,OAAO;QACd,MAAMC,oBAAS,CAACC,aAAa,CAAC;YAC5BC,SAAS,CAAC,oCAAoC,EAAEzC,OAAO2C,MAAM,CAC3DtC,oBAAU,EACVuC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjB;IACF;AACF;AAEA;;;;;;;CAOC,GACD,SAAST,mBACPN,MAAe,EACfgB,MAAwB;IAExB,IAAI;QACF,OAAOC,IAAAA,uBAAW,EAACjB,QAAQgB,QAAQ;IACrC,EAAE,OAAOP,OAAO;QACd,MAAMC,oBAAS,CAACC,aAAa,CAAC;YAC5BC,SAAS,CAAC,gBAAgB,EAAEH,MAAMG,OAAO,CAAC,CAAC;QAC7C;IACF;AACF"}
@@ -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
- getBip32EntropyBuilder: function() {
13
- return getBip32EntropyBuilder;
14
- },
15
- getBip32EntropyImplementation: function() {
16
- return getBip32EntropyImplementation;
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 _utils1 = require("../utils");
24
- const targetName = 'snap_getBip32Entropy';
25
- /**
26
- * The specification builder for the `snap_getBip32Entropy` permission.
27
- * `snap_getBip32Entropy` lets the Snap control private keys for a particular
28
- * BIP-32 node.
29
- *
30
- * @param options - The specification builder options.
31
- * @param options.methodHooks - The RPC method hooks needed by the method implementation.
32
- * @returns The specification for the `snap_getBip32Entropy` permission.
33
- */ const specificationBuilder = ({ methodHooks })=>{
34
- return {
35
- permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
36
- targetName,
37
- allowedCaveats: [
38
- _snapsutils.SnapCaveatType.PermittedDerivationPaths
39
- ],
40
- methodImplementation: getBip32EntropyImplementation(methodHooks),
41
- validator: ({ caveats })=>{
42
- if (caveats?.length !== 1 || caveats[0].type !== _snapsutils.SnapCaveatType.PermittedDerivationPaths) {
43
- throw _rpcerrors.rpcErrors.invalidParams({
44
- message: `Expected a single "${_snapsutils.SnapCaveatType.PermittedDerivationPaths}" caveat.`
45
- });
46
- }
47
- },
48
- subjectTypes: [
49
- _permissioncontroller.SubjectType.Snap
50
- ]
51
- };
52
- };
53
- const methodHooks = {
54
- getMnemonic: true,
55
- getUnlockPromise: true
56
- };
57
- const getBip32EntropyBuilder = Object.freeze({
58
- targetName,
59
- specificationBuilder,
60
- methodHooks
61
- });
62
- function getBip32EntropyImplementation({ getMnemonic, getUnlockPromise }) {
63
- return async function getBip32Entropy(args) {
64
- await getUnlockPromise(true);
65
- const { params } = args;
66
- (0, _utils.assert)(params);
67
- const node = await (0, _utils1.getNode)({
68
- curve: params.curve,
69
- path: params.path,
70
- secretRecoveryPhrase: await getMnemonic()
71
- });
72
- return node.toJSON();
73
- };
74
- }
75
-
76
- //# sourceMappingURL=getBip32Entropy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/restricted/getBip32Entropy.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n PermissionValidatorConstraint,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetBip32EntropyParams,\n GetBip32EntropyResult,\n} from '@metamask/snaps-sdk';\nimport { SnapCaveatType } from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assert } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport { getNode } from '../utils';\n\nconst targetName = 'snap_getBip32Entropy';\n\nexport type GetBip32EntropyMethodHooks = {\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\ntype GetBip32EntropySpecificationBuilderOptions = {\n methodHooks: GetBip32EntropyMethodHooks;\n};\n\ntype GetBip32EntropySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getBip32EntropyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\n/**\n * The specification builder for the `snap_getBip32Entropy` permission.\n * `snap_getBip32Entropy` lets the Snap control private keys for a particular\n * BIP-32 node.\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 `snap_getBip32Entropy` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetBip32EntropySpecificationBuilderOptions,\n GetBip32EntropySpecification\n> = ({ methodHooks }: GetBip32EntropySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats: [SnapCaveatType.PermittedDerivationPaths],\n methodImplementation: getBip32EntropyImplementation(methodHooks),\n validator: ({ caveats }) => {\n if (\n caveats?.length !== 1 ||\n caveats[0].type !== SnapCaveatType.PermittedDerivationPaths\n ) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.PermittedDerivationPaths}\" caveat.`,\n });\n }\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetBip32EntropyMethodHooks> = {\n getMnemonic: true,\n getUnlockPromise: true,\n};\n\nexport const getBip32EntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getBip32Entropy`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user.\n * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked\n * and prompts the user to unlock their MetaMask if it is locked.\n * @returns The method implementation which returns a `JsonSLIP10Node`.\n * @throws If the params are invalid.\n */\nexport function getBip32EntropyImplementation({\n getMnemonic,\n getUnlockPromise,\n}: GetBip32EntropyMethodHooks) {\n return async function getBip32Entropy(\n args: RestrictedMethodOptions<GetBip32EntropyParams>,\n ): Promise<GetBip32EntropyResult> {\n await getUnlockPromise(true);\n\n const { params } = args;\n assert(params);\n\n const node = await getNode({\n curve: params.curve,\n path: params.path,\n secretRecoveryPhrase: await getMnemonic(),\n });\n\n return node.toJSON();\n };\n}\n"],"names":["getBip32EntropyBuilder","getBip32EntropyImplementation","targetName","specificationBuilder","methodHooks","permissionType","PermissionType","RestrictedMethod","allowedCaveats","SnapCaveatType","PermittedDerivationPaths","methodImplementation","validator","caveats","length","type","rpcErrors","invalidParams","message","subjectTypes","SubjectType","Snap","getMnemonic","getUnlockPromise","Object","freeze","getBip32Entropy","args","params","assert","node","getNode","curve","path","secretRecoveryPhrase","toJSON"],"mappings":";;;;;;;;;;;IAqFaA,sBAAsB;eAAtBA;;IAgBGC,6BAA6B;eAA7BA;;;sCA/F4B;2BAClB;4BAKK;uBAER;wBAGC;AAExB,MAAMC,aAAa;AA4BnB;;;;;;;;CAQC,GACD,MAAMC,uBAIF,CAAC,EAAEC,WAAW,EAA8C;IAC9D,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CL;QACAM,gBAAgB;YAACC,0BAAc,CAACC,wBAAwB;SAAC;QACzDC,sBAAsBV,8BAA8BG;QACpDQ,WAAW,CAAC,EAAEC,OAAO,EAAE;YACrB,IACEA,SAASC,WAAW,KACpBD,OAAO,CAAC,EAAE,CAACE,IAAI,KAAKN,0BAAc,CAACC,wBAAwB,EAC3D;gBACA,MAAMM,oBAAS,CAACC,aAAa,CAAC;oBAC5BC,SAAS,CAAC,mBAAmB,EAAET,0BAAc,CAACC,wBAAwB,CAAC,SAAS,CAAC;gBACnF;YACF;QACF;QACAS,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAEA,MAAMjB,cAA6D;IACjEkB,aAAa;IACbC,kBAAkB;AACpB;AAEO,MAAMvB,yBAAyBwB,OAAOC,MAAM,CAAC;IAClDvB;IACAC;IACAC;AACF;AAYO,SAASH,8BAA8B,EAC5CqB,WAAW,EACXC,gBAAgB,EACW;IAC3B,OAAO,eAAeG,gBACpBC,IAAoD;QAEpD,MAAMJ,iBAAiB;QAEvB,MAAM,EAAEK,MAAM,EAAE,GAAGD;QACnBE,IAAAA,aAAM,EAACD;QAEP,MAAME,OAAO,MAAMC,IAAAA,eAAO,EAAC;YACzBC,OAAOJ,OAAOI,KAAK;YACnBC,MAAML,OAAOK,IAAI;YACjBC,sBAAsB,MAAMZ;QAC9B;QAEA,OAAOQ,KAAKK,MAAM;IACpB;AACF"}
@@ -1,91 +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
- Bip32PublicKeyArgsStruct: function() {
13
- return Bip32PublicKeyArgsStruct;
14
- },
15
- getBip32PublicKeyBuilder: function() {
16
- return getBip32PublicKeyBuilder;
17
- },
18
- getBip32PublicKeyImplementation: function() {
19
- return getBip32PublicKeyImplementation;
20
- }
21
- });
22
- const _permissioncontroller = require("@metamask/permission-controller");
23
- const _rpcerrors = require("@metamask/rpc-errors");
24
- const _snapsutils = require("@metamask/snaps-utils");
25
- const _utils = require("@metamask/utils");
26
- const _superstruct = require("superstruct");
27
- const _utils1 = require("../utils");
28
- const targetName = 'snap_getBip32PublicKey';
29
- const Bip32PublicKeyArgsStruct = (0, _snapsutils.bip32entropy)((0, _superstruct.object)({
30
- path: _snapsutils.Bip32PathStruct,
31
- curve: (0, _superstruct.enums)([
32
- 'ed25519',
33
- 'secp256k1'
34
- ]),
35
- compressed: (0, _superstruct.optional)((0, _superstruct.boolean)())
36
- }));
37
- /**
38
- * The specification builder for the `snap_getBip32PublicKey` permission.
39
- * `snap_getBip32PublicKey` lets the Snap retrieve public keys for a particular
40
- * BIP-32 node.
41
- *
42
- * @param options - The specification builder options.
43
- * @param options.methodHooks - The RPC method hooks needed by the method implementation.
44
- * @returns The specification for the `snap_getBip32PublicKey` permission.
45
- */ const specificationBuilder = ({ methodHooks })=>{
46
- return {
47
- permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
48
- targetName,
49
- allowedCaveats: [
50
- _snapsutils.SnapCaveatType.PermittedDerivationPaths
51
- ],
52
- methodImplementation: getBip32PublicKeyImplementation(methodHooks),
53
- validator: ({ caveats })=>{
54
- if (caveats?.length !== 1 || caveats[0].type !== _snapsutils.SnapCaveatType.PermittedDerivationPaths) {
55
- throw _rpcerrors.rpcErrors.invalidParams({
56
- message: `Expected a single "${_snapsutils.SnapCaveatType.PermittedDerivationPaths}" caveat.`
57
- });
58
- }
59
- },
60
- subjectTypes: [
61
- _permissioncontroller.SubjectType.Snap
62
- ]
63
- };
64
- };
65
- const methodHooks = {
66
- getMnemonic: true,
67
- getUnlockPromise: true
68
- };
69
- const getBip32PublicKeyBuilder = Object.freeze({
70
- targetName,
71
- specificationBuilder,
72
- methodHooks
73
- });
74
- function getBip32PublicKeyImplementation({ getMnemonic, getUnlockPromise }) {
75
- return async function getBip32PublicKey(args) {
76
- await getUnlockPromise(true);
77
- (0, _utils.assertStruct)(args.params, Bip32PublicKeyArgsStruct, 'Invalid BIP-32 public key params', _rpcerrors.rpcErrors.invalidParams);
78
- const { params } = args;
79
- const node = await (0, _utils1.getNode)({
80
- curve: params.curve,
81
- path: params.path,
82
- secretRecoveryPhrase: await getMnemonic()
83
- });
84
- if (params.compressed) {
85
- return node.compressedPublicKey;
86
- }
87
- return node.publicKey;
88
- };
89
- }
90
-
91
- //# sourceMappingURL=getBip32PublicKey.js.map
@@ -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
- getBip44EntropyBuilder: function() {
13
- return getBip44EntropyBuilder;
14
- },
15
- getBip44EntropyImplementation: function() {
16
- return getBip44EntropyImplementation;
17
- }
18
- });
19
- const _keytree = require("@metamask/key-tree");
20
- const _permissioncontroller = require("@metamask/permission-controller");
21
- const _rpcerrors = require("@metamask/rpc-errors");
22
- const _snapsutils = require("@metamask/snaps-utils");
23
- const targetName = 'snap_getBip44Entropy';
24
- /**
25
- * The specification builder for the `snap_getBip44Entropy` permission.
26
- * `snap_getBip44Entropy_*` lets the Snap control private keys for a particular
27
- * BIP-32 coin type.
28
- *
29
- * @param options - The specification builder options.
30
- * @param options.methodHooks - The RPC method hooks needed by the method
31
- * implementation.
32
- * @returns The specification for the `snap_getBip44Entropy` permission.
33
- */ const specificationBuilder = ({ methodHooks })=>{
34
- return {
35
- permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
36
- targetName,
37
- allowedCaveats: [
38
- _snapsutils.SnapCaveatType.PermittedCoinTypes
39
- ],
40
- methodImplementation: getBip44EntropyImplementation(methodHooks),
41
- validator: ({ caveats })=>{
42
- if (caveats?.length !== 1 || caveats[0].type !== _snapsutils.SnapCaveatType.PermittedCoinTypes) {
43
- throw _rpcerrors.rpcErrors.invalidParams({
44
- message: `Expected a single "${_snapsutils.SnapCaveatType.PermittedCoinTypes}" caveat.`
45
- });
46
- }
47
- },
48
- subjectTypes: [
49
- _permissioncontroller.SubjectType.Snap
50
- ]
51
- };
52
- };
53
- const methodHooks = {
54
- getMnemonic: true,
55
- getUnlockPromise: true
56
- };
57
- const getBip44EntropyBuilder = Object.freeze({
58
- targetName,
59
- specificationBuilder,
60
- methodHooks
61
- });
62
- function getBip44EntropyImplementation({ getMnemonic, getUnlockPromise }) {
63
- return async function getBip44Entropy(args) {
64
- await getUnlockPromise(true);
65
- // `args.params` is validated by the decorator, so it's safe to assert here.
66
- const params = args.params;
67
- const node = await _keytree.BIP44CoinTypeNode.fromDerivationPath([
68
- await getMnemonic(),
69
- `bip32:44'`,
70
- `bip32:${params.coinType}'`
71
- ]);
72
- return node.toJSON();
73
- };
74
- }
75
-
76
- //# sourceMappingURL=getBip44Entropy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/restricted/getBip44Entropy.ts"],"sourcesContent":["import { BIP44CoinTypeNode } from '@metamask/key-tree';\nimport type {\n PermissionSpecificationBuilder,\n PermissionValidatorConstraint,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetBip44EntropyParams,\n GetBip44EntropyResult,\n} from '@metamask/snaps-sdk';\nimport { SnapCaveatType } from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst targetName = 'snap_getBip44Entropy';\n\nexport type GetBip44EntropyMethodHooks = {\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\ntype GetBip44EntropySpecificationBuilderOptions = {\n methodHooks: GetBip44EntropyMethodHooks;\n};\n\ntype GetBip44EntropySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getBip44EntropyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\n/**\n * The specification builder for the `snap_getBip44Entropy` permission.\n * `snap_getBip44Entropy_*` lets the Snap control private keys for a particular\n * BIP-32 coin type.\n *\n * @param options - The specification builder options.\n * @param options.methodHooks - The RPC method hooks needed by the method\n * implementation.\n * @returns The specification for the `snap_getBip44Entropy` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetBip44EntropySpecificationBuilderOptions,\n GetBip44EntropySpecification\n> = ({ methodHooks }: GetBip44EntropySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats: [SnapCaveatType.PermittedCoinTypes],\n methodImplementation: getBip44EntropyImplementation(methodHooks),\n validator: ({ caveats }) => {\n if (\n caveats?.length !== 1 ||\n caveats[0].type !== SnapCaveatType.PermittedCoinTypes\n ) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.PermittedCoinTypes}\" caveat.`,\n });\n }\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetBip44EntropyMethodHooks> = {\n getMnemonic: true,\n getUnlockPromise: true,\n};\n\nexport const getBip44EntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getBip44Entropy`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase\n * of the user.\n * @param hooks.getUnlockPromise - A function that resolves once the MetaMask\n * extension is unlocked and prompts the user to unlock their MetaMask if it is\n * locked.\n * @returns The method implementation which returns a `BIP44CoinTypeNode`.\n * @throws If the params are invalid.\n */\nexport function getBip44EntropyImplementation({\n getMnemonic,\n getUnlockPromise,\n}: GetBip44EntropyMethodHooks) {\n return async function getBip44Entropy(\n args: RestrictedMethodOptions<GetBip44EntropyParams>,\n ): Promise<GetBip44EntropyResult> {\n await getUnlockPromise(true);\n\n // `args.params` is validated by the decorator, so it's safe to assert here.\n const params = args.params as GetBip44EntropyParams;\n\n const node = await BIP44CoinTypeNode.fromDerivationPath([\n await getMnemonic(),\n `bip32:44'`,\n `bip32:${params.coinType}'`,\n ]);\n\n return node.toJSON();\n };\n}\n"],"names":["getBip44EntropyBuilder","getBip44EntropyImplementation","targetName","specificationBuilder","methodHooks","permissionType","PermissionType","RestrictedMethod","allowedCaveats","SnapCaveatType","PermittedCoinTypes","methodImplementation","validator","caveats","length","type","rpcErrors","invalidParams","message","subjectTypes","SubjectType","Snap","getMnemonic","getUnlockPromise","Object","freeze","getBip44Entropy","args","params","node","BIP44CoinTypeNode","fromDerivationPath","coinType","toJSON"],"mappings":";;;;;;;;;;;IAqFaA,sBAAsB;eAAtBA;;IAkBGC,6BAA6B;eAA7BA;;;yBAvGkB;sCAOU;2BAClB;4BAKK;AAK/B,MAAMC,aAAa;AA4BnB;;;;;;;;;CASC,GACD,MAAMC,uBAIF,CAAC,EAAEC,WAAW,EAA8C;IAC9D,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CL;QACAM,gBAAgB;YAACC,0BAAc,CAACC,kBAAkB;SAAC;QACnDC,sBAAsBV,8BAA8BG;QACpDQ,WAAW,CAAC,EAAEC,OAAO,EAAE;YACrB,IACEA,SAASC,WAAW,KACpBD,OAAO,CAAC,EAAE,CAACE,IAAI,KAAKN,0BAAc,CAACC,kBAAkB,EACrD;gBACA,MAAMM,oBAAS,CAACC,aAAa,CAAC;oBAC5BC,SAAS,CAAC,mBAAmB,EAAET,0BAAc,CAACC,kBAAkB,CAAC,SAAS,CAAC;gBAC7E;YACF;QACF;QACAS,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAEA,MAAMjB,cAA6D;IACjEkB,aAAa;IACbC,kBAAkB;AACpB;AAEO,MAAMvB,yBAAyBwB,OAAOC,MAAM,CAAC;IAClDvB;IACAC;IACAC;AACF;AAcO,SAASH,8BAA8B,EAC5CqB,WAAW,EACXC,gBAAgB,EACW;IAC3B,OAAO,eAAeG,gBACpBC,IAAoD;QAEpD,MAAMJ,iBAAiB;QAEvB,4EAA4E;QAC5E,MAAMK,SAASD,KAAKC,MAAM;QAE1B,MAAMC,OAAO,MAAMC,0BAAiB,CAACC,kBAAkB,CAAC;YACtD,MAAMT;YACN,CAAC,SAAS,CAAC;YACX,CAAC,MAAM,EAAEM,OAAOI,QAAQ,CAAC,CAAC,CAAC;SAC5B;QAED,OAAOH,KAAKI,MAAM;IACpB;AACF"}