@metamask/snaps-utils 7.0.0 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/array.js +2 -2
  3. package/dist/array.mjs +2 -2
  4. package/dist/auxiliary-files.js +6 -6
  5. package/dist/auxiliary-files.mjs +6 -6
  6. package/dist/base64.js +5 -5
  7. package/dist/base64.mjs +5 -5
  8. package/dist/bytes.js +4 -4
  9. package/dist/bytes.mjs +4 -4
  10. package/dist/caveats.js +2 -2
  11. package/dist/caveats.mjs +2 -2
  12. package/dist/checksum.js +5 -5
  13. package/dist/checksum.mjs +5 -5
  14. package/dist/{chunk-Y3F7VUZB.mjs → chunk-224DMTNJ.mjs} +10 -10
  15. package/dist/{chunk-FJH6DDEL.mjs → chunk-2IWSQJKQ.mjs} +3 -3
  16. package/dist/{chunk-2QS3W66J.js → chunk-2LBN5T56.js} +4 -4
  17. package/dist/{chunk-3TH3NLQL.js → chunk-2PCPD5XY.js} +6 -6
  18. package/dist/{chunk-KWQKGJSV.js → chunk-3SOYDY4W.js} +1 -1
  19. package/dist/{chunk-ZXCNX3ZB.mjs → chunk-44GPX66J.mjs} +1 -1
  20. package/dist/{chunk-WDGBH5CP.js → chunk-44VFHYJO.js} +9 -9
  21. package/dist/chunk-44VFHYJO.js.map +1 -0
  22. package/dist/{chunk-R4BBIGBN.js → chunk-473MIETW.js} +3 -3
  23. package/dist/{chunk-KEXZDQAN.js → chunk-4BDR6KRH.js} +2 -2
  24. package/dist/chunk-4CMD46B2.js +1 -0
  25. package/dist/{chunk-TUAHXE75.mjs → chunk-5R7UF7KM.mjs} +1 -1
  26. package/dist/{chunk-P5V6S2PA.mjs → chunk-63OXILAY.mjs} +2 -2
  27. package/dist/{chunk-QWEXXUTO.mjs → chunk-6CHO3LOX.mjs} +1 -1
  28. package/dist/{chunk-B3YQVRPE.js → chunk-6LOYTBS3.js} +4 -4
  29. package/dist/{chunk-VGWELVCX.mjs → chunk-6YRUDGNL.mjs} +2 -2
  30. package/dist/{chunk-7H5TGXZ5.js → chunk-772OPTGX.js} +3 -3
  31. package/dist/{chunk-XC5E26VE.mjs → chunk-7LG4D4XA.mjs} +1 -1
  32. package/dist/chunk-7LOABHVW.js +1 -0
  33. package/dist/chunk-7MTAHOWC.mjs +1 -0
  34. package/dist/{chunk-F33RMB76.js → chunk-7P62OIGX.js} +7 -7
  35. package/dist/{chunk-32B4YQM7.mjs → chunk-7Y3WSN44.mjs} +3 -3
  36. package/dist/chunk-A3RRMELT.mjs +1 -0
  37. package/dist/{chunk-GMC2A3D7.js → chunk-A6E325SZ.js} +3 -3
  38. package/dist/{chunk-RS5HE55U.js → chunk-AFQY2CNY.js} +3 -3
  39. package/dist/{chunk-I3BUOULW.js → chunk-AOGVLPQZ.js} +1 -1
  40. package/dist/{chunk-QF3LHIJ5.mjs → chunk-AS5P6JRP.mjs} +1 -1
  41. package/dist/{chunk-MJABESWH.js → chunk-ASZWZ7JT.js} +1 -1
  42. package/dist/{chunk-3ZSMMNQB.mjs → chunk-BGSO2GQC.mjs} +1 -1
  43. package/dist/{chunk-4UMDRHDR.js → chunk-CMOSYNZR.js} +2 -2
  44. package/dist/{chunk-GK4IJQVW.js → chunk-CNNMLOQ6.js} +43 -43
  45. package/dist/{chunk-ZRVOIW3H.js → chunk-CQRPSEH3.js} +3 -3
  46. package/dist/{chunk-DKSB4FMW.mjs → chunk-DKDGMZFU.mjs} +1 -1
  47. package/dist/{chunk-IWENO6LT.js → chunk-E3BDBG6T.js} +1 -1
  48. package/dist/{chunk-YLT6CNSL.mjs → chunk-EA2FOAEG.mjs} +1 -1
  49. package/dist/chunk-EFRPCO3C.js +1 -0
  50. package/dist/{chunk-OQSLMZJN.js → chunk-ENKAY3PI.js} +18 -18
  51. package/dist/{chunk-7T3N2ZGQ.mjs → chunk-EXUEHPZ4.mjs} +1 -1
  52. package/dist/{chunk-JGMGNLZW.mjs → chunk-FOWIC2SO.mjs} +2 -2
  53. package/dist/{chunk-2IVFF3AA.mjs → chunk-GTAYOKI4.mjs} +2 -2
  54. package/dist/{chunk-6H32HLTZ.js → chunk-HF7HUZ5Z.js} +1 -1
  55. package/dist/{chunk-LHIPBIPS.mjs → chunk-HJRCBSNA.mjs} +2 -2
  56. package/dist/chunk-HJYRGKCX.js +50 -0
  57. package/dist/chunk-HYF7Q6VY.mjs +1 -0
  58. package/dist/{chunk-Z4J4GUGG.mjs → chunk-I77AVJKV.mjs} +1 -1
  59. package/dist/{chunk-HOTDTMNP.mjs → chunk-IGMAXVPP.mjs} +2 -2
  60. package/dist/{chunk-7KKLGQNE.js → chunk-IHQPAJ2B.js} +3 -3
  61. package/dist/{chunk-6WBLB5BX.js → chunk-IJX3CXOY.js} +1 -1
  62. package/dist/{chunk-WJOAEPZ7.js → chunk-IPOE62V4.js} +1 -1
  63. package/dist/{chunk-7XA5VYYV.mjs → chunk-IV3FSWZ7.mjs} +1 -1
  64. package/dist/{chunk-7PNGOFLU.js → chunk-IXBJNVHK.js} +3 -3
  65. package/dist/chunk-JI5NQ2C3.mjs +1 -0
  66. package/dist/{chunk-4GBOSMF7.mjs → chunk-JMDSN227.mjs} +2 -10
  67. package/dist/{chunk-XRGYWWT7.js → chunk-K6BCBPXF.js} +1 -1
  68. package/dist/{chunk-2G4HD42C.mjs → chunk-KMLVVVK3.mjs} +2 -2
  69. package/dist/{chunk-ZLFA4R5X.js → chunk-LBRWAC27.js} +3 -3
  70. package/dist/{chunk-HWFLO7W5.mjs → chunk-LCWDLIK5.mjs} +8 -8
  71. package/dist/{chunk-XEY3KVEH.js → chunk-LEKZPKS2.js} +1 -1
  72. package/dist/{chunk-TURGGK5F.mjs → chunk-LSPOXPJJ.mjs} +9 -5
  73. package/dist/chunk-LSPOXPJJ.mjs.map +1 -0
  74. package/dist/{chunk-UGQQ5DJ4.mjs → chunk-MCEKOGEG.mjs} +1 -1
  75. package/dist/{chunk-224S5XKL.js → chunk-MLOQHUOY.js} +5 -5
  76. package/dist/{chunk-QYFDFOWT.js → chunk-N722KRZW.js} +1 -1
  77. package/dist/{chunk-Q7FGULTV.js → chunk-NUCLSR2G.js} +1 -1
  78. package/dist/{chunk-XKXHM3PC.mjs → chunk-P252LKUT.mjs} +1 -1
  79. package/dist/{chunk-IUNNN6HN.mjs → chunk-PJMEJVOB.mjs} +1 -1
  80. package/dist/{chunk-RRPU7M4Y.js → chunk-PLBSSUVY.js} +1 -1
  81. package/dist/chunk-Q7RCL5IE.js +30 -0
  82. package/dist/{chunk-R7UAMO2U.js → chunk-QSCKTRRU.js} +3 -3
  83. package/dist/{chunk-H34N3OWO.mjs → chunk-QX6MAFJU.mjs} +2 -2
  84. package/dist/{chunk-O3XKEEJV.mjs → chunk-QYPLUMB7.mjs} +2 -2
  85. package/dist/chunk-QYPLUMB7.mjs.map +1 -0
  86. package/dist/chunk-RAZ7XG4Z.mjs +1 -0
  87. package/dist/chunk-RAZ7XG4Z.mjs.map +1 -0
  88. package/dist/{chunk-6CTV7VW5.mjs → chunk-SRMDDOVO.mjs} +1 -1
  89. package/dist/chunk-T3VM5YXY.js +1 -0
  90. package/dist/{chunk-FTY3BOF7.js → chunk-T3YY4JIJ.js} +1 -1
  91. package/dist/{chunk-ZVXX2CTH.mjs → chunk-T6FWIDA6.mjs} +1 -1
  92. package/dist/chunk-TFP64TMV.js +1 -0
  93. package/dist/{chunk-H636DAOG.js → chunk-TG4BDSYJ.js} +12 -12
  94. package/dist/{chunk-43EBXDVP.mjs → chunk-UMZNVWEM.mjs} +1 -1
  95. package/dist/{chunk-3SARO5TJ.mjs → chunk-UW74NLTC.mjs} +1 -1
  96. package/dist/{chunk-GW5NQXN4.mjs → chunk-VWGXNUMD.mjs} +2 -2
  97. package/dist/{chunk-N52KMB25.mjs → chunk-WEOCOYES.mjs} +2 -2
  98. package/dist/{chunk-4IKNNAVC.mjs → chunk-WF56W2AR.mjs} +5 -5
  99. package/dist/{chunk-VMUXXXJC.js → chunk-X44Z53IG.js} +5 -5
  100. package/dist/{chunk-B2DMAQNK.mjs → chunk-Z2JQNSVL.mjs} +1 -1
  101. package/dist/{chunk-LOW2T4MV.mjs → chunk-ZJRWU4AJ.mjs} +2 -2
  102. package/dist/{chunk-MSUZTHYT.js → chunk-ZT3KKTS2.js} +1 -1
  103. package/dist/cronjob.js +2 -2
  104. package/dist/cronjob.mjs +2 -2
  105. package/dist/deep-clone.js +2 -2
  106. package/dist/deep-clone.mjs +2 -2
  107. package/dist/default-endowments.js +2 -2
  108. package/dist/default-endowments.mjs +2 -2
  109. package/dist/derivation-paths.js +3 -3
  110. package/dist/derivation-paths.mjs +3 -3
  111. package/dist/entropy.js +2 -2
  112. package/dist/entropy.mjs +2 -2
  113. package/dist/errors.js +2 -2
  114. package/dist/errors.mjs +2 -2
  115. package/dist/eval-worker.js +5 -5
  116. package/dist/eval-worker.mjs +4 -4
  117. package/dist/eval.js +9 -9
  118. package/dist/eval.mjs +9 -9
  119. package/dist/fs.js +8 -8
  120. package/dist/fs.mjs +8 -8
  121. package/dist/handler-types.js +2 -2
  122. package/dist/handler-types.mjs +2 -2
  123. package/dist/handlers.js +3 -3
  124. package/dist/handlers.mjs +3 -3
  125. package/dist/icon.js +2 -2
  126. package/dist/icon.mjs +2 -2
  127. package/dist/iframe.js +2 -2
  128. package/dist/iframe.mjs +2 -2
  129. package/dist/index.executionenv.js +8 -8
  130. package/dist/index.executionenv.mjs +8 -8
  131. package/dist/index.js +35 -35
  132. package/dist/index.mjs +35 -35
  133. package/dist/json-rpc.js +2 -2
  134. package/dist/json-rpc.mjs +2 -2
  135. package/dist/json.js +2 -2
  136. package/dist/json.mjs +2 -2
  137. package/dist/localization.js +3 -3
  138. package/dist/localization.mjs +3 -3
  139. package/dist/logging.js +2 -2
  140. package/dist/logging.mjs +2 -2
  141. package/dist/manifest/index.js +15 -15
  142. package/dist/manifest/index.mjs +15 -15
  143. package/dist/manifest/manifest.js +22 -22
  144. package/dist/manifest/manifest.mjs +22 -22
  145. package/dist/manifest/node.js +24 -24
  146. package/dist/manifest/node.mjs +24 -24
  147. package/dist/manifest/validation.js +14 -14
  148. package/dist/manifest/validation.mjs +14 -14
  149. package/dist/mock.js +3 -3
  150. package/dist/mock.mjs +3 -3
  151. package/dist/namespace.js +2 -2
  152. package/dist/namespace.mjs +2 -2
  153. package/dist/node.js +43 -43
  154. package/dist/node.mjs +43 -43
  155. package/dist/npm.js +22 -22
  156. package/dist/npm.mjs +22 -22
  157. package/dist/path.js +2 -2
  158. package/dist/path.mjs +2 -2
  159. package/dist/post-process.js +2 -2
  160. package/dist/post-process.mjs +2 -2
  161. package/dist/snaps.js +8 -8
  162. package/dist/snaps.mjs +8 -8
  163. package/dist/strings.js +2 -2
  164. package/dist/strings.mjs +2 -2
  165. package/dist/structs.js +3 -3
  166. package/dist/structs.mjs +3 -3
  167. package/dist/tsconfig.build.tsbuildinfo +1 -1
  168. package/dist/types.js +2 -2
  169. package/dist/types.mjs +2 -2
  170. package/dist/ui.js +2 -2
  171. package/dist/ui.mjs +2 -2
  172. package/dist/validation.js +18 -18
  173. package/dist/validation.mjs +18 -18
  174. package/dist/versions.js +2 -2
  175. package/dist/versions.mjs +2 -2
  176. package/dist/virtual-file/VirtualFile.js +3 -3
  177. package/dist/virtual-file/VirtualFile.mjs +3 -3
  178. package/dist/virtual-file/index.js +4 -4
  179. package/dist/virtual-file/index.mjs +4 -4
  180. package/dist/virtual-file/node.js +6 -6
  181. package/dist/virtual-file/node.mjs +6 -6
  182. package/dist/virtual-file/toVirtualFile.js +4 -4
  183. package/dist/virtual-file/toVirtualFile.mjs +4 -4
  184. package/package.json +2 -2
  185. package/dist/chunk-2XF32FCF.js +0 -1
  186. package/dist/chunk-4GBOSMF7.mjs.map +0 -1
  187. package/dist/chunk-DK3IYVMP.mjs +0 -1
  188. package/dist/chunk-IIDK6BRC.mjs +0 -1
  189. package/dist/chunk-JV7OA3FD.js +0 -1
  190. package/dist/chunk-LEFOMYX3.mjs +0 -1
  191. package/dist/chunk-MYSBDK36.mjs +0 -1
  192. package/dist/chunk-O3XKEEJV.mjs.map +0 -1
  193. package/dist/chunk-O4PW77JW.mjs +0 -1
  194. package/dist/chunk-Q5T57UNN.js +0 -1
  195. package/dist/chunk-QJTAFTW7.js +0 -30
  196. package/dist/chunk-TURGGK5F.mjs.map +0 -1
  197. package/dist/chunk-WDGBH5CP.js.map +0 -1
  198. package/dist/chunk-XDEHYKW2.js +0 -1
  199. package/dist/chunk-XWFKTDB3.js +0 -50
  200. package/dist/chunk-YF4PGFCO.js +0 -1
  201. /package/dist/{chunk-Y3F7VUZB.mjs.map → chunk-224DMTNJ.mjs.map} +0 -0
  202. /package/dist/{chunk-FJH6DDEL.mjs.map → chunk-2IWSQJKQ.mjs.map} +0 -0
  203. /package/dist/{chunk-2QS3W66J.js.map → chunk-2LBN5T56.js.map} +0 -0
  204. /package/dist/{chunk-3TH3NLQL.js.map → chunk-2PCPD5XY.js.map} +0 -0
  205. /package/dist/{chunk-KWQKGJSV.js.map → chunk-3SOYDY4W.js.map} +0 -0
  206. /package/dist/{chunk-ZXCNX3ZB.mjs.map → chunk-44GPX66J.mjs.map} +0 -0
  207. /package/dist/{chunk-R4BBIGBN.js.map → chunk-473MIETW.js.map} +0 -0
  208. /package/dist/{chunk-KEXZDQAN.js.map → chunk-4BDR6KRH.js.map} +0 -0
  209. /package/dist/{chunk-2XF32FCF.js.map → chunk-4CMD46B2.js.map} +0 -0
  210. /package/dist/{chunk-TUAHXE75.mjs.map → chunk-5R7UF7KM.mjs.map} +0 -0
  211. /package/dist/{chunk-P5V6S2PA.mjs.map → chunk-63OXILAY.mjs.map} +0 -0
  212. /package/dist/{chunk-QWEXXUTO.mjs.map → chunk-6CHO3LOX.mjs.map} +0 -0
  213. /package/dist/{chunk-B3YQVRPE.js.map → chunk-6LOYTBS3.js.map} +0 -0
  214. /package/dist/{chunk-VGWELVCX.mjs.map → chunk-6YRUDGNL.mjs.map} +0 -0
  215. /package/dist/{chunk-7H5TGXZ5.js.map → chunk-772OPTGX.js.map} +0 -0
  216. /package/dist/{chunk-XC5E26VE.mjs.map → chunk-7LG4D4XA.mjs.map} +0 -0
  217. /package/dist/{chunk-JV7OA3FD.js.map → chunk-7LOABHVW.js.map} +0 -0
  218. /package/dist/{chunk-DK3IYVMP.mjs.map → chunk-7MTAHOWC.mjs.map} +0 -0
  219. /package/dist/{chunk-F33RMB76.js.map → chunk-7P62OIGX.js.map} +0 -0
  220. /package/dist/{chunk-32B4YQM7.mjs.map → chunk-7Y3WSN44.mjs.map} +0 -0
  221. /package/dist/{chunk-IIDK6BRC.mjs.map → chunk-A3RRMELT.mjs.map} +0 -0
  222. /package/dist/{chunk-GMC2A3D7.js.map → chunk-A6E325SZ.js.map} +0 -0
  223. /package/dist/{chunk-RS5HE55U.js.map → chunk-AFQY2CNY.js.map} +0 -0
  224. /package/dist/{chunk-I3BUOULW.js.map → chunk-AOGVLPQZ.js.map} +0 -0
  225. /package/dist/{chunk-QF3LHIJ5.mjs.map → chunk-AS5P6JRP.mjs.map} +0 -0
  226. /package/dist/{chunk-MJABESWH.js.map → chunk-ASZWZ7JT.js.map} +0 -0
  227. /package/dist/{chunk-3ZSMMNQB.mjs.map → chunk-BGSO2GQC.mjs.map} +0 -0
  228. /package/dist/{chunk-4UMDRHDR.js.map → chunk-CMOSYNZR.js.map} +0 -0
  229. /package/dist/{chunk-GK4IJQVW.js.map → chunk-CNNMLOQ6.js.map} +0 -0
  230. /package/dist/{chunk-ZRVOIW3H.js.map → chunk-CQRPSEH3.js.map} +0 -0
  231. /package/dist/{chunk-DKSB4FMW.mjs.map → chunk-DKDGMZFU.mjs.map} +0 -0
  232. /package/dist/{chunk-IWENO6LT.js.map → chunk-E3BDBG6T.js.map} +0 -0
  233. /package/dist/{chunk-YLT6CNSL.mjs.map → chunk-EA2FOAEG.mjs.map} +0 -0
  234. /package/dist/{chunk-Q5T57UNN.js.map → chunk-EFRPCO3C.js.map} +0 -0
  235. /package/dist/{chunk-OQSLMZJN.js.map → chunk-ENKAY3PI.js.map} +0 -0
  236. /package/dist/{chunk-7T3N2ZGQ.mjs.map → chunk-EXUEHPZ4.mjs.map} +0 -0
  237. /package/dist/{chunk-JGMGNLZW.mjs.map → chunk-FOWIC2SO.mjs.map} +0 -0
  238. /package/dist/{chunk-2IVFF3AA.mjs.map → chunk-GTAYOKI4.mjs.map} +0 -0
  239. /package/dist/{chunk-6H32HLTZ.js.map → chunk-HF7HUZ5Z.js.map} +0 -0
  240. /package/dist/{chunk-LHIPBIPS.mjs.map → chunk-HJRCBSNA.mjs.map} +0 -0
  241. /package/dist/{chunk-XWFKTDB3.js.map → chunk-HJYRGKCX.js.map} +0 -0
  242. /package/dist/{chunk-LEFOMYX3.mjs.map → chunk-HYF7Q6VY.mjs.map} +0 -0
  243. /package/dist/{chunk-Z4J4GUGG.mjs.map → chunk-I77AVJKV.mjs.map} +0 -0
  244. /package/dist/{chunk-HOTDTMNP.mjs.map → chunk-IGMAXVPP.mjs.map} +0 -0
  245. /package/dist/{chunk-7KKLGQNE.js.map → chunk-IHQPAJ2B.js.map} +0 -0
  246. /package/dist/{chunk-6WBLB5BX.js.map → chunk-IJX3CXOY.js.map} +0 -0
  247. /package/dist/{chunk-WJOAEPZ7.js.map → chunk-IPOE62V4.js.map} +0 -0
  248. /package/dist/{chunk-7XA5VYYV.mjs.map → chunk-IV3FSWZ7.mjs.map} +0 -0
  249. /package/dist/{chunk-7PNGOFLU.js.map → chunk-IXBJNVHK.js.map} +0 -0
  250. /package/dist/{chunk-MYSBDK36.mjs.map → chunk-JI5NQ2C3.mjs.map} +0 -0
  251. /package/dist/{chunk-O4PW77JW.mjs.map → chunk-JMDSN227.mjs.map} +0 -0
  252. /package/dist/{chunk-XRGYWWT7.js.map → chunk-K6BCBPXF.js.map} +0 -0
  253. /package/dist/{chunk-2G4HD42C.mjs.map → chunk-KMLVVVK3.mjs.map} +0 -0
  254. /package/dist/{chunk-ZLFA4R5X.js.map → chunk-LBRWAC27.js.map} +0 -0
  255. /package/dist/{chunk-HWFLO7W5.mjs.map → chunk-LCWDLIK5.mjs.map} +0 -0
  256. /package/dist/{chunk-XEY3KVEH.js.map → chunk-LEKZPKS2.js.map} +0 -0
  257. /package/dist/{chunk-UGQQ5DJ4.mjs.map → chunk-MCEKOGEG.mjs.map} +0 -0
  258. /package/dist/{chunk-224S5XKL.js.map → chunk-MLOQHUOY.js.map} +0 -0
  259. /package/dist/{chunk-QYFDFOWT.js.map → chunk-N722KRZW.js.map} +0 -0
  260. /package/dist/{chunk-Q7FGULTV.js.map → chunk-NUCLSR2G.js.map} +0 -0
  261. /package/dist/{chunk-XKXHM3PC.mjs.map → chunk-P252LKUT.mjs.map} +0 -0
  262. /package/dist/{chunk-IUNNN6HN.mjs.map → chunk-PJMEJVOB.mjs.map} +0 -0
  263. /package/dist/{chunk-RRPU7M4Y.js.map → chunk-PLBSSUVY.js.map} +0 -0
  264. /package/dist/{chunk-QJTAFTW7.js.map → chunk-Q7RCL5IE.js.map} +0 -0
  265. /package/dist/{chunk-R7UAMO2U.js.map → chunk-QSCKTRRU.js.map} +0 -0
  266. /package/dist/{chunk-H34N3OWO.mjs.map → chunk-QX6MAFJU.mjs.map} +0 -0
  267. /package/dist/{chunk-6CTV7VW5.mjs.map → chunk-SRMDDOVO.mjs.map} +0 -0
  268. /package/dist/{chunk-XDEHYKW2.js.map → chunk-T3VM5YXY.js.map} +0 -0
  269. /package/dist/{chunk-FTY3BOF7.js.map → chunk-T3YY4JIJ.js.map} +0 -0
  270. /package/dist/{chunk-ZVXX2CTH.mjs.map → chunk-T6FWIDA6.mjs.map} +0 -0
  271. /package/dist/{chunk-YF4PGFCO.js.map → chunk-TFP64TMV.js.map} +0 -0
  272. /package/dist/{chunk-H636DAOG.js.map → chunk-TG4BDSYJ.js.map} +0 -0
  273. /package/dist/{chunk-43EBXDVP.mjs.map → chunk-UMZNVWEM.mjs.map} +0 -0
  274. /package/dist/{chunk-3SARO5TJ.mjs.map → chunk-UW74NLTC.mjs.map} +0 -0
  275. /package/dist/{chunk-GW5NQXN4.mjs.map → chunk-VWGXNUMD.mjs.map} +0 -0
  276. /package/dist/{chunk-N52KMB25.mjs.map → chunk-WEOCOYES.mjs.map} +0 -0
  277. /package/dist/{chunk-4IKNNAVC.mjs.map → chunk-WF56W2AR.mjs.map} +0 -0
  278. /package/dist/{chunk-VMUXXXJC.js.map → chunk-X44Z53IG.js.map} +0 -0
  279. /package/dist/{chunk-B2DMAQNK.mjs.map → chunk-Z2JQNSVL.mjs.map} +0 -0
  280. /package/dist/{chunk-LOW2T4MV.mjs.map → chunk-ZJRWU4AJ.mjs.map} +0 -0
  281. /package/dist/{chunk-MSUZTHYT.js.map → chunk-ZT3KKTS2.js.map} +0 -0
