@ht-sdks/events-sdk-js-browser 1.0.4
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/LICENSE.MD +45 -0
- package/README.md +227 -0
- package/dist/cjs/browser/browser-umd.js +21 -0
- package/dist/cjs/browser/browser-umd.js.map +1 -0
- package/dist/cjs/browser/index.js +351 -0
- package/dist/cjs/browser/index.js.map +1 -0
- package/dist/cjs/browser/standalone-analytics.js +62 -0
- package/dist/cjs/browser/standalone-analytics.js.map +1 -0
- package/dist/cjs/browser/standalone-interface.js +3 -0
- package/dist/cjs/browser/standalone-interface.js.map +1 -0
- package/dist/cjs/browser/standalone.js +95 -0
- package/dist/cjs/browser/standalone.js.map +1 -0
- package/dist/cjs/core/analytics/index.js +589 -0
- package/dist/cjs/core/analytics/index.js.map +1 -0
- package/dist/cjs/core/analytics/interfaces.js +3 -0
- package/dist/cjs/core/analytics/interfaces.js.map +1 -0
- package/dist/cjs/core/arguments-resolver/index.js +134 -0
- package/dist/cjs/core/arguments-resolver/index.js.map +1 -0
- package/dist/cjs/core/auto-track.js +108 -0
- package/dist/cjs/core/auto-track.js.map +1 -0
- package/dist/cjs/core/buffer/index.js +303 -0
- package/dist/cjs/core/buffer/index.js.map +1 -0
- package/dist/cjs/core/callback/index.js +7 -0
- package/dist/cjs/core/callback/index.js.map +1 -0
- package/dist/cjs/core/connection/index.js +16 -0
- package/dist/cjs/core/connection/index.js.map +1 -0
- package/dist/cjs/core/constants/index.js +5 -0
- package/dist/cjs/core/constants/index.js.map +1 -0
- package/dist/cjs/core/context/index.js +19 -0
- package/dist/cjs/core/context/index.js.map +1 -0
- package/dist/cjs/core/environment/index.js +12 -0
- package/dist/cjs/core/environment/index.js.map +1 -0
- package/dist/cjs/core/events/index.js +138 -0
- package/dist/cjs/core/events/index.js.map +1 -0
- package/dist/cjs/core/events/interfaces.js +3 -0
- package/dist/cjs/core/events/interfaces.js.map +1 -0
- package/dist/cjs/core/inspector/index.js +14 -0
- package/dist/cjs/core/inspector/index.js.map +1 -0
- package/dist/cjs/core/page/add-page-context.js +25 -0
- package/dist/cjs/core/page/add-page-context.js.map +1 -0
- package/dist/cjs/core/page/get-page-context.js +92 -0
- package/dist/cjs/core/page/get-page-context.js.map +1 -0
- package/dist/cjs/core/page/index.js +6 -0
- package/dist/cjs/core/page/index.js.map +1 -0
- package/dist/cjs/core/plugin/index.js +3 -0
- package/dist/cjs/core/plugin/index.js.map +1 -0
- package/dist/cjs/core/query-string/gracefulDecodeURIComponent.js +20 -0
- package/dist/cjs/core/query-string/gracefulDecodeURIComponent.js.map +1 -0
- package/dist/cjs/core/query-string/index.js +48 -0
- package/dist/cjs/core/query-string/index.js.map +1 -0
- package/dist/cjs/core/query-string/pickPrefix.js +20 -0
- package/dist/cjs/core/query-string/pickPrefix.js.map +1 -0
- package/dist/cjs/core/queue/event-queue.js +27 -0
- package/dist/cjs/core/queue/event-queue.js.map +1 -0
- package/dist/cjs/core/session/index.js +71 -0
- package/dist/cjs/core/session/index.js.map +1 -0
- package/dist/cjs/core/stats/index.js +23 -0
- package/dist/cjs/core/stats/index.js.map +1 -0
- package/dist/cjs/core/stats/remote-metrics.js +111 -0
- package/dist/cjs/core/stats/remote-metrics.js.map +1 -0
- package/dist/cjs/core/storage/cookieStorage.js +72 -0
- package/dist/cjs/core/storage/cookieStorage.js.map +1 -0
- package/dist/cjs/core/storage/index.js +64 -0
- package/dist/cjs/core/storage/index.js.map +1 -0
- package/dist/cjs/core/storage/localStorage.js +51 -0
- package/dist/cjs/core/storage/localStorage.js.map +1 -0
- package/dist/cjs/core/storage/memoryStorage.js +24 -0
- package/dist/cjs/core/storage/memoryStorage.js.map +1 -0
- package/dist/cjs/core/storage/settings.js +16 -0
- package/dist/cjs/core/storage/settings.js.map +1 -0
- package/dist/cjs/core/storage/types.js +9 -0
- package/dist/cjs/core/storage/types.js.map +1 -0
- package/dist/cjs/core/storage/universalStorage.js +66 -0
- package/dist/cjs/core/storage/universalStorage.js.map +1 -0
- package/dist/cjs/core/user/index.js +273 -0
- package/dist/cjs/core/user/index.js.map +1 -0
- package/dist/cjs/core/user/migrate.js +114 -0
- package/dist/cjs/core/user/migrate.js.map +1 -0
- package/dist/cjs/core/user/tld.js +64 -0
- package/dist/cjs/core/user/tld.js.map +1 -0
- package/dist/cjs/core/user/vendor/crypto-es/lib/aes.js +248 -0
- package/dist/cjs/core/user/vendor/crypto-es/lib/aes.js.map +1 -0
- package/dist/cjs/core/user/vendor/crypto-es/lib/cipher-core.js +841 -0
- package/dist/cjs/core/user/vendor/crypto-es/lib/cipher-core.js.map +1 -0
- package/dist/cjs/core/user/vendor/crypto-es/lib/core.js +747 -0
- package/dist/cjs/core/user/vendor/crypto-es/lib/core.js.map +1 -0
- package/dist/cjs/core/user/vendor/crypto-es/lib/enc-base64.js +102 -0
- package/dist/cjs/core/user/vendor/crypto-es/lib/enc-base64.js.map +1 -0
- package/dist/cjs/core/user/vendor/crypto-es/lib/evpkdf.js +105 -0
- package/dist/cjs/core/user/vendor/crypto-es/lib/evpkdf.js.map +1 -0
- package/dist/cjs/core/user/vendor/crypto-es/lib/md5.js +217 -0
- package/dist/cjs/core/user/vendor/crypto-es/lib/md5.js.map +1 -0
- package/dist/cjs/generated/version.js +6 -0
- package/dist/cjs/generated/version.js.map +1 -0
- package/dist/cjs/index.js +16 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/bind-all.js +17 -0
- package/dist/cjs/lib/bind-all.js.map +1 -0
- package/dist/cjs/lib/browser-polyfill.js +22 -0
- package/dist/cjs/lib/browser-polyfill.js.map +1 -0
- package/dist/cjs/lib/client-hints/index.js +21 -0
- package/dist/cjs/lib/client-hints/index.js.map +1 -0
- package/dist/cjs/lib/client-hints/interfaces.js +3 -0
- package/dist/cjs/lib/client-hints/interfaces.js.map +1 -0
- package/dist/cjs/lib/create-deferred.js +21 -0
- package/dist/cjs/lib/create-deferred.js.map +1 -0
- package/dist/cjs/lib/csp-detection.js +8 -0
- package/dist/cjs/lib/csp-detection.js.map +1 -0
- package/dist/cjs/lib/embedded-write-key.js +22 -0
- package/dist/cjs/lib/embedded-write-key.js.map +1 -0
- package/dist/cjs/lib/fetch.js +19 -0
- package/dist/cjs/lib/fetch.js.map +1 -0
- package/dist/cjs/lib/get-global.js +21 -0
- package/dist/cjs/lib/get-global.js.map +1 -0
- package/dist/cjs/lib/get-process-env.js +15 -0
- package/dist/cjs/lib/get-process-env.js.map +1 -0
- package/dist/cjs/lib/global-analytics-helper.js +34 -0
- package/dist/cjs/lib/global-analytics-helper.js.map +1 -0
- package/dist/cjs/lib/group-by.js +28 -0
- package/dist/cjs/lib/group-by.js.map +1 -0
- package/dist/cjs/lib/is-plan-event-enabled.js +20 -0
- package/dist/cjs/lib/is-plan-event-enabled.js.map +1 -0
- package/dist/cjs/lib/is-thenable.js +15 -0
- package/dist/cjs/lib/is-thenable.js.map +1 -0
- package/dist/cjs/lib/load-script.js +56 -0
- package/dist/cjs/lib/load-script.js.map +1 -0
- package/dist/cjs/lib/merged-options.js +31 -0
- package/dist/cjs/lib/merged-options.js.map +1 -0
- package/dist/cjs/lib/on-page-change.js +35 -0
- package/dist/cjs/lib/on-page-change.js.map +1 -0
- package/dist/cjs/lib/p-while.js +25 -0
- package/dist/cjs/lib/p-while.js.map +1 -0
- package/dist/cjs/lib/parse-cdn.js +55 -0
- package/dist/cjs/lib/parse-cdn.js.map +1 -0
- package/dist/cjs/lib/pick.js +19 -0
- package/dist/cjs/lib/pick.js.map +1 -0
- package/dist/cjs/lib/priority-queue/backoff.js +10 -0
- package/dist/cjs/lib/priority-queue/backoff.js.map +1 -0
- package/dist/cjs/lib/priority-queue/index.js +7 -0
- package/dist/cjs/lib/priority-queue/index.js.map +1 -0
- package/dist/cjs/lib/priority-queue/persisted.js +108 -0
- package/dist/cjs/lib/priority-queue/persisted.js.map +1 -0
- package/dist/cjs/lib/sleep.js +10 -0
- package/dist/cjs/lib/sleep.js.map +1 -0
- package/dist/cjs/lib/to-facade.js +32 -0
- package/dist/cjs/lib/to-facade.js.map +1 -0
- package/dist/cjs/lib/version-type.js +14 -0
- package/dist/cjs/lib/version-type.js.map +1 -0
- package/dist/cjs/node/index.js +43 -0
- package/dist/cjs/node/index.js.map +1 -0
- package/dist/cjs/node/node.browser.js +13 -0
- package/dist/cjs/node/node.browser.js.map +1 -0
- package/dist/cjs/plugins/ajs-destination/index.js +345 -0
- package/dist/cjs/plugins/ajs-destination/index.js.map +1 -0
- package/dist/cjs/plugins/ajs-destination/loader.js +110 -0
- package/dist/cjs/plugins/ajs-destination/loader.js.map +1 -0
- package/dist/cjs/plugins/ajs-destination/types.js +3 -0
- package/dist/cjs/plugins/ajs-destination/types.js.map +1 -0
- package/dist/cjs/plugins/ajs-destination/utils.js +23 -0
- package/dist/cjs/plugins/ajs-destination/utils.js.map +1 -0
- package/dist/cjs/plugins/analytics-node/index.js +65 -0
- package/dist/cjs/plugins/analytics-node/index.js.map +1 -0
- package/dist/cjs/plugins/env-enrichment/index.js +181 -0
- package/dist/cjs/plugins/env-enrichment/index.js.map +1 -0
- package/dist/cjs/plugins/hightouchio/batched-dispatcher.js +113 -0
- package/dist/cjs/plugins/hightouchio/batched-dispatcher.js.map +1 -0
- package/dist/cjs/plugins/hightouchio/fetch-dispatcher.js +21 -0
- package/dist/cjs/plugins/hightouchio/fetch-dispatcher.js.map +1 -0
- package/dist/cjs/plugins/hightouchio/index.js +100 -0
- package/dist/cjs/plugins/hightouchio/index.js.map +1 -0
- package/dist/cjs/plugins/hightouchio/normalize.js +54 -0
- package/dist/cjs/plugins/hightouchio/normalize.js.map +1 -0
- package/dist/cjs/plugins/hightouchio/schedule-flush.js +76 -0
- package/dist/cjs/plugins/hightouchio/schedule-flush.js.map +1 -0
- package/dist/cjs/plugins/legacy-video-plugins/index.js +25 -0
- package/dist/cjs/plugins/legacy-video-plugins/index.js.map +1 -0
- package/dist/cjs/plugins/middleware/index.js +124 -0
- package/dist/cjs/plugins/middleware/index.js.map +1 -0
- package/dist/cjs/plugins/remote-loader/index.js +236 -0
- package/dist/cjs/plugins/remote-loader/index.js.map +1 -0
- package/dist/cjs/plugins/remote-middleware/index.js +70 -0
- package/dist/cjs/plugins/remote-middleware/index.js.map +1 -0
- package/dist/cjs/plugins/routing-middleware/index.js +26 -0
- package/dist/cjs/plugins/routing-middleware/index.js.map +1 -0
- package/dist/cjs/plugins/schema-filter/index.js +67 -0
- package/dist/cjs/plugins/schema-filter/index.js.map +1 -0
- package/dist/cjs/plugins/validation/index.js +33 -0
- package/dist/cjs/plugins/validation/index.js.map +1 -0
- package/dist/pkg/browser/browser-umd.js +18 -0
- package/dist/pkg/browser/browser-umd.js.map +1 -0
- package/dist/pkg/browser/index.js +347 -0
- package/dist/pkg/browser/index.js.map +1 -0
- package/dist/pkg/browser/standalone-analytics.js +58 -0
- package/dist/pkg/browser/standalone-analytics.js.map +1 -0
- package/dist/pkg/browser/standalone-interface.js +2 -0
- package/dist/pkg/browser/standalone-interface.js.map +1 -0
- package/dist/pkg/browser/standalone.js +93 -0
- package/dist/pkg/browser/standalone.js.map +1 -0
- package/dist/pkg/core/analytics/index.js +586 -0
- package/dist/pkg/core/analytics/index.js.map +1 -0
- package/dist/pkg/core/analytics/interfaces.js +2 -0
- package/dist/pkg/core/analytics/interfaces.js.map +1 -0
- package/dist/pkg/core/arguments-resolver/index.js +127 -0
- package/dist/pkg/core/arguments-resolver/index.js.map +1 -0
- package/dist/pkg/core/auto-track.js +103 -0
- package/dist/pkg/core/auto-track.js.map +1 -0
- package/dist/pkg/core/buffer/index.js +295 -0
- package/dist/pkg/core/buffer/index.js.map +1 -0
- package/dist/pkg/core/callback/index.js +2 -0
- package/dist/pkg/core/callback/index.js.map +1 -0
- package/dist/pkg/core/connection/index.js +11 -0
- package/dist/pkg/core/connection/index.js.map +1 -0
- package/dist/pkg/core/constants/index.js +2 -0
- package/dist/pkg/core/constants/index.js.map +1 -0
- package/dist/pkg/core/context/index.js +16 -0
- package/dist/pkg/core/context/index.js.map +1 -0
- package/dist/pkg/core/environment/index.js +7 -0
- package/dist/pkg/core/environment/index.js.map +1 -0
- package/dist/pkg/core/events/index.js +135 -0
- package/dist/pkg/core/events/index.js.map +1 -0
- package/dist/pkg/core/events/interfaces.js +2 -0
- package/dist/pkg/core/events/interfaces.js.map +1 -0
- package/dist/pkg/core/inspector/index.js +10 -0
- package/dist/pkg/core/inspector/index.js.map +1 -0
- package/dist/pkg/core/page/add-page-context.js +21 -0
- package/dist/pkg/core/page/add-page-context.js.map +1 -0
- package/dist/pkg/core/page/get-page-context.js +84 -0
- package/dist/pkg/core/page/get-page-context.js.map +1 -0
- package/dist/pkg/core/page/index.js +3 -0
- package/dist/pkg/core/page/index.js.map +1 -0
- package/dist/pkg/core/plugin/index.js +2 -0
- package/dist/pkg/core/plugin/index.js.map +1 -0
- package/dist/pkg/core/query-string/gracefulDecodeURIComponent.js +16 -0
- package/dist/pkg/core/query-string/gracefulDecodeURIComponent.js.map +1 -0
- package/dist/pkg/core/query-string/index.js +44 -0
- package/dist/pkg/core/query-string/index.js.map +1 -0
- package/dist/pkg/core/query-string/pickPrefix.js +16 -0
- package/dist/pkg/core/query-string/pickPrefix.js.map +1 -0
- package/dist/pkg/core/queue/event-queue.js +24 -0
- package/dist/pkg/core/queue/event-queue.js.map +1 -0
- package/dist/pkg/core/session/index.js +63 -0
- package/dist/pkg/core/session/index.js.map +1 -0
- package/dist/pkg/core/stats/index.js +20 -0
- package/dist/pkg/core/stats/index.js.map +1 -0
- package/dist/pkg/core/stats/remote-metrics.js +108 -0
- package/dist/pkg/core/stats/remote-metrics.js.map +1 -0
- package/dist/pkg/core/storage/cookieStorage.js +69 -0
- package/dist/pkg/core/storage/cookieStorage.js.map +1 -0
- package/dist/pkg/core/storage/index.js +58 -0
- package/dist/pkg/core/storage/index.js.map +1 -0
- package/dist/pkg/core/storage/localStorage.js +48 -0
- package/dist/pkg/core/storage/localStorage.js.map +1 -0
- package/dist/pkg/core/storage/memoryStorage.js +21 -0
- package/dist/pkg/core/storage/memoryStorage.js.map +1 -0
- package/dist/pkg/core/storage/settings.js +11 -0
- package/dist/pkg/core/storage/settings.js.map +1 -0
- package/dist/pkg/core/storage/types.js +6 -0
- package/dist/pkg/core/storage/types.js.map +1 -0
- package/dist/pkg/core/storage/universalStorage.js +63 -0
- package/dist/pkg/core/storage/universalStorage.js.map +1 -0
- package/dist/pkg/core/user/index.js +270 -0
- package/dist/pkg/core/user/index.js.map +1 -0
- package/dist/pkg/core/user/migrate.js +109 -0
- package/dist/pkg/core/user/migrate.js.map +1 -0
- package/dist/pkg/core/user/tld.js +59 -0
- package/dist/pkg/core/user/tld.js.map +1 -0
- package/dist/pkg/core/user/vendor/crypto-es/lib/aes.js +245 -0
- package/dist/pkg/core/user/vendor/crypto-es/lib/aes.js.map +1 -0
- package/dist/pkg/core/user/vendor/crypto-es/lib/cipher-core.js +838 -0
- package/dist/pkg/core/user/vendor/crypto-es/lib/cipher-core.js.map +1 -0
- package/dist/pkg/core/user/vendor/crypto-es/lib/core.js +744 -0
- package/dist/pkg/core/user/vendor/crypto-es/lib/core.js.map +1 -0
- package/dist/pkg/core/user/vendor/crypto-es/lib/enc-base64.js +98 -0
- package/dist/pkg/core/user/vendor/crypto-es/lib/enc-base64.js.map +1 -0
- package/dist/pkg/core/user/vendor/crypto-es/lib/evpkdf.js +101 -0
- package/dist/pkg/core/user/vendor/crypto-es/lib/evpkdf.js.map +1 -0
- package/dist/pkg/core/user/vendor/crypto-es/lib/md5.js +214 -0
- package/dist/pkg/core/user/vendor/crypto-es/lib/md5.js.map +1 -0
- package/dist/pkg/generated/version.js +3 -0
- package/dist/pkg/generated/version.js.map +1 -0
- package/dist/pkg/index.js +10 -0
- package/dist/pkg/index.js.map +1 -0
- package/dist/pkg/lib/bind-all.js +14 -0
- package/dist/pkg/lib/bind-all.js.map +1 -0
- package/dist/pkg/lib/browser-polyfill.js +18 -0
- package/dist/pkg/lib/browser-polyfill.js.map +1 -0
- package/dist/pkg/lib/client-hints/index.js +17 -0
- package/dist/pkg/lib/client-hints/index.js.map +1 -0
- package/dist/pkg/lib/client-hints/interfaces.js +2 -0
- package/dist/pkg/lib/client-hints/interfaces.js.map +1 -0
- package/dist/pkg/lib/create-deferred.js +17 -0
- package/dist/pkg/lib/create-deferred.js.map +1 -0
- package/dist/pkg/lib/csp-detection.js +4 -0
- package/dist/pkg/lib/csp-detection.js.map +1 -0
- package/dist/pkg/lib/embedded-write-key.js +18 -0
- package/dist/pkg/lib/embedded-write-key.js.map +1 -0
- package/dist/pkg/lib/fetch.js +14 -0
- package/dist/pkg/lib/fetch.js.map +1 -0
- package/dist/pkg/lib/get-global.js +17 -0
- package/dist/pkg/lib/get-global.js.map +1 -0
- package/dist/pkg/lib/get-process-env.js +11 -0
- package/dist/pkg/lib/get-process-env.js.map +1 -0
- package/dist/pkg/lib/global-analytics-helper.js +28 -0
- package/dist/pkg/lib/global-analytics-helper.js.map +1 -0
- package/dist/pkg/lib/group-by.js +24 -0
- package/dist/pkg/lib/group-by.js.map +1 -0
- package/dist/pkg/lib/is-plan-event-enabled.js +16 -0
- package/dist/pkg/lib/is-plan-event-enabled.js.map +1 -0
- package/dist/pkg/lib/is-thenable.js +11 -0
- package/dist/pkg/lib/is-thenable.js.map +1 -0
- package/dist/pkg/lib/load-script.js +51 -0
- package/dist/pkg/lib/load-script.js.map +1 -0
- package/dist/pkg/lib/merged-options.js +27 -0
- package/dist/pkg/lib/merged-options.js.map +1 -0
- package/dist/pkg/lib/on-page-change.js +31 -0
- package/dist/pkg/lib/on-page-change.js.map +1 -0
- package/dist/pkg/lib/p-while.js +21 -0
- package/dist/pkg/lib/p-while.js.map +1 -0
- package/dist/pkg/lib/parse-cdn.js +49 -0
- package/dist/pkg/lib/parse-cdn.js.map +1 -0
- package/dist/pkg/lib/pick.js +15 -0
- package/dist/pkg/lib/pick.js.map +1 -0
- package/dist/pkg/lib/priority-queue/backoff.js +6 -0
- package/dist/pkg/lib/priority-queue/backoff.js.map +1 -0
- package/dist/pkg/lib/priority-queue/index.js +3 -0
- package/dist/pkg/lib/priority-queue/index.js.map +1 -0
- package/dist/pkg/lib/priority-queue/persisted.js +105 -0
- package/dist/pkg/lib/priority-queue/persisted.js.map +1 -0
- package/dist/pkg/lib/sleep.js +6 -0
- package/dist/pkg/lib/sleep.js.map +1 -0
- package/dist/pkg/lib/to-facade.js +28 -0
- package/dist/pkg/lib/to-facade.js.map +1 -0
- package/dist/pkg/lib/version-type.js +9 -0
- package/dist/pkg/lib/version-type.js.map +1 -0
- package/dist/pkg/node/index.js +40 -0
- package/dist/pkg/node/index.js.map +1 -0
- package/dist/pkg/node/node.browser.js +10 -0
- package/dist/pkg/node/node.browser.js.map +1 -0
- package/dist/pkg/plugins/ajs-destination/index.js +341 -0
- package/dist/pkg/plugins/ajs-destination/index.js.map +1 -0
- package/dist/pkg/plugins/ajs-destination/loader.js +102 -0
- package/dist/pkg/plugins/ajs-destination/loader.js.map +1 -0
- package/dist/pkg/plugins/ajs-destination/types.js +2 -0
- package/dist/pkg/plugins/ajs-destination/types.js.map +1 -0
- package/dist/pkg/plugins/ajs-destination/utils.js +18 -0
- package/dist/pkg/plugins/ajs-destination/utils.js.map +1 -0
- package/dist/pkg/plugins/analytics-node/index.js +60 -0
- package/dist/pkg/plugins/analytics-node/index.js.map +1 -0
- package/dist/pkg/plugins/env-enrichment/index.js +176 -0
- package/dist/pkg/plugins/env-enrichment/index.js.map +1 -0
- package/dist/pkg/plugins/hightouchio/batched-dispatcher.js +110 -0
- package/dist/pkg/plugins/hightouchio/batched-dispatcher.js.map +1 -0
- package/dist/pkg/plugins/hightouchio/fetch-dispatcher.js +18 -0
- package/dist/pkg/plugins/hightouchio/fetch-dispatcher.js.map +1 -0
- package/dist/pkg/plugins/hightouchio/index.js +96 -0
- package/dist/pkg/plugins/hightouchio/index.js.map +1 -0
- package/dist/pkg/plugins/hightouchio/normalize.js +50 -0
- package/dist/pkg/plugins/hightouchio/normalize.js.map +1 -0
- package/dist/pkg/plugins/hightouchio/schedule-flush.js +72 -0
- package/dist/pkg/plugins/hightouchio/schedule-flush.js.map +1 -0
- package/dist/pkg/plugins/legacy-video-plugins/index.js +25 -0
- package/dist/pkg/plugins/legacy-video-plugins/index.js.map +1 -0
- package/dist/pkg/plugins/middleware/index.js +119 -0
- package/dist/pkg/plugins/middleware/index.js.map +1 -0
- package/dist/pkg/plugins/remote-loader/index.js +232 -0
- package/dist/pkg/plugins/remote-loader/index.js.map +1 -0
- package/dist/pkg/plugins/remote-middleware/index.js +66 -0
- package/dist/pkg/plugins/remote-middleware/index.js.map +1 -0
- package/dist/pkg/plugins/routing-middleware/index.js +21 -0
- package/dist/pkg/plugins/routing-middleware/index.js.map +1 -0
- package/dist/pkg/plugins/schema-filter/index.js +63 -0
- package/dist/pkg/plugins/schema-filter/index.js.map +1 -0
- package/dist/pkg/plugins/validation/index.js +30 -0
- package/dist/pkg/plugins/validation/index.js.map +1 -0
- package/dist/types/browser/browser-umd.d.ts +2 -0
- package/dist/types/browser/browser-umd.d.ts.map +1 -0
- package/dist/types/browser/index.d.ts +109 -0
- package/dist/types/browser/index.d.ts.map +1 -0
- package/dist/types/browser/standalone-analytics.d.ts +2 -0
- package/dist/types/browser/standalone-analytics.d.ts.map +1 -0
- package/dist/types/browser/standalone-interface.d.ts +10 -0
- package/dist/types/browser/standalone-interface.d.ts.map +1 -0
- package/dist/types/browser/standalone.d.ts +2 -0
- package/dist/types/browser/standalone.d.ts.map +1 -0
- package/dist/types/core/analytics/index.d.ts +149 -0
- package/dist/types/core/analytics/index.d.ts.map +1 -0
- package/dist/types/core/analytics/interfaces.d.ts +77 -0
- package/dist/types/core/analytics/interfaces.d.ts.map +1 -0
- package/dist/types/core/arguments-resolver/index.d.ts +34 -0
- package/dist/types/core/arguments-resolver/index.d.ts.map +1 -0
- package/dist/types/core/auto-track.d.ts +10 -0
- package/dist/types/core/auto-track.d.ts.map +1 -0
- package/dist/types/core/buffer/index.d.ts +102 -0
- package/dist/types/core/buffer/index.d.ts.map +1 -0
- package/dist/types/core/callback/index.d.ts +2 -0
- package/dist/types/core/callback/index.d.ts.map +1 -0
- package/dist/types/core/connection/index.d.ts +3 -0
- package/dist/types/core/connection/index.d.ts.map +1 -0
- package/dist/types/core/constants/index.d.ts +2 -0
- package/dist/types/core/constants/index.d.ts.map +1 -0
- package/dist/types/core/context/index.d.ts +9 -0
- package/dist/types/core/context/index.d.ts.map +1 -0
- package/dist/types/core/environment/index.d.ts +3 -0
- package/dist/types/core/environment/index.d.ts.map +1 -0
- package/dist/types/core/events/index.d.ts +22 -0
- package/dist/types/core/events/index.d.ts.map +1 -0
- package/dist/types/core/events/interfaces.d.ts +9 -0
- package/dist/types/core/events/interfaces.d.ts.map +1 -0
- package/dist/types/core/inspector/index.d.ts +3 -0
- package/dist/types/core/inspector/index.d.ts.map +1 -0
- package/dist/types/core/page/add-page-context.d.ts +9 -0
- package/dist/types/core/page/add-page-context.d.ts.map +1 -0
- package/dist/types/core/page/get-page-context.d.ts +45 -0
- package/dist/types/core/page/get-page-context.d.ts.map +1 -0
- package/dist/types/core/page/index.d.ts +3 -0
- package/dist/types/core/page/index.d.ts.map +1 -0
- package/dist/types/core/plugin/index.d.ts +11 -0
- package/dist/types/core/plugin/index.d.ts.map +1 -0
- package/dist/types/core/query-string/gracefulDecodeURIComponent.d.ts +9 -0
- package/dist/types/core/query-string/gracefulDecodeURIComponent.d.ts.map +1 -0
- package/dist/types/core/query-string/index.d.ts +7 -0
- package/dist/types/core/query-string/index.d.ts.map +1 -0
- package/dist/types/core/query-string/pickPrefix.d.ts +9 -0
- package/dist/types/core/query-string/pickPrefix.d.ts.map +1 -0
- package/dist/types/core/queue/event-queue.d.ts +10 -0
- package/dist/types/core/queue/event-queue.d.ts.map +1 -0
- package/dist/types/core/session/index.d.ts +32 -0
- package/dist/types/core/session/index.d.ts.map +1 -0
- package/dist/types/core/stats/index.d.ts +7 -0
- package/dist/types/core/stats/index.d.ts.map +1 -0
- package/dist/types/core/stats/remote-metrics.d.ts +32 -0
- package/dist/types/core/stats/remote-metrics.d.ts.map +1 -0
- package/dist/types/core/storage/cookieStorage.d.ts +21 -0
- package/dist/types/core/storage/cookieStorage.d.ts.map +1 -0
- package/dist/types/core/storage/index.d.ts +22 -0
- package/dist/types/core/storage/index.d.ts.map +1 -0
- package/dist/types/core/storage/localStorage.d.ts +11 -0
- package/dist/types/core/storage/localStorage.d.ts.map +1 -0
- package/dist/types/core/storage/memoryStorage.d.ts +11 -0
- package/dist/types/core/storage/memoryStorage.d.ts.map +1 -0
- package/dist/types/core/storage/settings.d.ts +8 -0
- package/dist/types/core/storage/settings.d.ts.map +1 -0
- package/dist/types/core/storage/types.d.ts +43 -0
- package/dist/types/core/storage/types.d.ts.map +1 -0
- package/dist/types/core/storage/universalStorage.d.ts +13 -0
- package/dist/types/core/storage/universalStorage.d.ts.map +1 -0
- package/dist/types/core/user/index.d.ts +81 -0
- package/dist/types/core/user/index.d.ts.map +1 -0
- package/dist/types/core/user/migrate.d.ts +11 -0
- package/dist/types/core/user/migrate.d.ts.map +1 -0
- package/dist/types/core/user/tld.d.ts +2 -0
- package/dist/types/core/user/tld.d.ts.map +1 -0
- package/dist/types/core/user/vendor/crypto-es/lib/aes.d.ts +23 -0
- package/dist/types/core/user/vendor/crypto-es/lib/aes.d.ts.map +1 -0
- package/dist/types/core/user/vendor/crypto-es/lib/cipher-core.d.ts +436 -0
- package/dist/types/core/user/vendor/crypto-es/lib/cipher-core.d.ts.map +1 -0
- package/dist/types/core/user/vendor/crypto-es/lib/core.d.ts +432 -0
- package/dist/types/core/user/vendor/crypto-es/lib/core.d.ts.map +1 -0
- package/dist/types/core/user/vendor/crypto-es/lib/enc-base64.d.ts +36 -0
- package/dist/types/core/user/vendor/crypto-es/lib/enc-base64.d.ts.map +1 -0
- package/dist/types/core/user/vendor/crypto-es/lib/evpkdf.d.ts +51 -0
- package/dist/types/core/user/vendor/crypto-es/lib/evpkdf.d.ts.map +1 -0
- package/dist/types/core/user/vendor/crypto-es/lib/md5.d.ts +41 -0
- package/dist/types/core/user/vendor/crypto-es/lib/md5.d.ts.map +1 -0
- package/dist/types/generated/version.d.ts +2 -0
- package/dist/types/generated/version.d.ts.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/bind-all.d.ts +4 -0
- package/dist/types/lib/bind-all.d.ts.map +1 -0
- package/dist/types/lib/browser-polyfill.d.ts +2 -0
- package/dist/types/lib/browser-polyfill.d.ts.map +1 -0
- package/dist/types/lib/client-hints/index.d.ts +3 -0
- package/dist/types/lib/client-hints/index.d.ts.map +1 -0
- package/dist/types/lib/client-hints/interfaces.d.ts +28 -0
- package/dist/types/lib/client-hints/interfaces.d.ts.map +1 -0
- package/dist/types/lib/create-deferred.d.ts +9 -0
- package/dist/types/lib/create-deferred.d.ts.map +1 -0
- package/dist/types/lib/csp-detection.d.ts +6 -0
- package/dist/types/lib/csp-detection.d.ts.map +1 -0
- package/dist/types/lib/embedded-write-key.d.ts +7 -0
- package/dist/types/lib/embedded-write-key.d.ts.map +1 -0
- package/dist/types/lib/fetch.d.ts +5 -0
- package/dist/types/lib/fetch.d.ts.map +1 -0
- package/dist/types/lib/get-global.d.ts +2 -0
- package/dist/types/lib/get-global.d.ts.map +1 -0
- package/dist/types/lib/get-process-env.d.ts +8 -0
- package/dist/types/lib/get-process-env.d.ts.map +1 -0
- package/dist/types/lib/global-analytics-helper.d.ts +18 -0
- package/dist/types/lib/global-analytics-helper.d.ts.map +1 -0
- package/dist/types/lib/group-by.d.ts +4 -0
- package/dist/types/lib/group-by.d.ts.map +1 -0
- package/dist/types/lib/is-plan-event-enabled.d.ts +9 -0
- package/dist/types/lib/is-plan-event-enabled.d.ts.map +1 -0
- package/dist/types/lib/is-thenable.d.ts +6 -0
- package/dist/types/lib/is-thenable.d.ts.map +1 -0
- package/dist/types/lib/load-script.d.ts +3 -0
- package/dist/types/lib/load-script.d.ts.map +1 -0
- package/dist/types/lib/merged-options.d.ts +13 -0
- package/dist/types/lib/merged-options.d.ts.map +1 -0
- package/dist/types/lib/on-page-change.d.ts +11 -0
- package/dist/types/lib/on-page-change.d.ts.map +1 -0
- package/dist/types/lib/p-while.d.ts +2 -0
- package/dist/types/lib/p-while.d.ts.map +1 -0
- package/dist/types/lib/parse-cdn.d.ts +4 -0
- package/dist/types/lib/parse-cdn.d.ts.map +1 -0
- package/dist/types/lib/pick.d.ts +3 -0
- package/dist/types/lib/pick.d.ts.map +1 -0
- package/dist/types/lib/priority-queue/backoff.d.ts +13 -0
- package/dist/types/lib/priority-queue/backoff.d.ts.map +1 -0
- package/dist/types/lib/priority-queue/index.d.ts +3 -0
- package/dist/types/lib/priority-queue/index.d.ts.map +1 -0
- package/dist/types/lib/priority-queue/persisted.d.ts +6 -0
- package/dist/types/lib/priority-queue/persisted.d.ts.map +1 -0
- package/dist/types/lib/sleep.d.ts +2 -0
- package/dist/types/lib/sleep.d.ts.map +1 -0
- package/dist/types/lib/to-facade.d.ts +7 -0
- package/dist/types/lib/to-facade.d.ts.map +1 -0
- package/dist/types/lib/version-type.d.ts +5 -0
- package/dist/types/lib/version-type.d.ts.map +1 -0
- package/dist/types/node/index.d.ts +8 -0
- package/dist/types/node/index.d.ts.map +1 -0
- package/dist/types/node/node.browser.d.ts +4 -0
- package/dist/types/node/node.browser.d.ts.map +1 -0
- package/dist/types/plugins/ajs-destination/index.d.ts +42 -0
- package/dist/types/plugins/ajs-destination/index.d.ts.map +1 -0
- package/dist/types/plugins/ajs-destination/loader.d.ts +12 -0
- package/dist/types/plugins/ajs-destination/loader.d.ts.map +1 -0
- package/dist/types/plugins/ajs-destination/types.d.ts +36 -0
- package/dist/types/plugins/ajs-destination/types.d.ts.map +1 -0
- package/dist/types/plugins/ajs-destination/utils.d.ts +5 -0
- package/dist/types/plugins/ajs-destination/utils.d.ts.map +1 -0
- package/dist/types/plugins/analytics-node/index.d.ts +12 -0
- package/dist/types/plugins/analytics-node/index.d.ts.map +1 -0
- package/dist/types/plugins/env-enrichment/index.d.ts +25 -0
- package/dist/types/plugins/env-enrichment/index.d.ts.map +1 -0
- package/dist/types/plugins/hightouchio/batched-dispatcher.d.ts +8 -0
- package/dist/types/plugins/hightouchio/batched-dispatcher.d.ts.map +1 -0
- package/dist/types/plugins/hightouchio/fetch-dispatcher.d.ts +8 -0
- package/dist/types/plugins/hightouchio/fetch-dispatcher.d.ts.map +1 -0
- package/dist/types/plugins/hightouchio/index.d.ts +26 -0
- package/dist/types/plugins/hightouchio/index.d.ts.map +1 -0
- package/dist/types/plugins/hightouchio/normalize.d.ts +6 -0
- package/dist/types/plugins/hightouchio/normalize.d.ts.map +1 -0
- package/dist/types/plugins/hightouchio/schedule-flush.d.ts +5 -0
- package/dist/types/plugins/hightouchio/schedule-flush.d.ts.map +1 -0
- package/dist/types/plugins/legacy-video-plugins/index.d.ts +3 -0
- package/dist/types/plugins/legacy-video-plugins/index.d.ts.map +1 -0
- package/dist/types/plugins/middleware/index.d.ts +18 -0
- package/dist/types/plugins/middleware/index.d.ts.map +1 -0
- package/dist/types/plugins/remote-loader/index.d.ts +47 -0
- package/dist/types/plugins/remote-loader/index.d.ts.map +1 -0
- package/dist/types/plugins/remote-middleware/index.d.ts +5 -0
- package/dist/types/plugins/remote-middleware/index.d.ts.map +1 -0
- package/dist/types/plugins/routing-middleware/index.d.ts +13 -0
- package/dist/types/plugins/routing-middleware/index.d.ts.map +1 -0
- package/dist/types/plugins/schema-filter/index.d.ts +5 -0
- package/dist/types/plugins/schema-filter/index.d.ts.map +1 -0
- package/dist/types/plugins/validation/index.d.ts +3 -0
- package/dist/types/plugins/validation/index.d.ts.map +1 -0
- package/dist/umd/799.bundle.cf7e55682bfd23cde904.js +2 -0
- package/dist/umd/799.bundle.cf7e55682bfd23cde904.js.map +1 -0
- package/dist/umd/870.bundle.6d7307379da86a3bf277.js +2 -0
- package/dist/umd/870.bundle.6d7307379da86a3bf277.js.map +1 -0
- package/dist/umd/ajs-destination.bundle.5a985a542b0de08e3e49.js +2 -0
- package/dist/umd/ajs-destination.bundle.5a985a542b0de08e3e49.js.map +1 -0
- package/dist/umd/auto-track.bundle.08c0e0f63bb92f96f8b5.js +2 -0
- package/dist/umd/auto-track.bundle.08c0e0f63bb92f96f8b5.js.map +1 -0
- package/dist/umd/events.min.js +2 -0
- package/dist/umd/events.min.js.map +1 -0
- package/dist/umd/index.js +2 -0
- package/dist/umd/index.js.map +1 -0
- package/dist/umd/legacyVideos.bundle.6250709892bb05b68333.js +2 -0
- package/dist/umd/legacyVideos.bundle.6250709892bb05b68333.js.map +1 -0
- package/dist/umd/queryString.bundle.e47b8db88c102418c8c2.js +2 -0
- package/dist/umd/queryString.bundle.e47b8db88c102418c8c2.js.map +1 -0
- package/dist/umd/remoteMiddleware.bundle.4da71e934f9fcee73678.js +2 -0
- package/dist/umd/remoteMiddleware.bundle.4da71e934f9fcee73678.js.map +1 -0
- package/dist/umd/schemaFilter.bundle.a17fd62888b293279f4b.js +2 -0
- package/dist/umd/schemaFilter.bundle.a17fd62888b293279f4b.js.map +1 -0
- package/dist/umd/tsub-middleware.bundle.a9604b3195f6189e429b.js +2 -0
- package/dist/umd/tsub-middleware.bundle.a9604b3195f6189e429b.js.map +1 -0
- package/package.json +106 -0
- package/src/browser/browser-umd.ts +19 -0
- package/src/browser/index.ts +486 -0
- package/src/browser/standalone-analytics.ts +62 -0
- package/src/browser/standalone-interface.ts +11 -0
- package/src/browser/standalone.ts +92 -0
- package/src/core/analytics/index.ts +672 -0
- package/src/core/analytics/interfaces.ts +100 -0
- package/src/core/arguments-resolver/index.ts +200 -0
- package/src/core/auto-track.ts +152 -0
- package/src/core/buffer/index.ts +371 -0
- package/src/core/callback/index.ts +1 -0
- package/src/core/connection/index.ts +13 -0
- package/src/core/constants/index.ts +1 -0
- package/src/core/context/index.ts +21 -0
- package/src/core/environment/index.ts +7 -0
- package/src/core/events/index.ts +277 -0
- package/src/core/events/interfaces.ts +36 -0
- package/src/core/inspector/index.ts +14 -0
- package/src/core/page/add-page-context.ts +33 -0
- package/src/core/page/get-page-context.ts +140 -0
- package/src/core/page/index.ts +2 -0
- package/src/core/plugin/index.ts +12 -0
- package/src/core/query-string/gracefulDecodeURIComponent.ts +16 -0
- package/src/core/query-string/index.ts +64 -0
- package/src/core/query-string/pickPrefix.ts +20 -0
- package/src/core/queue/event-queue.ts +22 -0
- package/src/core/session/index.ts +107 -0
- package/src/core/stats/index.ts +15 -0
- package/src/core/stats/remote-metrics.ts +144 -0
- package/src/core/storage/cookieStorage.ts +80 -0
- package/src/core/storage/index.ts +64 -0
- package/src/core/storage/localStorage.ts +45 -0
- package/src/core/storage/memoryStorage.ts +22 -0
- package/src/core/storage/settings.ts +23 -0
- package/src/core/storage/types.ts +49 -0
- package/src/core/storage/universalStorage.ts +78 -0
- package/src/core/user/index.ts +399 -0
- package/src/core/user/migrate.ts +126 -0
- package/src/core/user/tld.ts +65 -0
- package/src/core/user/vendor/crypto-es/LICENSE +53 -0
- package/src/core/user/vendor/crypto-es/lib/aes.ts +302 -0
- package/src/core/user/vendor/crypto-es/lib/cipher-core.ts +922 -0
- package/src/core/user/vendor/crypto-es/lib/core.ts +806 -0
- package/src/core/user/vendor/crypto-es/lib/enc-base64.ts +110 -0
- package/src/core/user/vendor/crypto-es/lib/evpkdf.ts +110 -0
- package/src/core/user/vendor/crypto-es/lib/md5.ts +238 -0
- package/src/core/user/vendor/readme.md +7 -0
- package/src/generated/version.ts +2 -0
- package/src/index.ts +13 -0
- package/src/lib/bind-all.ts +19 -0
- package/src/lib/browser-polyfill.ts +23 -0
- package/src/lib/client-hints/index.ts +16 -0
- package/src/lib/client-hints/interfaces.ts +42 -0
- package/src/lib/create-deferred.ts +16 -0
- package/src/lib/csp-detection.ts +8 -0
- package/src/lib/embedded-write-key.ts +24 -0
- package/src/lib/fetch.ts +10 -0
- package/src/lib/get-global.ts +16 -0
- package/src/lib/get-process-env.ts +11 -0
- package/src/lib/global-analytics-helper.ts +31 -0
- package/src/lib/group-by.ts +30 -0
- package/src/lib/is-plan-event-enabled.ts +20 -0
- package/src/lib/is-thenable.ts +9 -0
- package/src/lib/load-script.ts +66 -0
- package/src/lib/merged-options.ts +46 -0
- package/src/lib/on-page-change.ts +29 -0
- package/src/lib/p-while.ts +12 -0
- package/src/lib/parse-cdn.ts +56 -0
- package/src/lib/pick.ts +28 -0
- package/src/lib/priority-queue/backoff.ts +24 -0
- package/src/lib/priority-queue/index.ts +6 -0
- package/src/lib/priority-queue/persisted.ts +127 -0
- package/src/lib/sleep.ts +4 -0
- package/src/lib/to-facade.ts +50 -0
- package/src/lib/version-type.ts +10 -0
- package/src/node/index.ts +36 -0
- package/src/node/node.browser.ts +7 -0
- package/src/plugins/ajs-destination/index.ts +392 -0
- package/src/plugins/ajs-destination/loader.ts +129 -0
- package/src/plugins/ajs-destination/types.ts +44 -0
- package/src/plugins/ajs-destination/utils.ts +32 -0
- package/src/plugins/analytics-node/index.ts +67 -0
- package/src/plugins/env-enrichment/index.ts +208 -0
- package/src/plugins/hightouchio/batched-dispatcher.ts +127 -0
- package/src/plugins/hightouchio/fetch-dispatcher.ts +27 -0
- package/src/plugins/hightouchio/index.ts +147 -0
- package/src/plugins/hightouchio/normalize.ts +71 -0
- package/src/plugins/hightouchio/schedule-flush.ts +58 -0
- package/src/plugins/legacy-video-plugins/index.ts +16 -0
- package/src/plugins/middleware/index.ts +131 -0
- package/src/plugins/remote-loader/index.ts +256 -0
- package/src/plugins/remote-middleware/index.ts +44 -0
- package/src/plugins/routing-middleware/index.ts +37 -0
- package/src/plugins/schema-filter/index.ts +90 -0
- package/src/plugins/validation/index.ts +44 -0
- package/src/test-helpers/browser-storage.ts +75 -0
- package/src/test-helpers/factories.ts +18 -0
- package/src/test-helpers/fetch-parse.ts +8 -0
- package/src/test-helpers/fixtures/cdn-settings.ts +301 -0
- package/src/test-helpers/fixtures/classic-destination.ts +25 -0
- package/src/test-helpers/fixtures/client-hints.ts +28 -0
- package/src/test-helpers/fixtures/create-fetch-method.ts +30 -0
- package/src/test-helpers/fixtures/index.ts +4 -0
- package/src/test-helpers/fixtures/page-context.ts +11 -0
- package/src/test-helpers/test-writekeys.ts +5 -0
- package/src/test-helpers/type-assertions.ts +11 -0
|
@@ -0,0 +1,838 @@
|
|
|
1
|
+
//@ts-nocheck
|
|
2
|
+
/* eslint-disable no-use-before-define */
|
|
3
|
+
import { __extends } from "tslib";
|
|
4
|
+
import { Base, WordArray, BufferedBlockAlgorithm } from './core';
|
|
5
|
+
import { Base64 } from './enc-base64';
|
|
6
|
+
import { EvpKDFAlgo } from './evpkdf';
|
|
7
|
+
/**
|
|
8
|
+
* Abstract base cipher template.
|
|
9
|
+
*
|
|
10
|
+
* @property {number} keySize This cipher's key size. Default: 4 (128 bits)
|
|
11
|
+
* @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
|
|
12
|
+
* @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
|
|
13
|
+
* @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
|
|
14
|
+
*/
|
|
15
|
+
var Cipher = /** @class */ (function (_super) {
|
|
16
|
+
__extends(Cipher, _super);
|
|
17
|
+
/**
|
|
18
|
+
* Initializes a newly created cipher.
|
|
19
|
+
*
|
|
20
|
+
* @param {number} xformMode Either the encryption or decryption transormation mode constant.
|
|
21
|
+
* @param {WordArray} key The key.
|
|
22
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
*
|
|
26
|
+
* const cipher = CryptoJS.algo.AES.create(
|
|
27
|
+
* CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }
|
|
28
|
+
* );
|
|
29
|
+
*/
|
|
30
|
+
function Cipher(xformMode, key, cfg) {
|
|
31
|
+
var _this = _super.call(this) || this;
|
|
32
|
+
/**
|
|
33
|
+
* Configuration options.
|
|
34
|
+
*
|
|
35
|
+
* @property {WordArray} iv The IV to use for this operation.
|
|
36
|
+
*/
|
|
37
|
+
_this.cfg = Object.assign(new Base(), cfg);
|
|
38
|
+
// Store transform mode and key
|
|
39
|
+
_this._xformMode = xformMode;
|
|
40
|
+
_this._key = key;
|
|
41
|
+
// Set initial values
|
|
42
|
+
_this.reset();
|
|
43
|
+
return _this;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates this cipher in encryption mode.
|
|
47
|
+
*
|
|
48
|
+
* @param {WordArray} key The key.
|
|
49
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
50
|
+
*
|
|
51
|
+
* @return {Cipher} A cipher instance.
|
|
52
|
+
*
|
|
53
|
+
* @static
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
*
|
|
57
|
+
* const cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
|
|
58
|
+
*/
|
|
59
|
+
Cipher.createEncryptor = function (key, cfg) {
|
|
60
|
+
return this.create(this._ENC_XFORM_MODE, key, cfg);
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Creates this cipher in decryption mode.
|
|
64
|
+
*
|
|
65
|
+
* @param {WordArray} key The key.
|
|
66
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
67
|
+
*
|
|
68
|
+
* @return {Cipher} A cipher instance.
|
|
69
|
+
*
|
|
70
|
+
* @static
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
*
|
|
74
|
+
* const cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
|
|
75
|
+
*/
|
|
76
|
+
Cipher.createDecryptor = function (key, cfg) {
|
|
77
|
+
return this.create(this._DEC_XFORM_MODE, key, cfg);
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Creates shortcut functions to a cipher's object interface.
|
|
81
|
+
*
|
|
82
|
+
* @param {Cipher} cipher The cipher to create a helper for.
|
|
83
|
+
*
|
|
84
|
+
* @return {Object} An object with encrypt and decrypt shortcut functions.
|
|
85
|
+
*
|
|
86
|
+
* @static
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
*
|
|
90
|
+
* const AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
|
|
91
|
+
*/
|
|
92
|
+
Cipher._createHelper = function (SubCipher) {
|
|
93
|
+
var selectCipherStrategy = function (key) {
|
|
94
|
+
if (typeof key === 'string') {
|
|
95
|
+
return PasswordBasedCipher;
|
|
96
|
+
}
|
|
97
|
+
return SerializableCipher;
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
encrypt: function (message, key, cfg) {
|
|
101
|
+
return selectCipherStrategy(key).encrypt(SubCipher, message, key, cfg);
|
|
102
|
+
},
|
|
103
|
+
decrypt: function (ciphertext, key, cfg) {
|
|
104
|
+
return selectCipherStrategy(key).decrypt(SubCipher, ciphertext, key, cfg);
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Resets this cipher to its initial state.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
*
|
|
113
|
+
* cipher.reset();
|
|
114
|
+
*/
|
|
115
|
+
Cipher.prototype.reset = function () {
|
|
116
|
+
// Reset data buffer
|
|
117
|
+
_super.prototype.reset.call(this);
|
|
118
|
+
// Perform concrete-cipher logic
|
|
119
|
+
this._doReset();
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Adds data to be encrypted or decrypted.
|
|
123
|
+
*
|
|
124
|
+
* @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
|
|
125
|
+
*
|
|
126
|
+
* @return {WordArray} The data after processing.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
*
|
|
130
|
+
* const encrypted = cipher.process('data');
|
|
131
|
+
* const encrypted = cipher.process(wordArray);
|
|
132
|
+
*/
|
|
133
|
+
Cipher.prototype.process = function (dataUpdate) {
|
|
134
|
+
// Append
|
|
135
|
+
this._append(dataUpdate);
|
|
136
|
+
// Process available blocks
|
|
137
|
+
return this._process();
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Finalizes the encryption or decryption process.
|
|
141
|
+
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
142
|
+
*
|
|
143
|
+
* @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
|
|
144
|
+
*
|
|
145
|
+
* @return {WordArray} The data after final processing.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
*
|
|
149
|
+
* const encrypted = cipher.finalize();
|
|
150
|
+
* const encrypted = cipher.finalize('data');
|
|
151
|
+
* const encrypted = cipher.finalize(wordArray);
|
|
152
|
+
*/
|
|
153
|
+
Cipher.prototype.finalize = function (dataUpdate) {
|
|
154
|
+
// Final data update
|
|
155
|
+
if (dataUpdate) {
|
|
156
|
+
this._append(dataUpdate);
|
|
157
|
+
}
|
|
158
|
+
// Perform concrete-cipher logic
|
|
159
|
+
var finalProcessedData = this._doFinalize();
|
|
160
|
+
return finalProcessedData;
|
|
161
|
+
};
|
|
162
|
+
return Cipher;
|
|
163
|
+
}(BufferedBlockAlgorithm));
|
|
164
|
+
export { Cipher };
|
|
165
|
+
Cipher._ENC_XFORM_MODE = 1;
|
|
166
|
+
Cipher._DEC_XFORM_MODE = 2;
|
|
167
|
+
Cipher.keySize = 128 / 32;
|
|
168
|
+
Cipher.ivSize = 128 / 32;
|
|
169
|
+
/**
|
|
170
|
+
* Abstract base stream cipher template.
|
|
171
|
+
*
|
|
172
|
+
* @property {number} blockSize
|
|
173
|
+
*
|
|
174
|
+
* The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
|
|
175
|
+
*/
|
|
176
|
+
var StreamCipher = /** @class */ (function (_super) {
|
|
177
|
+
__extends(StreamCipher, _super);
|
|
178
|
+
function StreamCipher() {
|
|
179
|
+
var args = [];
|
|
180
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
181
|
+
args[_i] = arguments[_i];
|
|
182
|
+
}
|
|
183
|
+
var _this = _super.apply(this, args) || this;
|
|
184
|
+
_this.blockSize = 1;
|
|
185
|
+
return _this;
|
|
186
|
+
}
|
|
187
|
+
StreamCipher.prototype._doFinalize = function () {
|
|
188
|
+
// Process partial blocks
|
|
189
|
+
var finalProcessedBlocks = this._process(!!'flush');
|
|
190
|
+
return finalProcessedBlocks;
|
|
191
|
+
};
|
|
192
|
+
return StreamCipher;
|
|
193
|
+
}(Cipher));
|
|
194
|
+
export { StreamCipher };
|
|
195
|
+
/**
|
|
196
|
+
* Abstract base block cipher mode template.
|
|
197
|
+
*/
|
|
198
|
+
var BlockCipherMode = /** @class */ (function (_super) {
|
|
199
|
+
__extends(BlockCipherMode, _super);
|
|
200
|
+
/**
|
|
201
|
+
* Initializes a newly created mode.
|
|
202
|
+
*
|
|
203
|
+
* @param {Cipher} cipher A block cipher instance.
|
|
204
|
+
* @param {Array} iv The IV words.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
*
|
|
208
|
+
* const mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
|
|
209
|
+
*/
|
|
210
|
+
function BlockCipherMode(cipher, iv) {
|
|
211
|
+
var _this = _super.call(this) || this;
|
|
212
|
+
_this._cipher = cipher;
|
|
213
|
+
_this._iv = iv;
|
|
214
|
+
return _this;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Creates this mode for encryption.
|
|
218
|
+
*
|
|
219
|
+
* @param {Cipher} cipher A block cipher instance.
|
|
220
|
+
* @param {Array} iv The IV words.
|
|
221
|
+
*
|
|
222
|
+
* @static
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
*
|
|
226
|
+
* const mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
|
|
227
|
+
*/
|
|
228
|
+
BlockCipherMode.createEncryptor = function (cipher, iv) {
|
|
229
|
+
return this.Encryptor.create(cipher, iv);
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Creates this mode for decryption.
|
|
233
|
+
*
|
|
234
|
+
* @param {Cipher} cipher A block cipher instance.
|
|
235
|
+
* @param {Array} iv The IV words.
|
|
236
|
+
*
|
|
237
|
+
* @static
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
*
|
|
241
|
+
* const mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
|
|
242
|
+
*/
|
|
243
|
+
BlockCipherMode.createDecryptor = function (cipher, iv) {
|
|
244
|
+
return this.Decryptor.create(cipher, iv);
|
|
245
|
+
};
|
|
246
|
+
return BlockCipherMode;
|
|
247
|
+
}(Base));
|
|
248
|
+
export { BlockCipherMode };
|
|
249
|
+
function xorBlock(words, offset, blockSize) {
|
|
250
|
+
var _words = words;
|
|
251
|
+
var block;
|
|
252
|
+
// Shortcut
|
|
253
|
+
var iv = this._iv;
|
|
254
|
+
// Choose mixing block
|
|
255
|
+
if (iv) {
|
|
256
|
+
block = iv;
|
|
257
|
+
// Remove IV for subsequent blocks
|
|
258
|
+
this._iv = undefined;
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
block = this._prevBlock;
|
|
262
|
+
}
|
|
263
|
+
// XOR blocks
|
|
264
|
+
for (var i = 0; i < blockSize; i += 1) {
|
|
265
|
+
_words[offset + i] ^= block[i];
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Cipher Block Chaining mode.
|
|
270
|
+
*/
|
|
271
|
+
/**
|
|
272
|
+
* Abstract base CBC mode.
|
|
273
|
+
*/
|
|
274
|
+
var CBC = /** @class */ (function (_super) {
|
|
275
|
+
__extends(CBC, _super);
|
|
276
|
+
function CBC() {
|
|
277
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
278
|
+
}
|
|
279
|
+
return CBC;
|
|
280
|
+
}(BlockCipherMode));
|
|
281
|
+
export { CBC };
|
|
282
|
+
/**
|
|
283
|
+
* CBC encryptor.
|
|
284
|
+
*/
|
|
285
|
+
CBC.Encryptor = /** @class */ (function (_super) {
|
|
286
|
+
__extends(Encryptor, _super);
|
|
287
|
+
function Encryptor() {
|
|
288
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Processes the data block at offset.
|
|
292
|
+
*
|
|
293
|
+
* @param {Array} words The data words to operate on.
|
|
294
|
+
* @param {number} offset The offset where the block starts.
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
*
|
|
298
|
+
* mode.processBlock(data.words, offset);
|
|
299
|
+
*/
|
|
300
|
+
Encryptor.prototype.processBlock = function (words, offset) {
|
|
301
|
+
// Shortcuts
|
|
302
|
+
var cipher = this._cipher;
|
|
303
|
+
var blockSize = cipher.blockSize;
|
|
304
|
+
// XOR and encrypt
|
|
305
|
+
xorBlock.call(this, words, offset, blockSize);
|
|
306
|
+
cipher.encryptBlock(words, offset);
|
|
307
|
+
// Remember this block to use with next block
|
|
308
|
+
this._prevBlock = words.slice(offset, offset + blockSize);
|
|
309
|
+
};
|
|
310
|
+
return Encryptor;
|
|
311
|
+
}(CBC));
|
|
312
|
+
/**
|
|
313
|
+
* CBC decryptor.
|
|
314
|
+
*/
|
|
315
|
+
CBC.Decryptor = /** @class */ (function (_super) {
|
|
316
|
+
__extends(Decryptor, _super);
|
|
317
|
+
function Decryptor() {
|
|
318
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Processes the data block at offset.
|
|
322
|
+
*
|
|
323
|
+
* @param {Array} words The data words to operate on.
|
|
324
|
+
* @param {number} offset The offset where the block starts.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
*
|
|
328
|
+
* mode.processBlock(data.words, offset);
|
|
329
|
+
*/
|
|
330
|
+
Decryptor.prototype.processBlock = function (words, offset) {
|
|
331
|
+
// Shortcuts
|
|
332
|
+
var cipher = this._cipher;
|
|
333
|
+
var blockSize = cipher.blockSize;
|
|
334
|
+
// Remember this block to use with next block
|
|
335
|
+
var thisBlock = words.slice(offset, offset + blockSize);
|
|
336
|
+
// Decrypt and XOR
|
|
337
|
+
cipher.decryptBlock(words, offset);
|
|
338
|
+
xorBlock.call(this, words, offset, blockSize);
|
|
339
|
+
// This block becomes the previous block
|
|
340
|
+
this._prevBlock = thisBlock;
|
|
341
|
+
};
|
|
342
|
+
return Decryptor;
|
|
343
|
+
}(CBC));
|
|
344
|
+
/**
|
|
345
|
+
* PKCS #5/7 padding strategy.
|
|
346
|
+
*/
|
|
347
|
+
export var Pkcs7 = {
|
|
348
|
+
/**
|
|
349
|
+
* Pads data using the algorithm defined in PKCS #5/7.
|
|
350
|
+
*
|
|
351
|
+
* @param {WordArray} data The data to pad.
|
|
352
|
+
* @param {number} blockSize The multiple that the data should be padded to.
|
|
353
|
+
*
|
|
354
|
+
* @static
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
*
|
|
358
|
+
* CryptoJS.pad.Pkcs7.pad(wordArray, 4);
|
|
359
|
+
*/
|
|
360
|
+
pad: function (data, blockSize) {
|
|
361
|
+
// Shortcut
|
|
362
|
+
var blockSizeBytes = blockSize * 4;
|
|
363
|
+
// Count padding bytes
|
|
364
|
+
var nPaddingBytes = blockSizeBytes - (data.sigBytes % blockSizeBytes);
|
|
365
|
+
// Create padding word
|
|
366
|
+
var paddingWord = (nPaddingBytes << 24) |
|
|
367
|
+
(nPaddingBytes << 16) |
|
|
368
|
+
(nPaddingBytes << 8) |
|
|
369
|
+
nPaddingBytes;
|
|
370
|
+
// Create padding
|
|
371
|
+
var paddingWords = [];
|
|
372
|
+
for (var i = 0; i < nPaddingBytes; i += 4) {
|
|
373
|
+
paddingWords.push(paddingWord);
|
|
374
|
+
}
|
|
375
|
+
var padding = WordArray.create(paddingWords, nPaddingBytes);
|
|
376
|
+
// Add padding
|
|
377
|
+
data.concat(padding);
|
|
378
|
+
},
|
|
379
|
+
/**
|
|
380
|
+
* Unpads data that had been padded using the algorithm defined in PKCS #5/7.
|
|
381
|
+
*
|
|
382
|
+
* @param {WordArray} data The data to unpad.
|
|
383
|
+
*
|
|
384
|
+
* @static
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
*
|
|
388
|
+
* CryptoJS.pad.Pkcs7.unpad(wordArray);
|
|
389
|
+
*/
|
|
390
|
+
unpad: function (data) {
|
|
391
|
+
var _data = data;
|
|
392
|
+
// Get number of padding bytes from last byte
|
|
393
|
+
var nPaddingBytes = _data.words[(_data.sigBytes - 1) >>> 2] & 0xff;
|
|
394
|
+
// Remove padding
|
|
395
|
+
_data.sigBytes -= nPaddingBytes;
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
/**
|
|
399
|
+
* Abstract base block cipher template.
|
|
400
|
+
*
|
|
401
|
+
* @property {number} blockSize
|
|
402
|
+
*
|
|
403
|
+
* The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
|
|
404
|
+
*/
|
|
405
|
+
var BlockCipher = /** @class */ (function (_super) {
|
|
406
|
+
__extends(BlockCipher, _super);
|
|
407
|
+
function BlockCipher(xformMode, key, cfg) {
|
|
408
|
+
var _this =
|
|
409
|
+
/**
|
|
410
|
+
* Configuration options.
|
|
411
|
+
*
|
|
412
|
+
* @property {Mode} mode The block mode to use. Default: CBC
|
|
413
|
+
* @property {Padding} padding The padding strategy to use. Default: Pkcs7
|
|
414
|
+
*/
|
|
415
|
+
_super.call(this, xformMode, key, Object.assign({
|
|
416
|
+
mode: CBC,
|
|
417
|
+
padding: Pkcs7,
|
|
418
|
+
}, cfg)) || this;
|
|
419
|
+
_this.blockSize = 128 / 32;
|
|
420
|
+
return _this;
|
|
421
|
+
}
|
|
422
|
+
BlockCipher.prototype.reset = function () {
|
|
423
|
+
var modeCreator;
|
|
424
|
+
// Reset cipher
|
|
425
|
+
_super.prototype.reset.call(this);
|
|
426
|
+
// Shortcuts
|
|
427
|
+
var cfg = this.cfg;
|
|
428
|
+
var iv = cfg.iv, mode = cfg.mode;
|
|
429
|
+
// Reset block mode
|
|
430
|
+
if (this._xformMode === this.constructor._ENC_XFORM_MODE) {
|
|
431
|
+
modeCreator = mode.createEncryptor;
|
|
432
|
+
} /* if (this._xformMode == this._DEC_XFORM_MODE) */
|
|
433
|
+
else {
|
|
434
|
+
modeCreator = mode.createDecryptor;
|
|
435
|
+
// Keep at least one block in the buffer for unpadding
|
|
436
|
+
this._minBufferSize = 1;
|
|
437
|
+
}
|
|
438
|
+
this._mode = modeCreator.call(mode, this, iv && iv.words);
|
|
439
|
+
this._mode.__creator = modeCreator;
|
|
440
|
+
};
|
|
441
|
+
BlockCipher.prototype._doProcessBlock = function (words, offset) {
|
|
442
|
+
this._mode.processBlock(words, offset);
|
|
443
|
+
};
|
|
444
|
+
BlockCipher.prototype._doFinalize = function () {
|
|
445
|
+
var finalProcessedBlocks;
|
|
446
|
+
// Shortcut
|
|
447
|
+
var padding = this.cfg.padding;
|
|
448
|
+
// Finalize
|
|
449
|
+
if (this._xformMode === this.constructor._ENC_XFORM_MODE) {
|
|
450
|
+
// Pad data
|
|
451
|
+
padding.pad(this._data, this.blockSize);
|
|
452
|
+
// Process final blocks
|
|
453
|
+
finalProcessedBlocks = this._process(!!'flush');
|
|
454
|
+
} /* if (this._xformMode == this._DEC_XFORM_MODE) */
|
|
455
|
+
else {
|
|
456
|
+
// Process final blocks
|
|
457
|
+
finalProcessedBlocks = this._process(!!'flush');
|
|
458
|
+
// Unpad data
|
|
459
|
+
padding.unpad(finalProcessedBlocks);
|
|
460
|
+
}
|
|
461
|
+
return finalProcessedBlocks;
|
|
462
|
+
};
|
|
463
|
+
return BlockCipher;
|
|
464
|
+
}(Cipher));
|
|
465
|
+
export { BlockCipher };
|
|
466
|
+
/**
|
|
467
|
+
* A collection of cipher parameters.
|
|
468
|
+
*
|
|
469
|
+
* @property {WordArray} ciphertext The raw ciphertext.
|
|
470
|
+
* @property {WordArray} key The key to this ciphertext.
|
|
471
|
+
* @property {WordArray} iv The IV used in the ciphering operation.
|
|
472
|
+
* @property {WordArray} salt The salt used with a key derivation function.
|
|
473
|
+
* @property {Cipher} algorithm The cipher algorithm.
|
|
474
|
+
* @property {Mode} mode The block mode used in the ciphering operation.
|
|
475
|
+
* @property {Padding} padding The padding scheme used in the ciphering operation.
|
|
476
|
+
* @property {number} blockSize The block size of the cipher.
|
|
477
|
+
* @property {Format} formatter
|
|
478
|
+
* The default formatting strategy to convert this cipher params object to a string.
|
|
479
|
+
*/
|
|
480
|
+
var CipherParams = /** @class */ (function (_super) {
|
|
481
|
+
__extends(CipherParams, _super);
|
|
482
|
+
/**
|
|
483
|
+
* Initializes a newly created cipher params object.
|
|
484
|
+
*
|
|
485
|
+
* @param {Object} cipherParams An object with any of the possible cipher parameters.
|
|
486
|
+
*
|
|
487
|
+
* @example
|
|
488
|
+
*
|
|
489
|
+
* var cipherParams = CryptoJS.lib.CipherParams.create({
|
|
490
|
+
* ciphertext: ciphertextWordArray,
|
|
491
|
+
* key: keyWordArray,
|
|
492
|
+
* iv: ivWordArray,
|
|
493
|
+
* salt: saltWordArray,
|
|
494
|
+
* algorithm: CryptoJS.algo.AES,
|
|
495
|
+
* mode: CryptoJS.mode.CBC,
|
|
496
|
+
* padding: CryptoJS.pad.PKCS7,
|
|
497
|
+
* blockSize: 4,
|
|
498
|
+
* formatter: CryptoJS.format.OpenSSL
|
|
499
|
+
* });
|
|
500
|
+
*/
|
|
501
|
+
function CipherParams(cipherParams) {
|
|
502
|
+
var _this = _super.call(this) || this;
|
|
503
|
+
_this.mixIn(cipherParams);
|
|
504
|
+
return _this;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Converts this cipher params object to a string.
|
|
508
|
+
*
|
|
509
|
+
* @param {Format} formatter (Optional) The formatting strategy to use.
|
|
510
|
+
*
|
|
511
|
+
* @return {string} The stringified cipher params.
|
|
512
|
+
*
|
|
513
|
+
* @throws Error If neither the formatter nor the default formatter is set.
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
*
|
|
517
|
+
* var string = cipherParams + '';
|
|
518
|
+
* var string = cipherParams.toString();
|
|
519
|
+
* var string = cipherParams.toString(CryptoJS.format.OpenSSL);
|
|
520
|
+
*/
|
|
521
|
+
CipherParams.prototype.toString = function (formatter) {
|
|
522
|
+
return (formatter || this.formatter).stringify(this);
|
|
523
|
+
};
|
|
524
|
+
return CipherParams;
|
|
525
|
+
}(Base));
|
|
526
|
+
export { CipherParams };
|
|
527
|
+
/**
|
|
528
|
+
* OpenSSL formatting strategy.
|
|
529
|
+
*/
|
|
530
|
+
export var OpenSSLFormatter = {
|
|
531
|
+
/**
|
|
532
|
+
* Converts a cipher params object to an OpenSSL-compatible string.
|
|
533
|
+
*
|
|
534
|
+
* @param {CipherParams} cipherParams The cipher params object.
|
|
535
|
+
*
|
|
536
|
+
* @return {string} The OpenSSL-compatible string.
|
|
537
|
+
*
|
|
538
|
+
* @static
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
*
|
|
542
|
+
* var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
|
|
543
|
+
*/
|
|
544
|
+
stringify: function (cipherParams) {
|
|
545
|
+
var wordArray;
|
|
546
|
+
// Shortcuts
|
|
547
|
+
var ciphertext = cipherParams.ciphertext, salt = cipherParams.salt;
|
|
548
|
+
// Format
|
|
549
|
+
if (salt) {
|
|
550
|
+
wordArray = WordArray.create([0x53616c74, 0x65645f5f])
|
|
551
|
+
.concat(salt)
|
|
552
|
+
.concat(ciphertext);
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
wordArray = ciphertext;
|
|
556
|
+
}
|
|
557
|
+
return wordArray.toString(Base64);
|
|
558
|
+
},
|
|
559
|
+
/**
|
|
560
|
+
* Converts an OpenSSL-compatible string to a cipher params object.
|
|
561
|
+
*
|
|
562
|
+
* @param {string} openSSLStr The OpenSSL-compatible string.
|
|
563
|
+
*
|
|
564
|
+
* @return {CipherParams} The cipher params object.
|
|
565
|
+
*
|
|
566
|
+
* @static
|
|
567
|
+
*
|
|
568
|
+
* @example
|
|
569
|
+
*
|
|
570
|
+
* var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
|
|
571
|
+
*/
|
|
572
|
+
parse: function (openSSLStr) {
|
|
573
|
+
var salt;
|
|
574
|
+
// Parse base64
|
|
575
|
+
var ciphertext = Base64.parse(openSSLStr);
|
|
576
|
+
// Shortcut
|
|
577
|
+
var ciphertextWords = ciphertext.words;
|
|
578
|
+
// Test for salt
|
|
579
|
+
if (ciphertextWords[0] === 0x53616c74 &&
|
|
580
|
+
ciphertextWords[1] === 0x65645f5f) {
|
|
581
|
+
// Extract salt
|
|
582
|
+
salt = WordArray.create(ciphertextWords.slice(2, 4));
|
|
583
|
+
// Remove salt from ciphertext
|
|
584
|
+
ciphertextWords.splice(0, 4);
|
|
585
|
+
ciphertext.sigBytes -= 16;
|
|
586
|
+
}
|
|
587
|
+
return CipherParams.create({ ciphertext: ciphertext, salt: salt });
|
|
588
|
+
},
|
|
589
|
+
};
|
|
590
|
+
/**
|
|
591
|
+
* A cipher wrapper that returns ciphertext as a serializable cipher params object.
|
|
592
|
+
*/
|
|
593
|
+
var SerializableCipher = /** @class */ (function (_super) {
|
|
594
|
+
__extends(SerializableCipher, _super);
|
|
595
|
+
function SerializableCipher() {
|
|
596
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Encrypts a message.
|
|
600
|
+
*
|
|
601
|
+
* @param {Cipher} cipher The cipher algorithm to use.
|
|
602
|
+
* @param {WordArray|string} message The message to encrypt.
|
|
603
|
+
* @param {WordArray} key The key.
|
|
604
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
605
|
+
*
|
|
606
|
+
* @return {CipherParams} A cipher params object.
|
|
607
|
+
*
|
|
608
|
+
* @static
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
*
|
|
612
|
+
* var ciphertextParams = CryptoJS.lib.SerializableCipher
|
|
613
|
+
* .encrypt(CryptoJS.algo.AES, message, key);
|
|
614
|
+
* var ciphertextParams = CryptoJS.lib.SerializableCipher
|
|
615
|
+
* .encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
|
|
616
|
+
* var ciphertextParams = CryptoJS.lib.SerializableCipher
|
|
617
|
+
* .encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
|
618
|
+
*/
|
|
619
|
+
SerializableCipher.encrypt = function (cipher, message, key, cfg) {
|
|
620
|
+
// Apply config defaults
|
|
621
|
+
var _cfg = Object.assign(new Base(), this.cfg, cfg);
|
|
622
|
+
// Encrypt
|
|
623
|
+
var encryptor = cipher.createEncryptor(key, _cfg);
|
|
624
|
+
var ciphertext = encryptor.finalize(message);
|
|
625
|
+
// Shortcut
|
|
626
|
+
var cipherCfg = encryptor.cfg;
|
|
627
|
+
// Create and return serializable cipher params
|
|
628
|
+
return CipherParams.create({
|
|
629
|
+
ciphertext: ciphertext,
|
|
630
|
+
key: key,
|
|
631
|
+
iv: cipherCfg.iv,
|
|
632
|
+
algorithm: cipher,
|
|
633
|
+
mode: cipherCfg.mode,
|
|
634
|
+
padding: cipherCfg.padding,
|
|
635
|
+
blockSize: encryptor.blockSize,
|
|
636
|
+
formatter: _cfg.format,
|
|
637
|
+
});
|
|
638
|
+
};
|
|
639
|
+
/**
|
|
640
|
+
* Decrypts serialized ciphertext.
|
|
641
|
+
*
|
|
642
|
+
* @param {Cipher} cipher The cipher algorithm to use.
|
|
643
|
+
* @param {CipherParams|string} ciphertext The ciphertext to decrypt.
|
|
644
|
+
* @param {WordArray} key The key.
|
|
645
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
646
|
+
*
|
|
647
|
+
* @return {WordArray} The plaintext.
|
|
648
|
+
*
|
|
649
|
+
* @static
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
*
|
|
653
|
+
* var plaintext = CryptoJS.lib.SerializableCipher
|
|
654
|
+
* .decrypt(CryptoJS.algo.AES, formattedCiphertext, key,
|
|
655
|
+
* { iv: iv, format: CryptoJS.format.OpenSSL });
|
|
656
|
+
* var plaintext = CryptoJS.lib.SerializableCipher
|
|
657
|
+
* .decrypt(CryptoJS.algo.AES, ciphertextParams, key,
|
|
658
|
+
* { iv: iv, format: CryptoJS.format.OpenSSL });
|
|
659
|
+
*/
|
|
660
|
+
SerializableCipher.decrypt = function (cipher, ciphertext, key, cfg) {
|
|
661
|
+
var _ciphertext = ciphertext;
|
|
662
|
+
// Apply config defaults
|
|
663
|
+
var _cfg = Object.assign(new Base(), this.cfg, cfg);
|
|
664
|
+
// Convert string to CipherParams
|
|
665
|
+
_ciphertext = this._parse(_ciphertext, _cfg.format);
|
|
666
|
+
// Decrypt
|
|
667
|
+
var plaintext = cipher
|
|
668
|
+
.createDecryptor(key, _cfg)
|
|
669
|
+
.finalize(_ciphertext.ciphertext);
|
|
670
|
+
return plaintext;
|
|
671
|
+
};
|
|
672
|
+
/**
|
|
673
|
+
* Converts serialized ciphertext to CipherParams,
|
|
674
|
+
* else assumed CipherParams already and returns ciphertext unchanged.
|
|
675
|
+
*
|
|
676
|
+
* @param {CipherParams|string} ciphertext The ciphertext.
|
|
677
|
+
* @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
|
|
678
|
+
*
|
|
679
|
+
* @return {CipherParams} The unserialized ciphertext.
|
|
680
|
+
*
|
|
681
|
+
* @static
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
*
|
|
685
|
+
* var ciphertextParams = CryptoJS.lib.SerializableCipher
|
|
686
|
+
* ._parse(ciphertextStringOrParams, format);
|
|
687
|
+
*/
|
|
688
|
+
SerializableCipher._parse = function (ciphertext, format) {
|
|
689
|
+
if (typeof ciphertext === 'string') {
|
|
690
|
+
return format.parse(ciphertext, this);
|
|
691
|
+
}
|
|
692
|
+
return ciphertext;
|
|
693
|
+
};
|
|
694
|
+
return SerializableCipher;
|
|
695
|
+
}(Base));
|
|
696
|
+
export { SerializableCipher };
|
|
697
|
+
/**
|
|
698
|
+
* Configuration options.
|
|
699
|
+
*
|
|
700
|
+
* @property {Formatter} format
|
|
701
|
+
*
|
|
702
|
+
* The formatting strategy to convert cipher param objects to and from a string.
|
|
703
|
+
* Default: OpenSSL
|
|
704
|
+
*/
|
|
705
|
+
SerializableCipher.cfg = Object.assign(new Base(), { format: OpenSSLFormatter });
|
|
706
|
+
/**
|
|
707
|
+
* OpenSSL key derivation function.
|
|
708
|
+
*/
|
|
709
|
+
export var OpenSSLKdf = {
|
|
710
|
+
/**
|
|
711
|
+
* Derives a key and IV from a password.
|
|
712
|
+
*
|
|
713
|
+
* @param {string} password The password to derive from.
|
|
714
|
+
* @param {number} keySize The size in words of the key to generate.
|
|
715
|
+
* @param {number} ivSize The size in words of the IV to generate.
|
|
716
|
+
* @param {WordArray|string} salt
|
|
717
|
+
* (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
|
|
718
|
+
*
|
|
719
|
+
* @return {CipherParams} A cipher params object with the key, IV, and salt.
|
|
720
|
+
*
|
|
721
|
+
* @static
|
|
722
|
+
*
|
|
723
|
+
* @example
|
|
724
|
+
*
|
|
725
|
+
* var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
|
|
726
|
+
* var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
|
|
727
|
+
*/
|
|
728
|
+
execute: function (password, keySize, ivSize, salt, hasher) {
|
|
729
|
+
var _salt = salt;
|
|
730
|
+
// Generate random salt
|
|
731
|
+
if (!_salt) {
|
|
732
|
+
_salt = WordArray.random(64 / 8);
|
|
733
|
+
}
|
|
734
|
+
// Derive key and IV
|
|
735
|
+
var key;
|
|
736
|
+
if (!hasher) {
|
|
737
|
+
key = EvpKDFAlgo.create({ keySize: keySize + ivSize }).compute(password, _salt);
|
|
738
|
+
}
|
|
739
|
+
else {
|
|
740
|
+
key = EvpKDFAlgo.create({ keySize: keySize + ivSize, hasher: hasher }).compute(password, _salt);
|
|
741
|
+
}
|
|
742
|
+
// Separate key and IV
|
|
743
|
+
var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
|
|
744
|
+
key.sigBytes = keySize * 4;
|
|
745
|
+
// Return params
|
|
746
|
+
return CipherParams.create({ key: key, iv: iv, salt: _salt });
|
|
747
|
+
},
|
|
748
|
+
};
|
|
749
|
+
/**
|
|
750
|
+
* A serializable cipher wrapper that derives the key from a password,
|
|
751
|
+
* and returns ciphertext as a serializable cipher params object.
|
|
752
|
+
*/
|
|
753
|
+
var PasswordBasedCipher = /** @class */ (function (_super) {
|
|
754
|
+
__extends(PasswordBasedCipher, _super);
|
|
755
|
+
function PasswordBasedCipher() {
|
|
756
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Encrypts a message using a password.
|
|
760
|
+
*
|
|
761
|
+
* @param {Cipher} cipher The cipher algorithm to use.
|
|
762
|
+
* @param {WordArray|string} message The message to encrypt.
|
|
763
|
+
* @param {string} password The password.
|
|
764
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
765
|
+
*
|
|
766
|
+
* @return {CipherParams} A cipher params object.
|
|
767
|
+
*
|
|
768
|
+
* @static
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
*
|
|
772
|
+
* var ciphertextParams = CryptoJS.lib.PasswordBasedCipher
|
|
773
|
+
* .encrypt(CryptoJS.algo.AES, message, 'password');
|
|
774
|
+
* var ciphertextParams = CryptoJS.lib.PasswordBasedCipher
|
|
775
|
+
* .encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
|
|
776
|
+
*/
|
|
777
|
+
PasswordBasedCipher.encrypt = function (cipher, message, password, cfg) {
|
|
778
|
+
// Apply config defaults
|
|
779
|
+
var _cfg = Object.assign(new Base(), this.cfg, cfg);
|
|
780
|
+
// Derive key and other params
|
|
781
|
+
var derivedParams = _cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, _cfg.salt, _cfg.hasher);
|
|
782
|
+
// Add IV to config
|
|
783
|
+
_cfg.iv = derivedParams.iv;
|
|
784
|
+
// Encrypt
|
|
785
|
+
var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, _cfg);
|
|
786
|
+
// Mix in derived params
|
|
787
|
+
ciphertext.mixIn(derivedParams);
|
|
788
|
+
return ciphertext;
|
|
789
|
+
};
|
|
790
|
+
/**
|
|
791
|
+
* Decrypts serialized ciphertext using a password.
|
|
792
|
+
*
|
|
793
|
+
* @param {Cipher} cipher The cipher algorithm to use.
|
|
794
|
+
* @param {CipherParams|string} ciphertext The ciphertext to decrypt.
|
|
795
|
+
* @param {string} password The password.
|
|
796
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
797
|
+
*
|
|
798
|
+
* @return {WordArray} The plaintext.
|
|
799
|
+
*
|
|
800
|
+
* @static
|
|
801
|
+
*
|
|
802
|
+
* @example
|
|
803
|
+
*
|
|
804
|
+
* var plaintext = CryptoJS.lib.PasswordBasedCipher
|
|
805
|
+
* .decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password',
|
|
806
|
+
* { format: CryptoJS.format.OpenSSL });
|
|
807
|
+
* var plaintext = CryptoJS.lib.PasswordBasedCipher
|
|
808
|
+
* .decrypt(CryptoJS.algo.AES, ciphertextParams, 'password',
|
|
809
|
+
* { format: CryptoJS.format.OpenSSL });
|
|
810
|
+
*/
|
|
811
|
+
PasswordBasedCipher.decrypt = function (cipher, ciphertext, password, cfg) {
|
|
812
|
+
var _ciphertext = ciphertext;
|
|
813
|
+
// Apply config defaults
|
|
814
|
+
var _cfg = Object.assign(new Base(), this.cfg, cfg);
|
|
815
|
+
// Convert string to CipherParams
|
|
816
|
+
_ciphertext = this._parse(_ciphertext, _cfg.format);
|
|
817
|
+
// Derive key and other params
|
|
818
|
+
var derivedParams = _cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, _ciphertext.salt, _cfg.hasher);
|
|
819
|
+
// Add IV to config
|
|
820
|
+
_cfg.iv = derivedParams.iv;
|
|
821
|
+
// Decrypt
|
|
822
|
+
var plaintext = SerializableCipher.decrypt.call(this, cipher, _ciphertext, derivedParams.key, _cfg);
|
|
823
|
+
return plaintext;
|
|
824
|
+
};
|
|
825
|
+
return PasswordBasedCipher;
|
|
826
|
+
}(SerializableCipher));
|
|
827
|
+
export { PasswordBasedCipher };
|
|
828
|
+
/**
|
|
829
|
+
* Configuration options.
|
|
830
|
+
*
|
|
831
|
+
* @property {KDF} kdf
|
|
832
|
+
* The key derivation function to use to generate a key and IV from a password.
|
|
833
|
+
* Default: OpenSSL
|
|
834
|
+
*/
|
|
835
|
+
PasswordBasedCipher.cfg = Object.assign(SerializableCipher.cfg, {
|
|
836
|
+
kdf: OpenSSLKdf,
|
|
837
|
+
});
|
|
838
|
+
//# sourceMappingURL=cipher-core.js.map
|