@metamask/snaps-rpc-methods 11.0.0 → 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 (704) hide show
  1. package/CHANGELOG.md +14 -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} +3 -2
  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} +7 -6
  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 -122
  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 -43
  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} +48 -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} +4 -3
  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} +4 -3
  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} +4 -3
  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} +4 -3
  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} +4 -3
  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} +4 -3
  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} +5 -4
  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} +4 -3
  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} +6 -5
  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} +48 -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} +6 -5
  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} +7 -6
  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} +6 -5
  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} +7 -6
  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} +6 -5
  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/{types/restricted/getPreferences.d.ts → restricted/getPreferences.d.cts} +6 -5
  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 +39 -9
  361. package/dist/restricted/getPreferences.mjs.map +1 -1
  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} +17 -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 -35
  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} +8 -6
  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} +6 -5
  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} +6 -5
  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} +7 -6
  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} +6 -4
  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-57BL7O2P.mjs +0 -69
  437. package/dist/chunk-57BL7O2P.mjs.map +0 -1
  438. package/dist/chunk-62URQ5VS.mjs +0 -18
  439. package/dist/chunk-62URQ5VS.mjs.map +0 -1
  440. package/dist/chunk-6XKVFSC2.js +0 -32
  441. package/dist/chunk-6XKVFSC2.js.map +0 -1
  442. package/dist/chunk-756OQVOC.js +0 -67
  443. package/dist/chunk-756OQVOC.js.map +0 -1
  444. package/dist/chunk-7CV677MM.js +0 -42
  445. package/dist/chunk-7CV677MM.js.map +0 -1
  446. package/dist/chunk-7HVABE5R.js +0 -74
  447. package/dist/chunk-7HVABE5R.js.map +0 -1
  448. package/dist/chunk-7P6TF6CE.mjs +0 -55
  449. package/dist/chunk-7P6TF6CE.mjs.map +0 -1
  450. package/dist/chunk-7TVJV425.js +0 -1
  451. package/dist/chunk-7TVJV425.js.map +0 -1
  452. package/dist/chunk-A6H6I4VH.js +0 -61
  453. package/dist/chunk-A6H6I4VH.js.map +0 -1
  454. package/dist/chunk-AMMJ744B.mjs +0 -32
  455. package/dist/chunk-AMMJ744B.mjs.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-CD4OUHO5.mjs +0 -20
  461. package/dist/chunk-CD4OUHO5.mjs.map +0 -1
  462. package/dist/chunk-CDAVFOUS.js +0 -53
  463. package/dist/chunk-CDAVFOUS.js.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-FM4LNQR7.mjs +0 -34
  482. package/dist/chunk-FM4LNQR7.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-GEJDXRTL.mjs +0 -59
  486. package/dist/chunk-GEJDXRTL.mjs.map +0 -1
  487. package/dist/chunk-GPV4ETUH.mjs +0 -47
  488. package/dist/chunk-GPV4ETUH.mjs.map +0 -1
  489. package/dist/chunk-H6X3CWWQ.js +0 -54
  490. package/dist/chunk-H6X3CWWQ.js.map +0 -1
  491. package/dist/chunk-HOECEYMT.mjs +0 -70
  492. package/dist/chunk-HOECEYMT.mjs.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-JWDQUKKU.mjs +0 -80
  500. package/dist/chunk-JWDQUKKU.mjs.map +0 -1
  501. package/dist/chunk-K3UL5RVN.mjs +0 -43
  502. package/dist/chunk-K3UL5RVN.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-LP3RWEDJ.js +0 -43
  508. package/dist/chunk-LP3RWEDJ.js.map +0 -1
  509. package/dist/chunk-LR7UR4YU.mjs +0 -52
  510. package/dist/chunk-LR7UR4YU.mjs.map +0 -1
  511. package/dist/chunk-LXJBBRQ4.mjs +0 -57
  512. package/dist/chunk-LXJBBRQ4.mjs.map +0 -1
  513. package/dist/chunk-M2JQCKR7.js +0 -143
  514. package/dist/chunk-M2JQCKR7.js.map +0 -1
  515. package/dist/chunk-MC2Z4NF6.mjs +0 -45
  516. package/dist/chunk-MC2Z4NF6.mjs.map +0 -1
  517. package/dist/chunk-MXPVC2XP.mjs +0 -105
  518. package/dist/chunk-MXPVC2XP.mjs.map +0 -1
  519. package/dist/chunk-NU4NAAFG.js +0 -1
  520. package/dist/chunk-NU4NAAFG.js.map +0 -1
  521. package/dist/chunk-NWT2EXFD.js +0 -18
  522. package/dist/chunk-NWT2EXFD.js.map +0 -1
  523. package/dist/chunk-O66NZFSD.mjs +0 -23
  524. package/dist/chunk-O66NZFSD.mjs.map +0 -1
  525. package/dist/chunk-ODN35VOK.mjs +0 -119
  526. package/dist/chunk-ODN35VOK.mjs.map +0 -1
  527. package/dist/chunk-OI33OL7K.js +0 -47
  528. package/dist/chunk-OI33OL7K.js.map +0 -1
  529. package/dist/chunk-PIAWDTWO.mjs +0 -68
  530. package/dist/chunk-PIAWDTWO.mjs.map +0 -1
  531. package/dist/chunk-PIRQCNBJ.mjs +0 -78
  532. package/dist/chunk-PIRQCNBJ.mjs.map +0 -1
  533. package/dist/chunk-PK2RPAXI.js +0 -59
  534. package/dist/chunk-PK2RPAXI.js.map +0 -1
  535. package/dist/chunk-PS6OEQXL.js +0 -105
  536. package/dist/chunk-PS6OEQXL.js.map +0 -1
  537. package/dist/chunk-PXU6PORA.js +0 -119
  538. package/dist/chunk-PXU6PORA.js.map +0 -1
  539. package/dist/chunk-Q27K2I6Z.js +0 -23
  540. package/dist/chunk-Q27K2I6Z.js.map +0 -1
  541. package/dist/chunk-QDZAWH6F.js +0 -80
  542. package/dist/chunk-QDZAWH6F.js.map +0 -1
  543. package/dist/chunk-QMULJEYN.js +0 -35
  544. package/dist/chunk-QMULJEYN.js.map +0 -1
  545. package/dist/chunk-RHPSYX7X.js +0 -34
  546. package/dist/chunk-RHPSYX7X.js.map +0 -1
  547. package/dist/chunk-T56DKVFS.js +0 -70
  548. package/dist/chunk-T56DKVFS.js.map +0 -1
  549. package/dist/chunk-TAXLFFV4.mjs +0 -115
  550. package/dist/chunk-TAXLFFV4.mjs.map +0 -1
  551. package/dist/chunk-TE4W25CA.mjs +0 -143
  552. package/dist/chunk-TE4W25CA.mjs.map +0 -1
  553. package/dist/chunk-TG63GBK3.mjs +0 -1
  554. package/dist/chunk-TG63GBK3.mjs.map +0 -1
  555. package/dist/chunk-TNENASGX.mjs +0 -1
  556. package/dist/chunk-TNENASGX.mjs.map +0 -1
  557. package/dist/chunk-TQCUJQHY.mjs +0 -196
  558. package/dist/chunk-TQCUJQHY.mjs.map +0 -1
  559. package/dist/chunk-TT4DP2YW.mjs +0 -35
  560. package/dist/chunk-TT4DP2YW.mjs.map +0 -1
  561. package/dist/chunk-TVC3E5LI.mjs +0 -42
  562. package/dist/chunk-TVC3E5LI.mjs.map +0 -1
  563. package/dist/chunk-U6TJQLNV.js +0 -45
  564. package/dist/chunk-U6TJQLNV.js.map +0 -1
  565. package/dist/chunk-UB3733UY.mjs +0 -23
  566. package/dist/chunk-UB3733UY.mjs.map +0 -1
  567. package/dist/chunk-UCWANXBZ.js +0 -45
  568. package/dist/chunk-UCWANXBZ.js.map +0 -1
  569. package/dist/chunk-UF3UJTY3.js +0 -55
  570. package/dist/chunk-UF3UJTY3.js.map +0 -1
  571. package/dist/chunk-UY4DUF53.mjs +0 -45
  572. package/dist/chunk-UY4DUF53.mjs.map +0 -1
  573. package/dist/chunk-V3KRSCUK.mjs +0 -53
  574. package/dist/chunk-V3KRSCUK.mjs.map +0 -1
  575. package/dist/chunk-VUA6ICJO.js +0 -52
  576. package/dist/chunk-VUA6ICJO.js.map +0 -1
  577. package/dist/chunk-VVBTXSID.mjs +0 -82
  578. package/dist/chunk-VVBTXSID.mjs.map +0 -1
  579. package/dist/chunk-VYII7C3J.mjs +0 -79
  580. package/dist/chunk-VYII7C3J.mjs.map +0 -1
  581. package/dist/chunk-W33UWNA2.mjs +0 -90
  582. package/dist/chunk-W33UWNA2.mjs.map +0 -1
  583. package/dist/chunk-XGMYBPQR.mjs +0 -47
  584. package/dist/chunk-XGMYBPQR.mjs.map +0 -1
  585. package/dist/chunk-YGKFOOWI.js +0 -20
  586. package/dist/chunk-YGKFOOWI.js.map +0 -1
  587. package/dist/chunk-YOHE52XB.js +0 -23
  588. package/dist/chunk-YOHE52XB.js.map +0 -1
  589. package/dist/chunk-YT2Q3W5C.js +0 -69
  590. package/dist/chunk-YT2Q3W5C.js.map +0 -1
  591. package/dist/chunk-YZMFLB67.js +0 -75
  592. package/dist/chunk-YZMFLB67.js.map +0 -1
  593. package/dist/chunk-Z6YFGWHN.mjs +0 -61
  594. package/dist/chunk-Z6YFGWHN.mjs.map +0 -1
  595. package/dist/chunk-ZH3FC55E.mjs +0 -21
  596. package/dist/chunk-ZH3FC55E.mjs.map +0 -1
  597. package/dist/chunk-ZKISN6YP.js +0 -67
  598. package/dist/chunk-ZKISN6YP.js.map +0 -1
  599. package/dist/chunk-ZXDCQWMJ.mjs +0 -39
  600. package/dist/chunk-ZXDCQWMJ.mjs.map +0 -1
  601. package/dist/endowments/caveats/generic.js +0 -7
  602. package/dist/endowments/caveats/generic.js.map +0 -1
  603. package/dist/endowments/caveats/index.js +0 -18
  604. package/dist/endowments/caveats/index.js.map +0 -1
  605. package/dist/endowments/caveats/requestTime.js +0 -13
  606. package/dist/endowments/caveats/requestTime.js.map +0 -1
  607. package/dist/endowments/cronjob.js +0 -16
  608. package/dist/endowments/cronjob.js.map +0 -1
  609. package/dist/endowments/enum.js +0 -7
  610. package/dist/endowments/enum.js.map +0 -1
  611. package/dist/endowments/ethereum-provider.js +0 -8
  612. package/dist/endowments/ethereum-provider.js.map +0 -1
  613. package/dist/endowments/home-page.js +0 -8
  614. package/dist/endowments/home-page.js.map +0 -1
  615. package/dist/endowments/index.js +0 -54
  616. package/dist/endowments/index.js.map +0 -1
  617. package/dist/endowments/keyring.js +0 -17
  618. package/dist/endowments/keyring.js.map +0 -1
  619. package/dist/endowments/lifecycle-hooks.js +0 -8
  620. package/dist/endowments/lifecycle-hooks.js.map +0 -1
  621. package/dist/endowments/name-lookup.js +0 -19
  622. package/dist/endowments/name-lookup.js.map +0 -1
  623. package/dist/endowments/network-access.js +0 -8
  624. package/dist/endowments/network-access.js.map +0 -1
  625. package/dist/endowments/rpc.js +0 -17
  626. package/dist/endowments/rpc.js.map +0 -1
  627. package/dist/endowments/signature-insight.js +0 -17
  628. package/dist/endowments/signature-insight.js.map +0 -1
  629. package/dist/endowments/transaction-insight.js +0 -17
  630. package/dist/endowments/transaction-insight.js.map +0 -1
  631. package/dist/endowments/web-assembly.js +0 -8
  632. package/dist/endowments/web-assembly.js.map +0 -1
  633. package/dist/index.js +0 -123
  634. package/dist/index.js.map +0 -1
  635. package/dist/permissions.js +0 -44
  636. package/dist/permissions.js.map +0 -1
  637. package/dist/permitted/createInterface.js +0 -7
  638. package/dist/permitted/createInterface.js.map +0 -1
  639. package/dist/permitted/getAllSnaps.js +0 -7
  640. package/dist/permitted/getAllSnaps.js.map +0 -1
  641. package/dist/permitted/getClientStatus.js +0 -7
  642. package/dist/permitted/getClientStatus.js.map +0 -1
  643. package/dist/permitted/getFile.js +0 -9
  644. package/dist/permitted/getFile.js.map +0 -1
  645. package/dist/permitted/getInterfaceState.js +0 -7
  646. package/dist/permitted/getInterfaceState.js.map +0 -1
  647. package/dist/permitted/getSnaps.js +0 -7
  648. package/dist/permitted/getSnaps.js.map +0 -1
  649. package/dist/permitted/handlers.js +0 -21
  650. package/dist/permitted/handlers.js.map +0 -1
  651. package/dist/permitted/index.js +0 -27
  652. package/dist/permitted/index.js.map +0 -1
  653. package/dist/permitted/invokeKeyring.js +0 -8
  654. package/dist/permitted/invokeKeyring.js.map +0 -1
  655. package/dist/permitted/invokeSnapSugar.js +0 -11
  656. package/dist/permitted/invokeSnapSugar.js.map +0 -1
  657. package/dist/permitted/middleware.js +0 -21
  658. package/dist/permitted/middleware.js.map +0 -1
  659. package/dist/permitted/requestSnaps.js +0 -12
  660. package/dist/permitted/requestSnaps.js.map +0 -1
  661. package/dist/permitted/resolveInterface.js +0 -7
  662. package/dist/permitted/resolveInterface.js.map +0 -1
  663. package/dist/permitted/updateInterface.js +0 -7
  664. package/dist/permitted/updateInterface.js.map +0 -1
  665. package/dist/restricted/caveats/index.js +0 -17
  666. package/dist/restricted/caveats/index.js.map +0 -1
  667. package/dist/restricted/caveats/permittedCoinTypes.js +0 -13
  668. package/dist/restricted/caveats/permittedCoinTypes.js.map +0 -1
  669. package/dist/restricted/caveats/permittedDerivationPaths.js +0 -13
  670. package/dist/restricted/caveats/permittedDerivationPaths.js.map +0 -1
  671. package/dist/restricted/caveats/snapIds.js +0 -11
  672. package/dist/restricted/caveats/snapIds.js.map +0 -1
  673. package/dist/restricted/dialog.js +0 -11
  674. package/dist/restricted/dialog.js.map +0 -1
  675. package/dist/restricted/getBip32Entropy.js +0 -10
  676. package/dist/restricted/getBip32Entropy.js.map +0 -1
  677. package/dist/restricted/getBip32PublicKey.js +0 -12
  678. package/dist/restricted/getBip32PublicKey.js.map +0 -1
  679. package/dist/restricted/getBip44Entropy.js +0 -9
  680. package/dist/restricted/getBip44Entropy.js.map +0 -1
  681. package/dist/restricted/getEntropy.js +0 -10
  682. package/dist/restricted/getEntropy.js.map +0 -1
  683. package/dist/restricted/getLocale.js +0 -11
  684. package/dist/restricted/getLocale.js.map +0 -1
  685. package/dist/restricted/getPreferences.js +0 -11
  686. package/dist/restricted/getPreferences.js.map +0 -1
  687. package/dist/restricted/index.js +0 -37
  688. package/dist/restricted/index.js.map +0 -1
  689. package/dist/restricted/invokeSnap.js +0 -13
  690. package/dist/restricted/invokeSnap.js.map +0 -1
  691. package/dist/restricted/manageAccounts.js +0 -13
  692. package/dist/restricted/manageAccounts.js.map +0 -1
  693. package/dist/restricted/manageState.js +0 -20
  694. package/dist/restricted/manageState.js.map +0 -1
  695. package/dist/restricted/notify.js +0 -13
  696. package/dist/restricted/notify.js.map +0 -1
  697. package/dist/tsconfig.build.tsbuildinfo +0 -1
  698. package/dist/types/__fixtures__/index.d.ts +0 -1
  699. package/dist/types/endowments/caveats/index.d.ts +0 -2
  700. package/dist/types/index.d.ts +0 -7
  701. package/dist/types/permitted/index.d.ts +0 -11
  702. package/dist/types/restricted/dialog.d.ts +0 -1463
  703. package/dist/utils.js +0 -13
  704. package/dist/utils.js.map +0 -1
