@metamask/snaps-utils 6.1.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.
- package/CHANGELOG.md +24 -1
- package/dist/array.js +8 -0
- package/dist/array.js.map +1 -0
- package/dist/array.mjs +8 -0
- package/dist/array.mjs.map +1 -0
- package/dist/auxiliary-files.js +12 -0
- package/dist/auxiliary-files.js.map +1 -0
- package/dist/auxiliary-files.mjs +12 -0
- package/dist/auxiliary-files.mjs.map +1 -0
- package/dist/base64.js +13 -0
- package/dist/base64.js.map +1 -0
- package/dist/base64.mjs +13 -0
- package/dist/base64.mjs.map +1 -0
- package/dist/bytes.js +10 -0
- package/dist/bytes.js.map +1 -0
- package/dist/bytes.mjs +10 -0
- package/dist/bytes.mjs.map +1 -0
- package/dist/caveats.js +8 -0
- package/dist/caveats.js.map +1 -0
- package/dist/caveats.mjs +8 -0
- package/dist/caveats.mjs.map +1 -0
- package/dist/checksum.js +13 -0
- package/dist/checksum.js.map +1 -0
- package/dist/checksum.mjs +13 -0
- package/dist/checksum.mjs.map +1 -0
- package/dist/chunk-224DMTNJ.mjs +409 -0
- package/dist/chunk-224DMTNJ.mjs.map +1 -0
- package/dist/chunk-2IWSQJKQ.mjs +193 -0
- package/dist/chunk-2IWSQJKQ.mjs.map +1 -0
- package/dist/chunk-2LBN5T56.js +64 -0
- package/dist/chunk-2LBN5T56.js.map +1 -0
- package/dist/chunk-2PCPD5XY.js +169 -0
- package/dist/chunk-2PCPD5XY.js.map +1 -0
- package/dist/chunk-3SOYDY4W.js +152 -0
- package/dist/chunk-3SOYDY4W.js.map +1 -0
- package/dist/chunk-44GPX66J.mjs +70 -0
- package/dist/chunk-44GPX66J.mjs.map +1 -0
- package/dist/chunk-44VFHYJO.js +249 -0
- package/dist/chunk-44VFHYJO.js.map +1 -0
- package/dist/chunk-473MIETW.js +18 -0
- package/dist/chunk-473MIETW.js.map +1 -0
- package/dist/chunk-4BDR6KRH.js +50 -0
- package/dist/chunk-4BDR6KRH.js.map +1 -0
- package/dist/chunk-4CMD46B2.js +1 -0
- package/dist/chunk-4CMD46B2.js.map +1 -0
- package/dist/chunk-5R7UF7KM.mjs +21 -0
- package/dist/chunk-5R7UF7KM.mjs.map +1 -0
- package/dist/chunk-63OXILAY.mjs +69 -0
- package/dist/chunk-63OXILAY.mjs.map +1 -0
- package/dist/chunk-6CHO3LOX.mjs +10 -0
- package/dist/chunk-6CHO3LOX.mjs.map +1 -0
- package/dist/chunk-6LOYTBS3.js +107 -0
- package/dist/chunk-6LOYTBS3.js.map +1 -0
- package/dist/chunk-6YRUDGNL.mjs +18 -0
- package/dist/chunk-6YRUDGNL.mjs.map +1 -0
- package/dist/chunk-772OPTGX.js +70 -0
- package/dist/chunk-772OPTGX.js.map +1 -0
- package/dist/chunk-7LG4D4XA.mjs +20 -0
- package/dist/chunk-7LG4D4XA.mjs.map +1 -0
- package/dist/chunk-7LOABHVW.js +1 -0
- package/dist/chunk-7LOABHVW.js.map +1 -0
- package/dist/chunk-7MTAHOWC.mjs +1 -0
- package/dist/chunk-7MTAHOWC.mjs.map +1 -0
- package/dist/chunk-7P62OIGX.js +69 -0
- package/dist/chunk-7P62OIGX.js.map +1 -0
- package/dist/chunk-7Y3WSN44.mjs +103 -0
- package/dist/chunk-7Y3WSN44.mjs.map +1 -0
- package/dist/chunk-A3RRMELT.mjs +1 -0
- package/dist/chunk-A3RRMELT.mjs.map +1 -0
- package/dist/chunk-A6E325SZ.js +211 -0
- package/dist/chunk-A6E325SZ.js.map +1 -0
- package/dist/chunk-AFQY2CNY.js +109 -0
- package/dist/chunk-AFQY2CNY.js.map +1 -0
- package/dist/chunk-AOGVLPQZ.js +18 -0
- package/dist/chunk-AOGVLPQZ.js.map +1 -0
- package/dist/chunk-AS5P6JRP.mjs +9 -0
- package/dist/chunk-AS5P6JRP.mjs.map +1 -0
- package/dist/chunk-ASZWZ7JT.js +20 -0
- package/dist/chunk-ASZWZ7JT.js.map +1 -0
- package/dist/chunk-BGSO2GQC.mjs +41 -0
- package/dist/chunk-BGSO2GQC.mjs.map +1 -0
- package/dist/chunk-CMOSYNZR.js +95 -0
- package/dist/chunk-CMOSYNZR.js.map +1 -0
- package/dist/chunk-CNNMLOQ6.js +409 -0
- package/dist/chunk-CNNMLOQ6.js.map +1 -0
- package/dist/chunk-CQRPSEH3.js +74 -0
- package/dist/chunk-CQRPSEH3.js.map +1 -0
- package/dist/chunk-DKDGMZFU.mjs +74 -0
- package/dist/chunk-DKDGMZFU.mjs.map +1 -0
- package/dist/chunk-E3BDBG6T.js +20 -0
- package/dist/chunk-E3BDBG6T.js.map +1 -0
- package/dist/chunk-EA2FOAEG.mjs +64 -0
- package/dist/chunk-EA2FOAEG.mjs.map +1 -0
- package/dist/chunk-EFRPCO3C.js +1 -0
- package/dist/chunk-EFRPCO3C.js.map +1 -0
- package/dist/chunk-ENKAY3PI.js +281 -0
- package/dist/chunk-ENKAY3PI.js.map +1 -0
- package/dist/chunk-EXUEHPZ4.mjs +107 -0
- package/dist/chunk-EXUEHPZ4.mjs.map +1 -0
- package/dist/chunk-FOWIC2SO.mjs +38 -0
- package/dist/chunk-FOWIC2SO.mjs.map +1 -0
- package/dist/chunk-GTAYOKI4.mjs +211 -0
- package/dist/chunk-GTAYOKI4.mjs.map +1 -0
- package/dist/chunk-HF7HUZ5Z.js +10 -0
- package/dist/chunk-HF7HUZ5Z.js.map +1 -0
- package/dist/chunk-HJRCBSNA.mjs +32 -0
- package/dist/chunk-HJRCBSNA.mjs.map +1 -0
- package/dist/chunk-HJYRGKCX.js +50 -0
- package/dist/chunk-HJYRGKCX.js.map +1 -0
- package/dist/chunk-HYF7Q6VY.mjs +1 -0
- package/dist/chunk-HYF7Q6VY.mjs.map +1 -0
- package/dist/chunk-I77AVJKV.mjs +152 -0
- package/dist/chunk-I77AVJKV.mjs.map +1 -0
- package/dist/chunk-IGMAXVPP.mjs +21 -0
- package/dist/chunk-IGMAXVPP.mjs.map +1 -0
- package/dist/chunk-IHQPAJ2B.js +38 -0
- package/dist/chunk-IHQPAJ2B.js.map +1 -0
- package/dist/chunk-IJX3CXOY.js +9 -0
- package/dist/chunk-IJX3CXOY.js.map +1 -0
- package/dist/chunk-IPOE62V4.js +30 -0
- package/dist/chunk-IPOE62V4.js.map +1 -0
- package/dist/chunk-IV3FSWZ7.mjs +9 -0
- package/dist/chunk-IV3FSWZ7.mjs.map +1 -0
- package/dist/chunk-IXBJNVHK.js +22 -0
- package/dist/chunk-IXBJNVHK.js.map +1 -0
- package/dist/chunk-JI5NQ2C3.mjs +1 -0
- package/dist/chunk-JI5NQ2C3.mjs.map +1 -0
- package/dist/chunk-JMDSN227.mjs +25 -0
- package/dist/chunk-JMDSN227.mjs.map +1 -0
- package/dist/chunk-K6BCBPXF.js +151 -0
- package/dist/chunk-K6BCBPXF.js.map +1 -0
- package/dist/chunk-KMLVVVK3.mjs +22 -0
- package/dist/chunk-KMLVVVK3.mjs.map +1 -0
- package/dist/chunk-LBRWAC27.js +56 -0
- package/dist/chunk-LBRWAC27.js.map +1 -0
- package/dist/chunk-LCWDLIK5.mjs +281 -0
- package/dist/chunk-LCWDLIK5.mjs.map +1 -0
- package/dist/chunk-LEKZPKS2.js +21 -0
- package/dist/chunk-LEKZPKS2.js.map +1 -0
- package/dist/chunk-LSPOXPJJ.mjs +63 -0
- package/dist/chunk-LSPOXPJJ.mjs.map +1 -0
- package/dist/chunk-MCEKOGEG.mjs +50 -0
- package/dist/chunk-MCEKOGEG.mjs.map +1 -0
- package/dist/chunk-MLOQHUOY.js +32 -0
- package/dist/chunk-MLOQHUOY.js.map +1 -0
- package/dist/chunk-N722KRZW.js +41 -0
- package/dist/chunk-N722KRZW.js.map +1 -0
- package/dist/chunk-NUCLSR2G.js +8 -0
- package/dist/chunk-NUCLSR2G.js.map +1 -0
- package/dist/chunk-P252LKUT.mjs +9 -0
- package/dist/chunk-P252LKUT.mjs.map +1 -0
- package/dist/chunk-PHUTP7NB.js +25 -0
- package/dist/chunk-PHUTP7NB.js.map +1 -0
- package/dist/chunk-PJMEJVOB.mjs +29 -0
- package/dist/chunk-PJMEJVOB.mjs.map +1 -0
- package/dist/chunk-PLBSSUVY.js +29 -0
- package/dist/chunk-PLBSSUVY.js.map +1 -0
- package/dist/chunk-Q7RCL5IE.js +30 -0
- package/dist/chunk-Q7RCL5IE.js.map +1 -0
- package/dist/chunk-QSCKTRRU.js +21 -0
- package/dist/chunk-QSCKTRRU.js.map +1 -0
- package/dist/chunk-QX6MAFJU.mjs +169 -0
- package/dist/chunk-QX6MAFJU.mjs.map +1 -0
- package/dist/chunk-QYPLUMB7.mjs +249 -0
- 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-SRMDDOVO.mjs +20 -0
- package/dist/chunk-SRMDDOVO.mjs.map +1 -0
- package/dist/chunk-T3VM5YXY.js +1 -0
- package/dist/chunk-T3VM5YXY.js.map +1 -0
- package/dist/chunk-T3YY4JIJ.js +9 -0
- package/dist/chunk-T3YY4JIJ.js.map +1 -0
- package/dist/chunk-T6FWIDA6.mjs +95 -0
- package/dist/chunk-T6FWIDA6.mjs.map +1 -0
- package/dist/chunk-TFP64TMV.js +1 -0
- package/dist/chunk-TFP64TMV.js.map +1 -0
- package/dist/chunk-TG4BDSYJ.js +193 -0
- package/dist/chunk-TG4BDSYJ.js.map +1 -0
- package/dist/chunk-UMZNVWEM.mjs +30 -0
- package/dist/chunk-UMZNVWEM.mjs.map +1 -0
- package/dist/chunk-UW74NLTC.mjs +18 -0
- package/dist/chunk-UW74NLTC.mjs.map +1 -0
- package/dist/chunk-VWGXNUMD.mjs +151 -0
- package/dist/chunk-VWGXNUMD.mjs.map +1 -0
- package/dist/chunk-WEOCOYES.mjs +109 -0
- package/dist/chunk-WEOCOYES.mjs.map +1 -0
- package/dist/chunk-WF56W2AR.mjs +30 -0
- package/dist/chunk-WF56W2AR.mjs.map +1 -0
- package/dist/chunk-X44Z53IG.js +103 -0
- package/dist/chunk-X44Z53IG.js.map +1 -0
- package/dist/chunk-Z2JQNSVL.mjs +8 -0
- package/dist/chunk-Z2JQNSVL.mjs.map +1 -0
- package/dist/chunk-ZJRWU4AJ.mjs +50 -0
- package/dist/chunk-ZJRWU4AJ.mjs.map +1 -0
- package/dist/chunk-ZT3KKTS2.js +9 -0
- package/dist/chunk-ZT3KKTS2.js.map +1 -0
- package/dist/cronjob.js +20 -0
- package/dist/cronjob.js.map +1 -0
- package/dist/cronjob.mjs +20 -0
- package/dist/cronjob.mjs.map +1 -0
- package/dist/deep-clone.js +8 -0
- package/dist/deep-clone.js.map +1 -0
- package/dist/deep-clone.mjs +8 -0
- package/dist/deep-clone.mjs.map +1 -0
- package/dist/default-endowments.js +8 -0
- package/dist/default-endowments.js.map +1 -0
- package/dist/default-endowments.mjs +8 -0
- package/dist/default-endowments.mjs.map +1 -0
- package/dist/derivation-paths.js +13 -0
- package/dist/derivation-paths.js.map +1 -0
- package/dist/derivation-paths.mjs +13 -0
- package/dist/derivation-paths.mjs.map +1 -0
- package/dist/entropy.js +10 -0
- package/dist/entropy.js.map +1 -0
- package/dist/entropy.mjs +10 -0
- package/dist/entropy.mjs.map +1 -0
- package/dist/errors.js +20 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +20 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/eval-worker.js +43 -0
- package/dist/eval-worker.js.map +1 -0
- package/dist/eval-worker.mjs +43 -0
- package/dist/eval-worker.mjs.map +1 -0
- package/dist/eval.js +17 -0
- package/dist/eval.js.map +1 -0
- package/dist/eval.mjs +17 -0
- package/dist/eval.mjs.map +1 -0
- package/dist/fs.js +28 -0
- package/dist/fs.js.map +1 -0
- package/dist/fs.mjs +28 -0
- package/dist/fs.mjs.map +1 -0
- package/dist/handler-types.js +10 -0
- package/dist/handler-types.js.map +1 -0
- package/dist/handler-types.mjs +10 -0
- package/dist/handler-types.mjs.map +1 -0
- package/dist/handlers.js +35 -0
- package/dist/handlers.js.map +1 -0
- package/dist/handlers.mjs +35 -0
- package/dist/handlers.mjs.map +1 -0
- package/dist/icon.js +14 -0
- package/dist/icon.js.map +1 -0
- package/dist/icon.mjs +14 -0
- package/dist/icon.mjs.map +1 -0
- package/dist/iframe.js +8 -0
- package/dist/iframe.js.map +1 -0
- package/dist/iframe.mjs +8 -0
- package/dist/iframe.mjs.map +1 -0
- package/dist/index.executionenv.js +134 -0
- package/dist/index.executionenv.js.map +1 -0
- package/dist/index.executionenv.mjs +134 -0
- package/dist/index.executionenv.mjs.map +1 -0
- package/dist/index.js +378 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +378 -0
- package/dist/index.mjs.map +1 -0
- package/dist/json-rpc.js +18 -0
- package/dist/json-rpc.js.map +1 -0
- package/dist/json-rpc.mjs +18 -0
- package/dist/json-rpc.mjs.map +1 -0
- package/dist/json.js +8 -0
- package/dist/json.js.map +1 -0
- package/dist/json.mjs +8 -0
- package/dist/json.mjs.map +1 -0
- package/dist/localization.js +23 -0
- package/dist/localization.js.map +1 -0
- package/dist/localization.mjs +23 -0
- package/dist/localization.mjs.map +1 -0
- package/dist/logging.js +14 -0
- package/dist/logging.js.map +1 -0
- package/dist/logging.mjs +14 -0
- package/dist/logging.mjs.map +1 -0
- package/dist/manifest/index.js +59 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/index.mjs +59 -0
- package/dist/manifest/index.mjs.map +1 -0
- package/dist/manifest/manifest.js +42 -0
- package/dist/manifest/manifest.js.map +1 -0
- package/dist/manifest/manifest.mjs +42 -0
- package/dist/manifest/manifest.mjs.map +1 -0
- package/dist/manifest/node.js +85 -0
- package/dist/manifest/node.js.map +1 -0
- package/dist/manifest/node.mjs +85 -0
- package/dist/manifest/node.mjs.map +1 -0
- package/dist/manifest/validation.js +58 -0
- package/dist/manifest/validation.js.map +1 -0
- package/dist/manifest/validation.mjs +58 -0
- package/dist/manifest/validation.mjs.map +1 -0
- package/dist/mock.js +13 -0
- package/dist/mock.js.map +1 -0
- package/dist/mock.mjs +13 -0
- package/dist/mock.mjs.map +1 -0
- package/dist/namespace.js +44 -0
- package/dist/namespace.js.map +1 -0
- package/dist/namespace.mjs +44 -0
- package/dist/namespace.mjs.map +1 -0
- package/dist/node.js +448 -0
- package/dist/node.js.map +1 -0
- package/dist/node.mjs +448 -0
- package/dist/node.mjs.map +1 -0
- package/dist/npm.js +32 -0
- package/dist/npm.js.map +1 -0
- package/dist/npm.mjs +32 -0
- package/dist/npm.mjs.map +1 -0
- package/dist/path.js +8 -0
- package/dist/path.js.map +1 -0
- package/dist/path.mjs +8 -0
- package/dist/path.mjs.map +1 -0
- package/dist/post-process.js +10 -0
- package/dist/post-process.js.map +1 -0
- package/dist/post-process.mjs +10 -0
- package/dist/post-process.mjs.map +1 -0
- package/dist/snaps.js +48 -0
- package/dist/snaps.js.map +1 -0
- package/dist/snaps.mjs +48 -0
- package/dist/snaps.mjs.map +1 -0
- package/dist/strings.js +8 -0
- package/dist/strings.js.map +1 -0
- package/dist/strings.mjs +8 -0
- package/dist/strings.mjs.map +1 -0
- package/dist/structs.js +31 -0
- package/dist/structs.js.map +1 -0
- package/dist/structs.mjs +31 -0
- package/dist/structs.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/bytes.d.ts +1 -1
- package/dist/types/checksum.d.ts +1 -1
- package/dist/types/index.d.ts +1 -6
- package/dist/types/json-rpc.d.ts +1 -1
- package/dist/types/localization.d.ts +1 -1
- package/dist/types/manifest/index.d.ts +0 -1
- package/dist/types/manifest/manifest.d.ts +1 -1
- package/dist/types/manifest/node.d.ts +2 -0
- package/dist/types/manifest/validation.d.ts +5 -5
- package/dist/types/node.d.ts +8 -0
- package/dist/types/structs.d.ts +0 -20
- package/dist/types/ui.d.ts +7 -0
- package/dist/types/virtual-file/index.d.ts +0 -1
- package/dist/types/virtual-file/node.d.ts +2 -0
- package/dist/types.js +28 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +28 -0
- package/dist/types.mjs.map +1 -0
- package/dist/ui.js +12 -0
- package/dist/ui.js.map +1 -0
- package/dist/ui.mjs +12 -0
- package/dist/ui.mjs.map +1 -0
- package/dist/validation.js +24 -0
- package/dist/validation.js.map +1 -0
- package/dist/validation.mjs +24 -0
- package/dist/validation.mjs.map +1 -0
- package/dist/versions.js +12 -0
- package/dist/versions.js.map +1 -0
- package/dist/versions.mjs +12 -0
- package/dist/versions.mjs.map +1 -0
- package/dist/virtual-file/VirtualFile.js +9 -0
- package/dist/virtual-file/VirtualFile.js.map +1 -0
- package/dist/virtual-file/VirtualFile.mjs +9 -0
- package/dist/virtual-file/VirtualFile.mjs.map +1 -0
- package/dist/virtual-file/index.js +10 -0
- package/dist/virtual-file/index.js.map +1 -0
- package/dist/virtual-file/index.mjs +10 -0
- package/dist/virtual-file/index.mjs.map +1 -0
- package/dist/virtual-file/node.js +17 -0
- package/dist/virtual-file/node.js.map +1 -0
- package/dist/virtual-file/node.mjs +17 -0
- package/dist/virtual-file/node.mjs.map +1 -0
- package/dist/virtual-file/toVirtualFile.js +12 -0
- package/dist/virtual-file/toVirtualFile.js.map +1 -0
- package/dist/virtual-file/toVirtualFile.mjs +12 -0
- package/dist/virtual-file/toVirtualFile.mjs.map +1 -0
- package/package.json +23 -38
- package/dist/cjs/array.js +0 -23
- package/dist/cjs/array.js.map +0 -1
- package/dist/cjs/auxiliary-files.js +0 -27
- package/dist/cjs/auxiliary-files.js.map +0 -1
- package/dist/cjs/base64.js +0 -44
- package/dist/cjs/base64.js.map +0 -1
- package/dist/cjs/bytes.js +0 -23
- package/dist/cjs/bytes.js.map +0 -1
- package/dist/cjs/caveats.js +0 -48
- package/dist/cjs/caveats.js.map +0 -1
- package/dist/cjs/checksum.js +0 -43
- package/dist/cjs/checksum.js.map +0 -1
- package/dist/cjs/cronjob.js +0 -77
- package/dist/cjs/cronjob.js.map +0 -1
- package/dist/cjs/deep-clone.js +0 -22
- package/dist/cjs/deep-clone.js.map +0 -1
- package/dist/cjs/default-endowments.js +0 -49
- package/dist/cjs/default-endowments.js.map +0 -1
- package/dist/cjs/derivation-paths.js +0 -300
- package/dist/cjs/derivation-paths.js.map +0 -1
- package/dist/cjs/entropy.js +0 -23
- package/dist/cjs/entropy.js.map +0 -1
- package/dist/cjs/errors.js +0 -221
- package/dist/cjs/errors.js.map +0 -1
- package/dist/cjs/eval-worker.js +0 -44
- package/dist/cjs/eval-worker.js.map +0 -1
- package/dist/cjs/eval.js +0 -77
- package/dist/cjs/eval.js.map +0 -1
- package/dist/cjs/fs.js +0 -126
- package/dist/cjs/fs.js.map +0 -1
- package/dist/cjs/handler-types.js +0 -34
- package/dist/cjs/handler-types.js.map +0 -1
- package/dist/cjs/handlers.js +0 -173
- package/dist/cjs/handlers.js.map +0 -1
- package/dist/cjs/icon.js +0 -66
- package/dist/cjs/icon.js.map +0 -1
- package/dist/cjs/iframe.js +0 -59
- package/dist/cjs/iframe.js.map +0 -1
- package/dist/cjs/index.browser.js +0 -49
- package/dist/cjs/index.browser.js.map +0 -1
- package/dist/cjs/index.executionenv.js +0 -27
- package/dist/cjs/index.executionenv.js.map +0 -1
- package/dist/cjs/index.js +0 -54
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/json-rpc.js +0 -81
- package/dist/cjs/json-rpc.js.map +0 -1
- package/dist/cjs/json.js +0 -16
- package/dist/cjs/json.js.map +0 -1
- package/dist/cjs/localization.js +0 -113
- package/dist/cjs/localization.js.map +0 -1
- package/dist/cjs/logging.js +0 -40
- package/dist/cjs/logging.js.map +0 -1
- package/dist/cjs/manifest/index.browser.js +0 -20
- package/dist/cjs/manifest/index.browser.js.map +0 -1
- package/dist/cjs/manifest/index.js +0 -21
- package/dist/cjs/manifest/index.js.map +0 -1
- package/dist/cjs/manifest/manifest.js +0 -283
- package/dist/cjs/manifest/manifest.js.map +0 -1
- package/dist/cjs/manifest/validation.js +0 -244
- package/dist/cjs/manifest/validation.js.map +0 -1
- package/dist/cjs/mock.js +0 -128
- package/dist/cjs/mock.js.map +0 -1
- package/dist/cjs/namespace.js +0 -136
- package/dist/cjs/namespace.js.map +0 -1
- package/dist/cjs/npm.js +0 -96
- package/dist/cjs/npm.js.map +0 -1
- package/dist/cjs/path.js +0 -21
- package/dist/cjs/path.js.map +0 -1
- package/dist/cjs/post-process.js +0 -328
- package/dist/cjs/post-process.js.map +0 -1
- package/dist/cjs/snaps.js +0 -232
- package/dist/cjs/snaps.js.map +0 -1
- package/dist/cjs/strings.js +0 -21
- package/dist/cjs/strings.js.map +0 -1
- package/dist/cjs/structs.js +0 -210
- package/dist/cjs/structs.js.map +0 -1
- package/dist/cjs/types.js +0 -104
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/ui.js +0 -53
- package/dist/cjs/ui.js.map +0 -1
- package/dist/cjs/validation.js +0 -24
- package/dist/cjs/validation.js.map +0 -1
- package/dist/cjs/versions.js +0 -47
- package/dist/cjs/versions.js.map +0 -1
- package/dist/cjs/virtual-file/VirtualFile.js +0 -92
- package/dist/cjs/virtual-file/VirtualFile.js.map +0 -1
- package/dist/cjs/virtual-file/index.browser.js +0 -20
- package/dist/cjs/virtual-file/index.browser.js.map +0 -1
- package/dist/cjs/virtual-file/index.js +0 -21
- package/dist/cjs/virtual-file/index.js.map +0 -1
- package/dist/cjs/virtual-file/toVirtualFile.js +0 -33
- package/dist/cjs/virtual-file/toVirtualFile.js.map +0 -1
- package/dist/esm/array.js +0 -13
- package/dist/esm/array.js.map +0 -1
- package/dist/esm/auxiliary-files.js +0 -23
- package/dist/esm/auxiliary-files.js.map +0 -1
- package/dist/esm/base64.js +0 -36
- package/dist/esm/base64.js.map +0 -1
- package/dist/esm/bytes.js +0 -18
- package/dist/esm/bytes.js.map +0 -1
- package/dist/esm/caveats.js +0 -38
- package/dist/esm/caveats.js.map +0 -1
- package/dist/esm/checksum.js +0 -41
- package/dist/esm/checksum.js.map +0 -1
- package/dist/esm/cronjob.js +0 -59
- package/dist/esm/cronjob.js.map +0 -1
- package/dist/esm/deep-clone.js +0 -7
- package/dist/esm/deep-clone.js.map +0 -1
- package/dist/esm/default-endowments.js +0 -39
- package/dist/esm/default-endowments.js.map +0 -1
- package/dist/esm/derivation-paths.js +0 -287
- package/dist/esm/derivation-paths.js.map +0 -1
- package/dist/esm/entropy.js +0 -6
- package/dist/esm/entropy.js.map +0 -1
- package/dist/esm/errors.js +0 -211
- package/dist/esm/errors.js.map +0 -1
- package/dist/esm/eval-worker.js +0 -40
- package/dist/esm/eval-worker.js.map +0 -1
- package/dist/esm/eval.js +0 -65
- package/dist/esm/eval.js.map +0 -1
- package/dist/esm/fs.js +0 -136
- package/dist/esm/fs.js.map +0 -1
- package/dist/esm/handler-types.js +0 -16
- package/dist/esm/handler-types.js.map +0 -1
- package/dist/esm/handlers.js +0 -119
- package/dist/esm/handlers.js.map +0 -1
- package/dist/esm/icon.js +0 -51
- package/dist/esm/icon.js.map +0 -1
- package/dist/esm/iframe.js +0 -49
- package/dist/esm/iframe.js.map +0 -1
- package/dist/esm/index.browser.js +0 -32
- package/dist/esm/index.browser.js.map +0 -1
- package/dist/esm/index.executionenv.js +0 -10
- package/dist/esm/index.executionenv.js.map +0 -1
- package/dist/esm/index.js +0 -37
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/json-rpc.js +0 -79
- package/dist/esm/json-rpc.js.map +0 -1
- package/dist/esm/json.js +0 -17
- package/dist/esm/json.js.map +0 -1
- package/dist/esm/localization.js +0 -115
- package/dist/esm/localization.js.map +0 -1
- package/dist/esm/logging.js +0 -59
- package/dist/esm/logging.js.map +0 -1
- package/dist/esm/manifest/index.browser.js +0 -3
- package/dist/esm/manifest/index.browser.js.map +0 -1
- package/dist/esm/manifest/index.js +0 -4
- package/dist/esm/manifest/index.js.map +0 -1
- package/dist/esm/manifest/manifest.js +0 -307
- package/dist/esm/manifest/manifest.js.map +0 -1
- package/dist/esm/manifest/validation.js +0 -190
- package/dist/esm/manifest/validation.js.map +0 -1
- package/dist/esm/mock.js +0 -111
- package/dist/esm/mock.js.map +0 -1
- package/dist/esm/namespace.js +0 -113
- package/dist/esm/namespace.js.map +0 -1
- package/dist/esm/npm.js +0 -85
- package/dist/esm/npm.js.map +0 -1
- package/dist/esm/path.js +0 -17
- package/dist/esm/path.js.map +0 -1
- package/dist/esm/post-process.js +0 -333
- package/dist/esm/post-process.js.map +0 -1
- package/dist/esm/snaps.js +0 -217
- package/dist/esm/snaps.js.map +0 -1
- package/dist/esm/strings.js +0 -11
- package/dist/esm/strings.js.map +0 -1
- package/dist/esm/structs.js +0 -295
- package/dist/esm/structs.js.map +0 -1
- package/dist/esm/types.js +0 -78
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/ui.js +0 -50
- package/dist/esm/ui.js.map +0 -1
- package/dist/esm/validation.js +0 -19
- package/dist/esm/validation.js.map +0 -1
- package/dist/esm/versions.js +0 -41
- package/dist/esm/versions.js.map +0 -1
- package/dist/esm/virtual-file/VirtualFile.js +0 -82
- package/dist/esm/virtual-file/VirtualFile.js.map +0 -1
- package/dist/esm/virtual-file/index.browser.js +0 -3
- package/dist/esm/virtual-file/index.browser.js.map +0 -1
- package/dist/esm/virtual-file/index.js +0 -4
- package/dist/esm/virtual-file/index.js.map +0 -1
- package/dist/esm/virtual-file/toVirtualFile.js +0 -26
- package/dist/esm/virtual-file/toVirtualFile.js.map +0 -1
- package/dist/types/index.browser.d.ts +0 -30
- package/dist/types/manifest/index.browser.d.ts +0 -1
- package/dist/types/virtual-file/index.browser.d.ts +0 -1
package/dist/esm/eval-worker.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-unassigned-import
|
|
2
|
-
import 'ses/lockdown';
|
|
3
|
-
import { readFileSync } from 'fs';
|
|
4
|
-
import { SNAP_EXPORT_NAMES } from './handler-types';
|
|
5
|
-
import { generateMockEndowments } from './mock';
|
|
6
|
-
lockdown({
|
|
7
|
-
consoleTaming: 'unsafe',
|
|
8
|
-
errorTaming: 'unsafe',
|
|
9
|
-
mathTaming: 'unsafe',
|
|
10
|
-
dateTaming: 'unsafe',
|
|
11
|
-
overrideTaming: 'severe',
|
|
12
|
-
// We disable domain taming, because it does not work in certain cases when
|
|
13
|
-
// running tests. This is unlikely to be a problem in production, because
|
|
14
|
-
// Node.js domains are deprecated.
|
|
15
|
-
domainTaming: 'unsafe'
|
|
16
|
-
});
|
|
17
|
-
const snapFilePath = process.argv[2];
|
|
18
|
-
const snapModule = {
|
|
19
|
-
exports: {}
|
|
20
|
-
};
|
|
21
|
-
const compartment = new Compartment({
|
|
22
|
-
...generateMockEndowments(),
|
|
23
|
-
module: snapModule,
|
|
24
|
-
exports: snapModule.exports
|
|
25
|
-
});
|
|
26
|
-
// Mirror BaseSnapExecutor
|
|
27
|
-
compartment.globalThis.self = compartment.globalThis;
|
|
28
|
-
compartment.globalThis.global = compartment.globalThis;
|
|
29
|
-
compartment.globalThis.window = compartment.globalThis;
|
|
30
|
-
compartment.evaluate(readFileSync(snapFilePath, 'utf8'));
|
|
31
|
-
const invalidExports = Object.keys(snapModule.exports).filter((snapExport)=>!SNAP_EXPORT_NAMES.includes(snapExport));
|
|
32
|
-
if (invalidExports.length > 0) {
|
|
33
|
-
// eslint-disable-next-line no-console
|
|
34
|
-
console.warn(`Invalid snap exports detected:\n${invalidExports.join('\n')}`);
|
|
35
|
-
}
|
|
36
|
-
// To ensure the worker exits we explicitly call exit here
|
|
37
|
-
// If we didn't the eval would wait for timers set during Compartment eval
|
|
38
|
-
process.exit(0);
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=eval-worker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/eval-worker.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport 'ses/lockdown';\n\nimport { readFileSync } from 'fs';\n\nimport type { HandlerType } from './handler-types';\nimport { SNAP_EXPORT_NAMES } from './handler-types';\nimport { generateMockEndowments } from './mock';\n\ndeclare let lockdown: any, Compartment: any;\n\nlockdown({\n consoleTaming: 'unsafe',\n errorTaming: 'unsafe',\n mathTaming: 'unsafe',\n dateTaming: 'unsafe',\n overrideTaming: 'severe',\n\n // We disable domain taming, because it does not work in certain cases when\n // running tests. This is unlikely to be a problem in production, because\n // Node.js domains are deprecated.\n domainTaming: 'unsafe',\n});\n\nconst snapFilePath = process.argv[2];\n\nconst snapModule: { exports?: any } = { exports: {} };\n\nconst compartment = new Compartment({\n ...generateMockEndowments(),\n module: snapModule,\n exports: snapModule.exports,\n});\n\n// Mirror BaseSnapExecutor\ncompartment.globalThis.self = compartment.globalThis;\ncompartment.globalThis.global = compartment.globalThis;\ncompartment.globalThis.window = compartment.globalThis;\n\ncompartment.evaluate(readFileSync(snapFilePath, 'utf8'));\n\nconst invalidExports = Object.keys(snapModule.exports).filter(\n (snapExport) => !SNAP_EXPORT_NAMES.includes(snapExport as HandlerType),\n);\n\nif (invalidExports.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(`Invalid snap exports detected:\\n${invalidExports.join('\\n')}`);\n}\n\n// To ensure the worker exits we explicitly call exit here\n// If we didn't the eval would wait for timers set during Compartment eval\nprocess.exit(0);\n"],"names":["readFileSync","SNAP_EXPORT_NAMES","generateMockEndowments","lockdown","consoleTaming","errorTaming","mathTaming","dateTaming","overrideTaming","domainTaming","snapFilePath","process","argv","snapModule","exports","compartment","Compartment","module","globalThis","self","global","window","evaluate","invalidExports","Object","keys","filter","snapExport","includes","length","console","warn","join","exit"],"mappings":"AAAA,uDAAuD;AACvD,OAAO,eAAe;AAEtB,SAASA,YAAY,QAAQ,KAAK;AAGlC,SAASC,iBAAiB,QAAQ,kBAAkB;AACpD,SAASC,sBAAsB,QAAQ,SAAS;AAIhDC,SAAS;IACPC,eAAe;IACfC,aAAa;IACbC,YAAY;IACZC,YAAY;IACZC,gBAAgB;IAEhB,2EAA2E;IAC3E,yEAAyE;IACzE,kCAAkC;IAClCC,cAAc;AAChB;AAEA,MAAMC,eAAeC,QAAQC,IAAI,CAAC,EAAE;AAEpC,MAAMC,aAAgC;IAAEC,SAAS,CAAC;AAAE;AAEpD,MAAMC,cAAc,IAAIC,YAAY;IAClC,GAAGd,wBAAwB;IAC3Be,QAAQJ;IACRC,SAASD,WAAWC,OAAO;AAC7B;AAEA,0BAA0B;AAC1BC,YAAYG,UAAU,CAACC,IAAI,GAAGJ,YAAYG,UAAU;AACpDH,YAAYG,UAAU,CAACE,MAAM,GAAGL,YAAYG,UAAU;AACtDH,YAAYG,UAAU,CAACG,MAAM,GAAGN,YAAYG,UAAU;AAEtDH,YAAYO,QAAQ,CAACtB,aAAaU,cAAc;AAEhD,MAAMa,iBAAiBC,OAAOC,IAAI,CAACZ,WAAWC,OAAO,EAAEY,MAAM,CAC3D,CAACC,aAAe,CAAC1B,kBAAkB2B,QAAQ,CAACD;AAG9C,IAAIJ,eAAeM,MAAM,GAAG,GAAG;IAC7B,sCAAsC;IACtCC,QAAQC,IAAI,CAAC,CAAC,gCAAgC,EAAER,eAAeS,IAAI,CAAC,MAAM,CAAC;AAC7E;AAEA,0DAA0D;AAC1D,0EAA0E;AAC1ErB,QAAQsB,IAAI,CAAC"}
|
package/dist/esm/eval.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
function _define_property(obj, key, value) {
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value: value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
|
-
import { assert } from '@metamask/utils';
|
|
15
|
-
import { fork } from 'child_process';
|
|
16
|
-
import { join } from 'path';
|
|
17
|
-
import { validateFilePath } from './fs';
|
|
18
|
-
export class SnapEvalError extends Error {
|
|
19
|
-
constructor(message, output){
|
|
20
|
-
super(message);
|
|
21
|
-
_define_property(this, "output", void 0);
|
|
22
|
-
this.name = 'SnapEvalError';
|
|
23
|
-
this.output = output;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Spawn a new process to run the provided bundle in.
|
|
28
|
-
*
|
|
29
|
-
* @param bundlePath - The path to the bundle to run.
|
|
30
|
-
* @returns `null` if the worker ran successfully.
|
|
31
|
-
* @throws If the worker failed to run successfully.
|
|
32
|
-
*/ export async function evalBundle(bundlePath) {
|
|
33
|
-
await validateFilePath(bundlePath);
|
|
34
|
-
return new Promise((resolve, reject)=>{
|
|
35
|
-
const worker = fork(join(__dirname, 'eval-worker.js'), [
|
|
36
|
-
bundlePath
|
|
37
|
-
], {
|
|
38
|
-
// To avoid printing the output of the worker to the console, we set
|
|
39
|
-
// `stdio` to `pipe` and handle the output ourselves.
|
|
40
|
-
stdio: 'pipe'
|
|
41
|
-
});
|
|
42
|
-
let stdout = '';
|
|
43
|
-
let stderr = '';
|
|
44
|
-
assert(worker.stdout, '`stdout` should be defined.');
|
|
45
|
-
assert(worker.stderr, '`stderr` should be defined.');
|
|
46
|
-
worker.stdout.on('data', (data)=>{
|
|
47
|
-
stdout += data.toString();
|
|
48
|
-
});
|
|
49
|
-
worker.stderr.on('data', (data)=>{
|
|
50
|
-
stderr += data.toString();
|
|
51
|
-
});
|
|
52
|
-
worker.on('exit', (exitCode)=>{
|
|
53
|
-
const output = {
|
|
54
|
-
stdout,
|
|
55
|
-
stderr
|
|
56
|
-
};
|
|
57
|
-
if (exitCode === 0) {
|
|
58
|
-
return resolve(output);
|
|
59
|
-
}
|
|
60
|
-
return reject(new SnapEvalError(`Process exited with non-zero exit code: ${exitCode}.`, output));
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
//# sourceMappingURL=eval.js.map
|
package/dist/esm/eval.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/eval.ts"],"sourcesContent":["import { assert } from '@metamask/utils';\nimport { fork } from 'child_process';\nimport { join } from 'path';\n\nimport { validateFilePath } from './fs';\n\nexport type EvalOutput = {\n stdout: string;\n stderr: string;\n};\n\nexport class SnapEvalError extends Error {\n readonly output: EvalOutput;\n\n constructor(message: string, output: EvalOutput) {\n super(message);\n\n this.name = 'SnapEvalError';\n this.output = output;\n }\n}\n\n/**\n * Spawn a new process to run the provided bundle in.\n *\n * @param bundlePath - The path to the bundle to run.\n * @returns `null` if the worker ran successfully.\n * @throws If the worker failed to run successfully.\n */\nexport async function evalBundle(bundlePath: string): Promise<EvalOutput> {\n await validateFilePath(bundlePath);\n\n return new Promise((resolve, reject) => {\n const worker = fork(join(__dirname, 'eval-worker.js'), [bundlePath], {\n // To avoid printing the output of the worker to the console, we set\n // `stdio` to `pipe` and handle the output ourselves.\n stdio: 'pipe',\n });\n\n let stdout = '';\n let stderr = '';\n\n assert(worker.stdout, '`stdout` should be defined.');\n assert(worker.stderr, '`stderr` should be defined.');\n\n worker.stdout.on('data', (data: Buffer) => {\n stdout += data.toString();\n });\n\n worker.stderr.on('data', (data: Buffer) => {\n stderr += data.toString();\n });\n\n worker.on('exit', (exitCode: number) => {\n const output = {\n stdout,\n stderr,\n };\n\n if (exitCode === 0) {\n return resolve(output);\n }\n\n return reject(\n new SnapEvalError(\n `Process exited with non-zero exit code: ${exitCode}.`,\n output,\n ),\n );\n });\n });\n}\n"],"names":["assert","fork","join","validateFilePath","SnapEvalError","Error","constructor","message","output","name","evalBundle","bundlePath","Promise","resolve","reject","worker","__dirname","stdio","stdout","stderr","on","data","toString","exitCode"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,MAAM,QAAQ,kBAAkB;AACzC,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,IAAI,QAAQ,OAAO;AAE5B,SAASC,gBAAgB,QAAQ,OAAO;AAOxC,OAAO,MAAMC,sBAAsBC;IAGjCC,YAAYC,OAAe,EAAEC,MAAkB,CAAE;QAC/C,KAAK,CAACD;QAHR,uBAASC,UAAT,KAAA;QAKE,IAAI,CAACC,IAAI,GAAG;QACZ,IAAI,CAACD,MAAM,GAAGA;IAChB;AACF;AAEA;;;;;;CAMC,GACD,OAAO,eAAeE,WAAWC,UAAkB;IACjD,MAAMR,iBAAiBQ;IAEvB,OAAO,IAAIC,QAAQ,CAACC,SAASC;QAC3B,MAAMC,SAASd,KAAKC,KAAKc,WAAW,mBAAmB;YAACL;SAAW,EAAE;YACnE,oEAAoE;YACpE,qDAAqD;YACrDM,OAAO;QACT;QAEA,IAAIC,SAAS;QACb,IAAIC,SAAS;QAEbnB,OAAOe,OAAOG,MAAM,EAAE;QACtBlB,OAAOe,OAAOI,MAAM,EAAE;QAEtBJ,OAAOG,MAAM,CAACE,EAAE,CAAC,QAAQ,CAACC;YACxBH,UAAUG,KAAKC,QAAQ;QACzB;QAEAP,OAAOI,MAAM,CAACC,EAAE,CAAC,QAAQ,CAACC;YACxBF,UAAUE,KAAKC,QAAQ;QACzB;QAEAP,OAAOK,EAAE,CAAC,QAAQ,CAACG;YACjB,MAAMf,SAAS;gBACbU;gBACAC;YACF;YAEA,IAAII,aAAa,GAAG;gBAClB,OAAOV,QAAQL;YACjB;YAEA,OAAOM,OACL,IAAIV,cACF,CAAC,wCAAwC,EAAEmB,SAAS,CAAC,CAAC,EACtDf;QAGN;IACF;AACF"}
|
package/dist/esm/fs.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'fs';
|
|
2
|
-
import os from 'os';
|
|
3
|
-
import pathUtils from 'path';
|
|
4
|
-
import { parseJson } from './json';
|
|
5
|
-
import { readVirtualFile } from './virtual-file';
|
|
6
|
-
/**
|
|
7
|
-
* Checks whether the given path string resolves to an existing directory, and
|
|
8
|
-
* optionally creates the directory if it doesn't exist.
|
|
9
|
-
*
|
|
10
|
-
* @param pathString - The path string to check.
|
|
11
|
-
* @param createDir - Whether to create the directory if it doesn't exist.
|
|
12
|
-
* @returns Whether the given path is an existing directory.
|
|
13
|
-
*/ export async function isDirectory(pathString, createDir) {
|
|
14
|
-
try {
|
|
15
|
-
const stats = await fs.stat(pathString);
|
|
16
|
-
return stats.isDirectory();
|
|
17
|
-
} catch (error) {
|
|
18
|
-
if (error.code === 'ENOENT') {
|
|
19
|
-
if (!createDir) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
await fs.mkdir(pathString, {
|
|
23
|
-
recursive: true
|
|
24
|
-
});
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Checks whether the given path string resolves to an existing file.
|
|
32
|
-
*
|
|
33
|
-
* @param pathString - The path string to check.
|
|
34
|
-
* @returns Whether the given path is an existing file.
|
|
35
|
-
*/ export async function isFile(pathString) {
|
|
36
|
-
try {
|
|
37
|
-
const stats = await fs.stat(pathString);
|
|
38
|
-
return stats.isFile();
|
|
39
|
-
} catch (error) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Reads a `.json` file, parses its contents, and returns them.
|
|
45
|
-
*
|
|
46
|
-
* @param pathString - The path to the JSON file.
|
|
47
|
-
* @returns The parsed contents of the JSON file.
|
|
48
|
-
*/ export async function readJsonFile(pathString) {
|
|
49
|
-
if (!pathString.endsWith('.json')) {
|
|
50
|
-
throw new Error('The specified file must be a ".json" file.');
|
|
51
|
-
}
|
|
52
|
-
let file;
|
|
53
|
-
try {
|
|
54
|
-
file = await readVirtualFile(pathString, 'utf8');
|
|
55
|
-
} catch (error) {
|
|
56
|
-
if (error.code === 'ENOENT') {
|
|
57
|
-
throw new Error(`Could not find '${pathString}'. Please ensure that the file exists.`);
|
|
58
|
-
}
|
|
59
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
file.result = parseJson(file.toString());
|
|
62
|
-
return file;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Gets the complete out file path from an output file name and parent
|
|
66
|
-
* directory path.
|
|
67
|
-
*
|
|
68
|
-
* @param outDir - The path to the out file's parent directory.
|
|
69
|
-
* @param outFileName - The out file's name.
|
|
70
|
-
* @returns The complete path to the out file.
|
|
71
|
-
*/ export function getOutfilePath(outDir, outFileName) {
|
|
72
|
-
return pathUtils.join(outDir, outFileName || 'bundle.js');
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Ensures that the outfile name is just a `.js` file name.
|
|
76
|
-
* Throws on validation failure.
|
|
77
|
-
*
|
|
78
|
-
* @param filename - The file name to validate.
|
|
79
|
-
* @returns `true` if validation succeeded.
|
|
80
|
-
* @throws If the file name is invalid.
|
|
81
|
-
*/ export function validateOutfileName(filename) {
|
|
82
|
-
if (!filename.endsWith('.js') || filename === '.js' || pathUtils.basename(filename) !== filename) {
|
|
83
|
-
throw new Error(`Invalid outfile name: ${filename}. Must be a .js file`);
|
|
84
|
-
}
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Validates a file path. Throws on validation failure.
|
|
89
|
-
*
|
|
90
|
-
* @param filePath - The file path to validate.
|
|
91
|
-
* @returns `true` if validation succeeded.
|
|
92
|
-
* @throws If the path does not resolve to a file.
|
|
93
|
-
*/ export async function validateFilePath(filePath) {
|
|
94
|
-
const exists = await isFile(filePath);
|
|
95
|
-
if (!exists) {
|
|
96
|
-
throw new Error(`Invalid params: '${filePath}' is not a file or does not exist.`);
|
|
97
|
-
}
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Validates a directory path. Throws on validation failure.
|
|
102
|
-
*
|
|
103
|
-
* @param dirPath - The directory path to validate.
|
|
104
|
-
* @param createDir - Whether to create the directory if it doesn't exist.
|
|
105
|
-
* @returns `true` if validation succeeded or the directory was created.
|
|
106
|
-
* @throws If the directory does not exist or could not be created.
|
|
107
|
-
*/ export async function validateDirPath(dirPath, createDir) {
|
|
108
|
-
const exists = await isDirectory(dirPath, createDir);
|
|
109
|
-
if (!exists) {
|
|
110
|
-
throw new Error(`Invalid params: '${dirPath}' is not a directory or could not be created.`);
|
|
111
|
-
}
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Creates a temporary file with a given name and content, writes it to disk and calls the provided function.
|
|
116
|
-
* This function handles deletion of the temporary file after usage.
|
|
117
|
-
*
|
|
118
|
-
* @param fileName - The name of the temporary file.
|
|
119
|
-
* @param fileContents - The content of the temporary file.
|
|
120
|
-
* @param fn - The callback function to call when the temporary file has been created.
|
|
121
|
-
*/ export async function useTemporaryFile(fileName, fileContents, fn) {
|
|
122
|
-
const filePath = pathUtils.join(os.tmpdir(), fileName);
|
|
123
|
-
await fs.mkdir(pathUtils.dirname(filePath), {
|
|
124
|
-
recursive: true
|
|
125
|
-
});
|
|
126
|
-
await fs.writeFile(filePath, fileContents);
|
|
127
|
-
try {
|
|
128
|
-
await fn(filePath);
|
|
129
|
-
} finally{
|
|
130
|
-
if (await isFile(filePath)) {
|
|
131
|
-
await fs.unlink(filePath);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
//# sourceMappingURL=fs.js.map
|
package/dist/esm/fs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fs.ts"],"sourcesContent":["import type { Json } from '@metamask/utils';\nimport { promises as fs } from 'fs';\nimport os from 'os';\nimport pathUtils from 'path';\n\nimport { parseJson } from './json';\nimport type { VirtualFile } from './virtual-file';\nimport { readVirtualFile } from './virtual-file';\n\n/**\n * Checks whether the given path string resolves to an existing directory, and\n * optionally creates the directory if it doesn't exist.\n *\n * @param pathString - The path string to check.\n * @param createDir - Whether to create the directory if it doesn't exist.\n * @returns Whether the given path is an existing directory.\n */\nexport async function isDirectory(\n pathString: string,\n createDir: boolean,\n): Promise<boolean> {\n try {\n const stats = await fs.stat(pathString);\n return stats.isDirectory();\n } catch (error) {\n if (error.code === 'ENOENT') {\n if (!createDir) {\n return false;\n }\n\n await fs.mkdir(pathString, { recursive: true });\n return true;\n }\n\n return false;\n }\n}\n\n/**\n * Checks whether the given path string resolves to an existing file.\n *\n * @param pathString - The path string to check.\n * @returns Whether the given path is an existing file.\n */\nexport async function isFile(pathString: string): Promise<boolean> {\n try {\n const stats = await fs.stat(pathString);\n return stats.isFile();\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Reads a `.json` file, parses its contents, and returns them.\n *\n * @param pathString - The path to the JSON file.\n * @returns The parsed contents of the JSON file.\n */\nexport async function readJsonFile<Type extends Json = Json>(\n pathString: string,\n): Promise<VirtualFile<Type>> {\n if (!pathString.endsWith('.json')) {\n throw new Error('The specified file must be a \".json\" file.');\n }\n\n let file;\n try {\n file = await readVirtualFile(pathString, 'utf8');\n } catch (error) {\n if (error.code === 'ENOENT') {\n throw new Error(\n `Could not find '${pathString}'. Please ensure that the file exists.`,\n );\n }\n\n throw error;\n }\n file.result = parseJson(file.toString());\n return file as VirtualFile<Type>;\n}\n\n/**\n * Gets the complete out file path from an output file name and parent\n * directory path.\n *\n * @param outDir - The path to the out file's parent directory.\n * @param outFileName - The out file's name.\n * @returns The complete path to the out file.\n */\nexport function getOutfilePath(outDir: string, outFileName: string): string {\n return pathUtils.join(outDir, outFileName || 'bundle.js');\n}\n\n/**\n * Ensures that the outfile name is just a `.js` file name.\n * Throws on validation failure.\n *\n * @param filename - The file name to validate.\n * @returns `true` if validation succeeded.\n * @throws If the file name is invalid.\n */\nexport function validateOutfileName(filename: string): boolean {\n if (\n !filename.endsWith('.js') ||\n filename === '.js' ||\n pathUtils.basename(filename) !== filename\n ) {\n throw new Error(`Invalid outfile name: ${filename}. Must be a .js file`);\n }\n return true;\n}\n\n/**\n * Validates a file path. Throws on validation failure.\n *\n * @param filePath - The file path to validate.\n * @returns `true` if validation succeeded.\n * @throws If the path does not resolve to a file.\n */\nexport async function validateFilePath(filePath: string): Promise<boolean> {\n const exists = await isFile(filePath);\n if (!exists) {\n throw new Error(\n `Invalid params: '${filePath}' is not a file or does not exist.`,\n );\n }\n return true;\n}\n\n/**\n * Validates a directory path. Throws on validation failure.\n *\n * @param dirPath - The directory path to validate.\n * @param createDir - Whether to create the directory if it doesn't exist.\n * @returns `true` if validation succeeded or the directory was created.\n * @throws If the directory does not exist or could not be created.\n */\nexport async function validateDirPath(\n dirPath: string,\n createDir: boolean,\n): Promise<boolean> {\n const exists = await isDirectory(dirPath, createDir);\n if (!exists) {\n throw new Error(\n `Invalid params: '${dirPath}' is not a directory or could not be created.`,\n );\n }\n return true;\n}\n\n/**\n * Creates a temporary file with a given name and content, writes it to disk and calls the provided function.\n * This function handles deletion of the temporary file after usage.\n *\n * @param fileName - The name of the temporary file.\n * @param fileContents - The content of the temporary file.\n * @param fn - The callback function to call when the temporary file has been created.\n */\nexport async function useTemporaryFile(\n fileName: string,\n fileContents: string,\n fn: (path: string) => Promise<unknown>,\n): Promise<void> {\n const filePath = pathUtils.join(os.tmpdir(), fileName);\n await fs.mkdir(pathUtils.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, fileContents);\n try {\n await fn(filePath);\n } finally {\n if (await isFile(filePath)) {\n await fs.unlink(filePath);\n }\n }\n}\n"],"names":["promises","fs","os","pathUtils","parseJson","readVirtualFile","isDirectory","pathString","createDir","stats","stat","error","code","mkdir","recursive","isFile","readJsonFile","endsWith","Error","file","result","toString","getOutfilePath","outDir","outFileName","join","validateOutfileName","filename","basename","validateFilePath","filePath","exists","validateDirPath","dirPath","useTemporaryFile","fileName","fileContents","fn","tmpdir","dirname","writeFile","unlink"],"mappings":"AACA,SAASA,YAAYC,EAAE,QAAQ,KAAK;AACpC,OAAOC,QAAQ,KAAK;AACpB,OAAOC,eAAe,OAAO;AAE7B,SAASC,SAAS,QAAQ,SAAS;AAEnC,SAASC,eAAe,QAAQ,iBAAiB;AAEjD;;;;;;;CAOC,GACD,OAAO,eAAeC,YACpBC,UAAkB,EAClBC,SAAkB;IAElB,IAAI;QACF,MAAMC,QAAQ,MAAMR,GAAGS,IAAI,CAACH;QAC5B,OAAOE,MAAMH,WAAW;IAC1B,EAAE,OAAOK,OAAO;QACd,IAAIA,MAAMC,IAAI,KAAK,UAAU;YAC3B,IAAI,CAACJ,WAAW;gBACd,OAAO;YACT;YAEA,MAAMP,GAAGY,KAAK,CAACN,YAAY;gBAAEO,WAAW;YAAK;YAC7C,OAAO;QACT;QAEA,OAAO;IACT;AACF;AAEA;;;;;CAKC,GACD,OAAO,eAAeC,OAAOR,UAAkB;IAC7C,IAAI;QACF,MAAME,QAAQ,MAAMR,GAAGS,IAAI,CAACH;QAC5B,OAAOE,MAAMM,MAAM;IACrB,EAAE,OAAOJ,OAAO;QACd,OAAO;IACT;AACF;AAEA;;;;;CAKC,GACD,OAAO,eAAeK,aACpBT,UAAkB;IAElB,IAAI,CAACA,WAAWU,QAAQ,CAAC,UAAU;QACjC,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAIC;IACJ,IAAI;QACFA,OAAO,MAAMd,gBAAgBE,YAAY;IAC3C,EAAE,OAAOI,OAAO;QACd,IAAIA,MAAMC,IAAI,KAAK,UAAU;YAC3B,MAAM,IAAIM,MACR,CAAC,gBAAgB,EAAEX,WAAW,sCAAsC,CAAC;QAEzE;QAEA,MAAMI;IACR;IACAQ,KAAKC,MAAM,GAAGhB,UAAUe,KAAKE,QAAQ;IACrC,OAAOF;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASG,eAAeC,MAAc,EAAEC,WAAmB;IAChE,OAAOrB,UAAUsB,IAAI,CAACF,QAAQC,eAAe;AAC/C;AAEA;;;;;;;CAOC,GACD,OAAO,SAASE,oBAAoBC,QAAgB;IAClD,IACE,CAACA,SAASV,QAAQ,CAAC,UACnBU,aAAa,SACbxB,UAAUyB,QAAQ,CAACD,cAAcA,UACjC;QACA,MAAM,IAAIT,MAAM,CAAC,sBAAsB,EAAES,SAAS,oBAAoB,CAAC;IACzE;IACA,OAAO;AACT;AAEA;;;;;;CAMC,GACD,OAAO,eAAeE,iBAAiBC,QAAgB;IACrD,MAAMC,SAAS,MAAMhB,OAAOe;IAC5B,IAAI,CAACC,QAAQ;QACX,MAAM,IAAIb,MACR,CAAC,iBAAiB,EAAEY,SAAS,kCAAkC,CAAC;IAEpE;IACA,OAAO;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeE,gBACpBC,OAAe,EACfzB,SAAkB;IAElB,MAAMuB,SAAS,MAAMzB,YAAY2B,SAASzB;IAC1C,IAAI,CAACuB,QAAQ;QACX,MAAM,IAAIb,MACR,CAAC,iBAAiB,EAAEe,QAAQ,6CAA6C,CAAC;IAE9E;IACA,OAAO;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeC,iBACpBC,QAAgB,EAChBC,YAAoB,EACpBC,EAAsC;IAEtC,MAAMP,WAAW3B,UAAUsB,IAAI,CAACvB,GAAGoC,MAAM,IAAIH;IAC7C,MAAMlC,GAAGY,KAAK,CAACV,UAAUoC,OAAO,CAACT,WAAW;QAAEhB,WAAW;IAAK;IAC9D,MAAMb,GAAGuC,SAAS,CAACV,UAAUM;IAC7B,IAAI;QACF,MAAMC,GAAGP;IACX,SAAU;QACR,IAAI,MAAMf,OAAOe,WAAW;YAC1B,MAAM7B,GAAGwC,MAAM,CAACX;QAClB;IACF;AACF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export var HandlerType;
|
|
2
|
-
(function(HandlerType) {
|
|
3
|
-
HandlerType["OnRpcRequest"] = 'onRpcRequest';
|
|
4
|
-
HandlerType["OnSignature"] = 'onSignature';
|
|
5
|
-
HandlerType["OnTransaction"] = 'onTransaction';
|
|
6
|
-
HandlerType["OnCronjob"] = 'onCronjob';
|
|
7
|
-
HandlerType["OnInstall"] = 'onInstall';
|
|
8
|
-
HandlerType["OnUpdate"] = 'onUpdate';
|
|
9
|
-
HandlerType["OnNameLookup"] = 'onNameLookup';
|
|
10
|
-
HandlerType["OnKeyringRequest"] = 'onKeyringRequest';
|
|
11
|
-
HandlerType["OnHomePage"] = 'onHomePage';
|
|
12
|
-
HandlerType["OnUserInput"] = 'onUserInput';
|
|
13
|
-
})(HandlerType || (HandlerType = {}));
|
|
14
|
-
export const SNAP_EXPORT_NAMES = Object.values(HandlerType);
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=handler-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/handler-types.ts"],"sourcesContent":["export enum HandlerType {\n OnRpcRequest = 'onRpcRequest',\n OnSignature = 'onSignature',\n OnTransaction = 'onTransaction',\n OnCronjob = 'onCronjob',\n OnInstall = 'onInstall',\n OnUpdate = 'onUpdate',\n OnNameLookup = 'onNameLookup',\n OnKeyringRequest = 'onKeyringRequest',\n OnHomePage = 'onHomePage',\n OnUserInput = 'onUserInput',\n}\n\nexport type SnapHandler = {\n /**\n * The type of handler.\n */\n type: HandlerType;\n\n /**\n * Whether the handler is required, i.e., whether the request will fail if the\n * handler is called, but the snap does not export it.\n *\n * This is primarily used for the lifecycle handlers, which are optional.\n */\n required: boolean;\n\n /**\n * Validate the given snap export. This should return a type guard for the\n * handler type.\n *\n * @param snapExport - The export to validate.\n * @returns Whether the export is valid.\n */\n validator: (snapExport: unknown) => boolean;\n};\n\nexport const SNAP_EXPORT_NAMES = Object.values(HandlerType);\n"],"names":["HandlerType","OnRpcRequest","OnSignature","OnTransaction","OnCronjob","OnInstall","OnUpdate","OnNameLookup","OnKeyringRequest","OnHomePage","OnUserInput","SNAP_EXPORT_NAMES","Object","values"],"mappings":"WAAO;UAAKA,WAAW;IAAXA,YACVC,kBAAe;IADLD,YAEVE,iBAAc;IAFJF,YAGVG,mBAAgB;IAHNH,YAIVI,eAAY;IAJFJ,YAKVK,eAAY;IALFL,YAMVM,cAAW;IANDN,YAOVO,kBAAe;IAPLP,YAQVQ,sBAAmB;IARTR,YASVS,gBAAa;IATHT,YAUVU,iBAAc;GAVJV,gBAAAA;AAqCZ,OAAO,MAAMW,oBAAoBC,OAAOC,MAAM,CAACb,aAAa"}
|
package/dist/esm/handlers.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { SeverityLevel, ComponentStruct } from '@metamask/snaps-sdk';
|
|
2
|
-
import { assign, literal, nullable, object, optional, string, array, size, union } from 'superstruct';
|
|
3
|
-
import { HandlerType } from './handler-types';
|
|
4
|
-
export const SNAP_EXPORTS = {
|
|
5
|
-
[HandlerType.OnRpcRequest]: {
|
|
6
|
-
type: HandlerType.OnRpcRequest,
|
|
7
|
-
required: true,
|
|
8
|
-
validator: (snapExport)=>{
|
|
9
|
-
return typeof snapExport === 'function';
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
[HandlerType.OnTransaction]: {
|
|
13
|
-
type: HandlerType.OnTransaction,
|
|
14
|
-
required: true,
|
|
15
|
-
validator: (snapExport)=>{
|
|
16
|
-
return typeof snapExport === 'function';
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
[HandlerType.OnCronjob]: {
|
|
20
|
-
type: HandlerType.OnCronjob,
|
|
21
|
-
required: true,
|
|
22
|
-
validator: (snapExport)=>{
|
|
23
|
-
return typeof snapExport === 'function';
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
[HandlerType.OnNameLookup]: {
|
|
27
|
-
type: HandlerType.OnNameLookup,
|
|
28
|
-
required: true,
|
|
29
|
-
validator: (snapExport)=>{
|
|
30
|
-
return typeof snapExport === 'function';
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
[HandlerType.OnInstall]: {
|
|
34
|
-
type: HandlerType.OnInstall,
|
|
35
|
-
required: false,
|
|
36
|
-
validator: (snapExport)=>{
|
|
37
|
-
return typeof snapExport === 'function';
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
[HandlerType.OnUpdate]: {
|
|
41
|
-
type: HandlerType.OnUpdate,
|
|
42
|
-
required: false,
|
|
43
|
-
validator: (snapExport)=>{
|
|
44
|
-
return typeof snapExport === 'function';
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
[HandlerType.OnKeyringRequest]: {
|
|
48
|
-
type: HandlerType.OnKeyringRequest,
|
|
49
|
-
required: true,
|
|
50
|
-
validator: (snapExport)=>{
|
|
51
|
-
return typeof snapExport === 'function';
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
[HandlerType.OnHomePage]: {
|
|
55
|
-
type: HandlerType.OnHomePage,
|
|
56
|
-
required: true,
|
|
57
|
-
validator: (snapExport)=>{
|
|
58
|
-
return typeof snapExport === 'function';
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
[HandlerType.OnSignature]: {
|
|
62
|
-
type: HandlerType.OnSignature,
|
|
63
|
-
required: true,
|
|
64
|
-
validator: (snapExport)=>{
|
|
65
|
-
return typeof snapExport === 'function';
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
[HandlerType.OnUserInput]: {
|
|
69
|
-
type: HandlerType.OnUserInput,
|
|
70
|
-
required: true,
|
|
71
|
-
validator: (snapExport)=>{
|
|
72
|
-
return typeof snapExport === 'function';
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
export const OnTransactionSeverityResponseStruct = object({
|
|
77
|
-
severity: optional(literal(SeverityLevel.Critical))
|
|
78
|
-
});
|
|
79
|
-
export const OnTransactionResponseWithIdStruct = assign(OnTransactionSeverityResponseStruct, object({
|
|
80
|
-
id: string()
|
|
81
|
-
}));
|
|
82
|
-
export const OnTransactionResponseWithContentStruct = assign(OnTransactionSeverityResponseStruct, object({
|
|
83
|
-
content: ComponentStruct
|
|
84
|
-
}));
|
|
85
|
-
export const OnTransactionResponseStruct = nullable(union([
|
|
86
|
-
OnTransactionResponseWithContentStruct,
|
|
87
|
-
OnTransactionResponseWithIdStruct
|
|
88
|
-
]));
|
|
89
|
-
export const OnSignatureResponseStruct = OnTransactionResponseStruct;
|
|
90
|
-
export const OnHomePageResponseWithContentStruct = object({
|
|
91
|
-
content: ComponentStruct
|
|
92
|
-
});
|
|
93
|
-
export const OnHomePageResponseWithIdStruct = object({
|
|
94
|
-
id: string()
|
|
95
|
-
});
|
|
96
|
-
export const OnHomePageResponseStruct = union([
|
|
97
|
-
OnHomePageResponseWithContentStruct,
|
|
98
|
-
OnHomePageResponseWithIdStruct
|
|
99
|
-
]);
|
|
100
|
-
export const AddressResolutionStruct = object({
|
|
101
|
-
protocol: string(),
|
|
102
|
-
resolvedDomain: string()
|
|
103
|
-
});
|
|
104
|
-
export const DomainResolutionStruct = object({
|
|
105
|
-
protocol: string(),
|
|
106
|
-
resolvedAddress: string()
|
|
107
|
-
});
|
|
108
|
-
export const AddressResolutionResponseStruct = object({
|
|
109
|
-
resolvedDomains: size(array(AddressResolutionStruct), 1, Infinity)
|
|
110
|
-
});
|
|
111
|
-
export const DomainResolutionResponseStruct = object({
|
|
112
|
-
resolvedAddresses: size(array(DomainResolutionStruct), 1, Infinity)
|
|
113
|
-
});
|
|
114
|
-
export const OnNameLookupResponseStruct = nullable(union([
|
|
115
|
-
AddressResolutionResponseStruct,
|
|
116
|
-
DomainResolutionResponseStruct
|
|
117
|
-
]));
|
|
118
|
-
|
|
119
|
-
//# sourceMappingURL=handlers.js.map
|
package/dist/esm/handlers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/handlers.ts"],"sourcesContent":["import type {\n OnCronjobHandler,\n OnHomePageHandler,\n OnInstallHandler,\n OnKeyringRequestHandler,\n OnNameLookupHandler,\n OnRpcRequestHandler,\n OnSignatureHandler,\n OnTransactionHandler,\n OnUpdateHandler,\n OnUserInputHandler,\n} from '@metamask/snaps-sdk';\nimport { SeverityLevel, ComponentStruct } from '@metamask/snaps-sdk';\nimport {\n assign,\n literal,\n nullable,\n object,\n optional,\n string,\n array,\n size,\n union,\n} from 'superstruct';\n\nimport type { SnapHandler } from './handler-types';\nimport { HandlerType } from './handler-types';\n\nexport type SnapRpcHookArgs = {\n origin: string;\n handler: HandlerType;\n request: Record<string, unknown>;\n};\n\nexport const SNAP_EXPORTS = {\n [HandlerType.OnRpcRequest]: {\n type: HandlerType.OnRpcRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnRpcRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnTransaction]: {\n type: HandlerType.OnTransaction,\n required: true,\n validator: (snapExport: unknown): snapExport is OnTransactionHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnCronjob]: {\n type: HandlerType.OnCronjob,\n required: true,\n validator: (snapExport: unknown): snapExport is OnCronjobHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnNameLookup]: {\n type: HandlerType.OnNameLookup,\n required: true,\n validator: (snapExport: unknown): snapExport is OnNameLookupHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnInstall]: {\n type: HandlerType.OnInstall,\n required: false,\n validator: (snapExport: unknown): snapExport is OnInstallHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUpdate]: {\n type: HandlerType.OnUpdate,\n required: false,\n validator: (snapExport: unknown): snapExport is OnUpdateHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnKeyringRequest]: {\n type: HandlerType.OnKeyringRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnKeyringRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnHomePage]: {\n type: HandlerType.OnHomePage,\n required: true,\n validator: (snapExport: unknown): snapExport is OnHomePageHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnSignature]: {\n type: HandlerType.OnSignature,\n required: true,\n validator: (snapExport: unknown): snapExport is OnSignatureHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUserInput]: {\n type: HandlerType.OnUserInput,\n required: true,\n validator: (snapExport: unknown): snapExport is OnUserInputHandler => {\n return typeof snapExport === 'function';\n },\n },\n} as const;\n\nexport const OnTransactionSeverityResponseStruct = object({\n severity: optional(literal(SeverityLevel.Critical)),\n});\n\nexport const OnTransactionResponseWithIdStruct = assign(\n OnTransactionSeverityResponseStruct,\n object({\n id: string(),\n }),\n);\n\nexport const OnTransactionResponseWithContentStruct = assign(\n OnTransactionSeverityResponseStruct,\n object({\n content: ComponentStruct,\n }),\n);\n\nexport const OnTransactionResponseStruct = nullable(\n union([\n OnTransactionResponseWithContentStruct,\n OnTransactionResponseWithIdStruct,\n ]),\n);\n\nexport const OnSignatureResponseStruct = OnTransactionResponseStruct;\n\nexport const OnHomePageResponseWithContentStruct = object({\n content: ComponentStruct,\n});\n\nexport const OnHomePageResponseWithIdStruct = object({\n id: string(),\n});\n\nexport const OnHomePageResponseStruct = union([\n OnHomePageResponseWithContentStruct,\n OnHomePageResponseWithIdStruct,\n]);\n\nexport const AddressResolutionStruct = object({\n protocol: string(),\n resolvedDomain: string(),\n});\n\nexport const DomainResolutionStruct = object({\n protocol: string(),\n resolvedAddress: string(),\n});\n\nexport const AddressResolutionResponseStruct = object({\n resolvedDomains: size(array(AddressResolutionStruct), 1, Infinity),\n});\n\nexport const DomainResolutionResponseStruct = object({\n resolvedAddresses: size(array(DomainResolutionStruct), 1, Infinity),\n});\n\nexport const OnNameLookupResponseStruct = nullable(\n union([AddressResolutionResponseStruct, DomainResolutionResponseStruct]),\n);\n\n/**\n * Utility type for getting the handler function type from a handler type.\n */\nexport type HandlerFunction<Type extends SnapHandler> =\n Type['validator'] extends (snapExport: unknown) => snapExport is infer Handler\n ? Handler\n : never;\n\n/**\n * All the function-based handlers that a snap can implement.\n */\nexport type SnapFunctionExports = {\n [Key in keyof typeof SNAP_EXPORTS]?: HandlerFunction<\n (typeof SNAP_EXPORTS)[Key]\n >;\n};\n\n/**\n * All handlers that a snap can implement.\n */\nexport type SnapExports = SnapFunctionExports;\n"],"names":["SeverityLevel","ComponentStruct","assign","literal","nullable","object","optional","string","array","size","union","HandlerType","SNAP_EXPORTS","OnRpcRequest","type","required","validator","snapExport","OnTransaction","OnCronjob","OnNameLookup","OnInstall","OnUpdate","OnKeyringRequest","OnHomePage","OnSignature","OnUserInput","OnTransactionSeverityResponseStruct","severity","Critical","OnTransactionResponseWithIdStruct","id","OnTransactionResponseWithContentStruct","content","OnTransactionResponseStruct","OnSignatureResponseStruct","OnHomePageResponseWithContentStruct","OnHomePageResponseWithIdStruct","OnHomePageResponseStruct","AddressResolutionStruct","protocol","resolvedDomain","DomainResolutionStruct","resolvedAddress","AddressResolutionResponseStruct","resolvedDomains","Infinity","DomainResolutionResponseStruct","resolvedAddresses","OnNameLookupResponseStruct"],"mappings":"AAYA,SAASA,aAAa,EAAEC,eAAe,QAAQ,sBAAsB;AACrE,SACEC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,IAAI,EACJC,KAAK,QACA,cAAc;AAGrB,SAASC,WAAW,QAAQ,kBAAkB;AAQ9C,OAAO,MAAMC,eAAe;IAC1B,CAACD,YAAYE,YAAY,CAAC,EAAE;QAC1BC,MAAMH,YAAYE,YAAY;QAC9BE,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYO,aAAa,CAAC,EAAE;QAC3BJ,MAAMH,YAAYO,aAAa;QAC/BH,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYQ,SAAS,CAAC,EAAE;QACvBL,MAAMH,YAAYQ,SAAS;QAC3BJ,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYS,YAAY,CAAC,EAAE;QAC1BN,MAAMH,YAAYS,YAAY;QAC9BL,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYU,SAAS,CAAC,EAAE;QACvBP,MAAMH,YAAYU,SAAS;QAC3BN,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYW,QAAQ,CAAC,EAAE;QACtBR,MAAMH,YAAYW,QAAQ;QAC1BP,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYY,gBAAgB,CAAC,EAAE;QAC9BT,MAAMH,YAAYY,gBAAgB;QAClCR,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYa,UAAU,CAAC,EAAE;QACxBV,MAAMH,YAAYa,UAAU;QAC5BT,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYc,WAAW,CAAC,EAAE;QACzBX,MAAMH,YAAYc,WAAW;QAC7BV,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACN,YAAYe,WAAW,CAAC,EAAE;QACzBZ,MAAMH,YAAYe,WAAW;QAC7BX,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;AACF,EAAW;AAEX,OAAO,MAAMU,sCAAsCtB,OAAO;IACxDuB,UAAUtB,SAASH,QAAQH,cAAc6B,QAAQ;AACnD,GAAG;AAEH,OAAO,MAAMC,oCAAoC5B,OAC/CyB,qCACAtB,OAAO;IACL0B,IAAIxB;AACN,IACA;AAEF,OAAO,MAAMyB,yCAAyC9B,OACpDyB,qCACAtB,OAAO;IACL4B,SAAShC;AACX,IACA;AAEF,OAAO,MAAMiC,8BAA8B9B,SACzCM,MAAM;IACJsB;IACAF;CACD,GACD;AAEF,OAAO,MAAMK,4BAA4BD,4BAA4B;AAErE,OAAO,MAAME,sCAAsC/B,OAAO;IACxD4B,SAAShC;AACX,GAAG;AAEH,OAAO,MAAMoC,iCAAiChC,OAAO;IACnD0B,IAAIxB;AACN,GAAG;AAEH,OAAO,MAAM+B,2BAA2B5B,MAAM;IAC5C0B;IACAC;CACD,EAAE;AAEH,OAAO,MAAME,0BAA0BlC,OAAO;IAC5CmC,UAAUjC;IACVkC,gBAAgBlC;AAClB,GAAG;AAEH,OAAO,MAAMmC,yBAAyBrC,OAAO;IAC3CmC,UAAUjC;IACVoC,iBAAiBpC;AACnB,GAAG;AAEH,OAAO,MAAMqC,kCAAkCvC,OAAO;IACpDwC,iBAAiBpC,KAAKD,MAAM+B,0BAA0B,GAAGO;AAC3D,GAAG;AAEH,OAAO,MAAMC,iCAAiC1C,OAAO;IACnD2C,mBAAmBvC,KAAKD,MAAMkC,yBAAyB,GAAGI;AAC5D,GAAG;AAEH,OAAO,MAAMG,6BAA6B7C,SACxCM,MAAM;IAACkC;IAAiCG;CAA+B,GACvE"}
|
package/dist/esm/icon.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { isSvg, parseSvg } from '@metamask/snaps-sdk';
|
|
2
|
-
import { assert } from '@metamask/utils';
|
|
3
|
-
export const SVG_MAX_BYTE_SIZE = 100000;
|
|
4
|
-
export const SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(SVG_MAX_BYTE_SIZE / 1000)}kb`;
|
|
5
|
-
/**
|
|
6
|
-
* Assert that a virtual file containing a Snap icon is valid.
|
|
7
|
-
*
|
|
8
|
-
* @param icon - A virtual file containing a Snap icon.
|
|
9
|
-
*/ export function assertIsSnapIcon(icon) {
|
|
10
|
-
assert(icon.path.endsWith('.svg'), 'Expected snap icon to end in ".svg".');
|
|
11
|
-
assert(Buffer.byteLength(icon.value, 'utf8') <= SVG_MAX_BYTE_SIZE, `The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`);
|
|
12
|
-
assert(isSvg(icon.toString()), 'Snap icon must be a valid SVG.');
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Extract the dimensions of an image from an SVG string if possible.
|
|
16
|
-
*
|
|
17
|
-
* @param svg - An SVG string.
|
|
18
|
-
* @returns The height and width of the SVG or null.
|
|
19
|
-
*/ export function getSvgDimensions(svg) {
|
|
20
|
-
try {
|
|
21
|
-
const parsed = parseSvg(svg);
|
|
22
|
-
const height = parsed['@_height'];
|
|
23
|
-
const width = parsed['@_width'];
|
|
24
|
-
if (height && width) {
|
|
25
|
-
return {
|
|
26
|
-
height,
|
|
27
|
-
width
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
const viewBox = parsed['@_viewBox'];
|
|
31
|
-
if (viewBox) {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
-
const [_minX, _minY, viewBoxWidth, viewBoxHeight] = viewBox.split(' ');
|
|
34
|
-
if (viewBoxWidth && viewBoxHeight) {
|
|
35
|
-
const parsedWidth = parseInt(viewBoxWidth, 10);
|
|
36
|
-
const parsedHeight = parseInt(viewBoxHeight, 10);
|
|
37
|
-
assert(Number.isInteger(parsedWidth) && parsedWidth > 0);
|
|
38
|
-
assert(Number.isInteger(parsedHeight) && parsedHeight > 0);
|
|
39
|
-
return {
|
|
40
|
-
width: parsedWidth,
|
|
41
|
-
height: parsedHeight
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
} catch {
|
|
46
|
-
throw new Error('Snap icon must be a valid SVG.');
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=icon.js.map
|
package/dist/esm/icon.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/icon.ts"],"sourcesContent":["import { isSvg, parseSvg } from '@metamask/snaps-sdk';\nimport { assert } from '@metamask/utils';\n\nimport type { VirtualFile } from './virtual-file';\n\nexport const SVG_MAX_BYTE_SIZE = 100_000;\nexport const SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(\n SVG_MAX_BYTE_SIZE / 1000,\n)}kb`;\n\n/**\n * Assert that a virtual file containing a Snap icon is valid.\n *\n * @param icon - A virtual file containing a Snap icon.\n */\nexport function assertIsSnapIcon(icon: VirtualFile) {\n assert(icon.path.endsWith('.svg'), 'Expected snap icon to end in \".svg\".');\n\n assert(\n Buffer.byteLength(icon.value, 'utf8') <= SVG_MAX_BYTE_SIZE,\n `The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`,\n );\n\n assert(isSvg(icon.toString()), 'Snap icon must be a valid SVG.');\n}\n\n/**\n * Extract the dimensions of an image from an SVG string if possible.\n *\n * @param svg - An SVG string.\n * @returns The height and width of the SVG or null.\n */\nexport function getSvgDimensions(svg: string): {\n height: number;\n width: number;\n} | null {\n try {\n const parsed = parseSvg(svg);\n\n const height = parsed['@_height'];\n const width = parsed['@_width'];\n\n if (height && width) {\n return { height, width };\n }\n\n const viewBox = parsed['@_viewBox'];\n if (viewBox) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_minX, _minY, viewBoxWidth, viewBoxHeight] = viewBox.split(' ');\n\n if (viewBoxWidth && viewBoxHeight) {\n const parsedWidth = parseInt(viewBoxWidth, 10);\n const parsedHeight = parseInt(viewBoxHeight, 10);\n\n assert(Number.isInteger(parsedWidth) && parsedWidth > 0);\n assert(Number.isInteger(parsedHeight) && parsedHeight > 0);\n\n return {\n width: parsedWidth,\n height: parsedHeight,\n };\n }\n }\n } catch {\n throw new Error('Snap icon must be a valid SVG.');\n }\n\n return null;\n}\n"],"names":["isSvg","parseSvg","assert","SVG_MAX_BYTE_SIZE","SVG_MAX_BYTE_SIZE_TEXT","Math","floor","assertIsSnapIcon","icon","path","endsWith","Buffer","byteLength","value","toString","getSvgDimensions","svg","parsed","height","width","viewBox","_minX","_minY","viewBoxWidth","viewBoxHeight","split","parsedWidth","parseInt","parsedHeight","Number","isInteger","Error"],"mappings":"AAAA,SAASA,KAAK,EAAEC,QAAQ,QAAQ,sBAAsB;AACtD,SAASC,MAAM,QAAQ,kBAAkB;AAIzC,OAAO,MAAMC,oBAAoB,OAAQ;AACzC,OAAO,MAAMC,yBAAyB,CAAC,EAAEC,KAAKC,KAAK,CACjDH,oBAAoB,MACpB,EAAE,CAAC,CAAC;AAEN;;;;CAIC,GACD,OAAO,SAASI,iBAAiBC,IAAiB;IAChDN,OAAOM,KAAKC,IAAI,CAACC,QAAQ,CAAC,SAAS;IAEnCR,OACES,OAAOC,UAAU,CAACJ,KAAKK,KAAK,EAAE,WAAWV,mBACzC,CAAC,mDAAmD,EAAEC,uBAAuB,CAAC,CAAC;IAGjFF,OAAOF,MAAMQ,KAAKM,QAAQ,KAAK;AACjC;AAEA;;;;;CAKC,GACD,OAAO,SAASC,iBAAiBC,GAAW;IAI1C,IAAI;QACF,MAAMC,SAAShB,SAASe;QAExB,MAAME,SAASD,MAAM,CAAC,WAAW;QACjC,MAAME,QAAQF,MAAM,CAAC,UAAU;QAE/B,IAAIC,UAAUC,OAAO;YACnB,OAAO;gBAAED;gBAAQC;YAAM;QACzB;QAEA,MAAMC,UAAUH,MAAM,CAAC,YAAY;QACnC,IAAIG,SAAS;YACX,6DAA6D;YAC7D,MAAM,CAACC,OAAOC,OAAOC,cAAcC,cAAc,GAAGJ,QAAQK,KAAK,CAAC;YAElE,IAAIF,gBAAgBC,eAAe;gBACjC,MAAME,cAAcC,SAASJ,cAAc;gBAC3C,MAAMK,eAAeD,SAASH,eAAe;gBAE7CtB,OAAO2B,OAAOC,SAAS,CAACJ,gBAAgBA,cAAc;gBACtDxB,OAAO2B,OAAOC,SAAS,CAACF,iBAAiBA,eAAe;gBAExD,OAAO;oBACLT,OAAOO;oBACPR,QAAQU;gBACV;YACF;QACF;IACF,EAAE,OAAM;QACN,MAAM,IAAIG,MAAM;IAClB;IAEA,OAAO;AACT"}
|
package/dist/esm/iframe.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates the iframe to be used as the execution environment. This may run
|
|
3
|
-
* forever if the iframe never loads, but the promise should be wrapped in
|
|
4
|
-
* an initialization timeout in the SnapController.
|
|
5
|
-
*
|
|
6
|
-
* @param uri - The iframe URI.
|
|
7
|
-
* @param id - The ID to assign to the iframe.
|
|
8
|
-
* @param sandbox - Whether to enable the sandbox attribute.
|
|
9
|
-
* @returns A promise that resolves to the contentWindow of the iframe.
|
|
10
|
-
*/ export async function createWindow(uri, id, sandbox = true) {
|
|
11
|
-
return await new Promise((resolve, reject)=>{
|
|
12
|
-
const iframe = document.createElement('iframe');
|
|
13
|
-
// The order of operations appears to matter for everything except this
|
|
14
|
-
// attribute. We may as well set it here.
|
|
15
|
-
iframe.setAttribute('id', id);
|
|
16
|
-
iframe.setAttribute('data-testid', 'snaps-iframe');
|
|
17
|
-
if (sandbox) {
|
|
18
|
-
// For the sandbox property to have any effect it needs to be set before the iframe is appended.
|
|
19
|
-
// We apply this property as a principle of least authority (POLA)
|
|
20
|
-
// measure.
|
|
21
|
-
// Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox
|
|
22
|
-
iframe.setAttribute('sandbox', 'allow-scripts');
|
|
23
|
-
}
|
|
24
|
-
// In the past, we've had problems that appear to be symptomatic of the
|
|
25
|
-
// iframe firing the `load` event before its scripts are actually loaded,
|
|
26
|
-
// which has prevented snaps from executing properly. Therefore, we set
|
|
27
|
-
// the `src` attribute and append the iframe to the DOM before attaching
|
|
28
|
-
// the `load` listener.
|
|
29
|
-
//
|
|
30
|
-
// `load` should only fire when "all dependent resources" have been
|
|
31
|
-
// loaded, which includes scripts.
|
|
32
|
-
//
|
|
33
|
-
// MDN article for `load` event: https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
|
|
34
|
-
// Re: `load` firing twice: https://stackoverflow.com/questions/10781880/dynamically-created-iframe-triggers-onload-event-twice/15880489#15880489
|
|
35
|
-
iframe.setAttribute('src', uri);
|
|
36
|
-
document.body.appendChild(iframe);
|
|
37
|
-
iframe.addEventListener('load', ()=>{
|
|
38
|
-
if (iframe.contentWindow) {
|
|
39
|
-
resolve(iframe.contentWindow);
|
|
40
|
-
} else {
|
|
41
|
-
// We don't know of a case when this would happen, but better to fail
|
|
42
|
-
// fast if it does.
|
|
43
|
-
reject(new Error(`iframe.contentWindow not present on load for job "${id}".`));
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
//# sourceMappingURL=iframe.js.map
|
package/dist/esm/iframe.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/iframe.ts"],"sourcesContent":["/**\n * Creates the iframe to be used as the execution environment. This may run\n * forever if the iframe never loads, but the promise should be wrapped in\n * an initialization timeout in the SnapController.\n *\n * @param uri - The iframe URI.\n * @param id - The ID to assign to the iframe.\n * @param sandbox - Whether to enable the sandbox attribute.\n * @returns A promise that resolves to the contentWindow of the iframe.\n */\nexport async function createWindow(\n uri: string,\n id: string,\n sandbox = true,\n): Promise<Window> {\n return await new Promise((resolve, reject) => {\n const iframe = document.createElement('iframe');\n // The order of operations appears to matter for everything except this\n // attribute. We may as well set it here.\n iframe.setAttribute('id', id);\n iframe.setAttribute('data-testid', 'snaps-iframe');\n\n if (sandbox) {\n // For the sandbox property to have any effect it needs to be set before the iframe is appended.\n // We apply this property as a principle of least authority (POLA)\n // measure.\n // Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox\n iframe.setAttribute('sandbox', 'allow-scripts');\n }\n\n // In the past, we've had problems that appear to be symptomatic of the\n // iframe firing the `load` event before its scripts are actually loaded,\n // which has prevented snaps from executing properly. Therefore, we set\n // the `src` attribute and append the iframe to the DOM before attaching\n // the `load` listener.\n //\n // `load` should only fire when \"all dependent resources\" have been\n // loaded, which includes scripts.\n //\n // MDN article for `load` event: https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event\n // Re: `load` firing twice: https://stackoverflow.com/questions/10781880/dynamically-created-iframe-triggers-onload-event-twice/15880489#15880489\n iframe.setAttribute('src', uri);\n document.body.appendChild(iframe);\n\n iframe.addEventListener('load', () => {\n if (iframe.contentWindow) {\n resolve(iframe.contentWindow);\n } else {\n // We don't know of a case when this would happen, but better to fail\n // fast if it does.\n reject(\n new Error(\n `iframe.contentWindow not present on load for job \"${id}\".`,\n ),\n );\n }\n });\n });\n}\n"],"names":["createWindow","uri","id","sandbox","Promise","resolve","reject","iframe","document","createElement","setAttribute","body","appendChild","addEventListener","contentWindow","Error"],"mappings":"AAAA;;;;;;;;;CASC,GACD,OAAO,eAAeA,aACpBC,GAAW,EACXC,EAAU,EACVC,UAAU,IAAI;IAEd,OAAO,MAAM,IAAIC,QAAQ,CAACC,SAASC;QACjC,MAAMC,SAASC,SAASC,aAAa,CAAC;QACtC,uEAAuE;QACvE,yCAAyC;QACzCF,OAAOG,YAAY,CAAC,MAAMR;QAC1BK,OAAOG,YAAY,CAAC,eAAe;QAEnC,IAAIP,SAAS;YACX,gGAAgG;YAChG,kEAAkE;YAClE,WAAW;YACX,qFAAqF;YACrFI,OAAOG,YAAY,CAAC,WAAW;QACjC;QAEA,uEAAuE;QACvE,yEAAyE;QACzE,uEAAuE;QACvE,wEAAwE;QACxE,uBAAuB;QACvB,EAAE;QACF,mEAAmE;QACnE,kCAAkC;QAClC,EAAE;QACF,mGAAmG;QACnG,iJAAiJ;QACjJH,OAAOG,YAAY,CAAC,OAAOT;QAC3BO,SAASG,IAAI,CAACC,WAAW,CAACL;QAE1BA,OAAOM,gBAAgB,CAAC,QAAQ;YAC9B,IAAIN,OAAOO,aAAa,EAAE;gBACxBT,QAAQE,OAAOO,aAAa;YAC9B,OAAO;gBACL,qEAAqE;gBACrE,mBAAmB;gBACnBR,OACE,IAAIS,MACF,CAAC,kDAAkD,EAAEb,GAAG,EAAE,CAAC;YAGjE;QACF;IACF;AACF"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export * from './array';
|
|
2
|
-
export * from './auxiliary-files';
|
|
3
|
-
export * from './base64';
|
|
4
|
-
export * from './bytes';
|
|
5
|
-
export * from './caveats';
|
|
6
|
-
export * from './checksum';
|
|
7
|
-
export * from './cronjob';
|
|
8
|
-
export * from './deep-clone';
|
|
9
|
-
export * from './default-endowments';
|
|
10
|
-
export * from './derivation-paths';
|
|
11
|
-
export * from './entropy';
|
|
12
|
-
export * from './errors';
|
|
13
|
-
export * from './handlers';
|
|
14
|
-
export * from './handler-types';
|
|
15
|
-
export * from './iframe';
|
|
16
|
-
export * from './json';
|
|
17
|
-
export * from './json-rpc';
|
|
18
|
-
export * from './localization';
|
|
19
|
-
export * from './logging';
|
|
20
|
-
export * from './manifest/index.browser';
|
|
21
|
-
export * from './namespace';
|
|
22
|
-
export * from './path';
|
|
23
|
-
export * from './snaps';
|
|
24
|
-
export * from './strings';
|
|
25
|
-
export * from './structs';
|
|
26
|
-
export * from './types';
|
|
27
|
-
export * from './ui';
|
|
28
|
-
export * from './validation';
|
|
29
|
-
export * from './versions';
|
|
30
|
-
export * from './virtual-file/index.browser';
|
|
31
|
-
|
|
32
|
-
//# sourceMappingURL=index.browser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caveats';\nexport * from './checksum';\nexport * from './cronjob';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './derivation-paths';\nexport * from './entropy';\nexport * from './errors';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './localization';\nexport * from './logging';\nexport * from './manifest/index.browser';\nexport * from './namespace';\nexport * from './path';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './ui';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file/index.browser';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,uBAAuB;AACrC,cAAc,qBAAqB;AACnC,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,2BAA2B;AACzC,cAAc,cAAc;AAC5B,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,OAAO;AACrB,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,+BAA+B"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Special entrypoint for execution environments for bundle sizing reasons
|
|
2
|
-
export * from './errors';
|
|
3
|
-
export * from './handlers';
|
|
4
|
-
export * from './handler-types';
|
|
5
|
-
export * from './iframe';
|
|
6
|
-
export * from './logging';
|
|
7
|
-
export * from './namespace';
|
|
8
|
-
export * from './types';
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=index.executionenv.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.executionenv.ts"],"sourcesContent":["// Special entrypoint for execution environments for bundle sizing reasons\nexport * from './errors';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './logging';\nexport * from './namespace';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,UAAU"}
|