@thoughtspot/visual-embed-sdk 1.10.0 → 1.11.0-auth.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 +6 -2
- package/dist/src/auth.d.ts +5 -5
- package/dist/src/embed/base.d.ts +4 -4
- package/dist/src/embed/pinboard.d.ts +91 -0
- package/dist/src/embed/search.d.ts +0 -4
- package/dist/src/utils/plugin.d.ts +0 -0
- package/dist/src/v1/api.d.ts +19 -0
- package/dist/tsembed.es.js +31 -13
- package/dist/tsembed.js +31 -13
- package/lib/package.json +1 -1
- package/lib/src/auth.d.ts +5 -5
- package/lib/src/auth.js +13 -5
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.js +7 -3
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +4 -4
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/pinboard.d.ts +91 -0
- package/lib/src/embed/pinboard.js +110 -0
- package/lib/src/embed/pinboard.js.map +1 -0
- package/lib/src/embed/search.d.ts +0 -4
- package/lib/src/embed/search.js +1 -1
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.js +5 -1
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/utils/authService.js +11 -5
- package/lib/src/utils/authService.js.map +1 -1
- package/lib/src/utils/authService.spec.js +4 -2
- package/lib/src/utils/authService.spec.js.map +1 -1
- package/lib/src/utils/plugin.d.ts +0 -0
- package/lib/src/utils/plugin.js +1 -0
- package/lib/src/utils/plugin.js.map +1 -0
- package/lib/src/visual-embed-sdk.d.ts +4 -8
- package/package.json +1 -1
- package/src/auth.spec.ts +11 -3
- package/src/auth.ts +24 -10
- package/src/embed/base.ts +4 -4
- package/src/embed/search.ts +0 -5
- package/src/embed/ts-embed.ts +6 -1
- package/src/utils/authService.spec.ts +8 -2
- package/src/utils/authService.ts +15 -6
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ This project follows Semantic Versioning.
|
|
|
7
7
|
|
|
8
8
|
### New Features
|
|
9
9
|
- Events for all actions on Search Embed
|
|
10
|
+
## 1.10.0 (04-22-2022)
|
|
11
|
+
|
|
12
|
+
- Release to support TS version 8.2.0.cl
|
|
13
|
+
- Please check the full list of changes [here](https://developers.thoughtspot.com/docs/?pageid=whats-new)
|
|
10
14
|
|
|
11
15
|
## 1.9.5 (04-06-2022)
|
|
12
16
|
|
|
@@ -22,12 +26,12 @@ This project follows Semantic Versioning.
|
|
|
22
26
|
|
|
23
27
|
## 1.9.3 (03-22-2022)
|
|
24
28
|
|
|
25
|
-
### New Features
|
|
29
|
+
### New Features
|
|
26
30
|
- `disableLoginRedirect` option in `EmbedConfig`
|
|
27
31
|
|
|
28
32
|
## 1.9.2 (03-17-2022)
|
|
29
33
|
|
|
30
|
-
### New Features
|
|
34
|
+
### New Features
|
|
31
35
|
- Ability to trigger events on React components
|
|
32
36
|
- Added new `useEmbedRef` hook, check README for usage.
|
|
33
37
|
|
package/dist/src/auth.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare function initSession(sessionDetails: any): void;
|
|
|
20
20
|
* Perform token based authentication
|
|
21
21
|
* @param embedConfig The embed configuration
|
|
22
22
|
*/
|
|
23
|
-
export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<
|
|
23
|
+
export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
24
24
|
/**
|
|
25
25
|
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
26
26
|
* credentials.
|
|
@@ -29,14 +29,14 @@ export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<void>;
|
|
|
29
29
|
* strongly advised not to use this authentication method in production.
|
|
30
30
|
* @param embedConfig The embed configuration
|
|
31
31
|
*/
|
|
32
|
-
export declare const doBasicAuth: (embedConfig: EmbedConfig) => Promise<
|
|
33
|
-
export declare const doSamlAuth: (embedConfig: EmbedConfig) => Promise<
|
|
34
|
-
export declare const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<
|
|
32
|
+
export declare const doBasicAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
33
|
+
export declare const doSamlAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
34
|
+
export declare const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
35
35
|
/**
|
|
36
36
|
* Perform authentication on the ThoughtSpot cluster
|
|
37
37
|
* @param embedConfig The embed configuration
|
|
38
38
|
*/
|
|
39
|
-
export declare const authenticate: (embedConfig: EmbedConfig) => Promise<
|
|
39
|
+
export declare const authenticate: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
40
40
|
/**
|
|
41
41
|
* Check if we are authenticated to the ThoughtSpot cluster
|
|
42
42
|
*/
|
package/dist/src/embed/base.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { EmbedConfig } from '../types';
|
|
2
|
-
export declare let authPromise: Promise<
|
|
2
|
+
export declare let authPromise: Promise<boolean>;
|
|
3
3
|
/**
|
|
4
4
|
* Perform authentication on the ThoughtSpot app as applicable.
|
|
5
5
|
*/
|
|
6
|
-
export declare const handleAuth: () => Promise<
|
|
6
|
+
export declare const handleAuth: () => Promise<boolean>;
|
|
7
7
|
export declare const getEmbedConfig: () => EmbedConfig;
|
|
8
|
-
export declare const getAuthPromise: () => Promise<
|
|
8
|
+
export declare const getAuthPromise: () => Promise<boolean>;
|
|
9
9
|
/**
|
|
10
10
|
* 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
11
|
* @param url The URL provided for prefetch
|
|
@@ -19,7 +19,7 @@ export declare const prefetch: (url?: string) => void;
|
|
|
19
19
|
*
|
|
20
20
|
* @returns authPromise Promise which resolves when authentication is complete.
|
|
21
21
|
*/
|
|
22
|
-
export declare const init: (embedConfig: EmbedConfig) => Promise<
|
|
22
|
+
export declare const init: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
23
23
|
/**
|
|
24
24
|
* Renders functions in a queue, resolves to next function only after the callback next is called
|
|
25
25
|
* @param fn The function being registered
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021
|
|
3
|
+
*
|
|
4
|
+
* Embed a ThoughtSpot pinboard or visualization
|
|
5
|
+
* https://developers.thoughtspot.com/docs/?pageid=embed-pinboard
|
|
6
|
+
* https://developers.thoughtspot.com/docs/?pageid=embed-a-viz
|
|
7
|
+
*
|
|
8
|
+
* @summary Pinboard & visualization embed
|
|
9
|
+
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
10
|
+
*/
|
|
11
|
+
import { DOMSelector } from '../types';
|
|
12
|
+
import { V1Embed, ViewConfig } from './ts-embed';
|
|
13
|
+
/**
|
|
14
|
+
* The configuration for the embedded pinboard or visualization page view.
|
|
15
|
+
* @Category Pinboards and Charts
|
|
16
|
+
*/
|
|
17
|
+
export interface PinboardViewConfig extends ViewConfig {
|
|
18
|
+
/**
|
|
19
|
+
* If set to true, the embedded object container dynamically resizes
|
|
20
|
+
* according to the height of the pinboard.
|
|
21
|
+
*/
|
|
22
|
+
fullHeight?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* This is the minimum height(in pixels) for a full height pinboard.
|
|
25
|
+
* Setting this height helps resolves issues with empty pinboards and
|
|
26
|
+
* other screens navigable from a pinboard.
|
|
27
|
+
* @default 500
|
|
28
|
+
* * _since 1.5.0_
|
|
29
|
+
*/
|
|
30
|
+
defaultHeight?: number;
|
|
31
|
+
/**
|
|
32
|
+
* If set to true, the context menu in visualizations will be enabled.
|
|
33
|
+
*/
|
|
34
|
+
enableVizTransformations?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The pinboard to display in the embedded view.
|
|
37
|
+
*/
|
|
38
|
+
pinboardId: string;
|
|
39
|
+
/**
|
|
40
|
+
* The visualization within the pinboard to display.
|
|
41
|
+
*/
|
|
42
|
+
vizId?: string;
|
|
43
|
+
/**
|
|
44
|
+
* If set to true, all filter chips from a
|
|
45
|
+
* pinboard page will be read-only (no X buttons)
|
|
46
|
+
*/
|
|
47
|
+
preventPinboardFilterRemoval?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* An array of vizids which should be visible when this pinboard loads.
|
|
50
|
+
* The ids not in this array are hidden from the pinboard.
|
|
51
|
+
* _since: 1.6.0_
|
|
52
|
+
*/
|
|
53
|
+
pinboardVisibleVizs?: string[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Embed a ThoughtSpot pinboard or visualization
|
|
57
|
+
* @Category Pinboards and Charts
|
|
58
|
+
*/
|
|
59
|
+
export declare class PinboardEmbed extends V1Embed {
|
|
60
|
+
protected viewConfig: PinboardViewConfig;
|
|
61
|
+
private defaultHeight;
|
|
62
|
+
constructor(domSelector: DOMSelector, viewConfig: PinboardViewConfig);
|
|
63
|
+
/**
|
|
64
|
+
* Construct a map of params to be passed on to the
|
|
65
|
+
* embedded pinboard or visualization.
|
|
66
|
+
*/
|
|
67
|
+
private getEmbedParams;
|
|
68
|
+
/**
|
|
69
|
+
* Construct the URL of the embedded ThoughtSpot pinboard or visualization
|
|
70
|
+
* to be loaded within the iframe.
|
|
71
|
+
* @param pinboardId The GUID of the pinboard.
|
|
72
|
+
* @param vizId The optional GUID of a visualization within the pinboard.
|
|
73
|
+
* @param runtimeFilters A list of runtime filters to be applied to
|
|
74
|
+
* the pinboard or visualization on load.
|
|
75
|
+
*/
|
|
76
|
+
private getIFrameSrc;
|
|
77
|
+
/**
|
|
78
|
+
* Set the iframe height as per the computed height received
|
|
79
|
+
* from the ThoughtSpot app.
|
|
80
|
+
* @param data The event payload
|
|
81
|
+
*/
|
|
82
|
+
private updateIFrameHeight;
|
|
83
|
+
private embedIframeCenter;
|
|
84
|
+
private handleRouteChangeFullHeightPinboard;
|
|
85
|
+
/**
|
|
86
|
+
* Render an embedded ThoughtSpot pinboard or visualization
|
|
87
|
+
* @param renderOptions An object specifying the pinboard ID,
|
|
88
|
+
* visualization ID and the runtime filters.
|
|
89
|
+
*/
|
|
90
|
+
render(): PinboardEmbed;
|
|
91
|
+
}
|
|
@@ -44,10 +44,6 @@ 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;
|
|
51
47
|
/**
|
|
52
48
|
* If set to true, the Search Assist feature is enabled.
|
|
53
49
|
*/
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: ThoughtSpot Inc. 2012-2016
|
|
3
|
+
* Author: Shashank Singh (sunny@thoughtspot.com)
|
|
4
|
+
*
|
|
5
|
+
* @fileoverview ThoughtSpot Javascript API for use of ThoughtSpot in external webpages.
|
|
6
|
+
*/
|
|
7
|
+
import { AuthType } from '../types';
|
|
8
|
+
export declare enum Events {
|
|
9
|
+
THOUGHTSPOT_AUTH_EXPIRED = "ThoughtspotAuthExpired",
|
|
10
|
+
EXPORT_VIZ_DATA_TO_PARENT = "exportVizDataToParent",
|
|
11
|
+
ALERT = "alert",
|
|
12
|
+
EXPORT_VIZ_DATA_TO_CHILD = "exportVizDataToChild",
|
|
13
|
+
GET_DATA = "getData"
|
|
14
|
+
}
|
|
15
|
+
declare type Callback = (...args: any[]) => void;
|
|
16
|
+
declare function checkIfLoggedIn(tsHost: string, callback: Callback): void;
|
|
17
|
+
declare function initialize(onInitialized: Callback, onAuthExpiration: Callback, _thoughtspotHost: string, authType: AuthType): void;
|
|
18
|
+
declare function notifyOnAuthExpiration(): void;
|
|
19
|
+
export { initialize, checkIfLoggedIn, notifyOnAuthExpiration };
|
package/dist/tsembed.es.js
CHANGED
|
@@ -8687,8 +8687,16 @@ function initMixpanel(sessionInfo) {
|
|
|
8687
8687
|
}
|
|
8688
8688
|
|
|
8689
8689
|
// eslint-disable-next-line import/no-cycle
|
|
8690
|
+
function errorLoggedFetch(url, options = {}) {
|
|
8691
|
+
return fetch(url, options).then(async (r) => {
|
|
8692
|
+
if (!r.ok) {
|
|
8693
|
+
console.error('Failure', await r.json());
|
|
8694
|
+
}
|
|
8695
|
+
return r;
|
|
8696
|
+
});
|
|
8697
|
+
}
|
|
8690
8698
|
function fetchSessionInfoService(authVerificationUrl) {
|
|
8691
|
-
return
|
|
8699
|
+
return errorLoggedFetch(authVerificationUrl, {
|
|
8692
8700
|
credentials: 'include',
|
|
8693
8701
|
});
|
|
8694
8702
|
}
|
|
@@ -8696,12 +8704,10 @@ async function fetchAuthTokenService(authEndpoint) {
|
|
|
8696
8704
|
return fetch(authEndpoint);
|
|
8697
8705
|
}
|
|
8698
8706
|
async function fetchAuthService(thoughtSpotHost, username, authToken) {
|
|
8699
|
-
return
|
|
8700
|
-
credentials: 'include',
|
|
8701
|
-
});
|
|
8707
|
+
return errorLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`);
|
|
8702
8708
|
}
|
|
8703
8709
|
async function fetchBasicAuthService(thoughtSpotHost, username, password) {
|
|
8704
|
-
return
|
|
8710
|
+
return errorLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
|
|
8705
8711
|
method: 'POST',
|
|
8706
8712
|
headers: {
|
|
8707
8713
|
'content-type': 'application/x-www-form-urlencoded',
|
|
@@ -8782,10 +8788,13 @@ const doTokenAuth = async (embedConfig) => {
|
|
|
8782
8788
|
const response = await fetchAuthTokenService(authEndpoint);
|
|
8783
8789
|
authToken = await response.text();
|
|
8784
8790
|
}
|
|
8785
|
-
await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
8786
|
-
loggedInStatus =
|
|
8791
|
+
const resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
8792
|
+
loggedInStatus = resp.status === 200;
|
|
8787
8793
|
}
|
|
8788
|
-
|
|
8794
|
+
else {
|
|
8795
|
+
loggedInStatus = true;
|
|
8796
|
+
}
|
|
8797
|
+
return loggedInStatus;
|
|
8789
8798
|
};
|
|
8790
8799
|
/**
|
|
8791
8800
|
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
@@ -8802,7 +8811,10 @@ const doBasicAuth = async (embedConfig) => {
|
|
|
8802
8811
|
const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
8803
8812
|
loggedInStatus = response.status === 200;
|
|
8804
8813
|
}
|
|
8805
|
-
|
|
8814
|
+
else {
|
|
8815
|
+
loggedInStatus = true;
|
|
8816
|
+
}
|
|
8817
|
+
return loggedInStatus;
|
|
8806
8818
|
};
|
|
8807
8819
|
async function samlPopupFlow(ssoURL) {
|
|
8808
8820
|
document.body.insertAdjacentHTML('beforeend', '<div id="ts-saml-auth"></div>');
|
|
@@ -8866,6 +8878,7 @@ const doSamlAuth = async (embedConfig) => {
|
|
|
8866
8878
|
// bring back the page to the same URL
|
|
8867
8879
|
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
8868
8880
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
8881
|
+
return loggedInStatus;
|
|
8869
8882
|
};
|
|
8870
8883
|
const doOIDCAuth = async (embedConfig) => {
|
|
8871
8884
|
const { thoughtSpotHost } = embedConfig;
|
|
@@ -8877,6 +8890,7 @@ const doOIDCAuth = async (embedConfig) => {
|
|
|
8877
8890
|
// bring back the page to the same URL
|
|
8878
8891
|
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
8879
8892
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
8893
|
+
return loggedInStatus;
|
|
8880
8894
|
};
|
|
8881
8895
|
/**
|
|
8882
8896
|
* Perform authentication on the ThoughtSpot cluster
|
|
@@ -8894,7 +8908,7 @@ const authenticate = async (embedConfig) => {
|
|
|
8894
8908
|
case AuthType.Basic:
|
|
8895
8909
|
return doBasicAuth(embedConfig);
|
|
8896
8910
|
default:
|
|
8897
|
-
return Promise.resolve();
|
|
8911
|
+
return Promise.resolve(true);
|
|
8898
8912
|
}
|
|
8899
8913
|
};
|
|
8900
8914
|
|
|
@@ -9088,7 +9102,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
|
|
|
9088
9102
|
}
|
|
9089
9103
|
}
|
|
9090
9104
|
|
|
9091
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.
|
|
9105
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.11.0-auth.1";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**"];var exports={".":"./lib/src/index.js","./react":"./lib/src/react/index.js"};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false",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":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",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","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs && npx istanbul-merge --out ./coverage/coverage.json ./coverage/docs/coverage-final.json ./coverage/sdk/coverage-final.json && npx istanbul report --include ./coverage/coverage.json --dir ./coverage lcov",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","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","mixpanel-browser":"^2.41.0"};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","@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","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.1.0","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":"4.1.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-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^4.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",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-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.1.0","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","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,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};
|
|
9092
9106
|
|
|
9093
9107
|
/**
|
|
9094
9108
|
* Copyright (c) 2022
|
|
@@ -9336,7 +9350,11 @@ class TsEmbed {
|
|
|
9336
9350
|
type: EmbedEvent.Init,
|
|
9337
9351
|
});
|
|
9338
9352
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
9339
|
-
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then(() => {
|
|
9353
|
+
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
|
|
9354
|
+
if (!isLoggedIn) {
|
|
9355
|
+
this.el.innerHTML = 'Login failed';
|
|
9356
|
+
return;
|
|
9357
|
+
}
|
|
9340
9358
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
|
|
9341
9359
|
this.iFrame =
|
|
9342
9360
|
this.iFrame || document.createElement('iframe');
|
|
@@ -9909,7 +9927,7 @@ class SearchEmbed extends TsEmbed {
|
|
|
9909
9927
|
*/
|
|
9910
9928
|
getIFrameSrc(answerId, dataSources) {
|
|
9911
9929
|
var _a;
|
|
9912
|
-
const { hideResults,
|
|
9930
|
+
const { hideResults, enableSearchAssist, forceTable, searchOptions, } = this.viewConfig;
|
|
9913
9931
|
const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
|
|
9914
9932
|
const queryParams = this.getBaseQueryParams();
|
|
9915
9933
|
queryParams[Param.HideActions] = [
|
package/dist/tsembed.js
CHANGED
|
@@ -8656,8 +8656,16 @@
|
|
|
8656
8656
|
}
|
|
8657
8657
|
|
|
8658
8658
|
// eslint-disable-next-line import/no-cycle
|
|
8659
|
+
function errorLoggedFetch(url, options = {}) {
|
|
8660
|
+
return fetch(url, options).then(async (r) => {
|
|
8661
|
+
if (!r.ok) {
|
|
8662
|
+
console.error('Failure', await r.json());
|
|
8663
|
+
}
|
|
8664
|
+
return r;
|
|
8665
|
+
});
|
|
8666
|
+
}
|
|
8659
8667
|
function fetchSessionInfoService(authVerificationUrl) {
|
|
8660
|
-
return
|
|
8668
|
+
return errorLoggedFetch(authVerificationUrl, {
|
|
8661
8669
|
credentials: 'include',
|
|
8662
8670
|
});
|
|
8663
8671
|
}
|
|
@@ -8665,12 +8673,10 @@
|
|
|
8665
8673
|
return fetch(authEndpoint);
|
|
8666
8674
|
}
|
|
8667
8675
|
async function fetchAuthService(thoughtSpotHost, username, authToken) {
|
|
8668
|
-
return
|
|
8669
|
-
credentials: 'include',
|
|
8670
|
-
});
|
|
8676
|
+
return errorLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`);
|
|
8671
8677
|
}
|
|
8672
8678
|
async function fetchBasicAuthService(thoughtSpotHost, username, password) {
|
|
8673
|
-
return
|
|
8679
|
+
return errorLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
|
|
8674
8680
|
method: 'POST',
|
|
8675
8681
|
headers: {
|
|
8676
8682
|
'content-type': 'application/x-www-form-urlencoded',
|
|
@@ -8751,10 +8757,13 @@
|
|
|
8751
8757
|
const response = await fetchAuthTokenService(authEndpoint);
|
|
8752
8758
|
authToken = await response.text();
|
|
8753
8759
|
}
|
|
8754
|
-
await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
8755
|
-
loggedInStatus =
|
|
8760
|
+
const resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
8761
|
+
loggedInStatus = resp.status === 200;
|
|
8756
8762
|
}
|
|
8757
|
-
|
|
8763
|
+
else {
|
|
8764
|
+
loggedInStatus = true;
|
|
8765
|
+
}
|
|
8766
|
+
return loggedInStatus;
|
|
8758
8767
|
};
|
|
8759
8768
|
/**
|
|
8760
8769
|
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
@@ -8771,7 +8780,10 @@
|
|
|
8771
8780
|
const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
8772
8781
|
loggedInStatus = response.status === 200;
|
|
8773
8782
|
}
|
|
8774
|
-
|
|
8783
|
+
else {
|
|
8784
|
+
loggedInStatus = true;
|
|
8785
|
+
}
|
|
8786
|
+
return loggedInStatus;
|
|
8775
8787
|
};
|
|
8776
8788
|
async function samlPopupFlow(ssoURL) {
|
|
8777
8789
|
document.body.insertAdjacentHTML('beforeend', '<div id="ts-saml-auth"></div>');
|
|
@@ -8835,6 +8847,7 @@
|
|
|
8835
8847
|
// bring back the page to the same URL
|
|
8836
8848
|
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
8837
8849
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
8850
|
+
return loggedInStatus;
|
|
8838
8851
|
};
|
|
8839
8852
|
const doOIDCAuth = async (embedConfig) => {
|
|
8840
8853
|
const { thoughtSpotHost } = embedConfig;
|
|
@@ -8846,6 +8859,7 @@
|
|
|
8846
8859
|
// bring back the page to the same URL
|
|
8847
8860
|
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
8848
8861
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
8862
|
+
return loggedInStatus;
|
|
8849
8863
|
};
|
|
8850
8864
|
/**
|
|
8851
8865
|
* Perform authentication on the ThoughtSpot cluster
|
|
@@ -8863,7 +8877,7 @@
|
|
|
8863
8877
|
case exports.AuthType.Basic:
|
|
8864
8878
|
return doBasicAuth(embedConfig);
|
|
8865
8879
|
default:
|
|
8866
|
-
return Promise.resolve();
|
|
8880
|
+
return Promise.resolve(true);
|
|
8867
8881
|
}
|
|
8868
8882
|
};
|
|
8869
8883
|
|
|
@@ -9057,7 +9071,7 @@
|
|
|
9057
9071
|
}
|
|
9058
9072
|
}
|
|
9059
9073
|
|
|
9060
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.
|
|
9074
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.11.0-auth.1";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**"];var exports$1={".":"./lib/src/index.js","./react":"./lib/src/react/index.js"};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false",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":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",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","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs && npx istanbul-merge --out ./coverage/coverage.json ./coverage/docs/coverage-final.json ./coverage/sdk/coverage-final.json && npx istanbul report --include ./coverage/coverage.json --dir ./coverage lcov",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","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","mixpanel-browser":"^2.41.0"};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","@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","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.1.0","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":"4.1.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-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^4.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",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-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.1.0","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","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,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};
|
|
9061
9075
|
|
|
9062
9076
|
/**
|
|
9063
9077
|
* Copyright (c) 2022
|
|
@@ -9305,7 +9319,11 @@
|
|
|
9305
9319
|
type: exports.EmbedEvent.Init,
|
|
9306
9320
|
});
|
|
9307
9321
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
9308
|
-
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then(() => {
|
|
9322
|
+
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
|
|
9323
|
+
if (!isLoggedIn) {
|
|
9324
|
+
this.el.innerHTML = 'Login failed';
|
|
9325
|
+
return;
|
|
9326
|
+
}
|
|
9309
9327
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
|
|
9310
9328
|
this.iFrame =
|
|
9311
9329
|
this.iFrame || document.createElement('iframe');
|
|
@@ -9873,7 +9891,7 @@
|
|
|
9873
9891
|
*/
|
|
9874
9892
|
getIFrameSrc(answerId, dataSources) {
|
|
9875
9893
|
var _a;
|
|
9876
|
-
const { hideResults,
|
|
9894
|
+
const { hideResults, enableSearchAssist, forceTable, searchOptions, } = this.viewConfig;
|
|
9877
9895
|
const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
|
|
9878
9896
|
const queryParams = this.getBaseQueryParams();
|
|
9879
9897
|
queryParams[Param.HideActions] = [
|
package/lib/package.json
CHANGED
package/lib/src/auth.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare function initSession(sessionDetails: any): void;
|
|
|
20
20
|
* Perform token based authentication
|
|
21
21
|
* @param embedConfig The embed configuration
|
|
22
22
|
*/
|
|
23
|
-
export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<
|
|
23
|
+
export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
24
24
|
/**
|
|
25
25
|
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
26
26
|
* credentials.
|
|
@@ -29,14 +29,14 @@ export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<void>;
|
|
|
29
29
|
* strongly advised not to use this authentication method in production.
|
|
30
30
|
* @param embedConfig The embed configuration
|
|
31
31
|
*/
|
|
32
|
-
export declare const doBasicAuth: (embedConfig: EmbedConfig) => Promise<
|
|
33
|
-
export declare const doSamlAuth: (embedConfig: EmbedConfig) => Promise<
|
|
34
|
-
export declare const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<
|
|
32
|
+
export declare const doBasicAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
33
|
+
export declare const doSamlAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
34
|
+
export declare const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
35
35
|
/**
|
|
36
36
|
* Perform authentication on the ThoughtSpot cluster
|
|
37
37
|
* @param embedConfig The embed configuration
|
|
38
38
|
*/
|
|
39
|
-
export declare const authenticate: (embedConfig: EmbedConfig) => Promise<
|
|
39
|
+
export declare const authenticate: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
40
40
|
/**
|
|
41
41
|
* Check if we are authenticated to the ThoughtSpot cluster
|
|
42
42
|
*/
|
package/lib/src/auth.js
CHANGED
|
@@ -79,10 +79,13 @@ export const doTokenAuth = async (embedConfig) => {
|
|
|
79
79
|
const response = await fetchAuthTokenService(authEndpoint);
|
|
80
80
|
authToken = await response.text();
|
|
81
81
|
}
|
|
82
|
-
await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
83
|
-
loggedInStatus =
|
|
82
|
+
const resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
83
|
+
loggedInStatus = resp.status === 200;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
loggedInStatus = true;
|
|
84
87
|
}
|
|
85
|
-
loggedInStatus
|
|
88
|
+
return loggedInStatus;
|
|
86
89
|
};
|
|
87
90
|
/**
|
|
88
91
|
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
@@ -99,7 +102,10 @@ export const doBasicAuth = async (embedConfig) => {
|
|
|
99
102
|
const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
100
103
|
loggedInStatus = response.status === 200;
|
|
101
104
|
}
|
|
102
|
-
|
|
105
|
+
else {
|
|
106
|
+
loggedInStatus = true;
|
|
107
|
+
}
|
|
108
|
+
return loggedInStatus;
|
|
103
109
|
};
|
|
104
110
|
async function samlPopupFlow(ssoURL) {
|
|
105
111
|
document.body.insertAdjacentHTML('beforeend', '<div id="ts-saml-auth"></div>');
|
|
@@ -163,6 +169,7 @@ export const doSamlAuth = async (embedConfig) => {
|
|
|
163
169
|
// bring back the page to the same URL
|
|
164
170
|
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
165
171
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
172
|
+
return loggedInStatus;
|
|
166
173
|
};
|
|
167
174
|
export const doOIDCAuth = async (embedConfig) => {
|
|
168
175
|
const { thoughtSpotHost } = embedConfig;
|
|
@@ -174,6 +181,7 @@ export const doOIDCAuth = async (embedConfig) => {
|
|
|
174
181
|
// bring back the page to the same URL
|
|
175
182
|
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
176
183
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
184
|
+
return loggedInStatus;
|
|
177
185
|
};
|
|
178
186
|
/**
|
|
179
187
|
* Perform authentication on the ThoughtSpot cluster
|
|
@@ -191,7 +199,7 @@ export const authenticate = async (embedConfig) => {
|
|
|
191
199
|
case AuthType.Basic:
|
|
192
200
|
return doBasicAuth(embedConfig);
|
|
193
201
|
default:
|
|
194
|
-
return Promise.resolve();
|
|
202
|
+
return Promise.resolve(true);
|
|
195
203
|
}
|
|
196
204
|
};
|
|
197
205
|
/**
|
package/lib/src/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAe,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO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D,kBAAkB,CAAC,cAAc,CAAC,CACrC,EAAE,CAAC;IAEJ,MAAM,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAC1C,OAAO,cAAc,CAAC;AAC1B,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC7B,WAAwB,EACR,EAAE;IAClB,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC;IACjC,QAAQ,QAAQ,EAAE;QACd,KAAK,QAAQ,CAAC,GAAG;YACb,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;QACnC,KAAK,QAAQ,CAAC,IAAI;YACd,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;QACnC,KAAK,QAAQ,CAAC,UAAU;YACpB,OAAO,WAAW,CAAC,WAAW,CAAC,CAAC;QACpC,KAAK,QAAQ,CAAC,KAAK;YACf,OAAO,WAAW,CAAC,WAAW,CAAC,CAAC;QACpC;YACI,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KACpC;AACL,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAY,EAAE,CAAC,cAAc,CAAC"}
|
package/lib/src/auth.spec.js
CHANGED
|
@@ -97,7 +97,9 @@ describe('Unit test for auth', () => {
|
|
|
97
97
|
test('doTokenAuth: when user is not loggedIn & getAuthToken have response, isLoggedIn should called', async () => {
|
|
98
98
|
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(() => false);
|
|
99
99
|
jest.spyOn(authService, 'fetchAuthTokenService').mockImplementation(() => ({ text: () => Promise.resolve('abc') }));
|
|
100
|
-
jest.spyOn(authService, 'fetchAuthService')
|
|
100
|
+
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() => Promise.resolve({
|
|
101
|
+
status: 200,
|
|
102
|
+
}));
|
|
101
103
|
await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess);
|
|
102
104
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
103
105
|
expect(authService.fetchAuthService).toBeCalledWith(thoughtSpotHost, username, 'authToken');
|
|
@@ -105,7 +107,9 @@ describe('Unit test for auth', () => {
|
|
|
105
107
|
test('doTokenAuth: when user is not loggedIn & getAuthToken not present, isLoggedIn should called', async () => {
|
|
106
108
|
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(() => false);
|
|
107
109
|
jest.spyOn(authService, 'fetchAuthTokenService').mockImplementation(() => Promise.resolve({ text: () => Promise.resolve('abc') }));
|
|
108
|
-
jest.spyOn(authService, 'fetchAuthService')
|
|
110
|
+
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() => Promise.resolve({
|
|
111
|
+
status: 200,
|
|
112
|
+
}));
|
|
109
113
|
await authInstance.doTokenAuth(embedConfig.doTokenAuthFailureWithoutGetAuthToken);
|
|
110
114
|
await executeAfterWait(() => {
|
|
111
115
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
@@ -190,7 +194,7 @@ describe('Unit test for auth', () => {
|
|
|
190
194
|
expect(await authInstance.doSamlAuth({
|
|
191
195
|
...embedConfig.doSamlAuth,
|
|
192
196
|
noRedirect: true,
|
|
193
|
-
})).toBe(
|
|
197
|
+
})).toBe(false);
|
|
194
198
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
195
199
|
});
|
|
196
200
|
});
|