package/dist/utils.cjs ADDED
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNode = exports.getPathPrefix = exports.deriveEntropy = exports.selectHooks = void 0;
4
+ const key_tree_1 = require("@metamask/key-tree");
5
+ const utils_1 = require("@metamask/utils");
6
+ const sha3_1 = require("@noble/hashes/sha3");
7
+ const HARDENED_VALUE = 0x80000000;
8
+ /**
9
+ * Returns the subset of the specified `hooks` that are included in the
10
+ * `hookNames` object. This is a Principle of Least Authority (POLA) measure
11
+ * to ensure that each RPC method implementation only has access to the
12
+ * API "hooks" it needs to do its job.
13
+ *
14
+ * @param hooks - The hooks to select from.
15
+ * @param hookNames - The names of the hooks to select.
16
+ * @returns The selected hooks.
17
+ * @template Hooks - The hooks to select from.
18
+ * @template HookName - The names of the hooks to select.
19
+ */
20
+ function selectHooks(hooks, hookNames) {
21
+ if (hookNames) {
22
+ return Object.keys(hookNames).reduce((hookSubset, _hookName) => {
23
+ const hookName = _hookName;
24
+ hookSubset[hookName] = hooks[hookName];
25
+ return hookSubset;
26
+ }, {});
27
+ }
28
+ return undefined;
29
+ }
30
+ exports.selectHooks = selectHooks;
31
+ /**
32
+ * Get a BIP-32 derivation path array from a hash, which is compatible with
33
+ * `@metamask/key-tree`. The hash is assumed to be 32 bytes long.
34
+ *
35
+ * @param hash - The hash to derive indices from.
36
+ * @returns The derived indices as a {@link HardenedBIP32Node} array.
37
+ */
38
+ function getDerivationPathArray(hash) {
39
+ const array = [];
40
+ const view = (0, utils_1.createDataView)(hash);
41
+ for (let index = 0; index < 8; index++) {
42
+ const uint32 = view.getUint32(index * 4);
43
+ // This is essentially `index | 0x80000000`. Because JavaScript numbers are
44
+ // signed, we use the bitwise unsigned right shift operator to ensure that
45
+ // the result is a positive number.
46
+ // eslint-disable-next-line no-bitwise
47
+ const pathIndex = (uint32 | HARDENED_VALUE) >>> 0;
48
+ array.push(`bip32:${pathIndex - HARDENED_VALUE}'`);
49
+ }
50
+ return array;
51
+ }
52
+ /**
53
+ * Derive entropy from the given mnemonic phrase and salt.
54
+ *
55
+ * This is based on the reference implementation of
56
+ * [SIP-6](https://metamask.github.io/SIPs/SIPS/sip-6).
57
+ *
58
+ * @param options - The options for entropy derivation.
59
+ * @param options.input - The input value to derive entropy from.
60
+ * @param options.salt - An optional salt to use when deriving entropy.
61
+ * @param options.mnemonicPhrase - The mnemonic phrase to use for entropy
62
+ * derivation.
63
+ * @param options.magic - A hardened BIP-32 index, which is used to derive the
64
+ * root key from the mnemonic phrase.
65
+ * @returns The derived entropy.
66
+ */
67
+ async function deriveEntropy({ input, salt = '', mnemonicPhrase, magic, }) {
68
+ const inputBytes = (0, utils_1.stringToBytes)(input);
69
+ const saltBytes = (0, utils_1.stringToBytes)(salt);
70
+ // Get the derivation path from the snap ID.
71
+ const hash = (0, sha3_1.keccak_256)((0, utils_1.concatBytes)([inputBytes, (0, sha3_1.keccak_256)(saltBytes)]));
72
+ const computedDerivationPath = getDerivationPathArray(hash);
73
+ // Derive the private key using BIP-32.
74
+ const { privateKey } = await key_tree_1.SLIP10Node.fromDerivationPath({
75
+ derivationPath: [
76
+ mnemonicPhrase,
77
+ `bip32:${magic}`,
78
+ ...computedDerivationPath,
79
+ ],
80
+ curve: 'secp256k1',
81
+ });
82
+ // This should never happen, but this keeps TypeScript happy.
83
+ (0, utils_1.assert)(privateKey, 'Failed to derive the entropy.');
84
+ return (0, utils_1.add0x)(privateKey);
85
+ }
86
+ exports.deriveEntropy = deriveEntropy;
87
+ /**
88
+ * Get the path prefix to use for key derivation in `key-tree`. This assumes the
89
+ * following:
90
+ *
91
+ * - The Secp256k1 curve always uses the BIP-32 specification.
92
+ * - The Ed25519 curve always uses the SLIP-10 specification.
93
+ * - The BIP-32-Ed25519 curve always uses the CIP-3 specification.
94
+ *
95
+ * While this does not matter in most situations (no known case at the time of
96
+ * writing), `key-tree` requires a specific specification to be used.
97
+ *
98
+ * @param curve - The curve to get the path prefix for. The curve is NOT
99
+ * validated by this function.
100
+ * @returns The path prefix, i.e., `bip32` or `slip10`.
101
+ */
102
+ function getPathPrefix(curve) {
103
+ switch (curve) {
104
+ case 'secp256k1':
105
+ return 'bip32';
106
+ case 'ed25519':
107
+ return 'slip10';
108
+ case 'ed25519Bip32':
109
+ return 'cip3';
110
+ default:
111
+ return (0, utils_1.assertExhaustive)(curve);
112
+ }
113
+ }
114
+ exports.getPathPrefix = getPathPrefix;
115
+ /**
116
+ * Get a `key-tree`-compatible node.
117
+ *
118
+ * Note: This function assumes that all the parameters have been validated
119
+ * beforehand.
120
+ *
121
+ * @param options - The derivation options.
122
+ * @param options.curve - The curve to use for derivation.
123
+ * @param options.secretRecoveryPhrase - The secret recovery phrase to use for
124
+ * derivation.
125
+ * @param options.path - The derivation path to use as array, starting with an
126
+ * "m" as the first item.
127
+ * @returns The `key-tree` SLIP-10 node.
128
+ */
129
+ async function getNode({ curve, secretRecoveryPhrase, path, }) {
130
+ const prefix = getPathPrefix(curve);
131
+ return await key_tree_1.SLIP10Node.fromDerivationPath({
132
+ curve,
133
+ derivationPath: [
134
+ secretRecoveryPhrase,
135
+ ...path.slice(1).map((index) => `${prefix}:${index}`),
136
+ ],
137
+ });
138
+ }
139
+ exports.getNode = getNode;
140
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"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","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 * @returns The `key-tree` SLIP-10 node.\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,7 +1,7 @@
1
- import type { SupportedCurve } from '@metamask/key-tree';
2
- import { SLIP10Node } from '@metamask/key-tree';
3
- import type { MagicValue } from '@metamask/snaps-utils';
4
- import type { Hex } from '@metamask/utils';
1
+ import type { SupportedCurve } from "@metamask/key-tree";
2
+ import { SLIP10Node } from "@metamask/key-tree";
3
+ import type { MagicValue } from "@metamask/snaps-utils";
4
+ import type { Hex } from "@metamask/utils";
5
5
  /**
6
6
  * Maps an interface with method hooks to an object, using the keys of the
7
7
  * interface, and `true` as value. This ensures that the `methodHooks` object
@@ -91,6 +91,8 @@ type GetNodeArgs = {
91
91
  * derivation.
92
92
  * @param options.path - The derivation path to use as array, starting with an
93
93
  * "m" as the first item.
94
+ * @returns The `key-tree` SLIP-10 node.
94
95
  */
