@metamask/snaps-rpc-methods 14.3.0 → 15.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 (350) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/dist/permitted/cancelBackgroundEvent.cjs +20 -0
  3. package/dist/permitted/cancelBackgroundEvent.cjs.map +1 -1
  4. package/dist/permitted/cancelBackgroundEvent.d.cts +43 -3
  5. package/dist/permitted/cancelBackgroundEvent.d.cts.map +1 -1
  6. package/dist/permitted/cancelBackgroundEvent.d.mts +43 -3
  7. package/dist/permitted/cancelBackgroundEvent.d.mts.map +1 -1
  8. package/dist/permitted/cancelBackgroundEvent.mjs +20 -0
  9. package/dist/permitted/cancelBackgroundEvent.mjs.map +1 -1
  10. package/dist/permitted/clearState.cjs +13 -2
  11. package/dist/permitted/clearState.cjs.map +1 -1
  12. package/dist/permitted/clearState.d.cts +35 -3
  13. package/dist/permitted/clearState.d.cts.map +1 -1
  14. package/dist/permitted/clearState.d.mts +35 -3
  15. package/dist/permitted/clearState.d.mts.map +1 -1
  16. package/dist/permitted/clearState.mjs +13 -2
  17. package/dist/permitted/clearState.mjs.map +1 -1
  18. package/dist/permitted/closeWebSocket.cjs +19 -2
  19. package/dist/permitted/closeWebSocket.cjs.map +1 -1
  20. package/dist/permitted/closeWebSocket.d.cts +39 -4
  21. package/dist/permitted/closeWebSocket.d.cts.map +1 -1
  22. package/dist/permitted/closeWebSocket.d.mts +39 -4
  23. package/dist/permitted/closeWebSocket.d.mts.map +1 -1
  24. package/dist/permitted/closeWebSocket.mjs +19 -2
  25. package/dist/permitted/closeWebSocket.mjs.map +1 -1
  26. package/dist/permitted/createInterface.cjs +33 -2
  27. package/dist/permitted/createInterface.cjs.map +1 -1
  28. package/dist/permitted/createInterface.d.cts +68 -17
  29. package/dist/permitted/createInterface.d.cts.map +1 -1
  30. package/dist/permitted/createInterface.d.mts +68 -17
  31. package/dist/permitted/createInterface.d.mts.map +1 -1
  32. package/dist/permitted/createInterface.mjs +34 -3
  33. package/dist/permitted/createInterface.mjs.map +1 -1
  34. package/dist/permitted/endTrace.cjs +6 -2
  35. package/dist/permitted/endTrace.cjs.map +1 -1
  36. package/dist/permitted/endTrace.d.cts +28 -4
  37. package/dist/permitted/endTrace.d.cts.map +1 -1
  38. package/dist/permitted/endTrace.d.mts +28 -4
  39. package/dist/permitted/endTrace.d.mts.map +1 -1
  40. package/dist/permitted/endTrace.mjs +6 -2
  41. package/dist/permitted/endTrace.mjs.map +1 -1
  42. package/dist/permitted/getAllSnaps.cjs +4 -1
  43. package/dist/permitted/getAllSnaps.cjs.map +1 -1
  44. package/dist/permitted/getAllSnaps.d.cts +25 -3
  45. package/dist/permitted/getAllSnaps.d.cts.map +1 -1
  46. package/dist/permitted/getAllSnaps.d.mts +25 -3
  47. package/dist/permitted/getAllSnaps.d.mts.map +1 -1
  48. package/dist/permitted/getAllSnaps.mjs +4 -1
  49. package/dist/permitted/getAllSnaps.mjs.map +1 -1
  50. package/dist/permitted/getBackgroundEvents.cjs +24 -0
  51. package/dist/permitted/getBackgroundEvents.cjs.map +1 -1
  52. package/dist/permitted/getBackgroundEvents.d.cts +48 -3
  53. package/dist/permitted/getBackgroundEvents.d.cts.map +1 -1
  54. package/dist/permitted/getBackgroundEvents.d.mts +48 -3
  55. package/dist/permitted/getBackgroundEvents.d.mts.map +1 -1
  56. package/dist/permitted/getBackgroundEvents.mjs +24 -0
  57. package/dist/permitted/getBackgroundEvents.mjs.map +1 -1
  58. package/dist/permitted/getClientStatus.cjs +27 -2
  59. package/dist/permitted/getClientStatus.cjs.map +1 -1
  60. package/dist/permitted/getClientStatus.d.cts +50 -4
  61. package/dist/permitted/getClientStatus.d.cts.map +1 -1
  62. package/dist/permitted/getClientStatus.d.mts +50 -4
  63. package/dist/permitted/getClientStatus.d.mts.map +1 -1
  64. package/dist/permitted/getClientStatus.mjs +27 -2
  65. package/dist/permitted/getClientStatus.mjs.map +1 -1
  66. package/dist/permitted/getFile.cjs +28 -1
  67. package/dist/permitted/getFile.cjs.map +1 -1
  68. package/dist/permitted/getFile.d.cts +49 -3
  69. package/dist/permitted/getFile.d.cts.map +1 -1
  70. package/dist/permitted/getFile.d.mts +49 -3
  71. package/dist/permitted/getFile.d.mts.map +1 -1
  72. package/dist/permitted/getFile.mjs +28 -1
  73. package/dist/permitted/getFile.mjs.map +1 -1
  74. package/dist/permitted/getInterfaceContext.cjs +49 -3
  75. package/dist/permitted/getInterfaceContext.cjs.map +1 -1
  76. package/dist/permitted/getInterfaceContext.d.cts +65 -3
  77. package/dist/permitted/getInterfaceContext.d.cts.map +1 -1
  78. package/dist/permitted/getInterfaceContext.d.mts +65 -3
  79. package/dist/permitted/getInterfaceContext.d.mts.map +1 -1
  80. package/dist/permitted/getInterfaceContext.mjs +50 -4
  81. package/dist/permitted/getInterfaceContext.mjs.map +1 -1
  82. package/dist/permitted/getInterfaceState.cjs +27 -3
  83. package/dist/permitted/getInterfaceState.cjs.map +1 -1
  84. package/dist/permitted/getInterfaceState.d.cts +43 -3
  85. package/dist/permitted/getInterfaceState.d.cts.map +1 -1
  86. package/dist/permitted/getInterfaceState.d.mts +43 -3
  87. package/dist/permitted/getInterfaceState.d.mts.map +1 -1
  88. package/dist/permitted/getInterfaceState.mjs +28 -4
  89. package/dist/permitted/getInterfaceState.mjs.map +1 -1
  90. package/dist/permitted/getSnaps.cjs +21 -2
  91. package/dist/permitted/getSnaps.cjs.map +1 -1
  92. package/dist/permitted/getSnaps.d.cts +42 -4
  93. package/dist/permitted/getSnaps.d.cts.map +1 -1
  94. package/dist/permitted/getSnaps.d.mts +42 -4
  95. package/dist/permitted/getSnaps.d.mts.map +1 -1
  96. package/dist/permitted/getSnaps.mjs +21 -2
  97. package/dist/permitted/getSnaps.mjs.map +1 -1
  98. package/dist/permitted/getState.cjs +24 -2
  99. package/dist/permitted/getState.cjs.map +1 -1
  100. package/dist/permitted/getState.d.cts +46 -4
  101. package/dist/permitted/getState.d.cts.map +1 -1
  102. package/dist/permitted/getState.d.mts +46 -4
  103. package/dist/permitted/getState.d.mts.map +1 -1
  104. package/dist/permitted/getState.mjs +24 -2
  105. package/dist/permitted/getState.mjs.map +1 -1
  106. package/dist/permitted/getWebSockets.cjs +29 -2
  107. package/dist/permitted/getWebSockets.cjs.map +1 -1
  108. package/dist/permitted/getWebSockets.d.cts +50 -4
  109. package/dist/permitted/getWebSockets.d.cts.map +1 -1
  110. package/dist/permitted/getWebSockets.d.mts +50 -4
  111. package/dist/permitted/getWebSockets.d.mts.map +1 -1
  112. package/dist/permitted/getWebSockets.mjs +29 -2
  113. package/dist/permitted/getWebSockets.mjs.map +1 -1
  114. package/dist/permitted/handlers.cjs +0 -4
  115. package/dist/permitted/handlers.cjs.map +1 -1
  116. package/dist/permitted/handlers.d.cts +274 -56
  117. package/dist/permitted/handlers.d.cts.map +1 -1
  118. package/dist/permitted/handlers.d.mts +274 -56
  119. package/dist/permitted/handlers.d.mts.map +1 -1
  120. package/dist/permitted/handlers.mjs +0 -4
  121. package/dist/permitted/handlers.mjs.map +1 -1
  122. package/dist/permitted/index.cjs.map +1 -1
  123. package/dist/permitted/index.d.cts +1 -3
  124. package/dist/permitted/index.d.cts.map +1 -1
  125. package/dist/permitted/index.d.mts +1 -3
  126. package/dist/permitted/index.d.mts.map +1 -1
  127. package/dist/permitted/index.mjs.map +1 -1
  128. package/dist/permitted/invokeKeyring.cjs +8 -2
  129. package/dist/permitted/invokeKeyring.cjs.map +1 -1
  130. package/dist/permitted/invokeKeyring.d.cts +34 -4
  131. package/dist/permitted/invokeKeyring.d.cts.map +1 -1
  132. package/dist/permitted/invokeKeyring.d.mts +34 -4
  133. package/dist/permitted/invokeKeyring.d.mts.map +1 -1
  134. package/dist/permitted/invokeKeyring.mjs +8 -2
  135. package/dist/permitted/invokeKeyring.mjs.map +1 -1
  136. package/dist/permitted/invokeSnapSugar.cjs +25 -2
  137. package/dist/permitted/invokeSnapSugar.cjs.map +1 -1
  138. package/dist/permitted/invokeSnapSugar.d.cts +30 -3
  139. package/dist/permitted/invokeSnapSugar.d.cts.map +1 -1
  140. package/dist/permitted/invokeSnapSugar.d.mts +30 -3
  141. package/dist/permitted/invokeSnapSugar.d.mts.map +1 -1
  142. package/dist/permitted/invokeSnapSugar.mjs +25 -2
  143. package/dist/permitted/invokeSnapSugar.mjs.map +1 -1
  144. package/dist/permitted/listEntropySources.cjs +40 -1
  145. package/dist/permitted/listEntropySources.cjs.map +1 -1
  146. package/dist/permitted/listEntropySources.d.cts +64 -3
  147. package/dist/permitted/listEntropySources.d.cts.map +1 -1
  148. package/dist/permitted/listEntropySources.d.mts +64 -3
  149. package/dist/permitted/listEntropySources.d.mts.map +1 -1
  150. package/dist/permitted/listEntropySources.mjs +40 -1
  151. package/dist/permitted/listEntropySources.mjs.map +1 -1
  152. package/dist/permitted/openWebSocket.cjs +46 -2
  153. package/dist/permitted/openWebSocket.cjs.map +1 -1
  154. package/dist/permitted/openWebSocket.d.cts +66 -4
  155. package/dist/permitted/openWebSocket.d.cts.map +1 -1
  156. package/dist/permitted/openWebSocket.d.mts +66 -4
  157. package/dist/permitted/openWebSocket.d.mts.map +1 -1
  158. package/dist/permitted/openWebSocket.mjs +46 -2
  159. package/dist/permitted/openWebSocket.mjs.map +1 -1
  160. package/dist/permitted/requestSnaps.cjs +25 -2
  161. package/dist/permitted/requestSnaps.cjs.map +1 -1
  162. package/dist/permitted/requestSnaps.d.cts +51 -3
  163. package/dist/permitted/requestSnaps.d.cts.map +1 -1
  164. package/dist/permitted/requestSnaps.d.mts +51 -3
  165. package/dist/permitted/requestSnaps.d.mts.map +1 -1
  166. package/dist/permitted/requestSnaps.mjs +25 -2
  167. package/dist/permitted/requestSnaps.mjs.map +1 -1
  168. package/dist/permitted/resolveInterface.cjs +38 -2
  169. package/dist/permitted/resolveInterface.cjs.map +1 -1
  170. package/dist/permitted/resolveInterface.d.cts +55 -4
  171. package/dist/permitted/resolveInterface.d.cts.map +1 -1
  172. package/dist/permitted/resolveInterface.d.mts +55 -4
  173. package/dist/permitted/resolveInterface.d.mts.map +1 -1
  174. package/dist/permitted/resolveInterface.mjs +39 -3
  175. package/dist/permitted/resolveInterface.mjs.map +1 -1
  176. package/dist/permitted/scheduleBackgroundEvent.cjs +26 -0
  177. package/dist/permitted/scheduleBackgroundEvent.cjs.map +1 -1
  178. package/dist/permitted/scheduleBackgroundEvent.d.cts +49 -3
  179. package/dist/permitted/scheduleBackgroundEvent.d.cts.map +1 -1
  180. package/dist/permitted/scheduleBackgroundEvent.d.mts +49 -3
  181. package/dist/permitted/scheduleBackgroundEvent.d.mts.map +1 -1
  182. package/dist/permitted/scheduleBackgroundEvent.mjs +26 -0
  183. package/dist/permitted/scheduleBackgroundEvent.mjs.map +1 -1
  184. package/dist/permitted/sendWebSocketMessage.cjs +24 -2
  185. package/dist/permitted/sendWebSocketMessage.cjs.map +1 -1
  186. package/dist/permitted/sendWebSocketMessage.d.cts +44 -4
  187. package/dist/permitted/sendWebSocketMessage.d.cts.map +1 -1
  188. package/dist/permitted/sendWebSocketMessage.d.mts +44 -4
  189. package/dist/permitted/sendWebSocketMessage.d.mts.map +1 -1
  190. package/dist/permitted/sendWebSocketMessage.mjs +24 -2
  191. package/dist/permitted/sendWebSocketMessage.mjs.map +1 -1
  192. package/dist/permitted/setState.cjs +48 -2
  193. package/dist/permitted/setState.cjs.map +1 -1
  194. package/dist/permitted/setState.d.cts +72 -4
  195. package/dist/permitted/setState.d.cts.map +1 -1
  196. package/dist/permitted/setState.d.mts +72 -4
  197. package/dist/permitted/setState.d.mts.map +1 -1
  198. package/dist/permitted/setState.mjs +48 -2
  199. package/dist/permitted/setState.mjs.map +1 -1
  200. package/dist/permitted/startTrace.cjs +4 -1
  201. package/dist/permitted/startTrace.cjs.map +1 -1
  202. package/dist/permitted/startTrace.d.cts +26 -3
  203. package/dist/permitted/startTrace.d.cts.map +1 -1
  204. package/dist/permitted/startTrace.d.mts +26 -3
  205. package/dist/permitted/startTrace.d.mts.map +1 -1
  206. package/dist/permitted/startTrace.mjs +4 -1
  207. package/dist/permitted/startTrace.mjs.map +1 -1
  208. package/dist/permitted/trackError.cjs +4 -1
  209. package/dist/permitted/trackError.cjs.map +1 -1
  210. package/dist/permitted/trackError.d.cts +26 -3
  211. package/dist/permitted/trackError.d.cts.map +1 -1
  212. package/dist/permitted/trackError.d.mts +26 -3
  213. package/dist/permitted/trackError.d.mts.map +1 -1
  214. package/dist/permitted/trackError.mjs +4 -1
  215. package/dist/permitted/trackError.mjs.map +1 -1
  216. package/dist/permitted/trackEvent.cjs +4 -1
  217. package/dist/permitted/trackEvent.cjs.map +1 -1
  218. package/dist/permitted/trackEvent.d.cts +25 -4
  219. package/dist/permitted/trackEvent.d.cts.map +1 -1
  220. package/dist/permitted/trackEvent.d.mts +25 -4
  221. package/dist/permitted/trackEvent.d.mts.map +1 -1
  222. package/dist/permitted/trackEvent.mjs +4 -1
  223. package/dist/permitted/trackEvent.mjs.map +1 -1
  224. package/dist/permitted/updateInterface.cjs +47 -2
  225. package/dist/permitted/updateInterface.cjs.map +1 -1
  226. package/dist/permitted/updateInterface.d.cts +64 -3
  227. package/dist/permitted/updateInterface.d.cts.map +1 -1
  228. package/dist/permitted/updateInterface.d.mts +64 -3
  229. package/dist/permitted/updateInterface.d.mts.map +1 -1
  230. package/dist/permitted/updateInterface.mjs +48 -3
  231. package/dist/permitted/updateInterface.mjs.map +1 -1
  232. package/dist/restricted/caveats/snapIds.cjs.map +1 -1
  233. package/dist/restricted/caveats/snapIds.d.cts.map +1 -1
  234. package/dist/restricted/caveats/snapIds.d.mts.map +1 -1
  235. package/dist/restricted/caveats/snapIds.mjs.map +1 -1
  236. package/dist/restricted/dialog.cjs +49 -1
  237. package/dist/restricted/dialog.cjs.map +1 -1
  238. package/dist/restricted/dialog.d.cts +52 -2
  239. package/dist/restricted/dialog.d.cts.map +1 -1
  240. package/dist/restricted/dialog.d.mts +52 -2
  241. package/dist/restricted/dialog.d.mts.map +1 -1
  242. package/dist/restricted/dialog.mjs +49 -1
  243. package/dist/restricted/dialog.mjs.map +1 -1
  244. package/dist/restricted/getBip32Entropy.cjs +55 -0
  245. package/dist/restricted/getBip32Entropy.cjs.map +1 -1
  246. package/dist/restricted/getBip32Entropy.d.cts +55 -0
  247. package/dist/restricted/getBip32Entropy.d.cts.map +1 -1
  248. package/dist/restricted/getBip32Entropy.d.mts +55 -0
  249. package/dist/restricted/getBip32Entropy.d.mts.map +1 -1
  250. package/dist/restricted/getBip32Entropy.mjs +55 -0
  251. package/dist/restricted/getBip32Entropy.mjs.map +1 -1
  252. package/dist/restricted/getBip32PublicKey.cjs +36 -0
  253. package/dist/restricted/getBip32PublicKey.cjs.map +1 -1
  254. package/dist/restricted/getBip32PublicKey.d.cts +36 -0
  255. package/dist/restricted/getBip32PublicKey.d.cts.map +1 -1
  256. package/dist/restricted/getBip32PublicKey.d.mts +36 -0
  257. package/dist/restricted/getBip32PublicKey.d.mts.map +1 -1
  258. package/dist/restricted/getBip32PublicKey.mjs +36 -0
  259. package/dist/restricted/getBip32PublicKey.mjs.map +1 -1
  260. package/dist/restricted/getBip44Entropy.cjs +53 -0
  261. package/dist/restricted/getBip44Entropy.cjs.map +1 -1
  262. package/dist/restricted/getBip44Entropy.d.cts +53 -0
  263. package/dist/restricted/getBip44Entropy.d.cts.map +1 -1
  264. package/dist/restricted/getBip44Entropy.d.mts +53 -0
  265. package/dist/restricted/getBip44Entropy.d.mts.map +1 -1
  266. package/dist/restricted/getBip44Entropy.mjs +53 -0
  267. package/dist/restricted/getBip44Entropy.mjs.map +1 -1
  268. package/dist/restricted/getEntropy.cjs +35 -0
  269. package/dist/restricted/getEntropy.cjs.map +1 -1
  270. package/dist/restricted/getEntropy.d.cts +35 -0
  271. package/dist/restricted/getEntropy.d.cts.map +1 -1
  272. package/dist/restricted/getEntropy.d.mts +35 -0
  273. package/dist/restricted/getEntropy.d.mts.map +1 -1
  274. package/dist/restricted/getEntropy.mjs +35 -0
  275. package/dist/restricted/getEntropy.mjs.map +1 -1
  276. package/dist/restricted/getLocale.cjs +11 -0
  277. package/dist/restricted/getLocale.cjs.map +1 -1
  278. package/dist/restricted/getLocale.d.cts +11 -0
  279. package/dist/restricted/getLocale.d.cts.map +1 -1
  280. package/dist/restricted/getLocale.d.mts +11 -0
  281. package/dist/restricted/getLocale.d.mts.map +1 -1
  282. package/dist/restricted/getLocale.mjs +11 -0
  283. package/dist/restricted/getLocale.mjs.map +1 -1
  284. package/dist/restricted/getPreferences.cjs +24 -0
  285. package/dist/restricted/getPreferences.cjs.map +1 -1
  286. package/dist/restricted/getPreferences.d.cts +24 -0
  287. package/dist/restricted/getPreferences.d.cts.map +1 -1
  288. package/dist/restricted/getPreferences.d.mts +24 -0
  289. package/dist/restricted/getPreferences.d.mts.map +1 -1
  290. package/dist/restricted/getPreferences.mjs +24 -0
  291. package/dist/restricted/getPreferences.mjs.map +1 -1
  292. package/dist/restricted/index.d.cts +2 -2
  293. package/dist/restricted/index.d.mts +2 -2
  294. package/dist/restricted/invokeSnap.cjs +24 -2
  295. package/dist/restricted/invokeSnap.cjs.map +1 -1
  296. package/dist/restricted/invokeSnap.d.cts +29 -11
  297. package/dist/restricted/invokeSnap.d.cts.map +1 -1
  298. package/dist/restricted/invokeSnap.d.mts +29 -11
  299. package/dist/restricted/invokeSnap.d.mts.map +1 -1
  300. package/dist/restricted/invokeSnap.mjs +24 -2
  301. package/dist/restricted/invokeSnap.mjs.map +1 -1
  302. package/dist/restricted/manageAccounts.cjs +10 -0
  303. package/dist/restricted/manageAccounts.cjs.map +1 -1
  304. package/dist/restricted/manageAccounts.d.cts +10 -0
  305. package/dist/restricted/manageAccounts.d.cts.map +1 -1
  306. package/dist/restricted/manageAccounts.d.mts +10 -0
  307. package/dist/restricted/manageAccounts.d.mts.map +1 -1
  308. package/dist/restricted/manageAccounts.mjs +10 -0
  309. package/dist/restricted/manageAccounts.mjs.map +1 -1
  310. package/dist/restricted/manageState.cjs +42 -0
  311. package/dist/restricted/manageState.cjs.map +1 -1
  312. package/dist/restricted/manageState.d.cts +42 -0
  313. package/dist/restricted/manageState.d.cts.map +1 -1
  314. package/dist/restricted/manageState.d.mts +42 -0
  315. package/dist/restricted/manageState.d.mts.map +1 -1
  316. package/dist/restricted/manageState.mjs +42 -0
  317. package/dist/restricted/manageState.mjs.map +1 -1
  318. package/dist/restricted/notify.cjs +74 -0
  319. package/dist/restricted/notify.cjs.map +1 -1
  320. package/dist/restricted/notify.d.cts +75 -1
  321. package/dist/restricted/notify.d.cts.map +1 -1
  322. package/dist/restricted/notify.d.mts +75 -1
  323. package/dist/restricted/notify.d.mts.map +1 -1
  324. package/dist/restricted/notify.mjs +74 -0
  325. package/dist/restricted/notify.mjs.map +1 -1
  326. package/dist/utils.cjs +14 -1
  327. package/dist/utils.cjs.map +1 -1
  328. package/dist/utils.d.cts +6 -0
  329. package/dist/utils.d.cts.map +1 -1
  330. package/dist/utils.d.mts +6 -0
  331. package/dist/utils.d.mts.map +1 -1
  332. package/dist/utils.mjs +13 -0
  333. package/dist/utils.mjs.map +1 -1
  334. package/package.json +12 -8
  335. package/dist/permitted/experimentalProviderRequest.cjs +0 -152
  336. package/dist/permitted/experimentalProviderRequest.cjs.map +0 -1
  337. package/dist/permitted/experimentalProviderRequest.d.cts +0 -39
  338. package/dist/permitted/experimentalProviderRequest.d.cts.map +0 -1
  339. package/dist/permitted/experimentalProviderRequest.d.mts +0 -39
  340. package/dist/permitted/experimentalProviderRequest.d.mts.map +0 -1
  341. package/dist/permitted/experimentalProviderRequest.mjs +0 -149
  342. package/dist/permitted/experimentalProviderRequest.mjs.map +0 -1
  343. package/dist/permitted/getCurrencyRate.cjs +0 -63
  344. package/dist/permitted/getCurrencyRate.cjs.map +0 -1
  345. package/dist/permitted/getCurrencyRate.d.cts +0 -20
  346. package/dist/permitted/getCurrencyRate.d.cts.map +0 -1
  347. package/dist/permitted/getCurrencyRate.d.mts +0 -20
  348. package/dist/permitted/getCurrencyRate.d.mts.map +0 -1
  349. package/dist/permitted/getCurrencyRate.mjs +0 -60
  350. package/dist/permitted/getCurrencyRate.mjs.map +0 -1
