@thoughtspot/visual-embed-sdk 1.10.0 → 1.10.3

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 (76) hide show
  1. package/dist/src/auth.d.ts +18 -5
  2. package/dist/src/embed/base.d.ts +36 -6
  3. package/dist/src/embed/pinboard.d.ts +91 -0
  4. package/dist/src/index.d.ts +3 -2
  5. package/dist/src/types.d.ts +24 -0
  6. package/dist/src/utils/authService.d.ts +1 -0
  7. package/dist/src/utils/plugin.d.ts +0 -0
  8. package/dist/src/utils/processData.d.ts +1 -1
  9. package/dist/src/utils.d.ts +1 -0
  10. package/dist/src/v1/api.d.ts +19 -0
  11. package/dist/tsembed.es.js +544 -35
  12. package/dist/tsembed.js +542 -34
  13. package/lib/package.json +2 -1
  14. package/lib/src/auth.d.ts +18 -5
  15. package/lib/src/auth.js +51 -12
  16. package/lib/src/auth.js.map +1 -1
  17. package/lib/src/auth.spec.js +69 -11
  18. package/lib/src/auth.spec.js.map +1 -1
  19. package/lib/src/embed/base.d.ts +36 -6
  20. package/lib/src/embed/base.js +79 -11
  21. package/lib/src/embed/base.js.map +1 -1
  22. package/lib/src/embed/base.spec.js +51 -3
  23. package/lib/src/embed/base.spec.js.map +1 -1
  24. package/lib/src/embed/embed.spec.js +1 -1
  25. package/lib/src/embed/embed.spec.js.map +1 -1
  26. package/lib/src/embed/pinboard.d.ts +91 -0
  27. package/lib/src/embed/pinboard.js +110 -0
  28. package/lib/src/embed/pinboard.js.map +1 -0
  29. package/lib/src/embed/ts-embed.js +9 -10
  30. package/lib/src/embed/ts-embed.js.map +1 -1
  31. package/lib/src/embed/ts-embed.spec.js +16 -6
  32. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  33. package/lib/src/index.d.ts +3 -2
  34. package/lib/src/index.js +3 -2
  35. package/lib/src/index.js.map +1 -1
  36. package/lib/src/test/test-utils.js +1 -1
  37. package/lib/src/test/test-utils.js.map +1 -1
  38. package/lib/src/types.d.ts +24 -0
  39. package/lib/src/types.js +10 -0
  40. package/lib/src/types.js.map +1 -1
  41. package/lib/src/utils/authService.d.ts +1 -0
  42. package/lib/src/utils/authService.js +23 -3
  43. package/lib/src/utils/authService.js.map +1 -1
  44. package/lib/src/utils/authService.spec.js +21 -5
  45. package/lib/src/utils/authService.spec.js.map +1 -1
  46. package/lib/src/utils/plugin.d.ts +0 -0
  47. package/lib/src/utils/plugin.js +1 -0
  48. package/lib/src/utils/plugin.js.map +1 -0
  49. package/lib/src/utils/processData.d.ts +1 -1
  50. package/lib/src/utils/processData.js +37 -3
  51. package/lib/src/utils/processData.js.map +1 -1
  52. package/lib/src/utils/processData.spec.js +106 -4
  53. package/lib/src/utils/processData.spec.js.map +1 -1
  54. package/lib/src/utils.d.ts +1 -0
  55. package/lib/src/utils.js +4 -0
  56. package/lib/src/utils.js.map +1 -1
  57. package/lib/src/utils.spec.js +14 -1
  58. package/lib/src/utils.spec.js.map +1 -1
  59. package/lib/src/visual-embed-sdk.d.ts +124 -8
  60. package/package.json +2 -1
  61. package/src/auth.spec.ts +90 -11
  62. package/src/auth.ts +74 -16
  63. package/src/embed/base.spec.ts +58 -4
  64. package/src/embed/base.ts +98 -17
  65. package/src/embed/embed.spec.ts +1 -1
  66. package/src/embed/ts-embed.spec.ts +19 -9
  67. package/src/embed/ts-embed.ts +15 -12
  68. package/src/index.ts +5 -1
  69. package/src/test/test-utils.ts +1 -1
  70. package/src/types.ts +26 -0
  71. package/src/utils/authService.spec.ts +31 -5
  72. package/src/utils/authService.ts +29 -3
  73. package/src/utils/processData.spec.ts +139 -4
  74. package/src/utils/processData.ts +54 -4
  75. package/src/utils.spec.ts +26 -0
  76. package/src/utils.ts +5 -0
@@ -96,6 +96,10 @@ const appendToUrlHash = (url, stringToAppend) => {
96
96
  }
97
97
  return outputUrl;
98
98
  };
