@metamask/snaps-rpc-methods 10.0.1 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (698) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/dist/__fixtures__/entropy.cjs +31 -0
  3. package/dist/__fixtures__/entropy.cjs.map +1 -0
  4. package/dist/{types/__fixtures__/entropy.d.ts → __fixtures__/entropy.d.cts} +1 -0
  5. package/dist/__fixtures__/entropy.d.cts.map +1 -0
  6. package/dist/__fixtures__/entropy.d.mts +15 -0
  7. package/dist/__fixtures__/entropy.d.mts.map +1 -0
  8. package/dist/__fixtures__/entropy.mjs +28 -0
  9. package/dist/__fixtures__/entropy.mjs.map +1 -0
  10. package/dist/__fixtures__/index.cjs +18 -0
  11. package/dist/__fixtures__/index.cjs.map +1 -0
  12. package/dist/__fixtures__/index.d.cts +2 -0
  13. package/dist/__fixtures__/index.d.cts.map +1 -0
  14. package/dist/__fixtures__/index.d.mts +2 -0
  15. package/dist/__fixtures__/index.d.mts.map +1 -0
  16. package/dist/__fixtures__/index.mjs +2 -0
  17. package/dist/__fixtures__/index.mjs.map +1 -0
  18. package/dist/endowments/caveats/generic.cjs +50 -0
  19. package/dist/endowments/caveats/generic.cjs.map +1 -0
  20. package/dist/{types/endowments/caveats/generic.d.ts → endowments/caveats/generic.d.cts} +5 -4
  21. package/dist/endowments/caveats/generic.d.cts.map +1 -0
  22. package/dist/endowments/caveats/generic.d.mts +20 -0
  23. package/dist/endowments/caveats/generic.d.mts.map +1 -0
  24. package/dist/endowments/caveats/generic.mjs +45 -6
  25. package/dist/endowments/caveats/generic.mjs.map +1 -1
  26. package/dist/endowments/caveats/index.cjs +19 -0
  27. package/dist/endowments/caveats/index.cjs.map +1 -0
  28. package/dist/endowments/caveats/index.d.cts +3 -0
  29. package/dist/endowments/caveats/index.d.cts.map +1 -0
  30. package/dist/endowments/caveats/index.d.mts +3 -0
  31. package/dist/endowments/caveats/index.d.mts.map +1 -0
  32. package/dist/endowments/caveats/index.mjs +2 -17
  33. package/dist/endowments/caveats/index.mjs.map +1 -1
  34. package/dist/endowments/caveats/requestTime.cjs +104 -0
  35. package/dist/{chunk-FCVWU5XH.js.map → endowments/caveats/requestTime.cjs.map} +1 -1
  36. package/dist/{types/endowments/caveats/requestTime.d.ts → endowments/caveats/requestTime.d.cts} +5 -4
  37. package/dist/endowments/caveats/requestTime.d.cts.map +1 -0
  38. package/dist/endowments/caveats/requestTime.d.mts +30 -0
  39. package/dist/endowments/caveats/requestTime.d.mts.map +1 -0
  40. package/dist/endowments/caveats/requestTime.mjs +96 -11
  41. package/dist/endowments/caveats/requestTime.mjs.map +1 -1
  42. package/dist/endowments/cronjob.cjs +105 -0
  43. package/dist/endowments/cronjob.cjs.map +1 -0
  44. package/dist/{types/endowments/cronjob.d.ts → endowments/cronjob.d.cts} +7 -6
  45. package/dist/endowments/cronjob.d.cts.map +1 -0
  46. package/dist/endowments/cronjob.d.mts +52 -0
  47. package/dist/endowments/cronjob.d.mts.map +1 -0
  48. package/dist/endowments/cronjob.mjs +97 -14
  49. package/dist/endowments/cronjob.mjs.map +1 -1
  50. package/dist/endowments/enum.cjs +18 -0
  51. package/dist/endowments/enum.cjs.map +1 -0
  52. package/dist/{types/endowments/enum.d.ts → endowments/enum.d.cts} +1 -0
  53. package/dist/endowments/enum.d.cts.map +1 -0
  54. package/dist/endowments/enum.d.mts +14 -0
  55. package/dist/endowments/enum.d.mts.map +1 -0
  56. package/dist/endowments/enum.mjs +14 -6
  57. package/dist/endowments/enum.mjs.map +1 -1
  58. package/dist/endowments/ethereum-provider.cjs +32 -0
  59. package/dist/endowments/ethereum-provider.cjs.map +1 -0
  60. package/dist/{types/endowments/ethereum-provider.d.ts → endowments/ethereum-provider.d.cts} +4 -3
  61. package/dist/endowments/ethereum-provider.d.cts.map +1 -0
  62. package/dist/endowments/ethereum-provider.d.mts +15 -0
  63. package/dist/endowments/ethereum-provider.d.mts.map +1 -0
  64. package/dist/endowments/ethereum-provider.mjs +27 -6
  65. package/dist/endowments/ethereum-provider.mjs.map +1 -1
  66. package/dist/endowments/home-page.cjs +28 -0
  67. package/dist/{chunk-2SFH57UV.js.map → endowments/home-page.cjs.map} +1 -1
  68. package/dist/{types/endowments/home-page.d.ts → endowments/home-page.d.cts} +5 -4
  69. package/dist/endowments/home-page.d.cts.map +1 -0
  70. package/dist/endowments/home-page.d.mts +16 -0
  71. package/dist/endowments/home-page.d.mts.map +1 -0
  72. package/dist/endowments/home-page.mjs +23 -6
  73. package/dist/endowments/home-page.mjs.map +1 -1
  74. package/dist/endowments/index.cjs +92 -0
  75. package/dist/endowments/index.cjs.map +1 -0
  76. package/dist/{types/endowments/index.d.ts → endowments/index.d.cts} +12 -11
  77. package/dist/endowments/index.d.cts.map +1 -0
  78. package/dist/endowments/index.d.mts +132 -0
  79. package/dist/endowments/index.d.mts.map +1 -0
  80. package/dist/endowments/index.mjs +65 -52
  81. package/dist/endowments/index.mjs.map +1 -1
  82. package/dist/endowments/keyring.cjs +96 -0
  83. package/dist/endowments/keyring.cjs.map +1 -0
  84. package/dist/{types/endowments/keyring.d.ts → endowments/keyring.d.cts} +7 -6
  85. package/dist/endowments/keyring.d.cts.map +1 -0
  86. package/dist/endowments/keyring.d.mts +40 -0
  87. package/dist/endowments/keyring.d.mts.map +1 -0
  88. package/dist/endowments/keyring.mjs +89 -15
  89. package/dist/endowments/keyring.mjs.map +1 -1
  90. package/dist/endowments/lifecycle-hooks.cjs +28 -0
  91. package/dist/endowments/lifecycle-hooks.cjs.map +1 -0
  92. package/dist/{types/endowments/lifecycle-hooks.d.ts → endowments/lifecycle-hooks.d.cts} +5 -4
  93. package/dist/endowments/lifecycle-hooks.d.cts.map +1 -0
  94. package/dist/endowments/lifecycle-hooks.d.mts +16 -0
  95. package/dist/endowments/lifecycle-hooks.d.mts.map +1 -0
  96. package/dist/endowments/lifecycle-hooks.mjs +23 -6
  97. package/dist/endowments/lifecycle-hooks.mjs.map +1 -1
  98. package/dist/endowments/name-lookup.cjs +141 -0
  99. package/dist/endowments/name-lookup.cjs.map +1 -0
  100. package/dist/{types/endowments/name-lookup.d.ts → endowments/name-lookup.d.cts} +6 -5
  101. package/dist/endowments/name-lookup.d.cts.map +1 -0
  102. package/dist/endowments/name-lookup.d.mts +50 -0
  103. package/dist/endowments/name-lookup.d.mts.map +1 -0
  104. package/dist/endowments/name-lookup.mjs +133 -17
  105. package/dist/endowments/name-lookup.mjs.map +1 -1
  106. package/dist/endowments/network-access.cjs +30 -0
  107. package/dist/endowments/network-access.cjs.map +1 -0
  108. package/dist/{types/endowments/network-access.d.ts → endowments/network-access.d.cts} +4 -3
  109. package/dist/endowments/network-access.d.cts.map +1 -0
  110. package/dist/endowments/network-access.d.mts +15 -0
  111. package/dist/endowments/network-access.d.mts.map +1 -0
  112. package/dist/endowments/network-access.mjs +25 -6
  113. package/dist/endowments/network-access.mjs.map +1 -1
  114. package/dist/endowments/rpc.cjs +90 -0
  115. package/dist/endowments/rpc.cjs.map +1 -0
  116. package/dist/{types/endowments/rpc.d.ts → endowments/rpc.d.cts} +8 -7
  117. package/dist/endowments/rpc.d.cts.map +1 -0
  118. package/dist/endowments/rpc.d.mts +39 -0
  119. package/dist/endowments/rpc.d.mts.map +1 -0
  120. package/dist/endowments/rpc.mjs +83 -15
  121. package/dist/endowments/rpc.mjs.map +1 -1
  122. package/dist/endowments/signature-insight.cjs +102 -0
  123. package/dist/endowments/signature-insight.cjs.map +1 -0
  124. package/dist/{types/endowments/signature-insight.d.ts → endowments/signature-insight.d.cts} +6 -5
  125. package/dist/endowments/signature-insight.d.cts.map +1 -0
  126. package/dist/endowments/signature-insight.d.mts +40 -0
  127. package/dist/endowments/signature-insight.d.mts.map +1 -0
  128. package/dist/endowments/signature-insight.mjs +95 -15
  129. package/dist/endowments/signature-insight.mjs.map +1 -1
  130. package/dist/endowments/transaction-insight.cjs +105 -0
  131. package/dist/endowments/transaction-insight.cjs.map +1 -0
  132. package/dist/{types/endowments/transaction-insight.d.ts → endowments/transaction-insight.d.cts} +6 -5
  133. package/dist/endowments/transaction-insight.d.cts.map +1 -0
  134. package/dist/endowments/transaction-insight.d.mts +40 -0
  135. package/dist/endowments/transaction-insight.d.mts.map +1 -0
  136. package/dist/endowments/transaction-insight.mjs +98 -15
  137. package/dist/endowments/transaction-insight.mjs.map +1 -1
  138. package/dist/endowments/web-assembly.cjs +31 -0
  139. package/dist/endowments/web-assembly.cjs.map +1 -0
  140. package/dist/{types/endowments/web-assembly.d.ts → endowments/web-assembly.d.cts} +4 -3
  141. package/dist/endowments/web-assembly.d.cts.map +1 -0
  142. package/dist/endowments/web-assembly.d.mts +15 -0
  143. package/dist/endowments/web-assembly.d.mts.map +1 -0
  144. package/dist/endowments/web-assembly.mjs +26 -6
  145. package/dist/endowments/web-assembly.mjs.map +1 -1
  146. package/dist/index.cjs +28 -0
  147. package/dist/index.cjs.map +1 -0
  148. package/dist/index.d.cts +8 -0
  149. package/dist/index.d.cts.map +1 -0
  150. package/dist/index.d.mts +8 -0
  151. package/dist/index.d.mts.map +1 -0
  152. package/dist/index.mjs +6 -121
  153. package/dist/index.mjs.map +1 -1
  154. package/dist/permissions.cjs +55 -0
  155. package/dist/permissions.cjs.map +1 -0
  156. package/dist/{types/permissions.d.ts → permissions.d.cts} +3 -2
  157. package/dist/permissions.d.cts.map +1 -0
  158. package/dist/permissions.d.mts +17 -0
  159. package/dist/permissions.d.mts.map +1 -0
  160. package/dist/permissions.mjs +48 -42
  161. package/dist/permissions.mjs.map +1 -1
  162. package/dist/permitted/createInterface.cjs +64 -0
  163. package/dist/permitted/createInterface.cjs.map +1 -0
  164. package/dist/{types/permitted/createInterface.d.ts → permitted/createInterface.d.cts} +62 -47
  165. package/dist/permitted/createInterface.d.cts.map +1 -0
  166. package/dist/permitted/createInterface.d.mts +181 -0
  167. package/dist/permitted/createInterface.d.mts.map +1 -0
  168. package/dist/permitted/createInterface.mjs +59 -5
  169. package/dist/permitted/createInterface.mjs.map +1 -1
  170. package/dist/permitted/getAllSnaps.cjs +39 -0
  171. package/dist/permitted/getAllSnaps.cjs.map +1 -0
  172. package/dist/{types/permitted/getAllSnaps.d.ts → permitted/getAllSnaps.d.cts} +5 -4
  173. package/dist/permitted/getAllSnaps.d.cts.map +1 -0
  174. package/dist/permitted/getAllSnaps.d.mts +15 -0
  175. package/dist/permitted/getAllSnaps.d.mts.map +1 -0
  176. package/dist/permitted/getAllSnaps.mjs +34 -5
  177. package/dist/permitted/getAllSnaps.mjs.map +1 -1
  178. package/dist/permitted/getClientStatus.cjs +32 -0
  179. package/dist/permitted/getClientStatus.cjs.map +1 -0
  180. package/dist/{types/permitted/getClientStatus.d.ts → permitted/getClientStatus.d.cts} +5 -4
  181. package/dist/permitted/getClientStatus.d.cts.map +1 -0
  182. package/dist/permitted/getClientStatus.d.mts +14 -0
  183. package/dist/permitted/getClientStatus.d.mts.map +1 -0
  184. package/dist/permitted/getClientStatus.mjs +27 -5
  185. package/dist/permitted/getClientStatus.mjs.map +1 -1
  186. package/dist/permitted/getFile.cjs +47 -0
  187. package/dist/permitted/getFile.cjs.map +1 -0
  188. package/dist/{types/permitted/getFile.d.ts → permitted/getFile.d.cts} +6 -5
  189. package/dist/permitted/getFile.d.cts.map +1 -0
  190. package/dist/permitted/getFile.d.mts +16 -0
  191. package/dist/permitted/getFile.d.mts.map +1 -0
  192. package/dist/permitted/getFile.mjs +42 -7
  193. package/dist/permitted/getFile.mjs.map +1 -1
  194. package/dist/permitted/getInterfaceState.cjs +62 -0
  195. package/dist/permitted/getInterfaceState.cjs.map +1 -0
  196. package/dist/{types/permitted/getInterfaceState.d.ts → permitted/getInterfaceState.d.cts} +6 -5
  197. package/dist/permitted/getInterfaceState.d.cts.map +1 -0
  198. package/dist/permitted/getInterfaceState.d.mts +19 -0
  199. package/dist/permitted/getInterfaceState.d.mts.map +1 -0
  200. package/dist/permitted/getInterfaceState.mjs +57 -5
  201. package/dist/permitted/getInterfaceState.mjs.map +1 -1
  202. package/dist/permitted/getSnaps.cjs +33 -0
  203. package/dist/permitted/getSnaps.cjs.map +1 -0
  204. package/dist/{types/permitted/getSnaps.d.ts → permitted/getSnaps.d.cts} +5 -4
  205. package/dist/permitted/getSnaps.d.cts.map +1 -0
  206. package/dist/permitted/getSnaps.d.mts +14 -0
  207. package/dist/permitted/getSnaps.d.mts.map +1 -0
  208. package/dist/permitted/getSnaps.mjs +28 -5
  209. package/dist/permitted/getSnaps.mjs.map +1 -1
  210. package/dist/permitted/handlers.cjs +31 -0
  211. package/dist/permitted/handlers.cjs.map +1 -0
  212. package/dist/{types/permitted/handlers.d.ts → permitted/handlers.d.cts} +1 -0
  213. package/dist/permitted/handlers.d.cts.map +1 -0
  214. package/dist/permitted/handlers.d.mts +35 -0
  215. package/dist/permitted/handlers.d.mts.map +1 -0
  216. package/dist/permitted/handlers.mjs +26 -19
  217. package/dist/permitted/handlers.mjs.map +1 -1
  218. package/dist/permitted/index.cjs +19 -0
  219. package/dist/permitted/index.cjs.map +1 -0
  220. package/dist/permitted/index.d.cts +12 -0
  221. package/dist/permitted/index.d.cts.map +1 -0
  222. package/dist/permitted/index.d.mts +12 -0
  223. package/dist/permitted/index.d.mts.map +1 -0
  224. package/dist/permitted/index.mjs +2 -26
  225. package/dist/permitted/index.mjs.map +1 -1
  226. package/dist/permitted/invokeKeyring.cjs +83 -0
  227. package/dist/permitted/invokeKeyring.cjs.map +1 -0
  228. package/dist/{types/permitted/invokeKeyring.d.ts → permitted/invokeKeyring.d.cts} +5 -4
  229. package/dist/permitted/invokeKeyring.d.cts.map +1 -0
  230. package/dist/permitted/invokeKeyring.d.mts +16 -0
  231. package/dist/permitted/invokeKeyring.d.mts.map +1 -0
  232. package/dist/permitted/invokeKeyring.mjs +78 -6
  233. package/dist/permitted/invokeKeyring.mjs.map +1 -1
  234. package/dist/permitted/invokeSnapSugar.cjs +68 -0
  235. package/dist/permitted/invokeSnapSugar.cjs.map +1 -0
  236. package/dist/{types/permitted/invokeSnapSugar.d.ts → permitted/invokeSnapSugar.d.cts} +6 -5
  237. package/dist/permitted/invokeSnapSugar.d.cts.map +1 -0
  238. package/dist/permitted/invokeSnapSugar.d.mts +35 -0
  239. package/dist/permitted/invokeSnapSugar.d.mts.map +1 -0
  240. package/dist/permitted/invokeSnapSugar.mjs +61 -9
  241. package/dist/permitted/invokeSnapSugar.mjs.map +1 -1
  242. package/dist/permitted/middleware.cjs +40 -0
  243. package/dist/permitted/middleware.cjs.map +1 -0
  244. package/dist/{types/permitted/middleware.d.ts → permitted/middleware.d.cts} +3 -2
  245. package/dist/permitted/middleware.d.cts.map +1 -0
  246. package/dist/permitted/middleware.d.mts +11 -0
  247. package/dist/permitted/middleware.d.mts.map +1 -0
  248. package/dist/permitted/middleware.mjs +35 -20
  249. package/dist/permitted/middleware.mjs.map +1 -1
  250. package/dist/permitted/requestSnaps.cjs +121 -0
  251. package/dist/permitted/requestSnaps.cjs.map +1 -0
  252. package/dist/{types/permitted/requestSnaps.d.ts → permitted/requestSnaps.d.cts} +5 -4
  253. package/dist/permitted/requestSnaps.d.cts.map +1 -0
  254. package/dist/permitted/requestSnaps.d.mts +51 -0
  255. package/dist/permitted/requestSnaps.d.mts.map +1 -0
  256. package/dist/permitted/requestSnaps.mjs +114 -10
  257. package/dist/permitted/requestSnaps.mjs.map +1 -1
  258. package/dist/permitted/resolveInterface.cjs +65 -0
  259. package/dist/permitted/resolveInterface.cjs.map +1 -0
  260. package/dist/{types/permitted/resolveInterface.d.ts → permitted/resolveInterface.d.cts} +8 -7
  261. package/dist/permitted/resolveInterface.d.cts.map +1 -0
  262. package/dist/permitted/resolveInterface.d.mts +22 -0
  263. package/dist/permitted/resolveInterface.d.mts.map +1 -0
  264. package/dist/permitted/resolveInterface.mjs +60 -5
  265. package/dist/permitted/resolveInterface.mjs.map +1 -1
  266. package/dist/permitted/updateInterface.cjs +65 -0
  267. package/dist/permitted/updateInterface.cjs.map +1 -0
  268. package/dist/{types/permitted/updateInterface.d.ts → permitted/updateInterface.d.cts} +62 -47
  269. package/dist/permitted/updateInterface.d.cts.map +1 -0
  270. package/dist/permitted/updateInterface.d.mts +181 -0
  271. package/dist/permitted/updateInterface.d.mts.map +1 -0
  272. package/dist/permitted/updateInterface.mjs +60 -5
  273. package/dist/permitted/updateInterface.mjs.map +1 -1
  274. package/dist/restricted/caveats/index.cjs +22 -0
  275. package/dist/restricted/caveats/index.cjs.map +1 -0
  276. package/dist/{types/restricted/caveats/index.d.ts → restricted/caveats/index.d.cts} +3 -2
  277. package/dist/restricted/caveats/index.d.cts.map +1 -0
  278. package/dist/restricted/caveats/index.d.mts +9 -0
  279. package/dist/restricted/caveats/index.d.mts.map +1 -0
  280. package/dist/restricted/caveats/index.mjs +17 -15
  281. package/dist/restricted/caveats/index.mjs.map +1 -1
  282. package/dist/restricted/caveats/permittedCoinTypes.cjs +90 -0
  283. package/dist/restricted/caveats/permittedCoinTypes.cjs.map +1 -0
  284. package/dist/{types/restricted/caveats/permittedCoinTypes.d.ts → restricted/caveats/permittedCoinTypes.d.cts} +5 -4
  285. package/dist/restricted/caveats/permittedCoinTypes.d.cts.map +1 -0
  286. package/dist/restricted/caveats/permittedCoinTypes.d.mts +30 -0
  287. package/dist/restricted/caveats/permittedCoinTypes.d.mts.map +1 -0
  288. package/dist/restricted/caveats/permittedCoinTypes.mjs +82 -11
  289. package/dist/restricted/caveats/permittedCoinTypes.mjs.map +1 -1
  290. package/dist/restricted/caveats/permittedDerivationPaths.cjs +70 -0
  291. package/dist/restricted/caveats/permittedDerivationPaths.cjs.map +1 -0
  292. package/dist/{types/restricted/caveats/permittedDerivationPaths.d.ts → restricted/caveats/permittedDerivationPaths.d.cts} +5 -4
  293. package/dist/restricted/caveats/permittedDerivationPaths.d.cts.map +1 -0
  294. package/dist/restricted/caveats/permittedDerivationPaths.d.mts +33 -0
  295. package/dist/restricted/caveats/permittedDerivationPaths.d.mts.map +1 -0
  296. package/dist/restricted/caveats/permittedDerivationPaths.mjs +62 -11
  297. package/dist/restricted/caveats/permittedDerivationPaths.mjs.map +1 -1
  298. package/dist/restricted/caveats/snapIds.cjs +56 -0
  299. package/dist/restricted/caveats/snapIds.cjs.map +1 -0
  300. package/dist/{types/restricted/caveats/snapIds.d.ts → restricted/caveats/snapIds.d.cts} +5 -4
  301. package/dist/restricted/caveats/snapIds.d.cts.map +1 -0
  302. package/dist/restricted/caveats/snapIds.d.mts +22 -0
  303. package/dist/restricted/caveats/snapIds.d.mts.map +1 -0
  304. package/dist/restricted/caveats/snapIds.mjs +49 -9
  305. package/dist/restricted/caveats/snapIds.mjs.map +1 -1
  306. package/dist/restricted/dialog.cjs +222 -0
  307. package/dist/restricted/dialog.cjs.map +1 -0
  308. package/dist/restricted/dialog.d.cts +432 -0
  309. package/dist/restricted/dialog.d.cts.map +1 -0
  310. package/dist/restricted/dialog.d.mts +432 -0
  311. package/dist/restricted/dialog.d.mts.map +1 -0
  312. package/dist/restricted/dialog.mjs +216 -9
  313. package/dist/restricted/dialog.mjs.map +1 -1
  314. package/dist/restricted/getBip32Entropy.cjs +69 -0
  315. package/dist/restricted/getBip32Entropy.cjs.map +1 -0
  316. package/dist/{types/restricted/getBip32Entropy.d.ts → restricted/getBip32Entropy.d.cts} +8 -7
  317. package/dist/restricted/getBip32Entropy.d.cts.map +1 -0
  318. package/dist/restricted/getBip32Entropy.d.mts +45 -0
  319. package/dist/restricted/getBip32Entropy.d.mts.map +1 -0
  320. package/dist/restricted/getBip32Entropy.mjs +63 -8
  321. package/dist/restricted/getBip32Entropy.mjs.map +1 -1
  322. package/dist/restricted/getBip32PublicKey.cjs +78 -0
  323. package/dist/restricted/getBip32PublicKey.cjs.map +1 -0
  324. package/dist/{types/restricted/getBip32PublicKey.d.ts → restricted/getBip32PublicKey.d.cts} +9 -8
  325. package/dist/restricted/getBip32PublicKey.d.cts.map +1 -0
  326. package/dist/restricted/getBip32PublicKey.d.mts +54 -0
  327. package/dist/restricted/getBip32PublicKey.d.mts.map +1 -0
  328. package/dist/restricted/getBip32PublicKey.mjs +72 -10
  329. package/dist/restricted/getBip32PublicKey.mjs.map +1 -1
  330. package/dist/restricted/getBip44Entropy.cjs +71 -0
  331. package/dist/restricted/getBip44Entropy.cjs.map +1 -0
  332. package/dist/{types/restricted/getBip44Entropy.d.ts → restricted/getBip44Entropy.d.cts} +8 -7
  333. package/dist/restricted/getBip44Entropy.d.cts.map +1 -0
  334. package/dist/restricted/getBip44Entropy.d.mts +47 -0
  335. package/dist/restricted/getBip44Entropy.d.mts.map +1 -0
  336. package/dist/restricted/getBip44Entropy.mjs +65 -7
  337. package/dist/restricted/getBip44Entropy.mjs.map +1 -1
  338. package/dist/restricted/getEntropy.cjs +59 -0
  339. package/dist/restricted/getEntropy.cjs.map +1 -0
  340. package/dist/{types/restricted/getEntropy.d.ts → restricted/getEntropy.d.cts} +10 -9
  341. package/dist/restricted/getEntropy.d.cts.map +1 -0
  342. package/dist/restricted/getEntropy.d.mts +62 -0
  343. package/dist/restricted/getEntropy.d.mts.map +1 -0
  344. package/dist/restricted/getEntropy.mjs +54 -8
  345. package/dist/restricted/getEntropy.mjs.map +1 -1
  346. package/dist/restricted/getLocale.cjs +47 -0
  347. package/dist/restricted/getLocale.cjs.map +1 -0
  348. package/dist/{types/restricted/getLocale.d.ts → restricted/getLocale.d.cts} +13 -11
  349. package/dist/restricted/getLocale.d.cts.map +1 -0
  350. package/dist/restricted/getLocale.d.mts +50 -0
  351. package/dist/restricted/getLocale.d.mts.map +1 -0
  352. package/dist/restricted/getLocale.mjs +40 -9
  353. package/dist/restricted/getLocale.mjs.map +1 -1
  354. package/dist/restricted/getPreferences.cjs +46 -0
  355. package/dist/restricted/getPreferences.cjs.map +1 -0
  356. package/dist/restricted/getPreferences.d.cts +49 -0
  357. package/dist/restricted/getPreferences.d.cts.map +1 -0
  358. package/dist/restricted/getPreferences.d.mts +49 -0
  359. package/dist/restricted/getPreferences.d.mts.map +1 -0
  360. package/dist/restricted/getPreferences.mjs +41 -0
  361. package/dist/restricted/getPreferences.mjs.map +1 -0
  362. package/dist/restricted/index.cjs +49 -0
  363. package/dist/restricted/index.cjs.map +1 -0
  364. package/dist/{types/restricted/index.d.ts → restricted/index.d.cts} +31 -16
  365. package/dist/restricted/index.d.cts.map +1 -0
  366. package/dist/restricted/index.d.mts +169 -0
  367. package/dist/restricted/index.d.mts.map +1 -0
  368. package/dist/restricted/index.mjs +27 -34
  369. package/dist/restricted/index.mjs.map +1 -1
  370. package/dist/restricted/invokeSnap.cjs +96 -0
  371. package/dist/restricted/invokeSnap.cjs.map +1 -0
  372. package/dist/{types/restricted/invokeSnap.d.ts → restricted/invokeSnap.d.cts} +14 -12
  373. package/dist/restricted/invokeSnap.d.cts.map +1 -0
  374. package/dist/restricted/invokeSnap.d.mts +65 -0
  375. package/dist/restricted/invokeSnap.d.mts.map +1 -0
  376. package/dist/restricted/invokeSnap.mjs +89 -11
  377. package/dist/restricted/invokeSnap.mjs.map +1 -1
  378. package/dist/restricted/manageAccounts.cjs +61 -0
  379. package/dist/restricted/manageAccounts.cjs.map +1 -0
  380. package/dist/{types/restricted/manageAccounts.d.ts → restricted/manageAccounts.d.cts} +10 -9
  381. package/dist/restricted/manageAccounts.d.cts.map +1 -0
  382. package/dist/restricted/manageAccounts.d.mts +65 -0
  383. package/dist/restricted/manageAccounts.d.mts.map +1 -0
  384. package/dist/restricted/manageAccounts.mjs +54 -11
  385. package/dist/restricted/manageAccounts.mjs.map +1 -1
  386. package/dist/restricted/manageState.cjs +175 -0
  387. package/dist/restricted/manageState.cjs.map +1 -0
  388. package/dist/{types/restricted/manageState.d.ts → restricted/manageState.d.cts} +10 -9
  389. package/dist/restricted/manageState.d.cts.map +1 -0
  390. package/dist/restricted/manageState.d.mts +111 -0
  391. package/dist/restricted/manageState.d.mts.map +1 -0
  392. package/dist/restricted/manageState.mjs +166 -18
  393. package/dist/restricted/manageState.mjs.map +1 -1
  394. package/dist/restricted/notify.cjs +108 -0
  395. package/dist/restricted/notify.cjs.map +1 -0
  396. package/dist/{types/restricted/notify.d.ts → restricted/notify.d.cts} +11 -10
  397. package/dist/restricted/notify.d.cts.map +1 -0
  398. package/dist/restricted/notify.d.mts +83 -0
  399. package/dist/restricted/notify.d.mts.map +1 -0
  400. package/dist/restricted/notify.mjs +100 -11
  401. package/dist/restricted/notify.mjs.map +1 -1
  402. package/dist/utils.cjs +140 -0
  403. package/dist/utils.cjs.map +1 -0
  404. package/dist/{types/utils.d.ts → utils.d.cts} +9 -7
  405. package/dist/utils.d.cts.map +1 -0
  406. package/dist/utils.d.mts +98 -0
  407. package/dist/utils.d.mts.map +1 -0
  408. package/dist/utils.mjs +132 -12
  409. package/dist/utils.mjs.map +1 -1
  410. package/package.json +20 -19
  411. package/dist/chunk-23XDKQW2.mjs +0 -73
  412. package/dist/chunk-23XDKQW2.mjs.map +0 -1
  413. package/dist/chunk-2CTOCP34.mjs +0 -45
  414. package/dist/chunk-2CTOCP34.mjs.map +0 -1
  415. package/dist/chunk-2L2ATCIK.mjs +0 -78
  416. package/dist/chunk-2L2ATCIK.mjs.map +0 -1
  417. package/dist/chunk-2RDYC42U.mjs +0 -67
  418. package/dist/chunk-2RDYC42U.mjs.map +0 -1
  419. package/dist/chunk-2SFH57UV.js +0 -21
  420. package/dist/chunk-33LLA2MH.mjs +0 -75
  421. package/dist/chunk-33LLA2MH.mjs.map +0 -1
  422. package/dist/chunk-33MTKZ4H.js +0 -90
  423. package/dist/chunk-33MTKZ4H.js.map +0 -1
  424. package/dist/chunk-3UAWEHMF.js +0 -18
  425. package/dist/chunk-3UAWEHMF.js.map +0 -1
  426. package/dist/chunk-3WCLDJAS.mjs +0 -74
  427. package/dist/chunk-3WCLDJAS.mjs.map +0 -1
  428. package/dist/chunk-3WKIKYUH.js +0 -78
  429. package/dist/chunk-3WKIKYUH.js.map +0 -1
  430. package/dist/chunk-4D2B2UQ6.mjs +0 -23
  431. package/dist/chunk-4D2B2UQ6.mjs.map +0 -1
  432. package/dist/chunk-4LSOS7SM.js +0 -23
  433. package/dist/chunk-4LSOS7SM.js.map +0 -1
  434. package/dist/chunk-4PWFZPJC.js +0 -79
  435. package/dist/chunk-4PWFZPJC.js.map +0 -1
  436. package/dist/chunk-4TUORIA6.js +0 -59
  437. package/dist/chunk-4TUORIA6.js.map +0 -1
  438. package/dist/chunk-57BL7O2P.mjs +0 -69
  439. package/dist/chunk-57BL7O2P.mjs.map +0 -1
  440. package/dist/chunk-62URQ5VS.mjs +0 -18
  441. package/dist/chunk-62URQ5VS.mjs.map +0 -1
  442. package/dist/chunk-6VJVURH5.js +0 -43
  443. package/dist/chunk-6VJVURH5.js.map +0 -1
  444. package/dist/chunk-756OQVOC.js +0 -67
  445. package/dist/chunk-756OQVOC.js.map +0 -1
  446. package/dist/chunk-7CV677MM.js +0 -42
  447. package/dist/chunk-7CV677MM.js.map +0 -1
  448. package/dist/chunk-7HVABE5R.js +0 -74
  449. package/dist/chunk-7HVABE5R.js.map +0 -1
  450. package/dist/chunk-7P6TF6CE.mjs +0 -55
  451. package/dist/chunk-7P6TF6CE.mjs.map +0 -1
  452. package/dist/chunk-7TVJV425.js +0 -1
  453. package/dist/chunk-7TVJV425.js.map +0 -1
  454. package/dist/chunk-A6H6I4VH.js +0 -61
  455. package/dist/chunk-A6H6I4VH.js.map +0 -1
  456. package/dist/chunk-ATBKAX2S.js +0 -39
  457. package/dist/chunk-ATBKAX2S.js.map +0 -1
  458. package/dist/chunk-B3NIHNXW.js +0 -23
  459. package/dist/chunk-B3NIHNXW.js.map +0 -1
  460. package/dist/chunk-BSAXPL2T.mjs +0 -59
  461. package/dist/chunk-BSAXPL2T.mjs.map +0 -1
  462. package/dist/chunk-CD4OUHO5.mjs +0 -20
  463. package/dist/chunk-CD4OUHO5.mjs.map +0 -1
  464. package/dist/chunk-CH5O2YCX.mjs +0 -18
  465. package/dist/chunk-CH5O2YCX.mjs.map +0 -1
  466. package/dist/chunk-DLVPMPRZ.js +0 -45
  467. package/dist/chunk-DLVPMPRZ.js.map +0 -1
  468. package/dist/chunk-DTZF746A.mjs +0 -21
  469. package/dist/chunk-DTZF746A.mjs.map +0 -1
  470. package/dist/chunk-E27BGHCR.js +0 -78
  471. package/dist/chunk-E27BGHCR.js.map +0 -1
  472. package/dist/chunk-ELCOEVKA.js +0 -196
  473. package/dist/chunk-ELCOEVKA.js.map +0 -1
  474. package/dist/chunk-EOXTZF5U.js +0 -47
  475. package/dist/chunk-EOXTZF5U.js.map +0 -1
  476. package/dist/chunk-FCVWU5XH.js +0 -73
  477. package/dist/chunk-FFHVA6PP.js +0 -82
  478. package/dist/chunk-FFHVA6PP.js.map +0 -1
  479. package/dist/chunk-FJ7COFRJ.mjs +0 -54
  480. package/dist/chunk-FJ7COFRJ.mjs.map +0 -1
  481. package/dist/chunk-FNUO7MQ4.mjs +0 -43
  482. package/dist/chunk-FNUO7MQ4.mjs.map +0 -1
  483. package/dist/chunk-GE5XFDUE.js +0 -21
  484. package/dist/chunk-GE5XFDUE.js.map +0 -1
  485. package/dist/chunk-GPV4ETUH.mjs +0 -47
  486. package/dist/chunk-GPV4ETUH.mjs.map +0 -1
  487. package/dist/chunk-H6X3CWWQ.js +0 -54
  488. package/dist/chunk-H6X3CWWQ.js.map +0 -1
  489. package/dist/chunk-HOECEYMT.mjs +0 -70
  490. package/dist/chunk-HOECEYMT.mjs.map +0 -1
  491. package/dist/chunk-HZQ34FQT.js +0 -49
  492. package/dist/chunk-HZQ34FQT.js.map +0 -1
  493. package/dist/chunk-I2P65KBQ.mjs +0 -67
  494. package/dist/chunk-I2P65KBQ.mjs.map +0 -1
  495. package/dist/chunk-I3G6S6MJ.js +0 -68
  496. package/dist/chunk-I3G6S6MJ.js.map +0 -1
  497. package/dist/chunk-IE6EHYEG.js +0 -57
  498. package/dist/chunk-IE6EHYEG.js.map +0 -1
  499. package/dist/chunk-IZYMBIBD.mjs +0 -32
  500. package/dist/chunk-IZYMBIBD.mjs.map +0 -1
  501. package/dist/chunk-JWDQUKKU.mjs +0 -80
  502. package/dist/chunk-JWDQUKKU.mjs.map +0 -1
  503. package/dist/chunk-KRSIAVUJ.js +0 -115
  504. package/dist/chunk-KRSIAVUJ.js.map +0 -1
  505. package/dist/chunk-KSTF5JYB.mjs +0 -23
  506. package/dist/chunk-KSTF5JYB.mjs.map +0 -1
  507. package/dist/chunk-LR7UR4YU.mjs +0 -52
  508. package/dist/chunk-LR7UR4YU.mjs.map +0 -1
  509. package/dist/chunk-LXJBBRQ4.mjs +0 -57
  510. package/dist/chunk-LXJBBRQ4.mjs.map +0 -1
  511. package/dist/chunk-M2JQCKR7.js +0 -143
  512. package/dist/chunk-M2JQCKR7.js.map +0 -1
  513. package/dist/chunk-MC2Z4NF6.mjs +0 -45
  514. package/dist/chunk-MC2Z4NF6.mjs.map +0 -1
  515. package/dist/chunk-MXPVC2XP.mjs +0 -105
  516. package/dist/chunk-MXPVC2XP.mjs.map +0 -1
  517. package/dist/chunk-NU4NAAFG.js +0 -1
  518. package/dist/chunk-NU4NAAFG.js.map +0 -1
  519. package/dist/chunk-NWT2EXFD.js +0 -18
  520. package/dist/chunk-NWT2EXFD.js.map +0 -1
  521. package/dist/chunk-O66NZFSD.mjs +0 -23
  522. package/dist/chunk-O66NZFSD.mjs.map +0 -1
  523. package/dist/chunk-ODN35VOK.mjs +0 -119
  524. package/dist/chunk-ODN35VOK.mjs.map +0 -1
  525. package/dist/chunk-OI33OL7K.js +0 -47
  526. package/dist/chunk-OI33OL7K.js.map +0 -1
  527. package/dist/chunk-PIAWDTWO.mjs +0 -68
  528. package/dist/chunk-PIAWDTWO.mjs.map +0 -1
  529. package/dist/chunk-PIRQCNBJ.mjs +0 -78
  530. package/dist/chunk-PIRQCNBJ.mjs.map +0 -1
  531. package/dist/chunk-PS6OEQXL.js +0 -105
  532. package/dist/chunk-PS6OEQXL.js.map +0 -1
  533. package/dist/chunk-PXU6PORA.js +0 -119
  534. package/dist/chunk-PXU6PORA.js.map +0 -1
  535. package/dist/chunk-Q27K2I6Z.js +0 -23
  536. package/dist/chunk-Q27K2I6Z.js.map +0 -1
  537. package/dist/chunk-QDZAWH6F.js +0 -80
  538. package/dist/chunk-QDZAWH6F.js.map +0 -1
  539. package/dist/chunk-QMULJEYN.js +0 -35
  540. package/dist/chunk-QMULJEYN.js.map +0 -1
  541. package/dist/chunk-SYB5TG5O.mjs +0 -49
  542. package/dist/chunk-SYB5TG5O.mjs.map +0 -1
  543. package/dist/chunk-SYUGPLEP.js +0 -32
  544. package/dist/chunk-SYUGPLEP.js.map +0 -1
  545. package/dist/chunk-T56DKVFS.js +0 -70
  546. package/dist/chunk-T56DKVFS.js.map +0 -1
  547. package/dist/chunk-TAXLFFV4.mjs +0 -115
  548. package/dist/chunk-TAXLFFV4.mjs.map +0 -1
  549. package/dist/chunk-TE4W25CA.mjs +0 -143
  550. package/dist/chunk-TE4W25CA.mjs.map +0 -1
  551. package/dist/chunk-TG63GBK3.mjs +0 -1
  552. package/dist/chunk-TG63GBK3.mjs.map +0 -1
  553. package/dist/chunk-TNENASGX.mjs +0 -1
  554. package/dist/chunk-TNENASGX.mjs.map +0 -1
  555. package/dist/chunk-TQCUJQHY.mjs +0 -196
  556. package/dist/chunk-TQCUJQHY.mjs.map +0 -1
  557. package/dist/chunk-TT4DP2YW.mjs +0 -35
  558. package/dist/chunk-TT4DP2YW.mjs.map +0 -1
  559. package/dist/chunk-TVC3E5LI.mjs +0 -42
  560. package/dist/chunk-TVC3E5LI.mjs.map +0 -1
  561. package/dist/chunk-U6TJQLNV.js +0 -45
  562. package/dist/chunk-U6TJQLNV.js.map +0 -1
  563. package/dist/chunk-UB3733UY.mjs +0 -23
  564. package/dist/chunk-UB3733UY.mjs.map +0 -1
  565. package/dist/chunk-UCWANXBZ.js +0 -45
  566. package/dist/chunk-UCWANXBZ.js.map +0 -1
  567. package/dist/chunk-UF3UJTY3.js +0 -55
  568. package/dist/chunk-UF3UJTY3.js.map +0 -1
  569. package/dist/chunk-UY4DUF53.mjs +0 -45
  570. package/dist/chunk-UY4DUF53.mjs.map +0 -1
  571. package/dist/chunk-VUA6ICJO.js +0 -52
  572. package/dist/chunk-VUA6ICJO.js.map +0 -1
  573. package/dist/chunk-VVBTXSID.mjs +0 -82
  574. package/dist/chunk-VVBTXSID.mjs.map +0 -1
  575. package/dist/chunk-VYII7C3J.mjs +0 -79
  576. package/dist/chunk-VYII7C3J.mjs.map +0 -1
  577. package/dist/chunk-W33UWNA2.mjs +0 -90
  578. package/dist/chunk-W33UWNA2.mjs.map +0 -1
  579. package/dist/chunk-XGMYBPQR.mjs +0 -47
  580. package/dist/chunk-XGMYBPQR.mjs.map +0 -1
  581. package/dist/chunk-YGKFOOWI.js +0 -20
  582. package/dist/chunk-YGKFOOWI.js.map +0 -1
  583. package/dist/chunk-YOHE52XB.js +0 -23
  584. package/dist/chunk-YOHE52XB.js.map +0 -1
  585. package/dist/chunk-YT2Q3W5C.js +0 -69
  586. package/dist/chunk-YT2Q3W5C.js.map +0 -1
  587. package/dist/chunk-YZMFLB67.js +0 -75
  588. package/dist/chunk-YZMFLB67.js.map +0 -1
  589. package/dist/chunk-Z6YFGWHN.mjs +0 -61
  590. package/dist/chunk-Z6YFGWHN.mjs.map +0 -1
  591. package/dist/chunk-ZH3FC55E.mjs +0 -21
  592. package/dist/chunk-ZH3FC55E.mjs.map +0 -1
  593. package/dist/chunk-ZKISN6YP.js +0 -67
  594. package/dist/chunk-ZKISN6YP.js.map +0 -1
  595. package/dist/chunk-ZXDCQWMJ.mjs +0 -39
  596. package/dist/chunk-ZXDCQWMJ.mjs.map +0 -1
  597. package/dist/endowments/caveats/generic.js +0 -7
  598. package/dist/endowments/caveats/generic.js.map +0 -1
  599. package/dist/endowments/caveats/index.js +0 -18
  600. package/dist/endowments/caveats/index.js.map +0 -1
  601. package/dist/endowments/caveats/requestTime.js +0 -13
  602. package/dist/endowments/caveats/requestTime.js.map +0 -1
  603. package/dist/endowments/cronjob.js +0 -16
  604. package/dist/endowments/cronjob.js.map +0 -1
  605. package/dist/endowments/enum.js +0 -7
  606. package/dist/endowments/enum.js.map +0 -1
  607. package/dist/endowments/ethereum-provider.js +0 -8
  608. package/dist/endowments/ethereum-provider.js.map +0 -1
  609. package/dist/endowments/home-page.js +0 -8
  610. package/dist/endowments/home-page.js.map +0 -1
  611. package/dist/endowments/index.js +0 -54
  612. package/dist/endowments/index.js.map +0 -1
  613. package/dist/endowments/keyring.js +0 -17
  614. package/dist/endowments/keyring.js.map +0 -1
  615. package/dist/endowments/lifecycle-hooks.js +0 -8
  616. package/dist/endowments/lifecycle-hooks.js.map +0 -1
  617. package/dist/endowments/name-lookup.js +0 -19
  618. package/dist/endowments/name-lookup.js.map +0 -1
  619. package/dist/endowments/network-access.js +0 -8
  620. package/dist/endowments/network-access.js.map +0 -1
  621. package/dist/endowments/rpc.js +0 -17
  622. package/dist/endowments/rpc.js.map +0 -1
  623. package/dist/endowments/signature-insight.js +0 -17
  624. package/dist/endowments/signature-insight.js.map +0 -1
  625. package/dist/endowments/transaction-insight.js +0 -17
  626. package/dist/endowments/transaction-insight.js.map +0 -1
  627. package/dist/endowments/web-assembly.js +0 -8
  628. package/dist/endowments/web-assembly.js.map +0 -1
  629. package/dist/index.js +0 -122
  630. package/dist/index.js.map +0 -1
  631. package/dist/permissions.js +0 -43
  632. package/dist/permissions.js.map +0 -1
  633. package/dist/permitted/createInterface.js +0 -7
  634. package/dist/permitted/createInterface.js.map +0 -1
  635. package/dist/permitted/getAllSnaps.js +0 -7
  636. package/dist/permitted/getAllSnaps.js.map +0 -1
  637. package/dist/permitted/getClientStatus.js +0 -7
  638. package/dist/permitted/getClientStatus.js.map +0 -1
  639. package/dist/permitted/getFile.js +0 -9
  640. package/dist/permitted/getFile.js.map +0 -1
  641. package/dist/permitted/getInterfaceState.js +0 -7
  642. package/dist/permitted/getInterfaceState.js.map +0 -1
  643. package/dist/permitted/getSnaps.js +0 -7
  644. package/dist/permitted/getSnaps.js.map +0 -1
  645. package/dist/permitted/handlers.js +0 -21
  646. package/dist/permitted/handlers.js.map +0 -1
  647. package/dist/permitted/index.js +0 -27
  648. package/dist/permitted/index.js.map +0 -1
  649. package/dist/permitted/invokeKeyring.js +0 -8
  650. package/dist/permitted/invokeKeyring.js.map +0 -1
  651. package/dist/permitted/invokeSnapSugar.js +0 -11
  652. package/dist/permitted/invokeSnapSugar.js.map +0 -1
  653. package/dist/permitted/middleware.js +0 -21
  654. package/dist/permitted/middleware.js.map +0 -1
  655. package/dist/permitted/requestSnaps.js +0 -12
  656. package/dist/permitted/requestSnaps.js.map +0 -1
  657. package/dist/permitted/resolveInterface.js +0 -7
  658. package/dist/permitted/resolveInterface.js.map +0 -1
  659. package/dist/permitted/updateInterface.js +0 -7
  660. package/dist/permitted/updateInterface.js.map +0 -1
  661. package/dist/restricted/caveats/index.js +0 -17
  662. package/dist/restricted/caveats/index.js.map +0 -1
  663. package/dist/restricted/caveats/permittedCoinTypes.js +0 -13
  664. package/dist/restricted/caveats/permittedCoinTypes.js.map +0 -1
  665. package/dist/restricted/caveats/permittedDerivationPaths.js +0 -13
  666. package/dist/restricted/caveats/permittedDerivationPaths.js.map +0 -1
  667. package/dist/restricted/caveats/snapIds.js +0 -11
  668. package/dist/restricted/caveats/snapIds.js.map +0 -1
  669. package/dist/restricted/dialog.js +0 -11
  670. package/dist/restricted/dialog.js.map +0 -1
  671. package/dist/restricted/getBip32Entropy.js +0 -10
  672. package/dist/restricted/getBip32Entropy.js.map +0 -1
  673. package/dist/restricted/getBip32PublicKey.js +0 -12
  674. package/dist/restricted/getBip32PublicKey.js.map +0 -1
  675. package/dist/restricted/getBip44Entropy.js +0 -9
  676. package/dist/restricted/getBip44Entropy.js.map +0 -1
  677. package/dist/restricted/getEntropy.js +0 -10
  678. package/dist/restricted/getEntropy.js.map +0 -1
  679. package/dist/restricted/getLocale.js +0 -11
  680. package/dist/restricted/getLocale.js.map +0 -1
  681. package/dist/restricted/index.js +0 -36
  682. package/dist/restricted/index.js.map +0 -1
  683. package/dist/restricted/invokeSnap.js +0 -13
  684. package/dist/restricted/invokeSnap.js.map +0 -1
  685. package/dist/restricted/manageAccounts.js +0 -13
  686. package/dist/restricted/manageAccounts.js.map +0 -1
  687. package/dist/restricted/manageState.js +0 -20
  688. package/dist/restricted/manageState.js.map +0 -1
  689. package/dist/restricted/notify.js +0 -13
  690. package/dist/restricted/notify.js.map +0 -1
  691. package/dist/tsconfig.build.tsbuildinfo +0 -1
  692. package/dist/types/__fixtures__/index.d.ts +0 -1
  693. package/dist/types/endowments/caveats/index.d.ts +0 -2
  694. package/dist/types/index.d.ts +0 -7
  695. package/dist/types/permitted/index.d.ts +0 -11
  696. package/dist/types/restricted/dialog.d.ts +0 -1351
  697. package/dist/utils.js +0 -13
  698. package/dist/utils.js.map +0 -1