package/dist/types.js CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- var _chunk4UMDRHDRjs = require('./chunk-4UMDRHDR.js');
13
+ var _chunkCMOSYNZRjs = require('./chunk-CMOSYNZR.js');
14
14
  require('./chunk-PHUTP7NB.js');
15
15
 
16
16
 
@@ -24,5 +24,5 @@ require('./chunk-PHUTP7NB.js');
24
24
 
25
25
 
26
26
 
27
- exports.NameStruct = _chunk4UMDRHDRjs.NameStruct; exports.NpmSnapFileNames = _chunk4UMDRHDRjs.NpmSnapFileNames; exports.NpmSnapPackageJsonStruct = _chunk4UMDRHDRjs.NpmSnapPackageJsonStruct; exports.SNAP_STREAM_NAMES = _chunk4UMDRHDRjs.SNAP_STREAM_NAMES; exports.SnapIdPrefixes = _chunk4UMDRHDRjs.SnapIdPrefixes; exports.SnapValidationFailureReason = _chunk4UMDRHDRjs.SnapValidationFailureReason; exports.WALLET_SNAP_PERMISSION_KEY = _chunk4UMDRHDRjs.WALLET_SNAP_PERMISSION_KEY; exports.assertIsNpmSnapPackageJson = _chunk4UMDRHDRjs.assertIsNpmSnapPackageJson; exports.isNpmSnapPackageJson = _chunk4UMDRHDRjs.isNpmSnapPackageJson; exports.isValidUrl = _chunk4UMDRHDRjs.isValidUrl; exports.uri = _chunk4UMDRHDRjs.uri;
27
+ exports.NameStruct = _chunkCMOSYNZRjs.NameStruct; exports.NpmSnapFileNames = _chunkCMOSYNZRjs.NpmSnapFileNames; exports.NpmSnapPackageJsonStruct = _chunkCMOSYNZRjs.NpmSnapPackageJsonStruct; exports.SNAP_STREAM_NAMES = _chunkCMOSYNZRjs.SNAP_STREAM_NAMES; exports.SnapIdPrefixes = _chunkCMOSYNZRjs.SnapIdPrefixes; exports.SnapValidationFailureReason = _chunkCMOSYNZRjs.SnapValidationFailureReason; exports.WALLET_SNAP_PERMISSION_KEY = _chunkCMOSYNZRjs.WALLET_SNAP_PERMISSION_KEY; exports.assertIsNpmSnapPackageJson = _chunkCMOSYNZRjs.assertIsNpmSnapPackageJson; exports.isNpmSnapPackageJson = _chunkCMOSYNZRjs.isNpmSnapPackageJson; exports.isValidUrl = _chunkCMOSYNZRjs.isValidUrl; exports.uri = _chunkCMOSYNZRjs.uri;
28
28
  //# sourceMappingURL=types.js.map