99
+ function getRedirectUrl(url, stringToAppend, path = '') {
100
+ const targetUrl = path ? new URL(path, window.location.origin).href : url;
101
+ return appendToUrlHash(targetUrl, stringToAppend);
102
+ }
99
103
  const getEncodedQueryParamsString = (queryString) => {
100
104
  if (!queryString) {
101
105
  return queryString;
@@ -306,6 +310,16 @@ var EmbedEvent;
306
310
  * The ThoughtSpot auth session has expired.
307
311
  */
308
312
  EmbedEvent["AuthExpire"] = "ThoughtspotAuthExpired";
313
+ /**
314
+ * ThoughtSpot failed to validate the auth session.
315
+ * @hidden
316
+ */
317
+ EmbedEvent["AuthFailure"] = "ThoughtspotAuthFailure";
318
+ /**
319
+ * ThoughtSpot failed to validate the auth session.
320
+ * @hidden
321
+ */
322
+ EmbedEvent["AuthLogout"] = "ThoughtspotAuthLogout";
309
323
  /**
310
324
  * The height of the embedded Liveboard or visualization has been computed.
311
325
  * @return data - The height of the embedded Liveboard or visualization
@@ -8686,9 +8700,361 @@ function initMixpanel(sessionInfo) {
8686
8700
  }
8687
8701
  }
8688
8702
 
8703
+ function createCommonjsModule(fn) {
8704
+ var module = { exports: {} };
8705
+ return fn(module, module.exports), module.exports;
8706
+ }
8707
+
8708
+ var eventemitter3 = createCommonjsModule(function (module) {
8709
+
8710
+ var has = Object.prototype.hasOwnProperty
8711
+ , prefix = '~';
8712
+
8713
+ /**
8714
+ * Constructor to create a storage for our `EE` objects.
8715
+ * An `Events` instance is a plain object whose properties are event names.
8716
+ *
8717
+ * @constructor
8718
+ * @private
8719
+ */
8720
+ function Events() {}
8721
+
8722
+ //
8723
+ // We try to not inherit from `Object.prototype`. In some engines creating an
8724
+ // instance in this way is faster than calling `Object.create(null)` directly.
8725
+ // If `Object.create(null)` is not supported we prefix the event names with a
8726
+ // character to make sure that the built-in object properties are not
8727
+ // overridden or used as an attack vector.
8728
+ //
8729
+ if (Object.create) {
8730
+ Events.prototype = Object.create(null);
8731
+
8732
+ //
8733
+ // This hack is needed because the `__proto__` property is still inherited in
8734
+ // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
8735
+ //
8736
+ if (!new Events().__proto__) prefix = false;
8737
+ }
8738
+
8739
+ /**
8740
+ * Representation of a single event listener.
8741
+ *
8742
+ * @param {Function} fn The listener function.
8743
+ * @param {*} context The context to invoke the listener with.
8744
+ * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
8745
+ * @constructor
8746
+ * @private
8747
+ */
8748
+ function EE(fn, context, once) {
8749
+ this.fn = fn;
8750
+ this.context = context;
8751
+ this.once = once || false;
8752
+ }
8753
+
8754
+ /**
8755
+ * Add a listener for a given event.
8756
+ *
8757
+ * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
8758
+ * @param {(String|Symbol)} event The event name.
8759
+ * @param {Function} fn The listener function.
8760
+ * @param {*} context The context to invoke the listener with.
8761
+ * @param {Boolean} once Specify if the listener is a one-time listener.
8762
+ * @returns {EventEmitter}
8763
+ * @private
8764
+ */
8765
+ function addListener(emitter, event, fn, context, once) {
8766
+ if (typeof fn !== 'function') {
8767
+ throw new TypeError('The listener must be a function');
8768
+ }
8769
+
8770
+ var listener = new EE(fn, context || emitter, once)
8771
+ , evt = prefix ? prefix + event : event;
8772
+
8773
+ if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
8774
+ else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
8775
+ else emitter._events[evt] = [emitter._events[evt], listener];
8776
+
8777
+ return emitter;
8778
+ }
8779
+
8780
+ /**
8781
+ * Clear event by name.
8782
+ *
8783
+ * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
8784
+ * @param {(String|Symbol)} evt The Event name.
8785
+ * @private
8786
+ */
8787
+ function clearEvent(emitter, evt) {
8788
+ if (--emitter._eventsCount === 0) emitter._events = new Events();
8789
+ else delete emitter._events[evt];
8790
+ }
8791
+
8792
+ /**
8793
+ * Minimal `EventEmitter` interface that is molded against the Node.js
8794
+ * `EventEmitter` interface.
8795
+ *
8796
+ * @constructor
8797
+ * @public
8798
+ */
8799
+ function EventEmitter() {
8800
+ this._events = new Events();
8801
+ this._eventsCount = 0;
8802
+ }
8803
+
8804
+ /**
8805
+ * Return an array listing the events for which the emitter has registered
8806
+ * listeners.
8807
+ *
8808
+ * @returns {Array}
8809
+ * @public
8810
+ */
8811
+ EventEmitter.prototype.eventNames = function eventNames() {
8812
+ var names = []
8813
+ , events
8814
+ , name;
8815
+
8816
+ if (this._eventsCount === 0) return names;
8817
+
8818
+ for (name in (events = this._events)) {
8819
+ if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
8820
+ }
8821
+
8822
+ if (Object.getOwnPropertySymbols) {
8823
+ return names.concat(Object.getOwnPropertySymbols(events));
8824
+ }
8825
+
8826
+ return names;
8827
+ };
8828
+
8829
+ /**
8830
+ * Return the listeners registered for a given event.
8831
+ *
8832
+ * @param {(String|Symbol)} event The event name.
8833
+ * @returns {Array} The registered listeners.
8834
+ * @public
8835
+ */
8836
+ EventEmitter.prototype.listeners = function listeners(event) {
8837
+ var evt = prefix ? prefix + event : event
8838
+ , handlers = this._events[evt];
8839
+
8840
+ if (!handlers) return [];
8841
+ if (handlers.fn) return [handlers.fn];
8842
+
8843
+ for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
8844
+ ee[i] = handlers[i].fn;
8845
+ }
8846
+
8847
+ return ee;
8848
+ };
8849
+
8850
+ /**
8851
+ * Return the number of listeners listening to a given event.
8852
+ *
8853
+ * @param {(String|Symbol)} event The event name.
8854
+ * @returns {Number} The number of listeners.
8855
+ * @public
8856
+ */
8857
+ EventEmitter.prototype.listenerCount = function listenerCount(event) {
8858
+ var evt = prefix ? prefix + event : event
8859
+ , listeners = this._events[evt];
8860
+
8861
+ if (!listeners) return 0;
8862
+ if (listeners.fn) return 1;
8863
+ return listeners.length;
8864
+ };
8865
+
8866
+ /**
8867
+ * Calls each of the listeners registered for a given event.
8868
+ *
8869
+ * @param {(String|Symbol)} event The event name.
8870
+ * @returns {Boolean} `true` if the event had listeners, else `false`.
8871
+ * @public
8872
+ */
8873
+ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
8874
+ var evt = prefix ? prefix + event : event;
8875
+
8876
+ if (!this._events[evt]) return false;
8877
+
8878
+ var listeners = this._events[evt]
8879
+ , len = arguments.length
8880
+ , args
8881
+ , i;
8882
+
8883
+ if (listeners.fn) {
8884
+ if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
8885
+
8886
+ switch (len) {
8887
+ case 1: return listeners.fn.call(listeners.context), true;
8888
+ case 2: return listeners.fn.call(listeners.context, a1), true;
8889
+ case 3: return listeners.fn.call(listeners.context, a1, a2), true;
8890
+ case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
8891
+ case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
8892
+ case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
8893
+ }
8894
+
8895
+ for (i = 1, args = new Array(len -1); i < len; i++) {
8896
+ args[i - 1] = arguments[i];
8897
+ }
8898
+
8899
+ listeners.fn.apply(listeners.context, args);
8900
+ } else {
8901
+ var length = listeners.length
8902
+ , j;
8903
+
8904
+ for (i = 0; i < length; i++) {
8905
+ if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
8906
+
8907
+ switch (len) {
8908
+ case 1: listeners[i].fn.call(listeners[i].context); break;
8909
+ case 2: listeners[i].fn.call(listeners[i].context, a1); break;
8910
+ case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
8911
+ case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
8912
+ default:
8913
+ if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
8914
+ args[j - 1] = arguments[j];
8915
+ }
8916
+
8917
+ listeners[i].fn.apply(listeners[i].context, args);
8918
+ }
8919
+ }
8920
+ }
8921
+
8922
+ return true;
8923
+ };
8924
+
8925
+ /**
8926
+ * Add a listener for a given event.
8927
+ *
8928
+ * @param {(String|Symbol)} event The event name.
8929
+ * @param {Function} fn The listener function.
8930
+ * @param {*} [context=this] The context to invoke the listener with.
8931
+ * @returns {EventEmitter} `this`.
8932
+ * @public
8933
+ */
8934
+ EventEmitter.prototype.on = function on(event, fn, context) {
8935
+ return addListener(this, event, fn, context, false);
8936
+ };
8937
+
8938
+ /**
8939
+ * Add a one-time listener for a given event.
8940
+ *
8941
+ * @param {(String|Symbol)} event The event name.
8942
+ * @param {Function} fn The listener function.
8943
+ * @param {*} [context=this] The context to invoke the listener with.
8944
+ * @returns {EventEmitter} `this`.
8945
+ * @public
8946
+ */
8947
+ EventEmitter.prototype.once = function once(event, fn, context) {
8948
+ return addListener(this, event, fn, context, true);
8949
+ };
8950
+
8951
+ /**
8952
+ * Remove the listeners of a given event.
8953
+ *
8954
+ * @param {(String|Symbol)} event The event name.
8955
+ * @param {Function} fn Only remove the listeners that match this function.
8956
+ * @param {*} context Only remove the listeners that have this context.
8957
+ * @param {Boolean} once Only remove one-time listeners.
8958
+ * @returns {EventEmitter} `this`.
8959
+ * @public
8960
+ */
8961
+ EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
8962
+ var evt = prefix ? prefix + event : event;
8963
+
8964
+ if (!this._events[evt]) return this;
8965
+ if (!fn) {
8966
+ clearEvent(this, evt);
8967
+ return this;
8968
+ }
8969
+
8970
+ var listeners = this._events[evt];
8971
+
8972
+ if (listeners.fn) {
8973
+ if (
8974
+ listeners.fn === fn &&
8975
+ (!once || listeners.once) &&
8976
+ (!context || listeners.context === context)
8977
+ ) {
8978
+ clearEvent(this, evt);
8979
+ }
8980
+ } else {
8981
+ for (var i = 0, events = [], length = listeners.length; i < length; i++) {
8982
+ if (
8983
+ listeners[i].fn !== fn ||
8984
+ (once && !listeners[i].once) ||
8985
+ (context && listeners[i].context !== context)
8986
+ ) {
8987
+ events.push(listeners[i]);
8988
+ }
8989
+ }
8990
+
8991
+ //
8992
+ // Reset the array, or remove it completely if we have no more listeners.
8993
+ //
8994
+ if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
8995
+ else clearEvent(this, evt);
8996
+ }
8997
+
8998
+ return this;
8999
+ };
9000
+
9001
+ /**
9002
+ * Remove all listeners, or those of the specified event.
9003
+ *
9004
+ * @param {(String|Symbol)} [event] The event name.
9005
+ * @returns {EventEmitter} `this`.
9006
+ * @public
9007
+ */
9008
+ EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
9009
+ var evt;
9010
+
9011
+ if (event) {
9012
+ evt = prefix ? prefix + event : event;
9013
+ if (this._events[evt]) clearEvent(this, evt);
9014
+ } else {
9015
+ this._events = new Events();
9016
+ this._eventsCount = 0;
9017
+ }
9018
+
9019
+ return this;
9020
+ };
9021
+
9022
+ //
9023
+ // Alias methods names because people roll like that.
9024
+ //
9025
+ EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
9026
+ EventEmitter.prototype.addListener = EventEmitter.prototype.on;
9027
+
9028
+ //
9029
+ // Expose the prefix.
9030
+ //
9031
+ EventEmitter.prefixed = prefix;
9032
+
9033
+ //
9034
+ // Allow `EventEmitter` to be imported as module namespace.
9035
+ //
9036
+ EventEmitter.EventEmitter = EventEmitter;
9037
+
9038
+ //
9039
+ // Expose the module.
9040
+ //
9041
+ {
9042
+ module.exports = EventEmitter;
9043
+ }
9044
+ });
9045
+
8689
9046
  // eslint-disable-next-line import/no-cycle
