@thoughtspot/visual-embed-sdk 1.11.0-auth.1 → 1.11.0-auth.10

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 +2 -0
  2. package/dist/src/embed/base.d.ts +1 -0
  3. package/dist/src/embed/ts-embed.d.ts +1 -0
  4. package/dist/src/index.d.ts +2 -2
  5. package/dist/src/types.d.ts +5 -0
  6. package/dist/src/utils/authService.d.ts +1 -0
  7. package/dist/tsembed.es.js +59 -16
  8. package/dist/tsembed.js +59 -15
  9. package/lib/package.json +1 -1
  10. package/lib/src/auth.d.ts +2 -0
  11. package/lib/src/auth.js +25 -3
  12. package/lib/src/auth.js.map +1 -1
  13. package/lib/src/auth.spec.js +9 -8
  14. package/lib/src/auth.spec.js.map +1 -1
  15. package/lib/src/embed/base.d.ts +1 -0
  16. package/lib/src/embed/base.js +4 -1
  17. package/lib/src/embed/base.js.map +1 -1
  18. package/lib/src/embed/base.spec.js +1 -1
  19. package/lib/src/embed/base.spec.js.map +1 -1
  20. package/lib/src/embed/ts-embed.d.ts +1 -0
  21. package/lib/src/embed/ts-embed.js +12 -6
  22. package/lib/src/embed/ts-embed.js.map +1 -1
  23. package/lib/src/embed/ts-embed.spec.js +16 -6
  24. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  25. package/lib/src/index.d.ts +2 -2
  26. package/lib/src/index.js +2 -2
  27. package/lib/src/index.js.map +1 -1
  28. package/lib/src/test/test-utils.js +1 -1
  29. package/lib/src/test/test-utils.js.map +1 -1
  30. package/lib/src/types.d.ts +5 -0
  31. package/lib/src/types.js.map +1 -1
  32. package/lib/src/utils/authService.d.ts +1 -0
  33. package/lib/src/utils/authService.js +18 -6
  34. package/lib/src/utils/authService.js.map +1 -1
  35. package/lib/src/utils/authService.spec.js +7 -3
  36. package/lib/src/utils/authService.spec.js.map +1 -1
  37. package/lib/src/visual-embed-sdk.d.ts +8 -2
  38. package/package.json +1 -1
  39. package/src/auth.spec.ts +13 -8
  40. package/src/auth.ts +28 -2
  41. package/src/embed/base.spec.ts +1 -1
  42. package/src/embed/base.ts +5 -1
  43. package/src/embed/ts-embed.spec.ts +19 -9
  44. package/src/embed/ts-embed.ts +13 -6
  45. package/src/index.ts +2 -1
  46. package/src/test/test-utils.ts +1 -1
  47. package/src/types.ts +6 -0
  48. package/src/utils/authService.spec.ts +10 -3
  49. package/src/utils/authService.ts +22 -6
@@ -10,6 +10,7 @@ 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
  };
14
15
  /**
15
16
  * Return sessionInfo if available else make a loggedIn check to fetch the sessionInfo
@@ -32,6 +33,7 @@ export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<boolean>
32
33
  export declare const doBasicAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
33
34
  export declare const doSamlAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
34
35
  export declare const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
36
+ export declare const logout: (embedConfig: EmbedConfig) => Promise<boolean>;
35
37
  /**
36
38
  * Perform authentication on the ThoughtSpot cluster
37
39
  * @param embedConfig The embed configuration
@@ -20,6 +20,7 @@ export declare const prefetch: (url?: string) => void;
20
20
  * @returns authPromise Promise which resolves when authentication is complete.
21
21
  */
22
22
  export declare const init: (embedConfig: EmbedConfig) => Promise<boolean>;
23
+ export declare const logout: () => Promise<boolean>;
23
24
  /**
24
25
  * Renders functions in a queue, resolves to next function only after the callback next is called
25
26
  * @param fn The function being registered
@@ -143,6 +143,7 @@ export declare class TsEmbed {
143
143
  */