95
96
  export declare function getNode({ curve, secretRecoveryPhrase, path, }: GetNodeArgs): Promise<SLIP10Node>;
96
97
  export {};
98
+ //# sourceMappingURL=utils.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,cAAc,EACf,2BAA2B;AAC5B,OAAO,EAAE,UAAU,EAAE,2BAA2B;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,8BAA8B;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAa3C;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;KACxE,GAAG,IAAI,MAAM,SAAS,GAAG,IAAI;CAC/B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,SAAS,MAAM,KAAK,EAE5B,KAAK,EAAE,KAAK,EACZ,SAAS,CAAC,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GACpC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,SAAS,CAYnC;AA2BD,KAAK,oBAAoB,GAAG;IAC1B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,cAAc,EAAE,UAAU,CAAC;IAE3B;;;OAGG;IACH,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,IAAS,EACT,cAAc,EACd,KAAK,GACN,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,CAsBrC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,cAAc,GACpB,OAAO,GAAG,QAAQ,GAAG,MAAM,CAW7B;AAED,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,cAAc,CAAC;IACtB,oBAAoB,EAAE,UAAU,CAAC;IACjC,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAsB,OAAO,CAAC,EAC5B,KAAK,EACL,oBAAoB,EACpB,IAAI,GACL,EAAE,WAAW,uBAYb"}
@@ -0,0 +1,98 @@
1
+ import type { SupportedCurve } from "@metamask/key-tree";
2
+ import { SLIP10Node } from "@metamask/key-tree";
3
+ import type { MagicValue } from "@metamask/snaps-utils";
4
+ import type { Hex } from "@metamask/utils";
5
+ /**
6
+ * Maps an interface with method hooks to an object, using the keys of the
7
+ * interface, and `true` as value. This ensures that the `methodHooks` object
8
+ * has the same values as the interface.
9
+ */
10
+ export type MethodHooksObject<HooksType extends Record<string, unknown>> = {
11
+ [Key in keyof HooksType]: true;
12
+ };
13
+ /**
14
+ * Returns the subset of the specified `hooks` that are included in the
15
+ * `hookNames` object. This is a Principle of Least Authority (POLA) measure
16
+ * to ensure that each RPC method implementation only has access to the
17
+ * API "hooks" it needs to do its job.
18
+ *
19
+ * @param hooks - The hooks to select from.
20
+ * @param hookNames - The names of the hooks to select.
21
+ * @returns The selected hooks.
22
+ * @template Hooks - The hooks to select from.
23
+ * @template HookName - The names of the hooks to select.
24
+ */
25
+ export declare function selectHooks<Hooks extends Record<string, unknown>, HookName extends keyof Hooks>(hooks: Hooks, hookNames?: Record<HookName, boolean>): Pick<Hooks, HookName> | undefined;
26
+ type DeriveEntropyOptions = {
27
+ /**
28
+ * The input value to derive entropy from.
29
+ */
30
+ input: string;
31
+ /**
32
+ * An optional salt to use when deriving entropy.
33
+ */
34
+ salt?: string;
35
+ /**
36
+ * The mnemonic phrase to use for entropy derivation.
37
+ */
38
+ mnemonicPhrase: Uint8Array;
39
+ /**
40
+ * A hardened BIP-32 index, which is used to derive the root key from the
41
+ * mnemonic phrase.
42
+ */
43
+ magic: MagicValue;
44
+ };
45
+ /**
46
+ * Derive entropy from the given mnemonic phrase and salt.
47
+ *
48
+ * This is based on the reference implementation of
49
+ * [SIP-6](https://metamask.github.io/SIPs/SIPS/sip-6).
50
+ *
51
+ * @param options - The options for entropy derivation.
52
+ * @param options.input - The input value to derive entropy from.
53
+ * @param options.salt - An optional salt to use when deriving entropy.
54
+ * @param options.mnemonicPhrase - The mnemonic phrase to use for entropy
55
+ * derivation.
56
+ * @param options.magic - A hardened BIP-32 index, which is used to derive the
57
+ * root key from the mnemonic phrase.
58
+ * @returns The derived entropy.
59
+ */
60
+ export declare function deriveEntropy({ input, salt, mnemonicPhrase, magic, }: DeriveEntropyOptions): Promise<Hex>;
61
+ /**
62
+ * Get the path prefix to use for key derivation in `key-tree`. This assumes the
63
+ * following:
64
+ *
65
+ * - The Secp256k1 curve always uses the BIP-32 specification.
66
+ * - The Ed25519 curve always uses the SLIP-10 specification.
67
+ * - The BIP-32-Ed25519 curve always uses the CIP-3 specification.
68
+ *
69
+ * While this does not matter in most situations (no known case at the time of
70
+ * writing), `key-tree` requires a specific specification to be used.
71
+ *
72
+ * @param curve - The curve to get the path prefix for. The curve is NOT
73
+ * validated by this function.
74
+ * @returns The path prefix, i.e., `bip32` or `slip10`.
75
+ */
76
+ export declare function getPathPrefix(curve: SupportedCurve): 'bip32' | 'slip10' | 'cip3';
77
+ type GetNodeArgs = {
78
+ curve: SupportedCurve;
79
+ secretRecoveryPhrase: Uint8Array;
80
+ path: string[];
81
+ };
82
+ /**
83
+ * Get a `key-tree`-compatible node.
84
+ *
85
+ * Note: This function assumes that all the parameters have been validated
86
+ * beforehand.
87
+ *
88
+ * @param options - The derivation options.
89
+ * @param options.curve - The curve to use for derivation.
90
+ * @param options.secretRecoveryPhrase - The secret recovery phrase to use for
91
+ * derivation.
92
+ * @param options.path - The derivation path to use as array, starting with an
93
+ * "m" as the first item.
94
+ * @returns The `key-tree` SLIP-10 node.
95
+ */
96
+ export declare function getNode({ curve, secretRecoveryPhrase, path, }: GetNodeArgs): Promise<SLIP10Node>;
97
+ export {};
98
+ //# sourceMappingURL=utils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,cAAc,EACf,2BAA2B;AAC5B,OAAO,EAAE,UAAU,EAAE,2BAA2B;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,8BAA8B;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAa3C;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;KACxE,GAAG,IAAI,MAAM,SAAS,GAAG,IAAI;CAC/B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,SAAS,MAAM,KAAK,EAE5B,KAAK,EAAE,KAAK,EACZ,SAAS,CAAC,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GACpC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,SAAS,CAYnC;AA2BD,KAAK,oBAAoB,GAAG;IAC1B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,cAAc,EAAE,UAAU,CAAC;IAE3B;;;OAGG;IACH,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,IAAS,EACT,cAAc,EACd,KAAK,GACN,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,CAsBrC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,cAAc,GACpB,OAAO,GAAG,QAAQ,GAAG,MAAM,CAW7B;AAED,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,cAAc,CAAC;IACtB,oBAAoB,EAAE,UAAU,CAAC;IACjC,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAsB,OAAO,CAAC,EAC5B,KAAK,EACL,oBAAoB,EACpB,IAAI,GACL,EAAE,WAAW,uBAYb"}
package/dist/utils.mjs CHANGED
@@ -1,13 +1,133 @@
1
- import {
2
- deriveEntropy,
3
- getNode,
4
- getPathPrefix,
5
- selectHooks
6
- } from "./chunk-W33UWNA2.mjs";
7
- export {
8
- deriveEntropy,
9
- getNode,
10
- getPathPrefix,
11
- selectHooks
12
- };
1
+ import { SLIP10Node } from "@metamask/key-tree";
2
+ import { assertExhaustive, add0x, assert, concatBytes, createDataView, stringToBytes } from "@metamask/utils";
3
+ import { keccak_256 as keccak256 } from "@noble/hashes/sha3";
4
+ const HARDENED_VALUE = 0x80000000;
5
+ /**
6
+ * Returns the subset of the specified `hooks` that are included in the
7
+ * `hookNames` object. This is a Principle of Least Authority (POLA) measure
8
+ * to ensure that each RPC method implementation only has access to the
9
+ * API "hooks" it needs to do its job.
10
+ *
11
+ * @param hooks - The hooks to select from.
12
+ * @param hookNames - The names of the hooks to select.
13
+ * @returns The selected hooks.
14
+ * @template Hooks - The hooks to select from.
15
+ * @template HookName - The names of the hooks to select.
16
+ */
17
+ export function selectHooks(hooks, hookNames) {
18
+ if (hookNames) {
19
+ return Object.keys(hookNames).reduce((hookSubset, _hookName) => {
20
+ const hookName = _hookName;
21
+ hookSubset[hookName] = hooks[hookName];
22
+ return hookSubset;
23
+ }, {});
24
+ }
25
+ return undefined;
26
+ }
27
+ /**
28
+ * Get a BIP-32 derivation path array from a hash, which is compatible with
29
+ * `@metamask/key-tree`. The hash is assumed to be 32 bytes long.
30
+ *
31
+ * @param hash - The hash to derive indices from.
32
+ * @returns The derived indices as a {@link HardenedBIP32Node} array.
33
+ */
34
+ function getDerivationPathArray(hash) {
35
+ const array = [];
36
+ const view = createDataView(hash);
37
+ for (let index = 0; index < 8; index++) {
38
+ const uint32 = view.getUint32(index * 4);
39
+ // This is essentially `index | 0x80000000`. Because JavaScript numbers are
40
+ // signed, we use the bitwise unsigned right shift operator to ensure that
41
+ // the result is a positive number.
42
+ // eslint-disable-next-line no-bitwise
43
+ const pathIndex = (uint32 | HARDENED_VALUE) >>> 0;
44
+ array.push(`bip32:${pathIndex - HARDENED_VALUE}'`);
45
+ }
46
+ return array;
47
+ }
48
+ /**
49
+ * Derive entropy from the given mnemonic phrase and salt.
50
+ *
51
+ * This is based on the reference implementation of
52
+ * [SIP-6](https://metamask.github.io/SIPs/SIPS/sip-6).
53
+ *
54
+ * @param options - The options for entropy derivation.
55
+ * @param options.input - The input value to derive entropy from.
56
+ * @param options.salt - An optional salt to use when deriving entropy.
57
+ * @param options.mnemonicPhrase - The mnemonic phrase to use for entropy
58
+ * derivation.
59
+ * @param options.magic - A hardened BIP-32 index, which is used to derive the
60
+ * root key from the mnemonic phrase.
61
+ * @returns The derived entropy.
62
+ */
63
+ export async function deriveEntropy({ input, salt = '', mnemonicPhrase, magic, }) {
64
+ const inputBytes = stringToBytes(input);
65
+ const saltBytes = stringToBytes(salt);
66
+ // Get the derivation path from the snap ID.
67
+ const hash = keccak256(concatBytes([inputBytes, keccak256(saltBytes)]));
68
+ const computedDerivationPath = getDerivationPathArray(hash);
69
+ // Derive the private key using BIP-32.
70
+ const { privateKey } = await SLIP10Node.fromDerivationPath({
71
+ derivationPath: [
72
+ mnemonicPhrase,
73
+ `bip32:${magic}`,
74
+ ...computedDerivationPath,
75
+ ],
76
+ curve: 'secp256k1',
77
+ });
78
+ // This should never happen, but this keeps TypeScript happy.
79
+ assert(privateKey, 'Failed to derive the entropy.');
80
+ return add0x(privateKey);
81
+ }
82
+ /**
83
+ * Get the path prefix to use for key derivation in `key-tree`. This assumes the
84
+ * following:
85
+ *
86
+ * - The Secp256k1 curve always uses the BIP-32 specification.
87
+ * - The Ed25519 curve always uses the SLIP-10 specification.
88
+ * - The BIP-32-Ed25519 curve always uses the CIP-3 specification.
89
+ *
90
+ * While this does not matter in most situations (no known case at the time of
91
+ * writing), `key-tree` requires a specific specification to be used.
92
+ *
93
+ * @param curve - The curve to get the path prefix for. The curve is NOT
94
+ * validated by this function.
95
+ * @returns The path prefix, i.e., `bip32` or `slip10`.
96
+ */
97
+ export function getPathPrefix(curve) {
98
+ switch (curve) {
99
+ case 'secp256k1':
100
+ return 'bip32';
101
+ case 'ed25519':
102
+ return 'slip10';
103
+ case 'ed25519Bip32':
104
+ return 'cip3';
105
+ default:
106
+ return assertExhaustive(curve);
107
+ }
108
+ }
109
+ /**
110
+ * Get a `key-tree`-compatible node.
111
+ *
112
+ * Note: This function assumes that all the parameters have been validated
113
+ * beforehand.
114
+ *
115
+ * @param options - The derivation options.
116
+ * @param options.curve - The curve to use for derivation.
117
+ * @param options.secretRecoveryPhrase - The secret recovery phrase to use for
118
+ * derivation.
119
+ * @param options.path - The derivation path to use as array, starting with an
120
+ * "m" as the first item.
121
+ * @returns The `key-tree` SLIP-10 node.
122
+ */
123
+ export async function getNode({ curve, secretRecoveryPhrase, path, }) {
124
+ const prefix = getPathPrefix(curve);
125
+ return await SLIP10Node.fromDerivationPath({
126
+ curve,
127
+ derivationPath: [
128
+ secretRecoveryPhrase,
129
+ ...path.slice(1).map((index) => `${prefix}:${index}`),
130
+ ],
131
+ });
132
+ }
13
133
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"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","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 * @returns The `key-tree` SLIP-10 node.\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-rpc-methods",
3
- "version": "11.0.0",
3
+ "version": "11.1.0",
4
4
  "description": "MetaMask Snaps JSON-RPC method implementations.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,15 +9,20 @@
