@thoughtspot/visual-embed-sdk 1.11.0-alpha.0 → 1.11.0-auth.10
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/dist/src/auth.d.ts +7 -5
- package/dist/src/embed/base.d.ts +5 -4
- package/dist/src/embed/pinboard.d.ts +91 -0
- package/dist/src/embed/ts-embed.d.ts +1 -0
- package/dist/src/index.d.ts +2 -2
- package/dist/src/types.d.ts +5 -0
- package/dist/src/utils/authService.d.ts +1 -0
- package/dist/src/utils/plugin.d.ts +0 -0
- package/dist/src/v1/api.d.ts +19 -0
- package/dist/tsembed.es.js +78 -17
- package/dist/tsembed.js +78 -16
- package/lib/package.json +1 -1
- package/lib/src/auth.d.ts +7 -5
- package/lib/src/auth.js +37 -7
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.js +16 -11
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +5 -4
- package/lib/src/embed/base.js +4 -1
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +1 -1
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/pinboard.d.ts +91 -0
- package/lib/src/embed/pinboard.js +110 -0
- package/lib/src/embed/pinboard.js.map +1 -0
- package/lib/src/embed/ts-embed.d.ts +1 -0
- package/lib/src/embed/ts-embed.js +16 -6
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +16 -6
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +2 -2
- package/lib/src/index.js +2 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/test/test-utils.js +1 -1
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/types.d.ts +5 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService.d.ts +1 -0
- package/lib/src/utils/authService.js +21 -3
- package/lib/src/utils/authService.js.map +1 -1
- package/lib/src/utils/authService.spec.js +11 -5
- package/lib/src/utils/authService.spec.js.map +1 -1
- package/lib/src/utils/plugin.d.ts +0 -0
- package/lib/src/utils/plugin.js +1 -0
- package/lib/src/utils/plugin.js.map +1 -0
- package/lib/src/visual-embed-sdk.d.ts +12 -6
- package/package.json +1 -1
- package/src/auth.spec.ts +24 -11
- package/src/auth.ts +51 -11
- package/src/embed/base.spec.ts +1 -1
- package/src/embed/base.ts +9 -5
- package/src/embed/ts-embed.spec.ts +19 -9
- package/src/embed/ts-embed.ts +18 -6
- package/src/index.ts +2 -1
- package/src/test/test-utils.ts +1 -1
- package/src/types.ts +6 -0
- package/src/utils/authService.spec.ts +18 -5
- package/src/utils/authService.ts +28 -3
package/dist/src/auth.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare const EndPoints: {
|
|
|
10
10
|
OIDC_LOGIN_TEMPLATE: (targetUrl: string) => string;
|
|
11
11
|
TOKEN_LOGIN: string;
|
|
12
12
|
BASIC_LOGIN: string;
|
|
13
|
+
LOGOUT: string;
|
|
13
14
|
};
|
|
14
15
|
/**
|
|
15
16
|
* Return sessionInfo if available else make a loggedIn check to fetch the sessionInfo
|
|
@@ -20,7 +21,7 @@ export declare function initSession(sessionDetails: any): void;
|
|
|
20
21
|
* Perform token based authentication
|
|
21
22
|
* @param embedConfig The embed configuration
|
|
22
23
|
*/
|
|
23
|
-
export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<
|
|
24
|
+
export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
24
25
|
/**
|
|
25
26
|
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
26
27
|
* credentials.
|
|
@@ -29,14 +30,15 @@ export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<void>;
|
|
|
29
30
|
* strongly advised not to use this authentication method in production.
|
|
30
31
|
* @param embedConfig The embed configuration
|
|
31
32
|
*/
|
|
32
|
-
export declare const doBasicAuth: (embedConfig: EmbedConfig) => Promise<
|
|
33
|
-
export declare const doSamlAuth: (embedConfig: EmbedConfig) => Promise<
|
|
34
|
-
export declare const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<
|
|
33
|
+
export declare const doBasicAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
34
|
+
export declare const doSamlAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
35
|
+
export declare const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
36
|
+
export declare const logout: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
35
37
|
/**
|
|
36
38
|
* Perform authentication on the ThoughtSpot cluster
|
|
37
39
|
* @param embedConfig The embed configuration
|
|
38
40
|
*/
|
|
39
|
-
export declare const authenticate: (embedConfig: EmbedConfig) => Promise<
|
|
41
|
+
export declare const authenticate: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
40
42
|
/**
|
|
41
43
|
* Check if we are authenticated to the ThoughtSpot cluster
|
|
42
44
|
*/
|
package/dist/src/embed/base.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { EmbedConfig } from '../types';
|
|
2
|
-
export declare let authPromise: Promise<
|
|
2
|
+
export declare let authPromise: Promise<boolean>;
|
|
3
3
|
/**
|
|
4
4
|
* Perform authentication on the ThoughtSpot app as applicable.
|
|
5
5
|
*/
|
|
6
|
-
export declare const handleAuth: () => Promise<
|
|
6
|
+
export declare const handleAuth: () => Promise<boolean>;
|
|
7
7
|
export declare const getEmbedConfig: () => EmbedConfig;
|
|
8
|
-
export declare const getAuthPromise: () => Promise<
|
|
8
|
+
export declare const getAuthPromise: () => Promise<boolean>;
|
|
9
9
|
/**
|
|
10
10
|
* Prefetches static resources from the specified URL. Web browsers can then cache the prefetched resources and serve them from the user's local disk to provide faster access to your app.
|
|
11
11
|
* @param url The URL provided for prefetch
|
|
@@ -19,7 +19,8 @@ export declare const prefetch: (url?: string) => void;
|
|
|
19
19
|
*
|
|
20
20
|
* @returns authPromise Promise which resolves when authentication is complete.
|
|
21
21
|
*/
|
|
22
|
-
export declare const init: (embedConfig: EmbedConfig) => Promise<
|
|
22
|
+
export declare const init: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
23
|
+
export declare const logout: () => Promise<boolean>;
|
|
23
24
|
/**
|
|
24
25
|
* Renders functions in a queue, resolves to next function only after the callback next is called
|
|
25
26
|
* @param fn The function being registered
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021
|
|
3
|
+
*
|
|
4
|
+
* Embed a ThoughtSpot pinboard or visualization
|
|
5
|
+
* https://developers.thoughtspot.com/docs/?pageid=embed-pinboard
|
|
6
|
+
* https://developers.thoughtspot.com/docs/?pageid=embed-a-viz
|
|
7
|
+
*
|
|
8
|
+
* @summary Pinboard & visualization embed
|
|
9
|
+
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
10
|
+
*/
|
|
11
|
+
import { DOMSelector } from '../types';
|
|
12
|
+
import { V1Embed, ViewConfig } from './ts-embed';
|
|
13
|
+
/**
|
|
14
|
+
* The configuration for the embedded pinboard or visualization page view.
|
|
15
|
+
* @Category Pinboards and Charts
|
|
16
|
+
*/
|
|
17
|
+
export interface PinboardViewConfig extends ViewConfig {
|
|
18
|
+
/**
|
|
19
|
+
* If set to true, the embedded object container dynamically resizes
|
|
20
|
+
* according to the height of the pinboard.
|
|
21
|
+
*/
|
|
22
|
+
fullHeight?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* This is the minimum height(in pixels) for a full height pinboard.
|
|
25
|
+
* Setting this height helps resolves issues with empty pinboards and
|
|
26
|
+
* other screens navigable from a pinboard.
|
|
27
|
+
* @default 500
|
|
28
|
+
* * _since 1.5.0_
|
|
29
|
+
*/
|
|
30
|
+
defaultHeight?: number;
|
|
31
|
+
/**
|
|
32
|
+
* If set to true, the context menu in visualizations will be enabled.
|
|
33
|
+
*/
|
|
34
|
+
enableVizTransformations?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The pinboard to display in the embedded view.
|
|
37
|
+
*/
|
|
38
|
+
pinboardId: string;
|
|
39
|
+
/**
|
|
40
|
+
* The visualization within the pinboard to display.
|
|
41
|
+
*/
|
|
42
|
+
vizId?: string;
|
|
43
|
+
/**
|
|
44
|
+
* If set to true, all filter chips from a
|
|
45
|
+
* pinboard page will be read-only (no X buttons)
|
|
46
|
+
*/
|
|
47
|
+
preventPinboardFilterRemoval?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* An array of vizids which should be visible when this pinboard loads.
|
|
50
|
+
* The ids not in this array are hidden from the pinboard.
|
|
51
|
+
* _since: 1.6.0_
|
|
52
|
+
*/
|
|
53
|
+
pinboardVisibleVizs?: string[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Embed a ThoughtSpot pinboard or visualization
|
|
57
|
+
* @Category Pinboards and Charts
|
|
58
|
+
*/
|
|
59
|
+
export declare class PinboardEmbed extends V1Embed {
|
|
60
|
+
protected viewConfig: PinboardViewConfig;
|
|
61
|
+
private defaultHeight;
|
|
62
|
+
constructor(domSelector: DOMSelector, viewConfig: PinboardViewConfig);
|
|
63
|
+
/**
|
|
64
|
+
* Construct a map of params to be passed on to the
|
|
65
|
+
* embedded pinboard or visualization.
|
|
66
|
+
*/
|
|
67
|
+
private getEmbedParams;
|
|
68
|
+
/**
|
|
69
|
+
* Construct the URL of the embedded ThoughtSpot pinboard or visualization
|
|
70
|
+
* to be loaded within the iframe.
|
|
71
|
+
* @param pinboardId The GUID of the pinboard.
|
|
72
|
+
* @param vizId The optional GUID of a visualization within the pinboard.
|
|
73
|
+
* @param runtimeFilters A list of runtime filters to be applied to
|
|
74
|
+
* the pinboard or visualization on load.
|
|
75
|
+
*/
|
|
76
|
+
private getIFrameSrc;
|
|
77
|
+
/**
|
|
78
|
+
* Set the iframe height as per the computed height received
|
|
79
|
+
* from the ThoughtSpot app.
|
|
80
|
+
* @param data The event payload
|
|
81
|
+
*/
|
|
82
|
+
private updateIFrameHeight;
|
|
83
|
+
private embedIframeCenter;
|
|
84
|
+
private handleRouteChangeFullHeightPinboard;
|
|
85
|
+
/**
|
|
86
|
+
* Render an embedded ThoughtSpot pinboard or visualization
|
|
87
|
+
* @param renderOptions An object specifying the pinboard ID,
|
|
88
|
+
* visualization ID and the runtime filters.
|
|
89
|
+
*/
|
|
90
|
+
render(): PinboardEmbed;
|
|
91
|
+
}
|
|
@@ -143,6 +143,7 @@ export declare class TsEmbed {
|
|
|
143
143
|
*/
|
|
144
144
|
private shouldEncodeUrlQueryParams;
|
|
145
145
|
constructor(domSelector: DOMSelector, viewConfig?: ViewConfig);
|
|
146
|
+
private getLoginFiledMessage;
|
|
146
147
|
/**
|
|
147
148
|
* Gets a reference to the root DOM node where
|
|
148
149
|
* the embedded content will appear.
|
package/dist/src/index.d.ts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
9
9
|
*/
|
|
10
10
|
import { AppEmbed, Page, AppViewConfig } from './embed/app';
|
|
11
|
-
import { init, prefetch } from './embed/base';
|
|
11
|
+
import { init, prefetch, logout } from './embed/base';
|
|
12
12
|
import { PinboardEmbed, LiveboardViewConfig, LiveboardEmbed } from './embed/liveboard';
|
|
13
13
|
import { SearchEmbed, SearchViewConfig } from './embed/search';
|
|
14
14
|
import { AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig } from './types';
|
|
15
|
-
export { init, prefetch, SearchEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, LiveboardViewConfig, AppViewConfig, };
|
|
15
|
+
export { init, logout, prefetch, SearchEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, LiveboardViewConfig, AppViewConfig, };
|
package/dist/src/types.d.ts
CHANGED
|
@@ -119,6 +119,11 @@ export interface EmbedConfig {
|
|
|
119
119
|
* @default false
|
|
120
120
|
*/
|
|
121
121
|
disableLoginRedirect?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* This message is displayed on the embed view when the login fails.
|
|
124
|
+
* @version 1.10.1 | ThoughtSpot: *
|
|
125
|
+
*/
|
|
126
|
+
loginFailedMessage?: string;
|
|
122
127
|
/**
|
|
123
128
|
* Calls the prefetch method internally when set to true
|
|
124
129
|
* @default false
|
|
@@ -2,3 +2,4 @@ export declare function fetchSessionInfoService(authVerificationUrl: string): Pr
|
|
|
2
2
|
export declare function fetchAuthTokenService(authEndpoint: string): Promise<any>;
|
|
3
3
|
export declare function fetchAuthService(thoughtSpotHost: string, username: string, authToken: string): Promise<any>;
|
|
4
4
|
export declare function fetchBasicAuthService(thoughtSpotHost: string, username: string, password: string): Promise<any>;
|
|
5
|
+
export declare function fetchLogoutService(thoughtSpotHost: string): Promise<any>;
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: ThoughtSpot Inc. 2012-2016
|
|
3
|
+
* Author: Shashank Singh (sunny@thoughtspot.com)
|
|
4
|
+
*
|
|
5
|
+
* @fileoverview ThoughtSpot Javascript API for use of ThoughtSpot in external webpages.
|
|
6
|
+
*/
|
|
7
|
+
import { AuthType } from '../types';
|
|
8
|
+
export declare enum Events {
|
|
9
|
+
THOUGHTSPOT_AUTH_EXPIRED = "ThoughtspotAuthExpired",
|
|
10
|
+
EXPORT_VIZ_DATA_TO_PARENT = "exportVizDataToParent",
|
|
11
|
+
ALERT = "alert",
|
|
12
|
+
EXPORT_VIZ_DATA_TO_CHILD = "exportVizDataToChild",
|
|
13
|
+
GET_DATA = "getData"
|
|
14
|
+
}
|
|
15
|
+
declare type Callback = (...args: any[]) => void;
|
|
16
|
+
declare function checkIfLoggedIn(tsHost: string, callback: Callback): void;
|
|
17
|
+
declare function initialize(onInitialized: Callback, onAuthExpiration: Callback, _thoughtspotHost: string, authType: AuthType): void;
|
|
18
|
+
declare function notifyOnAuthExpiration(): void;
|
|
19
|
+
export { initialize, checkIfLoggedIn, notifyOnAuthExpiration };
|
package/dist/tsembed.es.js
CHANGED
|
@@ -8687,8 +8687,16 @@ function initMixpanel(sessionInfo) {
|
|
|
8687
8687
|
}
|
|
8688
8688
|
|
|
8689
8689
|
// eslint-disable-next-line import/no-cycle
|
|
8690
|
+
function failureLoggedFetch(url, options = {}) {
|
|
8691
|
+
return fetch(url, options).then(async (r) => {
|
|
8692
|
+
if (!r.ok && r.type !== 'opaqueredirect') {
|
|
8693
|
+
console.error('Failure', await r.text());
|
|
8694
|
+
}
|
|
8695
|
+
return r;
|
|
8696
|
+
});
|
|
8697
|
+
}
|
|
8690
8698
|
function fetchSessionInfoService(authVerificationUrl) {
|
|
8691
|
-
return
|
|
8699
|
+
return failureLoggedFetch(authVerificationUrl, {
|
|
8692
8700
|
credentials: 'include',
|
|
8693
8701
|
});
|
|
8694
8702
|
}
|
|
@@ -8696,12 +8704,14 @@ async function fetchAuthTokenService(authEndpoint) {
|
|
|
8696
8704
|
return fetch(authEndpoint);
|
|
8697
8705
|
}
|
|
8698
8706
|
async function fetchAuthService(thoughtSpotHost, username, authToken) {
|
|
8699
|
-
return
|
|
8707
|
+
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
|
|
8700
8708
|
credentials: 'include',
|
|
8709
|
+
// We do not want to follow the redirect, as it starts giving a CORS error
|
|
8710
|
+
redirect: 'manual',
|
|
8701
8711
|
});
|
|
8702
8712
|
}
|
|
8703
8713
|
async function fetchBasicAuthService(thoughtSpotHost, username, password) {
|
|
8704
|
-
return
|
|
8714
|
+
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
|
|
8705
8715
|
method: 'POST',
|
|
8706
8716
|
headers: {
|
|
8707
8717
|
'content-type': 'application/x-www-form-urlencoded',
|
|
@@ -8710,6 +8720,14 @@ async function fetchBasicAuthService(thoughtSpotHost, username, password) {
|
|
|
8710
8720
|
body: `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`,
|
|
8711
8721
|
credentials: 'include',
|
|
8712
8722
|
});
|
|
8723
|
+
}
|
|
8724
|
+
async function fetchLogoutService(thoughtSpotHost) {
|
|
8725
|
+
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
|
|
8726
|
+
credentials: 'include',
|
|
8727
|
+
headers: {
|
|
8728
|
+
'x-requested-by': 'ThoughtSpot',
|
|
8729
|
+
},
|
|
8730
|
+
});
|
|
8713
8731
|
}
|
|
8714
8732
|
|
|
8715
8733
|
// eslint-disable-next-line import/no-mutable-exports
|
|
@@ -8727,6 +8745,7 @@ const EndPoints = {
|
|
|
8727
8745
|
OIDC_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
|
|
8728
8746
|
TOKEN_LOGIN: '/callosum/v1/session/login/token',
|
|
8729
8747
|
BASIC_LOGIN: '/callosum/v1/session/login',
|
|
8748
|
+
LOGOUT: '/callosum/v1/session/logout',
|
|
8730
8749
|
};
|
|
8731
8750
|
/**
|
|
8732
8751
|
* Check if we are logged into the ThoughtSpot cluster
|
|
@@ -8747,6 +8766,17 @@ function initSession(sessionDetails) {
|
|
|
8747
8766
|
sessionInfo = sessionDetails;
|
|
8748
8767
|
initMixpanel(sessionInfo);
|
|
8749
8768
|
}
|
|
8769
|
+
const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every time getAuthToken callback is called.' +
|
|
8770
|
+
'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
|
|
8771
|
+
let prevAuthToken = null;
|
|
8772
|
+
function alertForDuplicateToken(authtoken) {
|
|
8773
|
+
if (prevAuthToken === authtoken) {
|
|
8774
|
+
// eslint-disable-next-line no-alert
|
|
8775
|
+
alert(DUPLICATE_TOKEN_ERR);
|
|
8776
|
+
throw new Error(DUPLICATE_TOKEN_ERR);
|
|
8777
|
+
}
|
|
8778
|
+
prevAuthToken = authtoken;
|
|
8779
|
+
}
|
|
8750
8780
|
/**
|
|
8751
8781
|
* Check if we are stuck at the SSO redirect URL
|
|
8752
8782
|
*/
|
|
@@ -8777,15 +8807,20 @@ const doTokenAuth = async (embedConfig) => {
|
|
|
8777
8807
|
let authToken = null;
|
|
8778
8808
|
if (getAuthToken) {
|
|
8779
8809
|
authToken = await getAuthToken();
|
|
8810
|
+
alertForDuplicateToken(authToken);
|
|
8780
8811
|
}
|
|
8781
8812
|
else {
|
|
8782
8813
|
const response = await fetchAuthTokenService(authEndpoint);
|
|
8783
8814
|
authToken = await response.text();
|
|
8784
8815
|
}
|
|
8785
|
-
await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
8786
|
-
|
|
8816
|
+
const resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
8817
|
+
// token login issues a 302 when successful
|
|
8818
|
+
loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
|
|
8819
|
+
}
|
|
8820
|
+
else {
|
|
8821
|
+
loggedInStatus = true;
|
|
8787
8822
|
}
|
|
8788
|
-
loggedInStatus
|
|
8823
|
+
return loggedInStatus;
|
|
8789
8824
|
};
|
|
8790
8825
|
/**
|
|
8791
8826
|
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
@@ -8800,9 +8835,12 @@ const doBasicAuth = async (embedConfig) => {
|
|
|
8800
8835
|
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
8801
8836
|
if (!loggedIn) {
|
|
8802
8837
|
const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
8803
|
-
loggedInStatus = response.
|
|
8838
|
+
loggedInStatus = response.ok;
|
|
8804
8839
|
}
|
|
8805
|
-
|
|
8840
|
+
else {
|
|
8841
|
+
loggedInStatus = true;
|
|
8842
|
+
}
|
|
8843
|
+
return loggedInStatus;
|
|
8806
8844
|
};
|
|
8807
8845
|
async function samlPopupFlow(ssoURL) {
|
|
8808
8846
|
document.body.insertAdjacentHTML('beforeend', '<div id="ts-saml-auth"></div>');
|
|
@@ -8866,6 +8904,7 @@ const doSamlAuth = async (embedConfig) => {
|
|
|
8866
8904
|
// bring back the page to the same URL
|
|
8867
8905
|
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
8868
8906
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
8907
|
+
return loggedInStatus;
|
|
8869
8908
|
};
|
|
8870
8909
|
const doOIDCAuth = async (embedConfig) => {
|
|
8871
8910
|
const { thoughtSpotHost } = embedConfig;
|
|
@@ -8877,6 +8916,15 @@ const doOIDCAuth = async (embedConfig) => {
|
|
|
8877
8916
|
// bring back the page to the same URL
|
|
8878
8917
|
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
8879
8918
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
8919
|
+
return loggedInStatus;
|
|
8920
|
+
};
|
|
8921
|
+
const logout = async (embedConfig) => {
|
|
8922
|
+
const { thoughtSpotHost } = embedConfig;
|
|
8923
|
+
const response = await fetchLogoutService(thoughtSpotHost);
|
|
8924
|
+
if (response.ok || response.status === 401) {
|
|
8925
|
+
loggedInStatus = false;
|
|
8926
|
+
}
|
|
8927
|
+
return loggedInStatus;
|
|
8880
8928
|
};
|
|
8881
8929
|
/**
|
|
8882
8930
|
* Perform authentication on the ThoughtSpot cluster
|
|
@@ -8894,7 +8942,7 @@ const authenticate = async (embedConfig) => {
|
|
|
8894
8942
|
case AuthType.Basic:
|
|
8895
8943
|
return doBasicAuth(embedConfig);
|
|
8896
8944
|
default:
|
|
8897
|
-
return Promise.resolve();
|
|
8945
|
+
return Promise.resolve(true);
|
|
8898
8946
|
}
|
|
8899
8947
|
};
|
|
8900
8948
|
|
|
@@ -8953,6 +9001,9 @@ const init = (embedConfig) => {
|
|
|
8953
9001
|
}
|
|
8954
9002
|
return authPromise;
|
|
8955
9003
|
};
|
|
9004
|
+
const logout$1 = () => {
|
|
9005
|
+
return logout(config);
|
|
9006
|
+
};
|
|
8956
9007
|
let renderQueue = Promise.resolve();
|
|
8957
9008
|
/**
|
|
8958
9009
|
* Renders functions in a queue, resolves to next function only after the callback next is called
|
|
@@ -9088,7 +9139,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
|
|
|
9088
9139
|
}
|
|
9089
9140
|
}
|
|
9090
9141
|
|
|
9091
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.11.0-
|
|
9142
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.11.0-auth.10";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**"];var exports={".":"./lib/src/index.js","./react":"./lib/src/react/index.js"};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs && npx istanbul-merge --out ./coverage/coverage.json ./coverage/docs/coverage-final.json ./coverage/sdk/coverage-final.json && npx istanbul report --include ./coverage/coverage.json --dir ./coverage lcov",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1","mixpanel-browser":"^2.41.0"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","dts-bundle":"0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.1.0","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"4.1.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^4.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.1.0","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports,scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
|
|
9092
9143
|
|
|
9093
9144
|
/**
|
|
9094
9145
|
* Copyright (c) 2022
|
|
@@ -9135,12 +9186,17 @@ class TsEmbed {
|
|
|
9135
9186
|
this.isError = false;
|
|
9136
9187
|
this.viewConfig = viewConfig;
|
|
9137
9188
|
this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
|
|
9138
|
-
|
|
9139
|
-
this.
|
|
9189
|
+
this.on(EmbedEvent.NoCookieAccess, () => {
|
|
9190
|
+
if (!this.embedConfig.suppressNoCookieAccessAlert) {
|
|
9140
9191
|
// eslint-disable-next-line no-alert
|
|
9141
|
-
alert('Third party cookie access is blocked on this browser, please allow third party cookies for
|
|
9142
|
-
}
|
|
9143
|
-
|
|
9192
|
+
alert('Third party cookie access is blocked on this browser, please allow third party cookies for this to work properly. \nYou can use `suppressNoCookieAccessAlert` to suppress this message.');
|
|
9193
|
+
}
|
|
9194
|
+
this.el.innerHTML = this.getLoginFiledMessage();
|
|
9195
|
+
});
|
|
9196
|
+
}
|
|
9197
|
+
getLoginFiledMessage() {
|
|
9198
|
+
const { loginFailedMessage } = this.embedConfig;
|
|
9199
|
+
return loginFailedMessage || 'Login failed';
|
|
9144
9200
|
}
|
|
9145
9201
|
/**
|
|
9146
9202
|
* Gets a reference to the root DOM node where
|
|
@@ -9336,7 +9392,11 @@ class TsEmbed {
|
|
|
9336
9392
|
type: EmbedEvent.Init,
|
|
9337
9393
|
});
|
|
9338
9394
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
9339
|
-
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then(() => {
|
|
9395
|
+
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
|
|
9396
|
+
if (!isLoggedIn) {
|
|
9397
|
+
this.el.innerHTML = this.getLoginFiledMessage();
|
|
9398
|
+
return;
|
|
9399
|
+
}
|
|
9340
9400
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
|
|
9341
9401
|
this.iFrame =
|
|
9342
9402
|
this.iFrame || document.createElement('iframe');
|
|
@@ -9386,6 +9446,7 @@ class TsEmbed {
|
|
|
9386
9446
|
}).catch((error) => {
|
|
9387
9447
|
nextInQueue();
|
|
9388
9448
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED);
|
|
9449
|
+
this.el.innerHTML = this.getLoginFiledMessage();
|
|
9389
9450
|
this.handleError(error);
|
|
9390
9451
|
});
|
|
9391
9452
|
});
|
|
@@ -9957,4 +10018,4 @@ class SearchEmbed extends TsEmbed {
|
|
|
9957
10018
|
}
|
|
9958
10019
|
}
|
|
9959
10020
|
|
|
9960
|
-
export { Action, AppEmbed, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, RuntimeFilterOp, SearchEmbed, init, prefetch };
|
|
10021
|
+
export { Action, AppEmbed, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, RuntimeFilterOp, SearchEmbed, init, logout$1 as logout, prefetch };
|