9047
+ function failureLoggedFetch(url, options = {}) {
9048
+ return fetch(url, options).then(async (r) => {
9049
+ var _a;
9050
+ if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
9051
+ console.error('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
9052
+ }
9053
+ return r;
9054
+ });
9055
+ }
8690
9056
  function fetchSessionInfoService(authVerificationUrl) {
8691
- return fetch(authVerificationUrl, {
9057
+ return failureLoggedFetch(authVerificationUrl, {
8692
9058
  credentials: 'include',
8693
9059
  });
8694
9060
  }
@@ -8696,12 +9062,14 @@ async function fetchAuthTokenService(authEndpoint) {
8696
9062
  return fetch(authEndpoint);
8697
9063
  }
8698
9064
  async function fetchAuthService(thoughtSpotHost, username, authToken) {
8699
- return fetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
9065
+ return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
8700
9066
  credentials: 'include',
9067
+ // We do not want to follow the redirect, as it starts giving a CORS error
9068
+ redirect: 'manual',
8701
9069
  });
8702
9070
  }
8703
9071
  async function fetchBasicAuthService(thoughtSpotHost, username, password) {
8704
- return fetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
9072
+ return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
8705
9073
  method: 'POST',
8706
9074
  headers: {
8707
9075
  'content-type': 'application/x-www-form-urlencoded',
@@ -8710,6 +9078,15 @@ async function fetchBasicAuthService(thoughtSpotHost, username, password) {
8710
9078
  body: `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`,
8711
9079
  credentials: 'include',
8712
9080
  });
9081
+ }
9082
+ async function fetchLogoutService(thoughtSpotHost) {
9083
+ return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
9084
+ credentials: 'include',
9085
+ method: 'POST',
9086
+ headers: {
9087
+ 'x-requested-by': 'ThoughtSpot',
9088
+ },
9089
+ });
8713
9090
  }
