@metamask/snaps-utils 6.1.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (560) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/dist/array.js +8 -0
  3. package/dist/array.js.map +1 -0
  4. package/dist/array.mjs +8 -0
  5. package/dist/array.mjs.map +1 -0
  6. package/dist/auxiliary-files.js +12 -0
  7. package/dist/auxiliary-files.js.map +1 -0
  8. package/dist/auxiliary-files.mjs +12 -0
  9. package/dist/auxiliary-files.mjs.map +1 -0
  10. package/dist/base64.js +13 -0
  11. package/dist/base64.js.map +1 -0
  12. package/dist/base64.mjs +13 -0
  13. package/dist/base64.mjs.map +1 -0
  14. package/dist/bytes.js +10 -0
  15. package/dist/bytes.js.map +1 -0
  16. package/dist/bytes.mjs +10 -0
  17. package/dist/bytes.mjs.map +1 -0
  18. package/dist/caveats.js +8 -0
  19. package/dist/caveats.js.map +1 -0
  20. package/dist/caveats.mjs +8 -0
  21. package/dist/caveats.mjs.map +1 -0
  22. package/dist/checksum.js +13 -0
  23. package/dist/checksum.js.map +1 -0
  24. package/dist/checksum.mjs +13 -0
  25. package/dist/checksum.mjs.map +1 -0
  26. package/dist/chunk-224S5XKL.js +32 -0
  27. package/dist/chunk-224S5XKL.js.map +1 -0
  28. package/dist/chunk-2G4HD42C.mjs +22 -0
  29. package/dist/chunk-2G4HD42C.mjs.map +1 -0
  30. package/dist/chunk-2IVFF3AA.mjs +211 -0
  31. package/dist/chunk-2IVFF3AA.mjs.map +1 -0
  32. package/dist/chunk-2QS3W66J.js +64 -0
  33. package/dist/chunk-2QS3W66J.js.map +1 -0
  34. package/dist/chunk-2XF32FCF.js +1 -0
  35. package/dist/chunk-2XF32FCF.js.map +1 -0
  36. package/dist/chunk-32B4YQM7.mjs +103 -0
  37. package/dist/chunk-32B4YQM7.mjs.map +1 -0
  38. package/dist/chunk-3SARO5TJ.mjs +18 -0
  39. package/dist/chunk-3SARO5TJ.mjs.map +1 -0
  40. package/dist/chunk-3TH3NLQL.js +169 -0
  41. package/dist/chunk-3TH3NLQL.js.map +1 -0
  42. package/dist/chunk-3ZSMMNQB.mjs +41 -0
  43. package/dist/chunk-3ZSMMNQB.mjs.map +1 -0
  44. package/dist/chunk-43EBXDVP.mjs +30 -0
  45. package/dist/chunk-43EBXDVP.mjs.map +1 -0
  46. package/dist/chunk-4GBOSMF7.mjs +33 -0
  47. package/dist/chunk-4GBOSMF7.mjs.map +1 -0
  48. package/dist/chunk-4IKNNAVC.mjs +30 -0
  49. package/dist/chunk-4IKNNAVC.mjs.map +1 -0
  50. package/dist/chunk-4UMDRHDR.js +95 -0
  51. package/dist/chunk-4UMDRHDR.js.map +1 -0
  52. package/dist/chunk-6CTV7VW5.mjs +20 -0
  53. package/dist/chunk-6CTV7VW5.mjs.map +1 -0
  54. package/dist/chunk-6H32HLTZ.js +10 -0
  55. package/dist/chunk-6H32HLTZ.js.map +1 -0
  56. package/dist/chunk-6WBLB5BX.js +9 -0
  57. package/dist/chunk-6WBLB5BX.js.map +1 -0
  58. package/dist/chunk-7H5TGXZ5.js +70 -0
  59. package/dist/chunk-7H5TGXZ5.js.map +1 -0
  60. package/dist/chunk-7KKLGQNE.js +38 -0
  61. package/dist/chunk-7KKLGQNE.js.map +1 -0
  62. package/dist/chunk-7PNGOFLU.js +22 -0
  63. package/dist/chunk-7PNGOFLU.js.map +1 -0
  64. package/dist/chunk-7T3N2ZGQ.mjs +107 -0
  65. package/dist/chunk-7T3N2ZGQ.mjs.map +1 -0
  66. package/dist/chunk-7XA5VYYV.mjs +9 -0
  67. package/dist/chunk-7XA5VYYV.mjs.map +1 -0
  68. package/dist/chunk-B2DMAQNK.mjs +8 -0
  69. package/dist/chunk-B2DMAQNK.mjs.map +1 -0
  70. package/dist/chunk-B3YQVRPE.js +107 -0
  71. package/dist/chunk-B3YQVRPE.js.map +1 -0
  72. package/dist/chunk-DK3IYVMP.mjs +1 -0
  73. package/dist/chunk-DK3IYVMP.mjs.map +1 -0
  74. package/dist/chunk-DKSB4FMW.mjs +74 -0
  75. package/dist/chunk-DKSB4FMW.mjs.map +1 -0
  76. package/dist/chunk-F33RMB76.js +69 -0
  77. package/dist/chunk-F33RMB76.js.map +1 -0
  78. package/dist/chunk-FJH6DDEL.mjs +193 -0
  79. package/dist/chunk-FJH6DDEL.mjs.map +1 -0
  80. package/dist/chunk-FTY3BOF7.js +9 -0
  81. package/dist/chunk-FTY3BOF7.js.map +1 -0
  82. package/dist/chunk-GK4IJQVW.js +409 -0
  83. package/dist/chunk-GK4IJQVW.js.map +1 -0
  84. package/dist/chunk-GMC2A3D7.js +211 -0
  85. package/dist/chunk-GMC2A3D7.js.map +1 -0
  86. package/dist/chunk-GW5NQXN4.mjs +151 -0
  87. package/dist/chunk-GW5NQXN4.mjs.map +1 -0
  88. package/dist/chunk-H34N3OWO.mjs +169 -0
  89. package/dist/chunk-H34N3OWO.mjs.map +1 -0
  90. package/dist/chunk-H636DAOG.js +193 -0
  91. package/dist/chunk-H636DAOG.js.map +1 -0
  92. package/dist/chunk-HOTDTMNP.mjs +21 -0
  93. package/dist/chunk-HOTDTMNP.mjs.map +1 -0
  94. package/dist/chunk-HWFLO7W5.mjs +281 -0
  95. package/dist/chunk-HWFLO7W5.mjs.map +1 -0
  96. package/dist/chunk-I3BUOULW.js +18 -0
  97. package/dist/chunk-I3BUOULW.js.map +1 -0
  98. package/dist/chunk-IIDK6BRC.mjs +1 -0
  99. package/dist/chunk-IIDK6BRC.mjs.map +1 -0
  100. package/dist/chunk-IUNNN6HN.mjs +29 -0
  101. package/dist/chunk-IUNNN6HN.mjs.map +1 -0
  102. package/dist/chunk-IWENO6LT.js +20 -0
  103. package/dist/chunk-IWENO6LT.js.map +1 -0
  104. package/dist/chunk-JGMGNLZW.mjs +38 -0
  105. package/dist/chunk-JGMGNLZW.mjs.map +1 -0
  106. package/dist/chunk-JV7OA3FD.js +1 -0
  107. package/dist/chunk-JV7OA3FD.js.map +1 -0
  108. package/dist/chunk-KEXZDQAN.js +50 -0
  109. package/dist/chunk-KEXZDQAN.js.map +1 -0
  110. package/dist/chunk-KWQKGJSV.js +152 -0
  111. package/dist/chunk-KWQKGJSV.js.map +1 -0
  112. package/dist/chunk-LEFOMYX3.mjs +1 -0
  113. package/dist/chunk-LEFOMYX3.mjs.map +1 -0
  114. package/dist/chunk-LHIPBIPS.mjs +32 -0
  115. package/dist/chunk-LHIPBIPS.mjs.map +1 -0
  116. package/dist/chunk-LOW2T4MV.mjs +50 -0
  117. package/dist/chunk-LOW2T4MV.mjs.map +1 -0
  118. package/dist/chunk-MJABESWH.js +20 -0
  119. package/dist/chunk-MJABESWH.js.map +1 -0
  120. package/dist/chunk-MSUZTHYT.js +9 -0
  121. package/dist/chunk-MSUZTHYT.js.map +1 -0
  122. package/dist/chunk-MYSBDK36.mjs +1 -0
  123. package/dist/chunk-MYSBDK36.mjs.map +1 -0
  124. package/dist/chunk-N52KMB25.mjs +109 -0
  125. package/dist/chunk-N52KMB25.mjs.map +1 -0
  126. package/dist/chunk-O3XKEEJV.mjs +249 -0
  127. package/dist/chunk-O3XKEEJV.mjs.map +1 -0
  128. package/dist/chunk-O4PW77JW.mjs +1 -0
  129. package/dist/chunk-O4PW77JW.mjs.map +1 -0
  130. package/dist/chunk-OQSLMZJN.js +281 -0
  131. package/dist/chunk-OQSLMZJN.js.map +1 -0
  132. package/dist/chunk-P5V6S2PA.mjs +69 -0
  133. package/dist/chunk-P5V6S2PA.mjs.map +1 -0
  134. package/dist/chunk-PHUTP7NB.js +25 -0
  135. package/dist/chunk-PHUTP7NB.js.map +1 -0
  136. package/dist/chunk-Q5T57UNN.js +1 -0
  137. package/dist/chunk-Q5T57UNN.js.map +1 -0
  138. package/dist/chunk-Q7FGULTV.js +8 -0
  139. package/dist/chunk-Q7FGULTV.js.map +1 -0
  140. package/dist/chunk-QF3LHIJ5.mjs +9 -0
  141. package/dist/chunk-QF3LHIJ5.mjs.map +1 -0
  142. package/dist/chunk-QJTAFTW7.js +30 -0
  143. package/dist/chunk-QJTAFTW7.js.map +1 -0
  144. package/dist/chunk-QWEXXUTO.mjs +10 -0
  145. package/dist/chunk-QWEXXUTO.mjs.map +1 -0
  146. package/dist/chunk-QYFDFOWT.js +41 -0
  147. package/dist/chunk-QYFDFOWT.js.map +1 -0
  148. package/dist/chunk-R4BBIGBN.js +18 -0
  149. package/dist/chunk-R4BBIGBN.js.map +1 -0
  150. package/dist/chunk-R7UAMO2U.js +21 -0
  151. package/dist/chunk-R7UAMO2U.js.map +1 -0
  152. package/dist/chunk-RRPU7M4Y.js +29 -0
  153. package/dist/chunk-RRPU7M4Y.js.map +1 -0
  154. package/dist/chunk-RS5HE55U.js +109 -0
  155. package/dist/chunk-RS5HE55U.js.map +1 -0
  156. package/dist/chunk-TUAHXE75.mjs +21 -0
  157. package/dist/chunk-TUAHXE75.mjs.map +1 -0
  158. package/dist/chunk-TURGGK5F.mjs +59 -0
  159. package/dist/chunk-TURGGK5F.mjs.map +1 -0
  160. package/dist/chunk-UGQQ5DJ4.mjs +50 -0
  161. package/dist/chunk-UGQQ5DJ4.mjs.map +1 -0
  162. package/dist/chunk-VGWELVCX.mjs +18 -0
  163. package/dist/chunk-VGWELVCX.mjs.map +1 -0
  164. package/dist/chunk-VMUXXXJC.js +103 -0
  165. package/dist/chunk-VMUXXXJC.js.map +1 -0
  166. package/dist/chunk-WDGBH5CP.js +249 -0
  167. package/dist/chunk-WDGBH5CP.js.map +1 -0
  168. package/dist/chunk-WJOAEPZ7.js +30 -0
  169. package/dist/chunk-WJOAEPZ7.js.map +1 -0
  170. package/dist/chunk-XC5E26VE.mjs +20 -0
  171. package/dist/chunk-XC5E26VE.mjs.map +1 -0
  172. package/dist/chunk-XDEHYKW2.js +1 -0
  173. package/dist/chunk-XDEHYKW2.js.map +1 -0
  174. package/dist/chunk-XEY3KVEH.js +21 -0
  175. package/dist/chunk-XEY3KVEH.js.map +1 -0
  176. package/dist/chunk-XKXHM3PC.mjs +9 -0
  177. package/dist/chunk-XKXHM3PC.mjs.map +1 -0
  178. package/dist/chunk-XRGYWWT7.js +151 -0
  179. package/dist/chunk-XRGYWWT7.js.map +1 -0
  180. package/dist/chunk-XWFKTDB3.js +50 -0
  181. package/dist/chunk-XWFKTDB3.js.map +1 -0
  182. package/dist/chunk-Y3F7VUZB.mjs +409 -0
  183. package/dist/chunk-Y3F7VUZB.mjs.map +1 -0
  184. package/dist/chunk-YF4PGFCO.js +1 -0
  185. package/dist/chunk-YF4PGFCO.js.map +1 -0
  186. package/dist/chunk-YLT6CNSL.mjs +64 -0
  187. package/dist/chunk-YLT6CNSL.mjs.map +1 -0
  188. package/dist/chunk-Z4J4GUGG.mjs +152 -0
  189. package/dist/chunk-Z4J4GUGG.mjs.map +1 -0
  190. package/dist/chunk-ZLFA4R5X.js +56 -0
  191. package/dist/chunk-ZLFA4R5X.js.map +1 -0
  192. package/dist/chunk-ZRVOIW3H.js +74 -0
  193. package/dist/chunk-ZRVOIW3H.js.map +1 -0
  194. package/dist/chunk-ZVXX2CTH.mjs +95 -0
  195. package/dist/chunk-ZVXX2CTH.mjs.map +1 -0
  196. package/dist/chunk-ZXCNX3ZB.mjs +70 -0
  197. package/dist/chunk-ZXCNX3ZB.mjs.map +1 -0
  198. package/dist/cronjob.js +20 -0
  199. package/dist/cronjob.js.map +1 -0
  200. package/dist/cronjob.mjs +20 -0
  201. package/dist/cronjob.mjs.map +1 -0
  202. package/dist/deep-clone.js +8 -0
  203. package/dist/deep-clone.js.map +1 -0
  204. package/dist/deep-clone.mjs +8 -0
  205. package/dist/deep-clone.mjs.map +1 -0
  206. package/dist/default-endowments.js +8 -0
  207. package/dist/default-endowments.js.map +1 -0
  208. package/dist/default-endowments.mjs +8 -0
  209. package/dist/default-endowments.mjs.map +1 -0
  210. package/dist/derivation-paths.js +13 -0
  211. package/dist/derivation-paths.js.map +1 -0
  212. package/dist/derivation-paths.mjs +13 -0
  213. package/dist/derivation-paths.mjs.map +1 -0
  214. package/dist/entropy.js +10 -0
  215. package/dist/entropy.js.map +1 -0
  216. package/dist/entropy.mjs +10 -0
  217. package/dist/entropy.mjs.map +1 -0
  218. package/dist/errors.js +20 -0
  219. package/dist/errors.js.map +1 -0
  220. package/dist/errors.mjs +20 -0
  221. package/dist/errors.mjs.map +1 -0
  222. package/dist/eval-worker.js +43 -0
  223. package/dist/eval-worker.js.map +1 -0
  224. package/dist/eval-worker.mjs +43 -0
  225. package/dist/eval-worker.mjs.map +1 -0
  226. package/dist/eval.js +17 -0
  227. package/dist/eval.js.map +1 -0
  228. package/dist/eval.mjs +17 -0
  229. package/dist/eval.mjs.map +1 -0
  230. package/dist/fs.js +28 -0
  231. package/dist/fs.js.map +1 -0
  232. package/dist/fs.mjs +28 -0
  233. package/dist/fs.mjs.map +1 -0
  234. package/dist/handler-types.js +10 -0
  235. package/dist/handler-types.js.map +1 -0
  236. package/dist/handler-types.mjs +10 -0
  237. package/dist/handler-types.mjs.map +1 -0
  238. package/dist/handlers.js +35 -0
  239. package/dist/handlers.js.map +1 -0
  240. package/dist/handlers.mjs +35 -0
  241. package/dist/handlers.mjs.map +1 -0
  242. package/dist/icon.js +14 -0
  243. package/dist/icon.js.map +1 -0
  244. package/dist/icon.mjs +14 -0
  245. package/dist/icon.mjs.map +1 -0
  246. package/dist/iframe.js +8 -0
  247. package/dist/iframe.js.map +1 -0
  248. package/dist/iframe.mjs +8 -0
  249. package/dist/iframe.mjs.map +1 -0
  250. package/dist/index.executionenv.js +134 -0
  251. package/dist/index.executionenv.js.map +1 -0
  252. package/dist/index.executionenv.mjs +134 -0
  253. package/dist/index.executionenv.mjs.map +1 -0
  254. package/dist/index.js +378 -0
  255. package/dist/index.js.map +1 -0
  256. package/dist/index.mjs +378 -0
  257. package/dist/index.mjs.map +1 -0
  258. package/dist/json-rpc.js +18 -0
  259. package/dist/json-rpc.js.map +1 -0
  260. package/dist/json-rpc.mjs +18 -0
  261. package/dist/json-rpc.mjs.map +1 -0
  262. package/dist/json.js +8 -0
  263. package/dist/json.js.map +1 -0
  264. package/dist/json.mjs +8 -0
  265. package/dist/json.mjs.map +1 -0
  266. package/dist/localization.js +23 -0
  267. package/dist/localization.js.map +1 -0
  268. package/dist/localization.mjs +23 -0
  269. package/dist/localization.mjs.map +1 -0
  270. package/dist/logging.js +14 -0
  271. package/dist/logging.js.map +1 -0
  272. package/dist/logging.mjs +14 -0
  273. package/dist/logging.mjs.map +1 -0
  274. package/dist/manifest/index.js +59 -0
  275. package/dist/manifest/index.js.map +1 -0
  276. package/dist/manifest/index.mjs +59 -0
  277. package/dist/manifest/index.mjs.map +1 -0
  278. package/dist/manifest/manifest.js +42 -0
  279. package/dist/manifest/manifest.js.map +1 -0
  280. package/dist/manifest/manifest.mjs +42 -0
  281. package/dist/manifest/manifest.mjs.map +1 -0
  282. package/dist/manifest/node.js +85 -0
  283. package/dist/manifest/node.js.map +1 -0
  284. package/dist/manifest/node.mjs +85 -0
  285. package/dist/manifest/node.mjs.map +1 -0
  286. package/dist/manifest/validation.js +58 -0
  287. package/dist/manifest/validation.js.map +1 -0
  288. package/dist/manifest/validation.mjs +58 -0
  289. package/dist/manifest/validation.mjs.map +1 -0
  290. package/dist/mock.js +13 -0
  291. package/dist/mock.js.map +1 -0
  292. package/dist/mock.mjs +13 -0
  293. package/dist/mock.mjs.map +1 -0
  294. package/dist/namespace.js +44 -0
  295. package/dist/namespace.js.map +1 -0
  296. package/dist/namespace.mjs +44 -0
  297. package/dist/namespace.mjs.map +1 -0
  298. package/dist/node.js +448 -0
  299. package/dist/node.js.map +1 -0
  300. package/dist/node.mjs +448 -0
  301. package/dist/node.mjs.map +1 -0
  302. package/dist/npm.js +32 -0
  303. package/dist/npm.js.map +1 -0
  304. package/dist/npm.mjs +32 -0
  305. package/dist/npm.mjs.map +1 -0
  306. package/dist/path.js +8 -0
  307. package/dist/path.js.map +1 -0
  308. package/dist/path.mjs +8 -0
  309. package/dist/path.mjs.map +1 -0
  310. package/dist/post-process.js +10 -0
  311. package/dist/post-process.js.map +1 -0
  312. package/dist/post-process.mjs +10 -0
  313. package/dist/post-process.mjs.map +1 -0
  314. package/dist/snaps.js +48 -0
  315. package/dist/snaps.js.map +1 -0
  316. package/dist/snaps.mjs +48 -0
  317. package/dist/snaps.mjs.map +1 -0
  318. package/dist/strings.js +8 -0
  319. package/dist/strings.js.map +1 -0
  320. package/dist/strings.mjs +8 -0
  321. package/dist/strings.mjs.map +1 -0
  322. package/dist/structs.js +31 -0
  323. package/dist/structs.js.map +1 -0
  324. package/dist/structs.mjs +31 -0
  325. package/dist/structs.mjs.map +1 -0
  326. package/dist/tsconfig.build.tsbuildinfo +1 -0
  327. package/dist/types/bytes.d.ts +1 -1
  328. package/dist/types/checksum.d.ts +1 -1
  329. package/dist/types/index.d.ts +1 -6
  330. package/dist/types/json-rpc.d.ts +1 -1
  331. package/dist/types/localization.d.ts +1 -1
  332. package/dist/types/manifest/index.d.ts +0 -1
  333. package/dist/types/manifest/manifest.d.ts +1 -1
  334. package/dist/types/manifest/node.d.ts +2 -0
  335. package/dist/types/manifest/validation.d.ts +5 -5
  336. package/dist/types/node.d.ts +8 -0
  337. package/dist/types/structs.d.ts +0 -20
  338. package/dist/types/ui.d.ts +7 -0
  339. package/dist/types/virtual-file/index.d.ts +0 -1
  340. package/dist/types/virtual-file/node.d.ts +2 -0
  341. package/dist/types.js +28 -0
  342. package/dist/types.js.map +1 -0
  343. package/dist/types.mjs +28 -0
  344. package/dist/types.mjs.map +1 -0
  345. package/dist/ui.js +12 -0
  346. package/dist/ui.js.map +1 -0
  347. package/dist/ui.mjs +12 -0
  348. package/dist/ui.mjs.map +1 -0
  349. package/dist/validation.js +24 -0
  350. package/dist/validation.js.map +1 -0
  351. package/dist/validation.mjs +24 -0
  352. package/dist/validation.mjs.map +1 -0
  353. package/dist/versions.js +12 -0
  354. package/dist/versions.js.map +1 -0
  355. package/dist/versions.mjs +12 -0
  356. package/dist/versions.mjs.map +1 -0
  357. package/dist/virtual-file/VirtualFile.js +9 -0
  358. package/dist/virtual-file/VirtualFile.js.map +1 -0
  359. package/dist/virtual-file/VirtualFile.mjs +9 -0
  360. package/dist/virtual-file/VirtualFile.mjs.map +1 -0
  361. package/dist/virtual-file/index.js +10 -0
  362. package/dist/virtual-file/index.js.map +1 -0
  363. package/dist/virtual-file/index.mjs +10 -0
  364. package/dist/virtual-file/index.mjs.map +1 -0
  365. package/dist/virtual-file/node.js +17 -0
  366. package/dist/virtual-file/node.js.map +1 -0
  367. package/dist/virtual-file/node.mjs +17 -0
  368. package/dist/virtual-file/node.mjs.map +1 -0
  369. package/dist/virtual-file/toVirtualFile.js +12 -0
  370. package/dist/virtual-file/toVirtualFile.js.map +1 -0
  371. package/dist/virtual-file/toVirtualFile.mjs +12 -0
  372. package/dist/virtual-file/toVirtualFile.mjs.map +1 -0
  373. package/package.json +23 -38
  374. package/dist/cjs/array.js +0 -23
  375. package/dist/cjs/array.js.map +0 -1
  376. package/dist/cjs/auxiliary-files.js +0 -27
  377. package/dist/cjs/auxiliary-files.js.map +0 -1
  378. package/dist/cjs/base64.js +0 -44
  379. package/dist/cjs/base64.js.map +0 -1
  380. package/dist/cjs/bytes.js +0 -23
  381. package/dist/cjs/bytes.js.map +0 -1
  382. package/dist/cjs/caveats.js +0 -48
  383. package/dist/cjs/caveats.js.map +0 -1
  384. package/dist/cjs/checksum.js +0 -43
  385. package/dist/cjs/checksum.js.map +0 -1
  386. package/dist/cjs/cronjob.js +0 -77
  387. package/dist/cjs/cronjob.js.map +0 -1
  388. package/dist/cjs/deep-clone.js +0 -22
  389. package/dist/cjs/deep-clone.js.map +0 -1
  390. package/dist/cjs/default-endowments.js +0 -49
  391. package/dist/cjs/default-endowments.js.map +0 -1
  392. package/dist/cjs/derivation-paths.js +0 -300
  393. package/dist/cjs/derivation-paths.js.map +0 -1
  394. package/dist/cjs/entropy.js +0 -23
  395. package/dist/cjs/entropy.js.map +0 -1
  396. package/dist/cjs/errors.js +0 -221
  397. package/dist/cjs/errors.js.map +0 -1
  398. package/dist/cjs/eval-worker.js +0 -44
  399. package/dist/cjs/eval-worker.js.map +0 -1
  400. package/dist/cjs/eval.js +0 -77
  401. package/dist/cjs/eval.js.map +0 -1
  402. package/dist/cjs/fs.js +0 -126
  403. package/dist/cjs/fs.js.map +0 -1
  404. package/dist/cjs/handler-types.js +0 -34
  405. package/dist/cjs/handler-types.js.map +0 -1
  406. package/dist/cjs/handlers.js +0 -173
  407. package/dist/cjs/handlers.js.map +0 -1
  408. package/dist/cjs/icon.js +0 -66
  409. package/dist/cjs/icon.js.map +0 -1
  410. package/dist/cjs/iframe.js +0 -59
  411. package/dist/cjs/iframe.js.map +0 -1
  412. package/dist/cjs/index.browser.js +0 -49
  413. package/dist/cjs/index.browser.js.map +0 -1
  414. package/dist/cjs/index.executionenv.js +0 -27
  415. package/dist/cjs/index.executionenv.js.map +0 -1
  416. package/dist/cjs/index.js +0 -54
  417. package/dist/cjs/index.js.map +0 -1
  418. package/dist/cjs/json-rpc.js +0 -81
  419. package/dist/cjs/json-rpc.js.map +0 -1
  420. package/dist/cjs/json.js +0 -16
  421. package/dist/cjs/json.js.map +0 -1
  422. package/dist/cjs/localization.js +0 -113
  423. package/dist/cjs/localization.js.map +0 -1
  424. package/dist/cjs/logging.js +0 -40
  425. package/dist/cjs/logging.js.map +0 -1
  426. package/dist/cjs/manifest/index.browser.js +0 -20
  427. package/dist/cjs/manifest/index.browser.js.map +0 -1
  428. package/dist/cjs/manifest/index.js +0 -21
  429. package/dist/cjs/manifest/index.js.map +0 -1
  430. package/dist/cjs/manifest/manifest.js +0 -283
  431. package/dist/cjs/manifest/manifest.js.map +0 -1
  432. package/dist/cjs/manifest/validation.js +0 -244
  433. package/dist/cjs/manifest/validation.js.map +0 -1
  434. package/dist/cjs/mock.js +0 -128
  435. package/dist/cjs/mock.js.map +0 -1
  436. package/dist/cjs/namespace.js +0 -136
  437. package/dist/cjs/namespace.js.map +0 -1
  438. package/dist/cjs/npm.js +0 -96
  439. package/dist/cjs/npm.js.map +0 -1
  440. package/dist/cjs/path.js +0 -21
  441. package/dist/cjs/path.js.map +0 -1
  442. package/dist/cjs/post-process.js +0 -328
  443. package/dist/cjs/post-process.js.map +0 -1
  444. package/dist/cjs/snaps.js +0 -232
  445. package/dist/cjs/snaps.js.map +0 -1
  446. package/dist/cjs/strings.js +0 -21
  447. package/dist/cjs/strings.js.map +0 -1
  448. package/dist/cjs/structs.js +0 -210
  449. package/dist/cjs/structs.js.map +0 -1
  450. package/dist/cjs/types.js +0 -104
  451. package/dist/cjs/types.js.map +0 -1
  452. package/dist/cjs/ui.js +0 -53
  453. package/dist/cjs/ui.js.map +0 -1
  454. package/dist/cjs/validation.js +0 -24
  455. package/dist/cjs/validation.js.map +0 -1
  456. package/dist/cjs/versions.js +0 -47
  457. package/dist/cjs/versions.js.map +0 -1
  458. package/dist/cjs/virtual-file/VirtualFile.js +0 -92
  459. package/dist/cjs/virtual-file/VirtualFile.js.map +0 -1
  460. package/dist/cjs/virtual-file/index.browser.js +0 -20
  461. package/dist/cjs/virtual-file/index.browser.js.map +0 -1
  462. package/dist/cjs/virtual-file/index.js +0 -21
  463. package/dist/cjs/virtual-file/index.js.map +0 -1
  464. package/dist/cjs/virtual-file/toVirtualFile.js +0 -33
  465. package/dist/cjs/virtual-file/toVirtualFile.js.map +0 -1
  466. package/dist/esm/array.js +0 -13
  467. package/dist/esm/array.js.map +0 -1
  468. package/dist/esm/auxiliary-files.js +0 -23
  469. package/dist/esm/auxiliary-files.js.map +0 -1
  470. package/dist/esm/base64.js +0 -36
  471. package/dist/esm/base64.js.map +0 -1
  472. package/dist/esm/bytes.js +0 -18
  473. package/dist/esm/bytes.js.map +0 -1
  474. package/dist/esm/caveats.js +0 -38
  475. package/dist/esm/caveats.js.map +0 -1
  476. package/dist/esm/checksum.js +0 -41
  477. package/dist/esm/checksum.js.map +0 -1
  478. package/dist/esm/cronjob.js +0 -59
  479. package/dist/esm/cronjob.js.map +0 -1
  480. package/dist/esm/deep-clone.js +0 -7
  481. package/dist/esm/deep-clone.js.map +0 -1
  482. package/dist/esm/default-endowments.js +0 -39
  483. package/dist/esm/default-endowments.js.map +0 -1
  484. package/dist/esm/derivation-paths.js +0 -287
  485. package/dist/esm/derivation-paths.js.map +0 -1
  486. package/dist/esm/entropy.js +0 -6
  487. package/dist/esm/entropy.js.map +0 -1
  488. package/dist/esm/errors.js +0 -211
  489. package/dist/esm/errors.js.map +0 -1
  490. package/dist/esm/eval-worker.js +0 -40
  491. package/dist/esm/eval-worker.js.map +0 -1
  492. package/dist/esm/eval.js +0 -65
  493. package/dist/esm/eval.js.map +0 -1
  494. package/dist/esm/fs.js +0 -136
  495. package/dist/esm/fs.js.map +0 -1
  496. package/dist/esm/handler-types.js +0 -16
  497. package/dist/esm/handler-types.js.map +0 -1
  498. package/dist/esm/handlers.js +0 -119
  499. package/dist/esm/handlers.js.map +0 -1
  500. package/dist/esm/icon.js +0 -51
  501. package/dist/esm/icon.js.map +0 -1
  502. package/dist/esm/iframe.js +0 -49
  503. package/dist/esm/iframe.js.map +0 -1
  504. package/dist/esm/index.browser.js +0 -32
  505. package/dist/esm/index.browser.js.map +0 -1
  506. package/dist/esm/index.executionenv.js +0 -10
  507. package/dist/esm/index.executionenv.js.map +0 -1
  508. package/dist/esm/index.js +0 -37
  509. package/dist/esm/index.js.map +0 -1
  510. package/dist/esm/json-rpc.js +0 -79
  511. package/dist/esm/json-rpc.js.map +0 -1
  512. package/dist/esm/json.js +0 -17
  513. package/dist/esm/json.js.map +0 -1
  514. package/dist/esm/localization.js +0 -115
  515. package/dist/esm/localization.js.map +0 -1
  516. package/dist/esm/logging.js +0 -59
  517. package/dist/esm/logging.js.map +0 -1
  518. package/dist/esm/manifest/index.browser.js +0 -3
  519. package/dist/esm/manifest/index.browser.js.map +0 -1
  520. package/dist/esm/manifest/index.js +0 -4
  521. package/dist/esm/manifest/index.js.map +0 -1
  522. package/dist/esm/manifest/manifest.js +0 -307
  523. package/dist/esm/manifest/manifest.js.map +0 -1
  524. package/dist/esm/manifest/validation.js +0 -190
  525. package/dist/esm/manifest/validation.js.map +0 -1
  526. package/dist/esm/mock.js +0 -111
  527. package/dist/esm/mock.js.map +0 -1
  528. package/dist/esm/namespace.js +0 -113
  529. package/dist/esm/namespace.js.map +0 -1
  530. package/dist/esm/npm.js +0 -85
  531. package/dist/esm/npm.js.map +0 -1
  532. package/dist/esm/path.js +0 -17
  533. package/dist/esm/path.js.map +0 -1
  534. package/dist/esm/post-process.js +0 -333
  535. package/dist/esm/post-process.js.map +0 -1
  536. package/dist/esm/snaps.js +0 -217
  537. package/dist/esm/snaps.js.map +0 -1
  538. package/dist/esm/strings.js +0 -11
  539. package/dist/esm/strings.js.map +0 -1
  540. package/dist/esm/structs.js +0 -295
  541. package/dist/esm/structs.js.map +0 -1
  542. package/dist/esm/types.js +0 -78
  543. package/dist/esm/types.js.map +0 -1
  544. package/dist/esm/ui.js +0 -50
  545. package/dist/esm/ui.js.map +0 -1
  546. package/dist/esm/validation.js +0 -19
  547. package/dist/esm/validation.js.map +0 -1
  548. package/dist/esm/versions.js +0 -41
  549. package/dist/esm/versions.js.map +0 -1
  550. package/dist/esm/virtual-file/VirtualFile.js +0 -82
  551. package/dist/esm/virtual-file/VirtualFile.js.map +0 -1
  552. package/dist/esm/virtual-file/index.browser.js +0 -3
  553. package/dist/esm/virtual-file/index.browser.js.map +0 -1
  554. package/dist/esm/virtual-file/index.js +0 -4
  555. package/dist/esm/virtual-file/index.js.map +0 -1
  556. package/dist/esm/virtual-file/toVirtualFile.js +0 -26
  557. package/dist/esm/virtual-file/toVirtualFile.js.map +0 -1
  558. package/dist/types/index.browser.d.ts +0 -30
  559. package/dist/types/manifest/index.browser.d.ts +0 -1
  560. package/dist/types/virtual-file/index.browser.d.ts +0 -1
