@esri/solutions-components 0.7.52 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/assets/t9n/consent-manager/resources.json +12 -0
- package/dist/assets/t9n/consent-manager/resources_en.json +12 -0
- package/dist/cjs/{_commonjsHelpers-384729db.js → _commonjsHelpers-480c2e77.js} +16 -0
- package/dist/cjs/basemap-gallery_7.cjs.entry.js +3 -3
- package/dist/cjs/buffer-tools_3.cjs.entry.js +3 -3
- package/dist/cjs/calcite-action-pad_2.cjs.entry.js +3 -3
- package/dist/cjs/calcite-alert_4.cjs.entry.js +4 -4
- package/dist/cjs/calcite-color-picker-hex-input_2.cjs.entry.js +2 -2
- package/dist/cjs/calcite-color-picker.cjs.entry.js +2 -2
- package/dist/cjs/calcite-combobox_5.cjs.entry.js +3 -3
- package/dist/cjs/calcite-flow_5.cjs.entry.js +4 -4
- package/dist/cjs/calcite-input-date-picker_3.cjs.entry.js +5 -5
- package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +6 -6
- package/dist/cjs/card-manager_3.cjs.entry.js +6 -6
- package/dist/cjs/{common-4cd3537b.js → common-e6e9f7d6.js} +1 -1
- package/dist/cjs/consent-manager.cjs.entry.js +1769 -0
- package/dist/cjs/crowdsource-manager.cjs.entry.js +3 -3
- package/dist/cjs/crowdsource-reporter.cjs.entry.js +3 -3
- package/dist/cjs/{downloadUtils-82bc9a04.js → downloadUtils-c2bd7c80.js} +6 -6
- package/dist/cjs/{esri-loader-a91c0ec1.js → esri-loader-ce6c3d3d.js} +1 -1
- package/dist/cjs/{helpers-e328869d.js → helpers-81779c18.js} +1 -1
- package/dist/cjs/{html2canvas-34208bbf.js → html2canvas-27a2547c.js} +1 -1
- package/dist/cjs/{index.es-79d8773c.js → index.es-22b3d1a2.js} +6 -6
- package/dist/cjs/instant-apps-ckeditor-wrapper_3.cjs.entry.js +6 -6
- package/dist/cjs/instant-apps-control-panel.cjs.entry.js +3 -3
- package/dist/cjs/instant-apps-export.cjs.entry.js +5 -5
- package/dist/cjs/instant-apps-header.cjs.entry.js +3 -3
- package/dist/cjs/instant-apps-interactive-legend-classic.cjs.entry.js +4 -4
- package/dist/cjs/instant-apps-interactive-legend-count_2.cjs.entry.js +4 -4
- package/dist/cjs/instant-apps-interactive-legend-group-legend-element-caption.cjs.entry.js +4 -4
- package/dist/cjs/instant-apps-interactive-legend-group-legend-element_5.cjs.entry.js +4 -4
- package/dist/cjs/instant-apps-interactive-legend.cjs.entry.js +6 -6
- package/dist/cjs/instant-apps-keyboard-shortcuts.cjs.entry.js +5 -5
- package/dist/cjs/instant-apps-language-switcher.cjs.entry.js +7 -7
- package/dist/cjs/instant-apps-language-translator.cjs.entry.js +7 -7
- package/dist/cjs/instant-apps-measurement.cjs.entry.js +5 -5
- package/dist/cjs/instant-apps-popover.cjs.entry.js +5 -5
- package/dist/cjs/instant-apps-scoreboard.cjs.entry.js +5 -5
- package/dist/cjs/instant-apps-splash.cjs.entry.js +5 -5
- package/dist/cjs/{languageSwitcher-7de41e17.js → languageSwitcher-4822684b.js} +1 -1
- package/dist/cjs/{languageUtil-a3b464f8.js → languageUtil-9bd00bad.js} +1 -1
- package/dist/cjs/layout-manager.cjs.entry.js +3 -3
- package/dist/cjs/{loadModules-51c30ab9.js → loadModules-69fc5b98.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{locale-8c42ba7a.js → locale-3d0a4bc2.js} +1 -1
- package/dist/cjs/{locale-dab3f46a.js → locale-3e33f44c.js} +2 -2
- package/dist/cjs/map-select-tools_3.cjs.entry.js +6 -6
- package/dist/cjs/{popupUtils-824d2f7c.js → popupUtils-6be3588c.js} +1 -1
- package/dist/cjs/public-notification.cjs.entry.js +6 -6
- package/dist/cjs/{purify-f8c3e427.js → purify-4791ecca.js} +1 -1
- package/dist/cjs/{resources-adfcb1ec.js → resources-02142b99.js} +1 -1
- package/dist/cjs/{restHelpersGet-e0737480.js → restHelpersGet-2ed729ab.js} +1 -1
- package/dist/cjs/solution-configuration.cjs.entry.js +6 -6
- package/dist/cjs/solution-contents_3.cjs.entry.js +7 -7
- package/dist/cjs/{solution-resource-abec7452.js → solution-resource-97186521.js} +1 -1
- package/dist/cjs/{solution-store-2f7fbcc5.js → solution-store-67bcf552.js} +2 -2
- package/dist/cjs/solutions-components.cjs.js +1 -1
- package/dist/cjs/spatial-ref.cjs.entry.js +5 -5
- package/dist/cjs/{utils-a137dc1a.js → utils-ea7a5a63.js} +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/consent-manager/consent-manager.css +67 -0
- package/dist/collection/components/consent-manager/consent-manager.js +278 -0
- package/dist/collection/components/consent-manager/test/consent-manager.e2e.js +29 -0
- package/dist/collection/components/consent-manager/test/consent-manager.spec.js +37 -0
- package/dist/collection/utils/interfaces.ts +4 -0
- package/dist/components/_commonjsHelpers.js +16 -1
- package/dist/components/consent-manager.d.ts +11 -0
- package/dist/components/consent-manager.js +1844 -0
- package/dist/components/downloadUtils.js +1 -1
- package/dist/components/index.es.js +1 -1
- package/dist/esm/{_commonjsHelpers-d5f9d613.js → _commonjsHelpers-0f74c230.js} +16 -1
- package/dist/esm/basemap-gallery_7.entry.js +3 -3
- package/dist/esm/buffer-tools_3.entry.js +3 -3
- package/dist/esm/calcite-action-pad_2.entry.js +3 -3
- package/dist/esm/calcite-alert_4.entry.js +4 -4
- package/dist/esm/calcite-color-picker-hex-input_2.entry.js +2 -2
- package/dist/esm/calcite-color-picker.entry.js +2 -2
- package/dist/esm/calcite-combobox_5.entry.js +3 -3
- package/dist/esm/calcite-flow_5.entry.js +4 -4
- package/dist/esm/calcite-input-date-picker_3.entry.js +5 -5
- package/dist/esm/calcite-shell-panel_14.entry.js +6 -6
- package/dist/esm/card-manager_3.entry.js +6 -6
- package/dist/esm/{common-d04ccc0d.js → common-06bcfe81.js} +1 -1
- package/dist/esm/consent-manager.entry.js +1765 -0
- package/dist/esm/crowdsource-manager.entry.js +3 -3
- package/dist/esm/crowdsource-reporter.entry.js +3 -3
- package/dist/esm/{downloadUtils-3bab4b5f.js → downloadUtils-a6c0e25f.js} +6 -6
- package/dist/esm/{esri-loader-eda07632.js → esri-loader-1b324844.js} +1 -1
- package/dist/esm/{helpers-633917fe.js → helpers-aeddac74.js} +1 -1
- package/dist/esm/{html2canvas-a0a4df55.js → html2canvas-7f5bb1cc.js} +1 -1
- package/dist/esm/{index.es-be703f2b.js → index.es-b0a676ae.js} +6 -6
- package/dist/esm/instant-apps-ckeditor-wrapper_3.entry.js +6 -6
- package/dist/esm/instant-apps-control-panel.entry.js +3 -3
- package/dist/esm/instant-apps-export.entry.js +5 -5
- package/dist/esm/instant-apps-header.entry.js +3 -3
- package/dist/esm/instant-apps-interactive-legend-classic.entry.js +4 -4
- package/dist/esm/instant-apps-interactive-legend-count_2.entry.js +4 -4
- package/dist/esm/instant-apps-interactive-legend-group-legend-element-caption.entry.js +4 -4
- package/dist/esm/instant-apps-interactive-legend-group-legend-element_5.entry.js +4 -4
- package/dist/esm/instant-apps-interactive-legend.entry.js +6 -6
- package/dist/esm/instant-apps-keyboard-shortcuts.entry.js +5 -5
- package/dist/esm/instant-apps-language-switcher.entry.js +7 -7
- package/dist/esm/instant-apps-language-translator.entry.js +7 -7
- package/dist/esm/instant-apps-measurement.entry.js +5 -5
- package/dist/esm/instant-apps-popover.entry.js +5 -5
- package/dist/esm/instant-apps-scoreboard.entry.js +5 -5
- package/dist/esm/instant-apps-splash.entry.js +5 -5
- package/dist/esm/{languageSwitcher-62232826.js → languageSwitcher-4faa659f.js} +1 -1
- package/dist/esm/{languageUtil-8b54477c.js → languageUtil-dc3111c1.js} +1 -1
- package/dist/esm/layout-manager.entry.js +3 -3
- package/dist/esm/{loadModules-b677d6d7.js → loadModules-877bbb89.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{locale-25a5ae3e.js → locale-bcbea4ef.js} +1 -1
- package/dist/esm/{locale-c7d9e9aa.js → locale-bd9034e1.js} +2 -2
- package/dist/esm/map-select-tools_3.entry.js +6 -6
- package/dist/esm/{popupUtils-23fe3c9f.js → popupUtils-af124b47.js} +1 -1
- package/dist/esm/public-notification.entry.js +6 -6
- package/dist/esm/{purify-c99d2ace.js → purify-dce4d86b.js} +1 -1
- package/dist/esm/{resources-79914606.js → resources-61b0cdad.js} +1 -1
- package/dist/esm/{restHelpersGet-af032ab2.js → restHelpersGet-2a85d395.js} +1 -1
- package/dist/esm/solution-configuration.entry.js +6 -6
- package/dist/esm/solution-contents_3.entry.js +7 -7
- package/dist/esm/{solution-resource-7b8d302d.js → solution-resource-77aa99c8.js} +1 -1
- package/dist/esm/{solution-store-01769bbf.js → solution-store-13ddaf1c.js} +2 -2
- package/dist/esm/solutions-components.js +1 -1
- package/dist/esm/spatial-ref.entry.js +5 -5
- package/dist/esm/{utils-b46c535b.js → utils-28d0a086.js} +1 -1
- package/dist/solutions-components/{p-54b7b859.entry.js → p-015a45e2.entry.js} +1 -1
- package/dist/solutions-components/{p-b756d01f.js → p-03037cf9.js} +1 -1
- package/dist/solutions-components/{p-2917dae0.entry.js → p-03a65871.entry.js} +1 -1
- package/dist/solutions-components/{p-86b21da1.js → p-07626c45.js} +1 -1
- package/dist/solutions-components/{p-14a48b14.js → p-090e0241.js} +1 -1
- package/dist/solutions-components/{p-531ccf84.entry.js → p-09312a7a.entry.js} +1 -1
- package/dist/solutions-components/{p-8595b4aa.entry.js → p-09801ba6.entry.js} +1 -1
- package/dist/solutions-components/{p-2f017ad2.entry.js → p-0d72a9ca.entry.js} +1 -1
- package/dist/solutions-components/p-0e5274bd.entry.js +6 -0
- package/dist/solutions-components/{p-bb94c414.entry.js → p-104f07e3.entry.js} +1 -1
- package/dist/solutions-components/{p-2592e0dd.js → p-188ed8b6.js} +1 -1
- package/dist/solutions-components/{p-16a82c20.js → p-192b6455.js} +1 -1
- package/dist/solutions-components/{p-7cfc4ba5.entry.js → p-1a7cef7b.entry.js} +1 -1
- package/dist/solutions-components/{p-463712ef.entry.js → p-1ac2125a.entry.js} +2 -2
- package/dist/solutions-components/{p-23fed594.entry.js → p-1bca71bf.entry.js} +1 -1
- package/dist/solutions-components/{p-ce4eed51.entry.js → p-220c46c2.entry.js} +1 -1
- package/dist/solutions-components/{p-c8ca9b8c.entry.js → p-299d1eaf.entry.js} +3 -3
- package/dist/solutions-components/{p-7cfce9ee.entry.js → p-2e7a9b9b.entry.js} +2 -2
- package/dist/solutions-components/{p-df468e80.entry.js → p-35c9256b.entry.js} +2 -2
- package/dist/solutions-components/{p-d561c970.entry.js → p-41bc9e9d.entry.js} +1 -1
- package/dist/solutions-components/{p-4742efa8.entry.js → p-5a28d60c.entry.js} +1 -1
- package/dist/solutions-components/{p-e46617d1.entry.js → p-5c7e3941.entry.js} +1 -1
- package/dist/solutions-components/{p-8dbf3319.entry.js → p-63466518.entry.js} +1 -1
- package/dist/solutions-components/{p-c05467fd.entry.js → p-6512dc44.entry.js} +1 -1
- package/dist/solutions-components/{p-0f66fd89.js → p-66bca043.js} +3 -3
- package/dist/solutions-components/{p-a8a0187d.js → p-70359c2b.js} +1 -1
- package/dist/solutions-components/{p-91d3732f.js → p-734d1dc5.js} +1 -1
- package/dist/solutions-components/{p-de459c0a.entry.js → p-7d6ee026.entry.js} +1 -1
- package/dist/solutions-components/{p-91710f0e.entry.js → p-8ad937b4.entry.js} +1 -1
- package/dist/solutions-components/{p-d918ec36.js → p-8ddc7786.js} +1 -1
- package/dist/solutions-components/p-8e9f96db.js +6 -0
- package/dist/solutions-components/{p-220ec0d1.js → p-94c634ba.js} +1 -1
- package/dist/solutions-components/{p-e2b0b3fa.entry.js → p-a2544cba.entry.js} +1 -1
- package/dist/solutions-components/{p-3cf84035.entry.js → p-a455c3f0.entry.js} +1 -1
- package/dist/solutions-components/{p-044cd52c.entry.js → p-a59078ee.entry.js} +1 -1
- package/dist/solutions-components/{p-701ed205.js → p-a7b7f8d1.js} +1 -1
- package/dist/solutions-components/{p-96104375.entry.js → p-aec4441b.entry.js} +1 -1
- package/dist/solutions-components/{p-d9995b7e.js → p-b41e2c4c.js} +3 -3
- package/dist/solutions-components/{p-d89fff3a.js → p-b503d01d.js} +1 -1
- package/dist/solutions-components/{p-cacd0307.entry.js → p-b80bc5b9.entry.js} +1 -1
- package/dist/solutions-components/{p-b04c9dc3.js → p-be8ef276.js} +1 -1
- package/dist/solutions-components/{p-6ac459d9.entry.js → p-c10b44ee.entry.js} +1 -1
- package/dist/solutions-components/{p-88cd4a24.entry.js → p-c302bbea.entry.js} +1 -1
- package/dist/solutions-components/{p-547b4dba.entry.js → p-c375881a.entry.js} +1 -1
- package/dist/solutions-components/{p-e05b02c5.entry.js → p-cd1ca3a6.entry.js} +1 -1
- package/dist/solutions-components/{p-3cce003d.js → p-cde1d741.js} +1 -1
- package/dist/solutions-components/{p-ccfdd890.entry.js → p-cfe890f6.entry.js} +1 -1
- package/dist/solutions-components/{p-a4bb0787.entry.js → p-df29f4c2.entry.js} +1 -1
- package/dist/solutions-components/p-e2d0ad1b.js +6 -0
- package/dist/solutions-components/{p-bf9e18d4.js → p-eab00813.js} +1 -1
- package/dist/solutions-components/{p-e8cd89c2.entry.js → p-efe1694a.entry.js} +1 -1
- package/dist/solutions-components/{p-697e9e11.entry.js → p-f3467807.entry.js} +1 -1
- package/dist/solutions-components/{p-3cb1de38.entry.js → p-f6be44e6.entry.js} +1 -1
- package/dist/solutions-components/{p-f23e6499.js → p-fb7a5f6e.js} +2 -2
- package/dist/solutions-components/{p-dbb6f1e2.entry.js → p-ff302d95.entry.js} +1 -1
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/interfaces.ts +4 -0
- package/dist/types/components/consent-manager/consent-manager.d.ts +109 -0
- package/dist/types/components.d.ts +62 -2
- package/dist/types/preact.d.ts +4 -0
- package/dist/types/utils/interfaces.d.ts +3 -0
- package/package.json +5 -2
- package/dist/solutions-components/p-00f9774c.js +0 -6
- package/dist/solutions-components/p-e1a4994d.js +0 -6
@@ -0,0 +1,1765 @@
|
|
1
|
+
/*!
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
*/
|
6
|
+
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-164d485a.js';
|
7
|
+
import { g as getLocaleComponentStrings } from './locale-bcbea4ef.js';
|
8
|
+
import { g as getAugmentedNamespace, c as createCommonjsModule, a as commonjsGlobal, b as commonjsRequire } from './_commonjsHelpers-0f74c230.js';
|
9
|
+
import './esri-loader-1b324844.js';
|
10
|
+
|
11
|
+
const _nodeResolve_empty = {};
|
12
|
+
|
13
|
+
const _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
|
14
|
+
__proto__: null,
|
15
|
+
'default': _nodeResolve_empty
|
16
|
+
});
|
17
|
+
|
18
|
+
const require$$0 = /*@__PURE__*/getAugmentedNamespace(_nodeResolve_empty$1);
|
19
|
+
|
20
|
+
var core = createCommonjsModule(function (module, exports) {
|
21
|
+
(function (root, factory) {
|
22
|
+
{
|
23
|
+
// CommonJS
|
24
|
+
module.exports = factory();
|
25
|
+
}
|
26
|
+
}(commonjsGlobal, function () {
|
27
|
+
|
28
|
+
/*globals window, global, require*/
|
29
|
+
|
30
|
+
/**
|
31
|
+
* CryptoJS core components.
|
32
|
+
*/
|
33
|
+
var CryptoJS = CryptoJS || (function (Math, undefined$1) {
|
34
|
+
|
35
|
+
var crypto;
|
36
|
+
|
37
|
+
// Native crypto from window (Browser)
|
38
|
+
if (typeof window !== 'undefined' && window.crypto) {
|
39
|
+
crypto = window.crypto;
|
40
|
+
}
|
41
|
+
|
42
|
+
// Native crypto in web worker (Browser)
|
43
|
+
if (typeof self !== 'undefined' && self.crypto) {
|
44
|
+
crypto = self.crypto;
|
45
|
+
}
|
46
|
+
|
47
|
+
// Native crypto from worker
|
48
|
+
if (typeof globalThis !== 'undefined' && globalThis.crypto) {
|
49
|
+
crypto = globalThis.crypto;
|
50
|
+
}
|
51
|
+
|
52
|
+
// Native (experimental IE 11) crypto from window (Browser)
|
53
|
+
if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
|
54
|
+
crypto = window.msCrypto;
|
55
|
+
}
|
56
|
+
|
57
|
+
// Native crypto from global (NodeJS)
|
58
|
+
if (!crypto && typeof commonjsGlobal !== 'undefined' && commonjsGlobal.crypto) {
|
59
|
+
crypto = commonjsGlobal.crypto;
|
60
|
+
}
|
61
|
+
|
62
|
+
// Native crypto import via require (NodeJS)
|
63
|
+
if (!crypto && typeof commonjsRequire === 'function') {
|
64
|
+
try {
|
65
|
+
crypto = require$$0;
|
66
|
+
} catch (err) {}
|
67
|
+
}
|
68
|
+
|
69
|
+
/*
|
70
|
+
* Cryptographically secure pseudorandom number generator
|
71
|
+
*
|
72
|
+
* As Math.random() is cryptographically not safe to use
|
73
|
+
*/
|
74
|
+
var cryptoSecureRandomInt = function () {
|
75
|
+
if (crypto) {
|
76
|
+
// Use getRandomValues method (Browser)
|
77
|
+
if (typeof crypto.getRandomValues === 'function') {
|
78
|
+
try {
|
79
|
+
return crypto.getRandomValues(new Uint32Array(1))[0];
|
80
|
+
} catch (err) {}
|
81
|
+
}
|
82
|
+
|
83
|
+
// Use randomBytes method (NodeJS)
|
84
|
+
if (typeof crypto.randomBytes === 'function') {
|
85
|
+
try {
|
86
|
+
return crypto.randomBytes(4).readInt32LE();
|
87
|
+
} catch (err) {}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
throw new Error('Native crypto module could not be used to get secure random number.');
|
92
|
+
};
|
93
|
+
|
94
|
+
/*
|
95
|
+
* Local polyfill of Object.create
|
96
|
+
|
97
|
+
*/
|
98
|
+
var create = Object.create || (function () {
|
99
|
+
function F() {}
|
100
|
+
|
101
|
+
return function (obj) {
|
102
|
+
var subtype;
|
103
|
+
|
104
|
+
F.prototype = obj;
|
105
|
+
|
106
|
+
subtype = new F();
|
107
|
+
|
108
|
+
F.prototype = null;
|
109
|
+
|
110
|
+
return subtype;
|
111
|
+
};
|
112
|
+
}());
|
113
|
+
|
114
|
+
/**
|
115
|
+
* CryptoJS namespace.
|
116
|
+
*/
|
117
|
+
var C = {};
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Library namespace.
|
121
|
+
*/
|
122
|
+
var C_lib = C.lib = {};
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Base object for prototypal inheritance.
|
126
|
+
*/
|
127
|
+
var Base = C_lib.Base = (function () {
|
128
|
+
|
129
|
+
|
130
|
+
return {
|
131
|
+
/**
|
132
|
+
* Creates a new object that inherits from this object.
|
133
|
+
*
|
134
|
+
* @param {Object} overrides Properties to copy into the new object.
|
135
|
+
*
|
136
|
+
* @return {Object} The new object.
|
137
|
+
*
|
138
|
+
* @static
|
139
|
+
*
|
140
|
+
* @example
|
141
|
+
*
|
142
|
+
* var MyType = CryptoJS.lib.Base.extend({
|
143
|
+
* field: 'value',
|
144
|
+
*
|
145
|
+
* method: function () {
|
146
|
+
* }
|
147
|
+
* });
|
148
|
+
*/
|
149
|
+
extend: function (overrides) {
|
150
|
+
// Spawn
|
151
|
+
var subtype = create(this);
|
152
|
+
|
153
|
+
// Augment
|
154
|
+
if (overrides) {
|
155
|
+
subtype.mixIn(overrides);
|
156
|
+
}
|
157
|
+
|
158
|
+
// Create default initializer
|
159
|
+
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
|
160
|
+
subtype.init = function () {
|
161
|
+
subtype.$super.init.apply(this, arguments);
|
162
|
+
};
|
163
|
+
}
|
164
|
+
|
165
|
+
// Initializer's prototype is the subtype object
|
166
|
+
subtype.init.prototype = subtype;
|
167
|
+
|
168
|
+
// Reference supertype
|
169
|
+
subtype.$super = this;
|
170
|
+
|
171
|
+
return subtype;
|
172
|
+
},
|
173
|
+
|
174
|
+
/**
|
175
|
+
* Extends this object and runs the init method.
|
176
|
+
* Arguments to create() will be passed to init().
|
177
|
+
*
|
178
|
+
* @return {Object} The new object.
|
179
|
+
*
|
180
|
+
* @static
|
181
|
+
*
|
182
|
+
* @example
|
183
|
+
*
|
184
|
+
* var instance = MyType.create();
|
185
|
+
*/
|
186
|
+
create: function () {
|
187
|
+
var instance = this.extend();
|
188
|
+
instance.init.apply(instance, arguments);
|
189
|
+
|
190
|
+
return instance;
|
191
|
+
},
|
192
|
+
|
193
|
+
/**
|
194
|
+
* Initializes a newly created object.
|
195
|
+
* Override this method to add some logic when your objects are created.
|
196
|
+
*
|
197
|
+
* @example
|
198
|
+
*
|
199
|
+
* var MyType = CryptoJS.lib.Base.extend({
|
200
|
+
* init: function () {
|
201
|
+
* // ...
|
202
|
+
* }
|
203
|
+
* });
|
204
|
+
*/
|
205
|
+
init: function () {
|
206
|
+
},
|
207
|
+
|
208
|
+
/**
|
209
|
+
* Copies properties into this object.
|
210
|
+
*
|
211
|
+
* @param {Object} properties The properties to mix in.
|
212
|
+
*
|
213
|
+
* @example
|
214
|
+
*
|
215
|
+
* MyType.mixIn({
|
216
|
+
* field: 'value'
|
217
|
+
* });
|
218
|
+
*/
|
219
|
+
mixIn: function (properties) {
|
220
|
+
for (var propertyName in properties) {
|
221
|
+
if (properties.hasOwnProperty(propertyName)) {
|
222
|
+
this[propertyName] = properties[propertyName];
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
// IE won't copy toString using the loop above
|
227
|
+
if (properties.hasOwnProperty('toString')) {
|
228
|
+
this.toString = properties.toString;
|
229
|
+
}
|
230
|
+
},
|
231
|
+
|
232
|
+
/**
|
233
|
+
* Creates a copy of this object.
|
234
|
+
*
|
235
|
+
* @return {Object} The clone.
|
236
|
+
*
|
237
|
+
* @example
|
238
|
+
*
|
239
|
+
* var clone = instance.clone();
|
240
|
+
*/
|
241
|
+
clone: function () {
|
242
|
+
return this.init.prototype.extend(this);
|
243
|
+
}
|
244
|
+
};
|
245
|
+
}());
|
246
|
+
|
247
|
+
/**
|
248
|
+
* An array of 32-bit words.
|
249
|
+
*
|
250
|
+
* @property {Array} words The array of 32-bit words.
|
251
|
+
* @property {number} sigBytes The number of significant bytes in this word array.
|
252
|
+
*/
|
253
|
+
var WordArray = C_lib.WordArray = Base.extend({
|
254
|
+
/**
|
255
|
+
* Initializes a newly created word array.
|
256
|
+
*
|
257
|
+
* @param {Array} words (Optional) An array of 32-bit words.
|
258
|
+
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
259
|
+
*
|
260
|
+
* @example
|
261
|
+
*
|
262
|
+
* var wordArray = CryptoJS.lib.WordArray.create();
|
263
|
+
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
|
264
|
+
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
|
265
|
+
*/
|
266
|
+
init: function (words, sigBytes) {
|
267
|
+
words = this.words = words || [];
|
268
|
+
|
269
|
+
if (sigBytes != undefined$1) {
|
270
|
+
this.sigBytes = sigBytes;
|
271
|
+
} else {
|
272
|
+
this.sigBytes = words.length * 4;
|
273
|
+
}
|
274
|
+
},
|
275
|
+
|
276
|
+
/**
|
277
|
+
* Converts this word array to a string.
|
278
|
+
*
|
279
|
+
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
|
280
|
+
*
|
281
|
+
* @return {string} The stringified word array.
|
282
|
+
*
|
283
|
+
* @example
|
284
|
+
*
|
285
|
+
* var string = wordArray + '';
|
286
|
+
* var string = wordArray.toString();
|
287
|
+
* var string = wordArray.toString(CryptoJS.enc.Utf8);
|
288
|
+
*/
|
289
|
+
toString: function (encoder) {
|
290
|
+
return (encoder || Hex).stringify(this);
|
291
|
+
},
|
292
|
+
|
293
|
+
/**
|
294
|
+
* Concatenates a word array to this word array.
|
295
|
+
*
|
296
|
+
* @param {WordArray} wordArray The word array to append.
|
297
|
+
*
|
298
|
+
* @return {WordArray} This word array.
|
299
|
+
*
|
300
|
+
* @example
|
301
|
+
*
|
302
|
+
* wordArray1.concat(wordArray2);
|
303
|
+
*/
|
304
|
+
concat: function (wordArray) {
|
305
|
+
// Shortcuts
|
306
|
+
var thisWords = this.words;
|
307
|
+
var thatWords = wordArray.words;
|
308
|
+
var thisSigBytes = this.sigBytes;
|
309
|
+
var thatSigBytes = wordArray.sigBytes;
|
310
|
+
|
311
|
+
// Clamp excess bits
|
312
|
+
this.clamp();
|
313
|
+
|
314
|
+
// Concat
|
315
|
+
if (thisSigBytes % 4) {
|
316
|
+
// Copy one byte at a time
|
317
|
+
for (var i = 0; i < thatSigBytes; i++) {
|
318
|
+
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
319
|
+
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
|
320
|
+
}
|
321
|
+
} else {
|
322
|
+
// Copy one word at a time
|
323
|
+
for (var j = 0; j < thatSigBytes; j += 4) {
|
324
|
+
thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
|
325
|
+
}
|
326
|
+
}
|
327
|
+
this.sigBytes += thatSigBytes;
|
328
|
+
|
329
|
+
// Chainable
|
330
|
+
return this;
|
331
|
+
},
|
332
|
+
|
333
|
+
/**
|
334
|
+
* Removes insignificant bits.
|
335
|
+
*
|
336
|
+
* @example
|
337
|
+
*
|
338
|
+
* wordArray.clamp();
|
339
|
+
*/
|
340
|
+
clamp: function () {
|
341
|
+
// Shortcuts
|
342
|
+
var words = this.words;
|
343
|
+
var sigBytes = this.sigBytes;
|
344
|
+
|
345
|
+
// Clamp
|
346
|
+
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
|
347
|
+
words.length = Math.ceil(sigBytes / 4);
|
348
|
+
},
|
349
|
+
|
350
|
+
/**
|
351
|
+
* Creates a copy of this word array.
|
352
|
+
*
|
353
|
+
* @return {WordArray} The clone.
|
354
|
+
*
|
355
|
+
* @example
|
356
|
+
*
|
357
|
+
* var clone = wordArray.clone();
|
358
|
+
*/
|
359
|
+
clone: function () {
|
360
|
+
var clone = Base.clone.call(this);
|
361
|
+
clone.words = this.words.slice(0);
|
362
|
+
|
363
|
+
return clone;
|
364
|
+
},
|
365
|
+
|
366
|
+
/**
|
367
|
+
* Creates a word array filled with random bytes.
|
368
|
+
*
|
369
|
+
* @param {number} nBytes The number of random bytes to generate.
|
370
|
+
*
|
371
|
+
* @return {WordArray} The random word array.
|
372
|
+
*
|
373
|
+
* @static
|
374
|
+
*
|
375
|
+
* @example
|
376
|
+
*
|
377
|
+
* var wordArray = CryptoJS.lib.WordArray.random(16);
|
378
|
+
*/
|
379
|
+
random: function (nBytes) {
|
380
|
+
var words = [];
|
381
|
+
|
382
|
+
for (var i = 0; i < nBytes; i += 4) {
|
383
|
+
words.push(cryptoSecureRandomInt());
|
384
|
+
}
|
385
|
+
|
386
|
+
return new WordArray.init(words, nBytes);
|
387
|
+
}
|
388
|
+
});
|
389
|
+
|
390
|
+
/**
|
391
|
+
* Encoder namespace.
|
392
|
+
*/
|
393
|
+
var C_enc = C.enc = {};
|
394
|
+
|
395
|
+
/**
|
396
|
+
* Hex encoding strategy.
|
397
|
+
*/
|
398
|
+
var Hex = C_enc.Hex = {
|
399
|
+
/**
|
400
|
+
* Converts a word array to a hex string.
|
401
|
+
*
|
402
|
+
* @param {WordArray} wordArray The word array.
|
403
|
+
*
|
404
|
+
* @return {string} The hex string.
|
405
|
+
*
|
406
|
+
* @static
|
407
|
+
*
|
408
|
+
* @example
|
409
|
+
*
|
410
|
+
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
|
411
|
+
*/
|
412
|
+
stringify: function (wordArray) {
|
413
|
+
// Shortcuts
|
414
|
+
var words = wordArray.words;
|
415
|
+
var sigBytes = wordArray.sigBytes;
|
416
|
+
|
417
|
+
// Convert
|
418
|
+
var hexChars = [];
|
419
|
+
for (var i = 0; i < sigBytes; i++) {
|
420
|
+
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
421
|
+
hexChars.push((bite >>> 4).toString(16));
|
422
|
+
hexChars.push((bite & 0x0f).toString(16));
|
423
|
+
}
|
424
|
+
|
425
|
+
return hexChars.join('');
|
426
|
+
},
|
427
|
+
|
428
|
+
/**
|
429
|
+
* Converts a hex string to a word array.
|
430
|
+
*
|
431
|
+
* @param {string} hexStr The hex string.
|
432
|
+
*
|
433
|
+
* @return {WordArray} The word array.
|
434
|
+
*
|
435
|
+
* @static
|
436
|
+
*
|
437
|
+
* @example
|
438
|
+
*
|
439
|
+
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
|
440
|
+
*/
|
441
|
+
parse: function (hexStr) {
|
442
|
+
// Shortcut
|
443
|
+
var hexStrLength = hexStr.length;
|
444
|
+
|
445
|
+
// Convert
|
446
|
+
var words = [];
|
447
|
+
for (var i = 0; i < hexStrLength; i += 2) {
|
448
|
+
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
|
449
|
+
}
|
450
|
+
|
451
|
+
return new WordArray.init(words, hexStrLength / 2);
|
452
|
+
}
|
453
|
+
};
|
454
|
+
|
455
|
+
/**
|
456
|
+
* Latin1 encoding strategy.
|
457
|
+
*/
|
458
|
+
var Latin1 = C_enc.Latin1 = {
|
459
|
+
/**
|
460
|
+
* Converts a word array to a Latin1 string.
|
461
|
+
*
|
462
|
+
* @param {WordArray} wordArray The word array.
|
463
|
+
*
|
464
|
+
* @return {string} The Latin1 string.
|
465
|
+
*
|
466
|
+
* @static
|
467
|
+
*
|
468
|
+
* @example
|
469
|
+
*
|
470
|
+
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
|
471
|
+
*/
|
472
|
+
stringify: function (wordArray) {
|
473
|
+
// Shortcuts
|
474
|
+
var words = wordArray.words;
|
475
|
+
var sigBytes = wordArray.sigBytes;
|
476
|
+
|
477
|
+
// Convert
|
478
|
+
var latin1Chars = [];
|
479
|
+
for (var i = 0; i < sigBytes; i++) {
|
480
|
+
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
481
|
+
latin1Chars.push(String.fromCharCode(bite));
|
482
|
+
}
|
483
|
+
|
484
|
+
return latin1Chars.join('');
|
485
|
+
},
|
486
|
+
|
487
|
+
/**
|
488
|
+
* Converts a Latin1 string to a word array.
|
489
|
+
*
|
490
|
+
* @param {string} latin1Str The Latin1 string.
|
491
|
+
*
|
492
|
+
* @return {WordArray} The word array.
|
493
|
+
*
|
494
|
+
* @static
|
495
|
+
*
|
496
|
+
* @example
|
497
|
+
*
|
498
|
+
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
|
499
|
+
*/
|
500
|
+
parse: function (latin1Str) {
|
501
|
+
// Shortcut
|
502
|
+
var latin1StrLength = latin1Str.length;
|
503
|
+
|
504
|
+
// Convert
|
505
|
+
var words = [];
|
506
|
+
for (var i = 0; i < latin1StrLength; i++) {
|
507
|
+
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
|
508
|
+
}
|
509
|
+
|
510
|
+
return new WordArray.init(words, latin1StrLength);
|
511
|
+
}
|
512
|
+
};
|
513
|
+
|
514
|
+
/**
|
515
|
+
* UTF-8 encoding strategy.
|
516
|
+
*/
|
517
|
+
var Utf8 = C_enc.Utf8 = {
|
518
|
+
/**
|
519
|
+
* Converts a word array to a UTF-8 string.
|
520
|
+
*
|
521
|
+
* @param {WordArray} wordArray The word array.
|
522
|
+
*
|
523
|
+
* @return {string} The UTF-8 string.
|
524
|
+
*
|
525
|
+
* @static
|
526
|
+
*
|
527
|
+
* @example
|
528
|
+
*
|
529
|
+
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
|
530
|
+
*/
|
531
|
+
stringify: function (wordArray) {
|
532
|
+
try {
|
533
|
+
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
534
|
+
} catch (e) {
|
535
|
+
throw new Error('Malformed UTF-8 data');
|
536
|
+
}
|
537
|
+
},
|
538
|
+
|
539
|
+
/**
|
540
|
+
* Converts a UTF-8 string to a word array.
|
541
|
+
*
|
542
|
+
* @param {string} utf8Str The UTF-8 string.
|
543
|
+
*
|
544
|
+
* @return {WordArray} The word array.
|
545
|
+
*
|
546
|
+
* @static
|
547
|
+
*
|
548
|
+
* @example
|
549
|
+
*
|
550
|
+
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
|
551
|
+
*/
|
552
|
+
parse: function (utf8Str) {
|
553
|
+
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
554
|
+
}
|
555
|
+
};
|
556
|
+
|
557
|
+
/**
|
558
|
+
* Abstract buffered block algorithm template.
|
559
|
+
*
|
560
|
+
* The property blockSize must be implemented in a concrete subtype.
|
561
|
+
*
|
562
|
+
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
|
563
|
+
*/
|
564
|
+
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
565
|
+
/**
|
566
|
+
* Resets this block algorithm's data buffer to its initial state.
|
567
|
+
*
|
568
|
+
* @example
|
569
|
+
*
|
570
|
+
* bufferedBlockAlgorithm.reset();
|
571
|
+
*/
|
572
|
+
reset: function () {
|
573
|
+
// Initial values
|
574
|
+
this._data = new WordArray.init();
|
575
|
+
this._nDataBytes = 0;
|
576
|
+
},
|
577
|
+
|
578
|
+
/**
|
579
|
+
* Adds new data to this block algorithm's buffer.
|
580
|
+
*
|
581
|
+
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
|
582
|
+
*
|
583
|
+
* @example
|
584
|
+
*
|
585
|
+
* bufferedBlockAlgorithm._append('data');
|
586
|
+
* bufferedBlockAlgorithm._append(wordArray);
|
587
|
+
*/
|
588
|
+
_append: function (data) {
|
589
|
+
// Convert string to WordArray, else assume WordArray already
|
590
|
+
if (typeof data == 'string') {
|
591
|
+
data = Utf8.parse(data);
|
592
|
+
}
|
593
|
+
|
594
|
+
// Append
|
595
|
+
this._data.concat(data);
|
596
|
+
this._nDataBytes += data.sigBytes;
|
597
|
+
},
|
598
|
+
|
599
|
+
/**
|
600
|
+
* Processes available data blocks.
|
601
|
+
*
|
602
|
+
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
|
603
|
+
*
|
604
|
+
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
|
605
|
+
*
|
606
|
+
* @return {WordArray} The processed data.
|
607
|
+
*
|
608
|
+
* @example
|
609
|
+
*
|
610
|
+
* var processedData = bufferedBlockAlgorithm._process();
|
611
|
+
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
|
612
|
+
*/
|
613
|
+
_process: function (doFlush) {
|
614
|
+
var processedWords;
|
615
|
+
|
616
|
+
// Shortcuts
|
617
|
+
var data = this._data;
|
618
|
+
var dataWords = data.words;
|
619
|
+
var dataSigBytes = data.sigBytes;
|
620
|
+
var blockSize = this.blockSize;
|
621
|
+
var blockSizeBytes = blockSize * 4;
|
622
|
+
|
623
|
+
// Count blocks ready
|
624
|
+
var nBlocksReady = dataSigBytes / blockSizeBytes;
|
625
|
+
if (doFlush) {
|
626
|
+
// Round up to include partial blocks
|
627
|
+
nBlocksReady = Math.ceil(nBlocksReady);
|
628
|
+
} else {
|
629
|
+
// Round down to include only full blocks,
|
630
|
+
// less the number of blocks that must remain in the buffer
|
631
|
+
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
632
|
+
}
|
633
|
+
|
634
|
+
// Count words ready
|
635
|
+
var nWordsReady = nBlocksReady * blockSize;
|
636
|
+
|
637
|
+
// Count bytes ready
|
638
|
+
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
|
639
|
+
|
640
|
+
// Process blocks
|
641
|
+
if (nWordsReady) {
|
642
|
+
for (var offset = 0; offset < nWordsReady; offset += blockSize) {
|
643
|
+
// Perform concrete-algorithm logic
|
644
|
+
this._doProcessBlock(dataWords, offset);
|
645
|
+
}
|
646
|
+
|
647
|
+
// Remove processed words
|
648
|
+
processedWords = dataWords.splice(0, nWordsReady);
|
649
|
+
data.sigBytes -= nBytesReady;
|
650
|
+
}
|
651
|
+
|
652
|
+
// Return processed words
|
653
|
+
return new WordArray.init(processedWords, nBytesReady);
|
654
|
+
},
|
655
|
+
|
656
|
+
/**
|
657
|
+
* Creates a copy of this object.
|
658
|
+
*
|
659
|
+
* @return {Object} The clone.
|
660
|
+
*
|
661
|
+
* @example
|
662
|
+
*
|
663
|
+
* var clone = bufferedBlockAlgorithm.clone();
|
664
|
+
*/
|
665
|
+
clone: function () {
|
666
|
+
var clone = Base.clone.call(this);
|
667
|
+
clone._data = this._data.clone();
|
668
|
+
|
669
|
+
return clone;
|
670
|
+
},
|
671
|
+
|
672
|
+
_minBufferSize: 0
|
673
|
+
});
|
674
|
+
|
675
|
+
/**
|
676
|
+
* Abstract hasher template.
|
677
|
+
*
|
678
|
+
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
|
679
|
+
*/
|
680
|
+
C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
681
|
+
/**
|
682
|
+
* Configuration options.
|
683
|
+
*/
|
684
|
+
cfg: Base.extend(),
|
685
|
+
|
686
|
+
/**
|
687
|
+
* Initializes a newly created hasher.
|
688
|
+
*
|
689
|
+
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
|
690
|
+
*
|
691
|
+
* @example
|
692
|
+
*
|
693
|
+
* var hasher = CryptoJS.algo.SHA256.create();
|
694
|
+
*/
|
695
|
+
init: function (cfg) {
|
696
|
+
// Apply config defaults
|
697
|
+
this.cfg = this.cfg.extend(cfg);
|
698
|
+
|
699
|
+
// Set initial values
|
700
|
+
this.reset();
|
701
|
+
},
|
702
|
+
|
703
|
+
/**
|
704
|
+
* Resets this hasher to its initial state.
|
705
|
+
*
|
706
|
+
* @example
|
707
|
+
*
|
708
|
+
* hasher.reset();
|
709
|
+
*/
|
710
|
+
reset: function () {
|
711
|
+
// Reset data buffer
|
712
|
+
BufferedBlockAlgorithm.reset.call(this);
|
713
|
+
|
714
|
+
// Perform concrete-hasher logic
|
715
|
+
this._doReset();
|
716
|
+
},
|
717
|
+
|
718
|
+
/**
|
719
|
+
* Updates this hasher with a message.
|
720
|
+
*
|
721
|
+
* @param {WordArray|string} messageUpdate The message to append.
|
722
|
+
*
|
723
|
+
* @return {Hasher} This hasher.
|
724
|
+
*
|
725
|
+
* @example
|
726
|
+
*
|
727
|
+
* hasher.update('message');
|
728
|
+
* hasher.update(wordArray);
|
729
|
+
*/
|
730
|
+
update: function (messageUpdate) {
|
731
|
+
// Append
|
732
|
+
this._append(messageUpdate);
|
733
|
+
|
734
|
+
// Update the hash
|
735
|
+
this._process();
|
736
|
+
|
737
|
+
// Chainable
|
738
|
+
return this;
|
739
|
+
},
|
740
|
+
|
741
|
+
/**
|
742
|
+
* Finalizes the hash computation.
|
743
|
+
* Note that the finalize operation is effectively a destructive, read-once operation.
|
744
|
+
*
|
745
|
+
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
746
|
+
*
|
747
|
+
* @return {WordArray} The hash.
|
748
|
+
*
|
749
|
+
* @example
|
750
|
+
*
|
751
|
+
* var hash = hasher.finalize();
|
752
|
+
* var hash = hasher.finalize('message');
|
753
|
+
* var hash = hasher.finalize(wordArray);
|
754
|
+
*/
|
755
|
+
finalize: function (messageUpdate) {
|
756
|
+
// Final message update
|
757
|
+
if (messageUpdate) {
|
758
|
+
this._append(messageUpdate);
|
759
|
+
}
|
760
|
+
|
761
|
+
// Perform concrete-hasher logic
|
762
|
+
var hash = this._doFinalize();
|
763
|
+
|
764
|
+
return hash;
|
765
|
+
},
|
766
|
+
|
767
|
+
blockSize: 512/32,
|
768
|
+
|
769
|
+
/**
|
770
|
+
* Creates a shortcut function to a hasher's object interface.
|
771
|
+
*
|
772
|
+
* @param {Hasher} hasher The hasher to create a helper for.
|
773
|
+
*
|
774
|
+
* @return {Function} The shortcut function.
|
775
|
+
*
|
776
|
+
* @static
|
777
|
+
*
|
778
|
+
* @example
|
779
|
+
*
|
780
|
+
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
|
781
|
+
*/
|
782
|
+
_createHelper: function (hasher) {
|
783
|
+
return function (message, cfg) {
|
784
|
+
return new hasher.init(cfg).finalize(message);
|
785
|
+
};
|
786
|
+
},
|
787
|
+
|
788
|
+
/**
|
789
|
+
* Creates a shortcut function to the HMAC's object interface.
|
790
|
+
*
|
791
|
+
* @param {Hasher} hasher The hasher to use in this HMAC helper.
|
792
|
+
*
|
793
|
+
* @return {Function} The shortcut function.
|
794
|
+
*
|
795
|
+
* @static
|
796
|
+
*
|
797
|
+
* @example
|
798
|
+
*
|
799
|
+
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
|
800
|
+
*/
|
801
|
+
_createHmacHelper: function (hasher) {
|
802
|
+
return function (message, key) {
|
803
|
+
return new C_algo.HMAC.init(hasher, key).finalize(message);
|
804
|
+
};
|
805
|
+
}
|
806
|
+
});
|
807
|
+
|
808
|
+
/**
|
809
|
+
* Algorithm namespace.
|
810
|
+
*/
|
811
|
+
var C_algo = C.algo = {};
|
812
|
+
|
813
|
+
return C;
|
814
|
+
}(Math));
|
815
|
+
|
816
|
+
|
817
|
+
return CryptoJS;
|
818
|
+
|
819
|
+
}));
|
820
|
+
});
|
821
|
+
|
822
|
+
var sha256 = createCommonjsModule(function (module, exports) {
|
823
|
+
(function (root, factory) {
|
824
|
+
{
|
825
|
+
// CommonJS
|
826
|
+
module.exports = factory(core);
|
827
|
+
}
|
828
|
+
}(commonjsGlobal, function (CryptoJS) {
|
829
|
+
|
830
|
+
(function (Math) {
|
831
|
+
// Shortcuts
|
832
|
+
var C = CryptoJS;
|
833
|
+
var C_lib = C.lib;
|
834
|
+
var WordArray = C_lib.WordArray;
|
835
|
+
var Hasher = C_lib.Hasher;
|
836
|
+
var C_algo = C.algo;
|
837
|
+
|
838
|
+
// Initialization and round constants tables
|
839
|
+
var H = [];
|
840
|
+
var K = [];
|
841
|
+
|
842
|
+
// Compute constants
|
843
|
+
(function () {
|
844
|
+
function isPrime(n) {
|
845
|
+
var sqrtN = Math.sqrt(n);
|
846
|
+
for (var factor = 2; factor <= sqrtN; factor++) {
|
847
|
+
if (!(n % factor)) {
|
848
|
+
return false;
|
849
|
+
}
|
850
|
+
}
|
851
|
+
|
852
|
+
return true;
|
853
|
+
}
|
854
|
+
|
855
|
+
function getFractionalBits(n) {
|
856
|
+
return ((n - (n | 0)) * 0x100000000) | 0;
|
857
|
+
}
|
858
|
+
|
859
|
+
var n = 2;
|
860
|
+
var nPrime = 0;
|
861
|
+
while (nPrime < 64) {
|
862
|
+
if (isPrime(n)) {
|
863
|
+
if (nPrime < 8) {
|
864
|
+
H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
|
865
|
+
}
|
866
|
+
K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
|
867
|
+
|
868
|
+
nPrime++;
|
869
|
+
}
|
870
|
+
|
871
|
+
n++;
|
872
|
+
}
|
873
|
+
}());
|
874
|
+
|
875
|
+
// Reusable object
|
876
|
+
var W = [];
|
877
|
+
|
878
|
+
/**
|
879
|
+
* SHA-256 hash algorithm.
|
880
|
+
*/
|
881
|
+
var SHA256 = C_algo.SHA256 = Hasher.extend({
|
882
|
+
_doReset: function () {
|
883
|
+
this._hash = new WordArray.init(H.slice(0));
|
884
|
+
},
|
885
|
+
|
886
|
+
_doProcessBlock: function (M, offset) {
|
887
|
+
// Shortcut
|
888
|
+
var H = this._hash.words;
|
889
|
+
|
890
|
+
// Working variables
|
891
|
+
var a = H[0];
|
892
|
+
var b = H[1];
|
893
|
+
var c = H[2];
|
894
|
+
var d = H[3];
|
895
|
+
var e = H[4];
|
896
|
+
var f = H[5];
|
897
|
+
var g = H[6];
|
898
|
+
var h = H[7];
|
899
|
+
|
900
|
+
// Computation
|
901
|
+
for (var i = 0; i < 64; i++) {
|
902
|
+
if (i < 16) {
|
903
|
+
W[i] = M[offset + i] | 0;
|
904
|
+
} else {
|
905
|
+
var gamma0x = W[i - 15];
|
906
|
+
var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
|
907
|
+
((gamma0x << 14) | (gamma0x >>> 18)) ^
|
908
|
+
(gamma0x >>> 3);
|
909
|
+
|
910
|
+
var gamma1x = W[i - 2];
|
911
|
+
var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
|
912
|
+
((gamma1x << 13) | (gamma1x >>> 19)) ^
|
913
|
+
(gamma1x >>> 10);
|
914
|
+
|
915
|
+
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
|
916
|
+
}
|
917
|
+
|
918
|
+
var ch = (e & f) ^ (~e & g);
|
919
|
+
var maj = (a & b) ^ (a & c) ^ (b & c);
|
920
|
+
|
921
|
+
var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
|
922
|
+
var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
|
923
|
+
|
924
|
+
var t1 = h + sigma1 + ch + K[i] + W[i];
|
925
|
+
var t2 = sigma0 + maj;
|
926
|
+
|
927
|
+
h = g;
|
928
|
+
g = f;
|
929
|
+
f = e;
|
930
|
+
e = (d + t1) | 0;
|
931
|
+
d = c;
|
932
|
+
c = b;
|
933
|
+
b = a;
|
934
|
+
a = (t1 + t2) | 0;
|
935
|
+
}
|
936
|
+
|
937
|
+
// Intermediate hash value
|
938
|
+
H[0] = (H[0] + a) | 0;
|
939
|
+
H[1] = (H[1] + b) | 0;
|
940
|
+
H[2] = (H[2] + c) | 0;
|
941
|
+
H[3] = (H[3] + d) | 0;
|
942
|
+
H[4] = (H[4] + e) | 0;
|
943
|
+
H[5] = (H[5] + f) | 0;
|
944
|
+
H[6] = (H[6] + g) | 0;
|
945
|
+
H[7] = (H[7] + h) | 0;
|
946
|
+
},
|
947
|
+
|
948
|
+
_doFinalize: function () {
|
949
|
+
// Shortcuts
|
950
|
+
var data = this._data;
|
951
|
+
var dataWords = data.words;
|
952
|
+
|
953
|
+
var nBitsTotal = this._nDataBytes * 8;
|
954
|
+
var nBitsLeft = data.sigBytes * 8;
|
955
|
+
|
956
|
+
// Add padding
|
957
|
+
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
958
|
+
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
|
959
|
+
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
|
960
|
+
data.sigBytes = dataWords.length * 4;
|
961
|
+
|
962
|
+
// Hash final blocks
|
963
|
+
this._process();
|
964
|
+
|
965
|
+
// Return final computed hash
|
966
|
+
return this._hash;
|
967
|
+
},
|
968
|
+
|
969
|
+
clone: function () {
|
970
|
+
var clone = Hasher.clone.call(this);
|
971
|
+
clone._hash = this._hash.clone();
|
972
|
+
|
973
|
+
return clone;
|
974
|
+
}
|
975
|
+
});
|
976
|
+
|
977
|
+
/**
|
978
|
+
* Shortcut function to the hasher's object interface.
|
979
|
+
*
|
980
|
+
* @param {WordArray|string} message The message to hash.
|
981
|
+
*
|
982
|
+
* @return {WordArray} The hash.
|
983
|
+
*
|
984
|
+
* @static
|
985
|
+
*
|
986
|
+
* @example
|
987
|
+
*
|
988
|
+
* var hash = CryptoJS.SHA256('message');
|
989
|
+
* var hash = CryptoJS.SHA256(wordArray);
|
990
|
+
*/
|
991
|
+
C.SHA256 = Hasher._createHelper(SHA256);
|
992
|
+
|
993
|
+
/**
|
994
|
+
* Shortcut function to the HMAC's object interface.
|
995
|
+
*
|
996
|
+
* @param {WordArray|string} message The message to hash.
|
997
|
+
* @param {WordArray|string} key The secret key.
|
998
|
+
*
|
999
|
+
* @return {WordArray} The HMAC.
|
1000
|
+
*
|
1001
|
+
* @static
|
1002
|
+
*
|
1003
|
+
* @example
|
1004
|
+
*
|
1005
|
+
* var hmac = CryptoJS.HmacSHA256(message, key);
|
1006
|
+
*/
|
1007
|
+
C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
|
1008
|
+
}(Math));
|
1009
|
+
|
1010
|
+
|
1011
|
+
return CryptoJS.SHA256;
|
1012
|
+
|
1013
|
+
}));
|
1014
|
+
});
|
1015
|
+
|
1016
|
+
var encHex = createCommonjsModule(function (module, exports) {
|
1017
|
+
(function (root, factory) {
|
1018
|
+
{
|
1019
|
+
// CommonJS
|
1020
|
+
module.exports = factory(core);
|
1021
|
+
}
|
1022
|
+
}(commonjsGlobal, function (CryptoJS) {
|
1023
|
+
|
1024
|
+
return CryptoJS.enc.Hex;
|
1025
|
+
|
1026
|
+
}));
|
1027
|
+
});
|
1028
|
+
|
1029
|
+
function shouldDisableTracking(options = {}) {
|
1030
|
+
const { disabled, portal } = options;
|
1031
|
+
if (disabled || (portal === null || portal === void 0 ? void 0 : portal.eueiEnabled) === false) {
|
1032
|
+
return true;
|
1033
|
+
}
|
1034
|
+
if (!portal || hasEueiEnabledAndIsMemberOfOrg(portal) || isRegisteredUserWithoutOrgInUSA(portal) || isAnonymousUserInUSA(portal)) {
|
1035
|
+
return false;
|
1036
|
+
}
|
1037
|
+
return true;
|
1038
|
+
}
|
1039
|
+
function hasEueiEnabledAndIsMemberOfOrg(portal) {
|
1040
|
+
return portal.eueiEnabled && portal.user && portal.user.orgId === portal.id;
|
1041
|
+
}
|
1042
|
+
function isRegisteredUserWithoutOrgInUSA(portal) {
|
1043
|
+
return portal.user && !portal.user.orgId && portal.ipCntryCode === 'US';
|
1044
|
+
}
|
1045
|
+
function isAnonymousUserInUSA(portal) {
|
1046
|
+
return !portal.user && portal.ipCntryCode === 'US';
|
1047
|
+
}
|
1048
|
+
|
1049
|
+
const storage = {
|
1050
|
+
storage: {},
|
1051
|
+
memory: true,
|
1052
|
+
get(key) {
|
1053
|
+
let stored;
|
1054
|
+
try {
|
1055
|
+
stored =
|
1056
|
+
(window.localStorage && window.localStorage.getItem(key)) ||
|
1057
|
+
this.storage[key];
|
1058
|
+
}
|
1059
|
+
catch (e) {
|
1060
|
+
stored = this.storage[key];
|
1061
|
+
}
|
1062
|
+
if (stored) {
|
1063
|
+
try {
|
1064
|
+
return JSON.parse(stored);
|
1065
|
+
}
|
1066
|
+
catch (e) {
|
1067
|
+
return undefined;
|
1068
|
+
}
|
1069
|
+
}
|
1070
|
+
else {
|
1071
|
+
return undefined;
|
1072
|
+
}
|
1073
|
+
},
|
1074
|
+
set(key, value) {
|
1075
|
+
// handle Safari private mode (setItem is not allowed)
|
1076
|
+
const valueToString = JSON.stringify(value);
|
1077
|
+
try {
|
1078
|
+
window.localStorage.setItem(key, valueToString);
|
1079
|
+
}
|
1080
|
+
catch (e) {
|
1081
|
+
if (!this.memory) {
|
1082
|
+
console.error('setting local storage failed, falling back to in-memory storage');
|
1083
|
+
this.memory = true;
|
1084
|
+
}
|
1085
|
+
this.storage[key] = value;
|
1086
|
+
}
|
1087
|
+
},
|
1088
|
+
delete(key) {
|
1089
|
+
try {
|
1090
|
+
window.localStorage.removeItem(key);
|
1091
|
+
}
|
1092
|
+
catch (e) {
|
1093
|
+
if (!this.memory) {
|
1094
|
+
console.error('setting local storage failed, falling back to in-memory storage');
|
1095
|
+
this.memory = true;
|
1096
|
+
}
|
1097
|
+
delete this.storage[key];
|
1098
|
+
}
|
1099
|
+
},
|
1100
|
+
};
|
1101
|
+
|
1102
|
+
const ESRI_TELEMETRY_DATA_ATTRIBUTE = 'esri-telemetry';
|
1103
|
+
function injectScriptElementAsync(attributes) {
|
1104
|
+
const onloadPromise = new Promise((resolve, reject) => {
|
1105
|
+
attributes.onload = resolve;
|
1106
|
+
attributes.onerror = reject;
|
1107
|
+
const script = injectScriptElement(attributes);
|
1108
|
+
if (!script || attributes.body) {
|
1109
|
+
// this is for the case where the script is already loaded or it has a body instead of a src
|
1110
|
+
resolve();
|
1111
|
+
}
|
1112
|
+
});
|
1113
|
+
return onloadPromise;
|
1114
|
+
}
|
1115
|
+
function scriptExists(attributes) {
|
1116
|
+
const { id, dataAttribute } = attributes;
|
1117
|
+
return !!document.getElementById(id) || !!document.querySelector(`[data-${ESRI_TELEMETRY_DATA_ATTRIBUTE}="${dataAttribute}"]`);
|
1118
|
+
}
|
1119
|
+
function injectScriptElement(attributes) {
|
1120
|
+
const { body, src, id, dataAttribute, section = 'body', type = 'text/javascript', async = false, defer = false, onload, onerror } = attributes;
|
1121
|
+
if (typeof window === 'undefined') {
|
1122
|
+
throw new WindowUndefinedError('Window is undefined: Cannot add script element.');
|
1123
|
+
}
|
1124
|
+
if (scriptExists(attributes)) {
|
1125
|
+
console.log(`script (${id || dataAttribute}) is already present, skipping`);
|
1126
|
+
return;
|
1127
|
+
}
|
1128
|
+
const scriptElement = createScriptElementWithAttributes({
|
1129
|
+
id,
|
1130
|
+
dataAttribute,
|
1131
|
+
type,
|
1132
|
+
async,
|
1133
|
+
defer,
|
1134
|
+
body,
|
1135
|
+
src,
|
1136
|
+
onload,
|
1137
|
+
onerror
|
1138
|
+
});
|
1139
|
+
return section === 'body'
|
1140
|
+
? document.body.appendChild(scriptElement)
|
1141
|
+
: document.head.appendChild(scriptElement);
|
1142
|
+
}
|
1143
|
+
class WindowUndefinedError extends Error {
|
1144
|
+
}
|
1145
|
+
function createScriptElementWithAttributes({ id, dataAttribute, type, async, defer, body, src, onload, onerror }) {
|
1146
|
+
const scriptElement = document.createElement('script');
|
1147
|
+
if (id) {
|
1148
|
+
scriptElement.id = id;
|
1149
|
+
}
|
1150
|
+
if (dataAttribute) {
|
1151
|
+
scriptElement.setAttribute(`data-${ESRI_TELEMETRY_DATA_ATTRIBUTE}`, dataAttribute);
|
1152
|
+
}
|
1153
|
+
src && (scriptElement.src = src);
|
1154
|
+
body && (scriptElement.innerText = body);
|
1155
|
+
scriptElement.type = type;
|
1156
|
+
scriptElement.async = async;
|
1157
|
+
scriptElement.defer = defer;
|
1158
|
+
onload && (scriptElement.onload = onload);
|
1159
|
+
onerror && (scriptElement.onerror = onerror);
|
1160
|
+
return scriptElement;
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
function createScriptTags(scripts) {
|
1164
|
+
return scripts.map(scriptObj => {
|
1165
|
+
const attrs = [];
|
1166
|
+
['src', 'id', 'dataAttribute', 'type'].forEach(attr => {
|
1167
|
+
let attrName = attr;
|
1168
|
+
if (attr === 'dataAttribute') {
|
1169
|
+
attrName = 'data-esri-telemetry';
|
1170
|
+
}
|
1171
|
+
if (scriptObj[attr]) {
|
1172
|
+
attrs.push(`${attrName}="${scriptObj[attr]}"`);
|
1173
|
+
}
|
1174
|
+
});
|
1175
|
+
['async', 'defer'].forEach(attr => {
|
1176
|
+
if (scriptObj[attr]) {
|
1177
|
+
attrs.push(`${attr}`);
|
1178
|
+
}
|
1179
|
+
});
|
1180
|
+
return `<script ${attrs.join(' ')}>${scriptObj.body ? scriptObj.body : ''}</script>`;
|
1181
|
+
}).join('');
|
1182
|
+
}
|
1183
|
+
|
1184
|
+
const INTERNAL_ORGS = [
|
1185
|
+
'esri.com',
|
1186
|
+
'esriuk.com',
|
1187
|
+
'esri.de',
|
1188
|
+
'esri.ca',
|
1189
|
+
'esrifrance.fr',
|
1190
|
+
'esri.nl',
|
1191
|
+
'esri-portugal.pt',
|
1192
|
+
'esribulgaria.com',
|
1193
|
+
'esri.fi',
|
1194
|
+
'esri.kr',
|
1195
|
+
'esrimalaysia.com.my',
|
1196
|
+
'esri.es',
|
1197
|
+
'esriaustralia.com.au',
|
1198
|
+
'esri-southafrica.com',
|
1199
|
+
'esri.cl',
|
1200
|
+
'esrichina.com.cn',
|
1201
|
+
'esri.co',
|
1202
|
+
'esriturkey.com.tr',
|
1203
|
+
'geodata.no',
|
1204
|
+
'esriitalia.it',
|
1205
|
+
'esri.pl',
|
1206
|
+
];
|
1207
|
+
/**
|
1208
|
+
* Telemetry class
|
1209
|
+
*/
|
1210
|
+
class Telemetry {
|
1211
|
+
constructor(options) {
|
1212
|
+
var _a, _b, _c;
|
1213
|
+
this.trackers = [];
|
1214
|
+
this.options = options;
|
1215
|
+
this.debug = options.debug;
|
1216
|
+
this.suppressDisabledWarnings = options.suppressDisabledWarnings;
|
1217
|
+
this.disabled = shouldDisableTracking(options);
|
1218
|
+
this.logger = options.logger || console;
|
1219
|
+
if (this.disabled && !this.suppressDisabledWarnings) {
|
1220
|
+
this.logger.info('Telemetry Disabled');
|
1221
|
+
}
|
1222
|
+
const user = ((_a = options.portal) === null || _a === void 0 ? void 0 : _a.user) || options.user;
|
1223
|
+
if (user) {
|
1224
|
+
this.setUser(user, (_c = (_b = options.portal) === null || _b === void 0 ? void 0 : _b.subscriptionInfo) === null || _c === void 0 ? void 0 : _c.type);
|
1225
|
+
}
|
1226
|
+
if (!this.disabled) {
|
1227
|
+
this.initializeTrackers();
|
1228
|
+
}
|
1229
|
+
}
|
1230
|
+
initializeTrackers() {
|
1231
|
+
if (this.options.plugins) {
|
1232
|
+
this.trackers.push(...this.options.plugins);
|
1233
|
+
}
|
1234
|
+
if (!this.trackers.length) {
|
1235
|
+
this.logger.error(new Error('No trackers configured'));
|
1236
|
+
}
|
1237
|
+
}
|
1238
|
+
getScriptTags() {
|
1239
|
+
return this.trackers.map((tracker) => {
|
1240
|
+
return tracker.getScriptTags && tracker.getScriptTags();
|
1241
|
+
}).join('');
|
1242
|
+
}
|
1243
|
+
async init() {
|
1244
|
+
const promises = this.trackers.map((tracker) => {
|
1245
|
+
return tracker.init();
|
1246
|
+
});
|
1247
|
+
await Promise.all(promises);
|
1248
|
+
}
|
1249
|
+
setUser(user = {}, orgType = 'Public') {
|
1250
|
+
user = typeof user === 'string' ? { username: user } : user;
|
1251
|
+
this.user = user;
|
1252
|
+
this.user.accountType = orgType;
|
1253
|
+
let internalDomain;
|
1254
|
+
if (user.email && user.email.split) {
|
1255
|
+
const domain = user.email.split('@')[1];
|
1256
|
+
internalDomain =
|
1257
|
+
INTERNAL_ORGS.filter((org) => {
|
1258
|
+
return domain === org;
|
1259
|
+
}).length > 0;
|
1260
|
+
}
|
1261
|
+
if (internalDomain ||
|
1262
|
+
['In House', 'Demo and Marketing'].indexOf(orgType) > -1) {
|
1263
|
+
this.user.internalUser = true;
|
1264
|
+
}
|
1265
|
+
}
|
1266
|
+
logPageView(page, event = {}, options = {}) {
|
1267
|
+
if (this.disabled && !this.suppressDisabledWarnings) {
|
1268
|
+
this.logger.info('Page view was not logged because telemetry is disabled.');
|
1269
|
+
return false;
|
1270
|
+
}
|
1271
|
+
const enabledTrackers = this.trackers.filter(({ disabled, hasError }) => !disabled && !hasError);
|
1272
|
+
if (!enabledTrackers.length) {
|
1273
|
+
this.logger.warn('Page view was not logged because no enabled telemetry-plugins are registered.');
|
1274
|
+
return false;
|
1275
|
+
}
|
1276
|
+
const attributes = this.preProcess(event, options);
|
1277
|
+
if (this.debug) {
|
1278
|
+
this.logger.info('Tracking page view', JSON.stringify(attributes));
|
1279
|
+
}
|
1280
|
+
const promises = enabledTrackers.map((tracker) => {
|
1281
|
+
return tracker.logPageView(page, attributes);
|
1282
|
+
});
|
1283
|
+
Promise.all(promises).then();
|
1284
|
+
return true;
|
1285
|
+
}
|
1286
|
+
logEvent(event, options = {}) {
|
1287
|
+
if (this.disabled && !this.suppressDisabledWarnings) {
|
1288
|
+
this.logger.info('Event was not logged because telemetry is disabled.');
|
1289
|
+
return false;
|
1290
|
+
}
|
1291
|
+
const enabledTrackers = this.trackers.filter(({ disabled, hasError }) => !disabled && !hasError);
|
1292
|
+
if (!enabledTrackers.length) {
|
1293
|
+
this.logger.warn('Event was not logged because no enabled telemetry-plugins are registered.');
|
1294
|
+
return false;
|
1295
|
+
}
|
1296
|
+
const eventAttributes = this.preProcess(event, options);
|
1297
|
+
if (this.debug) {
|
1298
|
+
this.logger.info('Tracking event', JSON.stringify(eventAttributes));
|
1299
|
+
}
|
1300
|
+
const promises = enabledTrackers.map((tracker) => {
|
1301
|
+
return tracker.logEvent(eventAttributes);
|
1302
|
+
});
|
1303
|
+
Promise.all(promises).then();
|
1304
|
+
return true;
|
1305
|
+
}
|
1306
|
+
logError(event = {}) {
|
1307
|
+
event = Object.assign({ eventType: 'error' }, event);
|
1308
|
+
this.logEvent(event);
|
1309
|
+
}
|
1310
|
+
startWorkflow(name, attributes = {}) {
|
1311
|
+
const workflow = {
|
1312
|
+
name,
|
1313
|
+
start: Date.now(),
|
1314
|
+
steps: [],
|
1315
|
+
workflowId: Math.floor((1 + Math.random()) * 0x100000000000).toString(16),
|
1316
|
+
};
|
1317
|
+
this.saveWorkflow(workflow);
|
1318
|
+
const workflowObj = Object.assign({ name, step: 'start' }, attributes);
|
1319
|
+
this.logWorkflow(workflowObj);
|
1320
|
+
return workflow;
|
1321
|
+
}
|
1322
|
+
stepWorkflow(name, step, attributes = {}) {
|
1323
|
+
//TODO: check if the check for attributes being a string is useful or can be removed
|
1324
|
+
const details = typeof attributes === 'string' ? attributes : attributes.details;
|
1325
|
+
const workflowObj = Object.assign({ name, step, details }, attributes);
|
1326
|
+
this.logWorkflow(workflowObj);
|
1327
|
+
}
|
1328
|
+
endWorkflow(name, attributes = {}) {
|
1329
|
+
const workflowObj = Object.assign({ name, step: 'finish' }, attributes);
|
1330
|
+
this.logWorkflow(workflowObj);
|
1331
|
+
}
|
1332
|
+
cancelWorkflow(name, attributes = {}) {
|
1333
|
+
const workflowObj = Object.assign({ name, step: 'cancel' }, attributes);
|
1334
|
+
this.logWorkflow(workflowObj);
|
1335
|
+
}
|
1336
|
+
getWorkflow(name) {
|
1337
|
+
const workflow = storage.get(`TELEMETRY-WORKFLOW:${name}`);
|
1338
|
+
// do not let old workflows be returned
|
1339
|
+
if (workflow) {
|
1340
|
+
const workflowAge = Date.now() - workflow.start;
|
1341
|
+
const timeout = 30 * 60 * 1000;
|
1342
|
+
if (workflowAge < timeout) {
|
1343
|
+
return workflow;
|
1344
|
+
}
|
1345
|
+
else {
|
1346
|
+
this.deleteWorkflow(workflow);
|
1347
|
+
}
|
1348
|
+
}
|
1349
|
+
}
|
1350
|
+
saveWorkflow(workflow) {
|
1351
|
+
storage.set(`TELEMETRY-WORKFLOW:${workflow.name}`, workflow);
|
1352
|
+
}
|
1353
|
+
deleteWorkflow(workflow) {
|
1354
|
+
storage.delete(`TELEMETRY-WORKFLOW:${workflow.name}`);
|
1355
|
+
}
|
1356
|
+
logWorkflow(options = {}) {
|
1357
|
+
/*
|
1358
|
+
const workflow = {
|
1359
|
+
name: 'add layer to map',
|
1360
|
+
step: 'start',
|
1361
|
+
details: 'some details about the step'
|
1362
|
+
}
|
1363
|
+
*/
|
1364
|
+
options = this.preProcess(options);
|
1365
|
+
let workflow = this.getWorkflow(options.name);
|
1366
|
+
if (!workflow) {
|
1367
|
+
this.startWorkflow(options.name);
|
1368
|
+
workflow = this.getWorkflow(options.name);
|
1369
|
+
}
|
1370
|
+
workflow.steps.push(options.step);
|
1371
|
+
workflow.duration = (Date.now() - workflow.start) / 1000;
|
1372
|
+
if (['cancel', 'finish'].indexOf(options.step) > -1) {
|
1373
|
+
this.deleteWorkflow(workflow);
|
1374
|
+
}
|
1375
|
+
else {
|
1376
|
+
this.saveWorkflow(workflow);
|
1377
|
+
}
|
1378
|
+
const track = Object.assign(options, {
|
1379
|
+
eventType: 'workflow',
|
1380
|
+
category: options.name,
|
1381
|
+
action: options.step,
|
1382
|
+
label: options.details,
|
1383
|
+
duration: workflow.duration,
|
1384
|
+
workflowId: workflow.workflowId,
|
1385
|
+
});
|
1386
|
+
this.logEvent(track);
|
1387
|
+
}
|
1388
|
+
preProcess(event = {}, options = {}) {
|
1389
|
+
let userMetadata = {};
|
1390
|
+
if (this.user) {
|
1391
|
+
userMetadata = {
|
1392
|
+
user: anonymize(this.user.username),
|
1393
|
+
org: anonymize(this.user.orgId),
|
1394
|
+
lastLogin: this.user.lastLogin,
|
1395
|
+
userSince: this.user.created,
|
1396
|
+
internalUser: this.user.internalUser || false,
|
1397
|
+
accountType: this.user.accountType,
|
1398
|
+
};
|
1399
|
+
}
|
1400
|
+
return Object.entries(Object.assign(Object.assign({}, event), userMetadata)).reduce(makeEventPayload(options.omitComplexData, this.logger), {});
|
1401
|
+
}
|
1402
|
+
disableTracker(trackerName) {
|
1403
|
+
var _a;
|
1404
|
+
const tracker = this.trackers.find(({ name }) => name === trackerName);
|
1405
|
+
if (tracker && !tracker.hasError) {
|
1406
|
+
tracker.disabled = true;
|
1407
|
+
(_a = tracker.disable) === null || _a === void 0 ? void 0 : _a.call(tracker);
|
1408
|
+
}
|
1409
|
+
}
|
1410
|
+
enableTracker(trackerName) {
|
1411
|
+
var _a;
|
1412
|
+
const tracker = this.trackers.find(({ name }) => name === trackerName);
|
1413
|
+
if (tracker && !tracker.hasError) {
|
1414
|
+
tracker.disabled = false;
|
1415
|
+
(_a = tracker.enable) === null || _a === void 0 ? void 0 : _a.call(tracker);
|
1416
|
+
}
|
1417
|
+
}
|
1418
|
+
}
|
1419
|
+
function anonymize(user) {
|
1420
|
+
if (!user)
|
1421
|
+
return;
|
1422
|
+
return sha256(user).toString(encHex);
|
1423
|
+
}
|
1424
|
+
function makeEventPayload(omitComplexData, logger) {
|
1425
|
+
return function (acc, [key, val]) {
|
1426
|
+
if (isPrimitive(val)) {
|
1427
|
+
acc[key] = val;
|
1428
|
+
}
|
1429
|
+
else if (!omitComplexData) {
|
1430
|
+
logger.warn(`You are trying to log a non-primitive value, ${key}:${JSON.stringify(val)}. This will get logged as [object Object]`);
|
1431
|
+
acc[key] = val;
|
1432
|
+
}
|
1433
|
+
return acc;
|
1434
|
+
};
|
1435
|
+
}
|
1436
|
+
function isPrimitive(val) {
|
1437
|
+
const primitives = ['string', 'number', 'boolean', 'undefined'];
|
1438
|
+
return (primitives.includes(typeof val) ||
|
1439
|
+
(val && typeof val.valueOf() === 'string'));
|
1440
|
+
}
|
1441
|
+
|
1442
|
+
/******************************************************************************
|
1443
|
+
Copyright (c) Microsoft Corporation.
|
1444
|
+
|
1445
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
1446
|
+
purpose with or without fee is hereby granted.
|
1447
|
+
|
1448
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
1449
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
1450
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
1451
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
1452
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
1453
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
1454
|
+
PERFORMANCE OF THIS SOFTWARE.
|
1455
|
+
***************************************************************************** */
|
1456
|
+
|
1457
|
+
function __rest(s, e) {
|
1458
|
+
var t = {};
|
1459
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
1460
|
+
t[p] = s[p];
|
1461
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
1462
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
1463
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
1464
|
+
t[p[i]] = s[p[i]];
|
1465
|
+
}
|
1466
|
+
return t;
|
1467
|
+
}
|
1468
|
+
|
1469
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
1470
|
+
var e = new Error(message);
|
1471
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
1472
|
+
};
|
1473
|
+
|
1474
|
+
/**
|
1475
|
+
* Class supporting Google Analytics 4
|
1476
|
+
*/
|
1477
|
+
class GoogleAnalytics {
|
1478
|
+
constructor(options) {
|
1479
|
+
var _a;
|
1480
|
+
this.name = 'googleAnalytics';
|
1481
|
+
this.dimensions = {};
|
1482
|
+
this.metrics = {};
|
1483
|
+
if (typeof window !== 'undefined' && !((_a = options === null || options === void 0 ? void 0 : options.measurementIds) === null || _a === void 0 ? void 0 : _a.length)) {
|
1484
|
+
// browser environment
|
1485
|
+
throw new Error('at least one measurementId needs to be provided in your configuration');
|
1486
|
+
}
|
1487
|
+
Object.assign(this, options);
|
1488
|
+
}
|
1489
|
+
_getScripts() {
|
1490
|
+
const measurementId = this.measurementIds ? this.measurementIds[0] : '';
|
1491
|
+
return [
|
1492
|
+
{
|
1493
|
+
dataAttribute: 'google-analytics',
|
1494
|
+
async: true,
|
1495
|
+
src: `https://www.googletagmanager.com/gtag/js?id=${measurementId}`
|
1496
|
+
},
|
1497
|
+
];
|
1498
|
+
}
|
1499
|
+
getScriptTags() {
|
1500
|
+
return createScriptTags(this._getScripts());
|
1501
|
+
}
|
1502
|
+
async init() {
|
1503
|
+
// for use in a broswer environment
|
1504
|
+
if (typeof window === 'undefined') {
|
1505
|
+
throw new WindowUndefinedError('Window is undefined: Cannot add script element.');
|
1506
|
+
}
|
1507
|
+
// calls _getScripts() and then iterates over the array and adds dom nodes for each and resolves once all have loaded.
|
1508
|
+
// injectScriptElementAsync will check if a script with the specified id already exists and, if so, do nothing
|
1509
|
+
await Promise.all(this._getScripts().map(scriptObj => {
|
1510
|
+
return injectScriptElementAsync(scriptObj);
|
1511
|
+
}));
|
1512
|
+
// runs second script
|
1513
|
+
this.injectConfig();
|
1514
|
+
}
|
1515
|
+
// we log page views manually, even though ga4 can do so automatically for pages now
|
1516
|
+
logPageView(page, options = {}) {
|
1517
|
+
const cleanedOptions = this.buildCustomParams(options);
|
1518
|
+
const pageViewOptionsObject = Object.assign({ page_title: page || window.location.pathname }, cleanedOptions);
|
1519
|
+
window.gtag('event', 'page_view', pageViewOptionsObject);
|
1520
|
+
return true;
|
1521
|
+
}
|
1522
|
+
logEvent(event) {
|
1523
|
+
// eventType is name of our event
|
1524
|
+
let { action } = event, customParams = __rest(event, ["action"]);
|
1525
|
+
const eventType = action || 'other';
|
1526
|
+
// if using telemetry wrapper, custom metrics/dimensions in customParams; if not, in options
|
1527
|
+
const eventParams = this.buildCustomParams(customParams);
|
1528
|
+
// should have custom metric & dimension data that looks like
|
1529
|
+
// metric_name: metric_value
|
1530
|
+
// dimension_name: dimension_value
|
1531
|
+
window.gtag('event', eventType, eventParams);
|
1532
|
+
return true;
|
1533
|
+
}
|
1534
|
+
disable() {
|
1535
|
+
if (this.measurementIds) {
|
1536
|
+
this.measurementIds.forEach(id => {
|
1537
|
+
window[`ga-disable-${id}`] = true;
|
1538
|
+
});
|
1539
|
+
}
|
1540
|
+
}
|
1541
|
+
enable() {
|
1542
|
+
if (this.measurementIds) {
|
1543
|
+
this.measurementIds.forEach(id => {
|
1544
|
+
window[`ga-disable-${id}`] = undefined;
|
1545
|
+
});
|
1546
|
+
}
|
1547
|
+
}
|
1548
|
+
// injects configs for each measurement id
|
1549
|
+
injectConfig() {
|
1550
|
+
window.dataLayer = window.dataLayer || [];
|
1551
|
+
window.gtag = function () { window.dataLayer.push(arguments); };
|
1552
|
+
window.gtag('js', new Date());
|
1553
|
+
const configOptions = {
|
1554
|
+
'custom_map': this.createDimensionsAndMetricsCustomMap(this.dimensions, this.metrics),
|
1555
|
+
'send_page_view': false,
|
1556
|
+
'anonymize_ip': true // anonymize ip for each event/page view tracked
|
1557
|
+
};
|
1558
|
+
this.measurementIds.forEach(measurementId => {
|
1559
|
+
window.gtag('config', measurementId, configOptions);
|
1560
|
+
});
|
1561
|
+
}
|
1562
|
+
buildCustomParams(eventParams) {
|
1563
|
+
let cleanedEventParams;
|
1564
|
+
let { category, label } = eventParams;
|
1565
|
+
// verify that all are valid custom metrics/dimensions
|
1566
|
+
cleanedEventParams = this.verifyCustomDimensionAndMetrics(eventParams);
|
1567
|
+
// ga3 syntax uses category/action/label, which have been changed
|
1568
|
+
// to event_category, event_action, and event_label in ga4
|
1569
|
+
if (category) {
|
1570
|
+
cleanedEventParams = Object.assign(Object.assign({}, cleanedEventParams), { event_category: category });
|
1571
|
+
}
|
1572
|
+
if (label) {
|
1573
|
+
cleanedEventParams = Object.assign(Object.assign({}, cleanedEventParams), { event_label: label });
|
1574
|
+
}
|
1575
|
+
return cleanedEventParams;
|
1576
|
+
}
|
1577
|
+
verifyCustomDimensionAndMetrics(eventParams) {
|
1578
|
+
// all valid metric names and dimension names
|
1579
|
+
// since we store metrics/dimensions as dimension<index>: dimension_name, we want values
|
1580
|
+
const metricAndDimensionsMap = this.createDimensionsAndMetricsCustomMap(this.dimensions, this.metrics);
|
1581
|
+
const metricAndDimensionNames = Object.values(metricAndDimensionsMap);
|
1582
|
+
// get all keys (name of metric/dimension),
|
1583
|
+
// filter out any keys not in valid names,
|
1584
|
+
// and then recreate new object with filtered keys and values only
|
1585
|
+
const cleanedEventParams = Object.keys(eventParams)
|
1586
|
+
.filter(key => metricAndDimensionNames.includes(key))
|
1587
|
+
.reduce((cur, key) => { return Object.assign(cur, { [key]: eventParams[key] }); }, {});
|
1588
|
+
return cleanedEventParams;
|
1589
|
+
}
|
1590
|
+
createDimensionsAndMetricsCustomMap(dimensions = {}, metrics = {}) {
|
1591
|
+
const metricsMap = this.createMetricCustomMap(metrics);
|
1592
|
+
const dimensionsMap = this.createDimensionCustomMap(dimensions);
|
1593
|
+
return Object.assign(Object.assign({}, metricsMap), dimensionsMap);
|
1594
|
+
}
|
1595
|
+
// under the assumption that our metrics come like { timeMetric: 1, otherMetric: 3} where metric_name: index
|
1596
|
+
createMetricCustomMap(metrics = {}) {
|
1597
|
+
return Object.keys(metrics)
|
1598
|
+
.map(function (key) {
|
1599
|
+
return {
|
1600
|
+
// format of metric<Index>: metric_name
|
1601
|
+
key: `metric${metrics[key]}`,
|
1602
|
+
value: key
|
1603
|
+
};
|
1604
|
+
})
|
1605
|
+
.filter((val) => val)
|
1606
|
+
.reduce((acc, { key, value }) => {
|
1607
|
+
acc[key] = value;
|
1608
|
+
return acc;
|
1609
|
+
}, {});
|
1610
|
+
}
|
1611
|
+
// under the assumption that our dimensions come like { someAttribute: 7, datasetId: 6} where dimension_name: index
|
1612
|
+
createDimensionCustomMap(dimensions = {}) {
|
1613
|
+
return Object.keys(dimensions)
|
1614
|
+
.map(function (key) {
|
1615
|
+
return {
|
1616
|
+
// format of dimension<Index>: dimension_name
|
1617
|
+
key: `dimension${dimensions[key]}`,
|
1618
|
+
value: key
|
1619
|
+
};
|
1620
|
+
})
|
1621
|
+
.filter((val) => val)
|
1622
|
+
.reduce((acc, { key, value }) => {
|
1623
|
+
acc[key] = value;
|
1624
|
+
return acc;
|
1625
|
+
}, {});
|
1626
|
+
}
|
1627
|
+
}
|
1628
|
+
|
1629
|
+
const consentManagerCss = ":host{display:block}.consent-panel{position:fixed;display:block;z-index:5000;bottom:0;left:0;width:100%;height:auto;text-align:center}.cookie-consent-popup-container{position:relative;display:block;bottom:0;left:0;width:100%;margin:0;padding-top:1rem;padding-bottom:1rem;transition:transform 0.5s ease-out 0s;background-color:rgba(51, 51, 51, 0.95);color:#fff}.button-container{position:static;margin-bottom:1rem;display:flex;justify-content:center;flex-wrap:wrap}.padding-end-1{padding-inline-end:1rem}.link-text{--calcite-ui-text-link:var(--calcite-color-text-inverse);--calcite-ui-brand:var(--calcite-color-text-inverse);--calcite-color-text-link:var(--calcite-color-text-inverse);--calcite-color-brand-underline:var(--calcite-color-text-inverse);--calcite-color-brand:var(--calcite-color-text-inverse)}";
|
1630
|
+
|
1631
|
+
const ConsentManager = class {
|
1632
|
+
constructor(hostRef) {
|
1633
|
+
registerInstance(this, hostRef);
|
1634
|
+
this.consentGranted = createEvent(this, "consentGranted", 7);
|
1635
|
+
//--------------------------------------------------------------------------
|
1636
|
+
//
|
1637
|
+
// Properties (protected)
|
1638
|
+
//
|
1639
|
+
//--------------------------------------------------------------------------
|
1640
|
+
/**
|
1641
|
+
* boolean: When true the user has granted consent and the telemetry instance will be avaliable
|
1642
|
+
*/
|
1643
|
+
this._consentGranted = false;
|
1644
|
+
/**
|
1645
|
+
* boolean: When true the telemetry instance has been loaded
|
1646
|
+
*/
|
1647
|
+
this._loaded = false;
|
1648
|
+
this.firstUseVar = "solutions-first-use";
|
1649
|
+
this.measurementIds = undefined;
|
1650
|
+
this.portal = undefined;
|
1651
|
+
this._shouldRender = undefined;
|
1652
|
+
this._translations = undefined;
|
1653
|
+
}
|
1654
|
+
//--------------------------------------------------------------------------
|
1655
|
+
//
|
1656
|
+
// Watch handlers
|
1657
|
+
//
|
1658
|
+
//--------------------------------------------------------------------------
|
1659
|
+
//--------------------------------------------------------------------------
|
1660
|
+
//
|
1661
|
+
// Methods (public)
|
1662
|
+
//
|
1663
|
+
//--------------------------------------------------------------------------
|
1664
|
+
/**
|
1665
|
+
* Initialize and return the telemetry instance if consent has been granted
|
1666
|
+
*/
|
1667
|
+
async getInstance() {
|
1668
|
+
if (localStorage.getItem(this.firstUseVar) === "true") {
|
1669
|
+
await this._init();
|
1670
|
+
return this._telemetryInstance;
|
1671
|
+
}
|
1672
|
+
else {
|
1673
|
+
return undefined;
|
1674
|
+
}
|
1675
|
+
}
|
1676
|
+
//--------------------------------------------------------------------------
|
1677
|
+
//
|
1678
|
+
// Functions (lifecycle)
|
1679
|
+
//
|
1680
|
+
//--------------------------------------------------------------------------
|
1681
|
+
/**
|
1682
|
+
* StencilJS: Called once just after the component is first connected to the DOM.
|
1683
|
+
*
|
1684
|
+
* @returns Promise when complete
|
1685
|
+
*/
|
1686
|
+
async componentWillLoad() {
|
1687
|
+
await this._getTranslations();
|
1688
|
+
this._shouldRender = localStorage.getItem(this.firstUseVar) === null;
|
1689
|
+
}
|
1690
|
+
/**
|
1691
|
+
* Renders the component.
|
1692
|
+
*/
|
1693
|
+
render() {
|
1694
|
+
return this._shouldRender ? (h(Host, null, h("calcite-panel", { class: "consent-panel calcite-mode-dark", id: "cookie-policy" }, h("div", { class: "cookie-consent-popup-container" }, h("div", { id: "cookie-policy-description-top", tabindex: "-1" }, h("p", null, this._translations.dearVisitor), h("p", null, this._translations.useAnalytics)), h("div", { class: "button-container" }, h("calcite-button", { appearance: "solid", class: "padding-end-1", kind: "brand", onClick: () => this._refuse() }, this._translations.refuseAnalytics), h("calcite-button", { appearance: "solid", kind: "brand", onClick: () => this._accept() }, this._translations.acceptAnalytics)), h("div", null, h("p", null, this._translations.moreInfo, "\u00A0", h("calcite-link", { class: "link-text", href: "https://www.arcgis.com/", rel: "noopener noreferrer", target: "_blank" }, this._translations.protectionPolicy), this._translations.our, "\u00A0", h("calcite-link", { class: "link-text", href: "https://www.arcgis.com/", rel: "noopener noreferrer", target: "_blank" }, this._translations.cookiePolicy, "\u00A0"), this._translations.andOur, "\u00A0", h("calcite-link", { class: "link-text", href: "https://www.arcgis.com/", rel: "noopener noreferrer", target: "_blank" }, this._translations.cookiesInventory))))))) : undefined;
|
1695
|
+
}
|
1696
|
+
//--------------------------------------------------------------------------
|
1697
|
+
//
|
1698
|
+
// Functions (protected)
|
1699
|
+
//
|
1700
|
+
//--------------------------------------------------------------------------
|
1701
|
+
/**
|
1702
|
+
* Fetches the component's translations
|
1703
|
+
*
|
1704
|
+
* @returns Promise when complete
|
1705
|
+
* @protected
|
1706
|
+
*/
|
1707
|
+
async _init() {
|
1708
|
+
var _a;
|
1709
|
+
if (!this._loaded && ((_a = this.measurementIds) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.portal) {
|
1710
|
+
const googleAnalyticsTracker = new GoogleAnalytics({
|
1711
|
+
measurementIds: this.measurementIds
|
1712
|
+
});
|
1713
|
+
this._telemetryInstance = new Telemetry({
|
1714
|
+
plugins: [googleAnalyticsTracker],
|
1715
|
+
portal: this.portal
|
1716
|
+
});
|
1717
|
+
await this._telemetryInstance.init();
|
1718
|
+
this._loaded = true;
|
1719
|
+
}
|
1720
|
+
}
|
1721
|
+
/**
|
1722
|
+
* Store the users granting of consent
|
1723
|
+
*
|
1724
|
+
* @protected
|
1725
|
+
*/
|
1726
|
+
_accept() {
|
1727
|
+
this._consentGranted = true;
|
1728
|
+
this._handleConsent();
|
1729
|
+
}
|
1730
|
+
/**
|
1731
|
+
* Store the users refusal of consent
|
1732
|
+
*
|
1733
|
+
* @protected
|
1734
|
+
*/
|
1735
|
+
_refuse() {
|
1736
|
+
this._consentGranted = false;
|
1737
|
+
this._handleConsent();
|
1738
|
+
}
|
1739
|
+
/**
|
1740
|
+
* Store and emit the users choice for consent
|
1741
|
+
*
|
1742
|
+
* @protected
|
1743
|
+
*/
|
1744
|
+
_handleConsent() {
|
1745
|
+
this._shouldRender = false;
|
1746
|
+
localStorage.setItem(this.firstUseVar, this._consentGranted.toString());
|
1747
|
+
this.consentGranted.emit({
|
1748
|
+
granted: this._consentGranted
|
1749
|
+
});
|
1750
|
+
}
|
1751
|
+
/**
|
1752
|
+
* Fetches the component's translations
|
1753
|
+
*
|
1754
|
+
* @returns Promise when complete
|
1755
|
+
* @protected
|
1756
|
+
*/
|
1757
|
+
async _getTranslations() {
|
1758
|
+
const messages = await getLocaleComponentStrings(this.el);
|
1759
|
+
this._translations = messages[0];
|
1760
|
+
}
|
1761
|
+
get el() { return getElement(this); }
|
1762
|
+
};
|
1763
|
+
ConsentManager.style = consentManagerCss;
|
1764
|
+
|
1765
|
+
export { ConsentManager as consent_manager };
|