@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.es.js
CHANGED
|
@@ -1571,7 +1571,7 @@ var HostEvent;
|
|
|
1571
1571
|
*
|
|
1572
1572
|
* @example
|
|
1573
1573
|
* ```js
|
|
1574
|
-
* liveboardEmbed.trigger(HostEvent.
|
|
1574
|
+
* liveboardEmbed.trigger(HostEvent.getExportRequestForCurrentPinboard).then(
|
|
1575
1575
|
* data=>console.log(data))
|
|
1576
1576
|
* ```
|
|
1577
1577
|
* @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1.sw
|
|
@@ -5940,6 +5940,7 @@ var isEqual_1 = isEqual;
|
|
|
5940
5940
|
|
|
5941
5941
|
const EndPoints = {
|
|
5942
5942
|
AUTH_VERIFICATION: '/callosum/v1/session/info',
|
|
5943
|
+
SESSION_INFO: '/callosum/v1/session/info',
|
|
5943
5944
|
SAML_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/saml/login?targetURLPath=${targetUrl}`,
|
|
5944
5945
|
OIDC_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
|
|
5945
5946
|
TOKEN_LOGIN: '/callosum/v1/session/login/token',
|
|
@@ -6056,7 +6057,7 @@ const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every tim
|
|
|
6056
6057
|
const INVALID_TOKEN_ERR = 'Invalid token received form token callback or authToken endpoint.';
|
|
6057
6058
|
let cachedAuthToken = null;
|
|
6058
6059
|
// This method can be used to get the authToken using the embedConfig
|
|
6059
|
-
|
|
6060
|
+
async function getAuthenticationToken(embedConfig) {
|
|
6060
6061
|
// Since we don't have token validation enabled , we cannot tell if the
|
|
6061
6062
|
// cached token is valid or not. So we will always fetch a new token.
|
|
6062
6063
|
if (cachedAuthToken && !embedConfig.disableTokenVerification) {
|
|
@@ -6079,11 +6080,17 @@ const getAuthenticationToken = async (embedConfig) => {
|
|
|
6079
6080
|
const response = await fetchAuthTokenService(authEndpoint);
|
|
6080
6081
|
authToken = await response.text();
|
|
6081
6082
|
}
|
|
6082
|
-
|
|
6083
|
-
|
|
6083
|
+
try {
|
|
6084
|
+
// this will throw error if the token is not valid
|
|
6085
|
+
await validateAuthToken(embedConfig, authToken);
|
|
6086
|
+
}
|
|
6087
|
+
catch (e) {
|
|
6088
|
+
logger.error(`Received invalid token from getAuthToken callback or authToken endpoint. Error : ${e.message}`);
|
|
6089
|
+
throw e;
|
|
6090
|
+
}
|
|
6084
6091
|
cachedAuthToken = authToken;
|
|
6085
6092
|
return authToken;
|
|
6086
|
-
}
|
|
6093
|
+
}
|
|
6087
6094
|
const validateAuthToken = async (embedConfig, authToken, suppressAlert) => {
|
|
6088
6095
|
if (embedConfig.disableTokenVerification) {
|
|
6089
6096
|
logger.info('Token verification is disabled. Assuming token is valid.');
|
|
@@ -6365,6 +6372,16 @@ var OperationType;
|
|
|
6365
6372
|
* const data = await underlying.fetchData(0, 100);
|
|
6366
6373
|
* })
|
|
6367
6374
|
* ```
|
|
6375
|
+
* @example
|
|
6376
|
+
* ```js
|
|
6377
|
+
* embed.on(EmbedEvent.Data, async (e) => {
|
|
6378
|
+
* const service = await embed.getAnswerService();
|
|
6379
|
+
* await service.addColumns([
|
|
6380
|
+
* "<column guid>"
|
|
6381
|
+
* ]);
|
|
6382
|
+
* console.log(await service.fetchData());
|
|
6383
|
+
* });
|
|
6384
|
+
* ```
|
|
6368
6385
|
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
6369
6386
|
* @group Events
|
|
6370
6387
|
*/
|
|
@@ -12705,6 +12722,7 @@ function emptyQueue() {
|
|
|
12705
12722
|
function initMixpanel(sessionInfo) {
|
|
12706
12723
|
var _a;
|
|
12707
12724
|
if (!sessionInfo || !sessionInfo.mixpanelToken) {
|
|
12725
|
+
logger.error('Mixpanel token not found in session info');
|
|
12708
12726
|
return;
|
|
12709
12727
|
}
|
|
12710
12728
|
// On a public cluster the user is anonymous, so don't set the identify to
|
|
@@ -13299,49 +13317,124 @@ var uniq_1 = uniq;
|
|
|
13299
13317
|
* @param url
|
|
13300
13318
|
* @param options
|
|
13301
13319
|
*/
|
|
13302
|
-
function
|
|
13320
|
+
function tokenizedFailureLoggedFetch(url, options = {}) {
|
|
13303
13321
|
return tokenizedFetch(url, options).then(async (r) => {
|
|
13304
13322
|
var _a;
|
|
13305
13323
|
if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
|
|
13306
|
-
logger.error(
|
|
13324
|
+
logger.error(`Failed to fetch ${url}`, await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
|
|
13307
13325
|
}
|
|
13308
13326
|
return r;
|
|
13309
13327
|
});
|
|
13310
13328
|
}
|
|
13311
13329
|
/**
|
|
13330
|
+
* Fetches the session info from the ThoughtSpot server.
|
|
13312
13331
|
*
|
|
13313
|
-
* @param
|
|
13332
|
+
* @param thoughtspotHost
|
|
13333
|
+
* @returns {Promise<any>}
|
|
13334
|
+
* @example
|
|
13335
|
+
* ```js
|
|
13336
|
+
* const response = await sessionInfoService();
|
|
13337
|
+
* ```
|
|
13314
13338
|
*/
|
|
13315
|
-
function fetchSessionInfoService(
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13339
|
+
async function fetchSessionInfoService(thoughtspotHost) {
|
|
13340
|
+
const sessionInfoPath = `${thoughtspotHost}${EndPoints.SESSION_INFO}`;
|
|
13341
|
+
const response = await tokenizedFailureLoggedFetch(sessionInfoPath);
|
|
13342
|
+
if (!response.ok) {
|
|
13343
|
+
throw new Error(`Failed to fetch session info: ${response.statusText}`);
|
|
13344
|
+
}
|
|
13345
|
+
const data = await response.json();
|
|
13346
|
+
return data;
|
|
13319
13347
|
}
|
|
13320
13348
|
/**
|
|
13321
13349
|
*
|
|
13322
13350
|
* @param thoughtSpotHost
|
|
13323
13351
|
*/
|
|
13324
13352
|
async function fetchLogoutService(thoughtSpotHost) {
|
|
13325
|
-
return
|
|
13353
|
+
return tokenizedFailureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
|
|
13326
13354
|
credentials: 'include',
|
|
13327
13355
|
method: 'POST',
|
|
13328
13356
|
headers: {
|
|
13329
13357
|
'x-requested-by': 'ThoughtSpot',
|
|
13330
13358
|
},
|
|
13331
13359
|
});
|
|
13360
|
+
}
|
|
13361
|
+
/**
|
|
13362
|
+
* Is active service to check if the user is logged in.
|
|
13363
|
+
*
|
|
13364
|
+
* @param thoughtSpotHost
|
|
13365
|
+
* @version SDK: 1.28.4 | ThoughtSpot: *
|
|
13366
|
+
*/
|
|
13367
|
+
async function isActiveService(thoughtSpotHost) {
|
|
13368
|
+
const isActiveUrl = `${thoughtSpotHost}${EndPoints.IS_ACTIVE}`;
|
|
13369
|
+
try {
|
|
13370
|
+
const res = await tokenizedFetch(isActiveUrl, {
|
|
13371
|
+
credentials: 'include',
|
|
13372
|
+
});
|
|
13373
|
+
return res.ok;
|
|
13374
|
+
}
|
|
13375
|
+
catch (e) {
|
|
13376
|
+
logger.warn(`Is Logged In Service failed : ${e.message}`);
|
|
13377
|
+
}
|
|
13378
|
+
return false;
|
|
13332
13379
|
}
|
|
13333
13380
|
|
|
13381
|
+
let sessionInfo = null;
|
|
13382
|
+
/**
|
|
13383
|
+
* Returns the session info object and caches it for future use.
|
|
13384
|
+
* Once fetched the session info object is cached and returned from the cache on
|
|
13385
|
+
* subsequent calls.
|
|
13386
|
+
*
|
|
13387
|
+
* @example ```js
|
|
13388
|
+
* const sessionInfo = await getSessionInfo();
|
|
13389
|
+
* console.log(sessionInfo);
|
|
13390
|
+
* ```
|
|
13391
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
13392
|
+
* @returns {Promise<SessionInfo>} The session info object.
|
|
13393
|
+
*/
|
|
13394
|
+
async function getSessionInfo() {
|
|
13395
|
+
if (!sessionInfo) {
|
|
13396
|
+
const host = getEmbedConfig().thoughtSpotHost;
|
|
13397
|
+
const sessionResponse = await fetchSessionInfoService(host);
|
|
13398
|
+
const processedSessionInfo = getSessionDetails(sessionResponse);
|
|
13399
|
+
sessionInfo = processedSessionInfo;
|
|
13400
|
+
}
|
|
13401
|
+
return sessionInfo;
|
|
13402
|
+
}
|
|
13403
|
+
/**
|
|
13404
|
+
* Processes the session info response and returns the session info object.
|
|
13405
|
+
*
|
|
13406
|
+
* @param sessionInfoResp {any} Response from the session info API.
|
|
13407
|
+
* @returns {SessionInfo} The session info object.
|
|
13408
|
+
* @example ```js
|
|
13409
|
+
* const sessionInfoResp = await fetch(sessionInfoPath);
|
|
13410
|
+
* const sessionInfo = getSessionDetails(sessionInfoResp);
|
|
13411
|
+
* console.log(sessionInfo);
|
|
13412
|
+
* ```
|
|
13413
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
13414
|
+
*/
|
|
13415
|
+
const getSessionDetails = (sessionInfoResp) => {
|
|
13416
|
+
const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
|
|
13417
|
+
const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
|
|
13418
|
+
const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
|
|
13419
|
+
? prodMixpanelToken
|
|
13420
|
+
: devMixpanelToken;
|
|
13421
|
+
return {
|
|
13422
|
+
userGUID: sessionInfoResp.userGUID,
|
|
13423
|
+
mixpanelToken,
|
|
13424
|
+
isPublicUser: sessionInfoResp.configInfo.isPublicUser,
|
|
13425
|
+
releaseVersion: sessionInfoResp.releaseVersion,
|
|
13426
|
+
clusterId: sessionInfoResp.configInfo.selfClusterId,
|
|
13427
|
+
clusterName: sessionInfoResp.configInfo.selfClusterName,
|
|
13428
|
+
...sessionInfoResp,
|
|
13429
|
+
};
|
|
13430
|
+
};
|
|
13431
|
+
|
|
13334
13432
|
// eslint-disable-next-line import/no-mutable-exports
|
|
13335
13433
|
let loggedInStatus = false;
|
|
13336
13434
|
// eslint-disable-next-line import/no-mutable-exports
|
|
13337
13435
|
let samlAuthWindow = null;
|
|
13338
13436
|
// eslint-disable-next-line import/no-mutable-exports
|
|
13339
13437
|
let samlCompletionPromise = null;
|
|
13340
|
-
let sessionInfo = null;
|
|
13341
|
-
let sessionInfoResolver = null;
|
|
13342
|
-
const sessionInfoPromise = new Promise((resolve) => {
|
|
13343
|
-
sessionInfoResolver = resolve;
|
|
13344
|
-
});
|
|
13345
13438
|
let releaseVersion = '';
|
|
13346
13439
|
const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
|
|
13347
13440
|
/**
|
|
@@ -13423,12 +13516,18 @@ function notifyAuthSDKSuccess() {
|
|
|
13423
13516
|
/**
|
|
13424
13517
|
*
|
|
13425
13518
|
*/
|
|
13426
|
-
function notifyAuthSuccess() {
|
|
13519
|
+
async function notifyAuthSuccess() {
|
|
13427
13520
|
if (!authEE) {
|
|
13428
13521
|
logger.error('SDK not initialized');
|
|
13429
13522
|
return;
|
|
13430
13523
|
}
|
|
13431
|
-
|
|
13524
|
+
try {
|
|
13525
|
+
const sessionInfo = await getSessionInfo();
|
|
13526
|
+
authEE.emit(AuthStatus.SUCCESS, sessionInfo);
|
|
13527
|
+
}
|
|
13528
|
+
catch (e) {
|
|
13529
|
+
logger.error('Failed to get session info');
|
|
13530
|
+
}
|
|
13432
13531
|
}
|
|
13433
13532
|
/**
|
|
13434
13533
|
*
|
|
@@ -13451,67 +13550,45 @@ function notifyLogout() {
|
|
|
13451
13550
|
}
|
|
13452
13551
|
authEE.emit(AuthStatus.LOGOUT);
|
|
13453
13552
|
}
|
|
13454
|
-
const initSession = (sessionDetails) => {
|
|
13455
|
-
const embedConfig = getEmbedConfig();
|
|
13456
|
-
if (sessionInfo == null) {
|
|
13457
|
-
sessionInfo = sessionDetails;
|
|
13458
|
-
if (!embedConfig.disableSDKTracking) {
|
|
13459
|
-
initMixpanel(sessionInfo);
|
|
13460
|
-
}
|
|
13461
|
-
sessionInfoResolver(sessionInfo);
|
|
13462
|
-
}
|
|
13463
|
-
};
|
|
13464
|
-
const getSessionDetails = (sessionInfoResp) => {
|
|
13465
|
-
const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
|
|
13466
|
-
const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
|
|
13467
|
-
const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
|
|
13468
|
-
? prodMixpanelToken
|
|
13469
|
-
: devMixpanelToken;
|
|
13470
|
-
return {
|
|
13471
|
-
userGUID: sessionInfoResp.userGUID,
|
|
13472
|
-
mixpanelToken,
|
|
13473
|
-
isPublicUser: sessionInfoResp.configInfo.isPublicUser,
|
|
13474
|
-
releaseVersion: sessionInfoResp.releaseVersion,
|
|
13475
|
-
clusterId: sessionInfoResp.configInfo.selfClusterId,
|
|
13476
|
-
clusterName: sessionInfoResp.configInfo.selfClusterName,
|
|
13477
|
-
...sessionInfoResp,
|
|
13478
|
-
};
|
|
13479
|
-
};
|
|
13480
13553
|
/**
|
|
13481
13554
|
* Check if we are logged into the ThoughtSpot cluster
|
|
13482
13555
|
*
|
|
13483
13556
|
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
13484
13557
|
*/
|
|
13485
13558
|
async function isLoggedIn(thoughtSpotHost) {
|
|
13486
|
-
const authVerificationUrl = `${thoughtSpotHost}${EndPoints.AUTH_VERIFICATION}`;
|
|
13487
|
-
let response = null;
|
|
13488
13559
|
try {
|
|
13489
|
-
response = await
|
|
13490
|
-
|
|
13491
|
-
const sessionDetails = getSessionDetails(sessionInfoResp);
|
|
13492
|
-
// Store user session details from session info
|
|
13493
|
-
initSession(sessionDetails);
|
|
13494
|
-
releaseVersion = sessionInfoResp.releaseVersion;
|
|
13560
|
+
const response = await isActiveService(thoughtSpotHost);
|
|
13561
|
+
return response;
|
|
13495
13562
|
}
|
|
13496
13563
|
catch (e) {
|
|
13497
13564
|
return false;
|
|
13498
13565
|
}
|
|
13499
|
-
return response.status === 200;
|
|
13500
13566
|
}
|
|
13501
13567
|
/**
|
|
13502
|
-
*
|
|
13568
|
+
* Services to be called after the login is successful,
|
|
13569
|
+
* This should be called after the cookie is set for cookie auth or
|
|
13570
|
+
* after the token is set for cookieless.
|
|
13571
|
+
*
|
|
13572
|
+
* @return {Promise<void>}
|
|
13573
|
+
* @example
|
|
13574
|
+
* ```js
|
|
13575
|
+
* await postLoginService();
|
|
13576
|
+
* ```
|
|
13577
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
13503
13578
|
*/
|
|
13504
|
-
function
|
|
13505
|
-
|
|
13579
|
+
async function postLoginService() {
|
|
13580
|
+
const sessionInfo = await getSessionInfo();
|
|
13581
|
+
releaseVersion = sessionInfo.releaseVersion;
|
|
13582
|
+
const embedConfig = getEmbedConfig();
|
|
13583
|
+
if (!embedConfig.disableSDKTracking) {
|
|
13584
|
+
initMixpanel(sessionInfo);
|
|
13585
|
+
}
|
|
13506
13586
|
}
|
|
13507
13587
|
/**
|
|
13508
|
-
* Return
|
|
13509
|
-
* authentication is successful. And info is available.
|
|
13510
|
-
*
|
|
13511
|
-
* @group Global methods
|
|
13588
|
+
* Return releaseVersion if available
|
|
13512
13589
|
*/
|
|
13513
|
-
function
|
|
13514
|
-
return
|
|
13590
|
+
function getReleaseVersion() {
|
|
13591
|
+
return releaseVersion;
|
|
13515
13592
|
}
|
|
13516
13593
|
/**
|
|
13517
13594
|
* Check if we are stuck at the SSO redirect URL
|
|
@@ -13542,7 +13619,14 @@ const doTokenAuth = async (embedConfig) => {
|
|
|
13542
13619
|
}
|
|
13543
13620
|
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
13544
13621
|
if (!loggedInStatus) {
|
|
13545
|
-
|
|
13622
|
+
let authToken;
|
|
13623
|
+
try {
|
|
13624
|
+
authToken = await getAuthenticationToken(embedConfig);
|
|
13625
|
+
}
|
|
13626
|
+
catch (e) {
|
|
13627
|
+
loggedInStatus = false;
|
|
13628
|
+
throw e;
|
|
13629
|
+
}
|
|
13546
13630
|
let resp;
|
|
13547
13631
|
try {
|
|
13548
13632
|
resp = await fetchAuthPostService(thoughtSpotHost, username, authToken);
|
|
@@ -13700,7 +13784,7 @@ const logout = async (embedConfig) => {
|
|
|
13700
13784
|
const { thoughtSpotHost } = embedConfig;
|
|
13701
13785
|
await fetchLogoutService(thoughtSpotHost);
|
|
13702
13786
|
resetCachedAuthToken();
|
|
13703
|
-
const thoughtspotIframes = document.querySelectorAll(
|
|
13787
|
+
const thoughtspotIframes = document.querySelectorAll("[data-ts-iframe='true']");
|
|
13704
13788
|
if (thoughtspotIframes === null || thoughtspotIframes === void 0 ? void 0 : thoughtspotIframes.length) {
|
|
13705
13789
|
thoughtspotIframes.forEach((el) => {
|
|
13706
13790
|
el.parentElement.innerHTML = embedConfig.loginFailedMessage;
|
|
@@ -13755,6 +13839,8 @@ const handleAuth = () => {
|
|
|
13755
13839
|
notifyAuthFailure(AuthFailureType.SDK);
|
|
13756
13840
|
}
|
|
13757
13841
|
else {
|
|
13842
|
+
// Post login service is called after successful login.
|
|
13843
|
+
postLoginService();
|
|
13758
13844
|
notifyAuthSDKSuccess();
|
|
13759
13845
|
}
|
|
13760
13846
|
}, () => {
|
|
@@ -14050,13 +14136,13 @@ function processCustomAction(e, thoughtSpotHost) {
|
|
|
14050
14136
|
};
|
|
14051
14137
|
}
|
|
14052
14138
|
/**
|
|
14139
|
+
* Responds to AuthInit sent from host signifying successful authentication in host.
|
|
14053
14140
|
*
|
|
14054
14141
|
* @param e
|
|
14142
|
+
* @returns {any}
|
|
14055
14143
|
*/
|
|
14056
14144
|
function processAuthInit(e) {
|
|
14057
14145
|
var _a, _b;
|
|
14058
|
-
// Store user session details sent by app.
|
|
14059
|
-
initSession(e.data);
|
|
14060
14146
|
notifyAuthSuccess();
|
|
14061
14147
|
// Expose only allowed details (eg: userGUID) back to SDK users.
|
|
14062
14148
|
return {
|
|
@@ -14194,7 +14280,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
|
|
|
14194
14280
|
});
|
|
14195
14281
|
}
|
|
14196
14282
|
|
|
14197
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.29.0-alpha.
|
|
14283
|
+
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={".":{"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,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};
|
|
14198
14284
|
|
|
14199
14285
|
/**
|
|
14200
14286
|
* Copyright (c) 2022
|
|
@@ -14294,6 +14380,7 @@ class TsEmbed {
|
|
|
14294
14380
|
});
|
|
14295
14381
|
}
|
|
14296
14382
|
catch (e) {
|
|
14383
|
+
logger.error(`Received invalid token. Error : ${e === null || e === void 0 ? void 0 : e.message}`);
|
|
14297
14384
|
processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
|
|
14298
14385
|
}
|
|
14299
14386
|
}
|
|
@@ -14638,6 +14725,7 @@ class TsEmbed {
|
|
|
14638
14725
|
* @param url - The URL of the embedded ThoughtSpot app.
|
|
14639
14726
|
*/
|
|
14640
14727
|
async renderIFrame(url) {
|
|
14728
|
+
console.log('here 7');
|
|
14641
14729
|
if (this.isError) {
|
|
14642
14730
|
return null;
|
|
14643
14731
|
}
|
|
@@ -14645,8 +14733,10 @@ class TsEmbed {
|
|
|
14645
14733
|
this.throwInitError();
|
|
14646
14734
|
}
|
|
14647
14735
|
if (url.length > URL_MAX_LENGTH) ;
|
|
14736
|
+
console.log('here 8');
|
|
14648
14737
|
return renderInQueue((nextInQueue) => {
|
|
14649
14738
|
var _a;
|
|
14739
|
+
console.log('here 6');
|
|
14650
14740
|
const initTimestamp = Date.now();
|
|
14651
14741
|
this.executeCallbacks(EmbedEvent.Init, {
|
|
14652
14742
|
data: {
|
|
@@ -14656,6 +14746,7 @@ class TsEmbed {
|
|
|
14656
14746
|
});
|
|
14657
14747
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
14658
14748
|
return (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
|
|
14749
|
+
console.log('here 9', isLoggedIn);
|
|
14659
14750
|
if (!isLoggedIn) {
|
|
14660
14751
|
this.handleInsertionIntoDOM(this.embedConfig.loginFailedMessage);
|
|
14661
14752
|
return;
|
|
@@ -14679,7 +14770,9 @@ class TsEmbed {
|
|
|
14679
14770
|
this.iFrame.addEventListener('error', () => {
|
|
14680
14771
|
nextInQueue();
|
|
14681
14772
|
});
|
|
14773
|
+
console.log('here 10', this.iFrame);
|
|
14682
14774
|
this.handleInsertionIntoDOM(this.iFrame);
|
|
14775
|
+
console.log('here 11', document.body.innerHTML);
|
|
14683
14776
|
const prefetchIframe = document.querySelectorAll('.prefetchIframe');
|
|
14684
14777
|
if (prefetchIframe.length) {
|
|
14685
14778
|
prefetchIframe.forEach((el) => {
|