@@ -36,6 +36,59 @@ const methodHooks = {
36
36
  getUnlockPromise: true,
37
37
  getClientCryptography: true,
38
38
  };
39
+ /**
40
+ * Enables you to [manage users' non-EVM accounts](https://docs.metamask.io/snaps/features/non-evm-networks/)
41
+ * by deriving the [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)
42
+ * keys specified by the `coinType` parameter. The keys are derived using the
43
+ * entropy from the user's Secret Recovery Phrase.
44
+ *
45
+ * If the keys you want to derive don't conform to the BIP-44 structure, use
46
+ * [`snap_getBip32Entropy`](https://docs.metamask.io/snaps/reference/snaps-api/snap_getbip32entropy)
47
+ * instead.
48
+ *
49
+ * This method is designed to be used with the [`@metamask/key-tree`](https://npmjs.com/package/@metamask/key-tree)
50
+ * module. `@metamask/key-tree` can help you get the [extended private keys](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys)
51
+ * for user addresses, but it's your responsibility to know how to use those
52
+ * keys to, for example, derive an address for the relevant protocol or sign a
53
+ * transaction for the user.
54
+ *
55
+ * @example
56
+ * ```json name="Manifest"
57
+ * {
58
+ * "initialPermissions": {
59
+ * "snap_getBip44Entropy": [
60
+ * {
61
+ * "coinType": 3
62
+ * }
63
+ * ]
64
+ * }
65
+ * }
66
+ * ```
67
+ * ```ts name="Usage"
68
+ * import { getBIP44AddressKeyDeriver } from '@metamask/key-tree'
69
+ *
70
+ * // This example uses Dogecoin, which has coin_type 3.
71
+ * const dogecoinNode = await snap.request({
72
+ * method: 'snap_getBip44Entropy',
73
+ * params: {
74
+ * coinType: 3,
75
+ * },
76
+ * })
77
+ *
78
+ * // Next, create an address key deriver function for the Dogecoin coin_type
79
+ * // node. In this case, its path is: m/44'/3'/0'/0/address_index
80
+ * const deriveDogecoinAddress = await getBIP44AddressKeyDeriver(dogecoinNode)
81
+ *
82
+ * // These are BIP-44 nodes containing the extended private keys for the
83
+ * // respective derivation paths.
84
+ *
85
+ * // m/44'/3'/0'/0/0
86
+ * const addressKey0 = await deriveDogecoinAddress(0)
87
+ *
88
+ * // m/44'/3'/0'/0/1
89
+ * const addressKey1 = await deriveDogecoinAddress(1)
90
+ * ```
91
+ */
39
92
  export const getBip44EntropyBuilder = Object.freeze({
40
93
  targetName,
41
94
  specificationBuilder,
@@ -1 +1 @@
1
- {"version":3,"file":"getBip44Entropy.mjs","sourceRoot":"","sources":["../../src/restricted/getBip44Entropy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,2BAA2B;AAOvD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC;AAC9E,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAKjD,OAAO,EAAE,cAAc,EAAE,8BAA8B;AAIvD,OAAO,EAAE,yBAAyB,EAAE,qBAAiB;AAErD,MAAM,UAAU,GAAG,sBAAsB,CAAC;AA0C1C;;;;;;;;;GASG;AACH,MAAM,oBAAoB,GAItB,CAAC,EAAE,WAAW,EAA8C,EAAE,EAAE;IAClE,OAAO;QACL,cAAc,EAAE,cAAc,CAAC,gBAAgB;QAC/C,UAAU;QACV,cAAc,EAAE,CAAC,cAAc,CAAC,kBAAkB,CAAC;QACnD,oBAAoB,EAAE,6BAA6B,CAAC,WAAW,CAAC;QAChE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;YACzB,IACE,OAAO,EAAE,MAAM,KAAK,CAAC;gBACrB,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,kBAAkB,EACrD,CAAC;gBACD,MAAM,SAAS,CAAC,aAAa,CAAC;oBAC5B,OAAO,EAAE,sBAAsB,cAAc,CAAC,kBAAkB,WAAW;iBAC5E,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,YAAY,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,WAAW,GAAkD;IACjE,eAAe,EAAE,IAAI;IACrB,gBAAgB,EAAE,IAAI;IACtB,qBAAqB,EAAE,IAAI;CAC5B,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,CAAC;IAClD,UAAU;IACV,oBAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AAEZ;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,6BAA6B,CAAC,EAC5C,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACM;IAC3B,OAAO,KAAK,UAAU,eAAe,CACnC,IAAoD;QAEpD,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAE7B,4EAA4E;QAC5E,MAAM,MAAM,GAAG,IAAI,CAAC,MAA+B,CAAC;QACpD,MAAM,IAAI,GAAG,MAAM,yBAAyB,CAC1C,eAAe,EACf,MAAM,CAAC,MAAM,CACd,CAAC;QAEF,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,QAAQ,CAC3C;YACE,cAAc,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,MAAM,CAAC,QAAQ,GAAG,CAAC;YAChE,OAAO,EAAE,SAAS;SACnB,EACD,qBAAqB,EAAE,CACxB,CAAC;QAEF,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CryptographicFunctions } from '@metamask/key-tree';\nimport { 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';\nimport { getValueFromEntropySource } from '../utils';\n\nconst targetName = 'snap_getBip44Entropy';\n\nexport type GetBip44EntropyMethodHooks = {\n /**\n * Get the mnemonic seed of the provided source. If no source is provided, the\n * mnemonic seed of the primary keyring will be returned.\n *\n * @param source - The optional ID of the source to get the mnemonic of.\n * @returns The mnemonic seed of the provided source, or the default source if no\n * source is provided.\n */\n getMnemonicSeed: (source?: string | undefined) => 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 * Get the cryptographic functions to use for the client. This may return an\n * empty object or `undefined` to fall back to the default cryptographic\n * functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions | undefined;\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 getMnemonicSeed: true,\n getUnlockPromise: true,\n getClientCryptography: 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.getMnemonicSeed - A function to retrieve the BIP-39 seed\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 * @param hooks.getClientCryptography - A function to retrieve the cryptographic\n * functions to use for the client.\n * @returns The method implementation which returns a `BIP44CoinTypeNode`.\n * @throws If the params are invalid.\n */\nexport function getBip44EntropyImplementation({\n getMnemonicSeed,\n getUnlockPromise,\n getClientCryptography,\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 const seed = await getValueFromEntropySource(\n getMnemonicSeed,\n params.source,\n );\n\n const node = await BIP44CoinTypeNode.fromSeed(\n {\n derivationPath: [seed, `bip32:44'`, `bip32:${params.coinType}'`],\n network: 'mainnet',\n },\n getClientCryptography(),\n );\n\n return node.toJSON();\n };\n}\n"]}
1
+ {"version":3,"file":"getBip44Entropy.mjs","sourceRoot":"","sources":["../../src/restricted/getBip44Entropy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,2BAA2B;AAOvD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC;A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CACnC,IAAoD;QAEpD,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAE7B,4EAA4E;QAC5E,MAAM,MAAM,GAAG,IAAI,CAAC,MAA+B,CAAC;QACpD,MAAM,IAAI,GAAG,MAAM,yBAAyB,CAC1C,eAAe,EACf,MAAM,CAAC,MAAM,CACd,CAAC;QAEF,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,QAAQ,CAC3C;YACE,cAAc,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,MAAM,CAAC,QAAQ,GAAG,CAAC;YAChE,OAAO,EAAE,SAAS;SACnB,EACD,qBAAqB,EAAE,CACxB,CAAC;QAEF,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CryptographicFunctions } from '@metamask/key-tree';\nimport { 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';\nimport { getValueFromEntropySource } from '../utils';\n\nconst targetName = 'snap_getBip44Entropy';\n\nexport type GetBip44EntropyMethodHooks = {\n /**\n * Get the mnemonic seed of the provided source. If no source is provided, the\n * mnemonic seed of the primary keyring will be returned.\n *\n * @param source - The optional ID of the source to get the mnemonic of.\n * @returns The mnemonic seed of the provided source, or the default source if no\n * source is provided.\n */\n getMnemonicSeed: (source?: string | undefined) => 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 * Get the cryptographic functions to use for the client. This may return an\n * empty object or `undefined` to fall back to the default cryptographic\n * functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions | undefined;\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 getMnemonicSeed: true,\n getUnlockPromise: true,\n getClientCryptography: true,\n};\n\n/**\n * Enables you to [manage users' non-EVM accounts](https://docs.metamask.io/snaps/features/non-evm-networks/)\n * by deriving the [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)\n * keys specified by the `coinType` parameter. The keys are derived using the\n * entropy from the user's Secret Recovery Phrase.\n *\n * If the keys you want to derive don't conform to the BIP-44 structure, use\n * [`snap_getBip32Entropy`](https://docs.metamask.io/snaps/reference/snaps-api/snap_getbip32entropy)\n * instead.\n *\n * This method is designed to be used with the [`@metamask/key-tree`](https://npmjs.com/package/@metamask/key-tree)\n * module. `@metamask/key-tree` can help you get the [extended private keys](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys)\n * for user addresses, but it's your responsibility to know how to use those\n * keys to, for example, derive an address for the relevant protocol or sign a\n * transaction for the user.\n *\n * @example\n * ```json name=\"Manifest\"\n * {\n * \"initialPermissions\": {\n * \"snap_getBip44Entropy\": [\n * {\n * \"coinType\": 3\n * }\n * ]\n * }\n * }\n * ```\n * ```ts name=\"Usage\"\n * import { getBIP44AddressKeyDeriver } from '@metamask/key-tree'\n *\n * // This example uses Dogecoin, which has coin_type 3.\n * const dogecoinNode = await snap.request({\n * method: 'snap_getBip44Entropy',\n * params: {\n * coinType: 3,\n * },\n * })\n *\n * // Next, create an address key deriver function for the Dogecoin coin_type\n * // node. In this case, its path is: m/44'/3'/0'/0/address_index\n * const deriveDogecoinAddress = await getBIP44AddressKeyDeriver(dogecoinNode)\n *\n * // These are BIP-44 nodes containing the extended private keys for the\n * // respective derivation paths.\n *\n * // m/44'/3'/0'/0/0\n * const addressKey0 = await deriveDogecoinAddress(0)\n *\n * // m/44'/3'/0'/0/1\n * const addressKey1 = await deriveDogecoinAddress(1)\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.getMnemonicSeed - A function to retrieve the BIP-39 seed\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 * @param hooks.getClientCryptography - A function to retrieve the cryptographic\n * functions to use for the client.\n * @returns The method implementation which returns a `BIP44CoinTypeNode`.\n * @throws If the params are invalid.\n */\nexport function getBip44EntropyImplementation({\n getMnemonicSeed,\n getUnlockPromise,\n getClientCryptography,\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 const seed = await getValueFromEntropySource(\n getMnemonicSeed,\n params.source,\n );\n\n const node = await BIP44CoinTypeNode.fromSeed(\n {\n derivationPath: [seed, `bip32:44'`, `bip32:${params.coinType}'`],\n network: 'mainnet',\n },\n getClientCryptography(),\n );\n\n return node.toJSON();\n };\n}\n"]}
@@ -27,6 +27,41 @@ const methodHooks = {
27
27
  getUnlockPromise: true,
28
28
  getClientCryptography: true,
29
29
  };
30
+ /**
31
+ * Get a deterministic 256-bit entropy value, specific to the Snap and the
32
+ * user's account. You can use this entropy to generate a private key, or any
33
+ * other value that requires a high level of randomness. Other Snaps can't
34
+ * access this entropy, and it changes if the user's secret recovery phrase
35
+ * changes.
36
+ *
37
+ * You can optionally specify a salt to generate different entropy for different
38
+ * purposes. Using a salt results in entropy unrelated to the entropy generated
39
+ * without a salt.
40
+ *
41
+ * This value is deterministic: it's always the same for the same Snap, user
42
+ * account, and salt.
43
+ *
44
+ * @example
45
+ * ```json name="Manifest"
46
+ * {
47
+ * "initialPermissions": {
48
+ * "snap_getEntropy": {}
49
+ * }
50
+ * }
51
+ * ```
52
+ * ```ts name="Usage"
53
+ * const entropy = await snap.request({
54
+ * method: 'snap_getEntropy',
55
+ * params: {
56
+ * version: 1,
57
+ * salt: 'foo', // Optional.
58
+ * },
59
+ * })
60
+ *
61
+ * // '0x...'
62
+ * console.log(entropy)
63
+ * ```
64
+ */
30
65
  exports.getEntropyBuilder = Object.freeze({
31
66
  targetName,
32
67
  specificationBuilder,
@@ -1 +1 @@
1
- {"version":3,"file":"getEntropy.cjs","sourceRoot":"","sources":["../../src/restricted/getEntropy.ts"],"names":[],"mappings":";;;AAMA,2EAA8E;AAC9E,qDAAiD;AAEjD,uDAA0D;AAE1D,uDAA0E;AAE1E,2CAA+C;AAG/C,wCAA4E;AAE5E,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAcxB,QAAA,oBAAoB,GAAG,IAAA,oBAAM,EAAC;IACzC,OAAO,EAAE,IAAA,qBAAO,EAAC,CAAC,CAAC;IACnB,IAAI,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IACxB,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CAC3B,CAAC,CAAC;AAUH,MAAM,oBAAoB,GAItB,CAAC,EACH,cAAc,GAAG,IAAI,EACrB,WAAW,GAC2B,EAAE,EAAE;IAC1C,OAAO;QACL,cAAc,EAAE,sCAAc,CAAC,gBAAgB;QAC/C,UAAU;QACV,cAAc;QACd,oBAAoB,EAAE,wBAAwB,CAAC,WAAW,CAAC;QAC3D,YAAY,EAAE,CAAC,mCAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,WAAW,GAAuC;IACtD,eAAe,EAAE,IAAI;IACrB,gBAAgB,EAAE,IAAI;IACtB,qBAAqB,EAAE,IAAI;CAC5B,CAAC;AAEW,QAAA,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,UAAU;IACV,oBAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AA8BZ;;;;;;;;;;;;;GAaG;AACH,SAAS,wBAAwB,CAAC,EAChC,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACL;IAChB,OAAO,KAAK,UAAU,UAAU,CAC9B,OAAkD;QAElD,MAAM,EACJ,MAAM,EACN,OAAO,EAAE,EAAE,MAAM,EAAE,GACpB,GAAG,OAAO,CAAC;QAEZ,IAAA,oBAAY,EACV,MAAM,EACN,4BAAoB,EACpB,sCAAsC,EACtC,sBAAS,CAAC,aAAa,CACxB,CAAC;QAEF,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,IAAI,GAAG,MAAM,IAAA,iCAAyB,EAC1C,eAAe,EACf,MAAM,CAAC,MAAM,CACd,CAAC;QAEF,OAAO,IAAA,6BAAqB,EAAC;YAC3B,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI;YACJ,KAAK,EAAE,+BAAiB;YACxB,sBAAsB,EAAE,qBAAqB,EAAE;SAChD,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CryptographicFunctions } from '@metamask/key-tree';\nimport 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 { Infer } from '@metamask/superstruct';\nimport { literal, object, optional, string } from '@metamask/superstruct';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport { getValueFromEntropySource, deriveEntropyFromSeed } 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 source: 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 getMnemonicSeed: true,\n getUnlockPromise: true,\n getClientCryptography: true,\n};\n\nexport const getEntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\nexport type GetEntropyHooks = {\n /**\n * Get the mnemonic seed of the provided source. If no source is provided, the\n * mnemonic seed of the primary keyring will be returned.\n *\n * @param source - The optional ID of the source to get the mnemonic of.\n * @returns The mnemonic seed of the provided source, or the default source if no\n * source is provided.\n */\n getMnemonicSeed: (source?: string | undefined) => 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 * Get the cryptographic functions to use for the client. This may return an\n * empty object or `undefined` to fall back to the default cryptographic\n * functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions | undefined;\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.getMnemonicSeed - A function to retrieve the BIP-39 seed\n * of the user.\n * @param hooks.getUnlockPromise - The method to get a promise that resolves\n * once the extension is unlocked.\n * @param hooks.getClientCryptography - A function to retrieve the cryptographic\n * functions to use for the client.\n * @returns The method implementation.\n */\nfunction getEntropyImplementation({\n getMnemonicSeed,\n getUnlockPromise,\n getClientCryptography,\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 seed = await getValueFromEntropySource(\n getMnemonicSeed,\n params.source,\n );\n\n return deriveEntropyFromSeed({\n input: origin,\n salt: params.salt,\n seed,\n magic: SIP_6_MAGIC_VALUE,\n cryptographicFunctions: getClientCryptography(),\n });\n };\n}\n"]}
1
+ {"version":3,"file":"getEntropy.cjs","sourceRoot":"","sources":["../../src/restricted/getEntropy.ts"],"names":[],"mappings":";;;AAMA,2EAA8E;AAC9E,qDAAiD;AAEjD,uDAA0D;AAE1D,uDAA0E;AAE1E,2CAA+C;AAG/C,wCAA4E;AAE5E,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAcxB,QAAA,oBAAoB,GAAG,IAAA,oBAAM,EAAC;IACzC,OAAO,EAAE,IAAA,qBAAO,EAAC,CAAC,CAAC;IACnB,IAAI,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IACxB,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CAC3B,CAAC,CAAC;AAUH,MAAM,oBAAoB,GAItB,CAAC,EACH,cAAc,GAAG,IAAI,EACrB,WAAW,GAC2B,EAAE,EAAE;IAC1C,OAAO;QACL,cAAc,EAAE,sCAAc,CAAC,gBAAgB;QAC/C,UAAU;QACV,cAAc;QACd,oBAAoB,EAAE,wBAAwB,CAAC,WAAW,CAAC;QAC3D,YAAY,EAAE,CAAC,mCAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,WAAW,GAAuC;IACtD,eAAe,EAAE,IAAI;IACrB,gBAAgB,EAAE,IAAI;IACtB,qBAAqB,EAAE,IAAI;CAC5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACU,QAAA,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,UAAU;IACV,oBAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AA8BZ;;;;;;;;;;;;;GAaG;AACH,SAAS,wBAAwB,CAAC,EAChC,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACL;IAChB,OAAO,KAAK,UAAU,UAAU,CAC9B,OAAkD;QAElD,MAAM,EACJ,MAAM,EACN,OAAO,EAAE,EAAE,MAAM,EAAE,GACpB,GAAG,OAAO,CAAC;QAEZ,IAAA,oBAAY,EACV,MAAM,EACN,4BAAoB,EACpB,sCAAsC,EACtC,sBAAS,CAAC,aAAa,CACxB,CAAC;QAEF,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,IAAI,GAAG,MAAM,IAAA,iCAAyB,EAC1C,eAAe,EACf,MAAM,CAAC,MAAM,CACd,CAAC;QAEF,OAAO,IAAA,6BAAqB,EAAC;YAC3B,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI;YACJ,KAAK,EAAE,+BAAiB;YACxB,sBAAsB,EAAE,qBAAqB,EAAE;SAChD,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CryptographicFunctions } from '@metamask/key-tree';\nimport 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 { Infer } from '@metamask/superstruct';\nimport { literal, object, optional, string } from '@metamask/superstruct';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport { getValueFromEntropySource, deriveEntropyFromSeed } 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 source: 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 getMnemonicSeed: true,\n getUnlockPromise: true,\n getClientCryptography: true,\n};\n\n/**\n * Get a deterministic 256-bit entropy value, specific to the Snap and the\n * user's account. You can use this entropy to generate a private key, or any\n * other value that requires a high level of randomness. Other Snaps can't\n * access this entropy, and it changes if the user's secret recovery phrase\n * changes.\n *\n * You can optionally specify a salt to generate different entropy for different\n * purposes. Using a salt results in entropy unrelated to the entropy generated\n * without a salt.\n *\n * This value is deterministic: it's always the same for the same Snap, user\n * account, and salt.\n *\n * @example\n * ```json name=\"Manifest\"\n * {\n * \"initialPermissions\": {\n * \"snap_getEntropy\": {}\n * }\n * }\n * ```\n * ```ts name=\"Usage\"\n * const entropy = await snap.request({\n * method: 'snap_getEntropy',\n * params: {\n * version: 1,\n * salt: 'foo', // Optional.\n * },\n * })\n *\n * // '0x...'\n * console.log(entropy)\n * ```\n */\nexport const getEntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\nexport type GetEntropyHooks = {\n /**\n * Get the mnemonic seed of the provided source. If no source is provided, the\n * mnemonic seed of the primary keyring will be returned.\n *\n * @param source - The optional ID of the source to get the mnemonic of.\n * @returns The mnemonic seed of the provided source, or the default source if no\n * source is provided.\n */\n getMnemonicSeed: (source?: string | undefined) => 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 * Get the cryptographic functions to use for the client. This may return an\n * empty object or `undefined` to fall back to the default cryptographic\n * functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions | undefined;\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.getMnemonicSeed - A function to retrieve the BIP-39 seed\n * of the user.\n * @param hooks.getUnlockPromise - The method to get a promise that resolves\n * once the extension is unlocked.\n * @param hooks.getClientCryptography - A function to retrieve the cryptographic\n * functions to use for the client.\n * @returns The method implementation.\n */\nfunction getEntropyImplementation({\n getMnemonicSeed,\n getUnlockPromise,\n getClientCryptography,\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 seed = await getValueFromEntropySource(\n getMnemonicSeed,\n params.source,\n );\n\n return deriveEntropyFromSeed({\n input: origin,\n salt: params.salt,\n seed,\n magic: SIP_6_MAGIC_VALUE,\n cryptographicFunctions: getClientCryptography(),\n });\n };\n}\n"]}
@@ -26,6 +26,41 @@ export declare const GetEntropyArgsStruct: import("@metamask/superstruct").Struc
26
26
  * omitted, the salt will be an empty string.
27
27
  */
28
28
  export type GetEntropyArgs = Infer<typeof GetEntropyArgsStruct>;
29
+ /**
30
+ * Get a deterministic 256-bit entropy value, specific to the Snap and the
31
+ * user's account. You can use this entropy to generate a private key, or any
32
+ * other value that requires a high level of randomness. Other Snaps can't
33
+ * access this entropy, and it changes if the user's secret recovery phrase
34
+ * changes.
35
+ *
36
+ * You can optionally specify a salt to generate different entropy for different
37
+ * purposes. Using a salt results in entropy unrelated to the entropy generated
38
+ * without a salt.
39
+ *
40
+ * This value is deterministic: it's always the same for the same Snap, user
41
+ * account, and salt.
42
+ *
43
+ * @example
44
+ * ```json name="Manifest"
45
+ * {
46
+ * "initialPermissions": {
47
+ * "snap_getEntropy": {}
48
+ * }
49
+ * }
50
+ * ```
51
+ * ```ts name="Usage"
52
+ * const entropy = await snap.request({
53
+ * method: 'snap_getEntropy',
54
+ * params: {
55
+ * version: 1,
56
+ * salt: 'foo', // Optional.
57
+ * },
58
+ * })
59
+ *
60
+ * // '0x...'
61
+ * console.log(entropy)
62
+ * ```
63
+ */
29
64
  export declare const getEntropyBuilder: Readonly<{
30
65
  readonly targetName: "snap_getEntropy";
31
66
  readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, GetEntropySpecificationBuilderOptions, {
@@ -1 +1 @@
1
- {"version":3,"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M,CAAC,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAEtE;;;;OAIG;IACH,gBAAgB,EAAE,CAAC,uBAAuB,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtE;;;;;;OAMG;IACH,qBAAqB,EAAE,MAAM,sBAAsB,GAAG,SAAS,CAAC;CACjE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,iBAAS,wBAAwB,CAAC,EAChC,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACtB,EAAE,eAAe,aAEL,wBAAwB,gBAAgB,CAAC,KACjD,QAAQ,gBAAgB,CAAC,CA2B7B"}
@@ -26,6 +26,41 @@ export declare const GetEntropyArgsStruct: import("@metamask/superstruct").Struc
26
26
  * omitted, the salt will be an empty string.
27
27
  */
28
28
  export type GetEntropyArgs = Infer<typeof GetEntropyArgsStruct>;
29
+ /**
30
+ * Get a deterministic 256-bit entropy value, specific to the Snap and the
31
+ * user's account. You can use this entropy to generate a private key, or any
32
+ * other value that requires a high level of randomness. Other Snaps can't
33
+ * access this entropy, and it changes if the user's secret recovery phrase
34
+ * changes.
35
+ *
36
+ * You can optionally specify a salt to generate different entropy for different
37
+ * purposes. Using a salt results in entropy unrelated to the entropy generated
38
+ * without a salt.
39
+ *
40
+ * This value is deterministic: it's always the same for the same Snap, user
41
+ * account, and salt.
42
+ *
43
+ * @example
44
+ * ```json name="Manifest"
45
+ * {
46
+ * "initialPermissions": {
47
+ * "snap_getEntropy": {}
48
+ * }
49
+ * }
50
+ * ```
51
+ * ```ts name="Usage"
52
+ * const entropy = await snap.request({
53
+ * method: 'snap_getEntropy',
54
+ * params: {
55
+ * version: 1,
56
+ * salt: 'foo', // Optional.
57
+ * },
58
+ * })
59
+ *
60
+ * // '0x...'
61
+ * console.log(entropy)
62
+ * ```
63
+ */
29
64
  export declare const getEntropyBuilder: Readonly<{
30
65
  readonly targetName: "snap_getEntropy";
31
66
  readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, GetEntropySpecificationBuilderOptions, {
@@ -1 +1 @@
1
- {"version":3,"file":"getEntropy.d.mts","sourceRoot":"","sources":["../../src/restricted/getEntropy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AACjE,OAAO,KAAK,EACV,8BAA8B,EAC9B,uBAAuB,EAExB,wCAAwC;AACzC,OAAO,EAAE,cAAc,EAAe,wCAAwC;AAE9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,4BAA4B;AAE9E,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAGlD,QAAA,MAAM,UAAU,oBAAoB,CAAC;AAErC,KAAK,qCAAqC,GAAG;IAC3C,cAAc,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IACxD,WAAW,EAAE,eAAe,CAAC;CAC9B,CAAC;AASF,eAAO,MAAM,oBAAoB;;;;;;;;EAI/B,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAyBhE,eAAO,MAAM,iBAAiB;;;wBA3CZ,eAAe,gBAAgB;oBACnC,iBAAiB;8BACP,WAAW,+BAA+B,CAAC;wBACjD,SAAS,cAAc,MAAM,CAAC,CAAC,GAAG,IAAI;;;EA4C7C,CAAC;AAEZ,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;OAOG;IACH,eAAe,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAEtE;;;;OAIG;IACH,gBAAgB,EAAE,CAAC,uBAAuB,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CA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E7C,CAAC;AAEZ,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;OAOG;IACH,eAAe,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAEtE;;;;OAIG;IACH,gBAAgB,EAAE,CAAC,uBAAuB,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtE;;;;;;OAMG;IACH,qBAAqB,EAAE,MAAM,sBAAsB,GAAG,SAAS,CAAC;CACjE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,iBAAS,wBAAwB,CAAC,EAChC,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACtB,EAAE,eAAe,aAEL,wBAAwB,gBAAgB,CAAC,KACjD,QAAQ,gBAAgB,CAAC,CA2B7B"}
@@ -24,6 +24,41 @@ const methodHooks = {
24
24
  getUnlockPromise: true,
25
25
  getClientCryptography: true,
26
26
  };
27
+ /**
28
+ * Get a deterministic 256-bit entropy value, specific to the Snap and the
29
+ * user's account. You can use this entropy to generate a private key, or any
30
+ * other value that requires a high level of randomness. Other Snaps can't
31
+ * access this entropy, and it changes if the user's secret recovery phrase
32
+ * changes.
33
+ *
34
+ * You can optionally specify a salt to generate different entropy for different
35
+ * purposes. Using a salt results in entropy unrelated to the entropy generated
36
+ * without a salt.
37
+ *
38
+ * This value is deterministic: it's always the same for the same Snap, user
39
+ * account, and salt.
40
+ *
41
+ * @example
42
+ * ```json name="Manifest"
43
+ * {
44
+ * "initialPermissions": {
45
+ * "snap_getEntropy": {}
46
+ * }
47
+ * }
48
+ * ```
49
+ * ```ts name="Usage"
50
+ * const entropy = await snap.request({
51
+ * method: 'snap_getEntropy',
52
+ * params: {
53
+ * version: 1,
54
+ * salt: 'foo', // Optional.
55
+ * },
56
+ * })
57
+ *
58
+ * // '0x...'
59
+ * console.log(entropy)
60
+ * ```
61
+ */
27
62
  export const getEntropyBuilder = Object.freeze({
28
63
  targetName,
29
64
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AC,EAChC,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACL;IAChB,OAAO,KAAK,UAAU,UAAU,CAC9B,OAAkD;QAElD,MAAM,EACJ,MAAM,EACN,OAAO,EAAE,EAAE,MAAM,EAAE,GACpB,GAAG,OAAO,CAAC;QAEZ,YAAY,CACV,MAAM,EACN,oBAAoB,EACpB,sCAAsC,EACtC,SAAS,CAAC,aAAa,CACxB,CAAC;QAEF,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,IAAI,GAAG,MAAM,yBAAyB,CAC1C,eAAe,EACf,MAAM,CAAC,MAAM,CACd,CAAC;QAEF,OAAO,qBAAqB,CAAC;YAC3B,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI;YACJ,KAAK,EAAE,iBAAiB;YACxB,sBAAsB,EAAE,qBAAqB,EAAE;SAChD,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CryptographicFunctions } from '@metamask/key-tree';\nimport 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 { Infer } from '@metamask/superstruct';\nimport { literal, object, optional, string } from '@metamask/superstruct';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport { getValueFromEntropySource, deriveEntropyFromSeed } 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 source: 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 getMnemonicSeed: true,\n getUnlockPromise: true,\n getClientCryptography: true,\n};\n\nexport const getEntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\nexport type GetEntropyHooks = {\n /**\n * Get the mnemonic seed of the provided source. If no source is provided, the\n * mnemonic seed of the primary keyring will be returned.\n *\n * @param source - The optional ID of the source to get the mnemonic of.\n * @returns The mnemonic seed of the provided source, or the default source if no\n * source is provided.\n */\n getMnemonicSeed: (source?: string | undefined) => 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 * Get the cryptographic functions to use for the client. This may return an\n * empty object or `undefined` to fall back to the default cryptographic\n * functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions | undefined;\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.getMnemonicSeed - A function to retrieve the BIP-39 seed\n * of the user.\n * @param hooks.getUnlockPromise - The method to get a promise that resolves\n * once the extension is unlocked.\n * @param hooks.getClientCryptography - A function to retrieve the cryptographic\n * functions to use for the client.\n * @returns The method implementation.\n */\nfunction getEntropyImplementation({\n getMnemonicSeed,\n getUnlockPromise,\n getClientCryptography,\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 seed = await getValueFromEntropySource(\n getMnemonicSeed,\n params.source,\n );\n\n return deriveEntropyFromSeed({\n input: origin,\n salt: params.salt,\n seed,\n magic: SIP_6_MAGIC_VALUE,\n cryptographicFunctions: getClientCryptography(),\n });\n };\n}\n"]}
1
+ {"version":3,"file":"getEntropy.mjs","sourceRoot":"","sources":["../../src/restricted/getEntropy.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC;AAC9E,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAEjD,OAAO,EAAE,iBAAiB,EAAE,8BAA8B;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,8BAA8B;AAE1E,OAAO,EAAE,YAAY,EAAE,wBAAwB;AAG/C,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,qBAAiB;AAE5E,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAcrC,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;IACzC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACnB,IAAI,EAAE,QAAQ,C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;YACxB,sBAAsB,EAAE,qBAAqB,EAAE;SAChD,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CryptographicFunctions } from '@metamask/key-tree';\nimport 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 { Infer } from '@metamask/superstruct';\nimport { literal, object, optional, string } from '@metamask/superstruct';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport { getValueFromEntropySource, deriveEntropyFromSeed } 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 source: 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 getMnemonicSeed: true,\n getUnlockPromise: true,\n getClientCryptography: true,\n};\n\n/**\n * Get a deterministic 256-bit entropy value, specific to the Snap and the\n * user's account. You can use this entropy to generate a private key, or any\n * other value that requires a high level of randomness. Other Snaps can't\n * access this entropy, and it changes if the user's secret recovery phrase\n * changes.\n *\n * You can optionally specify a salt to generate different entropy for different\n * purposes. Using a salt results in entropy unrelated to the entropy generated\n * without a salt.\n *\n * This value is deterministic: it's always the same for the same Snap, user\n * account, and salt.\n *\n * @example\n * ```json name=\"Manifest\"\n * {\n * \"initialPermissions\": {\n * \"snap_getEntropy\": {}\n * }\n * }\n * ```\n * ```ts name=\"Usage\"\n * const entropy = await snap.request({\n * method: 'snap_getEntropy',\n * params: {\n * version: 1,\n * salt: 'foo', // Optional.\n * },\n * })\n *\n * // '0x...'\n * console.log(entropy)\n * ```\n */\nexport const getEntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\nexport type GetEntropyHooks = {\n /**\n * Get the mnemonic seed of the provided source. If no source is provided, the\n * mnemonic seed of the primary keyring will be returned.\n *\n * @param source - The optional ID of the source to get the mnemonic of.\n * @returns The mnemonic seed of the provided source, or the default source if no\n * source is provided.\n */\n getMnemonicSeed: (source?: string | undefined) => 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 * Get the cryptographic functions to use for the client. This may return an\n * empty object or `undefined` to fall back to the default cryptographic\n * functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions | undefined;\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.getMnemonicSeed - A function to retrieve the BIP-39 seed\n * of the user.\n * @param hooks.getUnlockPromise - The method to get a promise that resolves\n * once the extension is unlocked.\n * @param hooks.getClientCryptography - A function to retrieve the cryptographic\n * functions to use for the client.\n * @returns The method implementation.\n */\nfunction getEntropyImplementation({\n getMnemonicSeed,\n getUnlockPromise,\n getClientCryptography,\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 seed = await getValueFromEntropySource(\n getMnemonicSeed,\n params.source,\n );\n\n return deriveEntropyFromSeed({\n input: origin,\n salt: params.salt,\n seed,\n magic: SIP_6_MAGIC_VALUE,\n cryptographicFunctions: getClientCryptography(),\n });\n };\n}\n"]}
@@ -26,6 +26,17 @@ exports.specificationBuilder = specificationBuilder;
26
26
  const methodHooks = {
27
27
  getPreferences: true,
28
28
  };
29
+ /**
30
+ * Get the user's locale setting. You can use this method to localize text in
31
+ * your Snap.
32
+ *
33
+ * Note that this method is deprecated. We recommend using
34
+ * [`snap_getPreferences`](https://docs.metamask.io/snaps/reference/snaps-api/snap_getpreferences)
35
+ * instead, which provides access to the user's locale as well as other
36
+ * preferences.
37
+ *
38
+ * @internal
39
+ */
29
40
  exports.getLocaleBuilder = Object.freeze({
30
41
  targetName: methodName,
31
42
  specificationBuilder: exports.specificationBuilder,
@@ -1 +1 @@
1
- {"version":3,"file":"getLocale.cjs","sourceRoot":"","sources":["../../src/restricted/getLocale.ts"],"names":[],"mappings":";;;AAMA,2EAA8E;AAS9E,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAkBpC;;;;;;;;;GASG;AACI,MAAM,oBAAoB,GAI7B,CAAC,EAAE,cAAc,GAAG,IAAI,EAAE,WAAW,EAA+B,EAAE,EAAE;IAC1E,OAAO;QACL,cAAc,EAAE,sCAAc,CAAC,gBAAgB;QAC/C,UAAU,EAAE,UAAU;QACtB,cAAc;QACd,oBAAoB,EAAE,iBAAiB,CAAC,WAAW,CAAC;QACpD,YAAY,EAAE,CAAC,mCAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,oBAAoB,wBAY/B;AAEF,MAAM,WAAW,GAA4C;IAC3D,cAAc,EAAE,IAAI;CACrB,CAAC;AAEW,QAAA,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,UAAU,EAAE,UAAU;IACtB,oBAAoB,EAApB,4BAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AAEZ;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,EAAE,cAAc,EAAwB;IACxE,OAAO,KAAK,UAAU,cAAc,CAClC,KAA0D;QAE1D,OAAO,cAAc,EAAE,CAAC,MAAM,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC;AAND,8CAMC","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 {\n GetLocaleResult,\n GetPreferencesResult,\n} 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 getPreferences: () => GetPreferencesResult;\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 * @deprecated - To be removed in favor of `snap_getPreferences`.\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 getPreferences: 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.getPreferences - A function that returns the user selected preferences.\n * @returns The user selected locale.\n */\nexport function getImplementation({ getPreferences }: GetLocaleMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetLocaleResult> {\n return getPreferences().locale;\n };\n}\n"]}
1
+ {"version":3,"file":"getLocale.cjs","sourceRoot":"","sources":["../../src/restricted/getLocale.ts"],"names":[],"mappings":";;;AAMA,2EAA8E;AAS9E,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAkBpC;;;;;;;;;GASG;AACI,MAAM,oBAAoB,GAI7B,CAAC,EAAE,cAAc,GAAG,IAAI,EAAE,WAAW,EAA+B,EAAE,EAAE;IAC1E,OAAO;QACL,cAAc,EAAE,sCAAc,CAAC,gBAAgB;QAC/C,UAAU,EAAE,UAAU;QACtB,cAAc;QACd,oBAAoB,EAAE,iBAAiB,CAAC,WAAW,CAAC;QACpD,YAAY,EAAE,CAAC,mCAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,oBAAoB,wBAY/B;AAEF,MAAM,WAAW,GAA4C;IAC3D,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF;;;;;;;;;;GAUG;AACU,QAAA,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,UAAU,EAAE,UAAU;IACtB,oBAAoB,EAApB,4BAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AAEZ;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,EAAE,cAAc,EAAwB;IACxE,OAAO,KAAK,UAAU,cAAc,CAClC,KAA0D;QAE1D,OAAO,cAAc,EAAE,CAAC,MAAM,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC;AAND,8CAMC","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 {\n GetLocaleResult,\n GetPreferencesResult,\n} 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 getPreferences: () => GetPreferencesResult;\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 * @deprecated - To be removed in favor of `snap_getPreferences`.\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 getPreferences: true,\n};\n\n/**\n * Get the user's locale setting. You can use this method to localize text in\n * your Snap.\n *\n * Note that this method is deprecated. We recommend using\n * [`snap_getPreferences`](https://docs.metamask.io/snaps/reference/snaps-api/snap_getpreferences)\n * instead, which provides access to the user's locale as well as other\n * preferences.\n *\n * @internal\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.getPreferences - A function that returns the user selected preferences.\n * @returns The user selected locale.\n */\nexport function getImplementation({ getPreferences }: GetLocaleMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetLocaleResult> {\n return getPreferences().locale;\n };\n}\n"]}
@@ -28,6 +28,17 @@ type Specification = ValidPermissionSpecification<{
28
28
  * @deprecated - To be removed in favor of `snap_getPreferences`.
29
29
  */
30
30
  export declare const specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, Specification>;
31
+ /**
32
+ * Get the user's locale setting. You can use this method to localize text in
33
+ * your Snap.
34
+ *
35
+ * Note that this method is deprecated. We recommend using
36
+ * [`snap_getPreferences`](https://docs.metamask.io/snaps/reference/snaps-api/snap_getpreferences)
37
+ * instead, which provides access to the user's locale as well as other
38
+ * preferences.
39
+ *
40
+ * @internal
41
+ */
31
42
  export declare const getLocaleBuilder: Readonly<{
32
43
  readonly targetName: "snap_getLocale";
33
44
  readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, {
@@ -1 +1 @@
1
- {"version":3,"file":"getLocale.d.cts","sourceRoot":"","sources":["../../src/restricted/getLocale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8BAA8B,EAC9B,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC3B,wCAAwC;AACzC,OAAO,EAAE,cAAc,EAAe,wCAAwC;AAC9E,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,4BAA4B;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAElD,QAAA,MAAM,UAAU,mBAAmB,CAAC;AAEpC,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,MAAM,oBAAoB,CAAC;CAC5C,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,cAAc,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IACxD,WAAW,EAAE,oBAAoB,CAAC;CACnC,CAAC;AAEF,KAAK,aAAa,GAAG,4BAA4B,CAAC;IAChD,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC;IAChD,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,oBAAoB,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC3D,cAAc,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;CACxD,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,EAAE,8BAA8B,CAC/D,cAAc,CAAC,gBAAgB,EAC/B,2BAA2B,EAC3B,aAAa,CASd,CAAC;AAMF,eAAO,MAAM,gBAAgB;;;wBAlCX,eAAe,gBA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A8B,CAC/D,cAAc,CAAC,gBAAgB,EAC/B,2BAA2B,EAC3B,aAAa,CASd,CAAC;AAMF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB;;;wBA7CX,eAAe,gBAAgB;oBACnC,iBAAiB;8BACP,WAAW,wBAAwB,CAAC;wBAC1C,SAAS,cAAc,MAAM,CAAC,CAAC,GAAG,IAAI;;;EA8C7C,CAAC;AAEZ;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,cAAc,EAAE,EAAE,oBAAoB,WAE/D,wBAAwB,0BAA0B,CAAC,KACzD,QAAQ,eAAe,CAAC,CAG5B"}
@@ -28,6 +28,17 @@ type Specification = ValidPermissionSpecification<{
28
28
  * @deprecated - To be removed in favor of `snap_getPreferences`.
29
29
  */
30
30
  export declare const specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, Specification>;
31
+ /**
32
+ * Get the user's locale setting. You can use this method to localize text in
33
+ * your Snap.
34
+ *
35
+ * Note that this method is deprecated. We recommend using
36
+ * [`snap_getPreferences`](https://docs.metamask.io/snaps/reference/snaps-api/snap_getpreferences)
37
+ * instead, which provides access to the user's locale as well as other
38
+ * preferences.
39
+ *
40
+ * @internal
41
+ */
31
42
  export declare const getLocaleBuilder: Readonly<{
32
43
  readonly targetName: "snap_getLocale";
33
44
  readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, {
@@ -1 +1 @@
1
- {"version":3,"file":"getLocale.d.mts","sourceRoot":"","sources":["../../src/restricted/getLocale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8BAA8B,EAC9B,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC3B,wCAAwC;AACzC,OAAO,EAAE,cAAc,EAAe,wCAAwC;AAC9E,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,4BAA4B;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,wBAA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Hooks }) =>
22
22
  const methodHooks = {
23
23
  getPreferences: true,
24
24
  };
25
+ /**
26
+ * Get the user's locale setting. You can use this method to localize text in
27
+ * your Snap.
28
+ *
29
+ * Note that this method is deprecated. We recommend using
30
+ * [`snap_getPreferences`](https://docs.metamask.io/snaps/reference/snaps-api/snap_getpreferences)
31
+ * instead, which provides access to the user's locale as well as other
32
+ * preferences.
33
+ *
34
+ * @internal
35
+ */
25
36
  export const getLocaleBuilder = Object.freeze({
26
37
  targetName: methodName,
27
38
  specificationBuilder,
@@ -1 +1 @@
1
- {"version":3,"file":"getLocale.mjs","sourceRoot":"","sources":["../../src/restricted/getLocale.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC;AAS9E,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAkBpC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAI7B,CAAC,EAAE,cAAc,GAAG,IAAI,EAAE,WAAW,EAA+B,EAAE,EAAE;IAC1E,OAAO;QACL,cAAc,EAAE,cAAc,CAAC,gBAAgB;QAC/C,UAAU,EAAE,UAAU;QACtB,cAAc;QACd,oBAAoB,EAAE,iBAAiB,CAAC,WAAW,CAAC;QACpD,YAAY,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,WAAW,GAA4C;IAC3D,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,UAAU,EAAE,UAAU;IACtB,oBAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AAEZ;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAE,cAAc,EAAwB;IACxE,OAAO,KAAK,UAAU,cAAc,CAClC,KAA0D;QAE1D,OAAO,cAAc,EAAE,CAAC,MAAM,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC","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 {\n GetLocaleResult,\n GetPreferencesResult,\n} 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 getPreferences: () => GetPreferencesResult;\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 * @deprecated - To be removed in favor of `snap_getPreferences`.\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 getPreferences: 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.getPreferences - A function that returns the user selected preferences.\n * @returns The user selected locale.\n */\nexport function getImplementation({ getPreferences }: GetLocaleMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetLocaleResult> {\n return getPreferences().locale;\n };\n}\n"]}
1
+ {"version":3,"file":"getLocale.mjs","sourceRoot":"","sources":["../../src/restricted/getLocale.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC;AAS9E,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAkBpC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAI7B,CAAC,EAAE,cAAc,GAAG,IAAI,EAAE,WAAW,EAA+B,EAAE,EAAE;IAC1E,OAAO;QACL,cAAc,EAAE,cAAc,CAAC,gBAAgB;QAC/C,UAAU,EAAE,UAAU;QACtB,cAAc;QACd,oBAAoB,EAAE,iBAAiB,CAAC,WAAW,CAAC;QACpD,YAAY,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,WAAW,GAA4C;IAC3D,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,UAAU,EAAE,UAAU;IACtB,oBAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AAEZ;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAE,cAAc,EAAwB;IACxE,OAAO,KAAK,UAAU,cAAc,CAClC,KAA0D;QAE1D,OAAO,cAAc,EAAE,CAAC,MAAM,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC","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 {\n GetLocaleResult,\n GetPreferencesResult,\n} 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 getPreferences: () => GetPreferencesResult;\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 * @deprecated - To be removed in favor of `snap_getPreferences`.\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 getPreferences: true,\n};\n\n/**\n * Get the user's locale setting. You can use this method to localize text in\n * your Snap.\n *\n * Note that this method is deprecated. We recommend using\n * [`snap_getPreferences`](https://docs.metamask.io/snaps/reference/snaps-api/snap_getpreferences)\n * instead, which provides access to the user's locale as well as other\n * preferences.\n *\n * @internal\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.getPreferences - A function that returns the user selected preferences.\n * @returns The user selected locale.\n */\nexport function getImplementation({ getPreferences }: GetLocaleMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetLocaleResult> {\n return getPreferences().locale;\n };\n}\n"]}
@@ -25,6 +25,30 @@ exports.specificationBuilder = specificationBuilder;
25
25
  const methodHooks = {
26
26
  getPreferences: true,
27
27
  };
28
+ /**
29
+ * Gets the user's preferences.
30
+ *
31
+ * @example
32
+ * ```json name="Manifest"
33
+ * {
34
+ * "initialPermissions": {
35
+ * "snap_getPreferences": {}
36
+ * }
37
+ * }
38
+ * ```
39
+ * ```ts name="Usage"
40
+ * const preferences = await snap.request({
41
+ * method: 'snap_getPreferences',
42
+ * });
43
+ *
44
+ * console.log(preferences);
45
+ * // {
46
+ * // locale: 'en',
47
+ * // currency: 'usd',
48
+ * // ...
49
+ * // }
50
+ * ```
51
+ */
28
52
  exports.getPreferencesBuilder = Object.freeze({
29
53
  targetName: methodName,
30
54
  specificationBuilder: exports.specificationBuilder,
@@ -1 +1 @@
1
- {"version":3,"file":"getPreferences.cjs","sourceRoot":"","sources":["../../src/restricted/getPreferences.ts"],"names":[],"mappings":";;;AAMA,2EAA8E;AAM9E,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAkBzC;;;;;;;;GAQG;AACI,MAAM,oBAAoB,GAI7B,CAAC,EAAE,cAAc,GAAG,IAAI,EAAE,WAAW,EAA+B,EAAE,EAAE;IAC1E,OAAO;QACL,cAAc,EAAE,sCAAc,CAAC,gBAAgB;QAC/C,UAAU,EAAE,UAAU;QACtB,cAAc;QACd,oBAAoB,EAAE,iBAAiB,CAAC,WAAW,CAAC;QACpD,YAAY,EAAE,CAAC,mCAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,oBAAoB,wBAY/B;AAEF,MAAM,WAAW,GAAiD;IAChE,cAAc,EAAE,IAAI;CACrB,CAAC;AAEW,QAAA,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,UAAU,EAAE,UAAU;IACtB,oBAAoB,EAApB,4BAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AAEZ;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,EAChC,cAAc,GACY;IAC1B,OAAO,KAAK,UAAU,cAAc,CAClC,KAA0D;QAE1D,OAAO,cAAc,EAAE,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC;AARD,8CAQC","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 { GetPreferencesResult } from '@metamask/snaps-sdk';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_getPreferences';\n\nexport type GetPreferencesMethodHooks = {\n getPreferences: () => GetPreferencesResult;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetPreferencesMethodHooks;\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_getPreferences` permission.\n * `snap_getPreferences` allows snaps to access user preferences.\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_getPreferences` 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<GetPreferencesMethodHooks> = {\n getPreferences: true,\n};\n\nexport const getPreferencesBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getPreferences`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getPreferences - A function that returns the user selected preferences.\n * @returns The user preferences.\n */\nexport function getImplementation({\n getPreferences,\n}: GetPreferencesMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetPreferencesResult> {\n return getPreferences();\n };\n}\n"]}
1
+ {"version":3,"file":"getPreferences.cjs","sourceRoot":"","sources":["../../src/restricted/getPreferences.ts"],"names":[],"mappings":";;;AAMA,2EAA8E;AAM9E,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAkBzC;;;;;;;;GAQG;AACI,MAAM,oBAAoB,GAI7B,CAAC,EAAE,cAAc,GAAG,IAAI,EAAE,WAAW,EAA+B,EAAE,EAAE;IAC1E,OAAO;QACL,cAAc,EAAE,sCAAc,CAAC,gBAAgB;QAC/C,UAAU,EAAE,UAAU;QACtB,cAAc;QACd,oBAAoB,EAAE,iBAAiB,CAAC,WAAW,CAAC;QACpD,YAAY,EAAE,CAAC,mCAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,oBAAoB,wBAY/B;AAEF,MAAM,WAAW,GAAiD;IAChE,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACU,QAAA,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,UAAU,EAAE,UAAU;IACtB,oBAAoB,EAApB,4BAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AAEZ;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,EAChC,cAAc,GACY;IAC1B,OAAO,KAAK,UAAU,cAAc,CAClC,KAA0D;QAE1D,OAAO,cAAc,EAAE,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC;AARD,8CAQC","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 { GetPreferencesResult } from '@metamask/snaps-sdk';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_getPreferences';\n\nexport type GetPreferencesMethodHooks = {\n getPreferences: () => GetPreferencesResult;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetPreferencesMethodHooks;\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_getPreferences` permission.\n * `snap_getPreferences` allows snaps to access user preferences.\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_getPreferences` 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<GetPreferencesMethodHooks> = {\n getPreferences: true,\n};\n\n/**\n * Gets the user's preferences.\n *\n * @example\n * ```json name=\"Manifest\"\n * {\n * \"initialPermissions\": {\n * \"snap_getPreferences\": {}\n * }\n * }\n * ```\n * ```ts name=\"Usage\"\n * const preferences = await snap.request({\n * method: 'snap_getPreferences',\n * });\n *\n * console.log(preferences);\n * // {\n * // locale: 'en',\n * // currency: 'usd',\n * // ...\n * // }\n * ```\n */\nexport const getPreferencesBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getPreferences`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getPreferences - A function that returns the user selected preferences.\n * @returns The user preferences.\n */\nexport function getImplementation({\n getPreferences,\n}: GetPreferencesMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetPreferencesResult> {\n return getPreferences();\n };\n}\n"]}
@@ -27,6 +27,30 @@ type Specification = ValidPermissionSpecification<{
27
27
  * @returns The specification for the `snap_getPreferences` permission.
28
28
  */
29
29
  export declare const specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, Specification>;
30
+ /**
31
+ * Gets the user's preferences.
32
+ *
33
+ * @example
34
+ * ```json name="Manifest"
35
+ * {
36
+ * "initialPermissions": {
37
+ * "snap_getPreferences": {}
38
+ * }
39
+ * }
40
+ * ```
41
+ * ```ts name="Usage"
42
+ * const preferences = await snap.request({
43
+ * method: 'snap_getPreferences',
44
+ * });
45
+ *
46
+ * console.log(preferences);
47
+ * // {
48
+ * // locale: 'en',
49
+ * // currency: 'usd',
50
+ * // ...
51
+ * // }
52
+ * ```
53
+ */
30
54
  export declare const getPreferencesBuilder: Readonly<{
31
55
  readonly targetName: "snap_getPreferences";
32
56
  readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, {
@@ -1 +1 @@
1
- {"version":3,"file":"getPreferences.d.cts","sourceRoot":"","sources":["../../src/restricted/getPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8BAA8B,EAC9B,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,E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CAAC,EAChC,cAAc,GACf,EAAE,yBAAyB,WAEjB,wBAAwB,0BAA0B,CAAC,KACzD,QAAQ,oBAAoB,CAAC,CAGjC"}
@@ -27,6 +27,30 @@ type Specification = ValidPermissionSpecification<{
27
27
  * @returns The specification for the `snap_getPreferences` permission.
28
28
  */
29
29
  export declare const specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, Specification>;
30
+ /**
31
+ * Gets the user's preferences.
32
+ *
33
+ * @example
34
+ * ```json name="Manifest"
35
+ * {
36
+ * "initialPermissions": {
37
+ * "snap_getPreferences": {}
38
+ * }
39
+ * }
40
+ * ```
41
+ * ```ts name="Usage"
42
+ * const preferences = await snap.request({
43
+ * method: 'snap_getPreferences',
44
+ * });
45
+ *
46
+ * console.log(preferences);
47
+ * // {
48
+ * // locale: 'en',
49
+ * // currency: 'usd',
50
+ * // ...
51
+ * // }
52
+ * ```
53
+ */
30
54
  export declare const getPreferencesBuilder: Readonly<{
31
55
  readonly targetName: "snap_getPreferences";
32
56
  readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, {