9
9
  "sideEffects": false,
10
10
  "exports": {
11
11
  ".": {
12
- "import": "./dist/index.mjs",
13
- "require": "./dist/index.js",
14
- "types": "./dist/types/index.d.ts"
12
+ "import": {
13
+ "types": "./dist/index.d.mts",
14
+ "default": "./dist/index.mjs"
15
+ },
16
+ "require": {
17
+ "types": "./dist/index.d.cts",
18
+ "default": "./dist/index.cjs"
19
+ }
15
20
  },
16
21
  "./package.json": "./package.json"
17
22
  },
18
- "main": "./dist/index.js",
23
+ "main": "./dist/index.cjs",
19
24
  "module": "./dist/index.mjs",
20
- "types": "./dist/types/index.d.ts",
25
+ "types": "./dist/index.d.cts",
21
26
  "files": [
22
27
  "dist"
23
28
  ],
@@ -30,22 +35,19 @@
30
35
  "lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog && yarn lint:dependencies",
31
36
  "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
32
37
  "lint:changelog": "../../scripts/validate-changelog.sh @metamask/snaps-rpc-methods",
33
- "build": "tsup --clean && yarn build:types",
34
- "build:types": "tsc --project tsconfig.build.json",
35
- "clean": "rimraf '*.tsbuildinfo' 'dist'",
38
+ "build": "ts-bridge --project tsconfig.build.json --verbose --no-references",
36
39
  "publish:preview": "yarn npm publish --tag preview",
