@thoughtspot/visual-embed-sdk 1.10.0-alpha.3 → 1.10.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/CHANGELOG.md +2 -2
- package/README.md +22 -3
- package/dist/src/auth.d.ts +18 -5
- package/dist/src/embed/app.d.ts +4 -2
- package/dist/src/embed/base.d.ts +21 -5
- package/dist/src/embed/search.d.ts +4 -0
- package/dist/src/embed/ts-embed.d.ts +1 -1
- package/dist/src/index.d.ts +3 -2
- package/dist/src/types.d.ts +29 -1
- package/dist/src/utils/authService.d.ts +1 -0
- package/dist/src/utils/processData.d.ts +1 -1
- package/dist/tsembed.es.js +560 -43
- package/dist/tsembed.js +558 -42
- package/lib/package.json +2 -1
- package/lib/src/auth.d.ts +18 -5
- package/lib/src/auth.js +48 -9
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.js +69 -11
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/embed/app.d.ts +4 -2
- package/lib/src/embed/app.js +17 -7
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +36 -2
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +21 -5
- package/lib/src/embed/base.js +64 -10
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +49 -3
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +1 -1
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +30 -1
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/search.d.ts +4 -0
- package/lib/src/embed/search.js +1 -1
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +1 -1
- package/lib/src/embed/ts-embed.js +18 -14
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +16 -6
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +3 -2
- package/lib/src/index.js +3 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/test/test-utils.js +1 -1
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/types.d.ts +29 -1
- package/lib/src/types.js +23 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService.d.ts +1 -0
- package/lib/src/utils/authService.js +21 -3
- package/lib/src/utils/authService.js.map +1 -1
- package/lib/src/utils/authService.spec.js +21 -5
- package/lib/src/utils/authService.spec.js.map +1 -1
- package/lib/src/utils/processData.d.ts +1 -1
- package/lib/src/utils/processData.js +37 -3
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js +106 -4
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +123 -11
- package/package.json +2 -1
- package/src/auth.spec.ts +90 -11
- package/src/auth.ts +63 -13
- package/src/embed/app.spec.ts +49 -1
- package/src/embed/app.ts +18 -6
- package/src/embed/base.spec.ts +56 -4
- package/src/embed/base.ts +83 -16
- package/src/embed/embed.spec.ts +1 -1
- package/src/embed/events.spec.ts +32 -0
- package/src/embed/search.ts +5 -0
- package/src/embed/ts-embed.spec.ts +19 -9
- package/src/embed/ts-embed.ts +24 -15
- package/src/index.ts +5 -1
- package/src/test/test-utils.ts +1 -1
- package/src/types.ts +29 -0
- package/src/utils/authService.spec.ts +31 -5
- package/src/utils/authService.ts +27 -3
- package/src/utils/processData.spec.ts +139 -4
- package/src/utils/processData.ts +54 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processData.spec.js","sourceRoot":"","sources":["../../../src/utils/processData.spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,mBAAmB,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,qBAAqB,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU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H,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC;QACjD,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,UAAU,EAAE,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QACjC,MAAM,EAAE,GAAQ,EAAE,CAAC;QACnB,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CACnE;YACI,IAAI,EAAE,CAAC,CAAC,IAAI;SACf,CACJ,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,UAAU,EAAE,CAAC;QACvC,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// Generated by dts-bundle v0.7.3
|
|
2
|
+
// Dependencies for this module:
|
|
3
|
+
// ../../eventemitter3
|
|
2
4
|
|
|
3
5
|
declare module '@thoughtspot/visual-embed-sdk' {
|
|
4
6
|
/**
|
|
@@ -11,11 +13,12 @@ declare module '@thoughtspot/visual-embed-sdk' {
|
|
|
11
13
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
12
14
|
*/
|
|
13
15
|
import { AppEmbed, Page, AppViewConfig } from '@thoughtspot/visual-embed-sdk/embed/app';
|
|
14
|
-
import { init, prefetch } from '@thoughtspot/visual-embed-sdk/embed/base';
|
|
16
|
+
import { init, prefetch, logout } from '@thoughtspot/visual-embed-sdk/embed/base';
|
|
15
17
|
import { PinboardEmbed, LiveboardViewConfig, LiveboardEmbed } from '@thoughtspot/visual-embed-sdk/embed/liveboard';
|
|
16
18
|
import { SearchEmbed, SearchViewConfig } from '@thoughtspot/visual-embed-sdk/embed/search';
|
|
19
|
+
import { AuthFailureType, AuthStatus } from '@thoughtspot/visual-embed-sdk/auth';
|
|
17
20
|
import { AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig } from '@thoughtspot/visual-embed-sdk/types';
|
|
18
|
-
export { init, prefetch, SearchEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, LiveboardViewConfig, AppViewConfig, };
|
|
21
|
+
export { init, logout, prefetch, SearchEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, AuthFailureType, AuthStatus, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, LiveboardViewConfig, AppViewConfig, };
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
declare module '@thoughtspot/visual-embed-sdk/embed/app' {
|
|
@@ -118,10 +121,12 @@ declare module '@thoughtspot/visual-embed-sdk/embed/app' {
|
|
|
118
121
|
/**
|
|
119
122
|
* Navigate to particular page for app embed. eg:answers/pinboards/home
|
|
120
123
|
* This is used for embedding answers, pinboards, visualizations and full application only.
|
|
121
|
-
* @param path The string, set to iframe src and navigate to new page
|
|
124
|
+
* @param path string | number The string, set to iframe src and navigate to new page
|
|
122
125
|
* eg: appEmbed.navigateToPage('pinboards')
|
|
126
|
+
* When used with `noReload` this can also be a number like 1/-1 to go forward/back.
|
|
127
|
+
* @param noReload boolean Trigger the navigation without reloading the page (version: 1.12.0 | 8.4.0.cl)
|
|
123
128
|
*/
|
|
124
|
-
navigateToPage(path: string): void;
|
|
129
|
+
navigateToPage(path: string | number, noReload?: boolean): void;
|
|
125
130
|
/**
|
|
126
131
|
* Renders the embedded application pages in the ThoughtSpot app.
|
|
127
132
|
* @param renderOptions An object containing the page ID
|
|
@@ -132,14 +137,27 @@ declare module '@thoughtspot/visual-embed-sdk/embed/app' {
|
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
declare module '@thoughtspot/visual-embed-sdk/embed/base' {
|
|
140
|
+
/**
|
|
141
|
+
* Copyright (c) 2022
|
|
142
|
+
*
|
|
143
|
+
* Base classes
|
|
144
|
+
*
|
|
145
|
+
* @summary Base classes
|
|
146
|
+
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
147
|
+
*/
|
|
148
|
+
import EventEmitter from 'eventemitter3';
|
|
135
149
|
import { EmbedConfig } from '@thoughtspot/visual-embed-sdk/types';
|
|
136
|
-
|
|
150
|
+
import { AuthFailureType } from '@thoughtspot/visual-embed-sdk/auth';
|
|
151
|
+
export let authPromise: Promise<boolean>;
|
|
152
|
+
export const getEmbedConfig: () => EmbedConfig;
|
|
153
|
+
export const getAuthPromise: () => Promise<boolean>;
|
|
154
|
+
export function notifyAuthSuccess(): void;
|
|
155
|
+
export function notifyAuthFailure(failureType: AuthFailureType): void;
|
|
156
|
+
export function notifyLogout(): void;
|
|
137
157
|
/**
|
|
138
158
|
* Perform authentication on the ThoughtSpot app as applicable.
|
|
139
159
|
*/
|
|
140
|
-
export const handleAuth: () => Promise<
|
|
141
|
-
export const getEmbedConfig: () => EmbedConfig;
|
|
142
|
-
export const getAuthPromise: () => Promise<void>;
|
|
160
|
+
export const handleAuth: () => Promise<boolean>;
|
|
143
161
|
/**
|
|
144
162
|
* 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.
|
|
145
163
|
* @param url The URL provided for prefetch
|
|
@@ -153,12 +171,15 @@ declare module '@thoughtspot/visual-embed-sdk/embed/base' {
|
|
|
153
171
|
*
|
|
154
172
|
* @returns authPromise Promise which resolves when authentication is complete.
|
|
155
173
|
*/
|
|
156
|
-
export const init: (embedConfig: EmbedConfig) =>
|
|
174
|
+
export const init: (embedConfig: EmbedConfig) => EventEmitter;
|
|
175
|
+
export function disableAutoLogin(): void;
|
|
176
|
+
export const logout: (doNotDisableAutoLogin?: boolean) => Promise<boolean>;
|
|
157
177
|
/**
|
|
158
178
|
* Renders functions in a queue, resolves to next function only after the callback next is called
|
|
159
179
|
* @param fn The function being registered
|
|
160
180
|
*/
|
|
161
181
|
export const renderInQueue: (fn: (next?: (val?: any) => void) => void) => void;
|
|
182
|
+
export function reset(): void;
|
|
162
183
|
}
|
|
163
184
|
|
|
164
185
|
declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
@@ -304,6 +325,10 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
|
304
325
|
* using raw answer data.
|
|
305
326
|
*/
|
|
306
327
|
hideResults?: boolean;
|
|
328
|
+
/**
|
|
329
|
+
* If set to true, expands all the data sources panel.
|
|
330
|
+
*/
|
|
331
|
+
expandAllDataSource?: boolean;
|
|
307
332
|
/**
|
|
308
333
|
* If set to true, the Search Assist feature is enabled.
|
|
309
334
|
*/
|
|
@@ -351,6 +376,65 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
|
351
376
|
export {};
|
|
352
377
|
}
|
|
353
378
|
|
|
379
|
+
declare module '@thoughtspot/visual-embed-sdk/auth' {
|
|
380
|
+
import { EmbedConfig } from '@thoughtspot/visual-embed-sdk/types';
|
|
381
|
+
export let loggedInStatus: boolean;
|
|
382
|
+
export let samlAuthWindow: Window;
|
|
383
|
+
export let samlCompletionPromise: Promise<void>;
|
|
384
|
+
export let sessionInfo: any;
|
|
385
|
+
export const SSO_REDIRECTION_MARKER_GUID = "5e16222e-ef02-43e9-9fbd-24226bf3ce5b";
|
|
386
|
+
export const EndPoints: {
|
|
387
|
+
AUTH_VERIFICATION: string;
|
|
388
|
+
SAML_LOGIN_TEMPLATE: (targetUrl: string) => string;
|
|
389
|
+
OIDC_LOGIN_TEMPLATE: (targetUrl: string) => string;
|
|
390
|
+
TOKEN_LOGIN: string;
|
|
391
|
+
BASIC_LOGIN: string;
|
|
392
|
+
LOGOUT: string;
|
|
393
|
+
};
|
|
394
|
+
export enum AuthFailureType {
|
|
395
|
+
SDK = "SDK",
|
|
396
|
+
NO_COOKIE_ACCESS = "NO_COOKIE_ACCESS",
|
|
397
|
+
EXPIRY = "EXPIRY",
|
|
398
|
+
OTHER = "OTHER"
|
|
399
|
+
}
|
|
400
|
+
export enum AuthStatus {
|
|
401
|
+
FAILURE = "FAILURE",
|
|
402
|
+
SUCCESS = "SUCCESS",
|
|
403
|
+
LOGOUT = "LOGOUT"
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Return sessionInfo if available else make a loggedIn check to fetch the sessionInfo
|
|
407
|
+
*/
|
|
408
|
+
export function getSessionInfo(): any;
|
|
409
|
+
export function initSession(sessionDetails: any): void;
|
|
410
|
+
/**
|
|
411
|
+
* Perform token based authentication
|
|
412
|
+
* @param embedConfig The embed configuration
|
|
413
|
+
*/
|
|
414
|
+
export const doTokenAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
415
|
+
/**
|
|
416
|
+
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
417
|
+
* credentials.
|
|
418
|
+
*
|
|
419
|
+
* Warning: This feature is primarily intended for developer testing. It is
|
|
420
|
+
* strongly advised not to use this authentication method in production.
|
|
421
|
+
* @param embedConfig The embed configuration
|
|
422
|
+
*/
|
|
423
|
+
export const doBasicAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
424
|
+
export const doSamlAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
425
|
+
export const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
426
|
+
export const logout: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
427
|
+
/**
|
|
428
|
+
* Perform authentication on the ThoughtSpot cluster
|
|
429
|
+
* @param embedConfig The embed configuration
|
|
430
|
+
*/
|
|
431
|
+
export const authenticate: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
432
|
+
/**
|
|
433
|
+
* Check if we are authenticated to the ThoughtSpot cluster
|
|
434
|
+
*/
|
|
435
|
+
export const isAuthenticated: () => boolean;
|
|
436
|
+
}
|
|
437
|
+
|
|
354
438
|
declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
355
439
|
/**
|
|
356
440
|
* The authentication mechanism for allowing access to the
|
|
@@ -465,6 +549,11 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
465
549
|
* @default false
|
|
466
550
|
*/
|
|
467
551
|
disableLoginRedirect?: boolean;
|
|
552
|
+
/**
|
|
553
|
+
* This message is displayed on the embed view when the login fails.
|
|
554
|
+
* @version 1.10.1 | ThoughtSpot: *
|
|
555
|
+
*/
|
|
556
|
+
loginFailedMessage?: string;
|
|
468
557
|
/**
|
|
469
558
|
* Calls the prefetch method internally when set to true
|
|
470
559
|
* @default false
|
|
@@ -678,6 +767,16 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
678
767
|
* The ThoughtSpot auth session has expired.
|
|
679
768
|
*/
|
|
680
769
|
AuthExpire = "ThoughtspotAuthExpired",
|
|
770
|
+
/**
|
|
771
|
+
* ThoughtSpot failed to validate the auth session.
|
|
772
|
+
* @hidden
|
|
773
|
+
*/
|
|
774
|
+
AuthFailure = "ThoughtspotAuthFailure",
|
|
775
|
+
/**
|
|
776
|
+
* ThoughtSpot failed to validate the auth session.
|
|
777
|
+
* @hidden
|
|
778
|
+
*/
|
|
779
|
+
AuthLogout = "ThoughtspotAuthLogout",
|
|
681
780
|
/**
|
|
682
781
|
* The height of the embedded Liveboard or visualization has been computed.
|
|
683
782
|
* @return data - The height of the embedded Liveboard or visualization
|
|
@@ -729,6 +828,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
729
828
|
* @version 1.9.1 or later
|
|
730
829
|
*/
|
|
731
830
|
LiveboardRendered = "PinboardRendered",
|
|
831
|
+
/**
|
|
832
|
+
* This can be used to register an event listener which
|
|
833
|
+
* is triggered on all events.
|
|
834
|
+
* @version SDK: 1.10.0 | ThoughtSpot: any
|
|
835
|
+
*/
|
|
836
|
+
ALL = "*",
|
|
732
837
|
/**
|
|
733
838
|
* Emitted when answer is saved in the app
|
|
734
839
|
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
|
|
@@ -871,7 +976,14 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
871
976
|
* @param - {@link RuntimeFilter}[] an array of {@link RuntimeFilter} Types.
|
|
872
977
|
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
873
978
|
*/
|
|
874
|
-
UpdateRuntimeFilters = "UpdateRuntimeFilters"
|
|
979
|
+
UpdateRuntimeFilters = "UpdateRuntimeFilters",
|
|
980
|
+
/**
|
|
981
|
+
* Navigate to a specific page in App embed without any reload.
|
|
982
|
+
* This is the same as calling `appEmbed.navigateToPage(path, true)`
|
|
983
|
+
* @param path - the path to navigate to (can be a number[1/-1] to go forward/back)
|
|
984
|
+
* @version SDK: 1.12.0 | ThoughtSpot: 8.4.0.cl
|
|
985
|
+
*/
|
|
986
|
+
Navigate = "Navigate"
|
|
875
987
|
}
|
|
876
988
|
/**
|
|
877
989
|
* The different visual modes that the data sources panel within
|
|
@@ -1314,7 +1426,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
1314
1426
|
* @param iframeSrc
|
|
1315
1427
|
*/
|
|
1316
1428
|
protected renderV1Embed(iframeSrc: string): void;
|
|
1317
|
-
on(messageType: EmbedEvent, callback: MessageCallback): typeof TsEmbed.prototype;
|
|
1429
|
+
on(messageType: EmbedEvent, callback: MessageCallback, options?: MessageOptions): typeof TsEmbed.prototype;
|
|
1318
1430
|
}
|
|
1319
1431
|
}
|
|
1320
1432
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtspot/visual-embed-sdk",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"algoliasearch": "^4.10.5",
|
|
46
46
|
"classnames": "^2.3.1",
|
|
47
|
+
"eventemitter3": "^4.0.7",
|
|
47
48
|
"mixpanel-browser": "^2.41.0"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
package/src/auth.spec.ts
CHANGED
|
@@ -9,12 +9,12 @@ const password = '12345678';
|
|
|
9
9
|
const samalLoginUrl = `${thoughtSpotHost}/callosum/v1/saml/login?targetURLPath=%235e16222e-ef02-43e9-9fbd-24226bf3ce5b`;
|
|
10
10
|
|
|
11
11
|
const embedConfig: any = {
|
|
12
|
-
doTokenAuthSuccess: {
|
|
12
|
+
doTokenAuthSuccess: (token: string) => ({
|
|
13
13
|
thoughtSpotHost,
|
|
14
14
|
username,
|
|
15
15
|
authEndpoint: 'auth',
|
|
16
|
-
getAuthToken: jest.fn(() => Promise.resolve(
|
|
17
|
-
},
|
|
16
|
+
getAuthToken: jest.fn(() => Promise.resolve(token)),
|
|
17
|
+
}),
|
|
18
18
|
doTokenAuthFailureWithoutAuthEndPoint: {
|
|
19
19
|
thoughtSpotHost,
|
|
20
20
|
username,
|
|
@@ -35,9 +35,15 @@ const embedConfig: any = {
|
|
|
35
35
|
doSamlAuth: {
|
|
36
36
|
thoughtSpotHost,
|
|
37
37
|
},
|
|
38
|
+
doOidcAuth: {
|
|
39
|
+
thoughtSpotHost,
|
|
40
|
+
},
|
|
38
41
|
SSOAuth: {
|
|
39
42
|
authType: AuthType.SSO,
|
|
40
43
|
},
|
|
44
|
+
OIDCAuth: {
|
|
45
|
+
authType: AuthType.OIDC,
|
|
46
|
+
},
|
|
41
47
|
authServerFailure: {
|
|
42
48
|
thoughtSpotHost,
|
|
43
49
|
username,
|
|
@@ -107,12 +113,14 @@ describe('Unit test for auth', () => {
|
|
|
107
113
|
status: 200,
|
|
108
114
|
}),
|
|
109
115
|
);
|
|
110
|
-
await authInstance.doTokenAuth(
|
|
116
|
+
await authInstance.doTokenAuth(
|
|
117
|
+
embedConfig.doTokenAuthSuccess('authToken'),
|
|
118
|
+
);
|
|
111
119
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
112
120
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
113
121
|
});
|
|
114
122
|
|
|
115
|
-
test('doTokenAuth: when user is not loggedIn & getAuthToken have response
|
|
123
|
+
test('doTokenAuth: when user is not loggedIn & getAuthToken have response', async () => {
|
|
116
124
|
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(
|
|
117
125
|
() => false,
|
|
118
126
|
);
|
|
@@ -120,13 +128,19 @@ describe('Unit test for auth', () => {
|
|
|
120
128
|
authService,
|
|
121
129
|
'fetchAuthTokenService',
|
|
122
130
|
).mockImplementation(() => ({ text: () => Promise.resolve('abc') }));
|
|
123
|
-
jest.spyOn(authService, 'fetchAuthService')
|
|
124
|
-
|
|
131
|
+
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() =>
|
|
132
|
+
Promise.resolve({
|
|
133
|
+
status: 200,
|
|
134
|
+
}),
|
|
135
|
+
);
|
|
136
|
+
await authInstance.doTokenAuth(
|
|
137
|
+
embedConfig.doTokenAuthSuccess('authToken2'),
|
|
138
|
+
);
|
|
125
139
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
126
140
|
expect(authService.fetchAuthService).toBeCalledWith(
|
|
127
141
|
thoughtSpotHost,
|
|
128
142
|
username,
|
|
129
|
-
'
|
|
143
|
+
'authToken2',
|
|
130
144
|
);
|
|
131
145
|
});
|
|
132
146
|
|
|
@@ -140,7 +154,12 @@ describe('Unit test for auth', () => {
|
|
|
140
154
|
).mockImplementation(() =>
|
|
141
155
|
Promise.resolve({ text: () => Promise.resolve('abc') }),
|
|
142
156
|
);
|
|
143
|
-
jest.spyOn(authService, 'fetchAuthService')
|
|
157
|
+
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() =>
|
|
158
|
+
Promise.resolve({
|
|
159
|
+
status: 200,
|
|
160
|
+
ok: true,
|
|
161
|
+
}),
|
|
162
|
+
);
|
|
144
163
|
await authInstance.doTokenAuth(
|
|
145
164
|
embedConfig.doTokenAuthFailureWithoutGetAuthToken,
|
|
146
165
|
);
|
|
@@ -155,6 +174,38 @@ describe('Unit test for auth', () => {
|
|
|
155
174
|
});
|
|
156
175
|
});
|
|
157
176
|
|
|
177
|
+
test('doTokenAuth: Should raise error when duplicate token is used', async () => {
|
|
178
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockResolvedValue({
|
|
179
|
+
status: 401,
|
|
180
|
+
});
|
|
181
|
+
jest.spyOn(window, 'alert').mockClear();
|
|
182
|
+
jest.spyOn(window, 'alert').mockReturnValue(undefined);
|
|
183
|
+
jest.spyOn(authService, 'fetchAuthService').mockReset();
|
|
184
|
+
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() =>
|
|
185
|
+
Promise.resolve({
|
|
186
|
+
status: 200,
|
|
187
|
+
ok: true,
|
|
188
|
+
}),
|
|
189
|
+
);
|
|
190
|
+
await authInstance.doTokenAuth(
|
|
191
|
+
embedConfig.doTokenAuthSuccess('authToken3'),
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
try {
|
|
195
|
+
await authInstance.doTokenAuth(
|
|
196
|
+
embedConfig.doTokenAuthSuccess('authToken3'),
|
|
197
|
+
);
|
|
198
|
+
expect(false).toBe(true);
|
|
199
|
+
} catch (e) {
|
|
200
|
+
expect(e.message).toContain('Duplicate token');
|
|
201
|
+
}
|
|
202
|
+
await executeAfterWait(() => {
|
|
203
|
+
expect(authInstance.loggedInStatus).toBe(false);
|
|
204
|
+
expect(window.alert).toBeCalled();
|
|
205
|
+
expect(authService.fetchAuthService).toHaveBeenCalledTimes(1);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
158
209
|
describe('doBasicAuth', () => {
|
|
159
210
|
beforeEach(() => {
|
|
160
211
|
global.fetch = window.fetch;
|
|
@@ -181,7 +232,7 @@ describe('Unit test for auth', () => {
|
|
|
181
232
|
jest.spyOn(
|
|
182
233
|
authService,
|
|
183
234
|
'fetchBasicAuthService',
|
|
184
|
-
).mockImplementation(() => ({ status: 200 }));
|
|
235
|
+
).mockImplementation(() => ({ status: 200, ok: true }));
|
|
185
236
|
|
|
186
237
|
await authInstance.doBasicAuth(embedConfig.doBasicAuth);
|
|
187
238
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
@@ -253,6 +304,7 @@ describe('Unit test for auth', () => {
|
|
|
253
304
|
},
|
|
254
305
|
});
|
|
255
306
|
spyOn(authInstance, 'samlCompletionPromise');
|
|
307
|
+
global.window.open = jest.fn();
|
|
256
308
|
jest.spyOn(
|
|
257
309
|
authService,
|
|
258
310
|
'fetchSessionInfoService',
|
|
@@ -263,8 +315,28 @@ describe('Unit test for auth', () => {
|
|
|
263
315
|
...embedConfig.doSamlAuth,
|
|
264
316
|
noRedirect: true,
|
|
265
317
|
}),
|
|
266
|
-
).toBe(
|
|
318
|
+
).toBe(true);
|
|
319
|
+
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
describe('doOIDCAuth', () => {
|
|
324
|
+
afterEach(() => {
|
|
325
|
+
delete global.window;
|
|
326
|
+
global.window = Object.create(originalWindow);
|
|
327
|
+
global.window.open = jest.fn();
|
|
328
|
+
global.fetch = window.fetch;
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('when user is not loggedIn & isAtSSORedirectUrl is true', async () => {
|
|
332
|
+
jest.spyOn(
|
|
333
|
+
authService,
|
|
334
|
+
'fetchSessionInfoService',
|
|
335
|
+
).mockImplementation(() => Promise.reject());
|
|
336
|
+
await authInstance.doOIDCAuth(embedConfig.doOidcAuth);
|
|
267
337
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
338
|
+
expect(window.location.hash).toBe('');
|
|
339
|
+
expect(authInstance.loggedInStatus).toBe(false);
|
|
268
340
|
});
|
|
269
341
|
});
|
|
270
342
|
|
|
@@ -275,6 +347,13 @@ describe('Unit test for auth', () => {
|
|
|
275
347
|
expect(authInstance.doSamlAuth).toBeCalled();
|
|
276
348
|
});
|
|
277
349
|
|
|
350
|
+
it('authenticate: when authType is OIDC', async () => {
|
|
351
|
+
jest.spyOn(authInstance, 'doOIDCAuth');
|
|
352
|
+
await authInstance.authenticate(embedConfig.OIDCAuth);
|
|
353
|
+
expect(window.location.hash).toBe('');
|
|
354
|
+
expect(authInstance.doOIDCAuth).toBeCalled();
|
|
355
|
+
});
|
|
356
|
+
|
|
278
357
|
it('authenticate: when authType is AuthServer', async () => {
|
|
279
358
|
spyOn(authInstance, 'doTokenAuth');
|
|
280
359
|
await authInstance.authenticate(embedConfig.authServerFailure);
|
package/src/auth.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
fetchAuthTokenService,
|
|
8
8
|
fetchAuthService,
|
|
9
9
|
fetchBasicAuthService,
|
|
10
|
+
fetchLogoutService,
|
|
10
11
|
} from './utils/authService';
|
|
11
12
|
|
|
12
13
|
// eslint-disable-next-line import/no-mutable-exports
|
|
@@ -29,8 +30,22 @@ export const EndPoints = {
|
|
|
29
30
|
`/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
|
|
30
31
|
TOKEN_LOGIN: '/callosum/v1/session/login/token',
|
|
31
32
|
BASIC_LOGIN: '/callosum/v1/session/login',
|
|
33
|
+
LOGOUT: '/callosum/v1/session/logout',
|
|
32
34
|
};
|
|
33
35
|
|
|
36
|
+
export enum AuthFailureType {
|
|
37
|
+
SDK = 'SDK',
|
|
38
|
+
NO_COOKIE_ACCESS = 'NO_COOKIE_ACCESS',
|
|
39
|
+
EXPIRY = 'EXPIRY',
|
|
40
|
+
OTHER = 'OTHER',
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export enum AuthStatus {
|
|
44
|
+
FAILURE = 'FAILURE',
|
|
45
|
+
SUCCESS = 'SUCCESS',
|
|
46
|
+
LOGOUT = 'LOGOUT',
|
|
47
|
+
}
|
|
48
|
+
|
|
34
49
|
/**
|
|
35
50
|
* Check if we are logged into the ThoughtSpot cluster
|
|
36
51
|
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
@@ -58,6 +73,19 @@ export function initSession(sessionDetails: any) {
|
|
|
58
73
|
initMixpanel(sessionInfo);
|
|
59
74
|
}
|
|
60
75
|
|
|
76
|
+
const DUPLICATE_TOKEN_ERR =
|
|
77
|
+
'Duplicate token, please issue a new token every time getAuthToken callback is called.' +
|
|
78
|
+
'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
|
|
79
|
+
let prevAuthToken: string = null;
|
|
80
|
+
function alertForDuplicateToken(authtoken: string) {
|
|
81
|
+
if (prevAuthToken === authtoken) {
|
|
82
|
+
// eslint-disable-next-line no-alert
|
|
83
|
+
alert(DUPLICATE_TOKEN_ERR);
|
|
84
|
+
throw new Error(DUPLICATE_TOKEN_ERR);
|
|
85
|
+
}
|
|
86
|
+
prevAuthToken = authtoken;
|
|
87
|
+
}
|
|
88
|
+
|
|
61
89
|
/**
|
|
62
90
|
* Check if we are stuck at the SSO redirect URL
|
|
63
91
|
*/
|
|
@@ -83,7 +111,9 @@ function removeSSORedirectUrlMarker(): void {
|
|
|
83
111
|
* Perform token based authentication
|
|
84
112
|
* @param embedConfig The embed configuration
|
|
85
113
|
*/
|
|
86
|
-
export const doTokenAuth = async (
|
|
114
|
+
export const doTokenAuth = async (
|
|
115
|
+
embedConfig: EmbedConfig,
|
|
116
|
+
): Promise<boolean> => {
|
|
87
117
|
const {
|
|
88
118
|
thoughtSpotHost,
|
|
89
119
|
username,
|
|
@@ -95,20 +125,25 @@ export const doTokenAuth = async (embedConfig: EmbedConfig): Promise<void> => {
|
|
|
95
125
|
'Either auth endpoint or getAuthToken function must be provided',
|
|
96
126
|
);
|
|
97
127
|
}
|
|
98
|
-
|
|
99
|
-
if (!
|
|
128
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
129
|
+
if (!loggedInStatus) {
|
|
100
130
|
let authToken = null;
|
|
101
131
|
if (getAuthToken) {
|
|
102
132
|
authToken = await getAuthToken();
|
|
133
|
+
alertForDuplicateToken(authToken);
|
|
103
134
|
} else {
|
|
104
135
|
const response = await fetchAuthTokenService(authEndpoint);
|
|
105
136
|
authToken = await response.text();
|
|
106
137
|
}
|
|
107
|
-
await fetchAuthService(
|
|
108
|
-
|
|
138
|
+
const resp = await fetchAuthService(
|
|
139
|
+
thoughtSpotHost,
|
|
140
|
+
username,
|
|
141
|
+
authToken,
|
|
142
|
+
);
|
|
143
|
+
// token login issues a 302 when successful
|
|
144
|
+
loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
|
|
109
145
|
}
|
|
110
|
-
|
|
111
|
-
loggedInStatus = true;
|
|
146
|
+
return loggedInStatus;
|
|
112
147
|
};
|
|
113
148
|
|
|
114
149
|
/**
|
|
@@ -119,7 +154,9 @@ export const doTokenAuth = async (embedConfig: EmbedConfig): Promise<void> => {
|
|
|
119
154
|
* strongly advised not to use this authentication method in production.
|
|
120
155
|
* @param embedConfig The embed configuration
|
|
121
156
|
*/
|
|
122
|
-
export const doBasicAuth = async (
|
|
157
|
+
export const doBasicAuth = async (
|
|
158
|
+
embedConfig: EmbedConfig,
|
|
159
|
+
): Promise<boolean> => {
|
|
123
160
|
const { thoughtSpotHost, username, password } = embedConfig;
|
|
124
161
|
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
125
162
|
if (!loggedIn) {
|
|
@@ -128,10 +165,11 @@ export const doBasicAuth = async (embedConfig: EmbedConfig): Promise<void> => {
|
|
|
128
165
|
username,
|
|
129
166
|
password,
|
|
130
167
|
);
|
|
131
|
-
loggedInStatus = response.
|
|
168
|
+
loggedInStatus = response.ok;
|
|
169
|
+
} else {
|
|
170
|
+
loggedInStatus = true;
|
|
132
171
|
}
|
|
133
|
-
|
|
134
|
-
loggedInStatus = true;
|
|
172
|
+
return loggedInStatus;
|
|
135
173
|
};
|
|
136
174
|
|
|
137
175
|
async function samlPopupFlow(ssoURL: string) {
|
|
@@ -198,6 +236,7 @@ const doSSOAuth = async (
|
|
|
198
236
|
const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
|
|
199
237
|
if (embedConfig.noRedirect) {
|
|
200
238
|
await samlPopupFlow(ssoURL);
|
|
239
|
+
loggedInStatus = true;
|
|
201
240
|
return;
|
|
202
241
|
}
|
|
203
242
|
|
|
@@ -218,6 +257,7 @@ export const doSamlAuth = async (embedConfig: EmbedConfig) => {
|
|
|
218
257
|
)}`;
|
|
219
258
|
|
|
220
259
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
260
|
+
return loggedInStatus;
|
|
221
261
|
};
|
|
222
262
|
|
|
223
263
|
export const doOIDCAuth = async (embedConfig: EmbedConfig) => {
|
|
@@ -234,13 +274,23 @@ export const doOIDCAuth = async (embedConfig: EmbedConfig) => {
|
|
|
234
274
|
)}`;
|
|
235
275
|
|
|
236
276
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
277
|
+
return loggedInStatus;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export const logout = async (embedConfig: EmbedConfig): Promise<boolean> => {
|
|
281
|
+
const { thoughtSpotHost } = embedConfig;
|
|
282
|
+
const response = await fetchLogoutService(thoughtSpotHost);
|
|
283
|
+
loggedInStatus = false;
|
|
284
|
+
return loggedInStatus;
|
|
237
285
|
};
|
|
238
286
|
|
|
239
287
|
/**
|
|
240
288
|
* Perform authentication on the ThoughtSpot cluster
|
|
241
289
|
* @param embedConfig The embed configuration
|
|
242
290
|
*/
|
|
243
|
-
export const authenticate = async (
|
|
291
|
+
export const authenticate = async (
|
|
292
|
+
embedConfig: EmbedConfig,
|
|
293
|
+
): Promise<boolean> => {
|
|
244
294
|
const { authType } = embedConfig;
|
|
245
295
|
switch (authType) {
|
|
246
296
|
case AuthType.SSO:
|
|
@@ -252,7 +302,7 @@ export const authenticate = async (embedConfig: EmbedConfig): Promise<void> => {
|
|
|
252
302
|
case AuthType.Basic:
|
|
253
303
|
return doBasicAuth(embedConfig);
|
|
254
304
|
default:
|
|
255
|
-
return Promise.resolve();
|
|
305
|
+
return Promise.resolve(true);
|
|
256
306
|
}
|
|
257
307
|
};
|
|
258
308
|
|