@@ -1,75 +0,0 @@
1
- import {
2
- createGenericPermissionValidator
3
- } from "./chunk-TT4DP2YW.mjs";
4
-
5
- // src/endowments/signature-insight.ts
6
- import { PermissionType, SubjectType } from "@metamask/permission-controller";
7
- import { rpcErrors } from "@metamask/rpc-errors";
8
- import { SnapCaveatType } from "@metamask/snaps-utils";
9
- import { assert, hasProperty, isObject, isPlainObject } from "@metamask/utils";
10
- var permissionName = "endowment:signature-insight" /* SignatureInsight */;
11
- var specificationBuilder = (_builderOptions) => {
12
- return {
13
- permissionType: PermissionType.Endowment,
14
- targetName: permissionName,
15
- allowedCaveats: [SnapCaveatType.SignatureOrigin],
16
- endowmentGetter: (_getterOptions) => null,
17
- validator: createGenericPermissionValidator([
18
- { type: SnapCaveatType.SignatureOrigin, optional: true },
19
- { type: SnapCaveatType.MaxRequestTime, optional: true }
20
- ]),
21
- subjectTypes: [SubjectType.Snap]
22
- };
23
- };
24
- var signatureInsightEndowmentBuilder = Object.freeze({
25
- targetName: permissionName,
26
- specificationBuilder
27
- });
28
- function validateCaveat(caveat) {
29
- if (!hasProperty(caveat, "value") || !isPlainObject(caveat)) {
30
- throw rpcErrors.invalidParams({
31
- message: "Expected a plain object."
32
- });
33
- }
34
- const { value } = caveat;
35
- assert(
36
- typeof value === "boolean",
37
- 'Expected caveat value to have type "boolean"'
38
- );
39
- }
40
- function getSignatureInsightCaveatMapper(value) {
41
- if (!value || !isObject(value) || isObject(value) && Object.keys(value).length === 0) {
42
- return { caveats: null };
43
- }
44
- return {
45
- caveats: [
46
- {
47
- type: SnapCaveatType.SignatureOrigin,
48
- value: hasProperty(value, "allowSignatureOrigin") && value.allowSignatureOrigin
49
- }
50
- ]
51
- };
52
- }
53
- function getSignatureOriginCaveat(permission) {
54
- if (!permission?.caveats) {
55
- return null;
56
- }
57
- assert(permission.caveats.length === 1);
58
- assert(permission.caveats[0].type === SnapCaveatType.SignatureOrigin);
59
- const caveat = permission.caveats[0];
60
- return caveat.value ?? null;
61
- }
62
- var signatureInsightCaveatSpecifications = {
63
- [SnapCaveatType.SignatureOrigin]: Object.freeze({
64
- type: SnapCaveatType.SignatureOrigin,
65
- validator: (caveat) => validateCaveat(caveat)
66
- })
67
- };
68
-
69
- export {
70
- signatureInsightEndowmentBuilder,
71
- getSignatureInsightCaveatMapper,
72
- getSignatureOriginCaveat,
73
- signatureInsightCaveatSpecifications
74
- };
75
- //# sourceMappingURL=chunk-33LLA2MH.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/endowments/signature-insight.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n EndowmentGetterParams,\n ValidPermissionSpecification,\n PermissionValidatorConstraint,\n PermissionConstraint,\n CaveatSpecificationConstraint,\n Caveat,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { SnapCaveatType } from '@metamask/snaps-utils';\nimport type { Json, NonEmptyArray } from '@metamask/utils';\nimport { assert, hasProperty, isObject, isPlainObject } from '@metamask/utils';\n\nimport { createGenericPermissionValidator } from './caveats';\nimport { SnapEndowments } from './enum';\n\nconst permissionName = SnapEndowments.SignatureInsight;\n\ntype SignatureInsightEndowmentSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.Endowment;\n targetName: typeof permissionName;\n endowmentGetter: (_options?: EndowmentGetterParams) => null;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\n/**\n * `endowment:signature-insight` returns nothing; it is intended to be used as a flag\n * by the extension to detect whether the snap has the capability to show information on the signature confirmation screen.\n *\n * @param _builderOptions - Optional specification builder options.\n * @returns The specification for the signature-insight endowment.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.Endowment,\n any,\n SignatureInsightEndowmentSpecification\n> = (_builderOptions?: unknown) => {\n return {\n permissionType: PermissionType.Endowment,\n targetName: permissionName,\n allowedCaveats: [SnapCaveatType.SignatureOrigin],\n endowmentGetter: (_getterOptions?: EndowmentGetterParams) => null,\n validator: createGenericPermissionValidator([\n { type: SnapCaveatType.SignatureOrigin, optional: true },\n { type: SnapCaveatType.MaxRequestTime, optional: true },\n ]),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nexport const signatureInsightEndowmentBuilder = Object.freeze({\n targetName: permissionName,\n specificationBuilder,\n} as const);\n\n/**\n * Validates the type of the caveat value.\n *\n * @param caveat - The caveat to validate.\n * @throws If the caveat value is invalid.\n */\nfunction validateCaveat(caveat: Caveat<string, any>): void {\n if (!hasProperty(caveat, 'value') || !isPlainObject(caveat)) {\n throw rpcErrors.invalidParams({\n message: 'Expected a plain object.',\n });\n }\n\n const { value } = caveat;\n\n assert(\n typeof value === 'boolean',\n 'Expected caveat value to have type \"boolean\"',\n );\n}\n\n/**\n * Map a raw value from the `initialPermissions` to a caveat specification.\n * Note that this function does not do any validation, that's handled by the\n * PermissionController when the permission is requested.\n *\n * @param value - The raw value from the `initialPermissions`.\n * @returns The caveat specification.\n */\nexport function getSignatureInsightCaveatMapper(\n value: Json,\n): Pick<PermissionConstraint, 'caveats'> {\n if (\n !value ||\n !isObject(value) ||\n (isObject(value) && Object.keys(value).length === 0)\n ) {\n return { caveats: null };\n }\n return {\n caveats: [\n {\n type: SnapCaveatType.SignatureOrigin,\n value:\n hasProperty(value, 'allowSignatureOrigin') &&\n (value.allowSignatureOrigin as boolean),\n },\n ],\n };\n}\n\n/**\n * Getter function to get the signature origin caveat from a permission.\n *\n * This does basic validation of the caveat, but does not validate the type or\n * value of the namespaces object itself, as this is handled by the\n * `PermissionsController` when the permission is requested.\n *\n * @param permission - The permission to get the signature origin caveat from.\n * @returns The signature origin, or `null` if the permission does not have a\n * signature origin caveat.\n */\nexport function getSignatureOriginCaveat(\n permission?: PermissionConstraint,\n): boolean | null {\n if (!permission?.caveats) {\n return null;\n }\n\n assert(permission.caveats.length === 1);\n assert(permission.caveats[0].type === SnapCaveatType.SignatureOrigin);\n\n const caveat = permission.caveats[0] as Caveat<string, boolean>;\n\n return caveat.value ?? null;\n}\n\nexport const signatureInsightCaveatSpecifications: Record<\n SnapCaveatType.SignatureOrigin,\n CaveatSpecificationConstraint\n> = {\n [SnapCaveatType.SignatureOrigin]: Object.freeze({\n type: SnapCaveatType.SignatureOrigin,\n validator: (caveat: Caveat<string, any>) => validateCaveat(caveat),\n }),\n};\n"],"mappings":";;;;;AASA,SAAS,gBAAgB,mBAAmB;AAC5C,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAE/B,SAAS,QAAQ,aAAa,UAAU,qBAAqB;AAK7D,IAAM;AAiBN,IAAM,uBAIF,CAAC,oBAA8B;AACjC,SAAO;AAAA,IACL,gBAAgB,eAAe;AAAA,IAC/B,YAAY;AAAA,IACZ,gBAAgB,CAAC,eAAe,eAAe;AAAA,IAC/C,iBAAiB,CAAC,mBAA2C;AAAA,IAC7D,WAAW,iCAAiC;AAAA,MAC1C,EAAE,MAAM,eAAe,iBAAiB,UAAU,KAAK;AAAA,MACvD,EAAE,MAAM,eAAe,gBAAgB,UAAU,KAAK;AAAA,IACxD,CAAC;AAAA,IACD,cAAc,CAAC,YAAY,IAAI;AAAA,EACjC;AACF;AAEO,IAAM,mCAAmC,OAAO,OAAO;AAAA,EAC5D,YAAY;AAAA,EACZ;AACF,CAAU;AAQV,SAAS,eAAe,QAAmC;AACzD,MAAI,CAAC,YAAY,QAAQ,OAAO,KAAK,CAAC,cAAc,MAAM,GAAG;AAC3D,UAAM,UAAU,cAAc;AAAA,MAC5B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,QAAM,EAAE,MAAM,IAAI;AAElB;AAAA,IACE,OAAO,UAAU;AAAA,IACjB;AAAA,EACF;AACF;AAUO,SAAS,gCACd,OACuC;AACvC,MACE,CAAC,SACD,CAAC,SAAS,KAAK,KACd,SAAS,KAAK,KAAK,OAAO,KAAK,KAAK,EAAE,WAAW,GAClD;AACA,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB;AACA,SAAO;AAAA,IACL,SAAS;AAAA,MACP;AAAA,QACE,MAAM,eAAe;AAAA,QACrB,OACE,YAAY,OAAO,sBAAsB,KACxC,MAAM;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;AAaO,SAAS,yBACd,YACgB;AAChB,MAAI,CAAC,YAAY,SAAS;AACxB,WAAO;AAAA,EACT;AAEA,SAAO,WAAW,QAAQ,WAAW,CAAC;AACtC,SAAO,WAAW,QAAQ,CAAC,EAAE,SAAS,eAAe,eAAe;AAEpE,QAAM,SAAS,WAAW,QAAQ,CAAC;AAEnC,SAAO,OAAO,SAAS;AACzB;AAEO,IAAM,uCAGT;AAAA,EACF,CAAC,eAAe,eAAe,GAAG,OAAO,OAAO;AAAA,IAC9C,MAAM,eAAe;AAAA,IACrB,WAAW,CAAC,WAAgC,eAAe,MAAM;AAAA,EACnE,CAAC;AACH;","names":[]}
@@ -1,90 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils.ts
2
- var _keytree = require('@metamask/key-tree');
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
- var _utils = require('@metamask/utils');
11
- var _sha3 = require('@noble/hashes/sha3');
12
- var HARDENED_VALUE = 2147483648;
13
- function selectHooks(hooks, hookNames) {
14
- if (hookNames) {
15
- return Object.keys(hookNames).reduce(
16
- (hookSubset, _hookName) => {
17
- const hookName = _hookName;
18
- hookSubset[hookName] = hooks[hookName];
19
- return hookSubset;
20
- },
21
- {}
22
- );
23
- }
24
- return void 0;
25
- }
26
- function getDerivationPathArray(hash) {
27
- const array = [];
28
- const view = _utils.createDataView.call(void 0, hash);
29
- for (let index = 0; index < 8; index++) {
30
- const uint32 = view.getUint32(index * 4);
31
- const pathIndex = (uint32 | HARDENED_VALUE) >>> 0;
32
- array.push(`bip32:${pathIndex - HARDENED_VALUE}'`);
33
- }
34
- return array;
35
- }
36
- async function deriveEntropy({
37
- input,
38
- salt = "",
39
- mnemonicPhrase,
40
- magic
41
- }) {
42
- const inputBytes = _utils.stringToBytes.call(void 0, input);
43
- const saltBytes = _utils.stringToBytes.call(void 0, salt);
44
- const hash = _sha3.keccak_256.call(void 0, _utils.concatBytes.call(void 0, [inputBytes, _sha3.keccak_256.call(void 0, saltBytes)]));
45
- const computedDerivationPath = getDerivationPathArray(hash);
46
- const { privateKey } = await _keytree.SLIP10Node.fromDerivationPath({
47
- derivationPath: [
48
- mnemonicPhrase,
49
- `bip32:${magic}`,
50
- ...computedDerivationPath
51
- ],
52
- curve: "secp256k1"
53
- });
54
- _utils.assert.call(void 0, privateKey, "Failed to derive the entropy.");
55
- return _utils.add0x.call(void 0, privateKey);
56
- }
57
- function getPathPrefix(curve) {
58
- switch (curve) {
59
- case "secp256k1":
60
- return "bip32";
61
- case "ed25519":
62
- return "slip10";
63
- case "ed25519Bip32":
64
- return "cip3";
65
- default:
66
- return _utils.assertExhaustive.call(void 0, curve);
67
- }
68
- }
69
- async function getNode({
70
- curve,
71
- secretRecoveryPhrase,
72
- path
73
- }) {
74
- const prefix = getPathPrefix(curve);
75
- return await _keytree.SLIP10Node.fromDerivationPath({
76
- curve,
77
- derivationPath: [
78
- secretRecoveryPhrase,
79
- ...path.slice(1).map((index) => `${prefix}:${index}`)
80
- ]
81
- });
82
- }
83
-
84
-
85
-
86
-
87
-
88
-
89
- exports.selectHooks = selectHooks; exports.deriveEntropy = deriveEntropy; exports.getPathPrefix = getPathPrefix; exports.getNode = getNode;
90
- //# sourceMappingURL=chunk-33MTKZ4H.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils.ts"],"names":[],"mappings":";AAMA,SAAS,kBAAkB;AAG3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc,iBAAiB;AAExC,IAAM,iBAAiB;AAuBhB,SAAS,YAId,OACA,WACmC;AACnC,MAAI,WAAW;AACb,WAAO,OAAO,KAAK,SAAS,EAAE;AAAA,MAC5B,CAAC,YAAY,cAAc;AACzB,cAAM,WAAW;AACjB,mBAAW,QAAQ,IAAI,MAAM,QAAQ;AACrC,eAAO;AAAA,MACT;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO;AACT;AASA,SAAS,uBAAuB,MAAuC;AACrE,QAAM,QAA6B,CAAC;AACpC,QAAM,OAAO,eAAe,IAAI;AAEhC,WAAS,QAAQ,GAAG,QAAQ,GAAG,SAAS;AACtC,UAAM,SAAS,KAAK,UAAU,QAAQ,CAAC;AAMvC,UAAM,aAAa,SAAS,oBAAoB;AAChD,UAAM,KAAK,SAAS,YAAY,cAAc,GAAY;AAAA,EAC5D;AAEA,SAAO;AACT;AAwCA,eAAsB,cAAc;AAAA,EAClC;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AACF,GAAuC;AACrC,QAAM,aAAa,cAAc,KAAK;AACtC,QAAM,YAAY,cAAc,IAAI;AAGpC,QAAM,OAAO,UAAU,YAAY,CAAC,YAAY,UAAU,SAAS,CAAC,CAAC,CAAC;AACtE,QAAM,yBAAyB,uBAAuB,IAAI;AAG1D,QAAM,EAAE,WAAW,IAAI,MAAM,WAAW,mBAAmB;AAAA,IACzD,gBAAgB;AAAA,MACd;AAAA,MACA,SAAS,KAAK;AAAA,MACd,GAAG;AAAA,IACL;AAAA,IACA,OAAO;AAAA,EACT,CAAC;AAGD,SAAO,YAAY,+BAA+B;AAElD,SAAO,MAAM,UAAU;AACzB;AAiBO,SAAS,cACd,OAC6B;AAC7B,UAAQ,OAAO;AAAA,IACb,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO,iBAAiB,KAAK;AAAA,EACjC;AACF;AAqBA,eAAsB,QAAQ;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AACF,GAAgB;AACd,QAAM,SAAS,cAAc,KAAK;AAElC,SAAO,MAAM,WAAW,mBAAmB;AAAA,IACzC;AAAA,IACA,gBAAgB;AAAA,MACd;AAAA,MACA,GAAI,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,UAAU,GAAG,MAAM,IAAI,KAAK,EAAE;AAAA,IAGvD;AAAA,EACF,CAAC;AACH","sourcesContent":["import type {\n HardenedBIP32Node,\n BIP32Node,\n SLIP10PathNode,\n SupportedCurve,\n} from '@metamask/key-tree';\nimport { SLIP10Node } from '@metamask/key-tree';\nimport type { MagicValue } from '@metamask/snaps-utils';\nimport type { Hex } from '@metamask/utils';\nimport {\n assertExhaustive,\n add0x,\n assert,\n concatBytes,\n createDataView,\n stringToBytes,\n} from '@metamask/utils';\nimport { keccak_256 as keccak256 } from '@noble/hashes/sha3';\n\nconst HARDENED_VALUE = 0x80000000;\n\n/**\n * Maps an interface with method hooks to an object, using the keys of the\n * interface, and `true` as value. This ensures that the `methodHooks` object\n * has the same values as the interface.\n */\nexport type MethodHooksObject<HooksType extends Record<string, unknown>> = {\n [Key in keyof HooksType]: true;\n};\n\n/**\n * Returns the subset of the specified `hooks` that are included in the\n * `hookNames` object. This is a Principle of Least Authority (POLA) measure\n * to ensure that each RPC method implementation only has access to the\n * API \"hooks\" it needs to do its job.\n *\n * @param hooks - The hooks to select from.\n * @param hookNames - The names of the hooks to select.\n * @returns The selected hooks.\n * @template Hooks - The hooks to select from.\n * @template HookName - The names of the hooks to select.\n */\nexport function selectHooks<\n Hooks extends Record<string, unknown>,\n HookName extends keyof Hooks,\n>(\n hooks: Hooks,\n hookNames?: Record<HookName, boolean>,\n): Pick<Hooks, HookName> | undefined {\n if (hookNames) {\n return Object.keys(hookNames).reduce<Partial<Pick<Hooks, HookName>>>(\n (hookSubset, _hookName) => {\n const hookName = _hookName as HookName;\n hookSubset[hookName] = hooks[hookName];\n return hookSubset;\n },\n {},\n ) as Pick<Hooks, HookName>;\n }\n return undefined;\n}\n\n/**\n * Get a BIP-32 derivation path array from a hash, which is compatible with\n * `@metamask/key-tree`. The hash is assumed to be 32 bytes long.\n *\n * @param hash - The hash to derive indices from.\n * @returns The derived indices as a {@link HardenedBIP32Node} array.\n */\nfunction getDerivationPathArray(hash: Uint8Array): HardenedBIP32Node[] {\n const array: HardenedBIP32Node[] = [];\n const view = createDataView(hash);\n\n for (let index = 0; index < 8; index++) {\n const uint32 = view.getUint32(index * 4);\n\n // This is essentially `index | 0x80000000`. Because JavaScript numbers are\n // signed, we use the bitwise unsigned right shift operator to ensure that\n // the result is a positive number.\n // eslint-disable-next-line no-bitwise\n const pathIndex = (uint32 | HARDENED_VALUE) >>> 0;\n array.push(`bip32:${pathIndex - HARDENED_VALUE}'` as const);\n }\n\n return array;\n}\n\ntype DeriveEntropyOptions = {\n /**\n * The input value to derive entropy from.\n */\n input: string;\n\n /**\n * An optional salt to use when deriving entropy.\n */\n salt?: string;\n\n /**\n * The mnemonic phrase to use for entropy derivation.\n */\n mnemonicPhrase: Uint8Array;\n\n /**\n * A hardened BIP-32 index, which is used to derive the root key from the\n * mnemonic phrase.\n */\n magic: MagicValue;\n};\n\n/**\n * Derive entropy from the given mnemonic phrase and salt.\n *\n * This is based on the reference implementation of\n * [SIP-6](https://metamask.github.io/SIPs/SIPS/sip-6).\n *\n * @param options - The options for entropy derivation.\n * @param options.input - The input value to derive entropy from.\n * @param options.salt - An optional salt to use when deriving entropy.\n * @param options.mnemonicPhrase - The mnemonic phrase to use for entropy\n * derivation.\n * @param options.magic - A hardened BIP-32 index, which is used to derive the\n * root key from the mnemonic phrase.\n * @returns The derived entropy.\n */\nexport async function deriveEntropy({\n input,\n salt = '',\n mnemonicPhrase,\n magic,\n}: DeriveEntropyOptions): Promise<Hex> {\n const inputBytes = stringToBytes(input);\n const saltBytes = stringToBytes(salt);\n\n // Get the derivation path from the snap ID.\n const hash = keccak256(concatBytes([inputBytes, keccak256(saltBytes)]));\n const computedDerivationPath = getDerivationPathArray(hash);\n\n // Derive the private key using BIP-32.\n const { privateKey } = await SLIP10Node.fromDerivationPath({\n derivationPath: [\n mnemonicPhrase,\n `bip32:${magic}`,\n ...computedDerivationPath,\n ],\n curve: 'secp256k1',\n });\n\n // This should never happen, but this keeps TypeScript happy.\n assert(privateKey, 'Failed to derive the entropy.');\n\n return add0x(privateKey);\n}\n\n/**\n * Get the path prefix to use for key derivation in `key-tree`. This assumes the\n * following:\n *\n * - The Secp256k1 curve always uses the BIP-32 specification.\n * - The Ed25519 curve always uses the SLIP-10 specification.\n * - The BIP-32-Ed25519 curve always uses the CIP-3 specification.\n *\n * While this does not matter in most situations (no known case at the time of\n * writing), `key-tree` requires a specific specification to be used.\n *\n * @param curve - The curve to get the path prefix for. The curve is NOT\n * validated by this function.\n * @returns The path prefix, i.e., `bip32` or `slip10`.\n */\nexport function getPathPrefix(\n curve: SupportedCurve,\n): 'bip32' | 'slip10' | 'cip3' {\n switch (curve) {\n case 'secp256k1':\n return 'bip32';\n case 'ed25519':\n return 'slip10';\n case 'ed25519Bip32':\n return 'cip3';\n default:\n return assertExhaustive(curve);\n }\n}\n\ntype GetNodeArgs = {\n curve: SupportedCurve;\n secretRecoveryPhrase: Uint8Array;\n path: string[];\n};\n\n/**\n * Get a `key-tree`-compatible node.\n *\n * Note: This function assumes that all the parameters have been validated\n * beforehand.\n *\n * @param options - The derivation options.\n * @param options.curve - The curve to use for derivation.\n * @param options.secretRecoveryPhrase - The secret recovery phrase to use for\n * derivation.\n * @param options.path - The derivation path to use as array, starting with an\n * \"m\" as the first item.\n */\nexport async function getNode({\n curve,\n secretRecoveryPhrase,\n path,\n}: GetNodeArgs) {\n const prefix = getPathPrefix(curve);\n\n return await SLIP10Node.fromDerivationPath({\n curve,\n derivationPath: [\n secretRecoveryPhrase,\n ...(path.slice(1).map((index) => `${prefix}:${index}`) as\n | BIP32Node[]\n | SLIP10PathNode[]),\n ],\n });\n}\n"]}
@@ -1,18 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/permitted/getClientStatus.ts
2
- var hookNames = {
3
- getIsLocked: true
4
- };
5
- var getClientStatusHandler = {
6
- methodNames: ["snap_getClientStatus"],
7
- implementation: getClientStatusImplementation,
8
- hookNames
9
- };
10
- async function getClientStatusImplementation(_request, response, _next, end, { getIsLocked }) {
11
- response.result = { locked: getIsLocked() };
12
- return end();
13
- }
14
-
15
-
16
-
17
- exports.getClientStatusHandler = getClientStatusHandler;
18
- //# sourceMappingURL=chunk-3UAWEHMF.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/permitted/getClientStatus.ts"],"names":[],"mappings":";AAWA,IAAM,YAAqD;AAAA,EACzD,aAAa;AACf;AAKO,IAAM,yBAIT;AAAA,EACF,aAAa,CAAC,sBAAsB;AAAA,EACpC,gBAAgB;AAAA,EAChB;AACF;AAsBA,eAAe,8BACb,UACA,UACA,OACA,KACA,EAAE,YAAY,GACC;AACf,WAAS,SAAS,EAAE,QAAQ,YAAY,EAAE;AAC1C,SAAO,IAAI;AACb","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport type { GetClientStatusResult } from '@metamask/snaps-sdk';\nimport type {\n JsonRpcParams,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst hookNames: MethodHooksObject<GetClientStatusHooks> = {\n getIsLocked: true,\n};\n\n/**\n * `snap_getClientStatus` returns useful information about the client running the snap.\n */\nexport const getClientStatusHandler: PermittedHandlerExport<\n GetClientStatusHooks,\n JsonRpcParams,\n GetClientStatusResult\n> = {\n methodNames: ['snap_getClientStatus'],\n implementation: getClientStatusImplementation,\n hookNames,\n};\n\nexport type GetClientStatusHooks = {\n /**\n * @returns Whether the client is locked or not.\n */\n getIsLocked: () => boolean;\n};\n\n/**\n * The `snap_getClientStatus` method implementation.\n * Returns useful information about the client running the snap.\n *\n * @param _request - The JSON-RPC request object. Not used by this function.\n * @param response - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.getIsLocked - A function that returns whether the client is locked or not.\n * @returns Nothing.\n */\nasync function getClientStatusImplementation(\n _request: JsonRpcRequest,\n response: PendingJsonRpcResponse<GetClientStatusResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { getIsLocked }: GetClientStatusHooks,\n): Promise<void> {\n response.result = { locked: getIsLocked() };\n return end();\n}\n"]}
@@ -1,74 +0,0 @@
1
- // src/endowments/cronjob.ts
2
- import { PermissionType, SubjectType } from "@metamask/permission-controller";
3
- import { rpcErrors } from "@metamask/rpc-errors";
4
- import {
5
- SnapCaveatType,
6
- isCronjobSpecificationArray
7
- } from "@metamask/snaps-utils";
8
- import { assert, hasProperty, isPlainObject } from "@metamask/utils";
9
- var permissionName = "endowment:cronjob" /* Cronjob */;
10
- var specificationBuilder = (_builderOptions) => {
11
- return {
12
- permissionType: PermissionType.Endowment,
13
- targetName: permissionName,
14
- allowedCaveats: [SnapCaveatType.SnapCronjob],
15
- endowmentGetter: (_getterOptions) => null,
16
- subjectTypes: [SubjectType.Snap]
17
- };
18
- };
19
- var cronjobEndowmentBuilder = Object.freeze({
20
- targetName: permissionName,
21
- specificationBuilder
22
- });
23
- function getCronjobCaveatMapper(value) {
24
- return {
25
- caveats: [
26
- {
27
- type: SnapCaveatType.SnapCronjob,
28
- value
29
- }
30
- ]
31
- };
32
- }
33
- function getCronjobCaveatJobs(permission) {
34
- if (!permission?.caveats) {
35
- return null;
36
- }
37
- assert(permission.caveats.length === 1);
38
- assert(permission.caveats[0].type === SnapCaveatType.SnapCronjob);
39
- const caveat = permission.caveats[0];
40
- return caveat.value?.jobs ?? null;
41
- }
42
- function validateCronjobCaveat(caveat) {
43
- if (!hasProperty(caveat, "value") || !isPlainObject(caveat.value)) {
44
- throw rpcErrors.invalidParams({
45
- message: "Expected a plain object."
46
- });
47
- }
48
- const { value } = caveat;
49
- if (!hasProperty(value, "jobs") || !isPlainObject(value)) {
50
- throw rpcErrors.invalidParams({
51
- message: "Expected a plain object."
52
- });
53
- }
54
- if (!isCronjobSpecificationArray(value.jobs)) {
55
- throw rpcErrors.invalidParams({
56
- message: "Expected a valid cronjob specification array."
57
- });
58
- }
59
- }
60
- var cronjobCaveatSpecifications = {
61
- [SnapCaveatType.SnapCronjob]: Object.freeze({
62
- type: SnapCaveatType.SnapCronjob,
63
- validator: (caveat) => validateCronjobCaveat(caveat)
64
- })
65
- };
66
-
67
- export {
68
- cronjobEndowmentBuilder,
69
- getCronjobCaveatMapper,
70
- getCronjobCaveatJobs,
71
- validateCronjobCaveat,
72
- cronjobCaveatSpecifications
73
- };
74
- //# sourceMappingURL=chunk-3WCLDJAS.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/endowments/cronjob.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n EndowmentGetterParams,\n ValidPermissionSpecification,\n PermissionConstraint,\n Caveat,\n CaveatSpecificationConstraint,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { CronjobSpecification } from '@metamask/snaps-utils';\nimport {\n SnapCaveatType,\n isCronjobSpecificationArray,\n} from '@metamask/snaps-utils';\nimport type { Json, NonEmptyArray } from '@metamask/utils';\nimport { assert, hasProperty, isPlainObject } from '@metamask/utils';\n\nimport { SnapEndowments } from './enum';\n\nconst permissionName = SnapEndowments.Cronjob;\n\ntype CronjobEndowmentSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.Endowment;\n targetName: typeof permissionName;\n endowmentGetter: (_options?: any) => null;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * `endowment:cronjob` returns nothing; it is intended to be used as a flag to determine whether the snap wants to run cronjobs.\n *\n * @param _builderOptions - Optional specification builder options.\n * @returns The specification for the cronjob endowment.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.Endowment,\n any,\n CronjobEndowmentSpecification\n> = (_builderOptions?: any) => {\n return {\n permissionType: PermissionType.Endowment,\n targetName: permissionName,\n allowedCaveats: [SnapCaveatType.SnapCronjob],\n endowmentGetter: (_getterOptions?: EndowmentGetterParams) => null,\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nexport const cronjobEndowmentBuilder = Object.freeze({\n targetName: permissionName,\n specificationBuilder,\n} as const);\n\n/**\n * Map a raw value from the `initialPermissions` to a caveat specification.\n * Note that this function does not do any validation, that's handled by the\n * PermissionsController when the permission is requested.\n *\n * @param value - The raw value from the `initialPermissions`.\n * @returns The caveat specification.\n */\nexport function getCronjobCaveatMapper(\n value: Json,\n): Pick<PermissionConstraint, 'caveats'> {\n return {\n caveats: [\n {\n type: SnapCaveatType.SnapCronjob,\n value,\n },\n ],\n };\n}\n\n/**\n * Getter function to get the cronjobs from a permission.\n *\n * This does basic validation of the caveat, but does not validate the type or\n * value of the namespaces object itself, as this is handled by the\n * `PermissionsController` when the permission is requested.\n *\n * @param permission - The permission to get the keyring namespaces from.\n * @returns The cronjobs, or `null` if the permission does not have a\n * cronjob caveat.\n */\nexport function getCronjobCaveatJobs(\n permission?: PermissionConstraint,\n): CronjobSpecification[] | null {\n if (!permission?.caveats) {\n return null;\n }\n\n assert(permission.caveats.length === 1);\n assert(permission.caveats[0].type === SnapCaveatType.SnapCronjob);\n\n const caveat = permission.caveats[0] as Caveat<string, { jobs: Json[] }>;\n\n return (caveat.value?.jobs as CronjobSpecification[]) ?? null;\n}\n\n/**\n * Validate the cronjob specification values associated with a caveat.\n * This validates that the value is a non-empty array with valid\n * cronjob expression and request object.\n *\n * @param caveat - The caveat to validate.\n * @throws If the value is invalid.\n */\nexport function validateCronjobCaveat(caveat: Caveat<string, any>) {\n if (!hasProperty(caveat, 'value') || !isPlainObject(caveat.value)) {\n throw rpcErrors.invalidParams({\n message: 'Expected a plain object.',\n });\n }\n\n const { value } = caveat;\n\n if (!hasProperty(value, 'jobs') || !isPlainObject(value)) {\n throw rpcErrors.invalidParams({\n message: 'Expected a plain object.',\n });\n }\n\n if (!isCronjobSpecificationArray(value.jobs)) {\n throw rpcErrors.invalidParams({\n message: 'Expected a valid cronjob specification array.',\n });\n }\n}\n\n/**\n * Caveat specification for the Cronjob.\n */\nexport const cronjobCaveatSpecifications: Record<\n SnapCaveatType.SnapCronjob,\n CaveatSpecificationConstraint\n> = {\n [SnapCaveatType.SnapCronjob]: Object.freeze({\n type: SnapCaveatType.SnapCronjob,\n validator: (caveat) => validateCronjobCaveat(caveat),\n }),\n};\n"],"mappings":";AAQA,SAAS,gBAAgB,mBAAmB;AAC5C,SAAS,iBAAiB;AAE1B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,QAAQ,aAAa,qBAAqB;AAInD,IAAM;AAeN,IAAM,uBAIF,CAAC,oBAA0B;AAC7B,SAAO;AAAA,IACL,gBAAgB,eAAe;AAAA,IAC/B,YAAY;AAAA,IACZ,gBAAgB,CAAC,eAAe,WAAW;AAAA,IAC3C,iBAAiB,CAAC,mBAA2C;AAAA,IAC7D,cAAc,CAAC,YAAY,IAAI;AAAA,EACjC;AACF;AAEO,IAAM,0BAA0B,OAAO,OAAO;AAAA,EACnD,YAAY;AAAA,EACZ;AACF,CAAU;AAUH,SAAS,uBACd,OACuC;AACvC,SAAO;AAAA,IACL,SAAS;AAAA,MACP;AAAA,QACE,MAAM,eAAe;AAAA,QACrB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAaO,SAAS,qBACd,YAC+B;AAC/B,MAAI,CAAC,YAAY,SAAS;AACxB,WAAO;AAAA,EACT;AAEA,SAAO,WAAW,QAAQ,WAAW,CAAC;AACtC,SAAO,WAAW,QAAQ,CAAC,EAAE,SAAS,eAAe,WAAW;AAEhE,QAAM,SAAS,WAAW,QAAQ,CAAC;AAEnC,SAAQ,OAAO,OAAO,QAAmC;AAC3D;AAUO,SAAS,sBAAsB,QAA6B;AACjE,MAAI,CAAC,YAAY,QAAQ,OAAO,KAAK,CAAC,cAAc,OAAO,KAAK,GAAG;AACjE,UAAM,UAAU,cAAc;AAAA,MAC5B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,QAAM,EAAE,MAAM,IAAI;AAElB,MAAI,CAAC,YAAY,OAAO,MAAM,KAAK,CAAC,cAAc,KAAK,GAAG;AACxD,UAAM,UAAU,cAAc;AAAA,MAC5B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,MAAI,CAAC,4BAA4B,MAAM,IAAI,GAAG;AAC5C,UAAM,UAAU,cAAc;AAAA,MAC5B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF;AAKO,IAAM,8BAGT;AAAA,EACF,CAAC,eAAe,WAAW,GAAG,OAAO,OAAO;AAAA,IAC1C,MAAM,eAAe;AAAA,IACrB,WAAW,CAAC,WAAW,sBAAsB,MAAM;AAAA,EACrD,CAAC;AACH;","names":[]}
@@ -1,78 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkQMULJEYNjs = require('./chunk-QMULJEYN.js');
4
-
5
- // src/endowments/transaction-insight.ts
6
- var _permissioncontroller = require('@metamask/permission-controller');
7
- var _rpcerrors = require('@metamask/rpc-errors');
8
- var _snapsutils = require('@metamask/snaps-utils');
9
- var _utils = require('@metamask/utils');
10
- var permissionName = "endowment:transaction-insight" /* TransactionInsight */;
11
- var specificationBuilder = (_builderOptions) => {
12
- return {
13
- permissionType: _permissioncontroller.PermissionType.Endowment,
14
- targetName: permissionName,
15
- allowedCaveats: [
16
- _snapsutils.SnapCaveatType.TransactionOrigin,
17
- _snapsutils.SnapCaveatType.MaxRequestTime
18
- ],
19
- endowmentGetter: (_getterOptions) => null,
20
- validator: _chunkQMULJEYNjs.createGenericPermissionValidator.call(void 0, [
21
- { type: _snapsutils.SnapCaveatType.TransactionOrigin, optional: true },
22
- { type: _snapsutils.SnapCaveatType.MaxRequestTime, optional: true }
23
- ]),
24
- subjectTypes: [_permissioncontroller.SubjectType.Snap]
25
- };
26
- };
27
- var transactionInsightEndowmentBuilder = Object.freeze({
28
- targetName: permissionName,
29
- specificationBuilder
30
- });
31
- function validateCaveat(caveat) {
32
- if (!_utils.hasProperty.call(void 0, caveat, "value") || !_utils.isPlainObject.call(void 0, caveat)) {
33
- throw _rpcerrors.rpcErrors.invalidParams({
34
- message: "Expected a plain object."
35
- });
36
- }
37
- const { value } = caveat;
38
- _utils.assert.call(void 0,
39
- typeof value === "boolean",
40
- 'Expected caveat value to have type "boolean"'
41
- );
42
- }
43
- function getTransactionInsightCaveatMapper(value) {
44
- if (!value || !_utils.isObject.call(void 0, value) || _utils.isObject.call(void 0, value) && Object.keys(value).length === 0) {
45
- return { caveats: null };
46
- }
47
- return {
48
- caveats: [
49
- {
50
- type: _snapsutils.SnapCaveatType.TransactionOrigin,
51
- value: _utils.hasProperty.call(void 0, value, "allowTransactionOrigin") && value.allowTransactionOrigin
52
- }
53
- ]
54
- };
55
- }
56
- function getTransactionOriginCaveat(permission) {
57
- if (!permission?.caveats) {
58
- return null;
59
- }
60
- _utils.assert.call(void 0, permission.caveats.length === 1);
61
- _utils.assert.call(void 0, permission.caveats[0].type === _snapsutils.SnapCaveatType.TransactionOrigin);
62
- const caveat = permission.caveats[0];
63
- return caveat.value ?? null;
64
- }
65
- var transactionInsightCaveatSpecifications = {
66
- [_snapsutils.SnapCaveatType.TransactionOrigin]: Object.freeze({
67
- type: _snapsutils.SnapCaveatType.TransactionOrigin,
68
- validator: (caveat) => validateCaveat(caveat)
69
- })
70
- };
71
-
72
-
73
-
74
-
75
-
76
-
77
- exports.transactionInsightEndowmentBuilder = transactionInsightEndowmentBuilder; exports.getTransactionInsightCaveatMapper = getTransactionInsightCaveatMapper; exports.getTransactionOriginCaveat = getTransactionOriginCaveat; exports.transactionInsightCaveatSpecifications = transactionInsightCaveatSpecifications;
78
- //# sourceMappingURL=chunk-3WKIKYUH.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/endowments/transaction-insight.ts"],"names":[],"mappings":";;;;;AASA,SAAS,gBAAgB,mBAAmB;AAC5C,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAE/B,SAAS,QAAQ,aAAa,UAAU,qBAAqB;AAK7D,IAAM;AAiBN,IAAM,uBAIF,CAAC,oBAA8B;AACjC,SAAO;AAAA,IACL,gBAAgB,eAAe;AAAA,IAC/B,YAAY;AAAA,IACZ,gBAAgB;AAAA,MACd,eAAe;AAAA,MACf,eAAe;AAAA,IACjB;AAAA,IACA,iBAAiB,CAAC,mBAA2C;AAAA,IAC7D,WAAW,iCAAiC;AAAA,MAC1C,EAAE,MAAM,eAAe,mBAAmB,UAAU,KAAK;AAAA,MACzD,EAAE,MAAM,eAAe,gBAAgB,UAAU,KAAK;AAAA,IACxD,CAAC;AAAA,IACD,cAAc,CAAC,YAAY,IAAI;AAAA,EACjC;AACF;AAEO,IAAM,qCAAqC,OAAO,OAAO;AAAA,EAC9D,YAAY;AAAA,EACZ;AACF,CAAU;AAQV,SAAS,eAAe,QAAmC;AACzD,MAAI,CAAC,YAAY,QAAQ,OAAO,KAAK,CAAC,cAAc,MAAM,GAAG;AAC3D,UAAM,UAAU,cAAc;AAAA,MAC5B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,QAAM,EAAE,MAAM,IAAI;AAElB;AAAA,IACE,OAAO,UAAU;AAAA,IACjB;AAAA,EACF;AACF;AAUO,SAAS,kCACd,OACuC;AACvC,MACE,CAAC,SACD,CAAC,SAAS,KAAK,KACd,SAAS,KAAK,KAAK,OAAO,KAAK,KAAK,EAAE,WAAW,GAClD;AACA,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB;AACA,SAAO;AAAA,IACL,SAAS;AAAA,MACP;AAAA,QACE,MAAM,eAAe;AAAA,QACrB,OACE,YAAY,OAAO,wBAAwB,KAC1C,MAAM;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;AAaO,SAAS,2BACd,YACgB;AAChB,MAAI,CAAC,YAAY,SAAS;AACxB,WAAO;AAAA,EACT;AAEA,SAAO,WAAW,QAAQ,WAAW,CAAC;AACtC,SAAO,WAAW,QAAQ,CAAC,EAAE,SAAS,eAAe,iBAAiB;AAEtE,QAAM,SAAS,WAAW,QAAQ,CAAC;AAEnC,SAAO,OAAO,SAAS;AACzB;AAEO,IAAM,yCAGT;AAAA,EACF,CAAC,eAAe,iBAAiB,GAAG,OAAO,OAAO;AAAA,IAChD,MAAM,eAAe;AAAA,IACrB,WAAW,CAAC,WAAgC,eAAe,MAAM;AAAA,EACnE,CAAC;AACH","sourcesContent":["import type {\n PermissionSpecificationBuilder,\n EndowmentGetterParams,\n ValidPermissionSpecification,\n PermissionValidatorConstraint,\n PermissionConstraint,\n CaveatSpecificationConstraint,\n Caveat,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { SnapCaveatType } from '@metamask/snaps-utils';\nimport type { Json, NonEmptyArray } from '@metamask/utils';\nimport { assert, hasProperty, isObject, isPlainObject } from '@metamask/utils';\n\nimport { createGenericPermissionValidator } from './caveats';\nimport { SnapEndowments } from './enum';\n\nconst permissionName = SnapEndowments.TransactionInsight;\n\ntype TransactionInsightEndowmentSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.Endowment;\n targetName: typeof permissionName;\n endowmentGetter: (_options?: EndowmentGetterParams) => null;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\n/**\n * `endowment:transaction-insight` returns nothing; it is intended to be used as a flag\n * by the extension to detect whether the snap has the capability to show information on the transaction confirmation screen.\n *\n * @param _builderOptions - Optional specification builder options.\n * @returns The specification for the transaction-insight endowment.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.Endowment,\n any,\n TransactionInsightEndowmentSpecification\n> = (_builderOptions?: unknown) => {\n return {\n permissionType: PermissionType.Endowment,\n targetName: permissionName,\n allowedCaveats: [\n SnapCaveatType.TransactionOrigin,\n SnapCaveatType.MaxRequestTime,\n ],\n endowmentGetter: (_getterOptions?: EndowmentGetterParams) => null,\n validator: createGenericPermissionValidator([\n { type: SnapCaveatType.TransactionOrigin, optional: true },\n { type: SnapCaveatType.MaxRequestTime, optional: true },\n ]),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nexport const transactionInsightEndowmentBuilder = Object.freeze({\n targetName: permissionName,\n specificationBuilder,\n} as const);\n\n/**\n * Validates the type of the caveat value.\n *\n * @param caveat - The caveat to validate.\n * @throws If the caveat value is invalid.\n */\nfunction validateCaveat(caveat: Caveat<string, any>): void {\n if (!hasProperty(caveat, 'value') || !isPlainObject(caveat)) {\n throw rpcErrors.invalidParams({\n message: 'Expected a plain object.',\n });\n }\n\n const { value } = caveat;\n\n assert(\n typeof value === 'boolean',\n 'Expected caveat value to have type \"boolean\"',\n );\n}\n\n/**\n * Map a raw value from the `initialPermissions` to a caveat specification.\n * Note that this function does not do any validation, that's handled by the\n * PermissionsController when the permission is requested.\n *\n * @param value - The raw value from the `initialPermissions`.\n * @returns The caveat specification.\n */\nexport function getTransactionInsightCaveatMapper(\n value: Json,\n): Pick<PermissionConstraint, 'caveats'> {\n if (\n !value ||\n !isObject(value) ||\n (isObject(value) && Object.keys(value).length === 0)\n ) {\n return { caveats: null };\n }\n return {\n caveats: [\n {\n type: SnapCaveatType.TransactionOrigin,\n value:\n hasProperty(value, 'allowTransactionOrigin') &&\n (value.allowTransactionOrigin as boolean),\n },\n ],\n };\n}\n\n/**\n * Getter function to get the transaction origin caveat from a permission.\n *\n * This does basic validation of the caveat, but does not validate the type or\n * value of the namespaces object itself, as this is handled by the\n * `PermissionsController` when the permission is requested.\n *\n * @param permission - The permission to get the transaction origin caveat from.\n * @returns The transaction origin, or `null` if the permission does not have a\n * transaction origin caveat.\n */\nexport function getTransactionOriginCaveat(\n permission?: PermissionConstraint,\n): boolean | null {\n if (!permission?.caveats) {\n return null;\n }\n\n assert(permission.caveats.length === 1);\n assert(permission.caveats[0].type === SnapCaveatType.TransactionOrigin);\n\n const caveat = permission.caveats[0] as Caveat<string, boolean>;\n\n return caveat.value ?? null;\n}\n\nexport const transactionInsightCaveatSpecifications: Record<\n SnapCaveatType.TransactionOrigin,\n CaveatSpecificationConstraint\n> = {\n [SnapCaveatType.TransactionOrigin]: Object.freeze({\n type: SnapCaveatType.TransactionOrigin,\n validator: (caveat: Caveat<string, any>) => validateCaveat(caveat),\n }),\n};\n"]}
@@ -1,23 +0,0 @@
1
- // src/endowments/network-access.ts
2
- import { PermissionType, SubjectType } from "@metamask/permission-controller";
3
- var permissionName = "endowment:network-access" /* NetworkAccess */;
4
- var specificationBuilder = (_builderOptions) => {
5
- return {
6
- permissionType: PermissionType.Endowment,
7
- targetName: permissionName,
8
- allowedCaveats: null,
9
- endowmentGetter: (_getterOptions) => {
10
- return ["fetch", "Request", "Headers", "Response"];
11
- },
12
- subjectTypes: [SubjectType.Snap]
13
- };
14
- };
15
- var networkAccessEndowmentBuilder = Object.freeze({
16
- targetName: permissionName,
17
- specificationBuilder
18
- });
19
-
20
- export {
21
- networkAccessEndowmentBuilder
22
- };
23
- //# sourceMappingURL=chunk-4D2B2UQ6.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/endowments/network-access.ts"],"sourcesContent":["import type {\n EndowmentGetterParams,\n PermissionSpecificationBuilder,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\n\nimport { SnapEndowments } from './enum';\n\nconst permissionName = SnapEndowments.NetworkAccess;\n\ntype NetworkAccessEndowmentSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.Endowment;\n targetName: typeof permissionName;\n endowmentGetter: (\n _options?: any,\n ) => ['fetch', 'Request', 'Headers', 'Response'];\n allowedCaveats: null;\n}>;\n\n/**\n * `endowment:network-access` returns the name of global browser API(s) that\n * enable network access. This is intended to populate the endowments of the\n * SES Compartment in which a Snap executes.\n *\n * @param _builderOptions - Optional specification builder options.\n * @returns The specification for the network endowment.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.Endowment,\n any,\n NetworkAccessEndowmentSpecification\n> = (_builderOptions?: any) => {\n return {\n permissionType: PermissionType.Endowment,\n targetName: permissionName,\n allowedCaveats: null,\n endowmentGetter: (_getterOptions?: EndowmentGetterParams) => {\n return ['fetch', 'Request', 'Headers', 'Response'];\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nexport const networkAccessEndowmentBuilder = Object.freeze({\n targetName: permissionName,\n specificationBuilder,\n} as const);\n"],"mappings":";AAKA,SAAS,gBAAgB,mBAAmB;AAI5C,IAAM;AAmBN,IAAM,uBAIF,CAAC,oBAA0B;AAC7B,SAAO;AAAA,IACL,gBAAgB,eAAe;AAAA,IAC/B,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,iBAAiB,CAAC,mBAA2C;AAC3D,aAAO,CAAC,SAAS,WAAW,WAAW,UAAU;AAAA,IACnD;AAAA,IACA,cAAc,CAAC,YAAY,IAAI;AAAA,EACjC;AACF;AAEO,IAAM,gCAAgC,OAAO,OAAO;AAAA,EACzD,YAAY;AAAA,EACZ;AACF,CAAU;","names":[]}
@@ -1,23 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/permitted/getAllSnaps.ts
2
- var _rpcerrors = require('@metamask/rpc-errors');
3
- var hookNames = {
4
- getAllSnaps: true
5
- };
6
- var getAllSnapsHandler = {
7
- methodNames: ["wallet_getAllSnaps"],
8
- implementation: getAllSnapsImplementation,
9
- hookNames
10
- };
11
- async function getAllSnapsImplementation(request, response, _next, end, { getAllSnaps }) {
12
- const { origin } = request;
13
- if (origin !== "https://snaps.metamask.io") {
14
- return end(_rpcerrors.rpcErrors.methodNotFound());
15
- }
16
- response.result = await getAllSnaps();
17
- return end();
18
- }
19
-
20
-
21
-
22
- exports.getAllSnapsHandler = getAllSnapsHandler;
23
- //# sourceMappingURL=chunk-4LSOS7SM.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/permitted/getAllSnaps.ts"],"names":[],"mappings":";AAEA,SAAS,iBAAiB;AAU1B,IAAM,YAAiD;AAAA,EACrD,aAAa;AACf;AAMO,IAAM,qBAIT;AAAA,EACF,aAAa,CAAC,oBAAoB;AAAA,EAClC,gBAAgB;AAAA,EAChB;AACF;AAsBA,eAAe,0BACb,SACA,UACA,OACA,KACA,EAAE,YAAY,GACC;AAEf,QAAM,EAAE,OAAO,IAAI;AAEnB,MAAI,WAAW,6BAA6B;AAC1C,WAAO,IAAI,UAAU,eAAe,CAAC;AAAA,EACvC;AAEA,WAAS,SAAS,MAAM,YAAY;AACpC,SAAO,IAAI;AACb","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { GetSnapsResult } from '@metamask/snaps-sdk';\nimport type {\n JsonRpcParams,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst hookNames: MethodHooksObject<GetAllSnapsHooks> = {\n getAllSnaps: true,\n};\n\n/**\n * `wallet_getAllSnaps` gets all installed Snaps. Currently, this can only be\n * called from `https://snaps.metamask.io`.\n */\nexport const getAllSnapsHandler: PermittedHandlerExport<\n GetAllSnapsHooks,\n JsonRpcParams,\n GetSnapsResult\n> = {\n methodNames: ['wallet_getAllSnaps'],\n implementation: getAllSnapsImplementation,\n hookNames,\n};\n\nexport type GetAllSnapsHooks = {\n /**\n * @returns All installed Snaps.\n */\n getAllSnaps: () => Promise<GetSnapsResult>;\n};\n\n/**\n * The `wallet_getAllSnaps` method implementation.\n * Fetches all installed snaps and adds them to the JSON-RPC response.\n *\n * @param request - The JSON-RPC request object.\n * @param response - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.getAllSnaps - A function that returns all installed snaps.\n * @returns Nothing.\n */\nasync function getAllSnapsImplementation(\n request: JsonRpcRequest,\n response: PendingJsonRpcResponse<GetSnapsResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { getAllSnaps }: GetAllSnapsHooks,\n): Promise<void> {\n // The origin is added by the MetaMask middleware stack.\n const { origin } = request as JsonRpcRequest & { origin: string };\n\n if (origin !== 'https://snaps.metamask.io') {\n return end(rpcErrors.methodNotFound());\n }\n\n response.result = await getAllSnaps();\n return end();\n}\n"]}
@@ -1,79 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunk33MTKZ4Hjs = require('./chunk-33MTKZ4H.js');
4
-
5
- // src/restricted/getBip32PublicKey.ts
6
- var _permissioncontroller = require('@metamask/permission-controller');
7
- var _rpcerrors = require('@metamask/rpc-errors');
8
-
9
-
10
-
11
-
12
-
13
- var _snapsutils = require('@metamask/snaps-utils');
14
- var _superstruct = require('@metamask/superstruct');
15
- var _utils = require('@metamask/utils');
16
- var targetName = "snap_getBip32PublicKey";
17
- var Bip32PublicKeyArgsStruct = _snapsutils.bip32entropy.call(void 0,
18
- _superstruct.object.call(void 0, {
19
- path: _snapsutils.Bip32PathStruct,
20
- curve: _snapsutils.CurveStruct,
21
- compressed: _superstruct.optional.call(void 0, _superstruct.boolean.call(void 0, ))
22
- })
23
- );
24
- var specificationBuilder = ({ methodHooks: methodHooks2 }) => {
25
- return {
26
- permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
27
- targetName,
28
- allowedCaveats: [_snapsutils.SnapCaveatType.PermittedDerivationPaths],
29
- methodImplementation: getBip32PublicKeyImplementation(methodHooks2),
30
- validator: ({ caveats }) => {
31
- if (caveats?.length !== 1 || caveats[0].type !== _snapsutils.SnapCaveatType.PermittedDerivationPaths) {
32
- throw _rpcerrors.rpcErrors.invalidParams({
33
- message: `Expected a single "${_snapsutils.SnapCaveatType.PermittedDerivationPaths}" caveat.`
34
- });
35
- }
36
- },
37
- subjectTypes: [_permissioncontroller.SubjectType.Snap]
38
- };
39
- };
40
- var methodHooks = {
41
- getMnemonic: true,
42
- getUnlockPromise: true
43
- };
44
- var getBip32PublicKeyBuilder = Object.freeze({
45
- targetName,
46
- specificationBuilder,
47
- methodHooks
48
- });
49
- function getBip32PublicKeyImplementation({
50
- getMnemonic,
51
- getUnlockPromise
52
- }) {
53
- return async function getBip32PublicKey(args) {
54
- await getUnlockPromise(true);
55
- _utils.assertStruct.call(void 0,
56
- args.params,
57
- Bip32PublicKeyArgsStruct,
58
- "Invalid BIP-32 public key params",
59
- _rpcerrors.rpcErrors.invalidParams
60
- );
61
- const { params } = args;
62
- const node = await _chunk33MTKZ4Hjs.getNode.call(void 0, {
63
- curve: params.curve,
64
- path: params.path,
65
- secretRecoveryPhrase: await getMnemonic()
66
- });
67
- if (params.compressed) {
68
- return node.compressedPublicKey;
69
- }
70
- return node.publicKey;
71
- };
72
- }
73
-
74
-
75
-
76
-
77
-
78
- exports.Bip32PublicKeyArgsStruct = Bip32PublicKeyArgsStruct; exports.getBip32PublicKeyBuilder = getBip32PublicKeyBuilder; exports.getBip32PublicKeyImplementation = getBip32PublicKeyImplementation;
79
- //# sourceMappingURL=chunk-4PWFZPJC.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/restricted/getBip32PublicKey.ts"],"names":["methodHooks"],"mappings":";;;;;AAMA,SAAS,gBAAgB,mBAAmB;AAC5C,SAAS,iBAAiB;AAK1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS,QAAQ,gBAAgB;AAE1C,SAAS,oBAAoB;AAK7B,IAAM,aAAa;AA4BZ,IAAM,2BAA2B;AAAA,EACtC,OAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY,SAAS,QAAQ,CAAC;AAAA,EAChC,CAAC;AACH;AAWA,IAAM,uBAIF,CAAC,EAAE,aAAAA,aAAY,MAAoD;AACrE,SAAO;AAAA,IACL,gBAAgB,eAAe;AAAA,IAC/B;AAAA,IACA,gBAAgB,CAAC,eAAe,wBAAwB;AAAA,IACxD,sBAAsB,gCAAgCA,YAAW;AAAA,IACjE,WAAW,CAAC,EAAE,QAAQ,MAAM;AAC1B,UACE,SAAS,WAAW,KACpB,QAAQ,CAAC,EAAE,SAAS,eAAe,0BACnC;AACA,cAAM,UAAU,cAAc;AAAA,UAC5B,SAAS,sBAAsB,eAAe,wBAAwB;AAAA,QACxE,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA,cAAc,CAAC,YAAY,IAAI;AAAA,EACjC;AACF;AAEA,IAAM,cAA+D;AAAA,EACnE,aAAa;AAAA,EACb,kBAAkB;AACpB;AAEO,IAAM,2BAA2B,OAAO,OAAO;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF,CAAU;AAYH,SAAS,gCAAgC;AAAA,EAC9C;AAAA,EACA;AACF,GAAiC;AAC/B,SAAO,eAAe,kBACpB,MACkC;AAClC,UAAM,iBAAiB,IAAI;AAE3B;AAAA,MACE,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA,UAAU;AAAA,IACZ;AAEA,UAAM,EAAE,OAAO,IAAI;AACnB,UAAM,OAAO,MAAM,QAAQ;AAAA,MACzB,OAAO,OAAO;AAAA,MACd,MAAM,OAAO;AAAA,MACb,sBAAsB,MAAM,YAAY;AAAA,IAC1C,CAAC;AAED,QAAI,OAAO,YAAY;AACrB,aAAO,KAAK;AAAA,IACd;AAEA,WAAO,KAAK;AAAA,EACd;AACF","sourcesContent":["import type {\n PermissionSpecificationBuilder,\n PermissionValidatorConstraint,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetBip32PublicKeyParams,\n GetBip32PublicKeyResult,\n} from '@metamask/snaps-sdk';\nimport {\n bip32entropy,\n Bip32PathStruct,\n CurveStruct,\n SnapCaveatType,\n} from '@metamask/snaps-utils';\nimport { boolean, object, optional } from '@metamask/superstruct';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport { getNode } from '../utils';\n\nconst targetName = 'snap_getBip32PublicKey';\n\nexport type GetBip32PublicKeyMethodHooks = {\n /**\n * @returns The mnemonic of the user's primary keyring.\n */\n getMnemonic: () => Promise<Uint8Array>;\n\n /**\n * Waits for the extension to be unlocked.\n *\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n};\n\ntype GetBip32PublicKeySpecificationBuilderOptions = {\n methodHooks: GetBip32PublicKeyMethodHooks;\n};\n\ntype GetBip32PublicKeySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getBip32PublicKeyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\nexport const Bip32PublicKeyArgsStruct = bip32entropy(\n object({\n path: Bip32PathStruct,\n curve: CurveStruct,\n compressed: optional(boolean()),\n }),\n);\n\n/**\n * The specification builder for the `snap_getBip32PublicKey` permission.\n * `snap_getBip32PublicKey` lets the Snap retrieve public keys for a particular\n * BIP-32 node.\n *\n * @param options - The specification builder options.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getBip32PublicKey` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetBip32PublicKeySpecificationBuilderOptions,\n GetBip32PublicKeySpecification\n> = ({ methodHooks }: GetBip32PublicKeySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats: [SnapCaveatType.PermittedDerivationPaths],\n methodImplementation: getBip32PublicKeyImplementation(methodHooks),\n validator: ({ caveats }) => {\n if (\n caveats?.length !== 1 ||\n caveats[0].type !== SnapCaveatType.PermittedDerivationPaths\n ) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.PermittedDerivationPaths}\" caveat.`,\n });\n }\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetBip32PublicKeyMethodHooks> = {\n getMnemonic: true,\n getUnlockPromise: true,\n};\n\nexport const getBip32PublicKeyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getBip32PublicKey`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user.\n * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked\n * and prompts the user to unlock their MetaMask if it is locked.\n * @returns The method implementation which returns a public key.\n * @throws If the params are invalid.\n */\nexport function getBip32PublicKeyImplementation({\n getMnemonic,\n getUnlockPromise,\n}: GetBip32PublicKeyMethodHooks) {\n return async function getBip32PublicKey(\n args: RestrictedMethodOptions<GetBip32PublicKeyParams>,\n ): Promise<GetBip32PublicKeyResult> {\n await getUnlockPromise(true);\n\n assertStruct(\n args.params,\n Bip32PublicKeyArgsStruct,\n 'Invalid BIP-32 public key params',\n rpcErrors.invalidParams,\n );\n\n const { params } = args;\n const node = await getNode({\n curve: params.curve,\n path: params.path,\n secretRecoveryPhrase: await getMnemonic(),\n });\n\n if (params.compressed) {\n return node.compressedPublicKey;\n }\n\n return node.publicKey;\n };\n}\n"]}
@@ -1,59 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkHZQ34FQTjs = require('./chunk-HZQ34FQT.js');
4
-
5
-
6
- var _chunk6VJVURH5js = require('./chunk-6VJVURH5.js');
7
-
8
-
9
- var _chunk33MTKZ4Hjs = require('./chunk-33MTKZ4H.js');
10
-
11
-
12
-
13
- var _chunkKRSIAVUJjs = require('./chunk-KRSIAVUJ.js');
14
-
15
- // src/permissions.ts
16
- var _utils = require('@metamask/utils');
17
- function processSnapPermissions(initialPermissions) {
18
- return Object.fromEntries(
19
- Object.entries(initialPermissions).map(([initialPermission, value]) => {
20
- if (_utils.hasProperty.call(void 0, _chunk6VJVURH5js.caveatMappers, initialPermission)) {
21
- return [initialPermission, _chunk6VJVURH5js.caveatMappers[initialPermission](value)];
22
- } else if (_utils.hasProperty.call(void 0, _chunkKRSIAVUJjs.endowmentCaveatMappers, initialPermission)) {
23
- return [
24
- initialPermission,
25
- _chunkKRSIAVUJjs.endowmentCaveatMappers[initialPermission](value)
26
- ];
27
- }
28
- return [
29
- initialPermission,
30
- value
31
- ];
32
- })
33
- );
34
- }
35
- var buildSnapEndowmentSpecifications = (excludedEndowments) => Object.values(_chunkKRSIAVUJjs.endowmentPermissionBuilders).reduce((allSpecifications, { targetName, specificationBuilder }) => {
36
- if (!excludedEndowments.includes(targetName)) {
37
- allSpecifications[targetName] = specificationBuilder({});
38
- }
39
- return allSpecifications;
40
- }, {});
41
- var buildSnapRestrictedMethodSpecifications = (excludedPermissions, hooks) => Object.values(_chunkHZQ34FQTjs.restrictedMethodPermissionBuilders).reduce((specifications, { targetName, specificationBuilder, methodHooks }) => {
42
- if (!excludedPermissions.includes(targetName)) {
43
- specifications[targetName] = specificationBuilder({
44
- // @ts-expect-error The selectHooks type is wonky
45
- methodHooks: _chunk33MTKZ4Hjs.selectHooks.call(void 0,
46
- hooks,
47
- methodHooks
48
- )
49
- });
50
- }
51
- return specifications;
52
- }, {});
53
-
54
-
55
-
56
-
57
-
58
- exports.processSnapPermissions = processSnapPermissions; exports.buildSnapEndowmentSpecifications = buildSnapEndowmentSpecifications; exports.buildSnapRestrictedMethodSpecifications = buildSnapRestrictedMethodSpecifications;
59
- //# sourceMappingURL=chunk-4TUORIA6.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/permissions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,SAAS,mBAAmB;AAuBrB,SAAS,uBACd,oBACuD;AACvD,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,kBAAkB,EAAE,IAAI,CAAC,CAAC,mBAAmB,KAAK,MAAM;AACrE,UAAI,YAAY,eAAe,iBAAiB,GAAG;AACjD,eAAO,CAAC,mBAAmB,cAAc,iBAAiB,EAAE,KAAK,CAAC;AAAA,MACpE,WAAW,YAAY,wBAAwB,iBAAiB,GAAG;AACjE,eAAO;AAAA,UACL;AAAA,UACA,uBAAuB,iBAAiB,EAAE,KAAK;AAAA,QACjD;AAAA,MACF;AAGA,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,IAAM,mCAAmC,CAC9C,uBAEA,OAAO,OAAO,2BAA2B,EAAE,OAEzC,CAAC,mBAAmB,EAAE,YAAY,qBAAqB,MAAM;AAC7D,MAAI,CAAC,mBAAmB,SAAS,UAAU,GAAG;AAC5C,sBAAkB,UAAU,IAAI,qBAAqB,CAAC,CAAC;AAAA,EACzD;AACA,SAAO;AACT,GAAG,CAAC,CAAC;AAEA,IAAM,0CAA0C,CACrD,qBACA,UAEA,OAAO,OAAO,kCAAkC,EAAE,OAEhD,CAAC,gBAAgB,EAAE,YAAY,sBAAsB,YAAY,MAAM;AACvE,MAAI,CAAC,oBAAoB,SAAS,UAAU,GAAG;AAC7C,mBAAe,UAAU,IAAI,qBAAqB;AAAA;AAAA,MAEhD,aAAa;AAAA,QACX;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT,GAAG,CAAC,CAAC","sourcesContent":["import type {\n PermissionConstraint,\n PermissionSpecificationConstraint,\n} from '@metamask/permission-controller';\nimport type { SnapPermissions } from '@metamask/snaps-utils';\nimport { hasProperty } from '@metamask/utils';\n\nimport {\n endowmentCaveatMappers,\n endowmentPermissionBuilders,\n} from './endowments';\nimport {\n caveatMappers,\n restrictedMethodPermissionBuilders,\n} from './restricted';\nimport { selectHooks } from './utils';\n\n/**\n * Map initial permissions as defined in a Snap manifest to something that can\n * be processed by the PermissionsController. Each caveat mapping function\n * should return a valid permission caveat value.\n *\n * This function does not validate the caveat values, since that is done by\n * the PermissionsController itself, upon requesting the permissions.\n *\n * @param initialPermissions - The initial permissions to process.\n * @returns The processed permissions.\n */\nexport function processSnapPermissions(\n initialPermissions: SnapPermissions,\n): Record<string, Pick<PermissionConstraint, 'caveats'>> {\n return Object.fromEntries(\n Object.entries(initialPermissions).map(([initialPermission, value]) => {\n if (hasProperty(caveatMappers, initialPermission)) {\n return [initialPermission, caveatMappers[initialPermission](value)];\n } else if (hasProperty(endowmentCaveatMappers, initialPermission)) {\n return [\n initialPermission,\n endowmentCaveatMappers[initialPermission](value),\n ];\n }\n\n // If we have no mapping, this may be a non-snap permission, return as-is\n return [\n initialPermission,\n value as Pick<PermissionConstraint, 'caveats'>,\n ];\n }),\n );\n}\n\nexport const buildSnapEndowmentSpecifications = (\n excludedEndowments: string[],\n) =>\n Object.values(endowmentPermissionBuilders).reduce<\n Record<string, PermissionSpecificationConstraint>\n >((allSpecifications, { targetName, specificationBuilder }) => {\n if (!excludedEndowments.includes(targetName)) {\n allSpecifications[targetName] = specificationBuilder({});\n }\n return allSpecifications;\n }, {});\n\nexport const buildSnapRestrictedMethodSpecifications = (\n excludedPermissions: string[],\n hooks: Record<string, unknown>,\n) =>\n Object.values(restrictedMethodPermissionBuilders).reduce<\n Record<string, PermissionSpecificationConstraint>\n >((specifications, { targetName, specificationBuilder, methodHooks }) => {\n if (!excludedPermissions.includes(targetName)) {\n specifications[targetName] = specificationBuilder({\n // @ts-expect-error The selectHooks type is wonky\n methodHooks: selectHooks<typeof hooks, keyof typeof methodHooks>(\n hooks,\n methodHooks,\n ) as Pick<typeof hooks, keyof typeof methodHooks>,\n });\n }\n return specifications;\n }, {});\n"]}