@metamask/snaps-utils 6.0.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 (562) hide show
  1. package/CHANGELOG.md +23 -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/icon.d.ts +16 -1
  330. package/dist/types/index.d.ts +1 -6
  331. package/dist/types/json-rpc.d.ts +1 -1
  332. package/dist/types/localization.d.ts +1 -1
  333. package/dist/types/manifest/index.d.ts +0 -1
  334. package/dist/types/manifest/manifest.d.ts +1 -1
  335. package/dist/types/manifest/node.d.ts +2 -0
  336. package/dist/types/manifest/validation.d.ts +5 -5
  337. package/dist/types/node.d.ts +8 -0
  338. package/dist/types/post-process.d.ts +1 -1
  339. package/dist/types/structs.d.ts +0 -20
  340. package/dist/types/ui.d.ts +7 -0
  341. package/dist/types/virtual-file/index.d.ts +0 -1
  342. package/dist/types/virtual-file/node.d.ts +2 -0
  343. package/dist/types.js +28 -0
  344. package/dist/types.js.map +1 -0
  345. package/dist/types.mjs +28 -0
  346. package/dist/types.mjs.map +1 -0
  347. package/dist/ui.js +12 -0
  348. package/dist/ui.js.map +1 -0
  349. package/dist/ui.mjs +12 -0
  350. package/dist/ui.mjs.map +1 -0
  351. package/dist/validation.js +24 -0
  352. package/dist/validation.js.map +1 -0
  353. package/dist/validation.mjs +24 -0
  354. package/dist/validation.mjs.map +1 -0
  355. package/dist/versions.js +12 -0
  356. package/dist/versions.js.map +1 -0
  357. package/dist/versions.mjs +12 -0
  358. package/dist/versions.mjs.map +1 -0
  359. package/dist/virtual-file/VirtualFile.js +9 -0
  360. package/dist/virtual-file/VirtualFile.js.map +1 -0
  361. package/dist/virtual-file/VirtualFile.mjs +9 -0
  362. package/dist/virtual-file/VirtualFile.mjs.map +1 -0
  363. package/dist/virtual-file/index.js +10 -0
  364. package/dist/virtual-file/index.js.map +1 -0
  365. package/dist/virtual-file/index.mjs +10 -0
  366. package/dist/virtual-file/index.mjs.map +1 -0
  367. package/dist/virtual-file/node.js +17 -0
  368. package/dist/virtual-file/node.js.map +1 -0
  369. package/dist/virtual-file/node.mjs +17 -0
  370. package/dist/virtual-file/node.mjs.map +1 -0
  371. package/dist/virtual-file/toVirtualFile.js +12 -0
  372. package/dist/virtual-file/toVirtualFile.js.map +1 -0
  373. package/dist/virtual-file/toVirtualFile.mjs +12 -0
  374. package/dist/virtual-file/toVirtualFile.mjs.map +1 -0
  375. package/package.json +24 -40
  376. package/dist/cjs/array.js +0 -23
  377. package/dist/cjs/array.js.map +0 -1
  378. package/dist/cjs/auxiliary-files.js +0 -27
  379. package/dist/cjs/auxiliary-files.js.map +0 -1
  380. package/dist/cjs/base64.js +0 -44
  381. package/dist/cjs/base64.js.map +0 -1
  382. package/dist/cjs/bytes.js +0 -23
  383. package/dist/cjs/bytes.js.map +0 -1
  384. package/dist/cjs/caveats.js +0 -48
  385. package/dist/cjs/caveats.js.map +0 -1
  386. package/dist/cjs/checksum.js +0 -43
  387. package/dist/cjs/checksum.js.map +0 -1
  388. package/dist/cjs/cronjob.js +0 -77
  389. package/dist/cjs/cronjob.js.map +0 -1
  390. package/dist/cjs/deep-clone.js +0 -22
  391. package/dist/cjs/deep-clone.js.map +0 -1
  392. package/dist/cjs/default-endowments.js +0 -49
  393. package/dist/cjs/default-endowments.js.map +0 -1
  394. package/dist/cjs/derivation-paths.js +0 -300
  395. package/dist/cjs/derivation-paths.js.map +0 -1
  396. package/dist/cjs/entropy.js +0 -23
  397. package/dist/cjs/entropy.js.map +0 -1
  398. package/dist/cjs/errors.js +0 -221
  399. package/dist/cjs/errors.js.map +0 -1
  400. package/dist/cjs/eval-worker.js +0 -44
  401. package/dist/cjs/eval-worker.js.map +0 -1
  402. package/dist/cjs/eval.js +0 -77
  403. package/dist/cjs/eval.js.map +0 -1
  404. package/dist/cjs/fs.js +0 -126
  405. package/dist/cjs/fs.js.map +0 -1
  406. package/dist/cjs/handler-types.js +0 -34
  407. package/dist/cjs/handler-types.js.map +0 -1
  408. package/dist/cjs/handlers.js +0 -173
  409. package/dist/cjs/handlers.js.map +0 -1
  410. package/dist/cjs/icon.js +0 -37
  411. package/dist/cjs/icon.js.map +0 -1
  412. package/dist/cjs/iframe.js +0 -59
  413. package/dist/cjs/iframe.js.map +0 -1
  414. package/dist/cjs/index.browser.js +0 -49
  415. package/dist/cjs/index.browser.js.map +0 -1
  416. package/dist/cjs/index.executionenv.js +0 -27
  417. package/dist/cjs/index.executionenv.js.map +0 -1
  418. package/dist/cjs/index.js +0 -54
  419. package/dist/cjs/index.js.map +0 -1
  420. package/dist/cjs/json-rpc.js +0 -81
  421. package/dist/cjs/json-rpc.js.map +0 -1
  422. package/dist/cjs/json.js +0 -16
  423. package/dist/cjs/json.js.map +0 -1
  424. package/dist/cjs/localization.js +0 -113
  425. package/dist/cjs/localization.js.map +0 -1
  426. package/dist/cjs/logging.js +0 -40
  427. package/dist/cjs/logging.js.map +0 -1
  428. package/dist/cjs/manifest/index.browser.js +0 -20
  429. package/dist/cjs/manifest/index.browser.js.map +0 -1
  430. package/dist/cjs/manifest/index.js +0 -21
  431. package/dist/cjs/manifest/index.js.map +0 -1
  432. package/dist/cjs/manifest/manifest.js +0 -275
  433. package/dist/cjs/manifest/manifest.js.map +0 -1
  434. package/dist/cjs/manifest/validation.js +0 -244
  435. package/dist/cjs/manifest/validation.js.map +0 -1
  436. package/dist/cjs/mock.js +0 -128
  437. package/dist/cjs/mock.js.map +0 -1
  438. package/dist/cjs/namespace.js +0 -136
  439. package/dist/cjs/namespace.js.map +0 -1
  440. package/dist/cjs/npm.js +0 -96
  441. package/dist/cjs/npm.js.map +0 -1
  442. package/dist/cjs/path.js +0 -21
  443. package/dist/cjs/path.js.map +0 -1
  444. package/dist/cjs/post-process.js +0 -328
  445. package/dist/cjs/post-process.js.map +0 -1
  446. package/dist/cjs/snaps.js +0 -232
  447. package/dist/cjs/snaps.js.map +0 -1
  448. package/dist/cjs/strings.js +0 -21
  449. package/dist/cjs/strings.js.map +0 -1
  450. package/dist/cjs/structs.js +0 -210
  451. package/dist/cjs/structs.js.map +0 -1
  452. package/dist/cjs/types.js +0 -104
  453. package/dist/cjs/types.js.map +0 -1
  454. package/dist/cjs/ui.js +0 -53
  455. package/dist/cjs/ui.js.map +0 -1
  456. package/dist/cjs/validation.js +0 -24
  457. package/dist/cjs/validation.js.map +0 -1
  458. package/dist/cjs/versions.js +0 -47
  459. package/dist/cjs/versions.js.map +0 -1
  460. package/dist/cjs/virtual-file/VirtualFile.js +0 -92
  461. package/dist/cjs/virtual-file/VirtualFile.js.map +0 -1
  462. package/dist/cjs/virtual-file/index.browser.js +0 -20
  463. package/dist/cjs/virtual-file/index.browser.js.map +0 -1
  464. package/dist/cjs/virtual-file/index.js +0 -21
  465. package/dist/cjs/virtual-file/index.js.map +0 -1
  466. package/dist/cjs/virtual-file/toVirtualFile.js +0 -33
  467. package/dist/cjs/virtual-file/toVirtualFile.js.map +0 -1
  468. package/dist/esm/array.js +0 -13
  469. package/dist/esm/array.js.map +0 -1
  470. package/dist/esm/auxiliary-files.js +0 -23
  471. package/dist/esm/auxiliary-files.js.map +0 -1
  472. package/dist/esm/base64.js +0 -36
  473. package/dist/esm/base64.js.map +0 -1
  474. package/dist/esm/bytes.js +0 -18
  475. package/dist/esm/bytes.js.map +0 -1
  476. package/dist/esm/caveats.js +0 -38
  477. package/dist/esm/caveats.js.map +0 -1
  478. package/dist/esm/checksum.js +0 -41
  479. package/dist/esm/checksum.js.map +0 -1
  480. package/dist/esm/cronjob.js +0 -59
  481. package/dist/esm/cronjob.js.map +0 -1
  482. package/dist/esm/deep-clone.js +0 -7
  483. package/dist/esm/deep-clone.js.map +0 -1
  484. package/dist/esm/default-endowments.js +0 -39
  485. package/dist/esm/default-endowments.js.map +0 -1
  486. package/dist/esm/derivation-paths.js +0 -287
  487. package/dist/esm/derivation-paths.js.map +0 -1
  488. package/dist/esm/entropy.js +0 -6
  489. package/dist/esm/entropy.js.map +0 -1
  490. package/dist/esm/errors.js +0 -211
  491. package/dist/esm/errors.js.map +0 -1
  492. package/dist/esm/eval-worker.js +0 -40
  493. package/dist/esm/eval-worker.js.map +0 -1
  494. package/dist/esm/eval.js +0 -65
  495. package/dist/esm/eval.js.map +0 -1
  496. package/dist/esm/fs.js +0 -136
  497. package/dist/esm/fs.js.map +0 -1
  498. package/dist/esm/handler-types.js +0 -16
  499. package/dist/esm/handler-types.js.map +0 -1
  500. package/dist/esm/handlers.js +0 -119
  501. package/dist/esm/handlers.js.map +0 -1
  502. package/dist/esm/icon.js +0 -11
  503. package/dist/esm/icon.js.map +0 -1
  504. package/dist/esm/iframe.js +0 -49
  505. package/dist/esm/iframe.js.map +0 -1
  506. package/dist/esm/index.browser.js +0 -32
  507. package/dist/esm/index.browser.js.map +0 -1
  508. package/dist/esm/index.executionenv.js +0 -10
  509. package/dist/esm/index.executionenv.js.map +0 -1
  510. package/dist/esm/index.js +0 -37
  511. package/dist/esm/index.js.map +0 -1
  512. package/dist/esm/json-rpc.js +0 -79
  513. package/dist/esm/json-rpc.js.map +0 -1
  514. package/dist/esm/json.js +0 -17
  515. package/dist/esm/json.js.map +0 -1
  516. package/dist/esm/localization.js +0 -115
  517. package/dist/esm/localization.js.map +0 -1
  518. package/dist/esm/logging.js +0 -59
  519. package/dist/esm/logging.js.map +0 -1
  520. package/dist/esm/manifest/index.browser.js +0 -3
  521. package/dist/esm/manifest/index.browser.js.map +0 -1
  522. package/dist/esm/manifest/index.js +0 -4
  523. package/dist/esm/manifest/index.js.map +0 -1
  524. package/dist/esm/manifest/manifest.js +0 -299
  525. package/dist/esm/manifest/manifest.js.map +0 -1
  526. package/dist/esm/manifest/validation.js +0 -190
  527. package/dist/esm/manifest/validation.js.map +0 -1
  528. package/dist/esm/mock.js +0 -111
  529. package/dist/esm/mock.js.map +0 -1
  530. package/dist/esm/namespace.js +0 -113
  531. package/dist/esm/namespace.js.map +0 -1
  532. package/dist/esm/npm.js +0 -85
  533. package/dist/esm/npm.js.map +0 -1
  534. package/dist/esm/path.js +0 -17
  535. package/dist/esm/path.js.map +0 -1
  536. package/dist/esm/post-process.js +0 -333
  537. package/dist/esm/post-process.js.map +0 -1
  538. package/dist/esm/snaps.js +0 -217
  539. package/dist/esm/snaps.js.map +0 -1
  540. package/dist/esm/strings.js +0 -11
  541. package/dist/esm/strings.js.map +0 -1
  542. package/dist/esm/structs.js +0 -295
  543. package/dist/esm/structs.js.map +0 -1
  544. package/dist/esm/types.js +0 -78
  545. package/dist/esm/types.js.map +0 -1
  546. package/dist/esm/ui.js +0 -50
  547. package/dist/esm/ui.js.map +0 -1
  548. package/dist/esm/validation.js +0 -19
  549. package/dist/esm/validation.js.map +0 -1
  550. package/dist/esm/versions.js +0 -41
  551. package/dist/esm/versions.js.map +0 -1
  552. package/dist/esm/virtual-file/VirtualFile.js +0 -82
  553. package/dist/esm/virtual-file/VirtualFile.js.map +0 -1
  554. package/dist/esm/virtual-file/index.browser.js +0 -3
  555. package/dist/esm/virtual-file/index.browser.js.map +0 -1
  556. package/dist/esm/virtual-file/index.js +0 -4
  557. package/dist/esm/virtual-file/index.js.map +0 -1
  558. package/dist/esm/virtual-file/toVirtualFile.js +0 -26
  559. package/dist/esm/virtual-file/toVirtualFile.js.map +0 -1
  560. package/dist/types/index.browser.d.ts +0 -30
  561. package/dist/types/manifest/index.browser.d.ts +0 -1
  562. package/dist/types/virtual-file/index.browser.d.ts +0 -1
