@qlik/api 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/analytics/change-stores.d.ts +40 -76
  2. package/analytics/change-stores.js +9 -10
  3. package/analytics.d.ts +1 -2
  4. package/analytics.js +5 -6
  5. package/api-keys.d.ts +46 -100
  6. package/api-keys.js +3 -4
  7. package/apps.d.ts +334 -461
  8. package/apps.js +74 -6
  9. package/assistants.d.ts +172 -337
  10. package/assistants.js +3 -4
  11. package/audits.d.ts +41 -85
  12. package/audits.js +3 -4
  13. package/auth-types.d.ts +110 -1
  14. package/auth-types.js +22 -1
  15. package/auth.d.ts +1 -2
  16. package/auth.js +1 -1
  17. package/automation-connections.d.ts +44 -95
  18. package/automation-connections.js +3 -4
  19. package/automation-connectors.d.ts +10 -20
  20. package/automation-connectors.js +3 -4
  21. package/automations.d.ts +54 -112
  22. package/automations.js +3 -4
  23. package/automl-deployments.d.ts +17 -36
  24. package/automl-deployments.js +3 -4
  25. package/automl-predictions.d.ts +12 -24
  26. package/automl-predictions.js +3 -4
  27. package/banners.d.ts +8 -14
  28. package/banners.js +3 -4
  29. package/brands.d.ts +19 -39
  30. package/brands.js +3 -4
  31. package/chunks/auth-B8lJw7rm.js +31 -0
  32. package/chunks/{interceptors-DipDBQQ5.js → boot-interceptors-DqRxTczb.js} +296 -248
  33. package/chunks/{chunk-D3vHIbds.js → chunk-BdHzlgOL.js} +3 -3
  34. package/chunks/{invoke-fetch-B7lGscuQ.js → invoke-fetch-DMAi6Fg3.js} +3 -3
  35. package/chunks/{invoke-fetch-DhdyFZ0F.js → invoke-fetch-pMN6iqup.js} +2 -3
  36. package/chunks/platform-types-CECrZkOF.d.ts +29 -0
  37. package/chunks/{public-runtime-modules-QhLPeQr5.js → public-runtime-modules-2KfyI2qM.js} +5 -5
  38. package/chunks/{qix-RCUslia8.js → qix-BdNrIA4s.js} +19 -20
  39. package/chunks/{qix-chunk-entrypoint-WAS4NVTf.js → qix-chunk-entrypoint-L9RpWwLK.js} +52 -58
  40. package/chunks/{qix-CrqXv44x.d.ts → qix-types-y_di0roE.d.ts} +33 -115
  41. package/collections.d.ts +67 -144
  42. package/collections.js +3 -4
  43. package/conditions.d.ts +87 -190
  44. package/conditions.js +3 -4
  45. package/consumption.d.ts +35 -72
  46. package/consumption.js +3 -4
  47. package/core/ip-policies.d.ts +43 -93
  48. package/core/ip-policies.js +5 -6
  49. package/core.d.ts +1 -2
  50. package/core.js +5 -6
  51. package/csp-origins.d.ts +42 -85
  52. package/csp-origins.js +3 -4
  53. package/csrf-token.d.ts +6 -11
  54. package/csrf-token.js +3 -4
  55. package/data-alerts.d.ts +152 -325
  56. package/data-alerts.js +3 -4
  57. package/data-assets.d.ts +16 -31
  58. package/data-assets.js +3 -4
  59. package/data-connections.d.ts +123 -257
  60. package/data-connections.js +3 -4
  61. package/data-credentials.d.ts +36 -76
  62. package/data-credentials.js +3 -4
  63. package/data-files.d.ts +60 -121
  64. package/data-files.js +3 -4
  65. package/data-governance/data-products.d.ts +429 -0
  66. package/data-governance/data-products.js +212 -0
  67. package/data-governance.d.ts +13 -0
  68. package/data-governance.js +12 -0
  69. package/data-qualities.d.ts +11 -25
  70. package/data-qualities.js +3 -4
  71. package/data-sets.d.ts +28 -57
  72. package/data-sets.js +3 -4
  73. package/data-sources.d.ts +45 -97
  74. package/data-sources.js +3 -4
  75. package/data-stores.d.ts +53 -107
  76. package/data-stores.js +3 -4
  77. package/dcaas.d.ts +32 -67
  78. package/dcaas.js +3 -4
  79. package/di-projects.d.ts +111 -136
  80. package/di-projects.js +25 -4
  81. package/direct-access-agents.d.ts +29 -63
  82. package/direct-access-agents.js +3 -4
  83. package/encryption.d.ts +28 -59
  84. package/encryption.js +3 -4
  85. package/extensions.d.ts +35 -73
  86. package/extensions.js +3 -4
  87. package/global-types.d.ts +139 -1
  88. package/glossaries.d.ts +75 -158
  89. package/glossaries.js +3 -4
  90. package/groups.d.ts +58 -125
  91. package/groups.js +3 -4
  92. package/identity-providers.d.ts +148 -324
  93. package/identity-providers.js +3 -4
  94. package/index.d.ts +18 -4
  95. package/index.js +64 -19
  96. package/interceptors.d.ts +2 -3
  97. package/interceptors.js +104 -2
  98. package/invoke-fetch-types.d.ts +97 -1
  99. package/items.d.ts +85 -181
  100. package/items.js +3 -4
  101. package/knowledgebases.d.ts +137 -270
  102. package/knowledgebases.js +3 -4
  103. package/licenses.d.ts +71 -153
  104. package/licenses.js +3 -4
  105. package/lineage-graphs.d.ts +39 -85
  106. package/lineage-graphs.js +3 -4
  107. package/ml.d.ts +290 -621
  108. package/ml.js +3 -4
  109. package/notes.d.ts +9 -18
  110. package/notes.js +3 -4
  111. package/notifications.d.ts +14 -30
  112. package/notifications.js +3 -4
  113. package/oauth-clients.d.ts +98 -159
  114. package/oauth-clients.js +4 -5
  115. package/oauth-tokens.d.ts +16 -33
  116. package/oauth-tokens.js +3 -4
  117. package/package.json +6 -4
  118. package/qix.d.ts +46 -2
  119. package/qix.js +2 -3
  120. package/questions.d.ts +53 -110
  121. package/questions.js +3 -4
  122. package/quotas.d.ts +13 -26
  123. package/quotas.js +3 -4
  124. package/reload-tasks.d.ts +23 -46
  125. package/reload-tasks.js +3 -4
  126. package/reloads.d.ts +26 -52
  127. package/reloads.js +3 -4
  128. package/report-templates.d.ts +30 -63
  129. package/report-templates.js +3 -4
  130. package/reports.d.ts +111 -238
  131. package/reports.js +3 -4
  132. package/roles.d.ts +36 -77
  133. package/roles.js +3 -4
  134. package/sharing-tasks.d.ts +201 -427
  135. package/sharing-tasks.js +3 -4
  136. package/spaces.d.ts +71 -157
  137. package/spaces.js +3 -4
  138. package/tasks.d.ts +76 -164
  139. package/tasks.js +3 -4
  140. package/temp-contents.d.ts +17 -35
  141. package/temp-contents.js +3 -4
  142. package/tenant-settings.d.ts +298 -0
  143. package/tenant-settings.js +107 -0
  144. package/tenants.d.ts +31 -67
  145. package/tenants.js +3 -4
  146. package/themes.d.ts +27 -55
  147. package/themes.js +3 -4
  148. package/transports.d.ts +46 -106
  149. package/transports.js +3 -4
  150. package/ui-config.d.ts +8 -17
  151. package/ui-config.js +3 -4
  152. package/users.d.ts +80 -170
  153. package/users.js +3 -4
  154. package/web-integrations.d.ts +38 -83
  155. package/web-integrations.js +3 -4
  156. package/web-notifications.d.ts +14 -29
  157. package/web-notifications.js +3 -4
  158. package/webhooks.d.ts +77 -162
  159. package/webhooks.js +3 -4
  160. package/chunks/auth-BowS4SUR.js +0 -28
  161. package/chunks/auth-types-YrlH_R9f.d.ts +0 -416
  162. package/chunks/auth-types-h43TVDpB.js +0 -24
  163. package/chunks/global-types-CEVAJebk.js +0 -1
  164. /package/chunks/{dist-n3iOVn1W.js → dist-DR758NU5.js} +0 -0
  165. /package/chunks/{invoke-fetch-C1Z0RJYU.d.ts → invoke-fetch-DFc3yzaj.d.ts} +0 -0
  166. /package/chunks/{utils-vv-xFm06.js → utils-jkpLuYZR.js} +0 -0
  167. /package/chunks/{websocket-errors-CRTDTtBL.js → websocket-errors-C5U1tba-.js} +0 -0
