@qlik/api 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-keys.d.ts +2 -2
- package/api-keys.js +2 -2
- package/apps.d.ts +4 -2
- package/apps.js +2 -2
- package/audits.d.ts +2 -2
- package/audits.js +2 -2
- package/{auth-types-nnUcWhuU.d.ts → auth-types-1P4wuncR.d.ts} +5 -1
- package/auth.d.ts +7 -3
- package/auth.js +4 -2
- package/automations.d.ts +2 -2
- package/automations.js +2 -2
- package/brands.d.ts +2 -2
- package/brands.js +2 -2
- package/chunks/{JEGN7XQV.js → AEXRZSVI.js} +3 -3
- package/chunks/{XZQNE4HH.js → F36DZZYS.js} +7 -2
- package/chunks/{L2BJNKLV.js → H46323PG.js} +3 -1
- package/chunks/{SIU6HO6B.js → LJNLYKW3.js} +160 -29
- package/chunks/{FFGE2RP7.js → QOUQIYWW.js} +1 -1
- package/chunks/{TT66UJZY.js → TDKU6D4Z.js} +3 -3
- package/chunks/{CHNBNLXY.js → VVREBIN2.js} +2 -2
- package/chunks/{RHF624NQ.js → ZT55IZXB.js} +1 -1
- package/chunks/{XOVMZWDC.js → ZVNQOWQU.js} +1 -1
- package/collections.d.ts +2 -2
- package/collections.js +2 -2
- package/csp-origins.d.ts +2 -2
- package/csp-origins.js +2 -2
- package/data-assets.d.ts +2 -2
- package/data-assets.js +2 -2
- package/data-connections.d.ts +2 -2
- package/data-connections.js +2 -2
- package/data-credentials.d.ts +2 -2
- package/data-credentials.js +2 -2
- package/data-files.d.ts +2 -2
- package/data-files.js +2 -2
- package/extensions.d.ts +2 -2
- package/extensions.js +2 -2
- package/{global.types-TzVhFPid.d.ts → global.types-B14bb3X9.d.ts} +23 -1
- package/glossaries.d.ts +2 -2
- package/glossaries.js +2 -2
- package/groups.d.ts +2 -2
- package/groups.js +2 -2
- package/identity-providers.d.ts +2 -2
- package/identity-providers.js +2 -2
- package/index.d.ts +4 -3
- package/index.js +4 -4
- package/items.d.ts +2 -2
- package/items.js +2 -2
- package/licenses.d.ts +2 -2
- package/licenses.js +2 -2
- package/package.json +1 -1
- package/qix.d.ts +3 -3
- package/qix.js +2 -2
- package/quotas.d.ts +2 -2
- package/quotas.js +2 -2
- package/reload-tasks.d.ts +2 -2
- package/reload-tasks.js +2 -2
- package/reloads.d.ts +2 -2
- package/reloads.js +2 -2
- package/roles.d.ts +2 -2
- package/roles.js +2 -2
- package/spaces.d.ts +2 -2
- package/spaces.js +2 -2
- package/temp-contents.d.ts +2 -2
- package/temp-contents.js +2 -2
- package/tenants.d.ts +2 -2
- package/tenants.js +2 -2
- package/themes.d.ts +2 -2
- package/themes.js +2 -2
- package/transports.d.ts +2 -2
- package/transports.js +2 -2
- package/users.d.ts +2 -2
- package/users.js +2 -2
- package/web-integrations.d.ts +2 -2
- package/web-integrations.js +2 -2
- package/web-notifications.d.ts +2 -2
- package/web-notifications.js +2 -2
- package/webhooks.d.ts +2 -2
- package/webhooks.js +2 -2
package/api-keys.d.ts
CHANGED
package/api-keys.js
CHANGED
package/apps.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ApiCallOptions, D as DownloadableBlob } from './global.types-
|
|
2
|
-
import './auth-types-
|
|
1
|
+
import { A as ApiCallOptions, D as DownloadableBlob } from './global.types-B14bb3X9.js';
|
|
2
|
+
import './auth-types-1P4wuncR.js';
|
|
3
3
|
|
|
4
4
|
type Analysis = "breakdown" | "changePoint" | "comparison" | "contribution" | "correlation" | "fact" | "mutualInfo" | "rank" | "spike" | "trend" | "values";
|
|
5
5
|
type AnalysisComposition = {
|
|
@@ -801,6 +801,8 @@ type ReloadIncludeFile = {
|
|
|
801
801
|
connection?: string;
|
|
802
802
|
/** File location within the connection. */
|
|
803
803
|
path?: string;
|
|
804
|
+
/** File QRI resource identifier. */
|
|
805
|
+
qri?: string;
|
|
804
806
|
};
|
|
805
807
|
type ReloadListMetadata = {
|
|
806
808
|
/** Array of ReloadMeta. */
|
package/apps.js
CHANGED
package/audits.d.ts
CHANGED
package/audits.js
CHANGED
|
@@ -28,6 +28,10 @@ type GetWebResourceAuthParamsProps<A extends AuthType = AuthType> = {
|
|
|
28
28
|
type WebResourceAuthParams = {
|
|
29
29
|
queryParams: Record<string, string>;
|
|
30
30
|
};
|
|
31
|
+
type GetRemoteAuthDataProps<A extends AuthType = AuthType> = {
|
|
32
|
+
hostConfig: HostConfig<A>;
|
|
33
|
+
queryParams?: Record<string, string>;
|
|
34
|
+
};
|
|
31
35
|
/** Props for function handleAuthenticationError */
|
|
32
36
|
type HandleAuthenticationErrorProps<A extends AuthType = AuthType> = {
|
|
33
37
|
/** host conifg for connecting to a host */
|
|
@@ -95,4 +99,4 @@ type HostConfigCommon = {
|
|
|
95
99
|
embedRuntimeUrl?: string;
|
|
96
100
|
};
|
|
97
101
|
|
|
98
|
-
export type { AuthType as A, Credentials as C, GetRestCallAuthParamsProps as G, HostConfig as H, RestCallAuthParams as R, WebSocketAuthParams as W, AuthModule as a, GetWebSocketAuthParamsProps as b, GetWebResourceAuthParamsProps as c, WebResourceAuthParams as d,
|
|
102
|
+
export type { AuthType as A, Credentials as C, GetRestCallAuthParamsProps as G, HostConfig as H, RestCallAuthParams as R, WebSocketAuthParams as W, AuthModule as a, GetWebSocketAuthParamsProps as b, GetWebResourceAuthParamsProps as c, WebResourceAuthParams as d, GetRemoteAuthDataProps as e, HandleAuthenticationErrorProps as f, AuthenticationErrorAction as g };
|
package/auth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AuthType, a as AuthModule, H as HostConfig } from './auth-types-
|
|
2
|
-
export {
|
|
1
|
+
import { A as AuthType, a as AuthModule, H as HostConfig } from './auth-types-1P4wuncR.js';
|
|
2
|
+
export { g as AuthenticationErrorAction, C as Credentials, e as GetRemoteAuthDataProps, G as GetRestCallAuthParamsProps, c as GetWebResourceAuthParamsProps, b as GetWebSocketAuthParamsProps, f as HandleAuthenticationErrorProps, R as RestCallAuthParams, d as WebResourceAuthParams, W as WebSocketAuthParams } from './auth-types-1P4wuncR.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Registers an auth module that can handle authentication. An auth module is used by specifying its name as authType in the HostConfig passed in to api calls.
|
|
@@ -18,9 +18,13 @@ declare function logout(): void;
|
|
|
18
18
|
* @param hostConfig the default HostConfig to use
|
|
19
19
|
*/
|
|
20
20
|
declare function setDefaultHostConfig(hostConfig: HostConfig | undefined): void;
|
|
21
|
+
declare function getAccessToken({ hostConfig }: {
|
|
22
|
+
hostConfig?: HostConfig;
|
|
23
|
+
}): Promise<string>;
|
|
21
24
|
declare const _default: {
|
|
22
25
|
registerAuthModule: typeof registerAuthModule;
|
|
23
26
|
setDefaultHostConfig: typeof setDefaultHostConfig;
|
|
27
|
+
getAccessToken: typeof getAccessToken;
|
|
24
28
|
};
|
|
25
29
|
|
|
26
|
-
export { AuthModule, AuthType, HostConfig, _default as default, logout, registerAuthModule, setDefaultHostConfig };
|
|
30
|
+
export { AuthModule, AuthType, HostConfig, _default as default, getAccessToken, logout, registerAuthModule, setDefaultHostConfig };
|
package/auth.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
auth_default,
|
|
3
|
+
getAccessToken,
|
|
3
4
|
logout,
|
|
4
5
|
registerAuthModule,
|
|
5
6
|
setDefaultHostConfig
|
|
6
|
-
} from "./chunks/
|
|
7
|
-
import "./chunks/
|
|
7
|
+
} from "./chunks/F36DZZYS.js";
|
|
8
|
+
import "./chunks/TDKU6D4Z.js";
|
|
8
9
|
import "./chunks/4HB3TAEO.js";
|
|
9
10
|
export {
|
|
10
11
|
auth_default as default,
|
|
12
|
+
getAccessToken,
|
|
11
13
|
logout,
|
|
12
14
|
registerAuthModule,
|
|
13
15
|
setDefaultHostConfig
|
package/automations.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ApiCallOptions } from './global.types-
|
|
2
|
-
import './auth-types-
|
|
1
|
+
import { A as ApiCallOptions } from './global.types-B14bb3X9.js';
|
|
2
|
+
import './auth-types-1P4wuncR.js';
|
|
3
3
|
|
|
4
4
|
type AutomationDetailRequestObject = {
|
|
5
5
|
description?: string;
|
package/automations.js
CHANGED
package/brands.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ApiCallOptions, D as DownloadableBlob } from './global.types-
|
|
2
|
-
import './auth-types-
|
|
1
|
+
import { A as ApiCallOptions, D as DownloadableBlob } from './global.types-B14bb3X9.js';
|
|
2
|
+
import './auth-types-1P4wuncR.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A brand is a collection of assets for applying custom branding. Only a single brand can be active in a tenant.
|
package/brands.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getRestCallAuthParams,
|
|
4
4
|
getWebSocketAuthParams,
|
|
5
5
|
toValidWebsocketLocationUrl
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./LJNLYKW3.js";
|
|
7
7
|
import "./4HB3TAEO.js";
|
|
8
8
|
|
|
9
9
|
// src/qix/session/enigma-session.ts
|
|
@@ -9073,10 +9073,10 @@ NotificationMixin = {
|
|
|
9073
9073
|
}
|
|
9074
9074
|
};
|
|
9075
9075
|
if (process.env.NODE_ENV === "development") {
|
|
9076
|
-
|
|
9076
|
+
globalThis.getNotifications = function() {
|
|
9077
9077
|
return notifications.filter((notification) => notification.observers && notification.observers.length);
|
|
9078
9078
|
};
|
|
9079
|
-
|
|
9079
|
+
globalThis.trackNotifications = function() {
|
|
9080
9080
|
trackNotifications = true;
|
|
9081
9081
|
};
|
|
9082
9082
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getAuthRuntimeModule
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./TDKU6D4Z.js";
|
|
4
4
|
|
|
5
5
|
// src/public/auth.ts
|
|
6
6
|
function registerAuthModule(name, authModule) {
|
|
@@ -12,14 +12,19 @@ function logout() {
|
|
|
12
12
|
function setDefaultHostConfig(hostConfig) {
|
|
13
13
|
void getAuthRuntimeModule(hostConfig).then((impl) => impl.setDefaultHostConfig(hostConfig));
|
|
14
14
|
}
|
|
15
|
+
async function getAccessToken({ hostConfig }) {
|
|
16
|
+
return getAuthRuntimeModule(hostConfig).then((impl) => impl.getAccessToken({ hostConfig }));
|
|
17
|
+
}
|
|
15
18
|
var auth_default = {
|
|
16
19
|
registerAuthModule,
|
|
17
|
-
setDefaultHostConfig
|
|
20
|
+
setDefaultHostConfig,
|
|
21
|
+
getAccessToken
|
|
18
22
|
};
|
|
19
23
|
|
|
20
24
|
export {
|
|
21
25
|
registerAuthModule,
|
|
22
26
|
logout,
|
|
23
27
|
setDefaultHostConfig,
|
|
28
|
+
getAccessToken,
|
|
24
29
|
auth_default
|
|
25
30
|
};
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
UnexpectedAuthTypeError,
|
|
6
6
|
auth_default,
|
|
7
7
|
checkForCrossDomainRequest,
|
|
8
|
+
getAccessToken,
|
|
8
9
|
getRestCallAuthParams,
|
|
9
10
|
getWebResourceAuthParams,
|
|
10
11
|
getWebSocketAuthParams,
|
|
@@ -17,7 +18,7 @@ import {
|
|
|
17
18
|
toValidEnigmaLocationUrl,
|
|
18
19
|
toValidLocationUrl,
|
|
19
20
|
toValidWebsocketLocationUrl
|
|
20
|
-
} from "./
|
|
21
|
+
} from "./LJNLYKW3.js";
|
|
21
22
|
import "./4HB3TAEO.js";
|
|
22
23
|
export {
|
|
23
24
|
AuthorizationError,
|
|
@@ -26,6 +27,7 @@ export {
|
|
|
26
27
|
UnexpectedAuthTypeError,
|
|
27
28
|
checkForCrossDomainRequest,
|
|
28
29
|
auth_default as default,
|
|
30
|
+
getAccessToken,
|
|
29
31
|
getRestCallAuthParams,
|
|
30
32
|
getWebResourceAuthParams,
|
|
31
33
|
getWebSocketAuthParams,
|
|
@@ -82,7 +82,10 @@ function setDefaultHostConfig(hostConfig) {
|
|
|
82
82
|
defaultHostConfig = hostConfig || {};
|
|
83
83
|
}
|
|
84
84
|
function withDefaultHostConfig(hostConfig) {
|
|
85
|
-
|
|
85
|
+
if (hostConfig && Object.keys(hostConfig).length > 0) {
|
|
86
|
+
return hostConfig;
|
|
87
|
+
}
|
|
88
|
+
return defaultHostConfig;
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
// src/auth/internal/auth-module-registry.ts
|
|
@@ -284,6 +287,14 @@ async function getRestCallAuthParams(props) {
|
|
|
284
287
|
hostConfig: hostConfigToUse
|
|
285
288
|
});
|
|
286
289
|
}
|
|
290
|
+
async function getAccessToken(props) {
|
|
291
|
+
const res = await getRestCallAuthParams({ method: "GET", ...props });
|
|
292
|
+
const authorizationHeader = res.headers?.Authorization;
|
|
293
|
+
if (authorizationHeader.indexOf("Bearer ") === 0) {
|
|
294
|
+
return authorizationHeader.substring(7);
|
|
295
|
+
}
|
|
296
|
+
throw new Error("Unknown format of authorization header returned by remote auth module");
|
|
297
|
+
}
|
|
287
298
|
function registerAuthModule2(name, authModule) {
|
|
288
299
|
registerAuthModule(name, authModule);
|
|
289
300
|
}
|
|
@@ -492,10 +503,17 @@ var none_default = {
|
|
|
492
503
|
|
|
493
504
|
// src/utils/utils.ts
|
|
494
505
|
import { nanoid } from "nanoid";
|
|
506
|
+
var forcedEnvironmentForTest;
|
|
495
507
|
function isBrowser() {
|
|
508
|
+
if (forcedEnvironmentForTest) {
|
|
509
|
+
return forcedEnvironmentForTest === "browser";
|
|
510
|
+
}
|
|
496
511
|
return typeof window === "object" && typeof window.document === "object";
|
|
497
512
|
}
|
|
498
513
|
function isNode() {
|
|
514
|
+
if (forcedEnvironmentForTest) {
|
|
515
|
+
return forcedEnvironmentForTest === "node";
|
|
516
|
+
}
|
|
499
517
|
return typeof process === "object" && typeof __require === "function";
|
|
500
518
|
}
|
|
501
519
|
function generateRandomString(targetLength) {
|
|
@@ -505,7 +523,14 @@ function generateRandomString(targetLength) {
|
|
|
505
523
|
// src/auth/internal/default-auth-modules/oauth/storage-helpers.ts
|
|
506
524
|
var storagePrefix = "qlik-qmfe-api";
|
|
507
525
|
function getTopicFromHostConfig(hostConfig) {
|
|
508
|
-
|
|
526
|
+
let topic = `${hostConfig.clientId + (hostConfig.scope ? `_${hostConfig.scope}` : "_user_default")}`;
|
|
527
|
+
if (hostConfig.subject) {
|
|
528
|
+
topic += `_${hostConfig.subject}`;
|
|
529
|
+
}
|
|
530
|
+
if (hostConfig.userId) {
|
|
531
|
+
topic += `_${hostConfig.userId}`;
|
|
532
|
+
}
|
|
533
|
+
return topic;
|
|
509
534
|
}
|
|
510
535
|
var cachedTokens = {};
|
|
511
536
|
function saveInLocalStorage(topic, name, value) {
|
|
@@ -560,6 +585,9 @@ async function loadOrAcquireAccessToken(hostConfig, acquireTokens) {
|
|
|
560
585
|
if (!hostConfig.clientId) {
|
|
561
586
|
throw new InvalidHostConfigError('A host config with authType set to "oauth2" has to also provide a clientId');
|
|
562
587
|
}
|
|
588
|
+
if (hostConfig.noCache) {
|
|
589
|
+
return acquireTokens();
|
|
590
|
+
}
|
|
563
591
|
const mayUseStorage = isBrowser();
|
|
564
592
|
const storedOauthTokens = cachedTokens[getTopicFromHostConfig(hostConfig)] || (mayUseStorage ? loadOauthTokensFromStorage(hostConfig) : void 0);
|
|
565
593
|
if (storedOauthTokens) {
|
|
@@ -628,6 +656,9 @@ function handleOAuthCallback() {
|
|
|
628
656
|
}
|
|
629
657
|
|
|
630
658
|
// src/auth/internal/default-auth-modules/oauth/oauth-utils.ts
|
|
659
|
+
function lookupGetAccessFn(getAccessToken2) {
|
|
660
|
+
return globalThis[getAccessToken2];
|
|
661
|
+
}
|
|
631
662
|
function handlePossibleErrors(data) {
|
|
632
663
|
if (data.errors) {
|
|
633
664
|
throw new AuthorizationError(data.errors);
|
|
@@ -712,17 +743,43 @@ async function exchangeCodeAndVerifierForAccessTokenData(hostConfig, code, verif
|
|
|
712
743
|
});
|
|
713
744
|
}
|
|
714
745
|
}
|
|
715
|
-
|
|
746
|
+
function createBodyWithCredentialsEtc(clientId, clientSecret, scope, subject, userId) {
|
|
747
|
+
const commonProps = {
|
|
748
|
+
client_id: clientId,
|
|
749
|
+
client_secret: clientSecret,
|
|
750
|
+
scope
|
|
751
|
+
};
|
|
752
|
+
if (subject) {
|
|
753
|
+
return {
|
|
754
|
+
...commonProps,
|
|
755
|
+
grant_type: "urn:qlik:oauth:user-impersonation",
|
|
756
|
+
user_lookup: {
|
|
757
|
+
field: "subject",
|
|
758
|
+
value: subject
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
if (userId) {
|
|
763
|
+
return {
|
|
764
|
+
...commonProps,
|
|
765
|
+
grant_type: "urn:qlik:oauth:user-impersonation",
|
|
766
|
+
user_lookup: {
|
|
767
|
+
field: "userId",
|
|
768
|
+
value: userId
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
return {
|
|
773
|
+
...commonProps,
|
|
774
|
+
grant_type: "client_credentials"
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
async function getOauthTokensWithCredentials(baseUrl, clientId, clientSecret, scope = "user_default", subject, userId) {
|
|
716
778
|
const result2 = await fetch(`${baseUrl}/oauth/token`, {
|
|
717
779
|
method: "POST",
|
|
718
780
|
mode: "cors",
|
|
719
781
|
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
|
-
})
|
|
782
|
+
body: JSON.stringify(createBodyWithCredentialsEtc(clientId, clientSecret, scope, subject, userId))
|
|
726
783
|
});
|
|
727
784
|
const data = await result2.json();
|
|
728
785
|
return {
|
|
@@ -766,7 +823,9 @@ async function getOAuthTokensForNode(hostConfig) {
|
|
|
766
823
|
toValidLocationUrl(hostConfig),
|
|
767
824
|
hostConfig.clientId,
|
|
768
825
|
hostConfig.clientSecret,
|
|
769
|
-
hostConfig.scope
|
|
826
|
+
hostConfig.scope,
|
|
827
|
+
hostConfig.subject,
|
|
828
|
+
hostConfig.userId
|
|
770
829
|
);
|
|
771
830
|
});
|
|
772
831
|
return oauthTokens;
|
|
@@ -777,6 +836,30 @@ async function getOAuthTokensForBrowser(hostConfig) {
|
|
|
777
836
|
throw new InvalidHostConfigError('A host config with authType set to "oauth2" has to also provide a clientId');
|
|
778
837
|
}
|
|
779
838
|
const oauthTokens = await loadOrAcquireAccessToken(hostConfig, async () => {
|
|
839
|
+
if (hostConfig.getAccessToken) {
|
|
840
|
+
try {
|
|
841
|
+
const tokenFetchedFromRemote = typeof hostConfig.getAccessToken === "string" ? await lookupGetAccessFn(hostConfig.getAccessToken)() : await hostConfig.getAccessToken();
|
|
842
|
+
return {
|
|
843
|
+
accessToken: tokenFetchedFromRemote,
|
|
844
|
+
refreshToken: void 0,
|
|
845
|
+
errors: void 0
|
|
846
|
+
};
|
|
847
|
+
} catch (error) {
|
|
848
|
+
return {
|
|
849
|
+
accessToken: void 0,
|
|
850
|
+
refreshToken: void 0,
|
|
851
|
+
errors: [
|
|
852
|
+
{
|
|
853
|
+
code: "",
|
|
854
|
+
status: 401,
|
|
855
|
+
title: "Could not fetch access token using custom function",
|
|
856
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
857
|
+
detail: `${error}`
|
|
858
|
+
}
|
|
859
|
+
]
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
}
|
|
780
863
|
const code = loadAndDeleteFromSessionStorage(getTopicFromHostConfig(hostConfig), "code");
|
|
781
864
|
const verifier = loadAndDeleteFromSessionStorage(getTopicFromHostConfig(hostConfig), "verifier");
|
|
782
865
|
if (code && verifier) {
|
|
@@ -804,14 +887,16 @@ async function getOAuthTokensForBrowser(hostConfig) {
|
|
|
804
887
|
}
|
|
805
888
|
var lastOauthTokensCall = Promise.resolve("");
|
|
806
889
|
async function getOAuthAccessToken(hostConfig) {
|
|
807
|
-
let getOauthTokensCall;
|
|
808
890
|
if (isNode()) {
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
891
|
+
const tokens = await getOAuthTokensForNode(hostConfig);
|
|
892
|
+
if (tokens) {
|
|
893
|
+
handlePossibleErrors(tokens);
|
|
894
|
+
return tokens.accessToken || "";
|
|
895
|
+
}
|
|
896
|
+
return "";
|
|
812
897
|
}
|
|
813
898
|
lastOauthTokensCall = lastOauthTokensCall.then(async () => {
|
|
814
|
-
const tokens = await
|
|
899
|
+
const tokens = await getOAuthTokensForBrowser(hostConfig);
|
|
815
900
|
if (tokens) {
|
|
816
901
|
handlePossibleErrors(tokens);
|
|
817
902
|
return tokens.accessToken || "";
|
|
@@ -842,7 +927,7 @@ async function refreshAccessToken(hostConfig) {
|
|
|
842
927
|
|
|
843
928
|
// src/auth/internal/default-auth-modules/oauth/temporary-token.ts
|
|
844
929
|
async function exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, purpose) {
|
|
845
|
-
const
|
|
930
|
+
const response = await fetch(`${toValidLocationUrl(hostConfig)}/oauth/token`, {
|
|
846
931
|
method: "POST",
|
|
847
932
|
credentials: "include",
|
|
848
933
|
mode: "cors",
|
|
@@ -857,22 +942,47 @@ async function exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, pur
|
|
|
857
942
|
client_id: hostConfig.clientId
|
|
858
943
|
})
|
|
859
944
|
});
|
|
860
|
-
if (
|
|
861
|
-
|
|
862
|
-
await hostConfig.authRedirectUserConfirmation();
|
|
863
|
-
}
|
|
864
|
-
startFullPageLoginFlow(hostConfig);
|
|
865
|
-
return new Promise(() => {
|
|
866
|
-
});
|
|
945
|
+
if (response.status !== 200) {
|
|
946
|
+
throw await toError(response);
|
|
867
947
|
}
|
|
868
|
-
const data = await
|
|
948
|
+
const data = await response.json();
|
|
869
949
|
return data.access_token;
|
|
870
950
|
}
|
|
951
|
+
async function toError(response) {
|
|
952
|
+
const body = await response.text();
|
|
953
|
+
try {
|
|
954
|
+
const data = JSON.parse(body);
|
|
955
|
+
return new AuthorizationError(data.errors);
|
|
956
|
+
} catch (err) {
|
|
957
|
+
return new AuthorizationError([
|
|
958
|
+
{
|
|
959
|
+
code: "unknown",
|
|
960
|
+
status: response.status,
|
|
961
|
+
detail: body,
|
|
962
|
+
title: "Unknown authentication error"
|
|
963
|
+
}
|
|
964
|
+
]);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
871
967
|
|
|
872
968
|
// src/auth/internal/default-auth-modules/oauth.ts
|
|
873
969
|
if (isBrowser()) {
|
|
874
970
|
handleOAuthCallback();
|
|
875
971
|
}
|
|
972
|
+
async function handlePotentialAuthenticationErrorAndRetry(hostConfig, fn) {
|
|
973
|
+
try {
|
|
974
|
+
return await fn();
|
|
975
|
+
} catch (err) {
|
|
976
|
+
const { retry } = await handleAuthenticationError5({
|
|
977
|
+
hostConfig,
|
|
978
|
+
canRetry: true
|
|
979
|
+
});
|
|
980
|
+
if (retry) {
|
|
981
|
+
return await fn();
|
|
982
|
+
}
|
|
983
|
+
throw err;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
876
986
|
async function getRestCallAuthParams5({
|
|
877
987
|
hostConfig
|
|
878
988
|
}) {
|
|
@@ -887,8 +997,10 @@ async function getRestCallAuthParams5({
|
|
|
887
997
|
async function getWebSocketAuthParams5({
|
|
888
998
|
hostConfig
|
|
889
999
|
}) {
|
|
890
|
-
const
|
|
891
|
-
|
|
1000
|
+
const websocketAccessToken = await handlePotentialAuthenticationErrorAndRetry(hostConfig, async () => {
|
|
1001
|
+
const accessToken = await getOAuthAccessToken(hostConfig);
|
|
1002
|
+
return exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, "websocket");
|
|
1003
|
+
});
|
|
892
1004
|
return {
|
|
893
1005
|
queryParams: {
|
|
894
1006
|
accessToken: websocketAccessToken
|
|
@@ -898,8 +1010,10 @@ async function getWebSocketAuthParams5({
|
|
|
898
1010
|
async function getWebResourceAuthParams2({
|
|
899
1011
|
hostConfig
|
|
900
1012
|
}) {
|
|
901
|
-
const
|
|
902
|
-
|
|
1013
|
+
const webResourceAccessToken = await handlePotentialAuthenticationErrorAndRetry(hostConfig, async () => {
|
|
1014
|
+
const accessToken = await getOAuthAccessToken(hostConfig);
|
|
1015
|
+
return exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, "webresource");
|
|
1016
|
+
});
|
|
903
1017
|
return {
|
|
904
1018
|
queryParams: {
|
|
905
1019
|
accessToken: webResourceAccessToken
|
|
@@ -909,6 +1023,13 @@ async function getWebResourceAuthParams2({
|
|
|
909
1023
|
async function handleAuthenticationError5({
|
|
910
1024
|
hostConfig
|
|
911
1025
|
}) {
|
|
1026
|
+
if (hostConfig.getAccessToken) {
|
|
1027
|
+
clearStoredOauthTokens(hostConfig);
|
|
1028
|
+
return {
|
|
1029
|
+
preventDefault: false,
|
|
1030
|
+
retry: true
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
912
1033
|
if (isBrowser()) {
|
|
913
1034
|
if (hostConfig.authRedirectUserConfirmation) {
|
|
914
1035
|
await hostConfig.authRedirectUserConfirmation();
|
|
@@ -931,7 +1052,16 @@ var oauth_default = {
|
|
|
931
1052
|
handleAuthenticationError: handleAuthenticationError5,
|
|
932
1053
|
validateHostConfig: (hostConfig) => internalValidateHostConfig(hostConfig, {
|
|
933
1054
|
requiredProps: ["clientId"],
|
|
934
|
-
optionalProps: [
|
|
1055
|
+
optionalProps: [
|
|
1056
|
+
"clientSecret",
|
|
1057
|
+
"redirectUri",
|
|
1058
|
+
"accessTokenStorage",
|
|
1059
|
+
"scope",
|
|
1060
|
+
"subject",
|
|
1061
|
+
"userId",
|
|
1062
|
+
"noCache",
|
|
1063
|
+
"getAccessToken"
|
|
1064
|
+
]
|
|
935
1065
|
})
|
|
936
1066
|
};
|
|
937
1067
|
|
|
@@ -1610,6 +1740,7 @@ export {
|
|
|
1610
1740
|
getWebResourceAuthParams,
|
|
1611
1741
|
handleAuthenticationError,
|
|
1612
1742
|
getRestCallAuthParams,
|
|
1743
|
+
getAccessToken,
|
|
1613
1744
|
registerAuthModule2 as registerAuthModule,
|
|
1614
1745
|
setDefaultHostConfig2 as setDefaultHostConfig,
|
|
1615
1746
|
checkForCrossDomainRequest,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// src/public/public-runtime-modules.ts
|
|
2
2
|
function getAuthRuntimeModule(hostConfig) {
|
|
3
3
|
const isNode = !!globalThis.process?.argv;
|
|
4
|
-
return isNode ? import("./
|
|
4
|
+
return isNode ? import("./H46323PG.js") : import("./OPRGGO4C.js").then((mod) => mod.importRuntimeModule("auth@v1", hostConfig));
|
|
5
5
|
}
|
|
6
6
|
async function getQixRuntimeModule(hostConfig) {
|
|
7
7
|
await getAuthRuntimeModule(hostConfig);
|
|
8
8
|
const isNode = !!globalThis.process?.argv;
|
|
9
|
-
return isNode ? import("./
|
|
9
|
+
return isNode ? import("./VVREBIN2.js") : import("./OPRGGO4C.js").then((mod) => mod.importRuntimeModule("qix@v1", hostConfig));
|
|
10
10
|
}
|
|
11
11
|
async function getInvokeFetchRuntimeModule(hostConfig) {
|
|
12
12
|
await getAuthRuntimeModule(hostConfig);
|
|
13
13
|
const isNode = !!globalThis.process?.argv;
|
|
14
|
-
return isNode ? import("./
|
|
14
|
+
return isNode ? import("./ZVNQOWQU.js") : import("./OPRGGO4C.js").then((mod) => mod.importRuntimeModule("invoke-fetch@v1", hostConfig));
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export {
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
invokeFetch,
|
|
5
5
|
isWindows,
|
|
6
6
|
toValidWebsocketLocationUrl
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./LJNLYKW3.js";
|
|
8
8
|
import "./4HB3TAEO.js";
|
|
9
9
|
|
|
10
10
|
// src/qix/session/shared-sessions.ts
|
|
@@ -83,7 +83,7 @@ function listenForWindowsAuthenticationInformation(session) {
|
|
|
83
83
|
return authSuggestedInWebsocket;
|
|
84
84
|
}
|
|
85
85
|
async function createAndSetupEnigmaSession(props, canRetry) {
|
|
86
|
-
const { createEnigmaSession } = await import("./
|
|
86
|
+
const { createEnigmaSession } = await import("./AEXRZSVI.js");
|
|
87
87
|
const session = await createEnigmaSession(props);
|
|
88
88
|
setupSessionListeners(session, props);
|
|
89
89
|
let global;
|
package/collections.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ApiCallOptions } from './global.types-
|
|
2
|
-
import './auth-types-
|
|
1
|
+
import { A as ApiCallOptions } from './global.types-B14bb3X9.js';
|
|
2
|
+
import './auth-types-1P4wuncR.js';
|
|
3
3
|
|
|
4
4
|
type CollectionByIdPatch = {
|
|
5
5
|
/** The operation to be performed. */
|
package/collections.js
CHANGED