@thoughtspot/visual-embed-sdk 1.29.0-alpha.8 → 1.29.0-alpha.SCAL-205893-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/cjs/package.json +1 -1
- package/cjs/src/auth.d.ts +14 -17
- package/cjs/src/auth.d.ts.map +1 -1
- package/cjs/src/auth.js +45 -59
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/auth.spec.d.ts +12 -0
- package/cjs/src/auth.spec.d.ts.map +1 -1
- package/cjs/src/auth.spec.js +89 -67
- package/cjs/src/auth.spec.js.map +1 -1
- package/cjs/src/authToken.d.ts +1 -1
- package/cjs/src/authToken.d.ts.map +1 -1
- package/cjs/src/authToken.js +10 -4
- package/cjs/src/authToken.js.map +1 -1
- package/cjs/src/embed/app.spec.js +4 -2
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +2 -0
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +1 -0
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/embed.spec.js +3 -0
- package/cjs/src/embed/embed.spec.js.map +1 -1
- package/cjs/src/embed/events.spec.js +3 -0
- package/cjs/src/embed/events.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +2 -0
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/pinboard.spec.js +3 -0
- package/cjs/src/embed/pinboard.spec.js.map +1 -1
- package/cjs/src/embed/sage.spec.js +3 -0
- package/cjs/src/embed/sage.spec.js.map +1 -1
- package/cjs/src/embed/search.spec.js +1 -0
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed-trigger.spec.js +3 -0
- package/cjs/src/embed/ts-embed-trigger.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +7 -0
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +7 -0
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +2 -1
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +2 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/mixpanel-service.d.ts +2 -1
- package/cjs/src/mixpanel-service.d.ts.map +1 -1
- package/cjs/src/mixpanel-service.js +1 -0
- package/cjs/src/mixpanel-service.js.map +1 -1
- package/cjs/src/mixpanel-service.spec.js +7 -0
- package/cjs/src/mixpanel-service.spec.js.map +1 -1
- package/cjs/src/react/index.d.ts +1 -1
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +2 -1
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +6 -0
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +1 -1
- package/cjs/src/types.js +1 -1
- package/cjs/src/utils/authService/authService.d.ts +1 -0
- package/cjs/src/utils/authService/authService.d.ts.map +1 -1
- package/cjs/src/utils/authService/authService.js +1 -0
- package/cjs/src/utils/authService/authService.js.map +1 -1
- package/cjs/src/utils/authService/authService.spec.js +18 -5
- package/cjs/src/utils/authService/authService.spec.js.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.d.ts +15 -2
- package/cjs/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.js +39 -9
- package/cjs/src/utils/authService/tokenizedAuthService.js.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
- package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
- package/cjs/src/utils/authService/tokenizedAuthService.spec.js +32 -0
- package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +1 -0
- package/cjs/src/utils/graphql/answerService/answerService.d.ts +10 -0
- package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.js +10 -0
- package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/cjs/src/utils/processData.js +2 -2
- package/cjs/src/utils/processData.js.map +1 -1
- package/cjs/src/utils/processData.spec.js +3 -2
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/cjs/src/utils/sessionInfoService.d.ts +66 -0
- package/cjs/src/utils/sessionInfoService.d.ts.map +1 -0
- package/cjs/src/utils/sessionInfoService.js +92 -0
- package/cjs/src/utils/sessionInfoService.js.map +1 -0
- package/dist/src/auth.d.ts +14 -17
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/auth.spec.d.ts +12 -0
- package/dist/src/auth.spec.d.ts.map +1 -1
- package/dist/src/authToken.d.ts +1 -1
- package/dist/src/authToken.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/mixpanel-service.d.ts +2 -1
- package/dist/src/mixpanel-service.d.ts.map +1 -1
- package/dist/src/react/index.d.ts +1 -1
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/utils/authService/authService.d.ts +1 -0
- package/dist/src/utils/authService/authService.d.ts.map +1 -1
- package/dist/src/utils/authService/tokenizedAuthService.d.ts +15 -2
- package/dist/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
- package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
- package/dist/src/utils/graphql/answerService/answerService.d.ts +10 -0
- package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/dist/src/utils/sessionInfoService.d.ts +66 -0
- package/dist/src/utils/sessionInfoService.d.ts.map +1 -0
- package/dist/tsembed-react.es.js +154 -58
- package/dist/tsembed-react.js +154 -57
- package/dist/tsembed.es.js +162 -69
- package/dist/tsembed.js +162 -69
- package/dist/visual-embed-sdk-react-full.d.ts +93 -20
- package/dist/visual-embed-sdk-react.d.ts +93 -20
- package/dist/visual-embed-sdk.d.ts +93 -20
- package/lib/package.json +1 -1
- package/lib/src/auth.d.ts +14 -17
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +44 -56
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.d.ts +12 -0
- package/lib/src/auth.spec.d.ts.map +1 -1
- package/lib/src/auth.spec.js +88 -66
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/authToken.d.ts +1 -1
- package/lib/src/authToken.d.ts.map +1 -1
- package/lib/src/authToken.js +10 -4
- package/lib/src/authToken.js.map +1 -1
- package/lib/src/embed/app.spec.js +4 -2
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +3 -1
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +1 -0
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +2 -0
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +2 -0
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +2 -0
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/pinboard.spec.js +2 -0
- package/lib/src/embed/pinboard.spec.js.map +1 -1
- package/lib/src/embed/sage.spec.js +2 -0
- package/lib/src/embed/sage.spec.js.map +1 -1
- package/lib/src/embed/search.spec.js +1 -0
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed-trigger.spec.js +2 -0
- package/lib/src/embed/ts-embed-trigger.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +7 -0
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +7 -0
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +2 -1
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +2 -1
- package/lib/src/index.js.map +1 -1
- package/lib/src/mixpanel-service.d.ts +2 -1
- package/lib/src/mixpanel-service.d.ts.map +1 -1
- package/lib/src/mixpanel-service.js +1 -0
- package/lib/src/mixpanel-service.js.map +1 -1
- package/lib/src/mixpanel-service.spec.js +7 -0
- package/lib/src/mixpanel-service.spec.js.map +1 -1
- package/lib/src/react/index.d.ts +1 -1
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +1 -1
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +6 -0
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +1 -1
- package/lib/src/types.js +1 -1
- package/lib/src/utils/authService/authService.d.ts +1 -0
- package/lib/src/utils/authService/authService.d.ts.map +1 -1
- package/lib/src/utils/authService/authService.js +1 -0
- package/lib/src/utils/authService/authService.js.map +1 -1
- package/lib/src/utils/authService/authService.spec.js +18 -5
- package/lib/src/utils/authService/authService.spec.js.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.d.ts +15 -2
- package/lib/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.js +37 -8
- package/lib/src/utils/authService/tokenizedAuthService.js.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
- package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
- package/lib/src/utils/authService/tokenizedAuthService.spec.js +29 -0
- package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +1 -0
- package/lib/src/utils/graphql/answerService/answerService.d.ts +10 -0
- package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.js +10 -0
- package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/lib/src/utils/processData.js +3 -3
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js +3 -2
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils/sessionInfoService.d.ts +66 -0
- package/lib/src/utils/sessionInfoService.d.ts.map +1 -0
- package/lib/src/utils/sessionInfoService.js +85 -0
- package/lib/src/utils/sessionInfoService.js.map +1 -0
- package/lib/src/visual-embed-sdk.d.ts +98 -21
- package/package.json +1 -1
- package/src/auth.spec.ts +92 -72
- package/src/auth.ts +46 -68
- package/src/authToken.ts +9 -4
- package/src/embed/app.spec.ts +4 -2
- package/src/embed/base.spec.ts +1 -0
- package/src/embed/base.ts +3 -0
- package/src/embed/embed.spec.ts +2 -0
- package/src/embed/events.spec.ts +2 -0
- package/src/embed/liveboard.spec.ts +2 -0
- package/src/embed/pinboard.spec.ts +2 -0
- package/src/embed/sage.spec.ts +3 -0
- package/src/embed/search.spec.ts +1 -0
- package/src/embed/ts-embed-trigger.spec.ts +3 -0
- package/src/embed/ts-embed.spec.ts +8 -0
- package/src/embed/ts-embed.ts +7 -0
- package/src/index.ts +2 -1
- package/src/mixpanel-service.spec.ts +12 -3
- package/src/mixpanel-service.ts +3 -1
- package/src/react/index.spec.tsx +7 -0
- package/src/react/index.tsx +1 -0
- package/src/types.ts +1 -1
- package/src/utils/authService/authService.spec.ts +18 -5
- package/src/utils/authService/authService.ts +1 -0
- package/src/utils/authService/tokenizedAuthService.spec.ts +36 -0
- package/src/utils/authService/tokenizedAuthService.ts +38 -8
- package/src/utils/graphql/answerService/answerService.ts +10 -0
- package/src/utils/processData.spec.ts +3 -2
- package/src/utils/processData.ts +3 -3
- package/src/utils/sessionInfoService.ts +101 -0
package/dist/tsembed-react.js
CHANGED
|
@@ -1892,7 +1892,7 @@
|
|
|
1892
1892
|
*
|
|
1893
1893
|
* @example
|
|
1894
1894
|
* ```js
|
|
1895
|
-
* liveboardEmbed.trigger(HostEvent.
|
|
1895
|
+
* liveboardEmbed.trigger(HostEvent.getExportRequestForCurrentPinboard).then(
|
|
1896
1896
|
* data=>console.log(data))
|
|
1897
1897
|
* ```
|
|
1898
1898
|
* @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1.sw
|
|
@@ -5959,6 +5959,7 @@
|
|
|
5959
5959
|
|
|
5960
5960
|
const EndPoints = {
|
|
5961
5961
|
AUTH_VERIFICATION: '/callosum/v1/session/info',
|
|
5962
|
+
SESSION_INFO: '/callosum/v1/session/info',
|
|
5962
5963
|
SAML_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/saml/login?targetURLPath=${targetUrl}`,
|
|
5963
5964
|
OIDC_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
|
|
5964
5965
|
TOKEN_LOGIN: '/callosum/v1/session/login/token',
|
|
@@ -6075,7 +6076,7 @@
|
|
|
6075
6076
|
const INVALID_TOKEN_ERR = 'Invalid token received form token callback or authToken endpoint.';
|
|
6076
6077
|
let cachedAuthToken = null;
|
|
6077
6078
|
// This method can be used to get the authToken using the embedConfig
|
|
6078
|
-
|
|
6079
|
+
async function getAuthenticationToken(embedConfig) {
|
|
6079
6080
|
// Since we don't have token validation enabled , we cannot tell if the
|
|
6080
6081
|
// cached token is valid or not. So we will always fetch a new token.
|
|
6081
6082
|
if (cachedAuthToken && !embedConfig.disableTokenVerification) {
|
|
@@ -6098,11 +6099,17 @@
|
|
|
6098
6099
|
const response = await fetchAuthTokenService(authEndpoint);
|
|
6099
6100
|
authToken = await response.text();
|
|
6100
6101
|
}
|
|
6101
|
-
|
|
6102
|
-
|
|
6102
|
+
try {
|
|
6103
|
+
// this will throw error if the token is not valid
|
|
6104
|
+
await validateAuthToken(embedConfig, authToken);
|
|
6105
|
+
}
|
|
6106
|
+
catch (e) {
|
|
6107
|
+
logger.error(`Received invalid token from getAuthToken callback or authToken endpoint. Error : ${e.message}`);
|
|
6108
|
+
throw e;
|
|
6109
|
+
}
|
|
6103
6110
|
cachedAuthToken = authToken;
|
|
6104
6111
|
return authToken;
|
|
6105
|
-
}
|
|
6112
|
+
}
|
|
6106
6113
|
const validateAuthToken = async (embedConfig, authToken, suppressAlert) => {
|
|
6107
6114
|
if (embedConfig.disableTokenVerification) {
|
|
6108
6115
|
logger.info('Token verification is disabled. Assuming token is valid.');
|
|
@@ -6372,6 +6379,16 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
6372
6379
|
* const data = await underlying.fetchData(0, 100);
|
|
6373
6380
|
* })
|
|
6374
6381
|
* ```
|
|
6382
|
+
* @example
|
|
6383
|
+
* ```js
|
|
6384
|
+
* embed.on(EmbedEvent.Data, async (e) => {
|
|
6385
|
+
* const service = await embed.getAnswerService();
|
|
6386
|
+
* await service.addColumns([
|
|
6387
|
+
* "<column guid>"
|
|
6388
|
+
* ]);
|
|
6389
|
+
* console.log(await service.fetchData());
|
|
6390
|
+
* });
|
|
6391
|
+
* ```
|
|
6375
6392
|
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
6376
6393
|
* @group Events
|
|
6377
6394
|
*/
|
|
@@ -12712,6 +12729,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
12712
12729
|
function initMixpanel(sessionInfo) {
|
|
12713
12730
|
var _a;
|
|
12714
12731
|
if (!sessionInfo || !sessionInfo.mixpanelToken) {
|
|
12732
|
+
logger.error('Mixpanel token not found in session info');
|
|
12715
12733
|
return;
|
|
12716
12734
|
}
|
|
12717
12735
|
// On a public cluster the user is anonymous, so don't set the identify to
|
|
@@ -13096,36 +13114,111 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
13096
13114
|
* @param url
|
|
13097
13115
|
* @param options
|
|
13098
13116
|
*/
|
|
13099
|
-
function
|
|
13117
|
+
function tokenizedFailureLoggedFetch(url, options = {}) {
|
|
13100
13118
|
return tokenizedFetch(url, options).then(async (r) => {
|
|
13101
13119
|
var _a;
|
|
13102
13120
|
if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
|
|
13103
|
-
logger.error(
|
|
13121
|
+
logger.error(`Failed to fetch ${url}`, await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
|
|
13104
13122
|
}
|
|
13105
13123
|
return r;
|
|
13106
13124
|
});
|
|
13107
13125
|
}
|
|
13108
13126
|
/**
|
|
13127
|
+
* Fetches the session info from the ThoughtSpot server.
|
|
13109
13128
|
*
|
|
13110
|
-
* @param
|
|
13129
|
+
* @param thoughtspotHost
|
|
13130
|
+
* @returns {Promise<any>}
|
|
13131
|
+
* @example
|
|
13132
|
+
* ```js
|
|
13133
|
+
* const response = await sessionInfoService();
|
|
13134
|
+
* ```
|
|
13111
13135
|
*/
|
|
13112
|
-
function fetchSessionInfoService(
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
|
|
13136
|
+
async function fetchSessionInfoService(thoughtspotHost) {
|
|
13137
|
+
const sessionInfoPath = `${thoughtspotHost}${EndPoints.SESSION_INFO}`;
|
|
13138
|
+
const response = await tokenizedFailureLoggedFetch(sessionInfoPath);
|
|
13139
|
+
if (!response.ok) {
|
|
13140
|
+
throw new Error(`Failed to fetch session info: ${response.statusText}`);
|
|
13141
|
+
}
|
|
13142
|
+
const data = await response.json();
|
|
13143
|
+
return data;
|
|
13144
|
+
}
|
|
13145
|
+
/**
|
|
13146
|
+
* Is active service to check if the user is logged in.
|
|
13147
|
+
*
|
|
13148
|
+
* @param thoughtSpotHost
|
|
13149
|
+
* @version SDK: 1.28.4 | ThoughtSpot: *
|
|
13150
|
+
*/
|
|
13151
|
+
async function isActiveService(thoughtSpotHost) {
|
|
13152
|
+
const isActiveUrl = `${thoughtSpotHost}${EndPoints.IS_ACTIVE}`;
|
|
13153
|
+
try {
|
|
13154
|
+
const res = await tokenizedFetch(isActiveUrl, {
|
|
13155
|
+
credentials: 'include',
|
|
13156
|
+
});
|
|
13157
|
+
return res.ok;
|
|
13158
|
+
}
|
|
13159
|
+
catch (e) {
|
|
13160
|
+
logger.warn(`Is Logged In Service failed : ${e.message}`);
|
|
13161
|
+
}
|
|
13162
|
+
return false;
|
|
13116
13163
|
}
|
|
13117
13164
|
|
|
13165
|
+
let sessionInfo = null;
|
|
13166
|
+
/**
|
|
13167
|
+
* Returns the session info object and caches it for future use.
|
|
13168
|
+
* Once fetched the session info object is cached and returned from the cache on
|
|
13169
|
+
* subsequent calls.
|
|
13170
|
+
*
|
|
13171
|
+
* @example ```js
|
|
13172
|
+
* const sessionInfo = await getSessionInfo();
|
|
13173
|
+
* console.log(sessionInfo);
|
|
13174
|
+
* ```
|
|
13175
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
13176
|
+
* @returns {Promise<SessionInfo>} The session info object.
|
|
13177
|
+
*/
|
|
13178
|
+
async function getSessionInfo() {
|
|
13179
|
+
if (!sessionInfo) {
|
|
13180
|
+
const host = getEmbedConfig().thoughtSpotHost;
|
|
13181
|
+
const sessionResponse = await fetchSessionInfoService(host);
|
|
13182
|
+
const processedSessionInfo = getSessionDetails(sessionResponse);
|
|
13183
|
+
sessionInfo = processedSessionInfo;
|
|
13184
|
+
}
|
|
13185
|
+
return sessionInfo;
|
|
13186
|
+
}
|
|
13187
|
+
/**
|
|
13188
|
+
* Processes the session info response and returns the session info object.
|
|
13189
|
+
*
|
|
13190
|
+
* @param sessionInfoResp {any} Response from the session info API.
|
|
13191
|
+
* @returns {SessionInfo} The session info object.
|
|
13192
|
+
* @example ```js
|
|
13193
|
+
* const sessionInfoResp = await fetch(sessionInfoPath);
|
|
13194
|
+
* const sessionInfo = getSessionDetails(sessionInfoResp);
|
|
13195
|
+
* console.log(sessionInfo);
|
|
13196
|
+
* ```
|
|
13197
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
13198
|
+
*/
|
|
13199
|
+
const getSessionDetails = (sessionInfoResp) => {
|
|
13200
|
+
const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
|
|
13201
|
+
const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
|
|
13202
|
+
const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
|
|
13203
|
+
? prodMixpanelToken
|
|
13204
|
+
: devMixpanelToken;
|
|
13205
|
+
return {
|
|
13206
|
+
userGUID: sessionInfoResp.userGUID,
|
|
13207
|
+
mixpanelToken,
|
|
13208
|
+
isPublicUser: sessionInfoResp.configInfo.isPublicUser,
|
|
13209
|
+
releaseVersion: sessionInfoResp.releaseVersion,
|
|
13210
|
+
clusterId: sessionInfoResp.configInfo.selfClusterId,
|
|
13211
|
+
clusterName: sessionInfoResp.configInfo.selfClusterName,
|
|
13212
|
+
...sessionInfoResp,
|
|
13213
|
+
};
|
|
13214
|
+
};
|
|
13215
|
+
|
|
13118
13216
|
// eslint-disable-next-line import/no-mutable-exports
|
|
13119
13217
|
let loggedInStatus = false;
|
|
13120
13218
|
// eslint-disable-next-line import/no-mutable-exports
|
|
13121
13219
|
let samlAuthWindow = null;
|
|
13122
13220
|
// eslint-disable-next-line import/no-mutable-exports
|
|
13123
13221
|
let samlCompletionPromise = null;
|
|
13124
|
-
let sessionInfo = null;
|
|
13125
|
-
let sessionInfoResolver = null;
|
|
13126
|
-
const sessionInfoPromise = new Promise((resolve) => {
|
|
13127
|
-
sessionInfoResolver = resolve;
|
|
13128
|
-
});
|
|
13129
13222
|
let releaseVersion = '';
|
|
13130
13223
|
const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
|
|
13131
13224
|
/**
|
|
@@ -13198,7 +13291,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
13198
13291
|
/**
|
|
13199
13292
|
*
|
|
13200
13293
|
*/
|
|
13201
|
-
function notifyAuthSuccess() {
|
|
13294
|
+
async function notifyAuthSuccess() {
|
|
13202
13295
|
{
|
|
13203
13296
|
logger.error('SDK not initialized');
|
|
13204
13297
|
return;
|
|
@@ -13223,52 +13316,39 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
13223
13316
|
return;
|
|
13224
13317
|
}
|
|
13225
13318
|
}
|
|
13226
|
-
const initSession = (sessionDetails) => {
|
|
13227
|
-
const embedConfig = getEmbedConfig();
|
|
13228
|
-
if (sessionInfo == null) {
|
|
13229
|
-
sessionInfo = sessionDetails;
|
|
13230
|
-
if (!embedConfig.disableSDKTracking) {
|
|
13231
|
-
initMixpanel(sessionInfo);
|
|
13232
|
-
}
|
|
13233
|
-
sessionInfoResolver(sessionInfo);
|
|
13234
|
-
}
|
|
13235
|
-
};
|
|
13236
|
-
const getSessionDetails = (sessionInfoResp) => {
|
|
13237
|
-
const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
|
|
13238
|
-
const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
|
|
13239
|
-
const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
|
|
13240
|
-
? prodMixpanelToken
|
|
13241
|
-
: devMixpanelToken;
|
|
13242
|
-
return {
|
|
13243
|
-
userGUID: sessionInfoResp.userGUID,
|
|
13244
|
-
mixpanelToken,
|
|
13245
|
-
isPublicUser: sessionInfoResp.configInfo.isPublicUser,
|
|
13246
|
-
releaseVersion: sessionInfoResp.releaseVersion,
|
|
13247
|
-
clusterId: sessionInfoResp.configInfo.selfClusterId,
|
|
13248
|
-
clusterName: sessionInfoResp.configInfo.selfClusterName,
|
|
13249
|
-
...sessionInfoResp,
|
|
13250
|
-
};
|
|
13251
|
-
};
|
|
13252
13319
|
/**
|
|
13253
13320
|
* Check if we are logged into the ThoughtSpot cluster
|
|
13254
13321
|
*
|
|
13255
13322
|
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
13256
13323
|
*/
|
|
13257
13324
|
async function isLoggedIn(thoughtSpotHost) {
|
|
13258
|
-
const authVerificationUrl = `${thoughtSpotHost}${EndPoints.AUTH_VERIFICATION}`;
|
|
13259
|
-
let response = null;
|
|
13260
13325
|
try {
|
|
13261
|
-
response = await
|
|
13262
|
-
|
|
13263
|
-
const sessionDetails = getSessionDetails(sessionInfoResp);
|
|
13264
|
-
// Store user session details from session info
|
|
13265
|
-
initSession(sessionDetails);
|
|
13266
|
-
releaseVersion = sessionInfoResp.releaseVersion;
|
|
13326
|
+
const response = await isActiveService(thoughtSpotHost);
|
|
13327
|
+
return response;
|
|
13267
13328
|
}
|
|
13268
13329
|
catch (e) {
|
|
13269
13330
|
return false;
|
|
13270
13331
|
}
|
|
13271
|
-
|
|
13332
|
+
}
|
|
13333
|
+
/**
|
|
13334
|
+
* Services to be called after the login is successful,
|
|
13335
|
+
* This should be called after the cookie is set for cookie auth or
|
|
13336
|
+
* after the token is set for cookieless.
|
|
13337
|
+
*
|
|
13338
|
+
* @return {Promise<void>}
|
|
13339
|
+
* @example
|
|
13340
|
+
* ```js
|
|
13341
|
+
* await postLoginService();
|
|
13342
|
+
* ```
|
|
13343
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
13344
|
+
*/
|
|
13345
|
+
async function postLoginService() {
|
|
13346
|
+
const sessionInfo = await getSessionInfo();
|
|
13347
|
+
releaseVersion = sessionInfo.releaseVersion;
|
|
13348
|
+
const embedConfig = getEmbedConfig();
|
|
13349
|
+
if (!embedConfig.disableSDKTracking) {
|
|
13350
|
+
initMixpanel(sessionInfo);
|
|
13351
|
+
}
|
|
13272
13352
|
}
|
|
13273
13353
|
/**
|
|
13274
13354
|
* Return releaseVersion if available
|
|
@@ -13305,7 +13385,14 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
13305
13385
|
}
|
|
13306
13386
|
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
13307
13387
|
if (!loggedInStatus) {
|
|
13308
|
-
|
|
13388
|
+
let authToken;
|
|
13389
|
+
try {
|
|
13390
|
+
authToken = await getAuthenticationToken(embedConfig);
|
|
13391
|
+
}
|
|
13392
|
+
catch (e) {
|
|
13393
|
+
loggedInStatus = false;
|
|
13394
|
+
throw e;
|
|
13395
|
+
}
|
|
13309
13396
|
let resp;
|
|
13310
13397
|
try {
|
|
13311
13398
|
resp = await fetchAuthPostService(thoughtSpotHost, username, authToken);
|
|
@@ -13503,6 +13590,8 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
13503
13590
|
notifyAuthFailure(AuthFailureType.SDK);
|
|
13504
13591
|
}
|
|
13505
13592
|
else {
|
|
13593
|
+
// Post login service is called after successful login.
|
|
13594
|
+
postLoginService();
|
|
13506
13595
|
notifyAuthSDKSuccess();
|
|
13507
13596
|
}
|
|
13508
13597
|
}, () => {
|
|
@@ -13553,13 +13642,13 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
13553
13642
|
};
|
|
13554
13643
|
}
|
|
13555
13644
|
/**
|
|
13645
|
+
* Responds to AuthInit sent from host signifying successful authentication in host.
|
|
13556
13646
|
*
|
|
13557
13647
|
* @param e
|
|
13648
|
+
* @returns {any}
|
|
13558
13649
|
*/
|
|
13559
13650
|
function processAuthInit(e) {
|
|
13560
13651
|
var _a, _b;
|
|
13561
|
-
// Store user session details sent by app.
|
|
13562
|
-
initSession(e.data);
|
|
13563
13652
|
notifyAuthSuccess();
|
|
13564
13653
|
// Expose only allowed details (eg: userGUID) back to SDK users.
|
|
13565
13654
|
return {
|
|
@@ -13697,7 +13786,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
13697
13786
|
});
|
|
13698
13787
|
}
|
|
13699
13788
|
|
|
13700
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.29.0-alpha.
|
|
13789
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.29.0-alpha.SCAL-205893-1";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/**","cjs/**"];var exports$1={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",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-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",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 --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","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",dompurify:"^2.3.4","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^46.9.0",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1"};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","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@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","current-git-branch":"^1.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.13.1","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":"6.7.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-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",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-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","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","embedded","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$1,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.js",limit:"45 kB"}],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};
|
|
13701
13790
|
|
|
13702
13791
|
/**
|
|
13703
13792
|
* Copyright (c) 2022
|
|
@@ -13797,6 +13886,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
13797
13886
|
});
|
|
13798
13887
|
}
|
|
13799
13888
|
catch (e) {
|
|
13889
|
+
logger.error(`Received invalid token. Error : ${e === null || e === void 0 ? void 0 : e.message}`);
|
|
13800
13890
|
processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
|
|
13801
13891
|
}
|
|
13802
13892
|
}
|
|
@@ -14141,6 +14231,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
14141
14231
|
* @param url - The URL of the embedded ThoughtSpot app.
|
|
14142
14232
|
*/
|
|
14143
14233
|
async renderIFrame(url) {
|
|
14234
|
+
console.log('here 7');
|
|
14144
14235
|
if (this.isError) {
|
|
14145
14236
|
return null;
|
|
14146
14237
|
}
|
|
@@ -14148,8 +14239,10 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
14148
14239
|
this.throwInitError();
|
|
14149
14240
|
}
|
|
14150
14241
|
if (url.length > URL_MAX_LENGTH) ;
|
|
14242
|
+
console.log('here 8');
|
|
14151
14243
|
return renderInQueue((nextInQueue) => {
|
|
14152
14244
|
var _a;
|
|
14245
|
+
console.log('here 6');
|
|
14153
14246
|
const initTimestamp = Date.now();
|
|
14154
14247
|
this.executeCallbacks(exports.EmbedEvent.Init, {
|
|
14155
14248
|
data: {
|
|
@@ -14159,6 +14252,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
14159
14252
|
});
|
|
14160
14253
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
14161
14254
|
return (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
|
|
14255
|
+
console.log('here 9', isLoggedIn);
|
|
14162
14256
|
if (!isLoggedIn) {
|
|
14163
14257
|
this.handleInsertionIntoDOM(this.embedConfig.loginFailedMessage);
|
|
14164
14258
|
return;
|
|
@@ -14182,7 +14276,9 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
14182
14276
|
this.iFrame.addEventListener('error', () => {
|
|
14183
14277
|
nextInQueue();
|
|
14184
14278
|
});
|
|
14279
|
+
console.log('here 10', this.iFrame);
|
|
14185
14280
|
this.handleInsertionIntoDOM(this.iFrame);
|
|
14281
|
+
console.log('here 11', document.body.innerHTML);
|
|
14186
14282
|
const prefetchIframe = document.querySelectorAll('.prefetchIframe');
|
|
14187
14283
|
if (prefetchIframe.length) {
|
|
14188
14284
|
prefetchIframe.forEach((el) => {
|
|
@@ -15784,6 +15880,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
15784
15880
|
exports.SageEmbed = SageEmbed$1;
|
|
15785
15881
|
exports.SearchBarEmbed = SearchBarEmbed$1;
|
|
15786
15882
|
exports.SearchEmbed = SearchEmbed$1;
|
|
15883
|
+
exports.getSessionInfo = getSessionInfo;
|
|
15787
15884
|
exports.useEmbedRef = useEmbedRef;
|
|
15788
15885
|
|
|
15789
15886
|
Object.defineProperty(exports, '__esModule', { value: true });
|