@@ -1,40 +0,0 @@
1
- // eslint-disable-next-line import/no-unassigned-import
2
- import 'ses/lockdown';
3
- import { readFileSync } from 'fs';
4
- import { SNAP_EXPORT_NAMES } from './handler-types';
5
- import { generateMockEndowments } from './mock';
6
- lockdown({
7
- consoleTaming: 'unsafe',
8
- errorTaming: 'unsafe',
9
- mathTaming: 'unsafe',
10
- dateTaming: 'unsafe',
11
- overrideTaming: 'severe',
12
- // We disable domain taming, because it does not work in certain cases when
13
- // running tests. This is unlikely to be a problem in production, because
14
- // Node.js domains are deprecated.
15
- domainTaming: 'unsafe'
16
- });
17
- const snapFilePath = process.argv[2];
18
- const snapModule = {
19
- exports: {}
20
- };
21
- const compartment = new Compartment({
22
- ...generateMockEndowments(),
23
- module: snapModule,
24
- exports: snapModule.exports
25
- });
26
- // Mirror BaseSnapExecutor
27
- compartment.globalThis.self = compartment.globalThis;
28
- compartment.globalThis.global = compartment.globalThis;
29
- compartment.globalThis.window = compartment.globalThis;
30
- compartment.evaluate(readFileSync(snapFilePath, 'utf8'));
31
- const invalidExports = Object.keys(snapModule.exports).filter((snapExport)=>!SNAP_EXPORT_NAMES.includes(snapExport));
32
- if (invalidExports.length > 0) {
33
- // eslint-disable-next-line no-console
34
- console.warn(`Invalid snap exports detected:\n${invalidExports.join('\n')}`);
35
- }
36
- // To ensure the worker exits we explicitly call exit here
37
- // If we didn't the eval would wait for timers set during Compartment eval
38
- process.exit(0);
39
-
40
- //# sourceMappingURL=eval-worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/eval-worker.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport 'ses/lockdown';\n\nimport { readFileSync } from 'fs';\n\nimport type { HandlerType } from './handler-types';\nimport { SNAP_EXPORT_NAMES } from './handler-types';\nimport { generateMockEndowments } from './mock';\n\ndeclare let lockdown: any, Compartment: any;\n\nlockdown({\n consoleTaming: 'unsafe',\n errorTaming: 'unsafe',\n mathTaming: 'unsafe',\n dateTaming: 'unsafe',\n overrideTaming: 'severe',\n\n // We disable domain taming, because it does not work in certain cases when\n // running tests. This is unlikely to be a problem in production, because\n // Node.js domains are deprecated.\n domainTaming: 'unsafe',\n});\n\nconst snapFilePath = process.argv[2];\n\nconst snapModule: { exports?: any } = { exports: {} };\n\nconst compartment = new Compartment({\n ...generateMockEndowments(),\n module: snapModule,\n exports: snapModule.exports,\n});\n\n// Mirror BaseSnapExecutor\ncompartment.globalThis.self = compartment.globalThis;\ncompartment.globalThis.global = compartment.globalThis;\ncompartment.globalThis.window = compartment.globalThis;\n\ncompartment.evaluate(readFileSync(snapFilePath, 'utf8'));\n\nconst invalidExports = Object.keys(snapModule.exports).filter(\n (snapExport) => !SNAP_EXPORT_NAMES.includes(snapExport as HandlerType),\n);\n\nif (invalidExports.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(`Invalid snap exports detected:\\n${invalidExports.join('\\n')}`);\n}\n\n// To ensure the worker exits we explicitly call exit here\n// If we didn't the eval would wait for timers set during Compartment eval\nprocess.exit(0);\n"],"names":["readFileSync","SNAP_EXPORT_NAMES","generateMockEndowments","lockdown","consoleTaming","errorTaming","mathTaming","dateTaming","overrideTaming","domainTaming","snapFilePath","process","argv","snapModule","exports","compartment","Compartment","module","globalThis","self","global","window","evaluate","invalidExports","Object","keys","filter","snapExport","includes","length","console","warn","join","exit"],"mappings":"AAAA,uDAAuD;AACvD,OAAO,eAAe;AAEtB,SAASA,YAAY,QAAQ,KAAK;AAGlC,SAASC,iBAAiB,QAAQ,kBAAkB;AACpD,SAASC,sBAAsB,QAAQ,SAAS;AAIhDC,SAAS;IACPC,eAAe;IACfC,aAAa;IACbC,YAAY;IACZC,YAAY;IACZC,gBAAgB;IAEhB,2EAA2E;IAC3E,yEAAyE;IACzE,kCAAkC;IAClCC,cAAc;AAChB;AAEA,MAAMC,eAAeC,QAAQC,IAAI,CAAC,EAAE;AAEpC,MAAMC,aAAgC;IAAEC,SAAS,CAAC;AAAE;AAEpD,MAAMC,cAAc,IAAIC,YAAY;IAClC,GAAGd,wBAAwB;IAC3Be,QAAQJ;IACRC,SAASD,WAAWC,OAAO;AAC7B;AAEA,0BAA0B;AAC1BC,YAAYG,UAAU,CAACC,IAAI,GAAGJ,YAAYG,UAAU;AACpDH,YAAYG,UAAU,CAACE,MAAM,GAAGL,YAAYG,UAAU;AACtDH,YAAYG,UAAU,CAACG,MAAM,GAAGN,YAAYG,UAAU;AAEtDH,YAAYO,QAAQ,CAACtB,aAAaU,cAAc;AAEhD,MAAMa,iBAAiBC,OAAOC,IAAI,CAACZ,WAAWC,OAAO,EAAEY,MAAM,CAC3D,CAACC,aAAe,CAAC1B,kBAAkB2B,QAAQ,CAACD;AAG9C,IAAIJ,eAAeM,MAAM,GAAG,GAAG;IAC7B,sCAAsC;IACtCC,QAAQC,IAAI,CAAC,CAAC,gCAAgC,EAAER,eAAeS,IAAI,CAAC,MAAM,CAAC;AAC7E;AAEA,0DAA0D;AAC1D,0EAA0E;AAC1ErB,QAAQsB,IAAI,CAAC"}
package/dist/esm/eval.js DELETED
@@ -1,65 +0,0 @@
1
- function _define_property(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
13
- }
14
- import { assert } from '@metamask/utils';
15
- import { fork } from 'child_process';
16
- import { join } from 'path';
17
- import { validateFilePath } from './fs';
18
- export class SnapEvalError extends Error {
19
- constructor(message, output){
20
- super(message);
21
- _define_property(this, "output", void 0);
22
- this.name = 'SnapEvalError';
23
- this.output = output;
24
- }
25
- }
26
- /**
27
- * Spawn a new process to run the provided bundle in.
28
- *
29
- * @param bundlePath - The path to the bundle to run.
30
- * @returns `null` if the worker ran successfully.
31
- * @throws If the worker failed to run successfully.
32
- */ export async function evalBundle(bundlePath) {
33
- await validateFilePath(bundlePath);
34
- return new Promise((resolve, reject)=>{
35
- const worker = fork(join(__dirname, 'eval-worker.js'), [
36
- bundlePath
37
- ], {
38
- // To avoid printing the output of the worker to the console, we set
39
- // `stdio` to `pipe` and handle the output ourselves.
40
- stdio: 'pipe'
41
- });
42
- let stdout = '';
43
- let stderr = '';
44
- assert(worker.stdout, '`stdout` should be defined.');
45
- assert(worker.stderr, '`stderr` should be defined.');
46
- worker.stdout.on('data', (data)=>{
47
- stdout += data.toString();
48
- });
49
- worker.stderr.on('data', (data)=>{
50
- stderr += data.toString();
51
- });
52
- worker.on('exit', (exitCode)=>{
53
- const output = {
54
- stdout,
55
- stderr
56
- };
57
- if (exitCode === 0) {
58
- return resolve(output);
59
- }
60
- return reject(new SnapEvalError(`Process exited with non-zero exit code: ${exitCode}.`, output));
61
- });
62
- });
63
- }
64
-
65
- //# sourceMappingURL=eval.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/eval.ts"],"sourcesContent":["import { assert } from '@metamask/utils';\nimport { fork } from 'child_process';\nimport { join } from 'path';\n\nimport { validateFilePath } from './fs';\n\nexport type EvalOutput = {\n stdout: string;\n stderr: string;\n};\n\nexport class SnapEvalError extends Error {\n readonly output: EvalOutput;\n\n constructor(message: string, output: EvalOutput) {\n super(message);\n\n this.name = 'SnapEvalError';\n this.output = output;\n }\n}\n\n/**\n * Spawn a new process to run the provided bundle in.\n *\n * @param bundlePath - The path to the bundle to run.\n * @returns `null` if the worker ran successfully.\n * @throws If the worker failed to run successfully.\n */\nexport async function evalBundle(bundlePath: string): Promise<EvalOutput> {\n await validateFilePath(bundlePath);\n\n return new Promise((resolve, reject) => {\n const worker = fork(join(__dirname, 'eval-worker.js'), [bundlePath], {\n // To avoid printing the output of the worker to the console, we set\n // `stdio` to `pipe` and handle the output ourselves.\n stdio: 'pipe',\n });\n\n let stdout = '';\n let stderr = '';\n\n assert(worker.stdout, '`stdout` should be defined.');\n assert(worker.stderr, '`stderr` should be defined.');\n\n worker.stdout.on('data', (data: Buffer) => {\n stdout += data.toString();\n });\n\n worker.stderr.on('data', (data: Buffer) => {\n stderr += data.toString();\n });\n\n worker.on('exit', (exitCode: number) => {\n const output = {\n stdout,\n stderr,\n };\n\n if (exitCode === 0) {\n return resolve(output);\n }\n\n return reject(\n new SnapEvalError(\n `Process exited with non-zero exit code: ${exitCode}.`,\n output,\n ),\n );\n });\n });\n}\n"],"names":["assert","fork","join","validateFilePath","SnapEvalError","Error","constructor","message","output","name","evalBundle","bundlePath","Promise","resolve","reject","worker","__dirname","stdio","stdout","stderr","on","data","toString","exitCode"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,MAAM,QAAQ,kBAAkB;AACzC,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,IAAI,QAAQ,OAAO;AAE5B,SAASC,gBAAgB,QAAQ,OAAO;AAOxC,OAAO,MAAMC,sBAAsBC;IAGjCC,YAAYC,OAAe,EAAEC,MAAkB,CAAE;QAC/C,KAAK,CAACD;QAHR,uBAASC,UAAT,KAAA;QAKE,IAAI,CAACC,IAAI,GAAG;QACZ,IAAI,CAACD,MAAM,GAAGA;IAChB;AACF;AAEA;;;;;;CAMC,GACD,OAAO,eAAeE,WAAWC,UAAkB;IACjD,MAAMR,iBAAiBQ;IAEvB,OAAO,IAAIC,QAAQ,CAACC,SAASC;QAC3B,MAAMC,SAASd,KAAKC,KAAKc,WAAW,mBAAmB;YAACL;SAAW,EAAE;YACnE,oEAAoE;YACpE,qDAAqD;YACrDM,OAAO;QACT;QAEA,IAAIC,SAAS;QACb,IAAIC,SAAS;QAEbnB,OAAOe,OAAOG,MAAM,EAAE;QACtBlB,OAAOe,OAAOI,MAAM,EAAE;QAEtBJ,OAAOG,MAAM,CAACE,EAAE,CAAC,QAAQ,CAACC;YACxBH,UAAUG,KAAKC,QAAQ;QACzB;QAEAP,OAAOI,MAAM,CAACC,EAAE,CAAC,QAAQ,CAACC;YACxBF,UAAUE,KAAKC,QAAQ;QACzB;QAEAP,OAAOK,EAAE,CAAC,QAAQ,CAACG;YACjB,MAAMf,SAAS;gBACbU;gBACAC;YACF;YAEA,IAAII,aAAa,GAAG;gBAClB,OAAOV,QAAQL;YACjB;YAEA,OAAOM,OACL,IAAIV,cACF,CAAC,wCAAwC,EAAEmB,SAAS,CAAC,CAAC,EACtDf;QAGN;IACF;AACF"}
package/dist/esm/fs.js DELETED
@@ -1,136 +0,0 @@
1
- import { promises as fs } from 'fs';
2
- import os from 'os';
3
- import pathUtils from 'path';
4
- import { parseJson } from './json';
5
- import { readVirtualFile } from './virtual-file';
6
- /**
7
- * Checks whether the given path string resolves to an existing directory, and
8
- * optionally creates the directory if it doesn't exist.
9
- *
10
- * @param pathString - The path string to check.
11
- * @param createDir - Whether to create the directory if it doesn't exist.
12
- * @returns Whether the given path is an existing directory.
13
- */ export async function isDirectory(pathString, createDir) {
14
- try {
15
- const stats = await fs.stat(pathString);
16
- return stats.isDirectory();
17
- } catch (error) {
18
- if (error.code === 'ENOENT') {
19
- if (!createDir) {
20
- return false;
21
- }
22
- await fs.mkdir(pathString, {
23
- recursive: true
24
- });
25
- return true;
26
- }
27
- return false;
28
- }
29
- }
30
- /**
31
- * Checks whether the given path string resolves to an existing file.
32
- *
33
- * @param pathString - The path string to check.
34
- * @returns Whether the given path is an existing file.
35
- */ export async function isFile(pathString) {
36
- try {
37
- const stats = await fs.stat(pathString);
38
- return stats.isFile();
39
- } catch (error) {
40
- return false;
41
- }
42
- }
43
- /**
44
- * Reads a `.json` file, parses its contents, and returns them.
45
- *
46
- * @param pathString - The path to the JSON file.
47
- * @returns The parsed contents of the JSON file.
48
- */ export async function readJsonFile(pathString) {
49
- if (!pathString.endsWith('.json')) {
50
- throw new Error('The specified file must be a ".json" file.');
51
- }
52
- let file;
53
- try {
54
- file = await readVirtualFile(pathString, 'utf8');
55
- } catch (error) {
56
- if (error.code === 'ENOENT') {
57
- throw new Error(`Could not find '${pathString}'. Please ensure that the file exists.`);
58
- }
59
- throw error;
60
- }
61
- file.result = parseJson(file.toString());
62
- return file;
63
- }
64
- /**
65
- * Gets the complete out file path from an output file name and parent
66
- * directory path.
67
- *
68
- * @param outDir - The path to the out file's parent directory.
69
- * @param outFileName - The out file's name.
70
- * @returns The complete path to the out file.
71
- */ export function getOutfilePath(outDir, outFileName) {
72
- return pathUtils.join(outDir, outFileName || 'bundle.js');
73
- }
74
- /**
75
- * Ensures that the outfile name is just a `.js` file name.
76
- * Throws on validation failure.
77
- *
78
- * @param filename - The file name to validate.
79
- * @returns `true` if validation succeeded.
80
- * @throws If the file name is invalid.
81
- */ export function validateOutfileName(filename) {
82
- if (!filename.endsWith('.js') || filename === '.js' || pathUtils.basename(filename) !== filename) {
83
- throw new Error(`Invalid outfile name: ${filename}. Must be a .js file`);
84
- }
85
- return true;
86
- }
87
- /**
88
- * Validates a file path. Throws on validation failure.
89
- *
90
- * @param filePath - The file path to validate.
91
- * @returns `true` if validation succeeded.
92
- * @throws If the path does not resolve to a file.
93
- */ export async function validateFilePath(filePath) {
94
- const exists = await isFile(filePath);
95
- if (!exists) {
96
- throw new Error(`Invalid params: '${filePath}' is not a file or does not exist.`);
97
- }
98
- return true;
99
- }
100
- /**
101
- * Validates a directory path. Throws on validation failure.
102
- *
103
- * @param dirPath - The directory path to validate.
104
- * @param createDir - Whether to create the directory if it doesn't exist.
105
- * @returns `true` if validation succeeded or the directory was created.
106
- * @throws If the directory does not exist or could not be created.
107
- */ export async function validateDirPath(dirPath, createDir) {
108
- const exists = await isDirectory(dirPath, createDir);
109
- if (!exists) {
110
- throw new Error(`Invalid params: '${dirPath}' is not a directory or could not be created.`);
111
- }
112
- return true;
113
- }
114
- /**
115
- * Creates a temporary file with a given name and content, writes it to disk and calls the provided function.
116
- * This function handles deletion of the temporary file after usage.
117
- *
118
- * @param fileName - The name of the temporary file.
119
- * @param fileContents - The content of the temporary file.
120
- * @param fn - The callback function to call when the temporary file has been created.
121
- */ export async function useTemporaryFile(fileName, fileContents, fn) {
122
- const filePath = pathUtils.join(os.tmpdir(), fileName);
123
- await fs.mkdir(pathUtils.dirname(filePath), {
124
- recursive: true
125
- });
126
- await fs.writeFile(filePath, fileContents);
127
- try {
128
- await fn(filePath);
129
- } finally{
130
- if (await isFile(filePath)) {
131
- await fs.unlink(filePath);
132
- }
133
- }
134
- }
135
-
136
- //# sourceMappingURL=fs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/fs.ts"],"sourcesContent":["import type { Json } from '@metamask/utils';\nimport { promises as fs } from 'fs';\nimport os from 'os';\nimport pathUtils from 'path';\n\nimport { parseJson } from './json';\nimport type { VirtualFile } from './virtual-file';\nimport { readVirtualFile } from './virtual-file';\n\n/**\n * Checks whether the given path string resolves to an existing directory, and\n * optionally creates the directory if it doesn't exist.\n *\n * @param pathString - The path string to check.\n * @param createDir - Whether to create the directory if it doesn't exist.\n * @returns Whether the given path is an existing directory.\n */\nexport async function isDirectory(\n pathString: string,\n createDir: boolean,\n): Promise<boolean> {\n try {\n const stats = await fs.stat(pathString);\n return stats.isDirectory();\n } catch (error) {\n if (error.code === 'ENOENT') {\n if (!createDir) {\n return false;\n }\n\n await fs.mkdir(pathString, { recursive: true });\n return true;\n }\n\n return false;\n }\n}\n\n/**\n * Checks whether the given path string resolves to an existing file.\n *\n * @param pathString - The path string to check.\n * @returns Whether the given path is an existing file.\n */\nexport async function isFile(pathString: string): Promise<boolean> {\n try {\n const stats = await fs.stat(pathString);\n return stats.isFile();\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Reads a `.json` file, parses its contents, and returns them.\n *\n * @param pathString - The path to the JSON file.\n * @returns The parsed contents of the JSON file.\n */\nexport async function readJsonFile<Type extends Json = Json>(\n pathString: string,\n): Promise<VirtualFile<Type>> {\n if (!pathString.endsWith('.json')) {\n throw new Error('The specified file must be a \".json\" file.');\n }\n\n let file;\n try {\n file = await readVirtualFile(pathString, 'utf8');\n } catch (error) {\n if (error.code === 'ENOENT') {\n throw new Error(\n `Could not find '${pathString}'. Please ensure that the file exists.`,\n );\n }\n\n throw error;\n }\n file.result = parseJson(file.toString());\n return file as VirtualFile<Type>;\n}\n\n/**\n * Gets the complete out file path from an output file name and parent\n * directory path.\n *\n * @param outDir - The path to the out file's parent directory.\n * @param outFileName - The out file's name.\n * @returns The complete path to the out file.\n */\nexport function getOutfilePath(outDir: string, outFileName: string): string {\n return pathUtils.join(outDir, outFileName || 'bundle.js');\n}\n\n/**\n * Ensures that the outfile name is just a `.js` file name.\n * Throws on validation failure.\n *\n * @param filename - The file name to validate.\n * @returns `true` if validation succeeded.\n * @throws If the file name is invalid.\n */\nexport function validateOutfileName(filename: string): boolean {\n if (\n !filename.endsWith('.js') ||\n filename === '.js' ||\n pathUtils.basename(filename) !== filename\n ) {\n throw new Error(`Invalid outfile name: ${filename}. Must be a .js file`);\n }\n return true;\n}\n\n/**\n * Validates a file path. Throws on validation failure.\n *\n * @param filePath - The file path to validate.\n * @returns `true` if validation succeeded.\n * @throws If the path does not resolve to a file.\n */\nexport async function validateFilePath(filePath: string): Promise<boolean> {\n const exists = await isFile(filePath);\n if (!exists) {\n throw new Error(\n `Invalid params: '${filePath}' is not a file or does not exist.`,\n );\n }\n return true;\n}\n\n/**\n * Validates a directory path. Throws on validation failure.\n *\n * @param dirPath - The directory path to validate.\n * @param createDir - Whether to create the directory if it doesn't exist.\n * @returns `true` if validation succeeded or the directory was created.\n * @throws If the directory does not exist or could not be created.\n */\nexport async function validateDirPath(\n dirPath: string,\n createDir: boolean,\n): Promise<boolean> {\n const exists = await isDirectory(dirPath, createDir);\n if (!exists) {\n throw new Error(\n `Invalid params: '${dirPath}' is not a directory or could not be created.`,\n );\n }\n return true;\n}\n\n/**\n * Creates a temporary file with a given name and content, writes it to disk and calls the provided function.\n * This function handles deletion of the temporary file after usage.\n *\n * @param fileName - The name of the temporary file.\n * @param fileContents - The content of the temporary file.\n * @param fn - The callback function to call when the temporary file has been created.\n */\nexport async function useTemporaryFile(\n fileName: string,\n fileContents: string,\n fn: (path: string) => Promise<unknown>,\n): Promise<void> {\n const filePath = pathUtils.join(os.tmpdir(), fileName);\n await fs.mkdir(pathUtils.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, fileContents);\n try {\n await fn(filePath);\n } finally {\n if (await isFile(filePath)) {\n await fs.unlink(filePath);\n }\n }\n}\n"],"names":["promises","fs","os","pathUtils","parseJson","readVirtualFile","isDirectory","pathString","createDir","stats","stat","error","code","mkdir","recursive","isFile","readJsonFile","endsWith","Error","file","result","toString","getOutfilePath","outDir","outFileName","join","validateOutfileName","filename","basename","validateFilePath","filePath","exists","validateDirPath","dirPath","useTemporaryFile","fileName","fileContents","fn","tmpdir","dirname","writeFile","unlink"],"mappings":"AACA,SAASA,YAAYC,EAAE,QAAQ,KAAK;AACpC,OAAOC,QAAQ,KAAK;AACpB,OAAOC,eAAe,OAAO;AAE7B,SAASC,SAAS,QAAQ,SAAS;AAEnC,SAASC,eAAe,QAAQ,iBAAiB;AAEjD;;;;;;;CAOC,GACD,OAAO,eAAeC,YACpBC,UAAkB,EAClBC,SAAkB;IAElB,IAAI;QACF,MAAMC,QAAQ,MAAMR,GAAGS,IAAI,CAACH;QAC5B,OAAOE,MAAMH,WAAW;IAC1B,EAAE,OAAOK,OAAO;QACd,IAAIA,MAAMC,IAAI,KAAK,UAAU;YAC3B,IAAI,CAACJ,WAAW;gBACd,OAAO;YACT;YAEA,MAAMP,GAAGY,KAAK,CAACN,YAAY;gBAAEO,WAAW;YAAK;YAC7C,OAAO;QACT;QAEA,OAAO;IACT;AACF;AAEA;;;;;CAKC,GACD,OAAO,eAAeC,OAAOR,UAAkB;IAC7C,IAAI;QACF,MAAME,QAAQ,MAAMR,GAAGS,IAAI,CAACH;QAC5B,OAAOE,MAAMM,MAAM;IACrB,EAAE,OAAOJ,OAAO;QACd,OAAO;IACT;AACF;AAEA;;;;;CAKC,GACD,OAAO,eAAeK,aACpBT,UAAkB;IAElB,IAAI,CAACA,WAAWU,QAAQ,CAAC,UAAU;QACjC,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAIC;IACJ,IAAI;QACFA,OAAO,MAAMd,gBAAgBE,YAAY;IAC3C,EAAE,OAAOI,OAAO;QACd,IAAIA,MAAMC,IAAI,KAAK,UAAU;YAC3B,MAAM,IAAIM,MACR,CAAC,gBAAgB,EAAEX,WAAW,sCAAsC,CAAC;QAEzE;QAEA,MAAMI;IACR;IACAQ,KAAKC,MAAM,GAAGhB,UAAUe,KAAKE,QAAQ;IACrC,OAAOF;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASG,eAAeC,MAAc,EAAEC,WAAmB;IAChE,OAAOrB,UAAUsB,IAAI,CAACF,QAAQC,eAAe;AAC/C;AAEA;;;;;;;CAOC,GACD,OAAO,SAASE,oBAAoBC,QAAgB;IAClD,IACE,CAACA,SAASV,QAAQ,CAAC,UACnBU,aAAa,SACbxB,UAAUyB,QAAQ,CAACD,cAAcA,UACjC;QACA,MAAM,IAAIT,MAAM,CAAC,sBAAsB,EAAES,SAAS,oBAAoB,CAAC;IACzE;IACA,OAAO;AACT;AAEA;;;;;;CAMC,GACD,OAAO,eAAeE,iBAAiBC,QAAgB;IACrD,MAAMC,SAAS,MAAMhB,OAAOe;IAC5B,IAAI,CAACC,QAAQ;QACX,MAAM,IAAIb,MACR,CAAC,iBAAiB,EAAEY,SAAS,kCAAkC,CAAC;IAEpE;IACA,OAAO;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeE,gBACpBC,OAAe,EACfzB,SAAkB;IAElB,MAAMuB,SAAS,MAAMzB,YAAY2B,SAASzB;IAC1C,IAAI,CAACuB,QAAQ;QACX,MAAM,IAAIb,MACR,CAAC,iBAAiB,EAAEe,QAAQ,6CAA6C,CAAC;IAE9E;IACA,OAAO;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeC,iBACpBC,QAAgB,EAChBC,YAAoB,EACpBC,EAAsC;IAEtC,MAAMP,WAAW3B,UAAUsB,IAAI,CAACvB,GAAGoC,MAAM,IAAIH;IAC7C,MAAMlC,GAAGY,KAAK,CAACV,UAAUoC,OAAO,CAACT,WAAW;QAAEhB,WAAW;IAAK;IAC9D,MAAMb,GAAGuC,SAAS,CAACV,UAAUM;IAC7B,IAAI;QACF,MAAMC,GAAGP;IACX,SAAU;QACR,IAAI,MAAMf,OAAOe,WAAW;YAC1B,MAAM7B,GAAGwC,MAAM,CAACX;QAClB;IACF;AACF"}
@@ -1,16 +0,0 @@
1
- export var HandlerType;
2
- (function(HandlerType) {
3
- HandlerType["OnRpcRequest"] = 'onRpcRequest';
4
- HandlerType["OnSignature"] = 'onSignature';
5
- HandlerType["OnTransaction"] = 'onTransaction';
6
- HandlerType["OnCronjob"] = 'onCronjob';
7
- HandlerType["OnInstall"] = 'onInstall';
8
- HandlerType["OnUpdate"] = 'onUpdate';
9
- HandlerType["OnNameLookup"] = 'onNameLookup';
10
- HandlerType["OnKeyringRequest"] = 'onKeyringRequest';
11
- HandlerType["OnHomePage"] = 'onHomePage';
12
- HandlerType["OnUserInput"] = 'onUserInput';
13
- })(HandlerType || (HandlerType = {}));
14
- export const SNAP_EXPORT_NAMES = Object.values(HandlerType);
15
-
16
- //# sourceMappingURL=handler-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/handler-types.ts"],"sourcesContent":["export enum HandlerType {\n OnRpcRequest = 'onRpcRequest',\n OnSignature = 'onSignature',\n OnTransaction = 'onTransaction',\n OnCronjob = 'onCronjob',\n OnInstall = 'onInstall',\n OnUpdate = 'onUpdate',\n OnNameLookup = 'onNameLookup',\n OnKeyringRequest = 'onKeyringRequest',\n OnHomePage = 'onHomePage',\n OnUserInput = 'onUserInput',\n}\n\nexport type SnapHandler = {\n /**\n * The type of handler.\n */\n type: HandlerType;\n\n /**\n * Whether the handler is required, i.e., whether the request will fail if the\n * handler is called, but the snap does not export it.\n *\n * This is primarily used for the lifecycle handlers, which are optional.\n */\n required: boolean;\n\n /**\n * Validate the given snap export. This should return a type guard for the\n * handler type.\n *\n * @param snapExport - The export to validate.\n * @returns Whether the export is valid.\n */\n validator: (snapExport: unknown) => boolean;\n};\n\nexport const SNAP_EXPORT_NAMES = Object.values(HandlerType);\n"],"names":["HandlerType","OnRpcRequest","OnSignature","OnTransaction","OnCronjob","OnInstall","OnUpdate","OnNameLookup","OnKeyringRequest","OnHomePage","OnUserInput","SNAP_EXPORT_NAMES","Object","values"],"mappings":"WAAO;UAAKA,WAAW;IAAXA,YACVC,kBAAe;IADLD,YAEVE,iBAAc;IAFJF,YAGVG,mBAAgB;IAHNH,YAIVI,eAAY;IAJFJ,YAKVK,eAAY;IALFL,YAMVM,cAAW;IANDN,YAOVO,kBAAe;IAPLP,YAQVQ,sBAAmB;IARTR,YASVS,gBAAa;IATHT,YAUVU,iBAAc;GAVJV,gBAAAA;AAqCZ,OAAO,MAAMW,oBAAoBC,OAAOC,MAAM,CAACb,aAAa"}
@@ -1,119 +0,0 @@
1
- import { SeverityLevel, ComponentStruct } from '@metamask/snaps-sdk';
2
- import { assign, literal, nullable, object, optional, string, array, size, union } from 'superstruct';
3
- import { HandlerType } from './handler-types';
4
- export const SNAP_EXPORTS = {
5
- [HandlerType.OnRpcRequest]: {
6
- type: HandlerType.OnRpcRequest,
7
- required: true,
8
- validator: (snapExport)=>{
9
- return typeof snapExport === 'function';
10
- }
11
- },
12
- [HandlerType.OnTransaction]: {
13
- type: HandlerType.OnTransaction,
14
- required: true,
15
- validator: (snapExport)=>{
16
- return typeof snapExport === 'function';
17
- }
18
- },
19
- [HandlerType.OnCronjob]: {
20
- type: HandlerType.OnCronjob,
21
- required: true,
22
- validator: (snapExport)=>{
23
- return typeof snapExport === 'function';
24
- }
25
- },
26
- [HandlerType.OnNameLookup]: {
27
- type: HandlerType.OnNameLookup,
28
- required: true,
29
- validator: (snapExport)=>{
30
- return typeof snapExport === 'function';
31
- }
32
- },
33
- [HandlerType.OnInstall]: {
34
- type: HandlerType.OnInstall,
35
- required: false,
36
- validator: (snapExport)=>{
37
- return typeof snapExport === 'function';
38
- }
39
- },
40
- [HandlerType.OnUpdate]: {
41
- type: HandlerType.OnUpdate,
42
- required: false,
43
- validator: (snapExport)=>{
44
- return typeof snapExport === 'function';
45
- }
46
- },
47
- [HandlerType.OnKeyringRequest]: {
48
- type: HandlerType.OnKeyringRequest,
49
- required: true,
50
- validator: (snapExport)=>{
51
- return typeof snapExport === 'function';
52
- }
53
- },
54
- [HandlerType.OnHomePage]: {
55
- type: HandlerType.OnHomePage,
56
- required: true,
57
- validator: (snapExport)=>{
58
- return typeof snapExport === 'function';
59
- }
60
- },
61
- [HandlerType.OnSignature]: {
62
- type: HandlerType.OnSignature,
63
- required: true,
64
- validator: (snapExport)=>{
65
- return typeof snapExport === 'function';
66
- }
67
- },
68
- [HandlerType.OnUserInput]: {
69
- type: HandlerType.OnUserInput,
70
- required: true,
71
- validator: (snapExport)=>{
72
- return typeof snapExport === 'function';
73
- }
74
- }
75
- };
76
- export const OnTransactionSeverityResponseStruct = object({
77
- severity: optional(literal(SeverityLevel.Critical))
78
- });
79
- export const OnTransactionResponseWithIdStruct = assign(OnTransactionSeverityResponseStruct, object({
80
- id: string()
81
- }));
82
- export const OnTransactionResponseWithContentStruct = assign(OnTransactionSeverityResponseStruct, object({
83
- content: ComponentStruct
84
- }));
85
- export const OnTransactionResponseStruct = nullable(union([
86
- OnTransactionResponseWithContentStruct,
87
- OnTransactionResponseWithIdStruct
88
- ]));
89
- export const OnSignatureResponseStruct = OnTransactionResponseStruct;
90
- export const OnHomePageResponseWithContentStruct = object({
91
- content: ComponentStruct
92
- });
93
- export const OnHomePageResponseWithIdStruct = object({
94
- id: string()
95
- });
96
- export const OnHomePageResponseStruct = union([
97
- OnHomePageResponseWithContentStruct,
98
- OnHomePageResponseWithIdStruct
99
- ]);
100
- export const AddressResolutionStruct = object({
101
- protocol: string(),
102
- resolvedDomain: string()
103
- });
104
- export const DomainResolutionStruct = object({
105
- protocol: string(),
106
- resolvedAddress: string()
107
- });
108
- export const AddressResolutionResponseStruct = object({
109
- resolvedDomains: size(array(AddressResolutionStruct), 1, Infinity)
110
- });
111
- export const DomainResolutionResponseStruct = object({
112
- resolvedAddresses: size(array(DomainResolutionStruct), 1, Infinity)
113
- });
114
- export const OnNameLookupResponseStruct = nullable(union([
115
- AddressResolutionResponseStruct,
116
- DomainResolutionResponseStruct
117
- ]));
118
-
119
- //# 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":["SeverityLevel","ComponentStruct","assign","literal","nullable","object","optional","string","array","size","union","HandlerType","SNAP_EXPORTS","OnRpcRequest","type","required","validator","snapExport","OnTransaction","OnCronjob","OnNameLookup","OnInstall","OnUpdate","OnKeyringRequest","OnHomePage","OnSignature","OnUserInput","OnTransactionSeverityResponseStruct","severity","Critical","OnTransactionResponseWithIdStruct","id","OnTransactionResponseWithContentStruct","content","OnTransactionResponseStruct","OnSignatureResponseStruct","OnHomePageResponseWithContentStruct","OnHomePageResponseWithIdStruct","OnHomePageResponseStruct","AddressResolutionStruct","protocol","resolvedDomain","DomainResolutionStruct","resolvedAddress","AddressResolutionResponseStruct","resolvedDomains","Infinity","DomainResolutionResponseStruct","resolvedAddresses","OnNameLookupResponseStruct"],"mappings":"AAYA,SAASA,aAAa,EAAEC,eAAe,QAAQ,sBAAsB;AACrE,SACEC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,IAAI,EACJC,KAAK,QACA,cAAc;AAGrB,SAASC,WAAW,QAAQ,kBAAkB;AAQ9C,OAAO,MAAMC,eAAe;IAC1B,CAACD,YAAYE,YAAY,CAAC,EAAE;QAC1BC,MAAMH,YAAYE,YAAY;QAC9BE,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYO,aAAa,CAAC,EAAE;QAC3BJ,MAAMH,YAAYO,aAAa;QAC/BH,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYQ,SAAS,CAAC,EAAE;QACvBL,MAAMH,YAAYQ,SAAS;QAC3BJ,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYS,YAAY,CAAC,EAAE;QAC1BN,MAAMH,YAAYS,YAAY;QAC9BL,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYU,SAAS,CAAC,EAAE;QACvBP,MAAMH,YAAYU,SAAS;QAC3BN,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYW,QAAQ,CAAC,EAAE;QACtBR,MAAMH,YAAYW,QAAQ;QAC1BP,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYY,gBAAgB,CAAC,EAAE;QAC9BT,MAAMH,YAAYY,gBAAgB;QAClCR,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYa,UAAU,CAAC,EAAE;QACxBV,MAAMH,YAAYa,UAAU;QAC5BT,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYc,WAAW,CAAC,EAAE;QACzBX,MAAMH,YAAYc,WAAW;QAC7BV,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYe,WAAW,CAAC,EAAE;QACzBZ,MAAMH,YAAYe,WAAW;QAC7BX,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;AACF,EAAW;AAEX,OAAO,MAAMU,sCAAsCtB,OAAO;IACxDuB,UAAUtB,SAASH,QAAQH,cAAc6B,QAAQ;AACnD,GAAG;AAEH,OAAO,MAAMC,oCAAoC5B,OAC/CyB,qCACAtB,OAAO;IACL0B,IAAIxB;AACN,IACA;AAEF,OAAO,MAAMyB,yCAAyC9B,OACpDyB,qCACAtB,OAAO;IACL4B,SAAShC;AACX,IACA;AAEF,OAAO,MAAMiC,8BAA8B9B,SACzCM,MAAM;IACJsB;IACAF;CACD,GACD;AAEF,OAAO,MAAMK,4BAA4BD,4BAA4B;AAErE,OAAO,MAAME,sCAAsC/B,OAAO;IACxD4B,SAAShC;AACX,GAAG;AAEH,OAAO,MAAMoC,iCAAiChC,OAAO;IACnD0B,IAAIxB;AACN,GAAG;AAEH,OAAO,MAAM+B,2BAA2B5B,MAAM;IAC5C0B;IACAC;CACD,EAAE;AAEH,OAAO,MAAME,0BAA0BlC,OAAO;IAC5CmC,UAAUjC;IACVkC,gBAAgBlC;AAClB,GAAG;AAEH,OAAO,MAAMmC,yBAAyBrC,OAAO;IAC3CmC,UAAUjC;IACVoC,iBAAiBpC;AACnB,GAAG;AAEH,OAAO,MAAMqC,kCAAkCvC,OAAO;IACpDwC,iBAAiBpC,KAAKD,MAAM+B,0BAA0B,GAAGO;AAC3D,GAAG;AAEH,OAAO,MAAMC,iCAAiC1C,OAAO;IACnD2C,mBAAmBvC,KAAKD,MAAMkC,yBAAyB,GAAGI;AAC5D,GAAG;AAEH,OAAO,MAAMG,6BAA6B7C,SACxCM,MAAM;IAACkC;IAAiCG;CAA+B,GACvE"}
package/dist/esm/icon.js DELETED
@@ -1,11 +0,0 @@
1
- import { assert } from '@metamask/utils';
2
- import isSvg from 'is-svg';
3
- export const SVG_MAX_BYTE_SIZE = 100000;
4
- export const SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(SVG_MAX_BYTE_SIZE / 1000)}kb`;
5
- export const assertIsSnapIcon = (icon)=>{
6
- assert(icon.path.endsWith('.svg'), 'Expected snap icon to end in ".svg".');
7
- assert(Buffer.byteLength(icon.value, 'utf8') <= SVG_MAX_BYTE_SIZE, `The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`);
8
- assert(isSvg(icon.toString()), 'Snap icon must be a valid SVG.');
9
- };
10
-
11
- //# sourceMappingURL=icon.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/icon.ts"],"sourcesContent":["import { assert } from '@metamask/utils';\nimport isSvg from 'is-svg';\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\nexport const 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"],"names":["assert","isSvg","SVG_MAX_BYTE_SIZE","SVG_MAX_BYTE_SIZE_TEXT","Math","floor","assertIsSnapIcon","icon","path","endsWith","Buffer","byteLength","value","toString"],"mappings":"AAAA,SAASA,MAAM,QAAQ,kBAAkB;AACzC,OAAOC,WAAW,SAAS;AAI3B,OAAO,MAAMC,oBAAoB,OAAQ;AACzC,OAAO,MAAMC,yBAAyB,CAAC,EAAEC,KAAKC,KAAK,CACjDH,oBAAoB,MACpB,EAAE,CAAC,CAAC;AAEN,OAAO,MAAMI,mBAAmB,CAACC;IAC/BP,OAAOO,KAAKC,IAAI,CAACC,QAAQ,CAAC,SAAS;IAEnCT,OACEU,OAAOC,UAAU,CAACJ,KAAKK,KAAK,EAAE,WAAWV,mBACzC,CAAC,mDAAmD,EAAEC,uBAAuB,CAAC,CAAC;IAGjFH,OAAOC,MAAMM,KAAKM,QAAQ,KAAK;AACjC,EAAE"}
@@ -1,49 +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
- */ export async function createWindow(uri, id, sandbox = true) {
11
- return await new Promise((resolve, reject)=>{
12
- const iframe = document.createElement('iframe');
13
- // The order of operations appears to matter for everything except this
14
- // attribute. We may as well set it here.
15
- iframe.setAttribute('id', id);
16
- iframe.setAttribute('data-testid', 'snaps-iframe');
17
- if (sandbox) {
18
- // For the sandbox property to have any effect it needs to be set before the iframe is appended.
19
- // We apply this property as a principle of least authority (POLA)
20
- // measure.
21
- // Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox
22
- iframe.setAttribute('sandbox', 'allow-scripts');
23
- }
24
- // In the past, we've had problems that appear to be symptomatic of the
25
- // iframe firing the `load` event before its scripts are actually loaded,
26
- // which has prevented snaps from executing properly. Therefore, we set
27
- // the `src` attribute and append the iframe to the DOM before attaching
28
- // the `load` listener.
29
- //
30
- // `load` should only fire when "all dependent resources" have been
31
- // loaded, which includes scripts.
32
- //
33
- // MDN article for `load` event: https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
34
- // Re: `load` firing twice: https://stackoverflow.com/questions/10781880/dynamically-created-iframe-triggers-onload-event-twice/15880489#15880489
35
- iframe.setAttribute('src', uri);
36
- document.body.appendChild(iframe);
37
- iframe.addEventListener('load', ()=>{
38
- if (iframe.contentWindow) {
39
- resolve(iframe.contentWindow);
40
- } else {
41
- // We don't know of a case when this would happen, but better to fail
42
- // fast if it does.
43
- reject(new Error(`iframe.contentWindow not present on load for job "${id}".`));
44
- }
45
- });
46
- });
47
- }
48
-
49
- //# 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,GACD,OAAO,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,32 +0,0 @@
1
- export * from './array';
2
- export * from './auxiliary-files';
3
- export * from './base64';
4
- export * from './bytes';
5
- export * from './caveats';
6
- export * from './checksum';
7
- export * from './cronjob';
8
- export * from './deep-clone';
9
- export * from './default-endowments';
10
- export * from './derivation-paths';
11
- export * from './entropy';
12
- export * from './errors';
13
- export * from './handlers';
14
- export * from './handler-types';
15
- export * from './iframe';
16
- export * from './json';
17
- export * from './json-rpc';
18
- export * from './localization';
19
- export * from './logging';
20
- export * from './manifest/index.browser';
21
- export * from './namespace';
22
- export * from './path';
23
- export * from './snaps';
24
- export * from './strings';
25
- export * from './structs';
26
- export * from './types';
27
- export * from './ui';
28
- export * from './validation';
29
- export * from './versions';
30
- export * from './virtual-file/index.browser';
31
-
32
- //# 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":"AAAA,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,uBAAuB;AACrC,cAAc,qBAAqB;AACnC,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,2BAA2B;AACzC,cAAc,cAAc;AAC5B,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,OAAO;AACrB,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,+BAA+B"}
@@ -1,10 +0,0 @@
1
- // Special entrypoint for execution environments for bundle sizing reasons
2
- export * from './errors';
3
- export * from './handlers';
4
- export * from './handler-types';
5
- export * from './iframe';
6
- export * from './logging';
7
- export * from './namespace';
8
- export * from './types';
9
-
10
- //# 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;AAC1E,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,UAAU"}
package/dist/esm/index.js DELETED
@@ -1,37 +0,0 @@
1
- export * from './array';
2
- export * from './auxiliary-files';
3
- export * from './base64';
4
- export * from './bytes';
5
- export * from './caveats';
6
- export * from './cronjob';
7
- export * from './checksum';
8
- export * from './deep-clone';
9
- export * from './default-endowments';
10
- export * from './derivation-paths';
11
- export * from './entropy';
12
- export * from './eval';
13
- export * from './errors';
14
- export * from './fs';
15
- export * from './handlers';
16
- export * from './handler-types';
17
- export * from './iframe';
18
- export * from './json';
19
- export * from './json-rpc';
20
- export * from './localization';
21
- export * from './logging';
22
- export * from './manifest';
23
- export * from './mock';
24
- export * from './namespace';
25
- export * from './npm';
26
- export * from './path';
27
- export * from './post-process';
28
- export * from './snaps';
29
- export * from './strings';
30
- export * from './structs';
31
- export * from './types';
32
- export * from './ui';
33
- export * from './validation';
34
- export * from './versions';
35
- export * from './virtual-file';
36
-
37
- //# 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":"AAAA,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,uBAAuB;AACrC,cAAc,qBAAqB;AACnC,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,OAAO;AACrB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,OAAO;AACrB,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,iBAAiB"}