@microsoft/applicationinsights-core-js 3.3.10-nightly3.2507-28 → 3.3.10-nightly3.2508-01

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.
Files changed (104) hide show
  1. package/browser/es5/applicationinsights-core-js.cjs.js +132 -49
  2. package/browser/es5/applicationinsights-core-js.cjs.js.map +1 -1
  3. package/browser/es5/applicationinsights-core-js.cjs.min.js +2 -2
  4. package/browser/es5/applicationinsights-core-js.cjs.min.js.map +1 -1
  5. package/browser/es5/applicationinsights-core-js.gbl.js +134 -51
  6. package/browser/es5/applicationinsights-core-js.gbl.js.map +1 -1
  7. package/browser/es5/applicationinsights-core-js.gbl.min.js +2 -2
  8. package/browser/es5/applicationinsights-core-js.gbl.min.js.map +1 -1
  9. package/browser/es5/applicationinsights-core-js.integrity.json +25 -25
  10. package/browser/es5/applicationinsights-core-js.js +134 -51
  11. package/browser/es5/applicationinsights-core-js.js.map +1 -1
  12. package/browser/es5/applicationinsights-core-js.min.js +2 -2
  13. package/browser/es5/applicationinsights-core-js.min.js.map +1 -1
  14. package/dist/es5/applicationinsights-core-js.js +132 -49
  15. package/dist/es5/applicationinsights-core-js.js.map +1 -1
  16. package/dist/es5/applicationinsights-core-js.min.js +2 -2
  17. package/dist/es5/applicationinsights-core-js.min.js.map +1 -1
  18. package/dist-es5/Config/ConfigDefaultHelpers.js +1 -1
  19. package/dist-es5/Config/ConfigDefaults.js +1 -1
  20. package/dist-es5/Config/DynamicConfig.js +1 -1
  21. package/dist-es5/Config/DynamicProperty.js +1 -1
  22. package/dist-es5/Config/DynamicState.js +1 -1
  23. package/dist-es5/Config/DynamicSupport.js +1 -1
  24. package/dist-es5/Config/IConfigDefaults.js +1 -1
  25. package/dist-es5/Config/IDynamicConfigHandler.js +1 -1
  26. package/dist-es5/Config/IDynamicPropertyHandler.js +1 -1
  27. package/dist-es5/Config/IDynamicWatcher.js +1 -1
  28. package/dist-es5/Config/_IDynamicConfigHandlerState.js +1 -1
  29. package/dist-es5/JavaScriptSDK/AggregationError.js +1 -1
  30. package/dist-es5/JavaScriptSDK/AppInsightsCore.js +1 -1
  31. package/dist-es5/JavaScriptSDK/AsyncUtils.js +1 -1
  32. package/dist-es5/JavaScriptSDK/BaseTelemetryPlugin.js +1 -1
  33. package/dist-es5/JavaScriptSDK/Constants.js +1 -1
  34. package/dist-es5/JavaScriptSDK/CookieMgr.js +172 -58
  35. package/dist-es5/JavaScriptSDK/CookieMgr.js.map +1 -1
  36. package/dist-es5/JavaScriptSDK/CoreUtils.js +1 -1
  37. package/dist-es5/JavaScriptSDK/DataCacheHelper.js +2 -2
  38. package/dist-es5/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  39. package/dist-es5/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  40. package/dist-es5/JavaScriptSDK/DiagnosticLogger.js +1 -1
  41. package/dist-es5/JavaScriptSDK/EnvUtils.js +1 -1
  42. package/dist-es5/JavaScriptSDK/EventHelpers.js +1 -1
  43. package/dist-es5/JavaScriptSDK/HelperFuncs.js +1 -1
  44. package/dist-es5/JavaScriptSDK/InstrumentHooks.js +1 -1
  45. package/dist-es5/JavaScriptSDK/InternalConstants.js +1 -1
  46. package/dist-es5/JavaScriptSDK/NotificationManager.js +1 -1
  47. package/dist-es5/JavaScriptSDK/PerfManager.js +1 -1
  48. package/dist-es5/JavaScriptSDK/ProcessTelemetryContext.js +1 -1
  49. package/dist-es5/JavaScriptSDK/RandomHelper.js +1 -1
  50. package/dist-es5/JavaScriptSDK/ResponseHelpers.js +1 -1
  51. package/dist-es5/JavaScriptSDK/SenderPostManager.js +1 -1
  52. package/dist-es5/JavaScriptSDK/StatsBeat.js +1 -1
  53. package/dist-es5/JavaScriptSDK/TelemetryHelpers.js +1 -1
  54. package/dist-es5/JavaScriptSDK/TelemetryInitializerPlugin.js +1 -1
  55. package/dist-es5/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
  56. package/dist-es5/JavaScriptSDK/UnloadHookContainer.js +1 -1
  57. package/dist-es5/JavaScriptSDK/W3cTraceParent.js +1 -1
  58. package/dist-es5/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
  59. package/dist-es5/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  60. package/dist-es5/JavaScriptSDK.Enums/FeatureOptInEnums.js +1 -1
  61. package/dist-es5/JavaScriptSDK.Enums/InitActiveStatusEnum.js +1 -1
  62. package/dist-es5/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  63. package/dist-es5/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  64. package/dist-es5/JavaScriptSDK.Enums/StatsType.js +1 -1
  65. package/dist-es5/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  66. package/dist-es5/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  67. package/dist-es5/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  68. package/dist-es5/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  69. package/dist-es5/JavaScriptSDK.Interfaces/IChannelControlsHost.js +1 -1
  70. package/dist-es5/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  71. package/dist-es5/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  72. package/dist-es5/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  73. package/dist-es5/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  74. package/dist-es5/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  75. package/dist-es5/JavaScriptSDK.Interfaces/IExceptionConfig.js +1 -1
  76. package/dist-es5/JavaScriptSDK.Interfaces/IFeatureOptIn.js +1 -1
  77. package/dist-es5/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  78. package/dist-es5/JavaScriptSDK.Interfaces/INetworkStatsbeat.js +1 -1
  79. package/dist-es5/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  80. package/dist-es5/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  81. package/dist-es5/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  82. package/dist-es5/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  83. package/dist-es5/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  84. package/dist-es5/JavaScriptSDK.Interfaces/ISenderPostManager.js +1 -1
  85. package/dist-es5/JavaScriptSDK.Interfaces/IStatsBeat.js +1 -1
  86. package/dist-es5/JavaScriptSDK.Interfaces/IStatsEventData.js +1 -1
  87. package/dist-es5/JavaScriptSDK.Interfaces/IStatsMgr.js +1 -1
  88. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  89. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  90. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  91. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  92. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  93. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  94. package/dist-es5/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  95. package/dist-es5/JavaScriptSDK.Interfaces/IUnloadHook.js +1 -1
  96. package/dist-es5/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
  97. package/dist-es5/JavaScriptSDK.Interfaces/IXDomainRequest.js +1 -1
  98. package/dist-es5/JavaScriptSDK.Interfaces/IXHROverride.js +1 -1
  99. package/dist-es5/__DynamicConstants.js +4 -4
  100. package/dist-es5/__DynamicConstants.js.map +1 -1
  101. package/dist-es5/applicationinsights-core-js.js +1 -1
  102. package/package.json +1 -1
  103. package/types/applicationinsights-core-js.d.ts +9 -1
  104. package/types/applicationinsights-core-js.namespaced.d.ts +9 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,12 +1,12 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  var _a, _b;
6
6
  import { arrForEach, arrIndexOf, dumpObj, getDocument, getLazy, getNavigator, isArray, isFunction, isNullOrUndefined, isString, isTruthy, isUndefined, objForEachKey, strEndsWith, strIndexOf, strLeft, strSubstring, strTrim, utcNow } from "@nevware21/ts-utils";
7
7
  import { cfgDfMerge } from "../Config/ConfigDefaultHelpers";
8
8
  import { createDynamicConfig, onConfigChange } from "../Config/DynamicConfig";
9
- import { _DYN_ENABLED, _DYN_LENGTH, _DYN_LOGGER, _DYN_SPLIT, _DYN_USER_AGENT } from "../__DynamicConstants";
9
+ import { _DYN_ENABLED, _DYN_LENGTH, _DYN_LOGGER, _DYN_PUSH, _DYN_SPLICE, _DYN_SPLIT, _DYN_USER_AGENT } from "../__DynamicConstants";
10
10
  import { _throwInternal } from "./DiagnosticLogger";
11
11
  import { getLocation, isIE } from "./EnvUtils";
12
12
  import { getExceptionName, isNotNullOrUndefined, setValue, strContains } from "./HelperFuncs";
@@ -40,6 +40,7 @@ var rootDefaultConfig = (_a = {
40
40
  _b.enabled = UNDEFINED_VALUE,
41
41
  _b.ignoreCookies = UNDEFINED_VALUE,
42
42
  _b.blockedCookies = UNDEFINED_VALUE,
43
+ _b.disableCookieDefer = false,
43
44
  _b)),
44
45
  cookieDomain: UNDEFINED_VALUE,
45
46
  cookiePath: UNDEFINED_VALUE