144
144
  private shouldEncodeUrlQueryParams;
145
145
  constructor(domSelector: DOMSelector, viewConfig?: ViewConfig);
146
+ private getLoginFiledMessage;
146
147
  /**
147
148
  * Gets a reference to the root DOM node where
148
149
  * the embedded content will appear.
@@ -8,8 +8,8 @@
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
14
  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, };
15
+ export { init, logout, prefetch, SearchEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, LiveboardViewConfig, AppViewConfig, };
@@ -119,6 +119,11 @@ export interface EmbedConfig {
119
119
  * @default false
120
120
  */
121
121
  disableLoginRedirect?: boolean;
122
+ /**
123
+ * This message is displayed on the embed view when the login fails.
124
+ * @version 1.10.1 | ThoughtSpot: *
125
+ */
126
+ loginFailedMessage?: string;
122
127
  /**
123
128
  * Calls the prefetch method internally when set to true
124
129
  * @default false
@@ -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>;
@@ -8687,16 +8687,16 @@ function initMixpanel(sessionInfo) {
8687
8687
  }
8688
8688
 
8689
8689
  // eslint-disable-next-line import/no-cycle
8690
- function errorLoggedFetch(url, options = {}) {
8690
+ function failureLoggedFetch(url, options = {}) {
8691
8691
  return fetch(url, options).then(async (r) => {
8692
- if (!r.ok) {
8693
- console.error('Failure', await r.json());
8692
+ if (!r.ok && r.type !== 'opaqueredirect') {
8693
+ console.error('Failure', await r.text());
8694
8694
  }
8695
8695
  return r;
8696
8696
  });
8697
8697
  }
8698
8698
  function fetchSessionInfoService(authVerificationUrl) {
8699
- return errorLoggedFetch(authVerificationUrl, {
8699
+ return failureLoggedFetch(authVerificationUrl, {
8700
8700
  credentials: 'include',
8701
8701
  });
8702
8702
  }
@@ -8704,10 +8704,14 @@ async function fetchAuthTokenService(authEndpoint) {
8704
8704
  return fetch(authEndpoint);
8705
8705
  }
8706
8706
  async function fetchAuthService(thoughtSpotHost, username, authToken) {
8707
- return errorLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`);
8707
+ return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
8708
+ credentials: 'include',
8709
+ // We do not want to follow the redirect, as it starts giving a CORS error
8710
+ redirect: 'manual',
8711
+ });
8708
8712
  }
8709
8713
  async function fetchBasicAuthService(thoughtSpotHost, username, password) {
8710
- return errorLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
8714
+ return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
8711
8715
  method: 'POST',
8712
8716
  headers: {
8713
8717
  'content-type': 'application/x-www-form-urlencoded',
@@ -8716,6 +8720,14 @@ async function fetchBasicAuthService(thoughtSpotHost, username, password) {
8716
8720
  body: `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`,
8717
8721
  credentials: 'include',
8718
8722
  });
8723
+ }
8724
+ async function fetchLogoutService(thoughtSpotHost) {
8725
+ return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
8726
+ credentials: 'include',
8727
+ headers: {
8728
+ 'x-requested-by': 'ThoughtSpot',
8729
+ },
8730
+ });
8719
8731
  }
8720
8732
 
8721
8733
  // eslint-disable-next-line import/no-mutable-exports
@@ -8733,6 +8745,7 @@ const EndPoints = {
8733
8745
  OIDC_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
8734
8746
  TOKEN_LOGIN: '/callosum/v1/session/login/token',
8735
8747
  BASIC_LOGIN: '/callosum/v1/session/login',
8748
+ LOGOUT: '/callosum/v1/session/logout',
8736
8749
  };
8737
8750
  /**
8738
8751
  * Check if we are logged into the ThoughtSpot cluster
@@ -8753,6 +8766,17 @@ function initSession(sessionDetails) {
8753
8766
  sessionInfo = sessionDetails;
8754
8767
  initMixpanel(sessionInfo);
8755
8768
  }
8769
+ const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every time getAuthToken callback is called.' +
8770
+ 'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
8771
+ let prevAuthToken = null;
8772
+ function alertForDuplicateToken(authtoken) {
8773
+ if (prevAuthToken === authtoken) {
8774
+ // eslint-disable-next-line no-alert
8775
+ alert(DUPLICATE_TOKEN_ERR);
8776
+ throw new Error(DUPLICATE_TOKEN_ERR);
8777
+ }
8778
+ prevAuthToken = authtoken;
8779
+ }
8756
8780
  /**
8757
8781
  * Check if we are stuck at the SSO redirect URL
8758
8782
  */