8714
9091
 
8715
9092
  // eslint-disable-next-line import/no-mutable-exports
@@ -8727,7 +9104,21 @@ const EndPoints = {
8727
9104
  OIDC_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
8728
9105
  TOKEN_LOGIN: '/callosum/v1/session/login/token',
8729
9106
  BASIC_LOGIN: '/callosum/v1/session/login',
9107
+ LOGOUT: '/callosum/v1/session/logout',
8730
9108
  };
9109
+ var AuthFailureType;
9110
+ (function (AuthFailureType) {
9111
+ AuthFailureType["SDK"] = "SDK";
9112
+ AuthFailureType["NO_COOKIE_ACCESS"] = "NO_COOKIE_ACCESS";
9113
+ AuthFailureType["EXPIRY"] = "EXPIRY";
9114
+ AuthFailureType["OTHER"] = "OTHER";
9115
+ })(AuthFailureType || (AuthFailureType = {}));
9116
+ var AuthStatus;
9117
+ (function (AuthStatus) {
9118
+ AuthStatus["FAILURE"] = "FAILURE";
9119
+ AuthStatus["SUCCESS"] = "SUCCESS";
9120
+ AuthStatus["LOGOUT"] = "LOGOUT";
9121
+ })(AuthStatus || (AuthStatus = {}));
8731
9122
  /**
8732
9123
  * Check if we are logged into the ThoughtSpot cluster
8733
9124
  * @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
@@ -8747,6 +9138,17 @@ function initSession(sessionDetails) {
8747
9138
  sessionInfo = sessionDetails;
8748
9139
  initMixpanel(sessionInfo);
8749
9140
  }
9141
+ const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every time getAuthToken callback is called.' +
9142
+ 'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
9143
+ let prevAuthToken = null;
9144
+ function alertForDuplicateToken(authtoken) {
9145
+ if (prevAuthToken === authtoken) {
9146
+ // eslint-disable-next-line no-alert
9147
+ alert(DUPLICATE_TOKEN_ERR);
9148
+ throw new Error(DUPLICATE_TOKEN_ERR);
9149
+ }
9150
+ prevAuthToken = authtoken;
9151
+ }
8750
9152
  /**
8751
9153
  * Check if we are stuck at the SSO redirect URL
8752
9154
  */