37
40
  "lint:ci": "yarn lint",
38
- "lint:dependencies": "depcheck",
39
- "build:ci": "tsup --clean"
41
+ "lint:dependencies": "depcheck"
40
42
  },
41
43
  "dependencies": {
42
44
  "@metamask/key-tree": "^9.1.2",
43
45
  "@metamask/permission-controller": "^11.0.0",
44
46
  "@metamask/rpc-errors": "^6.3.1",
45
- "@metamask/snaps-sdk": "^6.2.0",
46
- "@metamask/snaps-utils": "^8.0.0",
47
+ "@metamask/snaps-sdk": "^6.4.0",
48
+ "@metamask/snaps-utils": "^8.1.0",
47
49
  "@metamask/superstruct": "^3.1.0",
48
- "@metamask/utils": "^9.1.0",
50
+ "@metamask/utils": "^9.2.1",
49
51
  "@noble/hashes": "^1.3.1"
50
52
  },
51
53
  "devDependencies": {
@@ -58,16 +60,17 @@
58
60
  "@metamask/json-rpc-engine": "^9.0.2",
59
61
  "@swc/core": "1.3.78",
60
62
  "@swc/jest": "^0.2.26",
63
+ "@ts-bridge/cli": "^0.4.4",
61
64
  "@types/node": "18.14.2",
62
65
  "@typescript-eslint/eslint-plugin": "^5.42.1",
63
- "@typescript-eslint/parser": "^5.42.1",
66
+ "@typescript-eslint/parser": "^6.21.0",
64
67
  "deepmerge": "^4.2.2",
65
68
  "depcheck": "^1.4.7",
66
69
  "eslint": "^8.27.0",
67
70
  "eslint-config-prettier": "^8.5.0",
68
71
  "eslint-plugin-import": "^2.26.0",
69
72
  "eslint-plugin-jest": "^27.1.5",
70
- "eslint-plugin-jsdoc": "^39.6.2",
73
+ "eslint-plugin-jsdoc": "^41.1.2",
71
74
  "eslint-plugin-n": "^15.7.0",
72
75
  "eslint-plugin-prettier": "^4.2.1",
73
76
  "eslint-plugin-promise": "^6.1.1",
@@ -75,9 +78,7 @@
75
78
  "jest-it-up": "^2.0.0",
76
79
  "prettier": "^2.7.1",
77
80
  "prettier-plugin-packagejson": "^2.2.11",
78
- "rimraf": "^4.1.2",
79
- "tsup": "^8.0.1",
80
- "typescript": "~5.0.4"
81
+ "typescript": "~5.3.3"
81
82
  },
