@thoughtspot/visual-embed-sdk 1.19.0-alpha.9 → 1.20.0-alpha.0

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 (49) hide show
  1. package/dist/src/auth.d.ts +9 -2
  2. package/dist/src/auth.d.ts.map +1 -1
  3. package/dist/src/auth.spec.d.ts.map +1 -1
  4. package/dist/src/embed/ts-embed.d.ts +4 -0
  5. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  6. package/dist/src/index.d.ts +2 -2
  7. package/dist/src/index.d.ts.map +1 -1
  8. package/dist/src/types.d.ts +22 -3
  9. package/dist/src/types.d.ts.map +1 -1
  10. package/dist/src/utils/processData.d.ts.map +1 -1
  11. package/dist/tsembed.es.js +87 -25
  12. package/dist/tsembed.js +87 -24
  13. package/lib/package.json +4 -3
  14. package/lib/src/auth.d.ts +9 -2
  15. package/lib/src/auth.d.ts.map +1 -1
  16. package/lib/src/auth.js +36 -12
  17. package/lib/src/auth.js.map +1 -1
  18. package/lib/src/auth.spec.d.ts.map +1 -1
  19. package/lib/src/auth.spec.js +23 -1
  20. package/lib/src/auth.spec.js.map +1 -1
  21. package/lib/src/embed/ts-embed.d.ts +4 -0
  22. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  23. package/lib/src/embed/ts-embed.js +33 -3
  24. package/lib/src/embed/ts-embed.js.map +1 -1
  25. package/lib/src/embed/ts-embed.spec.js +126 -2
  26. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  27. package/lib/src/index.d.ts +2 -2
  28. package/lib/src/index.d.ts.map +1 -1
  29. package/lib/src/index.js +2 -2
  30. package/lib/src/index.js.map +1 -1
  31. package/lib/src/types.d.ts +22 -3
  32. package/lib/src/types.d.ts.map +1 -1
  33. package/lib/src/types.js +14 -1
  34. package/lib/src/types.js.map +1 -1
  35. package/lib/src/utils/processData.d.ts.map +1 -1
  36. package/lib/src/utils/processData.js +1 -11
  37. package/lib/src/utils/processData.js.map +1 -1
  38. package/lib/src/utils/processData.spec.js +0 -24
  39. package/lib/src/utils/processData.spec.js.map +1 -1
  40. package/lib/src/visual-embed-sdk.d.ts +33 -7
  41. package/package.json +4 -3
  42. package/src/auth.spec.ts +31 -2
  43. package/src/auth.ts +44 -12
  44. package/src/embed/ts-embed.spec.ts +151 -2
  45. package/src/embed/ts-embed.ts +39 -2
  46. package/src/index.ts +2 -1
  47. package/src/types.ts +20 -1
  48. package/src/utils/processData.spec.ts +0 -34
  49. package/src/utils/processData.ts +0 -12
@@ -43,7 +43,14 @@ import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
43
43
  import { processEventData } from '../utils/processData';
44
44
  import { processTrigger } from '../utils/processTrigger';
45
45
  import pkgInfo from '../../package.json';
46
- import { getAuthPromise, getEmbedConfig, renderInQueue } from './base';
46
+ import {
47
+ getAuthPromise,
48
+ getEmbedConfig,
49
+ renderInQueue,
50
+ handleAuth,
51
+ notifyAuthFailure,
52
+ } from './base';
53
+ import { AuthFailureType, getAuthenticaionToken } from '../auth';
47
54
 
48
55
  const { version } = pkgInfo;
49
56
 