@@ -146,6 +147,96 @@ export function createCookieMgr(rootConfig, logger) {
146
147
  var _getCookieFn;
147
148
  var _setCookieFn;
148
149
  var _delCookieFn;
150
+ // Buffer for storing cookie operations when cookies are disabled
151
+ // null = deferral disabled, array = deferral enabled with pending operations
152
+ var _pendingCookies = [];
153
+ // Helper function to format deletion cookie value
154
+ function _formatDeletionValue(path) {
155
+ var _a;
156
+ var values = (_a = {},
157
+ _a[STR_PATH] = path ? path : "/",
158
+ _a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
159
+ _a);
160
+ if (!isIE()) {
161
+ // Set max age to expire now
162
+ values["max-age"] = "0";
163
+ }
164
+ return _formatCookieValue(STR_EMPTY, values);
165
+ }
166
+ // Helper function to format a cookie value with all attributes
167
+ function _formatSetCookieValue(value, maxAgeSec, domain, path) {
168
+ var values = {};
169
+ var theValue = strTrim(value || STR_EMPTY);
170
+ var idx = strIndexOf(theValue, ";");
171
+ if (idx !== -1) {
172
+ theValue = strTrim(strLeft(value, idx));
173
+ values = _extractParts(strSubstring(value, idx + 1));
174
+ }
175
+ // Only update domain if not already present (isUndefined) and the value is truthy (not null, undefined or empty string)
176
+ setValue(values, STR_DOMAIN, domain || _domain, isTruthy, isUndefined);
177
+ if (!isNullOrUndefined(maxAgeSec)) {
178
+ var _isIE = isIE();
179
+ if (isUndefined(values[strExpires])) {
180
+ var nowMs = utcNow();
181
+ // Only add expires if not already present
182
+ var expireMs = nowMs + (maxAgeSec * 1000);
183
+ // Sanity check, if zero or -ve then ignore
184
+ if (expireMs > 0) {
185
+ var expiry = new Date();
186
+ expiry.setTime(expireMs);
187
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || STR_EMPTY, isTruthy);
188
+ }
189
+ }
190
+ if (!_isIE) {
191
+ // Only replace if not already present
192
+ setValue(values, "max-age", STR_EMPTY + maxAgeSec, null, isUndefined);
193
+ }
194
+ }
195
+ var location = getLocation();
196
+ if (location && location.protocol === "https:") {
197
+ setValue(values, "secure", null, null, isUndefined);
198
+ // Only set same site if not also secure
199
+ if (_allowUaSameSite === null) {
200
+ _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {})[_DYN_USER_AGENT /* @min:%2euserAgent */]);
201
+ }
202
+ if (_allowUaSameSite) {
203
+ setValue(values, "SameSite", "None", null, isUndefined);
204
+ }
205
+ }
206
+ setValue(values, STR_PATH, path || _path, null, isUndefined);
207
+ return _formatCookieValue(theValue, values);
208
+ }
209
+ // Helper function to remove any existing pending operations for a cookie name
210
+ function _removePendingCookie(name) {
211
+ if (_pendingCookies) {
212
+ // Remove all existing entries for this cookie name (iterate backwards to handle multiple entries safely)
213
+ for (var i = _pendingCookies[_DYN_LENGTH /* @min:%2elength */] - 1; i >= 0; i--) {
214
+ if (_pendingCookies[i].n === name) {
215
+ _pendingCookies[_DYN_SPLICE /* @min:%2esplice */](i, 1);
216
+ }
217
+ }
218
+ }
219
+ }
220
+ // Helper function to flush pending cookies when cookies become enabled
221
+ function _flushPendingCookies() {
222
+ if (areCookiesSupported(logger) && _pendingCookies) {
223
+ // Process all pending cookie operations in order
224
+ arrForEach(_pendingCookies, function (pendingData) {
225
+ if (!_isBlockedCookie(cookieMgrConfig, pendingData.n)) {
226
+ if (pendingData.o === 0 /* ePendingOp.Set */) {
227
+ // Apply the cached cookie value directly
228
+ _setCookieFn(pendingData.n, pendingData.v);
229
+ }
230
+ else if (pendingData.o === 1 /* ePendingOp.Purge */) {
231
+ // Apply the cached deletion
232
+ _delCookieFn(pendingData.n, pendingData.v);
233
+ }
234
+ }
235
+ });
236
+ // Clear the cache after flushing
237
+ _pendingCookies = [];
238
+ }
239
+ }
149
240
  // Make sure the root config is dynamic as it may be the global config
150
241
  rootConfig = createDynamicConfig(rootConfig || _globalCookieConfig, null, logger).cfg;
151
242
  // Will get recalled if the referenced configuration is changed
@@ -156,11 +247,27 @@ export function createCookieMgr(rootConfig, logger) {
156
247
  cookieMgrConfig = details.ref(details.cfg, "cookieCfg"); // details.setDf(details.cfg.cookieCfg, defaultConfig);
157
248
  _path = cookieMgrConfig[STR_PATH /* @min:%2epath */] || "/";
158
249
  _domain = cookieMgrConfig[STR_DOMAIN /* @min:%2edomain */];
250
+ // Handle deferral state changes based on disableCookieDefer setting
251
+ if (cookieMgrConfig.disableCookieDefer) {
252
+ // When deferral is disabled, set to null to disable any deferral behavior
253
+ // All pending operations are dropped
254
+ _pendingCookies = null;
255
+ }
256
+ else if (_pendingCookies === null) {
257
+ // When deferral is enabled and was previously disabled, initialize empty buffer
258
+ _pendingCookies = [];
259
+ }
260
+ // Check if enabled state is changing
261
+ var wasEnabled = _enabled;
159
262
  // Explicitly checking against false, so that setting to undefined will === true
160
263
  _enabled = _isCfgEnabled(rootConfig, cookieMgrConfig) !== false;
161
264
  _getCookieFn = cookieMgrConfig.getCookie || _getCookieValue;
162
265
  _setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
163
266
  _delCookieFn = cookieMgrConfig.delCookie || _setCookieValue;
267
+ // If cookies were just enabled via config change and we have pending cookies, flush them
268
+ if (!wasEnabled && _enabled && _pendingCookies) {
269
+ _flushPendingCookies();
270
+ }
164
271
  }, logger);
