@thoughtspot/visual-embed-sdk 1.11.0-auth.9 → 1.11.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 (79) hide show
  1. package/CHANGELOG.md +24 -2
  2. package/README.md +15 -2
  3. package/dist/src/auth.d.ts +13 -0
  4. package/dist/src/embed/base.d.ts +34 -4
  5. package/dist/src/embed/search.d.ts +4 -0
  6. package/dist/src/embed/ts-embed.d.ts +0 -1
  7. package/dist/src/index.d.ts +3 -2
  8. package/dist/src/types.d.ts +27 -0
  9. package/dist/src/utils/authService.d.ts +1 -0
  10. package/dist/src/utils/processData.d.ts +1 -1
  11. package/dist/src/utils.d.ts +1 -0
  12. package/dist/tsembed.es.js +1497 -2889
  13. package/dist/tsembed.js +1495 -2888
  14. package/lib/package.json +3 -2
  15. package/lib/src/auth.d.ts +13 -0
  16. package/lib/src/auth.js +35 -9
  17. package/lib/src/auth.js.map +1 -1
  18. package/lib/src/auth.spec.js +76 -1
  19. package/lib/src/auth.spec.js.map +1 -1
  20. package/lib/src/embed/base.d.ts +34 -4
  21. package/lib/src/embed/base.js +79 -11
  22. package/lib/src/embed/base.js.map +1 -1
  23. package/lib/src/embed/base.spec.js +50 -2
  24. package/lib/src/embed/base.spec.js.map +1 -1
  25. package/lib/src/embed/embed.spec.js +1 -1
  26. package/lib/src/embed/embed.spec.js.map +1 -1
  27. package/lib/src/embed/search.d.ts +4 -0
  28. package/lib/src/embed/search.js +1 -1
  29. package/lib/src/embed/search.js.map +1 -1
  30. package/lib/src/embed/ts-embed.d.ts +0 -1
  31. package/lib/src/embed/ts-embed.js +5 -16
  32. package/lib/src/embed/ts-embed.js.map +1 -1
  33. package/lib/src/index.d.ts +3 -2
  34. package/lib/src/index.js +3 -2
  35. package/lib/src/index.js.map +1 -1
  36. package/lib/src/types.d.ts +27 -0
  37. package/lib/src/types.js +10 -0
  38. package/lib/src/types.js.map +1 -1
  39. package/lib/src/utils/authService.d.ts +1 -0
  40. package/lib/src/utils/authService.js +12 -2
  41. package/lib/src/utils/authService.js.map +1 -1
  42. package/lib/src/utils/authService.spec.js +10 -0
  43. package/lib/src/utils/authService.spec.js.map +1 -1
  44. package/lib/src/utils/processData.d.ts +1 -1
  45. package/lib/src/utils/processData.js +37 -3
  46. package/lib/src/utils/processData.js.map +1 -1
  47. package/lib/src/utils/processData.spec.js +106 -4
  48. package/lib/src/utils/processData.spec.js.map +1 -1
  49. package/lib/src/utils.d.ts +1 -0
  50. package/lib/src/utils.js +4 -0
  51. package/lib/src/utils.js.map +1 -1
  52. package/lib/src/utils.spec.js +14 -1
  53. package/lib/src/utils.spec.js.map +1 -1
  54. package/lib/src/visual-embed-sdk.d.ts +129 -6
  55. package/package.json +3 -2
  56. package/src/auth.spec.ts +98 -2
  57. package/src/auth.ts +44 -7
  58. package/src/embed/base.spec.ts +57 -3
  59. package/src/embed/base.ts +96 -15
  60. package/src/embed/embed.spec.ts +1 -1
  61. package/src/embed/search.ts +5 -0
  62. package/src/embed/ts-embed.ts +10 -19
  63. package/src/index.ts +5 -1
  64. package/src/types.ts +28 -0
  65. package/src/utils/authService.spec.ts +13 -0
  66. package/src/utils/authService.ts +14 -2
  67. package/src/utils/processData.spec.ts +139 -4
  68. package/src/utils/processData.ts +54 -4
  69. package/src/utils.spec.ts +26 -0
  70. package/src/utils.ts +5 -0
  71. package/dist/src/embed/pinboard.d.ts +0 -91
  72. package/dist/src/utils/plugin.d.ts +0 -0
  73. package/dist/src/v1/api.d.ts +0 -19
  74. package/lib/src/embed/pinboard.d.ts +0 -91
  75. package/lib/src/embed/pinboard.js +0 -110
  76. package/lib/src/embed/pinboard.js.map +0 -1
  77. package/lib/src/utils/plugin.d.ts +0 -0
  78. package/lib/src/utils/plugin.js +0 -1
  79. package/lib/src/utils/plugin.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,28 @@ This project follows Semantic Versioning.
