@qlik/api 0.0.2 → 0.0.3
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/api-keys.d.mts +14 -0
- package/api-keys.d.ts +14 -0
- package/api-keys.js +14 -10
- package/api-keys.mjs +6 -2
- package/apps.d.mts +478 -148
- package/apps.d.ts +478 -148
- package/apps.js +100 -42
- package/apps.mjs +60 -2
- package/audits.d.mts +12 -0
- package/audits.d.ts +12 -0
- package/audits.js +10 -9
- package/audits.mjs +3 -2
- package/auth-AWZV4DPP.js +41 -0
- package/{auth-RTFXVSSK.mjs → auth-CPBNNC7S.mjs} +4 -1
- package/auth.js +4 -3
- package/auth.mjs +3 -2
- package/automations.d.mts +36 -0
- package/automations.d.ts +36 -0
- package/automations.js +28 -21
- package/automations.mjs +9 -2
- package/brands.d.mts +45 -4
- package/brands.d.ts +45 -4
- package/brands.js +20 -15
- package/brands.mjs +7 -2
- package/{chunk-ZT4C7KCQ.js → chunk-2STFUQKQ.js} +3 -3
- package/{chunk-7REWEWCX.mjs → chunk-3SVRHJII.mjs} +3 -3
- package/{chunk-CKPJE4IA.mjs → chunk-67GJTTPV.mjs} +1 -1
- package/{chunk-M7F4JFOB.js → chunk-7RY3NO6N.js} +2 -2
- package/{chunk-NALKLKZS.mjs → chunk-CYRLVHU3.mjs} +316 -53
- package/{chunk-RMKP2BDX.js → chunk-D52VW5UN.js} +318 -55
- package/{chunk-GUQBHY3H.mjs → chunk-GNWU6SP2.mjs} +1 -1
- package/{chunk-QN23TPIE.js → chunk-GV5SRHY2.js} +4 -4
- package/{chunk-OULT3V2U.js → chunk-JNGURO23.js} +3 -3
- package/chunk-P57PW2II.js +11 -0
- package/{chunk-3YE7EI7I.mjs → chunk-TE7XMBT5.mjs} +1 -1
- package/chunk-ZFXKCRJC.mjs +11 -0
- package/collections.d.mts +51 -17
- package/collections.d.ts +51 -17
- package/collections.js +28 -14
- package/collections.mjs +16 -2
- package/csp-origins.d.mts +12 -0
- package/csp-origins.d.ts +12 -0
- package/csp-origins.js +12 -9
- package/csp-origins.mjs +5 -2
- package/data-assets.d.mts +10 -0
- package/data-assets.d.ts +10 -0
- package/data-assets.js +13 -8
- package/data-assets.mjs +7 -2
- package/data-connections.d.mts +18 -0
- package/data-connections.d.ts +18 -0
- package/data-connections.js +19 -12
- package/data-connections.mjs +9 -2
- package/data-credentials.d.mts +8 -0
- package/data-credentials.d.ts +8 -0
- package/data-credentials.js +10 -7
- package/data-credentials.mjs +5 -2
- package/data-files.d.mts +98 -13
- package/data-files.d.ts +98 -13
- package/data-files.js +22 -15
- package/data-files.mjs +9 -2
- package/{enigma-session-VPPJMBEM.js → enigma-session-XPXDQAIV.js} +5 -4
- package/{enigma-session-HGXKZJVO.mjs → enigma-session-ZH6MYA54.mjs} +2 -1
- package/{esm-RX7B2TUN.js → esm-3VXX2GKL.js} +3 -1
- package/{esm-M5ZBFTVD.mjs → esm-OY4XVIJB.mjs} +3 -1
- package/extensions.d.mts +26 -2
- package/extensions.d.ts +26 -2
- package/extensions.js +13 -10
- package/extensions.mjs +5 -2
- package/glossaries.d.mts +55 -20
- package/glossaries.d.ts +55 -20
- package/glossaries.js +39 -27
- package/glossaries.mjs +14 -2
- package/groups.d.mts +16 -0
- package/groups.d.ts +16 -0
- package/groups.js +16 -11
- package/groups.mjs +7 -2
- package/identity-providers.d.mts +16 -0
- package/identity-providers.d.ts +16 -0
- package/identity-providers.js +14 -11
- package/identity-providers.mjs +5 -2
- package/index.js +135 -101
- package/index.mjs +131 -97
- package/{invoke-fetch-IMO4AMA3.mjs → invoke-fetch-3WZWAAZH.mjs} +4 -1
- package/invoke-fetch-UNTAUR7O.js +17 -0
- package/items.d.mts +6 -6
- package/items.d.ts +6 -6
- package/items.js +14 -11
- package/items.mjs +5 -2
- package/licenses.d.mts +18 -0
- package/licenses.d.ts +18 -0
- package/licenses.js +17 -12
- package/licenses.mjs +7 -2
- package/package.json +4 -4
- package/{qix-K22VHZRH.js → qix-UNWXPGMA.js} +9 -8
- package/{qix-57WD2ZE6.mjs → qix-ZSJ4PIK3.mjs} +3 -2
- package/qix.d.mts +1 -1
- package/qix.d.ts +1 -1
- package/qix.js +4 -3
- package/qix.mjs +3 -2
- package/quotas.d.mts +4 -0
- package/quotas.d.ts +4 -0
- package/quotas.js +6 -5
- package/quotas.mjs +3 -2
- package/reload-tasks.js +11 -8
- package/reload-tasks.mjs +5 -2
- package/reloads.d.mts +17 -10
- package/reloads.d.ts +17 -10
- package/reloads.js +9 -7
- package/reloads.mjs +4 -2
- package/roles.d.mts +4 -0
- package/roles.d.ts +4 -0
- package/roles.js +6 -5
- package/roles.mjs +3 -2
- package/spaces.d.mts +27 -4
- package/spaces.d.ts +27 -4
- package/spaces.js +21 -15
- package/spaces.mjs +8 -2
- package/temp-contents.d.mts +8 -3
- package/temp-contents.d.ts +8 -3
- package/temp-contents.js +8 -6
- package/temp-contents.mjs +4 -2
- package/tenants.d.mts +12 -0
- package/tenants.d.ts +12 -0
- package/tenants.js +14 -9
- package/tenants.mjs +7 -2
- package/themes.d.mts +26 -2
- package/themes.d.ts +26 -2
- package/themes.js +13 -10
- package/themes.mjs +5 -2
- package/transports.d.mts +12 -0
- package/transports.d.ts +12 -0
- package/transports.js +12 -9
- package/transports.mjs +5 -2
- package/users.d.mts +48 -29
- package/users.d.ts +48 -29
- package/users.js +18 -13
- package/users.mjs +7 -2
- package/web-integrations.d.mts +10 -0
- package/web-integrations.d.ts +10 -0
- package/web-integrations.js +11 -8
- package/web-integrations.mjs +5 -2
- package/web-notifications.d.mts +12 -0
- package/web-notifications.d.ts +12 -0
- package/web-notifications.js +12 -9
- package/web-notifications.mjs +5 -2
- package/webhooks.d.mts +25 -5
- package/webhooks.d.ts +25 -5
- package/webhooks.js +17 -13
- package/webhooks.mjs +6 -2
- package/auth-CSVTXOZX.js +0 -36
- package/auth-OU7OTB7Y.js +0 -38
- package/auth-TE272Q34.mjs +0 -36
- package/chunk-4ES65KO3.js +0 -57
- package/chunk-4FLMND6T.js +0 -25
- package/chunk-4OMEH5SW.mjs +0 -1337
- package/chunk-6JERR27K.js +0 -17
- package/chunk-E42WUFCK.mjs +0 -57
- package/chunk-H7SAZYEE.js +0 -21
- package/chunk-KMMWJZHM.mjs +0 -25
- package/chunk-W4J34XGA.mjs +0 -17
- package/chunk-WM7FQU2U.mjs +0 -21
- package/chunk-XASXL2NC.js +0 -1337
- package/enigma-session-4L373ALV.mjs +0 -10196
- package/enigma-session-TEB53FAF.js +0 -10196
- package/esm-4X3DKK5D.js +0 -63
- package/esm-SOWVJKOQ.mjs +0 -63
- package/invoke-fetch-7PKPQ3FD.js +0 -14
- package/invoke-fetch-MSSJAZ7K.mjs +0 -14
- package/invoke-fetch-PEI54KZO.js +0 -14
- package/qix-EU7PXRZ6.mjs +0 -573
- package/qix-RLTISYTB.js +0 -573
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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 _chunkP57PW2IIjs = require('./chunk-P57PW2II.js');
|
|
4
|
+
|
|
5
|
+
// src/platform/platform-functions.ts
|
|
2
6
|
var getPlatform = async (options = {}) => {
|
|
3
7
|
const isNodeEnvironment = typeof window === "undefined";
|
|
4
8
|
if (isNodeEnvironment) {
|
|
@@ -175,6 +179,21 @@ var InvalidAuthTypeError = class extends Error {
|
|
|
175
179
|
this.name = "InvalidAuthTypeError";
|
|
176
180
|
}
|
|
177
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
|
+
};
|
|
178
197
|
|
|
179
198
|
// src/auth/auth-functions.ts
|
|
180
199
|
function isHostCrossOrigin(hostConfig) {
|
|
@@ -465,9 +484,17 @@ var none_default = {
|
|
|
465
484
|
validateHostConfig: (hostConfig) => internalValidateHostConfig(hostConfig, { requiredProps: [], optionalProps: [] })
|
|
466
485
|
};
|
|
467
486
|
|
|
487
|
+
// src/utils/utils.ts
|
|
488
|
+
function isBrowser() {
|
|
489
|
+
return typeof window === "object" && typeof window.document === "object";
|
|
490
|
+
}
|
|
491
|
+
function isNode() {
|
|
492
|
+
return typeof process === "object" && typeof _chunkP57PW2IIjs.__require === "function";
|
|
493
|
+
}
|
|
494
|
+
|
|
468
495
|
// src/auth/internal/default-auth-modules/oauth/storage-helpers.ts
|
|
469
496
|
var storagePrefix = "qlik-qmfe-api";
|
|
470
|
-
var
|
|
497
|
+
var cachedTokens = {};
|
|
471
498
|
function saveInLocalStorage(scope, name, value) {
|
|
472
499
|
localStorage.setItem(`${storagePrefix}-${scope}-${name}`, value);
|
|
473
500
|
}
|
|
@@ -480,11 +507,11 @@ function loadFromLocalStorage(scope, name) {
|
|
|
480
507
|
function loadFromSessionStorage(scope, name) {
|
|
481
508
|
return sessionStorage.getItem(`${storagePrefix}-${scope}-${name}`) || void 0;
|
|
482
509
|
}
|
|
483
|
-
function deleteFromLocalStorage(scope,
|
|
484
|
-
localStorage.removeItem(`${storagePrefix}-${scope}-${name}`);
|
|
510
|
+
function deleteFromLocalStorage(scope, names) {
|
|
511
|
+
names.forEach((name) => localStorage.removeItem(`${storagePrefix}-${scope}-${name}`));
|
|
485
512
|
}
|
|
486
|
-
function deleteFromSessionStorage(scope,
|
|
487
|
-
sessionStorage.removeItem(`${storagePrefix}-${scope}-${name}`);
|
|
513
|
+
function deleteFromSessionStorage(scope, names) {
|
|
514
|
+
names.forEach((name) => sessionStorage.removeItem(`${storagePrefix}-${scope}-${name}`));
|
|
488
515
|
}
|
|
489
516
|
function loadAndDeleteFromSessionStorage(scope, name) {
|
|
490
517
|
const id = `${storagePrefix}-${scope}-${name}`;
|
|
@@ -492,43 +519,70 @@ function loadAndDeleteFromSessionStorage(scope, name) {
|
|
|
492
519
|
sessionStorage.removeItem(id);
|
|
493
520
|
return result2;
|
|
494
521
|
}
|
|
495
|
-
function
|
|
522
|
+
function loadOauthTokensFromStorage(hostConfig) {
|
|
496
523
|
if (!hostConfig.clientId) {
|
|
497
524
|
return void 0;
|
|
498
525
|
}
|
|
526
|
+
let accessToken;
|
|
527
|
+
let refreshToken;
|
|
499
528
|
if (hostConfig.accessTokenStorage === "local") {
|
|
500
|
-
|
|
529
|
+
accessToken = loadFromLocalStorage(hostConfig.clientId, "access-token");
|
|
530
|
+
refreshToken = loadFromLocalStorage(hostConfig.clientId, "refresh-token");
|
|
531
|
+
} else if (hostConfig.accessTokenStorage === "session") {
|
|
532
|
+
accessToken = loadFromSessionStorage(hostConfig.clientId, "access-token");
|
|
533
|
+
refreshToken = loadFromSessionStorage(hostConfig.clientId, "refresh-token");
|
|
501
534
|
}
|
|
502
|
-
if (
|
|
503
|
-
return
|
|
535
|
+
if (accessToken) {
|
|
536
|
+
return {
|
|
537
|
+
accessToken,
|
|
538
|
+
refreshToken
|
|
539
|
+
};
|
|
504
540
|
}
|
|
505
541
|
return void 0;
|
|
506
542
|
}
|
|
507
|
-
async function
|
|
543
|
+
async function loadCachedOauthTokens(hostConfig) {
|
|
544
|
+
return cachedTokens[hostConfig.clientId];
|
|
545
|
+
}
|
|
546
|
+
async function loadOrAcquireAccessToken(hostConfig, acquireTokens) {
|
|
508
547
|
if (!hostConfig.clientId) {
|
|
509
548
|
throw new InvalidHostConfigError('A host config with authType set to "oauth2" has to also provide a clientId');
|
|
510
549
|
}
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
if (
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
550
|
+
const mayUseStorage = isBrowser();
|
|
551
|
+
const storedOauthTokens = cachedTokens[hostConfig.clientId] || (mayUseStorage ? loadOauthTokensFromStorage(hostConfig) : void 0);
|
|
552
|
+
if (storedOauthTokens) {
|
|
553
|
+
return Promise.resolve(storedOauthTokens);
|
|
554
|
+
}
|
|
555
|
+
const tokensPromise = acquireTokens();
|
|
556
|
+
cachedTokens[hostConfig.clientId] = tokensPromise;
|
|
557
|
+
if (mayUseStorage) {
|
|
558
|
+
const tokens = await tokensPromise;
|
|
559
|
+
if (hostConfig.accessTokenStorage === "local" && tokens) {
|
|
560
|
+
if (tokens.accessToken) {
|
|
561
|
+
saveInLocalStorage(hostConfig.clientId, "access-token", tokens.accessToken);
|
|
562
|
+
}
|
|
563
|
+
if (tokens.refreshToken) {
|
|
564
|
+
saveInLocalStorage(hostConfig.clientId, "refresh-token", tokens.refreshToken);
|
|
565
|
+
}
|
|
566
|
+
} else if (hostConfig.accessTokenStorage === "session" && tokens) {
|
|
567
|
+
if (tokens.accessToken) {
|
|
568
|
+
saveInSessionStorage(hostConfig.clientId, "access-token", tokens.accessToken);
|
|
569
|
+
}
|
|
570
|
+
if (tokens.refreshToken) {
|
|
571
|
+
saveInSessionStorage(hostConfig.clientId, "refresh-token", tokens.refreshToken);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
522
574
|
}
|
|
523
|
-
return
|
|
575
|
+
return tokensPromise;
|
|
524
576
|
}
|
|
525
|
-
function
|
|
577
|
+
function clearStoredOauthTokens(hostConfig) {
|
|
526
578
|
if (!hostConfig.clientId) {
|
|
527
579
|
throw new InvalidHostConfigError('A host config with authType set to "oauth2" has to also provide a clientId');
|
|
528
580
|
}
|
|
529
|
-
delete
|
|
530
|
-
|
|
531
|
-
|
|
581
|
+
delete cachedTokens[hostConfig.clientId];
|
|
582
|
+
if (isBrowser()) {
|
|
583
|
+
deleteFromLocalStorage(hostConfig.clientId, ["access-token", "refresh-token"]);
|
|
584
|
+
deleteFromSessionStorage(hostConfig.clientId, ["access-token", "refresh-token"]);
|
|
585
|
+
}
|
|
532
586
|
}
|
|
533
587
|
|
|
534
588
|
// src/auth/internal/default-auth-modules/oauth/callback.ts
|
|
@@ -575,16 +629,21 @@ function toBase64Url(uint8Array) {
|
|
|
575
629
|
}
|
|
576
630
|
function byteArrayToBase64(hashArray) {
|
|
577
631
|
let result2 = "";
|
|
578
|
-
if (
|
|
579
|
-
result2 = Buffer.from(hashArray).toString("base64");
|
|
580
|
-
} else if (typeof window !== "undefined" && typeof window.btoa === "function") {
|
|
632
|
+
if (isBrowser()) {
|
|
581
633
|
const byteArrayToString = String.fromCharCode.apply(null, hashArray);
|
|
582
|
-
result2 =
|
|
634
|
+
result2 = btoa(byteArrayToString);
|
|
635
|
+
} else if (isNode()) {
|
|
636
|
+
result2 = Buffer.from(hashArray).toString("base64");
|
|
583
637
|
} else {
|
|
584
|
-
throw new Error("Environment not supported");
|
|
638
|
+
throw new Error("Environment not supported for oauth2 authentication");
|
|
585
639
|
}
|
|
586
640
|
return result2;
|
|
587
641
|
}
|
|
642
|
+
function handlePossibleErrors(data) {
|
|
643
|
+
if (data.errors) {
|
|
644
|
+
throw new AuthorizationError(data.errors);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
588
647
|
async function sha256(message) {
|
|
589
648
|
const msgBuffer = new TextEncoder().encode(message);
|
|
590
649
|
const hashBuffer = await globalThis.crypto.subtle.digest("SHA-256", msgBuffer);
|
|
@@ -606,7 +665,7 @@ async function startFullPageLoginFlow(hostConfig) {
|
|
|
606
665
|
const codeChallenge = await sha256(verifier);
|
|
607
666
|
const redirectUri = hostConfig.redirectUri || globalThis.location.href;
|
|
608
667
|
const scopes = ["user_default"];
|
|
609
|
-
|
|
668
|
+
clearStoredOauthTokens(hostConfig);
|
|
610
669
|
saveInSessionStorage(clientId, "state", state);
|
|
611
670
|
saveInSessionStorage(clientId, "verifier", verifier);
|
|
612
671
|
saveInSessionStorage(clientId, "href", globalThis.location.href);
|
|
@@ -641,9 +700,11 @@ async function exchangeCodeAndVerifierForAccessTokenData(hostConfig, code, verif
|
|
|
641
700
|
})
|
|
642
701
|
});
|
|
643
702
|
const data = await result2.json();
|
|
703
|
+
handlePossibleErrors(data);
|
|
644
704
|
return {
|
|
645
705
|
accessToken: data.access_token,
|
|
646
|
-
refreshToken: data.refresh_token
|
|
706
|
+
refreshToken: data.refresh_token,
|
|
707
|
+
errors: data.errors
|
|
647
708
|
};
|
|
648
709
|
} catch (err) {
|
|
649
710
|
console.error(err);
|
|
@@ -651,29 +712,85 @@ async function exchangeCodeAndVerifierForAccessTokenData(hostConfig, code, verif
|
|
|
651
712
|
});
|
|
652
713
|
}
|
|
653
714
|
}
|
|
654
|
-
async function
|
|
715
|
+
async function getOauthTokensWithCredentials(baseUrl, clientId, clientSecret, scope = "user_default") {
|
|
716
|
+
const result2 = await fetch(`${baseUrl}/oauth/token`, {
|
|
717
|
+
method: "POST",
|
|
718
|
+
mode: "cors",
|
|
719
|
+
headers: { "content-type": "application/json" },
|
|
720
|
+
body: JSON.stringify({
|
|
721
|
+
grant_type: "client_credentials",
|
|
722
|
+
client_id: clientId,
|
|
723
|
+
client_secret: clientSecret,
|
|
724
|
+
scope
|
|
725
|
+
})
|
|
726
|
+
});
|
|
727
|
+
const data = await result2.json();
|
|
728
|
+
return {
|
|
729
|
+
accessToken: data.access_token,
|
|
730
|
+
refreshToken: data.refresh_token,
|
|
731
|
+
errors: data.errors
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
async function getOauthTokensWithRefreshToken(baseUrl, refreshToken, clientSecret) {
|
|
735
|
+
const result2 = await fetch(`${baseUrl}/oauth/token`, {
|
|
736
|
+
method: "POST",
|
|
737
|
+
mode: "cors",
|
|
738
|
+
headers: { "content-type": "application/json" },
|
|
739
|
+
body: JSON.stringify({
|
|
740
|
+
grant_type: "refresh_token",
|
|
741
|
+
refresh_token: refreshToken,
|
|
742
|
+
client_secret: clientSecret
|
|
743
|
+
})
|
|
744
|
+
});
|
|
745
|
+
const data = await result2.json();
|
|
746
|
+
return {
|
|
747
|
+
accessToken: data.access_token,
|
|
748
|
+
refreshToken: data.refresh_token,
|
|
749
|
+
errors: data.errors
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
async function getOAuthTokensForNode(hostConfig) {
|
|
753
|
+
const { clientId, clientSecret } = hostConfig;
|
|
754
|
+
if (!clientId || !clientSecret) {
|
|
755
|
+
throw new InvalidHostConfigError(
|
|
756
|
+
'A host config with authType set to "oauth2" has to provide a clientId and a clientSecret'
|
|
757
|
+
);
|
|
758
|
+
}
|
|
759
|
+
const oauthTokens = await loadOrAcquireAccessToken(
|
|
760
|
+
hostConfig,
|
|
761
|
+
async () => getOauthTokensWithCredentials(
|
|
762
|
+
toValidLocationUrl(hostConfig),
|
|
763
|
+
hostConfig.clientId,
|
|
764
|
+
// @ts-expect-error clientSecret is not yet in HostConfig type
|
|
765
|
+
hostConfig.clientSecret,
|
|
766
|
+
hostConfig.scope
|
|
767
|
+
)
|
|
768
|
+
);
|
|
769
|
+
return oauthTokens;
|
|
770
|
+
}
|
|
771
|
+
async function getOAuthTokensForBrowser(hostConfig) {
|
|
655
772
|
const { clientId } = hostConfig;
|
|
656
773
|
if (!clientId) {
|
|
657
774
|
throw new InvalidHostConfigError('A host config with authType set to "oauth2" has to also provide a clientId');
|
|
658
775
|
}
|
|
659
|
-
const
|
|
776
|
+
const oauthTokens = await loadOrAcquireAccessToken(hostConfig, async () => {
|
|
660
777
|
const code = loadAndDeleteFromSessionStorage(clientId, "code");
|
|
661
778
|
const verifier = loadAndDeleteFromSessionStorage(clientId, "verifier");
|
|
662
779
|
if (code && verifier) {
|
|
663
|
-
const
|
|
780
|
+
const tokenResponse = await exchangeCodeAndVerifierForAccessTokenData(
|
|
664
781
|
hostConfig,
|
|
665
782
|
code,
|
|
666
783
|
verifier,
|
|
667
784
|
hostConfig.redirectUri
|
|
668
785
|
);
|
|
669
|
-
if (
|
|
670
|
-
return
|
|
786
|
+
if (tokenResponse) {
|
|
787
|
+
return tokenResponse;
|
|
671
788
|
}
|
|
672
789
|
}
|
|
673
790
|
return void 0;
|
|
674
791
|
});
|
|
675
|
-
if (
|
|
676
|
-
return
|
|
792
|
+
if (oauthTokens) {
|
|
793
|
+
return oauthTokens;
|
|
677
794
|
}
|
|
678
795
|
if (hostConfig.authRedirectUserConfirmation) {
|
|
679
796
|
await hostConfig.authRedirectUserConfirmation();
|
|
@@ -682,10 +799,41 @@ async function getOAuthAccessTokenInternal(hostConfig) {
|
|
|
682
799
|
return new Promise(() => {
|
|
683
800
|
});
|
|
684
801
|
}
|
|
685
|
-
var
|
|
802
|
+
var lastOauthTokensCall = Promise.resolve("");
|
|
686
803
|
async function getOAuthAccessToken(hostConfig) {
|
|
687
|
-
|
|
688
|
-
|
|
804
|
+
let getOauthTokensCall;
|
|
805
|
+
if (isNode()) {
|
|
806
|
+
getOauthTokensCall = getOAuthTokensForNode;
|
|
807
|
+
} else {
|
|
808
|
+
getOauthTokensCall = getOAuthTokensForBrowser;
|
|
809
|
+
}
|
|
810
|
+
lastOauthTokensCall = lastOauthTokensCall.then(async () => {
|
|
811
|
+
const tokens = await getOauthTokensCall(hostConfig);
|
|
812
|
+
if (tokens) {
|
|
813
|
+
handlePossibleErrors(tokens);
|
|
814
|
+
return tokens.accessToken || "";
|
|
815
|
+
}
|
|
816
|
+
return "";
|
|
817
|
+
});
|
|
818
|
+
return lastOauthTokensCall;
|
|
819
|
+
}
|
|
820
|
+
async function refreshAccessToken(hostConfig) {
|
|
821
|
+
const tokens = await loadCachedOauthTokens(hostConfig);
|
|
822
|
+
clearStoredOauthTokens(hostConfig);
|
|
823
|
+
if (tokens && tokens.refreshToken) {
|
|
824
|
+
const refreshedTokens = await loadOrAcquireAccessToken(
|
|
825
|
+
hostConfig,
|
|
826
|
+
async () => getOauthTokensWithRefreshToken(
|
|
827
|
+
toValidLocationUrl(hostConfig),
|
|
828
|
+
tokens.refreshToken,
|
|
829
|
+
// @ts-expect-error clientSecret is not yet in HostConfig type
|
|
830
|
+
hostConfig.clientSecret
|
|
831
|
+
)
|
|
832
|
+
);
|
|
833
|
+
if (refreshedTokens) {
|
|
834
|
+
handlePossibleErrors(refreshedTokens);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
689
837
|
}
|
|
690
838
|
|
|
691
839
|
// src/auth/internal/default-auth-modules/oauth/temporary-token.ts
|
|
@@ -718,7 +866,7 @@ async function exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, pur
|
|
|
718
866
|
}
|
|
719
867
|
|
|
720
868
|
// src/auth/internal/default-auth-modules/oauth.ts
|
|
721
|
-
if (
|
|
869
|
+
if (isBrowser()) {
|
|
722
870
|
handleOAuthCallback();
|
|
723
871
|
}
|
|
724
872
|
async function getRestCallAuthParams5({
|
|
@@ -757,12 +905,19 @@ async function getWebResourceAuthParams2({
|
|
|
757
905
|
async function handleAuthenticationError5({
|
|
758
906
|
hostConfig
|
|
759
907
|
}) {
|
|
760
|
-
if (
|
|
761
|
-
|
|
908
|
+
if (isBrowser()) {
|
|
909
|
+
if (hostConfig.authRedirectUserConfirmation) {
|
|
910
|
+
await hostConfig.authRedirectUserConfirmation();
|
|
911
|
+
}
|
|
912
|
+
startFullPageLoginFlow(hostConfig);
|
|
913
|
+
return {
|
|
914
|
+
preventDefault: true
|
|
915
|
+
};
|
|
762
916
|
}
|
|
763
|
-
|
|
917
|
+
await refreshAccessToken(hostConfig);
|
|
764
918
|
return {
|
|
765
|
-
preventDefault:
|
|
919
|
+
preventDefault: false,
|
|
920
|
+
retry: true
|
|
766
921
|
};
|
|
767
922
|
}
|
|
768
923
|
var oauth_default = {
|
|
@@ -772,7 +927,7 @@ var oauth_default = {
|
|
|
772
927
|
handleAuthenticationError: handleAuthenticationError5,
|
|
773
928
|
validateHostConfig: (hostConfig) => internalValidateHostConfig(hostConfig, {
|
|
774
929
|
requiredProps: ["clientId"],
|
|
775
|
-
optionalProps: ["redirectUri", "accessTokenStorage"]
|
|
930
|
+
optionalProps: ["clientSecret", "redirectUri", "accessTokenStorage"]
|
|
776
931
|
})
|
|
777
932
|
};
|
|
778
933
|
|
|
@@ -1017,9 +1172,10 @@ async function fetchAndTransformExceptions(input, init) {
|
|
|
1017
1172
|
return Promise.reject(new InvokeFetchError(getErrorMessage(e), 0, new Headers(), {}));
|
|
1018
1173
|
}
|
|
1019
1174
|
}
|
|
1020
|
-
async function performActualHttpFetch(method, completeUrl,
|
|
1175
|
+
async function performActualHttpFetch(method, completeUrl, unencodedBody, contentType, options, interceptors, authHeaders, credentials) {
|
|
1176
|
+
const { body, contentTypeHeader, requestOptions } = encodeBody(unencodedBody, _nullishCoalesce(contentType, () => ( "")));
|
|
1021
1177
|
const headers = {
|
|
1022
|
-
|
|
1178
|
+
...contentTypeHeader,
|
|
1023
1179
|
...authHeaders,
|
|
1024
1180
|
..._optionalChain([options, 'optionalAccess', _22 => _22.headers])
|
|
1025
1181
|
};
|
|
@@ -1030,8 +1186,10 @@ async function performActualHttpFetch(method, completeUrl, body, options, interc
|
|
|
1030
1186
|
mode: isCrossOrigin ? "cors" : "same-origin",
|
|
1031
1187
|
headers,
|
|
1032
1188
|
redirect: await isWindows(_optionalChain([options, 'optionalAccess', _24 => _24.hostConfig])) ? "manual" : "follow",
|
|
1033
|
-
body
|
|
1189
|
+
body,
|
|
1034
1190
|
// body data type must match "Content-Type" header
|
|
1191
|
+
...requestOptions
|
|
1192
|
+
// This adds 'duplex: "half"' if we're sending application/octet-stream, needed in node only.
|
|
1035
1193
|
};
|
|
1036
1194
|
let fetchTimeoutId;
|
|
1037
1195
|
if (_optionalChain([options, 'optionalAccess', _25 => _25.timeoutMs]) && options.timeoutMs > 0) {
|
|
@@ -1054,6 +1212,98 @@ async function performActualHttpFetch(method, completeUrl, body, options, interc
|
|
|
1054
1212
|
}
|
|
1055
1213
|
return invokeFetchResponse;
|
|
1056
1214
|
}
|
|
1215
|
+
function encodeBody(unencodedBody, contentType) {
|
|
1216
|
+
if (!unencodedBody) {
|
|
1217
|
+
return { body: null, contentTypeHeader: {}, requestOptions: {} };
|
|
1218
|
+
}
|
|
1219
|
+
const contentTypeHeader = {};
|
|
1220
|
+
const requestOptions = {};
|
|
1221
|
+
let body = null;
|
|
1222
|
+
switch (contentType) {
|
|
1223
|
+
case "":
|
|
1224
|
+
case "application/json":
|
|
1225
|
+
contentTypeHeader["Content-Type"] = "application/json";
|
|
1226
|
+
body = JSON.stringify(unencodedBody);
|
|
1227
|
+
break;
|
|
1228
|
+
case "multipart/form-data":
|
|
1229
|
+
body = encodeMultipartBody(unencodedBody);
|
|
1230
|
+
break;
|
|
1231
|
+
case "application/octet-stream":
|
|
1232
|
+
contentTypeHeader["Content-Type"] = contentType;
|
|
1233
|
+
requestOptions["duplex"] = "half";
|
|
1234
|
+
body = unencodedBody;
|
|
1235
|
+
break;
|
|
1236
|
+
case "text/plain":
|
|
1237
|
+
if (typeof unencodedBody === "string") {
|
|
1238
|
+
contentTypeHeader["Content-Type"] = contentType;
|
|
1239
|
+
body = unencodedBody;
|
|
1240
|
+
} else {
|
|
1241
|
+
throw new EncodingError(
|
|
1242
|
+
`Cannot send ${typeof unencodedBody} as ${contentType}, body should be a string.`,
|
|
1243
|
+
contentType,
|
|
1244
|
+
unencodedBody
|
|
1245
|
+
);
|
|
1246
|
+
}
|
|
1247
|
+
break;
|
|
1248
|
+
default:
|
|
1249
|
+
throw new EncodingError(
|
|
1250
|
+
`Unsupported content-type "${contentType}", supported are: application/json, multipart/form-data, application/octet-stream and text/plain`,
|
|
1251
|
+
contentType,
|
|
1252
|
+
unencodedBody
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
return { body, contentTypeHeader, requestOptions };
|
|
1256
|
+
}
|
|
1257
|
+
function encodeMultipartBody(unencodedBody) {
|
|
1258
|
+
const contentType = "multipart/form-data";
|
|
1259
|
+
if (typeof unencodedBody !== "object") {
|
|
1260
|
+
throw new EncodingError(
|
|
1261
|
+
`Cannot encode ${typeof unencodedBody} as ${contentType}, body should be an object.`,
|
|
1262
|
+
contentType,
|
|
1263
|
+
unencodedBody
|
|
1264
|
+
);
|
|
1265
|
+
}
|
|
1266
|
+
if (Array.isArray(unencodedBody)) {
|
|
1267
|
+
throw new EncodingError(
|
|
1268
|
+
`Cannot encode ${typeof unencodedBody} as ${contentType}, body should be an object.`,
|
|
1269
|
+
contentType,
|
|
1270
|
+
unencodedBody
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
if (unencodedBody instanceof FormData) {
|
|
1274
|
+
return unencodedBody;
|
|
1275
|
+
}
|
|
1276
|
+
const form = new FormData();
|
|
1277
|
+
Object.entries(unencodedBody).forEach((entry) => {
|
|
1278
|
+
const [key, value] = entry;
|
|
1279
|
+
switch (typeof value) {
|
|
1280
|
+
case "boolean":
|
|
1281
|
+
case "number":
|
|
1282
|
+
case "string":
|
|
1283
|
+
form.set(key, `${value}`);
|
|
1284
|
+
break;
|
|
1285
|
+
case "object":
|
|
1286
|
+
if (value instanceof Blob) {
|
|
1287
|
+
form.set(key, value);
|
|
1288
|
+
} else if (value instanceof Uint8Array) {
|
|
1289
|
+
const data = new Blob([value], { type: "application/octet-stream" });
|
|
1290
|
+
form.set(key, data);
|
|
1291
|
+
} else {
|
|
1292
|
+
const json = JSON.stringify(value);
|
|
1293
|
+
const data = new Blob([json], { type: "application/json" });
|
|
1294
|
+
form.set(key, data, "");
|
|
1295
|
+
}
|
|
1296
|
+
break;
|
|
1297
|
+
default:
|
|
1298
|
+
throw new EncodingError(
|
|
1299
|
+
`Cannot encode multipart-field "${key}" with value of type ${typeof value}, values must be objects, strings, numbers or boolean.`,
|
|
1300
|
+
contentType,
|
|
1301
|
+
unencodedBody
|
|
1302
|
+
);
|
|
1303
|
+
}
|
|
1304
|
+
});
|
|
1305
|
+
return form;
|
|
1306
|
+
}
|
|
1057
1307
|
async function getInvokeFetchUrlParams({
|
|
1058
1308
|
method,
|
|
1059
1309
|
pathTemplate,
|
|
@@ -1093,7 +1343,7 @@ function invokeFetchWithUrl(api, props, interceptors) {
|
|
|
1093
1343
|
interceptors
|
|
1094
1344
|
);
|
|
1095
1345
|
}
|
|
1096
|
-
function invokeFetchWithUrlAndRetry(api, { method, completeUrl, cacheKey, body, options, authHeaders, credentials }, performRetry, interceptors) {
|
|
1346
|
+
function invokeFetchWithUrlAndRetry(api, { method, completeUrl, cacheKey, body, options, authHeaders, credentials, contentType }, performRetry, interceptors) {
|
|
1097
1347
|
if (!cache[api]) {
|
|
1098
1348
|
cache[api] = {};
|
|
1099
1349
|
}
|
|
@@ -1111,6 +1361,7 @@ function invokeFetchWithUrlAndRetry(api, { method, completeUrl, cacheKey, body,
|
|
|
1111
1361
|
method,
|
|
1112
1362
|
completeUrl,
|
|
1113
1363
|
body,
|
|
1364
|
+
contentType,
|
|
1114
1365
|
options,
|
|
1115
1366
|
interceptors,
|
|
1116
1367
|
authHeaders,
|
|
@@ -1250,6 +1501,16 @@ var InvokeFetchError = class extends Error {
|
|
|
1250
1501
|
this.stack = cleanStack(this.stack);
|
|
1251
1502
|
}
|
|
1252
1503
|
};
|
|
1504
|
+
var EncodingError = class extends Error {
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
constructor(errorMessage, contentType, data) {
|
|
1508
|
+
super(errorMessage);
|
|
1509
|
+
this.contentType = contentType;
|
|
1510
|
+
this.data = data;
|
|
1511
|
+
this.stack = cleanStack(this.stack);
|
|
1512
|
+
}
|
|
1513
|
+
};
|
|
1253
1514
|
var regex = /^.+\/qmfe-api(?:\.js)?:(\d+)(?::\d+)?$/gim;
|
|
1254
1515
|
var isFromQmfeApi = (line) => {
|
|
1255
1516
|
const matches = line.match(regex);
|
|
@@ -1339,4 +1600,6 @@ var invoke_fetch_default = invokeFetchExp;
|
|
|
1339
1600
|
|
|
1340
1601
|
|
|
1341
1602
|
|
|
1342
|
-
|
|
1603
|
+
|
|
1604
|
+
|
|
1605
|
+
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.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;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk2STFUQKQjs = require('./chunk-2STFUQKQ.js');
|
|
4
4
|
|
|
5
5
|
// src/public/auth.ts
|
|
6
6
|
function registerAuthModule(name, authModule) {
|
|
7
|
-
void
|
|
7
|
+
void _chunk2STFUQKQjs.getAuthRuntimeModule.call(void 0, ).then((impl) => impl.registerAuthModule(name, authModule));
|
|
8
8
|
}
|
|
9
9
|
function logout() {
|
|
10
|
-
void
|
|
10
|
+
void _chunk2STFUQKQjs.getAuthRuntimeModule.call(void 0, ).then((impl) => impl.logout());
|
|
11
11
|
}
|
|
12
12
|
function setDefaultHostConfig(hostConfig) {
|
|
13
|
-
void
|
|
13
|
+
void _chunk2STFUQKQjs.getAuthRuntimeModule.call(void 0, hostConfig).then((impl) => impl.setDefaultHostConfig(hostConfig));
|
|
14
14
|
}
|
|
15
15
|
var auth_default = {
|
|
16
16
|
registerAuthModule,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk2STFUQKQjs = require('./chunk-2STFUQKQ.js');
|
|
4
4
|
|
|
5
5
|
// src/public/invoke-fetch.ts
|
|
6
6
|
async function invokeFetch(api, props) {
|
|
7
7
|
const hostConfig = _optionalChain([props, 'access', _ => _.options, 'optionalAccess', _2 => _2.hostConfig]);
|
|
8
|
-
return (await
|
|
8
|
+
return (await _chunk2STFUQKQjs.getInvokeFetchRuntimeModule.call(void 0, hostConfig)).invokeFetch(api, props);
|
|
9
9
|
}
|
|
10
10
|
function clearApiCache(api) {
|
|
11
|
-
void
|
|
11
|
+
void _chunk2STFUQKQjs.getInvokeFetchRuntimeModule.call(void 0, ).then((runtimeModule) => runtimeModule.clearApiCache(api));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.__require = __require;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
__require
|
|
11
|
+
};
|