package/dist/types.mjs CHANGED
@@ -10,8 +10,8 @@ import {
10
10
  isNpmSnapPackageJson,
11
11
  isValidUrl,
12
12
  uri
13
- } from "./chunk-ZVXX2CTH.mjs";
14
- import "./chunk-4GBOSMF7.mjs";
13
+ } from "./chunk-T6FWIDA6.mjs";
14
+ import "./chunk-JMDSN227.mjs";
15
15
  export {
16
16
  NameStruct,
17
17
  NpmSnapFileNames,
package/dist/ui.js CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk7H5TGXZ5js = require('./chunk-7H5TGXZ5.js');
5
+ var _chunk772OPTGXjs = require('./chunk-772OPTGX.js');
6
6
  require('./chunk-PHUTP7NB.js');
7
7
 
8
8
 
9
9
 
10
10
 
11
- exports.getTotalTextLength = _chunk7H5TGXZ5js.getTotalTextLength; exports.validateComponentLinks = _chunk7H5TGXZ5js.validateComponentLinks; exports.validateTextLinks = _chunk7H5TGXZ5js.validateTextLinks;
11
+ exports.getTotalTextLength = _chunk772OPTGXjs.getTotalTextLength; exports.validateComponentLinks = _chunk772OPTGXjs.validateComponentLinks; exports.validateTextLinks = _chunk772OPTGXjs.validateTextLinks;
12
12
  //# sourceMappingURL=ui.js.map
package/dist/ui.mjs CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  getTotalTextLength,
3
3
  validateComponentLinks,
4
4
  validateTextLinks
5
- } from "./chunk-ZXCNX3ZB.mjs";
6
- import "./chunk-4GBOSMF7.mjs";
5
+ } from "./chunk-44GPX66J.mjs";
6
+ import "./chunk-JMDSN227.mjs";
7
7
  export {
8
8
  getTotalTextLength,
9
9
  validateComponentLinks,
@@ -1,24 +1,24 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkQJTAFTW7js = require('./chunk-QJTAFTW7.js');
4
- require('./chunk-OQSLMZJN.js');
5
- require('./chunk-H636DAOG.js');
6
- require('./chunk-KEXZDQAN.js');
7
- require('./chunk-B3YQVRPE.js');
8
- require('./chunk-4UMDRHDR.js');
9
- require('./chunk-ZRVOIW3H.js');
10
- require('./chunk-RS5HE55U.js');
11
- require('./chunk-MSUZTHYT.js');
12
- require('./chunk-6H32HLTZ.js');
13
- require('./chunk-FTY3BOF7.js');
14
- require('./chunk-MJABESWH.js');
15
- require('./chunk-224S5XKL.js');
16
- require('./chunk-R4BBIGBN.js');
17
- require('./chunk-XWFKTDB3.js');
18
- require('./chunk-2QS3W66J.js');
19
- require('./chunk-Q7FGULTV.js');
3
+ var _chunkQ7RCL5IEjs = require('./chunk-Q7RCL5IE.js');
4
+ require('./chunk-ENKAY3PI.js');
5
+ require('./chunk-TG4BDSYJ.js');
6
+ require('./chunk-4BDR6KRH.js');
7
+ require('./chunk-6LOYTBS3.js');
8
+ require('./chunk-CMOSYNZR.js');
9
+ require('./chunk-CQRPSEH3.js');
10
+ require('./chunk-AFQY2CNY.js');
11
+ require('./chunk-ZT3KKTS2.js');
12
+ require('./chunk-HF7HUZ5Z.js');
13
+ require('./chunk-T3YY4JIJ.js');
14
+ require('./chunk-ASZWZ7JT.js');
15
+ require('./chunk-MLOQHUOY.js');
16
+ require('./chunk-473MIETW.js');
17
+ require('./chunk-HJYRGKCX.js');
18
+ require('./chunk-2LBN5T56.js');
19
+ require('./chunk-NUCLSR2G.js');
20
20
  require('./chunk-PHUTP7NB.js');
21
21
 
22
22
 
23
- exports.validateFetchedSnap = _chunkQJTAFTW7js.validateFetchedSnap;
23
+ exports.validateFetchedSnap = _chunkQ7RCL5IEjs.validateFetchedSnap;
24
24
  //# sourceMappingURL=validation.js.map
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  validateFetchedSnap
3
- } from "./chunk-4IKNNAVC.mjs";
4
- import "./chunk-HWFLO7W5.mjs";
5
- import "./chunk-FJH6DDEL.mjs";
6
- import "./chunk-UGQQ5DJ4.mjs";
7
- import "./chunk-7T3N2ZGQ.mjs";
8
- import "./chunk-ZVXX2CTH.mjs";
9
- import "./chunk-DKSB4FMW.mjs";
10
- import "./chunk-N52KMB25.mjs";
11
- import "./chunk-QF3LHIJ5.mjs";
12
- import "./chunk-QWEXXUTO.mjs";
13
- import "./chunk-XKXHM3PC.mjs";
14
- import "./chunk-XC5E26VE.mjs";
15
- import "./chunk-LHIPBIPS.mjs";
16
- import "./chunk-VGWELVCX.mjs";
17
- import "./chunk-LOW2T4MV.mjs";
18
- import "./chunk-YLT6CNSL.mjs";
19
- import "./chunk-B2DMAQNK.mjs";
20
- import "./chunk-4GBOSMF7.mjs";
3
+ } from "./chunk-WF56W2AR.mjs";
4
+ import "./chunk-LCWDLIK5.mjs";
5
+ import "./chunk-2IWSQJKQ.mjs";
6
+ import "./chunk-MCEKOGEG.mjs";
7
+ import "./chunk-EXUEHPZ4.mjs";
8
+ import "./chunk-T6FWIDA6.mjs";
9
+ import "./chunk-DKDGMZFU.mjs";
10
+ import "./chunk-WEOCOYES.mjs";
11
+ import "./chunk-AS5P6JRP.mjs";
12
+ import "./chunk-6CHO3LOX.mjs";
13
+ import "./chunk-P252LKUT.mjs";
14
+ import "./chunk-7LG4D4XA.mjs";
15
+ import "./chunk-HJRCBSNA.mjs";
16
+ import "./chunk-6YRUDGNL.mjs";
17
+ import "./chunk-ZJRWU4AJ.mjs";
18
+ import "./chunk-EA2FOAEG.mjs";
19
+ import "./chunk-Z2JQNSVL.mjs";
20
+ import "./chunk-JMDSN227.mjs";
21
21
  export {
22
22
  validateFetchedSnap
23
23
  };
