@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.es.js
CHANGED
|
@@ -1954,7 +1954,7 @@ var HostEvent;
|
|
|
1954
1954
|
*
|
|
1955
1955
|
* @example
|
|
1956
1956
|
* ```js
|
|
1957
|
-
* liveboardEmbed.trigger(HostEvent.
|
|
1957
|
+
* liveboardEmbed.trigger(HostEvent.getExportRequestForCurrentPinboard).then(
|
|
1958
1958
|
* data=>console.log(data))
|
|
1959
1959
|
* ```
|
|
1960
1960
|
* @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1.sw
|
|
@@ -6051,6 +6051,7 @@ const logger = new Logger();
|
|
|
6051
6051
|
|
|
6052
6052
|
const EndPoints = {
|
|
6053
6053
|
AUTH_VERIFICATION: '/callosum/v1/session/info',
|
|
6054
|
+
SESSION_INFO: '/callosum/v1/session/info',
|
|
6054
6055
|
SAML_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/saml/login?targetURLPath=${targetUrl}`,
|
|
6055
6056
|
OIDC_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
|
|
6056
6057
|
TOKEN_LOGIN: '/callosum/v1/session/login/token',
|
|
@@ -6167,7 +6168,7 @@ const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every tim
|
|
|
6167
6168
|
const INVALID_TOKEN_ERR = 'Invalid token received form token callback or authToken endpoint.';
|
|
6168
6169
|
let cachedAuthToken = null;
|
|
6169
6170
|
// This method can be used to get the authToken using the embedConfig
|
|
6170
|
-
|
|
6171
|
+
async function getAuthenticationToken(embedConfig) {
|
|
6171
6172
|
// Since we don't have token validation enabled , we cannot tell if the
|
|
6172
6173
|
// cached token is valid or not. So we will always fetch a new token.
|
|
6173
6174
|
if (cachedAuthToken && !embedConfig.disableTokenVerification) {
|
|
@@ -6190,11 +6191,17 @@ const getAuthenticationToken = async (embedConfig) => {
|
|
|
6190
6191
|
const response = await fetchAuthTokenService(authEndpoint);
|
|
6191
6192
|
authToken = await response.text();
|
|
6192
6193
|
}
|
|
6193
|
-
|
|
6194
|
-
|
|
6194
|
+
try {
|
|
6195
|
+
// this will throw error if the token is not valid
|
|
6196
|
+
await validateAuthToken(embedConfig, authToken);
|
|
6197
|
+
}
|
|
6198
|
+
catch (e) {
|
|
6199
|
+
logger.error(`Received invalid token from getAuthToken callback or authToken endpoint. Error : ${e.message}`);
|
|
6200
|
+
throw e;
|
|
6201
|
+
}
|
|
6195
6202
|
cachedAuthToken = authToken;
|
|
6196
6203
|
return authToken;
|
|
6197
|
-
}
|
|
6204
|
+
}
|
|
6198
6205
|
const validateAuthToken = async (embedConfig, authToken, suppressAlert) => {
|
|
6199
6206
|
if (embedConfig.disableTokenVerification) {
|
|
6200
6207
|
logger.info('Token verification is disabled. Assuming token is valid.');
|
|
@@ -6464,6 +6471,16 @@ var OperationType;
|
|
|
6464
6471
|
* const data = await underlying.fetchData(0, 100);
|
|
6465
6472
|
* })
|
|
6466
6473
|
* ```
|
|
6474
|
+
* @example
|
|
6475
|
+
* ```js
|
|
6476
|
+
* embed.on(EmbedEvent.Data, async (e) => {
|
|
6477
|
+
* const service = await embed.getAnswerService();
|
|
6478
|
+
* await service.addColumns([
|
|
6479
|
+
* "<column guid>"
|
|
6480
|
+
* ]);
|
|
6481
|
+
* console.log(await service.fetchData());
|
|
6482
|
+
* });
|
|
6483
|
+
* ```
|
|
6467
6484
|
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
6468
6485
|
* @group Events
|
|
6469
6486
|
*/
|
|
@@ -12804,6 +12821,7 @@ function emptyQueue() {
|
|
|
12804
12821
|
function initMixpanel(sessionInfo) {
|
|
12805
12822
|
var _a;
|
|
12806
12823
|
if (!sessionInfo || !sessionInfo.mixpanelToken) {
|
|
12824
|
+
logger.error('Mixpanel token not found in session info');
|
|
12807
12825
|
return;
|
|
12808
12826
|
}
|
|
12809
12827
|
// On a public cluster the user is anonymous, so don't set the identify to
|
|
@@ -13188,36 +13206,111 @@ var createSet = !(_Set && (1 / _setToArray(new _Set([,-0]))[1]) == INFINITY) ? n
|
|
|
13188
13206
|
* @param url
|
|
13189
13207
|
* @param options
|
|
13190
13208
|
*/
|
|
13191
|
-
function
|
|
13209
|
+
function tokenizedFailureLoggedFetch(url, options = {}) {
|
|
13192
13210
|
return tokenizedFetch(url, options).then(async (r) => {
|
|
13193
13211
|
var _a;
|
|
13194
13212
|
if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
|
|
13195
|
-
logger.error(
|
|
13213
|
+
logger.error(`Failed to fetch ${url}`, await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
|
|
13196
13214
|
}
|
|
13197
13215
|
return r;
|
|
13198
13216
|
});
|
|
13199
13217
|
}
|
|
13200
13218
|
/**
|
|
13219
|
+
* Fetches the session info from the ThoughtSpot server.
|
|
13201
13220
|
*
|
|
13202
|
-
* @param
|
|
13221
|
+
* @param thoughtspotHost
|
|
13222
|
+
* @returns {Promise<any>}
|
|
13223
|
+
* @example
|
|
13224
|
+
* ```js
|
|
13225
|
+
* const response = await sessionInfoService();
|
|
13226
|
+
* ```
|
|
13203
13227
|
*/
|
|
13204
|
-
function fetchSessionInfoService(
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13228
|
+
async function fetchSessionInfoService(thoughtspotHost) {
|
|
13229
|
+
const sessionInfoPath = `${thoughtspotHost}${EndPoints.SESSION_INFO}`;
|
|
13230
|
+
const response = await tokenizedFailureLoggedFetch(sessionInfoPath);
|
|
13231
|
+
if (!response.ok) {
|
|
13232
|
+
throw new Error(`Failed to fetch session info: ${response.statusText}`);
|
|
13233
|
+
}
|
|
13234
|
+
const data = await response.json();
|
|
13235
|
+
return data;
|
|
13236
|
+
}
|
|
13237
|
+
/**
|
|
13238
|
+
* Is active service to check if the user is logged in.
|
|
13239
|
+
*
|
|
13240
|
+
* @param thoughtSpotHost
|
|
13241
|
+
* @version SDK: 1.28.4 | ThoughtSpot: *
|
|
13242
|
+
*/
|
|
13243
|
+
async function isActiveService(thoughtSpotHost) {
|
|
13244
|
+
const isActiveUrl = `${thoughtSpotHost}${EndPoints.IS_ACTIVE}`;
|
|
13245
|
+
try {
|
|
13246
|
+
const res = await tokenizedFetch(isActiveUrl, {
|
|
13247
|
+
credentials: 'include',
|
|
13248
|
+
});
|
|
13249
|
+
return res.ok;
|
|
13250
|
+
}
|
|
13251
|
+
catch (e) {
|
|
13252
|
+
logger.warn(`Is Logged In Service failed : ${e.message}`);
|
|
13253
|
+
}
|
|
13254
|
+
return false;
|
|
13208
13255
|
}
|
|
13209
13256
|
|
|
13257
|
+
let sessionInfo = null;
|
|
13258
|
+
/**
|
|
13259
|
+
* Returns the session info object and caches it for future use.
|
|
13260
|
+
* Once fetched the session info object is cached and returned from the cache on
|
|
13261
|
+
* subsequent calls.
|
|
13262
|
+
*
|
|
13263
|
+
* @example ```js
|
|
13264
|
+
* const sessionInfo = await getSessionInfo();
|
|
13265
|
+
* console.log(sessionInfo);
|
|
13266
|
+
* ```
|
|
13267
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
13268
|
+
* @returns {Promise<SessionInfo>} The session info object.
|
|
13269
|
+
*/
|
|
13270
|
+
async function getSessionInfo() {
|
|
13271
|
+
if (!sessionInfo) {
|
|
13272
|
+
const host = getEmbedConfig().thoughtSpotHost;
|
|
13273
|
+
const sessionResponse = await fetchSessionInfoService(host);
|
|
13274
|
+
const processedSessionInfo = getSessionDetails(sessionResponse);
|
|
13275
|
+
sessionInfo = processedSessionInfo;
|
|
13276
|
+
}
|
|
13277
|
+
return sessionInfo;
|
|
13278
|
+
}
|
|
13279
|
+
/**
|
|
13280
|
+
* Processes the session info response and returns the session info object.
|
|
13281
|
+
*
|
|
13282
|
+
* @param sessionInfoResp {any} Response from the session info API.
|
|
13283
|
+
* @returns {SessionInfo} The session info object.
|
|
13284
|
+
* @example ```js
|
|
13285
|
+
* const sessionInfoResp = await fetch(sessionInfoPath);
|
|
13286
|
+
* const sessionInfo = getSessionDetails(sessionInfoResp);
|
|
13287
|
+
* console.log(sessionInfo);
|
|
13288
|
+
* ```
|
|
13289
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
13290
|
+
*/
|
|
13291
|
+
const getSessionDetails = (sessionInfoResp) => {
|
|
13292
|
+
const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
|
|
13293
|
+
const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
|
|
13294
|
+
const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
|
|
13295
|
+
? prodMixpanelToken
|
|
13296
|
+
: devMixpanelToken;
|
|
13297
|
+
return {
|
|
13298
|
+
userGUID: sessionInfoResp.userGUID,
|
|
13299
|
+
mixpanelToken,
|
|
13300
|
+
isPublicUser: sessionInfoResp.configInfo.isPublicUser,
|
|
13301
|
+
releaseVersion: sessionInfoResp.releaseVersion,
|
|
13302
|
+
clusterId: sessionInfoResp.configInfo.selfClusterId,
|
|
13303
|
+
clusterName: sessionInfoResp.configInfo.selfClusterName,
|
|
13304
|
+
...sessionInfoResp,
|
|
13305
|
+
};
|
|
13306
|
+
};
|
|
13307
|
+
|
|
13210
13308
|
// eslint-disable-next-line import/no-mutable-exports
|
|
13211
13309
|
let loggedInStatus = false;
|
|
13212
13310
|
// eslint-disable-next-line import/no-mutable-exports
|
|
13213
13311
|
let samlAuthWindow = null;
|
|
13214
13312
|
// eslint-disable-next-line import/no-mutable-exports
|
|
13215
13313
|
let samlCompletionPromise = null;
|
|
13216
|
-
let sessionInfo = null;
|
|
13217
|
-
let sessionInfoResolver = null;
|
|
13218
|
-
const sessionInfoPromise = new Promise((resolve) => {
|
|
13219
|
-
sessionInfoResolver = resolve;
|
|
13220
|
-
});
|
|
13221
13314
|
let releaseVersion = '';
|
|
13222
13315
|
const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
|
|
13223
13316
|
/**
|
|
@@ -13290,7 +13383,7 @@ function notifyAuthSDKSuccess() {
|
|
|
13290
13383
|
/**
|
|
13291
13384
|
*
|
|
13292
13385
|
*/
|
|
13293
|
-
function notifyAuthSuccess() {
|
|
13386
|
+
async function notifyAuthSuccess() {
|
|
13294
13387
|
{
|
|
13295
13388
|
logger.error('SDK not initialized');
|
|
13296
13389
|
return;
|
|
@@ -13315,52 +13408,39 @@ function notifyLogout() {
|
|
|
13315
13408
|
return;
|
|
13316
13409
|
}
|
|
13317
13410
|
}
|
|
13318
|
-
const initSession = (sessionDetails) => {
|
|
13319
|
-
const embedConfig = getEmbedConfig();
|
|
13320
|
-
if (sessionInfo == null) {
|
|
13321
|
-
sessionInfo = sessionDetails;
|
|
13322
|
-
if (!embedConfig.disableSDKTracking) {
|
|
13323
|
-
initMixpanel(sessionInfo);
|
|
13324
|
-
}
|
|
13325
|
-
sessionInfoResolver(sessionInfo);
|
|
13326
|
-
}
|
|
13327
|
-
};
|
|
13328
|
-
const getSessionDetails = (sessionInfoResp) => {
|
|
13329
|
-
const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
|
|
13330
|
-
const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
|
|
13331
|
-
const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
|
|
13332
|
-
? prodMixpanelToken
|
|
13333
|
-
: devMixpanelToken;
|
|
13334
|
-
return {
|
|
13335
|
-
userGUID: sessionInfoResp.userGUID,
|
|
13336
|
-
mixpanelToken,
|
|
13337
|
-
isPublicUser: sessionInfoResp.configInfo.isPublicUser,
|
|
13338
|
-
releaseVersion: sessionInfoResp.releaseVersion,
|
|
13339
|
-
clusterId: sessionInfoResp.configInfo.selfClusterId,
|
|
13340
|
-
clusterName: sessionInfoResp.configInfo.selfClusterName,
|
|
13341
|
-
...sessionInfoResp,
|
|
13342
|
-
};
|
|
13343
|
-
};
|
|
13344
13411
|
/**
|
|
13345
13412
|
* Check if we are logged into the ThoughtSpot cluster
|
|
13346
13413
|
*
|
|
13347
13414
|
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
13348
13415
|
*/
|
|
13349
13416
|
async function isLoggedIn(thoughtSpotHost) {
|
|
13350
|
-
const authVerificationUrl = `${thoughtSpotHost}${EndPoints.AUTH_VERIFICATION}`;
|
|
13351
|
-
let response = null;
|
|
13352
13417
|
try {
|
|
13353
|
-
response = await
|
|
13354
|
-
|
|
13355
|
-
const sessionDetails = getSessionDetails(sessionInfoResp);
|
|
13356
|
-
// Store user session details from session info
|
|
13357
|
-
initSession(sessionDetails);
|
|
13358
|
-
releaseVersion = sessionInfoResp.releaseVersion;
|
|
13418
|
+
const response = await isActiveService(thoughtSpotHost);
|
|
13419
|
+
return response;
|
|
13359
13420
|
}
|
|
13360
13421
|
catch (e) {
|
|
13361
13422
|
return false;
|
|
13362
13423
|
}
|
|
13363
|
-
|
|
13424
|
+
}
|
|
13425
|
+
/**
|
|
13426
|
+
* Services to be called after the login is successful,
|
|
13427
|
+
* This should be called after the cookie is set for cookie auth or
|
|
13428
|
+
* after the token is set for cookieless.
|
|
13429
|
+
*
|
|
13430
|
+
* @return {Promise<void>}
|
|
13431
|
+
* @example
|
|
13432
|
+
* ```js
|
|
13433
|
+
* await postLoginService();
|
|
13434
|
+
* ```
|
|
13435
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
13436
|
+
*/
|
|
13437
|
+
async function postLoginService() {
|
|
13438
|
+
const sessionInfo = await getSessionInfo();
|
|
13439
|
+
releaseVersion = sessionInfo.releaseVersion;
|
|
13440
|
+
const embedConfig = getEmbedConfig();
|
|
13441
|
+
if (!embedConfig.disableSDKTracking) {
|
|
13442
|
+
initMixpanel(sessionInfo);
|
|
13443
|
+
}
|
|
13364
13444
|
}
|
|
13365
13445
|
/**
|
|
13366
13446
|
* Return releaseVersion if available
|
|
@@ -13397,7 +13477,14 @@ const doTokenAuth = async (embedConfig) => {
|
|
|
13397
13477
|
}
|
|
13398
13478
|
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
13399
13479
|
if (!loggedInStatus) {
|
|
13400
|
-
|
|
13480
|
+
let authToken;
|
|
13481
|
+
try {
|
|
13482
|
+
authToken = await getAuthenticationToken(embedConfig);
|
|
13483
|
+
}
|
|
13484
|
+
catch (e) {
|
|
13485
|
+
loggedInStatus = false;
|
|
13486
|
+
throw e;
|
|
13487
|
+
}
|
|
13401
13488
|
let resp;
|
|
13402
13489
|
try {
|
|
13403
13490
|
resp = await fetchAuthPostService(thoughtSpotHost, username, authToken);
|
|
@@ -13595,6 +13682,8 @@ const handleAuth = () => {
|
|
|
13595
13682
|
notifyAuthFailure(AuthFailureType.SDK);
|
|
13596
13683
|
}
|
|
13597
13684
|
else {
|
|
13685
|
+
// Post login service is called after successful login.
|
|
13686
|
+
postLoginService();
|
|
13598
13687
|
notifyAuthSDKSuccess();
|
|
13599
13688
|
}
|
|
13600
13689
|
}, () => {
|
|
@@ -13645,13 +13734,13 @@ function processCustomAction(e, thoughtSpotHost) {
|
|
|
13645
13734
|
};
|
|
13646
13735
|
}
|
|
13647
13736
|
/**
|
|
13737
|
+
* Responds to AuthInit sent from host signifying successful authentication in host.
|
|
13648
13738
|
*
|
|
13649
13739
|
* @param e
|
|
13740
|
+
* @returns {any}
|
|
13650
13741
|
*/
|
|
13651
13742
|
function processAuthInit(e) {
|
|
13652
13743
|
var _a, _b;
|
|
13653
|
-
// Store user session details sent by app.
|
|
13654
|
-
initSession(e.data);
|
|
13655
13744
|
notifyAuthSuccess();
|
|
13656
13745
|
// Expose only allowed details (eg: userGUID) back to SDK users.
|
|
13657
13746
|
return {
|
|
@@ -13789,7 +13878,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
|
|
|
13789
13878
|
});
|
|
13790
13879
|
}
|
|
13791
13880
|
|
|
13792
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.29.0-alpha.
|
|
13881
|
+
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};
|
|
13793
13882
|
|
|
13794
13883
|
/**
|
|
13795
13884
|
* Copyright (c) 2022
|
|
@@ -13889,6 +13978,7 @@ class TsEmbed {
|
|
|
13889
13978
|
});
|
|
13890
13979
|
}
|
|
13891
13980
|
catch (e) {
|
|
13981
|
+
logger.error(`Received invalid token. Error : ${e === null || e === void 0 ? void 0 : e.message}`);
|
|
13892
13982
|
processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
|
|
13893
13983
|
}
|
|
13894
13984
|
}
|
|
@@ -14233,6 +14323,7 @@ class TsEmbed {
|
|
|
14233
14323
|
* @param url - The URL of the embedded ThoughtSpot app.
|
|
14234
14324
|
*/
|
|
14235
14325
|
async renderIFrame(url) {
|
|
14326
|
+
console.log('here 7');
|
|
14236
14327
|
if (this.isError) {
|
|
14237
14328
|
return null;
|
|
14238
14329
|
}
|
|
@@ -14240,8 +14331,10 @@ class TsEmbed {
|
|
|
14240
14331
|
this.throwInitError();
|
|
14241
14332
|
}
|
|
14242
14333
|
if (url.length > URL_MAX_LENGTH) ;
|
|
14334
|
+
console.log('here 8');
|
|
14243
14335
|
return renderInQueue((nextInQueue) => {
|
|
14244
14336
|
var _a;
|
|
14337
|
+
console.log('here 6');
|
|
14245
14338
|
const initTimestamp = Date.now();
|
|
14246
14339
|
this.executeCallbacks(EmbedEvent.Init, {
|
|
14247
14340
|
data: {
|
|
@@ -14251,6 +14344,7 @@ class TsEmbed {
|
|
|
14251
14344
|
});
|
|
14252
14345
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
14253
14346
|
return (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
|
|
14347
|
+
console.log('here 9', isLoggedIn);
|
|
14254
14348
|
if (!isLoggedIn) {
|
|
14255
14349
|
this.handleInsertionIntoDOM(this.embedConfig.loginFailedMessage);
|
|
14256
14350
|
return;
|
|
@@ -14274,7 +14368,9 @@ class TsEmbed {
|
|
|
14274
14368
|
this.iFrame.addEventListener('error', () => {
|
|
14275
14369
|
nextInQueue();
|
|
14276
14370
|
});
|
|
14371
|
+
console.log('here 10', this.iFrame);
|
|
14277
14372
|
this.handleInsertionIntoDOM(this.iFrame);
|
|
14373
|
+
console.log('here 11', document.body.innerHTML);
|
|
14278
14374
|
const prefetchIframe = document.querySelectorAll('.prefetchIframe');
|
|
14279
14375
|
if (prefetchIframe.length) {
|
|
14280
14376
|
prefetchIframe.forEach((el) => {
|
|
@@ -15869,4 +15965,4 @@ function useEmbedRef() {
|
|
|
15869
15965
|
return React.useRef(null);
|
|
15870
15966
|
}
|
|
15871
15967
|
|
|
15872
|
-
export { Action, AppEmbed$1 as AppEmbed, EmbedEvent, HomeLeftNavItem, HomepageModule, HostEvent, LiveboardEmbed$1 as LiveboardEmbed, LogLevel, Page, PinboardEmbed, PreRenderedAppEmbed, PreRenderedLiveboardEmbed, PreRenderedPinboardEmbed, PreRenderedSageEmbed, PreRenderedSearchBarEmbed, PreRenderedSearchEmbed, RuntimeFilterOp, SageEmbed$1 as SageEmbed, SearchBarEmbed$1 as SearchBarEmbed, SearchEmbed$1 as SearchEmbed, useEmbedRef };
|
|
15968
|
+
export { Action, AppEmbed$1 as AppEmbed, EmbedEvent, HomeLeftNavItem, HomepageModule, HostEvent, LiveboardEmbed$1 as LiveboardEmbed, LogLevel, Page, PinboardEmbed, PreRenderedAppEmbed, PreRenderedLiveboardEmbed, PreRenderedPinboardEmbed, PreRenderedSageEmbed, PreRenderedSearchBarEmbed, PreRenderedSearchEmbed, RuntimeFilterOp, SageEmbed$1 as SageEmbed, SearchBarEmbed$1 as SearchBarEmbed, SearchEmbed$1 as SearchEmbed, getSessionInfo, useEmbedRef };
|