7
7
 
8
8
  ### New Features
9
9
  - Events for all actions on Search Embed
10
+
11
+ ## 1.10.4 (05-06-2022)
12
+ ### New Features
13
+ - Config option `detectCookieAccessSlow` when doing Basic|AuthServer auth. [Ref doc](https://developers.thoughtspot.com/docs/typedoc/interfaces/EmbedConfig.html#detectCookieAccessSlow)
14
+
15
+ ## 1.10.3 (05-04-2022)
16
+ ### Fixed
17
+ - `logout` method works consistently on multiple TS releases
18
+
19
+ ## 1.10.2 (05-01-2022)
20
+ ### New features
21
+ - Ability to configure `redirectPath` on the origin when using SSO auth. [Ref doc](https://developers.thoughtspot.com/docs/typedoc/interfaces/EmbedConfig.html#redirectPath)
22
+
23
+ ## 1.10.1 (05-01-2022)
24
+
25
+ ### New features
26
+ - `logout` method exposed from the SDK. This can be used to log the user out. [Ref doc](https://developers.thoughtspot.com/docs/typedoc/modules.html#logout)
27
+
28
+ ### Updated
29
+ - When login fails the user is presented with a `Not logged in` message, which is configurable using `loginFailedMessage` property on `init`. [Ref doc](https://developers.thoughtspot.com/docs/typedoc/interfaces/EmbedConfig.html#loginFailedMessage)
30
+ - `init` now returns a event emitter which can be used to listen to Login `failures` and `success`. [Ref doc](https://developers.thoughtspot.com/docs/typedoc/modules.html#init)
31
+
10
32
  ## 1.10.0 (04-22-2022)
11
33
 
12
34
  - Release to support TS version 8.2.0.cl
@@ -26,12 +48,12 @@ This project follows Semantic Versioning.
26
48
 
27
49
  ## 1.9.3 (03-22-2022)
28
50
 
29
- ### New Features
51
+ ### New Features
30
52
  - `disableLoginRedirect` option in `EmbedConfig`
31
53
 
32
54
  ## 1.9.2 (03-17-2022)
33
55
 
34
- ### New Features
56
+ ### New Features
35
57
  - Ability to trigger events on React components
36
58
  - Added new `useEmbedRef` hook, check README for usage.
37
59
 
package/README.md CHANGED
@@ -4,11 +4,22 @@
4
4
 
5
5
  <br/>
6
6
 
7
- # ThoughtSpot Visual Embed SDK <br/> [![Coverage Status](https://coveralls.io/repos/github/ts-blink/embed-sdk/badge.svg?branch=main)](https://coveralls.io/github/ts-blink/embed-sdk?branch=main) ![npm (scoped with tag)](https://img.shields.io/npm/v/@thoughtspot/visual-embed-sdk) [![](https://data.jsdelivr.com/v1/package/npm/@thoughtspot/visual-embed-sdk/badge?style=rounded)](https://www.jsdelivr.com/package/npm/@thoughtspot/visual-embed-sdk) ![npm](https://img.shields.io/npm/dm/@thoughtspot/visual-embed-sdk?label=npm%20downloads&style=flat-square)
7
+ # ThoughtSpot Visual Embed SDK <br/> [![Coverage Status](https://coveralls.io/repos/github/ts-blink/embed-sdk/badge.svg?branch=main)](https://coveralls.io/github/ts-blink/embed-sdk?branch=main) ![npm (scoped with tag)](https://img.shields.io/npm/v/@thoughtspot/visual-embed-sdk) [![](https://data.jsdelivr.com/v1/package/npm/@thoughtspot/visual-embed-sdk/badge?style=rounded)](https://www.jsdelivr.com/package/npm/@thoughtspot/visual-embed-sdk) ![npm](https://img.shields.io/npm/dm/@thoughtspot/visual-embed-sdk?label=npm%20downloads&style=flat-square) [![Featured on Openbase](https://badges.openbase.com/js/featured/@thoughtspot/visual-embed-sdk.svg?token=IoqZUwE8aX7LYNedeuBLM2w5Wt52hu+Dh0eyKjlpC0E=)](https://openbase.com/js/@thoughtspot/visual-embed-sdk?utm_source=embedded&amp;utm_medium=badge&amp;utm_campaign=rate-badge) ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@thoughtspot/visual-embed-sdk?style=flat-square)
8
+
8
9
 
9
10
  SDK to embed ThoughtSpot into your web apps.
10
11
 
11
- <br/>
12
+ * [Usage](#usage)
13
+ * [Live Playground](#live-playground)
14
+ * [Full API Reference](#full-api-reference)
15
+ * [Quick Start](#quick-start)
16
+ * [Embedded Search](#embedded-search)
17
+ * [Embedded Liveboard &amp; Visualization](#embedded-liveboard--visualization)
18
+ * [Embedded Full App](#embedded-full-app)
19
+ * [Triggering and Listening to events](#triggering-and-listening-to-events)
20
+ * [React Components](#react-components)
21
+ * [Search Component](#search-component)
22
+ * [Triggering events on React components](#triggering-events-on-react-components--version-192)
12
23
 
13
24
  ## Usage
14
25
 
@@ -30,6 +41,7 @@ import { LiveboardEmbed } from '@thoughtspot/visual-embed-sdk';
30
41
 
31
42
  // NPM <script>
32
43
  <script src="https://cdn.jsdelivr.net/npm/@thoughtspot/visual-embed-sdk/dist/tsembed.js"></script>;
44
+ // Make the SDK available on global namespace window.tsembed
33
45
 
34
46
  // ES6 from web
35
47
  import {
@@ -52,6 +64,7 @@ Start a [free trial](https://www.thoughtspot.com/trial?tsref=trialtse) on your o
52
64
 
53
65
  - Detailed [developer guide](https://try-everywhere.thoughtspot.cloud/v2/#/everywhere/documentation/en/?pageid=getting-started).
54
66
  - Please visit our [API reference docs](https://developers.thoughtspot.com/docs/typedoc/modules.html).
67
+ - Comprehensive [CodeSandbox](https://codesandbox.io/s/big-tse-react-demo-i4g9xi?file=/src/App.tsx)
55
68
 
56
69
  <br/>
57
70
 
@@ -10,7 +10,19 @@ export declare const EndPoints: {
10
10
  OIDC_LOGIN_TEMPLATE: (targetUrl: string) => string;
11
11
  TOKEN_LOGIN: string;
12
12
  BASIC_LOGIN: string;
13
+ LOGOUT: string;
13
14
  };
15
+ export declare enum AuthFailureType {
16
+ SDK = "SDK",
17
+ NO_COOKIE_ACCESS = "NO_COOKIE_ACCESS",
18
+ EXPIRY = "EXPIRY",
19
+ OTHER = "OTHER"
20
+ }
21
+ export declare enum AuthStatus {
22
+ FAILURE = "FAILURE",
23
+ SUCCESS = "SUCCESS",
24
+ LOGOUT = "LOGOUT"
25
+ }
14
26
  /**
15
27
  * Return sessionInfo if available else make a loggedIn check to fetch the sessionInfo
16
28
  */
@@ -32,6 +44,7 @@ export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<boolean>
32
44
  export declare const doBasicAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
33
45
  export declare const doSamlAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
34
46
  export declare const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
47
+ export declare const logout: (embedConfig: EmbedConfig) => Promise<boolean>;
35
48
  /**
36
49
  * Perform authentication on the ThoughtSpot cluster
37
50
  * @param embedConfig The embed configuration
@@ -1,11 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2022
3
+ *
4
+ * Base classes
5
+ *
6
+ * @summary Base classes
7
+ * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
8
+ */
9
+ import EventEmitter from 'eventemitter3';
1
10
  import { EmbedConfig } from '../types';
11
+ import { AuthFailureType } from '../auth';
2
12
  export declare let authPromise: Promise<boolean>;
13
+ export declare const getEmbedConfig: () => EmbedConfig;
14
+ export declare const getAuthPromise: () => Promise<boolean>;
15
+ export declare function notifyAuthSuccess(): void;
16
+ export declare function notifyAuthFailure(failureType: AuthFailureType): void;
17
+ export declare function notifyLogout(): void;
3
18
  /**
4
19
  * Perform authentication on the ThoughtSpot app as applicable.
5
20
  */
6
21
  export declare const handleAuth: () => Promise<boolean>;
7
- export declare const getEmbedConfig: () => EmbedConfig;
8
- export declare const getAuthPromise: () => Promise<boolean>;
9
22
  /**
10
23
  * Prefetches static resources from the specified URL. Web browsers can then cache the prefetched resources and serve them from the user's local disk to provide faster access to your app.
11
24
  * @param url The URL provided for prefetch
@@ -17,11 +30,28 @@ export declare const prefetch: (url?: string) => void;
17
30
  * @param embedConfig The configuration object containing ThoughtSpot host,
18
31
  * authentication mechanism and so on.
19
32
  *
20
- * @returns authPromise Promise which resolves when authentication is complete.
33
+ * eg: authStatus = init(config);
34
+ * authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
35
+ *
36
+ * @returns event emitter which emits events on authentication success, failure and logout. {@link AuthStatus}
37
+ */
38
+ export declare const init: (embedConfig: EmbedConfig) => EventEmitter;
39
+ export declare function disableAutoLogin(): void;
40
+ /**
41
+ * Logout from ThoughtSpot. This also sets the autoLogin flag to false, to prevent
42
+ * the SDK from automatically logging in again.
43
+ *
44
+ * You can call the `init` method again to re login, if autoLogin is set to true in this
45
+ * second call it will be honored.
46
+ *
47
+ * @param doNotDisableAutoLogin This flag when passed will not disable autoLogin
48
+ * @returns Promise which resolves when logout completes.
49
+ * @version SDK: 1.10.1 | ThoughtSpot: *
21
50
  */
22
- export declare const init: (embedConfig: EmbedConfig) => Promise<boolean>;
51
+ export declare const logout: (doNotDisableAutoLogin?: boolean) => Promise<boolean>;
23
52
  /**
24
53
  * Renders functions in a queue, resolves to next function only after the callback next is called
25
54
  * @param fn The function being registered
26
55
  */
27
56
  export declare const renderInQueue: (fn: (next?: (val?: any) => void) => void) => void;
57
+ export declare function reset(): void;
@@ -44,6 +44,10 @@ export interface SearchViewConfig extends ViewConfig {
44
44
  * using raw answer data.
45
45
  */
46
46
  hideResults?: boolean;
47
+ /**
48
+ * If set to true, expands all the data sources panel.
49
+ */
50
+ expandAllDataSource?: boolean;
47
51
  /**
48
52
  * If set to true, the Search Assist feature is enabled.
49
53
  */
@@ -143,7 +143,6 @@ export declare class TsEmbed {
143
143
  */
144
144
  private shouldEncodeUrlQueryParams;
145
145
  constructor(domSelector: DOMSelector, viewConfig?: ViewConfig);
146
- private getLoginFiledMessage;
147
146
  /**
148
147
  * Gets a reference to the root DOM node where
149
148
  * the embedded content will appear.
@@ -8,8 +8,9 @@
8
8
  * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
9
9
  */
10
10
  import { AppEmbed, Page, AppViewConfig } from './embed/app';
11
- import { init, prefetch } from './embed/base';
11
+ import { init, prefetch, logout } from './embed/base';
12
12
  import { PinboardEmbed, LiveboardViewConfig, LiveboardEmbed } from './embed/liveboard';
13
13
  import { SearchEmbed, SearchViewConfig } from './embed/search';
14
+ import { AuthFailureType, AuthStatus } from './auth';
14
15
  import { AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig } from './types';
15
- export { init, prefetch, SearchEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, LiveboardViewConfig, AppViewConfig, };
16
+ export { init, logout, prefetch, SearchEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, AuthFailureType, AuthStatus, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, LiveboardViewConfig, AppViewConfig, };
@@ -90,6 +90,15 @@ export interface EmbedConfig {
90
90
  * @default false
91
91
  */
92
92
  noRedirect?: boolean;
93
+ /**
94
+ * [SSO] For SSO Authentication, one can supply an optional path param,
95
+ * this will be the path on the host origin where the SAML flow will be
96
+ * terminated.
97
+ *
98
+ * Eg: "/dashboard", "#/foo" [Do not include the host]
99
+ * @version SDK: 1.10.2 | ThoughtSpot: *
100
+ */
101
+ redirectPath?: string;
93
102
  /** @internal */
94
103
  basepath?: string;
95
104
  /**
@@ -144,6 +153,14 @@ export interface EmbedConfig {
144
153
  * @default ''
145
154
  */
146
155
  customCssUrl?: string;
156
+ /**
157
+ * [AuthServer|Basic] Detect if 3rd party cookies are enabled by doing an additional call. This is slower
158
+ * and should be avoided. Listen to the NO_COOKIE_ACCESS event to handle the situation.
159
+ *
160
+ * This is slightly slower than letting the browser handle the cookie check, as it involves an extra network call.
161
+ * @version SDK: 1.10.4 | ThoughtSpot: *
162
+ */
163
+ detectCookieAccessSlow?: boolean;
147
164
  }
148
165
  /**
149
166
  * MessagePayload: Embed event payload: message type, data and status (start/end)
@@ -337,6 +354,16 @@ export declare enum EmbedEvent {
337
354
  * The ThoughtSpot auth session has expired.
338
355
  */
339
356
  AuthExpire = "ThoughtspotAuthExpired",
357
+ /**
358
+ * ThoughtSpot failed to validate the auth session.
359
+ * @hidden
360
+ */
361
+ AuthFailure = "ThoughtspotAuthFailure",
362
+ /**
363
+ * ThoughtSpot failed to validate the auth session.
364
+ * @hidden
365
+ */
366
+ AuthLogout = "ThoughtspotAuthLogout",
340
367
  /**
341
368
  * The height of the embedded Liveboard or visualization has been computed.
342
369
  * @return data - The height of the embedded Liveboard or visualization
@@ -2,3 +2,4 @@ export declare function fetchSessionInfoService(authVerificationUrl: string): Pr
2
2
  export declare function fetchAuthTokenService(authEndpoint: string): Promise<any>;
3
3
  export declare function fetchAuthService(thoughtSpotHost: string, username: string, authToken: string): Promise<any>;
4
4
  export declare function fetchBasicAuthService(thoughtSpotHost: string, username: string, password: string): Promise<any>;
5
+ export declare function fetchLogoutService(thoughtSpotHost: string): Promise<any>;
@@ -1,3 +1,3 @@
1
1
  import { EmbedEvent } from '../types';
2
2
  export declare function processCustomAction(e: any, thoughtSpotHost: string): any;
3
- export declare function getProcessData(type: EmbedEvent, e: any, thoughtSpotHost: string): any;
3
+ export declare function processEventData(type: EmbedEvent, e: any, thoughtSpotHost: string, containerEl: Element): any;
@@ -32,6 +32,7 @@ export declare const getCssDimension: (value: number | string) => string;
32
32
  * @param stringToAppend The string to append to the URL hash
33
33
  */
34
34
  export declare const appendToUrlHash: (url: string, stringToAppend: string) => string;
35
+ export declare function getRedirectUrl(url: string, stringToAppend: string, path?: string): string;
35
36
  export declare const getEncodedQueryParamsString: (queryString: string) => string;
36
37
  export declare const getOffsetTop: (element: any) => any;
37
38
  export declare const embedEventStatus: {