package/dist/versions.js CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkWJOAEPZ7js = require('./chunk-WJOAEPZ7.js');
5
+ var _chunkIPOE62V4js = require('./chunk-IPOE62V4.js');
6
6
  require('./chunk-PHUTP7NB.js');
7
7
 
8
8
 
9
9
 
10
10
 
11
- exports.DEFAULT_REQUESTED_SNAP_VERSION = _chunkWJOAEPZ7js.DEFAULT_REQUESTED_SNAP_VERSION; exports.getTargetVersion = _chunkWJOAEPZ7js.getTargetVersion; exports.resolveVersionRange = _chunkWJOAEPZ7js.resolveVersionRange;
11
+ exports.DEFAULT_REQUESTED_SNAP_VERSION = _chunkIPOE62V4js.DEFAULT_REQUESTED_SNAP_VERSION; exports.getTargetVersion = _chunkIPOE62V4js.getTargetVersion; exports.resolveVersionRange = _chunkIPOE62V4js.resolveVersionRange;
12
12
  //# sourceMappingURL=versions.js.map
package/dist/versions.mjs CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  DEFAULT_REQUESTED_SNAP_VERSION,
3
3
  getTargetVersion,
4
4
  resolveVersionRange
5
- } from "./chunk-43EBXDVP.mjs";
6
- import "./chunk-4GBOSMF7.mjs";
5
+ } from "./chunk-UMZNVWEM.mjs";
6
+ import "./chunk-JMDSN227.mjs";
7
7
  export {
8
8
  DEFAULT_REQUESTED_SNAP_VERSION,
9
9
  getTargetVersion,
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkXWFKTDB3js = require('../chunk-XWFKTDB3.js');
4
- require('../chunk-Q7FGULTV.js');
3
+ var _chunkHJYRGKCXjs = require('../chunk-HJYRGKCX.js');
4
+ require('../chunk-NUCLSR2G.js');
5
5
  require('../chunk-PHUTP7NB.js');
6
6
 
7
7
 
8
- exports.VirtualFile = _chunkXWFKTDB3js.VirtualFile;
8
+ exports.VirtualFile = _chunkHJYRGKCXjs.VirtualFile;
9
9
  //# sourceMappingURL=VirtualFile.js.map
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  VirtualFile
3
- } from "../chunk-LOW2T4MV.mjs";
4
- import "../chunk-B2DMAQNK.mjs";
5
- import "../chunk-4GBOSMF7.mjs";
3
+ } from "../chunk-ZJRWU4AJ.mjs";
4
+ import "../chunk-Z2JQNSVL.mjs";
5
+ import "../chunk-JMDSN227.mjs";
6
6
  export {
7
7
  VirtualFile
8
8
  };
@@ -1,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-2XF32FCF.js');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-T3VM5YXY.js');
2
2
 
3
3
 
4
- var _chunkXWFKTDB3js = require('../chunk-XWFKTDB3.js');
5
- require('../chunk-Q7FGULTV.js');
4
+ var _chunkHJYRGKCXjs = require('../chunk-HJYRGKCX.js');
5
+ require('../chunk-NUCLSR2G.js');
6
6
  require('../chunk-PHUTP7NB.js');
7
7
 
8
8
 
9
- exports.VirtualFile = _chunkXWFKTDB3js.VirtualFile;
9
+ exports.VirtualFile = _chunkHJYRGKCXjs.VirtualFile;
10
10
  //# sourceMappingURL=index.js.map
@@ -1,9 +1,9 @@
1
- import "../chunk-IIDK6BRC.mjs";
1
+ import "../chunk-HYF7Q6VY.mjs";
2
2
  import {
3
3
  VirtualFile
4
- } from "../chunk-LOW2T4MV.mjs";
5
- import "../chunk-B2DMAQNK.mjs";
6
- import "../chunk-4GBOSMF7.mjs";
4
+ } from "../chunk-ZJRWU4AJ.mjs";
5
+ import "../chunk-Z2JQNSVL.mjs";
6
+ import "../chunk-JMDSN227.mjs";
7
7
  export {
8
8
  VirtualFile
9
9
  };
@@ -1,17 +1,17 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-XDEHYKW2.js');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-EFRPCO3C.js');
2
2
 
3
3
 
4
4
 
5
- var _chunkR7UAMO2Ujs = require('../chunk-R7UAMO2U.js');
6
- require('../chunk-2XF32FCF.js');
5
+ var _chunkQSCKTRRUjs = require('../chunk-QSCKTRRU.js');
6
+ require('../chunk-T3VM5YXY.js');
7
7
 
8
8
 
9
- var _chunkXWFKTDB3js = require('../chunk-XWFKTDB3.js');
10
- require('../chunk-Q7FGULTV.js');
9
+ var _chunkHJYRGKCXjs = require('../chunk-HJYRGKCX.js');
10
+ require('../chunk-NUCLSR2G.js');
11
11
  require('../chunk-PHUTP7NB.js');
12
12
 
13
13
 
14
14
 
15
15
 
16
- exports.VirtualFile = _chunkXWFKTDB3js.VirtualFile; exports.readVirtualFile = _chunkR7UAMO2Ujs.readVirtualFile; exports.writeVirtualFile = _chunkR7UAMO2Ujs.writeVirtualFile;
16
+ exports.VirtualFile = _chunkHJYRGKCXjs.VirtualFile; exports.readVirtualFile = _chunkQSCKTRRUjs.readVirtualFile; exports.writeVirtualFile = _chunkQSCKTRRUjs.writeVirtualFile;
17
17
  //# sourceMappingURL=node.js.map