@@ -1,173 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- SNAP_EXPORTS: function() {
13
- return SNAP_EXPORTS;
14
- },
15
- OnTransactionSeverityResponseStruct: function() {
16
- return OnTransactionSeverityResponseStruct;
17
- },
18
- OnTransactionResponseWithIdStruct: function() {
19
- return OnTransactionResponseWithIdStruct;
20
- },
21
- OnTransactionResponseWithContentStruct: function() {
22
- return OnTransactionResponseWithContentStruct;
23
- },
24
- OnTransactionResponseStruct: function() {
25
- return OnTransactionResponseStruct;
26
- },
27
- OnSignatureResponseStruct: function() {
28
- return OnSignatureResponseStruct;
29
- },
30
- OnHomePageResponseWithContentStruct: function() {
31
- return OnHomePageResponseWithContentStruct;
32
- },
33
- OnHomePageResponseWithIdStruct: function() {
34
- return OnHomePageResponseWithIdStruct;
35
- },
36
- OnHomePageResponseStruct: function() {
37
- return OnHomePageResponseStruct;
38
- },
39
- AddressResolutionStruct: function() {
40
- return AddressResolutionStruct;
41
- },
42
- DomainResolutionStruct: function() {
43
- return DomainResolutionStruct;
44
- },
45
- AddressResolutionResponseStruct: function() {
46
- return AddressResolutionResponseStruct;
47
- },
48
- DomainResolutionResponseStruct: function() {
49
- return DomainResolutionResponseStruct;
50
- },
51
- OnNameLookupResponseStruct: function() {
52
- return OnNameLookupResponseStruct;
53
- }
54
- });
55
- const _snapssdk = require("@metamask/snaps-sdk");
56
- const _superstruct = require("superstruct");
57
- const _handlertypes = require("./handler-types");
58
- const SNAP_EXPORTS = {
59
- [_handlertypes.HandlerType.OnRpcRequest]: {
60
- type: _handlertypes.HandlerType.OnRpcRequest,
61
- required: true,
62
- validator: (snapExport)=>{
63
- return typeof snapExport === 'function';
64
- }
65
- },
66
- [_handlertypes.HandlerType.OnTransaction]: {
67
- type: _handlertypes.HandlerType.OnTransaction,
68
- required: true,
69
- validator: (snapExport)=>{
70
- return typeof snapExport === 'function';
71
- }
72
- },
73
- [_handlertypes.HandlerType.OnCronjob]: {
74
- type: _handlertypes.HandlerType.OnCronjob,
75
- required: true,
76
- validator: (snapExport)=>{
77
- return typeof snapExport === 'function';
78
- }
79
- },
80
- [_handlertypes.HandlerType.OnNameLookup]: {
81
- type: _handlertypes.HandlerType.OnNameLookup,
82
- required: true,
83
- validator: (snapExport)=>{
84
- return typeof snapExport === 'function';
85
- }
86
- },
87
- [_handlertypes.HandlerType.OnInstall]: {
88
- type: _handlertypes.HandlerType.OnInstall,
89
- required: false,
90
- validator: (snapExport)=>{
91
- return typeof snapExport === 'function';
92
- }
93
- },
94
- [_handlertypes.HandlerType.OnUpdate]: {
95
- type: _handlertypes.HandlerType.OnUpdate,
96
- required: false,
97
- validator: (snapExport)=>{
98
- return typeof snapExport === 'function';
99
- }
100
- },
101
- [_handlertypes.HandlerType.OnKeyringRequest]: {
102
- type: _handlertypes.HandlerType.OnKeyringRequest,
103
- required: true,
104
- validator: (snapExport)=>{
105
- return typeof snapExport === 'function';
106
- }
107
- },
108
- [_handlertypes.HandlerType.OnHomePage]: {
109
- type: _handlertypes.HandlerType.OnHomePage,
110
- required: true,
111
- validator: (snapExport)=>{
112
- return typeof snapExport === 'function';
113
- }
114
- },
115
- [_handlertypes.HandlerType.OnSignature]: {
116
- type: _handlertypes.HandlerType.OnSignature,
117
- required: true,
118
- validator: (snapExport)=>{
119
- return typeof snapExport === 'function';
120
- }
121
- },
122
- [_handlertypes.HandlerType.OnUserInput]: {
123
- type: _handlertypes.HandlerType.OnUserInput,
124
- required: true,
125
- validator: (snapExport)=>{
126
- return typeof snapExport === 'function';
127
- }
128
- }
129
- };
130
- const OnTransactionSeverityResponseStruct = (0, _superstruct.object)({
131
- severity: (0, _superstruct.optional)((0, _superstruct.literal)(_snapssdk.SeverityLevel.Critical))
132
- });
133
- const OnTransactionResponseWithIdStruct = (0, _superstruct.assign)(OnTransactionSeverityResponseStruct, (0, _superstruct.object)({
134
- id: (0, _superstruct.string)()
135
- }));
136
- const OnTransactionResponseWithContentStruct = (0, _superstruct.assign)(OnTransactionSeverityResponseStruct, (0, _superstruct.object)({
137
- content: _snapssdk.ComponentStruct
138
- }));
139
- const OnTransactionResponseStruct = (0, _superstruct.nullable)((0, _superstruct.union)([
140
- OnTransactionResponseWithContentStruct,
141
- OnTransactionResponseWithIdStruct
142
- ]));
143
- const OnSignatureResponseStruct = OnTransactionResponseStruct;
144
- const OnHomePageResponseWithContentStruct = (0, _superstruct.object)({
145
- content: _snapssdk.ComponentStruct
146
- });
147
- const OnHomePageResponseWithIdStruct = (0, _superstruct.object)({
148
- id: (0, _superstruct.string)()
149
- });
150
- const OnHomePageResponseStruct = (0, _superstruct.union)([
151
- OnHomePageResponseWithContentStruct,
152
- OnHomePageResponseWithIdStruct
153
- ]);
154
- const AddressResolutionStruct = (0, _superstruct.object)({
155
- protocol: (0, _superstruct.string)(),
156
- resolvedDomain: (0, _superstruct.string)()
157
- });
158
- const DomainResolutionStruct = (0, _superstruct.object)({
159
- protocol: (0, _superstruct.string)(),
160
- resolvedAddress: (0, _superstruct.string)()
161
- });
162
- const AddressResolutionResponseStruct = (0, _superstruct.object)({
163
- resolvedDomains: (0, _superstruct.size)((0, _superstruct.array)(AddressResolutionStruct), 1, Infinity)
164
- });
165
- const DomainResolutionResponseStruct = (0, _superstruct.object)({
166
- resolvedAddresses: (0, _superstruct.size)((0, _superstruct.array)(DomainResolutionStruct), 1, Infinity)
167
- });
168
- const OnNameLookupResponseStruct = (0, _superstruct.nullable)((0, _superstruct.union)([
169
- AddressResolutionResponseStruct,
170
- DomainResolutionResponseStruct
171
- ]));
172
-
173
- //# sourceMappingURL=handlers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/handlers.ts"],"sourcesContent":["import type {\n OnCronjobHandler,\n OnHomePageHandler,\n OnInstallHandler,\n OnKeyringRequestHandler,\n OnNameLookupHandler,\n OnRpcRequestHandler,\n OnSignatureHandler,\n OnTransactionHandler,\n OnUpdateHandler,\n OnUserInputHandler,\n} from '@metamask/snaps-sdk';\nimport { SeverityLevel, ComponentStruct } from '@metamask/snaps-sdk';\nimport {\n assign,\n literal,\n nullable,\n object,\n optional,\n string,\n array,\n size,\n union,\n} from 'superstruct';\n\nimport type { SnapHandler } from './handler-types';\nimport { HandlerType } from './handler-types';\n\nexport type SnapRpcHookArgs = {\n origin: string;\n handler: HandlerType;\n request: Record<string, unknown>;\n};\n\nexport const SNAP_EXPORTS = {\n [HandlerType.OnRpcRequest]: {\n type: HandlerType.OnRpcRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnRpcRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnTransaction]: {\n type: HandlerType.OnTransaction,\n required: true,\n validator: (snapExport: unknown): snapExport is OnTransactionHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnCronjob]: {\n type: HandlerType.OnCronjob,\n required: true,\n validator: (snapExport: unknown): snapExport is OnCronjobHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnNameLookup]: {\n type: HandlerType.OnNameLookup,\n required: true,\n validator: (snapExport: unknown): snapExport is OnNameLookupHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnInstall]: {\n type: HandlerType.OnInstall,\n required: false,\n validator: (snapExport: unknown): snapExport is OnInstallHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUpdate]: {\n type: HandlerType.OnUpdate,\n required: false,\n validator: (snapExport: unknown): snapExport is OnUpdateHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnKeyringRequest]: {\n type: HandlerType.OnKeyringRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnKeyringRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnHomePage]: {\n type: HandlerType.OnHomePage,\n required: true,\n validator: (snapExport: unknown): snapExport is OnHomePageHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnSignature]: {\n type: HandlerType.OnSignature,\n required: true,\n validator: (snapExport: unknown): snapExport is OnSignatureHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUserInput]: {\n type: HandlerType.OnUserInput,\n required: true,\n validator: (snapExport: unknown): snapExport is OnUserInputHandler => {\n return typeof snapExport === 'function';\n },\n },\n} as const;\n\nexport const OnTransactionSeverityResponseStruct = object({\n severity: optional(literal(SeverityLevel.Critical)),\n});\n\nexport const OnTransactionResponseWithIdStruct = assign(\n OnTransactionSeverityResponseStruct,\n object({\n id: string(),\n }),\n);\n\nexport const OnTransactionResponseWithContentStruct = assign(\n OnTransactionSeverityResponseStruct,\n object({\n content: ComponentStruct,\n }),\n);\n\nexport const OnTransactionResponseStruct = nullable(\n union([\n OnTransactionResponseWithContentStruct,\n OnTransactionResponseWithIdStruct,\n ]),\n);\n\nexport const OnSignatureResponseStruct = OnTransactionResponseStruct;\n\nexport const OnHomePageResponseWithContentStruct = object({\n content: ComponentStruct,\n});\n\nexport const OnHomePageResponseWithIdStruct = object({\n id: string(),\n});\n\nexport const OnHomePageResponseStruct = union([\n OnHomePageResponseWithContentStruct,\n OnHomePageResponseWithIdStruct,\n]);\n\nexport const AddressResolutionStruct = object({\n protocol: string(),\n resolvedDomain: string(),\n});\n\nexport const DomainResolutionStruct = object({\n protocol: string(),\n resolvedAddress: string(),\n});\n\nexport const AddressResolutionResponseStruct = object({\n resolvedDomains: size(array(AddressResolutionStruct), 1, Infinity),\n});\n\nexport const DomainResolutionResponseStruct = object({\n resolvedAddresses: size(array(DomainResolutionStruct), 1, Infinity),\n});\n\nexport const OnNameLookupResponseStruct = nullable(\n union([AddressResolutionResponseStruct, DomainResolutionResponseStruct]),\n);\n\n/**\n * Utility type for getting the handler function type from a handler type.\n */\nexport type HandlerFunction<Type extends SnapHandler> =\n Type['validator'] extends (snapExport: unknown) => snapExport is infer Handler\n ? Handler\n : never;\n\n/**\n * All the function-based handlers that a snap can implement.\n */\nexport type SnapFunctionExports = {\n [Key in keyof typeof SNAP_EXPORTS]?: HandlerFunction<\n (typeof SNAP_EXPORTS)[Key]\n >;\n};\n\n/**\n * All handlers that a snap can implement.\n */\nexport type SnapExports = SnapFunctionExports;\n"],"names":["SNAP_EXPORTS","OnTransactionSeverityResponseStruct","OnTransactionResponseWithIdStruct","OnTransactionResponseWithContentStruct","OnTransactionResponseStruct","OnSignatureResponseStruct","OnHomePageResponseWithContentStruct","OnHomePageResponseWithIdStruct","OnHomePageResponseStruct","AddressResolutionStruct","DomainResolutionStruct","AddressResolutionResponseStruct","DomainResolutionResponseStruct","OnNameLookupResponseStruct","HandlerType","OnRpcRequest","type","required","validator","snapExport","OnTransaction","OnCronjob","OnNameLookup","OnInstall","OnUpdate","OnKeyringRequest","OnHomePage","OnSignature","OnUserInput","object","severity","optional","literal","SeverityLevel","Critical","assign","id","string","content","ComponentStruct","nullable","union","protocol","resolvedDomain","resolvedAddress","resolvedDomains","size","array","Infinity","resolvedAddresses"],"mappings":";;;;;;;;;;;IAkCaA,YAAY;eAAZA;;IAyEAC,mCAAmC;eAAnCA;;IAIAC,iCAAiC;eAAjCA;;IAOAC,sCAAsC;eAAtCA;;IAOAC,2BAA2B;eAA3BA;;IAOAC,yBAAyB;eAAzBA;;IAEAC,mCAAmC;eAAnCA;;IAIAC,8BAA8B;eAA9BA;;IAIAC,wBAAwB;eAAxBA;;IAKAC,uBAAuB;eAAvBA;;IAKAC,sBAAsB;eAAtBA;;IAKAC,+BAA+B;eAA/BA;;IAIAC,8BAA8B;eAA9BA;;IAIAC,0BAA0B;eAA1BA;;;0BAzJkC;6BAWxC;8BAGqB;AAQrB,MAAMb,eAAe;IAC1B,CAACc,yBAAW,CAACC,YAAY,CAAC,EAAE;QAC1BC,MAAMF,yBAAW,CAACC,YAAY;QAC9BE,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACL,yBAAW,CAACM,aAAa,CAAC,EAAE;QAC3BJ,MAAMF,yBAAW,CAACM,aAAa;QAC/BH,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACL,yBAAW,CAACO,SAAS,CAAC,EAAE;QACvBL,MAAMF,yBAAW,CAACO,SAAS;QAC3BJ,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACL,yBAAW,CAACQ,YAAY,CAAC,EAAE;QAC1BN,MAAMF,yBAAW,CAACQ,YAAY;QAC9BL,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACL,yBAAW,CAACS,SAAS,CAAC,EAAE;QACvBP,MAAMF,yBAAW,CAACS,SAAS;QAC3BN,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACL,yBAAW,CAACU,QAAQ,CAAC,EAAE;QACtBR,MAAMF,yBAAW,CAACU,QAAQ;QAC1BP,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACL,yBAAW,CAACW,gBAAgB,CAAC,EAAE;QAC9BT,MAAMF,yBAAW,CAACW,gBAAgB;QAClCR,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACL,yBAAW,CAACY,UAAU,CAAC,EAAE;QACxBV,MAAMF,yBAAW,CAACY,UAAU;QAC5BT,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACL,yBAAW,CAACa,WAAW,CAAC,EAAE;QACzBX,MAAMF,yBAAW,CAACa,WAAW;QAC7BV,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACL,yBAAW,CAACc,WAAW,CAAC,EAAE;QACzBZ,MAAMF,yBAAW,CAACc,WAAW;QAC7BX,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;AACF;AAEO,MAAMlB,sCAAsC4B,IAAAA,mBAAM,EAAC;IACxDC,UAAUC,IAAAA,qBAAQ,EAACC,IAAAA,oBAAO,EAACC,uBAAa,CAACC,QAAQ;AACnD;AAEO,MAAMhC,oCAAoCiC,IAAAA,mBAAM,EACrDlC,qCACA4B,IAAAA,mBAAM,EAAC;IACLO,IAAIC,IAAAA,mBAAM;AACZ;AAGK,MAAMlC,yCAAyCgC,IAAAA,mBAAM,EAC1DlC,qCACA4B,IAAAA,mBAAM,EAAC;IACLS,SAASC,yBAAe;AAC1B;AAGK,MAAMnC,8BAA8BoC,IAAAA,qBAAQ,EACjDC,IAAAA,kBAAK,EAAC;IACJtC;IACAD;CACD;AAGI,MAAMG,4BAA4BD;AAElC,MAAME,sCAAsCuB,IAAAA,mBAAM,EAAC;IACxDS,SAASC,yBAAe;AAC1B;AAEO,MAAMhC,iCAAiCsB,IAAAA,mBAAM,EAAC;IACnDO,IAAIC,IAAAA,mBAAM;AACZ;AAEO,MAAM7B,2BAA2BiC,IAAAA,kBAAK,EAAC;IAC5CnC;IACAC;CACD;AAEM,MAAME,0BAA0BoB,IAAAA,mBAAM,EAAC;IAC5Ca,UAAUL,IAAAA,mBAAM;IAChBM,gBAAgBN,IAAAA,mBAAM;AACxB;AAEO,MAAM3B,yBAAyBmB,IAAAA,mBAAM,EAAC;IAC3Ca,UAAUL,IAAAA,mBAAM;IAChBO,iBAAiBP,IAAAA,mBAAM;AACzB;AAEO,MAAM1B,kCAAkCkB,IAAAA,mBAAM,EAAC;IACpDgB,iBAAiBC,IAAAA,iBAAI,EAACC,IAAAA,kBAAK,EAACtC,0BAA0B,GAAGuC;AAC3D;AAEO,MAAMpC,iCAAiCiB,IAAAA,mBAAM,EAAC;IACnDoB,mBAAmBH,IAAAA,iBAAI,EAACC,IAAAA,kBAAK,EAACrC,yBAAyB,GAAGsC;AAC5D;AAEO,MAAMnC,6BAA6B2B,IAAAA,qBAAQ,EAChDC,IAAAA,kBAAK,EAAC;IAAC9B;IAAiCC;CAA+B"}
package/dist/cjs/icon.js DELETED
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- SVG_MAX_BYTE_SIZE: function() {
13
- return SVG_MAX_BYTE_SIZE;
14
- },
15
- SVG_MAX_BYTE_SIZE_TEXT: function() {
16
- return SVG_MAX_BYTE_SIZE_TEXT;
17
- },
18
- assertIsSnapIcon: function() {
19
- return assertIsSnapIcon;
20
- },
21
- getSvgDimensions: function() {
22
- return getSvgDimensions;
23
- }
24
- });
25
- const _snapssdk = require("@metamask/snaps-sdk");
26
- const _utils = require("@metamask/utils");
27
- const SVG_MAX_BYTE_SIZE = 100000;
28
- const SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(SVG_MAX_BYTE_SIZE / 1000)}kb`;
29
- function assertIsSnapIcon(icon) {
30
- (0, _utils.assert)(icon.path.endsWith('.svg'), 'Expected snap icon to end in ".svg".');
31
- (0, _utils.assert)(Buffer.byteLength(icon.value, 'utf8') <= SVG_MAX_BYTE_SIZE, `The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`);
32
- (0, _utils.assert)((0, _snapssdk.isSvg)(icon.toString()), 'Snap icon must be a valid SVG.');
33
- }
34
- function getSvgDimensions(svg) {
35
- try {
36
- const parsed = (0, _snapssdk.parseSvg)(svg);
37
- const height = parsed['@_height'];
38
- const width = parsed['@_width'];
39
- if (height && width) {
40
- return {
41
- height,
42
- width
43
- };
44
- }
45
- const viewBox = parsed['@_viewBox'];
46
- if (viewBox) {
47
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
- const [_minX, _minY, viewBoxWidth, viewBoxHeight] = viewBox.split(' ');
49
- if (viewBoxWidth && viewBoxHeight) {
50
- const parsedWidth = parseInt(viewBoxWidth, 10);
51
- const parsedHeight = parseInt(viewBoxHeight, 10);
52
- (0, _utils.assert)(Number.isInteger(parsedWidth) && parsedWidth > 0);
53
- (0, _utils.assert)(Number.isInteger(parsedHeight) && parsedHeight > 0);
54
- return {
55
- width: parsedWidth,
56
- height: parsedHeight
57
- };
58
- }
59
- }
60
- } catch {
61
- throw new Error('Snap icon must be a valid SVG.');
62
- }
63
- return null;
64
- }
65
-
66
- //# sourceMappingURL=icon.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/icon.ts"],"sourcesContent":["import { isSvg, parseSvg } from '@metamask/snaps-sdk';\nimport { assert } from '@metamask/utils';\n\nimport type { VirtualFile } from './virtual-file';\n\nexport const SVG_MAX_BYTE_SIZE = 100_000;\nexport const SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(\n SVG_MAX_BYTE_SIZE / 1000,\n)}kb`;\n\n/**\n * Assert that a virtual file containing a Snap icon is valid.\n *\n * @param icon - A virtual file containing a Snap icon.\n */\nexport function assertIsSnapIcon(icon: VirtualFile) {\n assert(icon.path.endsWith('.svg'), 'Expected snap icon to end in \".svg\".');\n\n assert(\n Buffer.byteLength(icon.value, 'utf8') <= SVG_MAX_BYTE_SIZE,\n `The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`,\n );\n\n assert(isSvg(icon.toString()), 'Snap icon must be a valid SVG.');\n}\n\n/**\n * Extract the dimensions of an image from an SVG string if possible.\n *\n * @param svg - An SVG string.\n * @returns The height and width of the SVG or null.\n */\nexport function getSvgDimensions(svg: string): {\n height: number;\n width: number;\n} | null {\n try {\n const parsed = parseSvg(svg);\n\n const height = parsed['@_height'];\n const width = parsed['@_width'];\n\n if (height && width) {\n return { height, width };\n }\n\n const viewBox = parsed['@_viewBox'];\n if (viewBox) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_minX, _minY, viewBoxWidth, viewBoxHeight] = viewBox.split(' ');\n\n if (viewBoxWidth && viewBoxHeight) {\n const parsedWidth = parseInt(viewBoxWidth, 10);\n const parsedHeight = parseInt(viewBoxHeight, 10);\n\n assert(Number.isInteger(parsedWidth) && parsedWidth > 0);\n assert(Number.isInteger(parsedHeight) && parsedHeight > 0);\n\n return {\n width: parsedWidth,\n height: parsedHeight,\n };\n }\n }\n } catch {\n throw new Error('Snap icon must be a valid SVG.');\n }\n\n return null;\n}\n"],"names":["SVG_MAX_BYTE_SIZE","SVG_MAX_BYTE_SIZE_TEXT","assertIsSnapIcon","getSvgDimensions","Math","floor","icon","assert","path","endsWith","Buffer","byteLength","value","isSvg","toString","svg","parsed","parseSvg","height","width","viewBox","_minX","_minY","viewBoxWidth","viewBoxHeight","split","parsedWidth","parseInt","parsedHeight","Number","isInteger","Error"],"mappings":";;;;;;;;;;;IAKaA,iBAAiB;eAAjBA;;IACAC,sBAAsB;eAAtBA;;IASGC,gBAAgB;eAAhBA;;IAiBAC,gBAAgB;eAAhBA;;;0BAhCgB;uBACT;AAIhB,MAAMH,oBAAoB;AAC1B,MAAMC,yBAAyB,CAAC,EAAEG,KAAKC,KAAK,CACjDL,oBAAoB,MACpB,EAAE,CAAC;AAOE,SAASE,iBAAiBI,IAAiB;IAChDC,IAAAA,aAAM,EAACD,KAAKE,IAAI,CAACC,QAAQ,CAAC,SAAS;IAEnCF,IAAAA,aAAM,EACJG,OAAOC,UAAU,CAACL,KAAKM,KAAK,EAAE,WAAWZ,mBACzC,CAAC,mDAAmD,EAAEC,uBAAuB,CAAC,CAAC;IAGjFM,IAAAA,aAAM,EAACM,IAAAA,eAAK,EAACP,KAAKQ,QAAQ,KAAK;AACjC;AAQO,SAASX,iBAAiBY,GAAW;IAI1C,IAAI;QACF,MAAMC,SAASC,IAAAA,kBAAQ,EAACF;QAExB,MAAMG,SAASF,MAAM,CAAC,WAAW;QACjC,MAAMG,QAAQH,MAAM,CAAC,UAAU;QAE/B,IAAIE,UAAUC,OAAO;YACnB,OAAO;gBAAED;gBAAQC;YAAM;QACzB;QAEA,MAAMC,UAAUJ,MAAM,CAAC,YAAY;QACnC,IAAII,SAAS;YACX,6DAA6D;YAC7D,MAAM,CAACC,OAAOC,OAAOC,cAAcC,cAAc,GAAGJ,QAAQK,KAAK,CAAC;YAElE,IAAIF,gBAAgBC,eAAe;gBACjC,MAAME,cAAcC,SAASJ,cAAc;gBAC3C,MAAMK,eAAeD,SAASH,eAAe;gBAE7CjB,IAAAA,aAAM,EAACsB,OAAOC,SAAS,CAACJ,gBAAgBA,cAAc;gBACtDnB,IAAAA,aAAM,EAACsB,OAAOC,SAAS,CAACF,iBAAiBA,eAAe;gBAExD,OAAO;oBACLT,OAAOO;oBACPR,QAAQU;gBACV;YACF;QACF;IACF,EAAE,OAAM;QACN,MAAM,IAAIG,MAAM;IAClB;IAEA,OAAO;AACT"}
@@ -1,59 +0,0 @@
1
- /**
2
- * Creates the iframe to be used as the execution environment. This may run
3
- * forever if the iframe never loads, but the promise should be wrapped in
4
- * an initialization timeout in the SnapController.
5
- *
6
- * @param uri - The iframe URI.
7
- * @param id - The ID to assign to the iframe.
8
- * @param sandbox - Whether to enable the sandbox attribute.
9
- * @returns A promise that resolves to the contentWindow of the iframe.
10
- */ "use strict";
11
- Object.defineProperty(exports, "__esModule", {
12
- value: true
13
- });
14
- Object.defineProperty(exports, "createWindow", {
15
- enumerable: true,
16
- get: function() {
17
- return createWindow;
18
- }
19
- });
20
- async function createWindow(uri, id, sandbox = true) {
21
- return await new Promise((resolve, reject)=>{
22
- const iframe = document.createElement('iframe');
23
- // The order of operations appears to matter for everything except this
24
- // attribute. We may as well set it here.
25
- iframe.setAttribute('id', id);
26
- iframe.setAttribute('data-testid', 'snaps-iframe');
27
- if (sandbox) {
28
- // For the sandbox property to have any effect it needs to be set before the iframe is appended.
29
- // We apply this property as a principle of least authority (POLA)
30
- // measure.
31
- // Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox
32
- iframe.setAttribute('sandbox', 'allow-scripts');
33
- }
34
- // In the past, we've had problems that appear to be symptomatic of the
35
- // iframe firing the `load` event before its scripts are actually loaded,
36
- // which has prevented snaps from executing properly. Therefore, we set
37
- // the `src` attribute and append the iframe to the DOM before attaching
38
- // the `load` listener.
39
- //
40
- // `load` should only fire when "all dependent resources" have been
41
- // loaded, which includes scripts.
42
- //
43
- // MDN article for `load` event: https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
44
- // Re: `load` firing twice: https://stackoverflow.com/questions/10781880/dynamically-created-iframe-triggers-onload-event-twice/15880489#15880489
45
- iframe.setAttribute('src', uri);
46
- document.body.appendChild(iframe);
47
- iframe.addEventListener('load', ()=>{
48
- if (iframe.contentWindow) {
49
- resolve(iframe.contentWindow);
50
- } else {
51
- // We don't know of a case when this would happen, but better to fail
52
- // fast if it does.
53
- reject(new Error(`iframe.contentWindow not present on load for job "${id}".`));
54
- }
55
- });
56
- });
57
- }
58
-
59
- //# sourceMappingURL=iframe.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/iframe.ts"],"sourcesContent":["/**\n * Creates the iframe to be used as the execution environment. This may run\n * forever if the iframe never loads, but the promise should be wrapped in\n * an initialization timeout in the SnapController.\n *\n * @param uri - The iframe URI.\n * @param id - The ID to assign to the iframe.\n * @param sandbox - Whether to enable the sandbox attribute.\n * @returns A promise that resolves to the contentWindow of the iframe.\n */\nexport async function createWindow(\n uri: string,\n id: string,\n sandbox = true,\n): Promise<Window> {\n return await new Promise((resolve, reject) => {\n const iframe = document.createElement('iframe');\n // The order of operations appears to matter for everything except this\n // attribute. We may as well set it here.\n iframe.setAttribute('id', id);\n iframe.setAttribute('data-testid', 'snaps-iframe');\n\n if (sandbox) {\n // For the sandbox property to have any effect it needs to be set before the iframe is appended.\n // We apply this property as a principle of least authority (POLA)\n // measure.\n // Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox\n iframe.setAttribute('sandbox', 'allow-scripts');\n }\n\n // In the past, we've had problems that appear to be symptomatic of the\n // iframe firing the `load` event before its scripts are actually loaded,\n // which has prevented snaps from executing properly. Therefore, we set\n // the `src` attribute and append the iframe to the DOM before attaching\n // the `load` listener.\n //\n // `load` should only fire when \"all dependent resources\" have been\n // loaded, which includes scripts.\n //\n // MDN article for `load` event: https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event\n // Re: `load` firing twice: https://stackoverflow.com/questions/10781880/dynamically-created-iframe-triggers-onload-event-twice/15880489#15880489\n iframe.setAttribute('src', uri);\n document.body.appendChild(iframe);\n\n iframe.addEventListener('load', () => {\n if (iframe.contentWindow) {\n resolve(iframe.contentWindow);\n } else {\n // We don't know of a case when this would happen, but better to fail\n // fast if it does.\n reject(\n new Error(\n `iframe.contentWindow not present on load for job \"${id}\".`,\n ),\n );\n }\n });\n });\n}\n"],"names":["createWindow","uri","id","sandbox","Promise","resolve","reject","iframe","document","createElement","setAttribute","body","appendChild","addEventListener","contentWindow","Error"],"mappings":"AAAA;;;;;;;;;CASC;;;;+BACqBA;;;eAAAA;;;AAAf,eAAeA,aACpBC,GAAW,EACXC,EAAU,EACVC,UAAU,IAAI;IAEd,OAAO,MAAM,IAAIC,QAAQ,CAACC,SAASC;QACjC,MAAMC,SAASC,SAASC,aAAa,CAAC;QACtC,uEAAuE;QACvE,yCAAyC;QACzCF,OAAOG,YAAY,CAAC,MAAMR;QAC1BK,OAAOG,YAAY,CAAC,eAAe;QAEnC,IAAIP,SAAS;YACX,gGAAgG;YAChG,kEAAkE;YAClE,WAAW;YACX,qFAAqF;YACrFI,OAAOG,YAAY,CAAC,WAAW;QACjC;QAEA,uEAAuE;QACvE,yEAAyE;QACzE,uEAAuE;QACvE,wEAAwE;QACxE,uBAAuB;QACvB,EAAE;QACF,mEAAmE;QACnE,kCAAkC;QAClC,EAAE;QACF,mGAAmG;QACnG,iJAAiJ;QACjJH,OAAOG,YAAY,CAAC,OAAOT;QAC3BO,SAASG,IAAI,CAACC,WAAW,CAACL;QAE1BA,OAAOM,gBAAgB,CAAC,QAAQ;YAC9B,IAAIN,OAAOO,aAAa,EAAE;gBACxBT,QAAQE,OAAOO,aAAa;YAC9B,OAAO;gBACL,qEAAqE;gBACrE,mBAAmB;gBACnBR,OACE,IAAIS,MACF,CAAC,kDAAkD,EAAEb,GAAG,EAAE,CAAC;YAGjE;QACF;IACF;AACF"}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./array"), exports);
6
- _export_star(require("./auxiliary-files"), exports);
7
- _export_star(require("./base64"), exports);
8
- _export_star(require("./bytes"), exports);
9
- _export_star(require("./caveats"), exports);
10
- _export_star(require("./checksum"), exports);
11
- _export_star(require("./cronjob"), exports);
12
- _export_star(require("./deep-clone"), exports);
13
- _export_star(require("./default-endowments"), exports);
14
- _export_star(require("./derivation-paths"), exports);
15
- _export_star(require("./entropy"), exports);
16
- _export_star(require("./errors"), exports);
17
- _export_star(require("./handlers"), exports);
18
- _export_star(require("./handler-types"), exports);
19
- _export_star(require("./iframe"), exports);
20
- _export_star(require("./json"), exports);
21
- _export_star(require("./json-rpc"), exports);
22
- _export_star(require("./localization"), exports);
23
- _export_star(require("./logging"), exports);
24
- _export_star(require("./manifest/index.browser"), exports);
25
- _export_star(require("./namespace"), exports);
26
- _export_star(require("./path"), exports);
27
- _export_star(require("./snaps"), exports);
28
- _export_star(require("./strings"), exports);
29
- _export_star(require("./structs"), exports);
30
- _export_star(require("./types"), exports);
31
- _export_star(require("./ui"), exports);
32
- _export_star(require("./validation"), exports);
33
- _export_star(require("./versions"), exports);
34
- _export_star(require("./virtual-file/index.browser"), exports);
35
- function _export_star(from, to) {
36
- Object.keys(from).forEach(function(k) {
37
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
38
- Object.defineProperty(to, k, {
39
- enumerable: true,
40
- get: function() {
41
- return from[k];
42
- }
43
- });
44
- }
45
- });
46
- return from;
47
- }
48
-
49
- //# sourceMappingURL=index.browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caveats';\nexport * from './checksum';\nexport * from './cronjob';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './derivation-paths';\nexport * from './entropy';\nexport * from './errors';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './localization';\nexport * from './logging';\nexport * from './manifest/index.browser';\nexport * from './namespace';\nexport * from './path';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './ui';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file/index.browser';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
@@ -1,27 +0,0 @@
1
- // Special entrypoint for execution environments for bundle sizing reasons
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- _export_star(require("./errors"), exports);
7
- _export_star(require("./handlers"), exports);
8
- _export_star(require("./handler-types"), exports);
9
- _export_star(require("./iframe"), exports);
10
- _export_star(require("./logging"), exports);
11
- _export_star(require("./namespace"), exports);
12
- _export_star(require("./types"), exports);
13
- function _export_star(from, to) {
14
- Object.keys(from).forEach(function(k) {
15
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
16
- Object.defineProperty(to, k, {
17
- enumerable: true,
18
- get: function() {
19
- return from[k];
20
- }
21
- });
22
- }
23
- });
24
- return from;
25
- }
26
-
27
- //# sourceMappingURL=index.executionenv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.executionenv.ts"],"sourcesContent":["// Special entrypoint for execution environments for bundle sizing reasons\nexport * from './errors';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './logging';\nexport * from './namespace';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,0EAA0E;;;;;qBAC5D;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
package/dist/cjs/index.js DELETED
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./array"), exports);
6
- _export_star(require("./auxiliary-files"), exports);
7
- _export_star(require("./base64"), exports);
8
- _export_star(require("./bytes"), exports);
9
- _export_star(require("./caveats"), exports);
10
- _export_star(require("./cronjob"), exports);
11
- _export_star(require("./checksum"), exports);
12
- _export_star(require("./deep-clone"), exports);
13
- _export_star(require("./default-endowments"), exports);
14
- _export_star(require("./derivation-paths"), exports);
15
- _export_star(require("./entropy"), exports);
16
- _export_star(require("./eval"), exports);
17
- _export_star(require("./errors"), exports);
18
- _export_star(require("./fs"), exports);
19
- _export_star(require("./handlers"), exports);
20
- _export_star(require("./handler-types"), exports);
21
- _export_star(require("./iframe"), exports);
22
- _export_star(require("./json"), exports);
23
- _export_star(require("./json-rpc"), exports);
24
- _export_star(require("./localization"), exports);
25
- _export_star(require("./logging"), exports);
26
- _export_star(require("./manifest"), exports);
27
- _export_star(require("./mock"), exports);
28
- _export_star(require("./namespace"), exports);
29
- _export_star(require("./npm"), exports);
30
- _export_star(require("./path"), exports);
31
- _export_star(require("./post-process"), exports);
32
- _export_star(require("./snaps"), exports);
33
- _export_star(require("./strings"), exports);
34
- _export_star(require("./structs"), exports);
35
- _export_star(require("./types"), exports);
36
- _export_star(require("./ui"), exports);
37
- _export_star(require("./validation"), exports);
38
- _export_star(require("./versions"), exports);
39
- _export_star(require("./virtual-file"), exports);
40
- function _export_star(from, to) {
41
- Object.keys(from).forEach(function(k) {
42
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
43
- Object.defineProperty(to, k, {
44
- enumerable: true,
45
- get: function() {
46
- return from[k];
47
- }
48
- });
49
- }
50
- });
51
- return from;
52
- }
53
-
54
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caveats';\nexport * from './cronjob';\nexport * from './checksum';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './derivation-paths';\nexport * from './entropy';\nexport * from './eval';\nexport * from './errors';\nexport * from './fs';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './localization';\nexport * from './logging';\nexport * from './manifest';\nexport * from './mock';\nexport * from './namespace';\nexport * from './npm';\nexport * from './path';\nexport * from './post-process';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './ui';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- RpcOriginsStruct: function() {
13
- return RpcOriginsStruct;
14
- },
15
- assertIsRpcOrigins: function() {
16
- return assertIsRpcOrigins;
17
- },
18
- KeyringOriginsStruct: function() {
19
- return KeyringOriginsStruct;
20
- },
21
- assertIsKeyringOrigins: function() {
22
- return assertIsKeyringOrigins;
23
- },
24
- isOriginAllowed: function() {
25
- return isOriginAllowed;
26
- },
27
- assertIsJsonRpcSuccess: function() {
28
- return assertIsJsonRpcSuccess;
29
- }
30
- });
31
- const _permissioncontroller = require("@metamask/permission-controller");
32
- const _utils = require("@metamask/utils");
33
- const _superstruct = require("superstruct");
34
- const RpcOriginsStruct = (0, _superstruct.refine)((0, _superstruct.object)({
35
- dapps: (0, _superstruct.optional)((0, _superstruct.boolean)()),
36
- snaps: (0, _superstruct.optional)((0, _superstruct.boolean)()),
37
- allowedOrigins: (0, _superstruct.optional)((0, _superstruct.array)((0, _superstruct.string)()))
38
- }), 'RPC origins', (value)=>{
39
- const hasOrigins = Boolean(value.snaps === true || value.dapps === true || value.allowedOrigins && value.allowedOrigins.length > 0);
40
- if (hasOrigins) {
41
- return true;
42
- }
43
- return 'Must specify at least one JSON-RPC origin.';
44
- });
45
- function assertIsRpcOrigins(value, // eslint-disable-next-line @typescript-eslint/naming-convention
46
- ErrorWrapper) {
47
- (0, _utils.assertStruct)(value, RpcOriginsStruct, 'Invalid JSON-RPC origins', ErrorWrapper);
48
- }
49
- const KeyringOriginsStruct = (0, _superstruct.object)({
50
- allowedOrigins: (0, _superstruct.optional)((0, _superstruct.array)((0, _superstruct.string)()))
51
- });
52
- function assertIsKeyringOrigins(value, // eslint-disable-next-line @typescript-eslint/naming-convention
53
- ErrorWrapper) {
54
- (0, _utils.assertStruct)(value, KeyringOriginsStruct, 'Invalid keyring origins', ErrorWrapper);
55
- }
56
- function isOriginAllowed(origins, subjectType, origin) {
57
- // The MetaMask client is always allowed.
58
- if (origin === 'metamask') {
59
- return true;
60
- }
61
- // If the origin is in the `allowedOrigins` list, it is allowed.
62
- if (origins.allowedOrigins?.includes(origin)) {
63
- return true;
64
- }
65
- // If the origin is a website and `dapps` is true, it is allowed.
66
- if (subjectType === _permissioncontroller.SubjectType.Website && origins.dapps) {
67
- return true;
68
- }
69
- // If the origin is a snap and `snaps` is true, it is allowed.
70
- return Boolean(subjectType === _permissioncontroller.SubjectType.Snap && origins.snaps);
71
- }
72
- function assertIsJsonRpcSuccess(value) {
73
- if (!(0, _utils.isJsonRpcSuccess)(value)) {
74
- if ((0, _utils.isJsonRpcFailure)(value)) {
75
- throw new Error(`JSON-RPC request failed: ${value.error.message}`);
76
- }
77
- throw new Error('Invalid JSON-RPC response.');
78
- }
79
- }
80
-
81
- //# sourceMappingURL=json-rpc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/json-rpc.ts"],"sourcesContent":["import { SubjectType } from '@metamask/permission-controller';\nimport type {\n AssertionErrorConstructor,\n Json,\n JsonRpcSuccess,\n} from '@metamask/utils';\nimport {\n assertStruct,\n isJsonRpcFailure,\n isJsonRpcSuccess,\n} from '@metamask/utils';\nimport type { Infer } from 'superstruct';\nimport { array, boolean, object, optional, refine, string } from 'superstruct';\n\nexport const RpcOriginsStruct = refine(\n object({\n dapps: optional(boolean()),\n snaps: optional(boolean()),\n allowedOrigins: optional(array(string())),\n }),\n 'RPC origins',\n (value) => {\n const hasOrigins = Boolean(\n value.snaps === true ||\n value.dapps === true ||\n (value.allowedOrigins && value.allowedOrigins.length > 0),\n );\n\n if (hasOrigins) {\n return true;\n }\n\n return 'Must specify at least one JSON-RPC origin.';\n },\n);\n\nexport type RpcOrigins = Infer<typeof RpcOriginsStruct>;\n\n/**\n * Asserts that the given value is a valid {@link RpcOrigins} object.\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 {@link RpcOrigins} object.\n */\nexport function assertIsRpcOrigins(\n value: unknown,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is RpcOrigins {\n assertStruct(\n value,\n RpcOriginsStruct,\n 'Invalid JSON-RPC origins',\n ErrorWrapper,\n );\n}\n\nexport const KeyringOriginsStruct = object({\n allowedOrigins: optional(array(string())),\n});\n\nexport type KeyringOrigins = Infer<typeof KeyringOriginsStruct>;\n\n/**\n * Assert that the given value is a valid {@link KeyringOrigins} object.\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 {@link KeyringOrigins} object.\n */\nexport function assertIsKeyringOrigins(\n value: unknown,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is KeyringOrigins {\n assertStruct(\n value,\n KeyringOriginsStruct,\n 'Invalid keyring origins',\n ErrorWrapper,\n );\n}\n\n/**\n * Check if the given origin is allowed by the given JSON-RPC origins object.\n *\n * @param origins - The JSON-RPC origins object.\n * @param subjectType - The type of the origin.\n * @param origin - The origin to check.\n * @returns Whether the origin is allowed.\n */\nexport function isOriginAllowed(\n origins: RpcOrigins,\n subjectType: SubjectType,\n origin: string,\n) {\n // The MetaMask client is always allowed.\n if (origin === 'metamask') {\n return true;\n }\n\n // If the origin is in the `allowedOrigins` list, it is allowed.\n if (origins.allowedOrigins?.includes(origin)) {\n return true;\n }\n\n // If the origin is a website and `dapps` is true, it is allowed.\n if (subjectType === SubjectType.Website && origins.dapps) {\n return true;\n }\n\n // If the origin is a snap and `snaps` is true, it is allowed.\n return Boolean(subjectType === SubjectType.Snap && origins.snaps);\n}\n\n/**\n * Assert that the given value is a successful JSON-RPC response. If the value\n * is not a success response, an error is thrown. If the value is an JSON-RPC\n * error, the error message is included in the thrown error.\n *\n * @param value - The value to check.\n * @throws If the value is not a JSON-RPC success response.\n */\nexport function assertIsJsonRpcSuccess(\n value: unknown,\n): asserts value is JsonRpcSuccess<Json> {\n if (!isJsonRpcSuccess(value)) {\n if (isJsonRpcFailure(value)) {\n throw new Error(`JSON-RPC request failed: ${value.error.message}`);\n }\n\n throw new Error('Invalid JSON-RPC response.');\n }\n}\n"],"names":["RpcOriginsStruct","assertIsRpcOrigins","KeyringOriginsStruct","assertIsKeyringOrigins","isOriginAllowed","assertIsJsonRpcSuccess","refine","object","dapps","optional","boolean","snaps","allowedOrigins","array","string","value","hasOrigins","Boolean","length","ErrorWrapper","assertStruct","origins","subjectType","origin","includes","SubjectType","Website","Snap","isJsonRpcSuccess","isJsonRpcFailure","Error","error","message"],"mappings":";;;;;;;;;;;IAcaA,gBAAgB;eAAhBA;;IAgCGC,kBAAkB;eAAlBA;;IAaHC,oBAAoB;eAApBA;;IAcGC,sBAAsB;eAAtBA;;IAqBAC,eAAe;eAAfA;;IAgCAC,sBAAsB;eAAtBA;;;sCA9HY;uBAUrB;6BAE0D;AAE1D,MAAML,mBAAmBM,IAAAA,mBAAM,EACpCC,IAAAA,mBAAM,EAAC;IACLC,OAAOC,IAAAA,qBAAQ,EAACC,IAAAA,oBAAO;IACvBC,OAAOF,IAAAA,qBAAQ,EAACC,IAAAA,oBAAO;IACvBE,gBAAgBH,IAAAA,qBAAQ,EAACI,IAAAA,kBAAK,EAACC,IAAAA,mBAAM;AACvC,IACA,eACA,CAACC;IACC,MAAMC,aAAaC,QACjBF,MAAMJ,KAAK,KAAK,QACdI,MAAMP,KAAK,KAAK,QACfO,MAAMH,cAAc,IAAIG,MAAMH,cAAc,CAACM,MAAM,GAAG;IAG3D,IAAIF,YAAY;QACd,OAAO;IACT;IAEA,OAAO;AACT;AAaK,SAASf,mBACdc,KAAc,EACd,gEAAgE;AAChEI,YAAwC;IAExCC,IAAAA,mBAAY,EACVL,OACAf,kBACA,4BACAmB;AAEJ;AAEO,MAAMjB,uBAAuBK,IAAAA,mBAAM,EAAC;IACzCK,gBAAgBH,IAAAA,qBAAQ,EAACI,IAAAA,kBAAK,EAACC,IAAAA,mBAAM;AACvC;AAYO,SAASX,uBACdY,KAAc,EACd,gEAAgE;AAChEI,YAAwC;IAExCC,IAAAA,mBAAY,EACVL,OACAb,sBACA,2BACAiB;AAEJ;AAUO,SAASf,gBACdiB,OAAmB,EACnBC,WAAwB,EACxBC,MAAc;IAEd,yCAAyC;IACzC,IAAIA,WAAW,YAAY;QACzB,OAAO;IACT;IAEA,gEAAgE;IAChE,IAAIF,QAAQT,cAAc,EAAEY,SAASD,SAAS;QAC5C,OAAO;IACT;IAEA,iEAAiE;IACjE,IAAID,gBAAgBG,iCAAW,CAACC,OAAO,IAAIL,QAAQb,KAAK,EAAE;QACxD,OAAO;IACT;IAEA,8DAA8D;IAC9D,OAAOS,QAAQK,gBAAgBG,iCAAW,CAACE,IAAI,IAAIN,QAAQV,KAAK;AAClE;AAUO,SAASN,uBACdU,KAAc;IAEd,IAAI,CAACa,IAAAA,uBAAgB,EAACb,QAAQ;QAC5B,IAAIc,IAAAA,uBAAgB,EAACd,QAAQ;YAC3B,MAAM,IAAIe,MAAM,CAAC,yBAAyB,EAAEf,MAAMgB,KAAK,CAACC,OAAO,CAAC,CAAC;QACnE;QAEA,MAAM,IAAIF,MAAM;IAClB;AACF"}
package/dist/cjs/json.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "parseJson", {
6
- enumerable: true,
7
- get: function() {
8
- return parseJson;
9
- }
10
- });
11
- const _utils = require("@metamask/utils");
12
- function parseJson(json) {
13
- return (0, _utils.getSafeJson)(JSON.parse(json));
14
- }
15
-
16
- //# sourceMappingURL=json.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/json.ts"],"sourcesContent":["import type { Json } from '@metamask/utils';\nimport { getSafeJson } from '@metamask/utils';\n\n// TODO: Upstream this to @metamask/utils\n\n/**\n * Parse JSON safely.\n *\n * Does multiple kinds of validation and strips unwanted properties like\n * `__proto__` and `constructor`.\n *\n * @param json - A JSON string to be parsed.\n * @returns The parsed JSON object.\n * @template Type - The type of the JSON object. The type is not actually\n * checked, but it is used to infer the return type.\n */\nexport function parseJson<Type extends Json = Json>(json: string) {\n return getSafeJson<Type>(JSON.parse(json));\n}\n"],"names":["parseJson","json","getSafeJson","JSON","parse"],"mappings":";;;;+BAgBgBA;;;eAAAA;;;uBAfY;AAerB,SAASA,UAAoCC,IAAY;IAC9D,OAAOC,IAAAA,kBAAW,EAAOC,KAAKC,KAAK,CAACH;AACtC"}