@@ -218,7 +225,11 @@ export class TsEmbed {
218
225
  /**
219
226
  * Send Custom style as part of payload of APP_INIT
220
227
  */
221
- private appInitCb = (_: any, responder: any) => {
228
+ private appInitCb = async (_: any, responder: any) => {
229
+ let authToken = '';
230
+ if (this.embedConfig.authType === AuthType.TrustedAuthTokenCookieless) {
231
+ authToken = await getAuthenticaionToken(this.embedConfig);
232
+ }
222
233
  responder({
223
234
  type: EmbedEvent.APP_INIT,
224
235
  data: {
@@ -226,15 +237,34 @@ export class TsEmbed {
226
237
  this.embedConfig,
227
238
  this.viewConfig,
228
239
  ),
240
+ authToken,
229
241
  },
230
242
  });
231
243
  };
232
244
 
245
+ /**
246
+ * Sends updated auth token to the iFrame to avoid user logout
247
+ */
248
+ private updateAuthToken = async (_: any, responder: any) => {
249
+ const { autoLogin = false, authType } = this.embedConfig; // Set autoLogin default to false
250
+ if (authType === AuthType.TrustedAuthTokenCookieless) {
251
+ const authToken = await getAuthenticaionToken(this.embedConfig);
252
+ responder({
253
+ type: EmbedEvent.AuthExpire,
254
+ data: { authToken },
255
+ });
256
+ } else if (autoLogin) {
257
+ handleAuth();
258
+ }
259
+ notifyAuthFailure(AuthFailureType.EXPIRY);
260
+ };
261
+
233
262
  /**
234
263
  * Register APP_INIT event and sendback init payload
235
264
  */
236
265
  private registerAppInit = () => {
237
266
  this.on(EmbedEvent.APP_INIT, this.appInitCb);
267
+ this.on(EmbedEvent.AuthExpire, this.updateAuthToken);
238
268
  };
239
269
 
240
270
  /**
@@ -288,6 +318,9 @@ export class TsEmbed {
288
318
  if (this.embedConfig.authType === AuthType.EmbeddedSSO) {
289
319
  queryParams[Param.ForceSAMLAutoRedirect] = true;
290
320
  }
321
+ if (this.embedConfig.authType === AuthType.TrustedAuthTokenCookieless) {
322
+ queryParams[Param.cookieless] = true;
323
+ }
291
324
 
292
325
  const {
293
326
  disabledActions,
@@ -300,6 +333,7 @@ export class TsEmbed {
300
333
  customizations,
301
334
  contextMenuTrigger,
302
335
  linkOverride,
336
+ insertInToSlide,
303
337
  } = this.viewConfig;
304
338
 
305
339
  if (Array.isArray(visibleActions) && Array.isArray(hiddenActions)) {
@@ -363,6 +397,9 @@ export class TsEmbed {
363
397
  if (linkOverride) {
364
398
  queryParams[Param.LinkOverride] = linkOverride;
365
399
  }
400
+ if (insertInToSlide) {
401
+ queryParams[Param.ShowInsertToSlide] = insertInToSlide;
402
+ }
366
403
  return queryParams;
367
404
  }
368
405
 
package/src/index.ts CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  } from './embed/liveboard';
18
18
  import { SearchEmbed, SearchViewConfig } from './embed/search';
19
19
  import { SearchBarEmbed, SearchBarViewConfig } from './embed/search-bar';
20
- import { AuthFailureType, AuthStatus, AuthEvent } from './auth';
20
+ import { AuthFailureType, AuthStatus, AuthEvent, getSessionInfo } from './auth';
21
21
  import {
22
22
  AuthType,
23
23
  RuntimeFilter,
@@ -35,6 +35,7 @@ export {
35
35
  logout,
36
36
  prefetch,
37
37
  getEmbedConfig as getInitConfig,
38
+ getSessionInfo,
38
39
  SearchEmbed,
39
40
  SearchBarEmbed,
40
41
  PinboardEmbed,
package/src/types.ts CHANGED
@@ -58,11 +58,18 @@ export enum AuthType {
58
58
  */
59
59
  AuthServer = 'AuthServer',
60
60
  /**
61
- * Trusted authentication server, Use you own authentication server
61
+ * Trusted authentication server, Use your own authentication server
62
62
  * which returns a bearer token, generated using the secret_key obtained from
63
63
  * ThoughtSpot.
64
64
  */
65
65
  TrustedAuthToken = 'AuthServer',
66
+ /**
67
+ * Trusted authentication server Cookieless, Use you own authentication server
68
+ * which returns a bearer token, generated using the secret_key obtained from
69
+ * ThoughtSpot. This uses a cookieless authentication approach, recommended
70
+ * to by pass third-party cookie-blocking restriction implemented by some browsers
71
+ */
72
+ TrustedAuthTokenCookieless = 'AuthServerCookieless',
66
73
  /**
67
74
  * Use the ThoughtSpot login API to authenticate to the cluster directly.
68
75
  *
@@ -382,6 +389,12 @@ export interface ViewConfig {
382
389
  * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
383
390
  */
384
391
  linkOverride?: boolean;
392
+ /**
393
+ * flag to enable insert into slides action
394
+ * @hidden
395
+ * @private
396
+ */
397
+ insertInToSlide?: boolean;
385
398
  }
386
399
 
387
400
  /**
@@ -1236,8 +1249,10 @@ export enum Param {
1236
1249
  // eslint-disable-next-line @typescript-eslint/no-shadow
1237
1250
  AuthType = 'authType',
1238
1251
  IconSpriteUrl = 'iconSprite',
1252
+ cookieless = 'cookieless',
1239
1253
  ContextMenuTrigger = 'isContextMenuEnabledOnLeftClick',
1240
1254
  LinkOverride = 'linkOverride',
1255
+ ShowInsertToSlide = 'insertInToSlide',
1241
1256
  }
1242
1257
 
1243
1258
  /**
@@ -1443,6 +1458,10 @@ export enum Action {
1443
1458
  * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1444
1459
  */
1445
1460
  AxisMenuRemove = 'axisMenuRemove',
1461
+ /**
1462
+ * @hidden
1463
+ */
1464
+ InsertInToSlide = 'insertInToSlide',
1446
1465
  }