@@ -8772,20 +9174,22 @@ const doTokenAuth = async (embedConfig) => {
8772
9174
  if (!authEndpoint && !getAuthToken) {
8773
9175
  throw new Error('Either auth endpoint or getAuthToken function must be provided');
8774
9176
  }
8775
- const loggedIn = await isLoggedIn(thoughtSpotHost);
8776
- if (!loggedIn) {
9177
+ loggedInStatus = await isLoggedIn(thoughtSpotHost);
9178
+ if (!loggedInStatus) {
8777
9179
  let authToken = null;
8778
9180
  if (getAuthToken) {
8779
9181
  authToken = await getAuthToken();
9182
+ alertForDuplicateToken(authToken);
8780
9183
  }
8781
9184
  else {
8782
9185
  const response = await fetchAuthTokenService(authEndpoint);
8783
9186
  authToken = await response.text();
8784
9187
  }
8785
- await fetchAuthService(thoughtSpotHost, username, authToken);
8786
- loggedInStatus = false;
9188
+ const resp = await fetchAuthService(thoughtSpotHost, username, authToken);
9189
+ // token login issues a 302 when successful
9190
+ loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
8787
9191
  }
8788
- loggedInStatus = true;
9192
+ return loggedInStatus;
8789
9193
  };
8790
9194
  /**
8791
9195
  * Perform basic authentication to the ThoughtSpot cluster using the cluster
@@ -8800,9 +9204,12 @@ const doBasicAuth = async (embedConfig) => {
8800
9204
  const loggedIn = await isLoggedIn(thoughtSpotHost);
8801
9205
  if (!loggedIn) {
8802
9206
  const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
8803
- loggedInStatus = response.status === 200;
9207
+ loggedInStatus = response.ok;
9208
+ }
9209
+ else {
9210
+ loggedInStatus = true;
8804
9211
  }
8805
- loggedInStatus = true;
9212
+ return loggedInStatus;
8806
9213
  };
8807
9214
  async function samlPopupFlow(ssoURL) {
8808
9215
  document.body.insertAdjacentHTML('beforeend', '<div id="ts-saml-auth"></div>');
@@ -8852,6 +9259,7 @@ const doSSOAuth = async (embedConfig, ssoEndPoint) => {
8852
9259
  const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
8853
9260
  if (embedConfig.noRedirect) {
8854
9261
  await samlPopupFlow(ssoURL);
9262
+ loggedInStatus = true;
8855
9263
  return;
8856
9264
  }
8857
9265
  window.location.href = ssoURL;
@@ -8862,10 +9270,11 @@ const doSamlAuth = async (embedConfig) => {
8862
9270
  // again and the same JS will execute again.
8863
9271
  const ssoRedirectUrl = embedConfig.noRedirect
8864
9272
  ? `${thoughtSpotHost}/v2/#/embed/saml-complete`
8865
- : appendToUrlHash(window.location.href, SSO_REDIRECTION_MARKER_GUID);
9273
+ : getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
8866
9274
  // bring back the page to the same URL
8867
9275
  const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
8868
9276
  await doSSOAuth(embedConfig, ssoEndPoint);
9277
+ return loggedInStatus;
8869
9278
  };
8870
9279
  const doOIDCAuth = async (embedConfig) => {
8871
9280
  const { thoughtSpotHost } = embedConfig;
@@ -8873,10 +9282,17 @@ const doOIDCAuth = async (embedConfig) => {
8873
9282
  // again and the same JS will execute again.
8874
9283
  const ssoRedirectUrl = embedConfig.noRedirect
8875
9284
  ? `${thoughtSpotHost}/v2/#/embed/saml-complete`
8876
- : appendToUrlHash(window.location.href, SSO_REDIRECTION_MARKER_GUID);
9285
+ : getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
8877
9286
  // bring back the page to the same URL
8878
9287
  const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
8879
9288
  await doSSOAuth(embedConfig, ssoEndPoint);
9289
+ return loggedInStatus;
9290
+ };
9291
+ const logout = async (embedConfig) => {
9292
+ const { thoughtSpotHost } = embedConfig;
9293
+ const response = await fetchLogoutService(thoughtSpotHost);
9294
+ loggedInStatus = false;
9295
+ return loggedInStatus;
8880
9296
  };
8881
9297
  /**
8882
9298
  * Perform authentication on the ThoughtSpot cluster
@@ -8894,26 +9310,55 @@ const authenticate = async (embedConfig) => {
8894
9310
  case AuthType.Basic:
8895
9311
  return doBasicAuth(embedConfig);
8896
9312
  default:
8897
- return Promise.resolve();
9313
+ return Promise.resolve(true);
8898
9314
  }
8899
9315
  };
8900
9316
 
8901
9317
  /* eslint-disable import/no-mutable-exports */
8902
9318
  let config = {};
9319
+ const CONFIG_DEFAULTS = {
9320
+ loginFailedMessage: 'Not logged in',
9321
+ authType: AuthType.None,
9322
+ };
8903
9323
  let authPromise;
9324
+ const getEmbedConfig = () => config;
9325
+ const getAuthPromise = () => authPromise;
9326
+ let authEE;
9327
+ function notifyAuthSuccess() {
9328
+ if (!authEE) {
9329
+ console.error('SDK not initialized');
9330
+ return;
9331
+ }
9332
+ authEE.emit(AuthStatus.SUCCESS);
9333
+ }
9334
+ function notifyAuthFailure(failureType) {
9335
+ if (!authEE) {
9336
+ console.error('SDK not initialized');
9337
+ return;
9338
+ }
9339
+ authEE.emit(AuthStatus.FAILURE, failureType);
9340
+ }
9341
+ function notifyLogout() {
9342
+ if (!authEE) {
9343
+ console.error('SDK not initialized');
9344
+ return;
9345
+ }
9346
+ authEE.emit(AuthStatus.LOGOUT);
9347
+ }
8904
9348
  /**
8905
9349
  * Perform authentication on the ThoughtSpot app as applicable.
8906
9350
  */
8907
9351
  const handleAuth = () => {
8908
- const authConfig = {
8909
- ...config,
8910
- thoughtSpotHost: getThoughtSpotHost(config),
8911
- };
8912
- authPromise = authenticate(authConfig);
9352
+ authPromise = authenticate(config);
9353
+ authPromise.then((isLoggedIn) => {
9354
+ if (!isLoggedIn) {
9355
+ notifyAuthFailure(AuthFailureType.SDK);
9356
+ }
9357
+ }, () => {
9358
+ notifyAuthFailure(AuthFailureType.SDK);
9359
+ });
8913
9360
  return authPromise;
8914
9361
  };
8915
- const getEmbedConfig = () => config;
8916
- const getAuthPromise = () => authPromise;
8917
9362
  /**
8918
9363
  * 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.
8919
9364
  * @param url The URL provided for prefetch
@@ -8939,10 +9384,18 @@ const prefetch = (url) => {
8939
9384
  * @param embedConfig The configuration object containing ThoughtSpot host,
8940
9385
  * authentication mechanism and so on.
8941
9386
  *
8942
- * @returns authPromise Promise which resolves when authentication is complete.
9387
+ * eg: authStatus = init(config);
9388
+ * authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
9389
+ *
9390
+ * @returns event emitter which emits events on authentication success, failure and logout. {@link AuthStatus}
8943
9391
  */
8944
9392
  const init = (embedConfig) => {
8945
- config = embedConfig;
9393
+ config = {
9394
+ ...CONFIG_DEFAULTS,
9395
+ ...embedConfig,
9396
+ thoughtSpotHost: getThoughtSpotHost(embedConfig),
9397
+ };
9398
+ authEE = new eventemitter3();
8946
9399
  handleAuth();
8947
9400
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
8948
9401
  authType: config.authType,
@@ -8951,7 +9404,30 @@ const init = (embedConfig) => {
8951
9404
  if (config.callPrefetch) {
8952
9405
  prefetch(config.thoughtSpotHost);
8953
9406
  }
8954
- return authPromise;
9407
+ return authEE;
9408
+ };
9409
+ function disableAutoLogin() {
9410
+ config.autoLogin = false;
9411
+ }
9412
+ /**
9413
+ * Logout from ThoughtSpot. This also sets the autoLogin flag to false, to prevent
9414
+ * the SDK from automatically logging in again.
9415
+ *
9416
+ * You can call the `init` method again to re login, if autoLogin is set to true in this
9417
+ * second call it will be honored.
9418
+ *
9419
+ * @param doNotDisableAutoLogin This flag when passed will not disable autoLogin
9420
+ * @returns Promise which resolves when logout completes.
9421
+ * @version SDK: 1.10.1 | ThoughtSpot: *
9422
+ */
9423
+ const logout$1 = (doNotDisableAutoLogin = false) => {
9424
+ if (!doNotDisableAutoLogin) {
9425
+ disableAutoLogin();
9426
+ }
9427
+ return logout(config).then((isLoggedIn) => {
9428
+ notifyLogout();
9429
+ return isLoggedIn;
9430
+ });
8955
9431
  };
8956
9432
  let renderQueue = Promise.resolve();
8957
9433
  /**
@@ -9037,6 +9513,7 @@ function processAuthInit(e) {
9037
9513
  var _a, _b;
9038
9514
  // Store user session details sent by app.
9039
9515
  initSession(e.data);
9516
+ notifyAuthSuccess();
9040
9517
  // Expose only allowed details (eg: userGUID) back to SDK users.
9041
9518
  return {
9042
9519
  ...e,
@@ -9050,9 +9527,36 @@ function processAuthExpire(e) {
9050
9527
  if (autoLogin) {
9051
9528
  handleAuth();
9052
9529
  }
9530
+ notifyAuthFailure(AuthFailureType.EXPIRY);
9531
+ return e;
9532
+ }
9533
+ function processNoCookieAccess(e, containerEl) {
9534
+ const { loginFailedMessage, suppressNoCookieAccessAlert, } = getEmbedConfig();
9535
+ if (!suppressNoCookieAccessAlert) {
9536
+ // eslint-disable-next-line no-alert
9537
+ 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.');
9538
+ }
9539
+ // eslint-disable-next-line no-param-reassign
9540
+ containerEl.innerHTML = loginFailedMessage;
9541
+ notifyAuthFailure(AuthFailureType.NO_COOKIE_ACCESS);
9542
+ return e;
9543
+ }
9544
+ function processAuthFailure(e, containerEl) {
9545
+ const { loginFailedMessage } = getEmbedConfig();
9546
+ // eslint-disable-next-line no-param-reassign
9547
+ containerEl.innerHTML = loginFailedMessage;
9548
+ notifyAuthFailure(AuthFailureType.OTHER);
9053
9549
  return e;
9054
9550
  }
9055
- function getProcessData(type, e, thoughtSpotHost) {
9551
+ function processAuthLogout(e, containerEl) {
9552
+ const { loginFailedMessage } = getEmbedConfig();
9553
+ // eslint-disable-next-line no-param-reassign
9554
+ containerEl.innerHTML = loginFailedMessage;
9555
+ disableAutoLogin();
9556
+ notifyLogout();
9557
+ return e;
9558
+ }
9559
+ function processEventData(type, e, thoughtSpotHost, containerEl) {
9056
9560
  switch (type) {
9057
9561
  case EmbedEvent.CustomAction:
9058
9562
  return processCustomAction(e, thoughtSpotHost);
@@ -9060,6 +9564,12 @@ function getProcessData(type, e, thoughtSpotHost) {
9060
9564
  return processAuthInit(e);
9061
9565
  case EmbedEvent.AuthExpire:
9062
9566
  return processAuthExpire(e);
9567
+ case EmbedEvent.NoCookieAccess:
9568
+ return processNoCookieAccess(e, containerEl);
9569
+ case EmbedEvent.AuthFailure:
9570
+ return processAuthFailure(e, containerEl);
9571
+ case EmbedEvent.AuthLogout:
9572
+ return processAuthLogout(e, containerEl);
9063
9573
  }
9064
9574
  return e;
9065
9575
  }
@@ -9088,7 +9598,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
9088
9598
  }
9089
9599
  }
9090
9600
 
9091
- var name="@thoughtspot/visual-embed-sdk";var version="1.10.0";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};
9601
+ var name="@thoughtspot/visual-embed-sdk";var version="1.10.3";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",eventemitter3:"^4.0.7","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
9602
 
9093
9603
  /**
9094
9604
  * Copyright (c) 2022
@@ -9135,12 +9645,6 @@ class TsEmbed {
9135
9645
  this.isError = false;
9136
9646
  this.viewConfig = viewConfig;
9137
9647
  this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
9138
- if (!this.embedConfig.suppressNoCookieAccessAlert) {
9139
- this.on(EmbedEvent.NoCookieAccess, () => {
9140
- // eslint-disable-next-line no-alert
9141
- alert('Third party cookie access is blocked on this browser, please allow third party cookies for ThoughtSpot to work properly');
9142
- });
9143
- }
9144
9648
  }
9145
9649
  /**
9146
9650
  * Gets a reference to the root DOM node where
@@ -9217,7 +9721,7 @@ class TsEmbed {
9217
9721
  const eventPort = this.getEventPort(event);
9218
9722
  const eventData = this.formatEventData(event, eventType);
9219
9723
  if (event.source === this.iFrame.contentWindow) {
9220
- this.executeCallbacks(eventType, getProcessData(eventType, eventData, this.thoughtSpotHost), eventPort);
9724
+ this.executeCallbacks(eventType, processEventData(eventType, eventData, this.thoughtSpotHost, this.el), eventPort);
9221
9725
  }
9222
9726
  });
9223
9727
  }
@@ -9336,7 +9840,11 @@ class TsEmbed {
9336
9840
  type: EmbedEvent.Init,
9337
9841
  });
9338
9842
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
9339
- (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then(() => {
9843
+ (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
9844
+ if (!isLoggedIn) {
9845
+ this.el.innerHTML = this.embedConfig.loginFailedMessage;
9846
+ return;
9847
+ }
9340
9848
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
9341
9849
  this.iFrame =
9342
9850
  this.iFrame || document.createElement('iframe');
@@ -9352,7 +9860,7 @@ class TsEmbed {
9352
9860
  this.iFrame.mozallowfullscreen = true;
9353
9861
  const { height: frameHeight, width: frameWidth, ...restParams } = frameOptions;
9354
9862
  const width = getCssDimension(frameWidth || DEFAULT_EMBED_WIDTH);
9355
- const height = getCssDimension(frameWidth || DEFAULT_EMBED_HEIGHT);
9863
+ const height = getCssDimension(frameHeight || DEFAULT_EMBED_HEIGHT);
9356
9864
  setAttributes(this.iFrame, restParams);
9357
9865
  this.iFrame.style.width = `${width}`;
9358
9866
  this.iFrame.style.height = `${height}`;
@@ -9386,6 +9894,7 @@ class TsEmbed {
9386
9894
  }).catch((error) => {
9387
9895
  nextInQueue();
9388
9896
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED);
9897
+ this.el.innerHTML = this.embedConfig.loginFailedMessage;
9389
9898
  this.handleError(error);
9390
9899
  });
9391
9900
  });
@@ -9957,4 +10466,4 @@ class SearchEmbed extends TsEmbed {
9957
10466
  }
9958
10467
  }
9959
10468
 
9960
- export { Action, AppEmbed, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, RuntimeFilterOp, SearchEmbed, init, prefetch };
10469
+ export { Action, AppEmbed, AuthFailureType, AuthStatus, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, RuntimeFilterOp, SearchEmbed, init, logout$1 as logout, prefetch };