@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/cronjob.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { JsonRpcIdStruct, JsonRpcParamsStruct, JsonRpcVersionStruct } from '@metamask/utils';
|
|
2
|
-
import { parseExpression } from 'cron-parser';
|
|
3
|
-
import { array, create, object, optional, refine, string } from 'superstruct';
|
|
4
|
-
export const CronjobRpcRequestStruct = object({
|
|
5
|
-
jsonrpc: optional(JsonRpcVersionStruct),
|
|
6
|
-
id: optional(JsonRpcIdStruct),
|
|
7
|
-
method: string(),
|
|
8
|
-
params: optional(JsonRpcParamsStruct)
|
|
9
|
-
});
|
|
10
|
-
export const CronExpressionStruct = refine(string(), 'CronExpression', (value)=>{
|
|
11
|
-
try {
|
|
12
|
-
parseExpression(value);
|
|
13
|
-
return true;
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* Parses a cron expression.
|
|
20
|
-
*
|
|
21
|
-
* @param expression - Expression to parse.
|
|
22
|
-
* @returns A CronExpression class instance.
|
|
23
|
-
*/ export function parseCronExpression(expression) {
|
|
24
|
-
const ensureStringExpression = create(expression, CronExpressionStruct);
|
|
25
|
-
return parseExpression(ensureStringExpression);
|
|
26
|
-
}
|
|
27
|
-
export const CronjobSpecificationStruct = object({
|
|
28
|
-
expression: CronExpressionStruct,
|
|
29
|
-
request: CronjobRpcRequestStruct
|
|
30
|
-
});
|
|
31
|
-
/**
|
|
32
|
-
* Check if the given value is a {@link CronjobSpecification} object.
|
|
33
|
-
*
|
|
34
|
-
* @param value - The value to check.
|
|
35
|
-
* @returns Whether the value is a valid {@link CronjobSpecification} object.
|
|
36
|
-
*/ export function isCronjobSpecification(value) {
|
|
37
|
-
try {
|
|
38
|
-
create(value, CronjobSpecificationStruct);
|
|
39
|
-
return true;
|
|
40
|
-
} catch {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
export const CronjobSpecificationArrayStruct = array(CronjobSpecificationStruct);
|
|
45
|
-
/**
|
|
46
|
-
* Check if the given value is an array of {@link CronjobSpecification} objects.
|
|
47
|
-
*
|
|
48
|
-
* @param value - The value to check.
|
|
49
|
-
* @returns Whether the value is a valid array of {@link CronjobSpecification} objects.
|
|
50
|
-
*/ export function isCronjobSpecificationArray(value) {
|
|
51
|
-
try {
|
|
52
|
-
create(value, CronjobSpecificationArrayStruct);
|
|
53
|
-
return true;
|
|
54
|
-
} catch {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
//# sourceMappingURL=cronjob.js.map
|
package/dist/esm/cronjob.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cronjob.ts"],"sourcesContent":["import {\n JsonRpcIdStruct,\n JsonRpcParamsStruct,\n JsonRpcVersionStruct,\n} from '@metamask/utils';\nimport { parseExpression } from 'cron-parser';\nimport type { Infer } from 'superstruct';\nimport { array, create, object, optional, refine, string } from 'superstruct';\n\nexport const CronjobRpcRequestStruct = object({\n jsonrpc: optional(JsonRpcVersionStruct),\n id: optional(JsonRpcIdStruct),\n method: string(),\n params: optional(JsonRpcParamsStruct),\n});\n\nexport type CronjobRpcRequest = Infer<typeof CronjobRpcRequestStruct>;\n\nexport const CronExpressionStruct = refine(\n string(),\n 'CronExpression',\n (value) => {\n try {\n parseExpression(value);\n return true;\n } catch {\n return false;\n }\n },\n);\n\nexport type CronExpression = Infer<typeof CronExpressionStruct>;\n\n/**\n * Parses a cron expression.\n *\n * @param expression - Expression to parse.\n * @returns A CronExpression class instance.\n */\nexport function parseCronExpression(expression: string | object) {\n const ensureStringExpression = create(expression, CronExpressionStruct);\n return parseExpression(ensureStringExpression);\n}\n\nexport const CronjobSpecificationStruct = object({\n expression: CronExpressionStruct,\n request: CronjobRpcRequestStruct,\n});\nexport type CronjobSpecification = Infer<typeof CronjobSpecificationStruct>;\n\n/**\n * Check if the given value is a {@link CronjobSpecification} object.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid {@link CronjobSpecification} object.\n */\nexport function isCronjobSpecification(value: unknown): boolean {\n try {\n create(value, CronjobSpecificationStruct);\n return true;\n } catch {\n return false;\n }\n}\n\nexport const CronjobSpecificationArrayStruct = array(\n CronjobSpecificationStruct,\n);\n\n/**\n * Check if the given value is an array of {@link CronjobSpecification} objects.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid array of {@link CronjobSpecification} objects.\n */\nexport function isCronjobSpecificationArray(value: unknown): boolean {\n try {\n create(value, CronjobSpecificationArrayStruct);\n return true;\n } catch {\n return false;\n }\n}\n"],"names":["JsonRpcIdStruct","JsonRpcParamsStruct","JsonRpcVersionStruct","parseExpression","array","create","object","optional","refine","string","CronjobRpcRequestStruct","jsonrpc","id","method","params","CronExpressionStruct","value","parseCronExpression","expression","ensureStringExpression","CronjobSpecificationStruct","request","isCronjobSpecification","CronjobSpecificationArrayStruct","isCronjobSpecificationArray"],"mappings":"AAAA,SACEA,eAAe,EACfC,mBAAmB,EACnBC,oBAAoB,QACf,kBAAkB;AACzB,SAASC,eAAe,QAAQ,cAAc;AAE9C,SAASC,KAAK,EAAEC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,MAAM,QAAQ,cAAc;AAE9E,OAAO,MAAMC,0BAA0BJ,OAAO;IAC5CK,SAASJ,SAASL;IAClBU,IAAIL,SAASP;IACba,QAAQJ;IACRK,QAAQP,SAASN;AACnB,GAAG;AAIH,OAAO,MAAMc,uBAAuBP,OAClCC,UACA,kBACA,CAACO;IACC,IAAI;QACFb,gBAAgBa;QAChB,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF,GACA;AAIF;;;;;CAKC,GACD,OAAO,SAASC,oBAAoBC,UAA2B;IAC7D,MAAMC,yBAAyBd,OAAOa,YAAYH;IAClD,OAAOZ,gBAAgBgB;AACzB;AAEA,OAAO,MAAMC,6BAA6Bd,OAAO;IAC/CY,YAAYH;IACZM,SAASX;AACX,GAAG;AAGH;;;;;CAKC,GACD,OAAO,SAASY,uBAAuBN,KAAc;IACnD,IAAI;QACFX,OAAOW,OAAOI;QACd,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,OAAO,MAAMG,kCAAkCnB,MAC7CgB,4BACA;AAEF;;;;;CAKC,GACD,OAAO,SAASI,4BAA4BR,KAAc;IACxD,IAAI;QACFX,OAAOW,OAAOO;QACd,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
package/dist/esm/deep-clone.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/deep-clone.ts"],"sourcesContent":["import rfdc from 'rfdc';\n\nexport const deepClone = rfdc({ proto: false, circles: false });\n"],"names":["rfdc","deepClone","proto","circles"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AAExB,OAAO,MAAMC,YAAYD,KAAK;IAAEE,OAAO;IAAOC,SAAS;AAAM,GAAG"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Global JavaScript APIs exposed by default to all snaps.
|
|
3
|
-
*/ export const DEFAULT_ENDOWMENTS = Object.freeze([
|
|
4
|
-
'atob',
|
|
5
|
-
'btoa',
|
|
6
|
-
'BigInt',
|
|
7
|
-
'console',
|
|
8
|
-
'crypto',
|
|
9
|
-
'Date',
|
|
10
|
-
'Math',
|
|
11
|
-
'setTimeout',
|
|
12
|
-
'clearTimeout',
|
|
13
|
-
'SubtleCrypto',
|
|
14
|
-
'TextDecoder',
|
|
15
|
-
'TextEncoder',
|
|
16
|
-
'URL',
|
|
17
|
-
'setInterval',
|
|
18
|
-
'clearInterval',
|
|
19
|
-
'Int8Array',
|
|
20
|
-
'Uint8Array',
|
|
21
|
-
'Uint8ClampedArray',
|
|
22
|
-
'Int16Array',
|
|
23
|
-
'Uint16Array',
|
|
24
|
-
'Int32Array',
|
|
25
|
-
'Uint32Array',
|
|
26
|
-
'Float32Array',
|
|
27
|
-
'Float64Array',
|
|
28
|
-
'BigInt64Array',
|
|
29
|
-
'BigUint64Array',
|
|
30
|
-
'DataView',
|
|
31
|
-
'ArrayBuffer',
|
|
32
|
-
// Used by fetch, but also as API for some packages that don't do network connections
|
|
33
|
-
// https://github.com/MetaMask/snaps-monorepo/issues/662
|
|
34
|
-
// https://github.com/MetaMask/snaps-monorepo/discussions/678
|
|
35
|
-
'AbortController',
|
|
36
|
-
'AbortSignal'
|
|
37
|
-
]);
|
|
38
|
-
|
|
39
|
-
//# sourceMappingURL=default-endowments.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/default-endowments.ts"],"sourcesContent":["/**\n * Global JavaScript APIs exposed by default to all snaps.\n */\nexport const DEFAULT_ENDOWMENTS: readonly string[] = Object.freeze([\n 'atob',\n 'btoa',\n 'BigInt',\n 'console',\n 'crypto',\n 'Date',\n 'Math',\n 'setTimeout',\n 'clearTimeout',\n 'SubtleCrypto',\n 'TextDecoder',\n 'TextEncoder',\n 'URL',\n 'setInterval',\n 'clearInterval',\n 'Int8Array',\n 'Uint8Array',\n 'Uint8ClampedArray',\n 'Int16Array',\n 'Uint16Array',\n 'Int32Array',\n 'Uint32Array',\n 'Float32Array',\n 'Float64Array',\n 'BigInt64Array',\n 'BigUint64Array',\n 'DataView',\n 'ArrayBuffer',\n // Used by fetch, but also as API for some packages that don't do network connections\n // https://github.com/MetaMask/snaps-monorepo/issues/662\n // https://github.com/MetaMask/snaps-monorepo/discussions/678\n 'AbortController',\n 'AbortSignal',\n]);\n"],"names":["DEFAULT_ENDOWMENTS","Object","freeze"],"mappings":"AAAA;;CAEC,GACD,OAAO,MAAMA,qBAAwCC,OAAOC,MAAM,CAAC;IACjE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,qFAAqF;IACrF,wDAAwD;IACxD,6DAA6D;IAC7D;IACA;CACD,EAAE"}
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import slip44 from '@metamask/slip44';
|
|
2
|
-
import { isEqual } from './array';
|
|
3
|
-
export const SNAPS_DERIVATION_PATHS = [
|
|
4
|
-
{
|
|
5
|
-
path: [
|
|
6
|
-
'm',
|
|
7
|
-
`44'`,
|
|
8
|
-
`0'`
|
|
9
|
-
],
|
|
10
|
-
curve: 'ed25519',
|
|
11
|
-
name: 'Test BIP-32 Path (ed25519)'
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
path: [
|
|
15
|
-
'm',
|
|
16
|
-
`44'`,
|
|
17
|
-
`1'`
|
|
18
|
-
],
|
|
19
|
-
curve: 'secp256k1',
|
|
20
|
-
name: 'Testnet'
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
path: [
|
|
24
|
-
'm',
|
|
25
|
-
`44'`,
|
|
26
|
-
`0'`
|
|
27
|
-
],
|
|
28
|
-
curve: 'secp256k1',
|
|
29
|
-
name: 'Bitcoin Legacy'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
path: [
|
|
33
|
-
'm',
|
|
34
|
-
`49'`,
|
|
35
|
-
`0'`
|
|
36
|
-
],
|
|
37
|
-
curve: 'secp256k1',
|
|
38
|
-
name: 'Bitcoin Nested SegWit'
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
path: [
|
|
42
|
-
'm',
|
|
43
|
-
`49'`,
|
|
44
|
-
`1'`
|
|
45
|
-
],
|
|
46
|
-
curve: 'secp256k1',
|
|
47
|
-
name: 'Bitcoin Testnet Nested SegWit'
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
path: [
|
|
51
|
-
'm',
|
|
52
|
-
`84'`,
|
|
53
|
-
`0'`
|
|
54
|
-
],
|
|
55
|
-
curve: 'secp256k1',
|
|
56
|
-
name: 'Bitcoin Native SegWit'
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
path: [
|
|
60
|
-
'm',
|
|
61
|
-
`84'`,
|
|
62
|
-
`1'`
|
|
63
|
-
],
|
|
64
|
-
curve: 'secp256k1',
|
|
65
|
-
name: 'Bitcoin Testnet Native SegWit'
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
path: [
|
|
69
|
-
'm',
|
|
70
|
-
`44'`,
|
|
71
|
-
`501'`
|
|
72
|
-
],
|
|
73
|
-
curve: 'ed25519',
|
|
74
|
-
name: 'Solana'
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
path: [
|
|
78
|
-
'm',
|
|
79
|
-
`44'`,
|
|
80
|
-
`501'`,
|
|
81
|
-
"0'",
|
|
82
|
-
"0'"
|
|
83
|
-
],
|
|
84
|
-
curve: 'ed25519',
|
|
85
|
-
name: 'Solana'
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
path: [
|
|
89
|
-
'm',
|
|
90
|
-
`44'`,
|
|
91
|
-
`2'`
|
|
92
|
-
],
|
|
93
|
-
curve: 'secp256k1',
|
|
94
|
-
name: 'Litecoin'
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
path: [
|
|
98
|
-
'm',
|
|
99
|
-
`44'`,
|
|
100
|
-
`3'`
|
|
101
|
-
],
|
|
102
|
-
curve: 'secp256k1',
|
|
103
|
-
name: 'Dogecoin'
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
path: [
|
|
107
|
-
'm',
|
|
108
|
-
`44'`,
|
|
109
|
-
`60'`
|
|
110
|
-
],
|
|
111
|
-
curve: 'secp256k1',
|
|
112
|
-
name: 'Ethereum'
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
path: [
|
|
116
|
-
'm',
|
|
117
|
-
`44'`,
|
|
118
|
-
`118'`
|
|
119
|
-
],
|
|
120
|
-
curve: 'secp256k1',
|
|
121
|
-
name: 'Atom'
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
path: [
|
|
125
|
-
'm',
|
|
126
|
-
`44'`,
|
|
127
|
-
`145'`
|
|
128
|
-
],
|
|
129
|
-
curve: 'secp256k1',
|
|
130
|
-
name: 'Bitcoin Cash'
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
path: [
|
|
134
|
-
'm',
|
|
135
|
-
`44'`,
|
|
136
|
-
`637'`
|
|
137
|
-
],
|
|
138
|
-
curve: 'ed25519',
|
|
139
|
-
name: 'Aptos'
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
path: [
|
|
143
|
-
'm',
|
|
144
|
-
`44'`,
|
|
145
|
-
`714'`
|
|
146
|
-
],
|
|
147
|
-
curve: 'secp256k1',
|
|
148
|
-
name: 'Binance (BNB)'
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
path: [
|
|
152
|
-
'm',
|
|
153
|
-
`44'`,
|
|
154
|
-
`784'`
|
|
155
|
-
],
|
|
156
|
-
curve: 'ed25519',
|
|
157
|
-
name: 'Sui'
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
path: [
|
|
161
|
-
'm',
|
|
162
|
-
`44'`,
|
|
163
|
-
`931'`
|
|
164
|
-
],
|
|
165
|
-
curve: 'secp256k1',
|
|
166
|
-
name: 'THORChain (RUNE)'
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
path: [
|
|
170
|
-
'm',
|
|
171
|
-
`44'`,
|
|
172
|
-
`330'`
|
|
173
|
-
],
|
|
174
|
-
curve: 'secp256k1',
|
|
175
|
-
name: 'Terra (LUNA)'
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
path: [
|
|
179
|
-
'm',
|
|
180
|
-
`44'`,
|
|
181
|
-
`459'`
|
|
182
|
-
],
|
|
183
|
-
curve: 'secp256k1',
|
|
184
|
-
name: 'Kava'
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
path: [
|
|
188
|
-
'm',
|
|
189
|
-
`44'`,
|
|
190
|
-
`529'`
|
|
191
|
-
],
|
|
192
|
-
curve: 'secp256k1',
|
|
193
|
-
name: 'Secret Network'
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
path: [
|
|
197
|
-
'm',
|
|
198
|
-
`44'`,
|
|
199
|
-
`397'`,
|
|
200
|
-
`0'`
|
|
201
|
-
],
|
|
202
|
-
curve: 'ed25519',
|
|
203
|
-
name: 'NEAR Protocol'
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
path: [
|
|
207
|
-
'm',
|
|
208
|
-
`44'`,
|
|
209
|
-
`1'`,
|
|
210
|
-
`0'`
|
|
211
|
-
],
|
|
212
|
-
curve: 'ed25519',
|
|
213
|
-
name: 'Testnet'
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
path: [
|
|
217
|
-
'm',
|
|
218
|
-
`44'`,
|
|
219
|
-
`472'`
|
|
220
|
-
],
|
|
221
|
-
curve: 'ed25519',
|
|
222
|
-
name: 'Arweave'
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
path: [
|
|
226
|
-
'm',
|
|
227
|
-
`44'`,
|
|
228
|
-
`12586'`
|
|
229
|
-
],
|
|
230
|
-
curve: 'secp256k1',
|
|
231
|
-
name: 'Mina'
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
path: [
|
|
235
|
-
'm',
|
|
236
|
-
`44'`,
|
|
237
|
-
`1729'`,
|
|
238
|
-
`0'`,
|
|
239
|
-
`0'`
|
|
240
|
-
],
|
|
241
|
-
curve: 'ed25519',
|
|
242
|
-
name: 'Tezos'
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
path: [
|
|
246
|
-
'm',
|
|
247
|
-
`1789'`,
|
|
248
|
-
`0'`
|
|
249
|
-
],
|
|
250
|
-
curve: 'ed25519',
|
|
251
|
-
name: 'Vega'
|
|
252
|
-
}
|
|
253
|
-
];
|
|
254
|
-
/**
|
|
255
|
-
* Gets the name of a derivation path supported by snaps.
|
|
256
|
-
*
|
|
257
|
-
* @param path - The derivation path.
|
|
258
|
-
* @param curve - The curve used to derive the keys.
|
|
259
|
-
* @returns The name of the derivation path, otherwise null.
|
|
260
|
-
*/ export function getSnapDerivationPathName(path, curve) {
|
|
261
|
-
const pathMetadata = SNAPS_DERIVATION_PATHS.find((derivationPath)=>derivationPath.curve === curve && isEqual(derivationPath.path, path));
|
|
262
|
-
if (pathMetadata) {
|
|
263
|
-
return pathMetadata.name;
|
|
264
|
-
}
|
|
265
|
-
// If the curve is secp256k1 and the path is a valid BIP44 path
|
|
266
|
-
// we try looking for the network/protocol name in SLIP44
|
|
267
|
-
if (curve === 'secp256k1' && path[0] === 'm' && path[1] === `44'` && path[2].endsWith(`'`)) {
|
|
268
|
-
const coinType = path[2].slice(0, -1);
|
|
269
|
-
return getSlip44ProtocolName(coinType) ?? null;
|
|
270
|
-
}
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Gets the name of the SLIP-44 protocol corresponding to the specified
|
|
275
|
-
* `coin_type`.
|
|
276
|
-
*
|
|
277
|
-
* @param coinType - The SLIP-44 `coin_type` value whose name
|
|
278
|
-
* to retrieve.
|
|
279
|
-
* @returns The name of the protocol, otherwise null.
|
|
280
|
-
*/ export function getSlip44ProtocolName(coinType) {
|
|
281
|
-
if (String(coinType) === '1') {
|
|
282
|
-
return 'Test Networks';
|
|
283
|
-
}
|
|
284
|
-
return slip44[coinType]?.name ?? null;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
//# sourceMappingURL=derivation-paths.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/derivation-paths.ts"],"sourcesContent":["import type { SupportedCurve } from '@metamask/key-tree';\nimport slip44 from '@metamask/slip44';\n\nimport { isEqual } from './array';\n\nexport type SnapsDerivationPath = {\n path: ['m', ...string[]];\n curve: SupportedCurve;\n name: string;\n};\n\nexport const SNAPS_DERIVATION_PATHS: SnapsDerivationPath[] = [\n {\n path: ['m', `44'`, `0'`],\n curve: 'ed25519',\n name: 'Test BIP-32 Path (ed25519)',\n },\n {\n path: ['m', `44'`, `1'`],\n curve: 'secp256k1',\n name: 'Testnet',\n },\n {\n path: ['m', `44'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Legacy',\n },\n {\n path: ['m', `49'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Nested SegWit',\n },\n {\n path: ['m', `49'`, `1'`],\n curve: 'secp256k1',\n name: 'Bitcoin Testnet Nested SegWit',\n },\n {\n path: ['m', `84'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Native SegWit',\n },\n {\n path: ['m', `84'`, `1'`],\n curve: 'secp256k1',\n name: 'Bitcoin Testnet Native SegWit',\n },\n {\n path: ['m', `44'`, `501'`],\n curve: 'ed25519',\n name: 'Solana',\n },\n {\n path: ['m', `44'`, `501'`, \"0'\", \"0'\"],\n curve: 'ed25519',\n name: 'Solana',\n },\n {\n path: ['m', `44'`, `2'`],\n curve: 'secp256k1',\n name: 'Litecoin',\n },\n {\n path: ['m', `44'`, `3'`],\n curve: 'secp256k1',\n name: 'Dogecoin',\n },\n {\n path: ['m', `44'`, `60'`],\n curve: 'secp256k1',\n name: 'Ethereum',\n },\n {\n path: ['m', `44'`, `118'`],\n curve: 'secp256k1',\n name: 'Atom',\n },\n {\n path: ['m', `44'`, `145'`],\n curve: 'secp256k1',\n name: 'Bitcoin Cash',\n },\n {\n path: ['m', `44'`, `637'`],\n curve: 'ed25519',\n name: 'Aptos',\n },\n {\n path: ['m', `44'`, `714'`],\n curve: 'secp256k1',\n name: 'Binance (BNB)',\n },\n {\n path: ['m', `44'`, `784'`],\n curve: 'ed25519',\n name: 'Sui',\n },\n {\n path: ['m', `44'`, `931'`],\n curve: 'secp256k1',\n name: 'THORChain (RUNE)',\n },\n {\n path: ['m', `44'`, `330'`],\n curve: 'secp256k1',\n name: 'Terra (LUNA)',\n },\n {\n path: ['m', `44'`, `459'`],\n curve: 'secp256k1',\n name: 'Kava',\n },\n {\n path: ['m', `44'`, `529'`],\n curve: 'secp256k1',\n name: 'Secret Network',\n },\n {\n path: ['m', `44'`, `397'`, `0'`],\n curve: 'ed25519',\n name: 'NEAR Protocol',\n },\n {\n path: ['m', `44'`, `1'`, `0'`],\n curve: 'ed25519',\n name: 'Testnet',\n },\n {\n path: ['m', `44'`, `472'`],\n curve: 'ed25519',\n name: 'Arweave',\n },\n {\n path: ['m', `44'`, `12586'`],\n curve: 'secp256k1',\n name: 'Mina',\n },\n {\n path: ['m', `44'`, `1729'`, `0'`, `0'`],\n curve: 'ed25519',\n name: 'Tezos',\n },\n {\n path: ['m', `1789'`, `0'`],\n curve: 'ed25519',\n name: 'Vega',\n },\n];\n\n/**\n * Gets the name of a derivation path supported by snaps.\n *\n * @param path - The derivation path.\n * @param curve - The curve used to derive the keys.\n * @returns The name of the derivation path, otherwise null.\n */\nexport function getSnapDerivationPathName(\n path: SnapsDerivationPath['path'],\n curve: SupportedCurve,\n): string | null {\n const pathMetadata = SNAPS_DERIVATION_PATHS.find(\n (derivationPath) =>\n derivationPath.curve === curve && isEqual(derivationPath.path, path),\n );\n\n if (pathMetadata) {\n return pathMetadata.name;\n }\n\n // If the curve is secp256k1 and the path is a valid BIP44 path\n // we try looking for the network/protocol name in SLIP44\n if (\n curve === 'secp256k1' &&\n path[0] === 'm' &&\n path[1] === `44'` &&\n path[2].endsWith(`'`)\n ) {\n const coinType = path[2].slice(0, -1);\n return getSlip44ProtocolName(coinType) ?? null;\n }\n\n return null;\n}\n\n/**\n * Gets the name of the SLIP-44 protocol corresponding to the specified\n * `coin_type`.\n *\n * @param coinType - The SLIP-44 `coin_type` value whose name\n * to retrieve.\n * @returns The name of the protocol, otherwise null.\n */\nexport function getSlip44ProtocolName(coinType: number | string) {\n if (String(coinType) === '1') {\n return 'Test Networks';\n }\n\n return slip44[coinType as keyof typeof slip44]?.name ?? null;\n}\n"],"names":["slip44","isEqual","SNAPS_DERIVATION_PATHS","path","curve","name","getSnapDerivationPathName","pathMetadata","find","derivationPath","endsWith","coinType","slice","getSlip44ProtocolName","String"],"mappings":"AACA,OAAOA,YAAY,mBAAmB;AAEtC,SAASC,OAAO,QAAQ,UAAU;AAQlC,OAAO,MAAMC,yBAAgD;IAC3D;QACEC,MAAM;YAAC;YAAK,CAAC,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;SAAC;QACxBC,OAAO;QACPC,MAAM;I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
|
|
|
1
|
-
{"version":3,"sources":["../../src/entropy.ts"],"sourcesContent":["// 0xd36e6170 - 0x80000000\nexport const SIP_6_MAGIC_VALUE = `1399742832'` as `${number}'`;\n\n// `${bytesToNumber(keccak256('Snaps state encryption').slice(0, 4))}'`\nexport const STATE_ENCRYPTION_MAGIC_VALUE = `572232532'` as `${number}'`;\n\nexport type MagicValue =\n | typeof SIP_6_MAGIC_VALUE\n | typeof STATE_ENCRYPTION_MAGIC_VALUE;\n"],"names":["SIP_6_MAGIC_VALUE","STATE_ENCRYPTION_MAGIC_VALUE"],"mappings":"AAAA,0BAA0B;AAC1B,OAAO,MAAMA,oBAAoB,CAAC,WAAW,CAAC,CAAiB;AAE/D,uEAAuE;AACvE,OAAO,MAAMC,+BAA+B,CAAC,UAAU,CAAC,CAAiB"}
|
package/dist/esm/errors.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
2
|
-
if (privateCollection.has(obj)) {
|
|
3
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
7
|
-
if (descriptor.get) {
|
|
8
|
-
return descriptor.get.call(receiver);
|
|
9
|
-
}
|
|
10
|
-
return descriptor.value;
|
|
11
|
-
}
|
|
12
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
13
|
-
if (descriptor.set) {
|
|
14
|
-
descriptor.set.call(receiver, value);
|
|
15
|
-
} else {
|
|
16
|
-
if (!descriptor.writable) {
|
|
17
|
-
throw new TypeError("attempted to set read only private field");
|
|
18
|
-
}
|
|
19
|
-
descriptor.value = value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
23
|
-
if (!privateMap.has(receiver)) {
|
|
24
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
25
|
-
}
|
|
26
|
-
return privateMap.get(receiver);
|
|
27
|
-
}
|
|
28
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
29
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
30
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
31
|
-
}
|
|
32
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
33
|
-
_check_private_redeclaration(obj, privateMap);
|
|
34
|
-
privateMap.set(obj, value);
|
|
35
|
-
}
|
|
36
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
37
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
38
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
import { errorCodes, JsonRpcError as RpcError, serializeCause } from '@metamask/rpc-errors';
|
|
42
|
-
import { getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE } from '@metamask/snaps-sdk';
|
|
43
|
-
import { isObject, isJsonRpcError } from '@metamask/utils';
|
|
44
|
-
export const SNAP_ERROR_WRAPPER_CODE = -31001;
|
|
45
|
-
export const SNAP_ERROR_WRAPPER_MESSAGE = 'Wrapped Snap Error';
|
|
46
|
-
var _error = /*#__PURE__*/ new WeakMap(), _message = /*#__PURE__*/ new WeakMap(), _stack = /*#__PURE__*/ new WeakMap();
|
|
47
|
-
export class WrappedSnapError extends Error {
|
|
48
|
-
/**
|
|
49
|
-
* The error name.
|
|
50
|
-
*
|
|
51
|
-
* @returns The error name.
|
|
52
|
-
*/ get name() {
|
|
53
|
-
return 'WrappedSnapError';
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* The error message.
|
|
57
|
-
*
|
|
58
|
-
* @returns The error message.
|
|
59
|
-
*/ get message() {
|
|
60
|
-
return _class_private_field_get(this, _message);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* The error stack.
|
|
64
|
-
*
|
|
65
|
-
* @returns The error stack.
|
|
66
|
-
*/ get stack() {
|
|
67
|
-
return _class_private_field_get(this, _stack);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Convert the error to a JSON object.
|
|
71
|
-
*
|
|
72
|
-
* @returns The JSON object.
|
|
73
|
-
*/ toJSON() {
|
|
74
|
-
const cause = isSnapError(_class_private_field_get(this, _error)) ? _class_private_field_get(this, _error).serialize() : serializeCause(_class_private_field_get(this, _error));
|
|
75
|
-
return {
|
|
76
|
-
code: SNAP_ERROR_WRAPPER_CODE,
|
|
77
|
-
message: SNAP_ERROR_WRAPPER_MESSAGE,
|
|
78
|
-
data: {
|
|
79
|
-
cause
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Serialize the error to a JSON object. This is called by
|
|
85
|
-
* `@metamask/rpc-errors` when serializing the error.
|
|
86
|
-
*
|
|
87
|
-
* @returns The JSON object.
|
|
88
|
-
*/ serialize() {
|
|
89
|
-
return this.toJSON();
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Create a new `WrappedSnapError`.
|
|
93
|
-
*
|
|
94
|
-
* @param error - The error to create the `WrappedSnapError` from.
|
|
95
|
-
*/ constructor(error){
|
|
96
|
-
const message = getErrorMessage(error);
|
|
97
|
-
super(message);
|
|
98
|
-
_class_private_field_init(this, _error, {
|
|
99
|
-
writable: true,
|
|
100
|
-
value: void 0
|
|
101
|
-
});
|
|
102
|
-
_class_private_field_init(this, _message, {
|
|
103
|
-
writable: true,
|
|
104
|
-
value: void 0
|
|
105
|
-
});
|
|
106
|
-
_class_private_field_init(this, _stack, {
|
|
107
|
-
writable: true,
|
|
108
|
-
value: void 0
|
|
109
|
-
});
|
|
110
|
-
_class_private_field_set(this, _error, error);
|
|
111
|
-
_class_private_field_set(this, _message, message);
|
|
112
|
-
_class_private_field_set(this, _stack, getErrorStack(error));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Check if an object is a `SnapError`.
|
|
117
|
-
*
|
|
118
|
-
* @param error - The object to check.
|
|
119
|
-
* @returns Whether the object is a `SnapError`.
|
|
120
|
-
*/ export function isSnapError(error) {
|
|
121
|
-
if (isObject(error) && 'serialize' in error && typeof error.serialize === 'function') {
|
|
122
|
-
const serialized = error.serialize();
|
|
123
|
-
return isJsonRpcError(serialized) && isSerializedSnapError(serialized);
|
|
124
|
-
}
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Check if a JSON-RPC error is a `SnapError`.
|
|
129
|
-
*
|
|
130
|
-
* @param error - The object to check.
|
|
131
|
-
* @returns Whether the object is a `SnapError`.
|
|
132
|
-
*/ export function isSerializedSnapError(error) {
|
|
133
|
-
return error.code === SNAP_ERROR_CODE && error.message === SNAP_ERROR_MESSAGE;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Check if a JSON-RPC error is a `WrappedSnapError`.
|
|
137
|
-
*
|
|
138
|
-
* @param error - The object to check.
|
|
139
|
-
* @returns Whether the object is a `WrappedSnapError`.
|
|
140
|
-
*/ export function isWrappedSnapError(error) {
|
|
141
|
-
return isJsonRpcError(error) && error.code === SNAP_ERROR_WRAPPER_CODE && error.message === SNAP_ERROR_WRAPPER_MESSAGE;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Get a JSON-RPC error with the given code, message, stack, and data.
|
|
145
|
-
*
|
|
146
|
-
* @param code - The error code.
|
|
147
|
-
* @param message - The error message.
|
|
148
|
-
* @param stack - The error stack.
|
|
149
|
-
* @param data - Additional data for the error.
|
|
150
|
-
* @returns The JSON-RPC error.
|
|
151
|
-
*/ function getJsonRpcError(code, message, stack, data) {
|
|
152
|
-
const error = new RpcError(code, message, data);
|
|
153
|
-
error.stack = stack;
|
|
154
|
-
return error;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Attempt to unwrap an unknown error to a `JsonRpcError`. This function will
|
|
158
|
-
* try to get the error code, message, and data from the error, and return a
|
|
159
|
-
* `JsonRpcError` with those properties.
|
|
160
|
-
*
|
|
161
|
-
* @param error - The error to unwrap.
|
|
162
|
-
* @returns A tuple containing the unwrapped error and a boolean indicating
|
|
163
|
-
* whether the error was handled.
|
|
164
|
-
*/ export function unwrapError(error) {
|
|
165
|
-
// This logic is a bit complicated, but it's necessary to handle all the
|
|
166
|
-
// different types of errors that can be thrown by a Snap.
|
|
167
|
-
// If the error is a wrapped Snap error, unwrap it.
|
|
168
|
-
if (isWrappedSnapError(error)) {
|
|
169
|
-
// The wrapped error can be a JSON-RPC error, or an unknown error. If it's
|
|
170
|
-
// a JSON-RPC error, we can unwrap it further.
|
|
171
|
-
if (isJsonRpcError(error.data.cause)) {
|
|
172
|
-
// If the JSON-RPC error is a wrapped Snap error, unwrap it further.
|
|
173
|
-
if (isSerializedSnapError(error.data.cause)) {
|
|
174
|
-
const { code, message, stack, data } = error.data.cause.data.cause;
|
|
175
|
-
return [
|
|
176
|
-
getJsonRpcError(code, message, stack, data),
|
|
177
|
-
true
|
|
178
|
-
];
|
|
179
|
-
}
|
|
180
|
-
// Otherwise, we use the original JSON-RPC error.
|
|
181
|
-
const { code, message, stack, data } = error.data.cause;
|
|
182
|
-
return [
|
|
183
|
-
getJsonRpcError(code, message, stack, data),
|
|
184
|
-
false
|
|
185
|
-
];
|
|
186
|
-
}
|
|
187
|
-
// Otherwise, we throw an internal error with the wrapped error as the
|
|
188
|
-
// message.
|
|
189
|
-
return [
|
|
190
|
-
getJsonRpcError(errorCodes.rpc.internal, getErrorMessage(error.data.cause), getErrorStack(error.data.cause)),
|
|
191
|
-
false
|
|
192
|
-
];
|
|
193
|
-
}
|
|
194
|
-
// The error can be a non-wrapped JSON-RPC error, in which case we can just
|
|
195
|
-
// re-throw it with the same code, message, and data.
|
|
196
|
-
if (isJsonRpcError(error)) {
|
|
197
|
-
const { code, message, stack, data } = error;
|
|
198
|
-
return [
|
|
199
|
-
getJsonRpcError(code, message, stack, data),
|
|
200
|
-
false
|
|
201
|
-
];
|
|
202
|
-
}
|
|
203
|
-
// If the error is not a wrapped error, we don't know how to handle it, so we
|
|
204
|
-
// throw an internal error with the error as the message.
|
|
205
|
-
return [
|
|
206
|
-
getJsonRpcError(errorCodes.rpc.internal, getErrorMessage(error), getErrorStack(error)),
|
|
207
|
-
false
|
|
208
|
-
];
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/esm/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors.ts"],"sourcesContent":["import {\n errorCodes,\n JsonRpcError as RpcError,\n serializeCause,\n} from '@metamask/rpc-errors';\nimport type { DataWithOptionalCause } from '@metamask/rpc-errors';\nimport type { SerializedSnapError, SnapError } from '@metamask/snaps-sdk';\nimport {\n getErrorMessage,\n getErrorStack,\n SNAP_ERROR_CODE,\n SNAP_ERROR_MESSAGE,\n} from '@metamask/snaps-sdk';\nimport type { Json, JsonRpcError } from '@metamask/utils';\nimport { isObject, isJsonRpcError } from '@metamask/utils';\n\nexport const SNAP_ERROR_WRAPPER_CODE = -31001;\nexport const SNAP_ERROR_WRAPPER_MESSAGE = 'Wrapped Snap Error';\n\nexport type SerializedSnapErrorWrapper = {\n code: typeof SNAP_ERROR_WRAPPER_CODE;\n message: typeof SNAP_ERROR_WRAPPER_MESSAGE;\n data: {\n cause: Json;\n };\n};\n\nexport class WrappedSnapError extends Error {\n readonly #error: unknown;\n\n readonly #message: string;\n\n readonly #stack?: string;\n\n /**\n * Create a new `WrappedSnapError`.\n *\n * @param error - The error to create the `WrappedSnapError` from.\n */\n constructor(error: unknown) {\n const message = getErrorMessage(error);\n super(message);\n\n this.#error = error;\n this.#message = message;\n this.#stack = getErrorStack(error);\n }\n\n /**\n * The error name.\n *\n * @returns The error name.\n */\n get name() {\n return 'WrappedSnapError';\n }\n\n /**\n * The error message.\n *\n * @returns The error message.\n */\n get message() {\n return this.#message;\n }\n\n /**\n * The error stack.\n *\n * @returns The error stack.\n */\n get stack() {\n return this.#stack;\n }\n\n /**\n * Convert the error to a JSON object.\n *\n * @returns The JSON object.\n */\n toJSON(): SerializedSnapErrorWrapper {\n const cause = isSnapError(this.#error)\n ? this.#error.serialize()\n : serializeCause(this.#error);\n\n return {\n code: SNAP_ERROR_WRAPPER_CODE,\n message: SNAP_ERROR_WRAPPER_MESSAGE,\n data: {\n cause,\n },\n };\n }\n\n /**\n * Serialize the error to a JSON object. This is called by\n * `@metamask/rpc-errors` when serializing the error.\n *\n * @returns The JSON object.\n */\n serialize() {\n return this.toJSON();\n }\n}\n\n/**\n * Check if an object is a `SnapError`.\n *\n * @param error - The object to check.\n * @returns Whether the object is a `SnapError`.\n */\nexport function isSnapError(error: unknown): error is SnapError {\n if (\n isObject(error) &&\n 'serialize' in error &&\n typeof error.serialize === 'function'\n ) {\n const serialized = error.serialize();\n return isJsonRpcError(serialized) && isSerializedSnapError(serialized);\n }\n\n return false;\n}\n\n/**\n * Check if a JSON-RPC error is a `SnapError`.\n *\n * @param error - The object to check.\n * @returns Whether the object is a `SnapError`.\n */\nexport function isSerializedSnapError(\n error: JsonRpcError,\n): error is SerializedSnapError {\n return error.code === SNAP_ERROR_CODE && error.message === SNAP_ERROR_MESSAGE;\n}\n\n/**\n * Check if a JSON-RPC error is a `WrappedSnapError`.\n *\n * @param error - The object to check.\n * @returns Whether the object is a `WrappedSnapError`.\n */\nexport function isWrappedSnapError(\n error: unknown,\n): error is SerializedSnapErrorWrapper {\n return (\n isJsonRpcError(error) &&\n error.code === SNAP_ERROR_WRAPPER_CODE &&\n error.message === SNAP_ERROR_WRAPPER_MESSAGE\n );\n}\n\n/**\n * Get a JSON-RPC error with the given code, message, stack, and data.\n *\n * @param code - The error code.\n * @param message - The error message.\n * @param stack - The error stack.\n * @param data - Additional data for the error.\n * @returns The JSON-RPC error.\n */\nfunction getJsonRpcError(\n code: number,\n message: string,\n stack?: string,\n data?: Json,\n) {\n const error = new RpcError(code, message, data);\n error.stack = stack;\n\n return error;\n}\n\n/**\n * Attempt to unwrap an unknown error to a `JsonRpcError`. This function will\n * try to get the error code, message, and data from the error, and return a\n * `JsonRpcError` with those properties.\n *\n * @param error - The error to unwrap.\n * @returns A tuple containing the unwrapped error and a boolean indicating\n * whether the error was handled.\n */\nexport function unwrapError(\n error: unknown,\n): [error: RpcError<DataWithOptionalCause>, isHandled: boolean] {\n // This logic is a bit complicated, but it's necessary to handle all the\n // different types of errors that can be thrown by a Snap.\n\n // If the error is a wrapped Snap error, unwrap it.\n if (isWrappedSnapError(error)) {\n // The wrapped error can be a JSON-RPC error, or an unknown error. If it's\n // a JSON-RPC error, we can unwrap it further.\n if (isJsonRpcError(error.data.cause)) {\n // If the JSON-RPC error is a wrapped Snap error, unwrap it further.\n if (isSerializedSnapError(error.data.cause)) {\n const { code, message, stack, data } = error.data.cause.data.cause;\n return [getJsonRpcError(code, message, stack, data), true];\n }\n\n // Otherwise, we use the original JSON-RPC error.\n const { code, message, stack, data } = error.data.cause;\n return [getJsonRpcError(code, message, stack, data), false];\n }\n\n // Otherwise, we throw an internal error with the wrapped error as the\n // message.\n return [\n getJsonRpcError(\n errorCodes.rpc.internal,\n getErrorMessage(error.data.cause),\n getErrorStack(error.data.cause),\n ),\n false,\n ];\n }\n\n // The error can be a non-wrapped JSON-RPC error, in which case we can just\n // re-throw it with the same code, message, and data.\n if (isJsonRpcError(error)) {\n const { code, message, stack, data } = error;\n return [getJsonRpcError(code, message, stack, data), false];\n }\n\n // If the error is not a wrapped error, we don't know how to handle it, so we\n // throw an internal error with the error as the message.\n return [\n getJsonRpcError(\n errorCodes.rpc.internal,\n getErrorMessage(error),\n getErrorStack(error),\n ),\n false,\n ];\n}\n"],"names":["errorCodes","JsonRpcError","RpcError","serializeCause","getErrorMessage","getErrorStack","SNAP_ERROR_CODE","SNAP_ERROR_MESSAGE","isObject","isJsonRpcError","SNAP_ERROR_WRAPPER_CODE","SNAP_ERROR_WRAPPER_MESSAGE","WrappedSnapError","Error","name","message","stack","toJSON","cause","isSnapError","error","serialize","code","data","constructor","serialized","isSerializedSnapError","isWrappedSnapError","getJsonRpcError","unwrapError","rpc","internal"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SACEA,UAAU,EACVC,gBAAgBC,QAAQ,EACxBC,cAAc,QACT,uBAAuB;AAG9B,SACEC,eAAe,EACfC,aAAa,EACbC,eAAe,EACfC,kBAAkB,QACb,sBAAsB;AAE7B,SAASC,QAAQ,EAAEC,cAAc,QAAQ,kBAAkB;AAE3D,OAAO,MAAMC,0BAA0B,CAAC,MAAM;AAC9C,OAAO,MAAMC,6BAA6B,qBAAqB;IAWpD,sCAEA,wCAEA;AALX,OAAO,MAAMC,yBAAyBC;IAqBpC;;;;GAIC,GACD,IAAIC,OAAO;QACT,OAAO;IACT;IAEA;;;;GAIC,GACD,IAAIC,UAAU;QACZ,gCAAO,IAAI,EAAEA;IACf;IAEA;;;;GAIC,GACD,IAAIC,QAAQ;QACV,gCAAO,IAAI,EAAEA;IACf;IAEA;;;;GAIC,GACDC,SAAqC;QACnC,MAAMC,QAAQC,qCAAY,IAAI,EAAEC,WAC5B,yBAAA,IAAI,EAAEA,QAAMC,SAAS,KACrBlB,wCAAe,IAAI,EAAEiB;QAEzB,OAAO;YACLE,MAAMZ;YACNK,SAASJ;YACTY,MAAM;gBACJL;YACF;QACF;IACF;IAEA;;;;;GAKC,GACDG,YAAY;QACV,OAAO,IAAI,CAACJ,MAAM;IACpB;IApEA;;;;GAIC,GACDO,YAAYJ,KAAc,CAAE;QAC1B,MAAML,UAAUX,gBAAgBgB;QAChC,KAAK,CAACL;QAbR,gCAAS;;mBAAT,KAAA;;QAEA,gCAAS;;mBAAT,KAAA;;QAEA,gCAAS;;mBAAT,KAAA;;uCAWQK,QAAQA;uCACRL,UAAUA;uCACVC,QAAQX,cAAce;IAC9B;AAyDF;AAEA;;;;;CAKC,GACD,OAAO,SAASD,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