@@ -1,14 +1,14 @@
1
- import "../chunk-O4PW77JW.mjs";
1
+ import "../chunk-RAZ7XG4Z.mjs";
2
2
  import {
3
3
  readVirtualFile,
4
4
  writeVirtualFile
5
- } from "../chunk-HOTDTMNP.mjs";
6
- import "../chunk-IIDK6BRC.mjs";
5
+ } from "../chunk-IGMAXVPP.mjs";
6
+ import "../chunk-HYF7Q6VY.mjs";
7
7
  import {
8
8
  VirtualFile
9
- } from "../chunk-LOW2T4MV.mjs";
10
- import "../chunk-B2DMAQNK.mjs";
11
- import "../chunk-4GBOSMF7.mjs";
9
+ } from "../chunk-ZJRWU4AJ.mjs";
10
+ import "../chunk-Z2JQNSVL.mjs";
11
+ import "../chunk-JMDSN227.mjs";
12
12
  export {
13
13
  VirtualFile,
14
14
  readVirtualFile,
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkR7UAMO2Ujs = require('../chunk-R7UAMO2U.js');
5
- require('../chunk-XWFKTDB3.js');
6
- require('../chunk-Q7FGULTV.js');
4
+ var _chunkQSCKTRRUjs = require('../chunk-QSCKTRRU.js');
5
+ require('../chunk-HJYRGKCX.js');
6
+ require('../chunk-NUCLSR2G.js');
7
7
  require('../chunk-PHUTP7NB.js');
8
8
 
9
9
 
10
10
 
11
- exports.readVirtualFile = _chunkR7UAMO2Ujs.readVirtualFile; exports.writeVirtualFile = _chunkR7UAMO2Ujs.writeVirtualFile;
11
+ exports.readVirtualFile = _chunkQSCKTRRUjs.readVirtualFile; exports.writeVirtualFile = _chunkQSCKTRRUjs.writeVirtualFile;
12
12
  //# sourceMappingURL=toVirtualFile.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  readVirtualFile,
3
3
  writeVirtualFile
4
- } from "../chunk-HOTDTMNP.mjs";
5
- import "../chunk-LOW2T4MV.mjs";
6
- import "../chunk-B2DMAQNK.mjs";
7
- import "../chunk-4GBOSMF7.mjs";
4
+ } from "../chunk-IGMAXVPP.mjs";
5
+ import "../chunk-ZJRWU4AJ.mjs";
6
+ import "../chunk-Z2JQNSVL.mjs";
7
+ import "../chunk-JMDSN227.mjs";
8
8
  export {
9
9
  readVirtualFile,
10
10
  writeVirtualFile
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-utils",
3
- "version": "7.0.0",
3
+ "version": "7.0.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/MetaMask/snaps.git"
@@ -58,7 +58,7 @@
58
58
  "@metamask/rpc-errors": "^6.2.1",
59
59
  "@metamask/slip44": "^3.1.0",
60
60
  "@metamask/snaps-registry": "^3.0.0",
61
- "@metamask/snaps-sdk": "^3.0.0",
61
+ "@metamask/snaps-sdk": "^3.0.1",
62
62
  "@metamask/utils": "^8.3.0",
63
63
  "@noble/hashes": "^1.3.1",
64
64
  "@scure/base": "^1.1.1",
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-2XF32FCF.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../node_modules/tsup/assets/esm_shims.js"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AAEjB,IAAM,cAAc,MAAM,cAAc,YAAY,GAAG;AACvD,IAAM,aAAa,MAAM,KAAK,QAAQ,YAAY,CAAC;AAE5C,IAAM,YAA4B,2BAAW;","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-DK3IYVMP.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-IIDK6BRC.mjs.map
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-JV7OA3FD.js.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-LEFOMYX3.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-MYSBDK36.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/post-process.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-shadow\nimport type { Node, Visitor, PluginObj } from '@babel/core';\nimport { transformSync, template } from '@babel/core';\nimport type { Expression, Identifier, TemplateElement } from '@babel/types';\nimport {\n binaryExpression,\n isUnaryExpression,\n isUpdateExpression,\n stringLiteral,\n templateElement,\n templateLiteral,\n} from '@babel/types';\n\n/**\n * Source map declaration taken from `@babel/core`. Babel doesn't export the\n * type for this, so it's copied from the source code instead here.\n */\nexport type SourceMap = {\n version: number;\n sources: string[];\n names: string[];\n sourceRoot?: string | undefined;\n sourcesContent?: string[] | undefined;\n mappings: string;\n file: string;\n};\n\n/**\n * The post process options.\n *\n * @property stripComments - Whether to strip comments. Defaults to `true`.\n * @property sourceMap - Whether to generate a source map for the modified code.\n * See also `inputSourceMap`.\n * @property inputSourceMap - The source map for the input code. When provided,\n * the source map will be used to generate a source map for the modified code.\n * This ensures that the source map is correct for the modified code, and still\n * points to the original source. If not provided, a new source map will be\n * generated instead.\n */\nexport type PostProcessOptions = {\n stripComments?: boolean;\n sourceMap?: boolean | 'inline';\n inputSourceMap?: SourceMap;\n};\n\n/**\n * The post processed bundle output.\n *\n * @property code - The modified code.\n * @property sourceMap - The source map for the modified code, if the source map\n * option was enabled.\n * @property warnings - Any warnings that occurred during the post-processing.\n */\nexport type PostProcessedBundle = {\n code: string;\n sourceMap?: SourceMap | null;\n warnings: PostProcessWarning[];\n};\n\nexport enum PostProcessWarning {\n UnsafeMathRandom = '`Math.random` was detected in the Snap bundle. This is not a secure source of randomness, and should not be used in a secure context. Use `crypto.getRandomValues` instead.',\n}\n\n// The RegEx below consists of multiple groups joined by a boolean OR.\n// Each part consists of two groups which capture a part of each string\n// which needs to be split up, e.g., `<!--` is split into `<!` and `--`.\nconst TOKEN_REGEX = /(<!)(--)|(--)(>)|(import)(\\(.*?\\))/gu;\n\n// An empty template element, i.e., a part of a template literal without any\n// value (\"\").\nconst EMPTY_TEMPLATE_ELEMENT = templateElement({ raw: '', cooked: '' });\n\nconst evalWrapper = template.statement(`\n (1, REF)(ARGS)\n`);\n\nconst objectEvalWrapper = template.statement(`\n (1, OBJECT.REF)\n`);\n\nconst regeneratorRuntimeWrapper = template.statement(`\n var regeneratorRuntime;\n`);\n\n/**\n * Breaks up tokens that would otherwise result in SES errors. The tokens are\n * broken up in a non-destructive way where possible. Currently works with:\n * - HTML comment tags `<!--` and `-->`, broken up into `<!`, `--`, and `--`,\n * `>`.\n * - `import(n)` statements, broken up into `import`, `(n)`.\n *\n * @param value - The string value to break up.\n * @returns The string split into an array, in a way that it can be joined\n * together to form the same string, but with the tokens separated into single\n * array elements.\n */\nfunction breakTokens(value: string): string[] {\n const tokens = value.split(TOKEN_REGEX);\n return (\n tokens\n // TODO: The `split` above results in some values being `undefined`.\n // There may be a better solution to avoid having to filter those out.\n .filter((token) => token !== '' && token !== undefined)\n );\n}\n\n/**\n * Breaks up tokens that would otherwise result in SES errors. The tokens are\n * broken up in a non-destructive way where possible. Currently works with:\n * - HTML comment tags `<!--` and `-->`, broken up into `<!`, `--`, and `--`,\n * `>`.\n * - `import(n)` statements, broken up into `import`, `(n)`.\n *\n * @param value - The string value to break up.\n * @returns The string split into a tuple consisting of the new template\n * elements and string literal expressions.\n */\nfunction breakTokensTemplateLiteral(\n value: string,\n): [TemplateElement[], Expression[]] {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore `matchAll` is not available in ES2017, but this code\n // should only be used in environments where the function is supported.\n const matches: RegExpMatchArray[] = Array.from(value.matchAll(TOKEN_REGEX));\n\n if (matches.length > 0) {\n const output = matches.reduce<[TemplateElement[], Expression[]]>(\n ([elements, expressions], rawMatch, index, values) => {\n const [, first, last] = rawMatch.filter((raw) => raw !== undefined);\n\n // Slice the text in front of the match, which does not need to be\n // broken up.\n const prefix = value.slice(\n index === 0\n ? 0\n : (values[index - 1].index as number) + values[index - 1][0].length,\n rawMatch.index,\n );\n\n return [\n [\n ...elements,\n templateElement({\n raw: getRawTemplateValue(prefix),\n cooked: prefix,\n }),\n EMPTY_TEMPLATE_ELEMENT,\n ],\n [...expressions, stringLiteral(first), stringLiteral(last)],\n ];\n },\n [[], []],\n );\n\n // Add the text after the last match to the output.\n const lastMatch = matches[matches.length - 1];\n const suffix = value.slice(\n (lastMatch.index as number) + lastMatch[0].length,\n );\n\n return [\n [\n ...output[0],\n templateElement({ raw: getRawTemplateValue(suffix), cooked: suffix }),\n ],\n output[1],\n ];\n }\n\n // If there are no matches, simply return the original value.\n return [\n [templateElement({ raw: getRawTemplateValue(value), cooked: value })],\n [],\n ];\n}\n\n/**\n * Get a raw template literal value from a cooked value. This adds a backslash\n * before every '`', '\\' and '${' characters.\n *\n * @see https://github.com/babel/babel/issues/9242#issuecomment-532529613\n * @param value - The cooked string to get the raw string for.\n * @returns The value as raw value.\n */\nfunction getRawTemplateValue(value: string) {\n return value.replace(/\\\\|`|\\$\\{/gu, '\\\\$&');\n}\n\n/**\n * Post process code with AST such that it can be evaluated in SES.\n *\n * Currently:\n * - Makes all direct calls to eval indirect.\n * - Handles certain Babel-related edge cases.\n * - Removes the `Buffer` provided by Browserify.\n * - Optionally removes comments.\n * - Breaks up tokens that would otherwise result in SES errors, such as HTML\n * comment tags `<!--` and `-->` and `import(n)` statements.\n *\n * @param code - The code to post process.\n * @param options - The post-process options.\n * @param options.stripComments - Whether to strip comments. Defaults to `true`.\n * @param options.sourceMap - Whether to generate a source map for the modified\n * code. See also `inputSourceMap`.\n * @param options.inputSourceMap - The source map for the input code. When\n * provided, the source map will be used to generate a source map for the\n * modified code. This ensures that the source map is correct for the modified\n * code, and still points to the original source. If not provided, a new source\n * map will be generated instead.\n * @returns An object containing the modified code, and source map, or null if\n * the provided code is null.\n */\nexport function postProcessBundle(\n code: string,\n {\n stripComments = true,\n sourceMap: sourceMaps,\n inputSourceMap,\n }: Partial<PostProcessOptions> = {},\n): PostProcessedBundle {\n const warnings = new Set<PostProcessWarning>();\n\n const pre: PluginObj['pre'] = ({ ast }) => {\n ast.comments?.forEach((comment) => {\n // Break up tokens that could be parsed as HTML comment terminators. The\n // regular expressions below are written strangely so as to avoid the\n // appearance of such tokens in our source code. For reference:\n // https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md\n comment.value = comment.value\n .replace(new RegExp(`<!${'--'}`, 'gu'), '< !--')\n .replace(new RegExp(`${'--'}>`, 'gu'), '-- >')\n .replace(/import(\\(.*\\))/gu, 'import\\\\$1');\n });\n };\n\n const visitor: Visitor<Node> = {\n FunctionExpression(path) {\n const { node } = path;\n\n // Browserify provides the `Buffer` global as an argument to modules that\n // use it, but this does not work in SES. Since we pass in `Buffer` as an\n // endowment, we can simply remove the argument.\n //\n // Note that this only removes `Buffer` from a wrapped function\n // expression, e.g., `(function (Buffer) { ... })`. Regular functions\n // are not affected.\n //\n // TODO: Since we're working on the AST level, we could check the scope\n // of the function expression, and possibly prevent false positives?\n if (node.type === 'FunctionExpression' && node.extra?.parenthesized) {\n node.params = node.params.filter(\n (param) => !(param.type === 'Identifier' && param.name === 'Buffer'),\n );\n }\n },\n\n CallExpression(path) {\n const { node } = path;\n\n // Replace `eval(foo)` with `(1, eval)(foo)`.\n if (node.callee.type === 'Identifier' && node.callee.name === 'eval') {\n path.replaceWith(\n evalWrapper({\n REF: node.callee,\n ARGS: node.arguments,\n }),\n );\n }\n\n // Detect the use of `Math.random()` and add a warning.\n if (\n node.callee.type === 'MemberExpression' &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'Math' &&\n node.callee.property.type === 'Identifier' &&\n node.callee.property.name === 'random'\n ) {\n warnings.add(PostProcessWarning.UnsafeMathRandom);\n }\n },\n\n MemberExpression(path) {\n const { node } = path;\n\n // Replace `object.eval(foo)` with `(1, object.eval)(foo)`.\n if (\n node.property.type === 'Identifier' &&\n node.property.name === 'eval' &&\n // We only apply this to MemberExpressions that are the callee of CallExpression\n path.parent.type === 'CallExpression' &&\n path.parent.callee === node\n ) {\n path.replaceWith(\n objectEvalWrapper({\n OBJECT: node.object,\n REF: node.property,\n }),\n );\n }\n },\n\n Identifier(path) {\n const { node } = path;\n\n // Insert `regeneratorRuntime` global if it's used in the code.\n if (node.name === 'regeneratorRuntime') {\n const program = path.findParent(\n (parent) => parent.node.type === 'Program',\n );\n\n // We know that `program` is a Program node here, but this keeps\n // TypeScript happy.\n if (program?.node.type === 'Program') {\n const body = program.node.body[0];\n\n // This stops it from inserting `regeneratorRuntime` multiple times.\n if (\n body.type === 'VariableDeclaration' &&\n (body.declarations[0].id as Identifier).name ===\n 'regeneratorRuntime'\n ) {\n return;\n }\n\n program?.node.body.unshift(regeneratorRuntimeWrapper());\n }\n }\n },\n\n TemplateLiteral(path) {\n const { node } = path;\n\n // This checks if the template literal was visited before. Without this,\n // it would cause an infinite loop resulting in a stack overflow. We can't\n // skip the path here, because we need to visit the children of the node.\n if (path.getData('visited')) {\n return;\n }\n\n // Break up tokens that could be parsed as HTML comment terminators, or\n // `import()` statements.\n // For reference:\n // - https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md\n // - https://github.com/MetaMask/snaps-monorepo/issues/505\n const [replacementQuasis, replacementExpressions] = node.quasis.reduce<\n [TemplateElement[], Expression[]]\n >(\n ([elements, expressions], quasi, index) => {\n // Note: Template literals have two variants, \"cooked\" and \"raw\". Here\n // we use the cooked version.\n // https://exploringjs.com/impatient-js/ch_template-literals.html#template-strings-cooked-vs-raw\n const tokens = breakTokensTemplateLiteral(\n quasi.value.cooked as string,\n );\n\n // Only update the node if something changed.\n if (tokens[0].length <= 1) {\n return [\n [...elements, quasi],\n [...expressions, node.expressions[index] as Expression],\n ];\n }\n\n return [\n [...elements, ...tokens[0]],\n [\n ...expressions,\n ...tokens[1],\n node.expressions[index] as Expression,\n ],\n ];\n },\n [[], []],\n );\n\n path.replaceWith(\n templateLiteral(\n replacementQuasis,\n replacementExpressions.filter(\n (expression) => expression !== undefined,\n ),\n ) as Node,\n );\n\n path.setData('visited', true);\n },\n\n StringLiteral(path) {\n const { node } = path;\n\n // Break up tokens that could be parsed as HTML comment terminators, or\n // `import()` statements.\n // For reference:\n // - https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md\n // - https://github.com/MetaMask/snaps-monorepo/issues/505\n const tokens = breakTokens(node.value);\n\n // Only update the node if the string literal was broken up.\n if (tokens.length <= 1) {\n return;\n }\n\n const replacement = tokens\n .slice(1)\n .reduce<Expression>(\n (acc, value) => binaryExpression('+', acc, stringLiteral(value)),\n stringLiteral(tokens[0]),\n );\n\n path.replaceWith(replacement as Node);\n path.skip();\n },\n\n BinaryExpression(path) {\n const { node } = path;\n\n const errorMessage =\n 'Using HTML comments (`<!--` and `-->`) as operators is not allowed. The behaviour of ' +\n 'these comments is ambiguous, and differs per browser and environment. If you want ' +\n 'to use them as operators, break them up into separate characters, i.e., `a-- > b` ' +\n 'and `a < ! --b`.';\n\n if (\n node.operator === '<' &&\n isUnaryExpression(node.right) &&\n isUpdateExpression(node.right.argument) &&\n node.right.argument.operator === '--' &&\n node.left.end &&\n node.right.argument.argument.start\n ) {\n const expression = code.slice(\n node.left.end,\n node.right.argument.argument.start,\n );\n\n if (expression.includes('<!--')) {\n throw new Error(errorMessage);\n }\n }\n\n if (\n node.operator === '>' &&\n isUpdateExpression(node.left) &&\n node.left.operator === '--' &&\n node.left.argument.end &&\n node.right.start\n ) {\n const expression = code.slice(node.left.argument.end, node.right.start);\n\n if (expression.includes('-->')) {\n throw new Error(errorMessage);\n }\n }\n },\n };\n\n try {\n const file = transformSync(code, {\n // Prevent Babel from searching for a config file.\n configFile: false,\n\n parserOpts: {\n // Strict mode isn't enabled by default, so we need to enable it here.\n strictMode: true,\n\n // If this is disabled, the AST does not include any comments. This is\n // useful for performance reasons, and we use it for stripping comments.\n attachComment: !stripComments,\n },\n\n // By default, Babel optimises bundles that exceed 500 KB, but that\n // results in characters which look like HTML comments, which breaks SES.\n compact: false,\n\n // This configures Babel to generate a new source map from the existing\n // source map if specified. If `sourceMap` is `true` but an input source\n // map is not provided, a new source map will be generated instead.\n inputSourceMap,\n sourceMaps,\n\n plugins: [\n () => ({\n pre,\n visitor,\n }),\n ],\n });\n\n if (!file?.code) {\n throw new Error('Bundled code is empty.');\n }\n\n return {\n code: file.code,\n sourceMap: file.map,\n warnings: Array.from(warnings),\n };\n } catch (error) {\n throw new Error(`Failed to post process code:\\n${error.message}`);\n }\n}\n"],"mappings":";AAEA,SAAS,eAAe,gBAAgB;AAExC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgDA,IAAK,qBAAL,kBAAKA,wBAAL;AACL,EAAAA,oBAAA,sBAAmB;AADT,SAAAA;AAAA,GAAA;AAOZ,IAAM,cAAc;AAIpB,IAAM,yBAAyB,gBAAgB,EAAE,KAAK,IAAI,QAAQ,GAAG,CAAC;AAEtE,IAAM,cAAc,SAAS,UAAU;AAAA;AAAA,CAEtC;AAED,IAAM,oBAAoB,SAAS,UAAU;AAAA;AAAA,CAE5C;AAED,IAAM,4BAA4B,SAAS,UAAU;AAAA;AAAA,CAEpD;AAcD,SAAS,YAAY,OAAyB;AAC5C,QAAM,SAAS,MAAM,MAAM,WAAW;AACtC,SACE,OAGG,OAAO,CAAC,UAAU,UAAU,MAAM,UAAU,MAAS;AAE5D;AAaA,SAAS,2BACP,OACmC;AAInC,QAAM,UAA8B,MAAM,KAAK,MAAM,SAAS,WAAW,CAAC;AAE1E,MAAI,QAAQ,SAAS,GAAG;AACtB,UAAM,SAAS,QAAQ;AAAA,MACrB,CAAC,CAAC,UAAU,WAAW,GAAG,UAAU,OAAO,WAAW;AACpD,cAAM,CAAC,EAAE,OAAO,IAAI,IAAI,SAAS,OAAO,CAAC,QAAQ,QAAQ,MAAS;AAIlE,cAAM,SAAS,MAAM;AAAA,UACnB,UAAU,IACN,IACC,OAAO,QAAQ,CAAC,EAAE,QAAmB,OAAO,QAAQ,CAAC,EAAE,CAAC,EAAE;AAAA,UAC/D,SAAS;AAAA,QACX;AAEA,eAAO;AAAA,UACL;AAAA,YACE,GAA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AC1C;AAEA,WAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,WAAW,KAAK;AAAA,MAChB,UAAU,MAAM,KAAK,QAAQ;AAAA,IAC/B;AAAA,EACF,SAAS,OAAO;AACd,UAAM,IAAI,MAAM;AAAA,EAAiC,MAAM,OAAO,EAAE;AAAA,EAClE;AACF;","names":["PostProcessWarning"]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-O4PW77JW.mjs.map
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-Q5T57UNN.js.map
@@ -1,30 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkOQSLMZJNjs = require('./chunk-OQSLMZJN.js');
4
-
5
-
6
- var _chunkH636DAOGjs = require('./chunk-H636DAOG.js');
7
-
8
-
9
- var _chunkKEXZDQANjs = require('./chunk-KEXZDQAN.js');
10
-
11
-
12
- var _chunkRS5HE55Ujs = require('./chunk-RS5HE55U.js');
13
-
14
- // src/validation.ts
15
- async function validateFetchedSnap(files) {
16
- _chunkOQSLMZJNjs.assertIsSnapManifest.call(void 0, files.manifest.result);
17
- await _chunkH636DAOGjs.validateSnapShasum.call(void 0, files);
18
- _chunkRS5HE55Ujs.validateSnapManifestLocalizations.call(void 0,
19
- files.manifest.result,
20
- files.localizationFiles.map((file) => file.result)
21
- );
22
- if (files.svgIcon) {
23
- _chunkKEXZDQANjs.assertIsSnapIcon.call(void 0, files.svgIcon);
24
- }
25
- }
26
-
27
-
28
-
29
- exports.validateFetchedSnap = validateFetchedSnap;
30
- //# sourceMappingURL=chunk-QJTAFTW7.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"],"mappings":";;;;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AASd,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAGvC,YAAY,SAAiB,QAAoB;AAC/C,UAAM,OAAO;AAEb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AASA,eAAsB,WAAW,YAAyC;AACxE,QAAM,iBAAiB,UAAU;AAEjC,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAS,KAAK,KAAK,WAAW,gBAAgB,GAAG,CAAC,UAAU,GAAG;AAAA;AAAA;AAAA,MAGnE,OAAO;AAAA,IACT,CAAC;AAED,QAAI,SAAS;AACb,QAAI,SAAS;AAEb,WAAO,OAAO,QAAQ,6BAA6B;AACnD,WAAO,OAAO,QAAQ,6BAA6B;AAEn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Y;AAAA,MAEZ,YAAY;AAAA;AAAA,QAEV,YAAY;AAAA;AAAA;AAAA,QAIZ,eAAe,CAAC;AAAA,MAClB;AAAA;AAAA;AAAA,MAIA,SAAS;AAAA;AAAA;AAAA;AAAA,MAKT;AAAA,MACA;AAAA,MAEA,SAAS;AAAA,QACP,OAAO;AAAA,UACL;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,QAAI,CAAC,MAAM,MAAM;AACf,YAAM,IAAI,MAAM,wBAAwB;AAAA,IAC1C;AAEA,WAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,WAAW,KAAK;AAAA,MAChB,UAAU,MAAM,KAAK,QAAQ;AAAA,IAC/B;AAAA,EACF,SAAS,OAAO;AACd,UAAM,IAAI,MAAM;AAAA,EAAiC,MAAM,OAAO,EAAE;AAAA,EAClE;AACF","sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-shadow\nimport type { Node, Visitor, PluginObj } from '@babel/core';\nimport { transformSync, template } from '@babel/core';\nimport type { Expression, Identifier, TemplateElement } from '@babel/types';\nimport {\n binaryExpression,\n isUnaryExpression,\n isUpdateExpression,\n stringLiteral,\n templateElement,\n templateLiteral,\n} from '@babel/types';\n\n/**\n * Source map declaration taken from `@babel/core`. Babel doesn't export the\n * type for this, so it's copied from the source code instead here.\n */\nexport type SourceMap = {\n version: number;\n sources: string[];\n names: string[];\n sourceRoot?: string | undefined;\n sourcesContent?: string[] | undefined;\n mappings: string;\n file: string;\n};\n\n/**\n * The post process options.\n *\n * @property stripComments - Whether to strip comments. Defaults to `true`.\n * @property sourceMap - Whether to generate a source map for the modified code.\n * See also `inputSourceMap`.\n * @property inputSourceMap - The source map for the input code. When provided,\n * the source map will be used to generate a source map for the modified code.\n * This ensures that the source map is correct for the modified code, and still\n * points to the original source. If not provided, a new source map will be\n * generated instead.\n */\nexport type PostProcessOptions = {\n stripComments?: boolean;\n sourceMap?: boolean | 'inline';\n inputSourceMap?: SourceMap;\n};\n\n/**\n * The post processed bundle output.\n *\n * @property code - The modified code.\n * @property sourceMap - The source map for the modified code, if the source map\n * option was enabled.\n * @property warnings - Any warnings that occurred during the post-processing.\n */\nexport type PostProcessedBundle = {\n code: string;\n sourceMap?: SourceMap | null;\n warnings: PostProcessWarning[];\n};\n\nexport enum PostProcessWarning {\n UnsafeMathRandom = '`Math.random` was detected in the Snap bundle. This is not a secure source of randomness, and should not be used in a secure context. Use `crypto.getRandomValues` instead.',\n}\n\n// The RegEx below consists of multiple groups joined by a boolean OR.\n// Each part consists of two groups which capture a part of each string\n// which needs to be split up, e.g., `<!--` is split into `<!` and `--`.\nconst TOKEN_REGEX = /(<!)(--)|(--)(>)|(import)(\\(.*?\\))/gu;\n\n// An empty template element, i.e., a part of a template literal without any\n// value (\"\").\nconst EMPTY_TEMPLATE_ELEMENT = templateElement({ raw: '', cooked: '' });\n\nconst evalWrapper = template.statement(`\n (1, REF)(ARGS)\n`);\n\nconst objectEvalWrapper = template.statement(`\n (1, OBJECT.REF)\n`);\n\nconst regeneratorRuntimeWrapper = template.statement(`\n var regeneratorRuntime;\n`);\n\n/**\n * Breaks up tokens that would otherwise result in SES errors. The tokens are\n * broken up in a non-destructive way where possible. Currently works with:\n * - HTML comment tags `<!--` and `-->`, broken up into `<!`, `--`, and `--`,\n * `>`.\n * - `import(n)` statements, broken up into `import`, `(n)`.\n *\n * @param value - The string value to break up.\n * @returns The string split into an array, in a way that it can be joined\n * together to form the same string, but with the tokens separated into single\n * array elements.\n */\nfunction breakTokens(value: string): string[] {\n const tokens = value.split(TOKEN_REGEX);\n return (\n tokens\n // TODO: The `split` above results in some values being `undefined`.\n // There may be a better solution to avoid having to filter those out.\n .filter((token) => token !== '' && token !== undefined)\n );\n}\n\n/**\n * Breaks up tokens that would otherwise result in SES errors. The tokens are\n * broken up in a non-destructive way where possible. Currently works with:\n * - HTML comment tags `<!--` and `-->`, broken up into `<!`, `--`, and `--`,\n * `>`.\n * - `import(n)` statements, broken up into `import`, `(n)`.\n *\n * @param value - The string value to break up.\n * @returns The string split into a tuple consisting of the new template\n * elements and string literal expressions.\n */\nfunction breakTokensTemplateLiteral(\n value: string,\n): [TemplateElement[], Expression[]] {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore `matchAll` is not available in ES2017, but this code\n // should only be used in environments where the function is supported.\n const matches: RegExpMatchArray[] = Array.from(value.matchAll(TOKEN_REGEX));\n\n if (matches.length > 0) {\n const output = matches.reduce<[TemplateElement[], Expression[]]>(\n ([elements, expressions], rawMatch, index, values) => {\n const [, first, last] = rawMatch.filter((raw) => raw !== undefined);\n\n // Slice the text in front of the match, which does not need to be\n // broken up.\n const prefix = value.slice(\n index === 0\n ? 0\n : (values[index - 1].index as number) + values[index - 1][0].length,\n rawMatch.index,\n );\n\n return [\n [\n ...elements,\n templateElement({\n raw: getRawTemplateValue(prefix),\n cooked: prefix,\n }),\n EMPTY_TEMPLATE_ELEMENT,\n ],\n [...expressions, stringLiteral(first), stringLiteral(last)],\n ];\n },\n [[], []],\n );\n\n // Add the text after the last match to the output.\n const lastMatch = matches[matches.length - 1];\n const suffix = value.slice(\n (lastMatch.index as number) + lastMatch[0].length,\n );\n\n return [\n [\n ...output[0],\n templateElement({ raw: getRawTemplateValue(suffix), cooked: suffix }),\n ],\n output[1],\n ];\n }\n\n // If there are no matches, simply return the original value.\n return [\n [templateElement({ raw: getRawTemplateValue(value), cooked: value })],\n [],\n ];\n}\n\n/**\n * Get a raw template literal value from a cooked value. This adds a backslash\n * before every '`', '\\' and '${' characters.\n *\n * @see https://github.com/babel/babel/issues/9242#issuecomment-532529613\n * @param value - The cooked string to get the raw string for.\n * @returns The value as raw value.\n */\nfunction getRawTemplateValue(value: string) {\n return value.replace(/\\\\|`|\\$\\{/gu, '\\\\$&');\n}\n\n/**\n * Post process code with AST such that it can be evaluated in SES.\n *\n * Currently:\n * - Makes all direct calls to eval indirect.\n * - Handles certain Babel-related edge cases.\n * - Removes the `Buffer` provided by Browserify.\n * - Optionally removes comments.\n * - Breaks up tokens that would otherwise result in SES errors, such as HTML\n * comment tags `<!--` and `-->` and `import(n)` statements.\n *\n * @param code - The code to post process.\n * @param options - The post-process options.\n * @param options.stripComments - Whether to strip comments. Defaults to `true`.\n * @param options.sourceMap - Whether to generate a source map for the modified\n * code. See also `inputSourceMap`.\n * @param options.inputSourceMap - The source map for the input code. When\n * provided, the source map will be used to generate a source map for the\n * modified code. This ensures that the source map is correct for the modified\n * code, and still points to the original source. If not provided, a new source\n * map will be generated instead.\n * @returns An object containing the modified code, and source map, or null if\n * the provided code is null.\n */\nexport function postProcessBundle(\n code: string,\n {\n stripComments = true,\n sourceMap: sourceMaps,\n inputSourceMap,\n }: Partial<PostProcessOptions> = {},\n): PostProcessedBundle {\n const warnings = new Set<PostProcessWarning>();\n\n const pre: PluginObj['pre'] = ({ ast }) => {\n ast.comments?.forEach((comment) => {\n // Break up tokens that could be parsed as HTML comment terminators. The\n // regular expressions below are written strangely so as to avoid the\n // appearance of such tokens in our source code. For reference:\n // https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md\n comment.value = comment.value\n .replace(new RegExp(`<!${'--'}`, 'gu'), '< !--')\n .replace(new RegExp(`${'--'}>`, 'gu'), '-- >')\n .replace(/import(\\(.*\\))/gu, 'import\\\\$1');\n });\n };\n\n const visitor: Visitor<Node> = {\n FunctionExpression(path) {\n const { node } = path;\n\n // Browserify provides the `Buffer` global as an argument to modules that\n // use it, but this does not work in SES. Since we pass in `Buffer` as an\n // endowment, we can simply remove the argument.\n //\n // Note that this only removes `Buffer` from a wrapped function\n // expression, e.g., `(function (Buffer) { ... })`. Regular functions\n // are not affected.\n //\n // TODO: Since we're working on the AST level, we could check the scope\n // of the function expression, and possibly prevent false positives?\n if (node.type === 'FunctionExpression' && node.extra?.parenthesized) {\n node.params = node.params.filter(\n (param) => !(param.type === 'Identifier' && param.name === 'Buffer'),\n );\n }\n },\n\n CallExpression(path) {\n const { node } = path;\n\n // Replace `eval(foo)` with `(1, eval)(foo)`.\n if (node.callee.type === 'Identifier' && node.callee.name === 'eval') {\n path.replaceWith(\n evalWrapper({\n REF: node.callee,\n ARGS: node.arguments,\n }),\n );\n }\n\n // Detect the use of `Math.random()` and add a warning.\n if (\n node.callee.type === 'MemberExpression' &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'Math' &&\n node.callee.property.type === 'Identifier' &&\n node.callee.property.name === 'random'\n ) {\n warnings.add(PostProcessWarning.UnsafeMathRandom);\n }\n },\n\n MemberExpression(path) {\n const { node } = path;\n\n // Replace `object.eval(foo)` with `(1, object.eval)(foo)`.\n if (\n node.property.type === 'Identifier' &&\n node.property.name === 'eval' &&\n // We only apply this to MemberExpressions that are the callee of CallExpression\n path.parent.type === 'CallExpression' &&\n path.parent.callee === node\n ) {\n path.replaceWith(\n objectEvalWrapper({\n OBJECT: node.object,\n REF: node.property,\n }),\n );\n }\n },\n\n Identifier(path) {\n const { node } = path;\n\n // Insert `regeneratorRuntime` global if it's used in the code.\n if (node.name === 'regeneratorRuntime') {\n const program = path.findParent(\n (parent) => parent.node.type === 'Program',\n );\n\n // We know that `program` is a Program node here, but this keeps\n // TypeScript happy.\n if (program?.node.type === 'Program') {\n const body = program.node.body[0];\n\n // This stops it from inserting `regeneratorRuntime` multiple times.\n if (\n body.type === 'VariableDeclaration' &&\n (body.declarations[0].id as Identifier).name ===\n 'regeneratorRuntime'\n ) {\n return;\n }\n\n program?.node.body.unshift(regeneratorRuntimeWrapper());\n }\n }\n },\n\n TemplateLiteral(path) {\n const { node } = path;\n\n // This checks if the template literal was visited before. Without this,\n // it would cause an infinite loop resulting in a stack overflow. We can't\n // skip the path here, because we need to visit the children of the node.\n if (path.getData('visited')) {\n return;\n }\n\n // Break up tokens that could be parsed as HTML comment terminators, or\n // `import()` statements.\n // For reference:\n // - https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md\n // - https://github.com/MetaMask/snaps-monorepo/issues/505\n const [replacementQuasis, replacementExpressions] = node.quasis.reduce<\n [TemplateElement[], Expression[]]\n >(\n ([elements, expressions], quasi, index) => {\n // Note: Template literals have two variants, \"cooked\" and \"raw\". Here\n // we use the cooked version.\n // https://exploringjs.com/impatient-js/ch_template-literals.html#template-strings-cooked-vs-raw\n const tokens = breakTokensTemplateLiteral(\n quasi.value.cooked as string,\n );\n\n // Only update the node if something changed.\n if (tokens[0].length <= 1) {\n return [\n [...elements, quasi],\n [...expressions, node.expressions[index] as Expression],\n ];\n }\n\n return [\n [...elements, ...tokens[0]],\n [\n ...expressions,\n ...tokens[1],\n node.expressions[index] as Expression,\n ],\n ];\n },\n [[], []],\n );\n\n path.replaceWith(\n templateLiteral(\n replacementQuasis,\n replacementExpressions.filter(\n (expression) => expression !== undefined,\n ),\n ) as Node,\n );\n\n path.setData('visited', true);\n },\n\n StringLiteral(path) {\n const { node } = path;\n\n // Break up tokens that could be parsed as HTML comment terminators, or\n // `import()` statements.\n // For reference:\n // - https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md\n // - https://github.com/MetaMask/snaps-monorepo/issues/505\n const tokens = breakTokens(node.value);\n\n // Only update the node if the string literal was broken up.\n if (tokens.length <= 1) {\n return;\n }\n\n const replacement = tokens\n .slice(1)\n .reduce<Expression>(\n (acc, value) => binaryExpression('+', acc, stringLiteral(value)),\n stringLiteral(tokens[0]),\n );\n\n path.replaceWith(replacement as Node);\n path.skip();\n },\n\n BinaryExpression(path) {\n const { node } = path;\n\n const errorMessage =\n 'Using HTML comments (`<!--` and `-->`) as operators is not allowed. The behaviour of ' +\n 'these comments is ambiguous, and differs per browser and environment. If you want ' +\n 'to use them as operators, break them up into separate characters, i.e., `a-- > b` ' +\n 'and `a < ! --b`.';\n\n if (\n node.operator === '<' &&\n isUnaryExpression(node.right) &&\n isUpdateExpression(node.right.argument) &&\n node.right.argument.operator === '--' &&\n node.left.end &&\n node.right.argument.argument.start\n ) {\n const expression = code.slice(\n node.left.end,\n node.right.argument.argument.start,\n );\n\n if (expression.includes('<!--')) {\n throw new Error(errorMessage);\n }\n }\n\n if (\n node.operator === '>' &&\n isUpdateExpression(node.left) &&\n node.left.operator === '--' &&\n node.left.argument.end &&\n node.right.start\n ) {\n const expression = code.slice(node.left.argument.end, node.right.start);\n\n if (expression.includes('-->')) {\n throw new Error(errorMessage);\n }\n }\n },\n };\n\n try {\n const file = transformSync(code, {\n // Prevent Babel from searching for a config file.\n configFile: false,\n\n parserOpts: {\n // Strict mode isn't enabled by default, so we need to enable it here.\n strictMode: true,\n\n // If this is disabled, the AST does not include any comments. This is\n // useful for performance reasons, and we use it for stripping comments.\n attachComment: !stripComments,\n },\n\n // By default, Babel optimises bundles that exceed 500 KB, but that\n // results in characters which look like HTML comments, which breaks SES.\n compact: false,\n\n // This configures Babel to generate a new source map from the existing\n // source map if specified. If `sourceMap` is `true` but an input source\n // map is not provided, a new source map will be generated instead.\n inputSourceMap,\n sourceMaps,\n\n plugins: [\n () => ({\n pre,\n visitor,\n }),\n ],\n });\n\n if (!file?.code) {\n throw new Error('Bundled code is empty.');\n }\n\n return {\n code: file.code,\n sourceMap: file.map,\n warnings: Array.from(warnings),\n };\n } catch (error) {\n throw new Error(`Failed to post process code:\\n${error.message}`);\n }\n}\n"]}
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-XDEHYKW2.js.map
@@ -1,50 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
- var _chunkQ7FGULTVjs = require('./chunk-Q7FGULTV.js');
4
-
5
- // src/virtual-file/VirtualFile.ts
6
- var _utils = require('@metamask/utils');
7
- var _base = require('@scure/base');
8
- var VirtualFile = class _VirtualFile {
9
- constructor(value) {
10
- let options;
11
- if (typeof value === "string" || value instanceof Uint8Array) {
12
- options = { value };
13
- } else {
14
- options = value;
15
- }
16
- this.value = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.value]), () => ( ""));
17
- this.result = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.result]), () => ( void 0));
18
- this.data = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _3 => _3.data]), () => ( {}));
19
- this.path = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _4 => _4.path]), () => ( "/"));
20
- }
21
- toString(encoding) {
22
- if (typeof this.value === "string") {
23
- _utils.assert.call(void 0, encoding === void 0, "Tried to encode string.");
24
- return this.value;
25
- } else if (this.value instanceof Uint8Array && encoding === "hex") {
26
- return _utils.bytesToHex.call(void 0, this.value);
27
- } else if (this.value instanceof Uint8Array && encoding === "base64") {
28
- return _base.base64.encode(this.value);
29
- }
30
- const decoder = new TextDecoder(encoding);
31
- return decoder.decode(this.value);
32
- }
33
- clone() {
34
- const vfile = new _VirtualFile();
35
- if (typeof this.value === "string") {
36
- vfile.value = this.value;
37
- } else {
38
- vfile.value = this.value.slice(0);
39
- }
40
- vfile.result = _chunkQ7FGULTVjs.deepClone.call(void 0, this.result);
41
- vfile.data = _chunkQ7FGULTVjs.deepClone.call(void 0, this.data);
42
- vfile.path = this.path;
43
- return vfile;
44
- }
45
- };
46
-
47
-
48
-
49
- exports.VirtualFile = VirtualFile;
50
- //# sourceMappingURL=chunk-XWFKTDB3.js.map
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-YF4PGFCO.js.map