1447
1466
 
1448
1467
  export interface SessionInterface {
@@ -94,40 +94,6 @@ describe('Unit test for process data', () => {
94
94
  expect(base.notifyAuthSuccess).toBeCalled();
95
95
  });
96
96
 
97
- test('AuthExpire autoLogin false', () => {
98
- const e = { type: EmbedEvent.AuthExpire };
99
- jest.spyOn(base, 'notifyAuthFailure');
100
- jest.spyOn(base, 'handleAuth');
101
- jest.spyOn(base, 'getEmbedConfig').mockReturnValue({});
102
- expect(
103
- processDataInstance.processEventData(e.type, e, '', null),
104
- ).toEqual({
105
- type: e.type,
106
- });
107
- expect(base.notifyAuthFailure).toBeCalledWith(
108
- auth.AuthFailureType.EXPIRY,
109
- );
110
- expect(base.handleAuth).not.toHaveBeenCalled();
111
- });
112
-
113
- test('AuthExpire autoLogin true', () => {
114
- const e = { type: EmbedEvent.AuthExpire };
115
- jest.spyOn(base, 'notifyAuthFailure');
116
- jest.spyOn(base, 'handleAuth').mockResolvedValue(true);
117
- jest.spyOn(base, 'getEmbedConfig').mockReturnValue({
118
- autoLogin: true,
119
- });
120
- expect(
121
- processDataInstance.processEventData(e.type, e, '', null),
122
- ).toEqual({
123
- type: e.type,
124
- });
125
- expect(base.notifyAuthFailure).toBeCalledWith(
126
- auth.AuthFailureType.EXPIRY,
127
- );
128
- expect(base.handleAuth).toBeCalled();
129
- });
130
-
131
97
  test('NoCookieAccess no suppress alert', () => {
132
98
  const e = { type: EmbedEvent.NoCookieAccess };
133
99
  jest.spyOn(base, 'notifyAuthFailure');
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  disableAutoLogin,
3
3
  getEmbedConfig,
4
- handleAuth,
5
4
  notifyAuthFailure,
6
5
  notifyAuthSuccess,
7
6
  notifyLogout,
@@ -46,15 +45,6 @@ function processAuthInit(e: any) {
46
45
  };
47
46
  }
48
47
 
49
- function processAuthExpire(e: any) {
50
- const { autoLogin = false } = getEmbedConfig(); // Set default to false
51
- if (autoLogin) {
52
- handleAuth();
53
- }
54
- notifyAuthFailure(AuthFailureType.EXPIRY);
55
- return e;
56
- }
57
-
58
48
  function processNoCookieAccess(e: any, containerEl: Element) {
59
49
  const {
60
50
  loginFailedMessage,
@@ -102,8 +92,6 @@ export function processEventData(
102
92
  return processCustomAction(e, thoughtSpotHost);
103
93
  case EmbedEvent.AuthInit:
104
94
  return processAuthInit(e);
105
- case EmbedEvent.AuthExpire:
106
- return processAuthExpire(e);
107
95
  case EmbedEvent.NoCookieAccess:
108
96
  return processNoCookieAccess(e, containerEl);
109
97
  case EmbedEvent.AuthFailure: