@thoughtspot/visual-embed-sdk 1.29.0-alpha.8 → 1.29.0-alpha.SCAL-205893-2

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.
Files changed (229) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/auth.d.ts +14 -17
  3. package/cjs/src/auth.d.ts.map +1 -1
  4. package/cjs/src/auth.js +50 -59
  5. package/cjs/src/auth.js.map +1 -1
  6. package/cjs/src/auth.spec.d.ts +12 -0
  7. package/cjs/src/auth.spec.d.ts.map +1 -1
  8. package/cjs/src/auth.spec.js +89 -67
  9. package/cjs/src/auth.spec.js.map +1 -1
  10. package/cjs/src/authToken.d.ts +1 -1
  11. package/cjs/src/authToken.d.ts.map +1 -1
  12. package/cjs/src/authToken.js +10 -4
  13. package/cjs/src/authToken.js.map +1 -1
  14. package/cjs/src/embed/app.spec.js +4 -2
  15. package/cjs/src/embed/app.spec.js.map +1 -1
  16. package/cjs/src/embed/base.d.ts.map +1 -1
  17. package/cjs/src/embed/base.js +2 -0
  18. package/cjs/src/embed/base.js.map +1 -1
  19. package/cjs/src/embed/base.spec.js +1 -0
  20. package/cjs/src/embed/base.spec.js.map +1 -1
  21. package/cjs/src/embed/embed.spec.js +3 -0
  22. package/cjs/src/embed/embed.spec.js.map +1 -1
  23. package/cjs/src/embed/events.spec.js +3 -0
  24. package/cjs/src/embed/events.spec.js.map +1 -1
  25. package/cjs/src/embed/liveboard.spec.js +2 -0
  26. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  27. package/cjs/src/embed/pinboard.spec.js +3 -0
  28. package/cjs/src/embed/pinboard.spec.js.map +1 -1
  29. package/cjs/src/embed/sage.spec.js +3 -0
  30. package/cjs/src/embed/sage.spec.js.map +1 -1
  31. package/cjs/src/embed/search.spec.js +1 -0
  32. package/cjs/src/embed/search.spec.js.map +1 -1
  33. package/cjs/src/embed/ts-embed-trigger.spec.js +3 -0
  34. package/cjs/src/embed/ts-embed-trigger.spec.js.map +1 -1
  35. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  36. package/cjs/src/embed/ts-embed.js +1 -0
  37. package/cjs/src/embed/ts-embed.js.map +1 -1
  38. package/cjs/src/embed/ts-embed.spec.js +7 -0
  39. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  40. package/cjs/src/index.d.ts +2 -1
  41. package/cjs/src/index.d.ts.map +1 -1
  42. package/cjs/src/index.js +2 -1
  43. package/cjs/src/index.js.map +1 -1
  44. package/cjs/src/mixpanel-service.d.ts +2 -1
  45. package/cjs/src/mixpanel-service.d.ts.map +1 -1
  46. package/cjs/src/mixpanel-service.js +1 -0
  47. package/cjs/src/mixpanel-service.js.map +1 -1
  48. package/cjs/src/mixpanel-service.spec.js +7 -0
  49. package/cjs/src/mixpanel-service.spec.js.map +1 -1
  50. package/cjs/src/react/index.d.ts +1 -1
  51. package/cjs/src/react/index.d.ts.map +1 -1
  52. package/cjs/src/react/index.js +2 -1
  53. package/cjs/src/react/index.js.map +1 -1
  54. package/cjs/src/react/index.spec.js +6 -0
  55. package/cjs/src/react/index.spec.js.map +1 -1
  56. package/cjs/src/types.d.ts +1 -1
  57. package/cjs/src/types.js +1 -1
  58. package/cjs/src/utils/authService/authService.d.ts +1 -0
  59. package/cjs/src/utils/authService/authService.d.ts.map +1 -1
  60. package/cjs/src/utils/authService/authService.js +1 -0
  61. package/cjs/src/utils/authService/authService.js.map +1 -1
  62. package/cjs/src/utils/authService/authService.spec.js +18 -5
  63. package/cjs/src/utils/authService/authService.spec.js.map +1 -1
  64. package/cjs/src/utils/authService/tokenizedAuthService.d.ts +15 -2
  65. package/cjs/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
  66. package/cjs/src/utils/authService/tokenizedAuthService.js +39 -9
  67. package/cjs/src/utils/authService/tokenizedAuthService.js.map +1 -1
  68. package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
  69. package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
  70. package/cjs/src/utils/authService/tokenizedAuthService.spec.js +32 -0
  71. package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +1 -0
  72. package/cjs/src/utils/graphql/answerService/answerService.d.ts +10 -0
  73. package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  74. package/cjs/src/utils/graphql/answerService/answerService.js +10 -0
  75. package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
  76. package/cjs/src/utils/processData.js +2 -2
  77. package/cjs/src/utils/processData.js.map +1 -1
  78. package/cjs/src/utils/processData.spec.js +3 -2
  79. package/cjs/src/utils/processData.spec.js.map +1 -1
  80. package/cjs/src/utils/sessionInfoService.d.ts +66 -0
  81. package/cjs/src/utils/sessionInfoService.d.ts.map +1 -0
  82. package/cjs/src/utils/sessionInfoService.js +92 -0
  83. package/cjs/src/utils/sessionInfoService.js.map +1 -0
  84. package/dist/src/auth.d.ts +14 -17
  85. package/dist/src/auth.d.ts.map +1 -1
  86. package/dist/src/auth.spec.d.ts +12 -0
  87. package/dist/src/auth.spec.d.ts.map +1 -1
  88. package/dist/src/authToken.d.ts +1 -1
  89. package/dist/src/authToken.d.ts.map +1 -1
  90. package/dist/src/embed/base.d.ts.map +1 -1
  91. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  92. package/dist/src/index.d.ts +2 -1
  93. package/dist/src/index.d.ts.map +1 -1
  94. package/dist/src/mixpanel-service.d.ts +2 -1
  95. package/dist/src/mixpanel-service.d.ts.map +1 -1
  96. package/dist/src/react/index.d.ts +1 -1
  97. package/dist/src/react/index.d.ts.map +1 -1
  98. package/dist/src/types.d.ts +1 -1
  99. package/dist/src/utils/authService/authService.d.ts +1 -0
  100. package/dist/src/utils/authService/authService.d.ts.map +1 -1
  101. package/dist/src/utils/authService/tokenizedAuthService.d.ts +15 -2
  102. package/dist/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
  103. package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
  104. package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
  105. package/dist/src/utils/graphql/answerService/answerService.d.ts +10 -0
  106. package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  107. package/dist/src/utils/sessionInfoService.d.ts +66 -0
  108. package/dist/src/utils/sessionInfoService.d.ts.map +1 -0
  109. package/dist/tsembed-react.es.js +153 -58
  110. package/dist/tsembed-react.js +153 -57
  111. package/dist/tsembed.es.js +161 -69
  112. package/dist/tsembed.js +161 -69
  113. package/dist/visual-embed-sdk-react-full.d.ts +93 -20
  114. package/dist/visual-embed-sdk-react.d.ts +93 -20
  115. package/dist/visual-embed-sdk.d.ts +93 -20
  116. package/lib/package.json +1 -1
  117. package/lib/src/auth.d.ts +14 -17
  118. package/lib/src/auth.d.ts.map +1 -1
  119. package/lib/src/auth.js +49 -56
  120. package/lib/src/auth.js.map +1 -1
  121. package/lib/src/auth.spec.d.ts +12 -0
  122. package/lib/src/auth.spec.d.ts.map +1 -1
  123. package/lib/src/auth.spec.js +88 -66
  124. package/lib/src/auth.spec.js.map +1 -1
  125. package/lib/src/authToken.d.ts +1 -1
  126. package/lib/src/authToken.d.ts.map +1 -1
  127. package/lib/src/authToken.js +10 -4
  128. package/lib/src/authToken.js.map +1 -1
  129. package/lib/src/embed/app.spec.js +4 -2
  130. package/lib/src/embed/app.spec.js.map +1 -1
  131. package/lib/src/embed/base.d.ts.map +1 -1
  132. package/lib/src/embed/base.js +3 -1
  133. package/lib/src/embed/base.js.map +1 -1
  134. package/lib/src/embed/base.spec.js +1 -0
  135. package/lib/src/embed/base.spec.js.map +1 -1
  136. package/lib/src/embed/embed.spec.js +2 -0
  137. package/lib/src/embed/embed.spec.js.map +1 -1
  138. package/lib/src/embed/events.spec.js +2 -0
  139. package/lib/src/embed/events.spec.js.map +1 -1
  140. package/lib/src/embed/liveboard.spec.js +2 -0
  141. package/lib/src/embed/liveboard.spec.js.map +1 -1
  142. package/lib/src/embed/pinboard.spec.js +2 -0
  143. package/lib/src/embed/pinboard.spec.js.map +1 -1
  144. package/lib/src/embed/sage.spec.js +2 -0
  145. package/lib/src/embed/sage.spec.js.map +1 -1
  146. package/lib/src/embed/search.spec.js +1 -0
  147. package/lib/src/embed/search.spec.js.map +1 -1
  148. package/lib/src/embed/ts-embed-trigger.spec.js +2 -0
  149. package/lib/src/embed/ts-embed-trigger.spec.js.map +1 -1
  150. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  151. package/lib/src/embed/ts-embed.js +1 -0
  152. package/lib/src/embed/ts-embed.js.map +1 -1
  153. package/lib/src/embed/ts-embed.spec.js +7 -0
  154. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  155. package/lib/src/index.d.ts +2 -1
  156. package/lib/src/index.d.ts.map +1 -1
  157. package/lib/src/index.js +2 -1
  158. package/lib/src/index.js.map +1 -1
  159. package/lib/src/mixpanel-service.d.ts +2 -1
  160. package/lib/src/mixpanel-service.d.ts.map +1 -1
  161. package/lib/src/mixpanel-service.js +1 -0
  162. package/lib/src/mixpanel-service.js.map +1 -1
  163. package/lib/src/mixpanel-service.spec.js +7 -0
  164. package/lib/src/mixpanel-service.spec.js.map +1 -1
  165. package/lib/src/react/index.d.ts +1 -1
  166. package/lib/src/react/index.d.ts.map +1 -1
  167. package/lib/src/react/index.js +1 -1
  168. package/lib/src/react/index.js.map +1 -1
  169. package/lib/src/react/index.spec.js +6 -0
  170. package/lib/src/react/index.spec.js.map +1 -1
  171. package/lib/src/types.d.ts +1 -1
  172. package/lib/src/types.js +1 -1
  173. package/lib/src/utils/authService/authService.d.ts +1 -0
  174. package/lib/src/utils/authService/authService.d.ts.map +1 -1
  175. package/lib/src/utils/authService/authService.js +1 -0
  176. package/lib/src/utils/authService/authService.js.map +1 -1
  177. package/lib/src/utils/authService/authService.spec.js +18 -5
  178. package/lib/src/utils/authService/authService.spec.js.map +1 -1
  179. package/lib/src/utils/authService/tokenizedAuthService.d.ts +15 -2
  180. package/lib/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
  181. package/lib/src/utils/authService/tokenizedAuthService.js +37 -8
  182. package/lib/src/utils/authService/tokenizedAuthService.js.map +1 -1
  183. package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
  184. package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
  185. package/lib/src/utils/authService/tokenizedAuthService.spec.js +29 -0
  186. package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +1 -0
  187. package/lib/src/utils/graphql/answerService/answerService.d.ts +10 -0
  188. package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  189. package/lib/src/utils/graphql/answerService/answerService.js +10 -0
  190. package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
  191. package/lib/src/utils/processData.js +3 -3
  192. package/lib/src/utils/processData.js.map +1 -1
  193. package/lib/src/utils/processData.spec.js +3 -2
  194. package/lib/src/utils/processData.spec.js.map +1 -1
  195. package/lib/src/utils/sessionInfoService.d.ts +66 -0
  196. package/lib/src/utils/sessionInfoService.d.ts.map +1 -0
  197. package/lib/src/utils/sessionInfoService.js +85 -0
  198. package/lib/src/utils/sessionInfoService.js.map +1 -0
  199. package/lib/src/visual-embed-sdk.d.ts +98 -21
  200. package/package.json +1 -1
  201. package/src/auth.spec.ts +92 -72
  202. package/src/auth.ts +50 -68
  203. package/src/authToken.ts +9 -4
  204. package/src/embed/app.spec.ts +4 -2
  205. package/src/embed/base.spec.ts +1 -0
  206. package/src/embed/base.ts +3 -0
  207. package/src/embed/embed.spec.ts +2 -0
  208. package/src/embed/events.spec.ts +2 -0
  209. package/src/embed/liveboard.spec.ts +2 -0
  210. package/src/embed/pinboard.spec.ts +2 -0
  211. package/src/embed/sage.spec.ts +3 -0
  212. package/src/embed/search.spec.ts +1 -0
  213. package/src/embed/ts-embed-trigger.spec.ts +3 -0
  214. package/src/embed/ts-embed.spec.ts +8 -0
  215. package/src/embed/ts-embed.ts +1 -0
  216. package/src/index.ts +2 -1
  217. package/src/mixpanel-service.spec.ts +12 -3
  218. package/src/mixpanel-service.ts +3 -1
  219. package/src/react/index.spec.tsx +7 -0
  220. package/src/react/index.tsx +1 -0
  221. package/src/types.ts +1 -1
  222. package/src/utils/authService/authService.spec.ts +18 -5
  223. package/src/utils/authService/authService.ts +1 -0
  224. package/src/utils/authService/tokenizedAuthService.spec.ts +36 -0
  225. package/src/utils/authService/tokenizedAuthService.ts +38 -8
  226. package/src/utils/graphql/answerService/answerService.ts +10 -0
  227. package/src/utils/processData.spec.ts +3 -2
  228. package/src/utils/processData.ts +3 -3
  229. package/src/utils/sessionInfoService.ts +101 -0