165
272
  var cookieMgr = {
166
273
  isEnabled: function () {
@@ -176,62 +283,65 @@ export function createCookieMgr(rootConfig, logger) {
176
283
  return enabled;
177
284
  },
178
285
  setEnabled: function (value) {
179
- // Explicitly checking against false, so that setting to undefined will === true
180
- _enabled = value !== false;
286
+ // Change the default config and allow the asynchronous dynamic config logic
287
+ // to process all of the changes at once (like handling change to the enabled and
288
+ // disabling caching at the same time)
181
289
  cookieMgrConfig[_DYN_ENABLED /* @min:%2eenabled */] = value;
290
+ // If this value is defined someone else might be listening to it so also update it,
291
+ // this also handles the edge case if the default above is not dynamic
292
+ if (!isUndefined(rootConfig[strDisableCookiesUsage])) {
293
+ rootConfig[strDisableCookiesUsage] = !value;
294
+ }
182
295
  },
183
296
  set: function (name, value, maxAgeSec, domain, path) {
184
297
  var result = false;
185
- if (_isMgrEnabled(cookieMgr) && !_isBlockedCookie(cookieMgrConfig, name)) {
186
- var values = {};
187
- var theValue = strTrim(value || STR_EMPTY);
188
- var idx = strIndexOf(theValue, ";");
189
- if (idx !== -1) {
190
- theValue = strTrim(strLeft(value, idx));
191
- values = _extractParts(strSubstring(value, idx + 1));
298
+ var isBlocked = _isBlockedCookie(cookieMgrConfig, name);
299
+ if (!isBlocked) {
300
+ var cookieValue = _formatSetCookieValue(value, maxAgeSec, domain, path);
301
+ if (_isMgrEnabled(cookieMgr)) {
302
+ _setCookieFn(name, cookieValue);
303
+ result = true;
192
304
  }
193
- // Only update domain if not already present (isUndefined) and the value is truthy (not null, undefined or empty string)
194
- setValue(values, STR_DOMAIN, domain || _domain, isTruthy, isUndefined);
195
- if (!isNullOrUndefined(maxAgeSec)) {
196
- var _isIE = isIE();
197
- if (isUndefined(values[strExpires])) {
198
- var nowMs = utcNow();
199
- // Only add expires if not already present
200
- var expireMs = nowMs + (maxAgeSec * 1000);
201
- // Sanity check, if zero or -ve then ignore
202
- if (expireMs > 0) {
203
- var expiry = new Date();
204
- expiry.setTime(expireMs);
205
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || STR_EMPTY, isTruthy);
206
- }
207
- }
208
- if (!_isIE) {
209
- // Only replace if not already present
210
- setValue(values, "max-age", STR_EMPTY + maxAgeSec, null, isUndefined);
211
- }
305
+ else if (_pendingCookies) {
306
+ // Defer the fully formatted cookie value if cookies are disabled and deferral is enabled
307
+ // Remove any previous operation for this cookie name (latest operation wins)
308
+ _removePendingCookie(name);
309
+ // Append new operation to the array
310
+ _pendingCookies[_DYN_PUSH /* @min:%2epush */]({
311
+ n: name,
312
+ o: 0 /* ePendingOp.Set */,
313
+ v: cookieValue
314
+ });
315
+ result = true; // Return true to indicate the operation was "successful" (deferred)
212
316
  }
213
- var location_1 = getLocation();
214
- if (location_1 && location_1.protocol === "https:") {
215
- setValue(values, "secure", null, null, isUndefined);
216
- // Only set same site if not also secure
217
- if (_allowUaSameSite === null) {
218
- _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {})[_DYN_USER_AGENT /* @min:%2euserAgent */]);
219
- }
220
- if (_allowUaSameSite) {
221
- setValue(values, "SameSite", "None", null, isUndefined);
222
- }
223
- }
224
- setValue(values, STR_PATH, path || _path, null, isUndefined);
225
- //let setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
226
- _setCookieFn(name, _formatCookieValue(theValue, values));
227
- result = true;
228
317
  }
229
318
  return result;
230
319
  },
231
320
  get: function (name) {
232
321
  var value = STR_EMPTY;
233
- if (_isMgrEnabled(cookieMgr) && !_isIgnoredCookie(cookieMgrConfig, name)) {
234
- value = _getCookieFn(name);
322
+ var isIgnored = _isIgnoredCookie(cookieMgrConfig, name);
323
+ if (!isIgnored) {
324
+ if (_isMgrEnabled(cookieMgr)) {
325
+ value = _getCookieFn(name);
326
+ }
327
+ else if (_pendingCookies) {
328
+ // Search for the most recent operation for this cookie (search backwards through array)
329
+ for (var i = _pendingCookies[_DYN_LENGTH /* @min:%2elength */] - 1; i >= 0; i--) {
330
+ var pendingData = _pendingCookies[i];
331
+ if (pendingData.n === name) {
332
+ // Found the most recent operation for this cookie name
333
+ if (pendingData.o === 0 /* ePendingOp.Set */) {
334
+ // Return deferred value if it was a set operation
335
+ // Extract the value part from the formatted cookie string (before first semicolon)
336
+ var cookieValue = pendingData.v;
337
+ var idx = strIndexOf(cookieValue, ";");
338
+ value = idx !== -1 ? strTrim(strLeft(cookieValue, idx)) : strTrim(cookieValue);
339
+ }
340
+ // If it was a Purge operation, value remains empty (STR_EMPTY)
341
+ break;
342
+ }
343
+ }
344
+ }
235
345
  }
236
346
  return value;
237
347
  },
@@ -241,23 +351,25 @@ export function createCookieMgr(rootConfig, logger) {
241
351
  // Only remove the cookie if the manager and cookie support has not been disabled
242
352
  result = cookieMgr.purge(name, path);
243
353
  }
354
+ else if (_pendingCookies) {
355
+ // Defer the deletion operation when cookies are disabled and deferral is enabled
356
+ // Remove any previous operation for this cookie name (latest operation wins)
357
+ _removePendingCookie(name);
358
+ // Append new deletion operation to the array
359
+ _pendingCookies[_DYN_PUSH /* @min:%2epush */]({
360
+ n: name,
361
+ o: 1 /* ePendingOp.Purge */,
362
+ v: _formatDeletionValue(path)
363
+ });
364
+ result = true;
365
+ }
244
366
  return result;
245
367
  },
246
368
  purge: function (name, path) {
247
- var _a;
248
369
  var result = false;
249
370
  if (areCookiesSupported(logger)) {
250
371
  // Setting the expiration date in the past immediately removes the cookie
251
- var values = (_a = {},
252
- _a[STR_PATH] = path ? path : "/",
253
- _a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
254
- _a);
255
- if (!isIE()) {
256
- // Set max age to expire now
257
- values["max-age"] = "0";
258
- }
259
- // let delCookie = cookieMgrConfig.delCookie || _setCookieValue;
260
- _delCookieFn(name, _formatCookieValue(STR_EMPTY, values));
372
+ _delCookieFn(name, _formatDeletionValue(path));
261
373
  result = true;
262
374
  }
263
375
  return result;
@@ -265,6 +377,8 @@ export function createCookieMgr(rootConfig, logger) {
265
377
  unload: function (isAsync) {
266
378
  unloadHandler && unloadHandler.rm();
267
379
  unloadHandler = null;
380
+ // Clear any pending cookies on unload
381
+ _pendingCookies = null;
268
382
  }
269
383
  };
270
384
  // Associated this cookie manager with the config
@@ -1 +1 @@
1
- {"version":3,"file":"CookieMgr.js.map","sources":["CookieMgr.js"],"sourcesContent":["var _a, _b;\r\nimport { arrForEach, arrIndexOf, dumpObj, getDocument, getLazy, getNavigator, isArray, isFunction, isNullOrUndefined, isString, isTruthy, isUndefined, objForEachKey, strEndsWith, strIndexOf, strLeft, strSubstring, strTrim, utcNow } from \"@nevware21/ts-utils\";\r\nimport { cfgDfMerge } from \"../Config/ConfigDefaultHelpers\";\r\nimport { createDynamicConfig, onConfigChange } from \"../Config/DynamicConfig\";\r\nimport { _DYN_ENABLED, _DYN_LENGTH, _DYN_LOGGER, _DYN_SPLIT, _DYN_USER_AGENT } from \"../__DynamicConstants\";\r\nimport { _throwInternal } from \"./DiagnosticLogger\";\r\nimport { getLocation, isIE } from \"./EnvUtils\";\r\nimport { getExceptionName, isNotNullOrUndefined, setValue, strContains } from \"./HelperFuncs\";\r\nimport { STR_DOMAIN, STR_EMPTY, STR_PATH, UNDEFINED_VALUE } from \"./InternalConstants\";\r\nvar strToGMTString = \"toGMTString\";\r\nvar strToUTCString = \"toUTCString\";\r\nvar strCookie = \"cookie\";\r\nvar strExpires = \"expires\";\r\nvar strIsCookieUseDisabled = \"isCookieUseDisabled\";\r\nvar strDisableCookiesUsage = \"disableCookiesUsage\";\r\nvar strConfigCookieMgr = \"_ckMgr\";\r\nvar _supportsCookies = null;\r\nvar _allowUaSameSite = null;\r\nvar _parsedCookieValue = null;\r\nvar _doc;\r\nvar _cookieCache = {};\r\nvar _globalCookieConfig = {};\r\n// // `isCookieUseDisabled` is deprecated, so explicitly casting as a key of IConfiguration to avoid typing error\r\n// // when both isCookieUseDisabled and disableCookiesUsage are used disableCookiesUsage will take precedent, which is\r\n// // why its listed first\r\n/**\r\n * Set the supported dynamic config values as undefined (or an empty object) so that\r\n * any listeners will be informed of any changes.\r\n * Explicitly NOT including the deprecated `isCookieUseDisabled` as we don't want to support\r\n * the v1 deprecated field as dynamic for updates\r\n */\r\nvar rootDefaultConfig = (_a = {\r\n cookieCfg: cfgDfMerge((_b = {},\r\n _b[STR_DOMAIN] = { fb: \"cookieDomain\", dfVal: isNotNullOrUndefined },\r\n _b.path = { fb: \"cookiePath\", dfVal: isNotNullOrUndefined },\r\n _b.enabled = UNDEFINED_VALUE,\r\n _b.ignoreCookies = UNDEFINED_VALUE,\r\n _b.blockedCookies = UNDEFINED_VALUE,\r\n _b)),\r\n cookieDomain: UNDEFINED_VALUE,\r\n cookiePath: UNDEFINED_VALUE\r\n },\r\n _a[strDisableCookiesUsage] = UNDEFINED_VALUE,\r\n _a);\r\nfunction _getDoc() {\r\n !_doc && (_doc = getLazy(function () { return getDocument(); }));\r\n}\r\n/**\r\n * @ignore\r\n * DO NOT USE or export from the module, this is exposed as public to support backward compatibility of previous static utility methods only.\r\n * If you want to manager cookies either use the ICookieMgr available from the core instance via getCookieMgr() or create\r\n * your own instance of the CookieMgr and use that.\r\n * Using this directly for enabling / disabling cookie handling will not only affect your usage but EVERY user of cookies.\r\n * Example, if you are using a shared component that is also using Application Insights you will affect their cookie handling.\r\n * @param logger - The DiagnosticLogger to use for reporting errors.\r\n */\r\nfunction _gblCookieMgr(config, logger) {\r\n // Stash the global instance against the BaseCookieMgr class\r\n var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];\r\n if (!inst) {\r\n // Note: not using the getSetValue() helper as that would require always creating a temporary cookieMgr\r\n // that ultimately is never used\r\n inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);\r\n _globalCookieConfig[strConfigCookieMgr] = inst;\r\n }\r\n return inst;\r\n}\r\nfunction _isMgrEnabled(cookieMgr) {\r\n if (cookieMgr) {\r\n return cookieMgr.isEnabled();\r\n }\r\n return true;\r\n}\r\nfunction _isIgnoredCookie(cookieMgrCfg, name) {\r\n if (name && cookieMgrCfg && isArray(cookieMgrCfg.ignoreCookies)) {\r\n return arrIndexOf(cookieMgrCfg.ignoreCookies, name) !== -1;\r\n }\r\n return false;\r\n}\r\nfunction _isBlockedCookie(cookieMgrCfg, name) {\r\n if (name && cookieMgrCfg && isArray(cookieMgrCfg.blockedCookies)) {\r\n if (arrIndexOf(cookieMgrCfg.blockedCookies, name) !== -1) {\r\n return true;\r\n }\r\n }\r\n return _isIgnoredCookie(cookieMgrCfg, name);\r\n}\r\nfunction _isCfgEnabled(rootConfig, cookieMgrConfig) {\r\n var isCfgEnabled = cookieMgrConfig[_DYN_ENABLED /* @min:%2eenabled */];\r\n if (isNullOrUndefined(isCfgEnabled)) {\r\n // Set the enabled from the provided setting or the legacy root values\r\n var cookieEnabled = void 0;\r\n // This field is deprecated and dynamic updates will not be fully supported\r\n if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {\r\n cookieEnabled = !rootConfig[strIsCookieUseDisabled];\r\n }\r\n // If this value is defined it takes precedent over the above\r\n if (!isUndefined(rootConfig[strDisableCookiesUsage])) {\r\n cookieEnabled = !rootConfig[strDisableCookiesUsage];\r\n }\r\n // Not setting the cookieMgrConfig.enabled as that will update (set) the global dynamic config\r\n // So future \"updates\" then may not be as expected\r\n isCfgEnabled = cookieEnabled;\r\n }\r\n return isCfgEnabled;\r\n}\r\n/**\r\n * Helper to return the ICookieMgr from the core (if not null/undefined) or a default implementation\r\n * associated with the configuration or a legacy default.\r\n * @param core - The AppInsightsCore instance to get the cookie manager from\r\n * @param config - The config to use if the core is not available\r\n * @returns\r\n */\r\nexport function safeGetCookieMgr(core, config) {\r\n var cookieMgr;\r\n if (core) {\r\n // Always returns an instance\r\n cookieMgr = core.getCookieMgr();\r\n }\r\n else if (config) {\r\n var cookieCfg = config.cookieCfg;\r\n if (cookieCfg && cookieCfg[strConfigCookieMgr]) {\r\n cookieMgr = cookieCfg[strConfigCookieMgr];\r\n }\r\n else {\r\n cookieMgr = createCookieMgr(config);\r\n }\r\n }\r\n if (!cookieMgr) {\r\n // Get or initialize the default global (legacy) cookie manager if we couldn't find one\r\n cookieMgr = _gblCookieMgr(config, (core || {})[_DYN_LOGGER /* @min:%2elogger */]);\r\n }\r\n return cookieMgr;\r\n}\r\nexport function createCookieMgr(rootConfig, logger) {\r\n var cookieMgrConfig;\r\n var _path;\r\n var _domain;\r\n var unloadHandler;\r\n // Explicitly checking against false, so that setting to undefined will === true\r\n var _enabled;\r\n var _getCookieFn;\r\n var _setCookieFn;\r\n var _delCookieFn;\r\n // Make sure the root config is dynamic as it may be the global config\r\n rootConfig = createDynamicConfig(rootConfig || _globalCookieConfig, null, logger).cfg;\r\n // Will get recalled if the referenced configuration is changed\r\n unloadHandler = onConfigChange(rootConfig, function (details) {\r\n // Make sure the root config has all of the the defaults to the root config to ensure they are dynamic\r\n details.setDf(details.cfg, rootDefaultConfig);\r\n // Create and apply the defaults to the cookieCfg element\r\n cookieMgrConfig = details.ref(details.cfg, \"cookieCfg\"); // details.setDf(details.cfg.cookieCfg, defaultConfig);\r\n _path = cookieMgrConfig[STR_PATH /* @min:%2epath */] || \"/\";\r\n _domain = cookieMgrConfig[STR_DOMAIN /* @min:%2edomain */];\r\n // Explicitly checking against false, so that setting to undefined will === true\r\n _enabled = _isCfgEnabled(rootConfig, cookieMgrConfig) !== false;\r\n _getCookieFn = cookieMgrConfig.getCookie || _getCookieValue;\r\n _setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;\r\n _delCookieFn = cookieMgrConfig.delCookie || _setCookieValue;\r\n }, logger);\r\n var cookieMgr = {\r\n isEnabled: function () {\r\n var enabled = _isCfgEnabled(rootConfig, cookieMgrConfig) !== false && _enabled && areCookiesSupported(logger);\r\n // Using an indirect lookup for any global cookie manager to support tree shaking for SDK's\r\n // that don't use the \"applicationinsights-core\" version of the default cookie function\r\n var gblManager = _globalCookieConfig[strConfigCookieMgr];\r\n if (enabled && gblManager && cookieMgr !== gblManager) {\r\n // Make sure the GlobalCookie Manager instance (if not this instance) is also enabled.\r\n // As the global (deprecated) functions may have been called (for backward compatibility)\r\n enabled = _isMgrEnabled(gblManager);\r\n }\r\n return enabled;\r\n },\r\n setEnabled: function (value) {\r\n // Explicitly checking against false, so that setting to undefined will === true\r\n _enabled = value !== false;\r\n cookieMgrConfig[_DYN_ENABLED /* @min:%2eenabled */] = value;\r\n },\r\n set: function (name, value, maxAgeSec, domain, path) {\r\n var result = false;\r\n if (_isMgrEnabled(cookieMgr) && !_isBlockedCookie(cookieMgrConfig, name)) {\r\n var values = {};\r\n var theValue = strTrim(value || STR_EMPTY);\r\n var idx = strIndexOf(theValue, \";\");\r\n if (idx !== -1) {\r\n theValue = strTrim(strLeft(value, idx));\r\n values = _extractParts(strSubstring(value, idx + 1));\r\n }\r\n // Only update domain if not already present (isUndefined) and the value is truthy (not null, undefined or empty string)\r\n setValue(values, STR_DOMAIN, domain || _domain, isTruthy, isUndefined);\r\n if (!isNullOrUndefined(maxAgeSec)) {\r\n var _isIE = isIE();\r\n if (isUndefined(values[strExpires])) {\r\n var nowMs = utcNow();\r\n // Only add expires if not already present\r\n var expireMs = nowMs + (maxAgeSec * 1000);\r\n // Sanity check, if zero or -ve then ignore\r\n if (expireMs > 0) {\r\n var expiry = new Date();\r\n expiry.setTime(expireMs);\r\n setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || STR_EMPTY, isTruthy);\r\n }\r\n }\r\n if (!_isIE) {\r\n // Only replace if not already present\r\n setValue(values, \"max-age\", STR_EMPTY + maxAgeSec, null, isUndefined);\r\n }\r\n }\r\n var location_1 = getLocation();\r\n if (location_1 && location_1.protocol === \"https:\") {\r\n setValue(values, \"secure\", null, null, isUndefined);\r\n // Only set same site if not also secure\r\n if (_allowUaSameSite === null) {\r\n _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {})[_DYN_USER_AGENT /* @min:%2euserAgent */]);\r\n }\r\n if (_allowUaSameSite) {\r\n setValue(values, \"SameSite\", \"None\", null, isUndefined);\r\n }\r\n }\r\n setValue(values, STR_PATH, path || _path, null, isUndefined);\r\n //let setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;\r\n _setCookieFn(name, _formatCookieValue(theValue, values));\r\n result = true;\r\n }\r\n return result;\r\n },\r\n get: function (name) {\r\n var value = STR_EMPTY;\r\n if (_isMgrEnabled(cookieMgr) && !_isIgnoredCookie(cookieMgrConfig, name)) {\r\n value = _getCookieFn(name);\r\n }\r\n return value;\r\n },\r\n del: function (name, path) {\r\n var result = false;\r\n if (_isMgrEnabled(cookieMgr)) {\r\n // Only remove the cookie if the manager and cookie support has not been disabled\r\n result = cookieMgr.purge(name, path);\r\n }\r\n return result;\r\n },\r\n purge: function (name, path) {\r\n var _a;\r\n var result = false;\r\n if (areCookiesSupported(logger)) {\r\n // Setting the expiration date in the past immediately removes the cookie\r\n var values = (_a = {},\r\n _a[STR_PATH] = path ? path : \"/\",\r\n _a[strExpires] = \"Thu, 01 Jan 1970 00:00:01 GMT\",\r\n _a);\r\n if (!isIE()) {\r\n // Set max age to expire now\r\n values[\"max-age\"] = \"0\";\r\n }\r\n // let delCookie = cookieMgrConfig.delCookie || _setCookieValue;\r\n _delCookieFn(name, _formatCookieValue(STR_EMPTY, values));\r\n result = true;\r\n }\r\n return result;\r\n },\r\n unload: function (isAsync) {\r\n unloadHandler && unloadHandler.rm();\r\n unloadHandler = null;\r\n }\r\n };\r\n // Associated this cookie manager with the config\r\n cookieMgr[strConfigCookieMgr] = cookieMgr;\r\n return cookieMgr;\r\n}\r\n/*\r\n* Helper method to tell if document.cookie object is supported by the runtime\r\n*/\r\nexport function areCookiesSupported(logger) {\r\n if (_supportsCookies === null) {\r\n _supportsCookies = false;\r\n !_doc && _getDoc();\r\n try {\r\n var doc = _doc.v || {};\r\n _supportsCookies = doc[strCookie] !== undefined;\r\n }\r\n catch (e) {\r\n _throwInternal(logger, 2 /* eLoggingSeverity.WARNING */, 68 /* _eInternalMessageId.CannotAccessCookie */, \"Cannot access document.cookie - \" + getExceptionName(e), { exception: dumpObj(e) });\r\n }\r\n }\r\n return _supportsCookies;\r\n}\r\nfunction _extractParts(theValue) {\r\n var values = {};\r\n if (theValue && theValue[_DYN_LENGTH /* @min:%2elength */]) {\r\n var parts = strTrim(theValue)[_DYN_SPLIT /* @min:%2esplit */](\";\");\r\n arrForEach(parts, function (thePart) {\r\n thePart = strTrim(thePart || STR_EMPTY);\r\n if (thePart) {\r\n var idx = strIndexOf(thePart, \"=\");\r\n if (idx === -1) {\r\n values[thePart] = null;\r\n }\r\n else {\r\n values[strTrim(strLeft(thePart, idx))] = strTrim(strSubstring(thePart, idx + 1));\r\n }\r\n }\r\n });\r\n }\r\n return values;\r\n}\r\nfunction _formatDate(theDate, func) {\r\n if (isFunction(theDate[func])) {\r\n return theDate[func]();\r\n }\r\n return null;\r\n}\r\nfunction _formatCookieValue(value, values) {\r\n var cookieValue = value || STR_EMPTY;\r\n objForEachKey(values, function (name, theValue) {\r\n cookieValue += \"; \" + name + (!isNullOrUndefined(theValue) ? \"=\" + theValue : STR_EMPTY);\r\n });\r\n return cookieValue;\r\n}\r\nfunction _getCookieValue(name) {\r\n var cookieValue = STR_EMPTY;\r\n !_doc && _getDoc();\r\n if (_doc.v) {\r\n var theCookie = _doc.v[strCookie] || STR_EMPTY;\r\n if (_parsedCookieValue !== theCookie) {\r\n _cookieCache = _extractParts(theCookie);\r\n _parsedCookieValue = theCookie;\r\n }\r\n cookieValue = strTrim(_cookieCache[name] || STR_EMPTY);\r\n }\r\n return cookieValue;\r\n}\r\nfunction _setCookieValue(name, cookieValue) {\r\n !_doc && _getDoc();\r\n if (_doc.v) {\r\n _doc.v[strCookie] = name + \"=\" + cookieValue;\r\n }\r\n}\r\nexport function uaDisallowsSameSiteNone(userAgent) {\r\n if (!isString(userAgent)) {\r\n return false;\r\n }\r\n // Cover all iOS based browsers here. This includes:\r\n // - Safari on iOS 12 for iPhone, iPod Touch, iPad\r\n // - WkWebview on iOS 12 for iPhone, iPod Touch, iPad\r\n // - Chrome on iOS 12 for iPhone, iPod Touch, iPad\r\n // All of which are broken by SameSite=None, because they use the iOS networking stack\r\n if (strContains(userAgent, \"CPU iPhone OS 12\") || strContains(userAgent, \"iPad; CPU OS 12\")) {\r\n return true;\r\n }\r\n // Cover Mac OS X based browsers that use the Mac OS networking stack. This includes:\r\n // - Safari on Mac OS X\r\n // This does not include:\r\n // - Internal browser on Mac OS X\r\n // - Chrome on Mac OS X\r\n // - Chromium on Mac OS X\r\n // Because they do not use the Mac OS networking stack.\r\n if (strContains(userAgent, \"Macintosh; Intel Mac OS X 10_14\") && strContains(userAgent, \"Version/\") && strContains(userAgent, \"Safari\")) {\r\n return true;\r\n }\r\n // Cover Mac OS X internal browsers that use the Mac OS networking stack. This includes:\r\n // - Internal browser on Mac OS X\r\n // This does not include:\r\n // - Safari on Mac OS X\r\n // - Chrome on Mac OS X\r\n // - Chromium on Mac OS X\r\n // Because they do not use the Mac OS networking stack.\r\n if (strContains(userAgent, \"Macintosh; Intel Mac OS X 10_14\") && strEndsWith(userAgent, \"AppleWebKit/605.1.15 (KHTML, like Gecko)\")) {\r\n return true;\r\n }\r\n // Cover Chrome 50-69, because some versions are broken by SameSite=None, and none in this range require it.\r\n // Note: this covers some pre-Chromium Edge versions, but pre-Chromim Edge does not require SameSite=None, so this is fine.\r\n // Note: this regex applies to Windows, Mac OS X, and Linux, deliberately.\r\n if (strContains(userAgent, \"Chrome/5\") || strContains(userAgent, \"Chrome/6\")) {\r\n return true;\r\n }\r\n // Unreal Engine runs Chromium 59, but does not advertise as Chrome until 4.23. Treat versions of Unreal\r\n // that don't specify their Chrome version as lacking support for SameSite=None.\r\n if (strContains(userAgent, \"UnrealEngine\") && !strContains(userAgent, \"Chrome\")) {\r\n return true;\r\n }\r\n // UCBrowser < 12.13.2 ignores Set-Cookie headers with SameSite=None\r\n // NB: this rule isn't complete - you need regex to make a complete rule.\r\n // See: https://www.chromium.org/updates/same-site/incompatible-clients\r\n if (strContains(userAgent, \"UCBrowser/12\") || strContains(userAgent, \"UCBrowser/11\")) {\r\n return true;\r\n }\r\n return false;\r\n}\r\n//# sourceMappingURL=CookieMgr.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"CookieMgr.js.map","sources":["CookieMgr.js"],"sourcesContent":["var _a, _b;\r\nimport { arrForEach, arrIndexOf, dumpObj, getDocument, getLazy, getNavigator, isArray, isFunction, isNullOrUndefined, isString, isTruthy, isUndefined, objForEachKey, strEndsWith, strIndexOf, strLeft, strSubstring, strTrim, utcNow } from \"@nevware21/ts-utils\";\r\nimport { cfgDfMerge } from \"../Config/ConfigDefaultHelpers\";\r\nimport { createDynamicConfig, onConfigChange } from \"../Config/DynamicConfig\";\r\nimport { _DYN_ENABLED, _DYN_LENGTH, _DYN_LOGGER, _DYN_PUSH, _DYN_SPLICE, _DYN_SPLIT, _DYN_USER_AGENT } from \"../__DynamicConstants\";\r\nimport { _throwInternal } from \"./DiagnosticLogger\";\r\nimport { getLocation, isIE } from \"./EnvUtils\";\r\nimport { getExceptionName, isNotNullOrUndefined, setValue, strContains } from \"./HelperFuncs\";\r\nimport { STR_DOMAIN, STR_EMPTY, STR_PATH, UNDEFINED_VALUE } from \"./InternalConstants\";\r\nvar strToGMTString = \"toGMTString\";\r\nvar strToUTCString = \"toUTCString\";\r\nvar strCookie = \"cookie\";\r\nvar strExpires = \"expires\";\r\nvar strIsCookieUseDisabled = \"isCookieUseDisabled\";\r\nvar strDisableCookiesUsage = \"disableCookiesUsage\";\r\nvar strConfigCookieMgr = \"_ckMgr\";\r\nvar _supportsCookies = null;\r\nvar _allowUaSameSite = null;\r\nvar _parsedCookieValue = null;\r\nvar _doc;\r\nvar _cookieCache = {};\r\nvar _globalCookieConfig = {};\r\n// // `isCookieUseDisabled` is deprecated, so explicitly casting as a key of IConfiguration to avoid typing error\r\n// // when both isCookieUseDisabled and disableCookiesUsage are used disableCookiesUsage will take precedent, which is\r\n// // why its listed first\r\n/**\r\n * Set the supported dynamic config values as undefined (or an empty object) so that\r\n * any listeners will be informed of any changes.\r\n * Explicitly NOT including the deprecated `isCookieUseDisabled` as we don't want to support\r\n * the v1 deprecated field as dynamic for updates\r\n */\r\nvar rootDefaultConfig = (_a = {\r\n cookieCfg: cfgDfMerge((_b = {},\r\n _b[STR_DOMAIN] = { fb: \"cookieDomain\", dfVal: isNotNullOrUndefined },\r\n _b.path = { fb: \"cookiePath\", dfVal: isNotNullOrUndefined },\r\n _b.enabled = UNDEFINED_VALUE,\r\n _b.ignoreCookies = UNDEFINED_VALUE,\r\n _b.blockedCookies = UNDEFINED_VALUE,\r\n _b.disableCookieDefer = false,\r\n _b)),\r\n cookieDomain: UNDEFINED_VALUE,\r\n cookiePath: UNDEFINED_VALUE\r\n },\r\n _a[strDisableCookiesUsage] = UNDEFINED_VALUE,\r\n _a);\r\nfunction _getDoc() {\r\n !_doc && (_doc = getLazy(function () { return getDocument(); }));\r\n}\r\n/**\r\n * @ignore\r\n * DO NOT USE or export from the module, this is exposed as public to support backward compatibility of previous static utility methods only.\r\n * If you want to manager cookies either use the ICookieMgr available from the core instance via getCookieMgr() or create\r\n * your own instance of the CookieMgr and use that.\r\n * Using this directly for enabling / disabling cookie handling will not only affect your usage but EVERY user of cookies.\r\n * Example, if you are using a shared component that is also using Application Insights you will affect their cookie handling.\r\n * @param logger - The DiagnosticLogger to use for reporting errors.\r\n */\r\nfunction _gblCookieMgr(config, logger) {\r\n // Stash the global instance against the BaseCookieMgr class\r\n var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];\r\n if (!inst) {\r\n // Note: not using the getSetValue() helper as that would require always creating a temporary cookieMgr\r\n // that ultimately is never used\r\n inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);\r\n _globalCookieConfig[strConfigCookieMgr] = inst;\r\n }\r\n return inst;\r\n}\r\nfunction _isMgrEnabled(cookieMgr) {\r\n if (cookieMgr) {\r\n return cookieMgr.isEnabled();\r\n }\r\n return true;\r\n}\r\nfunction _isIgnoredCookie(cookieMgrCfg, name) {\r\n if (name && cookieMgrCfg && isArray(cookieMgrCfg.ignoreCookies)) {\r\n return arrIndexOf(cookieMgrCfg.ignoreCookies, name) !== -1;\r\n }\r\n return false;\r\n}\r\nfunction _isBlockedCookie(cookieMgrCfg, name) {\r\n if (name && cookieMgrCfg && isArray(cookieMgrCfg.blockedCookies)) {\r\n if (arrIndexOf(cookieMgrCfg.blockedCookies, name) !== -1) {\r\n return true;\r\n }\r\n }\r\n return _isIgnoredCookie(cookieMgrCfg, name);\r\n}\r\nfunction _isCfgEnabled(rootConfig, cookieMgrConfig) {\r\n var isCfgEnabled = cookieMgrConfig[_DYN_ENABLED /* @min:%2eenabled */];\r\n if (isNullOrUndefined(isCfgEnabled)) {\r\n // Set the enabled from the provided setting or the legacy root values\r\n var cookieEnabled = void 0;\r\n // This field is deprecated and dynamic updates will not be fully supported\r\n if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {\r\n cookieEnabled = !rootConfig[strIsCookieUseDisabled];\r\n }\r\n // If this value is defined it takes precedent over the above\r\n if (!isUndefined(rootConfig[strDisableCookiesUsage])) {\r\n cookieEnabled = !rootConfig[strDisableCookiesUsage];\r\n }\r\n // Not setting the cookieMgrConfig.enabled as that will update (set) the global dynamic config\r\n // So future \"updates\" then may not be as expected\r\n isCfgEnabled = cookieEnabled;\r\n }\r\n return isCfgEnabled;\r\n}\r\n/**\r\n * Helper to return the ICookieMgr from the core (if not null/undefined) or a default implementation\r\n * associated with the configuration or a legacy default.\r\n * @param core - The AppInsightsCore instance to get the cookie manager from\r\n * @param config - The config to use if the core is not available\r\n * @returns\r\n */\r\nexport function safeGetCookieMgr(core, config) {\r\n var cookieMgr;\r\n if (core) {\r\n // Always returns an instance\r\n cookieMgr = core.getCookieMgr();\r\n }\r\n else if (config) {\r\n var cookieCfg = config.cookieCfg;\r\n if (cookieCfg && cookieCfg[strConfigCookieMgr]) {\r\n cookieMgr = cookieCfg[strConfigCookieMgr];\r\n }\r\n else {\r\n cookieMgr = createCookieMgr(config);\r\n }\r\n }\r\n if (!cookieMgr) {\r\n // Get or initialize the default global (legacy) cookie manager if we couldn't find one\r\n cookieMgr = _gblCookieMgr(config, (core || {})[_DYN_LOGGER /* @min:%2elogger */]);\r\n }\r\n return cookieMgr;\r\n}\r\nexport function createCookieMgr(rootConfig, logger) {\r\n var cookieMgrConfig;\r\n var _path;\r\n var _domain;\r\n var unloadHandler;\r\n // Explicitly checking against false, so that setting to undefined will === true\r\n var _enabled;\r\n var _getCookieFn;\r\n var _setCookieFn;\r\n var _delCookieFn;\r\n // Buffer for storing cookie operations when cookies are disabled\r\n // null = deferral disabled, array = deferral enabled with pending operations\r\n var _pendingCookies = [];\r\n // Helper function to format deletion cookie value\r\n function _formatDeletionValue(path) {\r\n var _a;\r\n var values = (_a = {},\r\n _a[STR_PATH] = path ? path : \"/\",\r\n _a[strExpires] = \"Thu, 01 Jan 1970 00:00:01 GMT\",\r\n _a);\r\n if (!isIE()) {\r\n // Set max age to expire now\r\n values[\"max-age\"] = \"0\";\r\n }\r\n return _formatCookieValue(STR_EMPTY, values);\r\n }\r\n // Helper function to format a cookie value with all attributes\r\n function _formatSetCookieValue(value, maxAgeSec, domain, path) {\r\n var values = {};\r\n var theValue = strTrim(value || STR_EMPTY);\r\n var idx = strIndexOf(theValue, \";\");\r\n if (idx !== -1) {\r\n theValue = strTrim(strLeft(value, idx));\r\n values = _extractParts(strSubstring(value, idx + 1));\r\n }\r\n // Only update domain if not already present (isUndefined) and the value is truthy (not null, undefined or empty string)\r\n setValue(values, STR_DOMAIN, domain || _domain, isTruthy, isUndefined);\r\n if (!isNullOrUndefined(maxAgeSec)) {\r\n var _isIE = isIE();\r\n if (isUndefined(values[strExpires])) {\r\n var nowMs = utcNow();\r\n // Only add expires if not already present\r\n var expireMs = nowMs + (maxAgeSec * 1000);\r\n // Sanity check, if zero or -ve then ignore\r\n if (expireMs > 0) {\r\n var expiry = new Date();\r\n expiry.setTime(expireMs);\r\n setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || STR_EMPTY, isTruthy);\r\n }\r\n }\r\n if (!_isIE) {\r\n // Only replace if not already present\r\n setValue(values, \"max-age\", STR_EMPTY + maxAgeSec, null, isUndefined);\r\n }\r\n }\r\n var location = getLocation();\r\n if (location && location.protocol === \"https:\") {\r\n setValue(values, \"secure\", null, null, isUndefined);\r\n // Only set same site if not also secure\r\n if (_allowUaSameSite === null) {\r\n _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {})[_DYN_USER_AGENT /* @min:%2euserAgent */]);\r\n }\r\n if (_allowUaSameSite) {\r\n setValue(values, \"SameSite\", \"None\", null, isUndefined);\r\n }\r\n }\r\n setValue(values, STR_PATH, path || _path, null, isUndefined);\r\n return _formatCookieValue(theValue, values);\r\n }\r\n // Helper function to remove any existing pending operations for a cookie name\r\n function _removePendingCookie(name) {\r\n if (_pendingCookies) {\r\n // Remove all existing entries for this cookie name (iterate backwards to handle multiple entries safely)\r\n for (var i = _pendingCookies[_DYN_LENGTH /* @min:%2elength */] - 1; i >= 0; i--) {\r\n if (_pendingCookies[i].n === name) {\r\n _pendingCookies[_DYN_SPLICE /* @min:%2esplice */](i, 1);\r\n }\r\n }\r\n }\r\n }\r\n // Helper function to flush pending cookies when cookies become enabled\r\n function _flushPendingCookies() {\r\n if (areCookiesSupported(logger) && _pendingCookies) {\r\n // Process all pending cookie operations in order\r\n arrForEach(_pendingCookies, function (pendingData) {\r\n if (!_isBlockedCookie(cookieMgrConfig, pendingData.n)) {\r\n if (pendingData.o === 0 /* ePendingOp.Set */) {\r\n // Apply the cached cookie value directly\r\n _setCookieFn(pendingData.n, pendingData.v);\r\n }\r\n else if (pendingData.o === 1 /* ePendingOp.Purge */) {\r\n // Apply the cached deletion\r\n _delCookieFn(pendingData.n, pendingData.v);\r\n }\r\n }\r\n });\r\n // Clear the cache after flushing\r\n _pendingCookies = [];\r\n }\r\n }\r\n // Make sure the root config is dynamic as it may be the global config\r\n rootConfig = createDynamicConfig(rootConfig || _globalCookieConfig, null, logger).cfg;\r\n // Will get recalled if the referenced configuration is changed\r\n unloadHandler = onConfigChange(rootConfig, function (details) {\r\n // Make sure the root config has all of the the defaults to the root config to ensure they are dynamic\r\n details.setDf(details.cfg, rootDefaultConfig);\r\n // Create and apply the defaults to the cookieCfg element\r\n cookieMgrConfig = details.ref(details.cfg, \"cookieCfg\"); // details.setDf(details.cfg.cookieCfg, defaultConfig);\r\n _path = cookieMgrConfig[STR_PATH /* @min:%2epath */] || \"/\";\r\n _domain = cookieMgrConfig[STR_DOMAIN /* @min:%2edomain */];\r\n // Handle deferral state changes based on disableCookieDefer setting\r\n if (cookieMgrConfig.disableCookieDefer) {\r\n // When deferral is disabled, set to null to disable any deferral behavior\r\n // All pending operations are dropped\r\n _pendingCookies = null;\r\n }\r\n else if (_pendingCookies === null) {\r\n // When deferral is enabled and was previously disabled, initialize empty buffer\r\n _pendingCookies = [];\r\n }\r\n // Check if enabled state is changing\r\n var wasEnabled = _enabled;\r\n // Explicitly checking against false, so that setting to undefined will === true\r\n _enabled = _isCfgEnabled(rootConfig, cookieMgrConfig) !== false;\r\n _getCookieFn = cookieMgrConfig.getCookie || _getCookieValue;\r\n _setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;\r\n _delCookieFn = cookieMgrConfig.delCookie || _setCookieValue;\r\n // If cookies were just enabled via config change and we have pending cookies, flush them\r\n if (!wasEnabled && _enabled && _pendingCookies) {\r\n _flushPendingCookies();\r\n }\r\n }, logger);\r\n var cookieMgr = {\r\n isEnabled: function () {\r\n var enabled = _isCfgEnabled(rootConfig, cookieMgrConfig) !== false && _enabled && areCookiesSupported(logger);\r\n // Using an indirect lookup for any global cookie manager to support tree shaking for SDK's\r\n // that don't use the \"applicationinsights-core\" version of the default cookie function\r\n var gblManager = _globalCookieConfig[strConfigCookieMgr];\r\n if (enabled && gblManager && cookieMgr !== gblManager) {\r\n // Make sure the GlobalCookie Manager instance (if not this instance) is also enabled.\r\n // As the global (deprecated) functions may have been called (for backward compatibility)\r\n enabled = _isMgrEnabled(gblManager);\r\n }\r\n return enabled;\r\n },\r\n setEnabled: function (value) {\r\n // Change the default config and allow the asynchronous dynamic config logic\r\n // to process all of the changes at once (like handling change to the enabled and\r\n // disabling caching at the same time)\r\n cookieMgrConfig[_DYN_ENABLED /* @min:%2eenabled */] = value;\r\n // If this value is defined someone else might be listening to it so also update it,\r\n // this also handles the edge case if the default above is not dynamic\r\n if (!isUndefined(rootConfig[strDisableCookiesUsage])) {\r\n rootConfig[strDisableCookiesUsage] = !value;\r\n }\r\n },\r\n set: function (name, value, maxAgeSec, domain, path) {\r\n var result = false;\r\n var isBlocked = _isBlockedCookie(cookieMgrConfig, name);\r\n if (!isBlocked) {\r\n var cookieValue = _formatSetCookieValue(value, maxAgeSec, domain, path);\r\n if (_isMgrEnabled(cookieMgr)) {\r\n _setCookieFn(name, cookieValue);\r\n result = true;\r\n }\r\n else if (_pendingCookies) {\r\n // Defer the fully formatted cookie value if cookies are disabled and deferral is enabled\r\n // Remove any previous operation for this cookie name (latest operation wins)\r\n _removePendingCookie(name);\r\n // Append new operation to the array\r\n _pendingCookies[_DYN_PUSH /* @min:%2epush */]({\r\n n: name,\r\n o: 0 /* ePendingOp.Set */,\r\n v: cookieValue\r\n });\r\n result = true; // Return true to indicate the operation was \"successful\" (deferred)\r\n }\r\n }\r\n return result;\r\n },\r\n get: function (name) {\r\n var value = STR_EMPTY;\r\n var isIgnored = _isIgnoredCookie(cookieMgrConfig, name);\r\n if (!isIgnored) {\r\n if (_isMgrEnabled(cookieMgr)) {\r\n value = _getCookieFn(name);\r\n }\r\n else if (_pendingCookies) {\r\n // Search for the most recent operation for this cookie (search backwards through array)\r\n for (var i = _pendingCookies[_DYN_LENGTH /* @min:%2elength */] - 1; i >= 0; i--) {\r\n var pendingData = _pendingCookies[i];\r\n if (pendingData.n === name) {\r\n // Found the most recent operation for this cookie name\r\n if (pendingData.o === 0 /* ePendingOp.Set */) {\r\n // Return deferred value if it was a set operation\r\n // Extract the value part from the formatted cookie string (before first semicolon)\r\n var cookieValue = pendingData.v;\r\n var idx = strIndexOf(cookieValue, \";\");\r\n value = idx !== -1 ? strTrim(strLeft(cookieValue, idx)) : strTrim(cookieValue);\r\n }\r\n // If it was a Purge operation, value remains empty (STR_EMPTY)\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return value;\r\n },\r\n del: function (name, path) {\r\n var result = false;\r\n if (_isMgrEnabled(cookieMgr)) {\r\n // Only remove the cookie if the manager and cookie support has not been disabled\r\n result = cookieMgr.purge(name, path);\r\n }\r\n else if (_pendingCookies) {\r\n // Defer the deletion operation when cookies are disabled and deferral is enabled\r\n // Remove any previous operation for this cookie name (latest operation wins)\r\n _removePendingCookie(name);\r\n // Append new deletion operation to the array\r\n _pendingCookies[_DYN_PUSH /* @min:%2epush */]({\r\n n: name,\r\n o: 1 /* ePendingOp.Purge */,\r\n v: _formatDeletionValue(path)\r\n });\r\n result = true;\r\n }\r\n return result;\r\n },\r\n purge: function (name, path) {\r\n var result = false;\r\n if (areCookiesSupported(logger)) {\r\n // Setting the expiration date in the past immediately removes the cookie\r\n _delCookieFn(name, _formatDeletionValue(path));\r\n result = true;\r\n }\r\n return result;\r\n },\r\n unload: function (isAsync) {\r\n unloadHandler && unloadHandler.rm();\r\n unloadHandler = null;\r\n // Clear any pending cookies on unload\r\n _pendingCookies = null;\r\n }\r\n };\r\n // Associated this cookie manager with the config\r\n cookieMgr[strConfigCookieMgr] = cookieMgr;\r\n return cookieMgr;\r\n}\r\n/*\r\n* Helper method to tell if document.cookie object is supported by the runtime\r\n*/\r\nexport function areCookiesSupported(logger) {\r\n if (_supportsCookies === null) {\r\n _supportsCookies = false;\r\n !_doc && _getDoc();\r\n try {\r\n var doc = _doc.v || {};\r\n _supportsCookies = doc[strCookie] !== undefined;\r\n }\r\n catch (e) {\r\n _throwInternal(logger, 2 /* eLoggingSeverity.WARNING */, 68 /* _eInternalMessageId.CannotAccessCookie */, \"Cannot access document.cookie - \" + getExceptionName(e), { exception: dumpObj(e) });\r\n }\r\n }\r\n return _supportsCookies;\r\n}\r\nfunction _extractParts(theValue) {\r\n var values = {};\r\n if (theValue && theValue[_DYN_LENGTH /* @min:%2elength */]) {\r\n var parts = strTrim(theValue)[_DYN_SPLIT /* @min:%2esplit */](\";\");\r\n arrForEach(parts, function (thePart) {\r\n thePart = strTrim(thePart || STR_EMPTY);\r\n if (thePart) {\r\n var idx = strIndexOf(thePart, \"=\");\r\n if (idx === -1) {\r\n values[thePart] = null;\r\n }\r\n else {\r\n values[strTrim(strLeft(thePart, idx))] = strTrim(strSubstring(thePart, idx + 1));\r\n }\r\n }\r\n });\r\n }\r\n return values;\r\n}\r\nfunction _formatDate(theDate, func) {\r\n if (isFunction(theDate[func])) {\r\n return theDate[func]();\r\n }\r\n return null;\r\n}\r\nfunction _formatCookieValue(value, values) {\r\n var cookieValue = value || STR_EMPTY;\r\n objForEachKey(values, function (name, theValue) {\r\n cookieValue += \"; \" + name + (!isNullOrUndefined(theValue) ? \"=\" + theValue : STR_EMPTY);\r\n });\r\n return cookieValue;\r\n}\r\nfunction _getCookieValue(name) {\r\n var cookieValue = STR_EMPTY;\r\n !_doc && _getDoc();\r\n if (_doc.v) {\r\n var theCookie = _doc.v[strCookie] || STR_EMPTY;\r\n if (_parsedCookieValue !== theCookie) {\r\n _cookieCache = _extractParts(theCookie);\r\n _parsedCookieValue = theCookie;\r\n }\r\n cookieValue = strTrim(_cookieCache[name] || STR_EMPTY);\r\n }\r\n return cookieValue;\r\n}\r\nfunction _setCookieValue(name, cookieValue) {\r\n !_doc && _getDoc();\r\n if (_doc.v) {\r\n _doc.v[strCookie] = name + \"=\" + cookieValue;\r\n }\r\n}\r\nexport function uaDisallowsSameSiteNone(userAgent) {\r\n if (!isString(userAgent)) {\r\n return false;\r\n }\r\n // Cover all iOS based browsers here. This includes:\r\n // - Safari on iOS 12 for iPhone, iPod Touch, iPad\r\n // - WkWebview on iOS 12 for iPhone, iPod Touch, iPad\r\n // - Chrome on iOS 12 for iPhone, iPod Touch, iPad\r\n // All of which are broken by SameSite=None, because they use the iOS networking stack\r\n if (strContains(userAgent, \"CPU iPhone OS 12\") || strContains(userAgent, \"iPad; CPU OS 12\")) {\r\n return true;\r\n }\r\n // Cover Mac OS X based browsers that use the Mac OS networking stack. This includes:\r\n // - Safari on Mac OS X\r\n // This does not include:\r\n // - Internal browser on Mac OS X\r\n // - Chrome on Mac OS X\r\n // - Chromium on Mac OS X\r\n // Because they do not use the Mac OS networking stack.\r\n if (strContains(userAgent, \"Macintosh; Intel Mac OS X 10_14\") && strContains(userAgent, \"Version/\") && strContains(userAgent, \"Safari\")) {\r\n return true;\r\n }\r\n // Cover Mac OS X internal browsers that use the Mac OS networking stack. This includes:\r\n // - Internal browser on Mac OS X\r\n // This does not include:\r\n // - Safari on Mac OS X\r\n // - Chrome on Mac OS X\r\n // - Chromium on Mac OS X\r\n // Because they do not use the Mac OS networking stack.\r\n if (strContains(userAgent, \"Macintosh; Intel Mac OS X 10_14\") && strEndsWith(userAgent, \"AppleWebKit/605.1.15 (KHTML, like Gecko)\")) {\r\n return true;\r\n }\r\n // Cover Chrome 50-69, because some versions are broken by SameSite=None, and none in this range require it.\r\n // Note: this covers some pre-Chromium Edge versions, but pre-Chromim Edge does not require SameSite=None, so this is fine.\r\n // Note: this regex applies to Windows, Mac OS X, and Linux, deliberately.\r\n if (strContains(userAgent, \"Chrome/5\") || strContains(userAgent, \"Chrome/6\")) {\r\n return true;\r\n }\r\n // Unreal Engine runs Chromium 59, but does not advertise as Chrome until 4.23. Treat versions of Unreal\r\n // that don't specify their Chrome version as lacking support for SameSite=None.\r\n if (strContains(userAgent, \"UnrealEngine\") && !strContains(userAgent, \"Chrome\")) {\r\n return true;\r\n }\r\n // UCBrowser < 12.13.2 ignores Set-Cookie headers with SameSite=None\r\n // NB: this rule isn't complete - you need regex to make a complete rule.\r\n // See: https://www.chromium.org/updates/same-site/incompatible-clients\r\n if (strContains(userAgent, \"UCBrowser/12\") || strContains(userAgent, \"UCBrowser/11\")) {\r\n return true;\r\n }\r\n return false;\r\n}\r\n//# sourceMappingURL=CookieMgr.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -8,7 +8,7 @@ import { objDefine } from "@nevware21/ts-utils";
8
8
  import { normalizeJsName } from "./HelperFuncs";
9
9
  import { STR_EMPTY } from "./InternalConstants";
10
10
  import { newId } from "./RandomHelper";
11
- var version = '3.3.10-nightly3.2507-28';
11
+ var version = '3.3.10-nightly3.2508-01';
12
12
  var instanceName = "." + newId(6);
13
13
  var _dataUid = 0;
14
14
  // Accepts only:
@@ -1 +1 @@
1
- {"version":3,"file":"DataCacheHelper.js.map","sources":["DataCacheHelper.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { objDefine } from \"@nevware21/ts-utils\";\r\nimport { normalizeJsName } from \"./HelperFuncs\";\r\nimport { STR_EMPTY } from \"./InternalConstants\";\r\nimport { newId } from \"./RandomHelper\";\r\nvar version = '3.3.10-nightly3.2507-28';\r\nvar instanceName = \".\" + newId(6);\r\nvar _dataUid = 0;\r\n// Accepts only:\r\n// - Node\r\n// - Node.ELEMENT_NODE\r\n// - Node.DOCUMENT_NODE\r\n// - Object\r\n// - Any\r\nfunction _canAcceptData(target) {\r\n return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);\r\n}\r\nfunction _getCache(data, target) {\r\n var theCache = target[data.id];\r\n if (!theCache) {\r\n theCache = {};\r\n try {\r\n if (_canAcceptData(target)) {\r\n objDefine(target, data.id, {\r\n e: false,\r\n v: theCache\r\n });\r\n }\r\n }\r\n catch (e) {\r\n // Not all environments allow extending all objects, so just ignore the cache in those cases\r\n }\r\n }\r\n return theCache;\r\n}\r\nexport function createUniqueNamespace(name, includeVersion) {\r\n if (includeVersion === void 0) { includeVersion = false; }\r\n return normalizeJsName(name + (_dataUid++) + (includeVersion ? \".\" + version : STR_EMPTY) + instanceName);\r\n}\r\nexport function createElmNodeData(name) {\r\n var data = {\r\n id: createUniqueNamespace(\"_aiData-\" + (name || STR_EMPTY) + \".\" + version),\r\n accept: function (target) {\r\n return _canAcceptData(target);\r\n },\r\n get: function (target, name, defValue, addDefault) {\r\n var theCache = target[data.id];\r\n if (!theCache) {\r\n if (addDefault) {\r\n // Side effect is adds the cache\r\n theCache = _getCache(data, target);\r\n theCache[normalizeJsName(name)] = defValue;\r\n }\r\n return defValue;\r\n }\r\n return theCache[normalizeJsName(name)];\r\n },\r\n kill: function (target, name) {\r\n if (target && target[name]) {\r\n try {\r\n delete target[name];\r\n }\r\n catch (e) {\r\n // Just cleaning up, so if this fails -- ignore\r\n }\r\n }\r\n }\r\n };\r\n return data;\r\n}\r\n//# sourceMappingURL=DataCacheHelper.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"DataCacheHelper.js.map","sources":["DataCacheHelper.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { objDefine } from \"@nevware21/ts-utils\";\r\nimport { normalizeJsName } from \"./HelperFuncs\";\r\nimport { STR_EMPTY } from \"./InternalConstants\";\r\nimport { newId } from \"./RandomHelper\";\r\nvar version = '3.3.10-nightly3.2508-01';\r\nvar instanceName = \".\" + newId(6);\r\nvar _dataUid = 0;\r\n// Accepts only:\r\n// - Node\r\n// - Node.ELEMENT_NODE\r\n// - Node.DOCUMENT_NODE\r\n// - Object\r\n// - Any\r\nfunction _canAcceptData(target) {\r\n return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);\r\n}\r\nfunction _getCache(data, target) {\r\n var theCache = target[data.id];\r\n if (!theCache) {\r\n theCache = {};\r\n try {\r\n if (_canAcceptData(target)) {\r\n objDefine(target, data.id, {\r\n e: false,\r\n v: theCache\r\n });\r\n }\r\n }\r\n catch (e) {\r\n // Not all environments allow extending all objects, so just ignore the cache in those cases\r\n }\r\n }\r\n return theCache;\r\n}\r\nexport function createUniqueNamespace(name, includeVersion) {\r\n if (includeVersion === void 0) { includeVersion = false; }\r\n return normalizeJsName(name + (_dataUid++) + (includeVersion ? \".\" + version : STR_EMPTY) + instanceName);\r\n}\r\nexport function createElmNodeData(name) {\r\n var data = {\r\n id: createUniqueNamespace(\"_aiData-\" + (name || STR_EMPTY) + \".\" + version),\r\n accept: function (target) {\r\n return _canAcceptData(target);\r\n },\r\n get: function (target, name, defValue, addDefault) {\r\n var theCache = target[data.id];\r\n if (!theCache) {\r\n if (addDefault) {\r\n // Side effect is adds the cache\r\n theCache = _getCache(data, target);\r\n theCache[normalizeJsName(name)] = defValue;\r\n }\r\n return defValue;\r\n }\r\n return theCache[normalizeJsName(name)];\r\n },\r\n kill: function (target, name) {\r\n if (target && target[name]) {\r\n try {\r\n delete target[name];\r\n }\r\n catch (e) {\r\n // Just cleaning up, so if this fails -- ignore\r\n }\r\n }\r\n }\r\n };\r\n return data;\r\n}\r\n//# sourceMappingURL=DataCacheHelper.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2507-28
2
+ * Application Insights JavaScript SDK - Core, 3.3.10-nightly3.2508-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5