@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/post-process.mjs
CHANGED
|
@@ -1,10 +1,336 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { transformSync, template } from "@babel/core";
|
|
2
|
+
import $babeltypes from "@babel/types";
|
|
3
|
+
const { binaryExpression, isUnaryExpression, isUpdateExpression, stringLiteral, templateElement, templateLiteral } = $babeltypes;
|
|
4
|
+
export var PostProcessWarning;
|
|
5
|
+
(function (PostProcessWarning) {
|
|
6
|
+
PostProcessWarning["UnsafeMathRandom"] = "`Math.random` was detected in the Snap bundle. This is not a secure source of randomness, and should not be used in a secure context. Use `crypto.getRandomValues` instead.";
|
|
7
|
+
})(PostProcessWarning || (PostProcessWarning = {}));
|
|
8
|
+
// The RegEx below consists of multiple groups joined by a boolean OR.
|
|
9
|
+
// Each part consists of two groups which capture a part of each string
|
|
10
|
+
// which needs to be split up, e.g., `<!--` is split into `<!` and `--`.
|
|
11
|
+
const TOKEN_REGEX = /(<!)(--)|(--)(>)|(--)(!)(>)|(import)(\(.*?\))/gu;
|
|
12
|
+
// An empty template element, i.e., a part of a template literal without any
|
|
13
|
+
// value ("").
|
|
14
|
+
const EMPTY_TEMPLATE_ELEMENT = templateElement({ raw: '', cooked: '' });
|
|
15
|
+
const evalWrapper = template.statement(`
|
|
16
|
+
(1, REF)(ARGS)
|
|
17
|
+
`);
|
|
18
|
+
const objectEvalWrapper = template.statement(`
|
|
19
|
+
(1, OBJECT.REF)
|
|
20
|
+
`);
|
|
21
|
+
const regeneratorRuntimeWrapper = template.statement(`
|
|
22
|
+
var regeneratorRuntime;
|
|
23
|
+
`);
|
|
24
|
+
/**
|
|
25
|
+
* Breaks up tokens that would otherwise result in SES errors. The tokens are
|
|
26
|
+
* broken up in a non-destructive way where possible. Currently works with:
|
|
27
|
+
* - HTML comment tags `<!--` and `-->`, broken up into `<!`, `--`, and `--`,
|
|
28
|
+
* `>`.
|
|
29
|
+
* - `import(n)` statements, broken up into `import`, `(n)`.
|
|
30
|
+
*
|
|
31
|
+
* @param value - The string value to break up.
|
|
32
|
+
* @returns The string split into an array, in a way that it can be joined
|
|
33
|
+
* together to form the same string, but with the tokens separated into single
|
|
34
|
+
* array elements.
|
|
35
|
+
*/
|
|
36
|
+
function breakTokens(value) {
|
|
37
|
+
const tokens = value.split(TOKEN_REGEX);
|
|
38
|
+
return (tokens
|
|
39
|
+
// TODO: The `split` above results in some values being `undefined`.
|
|
40
|
+
// There may be a better solution to avoid having to filter those out.
|
|
41
|
+
.filter((token) => token !== '' && token !== undefined));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Breaks up tokens that would otherwise result in SES errors. The tokens are
|
|
45
|
+
* broken up in a non-destructive way where possible. Currently works with:
|
|
46
|
+
* - HTML comment tags `<!--` and `-->`, broken up into `<!`, `--`, and `--`,
|
|
47
|
+
* `>`.
|
|
48
|
+
* - `import(n)` statements, broken up into `import`, `(n)`.
|
|
49
|
+
*
|
|
50
|
+
* @param value - The string value to break up.
|
|
51
|
+
* @returns The string split into a tuple consisting of the new template
|
|
52
|
+
* elements and string literal expressions.
|
|
53
|
+
*/
|
|
54
|
+
function breakTokensTemplateLiteral(value) {
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
56
|
+
// @ts-ignore `matchAll` is not available in ES2017, but this code
|
|
57
|
+
// should only be used in environments where the function is supported.
|
|
58
|
+
const matches = Array.from(value.matchAll(TOKEN_REGEX));
|
|
59
|
+
if (matches.length > 0) {
|
|
60
|
+
const output = matches.reduce(([elements, expressions], rawMatch, index, values) => {
|
|
61
|
+
const [, first, last] = rawMatch.filter((raw) => raw !== undefined);
|
|
62
|
+
// Slice the text in front of the match, which does not need to be
|
|
63
|
+
// broken up.
|
|
64
|
+
const prefix = value.slice(index === 0
|
|
65
|
+
? 0
|
|
66
|
+
: values[index - 1].index + values[index - 1][0].length, rawMatch.index);
|
|
67
|
+
return [
|
|
68
|
+
[
|
|
69
|
+
...elements,
|
|
70
|
+
templateElement({
|
|
71
|
+
raw: getRawTemplateValue(prefix),
|
|
72
|
+
cooked: prefix,
|
|
73
|
+
}),
|
|
74
|
+
EMPTY_TEMPLATE_ELEMENT,
|
|
75
|
+
],
|
|
76
|
+
[...expressions, stringLiteral(first), stringLiteral(last)],
|
|
77
|
+
];
|
|
78
|
+
}, [[], []]);
|
|
79
|
+
// Add the text after the last match to the output.
|
|
80
|
+
const lastMatch = matches[matches.length - 1];
|
|
81
|
+
const suffix = value.slice(lastMatch.index + lastMatch[0].length);
|
|
82
|
+
return [
|
|
83
|
+
[
|
|
84
|
+
...output[0],
|
|
85
|
+
templateElement({ raw: getRawTemplateValue(suffix), cooked: suffix }),
|
|
86
|
+
],
|
|
87
|
+
output[1],
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
// If there are no matches, simply return the original value.
|
|
91
|
+
return [
|
|
92
|
+
[templateElement({ raw: getRawTemplateValue(value), cooked: value })],
|
|
93
|
+
[],
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get a raw template literal value from a cooked value. This adds a backslash
|
|
98
|
+
* before every '`', '\' and '${' characters.
|
|
99
|
+
*
|
|
100
|
+
* @see https://github.com/babel/babel/issues/9242#issuecomment-532529613
|
|
101
|
+
* @param value - The cooked string to get the raw string for.
|
|
102
|
+
* @returns The value as raw value.
|
|
103
|
+
*/
|
|
104
|
+
function getRawTemplateValue(value) {
|
|
105
|
+
return value.replace(/\\|`|\$\{/gu, '\\$&');
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Post process code with AST such that it can be evaluated in SES.
|
|
109
|
+
*
|
|
110
|
+
* Currently:
|
|
111
|
+
* - Makes all direct calls to eval indirect.
|
|
112
|
+
* - Handles certain Babel-related edge cases.
|
|
113
|
+
* - Removes the `Buffer` provided by Browserify.
|
|
114
|
+
* - Optionally removes comments.
|
|
115
|
+
* - Breaks up tokens that would otherwise result in SES errors, such as HTML
|
|
116
|
+
* comment tags `<!--` and `-->` and `import(n)` statements.
|
|
117
|
+
*
|
|
118
|
+
* @param code - The code to post process.
|
|
119
|
+
* @param options - The post-process options.
|
|
120
|
+
* @param options.stripComments - Whether to strip comments. Defaults to `true`.
|
|
121
|
+
* @param options.sourceMap - Whether to generate a source map for the modified
|
|
122
|
+
* code. See also `inputSourceMap`.
|
|
123
|
+
* @param options.inputSourceMap - The source map for the input code. When
|
|
124
|
+
* provided, the source map will be used to generate a source map for the
|
|
125
|
+
* modified code. This ensures that the source map is correct for the modified
|
|
126
|
+
* code, and still points to the original source. If not provided, a new source
|
|
127
|
+
* map will be generated instead.
|
|
128
|
+
* @returns An object containing the modified code, and source map, or null if
|
|
129
|
+
* the provided code is null.
|
|
130
|
+
*/
|
|
131
|
+
export function postProcessBundle(code, { stripComments = true, sourceMap: sourceMaps, inputSourceMap, } = {}) {
|
|
132
|
+
const warnings = new Set();
|
|
133
|
+
const pre = ({ ast }) => {
|
|
134
|
+
ast.comments?.forEach((comment) => {
|
|
135
|
+
// Break up tokens that could be parsed as HTML comment terminators. The
|
|
136
|
+
// regular expressions below are written strangely so as to avoid the
|
|
137
|
+
// appearance of such tokens in our source code. For reference:
|
|
138
|
+
// https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md
|
|
139
|
+
comment.value = comment.value
|
|
140
|
+
.replace(new RegExp(`<!${'--'}`, 'gu'), '< !--')
|
|
141
|
+
.replace(new RegExp(`${'--'}>`, 'gu'), '-- >')
|
|
142
|
+
.replace(/import(\(.*\))/gu, 'import\\$1');
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
const visitor = {
|
|
146
|
+
FunctionExpression(path) {
|
|
147
|
+
const { node } = path;
|
|
148
|
+
// Browserify provides the `Buffer` global as an argument to modules that
|
|
149
|
+
// use it, but this does not work in SES. Since we pass in `Buffer` as an
|
|
150
|
+
// endowment, we can simply remove the argument.
|
|
151
|
+
//
|
|
152
|
+
// Note that this only removes `Buffer` from a wrapped function
|
|
153
|
+
// expression, e.g., `(function (Buffer) { ... })`. Regular functions
|
|
154
|
+
// are not affected.
|
|
155
|
+
//
|
|
156
|
+
// TODO: Since we're working on the AST level, we could check the scope
|
|
157
|
+
// of the function expression, and possibly prevent false positives?
|
|
158
|
+
if (node.type === 'FunctionExpression' && node.extra?.parenthesized) {
|
|
159
|
+
node.params = node.params.filter((param) => !(param.type === 'Identifier' && param.name === 'Buffer'));
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
CallExpression(path) {
|
|
163
|
+
const { node } = path;
|
|
164
|
+
// Replace `eval(foo)` with `(1, eval)(foo)`.
|
|
165
|
+
if (node.callee.type === 'Identifier' && node.callee.name === 'eval') {
|
|
166
|
+
path.replaceWith(evalWrapper({
|
|
167
|
+
REF: node.callee,
|
|
168
|
+
ARGS: node.arguments,
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
// Detect the use of `Math.random()` and add a warning.
|
|
172
|
+
if (node.callee.type === 'MemberExpression' &&
|
|
173
|
+
node.callee.object.type === 'Identifier' &&
|
|
174
|
+
node.callee.object.name === 'Math' &&
|
|
175
|
+
node.callee.property.type === 'Identifier' &&
|
|
176
|
+
node.callee.property.name === 'random') {
|
|
177
|
+
warnings.add(PostProcessWarning.UnsafeMathRandom);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
MemberExpression(path) {
|
|
181
|
+
const { node } = path;
|
|
182
|
+
// Replace `object.eval(foo)` with `(1, object.eval)(foo)`.
|
|
183
|
+
if (node.property.type === 'Identifier' &&
|
|
184
|
+
node.property.name === 'eval' &&
|
|
185
|
+
// We only apply this to MemberExpressions that are the callee of CallExpression
|
|
186
|
+
path.parent.type === 'CallExpression' &&
|
|
187
|
+
path.parent.callee === node) {
|
|
188
|
+
path.replaceWith(objectEvalWrapper({
|
|
189
|
+
OBJECT: node.object,
|
|
190
|
+
REF: node.property,
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
Identifier(path) {
|
|
195
|
+
const { node } = path;
|
|
196
|
+
// Insert `regeneratorRuntime` global if it's used in the code.
|
|
197
|
+
if (node.name === 'regeneratorRuntime') {
|
|
198
|
+
const program = path.findParent((parent) => parent.node.type === 'Program');
|
|
199
|
+
// We know that `program` is a Program node here, but this keeps
|
|
200
|
+
// TypeScript happy.
|
|
201
|
+
if (program?.node.type === 'Program') {
|
|
202
|
+
const body = program.node.body[0];
|
|
203
|
+
// This stops it from inserting `regeneratorRuntime` multiple times.
|
|
204
|
+
if (body.type === 'VariableDeclaration' &&
|
|
205
|
+
body.declarations[0].id.name ===
|
|
206
|
+
'regeneratorRuntime') {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
program?.node.body.unshift(regeneratorRuntimeWrapper());
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
TemplateLiteral(path) {
|
|
214
|
+
const { node } = path;
|
|
215
|
+
// This checks if the template literal was visited before. Without this,
|
|
216
|
+
// it would cause an infinite loop resulting in a stack overflow. We can't
|
|
217
|
+
// skip the path here, because we need to visit the children of the node.
|
|
218
|
+
if (path.getData('visited')) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
// Break up tokens that could be parsed as HTML comment terminators, or
|
|
222
|
+
// `import()` statements.
|
|
223
|
+
// For reference:
|
|
224
|
+
// - https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md
|
|
225
|
+
// - https://github.com/MetaMask/snaps-monorepo/issues/505
|
|
226
|
+
const [replacementQuasis, replacementExpressions] = node.quasis.reduce(([elements, expressions], quasi, index) => {
|
|
227
|
+
// Note: Template literals have two variants, "cooked" and "raw". Here
|
|
228
|
+
// we use the cooked version.
|
|
229
|
+
// https://exploringjs.com/impatient-js/ch_template-literals.html#template-strings-cooked-vs-raw
|
|
230
|
+
const tokens = breakTokensTemplateLiteral(quasi.value.cooked);
|
|
231
|
+
// Only update the node if something changed.
|
|
232
|
+
if (tokens[0].length <= 1) {
|
|
233
|
+
return [
|
|
234
|
+
[...elements, quasi],
|
|
235
|
+
[...expressions, node.expressions[index]],
|
|
236
|
+
];
|
|
237
|
+
}
|
|
238
|
+
return [
|
|
239
|
+
[...elements, ...tokens[0]],
|
|
240
|
+
[
|
|
241
|
+
...expressions,
|
|
242
|
+
...tokens[1],
|
|
243
|
+
node.expressions[index],
|
|
244
|
+
],
|
|
245
|
+
];
|
|
246
|
+
}, [[], []]);
|
|
247
|
+
path.replaceWith(templateLiteral(replacementQuasis, replacementExpressions.filter((expression) => expression !== undefined)));
|
|
248
|
+
path.setData('visited', true);
|
|
249
|
+
},
|
|
250
|
+
StringLiteral(path) {
|
|
251
|
+
const { node } = path;
|
|
252
|
+
// Break up tokens that could be parsed as HTML comment terminators, or
|
|
253
|
+
// `import()` statements.
|
|
254
|
+
// For reference:
|
|
255
|
+
// - https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md
|
|
256
|
+
// - https://github.com/MetaMask/snaps-monorepo/issues/505
|
|
257
|
+
const tokens = breakTokens(node.value);
|
|
258
|
+
// Only update the node if the string literal was broken up.
|
|
259
|
+
if (tokens.length <= 1) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const replacement = tokens
|
|
263
|
+
.slice(1)
|
|
264
|
+
.reduce((acc, value) => binaryExpression('+', acc, stringLiteral(value)), stringLiteral(tokens[0]));
|
|
265
|
+
path.replaceWith(replacement);
|
|
266
|
+
path.skip();
|
|
267
|
+
},
|
|
268
|
+
BinaryExpression(path) {
|
|
269
|
+
const { node } = path;
|
|
270
|
+
const errorMessage = 'Using HTML comments (`<!--` and `-->`) as operators is not allowed. The behaviour of ' +
|
|
271
|
+
'these comments is ambiguous, and differs per browser and environment. If you want ' +
|
|
272
|
+
'to use them as operators, break them up into separate characters, i.e., `a-- > b` ' +
|
|
273
|
+
'and `a < ! --b`.';
|
|
274
|
+
if (node.operator === '<' &&
|
|
275
|
+
isUnaryExpression(node.right) &&
|
|
276
|
+
isUpdateExpression(node.right.argument) &&
|
|
277
|
+
node.right.argument.operator === '--' &&
|
|
278
|
+
node.left.end &&
|
|
279
|
+
node.right.argument.argument.start) {
|
|
280
|
+
const expression = code.slice(node.left.end, node.right.argument.argument.start);
|
|
281
|
+
if (expression.includes('<!--')) {
|
|
282
|
+
throw new Error(errorMessage);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (node.operator === '>' &&
|
|
286
|
+
isUpdateExpression(node.left) &&
|
|
287
|
+
node.left.operator === '--' &&
|
|
288
|
+
node.left.argument.end &&
|
|
289
|
+
node.right.start) {
|
|
290
|
+
const expression = code.slice(node.left.argument.end, node.right.start);
|
|
291
|
+
if (expression.includes('-->')) {
|
|
292
|
+
throw new Error(errorMessage);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
try {
|
|
298
|
+
const file = transformSync(code, {
|
|
299
|
+
// Prevent Babel from searching for a config file.
|
|
300
|
+
configFile: false,
|
|
301
|
+
parserOpts: {
|
|
302
|
+
// Strict mode isn't enabled by default, so we need to enable it here.
|
|
303
|
+
strictMode: true,
|
|
304
|
+
// If this is disabled, the AST does not include any comments. This is
|
|
305
|
+
// useful for performance reasons, and we use it for stripping comments.
|
|
306
|
+
attachComment: !stripComments,
|
|
307
|
+
},
|
|
308
|
+
// By default, Babel optimises bundles that exceed 500 KB, but that
|
|
309
|
+
// results in characters which look like HTML comments, which breaks SES.
|
|
310
|
+
compact: false,
|
|
311
|
+
// This configures Babel to generate a new source map from the existing
|
|
312
|
+
// source map if specified. If `sourceMap` is `true` but an input source
|
|
313
|
+
// map is not provided, a new source map will be generated instead.
|
|
314
|
+
inputSourceMap,
|
|
315
|
+
sourceMaps,
|
|
316
|
+
plugins: [
|
|
317
|
+
() => ({
|
|
318
|
+
pre,
|
|
319
|
+
visitor,
|
|
320
|
+
}),
|
|
321
|
+
],
|
|
322
|
+
});
|
|
323
|
+
if (!file?.code) {
|
|
324
|
+
throw new Error('Bundled code is empty.');
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
code: file.code,
|
|
328
|
+
sourceMap: file.map,
|
|
329
|
+
warnings: Array.from(warnings),
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
throw new Error(`Failed to post process code:\n${error.message}`);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
10
336
|
//# sourceMappingURL=post-process.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"file":"post-process.mjs","sourceRoot":"","sources":["../src/post-process.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,oBAAoB;;;AAyDtD,MAAM,CAAN,IAAY,kBAEX;AAFD,WAAY,kBAAkB;IAC5B,sNAAgM,CAAA;AAClM,CAAC,EAFW,kBAAkB,KAAlB,kBAAkB,QAE7B;AAED,sEAAsE;AACtE,uEAAuE;AACvE,wEAAwE;AACxE,MAAM,WAAW,GAAG,iDAAiD,CAAC;AAEtE,4EAA4E;AAC5E,cAAc;AACd,MAAM,sBAAsB,GAAG,eAAe,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AAExE,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAC;;CAEtC,CAAC,CAAC;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C,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAExE,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC/B,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE;YAC/B,kDAAkD;YAClD,UAAU,EAAE,KAAK;YAEjB,UAAU,EAAE;gBACV,sEAAsE;gBACtE,UAAU,EAAE,IAAI;gBAEhB,sEAAsE;gBACtE,wEAAwE;gBACxE,aAAa,EAAE,CAAC,aAAa;aAC9B;YAED,mEAAmE;YACnE,yEAAyE;YACzE,OAAO,EAAE,KAAK;YAEd,uEAAuE;YACvE,wEAAwE;YACxE,mEAAmE;YACnE,cAAc;YACd,UAAU;YAEV,OAAO,EAAE;gBACP,GAAG,EAAE,CAAC,CAAC;oBACL,GAAG;oBACH,OAAO;iBACR,CAAC;aACH;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,GAAG;YACnB,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC/B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACpE,CAAC;AACH,CAAC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-shadow\nimport type { Node, Visitor, PluginObj } from '@babel/core';\nimport { transformSync, template } from '@babel/core';\nimport type { Expression, Identifier, TemplateElement } from '@babel/types';\nimport {\n binaryExpression,\n isUnaryExpression,\n isUpdateExpression,\n stringLiteral,\n templateElement,\n templateLiteral,\n} from '@babel/types';\n\n/**\n * Source map declaration taken from `@babel/core`. Babel doesn't export the\n * type for this, so it's copied from the source code instead here.\n */\nexport type SourceMap = {\n version: number;\n sources: string[];\n names: string[];\n sourceRoot?: string | undefined;\n sourcesContent?: string[] | undefined;\n mappings: string;\n file: string;\n};\n\n/**\n * The post process options.\n *\n * @property stripComments - Whether to strip comments. Defaults to `true`.\n * @property sourceMap - Whether to generate a source map for the modified code.\n * See also `inputSourceMap`.\n * @property inputSourceMap - The source map for the input code. When provided,\n * the source map will be used to generate a source map for the modified code.\n * This ensures that the source map is correct for the modified code, and still\n * points to the original source. If not provided, a new source map will be\n * generated instead.\n */\nexport type PostProcessOptions = {\n stripComments?: boolean;\n sourceMap?: boolean | 'inline';\n inputSourceMap?: SourceMap;\n};\n\n/**\n * The post processed bundle output.\n *\n * @property code - The modified code.\n * @property sourceMap - The source map for the modified code, if the source map\n * option was enabled.\n * @property warnings - Any warnings that occurred during the post-processing.\n */\nexport type PostProcessedBundle = {\n code: string;\n sourceMap?: SourceMap | null;\n warnings: PostProcessWarning[];\n};\n\nexport enum PostProcessWarning {\n UnsafeMathRandom = '`Math.random` was detected in the Snap bundle. This is not a secure source of randomness, and should not be used in a secure context. Use `crypto.getRandomValues` instead.',\n}\n\n// The RegEx below consists of multiple groups joined by a boolean OR.\n// Each part consists of two groups which capture a part of each string\n// which needs to be split up, e.g., `<!--` is split into `<!` and `--`.\nconst TOKEN_REGEX = /(<!)(--)|(--)(>)|(--)(!)(>)|(import)(\\(.*?\\))/gu;\n\n// An empty template element, i.e., a part of a template literal without any\n// value (\"\").\nconst EMPTY_TEMPLATE_ELEMENT = templateElement({ raw: '', cooked: '' });\n\nconst evalWrapper = template.statement(`\n (1, REF)(ARGS)\n`);\n\nconst objectEvalWrapper = template.statement(`\n (1, OBJECT.REF)\n`);\n\nconst regeneratorRuntimeWrapper = template.statement(`\n var regeneratorRuntime;\n`);\n\n/**\n * Breaks up tokens that would otherwise result in SES errors. The tokens are\n * broken up in a non-destructive way where possible. Currently works with:\n * - HTML comment tags `<!--` and `-->`, broken up into `<!`, `--`, and `--`,\n * `>`.\n * - `import(n)` statements, broken up into `import`, `(n)`.\n *\n * @param value - The string value to break up.\n * @returns The string split into an array, in a way that it can be joined\n * together to form the same string, but with the tokens separated into single\n * array elements.\n */\nfunction breakTokens(value: string): string[] {\n const tokens = value.split(TOKEN_REGEX);\n return (\n tokens\n // TODO: The `split` above results in some values being `undefined`.\n // There may be a better solution to avoid having to filter those out.\n .filter((token) => token !== '' && token !== undefined)\n );\n}\n\n/**\n * Breaks up tokens that would otherwise result in SES errors. The tokens are\n * broken up in a non-destructive way where possible. Currently works with:\n * - HTML comment tags `<!--` and `-->`, broken up into `<!`, `--`, and `--`,\n * `>`.\n * - `import(n)` statements, broken up into `import`, `(n)`.\n *\n * @param value - The string value to break up.\n * @returns The string split into a tuple consisting of the new template\n * elements and string literal expressions.\n */\nfunction breakTokensTemplateLiteral(\n value: string,\n): [TemplateElement[], Expression[]] {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore `matchAll` is not available in ES2017, but this code\n // should only be used in environments where the function is supported.\n const matches: RegExpMatchArray[] = Array.from(value.matchAll(TOKEN_REGEX));\n\n if (matches.length > 0) {\n const output = matches.reduce<[TemplateElement[], Expression[]]>(\n ([elements, expressions], rawMatch, index, values) => {\n const [, first, last] = rawMatch.filter((raw) => raw !== undefined);\n\n // Slice the text in front of the match, which does not need to be\n // broken up.\n const prefix = value.slice(\n index === 0\n ? 0\n : (values[index - 1].index as number) + values[index - 1][0].length,\n rawMatch.index,\n );\n\n return [\n [\n ...elements,\n templateElement({\n raw: getRawTemplateValue(prefix),\n cooked: prefix,\n }),\n EMPTY_TEMPLATE_ELEMENT,\n ],\n [...expressions, stringLiteral(first), stringLiteral(last)],\n ];\n },\n [[], []],\n );\n\n // Add the text after the last match to the output.\n const lastMatch = matches[matches.length - 1];\n const suffix = value.slice(\n (lastMatch.index as number) + lastMatch[0].length,\n );\n\n return [\n [\n ...output[0],\n templateElement({ raw: getRawTemplateValue(suffix), cooked: suffix }),\n ],\n output[1],\n ];\n }\n\n // If there are no matches, simply return the original value.\n return [\n [templateElement({ raw: getRawTemplateValue(value), cooked: value })],\n [],\n ];\n}\n\n/**\n * Get a raw template literal value from a cooked value. This adds a backslash\n * before every '`', '\\' and '${' characters.\n *\n * @see https://github.com/babel/babel/issues/9242#issuecomment-532529613\n * @param value - The cooked string to get the raw string for.\n * @returns The value as raw value.\n */\nfunction getRawTemplateValue(value: string) {\n return value.replace(/\\\\|`|\\$\\{/gu, '\\\\$&');\n}\n\n/**\n * Post process code with AST such that it can be evaluated in SES.\n *\n * Currently:\n * - Makes all direct calls to eval indirect.\n * - Handles certain Babel-related edge cases.\n * - Removes the `Buffer` provided by Browserify.\n * - Optionally removes comments.\n * - Breaks up tokens that would otherwise result in SES errors, such as HTML\n * comment tags `<!--` and `-->` and `import(n)` statements.\n *\n * @param code - The code to post process.\n * @param options - The post-process options.\n * @param options.stripComments - Whether to strip comments. Defaults to `true`.\n * @param options.sourceMap - Whether to generate a source map for the modified\n * code. See also `inputSourceMap`.\n * @param options.inputSourceMap - The source map for the input code. When\n * provided, the source map will be used to generate a source map for the\n * modified code. This ensures that the source map is correct for the modified\n * code, and still points to the original source. If not provided, a new source\n * map will be generated instead.\n * @returns An object containing the modified code, and source map, or null if\n * the provided code is null.\n */\nexport function postProcessBundle(\n code: string,\n {\n stripComments = true,\n sourceMap: sourceMaps,\n inputSourceMap,\n }: Partial<PostProcessOptions> = {},\n): PostProcessedBundle {\n const warnings = new Set<PostProcessWarning>();\n\n const pre: PluginObj['pre'] = ({ ast }) => {\n ast.comments?.forEach((comment) => {\n // Break up tokens that could be parsed as HTML comment terminators. The\n // regular expressions below are written strangely so as to avoid the\n // appearance of such tokens in our source code. For reference:\n // https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md\n comment.value = comment.value\n .replace(new RegExp(`<!${'--'}`, 'gu'), '< !--')\n .replace(new RegExp(`${'--'}>`, 'gu'), '-- >')\n .replace(/import(\\(.*\\))/gu, 'import\\\\$1');\n });\n };\n\n const visitor: Visitor<Node> = {\n FunctionExpression(path) {\n const { node } = path;\n\n // Browserify provides the `Buffer` global as an argument to modules that\n // use it, but this does not work in SES. Since we pass in `Buffer` as an\n // endowment, we can simply remove the argument.\n //\n // Note that this only removes `Buffer` from a wrapped function\n // expression, e.g., `(function (Buffer) { ... })`. Regular functions\n // are not affected.\n //\n // TODO: Since we're working on the AST level, we could check the scope\n // of the function expression, and possibly prevent false positives?\n if (node.type === 'FunctionExpression' && node.extra?.parenthesized) {\n node.params = node.params.filter(\n (param) => !(param.type === 'Identifier' && param.name === 'Buffer'),\n );\n }\n },\n\n CallExpression(path) {\n const { node } = path;\n\n // Replace `eval(foo)` with `(1, eval)(foo)`.\n if (node.callee.type === 'Identifier' && node.callee.name === 'eval') {\n path.replaceWith(\n evalWrapper({\n REF: node.callee,\n ARGS: node.arguments,\n }),\n );\n }\n\n // Detect the use of `Math.random()` and add a warning.\n if (\n node.callee.type === 'MemberExpression' &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'Math' &&\n node.callee.property.type === 'Identifier' &&\n node.callee.property.name === 'random'\n ) {\n warnings.add(PostProcessWarning.UnsafeMathRandom);\n }\n },\n\n MemberExpression(path) {\n const { node } = path;\n\n // Replace `object.eval(foo)` with `(1, object.eval)(foo)`.\n if (\n node.property.type === 'Identifier' &&\n node.property.name === 'eval' &&\n // We only apply this to MemberExpressions that are the callee of CallExpression\n path.parent.type === 'CallExpression' &&\n path.parent.callee === node\n ) {\n path.replaceWith(\n objectEvalWrapper({\n OBJECT: node.object,\n REF: node.property,\n }),\n );\n }\n },\n\n Identifier(path) {\n const { node } = path;\n\n // Insert `regeneratorRuntime` global if it's used in the code.\n if (node.name === 'regeneratorRuntime') {\n const program = path.findParent(\n (parent) => parent.node.type === 'Program',\n );\n\n // We know that `program` is a Program node here, but this keeps\n // TypeScript happy.\n if (program?.node.type === 'Program') {\n const body = program.node.body[0];\n\n // This stops it from inserting `regeneratorRuntime` multiple times.\n if (\n body.type === 'VariableDeclaration' &&\n (body.declarations[0].id as Identifier).name ===\n 'regeneratorRuntime'\n ) {\n return;\n }\n\n program?.node.body.unshift(regeneratorRuntimeWrapper());\n }\n }\n },\n\n TemplateLiteral(path) {\n const { node } = path;\n\n // This checks if the template literal was visited before. Without this,\n // it would cause an infinite loop resulting in a stack overflow. We can't\n // skip the path here, because we need to visit the children of the node.\n if (path.getData('visited')) {\n return;\n }\n\n // Break up tokens that could be parsed as HTML comment terminators, or\n // `import()` statements.\n // For reference:\n // - https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md\n // - https://github.com/MetaMask/snaps-monorepo/issues/505\n const [replacementQuasis, replacementExpressions] = node.quasis.reduce<\n [TemplateElement[], Expression[]]\n >(\n ([elements, expressions], quasi, index) => {\n // Note: Template literals have two variants, \"cooked\" and \"raw\". Here\n // we use the cooked version.\n // https://exploringjs.com/impatient-js/ch_template-literals.html#template-strings-cooked-vs-raw\n const tokens = breakTokensTemplateLiteral(\n quasi.value.cooked as string,\n );\n\n // Only update the node if something changed.\n if (tokens[0].length <= 1) {\n return [\n [...elements, quasi],\n [...expressions, node.expressions[index] as Expression],\n ];\n }\n\n return [\n [...elements, ...tokens[0]],\n [\n ...expressions,\n ...tokens[1],\n node.expressions[index] as Expression,\n ],\n ];\n },\n [[], []],\n );\n\n path.replaceWith(\n templateLiteral(\n replacementQuasis,\n replacementExpressions.filter(\n (expression) => expression !== undefined,\n ),\n ) as Node,\n );\n\n path.setData('visited', true);\n },\n\n StringLiteral(path) {\n const { node } = path;\n\n // Break up tokens that could be parsed as HTML comment terminators, or\n // `import()` statements.\n // For reference:\n // - https://github.com/endojs/endo/blob/70cc86eb400655e922413b99c38818d7b2e79da0/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md\n // - https://github.com/MetaMask/snaps-monorepo/issues/505\n const tokens = breakTokens(node.value);\n\n // Only update the node if the string literal was broken up.\n if (tokens.length <= 1) {\n return;\n }\n\n const replacement = tokens\n .slice(1)\n .reduce<Expression>(\n (acc, value) => binaryExpression('+', acc, stringLiteral(value)),\n stringLiteral(tokens[0]),\n );\n\n path.replaceWith(replacement as Node);\n path.skip();\n },\n\n BinaryExpression(path) {\n const { node } = path;\n\n const errorMessage =\n 'Using HTML comments (`<!--` and `-->`) as operators is not allowed. The behaviour of ' +\n 'these comments is ambiguous, and differs per browser and environment. If you want ' +\n 'to use them as operators, break them up into separate characters, i.e., `a-- > b` ' +\n 'and `a < ! --b`.';\n\n if (\n node.operator === '<' &&\n isUnaryExpression(node.right) &&\n isUpdateExpression(node.right.argument) &&\n node.right.argument.operator === '--' &&\n node.left.end &&\n node.right.argument.argument.start\n ) {\n const expression = code.slice(\n node.left.end,\n node.right.argument.argument.start,\n );\n\n if (expression.includes('<!--')) {\n throw new Error(errorMessage);\n }\n }\n\n if (\n node.operator === '>' &&\n isUpdateExpression(node.left) &&\n node.left.operator === '--' &&\n node.left.argument.end &&\n node.right.start\n ) {\n const expression = code.slice(node.left.argument.end, node.right.start);\n\n if (expression.includes('-->')) {\n throw new Error(errorMessage);\n }\n }\n },\n };\n\n try {\n const file = transformSync(code, {\n // Prevent Babel from searching for a config file.\n configFile: false,\n\n parserOpts: {\n // Strict mode isn't enabled by default, so we need to enable it here.\n strictMode: true,\n\n // If this is disabled, the AST does not include any comments. This is\n // useful for performance reasons, and we use it for stripping comments.\n attachComment: !stripComments,\n },\n\n // By default, Babel optimises bundles that exceed 500 KB, but that\n // results in characters which look like HTML comments, which breaks SES.\n compact: false,\n\n // This configures Babel to generate a new source map from the existing\n // source map if specified. If `sourceMap` is `true` but an input source\n // map is not provided, a new source map will be generated instead.\n inputSourceMap,\n sourceMaps,\n\n plugins: [\n () => ({\n pre,\n visitor,\n }),\n ],\n });\n\n if (!file?.code) {\n throw new Error('Bundled code is empty.');\n }\n\n return {\n code: file.code,\n sourceMap: file.map,\n warnings: Array.from(warnings),\n };\n } catch (error) {\n throw new Error(`Failed to post process code:\\n${error.message}`);\n }\n}\n"]}
|
package/dist/promise.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise.cjs","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":"","sourcesContent":["export type Promisable<Type> = Type | Promise<Type>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise.d.cts","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise.d.mts","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/promise.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=promise.mjs.map
|
package/dist/promise.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"promise.mjs","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":"","sourcesContent":["export type Promisable<Type> = Type | Promise<Type>;\n"]}
|
package/dist/snaps.cjs
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.verifyRequestedSnapPermissions = exports.isSnapPermitted = exports.isCaipChainId = exports.assertIsValidSnapId = exports.stripSnapPrefix = exports.getSnapPrefix = exports.SnapIdStruct = exports.HttpSnapIdStruct = exports.NpmSnapIdStruct = exports.LocalSnapIdStruct = exports.BaseSnapIdStruct = exports.LOCALHOST_HOSTNAMES = exports.validateSnapShasum = exports.getSnapChecksum = exports.SnapStatusEvents = exports.SnapStatus = exports.PROPOSED_NAME_REGEX = void 0;
|
|
7
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
8
|
+
const utils_1 = require("@metamask/utils");
|
|
9
|
+
const base_1 = require("@scure/base");
|
|
10
|
+
const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
|
11
|
+
const validate_npm_package_name_1 = __importDefault(require("validate-npm-package-name"));
|
|
12
|
+
const caveats_1 = require("./caveats.cjs");
|
|
13
|
+
const checksum_1 = require("./checksum.cjs");
|
|
14
|
+
const types_1 = require("./types.cjs");
|
|
15
|
+
// This RegEx matches valid npm package names (with some exceptions) and space-
|
|
16
|
+
// separated alphanumerical words, optionally with dashes and underscores.
|
|
17
|
+
// The RegEx consists of two parts. The first part matches space-separated
|
|
18
|
+
// words. It is based on the following Stackoverflow answer:
|
|
19
|
+
// https://stackoverflow.com/a/34974982
|
|
20
|
+
// The second part, after the pipe operator, is the same RegEx used for the
|
|
21
|
+
// `name` field of the official package.json JSON Schema, except that we allow
|
|
22
|
+
// mixed-case letters. It was originally copied from:
|
|
23
|
+
// https://github.com/SchemaStore/schemastore/blob/81a16897c1dabfd98c72242a5fd62eb080ff76d8/src/schemas/json/package.json#L132-L138
|
|
24
|
+
exports.PROPOSED_NAME_REGEX = /^(?:[A-Za-z0-9-_]+( [A-Za-z0-9-_]+)*)|(?:(?:@[A-Za-z0-9-*~][A-Za-z0-9-*._~]*\/)?[A-Za-z0-9-~][A-Za-z0-9-._~]*)$/u;
|
|
25
|
+
var SnapStatus;
|
|
26
|
+
(function (SnapStatus) {
|
|
27
|
+
SnapStatus["Installing"] = "installing";
|
|
28
|
+
SnapStatus["Updating"] = "updating";
|
|
29
|
+
SnapStatus["Running"] = "running";
|
|
30
|
+
SnapStatus["Stopped"] = "stopped";
|
|
31
|
+
SnapStatus["Crashed"] = "crashed";
|
|
32
|
+
})(SnapStatus || (exports.SnapStatus = SnapStatus = {}));
|
|
33
|
+
var SnapStatusEvents;
|
|
34
|
+
(function (SnapStatusEvents) {
|
|
35
|
+
SnapStatusEvents["Start"] = "START";
|
|
36
|
+
SnapStatusEvents["Stop"] = "STOP";
|
|
37
|
+
SnapStatusEvents["Crash"] = "CRASH";
|
|
38
|
+
SnapStatusEvents["Update"] = "UPDATE";
|
|
39
|
+
})(SnapStatusEvents || (exports.SnapStatusEvents = SnapStatusEvents = {}));
|
|
40
|
+
/**
|
|
41
|
+
* Gets a checksummable manifest by removing the shasum property and reserializing the JSON using a deterministic algorithm.
|
|
42
|
+
*
|
|
43
|
+
* @param manifest - The manifest itself.
|
|
44
|
+
* @returns A virtual file containing the checksummable manifest.
|
|
45
|
+
*/
|
|
46
|
+
function getChecksummableManifest(manifest) {
|
|
47
|
+
const manifestCopy = manifest.clone();
|
|
48
|
+
delete manifestCopy.result.source.shasum;
|
|
49
|
+
// We use fast-json-stable-stringify to deterministically serialize the JSON
|
|
50
|
+
// This is required before checksumming so we get reproducible checksums across platforms etc
|
|
51
|
+
manifestCopy.value = (0, fast_json_stable_stringify_1.default)(manifestCopy.result);
|
|
52
|
+
return manifestCopy;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Calculates the Base64-encoded SHA-256 digest of all required Snap files.
|
|
56
|
+
*
|
|
57
|
+
* @param files - All required Snap files to be included in the checksum.
|
|
58
|
+
* @returns The Base64-encoded SHA-256 digest of the source code.
|
|
59
|
+
*/
|
|
60
|
+
async function getSnapChecksum(files) {
|
|
61
|
+
const { manifest, sourceCode, svgIcon, auxiliaryFiles, localizationFiles } = files;
|
|
62
|
+
const all = [
|
|
63
|
+
getChecksummableManifest(manifest),
|
|
64
|
+
sourceCode,
|
|
65
|
+
svgIcon,
|
|
66
|
+
...auxiliaryFiles,
|
|
67
|
+
...localizationFiles,
|
|
68
|
+
].filter((file) => file !== undefined);
|
|
69
|
+
return base_1.base64.encode(await (0, checksum_1.checksumFiles)(all));
|
|
70
|
+
}
|
|
71
|
+
exports.getSnapChecksum = getSnapChecksum;
|
|
72
|
+
/**
|
|
73
|
+
* Checks whether the `source.shasum` property of a Snap manifest matches the
|
|
74
|
+
* shasum of the snap.
|
|
75
|
+
*
|
|
76
|
+
* @param files - All required Snap files to be included in the checksum.
|
|
77
|
+
* @param errorMessage - The error message to throw if validation fails.
|
|
78
|
+
*/
|
|
79
|
+
async function validateSnapShasum(files, errorMessage = 'Invalid Snap manifest: manifest shasum does not match computed shasum.') {
|
|
80
|
+
if (files.manifest.result.source.shasum !== (await getSnapChecksum(files))) {
|
|
81
|
+
throw new Error(errorMessage);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.validateSnapShasum = validateSnapShasum;
|
|
85
|
+
exports.LOCALHOST_HOSTNAMES = ['localhost', '127.0.0.1', '[::1]'];
|
|
86
|
+
// Require snap ids to only consist of printable ASCII characters
|
|
87
|
+
exports.BaseSnapIdStruct = (0, superstruct_1.pattern)((0, superstruct_1.string)(), /^[\x21-\x7E]*$/u);
|
|
88
|
+
const LocalSnapIdSubUrlStruct = (0, types_1.uri)({
|
|
89
|
+
protocol: (0, superstruct_1.enums)(['http:', 'https:']),
|
|
90
|
+
hostname: (0, superstruct_1.enums)(exports.LOCALHOST_HOSTNAMES),
|
|
91
|
+
hash: (0, superstruct_1.empty)((0, superstruct_1.string)()),
|
|
92
|
+
search: (0, superstruct_1.empty)((0, superstruct_1.string)()),
|
|
93
|
+
});
|
|
94
|
+
exports.LocalSnapIdStruct = (0, superstruct_1.refine)(exports.BaseSnapIdStruct, 'local Snap Id', (value) => {
|
|
95
|
+
if (!value.startsWith(types_1.SnapIdPrefixes.local)) {
|
|
96
|
+
return `Expected local snap ID, got "${value}".`;
|
|
97
|
+
}
|
|
98
|
+
const [error] = (0, superstruct_1.validate)(value.slice(types_1.SnapIdPrefixes.local.length), LocalSnapIdSubUrlStruct);
|
|
99
|
+
return error ?? true;
|
|
100
|
+
});
|
|
101
|
+
exports.NpmSnapIdStruct = (0, superstruct_1.intersection)([
|
|
102
|
+
exports.BaseSnapIdStruct,
|
|
103
|
+
(0, types_1.uri)({
|
|
104
|
+
protocol: (0, superstruct_1.literal)(types_1.SnapIdPrefixes.npm),
|
|
105
|
+
pathname: (0, superstruct_1.refine)((0, superstruct_1.string)(), 'package name', function* (value) {
|
|
106
|
+
const normalized = value.startsWith('/') ? value.slice(1) : value;
|
|
107
|
+
const { errors, validForNewPackages, warnings } = (0, validate_npm_package_name_1.default)(normalized);
|
|
108
|
+
if (!validForNewPackages) {
|
|
109
|
+
if (errors === undefined) {
|
|
110
|
+
(0, utils_1.assert)(warnings !== undefined);
|
|
111
|
+
yield* warnings;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
yield* errors;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return true;
|
|
118
|
+
}),
|
|
119
|
+
search: (0, superstruct_1.empty)((0, superstruct_1.string)()),
|
|
120
|
+
hash: (0, superstruct_1.empty)((0, superstruct_1.string)()),
|
|
121
|
+
}),
|
|
122
|
+
]);
|
|
123
|
+
exports.HttpSnapIdStruct = (0, superstruct_1.intersection)([
|
|
124
|
+
exports.BaseSnapIdStruct,
|
|
125
|
+
(0, types_1.uri)({
|
|
126
|
+
protocol: (0, superstruct_1.enums)(['http:', 'https:']),
|
|
127
|
+
search: (0, superstruct_1.empty)((0, superstruct_1.string)()),
|
|
128
|
+
hash: (0, superstruct_1.empty)((0, superstruct_1.string)()),
|
|
129
|
+
}),
|
|
130
|
+
]);
|
|
131
|
+
exports.SnapIdStruct = (0, superstruct_1.union)([exports.NpmSnapIdStruct, exports.LocalSnapIdStruct]);
|
|
132
|
+
/**
|
|
133
|
+
* Extracts the snap prefix from a snap ID.
|
|
134
|
+
*
|
|
135
|
+
* @param snapId - The snap ID to extract the prefix from.
|
|
136
|
+
* @returns The snap prefix from a snap id, e.g. `npm:`.
|
|
137
|
+
*/
|
|
138
|
+
function getSnapPrefix(snapId) {
|
|
139
|
+
const prefix = Object.values(types_1.SnapIdPrefixes).find((possiblePrefix) => snapId.startsWith(possiblePrefix));
|
|
140
|
+
if (prefix !== undefined) {
|
|
141
|
+
return prefix;
|
|
142
|
+
}
|
|
143
|
+
throw new Error(`Invalid or no prefix found for "${snapId}"`);
|
|
144
|
+
}
|
|
145
|
+
exports.getSnapPrefix = getSnapPrefix;
|
|
146
|
+
/**
|
|
147
|
+
* Strips snap prefix from a full snap ID.
|
|
148
|
+
*
|
|
149
|
+
* @param snapId - The snap ID to strip.
|
|
150
|
+
* @returns The stripped snap ID.
|
|
151
|
+
*/
|
|
152
|
+
function stripSnapPrefix(snapId) {
|
|
153
|
+
return snapId.replace(getSnapPrefix(snapId), '');
|
|
154
|
+
}
|
|
155
|
+
exports.stripSnapPrefix = stripSnapPrefix;
|
|
156
|
+
/**
|
|
157
|
+
* Assert that the given value is a valid snap ID.
|
|
158
|
+
*
|
|
159
|
+
* @param value - The value to check.
|
|
160
|
+
* @throws If the value is not a valid snap ID.
|
|
161
|
+
*/
|
|
162
|
+
function assertIsValidSnapId(value) {
|
|
163
|
+
(0, utils_1.assertStruct)(value, exports.SnapIdStruct, 'Invalid snap ID');
|
|
164
|
+
}
|
|
165
|
+
exports.assertIsValidSnapId = assertIsValidSnapId;
|
|
166
|
+
/**
|
|
167
|
+
* Typeguard to ensure a chainId follows the CAIP-2 standard.
|
|
168
|
+
*
|
|
169
|
+
* @param chainId - The chainId being tested.
|
|
170
|
+
* @returns `true` if the value is a valid CAIP chain id, and `false` otherwise.
|
|
171
|
+
*/
|
|
172
|
+
function isCaipChainId(chainId) {
|
|
173
|
+
return (typeof chainId === 'string' &&
|
|
174
|
+
/^(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-a-zA-Z0-9]{1,32})$/u.test(chainId));
|
|
175
|
+
}
|
|
176
|
+
exports.isCaipChainId = isCaipChainId;
|
|
177
|
+
/**
|
|
178
|
+
* Utility function to check if an origin has permission (and caveat) for a particular snap.
|
|
179
|
+
*
|
|
180
|
+
* @param permissions - An origin's permissions object.
|
|
181
|
+
* @param snapId - The id of the snap.
|
|
182
|
+
* @returns A boolean based on if an origin has the specified snap.
|
|
183
|
+
*/
|
|
184
|
+
function isSnapPermitted(permissions, snapId) {
|
|
185
|
+
return Boolean((permissions?.wallet_snap?.caveats?.find((caveat) => caveat.type === caveats_1.SnapCaveatType.SnapIds) ?? {}).value?.[snapId]);
|
|
186
|
+
}
|
|
187
|
+
exports.isSnapPermitted = isSnapPermitted;
|
|
188
|
+
/**
|
|
189
|
+
* Checks whether the passed in requestedPermissions is a valid
|
|
190
|
+
* permission request for a `wallet_snap` permission.
|
|
191
|
+
*
|
|
192
|
+
* @param requestedPermissions - The requested permissions.
|
|
193
|
+
* @throws If the criteria is not met.
|
|
194
|
+
*/
|
|
195
|
+
function verifyRequestedSnapPermissions(requestedPermissions) {
|
|
196
|
+
(0, utils_1.assert)((0, utils_1.isObject)(requestedPermissions), 'Requested permissions must be an object.');
|
|
197
|
+
const { wallet_snap: walletSnapPermission } = requestedPermissions;
|
|
198
|
+
(0, utils_1.assert)((0, utils_1.isObject)(walletSnapPermission), 'wallet_snap is missing from the requested permissions.');
|
|
199
|
+
const { caveats } = walletSnapPermission;
|
|
200
|
+
(0, utils_1.assert)(Array.isArray(caveats) && caveats.length === 1, 'wallet_snap must have a caveat property with a single-item array value.');
|
|
201
|
+
const [caveat] = caveats;
|
|
202
|
+
(0, utils_1.assert)((0, utils_1.isObject)(caveat) &&
|
|
203
|
+
caveat.type === caveats_1.SnapCaveatType.SnapIds &&
|
|
204
|
+
(0, utils_1.isObject)(caveat.value), `The requested permissions do not have a valid ${caveats_1.SnapCaveatType.SnapIds} caveat.`);
|
|
205
|
+
}
|
|
206
|
+
exports.verifyRequestedSnapPermissions = verifyRequestedSnapPermissions;
|
|
207
|
+
//# sourceMappingURL=snaps.cjs.map
|