@qlik/api 0.0.16 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/api-keys.js +25 -25
- package/apps.d.ts +9 -1
- package/apps.js +97 -97
- package/audits.js +23 -23
- package/auth.js +14 -14
- package/automations.js +47 -47
- package/brands.js +35 -35
- package/chunks/4HB3TAEO.js +4 -4
- package/chunks/{HHOVS7QC.mjs → CHNBNLXY.js} +3 -3
- package/chunks/{3YV6X7S6.mjs → FFGE2RP7.js} +1 -1
- package/chunks/{HOCTJESP.mjs → JEGN7XQV.js} +3 -3
- package/chunks/{6WX5AGKQ.mjs → L2BJNKLV.js} +2 -2
- package/chunks/OPRGGO4C.js +8 -8
- package/chunks/{O4EAKEIN.mjs → RHF624NQ.js} +1 -1
- package/chunks/{BYD63JCG.mjs → SIU6HO6B.js} +5 -3
- package/chunks/{EHAANYDL.mjs → TT66UJZY.js} +3 -3
- package/chunks/{UKVTBYP6.mjs → XOVMZWDC.js} +2 -2
- package/chunks/{6AD3HYSF.mjs → XZQNE4HH.js} +1 -1
- package/collections.js +33 -33
- package/csp-origins.js +23 -23
- package/data-assets.js +21 -21
- package/data-connections.js +29 -29
- package/data-credentials.js +19 -19
- package/data-files.js +35 -35
- package/docs/authentication.md +5 -5
- package/docs/examples/fetch-spaces.md +1 -15
- package/docs/examples/show-sheet-list.md +1 -1
- package/docs/features.md +1 -1
- package/extensions.js +25 -25
- package/glossaries.js +59 -59
- package/groups.d.ts +0 -3
- package/groups.js +27 -27
- package/identity-providers.d.ts +144 -10
- package/identity-providers.js +27 -27
- package/index.js +53 -53
- package/items.js +27 -27
- package/licenses.js +29 -29
- package/package.json +36 -232
- package/qix.d.ts +1 -1
- package/qix.js +10 -10
- package/quotas.js +15 -15
- package/reload-tasks.js +21 -21
- package/reloads.js +19 -19
- package/roles.js +15 -15
- package/spaces.js +35 -35
- package/temp-contents.js +17 -17
- package/tenants.js +23 -23
- package/themes.js +25 -25
- package/transports.js +23 -23
- package/users.d.ts +1 -3
- package/users.js +31 -31
- package/web-integrations.js +21 -21
- package/web-notifications.js +23 -23
- package/webhooks.js +31 -31
- package/api-keys.d.mts +0 -336
- package/api-keys.mjs +0 -80
- package/apps.d.mts +0 -2431
- package/apps.mjs +0 -398
- package/audits.d.mts +0 -286
- package/audits.mjs +0 -64
- package/auth-types-nnUcWhuU.d.mts +0 -98
- package/auth.d.mts +0 -26
- package/auth.mjs +0 -14
- package/automations.d.mts +0 -682
- package/automations.mjs +0 -173
- package/brands.d.mts +0 -670
- package/brands.mjs +0 -123
- package/chunks/2YWCEGTS.js +0 -21
- package/chunks/34ZKUFEA.js +0 -41
- package/chunks/4WHZ4EIW.js +0 -57
- package/chunks/B4VPD3ZT.js +0 -574
- package/chunks/BM4OSDRZ.js +0 -17
- package/chunks/DCXUEDOW.mjs +0 -67
- package/chunks/MTAQE4WC.js +0 -10411
- package/chunks/PLOSYUG2.js +0 -25
- package/chunks/URIW2U5M.js +0 -17
- package/chunks/VSY5YIQY.mjs +0 -11
- package/chunks/WOYJLK4Y.js +0 -1623
- package/collections.d.mts +0 -581
- package/collections.mjs +0 -114
- package/csp-origins.d.mts +0 -273
- package/csp-origins.mjs +0 -69
- package/data-assets.d.mts +0 -205
- package/data-assets.mjs +0 -66
- package/data-connections.d.mts +0 -594
- package/data-connections.mjs +0 -103
- package/data-credentials.d.mts +0 -204
- package/data-credentials.mjs +0 -59
- package/data-files.d.mts +0 -562
- package/data-files.mjs +0 -123
- package/extensions.d.mts +0 -293
- package/extensions.mjs +0 -77
- package/global.types-5iFvFJvX.d.mts +0 -115
- package/glossaries.d.mts +0 -1173
- package/glossaries.mjs +0 -237
- package/groups.d.mts +0 -434
- package/groups.mjs +0 -88
- package/identity-providers.d.mts +0 -550
- package/identity-providers.mjs +0 -83
- package/index.d.mts +0 -142
- package/index.mjs +0 -716
- package/items.d.mts +0 -535
- package/items.mjs +0 -87
- package/licenses.d.mts +0 -459
- package/licenses.mjs +0 -92
- package/qix.d.mts +0 -11629
- package/qix.mjs +0 -10
- package/quotas.d.mts +0 -112
- package/quotas.mjs +0 -32
- package/reload-tasks.d.mts +0 -227
- package/reload-tasks.mjs +0 -62
- package/reloads.d.mts +0 -207
- package/reloads.mjs +0 -46
- package/roles.d.mts +0 -175
- package/roles.mjs +0 -31
- package/spaces.d.mts +0 -562
- package/spaces.mjs +0 -124
- package/temp-contents.d.mts +0 -167
- package/temp-contents.mjs +0 -41
- package/tenants.d.mts +0 -300
- package/tenants.mjs +0 -73
- package/themes.d.mts +0 -268
- package/themes.mjs +0 -77
- package/transports.d.mts +0 -319
- package/transports.mjs +0 -65
- package/users.d.mts +0 -631
- package/users.mjs +0 -104
- package/web-integrations.d.mts +0 -274
- package/web-integrations.mjs +0 -62
- package/web-notifications.d.mts +0 -250
- package/web-notifications.mjs +0 -69
- package/webhooks.d.mts +0 -445
- package/webhooks.mjs +0 -104
package/chunks/WOYJLK4Y.js
DELETED
|
@@ -1,1623 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
var _4HB3TAEOjs = require('./4HB3TAEO.js');
|
|
4
|
-
|
|
5
|
-
// src/platform/platform-functions.ts
|
|
6
|
-
var getPlatform = async (options = {}) => {
|
|
7
|
-
const isNodeEnvironment = typeof window === "undefined";
|
|
8
|
-
if (isNodeEnvironment) {
|
|
9
|
-
return result({ isNodeEnv: true });
|
|
10
|
-
}
|
|
11
|
-
const { data: productInfo, status } = await getProductInfo(options);
|
|
12
|
-
if (status === 404) {
|
|
13
|
-
return result({ isUnknown: true });
|
|
14
|
-
}
|
|
15
|
-
if (!productInfo || status <= 399 && status >= 300) {
|
|
16
|
-
return result({ isQSE: true, isWindows: true });
|
|
17
|
-
}
|
|
18
|
-
const deploymentType = (_optionalChain([productInfo, 'access', _ => _.composition, 'optionalAccess', _2 => _2.deploymentType]) || "").toLowerCase();
|
|
19
|
-
if (deploymentType === "qliksenseserver") {
|
|
20
|
-
return result({ isQSE: true, isWindows: true });
|
|
21
|
-
}
|
|
22
|
-
if (deploymentType === "qliksensedesktop") {
|
|
23
|
-
return result({ isQSD: true, isWindows: true });
|
|
24
|
-
}
|
|
25
|
-
if (_optionalChain([productInfo, 'access', _3 => _3.composition, 'optionalAccess', _4 => _4.provider]) === "fedramp") {
|
|
26
|
-
return result({ isCloud: true, isQCG: true });
|
|
27
|
-
}
|
|
28
|
-
return result({ isCloud: true, isQCS: true });
|
|
29
|
-
};
|
|
30
|
-
var productInfoPromises = {};
|
|
31
|
-
function templateUrl(baseUrl) {
|
|
32
|
-
return `${baseUrl}/resources/autogenerated/product-info.json`;
|
|
33
|
-
}
|
|
34
|
-
var getProductInfo = async ({ hostConfig, noCache } = {}) => {
|
|
35
|
-
const url = toValidLocationUrl(hostConfig);
|
|
36
|
-
const completeUrl = templateUrl(url);
|
|
37
|
-
try {
|
|
38
|
-
if (!(completeUrl in productInfoPromises)) {
|
|
39
|
-
const fetchOptions = {};
|
|
40
|
-
if (globalThis.QlikMain && globalThis.QlikMain.resourceNeedsCredentials(completeUrl)) {
|
|
41
|
-
fetchOptions.credentials = "include";
|
|
42
|
-
}
|
|
43
|
-
const productInfoPromise = fetch(completeUrl, fetchOptions).then(async (res) => {
|
|
44
|
-
if (res.ok) {
|
|
45
|
-
return { data: await res.json(), status: res.status };
|
|
46
|
-
}
|
|
47
|
-
return { data: void 0, status: res.status };
|
|
48
|
-
});
|
|
49
|
-
productInfoPromises[completeUrl] = productInfoPromise;
|
|
50
|
-
}
|
|
51
|
-
const response = await productInfoPromises[completeUrl];
|
|
52
|
-
if (response.status >= 400 || !response.data) {
|
|
53
|
-
delete productInfoPromises[completeUrl];
|
|
54
|
-
}
|
|
55
|
-
return response;
|
|
56
|
-
} catch (err) {
|
|
57
|
-
delete productInfoPromises[completeUrl];
|
|
58
|
-
return { data: void 0, status: 500 };
|
|
59
|
-
} finally {
|
|
60
|
-
if (noCache) {
|
|
61
|
-
delete productInfoPromises[completeUrl];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
var result = (data) => ({
|
|
66
|
-
isNodeEnv: false,
|
|
67
|
-
isCloud: false,
|
|
68
|
-
isQCS: false,
|
|
69
|
-
isQCG: false,
|
|
70
|
-
isWindows: false,
|
|
71
|
-
isQSE: false,
|
|
72
|
-
isQSD: false,
|
|
73
|
-
isUnknown: false,
|
|
74
|
-
...data
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// src/auth/internal/default-host-config.ts
|
|
78
|
-
var defaultHostConfig = {};
|
|
79
|
-
function setDefaultHostConfig(hostConfig) {
|
|
80
|
-
defaultHostConfig = hostConfig || {};
|
|
81
|
-
}
|
|
82
|
-
function withDefaultHostConfig(hostConfig) {
|
|
83
|
-
return hostConfig || defaultHostConfig;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// src/auth/internal/auth-module-registry.ts
|
|
87
|
-
var authModules = {};
|
|
88
|
-
var ongoingAuthModuleLoading = Promise.resolve();
|
|
89
|
-
function registerAuthModule(name, authModule) {
|
|
90
|
-
authModules[name.toLowerCase()] = authModule;
|
|
91
|
-
}
|
|
92
|
-
function getRegisteredAuthModules() {
|
|
93
|
-
return Object.keys(authModules);
|
|
94
|
-
}
|
|
95
|
-
function getRegisteredAuthModule(authType) {
|
|
96
|
-
return authModules[authType.toLowerCase()];
|
|
97
|
-
}
|
|
98
|
-
async function getAuthModule(hostConfig) {
|
|
99
|
-
const hostConfigToUse = withDefaultHostConfig(hostConfig);
|
|
100
|
-
const authType = await guessAuthTypeIfMissing(hostConfigToUse);
|
|
101
|
-
if (ongoingAuthModuleLoading) {
|
|
102
|
-
await ongoingAuthModuleLoading;
|
|
103
|
-
}
|
|
104
|
-
let authModule = getRegisteredAuthModule(authType);
|
|
105
|
-
if (!authModule) {
|
|
106
|
-
ongoingAuthModuleLoading = (async () => {
|
|
107
|
-
authModule = await resolveGloballyDefinedAuthModule(authType);
|
|
108
|
-
if (authModule) {
|
|
109
|
-
registerAuthModule(authType, authModule);
|
|
110
|
-
}
|
|
111
|
-
})();
|
|
112
|
-
await ongoingAuthModuleLoading;
|
|
113
|
-
}
|
|
114
|
-
if (!authModule) {
|
|
115
|
-
throw new InvalidAuthTypeError(authType);
|
|
116
|
-
}
|
|
117
|
-
if (authModule.validateHostConfig) {
|
|
118
|
-
authModule.validateHostConfig({ authType, ...hostConfigToUse });
|
|
119
|
-
}
|
|
120
|
-
return authModule;
|
|
121
|
-
}
|
|
122
|
-
async function guessAuthTypeIfMissing(hostConfig) {
|
|
123
|
-
if (hostConfig.authType) {
|
|
124
|
-
return hostConfig.authType;
|
|
125
|
-
}
|
|
126
|
-
if (hostConfig.apiKey) {
|
|
127
|
-
return "apikey";
|
|
128
|
-
}
|
|
129
|
-
if (hostConfig.clientId) {
|
|
130
|
-
return "oauth2";
|
|
131
|
-
}
|
|
132
|
-
if (hostConfig.webIntegrationId) {
|
|
133
|
-
return "cookie";
|
|
134
|
-
}
|
|
135
|
-
if (await isWindows(hostConfig)) {
|
|
136
|
-
return "windowscookie";
|
|
137
|
-
}
|
|
138
|
-
return "cookie";
|
|
139
|
-
}
|
|
140
|
-
async function resolveGloballyDefinedAuthModule(authType) {
|
|
141
|
-
const globalWindow = globalThis;
|
|
142
|
-
const globalVariable = globalWindow[authType];
|
|
143
|
-
if (globalVariable) {
|
|
144
|
-
let potentialAuthModule;
|
|
145
|
-
if (typeof globalVariable === "function") {
|
|
146
|
-
potentialAuthModule = await globalVariable();
|
|
147
|
-
} else {
|
|
148
|
-
potentialAuthModule = globalVariable;
|
|
149
|
-
}
|
|
150
|
-
if (potentialAuthModule && potentialAuthModule.getRestCallAuthParams && potentialAuthModule.getWebSocketAuthParams && potentialAuthModule.handleAuthenticationError) {
|
|
151
|
-
return potentialAuthModule;
|
|
152
|
-
}
|
|
153
|
-
console.error("Not a valid auth module", potentialAuthModule);
|
|
154
|
-
throw new InvalidAuthTypeError(authType);
|
|
155
|
-
}
|
|
156
|
-
return Promise.resolve(void 0);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// src/auth/auth-errors.ts
|
|
160
|
-
var InvalidHostConfigError = class extends Error {
|
|
161
|
-
constructor(message) {
|
|
162
|
-
super(`Invalid host config: ${message}`);
|
|
163
|
-
this.name = "InvalidHostConfigError";
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
var UnexpectedAuthTypeError = class extends Error {
|
|
167
|
-
constructor(...expectedAuthTypes) {
|
|
168
|
-
const ors = expectedAuthTypes.map((item, index) => index === 0 ? `"${item}"` : `or "${item}"`).join(" ");
|
|
169
|
-
super(`HostConfig is not properly configured. authType is expected to be ${ors}`);
|
|
170
|
-
this.name = "UnexpectedAuthTypeError";
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
var InvalidAuthTypeError = class extends Error {
|
|
174
|
-
constructor(authType) {
|
|
175
|
-
const validAuthModules = getRegisteredAuthModules();
|
|
176
|
-
super(
|
|
177
|
-
`Not a valid auth type: ${authType}, valid auth types are; '${validAuthModules.filter((name) => name !== "QmfeEmbedFramerAuthModule").join("', '")}'`
|
|
178
|
-
);
|
|
179
|
-
this.name = "InvalidAuthTypeError";
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
var AuthorizationError = class extends Error {
|
|
183
|
-
constructor(errors) {
|
|
184
|
-
const errorArray = Array.isArray(errors) ? errors : [errors];
|
|
185
|
-
super(
|
|
186
|
-
errorArray.map(
|
|
187
|
-
(error) => `
|
|
188
|
-
Code: ${error.code}
|
|
189
|
-
Status: ${error.status}
|
|
190
|
-
${error.title}:
|
|
191
|
-
${error.detail}
|
|
192
|
-
`
|
|
193
|
-
).join(",\n")
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
// src/auth/auth-functions.ts
|
|
199
|
-
function isHostCrossOrigin(hostConfig) {
|
|
200
|
-
if (!_optionalChain([globalThis, 'access', _5 => _5.location, 'optionalAccess', _6 => _6.origin])) {
|
|
201
|
-
return true;
|
|
202
|
-
}
|
|
203
|
-
const hostConfigToUse = withDefaultHostConfig(hostConfig);
|
|
204
|
-
if (Object.keys(hostConfigToUse).length === 0) {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
try {
|
|
208
|
-
const locationUrl = new URL(toValidLocationUrl(hostConfigToUse));
|
|
209
|
-
return locationUrl.origin !== globalThis.location.origin;
|
|
210
|
-
} catch (e2) {
|
|
211
|
-
}
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
async function isWindows(hostConfig) {
|
|
215
|
-
const hostConfigToUse = withDefaultHostConfig(hostConfig);
|
|
216
|
-
if (hostConfigToUse.authType === "cookie") {
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
if (hostConfigToUse.authType === "windowscookie") {
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
return (await getPlatform({ hostConfig })).isWindows;
|
|
223
|
-
}
|
|
224
|
-
function toValidLocationUrl(hostConfig) {
|
|
225
|
-
const url = _optionalChain([withDefaultHostConfig, 'call', _7 => _7(hostConfig), 'optionalAccess', _8 => _8.host]);
|
|
226
|
-
let locationUrl;
|
|
227
|
-
if (!url) {
|
|
228
|
-
locationUrl = "";
|
|
229
|
-
} else if (url.toLowerCase().startsWith("https://") || url.toLowerCase().startsWith("http://")) {
|
|
230
|
-
locationUrl = url;
|
|
231
|
-
} else {
|
|
232
|
-
locationUrl = `https://${url}`;
|
|
233
|
-
}
|
|
234
|
-
while (locationUrl[locationUrl.length - 1] === "/") {
|
|
235
|
-
locationUrl = locationUrl.substring(0, locationUrl.length - 1);
|
|
236
|
-
}
|
|
237
|
-
return locationUrl;
|
|
238
|
-
}
|
|
239
|
-
function toValidEnigmaLocationUrl(hostConfig) {
|
|
240
|
-
return toValidWebsocketLocationUrl(hostConfig);
|
|
241
|
-
}
|
|
242
|
-
function toValidWebsocketLocationUrl(hostConfig) {
|
|
243
|
-
const url = _optionalChain([withDefaultHostConfig, 'call', _9 => _9(hostConfig), 'optionalAccess', _10 => _10.host]);
|
|
244
|
-
let locationUrl;
|
|
245
|
-
if (!url) {
|
|
246
|
-
locationUrl = globalThis.location.origin;
|
|
247
|
-
} else if (url.toLowerCase().startsWith("https://") || url.toLowerCase().startsWith("http://")) {
|
|
248
|
-
locationUrl = url;
|
|
249
|
-
} else {
|
|
250
|
-
locationUrl = `https://${url}`;
|
|
251
|
-
}
|
|
252
|
-
while (locationUrl[locationUrl.length - 1] === "/") {
|
|
253
|
-
locationUrl = locationUrl.substring(0, locationUrl.length - 1);
|
|
254
|
-
}
|
|
255
|
-
return locationUrl.replace(leadingHttp, "ws");
|
|
256
|
-
}
|
|
257
|
-
async function getWebSocketAuthParams(props) {
|
|
258
|
-
const hostConfigToUse = withDefaultHostConfig(props.hostConfig);
|
|
259
|
-
return (await getAuthModule(hostConfigToUse)).getWebSocketAuthParams({
|
|
260
|
-
...props,
|
|
261
|
-
hostConfig: hostConfigToUse
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
async function getWebResourceAuthParams(props) {
|
|
265
|
-
const hostConfigToUse = withDefaultHostConfig(props.hostConfig);
|
|
266
|
-
return await _asyncOptionalChain([(await getAuthModule(hostConfigToUse)), 'access', async _11 => _11.getWebResourceAuthParams, 'optionalCall', async _12 => _12({
|
|
267
|
-
...props,
|
|
268
|
-
hostConfig: hostConfigToUse
|
|
269
|
-
})]) || { queryParams: {} };
|
|
270
|
-
}
|
|
271
|
-
async function handleAuthenticationError(props) {
|
|
272
|
-
const hostConfigToUse = withDefaultHostConfig(props.hostConfig);
|
|
273
|
-
return (await getAuthModule(hostConfigToUse)).handleAuthenticationError({
|
|
274
|
-
...props,
|
|
275
|
-
hostConfig: hostConfigToUse
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
async function getRestCallAuthParams(props) {
|
|
279
|
-
const hostConfigToUse = withDefaultHostConfig(props.hostConfig);
|
|
280
|
-
return (await getAuthModule(hostConfigToUse)).getRestCallAuthParams({
|
|
281
|
-
...props,
|
|
282
|
-
hostConfig: hostConfigToUse
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
function registerAuthModule2(name, authModule) {
|
|
286
|
-
registerAuthModule(name, authModule);
|
|
287
|
-
}
|
|
288
|
-
function setDefaultHostConfig2(hostConfig) {
|
|
289
|
-
setDefaultHostConfig(hostConfig);
|
|
290
|
-
}
|
|
291
|
-
function checkForCrossDomainRequest(hostConfig) {
|
|
292
|
-
const hostConfigToUse = withDefaultHostConfig(hostConfig);
|
|
293
|
-
if (isHostCrossOrigin(hostConfigToUse)) {
|
|
294
|
-
if (Object.keys(hostConfigToUse).length === 0) {
|
|
295
|
-
throw new InvalidHostConfigError("a host config must be provided when making a cross domain request");
|
|
296
|
-
}
|
|
297
|
-
if (!hostConfigToUse.host) {
|
|
298
|
-
throw new InvalidHostConfigError("A 'host' must be set in host config when making a cross domain request");
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
var logout = () => {
|
|
303
|
-
globalThis.loggingOut = true;
|
|
304
|
-
globalThis.location.href = "/logout";
|
|
305
|
-
};
|
|
306
|
-
var leadingHttp = /^http/;
|
|
307
|
-
|
|
308
|
-
// src/auth/internal/auth-functions.ts
|
|
309
|
-
function getCredentialsForCookieAuth(hostConfig) {
|
|
310
|
-
if (hostConfig.crossSiteCookies === false) {
|
|
311
|
-
return "same-origin";
|
|
312
|
-
}
|
|
313
|
-
if (isHostCrossOrigin(hostConfig)) {
|
|
314
|
-
return "include";
|
|
315
|
-
}
|
|
316
|
-
return "same-origin";
|
|
317
|
-
}
|
|
318
|
-
function internalValidateHostConfig(hostConfig, options) {
|
|
319
|
-
const missingRequiredProps = [];
|
|
320
|
-
for (const requiredProp of options.requiredProps) {
|
|
321
|
-
if (!hostConfig[requiredProp]) {
|
|
322
|
-
missingRequiredProps.push(requiredProp);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
if (missingRequiredProps.length > 0) {
|
|
326
|
-
throw new InvalidHostConfigError(
|
|
327
|
-
`missing required properties in host config; '${missingRequiredProps.join("', '")}'`
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
const validProps = [
|
|
331
|
-
"authType",
|
|
332
|
-
"autoRedirect",
|
|
333
|
-
"authRedirectUserConfirmation",
|
|
334
|
-
"embedRuntimeUrl",
|
|
335
|
-
"host",
|
|
336
|
-
...options.requiredProps,
|
|
337
|
-
...options.optionalProps
|
|
338
|
-
];
|
|
339
|
-
const invalidKeys = [];
|
|
340
|
-
Object.keys(hostConfig).forEach((key) => {
|
|
341
|
-
if (!validProps.some((k) => k === key)) {
|
|
342
|
-
invalidKeys.push(key);
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
if (invalidKeys.length > 0) {
|
|
346
|
-
throw new InvalidHostConfigError(`unknown properties in host config; '${invalidKeys.join("', '")}'`);
|
|
347
|
-
}
|
|
348
|
-
return true;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// src/auth/internal/default-auth-modules/apikey.ts
|
|
352
|
-
function getRestCallAuthParams2({ hostConfig }) {
|
|
353
|
-
return Promise.resolve({
|
|
354
|
-
headers: {
|
|
355
|
-
Authorization: `Bearer ${_optionalChain([hostConfig, 'optionalAccess', _13 => _13.apiKey])}`
|
|
356
|
-
},
|
|
357
|
-
queryParams: {},
|
|
358
|
-
credentials: "omit"
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
async function getWebSocketAuthParams2() {
|
|
362
|
-
return {
|
|
363
|
-
queryParams: {
|
|
364
|
-
// accessToken: hostConfig.apiKey,
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
function handleAuthenticationError2() {
|
|
369
|
-
return Promise.resolve({});
|
|
370
|
-
}
|
|
371
|
-
var apikey_default = {
|
|
372
|
-
getRestCallAuthParams: getRestCallAuthParams2,
|
|
373
|
-
getWebSocketAuthParams: getWebSocketAuthParams2,
|
|
374
|
-
handleAuthenticationError: handleAuthenticationError2,
|
|
375
|
-
validateHostConfig: (hostConfig) => internalValidateHostConfig(hostConfig, { requiredProps: ["apiKey"], optionalProps: [] })
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
// src/http/http-functions.ts
|
|
379
|
-
var QLIK_CSRF_TOKEN = "qlik-csrf-token";
|
|
380
|
-
function clearCsrfToken(hostConfig) {
|
|
381
|
-
const locationUrl = toValidLocationUrl(hostConfig);
|
|
382
|
-
delete csrfTokens[locationUrl];
|
|
383
|
-
}
|
|
384
|
-
async function getCsrfToken(hostConfig, noCache) {
|
|
385
|
-
const locationUrl = toValidLocationUrl(hostConfig);
|
|
386
|
-
const fetchCsrfToken = async () => {
|
|
387
|
-
const res = await invokeFetch("csrf-token", {
|
|
388
|
-
method: "get",
|
|
389
|
-
pathTemplate: "/api/v1/csrf-token",
|
|
390
|
-
options: {
|
|
391
|
-
hostConfig,
|
|
392
|
-
noCache: true
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
const csrfToken = res.headers.get(QLIK_CSRF_TOKEN);
|
|
396
|
-
if (!csrfToken) {
|
|
397
|
-
return "";
|
|
398
|
-
}
|
|
399
|
-
return csrfToken;
|
|
400
|
-
};
|
|
401
|
-
if (noCache) {
|
|
402
|
-
csrfTokens[locationUrl] = fetchCsrfToken();
|
|
403
|
-
return csrfTokens[locationUrl];
|
|
404
|
-
}
|
|
405
|
-
csrfTokens[locationUrl] = csrfTokens[locationUrl] || fetchCsrfToken();
|
|
406
|
-
return csrfTokens[locationUrl];
|
|
407
|
-
}
|
|
408
|
-
var csrfTokens = {};
|
|
409
|
-
|
|
410
|
-
// src/auth/internal/default-auth-modules/cookie.ts
|
|
411
|
-
function isModifyingVerb(verb) {
|
|
412
|
-
return !(verb === "get" || verb === "GET");
|
|
413
|
-
}
|
|
414
|
-
async function getRestCallAuthParams3({
|
|
415
|
-
hostConfig,
|
|
416
|
-
method
|
|
417
|
-
}) {
|
|
418
|
-
const headers = {};
|
|
419
|
-
if (isModifyingVerb(method)) {
|
|
420
|
-
headers["qlik-csrf-token"] = await getCsrfToken(hostConfig);
|
|
421
|
-
}
|
|
422
|
-
if (hostConfig.webIntegrationId) {
|
|
423
|
-
headers["qlik-web-integration-id"] = hostConfig.webIntegrationId;
|
|
424
|
-
}
|
|
425
|
-
return { headers, queryParams: {}, credentials: getCredentialsForCookieAuth(hostConfig) };
|
|
426
|
-
}
|
|
427
|
-
async function getWebSocketAuthParams3({
|
|
428
|
-
hostConfig
|
|
429
|
-
}) {
|
|
430
|
-
const params = {
|
|
431
|
-
// Bypass the cache to get one rest call out the door that can catch a 401 since the websocket only returns a general error
|
|
432
|
-
"qlik-csrf-token": await getCsrfToken(hostConfig, true)
|
|
433
|
-
};
|
|
434
|
-
if (hostConfig.webIntegrationId) {
|
|
435
|
-
params["qlik-web-integration-id"] = hostConfig.webIntegrationId;
|
|
436
|
-
}
|
|
437
|
-
return { queryParams: params };
|
|
438
|
-
}
|
|
439
|
-
async function handleAuthenticationError3({
|
|
440
|
-
hostConfig,
|
|
441
|
-
status,
|
|
442
|
-
errorBody = {}
|
|
443
|
-
}) {
|
|
444
|
-
clearCsrfToken(hostConfig);
|
|
445
|
-
if (status === 403) {
|
|
446
|
-
return {
|
|
447
|
-
preventDefault: false,
|
|
448
|
-
// Only retry if the csrf token has expired
|
|
449
|
-
retry: _optionalChain([errorBody, 'optionalAccess', _14 => _14.code]) === "CSRF-TOKEN-2"
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
const webIntegrationParam = hostConfig.webIntegrationId ? `qlik-web-integration-id=${_optionalChain([hostConfig, 'optionalAccess', _15 => _15.webIntegrationId])}&` : "";
|
|
453
|
-
const locationUrl = toValidLocationUrl(hostConfig);
|
|
454
|
-
if (hostConfig.authRedirectUserConfirmation) {
|
|
455
|
-
await hostConfig.authRedirectUserConfirmation();
|
|
456
|
-
}
|
|
457
|
-
globalThis.location.replace(
|
|
458
|
-
`${locationUrl}/login?${webIntegrationParam}returnto=${encodeURIComponent(globalThis.location.href)}`
|
|
459
|
-
);
|
|
460
|
-
return {
|
|
461
|
-
preventDefault: true
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
var cookie_default = {
|
|
465
|
-
getRestCallAuthParams: getRestCallAuthParams3,
|
|
466
|
-
getWebSocketAuthParams: getWebSocketAuthParams3,
|
|
467
|
-
handleAuthenticationError: handleAuthenticationError3,
|
|
468
|
-
validateHostConfig: (hostConfig) => internalValidateHostConfig(hostConfig, {
|
|
469
|
-
requiredProps: [],
|
|
470
|
-
optionalProps: ["webIntegrationId", "crossSiteCookies"]
|
|
471
|
-
})
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
// src/auth/internal/default-auth-modules/none.ts
|
|
475
|
-
function getRestCallAuthParams4() {
|
|
476
|
-
return Promise.resolve({ headers: {}, queryParams: {}, credentials: "same-origin" });
|
|
477
|
-
}
|
|
478
|
-
function getWebSocketAuthParams4() {
|
|
479
|
-
return Promise.resolve({ queryParams: {} });
|
|
480
|
-
}
|
|
481
|
-
function handleAuthenticationError4() {
|
|
482
|
-
return Promise.resolve({});
|
|
483
|
-
}
|
|
484
|
-
var none_default = {
|
|
485
|
-
getRestCallAuthParams: getRestCallAuthParams4,
|
|
486
|
-
getWebSocketAuthParams: getWebSocketAuthParams4,
|
|
487
|
-
handleAuthenticationError: handleAuthenticationError4,
|
|
488
|
-
validateHostConfig: (hostConfig) => internalValidateHostConfig(hostConfig, { requiredProps: [], optionalProps: [] })
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
// src/utils/utils.ts
|
|
492
|
-
var _nanoid = require('nanoid');
|
|
493
|
-
function isBrowser() {
|
|
494
|
-
return typeof window === "object" && typeof window.document === "object";
|
|
495
|
-
}
|
|
496
|
-
function isNode() {
|
|
497
|
-
return typeof process === "object" && typeof _4HB3TAEOjs.__require === "function";
|
|
498
|
-
}
|
|
499
|
-
function generateRandomString(targetLength) {
|
|
500
|
-
return _nanoid.nanoid.call(void 0, targetLength);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
// src/auth/internal/default-auth-modules/oauth/storage-helpers.ts
|
|
504
|
-
var storagePrefix = "qlik-qmfe-api";
|
|
505
|
-
function getTopicFromHostConfig(hostConfig) {
|
|
506
|
-
return hostConfig.clientId + (hostConfig.scope ? `_${hostConfig.scope}` : "_user_default");
|
|
507
|
-
}
|
|
508
|
-
var cachedTokens = {};
|
|
509
|
-
function saveInLocalStorage(topic, name, value) {
|
|
510
|
-
localStorage.setItem(`${storagePrefix}-${topic}-${name}`, value);
|
|
511
|
-
}
|
|
512
|
-
function saveInSessionStorage(topic, name, value) {
|
|
513
|
-
sessionStorage.setItem(`${storagePrefix}-${topic}-${name}`, value);
|
|
514
|
-
}
|
|
515
|
-
function loadFromLocalStorage(topic, name) {
|
|
516
|
-
return localStorage.getItem(`${storagePrefix}-${topic}-${name}`) || void 0;
|
|
517
|
-
}
|
|
518
|
-
function loadFromSessionStorage(topic, name) {
|
|
519
|
-
return sessionStorage.getItem(`${storagePrefix}-${topic}-${name}`) || void 0;
|
|
520
|
-
}
|
|
521
|
-
function deleteFromLocalStorage(topic, names) {
|
|
522
|
-
names.forEach((name) => localStorage.removeItem(`${storagePrefix}-${topic}-${name}`));
|
|
523
|
-
}
|
|
524
|
-
function deleteFromSessionStorage(topic, names) {
|
|
525
|
-
names.forEach((name) => sessionStorage.removeItem(`${storagePrefix}-${topic}-${name}`));
|
|
526
|
-
}
|
|
527
|
-
function loadAndDeleteFromSessionStorage(topic, name) {
|
|
528
|
-
const id = `${storagePrefix}-${topic}-${name}`;
|
|
529
|
-
const result2 = sessionStorage.getItem(id) || void 0;
|
|
530
|
-
sessionStorage.removeItem(id);
|
|
531
|
-
return result2;
|
|
532
|
-
}
|
|
533
|
-
function loadOauthTokensFromStorage(hostConfig) {
|
|
534
|
-
if (!hostConfig.clientId) {
|
|
535
|
-
return void 0;
|
|
536
|
-
}
|
|
537
|
-
let accessToken;
|
|
538
|
-
let refreshToken;
|
|
539
|
-
if (hostConfig.accessTokenStorage === "local") {
|
|
540
|
-
accessToken = loadFromLocalStorage(getTopicFromHostConfig(hostConfig), "access-token");
|
|
541
|
-
refreshToken = loadFromLocalStorage(getTopicFromHostConfig(hostConfig), "refresh-token");
|
|
542
|
-
} else if (hostConfig.accessTokenStorage === "session") {
|
|
543
|
-
accessToken = loadFromSessionStorage(getTopicFromHostConfig(hostConfig), "access-token");
|
|
544
|
-
refreshToken = loadFromSessionStorage(getTopicFromHostConfig(hostConfig), "refresh-token");
|
|
545
|
-
}
|
|
546
|
-
if (accessToken) {
|
|
547
|
-
return {
|
|
548
|
-
accessToken,
|
|
549
|
-
refreshToken
|
|
550
|
-
};
|
|
551
|
-
}
|
|
552
|
-
return void 0;
|
|
553
|
-
}
|
|
554
|
-
async function loadCachedOauthTokens(hostConfig) {
|
|
555
|
-
return cachedTokens[getTopicFromHostConfig(hostConfig)];
|
|
556
|
-
}
|
|
557
|
-
async function loadOrAcquireAccessToken(hostConfig, acquireTokens) {
|
|
558
|
-
if (!hostConfig.clientId) {
|
|
559
|
-
throw new InvalidHostConfigError('A host config with authType set to "oauth2" has to also provide a clientId');
|
|
560
|
-
}
|
|
561
|
-
const mayUseStorage = isBrowser();
|
|
562
|
-
const storedOauthTokens = cachedTokens[getTopicFromHostConfig(hostConfig)] || (mayUseStorage ? loadOauthTokensFromStorage(hostConfig) : void 0);
|
|
563
|
-
if (storedOauthTokens) {
|
|
564
|
-
return Promise.resolve(storedOauthTokens);
|
|
565
|
-
}
|
|
566
|
-
const tokensPromise = acquireTokens();
|
|
567
|
-
cachedTokens[getTopicFromHostConfig(hostConfig)] = tokensPromise;
|
|
568
|
-
if (mayUseStorage) {
|
|
569
|
-
const tokens = await tokensPromise;
|
|
570
|
-
if (hostConfig.accessTokenStorage === "local" && tokens) {
|
|
571
|
-
if (tokens.accessToken) {
|
|
572
|
-
saveInLocalStorage(getTopicFromHostConfig(hostConfig), "access-token", tokens.accessToken);
|
|
573
|
-
}
|
|
574
|
-
if (tokens.refreshToken) {
|
|
575
|
-
saveInLocalStorage(getTopicFromHostConfig(hostConfig), "refresh-token", tokens.refreshToken);
|
|
576
|
-
}
|
|
577
|
-
} else if (hostConfig.accessTokenStorage === "session" && tokens) {
|
|
578
|
-
if (tokens.accessToken) {
|
|
579
|
-
saveInSessionStorage(getTopicFromHostConfig(hostConfig), "access-token", tokens.accessToken);
|
|
580
|
-
}
|
|
581
|
-
if (tokens.refreshToken) {
|
|
582
|
-
saveInSessionStorage(getTopicFromHostConfig(hostConfig), "refresh-token", tokens.refreshToken);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
return tokensPromise;
|
|
587
|
-
}
|
|
588
|
-
function clearStoredOauthTokens(hostConfig) {
|
|
589
|
-
if (!hostConfig.clientId) {
|
|
590
|
-
throw new InvalidHostConfigError('A host config with authType set to "oauth2" has to also provide a clientId');
|
|
591
|
-
}
|
|
592
|
-
delete cachedTokens[getTopicFromHostConfig(hostConfig)];
|
|
593
|
-
if (isBrowser()) {
|
|
594
|
-
deleteFromLocalStorage(getTopicFromHostConfig(hostConfig), ["access-token", "refresh-token"]);
|
|
595
|
-
deleteFromSessionStorage(getTopicFromHostConfig(hostConfig), ["access-token", "refresh-token"]);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
// src/auth/internal/default-auth-modules/oauth/callback.ts
|
|
600
|
-
function handleOAuthCallback() {
|
|
601
|
-
const urlParams = new URLSearchParams(globalThis.location.search);
|
|
602
|
-
const callbackCode = urlParams.get("code") || void 0;
|
|
603
|
-
const callbackState = urlParams.get("state") || void 0;
|
|
604
|
-
if (urlParams.get("error")) {
|
|
605
|
-
const element = document.createElement("pre");
|
|
606
|
-
element.innerText = `<code>${JSON.stringify({
|
|
607
|
-
error: urlParams.get("error"),
|
|
608
|
-
error_code: urlParams.get("error_code"),
|
|
609
|
-
error_description: urlParams.get("error_description"),
|
|
610
|
-
error_detail: urlParams.get("error_detail"),
|
|
611
|
-
error_uri: urlParams.get("error_uri")
|
|
612
|
-
})}</code>`;
|
|
613
|
-
document.body.prepend(element);
|
|
614
|
-
}
|
|
615
|
-
const topic = loadAndDeleteFromSessionStorage("", "client-in-progress");
|
|
616
|
-
if (topic && callbackCode && callbackState) {
|
|
617
|
-
const stateFromLocalStorage = loadAndDeleteFromSessionStorage(topic, "state");
|
|
618
|
-
const finalRedirectUri = loadAndDeleteFromSessionStorage(topic, "href");
|
|
619
|
-
if (stateFromLocalStorage && stateFromLocalStorage === callbackState && finalRedirectUri) {
|
|
620
|
-
saveInSessionStorage(topic, "code", callbackCode);
|
|
621
|
-
if (finalRedirectUri !== globalThis.location.href) {
|
|
622
|
-
globalThis.location.replace(finalRedirectUri);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
// src/auth/internal/default-auth-modules/oauth/oauth-utils.ts
|
|
629
|
-
function handlePossibleErrors(data) {
|
|
630
|
-
if (data.errors) {
|
|
631
|
-
throw new AuthorizationError(data.errors);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
function toQueryString(queryParams) {
|
|
635
|
-
const queryParamsKeys = Object.keys(queryParams);
|
|
636
|
-
queryParamsKeys.sort();
|
|
637
|
-
const query = queryParamsKeys.map((k) => `${k}=${queryParams[k]}`).join("&");
|
|
638
|
-
return query;
|
|
639
|
-
}
|
|
640
|
-
function byteArrayToBase64(hashArray) {
|
|
641
|
-
let result2 = "";
|
|
642
|
-
if (isBrowser()) {
|
|
643
|
-
const byteArrayToString = String.fromCharCode.apply(null, hashArray);
|
|
644
|
-
result2 = btoa(byteArrayToString);
|
|
645
|
-
} else if (isNode()) {
|
|
646
|
-
result2 = Buffer.from(hashArray).toString("base64");
|
|
647
|
-
} else {
|
|
648
|
-
throw new Error("Environment not supported for oauth2 authentication");
|
|
649
|
-
}
|
|
650
|
-
return result2;
|
|
651
|
-
}
|
|
652
|
-
async function sha256(message) {
|
|
653
|
-
const msgBuffer = new TextEncoder().encode(message);
|
|
654
|
-
const hashBuffer = await globalThis.crypto.subtle.digest("SHA-256", msgBuffer);
|
|
655
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
656
|
-
const hashBase64 = byteArrayToBase64(hashArray);
|
|
657
|
-
return hashBase64.replaceAll(/\+/g, "-").replaceAll(/\//g, "_").replace(/=+$/, "");
|
|
658
|
-
}
|
|
659
|
-
async function startFullPageLoginFlow(hostConfig) {
|
|
660
|
-
const clientId = hostConfig.clientId || "";
|
|
661
|
-
const locationUrl = toValidLocationUrl(hostConfig);
|
|
662
|
-
const verifier = generateRandomString(128);
|
|
663
|
-
const state = generateRandomString(43);
|
|
664
|
-
const codeChallenge = await sha256(verifier);
|
|
665
|
-
const redirectUri = hostConfig.redirectUri || globalThis.location.href;
|
|
666
|
-
clearStoredOauthTokens(hostConfig);
|
|
667
|
-
saveInSessionStorage(getTopicFromHostConfig(hostConfig), "state", state);
|
|
668
|
-
saveInSessionStorage(getTopicFromHostConfig(hostConfig), "verifier", verifier);
|
|
669
|
-
saveInSessionStorage(getTopicFromHostConfig(hostConfig), "href", globalThis.location.href);
|
|
670
|
-
saveInSessionStorage("", "client-in-progress", getTopicFromHostConfig(hostConfig));
|
|
671
|
-
const queryParams = {
|
|
672
|
-
response_type: "code",
|
|
673
|
-
client_id: clientId,
|
|
674
|
-
redirect_uri: redirectUri,
|
|
675
|
-
scope: hostConfig.scope || "user_default",
|
|
676
|
-
state,
|
|
677
|
-
code_challenge: codeChallenge,
|
|
678
|
-
code_challenge_method: "S256"
|
|
679
|
-
};
|
|
680
|
-
const url = `${locationUrl}/oauth/authorize?${toQueryString(queryParams)}`;
|
|
681
|
-
globalThis.location.replace(url);
|
|
682
|
-
}
|
|
683
|
-
async function exchangeCodeAndVerifierForAccessTokenData(hostConfig, code, verifier, redirectUri) {
|
|
684
|
-
try {
|
|
685
|
-
const result2 = await fetch(`${toValidLocationUrl(hostConfig)}/oauth/token`, {
|
|
686
|
-
method: "POST",
|
|
687
|
-
credentials: "include",
|
|
688
|
-
mode: "cors",
|
|
689
|
-
headers: { "content-type": "application/json" },
|
|
690
|
-
redirect: "follow",
|
|
691
|
-
body: JSON.stringify({
|
|
692
|
-
grant_type: "authorization_code",
|
|
693
|
-
scope: hostConfig.scope || "user_default",
|
|
694
|
-
...code ? { code } : {},
|
|
695
|
-
...{ redirect_uri: redirectUri || globalThis.location.href },
|
|
696
|
-
...verifier ? { code_verifier: verifier } : {},
|
|
697
|
-
client_id: hostConfig.clientId
|
|
698
|
-
})
|
|
699
|
-
});
|
|
700
|
-
const data = await result2.json();
|
|
701
|
-
handlePossibleErrors(data);
|
|
702
|
-
return {
|
|
703
|
-
accessToken: data.access_token,
|
|
704
|
-
refreshToken: data.refresh_token,
|
|
705
|
-
errors: data.errors
|
|
706
|
-
};
|
|
707
|
-
} catch (err) {
|
|
708
|
-
console.error(err);
|
|
709
|
-
return new Promise(() => {
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
async function getOauthTokensWithCredentials(baseUrl, clientId, clientSecret, scope = "user_default") {
|
|
714
|
-
const result2 = await fetch(`${baseUrl}/oauth/token`, {
|
|
715
|
-
method: "POST",
|
|
716
|
-
mode: "cors",
|
|
717
|
-
headers: { "content-type": "application/json" },
|
|
718
|
-
body: JSON.stringify({
|
|
719
|
-
grant_type: "client_credentials",
|
|
720
|
-
client_id: clientId,
|
|
721
|
-
client_secret: clientSecret,
|
|
722
|
-
scope
|
|
723
|
-
})
|
|
724
|
-
});
|
|
725
|
-
const data = await result2.json();
|
|
726
|
-
return {
|
|
727
|
-
accessToken: data.access_token,
|
|
728
|
-
refreshToken: data.refresh_token,
|
|
729
|
-
errors: data.errors
|
|
730
|
-
};
|
|
731
|
-
}
|
|
732
|
-
async function getOauthTokensWithRefreshToken(baseUrl, refreshToken, clientSecret) {
|
|
733
|
-
const result2 = await fetch(`${baseUrl}/oauth/token`, {
|
|
734
|
-
method: "POST",
|
|
735
|
-
mode: "cors",
|
|
736
|
-
headers: { "content-type": "application/json" },
|
|
737
|
-
body: JSON.stringify({
|
|
738
|
-
grant_type: "refresh_token",
|
|
739
|
-
refresh_token: refreshToken,
|
|
740
|
-
client_secret: clientSecret
|
|
741
|
-
})
|
|
742
|
-
});
|
|
743
|
-
const data = await result2.json();
|
|
744
|
-
return {
|
|
745
|
-
accessToken: data.access_token,
|
|
746
|
-
refreshToken: data.refresh_token,
|
|
747
|
-
errors: data.errors
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
async function getOAuthTokensForNode(hostConfig) {
|
|
751
|
-
const { clientId, clientSecret } = hostConfig;
|
|
752
|
-
if (!clientId || !clientSecret) {
|
|
753
|
-
throw new InvalidHostConfigError(
|
|
754
|
-
'A host config with authType set to "oauth2" has to provide a clientId and a clientSecret'
|
|
755
|
-
);
|
|
756
|
-
}
|
|
757
|
-
const oauthTokens = await loadOrAcquireAccessToken(hostConfig, async () => {
|
|
758
|
-
if (!hostConfig.clientId || !hostConfig.clientSecret) {
|
|
759
|
-
throw new InvalidHostConfigError(
|
|
760
|
-
'A host config with authType set to "oauth2" has to provide a clientId and a clientSecret'
|
|
761
|
-
);
|
|
762
|
-
}
|
|
763
|
-
return getOauthTokensWithCredentials(
|
|
764
|
-
toValidLocationUrl(hostConfig),
|
|
765
|
-
hostConfig.clientId,
|
|
766
|
-
hostConfig.clientSecret,
|
|
767
|
-
hostConfig.scope
|
|
768
|
-
);
|
|
769
|
-
});
|
|
770
|
-
return oauthTokens;
|
|
771
|
-
}
|
|
772
|
-
async function getOAuthTokensForBrowser(hostConfig) {
|
|
773
|
-
const { clientId } = hostConfig;
|
|
774
|
-
if (!clientId) {
|
|
775
|
-
throw new InvalidHostConfigError('A host config with authType set to "oauth2" has to also provide a clientId');
|
|
776
|
-
}
|
|
777
|
-
const oauthTokens = await loadOrAcquireAccessToken(hostConfig, async () => {
|
|
778
|
-
const code = loadAndDeleteFromSessionStorage(getTopicFromHostConfig(hostConfig), "code");
|
|
779
|
-
const verifier = loadAndDeleteFromSessionStorage(getTopicFromHostConfig(hostConfig), "verifier");
|
|
780
|
-
if (code && verifier) {
|
|
781
|
-
const tokenResponse = await exchangeCodeAndVerifierForAccessTokenData(
|
|
782
|
-
hostConfig,
|
|
783
|
-
code,
|
|
784
|
-
verifier,
|
|
785
|
-
hostConfig.redirectUri
|
|
786
|
-
);
|
|
787
|
-
if (tokenResponse) {
|
|
788
|
-
return tokenResponse;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
return void 0;
|
|
792
|
-
});
|
|
793
|
-
if (oauthTokens) {
|
|
794
|
-
return oauthTokens;
|
|
795
|
-
}
|
|
796
|
-
if (hostConfig.authRedirectUserConfirmation) {
|
|
797
|
-
await hostConfig.authRedirectUserConfirmation();
|
|
798
|
-
}
|
|
799
|
-
startFullPageLoginFlow(hostConfig);
|
|
800
|
-
return new Promise(() => {
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
var lastOauthTokensCall = Promise.resolve("");
|
|
804
|
-
async function getOAuthAccessToken(hostConfig) {
|
|
805
|
-
let getOauthTokensCall;
|
|
806
|
-
if (isNode()) {
|
|
807
|
-
getOauthTokensCall = getOAuthTokensForNode;
|
|
808
|
-
} else {
|
|
809
|
-
getOauthTokensCall = getOAuthTokensForBrowser;
|
|
810
|
-
}
|
|
811
|
-
lastOauthTokensCall = lastOauthTokensCall.then(async () => {
|
|
812
|
-
const tokens = await getOauthTokensCall(hostConfig);
|
|
813
|
-
if (tokens) {
|
|
814
|
-
handlePossibleErrors(tokens);
|
|
815
|
-
return tokens.accessToken || "";
|
|
816
|
-
}
|
|
817
|
-
return "";
|
|
818
|
-
});
|
|
819
|
-
return lastOauthTokensCall;
|
|
820
|
-
}
|
|
821
|
-
async function refreshAccessToken(hostConfig) {
|
|
822
|
-
const tokens = await loadCachedOauthTokens(hostConfig);
|
|
823
|
-
clearStoredOauthTokens(hostConfig);
|
|
824
|
-
if (tokens && tokens.refreshToken && hostConfig.clientSecret) {
|
|
825
|
-
const refreshedTokens = await loadOrAcquireAccessToken(hostConfig, async () => {
|
|
826
|
-
if (!tokens || !tokens.refreshToken || !hostConfig.clientSecret) {
|
|
827
|
-
throw new Error("Trying to refresh tokens without refreshToken or clientSecret");
|
|
828
|
-
}
|
|
829
|
-
return getOauthTokensWithRefreshToken(
|
|
830
|
-
toValidLocationUrl(hostConfig),
|
|
831
|
-
tokens.refreshToken,
|
|
832
|
-
hostConfig.clientSecret
|
|
833
|
-
);
|
|
834
|
-
});
|
|
835
|
-
if (refreshedTokens) {
|
|
836
|
-
handlePossibleErrors(refreshedTokens);
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
// src/auth/internal/default-auth-modules/oauth/temporary-token.ts
|
|
842
|
-
async function exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, purpose) {
|
|
843
|
-
const result2 = await fetch(`${toValidLocationUrl(hostConfig)}/oauth/token`, {
|
|
844
|
-
method: "POST",
|
|
845
|
-
credentials: "include",
|
|
846
|
-
mode: "cors",
|
|
847
|
-
headers: { "content-type": "application/json" },
|
|
848
|
-
redirect: "follow",
|
|
849
|
-
body: JSON.stringify({
|
|
850
|
-
subject_token: accessToken,
|
|
851
|
-
subject_token_type: "urn:ietf:params:oauth:token-type:access_token",
|
|
852
|
-
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
|
|
853
|
-
purpose,
|
|
854
|
-
redirect_uri: _optionalChain([globalThis, 'access', _16 => _16.location, 'optionalAccess', _17 => _17.href]),
|
|
855
|
-
client_id: hostConfig.clientId
|
|
856
|
-
})
|
|
857
|
-
});
|
|
858
|
-
if (result2.status === 401) {
|
|
859
|
-
if (hostConfig.authRedirectUserConfirmation) {
|
|
860
|
-
await hostConfig.authRedirectUserConfirmation();
|
|
861
|
-
}
|
|
862
|
-
startFullPageLoginFlow(hostConfig);
|
|
863
|
-
return new Promise(() => {
|
|
864
|
-
});
|
|
865
|
-
}
|
|
866
|
-
const data = await result2.json();
|
|
867
|
-
return data.access_token;
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
// src/auth/internal/default-auth-modules/oauth.ts
|
|
871
|
-
if (isBrowser()) {
|
|
872
|
-
handleOAuthCallback();
|
|
873
|
-
}
|
|
874
|
-
async function getRestCallAuthParams5({
|
|
875
|
-
hostConfig
|
|
876
|
-
}) {
|
|
877
|
-
return {
|
|
878
|
-
headers: {
|
|
879
|
-
Authorization: `Bearer ${await getOAuthAccessToken(hostConfig)}`
|
|
880
|
-
},
|
|
881
|
-
queryParams: {},
|
|
882
|
-
credentials: "omit"
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
|
-
async function getWebSocketAuthParams5({
|
|
886
|
-
hostConfig
|
|
887
|
-
}) {
|
|
888
|
-
const accessToken = await getOAuthAccessToken(hostConfig);
|
|
889
|
-
const websocketAccessToken = await exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, "websocket");
|
|
890
|
-
return {
|
|
891
|
-
queryParams: {
|
|
892
|
-
accessToken: websocketAccessToken
|
|
893
|
-
}
|
|
894
|
-
};
|
|
895
|
-
}
|
|
896
|
-
async function getWebResourceAuthParams2({
|
|
897
|
-
hostConfig
|
|
898
|
-
}) {
|
|
899
|
-
const accessToken = await getOAuthAccessToken(hostConfig);
|
|
900
|
-
const webResourceAccessToken = await exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, "webresource");
|
|
901
|
-
return {
|
|
902
|
-
queryParams: {
|
|
903
|
-
accessToken: webResourceAccessToken
|
|
904
|
-
}
|
|
905
|
-
};
|
|
906
|
-
}
|
|
907
|
-
async function handleAuthenticationError5({
|
|
908
|
-
hostConfig
|
|
909
|
-
}) {
|
|
910
|
-
if (isBrowser()) {
|
|
911
|
-
if (hostConfig.authRedirectUserConfirmation) {
|
|
912
|
-
await hostConfig.authRedirectUserConfirmation();
|
|
913
|
-
}
|
|
914
|
-
startFullPageLoginFlow(hostConfig);
|
|
915
|
-
return {
|
|
916
|
-
preventDefault: true
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
await refreshAccessToken(hostConfig);
|
|
920
|
-
return {
|
|
921
|
-
preventDefault: false,
|
|
922
|
-
retry: true
|
|
923
|
-
};
|
|
924
|
-
}
|
|
925
|
-
var oauth_default = {
|
|
926
|
-
getRestCallAuthParams: getRestCallAuthParams5,
|
|
927
|
-
getWebSocketAuthParams: getWebSocketAuthParams5,
|
|
928
|
-
getWebResourceAuthParams: getWebResourceAuthParams2,
|
|
929
|
-
handleAuthenticationError: handleAuthenticationError5,
|
|
930
|
-
validateHostConfig: (hostConfig) => internalValidateHostConfig(hostConfig, {
|
|
931
|
-
requiredProps: ["clientId"],
|
|
932
|
-
optionalProps: ["clientSecret", "redirectUri", "accessTokenStorage", "scope"]
|
|
933
|
-
})
|
|
934
|
-
};
|
|
935
|
-
|
|
936
|
-
// src/auth/internal/default-auth-modules/windows-cookie/xrf-keys.ts
|
|
937
|
-
var xrfKeys = {};
|
|
938
|
-
function createXrfKey() {
|
|
939
|
-
let result2 = "";
|
|
940
|
-
for (let i = 0; i < 16; i += 1) {
|
|
941
|
-
const j = Math.floor(Math.random() * 62);
|
|
942
|
-
if (j < 10) {
|
|
943
|
-
result2 += j;
|
|
944
|
-
} else if (j > 9 && j < 36) {
|
|
945
|
-
result2 += String.fromCharCode(j + 55);
|
|
946
|
-
} else {
|
|
947
|
-
result2 += String.fromCharCode(j + 61);
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
return result2;
|
|
951
|
-
}
|
|
952
|
-
function getXrfKey(hostConfig) {
|
|
953
|
-
const locationUrl = toValidLocationUrl(hostConfig);
|
|
954
|
-
xrfKeys[locationUrl] = xrfKeys[locationUrl] || createXrfKey();
|
|
955
|
-
return xrfKeys[locationUrl];
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
// src/auth/internal/default-auth-modules/windows-cookie.ts
|
|
959
|
-
function getRestCallAuthParams6({
|
|
960
|
-
hostConfig
|
|
961
|
-
}) {
|
|
962
|
-
return Promise.resolve({
|
|
963
|
-
headers: {
|
|
964
|
-
"X-Qlik-XrfKey": getXrfKey(hostConfig)
|
|
965
|
-
},
|
|
966
|
-
queryParams: {
|
|
967
|
-
xrfkey: getXrfKey(hostConfig)
|
|
968
|
-
},
|
|
969
|
-
credentials: getCredentialsForCookieAuth(hostConfig)
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
function getWebSocketAuthParams6({
|
|
973
|
-
hostConfig
|
|
974
|
-
}) {
|
|
975
|
-
return Promise.resolve({
|
|
976
|
-
queryParams: {
|
|
977
|
-
xrfkey: getXrfKey(hostConfig)
|
|
978
|
-
}
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
|
-
async function handleAuthenticationError6({
|
|
982
|
-
hostConfig
|
|
983
|
-
}) {
|
|
984
|
-
if (hostConfig.loginUri) {
|
|
985
|
-
if (hostConfig.authRedirectUserConfirmation) {
|
|
986
|
-
await hostConfig.authRedirectUserConfirmation();
|
|
987
|
-
}
|
|
988
|
-
globalThis.location.replace(
|
|
989
|
-
hostConfig.loginUri.replace("{location}", encodeURIComponent(globalThis.location.href))
|
|
990
|
-
);
|
|
991
|
-
return {
|
|
992
|
-
preventDefault: true
|
|
993
|
-
};
|
|
994
|
-
}
|
|
995
|
-
return {
|
|
996
|
-
// Do nothing, just let the error be thrown to calling code
|
|
997
|
-
};
|
|
998
|
-
}
|
|
999
|
-
var windows_cookie_default = {
|
|
1000
|
-
getRestCallAuthParams: getRestCallAuthParams6,
|
|
1001
|
-
getWebSocketAuthParams: getWebSocketAuthParams6,
|
|
1002
|
-
handleAuthenticationError: handleAuthenticationError6,
|
|
1003
|
-
validateHostConfig: (hostConfig) => internalValidateHostConfig(hostConfig, {
|
|
1004
|
-
requiredProps: [],
|
|
1005
|
-
optionalProps: ["loginUri", "crossSiteCookies"]
|
|
1006
|
-
})
|
|
1007
|
-
};
|
|
1008
|
-
|
|
1009
|
-
// src/auth/auth.ts
|
|
1010
|
-
globalThis.loggingOut = false;
|
|
1011
|
-
var authModulesRegistered = false;
|
|
1012
|
-
function registerDefaultAuthModules() {
|
|
1013
|
-
if (!authModulesRegistered) {
|
|
1014
|
-
registerAuthModule("apikey", apikey_default);
|
|
1015
|
-
registerAuthModule("cookie", cookie_default);
|
|
1016
|
-
registerAuthModule("none", none_default);
|
|
1017
|
-
registerAuthModule("oauth2", oauth_default);
|
|
1018
|
-
registerAuthModule("windowscookie", windows_cookie_default);
|
|
1019
|
-
authModulesRegistered = true;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
registerDefaultAuthModules();
|
|
1023
|
-
var auth = {
|
|
1024
|
-
logout,
|
|
1025
|
-
registerAuthModule,
|
|
1026
|
-
setDefaultHostConfig: setDefaultHostConfig2,
|
|
1027
|
-
getRestCallAuthParams,
|
|
1028
|
-
getWebSocketAuthParams,
|
|
1029
|
-
getWebResourceAuthParams,
|
|
1030
|
-
handleAuthenticationError,
|
|
1031
|
-
toValidLocationUrl,
|
|
1032
|
-
toValidEnigmaLocationUrl,
|
|
1033
|
-
toValidWebsocketLocationUrl,
|
|
1034
|
-
isWindows,
|
|
1035
|
-
isHostCrossOrigin
|
|
1036
|
-
};
|
|
1037
|
-
var auth_default = auth;
|
|
1038
|
-
|
|
1039
|
-
// src/invoke-fetch/internal/invoke-fetch-helpers.ts
|
|
1040
|
-
function encodeQueryParams(query) {
|
|
1041
|
-
if (query) {
|
|
1042
|
-
return Object.entries(query).map((kv) => {
|
|
1043
|
-
const [, value] = kv;
|
|
1044
|
-
if (value === void 0) {
|
|
1045
|
-
return void 0;
|
|
1046
|
-
}
|
|
1047
|
-
return kv.map(
|
|
1048
|
-
(val) => (
|
|
1049
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1050
|
-
encodeURIComponent(val)
|
|
1051
|
-
)
|
|
1052
|
-
).join("=");
|
|
1053
|
-
}).filter(Boolean).join("&");
|
|
1054
|
-
}
|
|
1055
|
-
return "";
|
|
1056
|
-
}
|
|
1057
|
-
function applyPathVariables(pathTemplate, pathVariables) {
|
|
1058
|
-
let result2 = pathTemplate;
|
|
1059
|
-
if (pathVariables) {
|
|
1060
|
-
Object.keys(pathVariables).forEach((key) => {
|
|
1061
|
-
result2 = result2.replace(`{${key}}`, pathVariables[key]);
|
|
1062
|
-
});
|
|
1063
|
-
}
|
|
1064
|
-
return result2;
|
|
1065
|
-
}
|
|
1066
|
-
function toCacheKey(url, query, headers) {
|
|
1067
|
-
let cacheKey = url;
|
|
1068
|
-
if (query !== "") {
|
|
1069
|
-
cacheKey = cacheKey.concat(`?${query}`);
|
|
1070
|
-
}
|
|
1071
|
-
if (headers) {
|
|
1072
|
-
cacheKey = cacheKey.concat(`+headers=${JSON.stringify(headers)}`);
|
|
1073
|
-
}
|
|
1074
|
-
return cacheKey;
|
|
1075
|
-
}
|
|
1076
|
-
function toCompleteUrl(url, query) {
|
|
1077
|
-
if (query !== "") {
|
|
1078
|
-
return `${url}?${query}`;
|
|
1079
|
-
}
|
|
1080
|
-
return url;
|
|
1081
|
-
}
|
|
1082
|
-
function shouldUseCachedResult(options, cacheEntry, defaultMaxCacheTime) {
|
|
1083
|
-
if (!cacheEntry || typeof cacheEntry.value === void 0) {
|
|
1084
|
-
return false;
|
|
1085
|
-
}
|
|
1086
|
-
if (_optionalChain([options, 'optionalAccess', _18 => _18.noCache])) {
|
|
1087
|
-
return false;
|
|
1088
|
-
}
|
|
1089
|
-
if (_optionalChain([options, 'optionalAccess', _19 => _19.useCacheIfAfter])) {
|
|
1090
|
-
return options.useCacheIfAfter.getTime() <= cacheEntry.lastPulled;
|
|
1091
|
-
}
|
|
1092
|
-
const age = Date.now() - cacheEntry.lastPulled;
|
|
1093
|
-
if (_optionalChain([options, 'optionalAccess', _20 => _20.maxCacheAge])) {
|
|
1094
|
-
return age <= _optionalChain([options, 'optionalAccess', _21 => _21.maxCacheAge]);
|
|
1095
|
-
}
|
|
1096
|
-
return age < defaultMaxCacheTime;
|
|
1097
|
-
}
|
|
1098
|
-
var shouldPopulateCache = (method) => method === "get" || method === "GET";
|
|
1099
|
-
function clone(value) {
|
|
1100
|
-
if (value && (value instanceof Blob || value instanceof Object && value.toString() === "[object Blob]")) {
|
|
1101
|
-
return value;
|
|
1102
|
-
}
|
|
1103
|
-
if (typeof value === "string") {
|
|
1104
|
-
return value;
|
|
1105
|
-
}
|
|
1106
|
-
return JSON.parse(JSON.stringify(value));
|
|
1107
|
-
}
|
|
1108
|
-
function isModifyingVerb2(verb) {
|
|
1109
|
-
return !(verb === "get" || verb === "GET");
|
|
1110
|
-
}
|
|
1111
|
-
function cacheKeyToUrl(cachedUrl) {
|
|
1112
|
-
const queryIdx = cachedUrl.indexOf("?");
|
|
1113
|
-
if (queryIdx >= 0) {
|
|
1114
|
-
return cachedUrl.substring(0, queryIdx);
|
|
1115
|
-
}
|
|
1116
|
-
const headersIdx = cachedUrl.indexOf("+headers=");
|
|
1117
|
-
if (headersIdx >= 0) {
|
|
1118
|
-
return cachedUrl.substring(0, headersIdx);
|
|
1119
|
-
}
|
|
1120
|
-
return cachedUrl;
|
|
1121
|
-
}
|
|
1122
|
-
function clearRelatedCacheEntries(cache2, cacheKey) {
|
|
1123
|
-
const modifyingUrl = cacheKeyToUrl(cacheKey);
|
|
1124
|
-
for (const existingCacheKey in cache2) {
|
|
1125
|
-
const cleanUrl = cacheKeyToUrl(existingCacheKey);
|
|
1126
|
-
if (
|
|
1127
|
-
// Either up or down the path...
|
|
1128
|
-
modifyingUrl.startsWith(cleanUrl) || cleanUrl.startsWith(modifyingUrl)
|
|
1129
|
-
) {
|
|
1130
|
-
delete cache2[existingCacheKey];
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
function cloneResultPromise(value) {
|
|
1135
|
-
return value.then((resp) => {
|
|
1136
|
-
const result2 = {
|
|
1137
|
-
data: clone(resp.data),
|
|
1138
|
-
headers: resp.headers,
|
|
1139
|
-
status: resp.status
|
|
1140
|
-
};
|
|
1141
|
-
if (resp.next) {
|
|
1142
|
-
result2.next = resp.next;
|
|
1143
|
-
}
|
|
1144
|
-
if (resp.prev) {
|
|
1145
|
-
result2.prev = resp.prev;
|
|
1146
|
-
}
|
|
1147
|
-
return result2;
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1150
|
-
function clearCacheOnError(cacheEntry, cacheKey, value) {
|
|
1151
|
-
return value.catch((error) => {
|
|
1152
|
-
delete cacheEntry[cacheKey];
|
|
1153
|
-
return Promise.reject(error);
|
|
1154
|
-
});
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
// src/invoke-fetch/internal/invoke-fetch-methods.ts
|
|
1158
|
-
var defaultCacheTime = 1e3 * 60 * 10;
|
|
1159
|
-
var cache = {};
|
|
1160
|
-
globalThis.__API_CACHE__DO_NOT_USE_OR_YOU_WILL_BE_FIRED = cache;
|
|
1161
|
-
function clearApiCacheInternal(api) {
|
|
1162
|
-
cache[api] = {};
|
|
1163
|
-
}
|
|
1164
|
-
function getErrorMessage(error) {
|
|
1165
|
-
if (error instanceof Error) {
|
|
1166
|
-
if (error.cause) {
|
|
1167
|
-
if (error.message) {
|
|
1168
|
-
return `${error.message} - ${getErrorMessage(error.cause)}`;
|
|
1169
|
-
}
|
|
1170
|
-
return getErrorMessage(error.cause);
|
|
1171
|
-
}
|
|
1172
|
-
return error.message;
|
|
1173
|
-
}
|
|
1174
|
-
return String(error);
|
|
1175
|
-
}
|
|
1176
|
-
async function fetchAndTransformExceptions(input, init) {
|
|
1177
|
-
try {
|
|
1178
|
-
return await fetch(input, init);
|
|
1179
|
-
} catch (e) {
|
|
1180
|
-
return Promise.reject(new InvokeFetchError(getErrorMessage(e), 0, new Headers(), {}));
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
async function performActualHttpFetch(method, completeUrl, unencodedBody, contentType, options, interceptors, authHeaders, credentials) {
|
|
1184
|
-
const { body, contentTypeHeader, requestOptions } = encodeBody(unencodedBody, _nullishCoalesce(contentType, () => ( "")));
|
|
1185
|
-
const headers = {
|
|
1186
|
-
...contentTypeHeader,
|
|
1187
|
-
...authHeaders,
|
|
1188
|
-
..._optionalChain([options, 'optionalAccess', _22 => _22.headers])
|
|
1189
|
-
};
|
|
1190
|
-
const isCrossOrigin = isHostCrossOrigin(_optionalChain([options, 'optionalAccess', _23 => _23.hostConfig]));
|
|
1191
|
-
let request = {
|
|
1192
|
-
method,
|
|
1193
|
-
credentials,
|
|
1194
|
-
mode: isCrossOrigin ? "cors" : "same-origin",
|
|
1195
|
-
headers,
|
|
1196
|
-
redirect: await isWindows(_optionalChain([options, 'optionalAccess', _24 => _24.hostConfig])) ? "manual" : "follow",
|
|
1197
|
-
body,
|
|
1198
|
-
// body data type must match "Content-Type" header
|
|
1199
|
-
...requestOptions
|
|
1200
|
-
// This adds 'duplex: "half"' if we're sending application/octet-stream, needed in node only.
|
|
1201
|
-
};
|
|
1202
|
-
let fetchTimeoutId;
|
|
1203
|
-
if (_optionalChain([options, 'optionalAccess', _25 => _25.timeoutMs]) && options.timeoutMs > 0) {
|
|
1204
|
-
const controller = new AbortController();
|
|
1205
|
-
fetchTimeoutId = setTimeout(() => {
|
|
1206
|
-
controller.abort();
|
|
1207
|
-
}, options.timeoutMs);
|
|
1208
|
-
request.signal = controller.signal;
|
|
1209
|
-
}
|
|
1210
|
-
if (_optionalChain([interceptors, 'optionalAccess', _26 => _26.request, 'access', _27 => _27.hasInterceptors, 'call', _28 => _28()])) {
|
|
1211
|
-
request = await interceptors.request.apply(completeUrl, request);
|
|
1212
|
-
}
|
|
1213
|
-
const fetchResponse = await fetchAndTransformExceptions(completeUrl, request);
|
|
1214
|
-
if (fetchTimeoutId) {
|
|
1215
|
-
clearTimeout(fetchTimeoutId);
|
|
1216
|
-
}
|
|
1217
|
-
let invokeFetchResponse = await parseFetchResponse(fetchResponse, completeUrl);
|
|
1218
|
-
if (_optionalChain([interceptors, 'optionalAccess', _29 => _29.response, 'access', _30 => _30.hasInterceptors, 'call', _31 => _31()])) {
|
|
1219
|
-
invokeFetchResponse = await interceptors.response.apply(invokeFetchResponse);
|
|
1220
|
-
}
|
|
1221
|
-
return invokeFetchResponse;
|
|
1222
|
-
}
|
|
1223
|
-
function encodeBody(unencodedBody, contentType) {
|
|
1224
|
-
if (!unencodedBody) {
|
|
1225
|
-
return { body: null, contentTypeHeader: {}, requestOptions: {} };
|
|
1226
|
-
}
|
|
1227
|
-
const contentTypeHeader = {};
|
|
1228
|
-
const requestOptions = {};
|
|
1229
|
-
let body = null;
|
|
1230
|
-
switch (contentType) {
|
|
1231
|
-
case "":
|
|
1232
|
-
case "application/json":
|
|
1233
|
-
contentTypeHeader["Content-Type"] = "application/json";
|
|
1234
|
-
body = JSON.stringify(unencodedBody);
|
|
1235
|
-
break;
|
|
1236
|
-
case "multipart/form-data":
|
|
1237
|
-
body = encodeMultipartBody(unencodedBody);
|
|
1238
|
-
break;
|
|
1239
|
-
case "application/octet-stream":
|
|
1240
|
-
contentTypeHeader["Content-Type"] = contentType;
|
|
1241
|
-
requestOptions["duplex"] = "half";
|
|
1242
|
-
body = unencodedBody;
|
|
1243
|
-
break;
|
|
1244
|
-
case "text/plain":
|
|
1245
|
-
if (typeof unencodedBody === "string") {
|
|
1246
|
-
contentTypeHeader["Content-Type"] = contentType;
|
|
1247
|
-
body = unencodedBody;
|
|
1248
|
-
} else {
|
|
1249
|
-
throw new EncodingError(
|
|
1250
|
-
`Cannot send ${typeof unencodedBody} as ${contentType}, body should be a string.`,
|
|
1251
|
-
contentType,
|
|
1252
|
-
unencodedBody
|
|
1253
|
-
);
|
|
1254
|
-
}
|
|
1255
|
-
break;
|
|
1256
|
-
default:
|
|
1257
|
-
throw new EncodingError(
|
|
1258
|
-
`Unsupported content-type "${contentType}", supported are: application/json, multipart/form-data, application/octet-stream and text/plain`,
|
|
1259
|
-
contentType,
|
|
1260
|
-
unencodedBody
|
|
1261
|
-
);
|
|
1262
|
-
}
|
|
1263
|
-
return { body, contentTypeHeader, requestOptions };
|
|
1264
|
-
}
|
|
1265
|
-
function encodeMultipartBody(unencodedBody) {
|
|
1266
|
-
const contentType = "multipart/form-data";
|
|
1267
|
-
if (typeof unencodedBody !== "object") {
|
|
1268
|
-
throw new EncodingError(
|
|
1269
|
-
`Cannot encode ${typeof unencodedBody} as ${contentType}, body should be an object.`,
|
|
1270
|
-
contentType,
|
|
1271
|
-
unencodedBody
|
|
1272
|
-
);
|
|
1273
|
-
}
|
|
1274
|
-
if (Array.isArray(unencodedBody)) {
|
|
1275
|
-
throw new EncodingError(
|
|
1276
|
-
`Cannot encode ${typeof unencodedBody} as ${contentType}, body should be an object.`,
|
|
1277
|
-
contentType,
|
|
1278
|
-
unencodedBody
|
|
1279
|
-
);
|
|
1280
|
-
}
|
|
1281
|
-
if (unencodedBody instanceof FormData) {
|
|
1282
|
-
return unencodedBody;
|
|
1283
|
-
}
|
|
1284
|
-
const form = new FormData();
|
|
1285
|
-
Object.entries(unencodedBody).forEach((entry) => {
|
|
1286
|
-
const [key, value] = entry;
|
|
1287
|
-
switch (typeof value) {
|
|
1288
|
-
case "boolean":
|
|
1289
|
-
case "number":
|
|
1290
|
-
case "string":
|
|
1291
|
-
form.set(key, `${value}`);
|
|
1292
|
-
break;
|
|
1293
|
-
case "object":
|
|
1294
|
-
if (value instanceof Blob) {
|
|
1295
|
-
form.set(key, value);
|
|
1296
|
-
} else if (value instanceof Uint8Array) {
|
|
1297
|
-
const data = new Blob([value], { type: "application/octet-stream" });
|
|
1298
|
-
form.set(key, data);
|
|
1299
|
-
} else {
|
|
1300
|
-
const json = JSON.stringify(value);
|
|
1301
|
-
const data = new Blob([json], { type: "application/json" });
|
|
1302
|
-
form.set(key, data, "");
|
|
1303
|
-
}
|
|
1304
|
-
break;
|
|
1305
|
-
default:
|
|
1306
|
-
throw new EncodingError(
|
|
1307
|
-
`Cannot encode multipart-field "${key}" with value of type ${typeof value}, values must be objects, strings, numbers or boolean.`,
|
|
1308
|
-
contentType,
|
|
1309
|
-
unencodedBody
|
|
1310
|
-
);
|
|
1311
|
-
}
|
|
1312
|
-
});
|
|
1313
|
-
return form;
|
|
1314
|
-
}
|
|
1315
|
-
async function getInvokeFetchUrlParams({
|
|
1316
|
-
method,
|
|
1317
|
-
pathTemplate,
|
|
1318
|
-
pathVariables,
|
|
1319
|
-
query,
|
|
1320
|
-
options
|
|
1321
|
-
}) {
|
|
1322
|
-
const locationUrl = toValidLocationUrl(_optionalChain([options, 'optionalAccess', _32 => _32.hostConfig]));
|
|
1323
|
-
const {
|
|
1324
|
-
headers: authHeaders,
|
|
1325
|
-
queryParams: authQueryParams,
|
|
1326
|
-
credentials
|
|
1327
|
-
} = await getRestCallAuthParams({
|
|
1328
|
-
hostConfig: _optionalChain([options, 'optionalAccess', _33 => _33.hostConfig]),
|
|
1329
|
-
method
|
|
1330
|
-
});
|
|
1331
|
-
const url = locationUrl + applyPathVariables(pathTemplate, pathVariables);
|
|
1332
|
-
const queryString = encodeQueryParams({ ...query, ...authQueryParams });
|
|
1333
|
-
const completeUrl = toCompleteUrl(url, queryString);
|
|
1334
|
-
const cacheKey = toCacheKey(url, queryString, _optionalChain([options, 'optionalAccess', _34 => _34.headers]));
|
|
1335
|
-
return { completeUrl, cacheKey, authHeaders, credentials };
|
|
1336
|
-
}
|
|
1337
|
-
function invokeFetchWithUrl(api, props, interceptors) {
|
|
1338
|
-
return invokeFetchWithUrlAndRetry(
|
|
1339
|
-
api,
|
|
1340
|
-
props,
|
|
1341
|
-
async () => {
|
|
1342
|
-
const { cacheKey, authHeaders, credentials } = await getInvokeFetchUrlParams(props);
|
|
1343
|
-
return invokeFetchWithUrlAndRetry(
|
|
1344
|
-
api,
|
|
1345
|
-
{ ...props, cacheKey, authHeaders, credentials },
|
|
1346
|
-
void 0,
|
|
1347
|
-
// only retry once
|
|
1348
|
-
interceptors
|
|
1349
|
-
);
|
|
1350
|
-
},
|
|
1351
|
-
interceptors
|
|
1352
|
-
);
|
|
1353
|
-
}
|
|
1354
|
-
function invokeFetchWithUrlAndRetry(api, { method, completeUrl, cacheKey, body, options, authHeaders, credentials, contentType }, performRetry, interceptors) {
|
|
1355
|
-
if (!cache[api]) {
|
|
1356
|
-
cache[api] = {};
|
|
1357
|
-
}
|
|
1358
|
-
const cacheEntry = isModifyingVerb2(method) ? void 0 : cache[api][cacheKey];
|
|
1359
|
-
if (isModifyingVerb2(method)) {
|
|
1360
|
-
clearRelatedCacheEntries(cache[api], cacheKey);
|
|
1361
|
-
}
|
|
1362
|
-
if (cacheEntry && shouldUseCachedResult(options, cacheEntry, defaultCacheTime)) {
|
|
1363
|
-
cacheEntry.lastHit = /* @__PURE__ */ new Date();
|
|
1364
|
-
cacheEntry.hitCount += 1;
|
|
1365
|
-
cacheEntry.accessedPaths.add(globalThis.location ? globalThis.location.pathname : "node");
|
|
1366
|
-
return cloneResultPromise(cacheEntry.value);
|
|
1367
|
-
}
|
|
1368
|
-
const resultPromiseFromBackend = performActualHttpFetch(
|
|
1369
|
-
method,
|
|
1370
|
-
completeUrl,
|
|
1371
|
-
body,
|
|
1372
|
-
contentType,
|
|
1373
|
-
options,
|
|
1374
|
-
interceptors,
|
|
1375
|
-
authHeaders,
|
|
1376
|
-
credentials
|
|
1377
|
-
);
|
|
1378
|
-
const resultAfterAuthenticationCheck = interceptAuthenticationErrors(
|
|
1379
|
-
_optionalChain([options, 'optionalAccess', _35 => _35.hostConfig]),
|
|
1380
|
-
resultPromiseFromBackend,
|
|
1381
|
-
performRetry
|
|
1382
|
-
);
|
|
1383
|
-
const resultPromiseAfterPagingAddon = addPagingFunctions(
|
|
1384
|
-
api,
|
|
1385
|
-
resultAfterAuthenticationCheck,
|
|
1386
|
-
method,
|
|
1387
|
-
body,
|
|
1388
|
-
options,
|
|
1389
|
-
interceptors,
|
|
1390
|
-
authHeaders,
|
|
1391
|
-
credentials
|
|
1392
|
-
);
|
|
1393
|
-
const resultPromiseAfterCacheClearing = clearCacheOnError(cache[api], cacheKey, resultPromiseAfterPagingAddon);
|
|
1394
|
-
if (shouldPopulateCache(method)) {
|
|
1395
|
-
if (Object.hasOwn && !Object.hasOwn(cache, api) || api === "__proto__") {
|
|
1396
|
-
throw new Error(`Forbidden api name: ${api}`);
|
|
1397
|
-
}
|
|
1398
|
-
cache[api][cacheKey] = {
|
|
1399
|
-
lastPulled: Date.now(),
|
|
1400
|
-
value: resultPromiseAfterCacheClearing,
|
|
1401
|
-
lastHit: null,
|
|
1402
|
-
hitCount: 0,
|
|
1403
|
-
accessedPaths: /* @__PURE__ */ new Set()
|
|
1404
|
-
};
|
|
1405
|
-
}
|
|
1406
|
-
return cloneResultPromise(resultPromiseAfterCacheClearing);
|
|
1407
|
-
}
|
|
1408
|
-
function addPagingFunctions(api, value, method, body, options, interceptors, authHeaders, credentials) {
|
|
1409
|
-
return value.then((resp) => {
|
|
1410
|
-
const dataWithPotentialLinks = resp.data;
|
|
1411
|
-
if (!dataWithPotentialLinks) {
|
|
1412
|
-
return resp;
|
|
1413
|
-
}
|
|
1414
|
-
const prevUrl = _optionalChain([dataWithPotentialLinks, 'access', _36 => _36.links, 'optionalAccess', _37 => _37.prev, 'optionalAccess', _38 => _38.href]);
|
|
1415
|
-
const nextUrl = _optionalChain([dataWithPotentialLinks, 'access', _39 => _39.links, 'optionalAccess', _40 => _40.next, 'optionalAccess', _41 => _41.href]);
|
|
1416
|
-
if (prevUrl) {
|
|
1417
|
-
resp.prev = (prevOptions) => invokeFetchWithUrl(
|
|
1418
|
-
api,
|
|
1419
|
-
{
|
|
1420
|
-
method,
|
|
1421
|
-
completeUrl: prevUrl,
|
|
1422
|
-
body,
|
|
1423
|
-
options: prevOptions || options,
|
|
1424
|
-
cacheKey: toCacheKey(prevUrl, "", _optionalChain([options, 'optionalAccess', _42 => _42.headers])),
|
|
1425
|
-
authHeaders,
|
|
1426
|
-
credentials
|
|
1427
|
-
},
|
|
1428
|
-
interceptors
|
|
1429
|
-
);
|
|
1430
|
-
}
|
|
1431
|
-
if (nextUrl) {
|
|
1432
|
-
resp.next = (nextOptions) => invokeFetchWithUrl(
|
|
1433
|
-
api,
|
|
1434
|
-
{
|
|
1435
|
-
method,
|
|
1436
|
-
completeUrl: nextUrl,
|
|
1437
|
-
body,
|
|
1438
|
-
options: nextOptions || options,
|
|
1439
|
-
cacheKey: toCacheKey(nextUrl, "", _optionalChain([options, 'optionalAccess', _43 => _43.headers])),
|
|
1440
|
-
authHeaders,
|
|
1441
|
-
credentials
|
|
1442
|
-
},
|
|
1443
|
-
interceptors
|
|
1444
|
-
);
|
|
1445
|
-
}
|
|
1446
|
-
return resp;
|
|
1447
|
-
});
|
|
1448
|
-
}
|
|
1449
|
-
function neverResolvingPromise() {
|
|
1450
|
-
return new Promise(() => {
|
|
1451
|
-
});
|
|
1452
|
-
}
|
|
1453
|
-
async function interceptAuthenticationErrors(hostConfig, resultPromise, performRetry) {
|
|
1454
|
-
try {
|
|
1455
|
-
return await resultPromise;
|
|
1456
|
-
} catch (error) {
|
|
1457
|
-
const err = error;
|
|
1458
|
-
if (err.status === 401 || err.status === 403 || (err.status === 301 || err.status === 302) && await isWindows(hostConfig)) {
|
|
1459
|
-
if (globalThis.loggingOut) {
|
|
1460
|
-
return await neverResolvingPromise();
|
|
1461
|
-
}
|
|
1462
|
-
const { retry, preventDefault } = await handleAuthenticationError({
|
|
1463
|
-
hostConfig,
|
|
1464
|
-
status: err.status,
|
|
1465
|
-
headers: err.headers,
|
|
1466
|
-
errorBody: err.data,
|
|
1467
|
-
canRetry: !!performRetry
|
|
1468
|
-
});
|
|
1469
|
-
if (retry && performRetry) {
|
|
1470
|
-
return await performRetry();
|
|
1471
|
-
}
|
|
1472
|
-
if (preventDefault) {
|
|
1473
|
-
return neverResolvingPromise();
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
throw error;
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
function toDownloadableBlob(blob) {
|
|
1480
|
-
const result2 = blob;
|
|
1481
|
-
result2.download = (filename) => download(blob, filename);
|
|
1482
|
-
return result2;
|
|
1483
|
-
}
|
|
1484
|
-
async function download(blob, filename) {
|
|
1485
|
-
if (isBrowser()) {
|
|
1486
|
-
const a = document.createElement("a");
|
|
1487
|
-
a.href = window.URL.createObjectURL(blob);
|
|
1488
|
-
a.download = filename;
|
|
1489
|
-
a.click();
|
|
1490
|
-
} else {
|
|
1491
|
-
const { writeFileSync } = await Promise.resolve().then(() => _interopRequireWildcard(require("fs")));
|
|
1492
|
-
writeFileSync(filename, Buffer.from(await blob.arrayBuffer()));
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
|
|
1496
|
-
// src/invoke-fetch/invoke-fetch-error.ts
|
|
1497
|
-
var InvokeFetchError = class extends Error {
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
constructor(errorMessage, status, headers, data) {
|
|
1502
|
-
super(errorMessage);
|
|
1503
|
-
this.status = status;
|
|
1504
|
-
this.headers = headers;
|
|
1505
|
-
this.data = data;
|
|
1506
|
-
this.stack = cleanStack(this.stack);
|
|
1507
|
-
}
|
|
1508
|
-
};
|
|
1509
|
-
var EncodingError = class extends Error {
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
constructor(errorMessage, contentType, data) {
|
|
1513
|
-
super(errorMessage);
|
|
1514
|
-
this.contentType = contentType;
|
|
1515
|
-
this.data = data;
|
|
1516
|
-
this.stack = cleanStack(this.stack);
|
|
1517
|
-
}
|
|
1518
|
-
};
|
|
1519
|
-
var regex = /^.+\/qmfe-api(?:\.js)?:(\d+)(?::\d+)?$/gim;
|
|
1520
|
-
var isFromQmfeApi = (line) => {
|
|
1521
|
-
const matches = line.match(regex);
|
|
1522
|
-
return Boolean(matches && matches.length > 0);
|
|
1523
|
-
};
|
|
1524
|
-
function cleanStack(stack) {
|
|
1525
|
-
if (!stack) {
|
|
1526
|
-
return stack;
|
|
1527
|
-
}
|
|
1528
|
-
const newStack = [];
|
|
1529
|
-
const lines = stack.split("\n");
|
|
1530
|
-
lines.reverse();
|
|
1531
|
-
for (const line of lines) {
|
|
1532
|
-
if (isFromQmfeApi(line)) {
|
|
1533
|
-
break;
|
|
1534
|
-
}
|
|
1535
|
-
newStack.unshift(line);
|
|
1536
|
-
}
|
|
1537
|
-
return newStack.join("\n");
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
// src/invoke-fetch/invoke-fetch-functions.ts
|
|
1541
|
-
async function invokeFetch(api, props, interceptors) {
|
|
1542
|
-
checkForCrossDomainRequest(_optionalChain([props, 'access', _44 => _44.options, 'optionalAccess', _45 => _45.hostConfig]));
|
|
1543
|
-
const { completeUrl, cacheKey, authHeaders, credentials } = await getInvokeFetchUrlParams(props);
|
|
1544
|
-
return invokeFetchWithUrl(
|
|
1545
|
-
api,
|
|
1546
|
-
{ ...props, method: props.method.toUpperCase(), completeUrl, cacheKey, authHeaders, credentials },
|
|
1547
|
-
interceptors
|
|
1548
|
-
);
|
|
1549
|
-
}
|
|
1550
|
-
function clearApiCache(api) {
|
|
1551
|
-
clearApiCacheInternal(api);
|
|
1552
|
-
}
|
|
1553
|
-
async function parseFetchResponse(fetchResponse, url) {
|
|
1554
|
-
let resultData;
|
|
1555
|
-
const contentType = _optionalChain([fetchResponse, 'access', _46 => _46.headers, 'access', _47 => _47.get, 'call', _48 => _48("content-type"), 'optionalAccess', _49 => _49.split, 'call', _50 => _50(";"), 'access', _51 => _51[0]]);
|
|
1556
|
-
switch (contentType) {
|
|
1557
|
-
case "image/png":
|
|
1558
|
-
case "image/jpeg":
|
|
1559
|
-
case "image/x-icon":
|
|
1560
|
-
case "application/offset+octet-stream":
|
|
1561
|
-
case "application/octet-stream":
|
|
1562
|
-
resultData = toDownloadableBlob(await fetchResponse.blob());
|
|
1563
|
-
break;
|
|
1564
|
-
default:
|
|
1565
|
-
try {
|
|
1566
|
-
resultData = await fetchResponse.text();
|
|
1567
|
-
resultData = JSON.parse(resultData);
|
|
1568
|
-
} catch (e3) {
|
|
1569
|
-
}
|
|
1570
|
-
break;
|
|
1571
|
-
}
|
|
1572
|
-
const { status, statusText, headers } = fetchResponse;
|
|
1573
|
-
const errorMsg = `request to '${url}' failed with status ${status} ${statusText}.`;
|
|
1574
|
-
if (status >= 300) {
|
|
1575
|
-
throw new InvokeFetchError(errorMsg, status, headers, resultData);
|
|
1576
|
-
}
|
|
1577
|
-
if (status === 0) {
|
|
1578
|
-
throw new InvokeFetchError(errorMsg, 302, headers, resultData);
|
|
1579
|
-
}
|
|
1580
|
-
const invokeFetchResponse = {
|
|
1581
|
-
status,
|
|
1582
|
-
headers,
|
|
1583
|
-
data: resultData
|
|
1584
|
-
};
|
|
1585
|
-
return invokeFetchResponse;
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
// src/invoke-fetch/invoke-fetch.ts
|
|
1589
|
-
var invokeFetchExp = {
|
|
1590
|
-
invokeFetch,
|
|
1591
|
-
clearApiCache,
|
|
1592
|
-
parseFetchResponse
|
|
1593
|
-
};
|
|
1594
|
-
var invoke_fetch_default = invokeFetchExp;
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
exports.getPlatform = getPlatform; exports.InvalidHostConfigError = InvalidHostConfigError; exports.UnexpectedAuthTypeError = UnexpectedAuthTypeError; exports.InvalidAuthTypeError = InvalidAuthTypeError; exports.AuthorizationError = AuthorizationError; exports.isHostCrossOrigin = isHostCrossOrigin; exports.isWindows = isWindows; exports.toValidLocationUrl = toValidLocationUrl; exports.toValidEnigmaLocationUrl = toValidEnigmaLocationUrl; exports.toValidWebsocketLocationUrl = toValidWebsocketLocationUrl; exports.getWebSocketAuthParams = getWebSocketAuthParams; exports.getWebResourceAuthParams = getWebResourceAuthParams; exports.handleAuthenticationError = handleAuthenticationError; exports.getRestCallAuthParams = getRestCallAuthParams; exports.registerAuthModule = registerAuthModule2; exports.setDefaultHostConfig = setDefaultHostConfig2; exports.checkForCrossDomainRequest = checkForCrossDomainRequest; exports.logout = logout; exports.generateRandomString = generateRandomString; exports.InvokeFetchError = InvokeFetchError; exports.EncodingError = EncodingError; exports.invokeFetch = invokeFetch; exports.clearApiCache = clearApiCache; exports.parseFetchResponse = parseFetchResponse; exports.invoke_fetch_default = invoke_fetch_default; exports.auth_default = auth_default;
|