@@ -1892,7 +1892,7 @@
1892
1892
  *
1893
1893
  * @example
1894
1894
  * ```js
1895
- * liveboardEmbed.trigger(HostEvent.getexportrequestforcurrentpinboard).then(
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
- const getAuthenticationToken = async (embedConfig) => {
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
- // this will throw error if the token is not valid
6102
- await validateAuthToken(embedConfig, authToken);
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 tokenisedFailureLoggedFetch(url, options = {}) {
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('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
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 authVerificationUrl
13129
+ * @param thoughtspotHost
13130
+ * @returns {Promise<any>}
13131
+ * @example
13132
+ * ```js
13133
+ * const response = await sessionInfoService();
13134
+ * ```
13111
13135
  */
13112
- function fetchSessionInfoService(authVerificationUrl) {
13113
- return tokenisedFailureLoggedFetch(authVerificationUrl, {
13114
- credentials: 'include',
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,44 @@ 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 fetchSessionInfoService(authVerificationUrl);
13262
- const sessionInfoResp = await response.json();
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
- return response.status === 200;
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
+ try {
13347
+ const sessionInfo = await getSessionInfo();
13348
+ releaseVersion = sessionInfo.releaseVersion;
13349
+ const embedConfig = getEmbedConfig();
13350
+ if (!embedConfig.disableSDKTracking) {
13351
+ initMixpanel(sessionInfo);
13352
+ }
13353
+ }
13354
+ catch (e) {
13355
+ logger.error('Post login services failed', e.message);
13356
+ }
13272
13357
  }
13273
13358
  /**
13274
13359
  * Return releaseVersion if available
@@ -13305,7 +13390,14 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13305
13390
  }
13306
13391
  loggedInStatus = await isLoggedIn(thoughtSpotHost);
13307
13392
  if (!loggedInStatus) {
13308
- const authToken = await getAuthenticationToken(embedConfig);
13393
+ let authToken;
13394
+ try {
13395
+ authToken = await getAuthenticationToken(embedConfig);
13396
+ }
13397
+ catch (e) {
13398
+ loggedInStatus = false;
13399
+ throw e;
13400
+ }
13309
13401
  let resp;
13310
13402
  try {
13311
13403
  resp = await fetchAuthPostService(thoughtSpotHost, username, authToken);
@@ -13503,6 +13595,8 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13503
13595
  notifyAuthFailure(AuthFailureType.SDK);
13504
13596
  }
13505
13597
  else {
13598
+ // Post login service is called after successful login.
13599
+ postLoginService();
13506
13600
  notifyAuthSDKSuccess();
13507
13601
  }
13508
13602
  }, () => {
@@ -13553,13 +13647,13 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13553
13647
  };
13554
13648
  }
13555
13649
  /**
13650
+ * Responds to AuthInit sent from host signifying successful authentication in host.
13556
13651
  *
13557
13652
  * @param e
13653
+ * @returns {any}
13558
13654
  */
13559
13655
  function processAuthInit(e) {
13560
13656
  var _a, _b;
13561
- // Store user session details sent by app.
13562
- initSession(e.data);
13563
13657
  notifyAuthSuccess();
13564
13658
  // Expose only allowed details (eg: userGUID) back to SDK users.
13565
13659
  return {
@@ -13697,7 +13791,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13697
13791
  });
13698
13792
  }
13699
13793
 
13700
- var name="@thoughtspot/visual-embed-sdk";var version="1.29.0-alpha.8";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};
13794
+ var name="@thoughtspot/visual-embed-sdk";var version="1.29.0-alpha.SCAL-205893-2";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
13795
 
13702
13796
  /**
13703
13797
  * Copyright (c) 2022
@@ -13797,6 +13891,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13797
13891
  });
13798
13892
  }
13799
13893
  catch (e) {
13894
+ logger.error(`Received invalid token. Error : ${e === null || e === void 0 ? void 0 : e.message}`);
13800
13895
  processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
13801
13896
  }
13802
13897
  }
@@ -15784,6 +15879,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
15784
15879
  exports.SageEmbed = SageEmbed$1;
15785
15880
  exports.SearchBarEmbed = SearchBarEmbed$1;
15786
15881
  exports.SearchEmbed = SearchEmbed$1;
15882
+ exports.getSessionInfo = getSessionInfo;
15787
15883
  exports.useEmbedRef = useEmbedRef;
15788
15884
 
15789
15885
  Object.defineProperty(exports, '__esModule', { value: true });