@metamask/snaps-utils 8.0.1 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/dist/array.cjs +17 -0
- package/dist/array.cjs.map +1 -0
- package/dist/array.d.cts +11 -0
- package/dist/array.d.cts.map +1 -0
- package/dist/array.d.mts +11 -0
- package/dist/array.d.mts.map +1 -0
- package/dist/array.mjs +12 -7
- package/dist/array.mjs.map +1 -1
- package/dist/auxiliary-files.cjs +39 -0
- package/dist/auxiliary-files.cjs.map +1 -0
- package/dist/auxiliary-files.d.cts +17 -0
- package/dist/auxiliary-files.d.cts.map +1 -0
- package/dist/auxiliary-files.d.mts +17 -0
- package/dist/auxiliary-files.d.mts.map +1 -0
- package/dist/auxiliary-files.mjs +33 -14
- package/dist/auxiliary-files.mjs.map +1 -1
- package/dist/base64.cjs +38 -0
- package/dist/base64.cjs.map +1 -0
- package/dist/base64.d.cts +16 -0
- package/dist/base64.d.cts.map +1 -0
- package/dist/base64.d.mts +16 -0
- package/dist/base64.d.mts.map +1 -0
- package/dist/base64.mjs +32 -12
- package/dist/base64.mjs.map +1 -1
- package/dist/bytes.cjs +22 -0
- package/dist/bytes.cjs.map +1 -0
- package/dist/bytes.d.cts +9 -0
- package/dist/bytes.d.cts.map +1 -0
- package/dist/bytes.d.mts +9 -0
- package/dist/bytes.d.mts.map +1 -0
- package/dist/bytes.mjs +17 -9
- package/dist/bytes.mjs.map +1 -1
- package/dist/caveats.cjs +51 -0
- package/dist/caveats.cjs.map +1 -0
- package/dist/caveats.d.cts +47 -0
- package/dist/caveats.d.cts.map +1 -0
- package/dist/caveats.d.mts +47 -0
- package/dist/caveats.d.mts.map +1 -0
- package/dist/caveats.mjs +47 -7
- package/dist/caveats.mjs.map +1 -1
- package/dist/checksum.cjs +49 -0
- package/dist/checksum.cjs.map +1 -0
- package/dist/checksum.d.cts +22 -0
- package/dist/checksum.d.cts.map +1 -0
- package/dist/checksum.d.mts +22 -0
- package/dist/checksum.d.mts.map +1 -0
- package/dist/checksum.mjs +43 -12
- package/dist/checksum.mjs.map +1 -1
- package/dist/constants.cjs +8 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +2 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +2 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +4 -7
- package/dist/constants.mjs.map +1 -1
- package/dist/cronjob.cjs +70 -0
- package/dist/cronjob.cjs.map +1 -0
- package/dist/cronjob.d.cts +90 -0
- package/dist/cronjob.d.cts.map +1 -0
- package/dist/cronjob.d.mts +90 -0
- package/dist/cronjob.d.mts.map +1 -0
- package/dist/cronjob.mjs +64 -19
- package/dist/cronjob.mjs.map +1 -1
- package/dist/deep-clone.cjs +9 -0
- package/dist/deep-clone.cjs.map +1 -0
- package/dist/deep-clone.d.cts +2 -0
- package/dist/deep-clone.d.cts.map +1 -0
- package/dist/deep-clone.d.mts +2 -0
- package/dist/deep-clone.d.mts.map +1 -0
- package/dist/deep-clone.mjs +9 -7
- package/dist/deep-clone.mjs.map +1 -1
- package/dist/default-endowments.cjs +42 -0
- package/dist/default-endowments.cjs.map +1 -0
- package/dist/default-endowments.d.cts +5 -0
- package/dist/default-endowments.d.cts.map +1 -0
- package/dist/default-endowments.d.mts +5 -0
- package/dist/default-endowments.d.mts.map +1 -0
- package/dist/default-endowments.mjs +38 -7
- package/dist/default-endowments.mjs.map +1 -1
- package/dist/derivation-paths.cjs +215 -0
- package/dist/derivation-paths.cjs.map +1 -0
- package/dist/derivation-paths.d.cts +25 -0
- package/dist/derivation-paths.d.cts.map +1 -0
- package/dist/derivation-paths.d.mts +25 -0
- package/dist/derivation-paths.d.mts.map +1 -0
- package/dist/derivation-paths.mjs +206 -12
- package/dist/derivation-paths.mjs.map +1 -1
- package/dist/entropy.cjs +8 -0
- package/dist/entropy.cjs.map +1 -0
- package/dist/entropy.d.cts +4 -0
- package/dist/entropy.d.cts.map +1 -0
- package/dist/entropy.d.mts +4 -0
- package/dist/entropy.d.mts.map +1 -0
- package/dist/entropy.mjs +4 -9
- package/dist/entropy.mjs.map +1 -1
- package/dist/errors.cjs +189 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +85 -0
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +85 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +179 -18
- package/dist/errors.mjs.map +1 -1
- package/dist/eval-worker.cjs +42 -0
- package/dist/eval-worker.cjs.map +1 -0
- package/dist/eval-worker.d.cts +2 -0
- package/dist/eval-worker.d.cts.map +1 -0
- package/dist/eval-worker.d.mts +2 -0
- package/dist/eval-worker.d.mts.map +1 -0
- package/dist/eval-worker.mjs +28 -31
- package/dist/eval-worker.mjs.map +1 -1
- package/dist/eval.cjs +54 -0
- package/dist/eval.cjs.map +1 -0
- package/dist/eval.d.cts +17 -0
- package/dist/eval.d.cts.map +1 -0
- package/dist/eval.d.mts +17 -0
- package/dist/eval.d.mts.map +1 -0
- package/dist/eval.mjs +48 -16
- package/dist/eval.mjs.map +1 -1
- package/dist/fs.cjs +159 -0
- package/dist/fs.cjs.map +1 -0
- package/dist/fs.d.cts +70 -0
- package/dist/fs.d.cts.map +1 -0
- package/dist/fs.d.mts +70 -0
- package/dist/fs.d.mts.map +1 -0
- package/dist/fs.mjs +144 -27
- package/dist/fs.mjs.map +1 -1
- package/dist/handler-types.cjs +18 -0
- package/dist/handler-types.cjs.map +1 -0
- package/dist/handler-types.d.cts +35 -0
- package/dist/handler-types.d.cts.map +1 -0
- package/dist/handler-types.d.mts +35 -0
- package/dist/handler-types.d.mts.map +1 -0
- package/dist/handler-types.mjs +14 -9
- package/dist/handler-types.mjs.map +1 -1
- package/dist/handlers.cjs +119 -0
- package/dist/handlers.cjs.map +1 -0
- package/dist/handlers.d.cts +750 -0
- package/dist/handlers.d.cts.map +1 -0
- package/dist/handlers.d.mts +750 -0
- package/dist/handlers.d.mts.map +1 -0
- package/dist/handlers.mjs +114 -33
- package/dist/handlers.mjs.map +1 -1
- package/dist/icon.cjs +58 -0
- package/dist/icon.cjs.map +1 -0
- package/dist/icon.d.cts +20 -0
- package/dist/icon.d.cts.map +1 -0
- package/dist/icon.d.mts +20 -0
- package/dist/icon.d.mts.map +1 -0
- package/dist/icon.mjs +52 -14
- package/dist/icon.mjs.map +1 -1
- package/dist/iframe.cjs +54 -0
- package/dist/iframe.cjs.map +1 -0
- package/dist/iframe.d.cts +12 -0
- package/dist/iframe.d.cts.map +1 -0
- package/dist/iframe.d.mts +12 -0
- package/dist/iframe.d.mts.map +1 -0
- package/dist/iframe.mjs +49 -7
- package/dist/iframe.mjs.map +1 -1
- package/dist/iframe.test.browser.cjs +15 -0
- package/dist/iframe.test.browser.cjs.map +1 -0
- package/dist/iframe.test.browser.d.cts +2 -0
- package/dist/iframe.test.browser.d.cts.map +1 -0
- package/dist/iframe.test.browser.d.mts +2 -0
- package/dist/iframe.test.browser.d.mts.map +1 -0
- package/dist/iframe.test.browser.mjs +13 -0
- package/dist/iframe.test.browser.mjs.map +1 -0
- package/dist/index.cjs +49 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +33 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +33 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.executionenv.cjs +25 -0
- package/dist/index.executionenv.cjs.map +1 -0
- package/dist/index.executionenv.d.cts +8 -0
- package/dist/index.executionenv.d.cts.map +1 -0
- package/dist/index.executionenv.d.mts +8 -0
- package/dist/index.executionenv.d.mts.map +1 -0
- package/dist/index.executionenv.mjs +8 -127
- package/dist/index.executionenv.mjs.map +1 -1
- package/dist/index.mjs +32 -397
- package/dist/index.mjs.map +1 -1
- package/dist/json-rpc.cjs +135 -0
- package/dist/json-rpc.cjs.map +1 -0
- package/dist/json-rpc.d.cts +56 -0
- package/dist/json-rpc.d.cts.map +1 -0
- package/dist/json-rpc.d.mts +56 -0
- package/dist/json-rpc.d.mts.map +1 -0
- package/dist/json-rpc.mjs +127 -17
- package/dist/json-rpc.mjs.map +1 -1
- package/dist/json.cjs +34 -0
- package/dist/json.cjs.map +1 -0
- package/dist/json.d.cts +23 -0
- package/dist/json.d.cts.map +1 -0
- package/dist/json.d.mts +23 -0
- package/dist/json.d.mts.map +1 -0
- package/dist/json.mjs +28 -9
- package/dist/json.mjs.map +1 -1
- package/dist/localization.cjs +128 -0
- package/dist/localization.cjs.map +1 -0
- package/dist/localization.d.cts +146 -0
- package/dist/localization.d.cts.map +1 -0
- package/dist/localization.d.mts +146 -0
- package/dist/localization.d.mts.map +1 -0
- package/dist/localization.mjs +119 -22
- package/dist/localization.mjs.map +1 -1
- package/dist/logging.cjs +67 -0
- package/dist/logging.cjs.map +1 -0
- package/dist/logging.d.cts +50 -0
- package/dist/logging.d.cts.map +1 -0
- package/dist/logging.d.mts +50 -0
- package/dist/logging.d.mts.map +1 -0
- package/dist/logging.mjs +60 -13
- package/dist/logging.mjs.map +1 -1
- package/dist/manifest/index.cjs +18 -0
- package/dist/manifest/index.cjs.map +1 -0
- package/dist/manifest/index.d.cts +2 -0
- package/dist/manifest/index.d.cts.map +1 -0
- package/dist/manifest/index.d.mts +2 -0
- package/dist/manifest/index.d.mts.map +1 -0
- package/dist/manifest/index.mjs +1 -64
- package/dist/manifest/index.mjs.map +1 -1
- package/dist/manifest/manifest.cjs +267 -0
- package/dist/manifest/manifest.cjs.map +1 -0
- package/dist/manifest/manifest.d.cts +100 -0
- package/dist/manifest/manifest.d.cts.map +1 -0
- package/dist/manifest/manifest.d.mts +100 -0
- package/dist/manifest/manifest.d.mts.map +1 -0
- package/dist/manifest/manifest.mjs +252 -57
- package/dist/manifest/manifest.mjs.map +1 -1
- package/dist/manifest/node.cjs +19 -0
- package/dist/manifest/node.cjs.map +1 -0
- package/dist/manifest/node.d.cts +3 -0
- package/dist/manifest/node.d.cts.map +1 -0
- package/dist/manifest/node.d.mts +3 -0
- package/dist/manifest/node.d.mts.map +1 -0
- package/dist/manifest/node.mjs +2 -105
- package/dist/manifest/node.mjs.map +1 -1
- package/dist/manifest/validation.cjs +194 -0
- package/dist/manifest/validation.cjs.map +1 -0
- package/dist/manifest/validation.d.cts +254 -0
- package/dist/manifest/validation.d.cts.map +1 -0
- package/dist/manifest/validation.d.mts +254 -0
- package/dist/manifest/validation.d.mts.map +1 -0
- package/dist/manifest/validation.mjs +186 -63
- package/dist/manifest/validation.mjs.map +1 -1
- package/dist/manifest/validator-types.cjs +3 -0
- package/dist/manifest/validator-types.cjs.map +1 -0
- package/dist/manifest/validator-types.d.cts +35 -0
- package/dist/manifest/validator-types.d.cts.map +1 -0
- package/dist/manifest/validator-types.d.mts +35 -0
- package/dist/manifest/validator-types.d.mts.map +1 -0
- package/dist/manifest/validator-types.mjs +1 -0
- package/dist/manifest/validator-types.mjs.map +1 -1
- package/dist/manifest/validator.cjs +109 -0
- package/dist/manifest/validator.cjs.map +1 -0
- package/dist/manifest/validator.d.cts +24 -0
- package/dist/manifest/validator.d.cts.map +1 -0
- package/dist/manifest/validator.d.mts +24 -0
- package/dist/manifest/validator.d.mts.map +1 -0
- package/dist/manifest/validator.mjs +79 -42
- package/dist/manifest/validator.mjs.map +1 -1
- package/dist/manifest/validators/checksum.cjs +23 -0
- package/dist/manifest/validators/checksum.cjs.map +1 -0
- package/dist/manifest/validators/checksum.d.cts +6 -0
- package/dist/manifest/validators/checksum.d.cts.map +1 -0
- package/dist/manifest/validators/checksum.d.mts +6 -0
- package/dist/manifest/validators/checksum.d.mts.map +1 -0
- package/dist/manifest/validators/checksum.mjs +18 -13
- package/dist/manifest/validators/checksum.mjs.map +1 -1
- package/dist/manifest/validators/expected-files.cjs +24 -0
- package/dist/manifest/validators/expected-files.cjs.map +1 -0
- package/dist/manifest/validators/expected-files.d.cts +6 -0
- package/dist/manifest/validators/expected-files.d.cts.map +1 -0
- package/dist/manifest/validators/expected-files.d.mts +6 -0
- package/dist/manifest/validators/expected-files.d.mts.map +1 -0
- package/dist/manifest/validators/expected-files.mjs +19 -7
- package/dist/manifest/validators/expected-files.mjs.map +1 -1
- package/dist/manifest/validators/icon-declared.cjs +15 -0
- package/dist/manifest/validators/icon-declared.cjs.map +1 -0
- package/dist/manifest/validators/icon-declared.d.cts +6 -0
- package/dist/manifest/validators/icon-declared.d.cts.map +1 -0
- package/dist/manifest/validators/icon-declared.d.mts +6 -0
- package/dist/manifest/validators/icon-declared.d.mts.map +1 -0
- package/dist/manifest/validators/icon-declared.mjs +10 -6
- package/dist/manifest/validators/icon-declared.mjs.map +1 -1
- package/dist/manifest/validators/icon-dimensions.cjs +20 -0
- package/dist/manifest/validators/icon-dimensions.cjs.map +1 -0
- package/dist/manifest/validators/icon-dimensions.d.cts +6 -0
- package/dist/manifest/validators/icon-dimensions.d.cts.map +1 -0
- package/dist/manifest/validators/icon-dimensions.d.mts +6 -0
- package/dist/manifest/validators/icon-dimensions.d.mts.map +1 -0
- package/dist/manifest/validators/icon-dimensions.mjs +15 -8
- package/dist/manifest/validators/icon-dimensions.mjs.map +1 -1
- package/dist/manifest/validators/icon-missing.cjs +16 -0
- package/dist/manifest/validators/icon-missing.cjs.map +1 -0
- package/dist/manifest/validators/icon-missing.d.cts +6 -0
- package/dist/manifest/validators/icon-missing.d.cts.map +1 -0
- package/dist/manifest/validators/icon-missing.d.mts +6 -0
- package/dist/manifest/validators/icon-missing.d.mts.map +1 -0
- package/dist/manifest/validators/icon-missing.mjs +11 -6
- package/dist/manifest/validators/icon-missing.mjs.map +1 -1
- package/dist/manifest/validators/index.cjs +31 -0
- package/dist/manifest/validators/index.cjs.map +1 -0
- package/dist/manifest/validators/index.d.cts +15 -0
- package/dist/manifest/validators/index.d.cts.map +1 -0
- package/dist/manifest/validators/index.d.mts +15 -0
- package/dist/manifest/validators/index.d.mts.map +1 -0
- package/dist/manifest/validators/index.mjs +14 -79
- package/dist/manifest/validators/index.mjs.map +1 -1
- package/dist/manifest/validators/is-localization-file.cjs +23 -0
- package/dist/manifest/validators/is-localization-file.cjs.map +1 -0
- package/dist/manifest/validators/is-localization-file.d.cts +6 -0
- package/dist/manifest/validators/is-localization-file.d.cts.map +1 -0
- package/dist/manifest/validators/is-localization-file.d.mts +6 -0
- package/dist/manifest/validators/is-localization-file.d.mts.map +1 -0
- package/dist/manifest/validators/is-localization-file.mjs +18 -10
- package/dist/manifest/validators/is-localization-file.mjs.map +1 -1
- package/dist/manifest/validators/is-package-json.cjs +24 -0
- package/dist/manifest/validators/is-package-json.cjs.map +1 -0
- package/dist/manifest/validators/is-package-json.d.cts +6 -0
- package/dist/manifest/validators/is-package-json.d.cts.map +1 -0
- package/dist/manifest/validators/is-package-json.d.mts +6 -0
- package/dist/manifest/validators/is-package-json.d.mts.map +1 -0
- package/dist/manifest/validators/is-package-json.mjs +19 -9
- package/dist/manifest/validators/is-package-json.mjs.map +1 -1
- package/dist/manifest/validators/is-snap-icon.cjs +24 -0
- package/dist/manifest/validators/is-snap-icon.cjs.map +1 -0
- package/dist/manifest/validators/is-snap-icon.d.cts +6 -0
- package/dist/manifest/validators/is-snap-icon.d.cts.map +1 -0
- package/dist/manifest/validators/is-snap-icon.d.mts +6 -0
- package/dist/manifest/validators/is-snap-icon.d.mts.map +1 -0
- package/dist/manifest/validators/is-snap-icon.mjs +19 -8
- package/dist/manifest/validators/is-snap-icon.mjs.map +1 -1
- package/dist/manifest/validators/is-snap-manifest.cjs +25 -0
- package/dist/manifest/validators/is-snap-manifest.cjs.map +1 -0
- package/dist/manifest/validators/is-snap-manifest.d.cts +6 -0
- package/dist/manifest/validators/is-snap-manifest.d.cts.map +1 -0
- package/dist/manifest/validators/is-snap-manifest.d.mts +6 -0
- package/dist/manifest/validators/is-snap-manifest.d.mts.map +1 -0
- package/dist/manifest/validators/is-snap-manifest.mjs +20 -21
- package/dist/manifest/validators/is-snap-manifest.mjs.map +1 -1
- package/dist/manifest/validators/manifest-localization.cjs +30 -0
- package/dist/manifest/validators/manifest-localization.cjs.map +1 -0
- package/dist/manifest/validators/manifest-localization.d.cts +6 -0
- package/dist/manifest/validators/manifest-localization.d.cts.map +1 -0
- package/dist/manifest/validators/manifest-localization.d.mts +6 -0
- package/dist/manifest/validators/manifest-localization.d.mts.map +1 -0
- package/dist/manifest/validators/manifest-localization.mjs +25 -8
- package/dist/manifest/validators/manifest-localization.mjs.map +1 -1
- package/dist/manifest/validators/package-json-recommended-fields.cjs +18 -0
- package/dist/manifest/validators/package-json-recommended-fields.cjs.map +1 -0
- package/dist/manifest/validators/package-json-recommended-fields.d.cts +6 -0
- package/dist/manifest/validators/package-json-recommended-fields.d.cts.map +1 -0
- package/dist/manifest/validators/package-json-recommended-fields.d.mts +6 -0
- package/dist/manifest/validators/package-json-recommended-fields.d.mts.map +1 -0
- package/dist/manifest/validators/package-json-recommended-fields.mjs +13 -6
- package/dist/manifest/validators/package-json-recommended-fields.mjs.map +1 -1
- package/dist/manifest/validators/package-name-match.cjs +21 -0
- package/dist/manifest/validators/package-name-match.cjs.map +1 -0
- package/dist/manifest/validators/package-name-match.d.cts +6 -0
- package/dist/manifest/validators/package-name-match.d.cts.map +1 -0
- package/dist/manifest/validators/package-name-match.d.mts +6 -0
- package/dist/manifest/validators/package-name-match.d.mts.map +1 -0
- package/dist/manifest/validators/package-name-match.mjs +16 -7
- package/dist/manifest/validators/package-name-match.mjs.map +1 -1
- package/dist/manifest/validators/repository-match.cjs +29 -0
- package/dist/manifest/validators/repository-match.cjs.map +1 -0
- package/dist/manifest/validators/repository-match.d.cts +6 -0
- package/dist/manifest/validators/repository-match.d.cts.map +1 -0
- package/dist/manifest/validators/repository-match.d.mts +6 -0
- package/dist/manifest/validators/repository-match.d.mts.map +1 -0
- package/dist/manifest/validators/repository-match.mjs +28 -8
- package/dist/manifest/validators/repository-match.mjs.map +1 -1
- package/dist/manifest/validators/version-match.cjs +21 -0
- package/dist/manifest/validators/version-match.cjs.map +1 -0
- package/dist/manifest/validators/version-match.d.cts +6 -0
- package/dist/manifest/validators/version-match.d.cts.map +1 -0
- package/dist/manifest/validators/version-match.d.mts +6 -0
- package/dist/manifest/validators/version-match.d.mts.map +1 -0
- package/dist/manifest/validators/version-match.mjs +16 -7
- package/dist/manifest/validators/version-match.mjs.map +1 -1
- package/dist/mock.cjs +113 -0
- package/dist/mock.cjs.map +1 -0
- package/dist/mock.d.cts +15 -0
- package/dist/mock.d.cts.map +1 -0
- package/dist/mock.d.mts +15 -0
- package/dist/mock.d.mts.map +1 -0
- package/dist/mock.mjs +103 -11
- package/dist/mock.mjs.map +1 -1
- package/dist/namespace.cjs +136 -0
- package/dist/namespace.cjs.map +1 -0
- package/dist/namespace.d.cts +130 -0
- package/dist/namespace.d.cts.map +1 -0
- package/dist/namespace.d.mts +130 -0
- package/dist/namespace.d.mts.map +1 -0
- package/dist/namespace.mjs +125 -43
- package/dist/namespace.mjs.map +1 -1
- package/dist/node.cjs +25 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +8 -0
- package/dist/node.d.cts.map +1 -0
- package/dist/node.d.mts +8 -0
- package/dist/node.d.mts.map +1 -0
- package/dist/node.mjs +8 -475
- package/dist/node.mjs.map +1 -1
- package/dist/path.cjs +21 -0
- package/dist/path.cjs.map +1 -0
- package/dist/path.d.cts +8 -0
- package/dist/path.d.cts.map +1 -0
- package/dist/path.d.mts +8 -0
- package/dist/path.d.mts.map +1 -0
- package/dist/path.mjs +16 -7
- package/dist/path.mjs.map +1 -1
- package/dist/post-process.cjs +339 -0
- package/dist/post-process.cjs.map +1 -0
- package/dist/post-process.d.cts +72 -0
- package/dist/post-process.d.cts.map +1 -0
- package/dist/post-process.d.mts +72 -0
- package/dist/post-process.d.mts.map +1 -0
- package/dist/post-process.mjs +335 -9
- package/dist/post-process.mjs.map +1 -1
- package/dist/promise.cjs +3 -0
- package/dist/promise.cjs.map +1 -0
- package/dist/promise.d.cts +2 -0
- package/dist/promise.d.cts.map +1 -0
- package/dist/promise.d.mts +2 -0
- package/dist/promise.d.mts.map +1 -0
- package/dist/promise.mjs +1 -1
- package/dist/promise.mjs.map +1 -1
- package/dist/snaps.cjs +207 -0
- package/dist/snaps.cjs.map +1 -0
- package/dist/snaps.d.cts +170 -0
- package/dist/snaps.d.cts.map +1 -0
- package/dist/snaps.d.mts +170 -0
- package/dist/snaps.d.mts.map +1 -0
- package/dist/snaps.mjs +200 -45
- package/dist/snaps.mjs.map +1 -1
- package/dist/strings.cjs +15 -0
- package/dist/strings.cjs.map +1 -0
- package/dist/strings.d.cts +9 -0
- package/dist/strings.d.cts.map +1 -0
- package/dist/strings.d.mts +9 -0
- package/dist/strings.d.mts.map +1 -0
- package/dist/strings.mjs +10 -7
- package/dist/strings.mjs.map +1 -1
- package/dist/structs.cjs +316 -0
- package/dist/structs.cjs.map +1 -0
- package/dist/structs.d.cts +181 -0
- package/dist/structs.d.cts.map +1 -0
- package/dist/structs.d.mts +181 -0
- package/dist/structs.d.mts.map +1 -0
- package/dist/structs.mjs +300 -32
- package/dist/structs.mjs.map +1 -1
- package/dist/svg.cjs +49 -0
- package/dist/svg.cjs.map +1 -0
- package/dist/svg.d.cts +15 -0
- package/dist/svg.d.cts.map +1 -0
- package/dist/svg.d.mts +15 -0
- package/dist/svg.d.mts.map +1 -0
- package/dist/svg.mjs +43 -9
- package/dist/svg.mjs.map +1 -1
- package/dist/types.cjs +64 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +104 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +104 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +58 -21
- package/dist/types.mjs.map +1 -1
- package/dist/ui.cjs +405 -0
- package/dist/ui.cjs.map +1 -0
- package/dist/ui.d.cts +93 -0
- package/dist/ui.d.cts.map +1 -0
- package/dist/ui.d.mts +93 -0
- package/dist/ui.d.mts.map +1 -0
- package/dist/ui.mjs +391 -23
- package/dist/ui.mjs.map +1 -1
- package/dist/validation.cjs +23 -0
- package/dist/validation.cjs.map +1 -0
- package/dist/validation.d.cts +9 -0
- package/dist/validation.d.cts.map +1 -0
- package/dist/validation.d.mts +9 -0
- package/dist/validation.d.mts.map +1 -0
- package/dist/validation.mjs +18 -26
- package/dist/validation.mjs.map +1 -1
- package/dist/versions.cjs +44 -0
- package/dist/versions.cjs.map +1 -0
- package/dist/versions.d.cts +22 -0
- package/dist/versions.d.cts.map +1 -0
- package/dist/versions.d.mts +22 -0
- package/dist/versions.d.mts.map +1 -0
- package/dist/versions.mjs +38 -11
- package/dist/versions.mjs.map +1 -1
- package/dist/virtual-file/VirtualFile.cjs +75 -0
- package/dist/virtual-file/VirtualFile.cjs.map +1 -0
- package/dist/virtual-file/VirtualFile.d.cts +35 -0
- package/dist/virtual-file/VirtualFile.d.cts.map +1 -0
- package/dist/virtual-file/VirtualFile.d.mts +35 -0
- package/dist/virtual-file/VirtualFile.d.mts.map +1 -0
- package/dist/virtual-file/VirtualFile.mjs +70 -8
- package/dist/virtual-file/VirtualFile.mjs.map +1 -1
- package/dist/virtual-file/index.cjs +18 -0
- package/dist/virtual-file/index.cjs.map +1 -0
- package/dist/virtual-file/index.d.cts +2 -0
- package/dist/virtual-file/index.d.cts.map +1 -0
- package/dist/virtual-file/index.d.mts +2 -0
- package/dist/virtual-file/index.d.mts.map +1 -0
- package/dist/virtual-file/index.mjs +1 -9
- package/dist/virtual-file/index.mjs.map +1 -1
- package/dist/virtual-file/node.cjs +19 -0
- package/dist/virtual-file/node.cjs.map +1 -0
- package/dist/virtual-file/node.d.cts +3 -0
- package/dist/virtual-file/node.d.cts.map +1 -0
- package/dist/virtual-file/node.d.mts +3 -0
- package/dist/virtual-file/node.d.mts.map +1 -0
- package/dist/virtual-file/node.mjs +2 -16
- package/dist/virtual-file/node.mjs.map +1 -1
- package/dist/virtual-file/toVirtualFile.cjs +31 -0
- package/dist/virtual-file/toVirtualFile.cjs.map +1 -0
- package/dist/virtual-file/toVirtualFile.d.cts +24 -0
- package/dist/virtual-file/toVirtualFile.d.cts.map +1 -0
- package/dist/virtual-file/toVirtualFile.d.mts +24 -0
- package/dist/virtual-file/toVirtualFile.d.mts.map +1 -0
- package/dist/virtual-file/toVirtualFile.mjs +25 -11
- package/dist/virtual-file/toVirtualFile.mjs.map +1 -1
- package/package.json +36 -24
- package/dist/array.js +0 -8
- package/dist/array.js.map +0 -1
- package/dist/auxiliary-files.js +0 -15
- package/dist/auxiliary-files.js.map +0 -1
- package/dist/base64.js +0 -13
- package/dist/base64.js.map +0 -1
- package/dist/bytes.js +0 -10
- package/dist/bytes.js.map +0 -1
- package/dist/caveats.js +0 -8
- package/dist/caveats.js.map +0 -1
- package/dist/checksum.js +0 -13
- package/dist/checksum.js.map +0 -1
- package/dist/chunk-37EUH3KZ.js +0 -293
- package/dist/chunk-37EUH3KZ.js.map +0 -1
- package/dist/chunk-3N27GIUS.mjs +0 -229
- package/dist/chunk-3N27GIUS.mjs.map +0 -1
- package/dist/chunk-3OXW5H4F.js +0 -30
- package/dist/chunk-3OXW5H4F.js.map +0 -1
- package/dist/chunk-3RFGTBEP.js +0 -151
- package/dist/chunk-3RFGTBEP.js.map +0 -1
- package/dist/chunk-3RUWAMJT.mjs +0 -31
- package/dist/chunk-3RUWAMJT.mjs.map +0 -1
- package/dist/chunk-3S4INAGA.mjs +0 -18
- package/dist/chunk-3S4INAGA.mjs.map +0 -1
- package/dist/chunk-44VFHYJO.js +0 -249
- package/dist/chunk-44VFHYJO.js.map +0 -1
- package/dist/chunk-4AA3TKRJ.mjs +0 -153
- package/dist/chunk-4AA3TKRJ.mjs.map +0 -1
- package/dist/chunk-4BGZ2CHC.mjs +0 -22
- package/dist/chunk-4BGZ2CHC.mjs.map +0 -1
- package/dist/chunk-4CMD46B2.js +0 -1
- package/dist/chunk-4CMD46B2.js.map +0 -1
- package/dist/chunk-4RYTYEUQ.mjs +0 -33
- package/dist/chunk-4RYTYEUQ.mjs.map +0 -1
- package/dist/chunk-4ZJOU3LR.js +0 -71
- package/dist/chunk-4ZJOU3LR.js.map +0 -1
- package/dist/chunk-53QXTM77.js +0 -229
- package/dist/chunk-53QXTM77.js.map +0 -1
- package/dist/chunk-5FTBWYCW.mjs +0 -27
- package/dist/chunk-5FTBWYCW.mjs.map +0 -1
- package/dist/chunk-5MABKEV7.mjs +0 -66
- package/dist/chunk-5MABKEV7.mjs.map +0 -1
- package/dist/chunk-5R7UF7KM.mjs +0 -21
- package/dist/chunk-5R7UF7KM.mjs.map +0 -1
- package/dist/chunk-5UAPBOKO.js +0 -37
- package/dist/chunk-5UAPBOKO.js.map +0 -1
- package/dist/chunk-5WKQI22S.js +0 -7
- package/dist/chunk-5WKQI22S.js.map +0 -1
- package/dist/chunk-63OXILAY.mjs +0 -69
- package/dist/chunk-63OXILAY.mjs.map +0 -1
- package/dist/chunk-6ATNGN44.js +0 -300
- package/dist/chunk-6ATNGN44.js.map +0 -1
- package/dist/chunk-6HXIPMBN.js +0 -103
- package/dist/chunk-6HXIPMBN.js.map +0 -1
- package/dist/chunk-6YJWU77L.js +0 -19
- package/dist/chunk-6YJWU77L.js.map +0 -1
- package/dist/chunk-7HLSXEHK.mjs +0 -300
- package/dist/chunk-7HLSXEHK.mjs.map +0 -1
- package/dist/chunk-7LG4D4XA.mjs +0 -20
- package/dist/chunk-7LG4D4XA.mjs.map +0 -1
- package/dist/chunk-7P62OIGX.js +0 -69
- package/dist/chunk-7P62OIGX.js.map +0 -1
- package/dist/chunk-7T7FYH77.mjs +0 -37
- package/dist/chunk-7T7FYH77.mjs.map +0 -1
- package/dist/chunk-7VJ2BOVU.js +0 -15
- package/dist/chunk-7VJ2BOVU.js.map +0 -1
- package/dist/chunk-A3RRMELT.mjs +0 -1
- package/dist/chunk-A3RRMELT.mjs.map +0 -1
- package/dist/chunk-AMW2VJ3N.js +0 -32
- package/dist/chunk-AMW2VJ3N.js.map +0 -1
- package/dist/chunk-ANYNWSCA.mjs +0 -104
- package/dist/chunk-ANYNWSCA.mjs.map +0 -1
- package/dist/chunk-AOGVLPQZ.js +0 -18
- package/dist/chunk-AOGVLPQZ.js.map +0 -1
- package/dist/chunk-AS5P6JRP.mjs +0 -9
- package/dist/chunk-AS5P6JRP.mjs.map +0 -1
- package/dist/chunk-ASZWZ7JT.js +0 -20
- package/dist/chunk-ASZWZ7JT.js.map +0 -1
- package/dist/chunk-B5GNTDE2.js +0 -109
- package/dist/chunk-B5GNTDE2.js.map +0 -1
- package/dist/chunk-BGSO2GQC.mjs +0 -41
- package/dist/chunk-BGSO2GQC.mjs.map +0 -1
- package/dist/chunk-BPK5BH7K.js +0 -27
- package/dist/chunk-BPK5BH7K.js.map +0 -1
- package/dist/chunk-CJK7DDV2.mjs +0 -109
- package/dist/chunk-CJK7DDV2.mjs.map +0 -1
- package/dist/chunk-CPG2UGAA.js +0 -25
- package/dist/chunk-CPG2UGAA.js.map +0 -1
- package/dist/chunk-DE22V5AO.mjs +0 -53
- package/dist/chunk-DE22V5AO.mjs.map +0 -1
- package/dist/chunk-DEQUNIME.js +0 -53
- package/dist/chunk-DEQUNIME.js.map +0 -1
- package/dist/chunk-DKO64Y4H.mjs +0 -27
- package/dist/chunk-DKO64Y4H.mjs.map +0 -1
- package/dist/chunk-E3BDBG6T.js +0 -20
- package/dist/chunk-E3BDBG6T.js.map +0 -1
- package/dist/chunk-EFRPCO3C.js +0 -1
- package/dist/chunk-EFRPCO3C.js.map +0 -1
- package/dist/chunk-EVHDXNOC.mjs +0 -35
- package/dist/chunk-EVHDXNOC.mjs.map +0 -1
- package/dist/chunk-EYWMVDCD.mjs +0 -25
- package/dist/chunk-EYWMVDCD.mjs.map +0 -1
- package/dist/chunk-FA4QIZH6.js +0 -1
- package/dist/chunk-FA4QIZH6.js.map +0 -1
- package/dist/chunk-FBZ5SU7X.js +0 -189
- package/dist/chunk-FBZ5SU7X.js.map +0 -1
- package/dist/chunk-GIVJAZ2Q.mjs +0 -248
- package/dist/chunk-GIVJAZ2Q.mjs.map +0 -1
- package/dist/chunk-GJAVOB7B.js +0 -24
- package/dist/chunk-GJAVOB7B.js.map +0 -1
- package/dist/chunk-GXSTPU7D.mjs +0 -293
- package/dist/chunk-GXSTPU7D.mjs.map +0 -1
- package/dist/chunk-HY4W6BUH.mjs +0 -24
- package/dist/chunk-HY4W6BUH.mjs.map +0 -1
- package/dist/chunk-HYF7Q6VY.mjs +0 -1
- package/dist/chunk-HYF7Q6VY.mjs.map +0 -1
- package/dist/chunk-I2SWLZ34.js +0 -30
- package/dist/chunk-I2SWLZ34.js.map +0 -1
- package/dist/chunk-IELPPZJP.mjs +0 -189
- package/dist/chunk-IELPPZJP.mjs.map +0 -1
- package/dist/chunk-IJX3CXOY.js +0 -9
- package/dist/chunk-IJX3CXOY.js.map +0 -1
- package/dist/chunk-IPUL74MZ.mjs +0 -30
- package/dist/chunk-IPUL74MZ.mjs.map +0 -1
- package/dist/chunk-IV3FSWZ7.mjs +0 -9
- package/dist/chunk-IV3FSWZ7.mjs.map +0 -1
- package/dist/chunk-IVDERT5W.js +0 -22
- package/dist/chunk-IVDERT5W.js.map +0 -1
- package/dist/chunk-JETPRED3.js +0 -248
- package/dist/chunk-JETPRED3.js.map +0 -1
- package/dist/chunk-JI5NQ2C3.mjs +0 -1
- package/dist/chunk-JI5NQ2C3.mjs.map +0 -1
- package/dist/chunk-JJTIVHFX.mjs +0 -38
- package/dist/chunk-JJTIVHFX.mjs.map +0 -1
- package/dist/chunk-L2DHOOBX.js +0 -33
- package/dist/chunk-L2DHOOBX.js.map +0 -1
- package/dist/chunk-LEKZPKS2.js +0 -21
- package/dist/chunk-LEKZPKS2.js.map +0 -1
- package/dist/chunk-LHQP7CUJ.mjs +0 -107
- package/dist/chunk-LHQP7CUJ.mjs.map +0 -1
- package/dist/chunk-LOJA2ZS4.js +0 -107
- package/dist/chunk-LOJA2ZS4.js.map +0 -1
- package/dist/chunk-LQSEBGOX.js +0 -34
- package/dist/chunk-LQSEBGOX.js.map +0 -1
- package/dist/chunk-MDOG3S4V.mjs +0 -34
- package/dist/chunk-MDOG3S4V.mjs.map +0 -1
- package/dist/chunk-MFGLB75H.mjs +0 -22
- package/dist/chunk-MFGLB75H.mjs.map +0 -1
- package/dist/chunk-MKFQAXRF.js +0 -21
- package/dist/chunk-MKFQAXRF.js.map +0 -1
- package/dist/chunk-MQURBEO4.mjs +0 -16
- package/dist/chunk-MQURBEO4.mjs.map +0 -1
- package/dist/chunk-MWAZGSRO.js +0 -75
- package/dist/chunk-MWAZGSRO.js.map +0 -1
- package/dist/chunk-N2JAYIUP.mjs +0 -75
- package/dist/chunk-N2JAYIUP.mjs.map +0 -1
- package/dist/chunk-N4MA537G.js +0 -22
- package/dist/chunk-N4MA537G.js.map +0 -1
- package/dist/chunk-N5HVDE3P.mjs +0 -30
- package/dist/chunk-N5HVDE3P.mjs.map +0 -1
- package/dist/chunk-N722KRZW.js +0 -41
- package/dist/chunk-N722KRZW.js.map +0 -1
- package/dist/chunk-NNYGTNHP.mjs +0 -1
- package/dist/chunk-NNYGTNHP.mjs.map +0 -1
- package/dist/chunk-NSVVZNSD.mjs +0 -183
- package/dist/chunk-NSVVZNSD.mjs.map +0 -1
- package/dist/chunk-NUCLSR2G.js +0 -8
- package/dist/chunk-NUCLSR2G.js.map +0 -1
- package/dist/chunk-OBN2WDFU.js +0 -38
- package/dist/chunk-OBN2WDFU.js.map +0 -1
- package/dist/chunk-P252LKUT.mjs +0 -9
- package/dist/chunk-P252LKUT.mjs.map +0 -1
- package/dist/chunk-PAOTMYIM.mjs +0 -69
- package/dist/chunk-PAOTMYIM.mjs.map +0 -1
- package/dist/chunk-PJMEJVOB.mjs +0 -29
- package/dist/chunk-PJMEJVOB.mjs.map +0 -1
- package/dist/chunk-PLBSSUVY.js +0 -29
- package/dist/chunk-PLBSSUVY.js.map +0 -1
- package/dist/chunk-PLNIERDY.js +0 -34
- package/dist/chunk-PLNIERDY.js.map +0 -1
- package/dist/chunk-PO5BBHHX.mjs +0 -22
- package/dist/chunk-PO5BBHHX.mjs.map +0 -1
- package/dist/chunk-PTOH2SVI.mjs +0 -55
- package/dist/chunk-PTOH2SVI.mjs.map +0 -1
- package/dist/chunk-PZF4KWU2.mjs +0 -151
- package/dist/chunk-PZF4KWU2.mjs.map +0 -1
- package/dist/chunk-QD3LTING.js +0 -34
- package/dist/chunk-QD3LTING.js.map +0 -1
- package/dist/chunk-QGCNQRIQ.js +0 -35
- package/dist/chunk-QGCNQRIQ.js.map +0 -1
- package/dist/chunk-QYPLUMB7.mjs +0 -249
- package/dist/chunk-QYPLUMB7.mjs.map +0 -1
- package/dist/chunk-RAZ7XG4Z.mjs +0 -1
- package/dist/chunk-RAZ7XG4Z.mjs.map +0 -1
- package/dist/chunk-RNMJQSVQ.js +0 -69
- package/dist/chunk-RNMJQSVQ.js.map +0 -1
- package/dist/chunk-RRFKK45V.mjs +0 -15
- package/dist/chunk-RRFKK45V.mjs.map +0 -1
- package/dist/chunk-S3BWTUTZ.js +0 -31
- package/dist/chunk-S3BWTUTZ.js.map +0 -1
- package/dist/chunk-SKKANJ45.mjs +0 -19
- package/dist/chunk-SKKANJ45.mjs.map +0 -1
- package/dist/chunk-SPCIIRSB.mjs +0 -7
- package/dist/chunk-SPCIIRSB.mjs.map +0 -1
- package/dist/chunk-SRMDDOVO.mjs +0 -20
- package/dist/chunk-SRMDDOVO.mjs.map +0 -1
- package/dist/chunk-SYYDKPK3.js +0 -15
- package/dist/chunk-SYYDKPK3.js.map +0 -1
- package/dist/chunk-T2VA4YJE.js +0 -104
- package/dist/chunk-T2VA4YJE.js.map +0 -1
- package/dist/chunk-T3VM5YXY.js +0 -1
- package/dist/chunk-T3VM5YXY.js.map +0 -1
- package/dist/chunk-T3YY4JIJ.js +0 -9
- package/dist/chunk-T3YY4JIJ.js.map +0 -1
- package/dist/chunk-T5ZOOZ46.js +0 -22
- package/dist/chunk-T5ZOOZ46.js.map +0 -1
- package/dist/chunk-TAMKWZ4E.js +0 -183
- package/dist/chunk-TAMKWZ4E.js.map +0 -1
- package/dist/chunk-TFP64TMV.js +0 -1
- package/dist/chunk-TFP64TMV.js.map +0 -1
- package/dist/chunk-TYWGZIOF.mjs +0 -34
- package/dist/chunk-TYWGZIOF.mjs.map +0 -1
- package/dist/chunk-UAINMOUU.js +0 -18
- package/dist/chunk-UAINMOUU.js.map +0 -1
- package/dist/chunk-UNNEBOL4.mjs +0 -15
- package/dist/chunk-UNNEBOL4.mjs.map +0 -1
- package/dist/chunk-UW74NLTC.mjs +0 -18
- package/dist/chunk-UW74NLTC.mjs.map +0 -1
- package/dist/chunk-VBYSWMSU.js +0 -66
- package/dist/chunk-VBYSWMSU.js.map +0 -1
- package/dist/chunk-VEPYH26P.js +0 -27
- package/dist/chunk-VEPYH26P.js.map +0 -1
- package/dist/chunk-VIAHMNTA.mjs +0 -34
- package/dist/chunk-VIAHMNTA.mjs.map +0 -1
- package/dist/chunk-VWLBM7XM.js +0 -1
- package/dist/chunk-VWLBM7XM.js.map +0 -1
- package/dist/chunk-W7A3BYUP.mjs +0 -1
- package/dist/chunk-W7A3BYUP.mjs.map +0 -1
- package/dist/chunk-W7KRIAIX.js +0 -55
- package/dist/chunk-W7KRIAIX.js.map +0 -1
- package/dist/chunk-X2GGUOMY.js +0 -153
- package/dist/chunk-X2GGUOMY.js.map +0 -1
- package/dist/chunk-X3UZCGO5.mjs +0 -103
- package/dist/chunk-X3UZCGO5.mjs.map +0 -1
- package/dist/chunk-XF2AZMWG.mjs +0 -32
- package/dist/chunk-XF2AZMWG.mjs.map +0 -1
- package/dist/chunk-XWYJQWHG.js +0 -56
- package/dist/chunk-XWYJQWHG.js.map +0 -1
- package/dist/chunk-XZ7362GQ.mjs +0 -63
- package/dist/chunk-XZ7362GQ.mjs.map +0 -1
- package/dist/chunk-XZNJFDBF.mjs +0 -21
- package/dist/chunk-XZNJFDBF.mjs.map +0 -1
- package/dist/chunk-YJHQZFR4.mjs +0 -71
- package/dist/chunk-YJHQZFR4.mjs.map +0 -1
- package/dist/chunk-YL2EHYAA.js +0 -16
- package/dist/chunk-YL2EHYAA.js.map +0 -1
- package/dist/chunk-Z2JQNSVL.mjs +0 -8
- package/dist/chunk-Z2JQNSVL.mjs.map +0 -1
- package/dist/chunk-ZT3KKTS2.js +0 -9
- package/dist/chunk-ZT3KKTS2.js.map +0 -1
- package/dist/constants.js +0 -8
- package/dist/constants.js.map +0 -1
- package/dist/cronjob.js +0 -20
- package/dist/cronjob.js.map +0 -1
- package/dist/deep-clone.js +0 -8
- package/dist/deep-clone.js.map +0 -1
- package/dist/default-endowments.js +0 -8
- package/dist/default-endowments.js.map +0 -1
- package/dist/derivation-paths.js +0 -13
- package/dist/derivation-paths.js.map +0 -1
- package/dist/entropy.js +0 -10
- package/dist/entropy.js.map +0 -1
- package/dist/errors.js +0 -20
- package/dist/errors.js.map +0 -1
- package/dist/eval-worker.js +0 -43
- package/dist/eval-worker.js.map +0 -1
- package/dist/eval.js +0 -17
- package/dist/eval.js.map +0 -1
- package/dist/fs.js +0 -28
- package/dist/fs.js.map +0 -1
- package/dist/handler-types.js +0 -10
- package/dist/handler-types.js.map +0 -1
- package/dist/handlers.js +0 -35
- package/dist/handlers.js.map +0 -1
- package/dist/icon.js +0 -15
- package/dist/icon.js.map +0 -1
- package/dist/iframe.js +0 -8
- package/dist/iframe.js.map +0 -1
- package/dist/index.executionenv.js +0 -128
- package/dist/index.executionenv.js.map +0 -1
- package/dist/index.js +0 -398
- package/dist/index.js.map +0 -1
- package/dist/json-rpc.js +0 -18
- package/dist/json-rpc.js.map +0 -1
- package/dist/json.js +0 -10
- package/dist/json.js.map +0 -1
- package/dist/localization.js +0 -23
- package/dist/localization.js.map +0 -1
- package/dist/logging.js +0 -14
- package/dist/logging.js.map +0 -1
- package/dist/manifest/index.js +0 -65
- package/dist/manifest/index.js.map +0 -1
- package/dist/manifest/manifest.js +0 -59
- package/dist/manifest/manifest.js.map +0 -1
- package/dist/manifest/node.js +0 -106
- package/dist/manifest/node.js.map +0 -1
- package/dist/manifest/validation.js +0 -64
- package/dist/manifest/validation.js.map +0 -1
- package/dist/manifest/validator-types.js +0 -1
- package/dist/manifest/validator-types.js.map +0 -1
- package/dist/manifest/validator.js +0 -44
- package/dist/manifest/validator.js.map +0 -1
- package/dist/manifest/validators/checksum.js +0 -15
- package/dist/manifest/validators/checksum.js.map +0 -1
- package/dist/manifest/validators/expected-files.js +0 -9
- package/dist/manifest/validators/expected-files.js.map +0 -1
- package/dist/manifest/validators/icon-declared.js +0 -8
- package/dist/manifest/validators/icon-declared.js.map +0 -1
- package/dist/manifest/validators/icon-dimensions.js +0 -10
- package/dist/manifest/validators/icon-dimensions.js.map +0 -1
- package/dist/manifest/validators/icon-missing.js +0 -8
- package/dist/manifest/validators/icon-missing.js.map +0 -1
- package/dist/manifest/validators/index.js +0 -80
- package/dist/manifest/validators/index.js.map +0 -1
- package/dist/manifest/validators/is-localization-file.js +0 -12
- package/dist/manifest/validators/is-localization-file.js.map +0 -1
- package/dist/manifest/validators/is-package-json.js +0 -11
- package/dist/manifest/validators/is-package-json.js.map +0 -1
- package/dist/manifest/validators/is-snap-icon.js +0 -10
- package/dist/manifest/validators/is-snap-icon.js.map +0 -1
- package/dist/manifest/validators/is-snap-manifest.js +0 -23
- package/dist/manifest/validators/is-snap-manifest.js.map +0 -1
- package/dist/manifest/validators/manifest-localization.js +0 -10
- package/dist/manifest/validators/manifest-localization.js.map +0 -1
- package/dist/manifest/validators/package-json-recommended-fields.js +0 -8
- package/dist/manifest/validators/package-json-recommended-fields.js.map +0 -1
- package/dist/manifest/validators/package-name-match.js +0 -9
- package/dist/manifest/validators/package-name-match.js.map +0 -1
- package/dist/manifest/validators/repository-match.js +0 -10
- package/dist/manifest/validators/repository-match.js.map +0 -1
- package/dist/manifest/validators/version-match.js +0 -9
- package/dist/manifest/validators/version-match.js.map +0 -1
- package/dist/mock.js +0 -13
- package/dist/mock.js.map +0 -1
- package/dist/namespace.js +0 -44
- package/dist/namespace.js.map +0 -1
- package/dist/node.js +0 -476
- package/dist/node.js.map +0 -1
- package/dist/path.js +0 -8
- package/dist/path.js.map +0 -1
- package/dist/post-process.js +0 -10
- package/dist/post-process.js.map +0 -1
- package/dist/promise.js +0 -2
- package/dist/promise.js.map +0 -1
- package/dist/snaps.js +0 -46
- package/dist/snaps.js.map +0 -1
- package/dist/strings.js +0 -8
- package/dist/strings.js.map +0 -1
- package/dist/structs.js +0 -33
- package/dist/structs.js.map +0 -1
- package/dist/svg.js +0 -10
- package/dist/svg.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/array.d.ts +0 -10
- package/dist/types/auxiliary-files.d.ts +0 -16
- package/dist/types/base64.d.ts +0 -15
- package/dist/types/bytes.d.ts +0 -8
- package/dist/types/caveats.d.ts +0 -46
- package/dist/types/checksum.d.ts +0 -21
- package/dist/types/constants.d.ts +0 -1
- package/dist/types/cronjob.d.ts +0 -89
- package/dist/types/deep-clone.d.ts +0 -1
- package/dist/types/default-endowments.d.ts +0 -4
- package/dist/types/derivation-paths.d.ts +0 -24
- package/dist/types/entropy.d.ts +0 -3
- package/dist/types/errors.d.ts +0 -84
- package/dist/types/eval-worker.d.ts +0 -1
- package/dist/types/eval.d.ts +0 -16
- package/dist/types/fs.d.ts +0 -69
- package/dist/types/handler-types.d.ts +0 -34
- package/dist/types/handlers.d.ts +0 -749
- package/dist/types/icon.d.ts +0 -19
- package/dist/types/iframe.d.ts +0 -11
- package/dist/types/iframe.test.browser.d.ts +0 -1
- package/dist/types/index.d.ts +0 -32
- package/dist/types/index.executionenv.d.ts +0 -7
- package/dist/types/json-rpc.d.ts +0 -55
- package/dist/types/json.d.ts +0 -22
- package/dist/types/localization.d.ts +0 -145
- package/dist/types/logging.d.ts +0 -49
- package/dist/types/manifest/index.d.ts +0 -1
- package/dist/types/manifest/manifest.d.ts +0 -98
- package/dist/types/manifest/node.d.ts +0 -2
- package/dist/types/manifest/validation.d.ts +0 -253
- package/dist/types/manifest/validator-types.d.ts +0 -34
- package/dist/types/manifest/validator.d.ts +0 -22
- package/dist/types/manifest/validators/checksum.d.ts +0 -5
- package/dist/types/manifest/validators/expected-files.d.ts +0 -5
- package/dist/types/manifest/validators/icon-declared.d.ts +0 -5
- package/dist/types/manifest/validators/icon-dimensions.d.ts +0 -5
- package/dist/types/manifest/validators/icon-missing.d.ts +0 -5
- package/dist/types/manifest/validators/index.d.ts +0 -14
- package/dist/types/manifest/validators/is-localization-file.d.ts +0 -5
- package/dist/types/manifest/validators/is-package-json.d.ts +0 -5
- package/dist/types/manifest/validators/is-snap-icon.d.ts +0 -5
- package/dist/types/manifest/validators/is-snap-manifest.d.ts +0 -5
- package/dist/types/manifest/validators/manifest-localization.d.ts +0 -5
- package/dist/types/manifest/validators/package-json-recommended-fields.d.ts +0 -5
- package/dist/types/manifest/validators/package-name-match.d.ts +0 -5
- package/dist/types/manifest/validators/repository-match.d.ts +0 -5
- package/dist/types/manifest/validators/version-match.d.ts +0 -5
- package/dist/types/mock.d.ts +0 -14
- package/dist/types/namespace.d.ts +0 -129
- package/dist/types/node.d.ts +0 -7
- package/dist/types/path.d.ts +0 -7
- package/dist/types/post-process.d.ts +0 -71
- package/dist/types/promise.d.ts +0 -1
- package/dist/types/snaps.d.ts +0 -169
- package/dist/types/strings.d.ts +0 -8
- package/dist/types/structs.d.ts +0 -180
- package/dist/types/svg.d.ts +0 -14
- package/dist/types/types.d.ts +0 -103
- package/dist/types/ui.d.ts +0 -84
- package/dist/types/validation.d.ts +0 -8
- package/dist/types/versions.d.ts +0 -21
- package/dist/types/virtual-file/VirtualFile.d.ts +0 -34
- package/dist/types/virtual-file/index.d.ts +0 -1
- package/dist/types/virtual-file/node.d.ts +0 -2
- package/dist/types/virtual-file/toVirtualFile.d.ts +0 -21
- package/dist/types.js +0 -22
- package/dist/types.js.map +0 -1
- package/dist/ui.js +0 -24
- package/dist/ui.js.map +0 -1
- package/dist/validation.js +0 -27
- package/dist/validation.js.map +0 -1
- package/dist/versions.js +0 -12
- package/dist/versions.js.map +0 -1
- package/dist/virtual-file/VirtualFile.js +0 -9
- package/dist/virtual-file/VirtualFile.js.map +0 -1
- package/dist/virtual-file/index.js +0 -10
- package/dist/virtual-file/index.js.map +0 -1
- package/dist/virtual-file/node.js +0 -17
- package/dist/virtual-file/node.js.map +0 -1
- package/dist/virtual-file/toVirtualFile.js +0 -12
- package/dist/virtual-file/toVirtualFile.js.map +0 -1
package/dist/ui.mjs
CHANGED
|
@@ -1,24 +1,392 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
1
|
+
import { jsx as _jsx } from "@metamask/snaps-sdk/jsx-runtime";
|
|
2
|
+
import { NodeType } from "@metamask/snaps-sdk";
|
|
3
|
+
import { Italic, Link, Bold, Row, Text, Field, Image, Input, Heading, Form, Divider, Spinner, Copyable, Box, Button, Address } from "@metamask/snaps-sdk/jsx";
|
|
4
|
+
import { assert, assertExhaustive, hasProperty, isPlainObject } from "@metamask/utils";
|
|
5
|
+
import { lexer, walkTokens } from "marked";
|
|
6
|
+
const MAX_TEXT_LENGTH = 50000; // 50 kb
|
|
7
|
+
const ALLOWED_PROTOCOLS = ['https:', 'mailto:'];
|
|
8
|
+
/**
|
|
9
|
+
* Get the button variant from a legacy button component variant.
|
|
10
|
+
*
|
|
11
|
+
* @param variant - The legacy button component variant.
|
|
12
|
+
* @returns The button variant.
|
|
13
|
+
*/
|
|
14
|
+
function getButtonVariant(variant) {
|
|
15
|
+
switch (variant) {
|
|
16
|
+
case 'primary':
|
|
17
|
+
return 'primary';
|
|
18
|
+
case 'secondary':
|
|
19
|
+
return 'destructive';
|
|
20
|
+
default:
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get the children of a JSX element. If there is only one child, the child is
|
|
26
|
+
* returned directly. Otherwise, the children are returned as an array.
|
|
27
|
+
*
|
|
28
|
+
* @param elements - The JSX elements.
|
|
29
|
+
* @returns The child or children.
|
|
30
|
+
*/
|
|
31
|
+
function getChildren(elements) {
|
|
32
|
+
if (elements.length === 1) {
|
|
33
|
+
return elements[0];
|
|
34
|
+
}
|
|
35
|
+
return elements;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get the text of a link token.
|
|
39
|
+
*
|
|
40
|
+
* @param token - The link token.
|
|
41
|
+
* @returns The text of the link token.
|
|
42
|
+
*/
|
|
43
|
+
function getLinkText(token) {
|
|
44
|
+
if (token.tokens && token.tokens.length > 0) {
|
|
45
|
+
return getChildren(token.tokens.flatMap(getTextChildFromToken));
|
|
46
|
+
}
|
|
47
|
+
return token.href;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the text child from a list of markdown tokens.
|
|
51
|
+
*
|
|
52
|
+
* @param tokens - The markdown tokens.
|
|
53
|
+
* @returns The text child.
|
|
54
|
+
*/
|
|
55
|
+
function getTextChildFromTokens(tokens) {
|
|
56
|
+
return getChildren(tokens.flatMap(getTextChildFromToken));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get the text child from a markdown token.
|
|
60
|
+
*
|
|
61
|
+
* @param token - The markdown token.
|
|
62
|
+
* @returns The text child.
|
|
63
|
+
*/
|
|
64
|
+
function getTextChildFromToken(token) {
|
|
65
|
+
switch (token.type) {
|
|
66
|
+
case 'link': {
|
|
67
|
+
return _jsx(Link, { href: token.href, children: getLinkText(token) });
|
|
68
|
+
}
|
|
69
|
+
case 'text':
|
|
70
|
+
return token.text;
|
|
71
|
+
case 'strong':
|
|
72
|
+
return (_jsx(Bold, { children: getTextChildFromTokens(
|
|
73
|
+
// Due to the way `marked` is typed, `token.tokens` can be
|
|
74
|
+
// `undefined`, but it's a required field of `Tokens.Bold`, so we
|
|
75
|
+
// can safely cast it to `Token[]`.
|
|
76
|
+
token.tokens) }));
|
|
77
|
+
case 'em':
|
|
78
|
+
return (_jsx(Italic, { children: getTextChildFromTokens(
|
|
79
|
+
// Due to the way `marked` is typed, `token.tokens` can be
|
|
80
|
+
// `undefined`, but it's a required field of `Tokens.Bold`, so we
|
|
81
|
+
// can safely cast it to `Token[]`.
|
|
82
|
+
token.tokens) }));
|
|
83
|
+
default:
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get all text children from a markdown string.
|
|
89
|
+
*
|
|
90
|
+
* @param value - The markdown string.
|
|
91
|
+
* @returns The text children.
|
|
92
|
+
*/
|
|
93
|
+
export function getTextChildren(value) {
|
|
94
|
+
const rootTokens = lexer(value, { gfm: false });
|
|
95
|
+
const children = [];
|
|
96
|
+
walkTokens(rootTokens, (token) => {
|
|
97
|
+
if (token.type === 'paragraph') {
|
|
98
|
+
if (children.length > 0) {
|
|
99
|
+
children.push('\n\n');
|
|
100
|
+
}
|
|
101
|
+
const { tokens } = token;
|
|
102
|
+
// We do not need to consider nesting deeper than 1 level here and we can therefore cast.
|
|
103
|
+
children.push(...tokens.flatMap(getTextChildFromToken));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
107
|
+
return children.filter((child) => child !== null);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Validate the text size of a component. The text size is the total length of
|
|
111
|
+
* all text in the component.
|
|
112
|
+
*
|
|
113
|
+
* @param component - The component to validate.
|
|
114
|
+
* @throws An error if the text size exceeds the maximum allowed size.
|
|
115
|
+
*/
|
|
116
|
+
function validateComponentTextSize(component) {
|
|
117
|
+
const textSize = getTotalTextLength(component);
|
|
118
|
+
assert(textSize <= MAX_TEXT_LENGTH, `The text in a Snap UI may not be larger than ${MAX_TEXT_LENGTH / 1000} kB.`);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get a JSX element from a legacy UI component. This supports all legacy UI
|
|
122
|
+
* components, and maps them to their JSX equivalents where possible.
|
|
123
|
+
*
|
|
124
|
+
* This function validates the text size of the component, but does not validate
|
|
125
|
+
* the total size. The total size of the component should be validated before
|
|
126
|
+
* calling this function.
|
|
127
|
+
*
|
|
128
|
+
* @param legacyComponent - The legacy UI component.
|
|
129
|
+
* @returns The JSX element.
|
|
130
|
+
*/
|
|
131
|
+
export function getJsxElementFromComponent(legacyComponent) {
|
|
132
|
+
validateComponentTextSize(legacyComponent);
|
|
133
|
+
/**
|
|
134
|
+
* Get the JSX element for a component. This function is recursive and will
|
|
135
|
+
* call itself for child components.
|
|
136
|
+
*
|
|
137
|
+
* @param component - The component to convert to a JSX element.
|
|
138
|
+
* @returns The JSX element.
|
|
139
|
+
*/
|
|
140
|
+
function getElement(component) {
|
|
141
|
+
switch (component.type) {
|
|
142
|
+
case NodeType.Address:
|
|
143
|
+
return _jsx(Address, { address: component.value });
|
|
144
|
+
case NodeType.Button:
|
|
145
|
+
return (_jsx(Button, { name: component.name, variant: getButtonVariant(component.variant), type: component.buttonType, children: component.value }));
|
|
146
|
+
case NodeType.Copyable:
|
|
147
|
+
return (_jsx(Copyable, { value: component.value, sensitive: component.sensitive }));
|
|
148
|
+
case NodeType.Divider:
|
|
149
|
+
return _jsx(Divider, {});
|
|
150
|
+
case NodeType.Form:
|
|
151
|
+
return (_jsx(Form, { name: component.name, children: getChildren(component.children.map(getElement)) }));
|
|
152
|
+
case NodeType.Heading:
|
|
153
|
+
return _jsx(Heading, { children: component.value });
|
|
154
|
+
case NodeType.Image:
|
|
155
|
+
// `Image` supports `alt`, but the legacy `Image` component does not.
|
|
156
|
+
return _jsx(Image, { src: component.value });
|
|
157
|
+
case NodeType.Input:
|
|
158
|
+
return (_jsx(Field, { label: component.label, error: component.error, children: _jsx(Input, { name: component.name, type: component.inputType, value: component.value, placeholder: component.placeholder }) }));
|
|
159
|
+
case NodeType.Panel:
|
|
160
|
+
// `Panel` is renamed to `Box` in JSX.
|
|
161
|
+
return (_jsx(Box, { children: getChildren(component.children.map(getElement)) }));
|
|
162
|
+
case NodeType.Row:
|
|
163
|
+
return (_jsx(Row, { label: component.label, variant: component.variant, children: getElement(component.value) }));
|
|
164
|
+
case NodeType.Spinner:
|
|
165
|
+
return _jsx(Spinner, {});
|
|
166
|
+
case NodeType.Text:
|
|
167
|
+
return _jsx(Text, { children: getChildren(getTextChildren(component.value)) });
|
|
168
|
+
/* istanbul ignore next 2 */
|
|
169
|
+
default:
|
|
170
|
+
return assertExhaustive(component);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return getElement(legacyComponent);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Extract all links from a Markdown text string using the `marked` lexer.
|
|
177
|
+
*
|
|
178
|
+
* @param text - The markdown text string.
|
|
179
|
+
* @returns A list of URLs linked to in the string.
|
|
180
|
+
*/
|
|
181
|
+
function getMarkdownLinks(text) {
|
|
182
|
+
const tokens = lexer(text, { gfm: false });
|
|
183
|
+
const links = [];
|
|
184
|
+
// Walk the lexed tokens and collect all link tokens
|
|
185
|
+
walkTokens(tokens, (token) => {
|
|
186
|
+
if (token.type === 'link') {
|
|
187
|
+
links.push(token);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return links;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Validate a link against the phishing list.
|
|
194
|
+
*
|
|
195
|
+
* @param link - The link to validate.
|
|
196
|
+
* @param isOnPhishingList - The function that checks the link against the
|
|
197
|
+
* phishing list.
|
|
198
|
+
*/
|
|
199
|
+
export function validateLink(link, isOnPhishingList) {
|
|
200
|
+
try {
|
|
201
|
+
const url = new URL(link);
|
|
202
|
+
assert(ALLOWED_PROTOCOLS.includes(url.protocol), `Protocol must be one of: ${ALLOWED_PROTOCOLS.join(', ')}.`);
|
|
203
|
+
const hostname = url.protocol === 'mailto:' ? url.pathname.split('@')[1] : url.hostname;
|
|
204
|
+
assert(!isOnPhishingList(hostname), 'The specified URL is not allowed.');
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
throw new Error(`Invalid URL: ${error?.code === 'ERR_ASSERTION' ? error.message : 'Unable to parse URL.'}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Search for Markdown links in a string and checks them against the phishing
|
|
212
|
+
* list.
|
|
213
|
+
*
|
|
214
|
+
* @param text - The text to verify.
|
|
215
|
+
* @param isOnPhishingList - The function that checks the link against the
|
|
216
|
+
* phishing list.
|
|
217
|
+
* @throws If the text contains a link that is not allowed.
|
|
218
|
+
*/
|
|
219
|
+
export function validateTextLinks(text, isOnPhishingList) {
|
|
220
|
+
const links = getMarkdownLinks(text);
|
|
221
|
+
for (const link of links) {
|
|
222
|
+
validateLink(link.href, isOnPhishingList);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Walk a JSX tree and validate each {@link LinkElement} node against the
|
|
227
|
+
* phishing list.
|
|
228
|
+
*
|
|
229
|
+
* @param node - The JSX node to walk.
|
|
230
|
+
* @param isOnPhishingList - The function that checks the link against the
|
|
231
|
+
* phishing list.
|
|
232
|
+
*/
|
|
233
|
+
export function validateJsxLinks(node, isOnPhishingList) {
|
|
234
|
+
walkJsx(node, (childNode) => {
|
|
235
|
+
if (childNode.type !== 'Link') {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
validateLink(childNode.props.href, isOnPhishingList);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Calculate the total length of all text in the component.
|
|
243
|
+
*
|
|
244
|
+
* @param component - A custom UI component.
|
|
245
|
+
* @returns The total length of all text components in the component.
|
|
246
|
+
*/
|
|
247
|
+
export function getTotalTextLength(component) {
|
|
248
|
+
const { type } = component;
|
|
249
|
+
switch (type) {
|
|
250
|
+
case NodeType.Panel:
|
|
251
|
+
return component.children.reduce(
|
|
252
|
+
// This is a bug in TypeScript: https://github.com/microsoft/TypeScript/issues/48313
|
|
253
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
254
|
+
(sum, node) => sum + getTotalTextLength(node), 0);
|
|
255
|
+
case NodeType.Row:
|
|
256
|
+
return getTotalTextLength(component.value);
|
|
257
|
+
case NodeType.Text:
|
|
258
|
+
return component.value.length;
|
|
259
|
+
default:
|
|
260
|
+
return 0;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Check if a JSX element has children.
|
|
265
|
+
*
|
|
266
|
+
* @param element - A JSX element.
|
|
267
|
+
* @returns `true` if the element has children, `false` otherwise.
|
|
268
|
+
*/
|
|
269
|
+
export function hasChildren(element) {
|
|
270
|
+
return hasProperty(element.props, 'children');
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Filter a JSX child to remove `null`, `undefined`, plain booleans, and empty
|
|
274
|
+
* strings.
|
|
275
|
+
*
|
|
276
|
+
* @param child - The JSX child to filter.
|
|
277
|
+
* @returns `true` if the child is not `null`, `undefined`, a plain boolean, or
|
|
278
|
+
* an empty string, `false` otherwise.
|
|
279
|
+
*/
|
|
280
|
+
function filterJsxChild(child) {
|
|
281
|
+
return Boolean(child) && child !== true;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Get the children of a JSX element as an array. If the element has only one
|
|
285
|
+
* child, the child is returned as an array.
|
|
286
|
+
*
|
|
287
|
+
* @param element - A JSX element.
|
|
288
|
+
* @returns The children of the element.
|
|
289
|
+
*/
|
|
290
|
+
export function getJsxChildren(element) {
|
|
291
|
+
if (hasChildren(element)) {
|
|
292
|
+
if (Array.isArray(element.props.children)) {
|
|
293
|
+
// @ts-expect-error - Each member of the union type has signatures, but
|
|
294
|
+
// none of those signatures are compatible with each other.
|
|
295
|
+
return element.props.children.filter(filterJsxChild).flat(Infinity);
|
|
296
|
+
}
|
|
297
|
+
if (element.props.children) {
|
|
298
|
+
return [element.props.children];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return [];
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Walk a JSX tree and call a callback on each node.
|
|
305
|
+
*
|
|
306
|
+
* @param node - The JSX node to walk.
|
|
307
|
+
* @param callback - The callback to call on each node.
|
|
308
|
+
* @param depth - The current depth in the JSX tree for a walk.
|
|
309
|
+
* @returns The result of the callback, if any.
|
|
310
|
+
*/
|
|
311
|
+
export function walkJsx(node, callback, depth = 0) {
|
|
312
|
+
if (Array.isArray(node)) {
|
|
313
|
+
for (const child of node) {
|
|
314
|
+
const childResult = walkJsx(child, callback, depth);
|
|
315
|
+
if (childResult !== undefined) {
|
|
316
|
+
return childResult;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return undefined;
|
|
320
|
+
}
|
|
321
|
+
const result = callback(node, depth);
|
|
322
|
+
if (result !== undefined) {
|
|
323
|
+
return result;
|
|
324
|
+
}
|
|
325
|
+
if (hasProperty(node, 'props') &&
|
|
326
|
+
isPlainObject(node.props) &&
|
|
327
|
+
hasProperty(node.props, 'children')) {
|
|
328
|
+
const children = getJsxChildren(node);
|
|
329
|
+
for (const child of children) {
|
|
330
|
+
if (isPlainObject(child)) {
|
|
331
|
+
const childResult = walkJsx(child, callback, depth + 1);
|
|
332
|
+
if (childResult !== undefined) {
|
|
333
|
+
return childResult;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return undefined;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Serialise a JSX prop to a string.
|
|
342
|
+
*
|
|
343
|
+
* @param prop - The JSX prop.
|
|
344
|
+
* @returns The serialised JSX prop.
|
|
345
|
+
*/
|
|
346
|
+
function serialiseProp(prop) {
|
|
347
|
+
if (typeof prop === 'string') {
|
|
348
|
+
return `"${prop}"`;
|
|
349
|
+
}
|
|
350
|
+
return `{${JSON.stringify(prop)}}`;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Serialise JSX props to a string.
|
|
354
|
+
*
|
|
355
|
+
* @param props - The JSX props.
|
|
356
|
+
* @returns The serialised JSX props.
|
|
357
|
+
*/
|
|
358
|
+
function serialiseProps(props) {
|
|
359
|
+
return Object.entries(props)
|
|
360
|
+
.filter(([key]) => key !== 'children')
|
|
361
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
362
|
+
.map(([key, value]) => ` ${key}=${serialiseProp(value)}`)
|
|
363
|
+
.join('');
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Serialise a JSX node to a string.
|
|
367
|
+
*
|
|
368
|
+
* @param node - The JSX node.
|
|
369
|
+
* @param indentation - The indentation level. Defaults to `0`. This should not
|
|
370
|
+
* be set by the caller, as it is used for recursion.
|
|
371
|
+
* @returns The serialised JSX node.
|
|
372
|
+
*/
|
|
373
|
+
export function serialiseJsx(node, indentation = 0) {
|
|
374
|
+
if (Array.isArray(node)) {
|
|
375
|
+
return node.map((child) => serialiseJsx(child, indentation)).join('');
|
|
376
|
+
}
|
|
377
|
+
const indent = ' '.repeat(indentation);
|
|
378
|
+
if (typeof node === 'string') {
|
|
379
|
+
return `${indent}${node}\n`;
|
|
380
|
+
}
|
|
381
|
+
if (!node) {
|
|
382
|
+
return '';
|
|
383
|
+
}
|
|
384
|
+
const { type, props } = node;
|
|
385
|
+
const trailingNewline = indentation > 0 ? '\n' : '';
|
|
386
|
+
if (hasProperty(props, 'children')) {
|
|
387
|
+
const children = serialiseJsx(props.children, indentation + 1);
|
|
388
|
+
return `${indent}<${type}${serialiseProps(props)}>\n${children}${indent}</${type}>${trailingNewline}`;
|
|
389
|
+
}
|
|
390
|
+
return `${indent}<${type}${serialiseProps(props)} />${trailingNewline}`;
|
|
391
|
+
}
|
|
24
392
|
//# sourceMappingURL=ui.mjs.map
|
package/dist/ui.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sour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,EAAE,CAAC;IACzD,CAAC;IAED,OAAO,GAAG,MAAM,IAAI,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,eAAe,EAAE,CAAC;AAC1E,CAAC","sourcesContent":["import type { Component } from '@metamask/snaps-sdk';\nimport { NodeType } from '@metamask/snaps-sdk';\nimport type {\n BoldChildren,\n GenericSnapElement,\n ItalicChildren,\n JSXElement,\n LinkElement,\n Nestable,\n RowChildren,\n SnapNode,\n StandardFormattingElement,\n TextChildren,\n} from '@metamask/snaps-sdk/jsx';\nimport {\n Italic,\n Link,\n Bold,\n Row,\n Text,\n Field,\n Image,\n Input,\n Heading,\n Form,\n Divider,\n Spinner,\n Copyable,\n Box,\n Button,\n Address,\n} from '@metamask/snaps-sdk/jsx';\nimport {\n assert,\n assertExhaustive,\n hasProperty,\n isPlainObject,\n} from '@metamask/utils';\nimport { lexer, walkTokens } from 'marked';\nimport type { Token, Tokens } from 'marked';\n\nconst MAX_TEXT_LENGTH = 50_000; // 50 kb\nconst ALLOWED_PROTOCOLS = ['https:', 'mailto:'];\n\n/**\n * Get the button variant from a legacy button component variant.\n *\n * @param variant - The legacy button component variant.\n * @returns The button variant.\n */\nfunction getButtonVariant(variant?: 'primary' | 'secondary' | undefined) {\n switch (variant) {\n case 'primary':\n return 'primary';\n case 'secondary':\n return 'destructive';\n default:\n return undefined;\n }\n}\n\n/**\n * Get the children of a JSX element. If there is only one child, the child is\n * returned directly. Otherwise, the children are returned as an array.\n *\n * @param elements - The JSX elements.\n * @returns The child or children.\n */\nfunction getChildren<Type>(elements: Type[]) {\n if (elements.length === 1) {\n return elements[0];\n }\n\n return elements;\n}\n\n/**\n * Get the text of a link token.\n *\n * @param token - The link token.\n * @returns The text of the link token.\n */\nfunction getLinkText(token: Tokens.Link | Tokens.Generic) {\n if (token.tokens && token.tokens.length > 0) {\n return getChildren(token.tokens.flatMap(getTextChildFromToken));\n }\n\n return token.href;\n}\n\n/**\n * Get the text child from a list of markdown tokens.\n *\n * @param tokens - The markdown tokens.\n * @returns The text child.\n */\nfunction getTextChildFromTokens(tokens: Token[]) {\n return getChildren(tokens.flatMap(getTextChildFromToken));\n}\n\n/**\n * Get the text child from a markdown token.\n *\n * @param token - The markdown token.\n * @returns The text child.\n */\nfunction getTextChildFromToken(token: Token): TextChildren {\n switch (token.type) {\n case 'link': {\n return <Link href={token.href} children={getLinkText(token)} />;\n }\n\n case 'text':\n return token.text;\n\n case 'strong':\n return (\n <Bold>\n {\n getTextChildFromTokens(\n // Due to the way `marked` is typed, `token.tokens` can be\n // `undefined`, but it's a required field of `Tokens.Bold`, so we\n // can safely cast it to `Token[]`.\n token.tokens as Token[],\n ) as BoldChildren\n }\n </Bold>\n );\n\n case 'em':\n return (\n <Italic>\n {\n getTextChildFromTokens(\n // Due to the way `marked` is typed, `token.tokens` can be\n // `undefined`, but it's a required field of `Tokens.Bold`, so we\n // can safely cast it to `Token[]`.\n token.tokens as Token[],\n ) as ItalicChildren\n }\n </Italic>\n );\n\n default:\n return null;\n }\n}\n\n/**\n * Get all text children from a markdown string.\n *\n * @param value - The markdown string.\n * @returns The text children.\n */\nexport function getTextChildren(\n value: string,\n): (string | StandardFormattingElement | LinkElement)[] {\n const rootTokens = lexer(value, { gfm: false });\n const children: (string | StandardFormattingElement | LinkElement | null)[] =\n [];\n\n walkTokens(rootTokens, (token) => {\n if (token.type === 'paragraph') {\n if (children.length > 0) {\n children.push('\\n\\n');\n }\n\n const { tokens } = token as Tokens.Paragraph;\n // We do not need to consider nesting deeper than 1 level here and we can therefore cast.\n children.push(\n ...(tokens.flatMap(getTextChildFromToken) as (\n | string\n | StandardFormattingElement\n | LinkElement\n | null\n )[]),\n );\n }\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return children.filter((child) => child !== null) as (\n | string\n | StandardFormattingElement\n | LinkElement\n )[];\n}\n\n/**\n * Validate the text size of a component. The text size is the total length of\n * all text in the component.\n *\n * @param component - The component to validate.\n * @throws An error if the text size exceeds the maximum allowed size.\n */\nfunction validateComponentTextSize(component: Component) {\n const textSize = getTotalTextLength(component);\n assert(\n textSize <= MAX_TEXT_LENGTH,\n `The text in a Snap UI may not be larger than ${\n MAX_TEXT_LENGTH / 1000\n } kB.`,\n );\n}\n\n/**\n * Get a JSX element from a legacy UI component. This supports all legacy UI\n * components, and maps them to their JSX equivalents where possible.\n *\n * This function validates the text size of the component, but does not validate\n * the total size. The total size of the component should be validated before\n * calling this function.\n *\n * @param legacyComponent - The legacy UI component.\n * @returns The JSX element.\n */\nexport function getJsxElementFromComponent(\n legacyComponent: Component,\n): JSXElement {\n validateComponentTextSize(legacyComponent);\n\n /**\n * Get the JSX element for a component. This function is recursive and will\n * call itself for child components.\n *\n * @param component - The component to convert to a JSX element.\n * @returns The JSX element.\n */\n function getElement(component: Component) {\n switch (component.type) {\n case NodeType.Address:\n return <Address address={component.value} />;\n\n case NodeType.Button:\n return (\n <Button\n name={component.name}\n variant={getButtonVariant(component.variant)}\n type={component.buttonType}\n >\n {component.value}\n </Button>\n );\n\n case NodeType.Copyable:\n return (\n <Copyable value={component.value} sensitive={component.sensitive} />\n );\n\n case NodeType.Divider:\n return <Divider />;\n\n case NodeType.Form:\n return (\n <Form name={component.name}>\n {getChildren(component.children.map(getElement))}\n </Form>\n );\n\n case NodeType.Heading:\n return <Heading children={component.value} />;\n\n case NodeType.Image:\n // `Image` supports `alt`, but the legacy `Image` component does not.\n return <Image src={component.value} />;\n\n case NodeType.Input:\n return (\n <Field label={component.label} error={component.error}>\n <Input\n name={component.name}\n type={component.inputType}\n value={component.value}\n placeholder={component.placeholder}\n />\n </Field>\n );\n\n case NodeType.Panel:\n // `Panel` is renamed to `Box` in JSX.\n return (\n <Box children={getChildren(component.children.map(getElement))} />\n );\n\n case NodeType.Row:\n return (\n <Row label={component.label} variant={component.variant}>\n {getElement(component.value) as RowChildren}\n </Row>\n );\n\n case NodeType.Spinner:\n return <Spinner />;\n\n case NodeType.Text:\n return <Text>{getChildren(getTextChildren(component.value))}</Text>;\n\n /* istanbul ignore next 2 */\n default:\n return assertExhaustive(component);\n }\n }\n\n return getElement(legacyComponent);\n}\n\n/**\n * Extract all links from a Markdown text string using the `marked` lexer.\n *\n * @param text - The markdown text string.\n * @returns A list of URLs linked to in the string.\n */\nfunction getMarkdownLinks(text: string) {\n const tokens = lexer(text, { gfm: false });\n const links: Tokens.Link[] = [];\n\n // Walk the lexed tokens and collect all link tokens\n walkTokens(tokens, (token) => {\n if (token.type === 'link') {\n links.push(token as Tokens.Link);\n }\n });\n\n return links;\n}\n\n/**\n * Validate a link against the phishing list.\n *\n * @param link - The link to validate.\n * @param isOnPhishingList - The function that checks the link against the\n * phishing list.\n */\nexport function validateLink(\n link: string,\n isOnPhishingList: (url: string) => boolean,\n) {\n try {\n const url = new URL(link);\n assert(\n ALLOWED_PROTOCOLS.includes(url.protocol),\n `Protocol must be one of: ${ALLOWED_PROTOCOLS.join(', ')}.`,\n );\n\n const hostname =\n url.protocol === 'mailto:' ? url.pathname.split('@')[1] : url.hostname;\n\n assert(!isOnPhishingList(hostname), 'The specified URL is not allowed.');\n } catch (error) {\n throw new Error(\n `Invalid URL: ${\n error?.code === 'ERR_ASSERTION' ? error.message : 'Unable to parse URL.'\n }`,\n );\n }\n}\n\n/**\n * Search for Markdown links in a string and checks them against the phishing\n * list.\n *\n * @param text - The text to verify.\n * @param isOnPhishingList - The function that checks the link against the\n * phishing list.\n * @throws If the text contains a link that is not allowed.\n */\nexport function validateTextLinks(\n text: string,\n isOnPhishingList: (url: string) => boolean,\n) {\n const links = getMarkdownLinks(text);\n\n for (const link of links) {\n validateLink(link.href, isOnPhishingList);\n }\n}\n\n/**\n * Walk a JSX tree and validate each {@link LinkElement} node against the\n * phishing list.\n *\n * @param node - The JSX node to walk.\n * @param isOnPhishingList - The function that checks the link against the\n * phishing list.\n */\nexport function validateJsxLinks(\n node: JSXElement,\n isOnPhishingList: (url: string) => boolean,\n) {\n walkJsx(node, (childNode) => {\n if (childNode.type !== 'Link') {\n return;\n }\n\n validateLink(childNode.props.href, isOnPhishingList);\n });\n}\n\n/**\n * Calculate the total length of all text in the component.\n *\n * @param component - A custom UI component.\n * @returns The total length of all text components in the component.\n */\nexport function getTotalTextLength(component: Component): number {\n const { type } = component;\n\n switch (type) {\n case NodeType.Panel:\n return component.children.reduce<number>(\n // This is a bug in TypeScript: https://github.com/microsoft/TypeScript/issues/48313\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n (sum, node) => sum + getTotalTextLength(node),\n 0,\n );\n\n case NodeType.Row:\n return getTotalTextLength(component.value);\n\n case NodeType.Text:\n return component.value.length;\n\n default:\n return 0;\n }\n}\n\n/**\n * Check if a JSX element has children.\n *\n * @param element - A JSX element.\n * @returns `true` if the element has children, `false` otherwise.\n */\nexport function hasChildren<Element extends JSXElement>(\n element: Element,\n): element is Element & {\n props: { children: Nestable<JSXElement | string> };\n} {\n return hasProperty(element.props, 'children');\n}\n\n/**\n * Filter a JSX child to remove `null`, `undefined`, plain booleans, and empty\n * strings.\n *\n * @param child - The JSX child to filter.\n * @returns `true` if the child is not `null`, `undefined`, a plain boolean, or\n * an empty string, `false` otherwise.\n */\nfunction filterJsxChild(child: JSXElement | string | boolean | null): boolean {\n return Boolean(child) && child !== true;\n}\n\n/**\n * Get the children of a JSX element as an array. If the element has only one\n * child, the child is returned as an array.\n *\n * @param element - A JSX element.\n * @returns The children of the element.\n */\nexport function getJsxChildren(element: JSXElement): (JSXElement | string)[] {\n if (hasChildren(element)) {\n if (Array.isArray(element.props.children)) {\n // @ts-expect-error - Each member of the union type has signatures, but\n // none of those signatures are compatible with each other.\n return element.props.children.filter(filterJsxChild).flat(Infinity);\n }\n\n if (element.props.children) {\n return [element.props.children];\n }\n }\n\n return [];\n}\n\n/**\n * Walk a JSX tree and call a callback on each node.\n *\n * @param node - The JSX node to walk.\n * @param callback - The callback to call on each node.\n * @param depth - The current depth in the JSX tree for a walk.\n * @returns The result of the callback, if any.\n */\nexport function walkJsx<Value>(\n node: JSXElement | JSXElement[],\n callback: (node: JSXElement, depth: number) => Value | undefined,\n depth = 0,\n): Value | undefined {\n if (Array.isArray(node)) {\n for (const child of node) {\n const childResult = walkJsx(child as JSXElement, callback, depth);\n if (childResult !== undefined) {\n return childResult;\n }\n }\n\n return undefined;\n }\n\n const result = callback(node, depth);\n if (result !== undefined) {\n return result;\n }\n\n if (\n hasProperty(node, 'props') &&\n isPlainObject(node.props) &&\n hasProperty(node.props, 'children')\n ) {\n const children = getJsxChildren(node);\n for (const child of children) {\n if (isPlainObject(child)) {\n const childResult = walkJsx(child, callback, depth + 1);\n if (childResult !== undefined) {\n return childResult;\n }\n }\n }\n }\n\n return undefined;\n}\n\n/**\n * Serialise a JSX prop to a string.\n *\n * @param prop - The JSX prop.\n * @returns The serialised JSX prop.\n */\nfunction serialiseProp(prop: unknown): string {\n if (typeof prop === 'string') {\n return `\"${prop}\"`;\n }\n\n return `{${JSON.stringify(prop)}}`;\n}\n\n/**\n * Serialise JSX props to a string.\n *\n * @param props - The JSX props.\n * @returns The serialised JSX props.\n */\nfunction serialiseProps(props: Record<string, unknown>): string {\n return Object.entries(props)\n .filter(([key]) => key !== 'children')\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([key, value]) => ` ${key}=${serialiseProp(value)}`)\n .join('');\n}\n\n/**\n * Serialise a JSX node to a string.\n *\n * @param node - The JSX node.\n * @param indentation - The indentation level. Defaults to `0`. This should not\n * be set by the caller, as it is used for recursion.\n * @returns The serialised JSX node.\n */\nexport function serialiseJsx(node: SnapNode, indentation = 0): string {\n if (Array.isArray(node)) {\n return node.map((child) => serialiseJsx(child, indentation)).join('');\n }\n\n const indent = ' '.repeat(indentation);\n if (typeof node === 'string') {\n return `${indent}${node}\\n`;\n }\n\n if (!node) {\n return '';\n }\n\n const { type, props } = node as GenericSnapElement;\n const trailingNewline = indentation > 0 ? '\\n' : '';\n\n if (hasProperty(props, 'children')) {\n const children = serialiseJsx(props.children as SnapNode, indentation + 1);\n return `${indent}<${type}${serialiseProps(\n props,\n )}>\\n${children}${indent}</${type}>${trailingNewline}`;\n }\n\n return `${indent}<${type}${serialiseProps(props)} />${trailingNewline}`;\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateFetchedSnap = void 0;
|
|
4
|
+
const icon_1 = require("./icon.cjs");
|
|
5
|
+
const localization_1 = require("./localization.cjs");
|
|
6
|
+
const validation_1 = require("./manifest/validation.cjs");
|
|
7
|
+
const snaps_1 = require("./snaps.cjs");
|
|
8
|
+
/**
|
|
9
|
+
* Validates the files contained in a fetched snap.
|
|
10
|
+
*
|
|
11
|
+
* @param files - All potentially included files in a fetched snap.
|
|
12
|
+
* @throws If any of the files are considered invalid.
|
|
13
|
+
*/
|
|
14
|
+
async function validateFetchedSnap(files) {
|
|
15
|
+
(0, validation_1.assertIsSnapManifest)(files.manifest.result);
|
|
16
|
+
await (0, snaps_1.validateSnapShasum)(files);
|
|
17
|
+
(0, localization_1.validateSnapManifestLocalizations)(files.manifest.result, files.localizationFiles.map((file) => file.result));
|
|
18
|
+
if (files.svgIcon) {
|
|
19
|
+
(0, icon_1.assertIsSnapIcon)(files.svgIcon);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.validateFetchedSnap = validateFetchedSnap;
|
|
23
|
+
//# sourceMappingURL=validation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.cjs","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAC1C,qDAAmE;AACnE,0DAA6D;AAC7D,uCAA6C;AAG7C;;;;;GAKG;AACI,KAAK,UAAU,mBAAmB,CACvC,KAAuB;IAEvB,IAAA,iCAAoB,EAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,IAAA,0BAAkB,EAAC,KAAK,CAAC,CAAC;IAChC,IAAA,gDAAiC,EAC/B,KAAK,CAAC,QAAQ,CAAC,MAAM,EACrB,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CACnD,CAAC;IAEF,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,IAAA,uBAAgB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAbD,kDAaC","sourcesContent":["import { assertIsSnapIcon } from './icon';\nimport { validateSnapManifestLocalizations } from './localization';\nimport { assertIsSnapManifest } from './manifest/validation';\nimport { validateSnapShasum } from './snaps';\nimport type { FetchedSnapFiles } from './types';\n\n/**\n * Validates the files contained in a fetched snap.\n *\n * @param files - All potentially included files in a fetched snap.\n * @throws If any of the files are considered invalid.\n */\nexport async function validateFetchedSnap(\n files: FetchedSnapFiles,\n): Promise<void> {\n assertIsSnapManifest(files.manifest.result);\n await validateSnapShasum(files);\n validateSnapManifestLocalizations(\n files.manifest.result,\n files.localizationFiles.map((file) => file.result),\n );\n\n if (files.svgIcon) {\n assertIsSnapIcon(files.svgIcon);\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FetchedSnapFiles } from "./types.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* Validates the files contained in a fetched snap.
|
|
4
|
+
*
|
|
5
|
+
* @param files - All potentially included files in a fetched snap.
|
|
6
|
+
* @throws If any of the files are considered invalid.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateFetchedSnap(files: FetchedSnapFiles): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=validation.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.cts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAgB;AAEhD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FetchedSnapFiles } from "./types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Validates the files contained in a fetched snap.
|
|
4
|
+
*
|
|
5
|
+
* @param files - All potentially included files in a fetched snap.
|
|
6
|
+
* @throws If any of the files are considered invalid.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateFetchedSnap(files: FetchedSnapFiles): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=validation.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.mts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAgB;AAEhD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
package/dist/validation.mjs
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "./
|
|
4
|
-
import "./
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import "./chunk-3S4INAGA.mjs";
|
|
20
|
-
import "./chunk-DE22V5AO.mjs";
|
|
21
|
-
import "./chunk-Z2JQNSVL.mjs";
|
|
22
|
-
import "./chunk-YJHQZFR4.mjs";
|
|
23
|
-
import "./chunk-3RUWAMJT.mjs";
|
|
24
|
-
export {
|
|
25
|
-
validateFetchedSnap
|
|
26
|
-
};
|
|
1
|
+
import { assertIsSnapIcon } from "./icon.mjs";
|
|
2
|
+
import { validateSnapManifestLocalizations } from "./localization.mjs";
|
|
3
|
+
import { assertIsSnapManifest } from "./manifest/validation.mjs";
|
|
4
|
+
import { validateSnapShasum } from "./snaps.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* Validates the files contained in a fetched snap.
|
|
7
|
+
*
|
|
8
|
+
* @param files - All potentially included files in a fetched snap.
|
|
9
|
+
* @throws If any of the files are considered invalid.
|
|
10
|
+
*/
|
|
11
|
+
export async function validateFetchedSnap(files) {
|
|
12
|
+
assertIsSnapManifest(files.manifest.result);
|
|
13
|
+
await validateSnapShasum(files);
|
|
14
|
+
validateSnapManifestLocalizations(files.manifest.result, files.localizationFiles.map((file) => file.result));
|
|
15
|
+
if (files.svgIcon) {
|
|
16
|
+
assertIsSnapIcon(files.svgIcon);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
27
19
|
//# sourceMappingURL=validation.mjs.map
|
package/dist/validation.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"validation.mjs","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,mBAAe;AAC1C,OAAO,EAAE,iCAAiC,EAAE,2BAAuB;AACnE,OAAO,EAAE,oBAAoB,EAAE,kCAA8B;AAC7D,OAAO,EAAE,kBAAkB,EAAE,oBAAgB;AAG7C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,KAAuB;IAEvB,oBAAoB,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAChC,iCAAiC,CAC/B,KAAK,CAAC,QAAQ,CAAC,MAAM,EACrB,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CACnD,CAAC;IAEF,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;AACH,CAAC","sourcesContent":["import { assertIsSnapIcon } from './icon';\nimport { validateSnapManifestLocalizations } from './localization';\nimport { assertIsSnapManifest } from './manifest/validation';\nimport { validateSnapShasum } from './snaps';\nimport type { FetchedSnapFiles } from './types';\n\n/**\n * Validates the files contained in a fetched snap.\n *\n * @param files - All potentially included files in a fetched snap.\n * @throws If any of the files are considered invalid.\n */\nexport async function validateFetchedSnap(\n files: FetchedSnapFiles,\n): Promise<void> {\n assertIsSnapManifest(files.manifest.result);\n await validateSnapShasum(files);\n validateSnapManifestLocalizations(\n files.manifest.result,\n files.localizationFiles.map((file) => file.result),\n );\n\n if (files.svgIcon) {\n assertIsSnapIcon(files.svgIcon);\n }\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveVersionRange = exports.getTargetVersion = exports.DEFAULT_REQUESTED_SNAP_VERSION = void 0;
|
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
+
const utils_1 = require("@metamask/utils");
|
|
6
|
+
const semver_1 = require("semver");
|
|
7
|
+
exports.DEFAULT_REQUESTED_SNAP_VERSION = '*';
|
|
8
|
+
/**
|
|
9
|
+
* Return the highest version in the list that satisfies the range, or `null` if
|
|
10
|
+
* none of them do. For the satisfaction check, pre-release versions will only
|
|
11
|
+
* be checked if no satisfactory non-prerelease version is found first.
|
|
12
|
+
*
|
|
13
|
+
* @param versions - The list of version to check.
|
|
14
|
+
* @param versionRange - The SemVer version range to check against.
|
|
15
|
+
* @returns The highest version in the list that satisfies the range,
|
|
16
|
+
* or `null` if none of them do.
|
|
17
|
+
*/
|
|
18
|
+
function getTargetVersion(versions, versionRange) {
|
|
19
|
+
const maxSatisfyingNonPreRelease = (0, semver_1.maxSatisfying)(versions, versionRange);
|
|
20
|
+
// By default don't use pre-release versions
|
|
21
|
+
if (maxSatisfyingNonPreRelease) {
|
|
22
|
+
return maxSatisfyingNonPreRelease;
|
|
23
|
+
}
|
|
24
|
+
// If no satisfying release version is found by default, try pre-release versions
|
|
25
|
+
return (0, semver_1.maxSatisfying)(versions, versionRange, {
|
|
26
|
+
includePrerelease: true,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.getTargetVersion = getTargetVersion;
|
|
30
|
+
/**
|
|
31
|
+
* Parse a version received by some subject attempting to access a snap.
|
|
32
|
+
*
|
|
33
|
+
* @param version - The received version value.
|
|
34
|
+
* @returns `*` if the version is `undefined` or `latest", otherwise returns
|
|
35
|
+
* the specified version.
|
|
36
|
+
*/
|
|
37
|
+
function resolveVersionRange(version) {
|
|
38
|
+
if (version === undefined || version === 'latest') {
|
|
39
|
+
return [undefined, exports.DEFAULT_REQUESTED_SNAP_VERSION];
|
|
40
|
+
}
|
|
41
|
+
return (0, superstruct_1.validate)(version, utils_1.VersionRangeStruct);
|
|
42
|
+
}
|
|
43
|
+
exports.resolveVersionRange = resolveVersionRange;
|
|
44
|
+
//# sourceMappingURL=versions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.cjs","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":";;;AAAA,uDAAiD;AAEjD,2CAAqD;AACrD,mCAA8D;AAEjD,QAAA,8BAA8B,GAAG,GAAkB,CAAC;AAEjE;;;;;;;;;GASG;AACH,SAAgB,gBAAgB,CAC9B,QAAyB,EACzB,YAAyB;IAEzB,MAAM,0BAA0B,GAAG,IAAA,sBAAmB,EACpD,QAAQ,EACR,YAAY,CACb,CAAC;IAEF,4CAA4C;IAC5C,IAAI,0BAA0B,EAAE,CAAC;QAC/B,OAAO,0BAA0B,CAAC;IACpC,CAAC;IAED,iFAAiF;IACjF,OAAO,IAAA,sBAAmB,EAAC,QAAQ,EAAE,YAAY,EAAE;QACjD,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;AACL,CAAC;AAlBD,4CAkBC;AAED;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,OAAc;IAEd,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QAClD,OAAO,CAAC,SAAS,EAAE,sCAA8B,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,IAAA,sBAAQ,EAAC,OAAO,EAAE,0BAAkB,CAAC,CAAC;AAC/C,CAAC;AAPD,kDAOC","sourcesContent":["import { validate } from '@metamask/superstruct';\nimport type { Json, SemVerVersion, SemVerRange } from '@metamask/utils';\nimport { VersionRangeStruct } from '@metamask/utils';\nimport { maxSatisfying as maxSatisfyingSemver } from 'semver';\n\nexport const DEFAULT_REQUESTED_SNAP_VERSION = '*' as SemVerRange;\n\n/**\n * Return the highest version in the list that satisfies the range, or `null` if\n * none of them do. For the satisfaction check, pre-release versions will only\n * be checked if no satisfactory non-prerelease version is found first.\n *\n * @param versions - The list of version to check.\n * @param versionRange - The SemVer version range to check against.\n * @returns The highest version in the list that satisfies the range,\n * or `null` if none of them do.\n */\nexport function getTargetVersion(\n versions: SemVerVersion[],\n versionRange: SemVerRange,\n): SemVerVersion | null {\n const maxSatisfyingNonPreRelease = maxSatisfyingSemver(\n versions,\n versionRange,\n );\n\n // By default don't use pre-release versions\n if (maxSatisfyingNonPreRelease) {\n return maxSatisfyingNonPreRelease;\n }\n\n // If no satisfying release version is found by default, try pre-release versions\n return maxSatisfyingSemver(versions, versionRange, {\n includePrerelease: true,\n });\n}\n\n/**\n * Parse a version received by some subject attempting to access a snap.\n *\n * @param version - The received version value.\n * @returns `*` if the version is `undefined` or `latest\", otherwise returns\n * the specified version.\n */\nexport function resolveVersionRange(\n version?: Json,\n): [error: undefined, range: SemVerRange] | [error: Error, range: undefined] {\n if (version === undefined || version === 'latest') {\n return [undefined, DEFAULT_REQUESTED_SNAP_VERSION];\n }\n return validate(version, VersionRangeStruct);\n}\n"]}
|