@@ -1,9 +1,10 @@
1
- import { a as sortKeys, i as isNode, r as isBrowser, t as cleanFalsyValues } from "./utils-vv-xFm06.js";
2
- import { n as hostConfigCommonProperties, t as authTypesThatCanBeOmitted } from "./auth-types-h43TVDpB.js";
1
+ import { a as sortKeys, i as isNode, r as isBrowser, t as cleanFalsyValues } from "./utils-jkpLuYZR.js";
2
+ import { authTypesThatCanBeOmitted, hostConfigCommonProperties } from "../auth-types.js";
3
+ import { getInterceptors } from "../interceptors.js";
3
4
 
4
5
  //#region src/platform/platform-functions.ts
5
6
  const getPlatform = async (options = {}) => {
6
- const hc = withResolvedHostConfig(options.hostConfig);
7
+ const hc = resolveHostConfig(options.hostConfig);
7
8
  if (hc.authType === "mock-backend-rest-recorder") return hc.recordGetPlatform();
8
9
  if (hc?.authType === "mock-backend") return hc.mockGetPlatform();
9
10
  if (hc?.authType === "noauth") return result({ isUnknown: true });
@@ -137,9 +138,9 @@ const HEX_ALPHABET = "0123456789abcdef";
137
138
  function generateRandomFromAlphabet(alphabet, length) {
138
139
  const bytes = new Uint8Array(length);
139
140
  globalThis.crypto.getRandomValues(bytes);
140
- let result$1 = "";
141
- for (let i = 0; i < length; i++) result$1 += alphabet[bytes[i] % alphabet.length];
142
- return result$1;
141
+ let result = "";
142
+ for (let i = 0; i < length; i++) result += alphabet[bytes[i] % alphabet.length];
143
+ return result;
143
144
  }
144
145
  /**
145
146
  * Method helper for generating a random string [a-zA-Z0-9\-_]{length}
@@ -156,6 +157,154 @@ function generateRandomHexString(targetLength) {
156
157
  return generateRandomFromAlphabet(HEX_ALPHABET, targetLength);
157
158
  }
158
159
 
160
+ //#endregion
161
+ //#region src/auth/internal/host-config-functions.ts
162
+ const emptyHostConfig = {};
163
+ const normalizedHostConfigs = /* @__PURE__ */ new Map();
164
+ /**
165
+ * Returns a new host config with all default and falsy values removed.
166
+ * @param hostConfig - The host config to fill with defaults
167
+ * @returns
168
+ */
169
+ function removeDefaults(hostConfig) {
170
+ const cleanedHostConfig = cleanFalsyValues(hostConfig) || {};
171
+ if (cleanedHostConfig.host) cleanedHostConfig.host = toValidLocationUrl(cleanedHostConfig);
172
+ if (isBrowser()) {
173
+ if (toValidLocationUrl(cleanedHostConfig) === window.location.origin) delete cleanedHostConfig.host;
174
+ }
175
+ if (cleanedHostConfig.authType && authTypesThatCanBeOmitted.includes(cleanedHostConfig.authType)) delete cleanedHostConfig.authType;
176
+ return cleanedHostConfig;
177
+ }
178
+ function globalReplacer(key, value) {
179
+ if (typeof value === "function") return;
180
+ return value;
181
+ }
182
+ /**
183
+ * Serializes the provided hostConfig, if present, otherwise the default one.
184
+ */
185
+ function serializeHostConfig$1(hostConfig) {
186
+ const sorted = sortKeys(removeDefaults(resolveHostConfig(hostConfig)));
187
+ return JSON.stringify(sorted, globalReplacer);
188
+ }
189
+ const registeredHostConfigs = /* @__PURE__ */ new Map();
190
+ /**
191
+ * Registers a host config with the given name.
192
+ * @param name The name of the host config to be used to reference the host config later.
193
+ * @param hostConfig The host config to register.
194
+ */
195
+ function registerHostConfig$1(name, hostConfig) {
196
+ const reference = hostConfig?.reference || null;
197
+ if (reference && !registeredHostConfigs.has(reference)) throw new InvalidHostConfigError(`Host config with reference "${reference}" is not registered. Please register it before using it.`);
198
+ if (registeredHostConfigs.has(name)) console.warn(`registerHostConfig: Host config with name "${name}" is already registered. Overwriting.`);
199
+ registeredHostConfigs.set(name, hostConfig);
200
+ }
201
+ /**
202
+ * Unregisters a host config with the given name.
203
+ * @param name The name of the host config to unregister.
204
+ */
205
+ function unregisterHostConfig$1(name) {
206
+ if (registeredHostConfigs.has(name)) registeredHostConfigs.delete(name);
207
+ else console.warn(`unregisterHostConfig: Host config with name "${name}" not found.`);
208
+ }
209
+ /**
210
+ * Gets the host config with the given name.
211
+ * @private
212
+ * @param name The name of the host config to get.
213
+ * @returns The host config, or undefined if not found.
214
+ */
215
+ function getRegisteredHostConfig(name) {
216
+ return registeredHostConfigs.get(name);
217
+ }
218
+ /**
219
+ * Sets the default host config that will be used for all api calls that do not include a HostConfig
220
+ * @private
221
+ * @param hostConfig the default HostConfig to use
222
+ */
223
+ function setDefaultHostConfig$1(hostConfig) {
224
+ registerHostConfig$1("default", hostConfig || {});
225
+ }
226
+ /**
227
+ * Gets the default host config that will be used for all qmfe api calls that do not include a HostConfig.
228
+ * @private
229
+ * @returns The default host config that will be used for all qmfe api calls that do not include a HostConfig
230
+ */
231
+ function getDefaultHostConfig$1() {
232
+ return getRegisteredHostConfig("default") || {};
233
+ }
234
+ function normalizeHostConfig$1(hostConfig) {
235
+ const suppliedHostConfigOrEmpty = hostConfig || emptyHostConfig;
236
+ const serializedHostConfigKey = serializeHostConfig$1(suppliedHostConfigOrEmpty);
237
+ let normalizedHostConfig = normalizedHostConfigs.get(serializedHostConfigKey);
238
+ if (!normalizedHostConfig) {
239
+ normalizedHostConfig = removeDefaults(resolveHostConfig(suppliedHostConfigOrEmpty));
240
+ normalizedHostConfigs.set(serializedHostConfigKey, normalizedHostConfig);
241
+ }
242
+ return normalizedHostConfig;
243
+ }
244
+
245
+ //#endregion
246
+ //#region src/auth/internal/page-redirect-request-listeners.ts
247
+ /**
248
+ * A store containing all listener registries for different host configurations.
249
+ */
250
+ const listenerRegistries$1 = /* @__PURE__ */ new Map();
251
+ /**
252
+ * Retrieves the listener registry for a given host configuration, creating one if it doesn't exist.
253
+ */
254
+ function getRegistryForHostConfig(hostConfig) {
255
+ const key = serializeHostConfig$1(hostConfig);
256
+ let registry = listenerRegistries$1.get(key);
257
+ if (!registry) {
258
+ registry = {
259
+ redirectRequestedListeners: /* @__PURE__ */ new Set(),
260
+ redirectStartedListeners: /* @__PURE__ */ new Set()
261
+ };
262
+ listenerRegistries$1.set(key, registry);
263
+ }
264
+ return registry;
265
+ }
266
+ /**
267
+ * Registers a listener for page redirects requested by auth modules.
268
+ * @param hostConfig
269
+ * @param listener
270
+ * @returns
271
+ */
272
+ function onPageRedirectRequested$1(hostConfig, listener) {
273
+ const registry = getRegistryForHostConfig(hostConfig);
274
+ registry.redirectRequestedListeners.add(listener);
275
+ return () => {
276
+ registry.redirectRequestedListeners.delete(listener);
277
+ };
278
+ }
279
+ function onPageRedirectStarted$1(hostConfig, listener) {
280
+ const registry = getRegistryForHostConfig(hostConfig);
281
+ registry.redirectStartedListeners.add(listener);
282
+ return () => {
283
+ registry.redirectStartedListeners.delete(listener);
284
+ };
285
+ }
286
+ function requestRedirect(hostConfig) {
287
+ const registry = getRegistryForHostConfig(hostConfig);
288
+ const hasRedirectListener = registry.redirectRequestedListeners.size > 0 || hostConfig.authRedirectUserConfirmation;
289
+ if (hostConfig.autoRedirect || !hasRedirectListener) return Promise.resolve();
290
+ if (typeof hostConfig.authRedirectUserConfirmation === "function") return hostConfig.authRedirectUserConfirmation().catch(() => {});
291
+ return new Promise((resolve) => {
292
+ const proceed = () => {
293
+ for (const startedListener of registry.redirectStartedListeners) try {
294
+ startedListener();
295
+ } catch (error) {
296
+ console.warn(error);
297
+ }
298
+ resolve();
299
+ };
300
+ for (const requestListener of registry.redirectRequestedListeners) try {
301
+ requestListener({ proceed });
302
+ } catch (error) {
303
+ console.warn(error);
304
+ }
305
+ });
306
+ }
307
+
159
308
  //#endregion
160
309
  //#region src/utils/expose-internal-test-apis.ts
161
310
  function exposeInternalApiOnWindow(name, fn) {
@@ -218,9 +367,9 @@ function deleteFromSessionStorage(topic, names) {
218
367
  }
219
368
  function loadAndDeleteFromSessionStorage(topic, name) {
220
369
  const id = `${storagePrefix}-${topic}-${name}`;
221
- const result$1 = sessionStorage.getItem(id) || void 0;
370
+ const result = sessionStorage.getItem(id) || void 0;
222
371
  sessionStorage.removeItem(id);
223
- return result$1;
372
+ return result;
224
373
  }
225
374
  function loadOauthTokensFromStorage(topic, accessTokenStorage) {
226
375
  let accessToken;
@@ -297,8 +446,8 @@ function toPerformInteractiveLoginFunction(performInteractiveLogin) {
297
446
  }
298
447
  return performInteractiveLogin;
299
448
  }
300
- function lookupGetAccessFn(getAccessToken$1) {
301
- return globalThis[getAccessToken$1];
449
+ function lookupGetAccessFn(getAccessToken) {
450
+ return globalThis[getAccessToken];
302
451
  }
303
452
  function lookupInteractiveLoginFn(name) {
304
453
  return globalThis[name];
@@ -312,13 +461,13 @@ function toQueryString(queryParams) {
312
461
  return queryParamsKeys.map((k) => `${k}=${queryParams[k]}`).join("&");
313
462
  }
314
463
  function byteArrayToBase64(hashArray) {
315
- let result$1 = "";
464
+ let result = "";
316
465
  if (isBrowser()) {
317
466
  const byteArrayToString = String.fromCharCode.apply(null, hashArray);
318
- result$1 = btoa(byteArrayToString);
319
- } else if (isNode()) result$1 = Buffer.from(hashArray).toString("base64");
467
+ result = btoa(byteArrayToString);
468
+ } else if (isNode()) result = Buffer.from(hashArray).toString("base64");
320
469
  else throw new Error("Environment not supported for oauth2 authentication");
321
- return result$1;
470
+ return result;
322
471
  }
323
472
  /**
324
473
  * @param message string to hash
@@ -502,16 +651,16 @@ async function getOAuthTokensForBrowser(hostConfig) {
502
651
  if (hostConfig.performInteractiveLogin) {
503
652
  let usedRedirectUri;
504
653
  try {
505
- const verifier$1 = generateRandomString(128);
654
+ const verifier = generateRandomString(128);
506
655
  const originalState = generateRandomString(43);
507
- const { code: code$1, state } = extractCodeAndState(await toPerformInteractiveLoginFunction(hostConfig.performInteractiveLogin)({ getLoginUrl: async ({ redirectUri }) => {
656
+ const { code, state } = extractCodeAndState(await toPerformInteractiveLoginFunction(hostConfig.performInteractiveLogin)({ getLoginUrl: async ({ redirectUri }) => {
508
657
  usedRedirectUri = redirectUri;
509
- return createInteractiveLoginUrl(hostConfig, redirectUri, originalState, verifier$1);
658
+ return createInteractiveLoginUrl(hostConfig, redirectUri, originalState, verifier);
510
659
  } }));
511
660
  if (!usedRedirectUri) return errorMessageToAuthData("No redirect uri provided");
512
661
  if (originalState !== state) return errorMessageToAuthData("State returned by custom interactive login function does not match original");
513
- if (!code$1) return errorMessageToAuthData("No code found in response from custom interactive login function");
514
- return await exchangeCodeAndVerifierForAccessTokenData(hostConfig, code$1, verifier$1, usedRedirectUri);
662
+ if (!code) return errorMessageToAuthData("No code found in response from custom interactive login function");
663
+ return await exchangeCodeAndVerifierForAccessTokenData(hostConfig, code, verifier, usedRedirectUri);
515
664
  } catch (error) {
516
665
  return {
517
666
  accessToken: void 0,
@@ -535,7 +684,7 @@ async function getOAuthTokensForBrowser(hostConfig) {
535
684
  });
536
685
  if (oauthTokens) return oauthTokens;
537
686
  if (hostConfig.performInteractiveLogin) return new Promise(() => {});
538
- if (hostConfig.authRedirectUserConfirmation) await hostConfig.authRedirectUserConfirmation();
687
+ await requestRedirect(hostConfig);
539
688
  startFullPageLoginFlow(hostConfig);
540
689
  return new Promise(() => {});
541
690
  }
@@ -810,11 +959,11 @@ function encodeQueryParams(query) {
810
959
  * @private
811
960
  */
812
961
  function applyPathVariables(pathTemplate, pathVariables) {
813
- let result$1 = pathTemplate;
962
+ let result = pathTemplate;
814
963
  if (pathVariables) Object.keys(pathVariables).forEach((key) => {
815
- result$1 = result$1.replace(`{${key}}`, pathVariables[key]);
964
+ result = result.replace(`{${key}}`, pathVariables[key]);
816
965
  });
817
- return result$1;
966
+ return result;
818
967
  }
819
968
  /**
820
969
  * Join url and query to a complete url
@@ -888,6 +1037,7 @@ async function invokeXHR(completeUrl, { method, headers, credentials, keepalive,
888
1037
  //#region src/invoke-fetch/internal/response-cache.ts
889
1038
  const responseCaches = {};
890
1039
  globalThis.__API_CACHE__DO_NOT_USE_OR_YOU_WILL_BE_FIRED = responseCaches;
1040
+ if (globalThis.QlikMain?.INTERNAL__DO_NOT_USE) globalThis.QlikMain.INTERNAL__DO_NOT_USE.apiCache = responseCaches;
891
1041
  let defaultCacheTime = 1e3 * 60 * 10;
892
1042
  /**
893
1043
  * The global namespace is used as a fallback if an entry is not found in a specific cache.
@@ -1045,14 +1195,14 @@ function clone(value) {
1045
1195
  */
1046
1196
  function cloneResultPromise(value) {
1047
1197
  return value.then((resp) => {
1048
- const result$1 = {
1198
+ const result = {
1049
1199
  data: clone(resp.data),
1050
1200
  headers: resp.headers,
1051
1201
  status: resp.status
1052
1202
  };
1053
- if (resp.next) result$1.next = resp.next;
1054
- if (resp.prev) result$1.prev = resp.prev;
1055
- return result$1;
1203
+ if (resp.next) result.next = resp.next;
1204
+ if (resp.prev) result.prev = resp.prev;
1205
+ return result;
1056
1206
  });
1057
1207
  }
1058
1208
  /**
@@ -1323,10 +1473,10 @@ function getServiceOverrideHeaderFromLocalStorage() {
1323
1473
  }
1324
1474
  /** Convert a Blob to a DownloadableBlob */
1325
1475
  function toDownloadableBlob(blob, name) {
1326
- const result$1 = blob;
1327
- if (name) result$1.download = (filename = name) => download(blob, filename);
1328
- else result$1.download = (filename) => download(blob, filename);
1329
- return result$1;
1476
+ const result = blob;
1477
+ if (name) result.download = (filename = name) => download(blob, filename);
1478
+ else result.download = (filename) => download(blob, filename);
1479
+ return result;
1330
1480
  }
1331
1481
  /** Convenience-function for downloading a blob. */
1332
1482
  async function download(blob, filename) {
@@ -1352,8 +1502,8 @@ const defaultUserAgent = "qmfe-api/latest";
1352
1502
  * @param api Name of api to call. Will be used for caching responses.
1353
1503
  * @param invokeFetchProps InvokeFetchProperties
1354
1504
  */
1355
- async function invokeFetch(api, props, interceptors$1) {
1356
- const effectiveInterceptors = interceptors$1 || getInterceptors();
1505
+ async function invokeFetch(api, props, interceptors) {
1506
+ const effectiveInterceptors = interceptors || getInterceptors();
1357
1507
  const invokeFetchFinal = (reqeust) => invokeFetchIntercepted(api, reqeust);
1358
1508
  return (effectiveInterceptors || []).reduce((proceed, interceptor) => (request) => interceptor(request, proceed), invokeFetchFinal)(props);
1359
1509
  }
@@ -1516,16 +1666,16 @@ function internalGetCredentialsForCookieAuth(hostConfig) {
1516
1666
  if (isHostCrossOrigin(hostConfig)) return "include";
1517
1667
  return "same-origin";
1518
1668
  }
1519
- async function resolveTokenIfPresent(getAccessToken$1) {
1520
- if (typeof getAccessToken$1 === "function") return getAccessToken$1();
1521
- if (typeof getAccessToken$1 === "string") {
1522
- const accessTokenFn = lookupGlobalGetAccessTokenFn(getAccessToken$1);
1523
- if (typeof accessTokenFn !== "function") throw new Error(`getAccessToken function "${getAccessToken$1}" not found on globalThis. Please make sure it is defined.`);
1669
+ async function resolveTokenIfPresent(getAccessToken) {
1670
+ if (typeof getAccessToken === "function") return getAccessToken();
1671
+ if (typeof getAccessToken === "string") {
1672
+ const accessTokenFn = lookupGlobalGetAccessTokenFn(getAccessToken);
1673
+ if (typeof accessTokenFn !== "function") throw new Error(`getAccessToken function "${getAccessToken}" not found on globalThis. Please make sure it is defined.`);
1524
1674
  return accessTokenFn();
1525
1675
  }
1526
1676
  }
1527
- function lookupGlobalGetAccessTokenFn(getAccessToken$1) {
1528
- return globalThis[getAccessToken$1];
1677
+ function lookupGlobalGetAccessTokenFn(getAccessToken) {
1678
+ return globalThis[getAccessToken];
1529
1679
  }
1530
1680
 
1531
1681
  //#endregion
@@ -1565,7 +1715,7 @@ async function handleAuthenticationError$7({ hostConfig, status }) {
1565
1715
  };
1566
1716
  const webIntegrationParam = hostConfig.webIntegrationId ? `qlik-web-integration-id=${hostConfig?.webIntegrationId}&` : "";
1567
1717
  const locationUrl = toValidLocationUrl(hostConfig);
1568
- if (hostConfig.authRedirectUserConfirmation) await hostConfig.authRedirectUserConfirmation();
1718
+ await requestRedirect(hostConfig);
1569
1719
  globalThis.location.replace(`${locationUrl}/login?${webIntegrationParam}returnto=${encodeURIComponent(globalThis.location.href)}`);
1570
1720
  return { preventDefault: true };
1571
1721
  }
@@ -1712,7 +1862,7 @@ async function handleAuthenticationError$4({ hostConfig }) {
1712
1862
  clearStoredOauthTokens(hostConfig);
1713
1863
  return { retry: true };
1714
1864
  }
1715
- if (hostConfig.authRedirectUserConfirmation) await hostConfig.authRedirectUserConfirmation();
1865
+ await requestRedirect(hostConfig);
1716
1866
  startFullPageLoginFlow(hostConfig);
1717
1867
  return { preventDefault: true };
1718
1868
  }
@@ -1770,14 +1920,14 @@ const xrfKeys = {};
1770
1920
  * @returns {string} 16 character long xrf-key
1771
1921
  */
1772
1922
  function createXrfKey() {
1773
- let result$1 = "";
1923
+ let result = "";
1774
1924
  for (let i = 0; i < 16; i += 1) {
1775
1925
  const j = Math.floor(Math.random() * 62);
1776
- if (j < 10) result$1 += j;
1777
- else if (j > 9 && j < 36) result$1 += String.fromCharCode(j + 55);
1778
- else result$1 += String.fromCharCode(j + 61);
1926
+ if (j < 10) result += j;
1927
+ else if (j > 9 && j < 36) result += String.fromCharCode(j + 55);
1928
+ else result += String.fromCharCode(j + 61);
1779
1929
  }
1780
- return result$1;
1930
+ return result;
1781
1931
  }
1782
1932
  function getXrfKey(hostConfig) {
1783
1933
  const locationUrl = toValidLocationUrl(hostConfig);
@@ -1802,7 +1952,7 @@ async function getWebSocketAuthParams$2({ hostConfig }) {
1802
1952
  }
1803
1953
  async function handleAuthenticationError$2({ hostConfig }) {
1804
1954
  if (hostConfig.loginUri) {
1805
- if (hostConfig.authRedirectUserConfirmation) await hostConfig.authRedirectUserConfirmation();
1955
+ await requestRedirect(hostConfig);
1806
1956
  globalThis.location.replace(hostConfig.loginUri.replace("{location}", encodeURIComponent(globalThis.location.href)));
1807
1957
  return { preventDefault: true };
1808
1958
  }
@@ -1968,7 +2118,7 @@ function getRegisteredAuthModule(authType) {
1968
2118
  * @param hostConfig
1969
2119
  */
1970
2120
  async function getAuthModule(hostConfig) {
1971
- const hostConfigToUse = withResolvedHostConfig(hostConfig);
2121
+ const hostConfigToUse = resolveHostConfig(hostConfig);
1972
2122
  const authType = await determineAuthType$1(hostConfigToUse);
1973
2123
  if (ongoingAuthModuleLoading) await ongoingAuthModuleLoading;
1974
2124
  let authModule = getRegisteredAuthModule(authType);
@@ -2093,76 +2243,55 @@ var AuthorizationError = class extends Error {
2093
2243
  };
2094
2244
 
2095
2245
  //#endregion
2096
- //#region src/auth/internal/host-config-functions.ts
2246
+ //#region src/auth/internal/fatal-auth-error-listeners.ts
2247
+ const listenerRegistries = /* @__PURE__ */ new Map();
2248
+ let lastErrorMessage = "";
2249
+ let lastHostConfig;
2097
2250
  /**
2098
- * Returns a new host config with all default and falsy values removed.
2099
- * @param hostConfig - The host config to fill with defaults
2100
- * @returns
2251
+ * Retrieves the listener registry for a given host configuration, creating one if it doesn't exist.
2101
2252
  */
2102
- function removeDefaults(hostConfig) {
2103
- const cleanedHostConfig = cleanFalsyValues(hostConfig) || {};
2104
- if (cleanedHostConfig.host) cleanedHostConfig.host = toValidLocationUrl(cleanedHostConfig);
2105
- if (isBrowser()) {
2106
- if (toValidLocationUrl(cleanedHostConfig) === window.location.origin) delete cleanedHostConfig.host;
2253
+ function getAuthErrorListenerRegistryForHostConfig(hostConfig) {
2254
+ const key = serializeHostConfig$1(hostConfig);
2255
+ let registry = listenerRegistries.get(key);
2256
+ if (!registry) {
2257
+ registry = { listeners: /* @__PURE__ */ new Set() };
2258
+ listenerRegistries.set(key, registry);
2107
2259
  }
2108
- if (cleanedHostConfig.authType && authTypesThatCanBeOmitted.includes(cleanedHostConfig.authType)) delete cleanedHostConfig.authType;
2109
- return cleanedHostConfig;
2110
- }
2111
- function globalReplacer(key, value) {
2112
- if (typeof value === "function") return;
2113
- return value;
2114
- }
2115
- /**
2116
- * Serializes the provided hostConfig, if present, otherwise the default one.
2117
- */
2118
- function serializeHostConfig$1(hostConfig) {
2119
- const sorted = sortKeys(removeDefaults(withResolvedHostConfig(hostConfig)));
2120
- return JSON.stringify(sorted, globalReplacer);
2121
- }
2122
- const registeredHostConfigs = /* @__PURE__ */ new Map();
2123
- /**
2124
- * Registers a host config with the given name.
2125
- * @param name The name of the host config to be used to reference the host config later.
2126
- * @param hostConfig The host config to register.
2127
- */
2128
- function registerHostConfig$1(name, hostConfig) {
2129
- const reference = hostConfig?.reference || null;
2130
- if (reference && !registeredHostConfigs.has(reference)) throw new InvalidHostConfigError(`Host config with reference "${reference}" is not registered. Please register it before using it.`);
2131
- if (registeredHostConfigs.has(name)) console.warn(`registerHostConfig: Host config with name "${name}" is already registered. Overwriting.`);
2132
- registeredHostConfigs.set(name, hostConfig);
2133
- }
2134
- /**
2135
- * Unregisters a host config with the given name.
2136
- * @param name The name of the host config to unregister.
2137
- */
2138
- function unregisterHostConfig$1(name) {
2139
- if (registeredHostConfigs.has(name)) registeredHostConfigs.delete(name);
2140
- else console.warn(`unregisterHostConfig: Host config with name "${name}" not found.`);
2141
- }
2142
- /**
2143
- * Gets the host config with the given name.
2144
- * @private
2145
- * @param name The name of the host config to get.
2146
- * @returns The host config, or undefined if not found.
2147
- */
2148
- function getRegisteredHostConfig(name) {
2149
- return registeredHostConfigs.get(name);
2150
- }
2151
- /**
2152
- * Sets the default host config that will be used for all api calls that do not include a HostConfig
2153
- * @private
2154
- * @param hostConfig the default HostConfig to use
2155
- */
2156
- function setDefaultHostConfig$1(hostConfig) {
2157
- registerHostConfig$1("default", hostConfig || {});
2260
+ return registry;
2261
+ }
2262
+ /**
2263
+ * Emits a fatal authentication error to all registered listeners plus to the onAuthFailed property in the hostConfig.
2264
+ * If there are no listeners or onAuthFailed callback, the error message is logged to the console.
2265
+ */
2266
+ function emitFatalAuthError(hostConfig, normalizedError) {
2267
+ if (hostConfig === lastHostConfig && normalizedError.message === lastErrorMessage) return;
2268
+ lastHostConfig = hostConfig;
2269
+ lastErrorMessage = normalizedError.message;
2270
+ let someOneIsListening = false;
2271
+ const registry = getAuthErrorListenerRegistryForHostConfig(hostConfig);
2272
+ for (const listener of registry.listeners) try {
2273
+ someOneIsListening = true;
2274
+ listener(normalizedError);
2275
+ } catch (listenerError) {
2276
+ console.warn("Error in auth error listener", listenerError);
2277
+ }
2278
+ if (hostConfig.onAuthFailed) try {
2279
+ someOneIsListening = true;
2280
+ hostConfig.onAuthFailed(normalizedError);
2281
+ } catch (callbackError) {
2282
+ console.warn("Error in onAuthFailed callback", callbackError);
2283
+ }
2284
+ if (!someOneIsListening) console.error(normalizedError.message);
2158
2285
  }
2159
2286
  /**
2160
- * Gets the default host config that will be used for all qmfe api calls that do not include a HostConfig.
2161
- * @private
2162
- * @returns The default host config that will be used for all qmfe api calls that do not include a HostConfig
2287
+ * Registers a listener for fatal auth errors. This means errors in the actual auth mechanism, i.e. misconfigurations etc.
2163
2288
  */
2164
- function getDefaultHostConfig$1() {
2165
- return getRegisteredHostConfig("default") || {};
2289
+ function onFatalAuthError$1(hostConfig, callback) {
2290
+ const registry = getAuthErrorListenerRegistryForHostConfig(hostConfig);
2291
+ registry.listeners.add(callback);
2292
+ return () => {
2293
+ registry.listeners.delete(callback);
2294
+ };
2166
2295
  }
2167
2296
 
2168
2297
  //#endregion
@@ -2171,14 +2300,6 @@ function getDefaultHostConfig$1() {
2171
2300
  * Set initial loggingOut value to false to make sure it has a value before any auth module is loaded
2172
2301
  */
2173
2302
  globalThis.loggingOut = false;
2174
- let lastErrorMessage = "";
2175
- /** Default error logger that simply prints the error unless it is identical to the last one (to prevent bloating of the console) */
2176
- function logToConsole({ message }) {
2177
- if (message !== lastErrorMessage) {
2178
- lastErrorMessage = message;
2179
- console.error(message);
2180
- }
2181
- }
2182
2303
  /**
2183
2304
  * Determines the authType associated with a HostConfig even if it's
2184
2305
  * not explicitly set.
@@ -2195,7 +2316,7 @@ function determineAuthType(hostConfig) {
2195
2316
  */
2196
2317
  function isHostCrossOrigin(hostConfig) {
2197
2318
  if (!globalThis.location?.origin) return true;
2198
- const hostConfigToUse = withResolvedHostConfig(hostConfig);
2319
+ const hostConfigToUse = resolveHostConfig(hostConfig);
2199
2320
  if (Object.keys(hostConfigToUse).length === 0) return false;
2200
2321
  try {
2201
2322
  return new URL(toValidLocationUrl(hostConfigToUse)).origin !== globalThis.location.origin;
@@ -2207,7 +2328,7 @@ function isHostCrossOrigin(hostConfig) {
2207
2328
  * @param hostConfig the HostConfig containing authentication details
2208
2329
  */
2209
2330
  async function isWindows(hostConfig) {
2210
- const hostConfigToUse = withResolvedHostConfig(hostConfig);
2331
+ const hostConfigToUse = resolveHostConfig(hostConfig);
2211
2332
  if (typeof hostConfigToUse.forceIsWindows === "boolean") return hostConfigToUse.forceIsWindows;
2212
2333
  if (hostConfigToUse.host?.endsWith(".qlik-stage.com") || hostConfigToUse.host?.endsWith(".qlikcloud.com") || hostConfigToUse.host?.endsWith(".qlikcloudgov.com")) return false;
2213
2334
  if (hostConfigToUse.authType === "cookie") return false;
@@ -2219,7 +2340,7 @@ async function isWindows(hostConfig) {
2219
2340
  * @param hostConfig the HostConfig containing authentication details
2220
2341
  */
2221
2342
  function toValidLocationUrl(hostConfig) {
2222
- const url = withResolvedHostConfig(hostConfig)?.host?.trim();
2343
+ const url = resolveHostConfig(hostConfig)?.host?.trim();
2223
2344
  let locationUrl;
2224
2345
  if (!url) locationUrl = "";
2225
2346
  else if (url.toLowerCase().startsWith("https://") || url.toLowerCase().startsWith("http://")) locationUrl = url;
@@ -2232,7 +2353,7 @@ function toValidLocationUrl(hostConfig) {
2232
2353
  * @param hostConfig the HostConfig containing authentication details
2233
2354
  */
2234
2355
  function toValidWebsocketLocationUrl(hostConfig) {
2235
- const url = withResolvedHostConfig(hostConfig)?.host;
2356
+ const url = resolveHostConfig(hostConfig)?.host;
2236
2357
  let locationUrl;
2237
2358
  if (!url) locationUrl = globalThis.location.origin;
2238
2359
  else if (url.toLowerCase().startsWith("https://") || url.toLowerCase().startsWith("http://")) locationUrl = url;
@@ -2245,14 +2366,14 @@ function toValidWebsocketLocationUrl(hostConfig) {
2245
2366
  * @param hostConfig the HostConfig containing authentication details
2246
2367
  */
2247
2368
  async function getWebSocketAuthParams(props) {
2248
- const hostConfigToUse = withResolvedHostConfig(props.hostConfig);
2369
+ const hostConfigToUse = resolveHostConfig(props.hostConfig);
2249
2370
  try {
2250
2371
  return await (await getAuthModule(hostConfigToUse)).getWebSocketAuthParams({
2251
2372
  ...props,
2252
2373
  hostConfig: hostConfigToUse
2253
2374
  });
2254
2375
  } catch (err) {
2255
- (hostConfigToUse.onAuthFailed || logToConsole)(normalizeAuthModuleError(err));
2376
+ emitFatalAuthError(hostConfigToUse, normalizeAuthModuleError(err));
2256
2377
  throw err;
2257
2378
  }
2258
2379
  }
@@ -2262,14 +2383,14 @@ async function getWebSocketAuthParams(props) {
2262
2383
  * @param hostConfig the HostConfig containing authentication details
2263
2384
  */
2264
2385
  async function getWebResourceAuthParams(props) {
2265
- const hostConfigToUse = withResolvedHostConfig(props.hostConfig);
2386
+ const hostConfigToUse = resolveHostConfig(props.hostConfig);
2266
2387
  try {
2267
2388
  return await (await getAuthModule(hostConfigToUse)).getWebResourceAuthParams?.({
2268
2389
  ...props,
2269
2390
  hostConfig: hostConfigToUse
2270
2391
  }) || { queryParams: {} };
2271
2392
  } catch (err) {
2272
- (hostConfigToUse.onAuthFailed || logToConsole)(normalizeAuthModuleError(err));
2393
+ emitFatalAuthError(hostConfigToUse, normalizeAuthModuleError(err));
2273
2394
  throw err;
2274
2395
  }
2275
2396
  }
@@ -2277,21 +2398,21 @@ async function getWebResourceAuthParams(props) {
2277
2398
  * Calls and return handleAuthenticationError on the authModule a host config is associated with.
2278
2399
  */
2279
2400
  async function handleAuthenticationError(props) {
2280
- const hostConfigToUse = withResolvedHostConfig(props.hostConfig);
2281
- const result$1 = await (await getAuthModule(hostConfigToUse)).handleAuthenticationError({
2401
+ const hostConfigToUse = resolveHostConfig(props.hostConfig);
2402
+ const result = await (await getAuthModule(hostConfigToUse)).handleAuthenticationError({
2282
2403
  ...props,
2283
2404
  hostConfig: hostConfigToUse
2284
2405
  });
2285
- const willRetry = props.canRetry && result$1.retry;
2286
- const willHangUntilANewPageIsLoaded = result$1.preventDefault;
2406
+ const willRetry = props.canRetry && result.retry;
2407
+ const willHangUntilANewPageIsLoaded = result.preventDefault;
2287
2408
  if (!willRetry && !willHangUntilANewPageIsLoaded) {
2288
2409
  const { status, errorBody } = props;
2289
- (hostConfigToUse.onAuthFailed || logToConsole)(normalizeInbandAuthError({
2410
+ emitFatalAuthError(hostConfigToUse, normalizeInbandAuthError({
2290
2411
  status,
2291
2412
  errorBody
2292
2413
  }));
2293
2414
  }
2294
- return result$1;
2415
+ return result;
2295
2416
  }
2296
2417
  /**
2297
2418
  * Returns a record of headers and a record of query params that needs to be added to outgoing rest calls
@@ -2299,14 +2420,14 @@ async function handleAuthenticationError(props) {
2299
2420
  * @param props.method the http method, which may affect what authentication are needed.
2300
2421
  */
2301
2422
  async function getRestCallAuthParams(props) {
2302
- const hostConfigToUse = withResolvedHostConfig(props.hostConfig);
2423
+ const hostConfigToUse = resolveHostConfig(props.hostConfig);
2303
2424
  try {
2304
2425
  return await (await getAuthModule(hostConfigToUse)).getRestCallAuthParams({
2305
2426
  ...props,
2306
2427
  hostConfig: hostConfigToUse
2307
2428
  });
2308
2429
  } catch (err) {
2309
- (hostConfigToUse.onAuthFailed || logToConsole)(normalizeAuthModuleError(err));
2430
+ emitFatalAuthError(hostConfigToUse, normalizeAuthModuleError(err));
2310
2431
  throw err;
2311
2432
  }
2312
2433
  }
@@ -2363,13 +2484,19 @@ function serializeHostConfig(hostConfig) {
2363
2484
  * Throws errors if hostConfig is missing or missing properties on cross domain requests
2364
2485
  */
2365
2486
  function checkForCrossDomainRequest(hostConfig) {
2366
- const hostConfigToUse = withResolvedHostConfig(hostConfig);
2487
+ const hostConfigToUse = resolveHostConfig(hostConfig);
2367
2488
  if (isHostCrossOrigin(hostConfigToUse)) {
2368
2489
  if (Object.keys(hostConfigToUse).length === 0) throw new InvalidHostConfigError("a host config must be provided when making a cross domain request");
2369
2490
  if (!hostConfigToUse.host) throw new InvalidHostConfigError("A 'host' property must be set in host config when making a cross domain request");
2370
2491
  }
2371
2492
  }
2372
2493
  /**
2494
+ * Returns a normalized host config that will always be the same instance when the serialized host config is the same.
2495
+ */
2496
+ function normalizeHostConfig(hostConfig) {
2497
+ return normalizeHostConfig$1(hostConfig);
2498
+ }
2499
+ /**
2373
2500
  * Logs out the user and sets `global.loggingOut` to true.
2374
2501
  * **NOTE**: Does not abort pending requests.
2375
2502
  */
@@ -2400,15 +2527,14 @@ function normalizeAuthModuleError(err) {
2400
2527
  return { message: err.message || "Unknown error" };
2401
2528
  }
2402
2529
  /**
2403
- * Returns a resolved host config. If the host config is a reference to a registered host config, it will be resolved
2404
- * to the actual host config.
2405
- * If the host config is undefined or empty, the default host config will be used.
2406
- * If the host config is not a reference, it will be returned as is.
2407
- * @private
2530
+ * Replaces the supplied host config according the following rules:
2531
+ * * If the host config is a reference to a registered host config, the registered host config will be used.
2532
+ * * If the host config is undefined or empty, the default host config will be returned.
2533
+ * * If the host config is not a reference and not empty or undefined, it will be returned as is.
2534
+ * * If the host config is empty or undefined an empty object (which represents the default cookie mode) is returned.
2408
2535
  * @param hostConfig - The host config to resolve
2409
- * @returns
2410
2536
  */
2411
- function withResolvedHostConfig(hostConfig) {
2537
+ function resolveHostConfig(hostConfig) {
2412
2538
  if (hostConfig?.reference) {
2413
2539
  const refConfig = getRegisteredHostConfig(hostConfig.reference);
2414
2540
  if (!refConfig) throw new InvalidHostConfigError(`Host config with name "${hostConfig.reference}" not found.`);
@@ -2423,6 +2549,30 @@ function withResolvedHostConfig(hostConfig) {
2423
2549
  function getDefaultHostConfig() {
2424
2550
  return getDefaultHostConfig$1();
2425
2551
  }
2552
+ /**
2553
+ * Registers a callback to be invoked when a fatal authentication error occurs for the provided hostConfig.
2554
+ * @param callback The callback function to register
2555
+ * @returns A function to unregister the callback
2556
+ */
2557
+ function onFatalAuthError(hostConfig, callback) {
2558
+ return onFatalAuthError$1(hostConfig, callback);
2559
+ }
2560
+ /**
2561
+ * Registers a listener for page redirect requested by the auth module that is handling authentication for the provided host configuration.
2562
+ * This is typically used when embedded to let the end user explicitly approve a redirect by for instance clicking an "authorize" button. The user can then decide to leave that UI unauthorized
2563
+ * and stay on the page.
2564
+ * The listener is provided a `proceed` function that if called continues the redirect process. Before actually redirecting the page, the onPageRedirectStarted listeners are called.
2565
+ * Note that if more than one listener is registered, it still takes just one proceed call to continue the redirect process so it can not be used to block the redirect.
2566
+ */
2567
+ function onPageRedirectRequested(hostConfig, listener) {
2568
+ return onPageRedirectRequested$1(hostConfig, listener);
2569
+ }
2570
+ /**
2571
+ * Registers a listener that will be called when a page redirect is started by the auth module that is handling authentication for the provided host configuration.
2572
+ */
2573
+ function onPageRedirectStarted(hostConfig, listener) {
2574
+ return onPageRedirectStarted$1(hostConfig, listener);
2575
+ }
2426
2576
 
2427
2577
  //#endregion
2428
2578
  //#region src/interceptors/boot-interceptors.ts
@@ -2513,106 +2663,4 @@ function populateCacheFrom(responses, pathsToInclude, serializedHostConfig, loca
2513
2663
  }
2514
2664
 
2515
2665
  //#endregion
2516
- //#region src/interceptors/interceptors.ts
2517
- let GLOBAL_INTERCEPTORS;
2518
- function createInterceptors() {
2519
- const interceptors$1 = [...GLOBAL_INTERCEPTORS?.getInterceptors() || []];
2520
- return {
2521
- addInterceptor: (interceptor) => {
2522
- interceptors$1.push(interceptor);
2523
- return interceptor;
2524
- },
2525
- removeInterceptor: (interceptor) => {
2526
- const index = interceptors$1.indexOf(interceptor);
2527
- let removed;
2528
- if (index !== -1) removed = interceptors$1.splice(index, 1)[0];
2529
- return removed || null;
2530
- },
2531
- getInterceptors: () => interceptors$1
2532
- };
2533
- }
2534
- let addDefaultInterceptorsRun = false;
2535
- function addDefaultInterceptors() {
2536
- if (addDefaultInterceptorsRun) return;
2537
- if (isBrowser()) {
2538
- const readFlagsFromUrlQuery = () => {
2539
- const featuresParam = new URLSearchParams(window.location.search).get("features");
2540
- if (!featuresParam) return {};
2541
- return featuresParam.split(",").map((item) => item.trim()).reduce((map, obj) => {
2542
- const value = !obj.startsWith("!");
2543
- const key = value ? obj : obj.substring(1);
2544
- map[key] = value;
2545
- return map;
2546
- }, {});
2547
- };
2548
- const readFlagsFromLocalStorage = () => {
2549
- try {
2550
- const featuresParam = localStorage.getItem("qcs-features");
2551
- if (featuresParam) return JSON.parse(featuresParam);
2552
- return {};
2553
- } catch {
2554
- return {};
2555
- }
2556
- };
2557
- const flagsFromUrl = readFlagsFromUrlQuery();
2558
- const flagsFromLocalStorage = readFlagsFromLocalStorage();
2559
- const featuresInterceptor = async (request, proceed) => {
2560
- let resultPromise;
2561
- if (request.pathTemplate === "/api/v1/features") {
2562
- resultPromise = proceed(request);
2563
- const result$1 = await resultPromise;
2564
- return {
2565
- ...result$1,
2566
- data: {
2567
- ...result$1.data || {},
2568
- ...flagsFromLocalStorage,
2569
- ...flagsFromUrl
2570
- }
2571
- };
2572
- }
2573
- return proceed(request);
2574
- };
2575
- GLOBAL_INTERCEPTORS.addInterceptor(featuresInterceptor);
2576
- GLOBAL_INTERCEPTORS.addInterceptor(coreBootInterceptor);
2577
- }
2578
- addDefaultInterceptorsRun = true;
2579
- }
2580
- /**
2581
- * The global interceptor stack
2582
- */
2583
- GLOBAL_INTERCEPTORS = createInterceptors();
2584
- /**
2585
- * Adds an interceptor to the global interceptor stack
2586
- * Returns the newly added interceptor
2587
- * @param interceptor the interceptor to add
2588
- * @returns the newly added interceptor
2589
- */
2590
- function addInterceptor(interceptor) {
2591
- return GLOBAL_INTERCEPTORS.addInterceptor(interceptor);
2592
- }
2593
- /**
2594
- * Removes an interceptor from the global interceptor stack
2595
- * @param interceptor the interceptor remove
2596
- */
2597
- function removeInterceptor(interceptor) {
2598
- return GLOBAL_INTERCEPTORS.removeInterceptor(interceptor);
2599
- }
2600
- /**
2601
- * Gets all registered interceptors
2602
- */
2603
- function getInterceptors() {
2604
- return GLOBAL_INTERCEPTORS.getInterceptors();
2605
- }
2606
- /**
2607
- * The interceptors API
2608
- */
2609
- const interceptors = {
2610
- addInterceptor,
2611
- removeInterceptor,
2612
- getInterceptors,
2613
- createInterceptors
2614
- };
2615
- var interceptors_default = interceptors;
2616
-
2617
- //#endregion
2618
- export { parseFetchResponse as A, unregisterHostConfig as C, UnexpectedAuthTypeError as D, InvalidHostConfigError as E, generateRandomString as F, getPlatform as I, EncodingError as M, InvokeFetchError as N, clearApiCache as O, exposeInternalApiOnWindow as P, toValidWebsocketLocationUrl as S, InvalidAuthTypeError as T, registerAuthModule as _, interceptors_default as a, setDefaultHostConfig as b, getAccessToken as c, getWebResourceAuthParams as d, getWebSocketAuthParams as f, logout as g, isWindows as h, getInterceptors as i, appendQueryToUrl as j, invokeFetch as k, getDefaultHostConfig as l, isHostCrossOrigin as m, addInterceptor as n, removeInterceptor as o, handleAuthenticationError as p, createInterceptors as r, determineAuthType as s, addDefaultInterceptors as t, getRestCallAuthParams as u, registerHostConfig as v, AuthorizationError as w, toValidLocationUrl as x, serializeHostConfig as y };
2666
+ export { appendQueryToUrl as A, AuthorizationError as C, clearApiCache as D, UnexpectedAuthTypeError as E, getPlatform as F, InvokeFetchError as M, exposeInternalApiOnWindow as N, invokeFetch as O, generateRandomString as P, unregisterHostConfig as S, InvalidHostConfigError as T, registerHostConfig as _, getRestCallAuthParams as a, toValidLocationUrl as b, handleAuthenticationError as c, logout as d, normalizeHostConfig as f, registerAuthModule as g, onPageRedirectStarted as h, getDefaultHostConfig as i, EncodingError as j, parseFetchResponse as k, isHostCrossOrigin as l, onPageRedirectRequested as m, determineAuthType as n, getWebResourceAuthParams as o, onFatalAuthError as p, getAccessToken as r, getWebSocketAuthParams as s, coreBootInterceptor as t, isWindows as u, serializeHostConfig as v, InvalidAuthTypeError as w, toValidWebsocketLocationUrl as x, setDefaultHostConfig as y };