82
83
  "engines": {
83
84
  "node": "^18.16 || >=20"
@@ -1,73 +0,0 @@
1
- // src/endowments/caveats/requestTime.ts
2
- import { rpcErrors } from "@metamask/rpc-errors";
3
- import { MaxRequestTimeStruct, SnapCaveatType } from "@metamask/snaps-utils";
4
- import { assertStruct, hasProperty, isObject } from "@metamask/utils";
5
- function assertIsMaxRequestTime(value, ErrorWrapper) {
6
- assertStruct(
7
- value,
8
- MaxRequestTimeStruct,
9
- "Invalid maxRequestTime",
10
- ErrorWrapper
11
- );
12
- }
13
- function validateMaxRequestTimeCaveat(caveat) {
14
- if (!hasProperty(caveat, "value")) {
15
- throw rpcErrors.invalidParams({
16
- message: "Invalid maxRequestTime caveat."
17
- });
18
- }
19
- const { value } = caveat;
20
- assertIsMaxRequestTime(value, rpcErrors.invalidParams);
21
- }
22
- function getMaxRequestTimeCaveatMapper(value) {
23
- if (!value || !isObject(value) || isObject(value) && !hasProperty(value, "maxRequestTime")) {
24
- return { caveats: null };
25
- }
26
- return {
27
- caveats: [
28
- {
29
- type: SnapCaveatType.MaxRequestTime,
30
- value: value.maxRequestTime
31
- }
32
- ]
33
- };
34
- }
35
- function createMaxRequestTimeMapper(mapper) {
36
- return function(value) {
37
- const { maxRequestTime, ...rest } = value;
38
- const mapperResult = mapper(rest);
39
- if (!maxRequestTime) {
40
- return mapperResult;
41
- }
42
- return {
43
- ...mapperResult,
44
- caveats: [
45
- ...mapperResult.caveats ?? [],
46
- {
47
- type: SnapCaveatType.MaxRequestTime,
48
- value: maxRequestTime
49
- }
50
- ]
51
- };
52
- };
53
- }
54
- function getMaxRequestTimeCaveat(permission) {
55
- const foundCaveat = permission?.caveats?.find(
56
- (caveat) => caveat.type === SnapCaveatType.MaxRequestTime
57
- );
58
- return foundCaveat?.value ?? null;
59
- }
60
- var maxRequestTimeCaveatSpecifications = {
61
- [SnapCaveatType.MaxRequestTime]: Object.freeze({
62
- type: SnapCaveatType.MaxRequestTime,
63
- validator: (caveat) => validateMaxRequestTimeCaveat(caveat)
64
- })
65
- };
66
-
67
- export {
68
- getMaxRequestTimeCaveatMapper,
69
- createMaxRequestTimeMapper,
70
- getMaxRequestTimeCaveat,
71
- maxRequestTimeCaveatSpecifications
72
- };
73
- //# sourceMappingURL=chunk-23XDKQW2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/endowments/caveats/requestTime.ts"],"sourcesContent":["import type {\n Caveat,\n CaveatSpecificationConstraint,\n PermissionConstraint,\n} from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { MaxRequestTimeStruct, SnapCaveatType } from '@metamask/snaps-utils';\nimport type { AssertionErrorConstructor, Json } from '@metamask/utils';\nimport { assertStruct, hasProperty, isObject } from '@metamask/utils';\n\nimport type { CaveatMapperFunction, CaveatMapperReturnValue } from './generic';\n\n/**\n * Asserts that the given value is a valid `maxRequestTime` value.\n *\n * @param value - The value to assert.\n * @param ErrorWrapper - An optional error wrapper to use. Defaults to\n * {@link AssertionError}.\n * @throws If the value is not a valid `maxRequestTime` value.\n */\nfunction assertIsMaxRequestTime(\n value: unknown, // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is number {\n assertStruct(\n value,\n MaxRequestTimeStruct,\n 'Invalid maxRequestTime',\n ErrorWrapper,\n );\n}\n\n/**\n * Validate the value of a caveat. This does not validate the type of the\n * caveat itself, only the value of the caveat.\n *\n * @param caveat - The caveat to validate.\n * @throws If the caveat value is invalid.\n */\nfunction validateMaxRequestTimeCaveat(caveat: Caveat<string, any>) {\n if (!hasProperty(caveat, 'value')) {\n throw rpcErrors.invalidParams({\n message: 'Invalid maxRequestTime caveat.',\n });\n }\n\n const { value } = caveat;\n assertIsMaxRequestTime(value, rpcErrors.invalidParams);\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 getMaxRequestTimeCaveatMapper(\n value: Json,\n): CaveatMapperReturnValue {\n if (\n !value ||\n !isObject(value) ||\n (isObject(value) && !hasProperty(value, 'maxRequestTime'))\n ) {\n return { caveats: null };\n }\n return {\n caveats: [\n {\n type: SnapCaveatType.MaxRequestTime,\n value: value.maxRequestTime,\n },\n ],\n };\n}\n\n/**\n * Creates a wrapping caveat mapper that creates the `maxRequestTime` caveat\n * and merges it with any other caveats created by the mapper function.\n *\n * @param mapper - Another caveat mapper function.\n * @returns The caveat specification.\n */\nexport function createMaxRequestTimeMapper(\n mapper: CaveatMapperFunction,\n): CaveatMapperFunction {\n return function (value: Json) {\n // We assume this to be used only with caveats of this type\n const { maxRequestTime, ...rest } = value as Record<string, Json>;\n\n const mapperResult = mapper(rest);\n\n if (!maxRequestTime) {\n return mapperResult;\n }\n\n return {\n ...mapperResult,\n caveats: [\n ...(mapperResult.caveats ?? []),\n {\n type: SnapCaveatType.MaxRequestTime,\n value: maxRequestTime,\n },\n ],\n };\n };\n}\n\n/**\n * Getter function to get the {@link MaxRequestTime} caveat value from a permission if specified.\n *\n * @param permission - The permission to get the caveat value from.\n * @returns The caveat value if present, otherwise null.\n */\nexport function getMaxRequestTimeCaveat(\n permission?: PermissionConstraint,\n): number | null {\n const foundCaveat = permission?.caveats?.find(\n (caveat) => caveat.type === SnapCaveatType.MaxRequestTime,\n );\n return (foundCaveat?.value as number) ?? null;\n}\n\nexport const maxRequestTimeCaveatSpecifications: Record<\n SnapCaveatType.MaxRequestTime,\n CaveatSpecificationConstraint\n> = {\n [SnapCaveatType.MaxRequestTime]: Object.freeze({\n type: SnapCaveatType.MaxRequestTime,\n validator: (caveat: Caveat<string, any>) =>\n validateMaxRequestTimeCaveat(caveat),\n }),\n};\n"],"mappings":";AAKA,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB,sBAAsB;AAErD,SAAS,cAAc,aAAa,gBAAgB;AAYpD,SAAS,uBACP,OACA,cACyB;AACzB;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AASA,SAAS,6BAA6B,QAA6B;AACjE,MAAI,CAAC,YAAY,QAAQ,OAAO,GAAG;AACjC,UAAM,UAAU,cAAc;AAAA,MAC5B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,QAAM,EAAE,MAAM,IAAI;AAClB,yBAAuB,OAAO,UAAU,aAAa;AACvD;AAUO,SAAS,8BACd,OACyB;AACzB,MACE,CAAC,SACD,CAAC,SAAS,KAAK,KACd,SAAS,KAAK,KAAK,CAAC,YAAY,OAAO,gBAAgB,GACxD;AACA,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB;AACA,SAAO;AAAA,IACL,SAAS;AAAA,MACP;AAAA,QACE,MAAM,eAAe;AAAA,QACrB,OAAO,MAAM;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF;AASO,SAAS,2BACd,QACsB;AACtB,SAAO,SAAU,OAAa;AAE5B,UAAM,EAAE,gBAAgB,GAAG,KAAK,IAAI;AAEpC,UAAM,eAAe,OAAO,IAAI;AAEhC,QAAI,CAAC,gBAAgB;AACnB,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAI,aAAa,WAAW,CAAC;AAAA,QAC7B;AAAA,UACE,MAAM,eAAe;AAAA,UACrB,OAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAQO,SAAS,wBACd,YACe;AACf,QAAM,cAAc,YAAY,SAAS;AAAA,IACvC,CAAC,WAAW,OAAO,SAAS,eAAe;AAAA,EAC7C;AACA,SAAQ,aAAa,SAAoB;AAC3C;AAEO,IAAM,qCAGT;AAAA,EACF,CAAC,eAAe,cAAc,GAAG,OAAO,OAAO;AAAA,IAC7C,MAAM,eAAe;AAAA,IACrB,WAAW,CAAC,WACV,6BAA6B,MAAM;AAAA,EACvC,CAAC;AACH;","names":[]}