@metamask/snaps-utils 7.0.0 → 7.0.2
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.
- package/CHANGELOG.md +12 -1
- package/dist/array.js +2 -2
- package/dist/array.mjs +2 -2
- package/dist/auxiliary-files.js +6 -6
- package/dist/auxiliary-files.mjs +6 -6
- package/dist/base64.js +5 -5
- package/dist/base64.mjs +5 -5
- package/dist/bytes.js +4 -4
- package/dist/bytes.mjs +4 -4
- package/dist/caveats.js +2 -2
- package/dist/caveats.mjs +2 -2
- package/dist/checksum.js +5 -5
- package/dist/checksum.mjs +5 -5
- package/dist/{chunk-FJH6DDEL.mjs → chunk-2IWSQJKQ.mjs} +3 -3
- package/dist/{chunk-2QS3W66J.js → chunk-2LBN5T56.js} +4 -4
- package/dist/{chunk-3TH3NLQL.js → chunk-2PCPD5XY.js} +6 -6
- package/dist/{chunk-KWQKGJSV.js → chunk-3SOYDY4W.js} +1 -1
- package/dist/{chunk-ZXCNX3ZB.mjs → chunk-44GPX66J.mjs} +1 -1
- package/dist/{chunk-WDGBH5CP.js → chunk-44VFHYJO.js} +9 -9
- package/dist/chunk-44VFHYJO.js.map +1 -0
- package/dist/{chunk-R4BBIGBN.js → chunk-473MIETW.js} +3 -3
- package/dist/chunk-4CMD46B2.js +1 -0
- package/dist/{chunk-TUAHXE75.mjs → chunk-5R7UF7KM.mjs} +1 -1
- package/dist/{chunk-P5V6S2PA.mjs → chunk-63OXILAY.mjs} +2 -2
- package/dist/{chunk-QWEXXUTO.mjs → chunk-6CHO3LOX.mjs} +1 -1
- package/dist/{chunk-B3YQVRPE.js → chunk-6LOYTBS3.js} +4 -4
- package/dist/{chunk-VGWELVCX.mjs → chunk-6YRUDGNL.mjs} +2 -2
- package/dist/{chunk-7H5TGXZ5.js → chunk-772OPTGX.js} +3 -3
- package/dist/{chunk-XC5E26VE.mjs → chunk-7LG4D4XA.mjs} +1 -1
- package/dist/chunk-7LOABHVW.js +1 -0
- package/dist/chunk-7MTAHOWC.mjs +1 -0
- package/dist/{chunk-F33RMB76.js → chunk-7P62OIGX.js} +7 -7
- package/dist/{chunk-32B4YQM7.mjs → chunk-7Y3WSN44.mjs} +3 -3
- package/dist/chunk-A3RRMELT.mjs +1 -0
- package/dist/{chunk-GMC2A3D7.js → chunk-A6E325SZ.js} +3 -3
- package/dist/{chunk-RS5HE55U.js → chunk-AFQY2CNY.js} +3 -3
- package/dist/{chunk-I3BUOULW.js → chunk-AOGVLPQZ.js} +1 -1
- package/dist/{chunk-QF3LHIJ5.mjs → chunk-AS5P6JRP.mjs} +1 -1
- package/dist/{chunk-MJABESWH.js → chunk-ASZWZ7JT.js} +1 -1
- package/dist/{chunk-GK4IJQVW.js → chunk-AWRMYDIN.js} +43 -43
- package/dist/{chunk-3ZSMMNQB.mjs → chunk-BGSO2GQC.mjs} +1 -1
- package/dist/{chunk-4UMDRHDR.js → chunk-CMOSYNZR.js} +2 -2
- package/dist/{chunk-ZRVOIW3H.js → chunk-CQRPSEH3.js} +3 -3
- package/dist/{chunk-DKSB4FMW.mjs → chunk-DKDGMZFU.mjs} +1 -1
- package/dist/{chunk-IWENO6LT.js → chunk-E3BDBG6T.js} +1 -1
- package/dist/{chunk-YLT6CNSL.mjs → chunk-EA2FOAEG.mjs} +1 -1
- package/dist/chunk-EFRPCO3C.js +1 -0
- package/dist/{chunk-OQSLMZJN.js → chunk-ENKAY3PI.js} +18 -18
- package/dist/{chunk-7T3N2ZGQ.mjs → chunk-EXUEHPZ4.mjs} +1 -1
- package/dist/{chunk-JGMGNLZW.mjs → chunk-FOWIC2SO.mjs} +2 -2
- package/dist/{chunk-2IVFF3AA.mjs → chunk-GTAYOKI4.mjs} +2 -2
- package/dist/{chunk-6H32HLTZ.js → chunk-HF7HUZ5Z.js} +1 -1
- package/dist/{chunk-LHIPBIPS.mjs → chunk-HJRCBSNA.mjs} +2 -2
- package/dist/chunk-HJYRGKCX.js +50 -0
- package/dist/chunk-HYF7Q6VY.mjs +1 -0
- package/dist/{chunk-Z4J4GUGG.mjs → chunk-I77AVJKV.mjs} +1 -1
- package/dist/{chunk-HOTDTMNP.mjs → chunk-IGMAXVPP.mjs} +2 -2
- package/dist/{chunk-7KKLGQNE.js → chunk-IHQPAJ2B.js} +3 -3
- package/dist/{chunk-6WBLB5BX.js → chunk-IJX3CXOY.js} +1 -1
- package/dist/{chunk-WJOAEPZ7.js → chunk-IPOE62V4.js} +1 -1
- package/dist/{chunk-7XA5VYYV.mjs → chunk-IV3FSWZ7.mjs} +1 -1
- package/dist/{chunk-7PNGOFLU.js → chunk-IXBJNVHK.js} +3 -3
- package/dist/chunk-JI5NQ2C3.mjs +1 -0
- package/dist/{chunk-4GBOSMF7.mjs → chunk-JMDSN227.mjs} +2 -10
- package/dist/{chunk-XRGYWWT7.js → chunk-K6BCBPXF.js} +1 -1
- package/dist/{chunk-2G4HD42C.mjs → chunk-KMLVVVK3.mjs} +2 -2
- package/dist/{chunk-ZLFA4R5X.js → chunk-LBRWAC27.js} +3 -3
- package/dist/{chunk-HWFLO7W5.mjs → chunk-LCWDLIK5.mjs} +8 -8
- package/dist/{chunk-XEY3KVEH.js → chunk-LEKZPKS2.js} +1 -1
- package/dist/{chunk-4IKNNAVC.mjs → chunk-LGT3PBPZ.mjs} +5 -5
- package/dist/{chunk-TURGGK5F.mjs → chunk-LSPOXPJJ.mjs} +9 -5
- package/dist/chunk-LSPOXPJJ.mjs.map +1 -0
- package/dist/{chunk-KEXZDQAN.js → chunk-M3KAAQFK.js} +4 -3
- package/dist/chunk-M3KAAQFK.js.map +1 -0
- package/dist/{chunk-224S5XKL.js → chunk-MLOQHUOY.js} +5 -5
- package/dist/{chunk-UGQQ5DJ4.mjs → chunk-MNCFAD4E.mjs} +4 -3
- package/dist/chunk-MNCFAD4E.mjs.map +1 -0
- package/dist/{chunk-QYFDFOWT.js → chunk-N722KRZW.js} +1 -1
- package/dist/{chunk-Q7FGULTV.js → chunk-NUCLSR2G.js} +1 -1
- package/dist/{chunk-XKXHM3PC.mjs → chunk-P252LKUT.mjs} +1 -1
- package/dist/{chunk-Y3F7VUZB.mjs → chunk-PIG67G67.mjs} +10 -10
- package/dist/{chunk-IUNNN6HN.mjs → chunk-PJMEJVOB.mjs} +1 -1
- package/dist/{chunk-RRPU7M4Y.js → chunk-PLBSSUVY.js} +1 -1
- package/dist/{chunk-R7UAMO2U.js → chunk-QSCKTRRU.js} +3 -3
- package/dist/{chunk-H34N3OWO.mjs → chunk-QX6MAFJU.mjs} +2 -2
- package/dist/{chunk-O3XKEEJV.mjs → chunk-QYPLUMB7.mjs} +2 -2
- package/dist/chunk-QYPLUMB7.mjs.map +1 -0
- package/dist/chunk-RAZ7XG4Z.mjs +1 -0
- package/dist/chunk-RAZ7XG4Z.mjs.map +1 -0
- package/dist/{chunk-6CTV7VW5.mjs → chunk-SRMDDOVO.mjs} +1 -1
- package/dist/chunk-T3VM5YXY.js +1 -0
- package/dist/{chunk-FTY3BOF7.js → chunk-T3YY4JIJ.js} +1 -1
- package/dist/{chunk-ZVXX2CTH.mjs → chunk-T6FWIDA6.mjs} +1 -1
- package/dist/chunk-TFP64TMV.js +1 -0
- package/dist/{chunk-H636DAOG.js → chunk-TG4BDSYJ.js} +12 -12
- package/dist/{chunk-43EBXDVP.mjs → chunk-UMZNVWEM.mjs} +1 -1
- package/dist/{chunk-3SARO5TJ.mjs → chunk-UW74NLTC.mjs} +1 -1
- package/dist/{chunk-GW5NQXN4.mjs → chunk-VWGXNUMD.mjs} +2 -2
- package/dist/{chunk-N52KMB25.mjs → chunk-WEOCOYES.mjs} +2 -2
- package/dist/{chunk-VMUXXXJC.js → chunk-X44Z53IG.js} +5 -5
- package/dist/chunk-YMUOYQFU.js +30 -0
- package/dist/{chunk-B2DMAQNK.mjs → chunk-Z2JQNSVL.mjs} +1 -1
- package/dist/{chunk-LOW2T4MV.mjs → chunk-ZJRWU4AJ.mjs} +2 -2
- package/dist/{chunk-MSUZTHYT.js → chunk-ZT3KKTS2.js} +1 -1
- package/dist/cronjob.js +2 -2
- package/dist/cronjob.mjs +2 -2
- package/dist/deep-clone.js +2 -2
- package/dist/deep-clone.mjs +2 -2
- package/dist/default-endowments.js +2 -2
- package/dist/default-endowments.mjs +2 -2
- package/dist/derivation-paths.js +3 -3
- package/dist/derivation-paths.mjs +3 -3
- package/dist/entropy.js +2 -2
- package/dist/entropy.mjs +2 -2
- package/dist/errors.js +2 -2
- package/dist/errors.mjs +2 -2
- package/dist/eval-worker.js +5 -5
- package/dist/eval-worker.mjs +4 -4
- package/dist/eval.js +9 -9
- package/dist/eval.mjs +9 -9
- package/dist/fs.js +8 -8
- package/dist/fs.mjs +8 -8
- package/dist/handler-types.js +2 -2
- package/dist/handler-types.mjs +2 -2
- package/dist/handlers.js +3 -3
- package/dist/handlers.mjs +3 -3
- package/dist/icon.js +2 -2
- package/dist/icon.mjs +2 -2
- package/dist/iframe.js +2 -2
- package/dist/iframe.mjs +2 -2
- package/dist/index.executionenv.js +8 -8
- package/dist/index.executionenv.mjs +8 -8
- package/dist/index.js +35 -35
- package/dist/index.mjs +35 -35
- package/dist/json-rpc.js +2 -2
- package/dist/json-rpc.mjs +2 -2
- package/dist/json.js +2 -2
- package/dist/json.mjs +2 -2
- package/dist/localization.js +3 -3
- package/dist/localization.mjs +3 -3
- package/dist/logging.js +2 -2
- package/dist/logging.mjs +2 -2
- package/dist/manifest/index.js +15 -15
- package/dist/manifest/index.mjs +15 -15
- package/dist/manifest/manifest.js +22 -22
- package/dist/manifest/manifest.mjs +22 -22
- package/dist/manifest/node.js +24 -24
- package/dist/manifest/node.mjs +24 -24
- package/dist/manifest/validation.js +14 -14
- package/dist/manifest/validation.mjs +14 -14
- package/dist/mock.js +3 -3
- package/dist/mock.mjs +3 -3
- package/dist/namespace.js +2 -2
- package/dist/namespace.mjs +2 -2
- package/dist/node.js +43 -43
- package/dist/node.mjs +43 -43
- package/dist/npm.js +22 -22
- package/dist/npm.mjs +22 -22
- package/dist/path.js +2 -2
- package/dist/path.mjs +2 -2
- package/dist/post-process.js +2 -2
- package/dist/post-process.mjs +2 -2
- package/dist/snaps.js +8 -8
- package/dist/snaps.mjs +8 -8
- package/dist/strings.js +2 -2
- package/dist/strings.mjs +2 -2
- package/dist/structs.js +3 -3
- package/dist/structs.mjs +3 -3
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/handlers.d.ts +14 -0
- package/dist/types.js +2 -2
- package/dist/types.mjs +2 -2
- package/dist/ui.js +2 -2
- package/dist/ui.mjs +2 -2
- package/dist/validation.js +18 -18
- package/dist/validation.mjs +18 -18
- package/dist/versions.js +2 -2
- package/dist/versions.mjs +2 -2
- package/dist/virtual-file/VirtualFile.js +3 -3
- package/dist/virtual-file/VirtualFile.mjs +3 -3
- package/dist/virtual-file/index.js +4 -4
- package/dist/virtual-file/index.mjs +4 -4
- package/dist/virtual-file/node.js +6 -6
- package/dist/virtual-file/node.mjs +6 -6
- package/dist/virtual-file/toVirtualFile.js +4 -4
- package/dist/virtual-file/toVirtualFile.mjs +4 -4
- package/package.json +3 -3
- package/dist/chunk-2XF32FCF.js +0 -1
- package/dist/chunk-4GBOSMF7.mjs.map +0 -1
- package/dist/chunk-DK3IYVMP.mjs +0 -1
- package/dist/chunk-IIDK6BRC.mjs +0 -1
- package/dist/chunk-JV7OA3FD.js +0 -1
- package/dist/chunk-KEXZDQAN.js.map +0 -1
- package/dist/chunk-LEFOMYX3.mjs +0 -1
- package/dist/chunk-MYSBDK36.mjs +0 -1
- package/dist/chunk-O3XKEEJV.mjs.map +0 -1
- package/dist/chunk-O4PW77JW.mjs +0 -1
- package/dist/chunk-Q5T57UNN.js +0 -1
- package/dist/chunk-QJTAFTW7.js +0 -30
- package/dist/chunk-TURGGK5F.mjs.map +0 -1
- package/dist/chunk-UGQQ5DJ4.mjs.map +0 -1
- package/dist/chunk-WDGBH5CP.js.map +0 -1
- package/dist/chunk-XDEHYKW2.js +0 -1
- package/dist/chunk-XWFKTDB3.js +0 -50
- package/dist/chunk-YF4PGFCO.js +0 -1
- /package/dist/{chunk-FJH6DDEL.mjs.map → chunk-2IWSQJKQ.mjs.map} +0 -0
- /package/dist/{chunk-2QS3W66J.js.map → chunk-2LBN5T56.js.map} +0 -0
- /package/dist/{chunk-3TH3NLQL.js.map → chunk-2PCPD5XY.js.map} +0 -0
- /package/dist/{chunk-KWQKGJSV.js.map → chunk-3SOYDY4W.js.map} +0 -0
- /package/dist/{chunk-ZXCNX3ZB.mjs.map → chunk-44GPX66J.mjs.map} +0 -0
- /package/dist/{chunk-R4BBIGBN.js.map → chunk-473MIETW.js.map} +0 -0
- /package/dist/{chunk-2XF32FCF.js.map → chunk-4CMD46B2.js.map} +0 -0
- /package/dist/{chunk-TUAHXE75.mjs.map → chunk-5R7UF7KM.mjs.map} +0 -0
- /package/dist/{chunk-P5V6S2PA.mjs.map → chunk-63OXILAY.mjs.map} +0 -0
- /package/dist/{chunk-QWEXXUTO.mjs.map → chunk-6CHO3LOX.mjs.map} +0 -0
- /package/dist/{chunk-B3YQVRPE.js.map → chunk-6LOYTBS3.js.map} +0 -0
- /package/dist/{chunk-VGWELVCX.mjs.map → chunk-6YRUDGNL.mjs.map} +0 -0
- /package/dist/{chunk-7H5TGXZ5.js.map → chunk-772OPTGX.js.map} +0 -0
- /package/dist/{chunk-XC5E26VE.mjs.map → chunk-7LG4D4XA.mjs.map} +0 -0
- /package/dist/{chunk-JV7OA3FD.js.map → chunk-7LOABHVW.js.map} +0 -0
- /package/dist/{chunk-DK3IYVMP.mjs.map → chunk-7MTAHOWC.mjs.map} +0 -0
- /package/dist/{chunk-F33RMB76.js.map → chunk-7P62OIGX.js.map} +0 -0
- /package/dist/{chunk-32B4YQM7.mjs.map → chunk-7Y3WSN44.mjs.map} +0 -0
- /package/dist/{chunk-IIDK6BRC.mjs.map → chunk-A3RRMELT.mjs.map} +0 -0
- /package/dist/{chunk-GMC2A3D7.js.map → chunk-A6E325SZ.js.map} +0 -0
- /package/dist/{chunk-RS5HE55U.js.map → chunk-AFQY2CNY.js.map} +0 -0
- /package/dist/{chunk-I3BUOULW.js.map → chunk-AOGVLPQZ.js.map} +0 -0
- /package/dist/{chunk-QF3LHIJ5.mjs.map → chunk-AS5P6JRP.mjs.map} +0 -0
- /package/dist/{chunk-MJABESWH.js.map → chunk-ASZWZ7JT.js.map} +0 -0
- /package/dist/{chunk-GK4IJQVW.js.map → chunk-AWRMYDIN.js.map} +0 -0
- /package/dist/{chunk-3ZSMMNQB.mjs.map → chunk-BGSO2GQC.mjs.map} +0 -0
- /package/dist/{chunk-4UMDRHDR.js.map → chunk-CMOSYNZR.js.map} +0 -0
- /package/dist/{chunk-ZRVOIW3H.js.map → chunk-CQRPSEH3.js.map} +0 -0
- /package/dist/{chunk-DKSB4FMW.mjs.map → chunk-DKDGMZFU.mjs.map} +0 -0
- /package/dist/{chunk-IWENO6LT.js.map → chunk-E3BDBG6T.js.map} +0 -0
- /package/dist/{chunk-YLT6CNSL.mjs.map → chunk-EA2FOAEG.mjs.map} +0 -0
- /package/dist/{chunk-Q5T57UNN.js.map → chunk-EFRPCO3C.js.map} +0 -0
- /package/dist/{chunk-OQSLMZJN.js.map → chunk-ENKAY3PI.js.map} +0 -0
- /package/dist/{chunk-7T3N2ZGQ.mjs.map → chunk-EXUEHPZ4.mjs.map} +0 -0
- /package/dist/{chunk-JGMGNLZW.mjs.map → chunk-FOWIC2SO.mjs.map} +0 -0
- /package/dist/{chunk-2IVFF3AA.mjs.map → chunk-GTAYOKI4.mjs.map} +0 -0
- /package/dist/{chunk-6H32HLTZ.js.map → chunk-HF7HUZ5Z.js.map} +0 -0
- /package/dist/{chunk-LHIPBIPS.mjs.map → chunk-HJRCBSNA.mjs.map} +0 -0
- /package/dist/{chunk-XWFKTDB3.js.map → chunk-HJYRGKCX.js.map} +0 -0
- /package/dist/{chunk-LEFOMYX3.mjs.map → chunk-HYF7Q6VY.mjs.map} +0 -0
- /package/dist/{chunk-Z4J4GUGG.mjs.map → chunk-I77AVJKV.mjs.map} +0 -0
- /package/dist/{chunk-HOTDTMNP.mjs.map → chunk-IGMAXVPP.mjs.map} +0 -0
- /package/dist/{chunk-7KKLGQNE.js.map → chunk-IHQPAJ2B.js.map} +0 -0
- /package/dist/{chunk-6WBLB5BX.js.map → chunk-IJX3CXOY.js.map} +0 -0
- /package/dist/{chunk-WJOAEPZ7.js.map → chunk-IPOE62V4.js.map} +0 -0
- /package/dist/{chunk-7XA5VYYV.mjs.map → chunk-IV3FSWZ7.mjs.map} +0 -0
- /package/dist/{chunk-7PNGOFLU.js.map → chunk-IXBJNVHK.js.map} +0 -0
- /package/dist/{chunk-MYSBDK36.mjs.map → chunk-JI5NQ2C3.mjs.map} +0 -0
- /package/dist/{chunk-O4PW77JW.mjs.map → chunk-JMDSN227.mjs.map} +0 -0
- /package/dist/{chunk-XRGYWWT7.js.map → chunk-K6BCBPXF.js.map} +0 -0
- /package/dist/{chunk-2G4HD42C.mjs.map → chunk-KMLVVVK3.mjs.map} +0 -0
- /package/dist/{chunk-ZLFA4R5X.js.map → chunk-LBRWAC27.js.map} +0 -0
- /package/dist/{chunk-HWFLO7W5.mjs.map → chunk-LCWDLIK5.mjs.map} +0 -0
- /package/dist/{chunk-XEY3KVEH.js.map → chunk-LEKZPKS2.js.map} +0 -0
- /package/dist/{chunk-4IKNNAVC.mjs.map → chunk-LGT3PBPZ.mjs.map} +0 -0
- /package/dist/{chunk-224S5XKL.js.map → chunk-MLOQHUOY.js.map} +0 -0
- /package/dist/{chunk-QYFDFOWT.js.map → chunk-N722KRZW.js.map} +0 -0
- /package/dist/{chunk-Q7FGULTV.js.map → chunk-NUCLSR2G.js.map} +0 -0
- /package/dist/{chunk-XKXHM3PC.mjs.map → chunk-P252LKUT.mjs.map} +0 -0
- /package/dist/{chunk-Y3F7VUZB.mjs.map → chunk-PIG67G67.mjs.map} +0 -0
- /package/dist/{chunk-IUNNN6HN.mjs.map → chunk-PJMEJVOB.mjs.map} +0 -0
- /package/dist/{chunk-RRPU7M4Y.js.map → chunk-PLBSSUVY.js.map} +0 -0
- /package/dist/{chunk-R7UAMO2U.js.map → chunk-QSCKTRRU.js.map} +0 -0
- /package/dist/{chunk-H34N3OWO.mjs.map → chunk-QX6MAFJU.mjs.map} +0 -0
- /package/dist/{chunk-6CTV7VW5.mjs.map → chunk-SRMDDOVO.mjs.map} +0 -0
- /package/dist/{chunk-XDEHYKW2.js.map → chunk-T3VM5YXY.js.map} +0 -0
- /package/dist/{chunk-FTY3BOF7.js.map → chunk-T3YY4JIJ.js.map} +0 -0
- /package/dist/{chunk-ZVXX2CTH.mjs.map → chunk-T6FWIDA6.mjs.map} +0 -0
- /package/dist/{chunk-YF4PGFCO.js.map → chunk-TFP64TMV.js.map} +0 -0
- /package/dist/{chunk-H636DAOG.js.map → chunk-TG4BDSYJ.js.map} +0 -0
- /package/dist/{chunk-43EBXDVP.mjs.map → chunk-UMZNVWEM.mjs.map} +0 -0
- /package/dist/{chunk-3SARO5TJ.mjs.map → chunk-UW74NLTC.mjs.map} +0 -0
- /package/dist/{chunk-GW5NQXN4.mjs.map → chunk-VWGXNUMD.mjs.map} +0 -0
- /package/dist/{chunk-N52KMB25.mjs.map → chunk-WEOCOYES.mjs.map} +0 -0
- /package/dist/{chunk-VMUXXXJC.js.map → chunk-X44Z53IG.js.map} +0 -0
- /package/dist/{chunk-QJTAFTW7.js.map → chunk-YMUOYQFU.js.map} +0 -0
- /package/dist/{chunk-B2DMAQNK.mjs.map → chunk-Z2JQNSVL.mjs.map} +0 -0
- /package/dist/{chunk-LOW2T4MV.mjs.map → chunk-ZJRWU4AJ.mjs.map} +0 -0
- /package/dist/{chunk-MSUZTHYT.js.map → chunk-ZT3KKTS2.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getBytes
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6YRUDGNL.mjs";
|
|
4
4
|
|
|
5
5
|
// src/checksum.ts
|
|
6
6
|
import { assert, concatBytes } from "@metamask/utils";
|
|
@@ -29,4 +29,4 @@ export {
|
|
|
29
29
|
checksum,
|
|
30
30
|
checksumFiles
|
|
31
31
|
};
|
|
32
|
-
//# sourceMappingURL=chunk-
|
|
32
|
+
//# sourceMappingURL=chunk-HJRCBSNA.mjs.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkNUCLSR2Gjs = require('./chunk-NUCLSR2G.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 = options?.value ?? "";
|
|
17
|
+
this.result = options?.result ?? void 0;
|
|
18
|
+
this.data = options?.data ?? {};
|
|
19
|
+
this.path = options?.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 = _chunkNUCLSR2Gjs.deepClone.call(void 0, this.result);
|
|
41
|
+
vfile.data = _chunkNUCLSR2Gjs.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-HJYRGKCX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-HYF7Q6VY.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
VirtualFile
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZJRWU4AJ.mjs";
|
|
4
4
|
|
|
5
5
|
// src/virtual-file/toVirtualFile.ts
|
|
6
6
|
import { promises as fsPromises } from "fs";
|
|
@@ -18,4 +18,4 @@ export {
|
|
|
18
18
|
readVirtualFile,
|
|
19
19
|
writeVirtualFile
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-IGMAXVPP.mjs.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk473MIETWjs = require('./chunk-473MIETW.js');
|
|
4
4
|
|
|
5
5
|
// src/base64.ts
|
|
6
6
|
var _utils = require('@metamask/utils');
|
|
7
7
|
async function encodeBase64(input) {
|
|
8
|
-
const bytes =
|
|
8
|
+
const bytes = _chunk473MIETWjs.getBytes.call(void 0, input);
|
|
9
9
|
if ("FileReader" in globalThis) {
|
|
10
10
|
return await new Promise((resolve, reject) => {
|
|
11
11
|
const reader = Object.assign(new FileReader(), {
|
|
@@ -35,4 +35,4 @@ async function decodeBase64(base64) {
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
exports.encodeBase64 = encodeBase64; exports.decodeBase64 = decodeBase64;
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
38
|
+
//# sourceMappingURL=chunk-IHQPAJ2B.js.map
|
|
@@ -27,4 +27,4 @@ function resolveVersionRange(version) {
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
exports.DEFAULT_REQUESTED_SNAP_VERSION = DEFAULT_REQUESTED_SNAP_VERSION; exports.getTargetVersion = getTargetVersion; exports.resolveVersionRange = resolveVersionRange;
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-IPOE62V4.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkIHQPAJ2Bjs = require('./chunk-IHQPAJ2B.js');
|
|
4
4
|
|
|
5
5
|
// src/auxiliary-files.ts
|
|
6
6
|
var _snapssdk = require('@metamask/snaps-sdk');
|
|
@@ -9,7 +9,7 @@ async function encodeAuxiliaryFile(value, encoding) {
|
|
|
9
9
|
if (encoding === _snapssdk.AuxiliaryFileEncoding.Base64) {
|
|
10
10
|
return value;
|
|
11
11
|
}
|
|
12
|
-
const decoded = await
|
|
12
|
+
const decoded = await _chunkIHQPAJ2Bjs.decodeBase64.call(void 0, value);
|
|
13
13
|
if (encoding === _snapssdk.AuxiliaryFileEncoding.Utf8) {
|
|
14
14
|
return _utils.bytesToString.call(void 0, decoded);
|
|
15
15
|
}
|
|
@@ -19,4 +19,4 @@ async function encodeAuxiliaryFile(value, encoding) {
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
exports.encodeAuxiliaryFile = encodeAuxiliaryFile;
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-IXBJNVHK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-JI5NQ2C3.mjs.map
|
|
@@ -17,17 +17,9 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
17
17
|
return value;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
// ../../node_modules/tsup/assets/esm_shims.js
|
|
21
|
-
import { fileURLToPath } from "url";
|
|
22
|
-
import path from "path";
|
|
23
|
-
var getFilename = () => fileURLToPath(import.meta.url);
|
|
24
|
-
var getDirname = () => path.dirname(getFilename());
|
|
25
|
-
var __dirname = /* @__PURE__ */ getDirname();
|
|
26
|
-
|
|
27
20
|
export {
|
|
28
21
|
__privateGet,
|
|
29
22
|
__privateAdd,
|
|
30
|
-
__privateSet
|
|
31
|
-
__dirname
|
|
23
|
+
__privateSet
|
|
32
24
|
};
|
|
33
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-JMDSN227.mjs.map
|
|
@@ -148,4 +148,4 @@ function unwrapError(error) {
|
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
exports.SNAP_ERROR_WRAPPER_CODE = SNAP_ERROR_WRAPPER_CODE; exports.SNAP_ERROR_WRAPPER_MESSAGE = SNAP_ERROR_WRAPPER_MESSAGE; exports.WrappedSnapError = WrappedSnapError; exports.isSnapError = isSnapError; exports.isSerializedSnapError = isSerializedSnapError; exports.isWrappedSnapError = isWrappedSnapError; exports.unwrapError = unwrapError;
|
|
151
|
-
//# sourceMappingURL=chunk-
|
|
151
|
+
//# sourceMappingURL=chunk-K6BCBPXF.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
decodeBase64
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FOWIC2SO.mjs";
|
|
4
4
|
|
|
5
5
|
// src/auxiliary-files.ts
|
|
6
6
|
import { AuxiliaryFileEncoding } from "@metamask/snaps-sdk";
|
|
@@ -19,4 +19,4 @@ async function encodeAuxiliaryFile(value, encoding) {
|
|
|
19
19
|
export {
|
|
20
20
|
encodeAuxiliaryFile
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-KMLVVVK3.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkX44Z53IGjs = require('./chunk-X44Z53IG.js');
|
|
4
4
|
|
|
5
5
|
// src/eval.ts
|
|
6
6
|
var _utils = require('@metamask/utils');
|
|
@@ -14,7 +14,7 @@ var SnapEvalError = class extends Error {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
async function evalBundle(bundlePath) {
|
|
17
|
-
await
|
|
17
|
+
await _chunkX44Z53IGjs.validateFilePath.call(void 0, bundlePath);
|
|
18
18
|
return new Promise((resolve, reject) => {
|
|
19
19
|
const worker = _child_process.fork.call(void 0, _path.join.call(void 0, __dirname, "eval-worker.js"), [bundlePath], {
|
|
20
20
|
// To avoid printing the output of the worker to the console, we set
|
|
@@ -53,4 +53,4 @@ async function evalBundle(bundlePath) {
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
exports.SnapEvalError = SnapEvalError; exports.evalBundle = evalBundle;
|
|
56
|
-
//# sourceMappingURL=chunk-
|
|
56
|
+
//# sourceMappingURL=chunk-LBRWAC27.js.map
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SnapIdStruct
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2IWSQJKQ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ChainIdStruct
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EXUEHPZ4.mjs";
|
|
7
7
|
import {
|
|
8
8
|
NameStruct,
|
|
9
9
|
uri
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-T6FWIDA6.mjs";
|
|
11
11
|
import {
|
|
12
12
|
KeyringOriginsStruct,
|
|
13
13
|
RpcOriginsStruct
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-DKDGMZFU.mjs";
|
|
15
15
|
import {
|
|
16
16
|
SIP_6_MAGIC_VALUE,
|
|
17
17
|
STATE_ENCRYPTION_MAGIC_VALUE
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-AS5P6JRP.mjs";
|
|
19
19
|
import {
|
|
20
20
|
isEqual
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-P252LKUT.mjs";
|
|
22
22
|
import {
|
|
23
23
|
CronjobSpecificationArrayStruct
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-EA2FOAEG.mjs";
|
|
25
25
|
|
|
26
26
|
// src/manifest/validation.ts
|
|
27
27
|
import { isValidBIP32PathSegment } from "@metamask/key-tree";
|
|
@@ -278,4 +278,4 @@ export {
|
|
|
278
278
|
assertIsSnapManifest,
|
|
279
279
|
createSnapManifest
|
|
280
280
|
};
|
|
281
|
-
//# sourceMappingURL=chunk-
|
|
281
|
+
//# sourceMappingURL=chunk-LCWDLIK5.mjs.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertIsSnapManifest
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LCWDLIK5.mjs";
|
|
4
4
|
import {
|
|
5
5
|
validateSnapShasum
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2IWSQJKQ.mjs";
|
|
7
7
|
import {
|
|
8
8
|
assertIsSnapIcon
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-MNCFAD4E.mjs";
|
|
10
10
|
import {
|
|
11
11
|
validateSnapManifestLocalizations
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WEOCOYES.mjs";
|
|
13
13
|
|
|
14
14
|
// src/validation.ts
|
|
15
15
|
async function validateFetchedSnap(files) {
|
|
@@ -27,4 +27,4 @@ async function validateFetchedSnap(files) {
|
|
|
27
27
|
export {
|
|
28
28
|
validateFetchedSnap
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-LGT3PBPZ.mjs.map
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
|
|
4
|
+
const getFilename = () => fileURLToPath(import.meta.url)
|
|
5
|
+
const getDirname = () => path.dirname(getFilename())
|
|
6
|
+
|
|
7
|
+
export const __dirname = /* @__PURE__ */ getDirname()
|
|
1
8
|
import {
|
|
2
9
|
validateFilePath
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
__dirname
|
|
6
|
-
} from "./chunk-4GBOSMF7.mjs";
|
|
10
|
+
} from "./chunk-7Y3WSN44.mjs";
|
|
7
11
|
|
|
8
12
|
// src/eval.ts
|
|
9
13
|
import { assert } from "@metamask/utils";
|
|
@@ -56,4 +60,4 @@ export {
|
|
|
56
60
|
SnapEvalError,
|
|
57
61
|
evalBundle
|
|
58
62
|
};
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
63
|
+
//# sourceMappingURL=chunk-LSPOXPJJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eval.ts"],"names":[],"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;AAEnD,WAAO,OAAO,GAAG,QAAQ,CAAC,SAAiB;AACzC,gBAAU,KAAK,SAAS;AAAA,IAC1B,CAAC;AAED,WAAO,OAAO,GAAG,QAAQ,CAAC,SAAiB;AACzC,gBAAU,KAAK,SAAS;AAAA,IAC1B,CAAC;AAED,WAAO,GAAG,QAAQ,CAAC,aAAqB;AACtC,YAAM,SAAS;AAAA,QACb;AAAA,QACA;AAAA,MACF;AAEA,UAAI,aAAa,GAAG;AAClB,eAAO,QAAQ,MAAM;AAAA,MACvB;AAEA,aAAO;AAAA,QACL,IAAI;AAAA,UACF,2CAA2C,QAAQ;AAAA,UACnD;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH","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"]}
|
|
@@ -7,8 +7,9 @@ var SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(
|
|
|
7
7
|
)}kb`;
|
|
8
8
|
function assertIsSnapIcon(icon) {
|
|
9
9
|
_utils.assert.call(void 0, icon.path.endsWith(".svg"), 'Expected snap icon to end in ".svg".');
|
|
10
|
+
const byteLength = typeof icon.value === "string" ? _utils.stringToBytes.call(void 0, icon.value).byteLength : icon.value.byteLength;
|
|
10
11
|
_utils.assert.call(void 0,
|
|
11
|
-
|
|
12
|
+
byteLength <= SVG_MAX_BYTE_SIZE,
|
|
12
13
|
`The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`
|
|
13
14
|
);
|
|
14
15
|
_utils.assert.call(void 0, _snapssdk.isSvg.call(void 0, icon.toString()), "Snap icon must be a valid SVG.");
|
|
@@ -35,7 +36,7 @@ function getSvgDimensions(svg) {
|
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
} catch
|
|
39
|
+
} catch {
|
|
39
40
|
throw new Error("Snap icon must be a valid SVG.");
|
|
40
41
|
}
|
|
41
42
|
return null;
|
|
@@ -47,4 +48,4 @@ function getSvgDimensions(svg) {
|
|
|
47
48
|
|
|
48
49
|
|
|
49
50
|
exports.SVG_MAX_BYTE_SIZE = SVG_MAX_BYTE_SIZE; exports.SVG_MAX_BYTE_SIZE_TEXT = SVG_MAX_BYTE_SIZE_TEXT; exports.assertIsSnapIcon = assertIsSnapIcon; exports.getSvgDimensions = getSvgDimensions;
|
|
50
|
-
//# sourceMappingURL=chunk-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{ isSvg, parseSvg } from '@metamask/snaps-sdk';\nimport { assert, stringToBytes } from '@metamask/utils';\n\nimport type { VirtualFile } from './virtual-file';\n\nexport const SVG_MAX_BYTE_SIZE = 100_000;\nexport const SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(\n SVG_MAX_BYTE_SIZE / 1000,\n)}kb`;\n\n/**\n * Assert that a virtual file containing a Snap icon is valid.\n *\n * @param icon - A virtual file containing a Snap icon.\n */\nexport function assertIsSnapIcon(icon: VirtualFile) {\n assert(icon.path.endsWith('.svg'), 'Expected snap icon to end in \".svg\".');\n\n const byteLength =\n typeof icon.value === 'string'\n ? stringToBytes(icon.value).byteLength\n : icon.value.byteLength;\n\n assert(\n byteLength <= SVG_MAX_BYTE_SIZE,\n `The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`,\n );\n\n assert(isSvg(icon.toString()), 'Snap icon must be a valid SVG.');\n}\n\n/**\n * Extract the dimensions of an image from an SVG string if possible.\n *\n * @param svg - An SVG string.\n * @returns The height and width of the SVG or null.\n */\nexport function getSvgDimensions(svg: string): {\n height: number;\n width: number;\n} | null {\n try {\n const parsed = parseSvg(svg);\n\n const height = parsed['@_height'];\n const width = parsed['@_width'];\n\n if (height && width) {\n return { height, width };\n }\n\n const viewBox = parsed['@_viewBox'];\n if (viewBox) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_minX, _minY, viewBoxWidth, viewBoxHeight] = viewBox.split(' ');\n\n if (viewBoxWidth && viewBoxHeight) {\n const parsedWidth = parseInt(viewBoxWidth, 10);\n const parsedHeight = parseInt(viewBoxHeight, 10);\n\n assert(Number.isInteger(parsedWidth) && parsedWidth > 0);\n assert(Number.isInteger(parsedHeight) && parsedHeight > 0);\n\n return {\n width: parsedWidth,\n height: parsedHeight,\n };\n }\n }\n } catch {\n throw new Error('Snap icon must be a valid SVG.');\n }\n\n return null;\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk473MIETWjs = require('./chunk-473MIETW.js');
|
|
4
4
|
|
|
5
5
|
// src/checksum.ts
|
|
6
6
|
var _utils = require('@metamask/utils');
|
|
7
7
|
var _sha256 = require('@noble/hashes/sha256');
|
|
8
8
|
async function checksum(bytes) {
|
|
9
|
-
const value =
|
|
10
|
-
if ("crypto" in globalThis && typeof globalThis.crypto === "object" &&
|
|
9
|
+
const value = _chunk473MIETWjs.getBytes.call(void 0, bytes);
|
|
10
|
+
if ("crypto" in globalThis && typeof globalThis.crypto === "object" && crypto.subtle?.digest) {
|
|
11
11
|
return new Uint8Array(await crypto.subtle.digest("SHA-256", value));
|
|
12
12
|
}
|
|
13
13
|
return _sha256.sha256.call(void 0, value);
|
|
@@ -29,4 +29,4 @@ async function checksumFiles(files) {
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
exports.checksum = checksum; exports.checksumFiles = checksumFiles;
|
|
32
|
-
//# sourceMappingURL=chunk-
|
|
32
|
+
//# sourceMappingURL=chunk-MLOQHUOY.js.map
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
// src/icon.ts
|
|
2
2
|
import { isSvg, parseSvg } from "@metamask/snaps-sdk";
|
|
3
|
-
import { assert } from "@metamask/utils";
|
|
3
|
+
import { assert, stringToBytes } from "@metamask/utils";
|
|
4
4
|
var SVG_MAX_BYTE_SIZE = 1e5;
|
|
5
5
|
var SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(
|
|
6
6
|
SVG_MAX_BYTE_SIZE / 1e3
|
|
7
7
|
)}kb`;
|
|
8
8
|
function assertIsSnapIcon(icon) {
|
|
9
9
|
assert(icon.path.endsWith(".svg"), 'Expected snap icon to end in ".svg".');
|
|
10
|
+
const byteLength = typeof icon.value === "string" ? stringToBytes(icon.value).byteLength : icon.value.byteLength;
|
|
10
11
|
assert(
|
|
11
|
-
|
|
12
|
+
byteLength <= SVG_MAX_BYTE_SIZE,
|
|
12
13
|
`The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`
|
|
13
14
|
);
|
|
14
15
|
assert(isSvg(icon.toString()), "Snap icon must be a valid SVG.");
|
|
@@ -47,4 +48,4 @@ export {
|
|
|
47
48
|
assertIsSnapIcon,
|
|
48
49
|
getSvgDimensions
|
|
49
50
|
};
|
|
50
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-MNCFAD4E.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/icon.ts"],"sourcesContent":["import { isSvg, parseSvg } from '@metamask/snaps-sdk';\nimport { assert, stringToBytes } from '@metamask/utils';\n\nimport type { VirtualFile } from './virtual-file';\n\nexport const SVG_MAX_BYTE_SIZE = 100_000;\nexport const SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(\n SVG_MAX_BYTE_SIZE / 1000,\n)}kb`;\n\n/**\n * Assert that a virtual file containing a Snap icon is valid.\n *\n * @param icon - A virtual file containing a Snap icon.\n */\nexport function assertIsSnapIcon(icon: VirtualFile) {\n assert(icon.path.endsWith('.svg'), 'Expected snap icon to end in \".svg\".');\n\n const byteLength =\n typeof icon.value === 'string'\n ? stringToBytes(icon.value).byteLength\n : icon.value.byteLength;\n\n assert(\n byteLength <= SVG_MAX_BYTE_SIZE,\n `The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`,\n );\n\n assert(isSvg(icon.toString()), 'Snap icon must be a valid SVG.');\n}\n\n/**\n * Extract the dimensions of an image from an SVG string if possible.\n *\n * @param svg - An SVG string.\n * @returns The height and width of the SVG or null.\n */\nexport function getSvgDimensions(svg: string): {\n height: number;\n width: number;\n} | null {\n try {\n const parsed = parseSvg(svg);\n\n const height = parsed['@_height'];\n const width = parsed['@_width'];\n\n if (height && width) {\n return { height, width };\n }\n\n const viewBox = parsed['@_viewBox'];\n if (viewBox) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_minX, _minY, viewBoxWidth, viewBoxHeight] = viewBox.split(' ');\n\n if (viewBoxWidth && viewBoxHeight) {\n const parsedWidth = parseInt(viewBoxWidth, 10);\n const parsedHeight = parseInt(viewBoxHeight, 10);\n\n assert(Number.isInteger(parsedWidth) && parsedWidth > 0);\n assert(Number.isInteger(parsedHeight) && parsedHeight > 0);\n\n return {\n width: parsedWidth,\n height: parsedHeight,\n };\n }\n }\n } catch {\n throw new Error('Snap icon must be a valid SVG.');\n }\n\n return null;\n}\n"],"mappings":";AAAA,SAAS,OAAO,gBAAgB;AAChC,SAAS,QAAQ,qBAAqB;AAI/B,IAAM,oBAAoB;AAC1B,IAAM,yBAAyB,GAAG,KAAK;AAAA,EAC5C,oBAAoB;AACtB,CAAC;AAOM,SAAS,iBAAiB,MAAmB;AAClD,SAAO,KAAK,KAAK,SAAS,MAAM,GAAG,sCAAsC;AAEzE,QAAM,aACJ,OAAO,KAAK,UAAU,WAClB,cAAc,KAAK,KAAK,EAAE,aAC1B,KAAK,MAAM;AAEjB;AAAA,IACE,cAAc;AAAA,IACd,sDAAsD,sBAAsB;AAAA,EAC9E;AAEA,SAAO,MAAM,KAAK,SAAS,CAAC,GAAG,gCAAgC;AACjE;AAQO,SAAS,iBAAiB,KAGxB;AACP,MAAI;AACF,UAAM,SAAS,SAAS,GAAG;AAE3B,UAAM,SAAS,OAAO,UAAU;AAChC,UAAM,QAAQ,OAAO,SAAS;AAE9B,QAAI,UAAU,OAAO;AACnB,aAAO,EAAE,QAAQ,MAAM;AAAA,IACzB;AAEA,UAAM,UAAU,OAAO,WAAW;AAClC,QAAI,SAAS;AAEX,YAAM,CAAC,OAAO,OAAO,cAAc,aAAa,IAAI,QAAQ,MAAM,GAAG;AAErE,UAAI,gBAAgB,eAAe;AACjC,cAAM,cAAc,SAAS,cAAc,EAAE;AAC7C,cAAM,eAAe,SAAS,eAAe,EAAE;AAE/C,eAAO,OAAO,UAAU,WAAW,KAAK,cAAc,CAAC;AACvD,eAAO,OAAO,UAAU,YAAY,KAAK,eAAe,CAAC;AAEzD,eAAO;AAAA,UACL,OAAO;AAAA,UACP,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA,EACF,QAAQ;AACN,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertIsSnapManifest
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LCWDLIK5.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ProgrammaticallyFixableSnapError,
|
|
6
6
|
getSnapChecksum,
|
|
7
7
|
validateSnapShasum
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-2IWSQJKQ.mjs";
|
|
9
9
|
import {
|
|
10
10
|
assertIsSnapIcon,
|
|
11
11
|
getSvgDimensions
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-MNCFAD4E.mjs";
|
|
13
13
|
import {
|
|
14
14
|
SnapValidationFailureReason,
|
|
15
15
|
assertIsNpmSnapPackageJson
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-T6FWIDA6.mjs";
|
|
17
17
|
import {
|
|
18
18
|
getValidatedLocalizationFiles,
|
|
19
19
|
validateSnapManifestLocalizations
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-WEOCOYES.mjs";
|
|
21
21
|
import {
|
|
22
22
|
readJsonFile
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-7Y3WSN44.mjs";
|
|
24
24
|
import {
|
|
25
25
|
readVirtualFile
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-IGMAXVPP.mjs";
|
|
27
27
|
import {
|
|
28
28
|
VirtualFile
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-ZJRWU4AJ.mjs";
|
|
30
30
|
import {
|
|
31
31
|
deepClone
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-Z2JQNSVL.mjs";
|
|
33
33
|
|
|
34
34
|
// src/manifest/manifest.ts
|
|
35
35
|
import { getErrorMessage } from "@metamask/snaps-sdk";
|
|
@@ -406,4 +406,4 @@ export {
|
|
|
406
406
|
getWritableManifest,
|
|
407
407
|
validateNpmSnapManifest
|
|
408
408
|
};
|
|
409
|
-
//# sourceMappingURL=chunk-
|
|
409
|
+
//# sourceMappingURL=chunk-PIG67G67.mjs.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkHJYRGKCXjs = require('./chunk-HJYRGKCX.js');
|
|
4
4
|
|
|
5
5
|
// src/virtual-file/toVirtualFile.ts
|
|
6
6
|
var _fs = require('fs');
|
|
7
7
|
async function readVirtualFile(path, encoding = null) {
|
|
8
|
-
return new (0,
|
|
8
|
+
return new (0, _chunkHJYRGKCXjs.VirtualFile)({
|
|
9
9
|
path,
|
|
10
10
|
value: await _fs.promises.readFile(path, { encoding })
|
|
11
11
|
});
|
|
@@ -18,4 +18,4 @@ async function writeVirtualFile(vfile, options) {
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
exports.readVirtualFile = readVirtualFile; exports.writeVirtualFile = writeVirtualFile;
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-QSCKTRRU.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isEqual
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-P252LKUT.mjs";
|
|
4
4
|
|
|
5
5
|
// src/derivation-paths.ts
|
|
6
6
|
import slip44 from "@metamask/slip44";
|
|
@@ -166,4 +166,4 @@ export {
|
|
|
166
166
|
getSnapDerivationPathName,
|
|
167
167
|
getSlip44ProtocolName
|
|
168
168
|
};
|
|
169
|
-
//# sourceMappingURL=chunk-
|
|
169
|
+
//# sourceMappingURL=chunk-QX6MAFJU.mjs.map
|
|
@@ -12,7 +12,7 @@ var PostProcessWarning = /* @__PURE__ */ ((PostProcessWarning2) => {
|
|
|
12
12
|
PostProcessWarning2["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.";
|
|
13
13
|
return PostProcessWarning2;
|
|
14
14
|
})(PostProcessWarning || {});
|
|
15
|
-
var TOKEN_REGEX = /(<!)(--)|(--)(>)|(import)(\(.*?\))/gu;
|
|
15
|
+
var TOKEN_REGEX = /(<!)(--)|(--)(>)|(--)(!)(>)|(import)(\(.*?\))/gu;
|
|
16
16
|
var EMPTY_TEMPLATE_ELEMENT = templateElement({ raw: "", cooked: "" });
|
|
17
17
|
var evalWrapper = template.statement(`
|
|
18
18
|
(1, REF)(ARGS)
|
|
@@ -246,4 +246,4 @@ export {
|
|
|
246
246
|
PostProcessWarning,
|
|
247
247
|
postProcessBundle
|
|
248
248
|
};
|
|
249
|
-
//# sourceMappingURL=chunk-
|
|
249
|
+
//# sourceMappingURL=chunk-QYPLUMB7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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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