@@ -8783,13 +8807,15 @@ const doTokenAuth = async (embedConfig) => {
8783
8807
  let authToken = null;
8784
8808
  if (getAuthToken) {
8785
8809
  authToken = await getAuthToken();
8810
+ alertForDuplicateToken(authToken);
8786
8811
  }
8787
8812
  else {
8788
8813
  const response = await fetchAuthTokenService(authEndpoint);
8789
8814
  authToken = await response.text();
8790
8815
  }
8791
8816
  const resp = await fetchAuthService(thoughtSpotHost, username, authToken);
8792
- loggedInStatus = resp.status === 200;
8817
+ // token login issues a 302 when successful
8818
+ loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
8793
8819
  }
8794
8820
  else {
8795
8821
  loggedInStatus = true;
@@ -8809,7 +8835,7 @@ const doBasicAuth = async (embedConfig) => {
8809
8835
  const loggedIn = await isLoggedIn(thoughtSpotHost);
8810
8836
  if (!loggedIn) {
8811
8837
  const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
8812
- loggedInStatus = response.status === 200;
8838
+ loggedInStatus = response.ok;
8813
8839
  }
8814
8840
  else {
8815
8841
  loggedInStatus = true;
@@ -8892,6 +8918,14 @@ const doOIDCAuth = async (embedConfig) => {
8892
8918
  await doSSOAuth(embedConfig, ssoEndPoint);
8893
8919
  return loggedInStatus;
8894
8920
  };
8921
+ const logout = async (embedConfig) => {
8922
+ const { thoughtSpotHost } = embedConfig;
8923
+ const response = await fetchLogoutService(thoughtSpotHost);
8924
+ if (response.ok || response.status === 401) {
8925
+ loggedInStatus = false;
8926
+ }
8927
+ return loggedInStatus;
8928
+ };
8895
8929
  /**
8896
8930
  * Perform authentication on the ThoughtSpot cluster
8897
8931
  * @param embedConfig The embed configuration
@@ -8967,6 +9001,9 @@ const init = (embedConfig) => {
8967
9001
  }
8968
9002
  return authPromise;
8969
9003
  };
9004
+ const logout$1 = () => {
9005
+ return logout(config);
9006
+ };
8970
9007
  let renderQueue = Promise.resolve();
8971
9008
  /**
8972
9009
  * Renders functions in a queue, resolves to next function only after the callback next is called
@@ -9102,7 +9139,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
9102
9139
  }
9103
9140
  }
9104
9141
 
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};
9142
+ var name="@thoughtspot/visual-embed-sdk";var version="1.11.0-auth.10";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};
9106
9143
 
9107
9144
  /**
9108
9145
  * Copyright (c) 2022
@@ -9149,12 +9186,17 @@ class TsEmbed {
9149
9186
  this.isError = false;
9150
9187
  this.viewConfig = viewConfig;
9151
9188
  this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
9152
- if (!this.embedConfig.suppressNoCookieAccessAlert) {
9153
- this.on(EmbedEvent.NoCookieAccess, () => {
9189
+ this.on(EmbedEvent.NoCookieAccess, () => {
9190
+ if (!this.embedConfig.suppressNoCookieAccessAlert) {
9154
9191
  // eslint-disable-next-line no-alert
9155
- alert('Third party cookie access is blocked on this browser, please allow third party cookies for ThoughtSpot to work properly');
9156
- });
9157
- }
9192
+ alert('Third party cookie access is blocked on this browser, please allow third party cookies for this to work properly. \nYou can use `suppressNoCookieAccessAlert` to suppress this message.');
9193
+ }
9194
+ this.el.innerHTML = this.getLoginFiledMessage();
9195
+ });
9196
+ }
9197
+ getLoginFiledMessage() {
9198
+ const { loginFailedMessage } = this.embedConfig;
9199
+ return loginFailedMessage || 'Login failed';
9158
9200
  }
9159
9201
  /**
9160
9202
  * Gets a reference to the root DOM node where
@@ -9352,7 +9394,7 @@ class TsEmbed {
9352
9394
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
9353
9395
  (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
9354
9396
  if (!isLoggedIn) {
9355
- this.el.innerHTML = 'Login failed';
9397
+ this.el.innerHTML = this.getLoginFiledMessage();
9356
9398
  return;
9357
9399
  }
9358
9400
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
@@ -9404,6 +9446,7 @@ class TsEmbed {
9404
9446
  }).catch((error) => {
9405
9447
  nextInQueue();
9406
9448
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED);
9449
+ this.el.innerHTML = this.getLoginFiledMessage();
9407
9450
  this.handleError(error);
9408
9451
  });
9409
9452
  });
@@ -9975,4 +10018,4 @@ class SearchEmbed extends TsEmbed {
9975
10018
  }
9976
10019
  }
9977
10020
 
9978
- export { Action, AppEmbed, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, RuntimeFilterOp, SearchEmbed, init, prefetch };
10021
+ export { Action, AppEmbed, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, RuntimeFilterOp, SearchEmbed, init, logout$1 as logout, prefetch };
package/dist/tsembed.js CHANGED
@@ -8656,16 +8656,16 @@
8656
8656
  }
8657
8657
 
8658
8658
  // eslint-disable-next-line import/no-cycle
8659
- function errorLoggedFetch(url, options = {}) {
8659
+ function failureLoggedFetch(url, options = {}) {
8660
8660
  return fetch(url, options).then(async (r) => {
8661
- if (!r.ok) {
8662
- console.error('Failure', await r.json());
8661
+ if (!r.ok && r.type !== 'opaqueredirect') {
8662
+ console.error('Failure', await r.text());
8663
8663
  }
8664
8664
  return r;
8665
8665
  });
8666
8666
  }
8667
8667
  function fetchSessionInfoService(authVerificationUrl) {
8668
- return errorLoggedFetch(authVerificationUrl, {
8668
+ return failureLoggedFetch(authVerificationUrl, {
8669
8669
  credentials: 'include',
8670
8670
  });
8671
8671
  }
@@ -8673,10 +8673,14 @@
8673
8673
  return fetch(authEndpoint);
8674
8674
  }
8675
8675
  async function fetchAuthService(thoughtSpotHost, username, authToken) {
8676
- return errorLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`);
8676
+ return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
8677
+ credentials: 'include',
8678
+ // We do not want to follow the redirect, as it starts giving a CORS error
8679
+ redirect: 'manual',
8680
+ });
8677
8681
  }
8678
8682
  async function fetchBasicAuthService(thoughtSpotHost, username, password) {
8679
- return errorLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
8683
+ return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
8680
8684
  method: 'POST',
8681
8685
  headers: {
8682
8686
  'content-type': 'application/x-www-form-urlencoded',
@@ -8685,6 +8689,14 @@
8685
8689
  body: `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`,
8686
8690
  credentials: 'include',
8687
8691
  });
8692
+ }
8693
+ async function fetchLogoutService(thoughtSpotHost) {
8694
+ return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
8695
+ credentials: 'include',
8696
+ headers: {
8697
+ 'x-requested-by': 'ThoughtSpot',
8698
+ },
8699
+ });
8688
8700
  }
8689
8701
 
8690
8702
  // eslint-disable-next-line import/no-mutable-exports
@@ -8702,6 +8714,7 @@
8702
8714
  OIDC_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
8703
8715
  TOKEN_LOGIN: '/callosum/v1/session/login/token',
8704
8716
  BASIC_LOGIN: '/callosum/v1/session/login',
8717
+ LOGOUT: '/callosum/v1/session/logout',
8705
8718
  };
8706
8719
  /**
8707
8720
  * Check if we are logged into the ThoughtSpot cluster
@@ -8722,6 +8735,17 @@
8722
8735
  sessionInfo = sessionDetails;
8723
8736
  initMixpanel(sessionInfo);
8724
8737
  }
8738
+ const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every time getAuthToken callback is called.' +
8739
+ 'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
8740
+ let prevAuthToken = null;
8741
+ function alertForDuplicateToken(authtoken) {
8742
+ if (prevAuthToken === authtoken) {
8743
+ // eslint-disable-next-line no-alert
8744
+ alert(DUPLICATE_TOKEN_ERR);
8745
+ throw new Error(DUPLICATE_TOKEN_ERR);
8746
+ }
8747
+ prevAuthToken = authtoken;
8748
+ }
8725
8749
  /**
8726
8750
  * Check if we are stuck at the SSO redirect URL
8727
8751
  */
@@ -8752,13 +8776,15 @@
8752
8776
  let authToken = null;
8753
8777
  if (getAuthToken) {
8754
8778
  authToken = await getAuthToken();
8779
+ alertForDuplicateToken(authToken);
8755
8780
  }
8756
8781
  else {
8757
8782
  const response = await fetchAuthTokenService(authEndpoint);
8758
8783
  authToken = await response.text();
8759
8784
  }
8760
8785
  const resp = await fetchAuthService(thoughtSpotHost, username, authToken);
8761
- loggedInStatus = resp.status === 200;
8786
+ // token login issues a 302 when successful
8787
+ loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
8762
8788
  }
8763
8789
  else {
8764
8790
  loggedInStatus = true;
@@ -8778,7 +8804,7 @@
8778
8804
  const loggedIn = await isLoggedIn(thoughtSpotHost);
8779
8805
  if (!loggedIn) {
8780
8806
  const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
8781
- loggedInStatus = response.status === 200;
8807
+ loggedInStatus = response.ok;
8782
8808
  }
8783
8809
  else {
8784
8810
  loggedInStatus = true;
@@ -8861,6 +8887,14 @@
8861
8887
  await doSSOAuth(embedConfig, ssoEndPoint);
8862
8888
  return loggedInStatus;
8863
8889
  };
8890
+ const logout = async (embedConfig) => {
8891
+ const { thoughtSpotHost } = embedConfig;
8892
+ const response = await fetchLogoutService(thoughtSpotHost);
8893
+ if (response.ok || response.status === 401) {
8894
+ loggedInStatus = false;
8895
+ }
8896
+ return loggedInStatus;
8897
+ };
8864
8898
  /**
8865
8899
  * Perform authentication on the ThoughtSpot cluster
8866
8900
  * @param embedConfig The embed configuration
@@ -8936,6 +8970,9 @@
8936
8970
  }
8937
8971
  return authPromise;
8938
8972
  };
8973
+ const logout$1 = () => {
8974
+ return logout(config);
8975
+ };
8939
8976
  let renderQueue = Promise.resolve();
8940
8977
  /**
8941
8978
  * Renders functions in a queue, resolves to next function only after the callback next is called
@@ -9071,7 +9108,7 @@
9071
9108
  }
9072
9109
  }
9073
9110
 
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};
9111
+ var name="@thoughtspot/visual-embed-sdk";var version="1.11.0-auth.10";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};
9075
9112
 
9076
9113
  /**
9077
9114
  * Copyright (c) 2022
@@ -9118,12 +9155,17 @@
9118
9155
  this.isError = false;
9119
9156
  this.viewConfig = viewConfig;
9120
9157
  this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
9121
- if (!this.embedConfig.suppressNoCookieAccessAlert) {
9122
- this.on(exports.EmbedEvent.NoCookieAccess, () => {
9158
+ this.on(exports.EmbedEvent.NoCookieAccess, () => {
9159
+ if (!this.embedConfig.suppressNoCookieAccessAlert) {
9123
9160
  // eslint-disable-next-line no-alert
9124
- alert('Third party cookie access is blocked on this browser, please allow third party cookies for ThoughtSpot to work properly');
9125
- });
9126
- }
9161
+ alert('Third party cookie access is blocked on this browser, please allow third party cookies for this to work properly. \nYou can use `suppressNoCookieAccessAlert` to suppress this message.');
9162
+ }
9163
+ this.el.innerHTML = this.getLoginFiledMessage();
9164
+ });
9165
+ }
9166
+ getLoginFiledMessage() {
9167
+ const { loginFailedMessage } = this.embedConfig;
9168
+ return loginFailedMessage || 'Login failed';
9127
9169
  }
9128
9170
  /**
9129
9171
  * Gets a reference to the root DOM node where
@@ -9321,7 +9363,7 @@
9321
9363
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
9322
9364
  (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
9323
9365
  if (!isLoggedIn) {
9324
- this.el.innerHTML = 'Login failed';
9366
+ this.el.innerHTML = this.getLoginFiledMessage();
9325
9367
  return;
9326
9368
  }
9327
9369
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
@@ -9373,6 +9415,7 @@
9373
9415
  }).catch((error) => {
9374
9416
  nextInQueue();
9375
9417
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED);
9418
+ this.el.innerHTML = this.getLoginFiledMessage();
9376
9419
  this.handleError(error);
9377
9420
  });
9378
9421
  });
@@ -9944,6 +9987,7 @@
9944
9987
  exports.PinboardEmbed = PinboardEmbed;
9945
9988
  exports.SearchEmbed = SearchEmbed;
9946
9989
  exports.init = init;
9990
+ exports.logout = logout$1;
9947
9991
  exports.prefetch = prefetch;
9948
9992
 
9949
9993
  Object.defineProperty(exports, '__esModule', { value: true });
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.11.0-auth.1",
3
+ "version": "1.11.0-auth.10",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
package/lib/src/auth.d.ts CHANGED
@@ -10,6 +10,7 @@ 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
  };
14
15
  /**
15
16
  * Return sessionInfo if available else make a loggedIn check to fetch the sessionInfo
@@ -32,6 +33,7 @@ export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<boolean>
32
33
  export declare const doBasicAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
33
34
  export declare const doSamlAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
34
35
  export declare const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
36
+ export declare const logout: (embedConfig: EmbedConfig) => Promise<boolean>;
35
37
  /**
36
38
  * Perform authentication on the ThoughtSpot cluster
37
39
  * @param embedConfig The embed configuration
package/lib/src/auth.js CHANGED
@@ -2,7 +2,7 @@ import { initMixpanel } from './mixpanel-service';
2
2
  import { AuthType, EmbedEvent } from './types';
3
3
  import { appendToUrlHash } from './utils';
4
4
  // eslint-disable-next-line import/no-cycle
5
- import { fetchSessionInfoService, fetchAuthTokenService, fetchAuthService, fetchBasicAuthService, } from './utils/authService';
5
+ import { fetchSessionInfoService, fetchAuthTokenService, fetchAuthService, fetchBasicAuthService, fetchLogoutService, } from './utils/authService';
6
6
  // eslint-disable-next-line import/no-mutable-exports
7
7
  export let loggedInStatus = false;
8
8
  // eslint-disable-next-line import/no-mutable-exports
@@ -18,6 +18,7 @@ export const EndPoints = {
18
18
  OIDC_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
19
19
  TOKEN_LOGIN: '/callosum/v1/session/login/token',
20
20
  BASIC_LOGIN: '/callosum/v1/session/login',
21
+ LOGOUT: '/callosum/v1/session/logout',
21
22
  };
22
23
  /**
23
24
  * Check if we are logged into the ThoughtSpot cluster
@@ -44,6 +45,17 @@ export function initSession(sessionDetails) {
44
45
  sessionInfo = sessionDetails;
45
46
  initMixpanel(sessionInfo);
46
47
  }
48
+ const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every time getAuthToken callback is called.' +
49
+ 'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
50
+ let prevAuthToken = null;
51
+ function alertForDuplicateToken(authtoken) {
52
+ if (prevAuthToken === authtoken) {
53
+ // eslint-disable-next-line no-alert
54
+ alert(DUPLICATE_TOKEN_ERR);
55
+ throw new Error(DUPLICATE_TOKEN_ERR);
56
+ }
57
+ prevAuthToken = authtoken;
58
+ }
47
59
  /**
48
60
  * Check if we are stuck at the SSO redirect URL
49
61
  */
@@ -74,13 +86,15 @@ export const doTokenAuth = async (embedConfig) => {
74
86
  let authToken = null;
75
87
  if (getAuthToken) {
76
88
  authToken = await getAuthToken();
89
+ alertForDuplicateToken(authToken);
77
90
  }
78
91
  else {
79
92
  const response = await fetchAuthTokenService(authEndpoint);
80
93
  authToken = await response.text();
81
94
  }
82
95
  const resp = await fetchAuthService(thoughtSpotHost, username, authToken);
83
- loggedInStatus = resp.status === 200;
96
+ // token login issues a 302 when successful
97
+ loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
84
98
  }
85
99
  else {
86
100
  loggedInStatus = true;
@@ -100,7 +114,7 @@ export const doBasicAuth = async (embedConfig) => {
100
114
  const loggedIn = await isLoggedIn(thoughtSpotHost);
101
115
  if (!loggedIn) {
102
116
  const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
103
- loggedInStatus = response.status === 200;
117
+ loggedInStatus = response.ok;
104
118
  }
105
119
  else {
106
120
  loggedInStatus = true;
@@ -183,6 +197,14 @@ export const doOIDCAuth = async (embedConfig) => {
183
197
  await doSSOAuth(embedConfig, ssoEndPoint);
184
198
  return loggedInStatus;
185
199
  };
200
+ export const logout = async (embedConfig) => {
201
+ const { thoughtSpotHost } = embedConfig;
202
+ const response = await fetchLogoutService(thoughtSpotHost);
203
+ if (response.ok || response.status === 401) {
204
+ loggedInStatus = false;
205
+ }
206
+ return loggedInStatus;
207
+ };
186
208
  /**
187
209
  * Perform authentication on the ThoughtSpot cluster
188
210
  * @param embedConfig The embed configuration
@@ -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,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,2CAA2C;AAC3C,OAAO,EACH,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,qDAAqD;AACrD,MAAM,CAAC,IAAI,cAAc,GAAG,KAAK,CAAC;AAClC,qDAAqD;AACrD,MAAM,CAAC,IAAI,cAAc,GAAW,IAAI,CAAC;AACzC,qDAAqD;AACrD,MAAM,CAAC,IAAI,qBAAqB,GAAkB,IAAI,CAAC;AACvD,qDAAqD;AACrD,MAAM,CAAC,IAAI,WAAW,GAAQ,IAAI,CAAC;AAEnC,MAAM,CAAC,MAAM,2BAA2B,GACpC,sCAAsC,CAAC;AAE3C,MAAM,CAAC,MAAM,SAAS,GAAG;IACrB,iBAAiB,EAAE,2BAA2B;IAC9C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