@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
package/dist/tsembed.js CHANGED
@@ -102,6 +102,10 @@
102
102
  }
103
103
  return outputUrl;
104
104
  };
105
+ function getRedirectUrl(url, stringToAppend, path = '') {
106
+ const targetUrl = path ? new URL(path, window.location.origin).href : url;
107
+ return appendToUrlHash(targetUrl, stringToAppend);
108
+ }
105
109
  const getEncodedQueryParamsString = (queryString) => {
106
110
  if (!queryString) {
107
111
  return queryString;
@@ -296,6 +300,16 @@
296
300
  * The ThoughtSpot auth session has expired.
297
301
  */
298
302
  EmbedEvent["AuthExpire"] = "ThoughtspotAuthExpired";
303
+ /**
304
+ * ThoughtSpot failed to validate the auth session.
305
+ * @hidden
306
+ */
307
+ EmbedEvent["AuthFailure"] = "ThoughtspotAuthFailure";
308
+ /**
309
+ * ThoughtSpot failed to validate the auth session.
310
+ * @hidden
311
+ */
312
+ EmbedEvent["AuthLogout"] = "ThoughtspotAuthLogout";
299
313
  /**
300
314
  * The height of the embedded Liveboard or visualization has been computed.
301
315
  * @return data - The height of the embedded Liveboard or visualization
@@ -8655,9 +8669,361 @@
8655
8669
  }
8656
8670
  }
8657
8671
 
8672
+ function createCommonjsModule(fn) {
8673
+ var module = { exports: {} };
8674
+ return fn(module, module.exports), module.exports;
8675
+ }
8676
+
8677
+ var eventemitter3 = createCommonjsModule(function (module) {
8678
+
8679
+ var has = Object.prototype.hasOwnProperty
8680
+ , prefix = '~';
8681
+
8682
+ /**
8683
+ * Constructor to create a storage for our `EE` objects.
8684
+ * An `Events` instance is a plain object whose properties are event names.
8685
+ *
8686
+ * @constructor
8687
+ * @private
8688
+ */
8689
+ function Events() {}
8690
+
8691
+ //
8692
+ // We try to not inherit from `Object.prototype`. In some engines creating an
8693
+ // instance in this way is faster than calling `Object.create(null)` directly.
8694
+ // If `Object.create(null)` is not supported we prefix the event names with a
8695
+ // character to make sure that the built-in object properties are not
8696
+ // overridden or used as an attack vector.
8697
+ //
8698
+ if (Object.create) {
8699
+ Events.prototype = Object.create(null);
8700
+
8701
+ //
8702
+ // This hack is needed because the `__proto__` property is still inherited in
8703
+ // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
8704
+ //
8705
+ if (!new Events().__proto__) prefix = false;
8706
+ }
8707
+
8708
+ /**
8709
+ * Representation of a single event listener.
8710
+ *
8711
+ * @param {Function} fn The listener function.
8712
+ * @param {*} context The context to invoke the listener with.
8713
+ * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
8714
+ * @constructor
8715
+ * @private
8716
+ */
8717
+ function EE(fn, context, once) {
8718
+ this.fn = fn;
8719
+ this.context = context;
8720
+ this.once = once || false;
8721
+ }
8722
+
8723
+ /**
8724
+ * Add a listener for a given event.
8725
+ *
8726
+ * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
8727
+ * @param {(String|Symbol)} event The event name.
8728
+ * @param {Function} fn The listener function.
8729
+ * @param {*} context The context to invoke the listener with.
8730
+ * @param {Boolean} once Specify if the listener is a one-time listener.
8731
+ * @returns {EventEmitter}
8732
+ * @private
8733
+ */
8734
+ function addListener(emitter, event, fn, context, once) {
8735
+ if (typeof fn !== 'function') {
8736
+ throw new TypeError('The listener must be a function');
8737
+ }
8738
+
8739
+ var listener = new EE(fn, context || emitter, once)
8740
+ , evt = prefix ? prefix + event : event;
8741
+
8742
+ if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
8743
+ else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
8744
+ else emitter._events[evt] = [emitter._events[evt], listener];
8745
+
8746
+ return emitter;
8747
+ }
8748
+
8749
+ /**
8750
+ * Clear event by name.
8751
+ *
8752
+ * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
8753
+ * @param {(String|Symbol)} evt The Event name.
8754
+ * @private
8755
+ */
8756
+ function clearEvent(emitter, evt) {
8757
+ if (--emitter._eventsCount === 0) emitter._events = new Events();
8758
+ else delete emitter._events[evt];
8759
+ }
8760
+
8761
+ /**
8762
+ * Minimal `EventEmitter` interface that is molded against the Node.js
8763
+ * `EventEmitter` interface.
8764
+ *
8765
+ * @constructor
8766
+ * @public
8767
+ */
8768
+ function EventEmitter() {
8769
+ this._events = new Events();
8770
+ this._eventsCount = 0;
8771
+ }
8772
+
8773
+ /**
8774
+ * Return an array listing the events for which the emitter has registered
8775
+ * listeners.
8776
+ *
8777
+ * @returns {Array}
8778
+ * @public
8779
+ */
8780
+ EventEmitter.prototype.eventNames = function eventNames() {
8781
+ var names = []
8782
+ , events
8783
+ , name;
8784
+
8785
+ if (this._eventsCount === 0) return names;
8786
+
8787
+ for (name in (events = this._events)) {
8788
+ if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
8789
+ }
8790
+
8791
+ if (Object.getOwnPropertySymbols) {
8792
+ return names.concat(Object.getOwnPropertySymbols(events));
8793
+ }
8794
+
8795
+ return names;
8796
+ };
8797
+
8798
+ /**
8799
+ * Return the listeners registered for a given event.
8800
+ *
8801
+ * @param {(String|Symbol)} event The event name.
8802
+ * @returns {Array} The registered listeners.
8803
+ * @public
8804
+ */
8805
+ EventEmitter.prototype.listeners = function listeners(event) {
8806
+ var evt = prefix ? prefix + event : event
8807
+ , handlers = this._events[evt];
8808
+
8809
+ if (!handlers) return [];
8810
+ if (handlers.fn) return [handlers.fn];
8811
+
8812
+ for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
8813
+ ee[i] = handlers[i].fn;
8814
+ }
8815
+
8816
+ return ee;
8817
+ };
8818
+
8819
+ /**
8820
+ * Return the number of listeners listening to a given event.
8821
+ *
8822
+ * @param {(String|Symbol)} event The event name.
8823
+ * @returns {Number} The number of listeners.
8824
+ * @public
8825
+ */
8826
+ EventEmitter.prototype.listenerCount = function listenerCount(event) {
8827
+ var evt = prefix ? prefix + event : event
8828
+ , listeners = this._events[evt];
8829
+
8830
+ if (!listeners) return 0;
8831
+ if (listeners.fn) return 1;
8832
+ return listeners.length;
8833
+ };
8834
+
8835
+ /**
8836
+ * Calls each of the listeners registered for a given event.
8837
+ *
8838
+ * @param {(String|Symbol)} event The event name.
8839
+ * @returns {Boolean} `true` if the event had listeners, else `false`.
8840
+ * @public
8841
+ */
8842
+ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
8843
+ var evt = prefix ? prefix + event : event;
8844
+
8845
+ if (!this._events[evt]) return false;
8846
+
8847
+ var listeners = this._events[evt]
8848
+ , len = arguments.length
8849
+ , args
8850
+ , i;
8851
+
8852
+ if (listeners.fn) {
8853
+ if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
8854
+
8855
+ switch (len) {
8856
+ case 1: return listeners.fn.call(listeners.context), true;
8857
+ case 2: return listeners.fn.call(listeners.context, a1), true;
8858
+ case 3: return listeners.fn.call(listeners.context, a1, a2), true;
8859
+ case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
8860
+ case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
8861
+ case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
8862
+ }
8863
+
8864
+ for (i = 1, args = new Array(len -1); i < len; i++) {
8865
+ args[i - 1] = arguments[i];
8866
+ }
8867
+
8868
+ listeners.fn.apply(listeners.context, args);
8869
+ } else {
8870
+ var length = listeners.length
8871
+ , j;
8872
+
8873
+ for (i = 0; i < length; i++) {
8874
+ if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
8875
+
8876
+ switch (len) {
8877
+ case 1: listeners[i].fn.call(listeners[i].context); break;
8878
+ case 2: listeners[i].fn.call(listeners[i].context, a1); break;
8879
+ case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
8880
+ case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
8881
+ default:
8882
+ if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
8883
+ args[j - 1] = arguments[j];
8884
+ }
8885
+
8886
+ listeners[i].fn.apply(listeners[i].context, args);
8887
+ }
8888
+ }
8889
+ }
8890
+
8891
+ return true;
8892
+ };
8893
+
8894
+ /**
8895
+ * Add a listener for a given event.
8896
+ *
8897
+ * @param {(String|Symbol)} event The event name.
8898
+ * @param {Function} fn The listener function.
8899
+ * @param {*} [context=this] The context to invoke the listener with.
8900
+ * @returns {EventEmitter} `this`.
8901
+ * @public
8902
+ */
8903
+ EventEmitter.prototype.on = function on(event, fn, context) {
8904
+ return addListener(this, event, fn, context, false);
8905
+ };
8906
+
8907
+ /**
8908
+ * Add a one-time listener for a given event.
8909
+ *
8910
+ * @param {(String|Symbol)} event The event name.
8911
+ * @param {Function} fn The listener function.
8912
+ * @param {*} [context=this] The context to invoke the listener with.
8913
+ * @returns {EventEmitter} `this`.
8914
+ * @public
8915
+ */
8916
+ EventEmitter.prototype.once = function once(event, fn, context) {
8917
+ return addListener(this, event, fn, context, true);
8918
+ };
8919
+
8920
+ /**
8921
+ * Remove the listeners of a given event.
8922
+ *
8923
+ * @param {(String|Symbol)} event The event name.
8924
+ * @param {Function} fn Only remove the listeners that match this function.
8925
+ * @param {*} context Only remove the listeners that have this context.
8926
+ * @param {Boolean} once Only remove one-time listeners.
8927
+ * @returns {EventEmitter} `this`.
8928
+ * @public
8929
+ */
8930
+ EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
8931
+ var evt = prefix ? prefix + event : event;
8932
+
8933
+ if (!this._events[evt]) return this;
8934
+ if (!fn) {
8935
+ clearEvent(this, evt);
8936
+ return this;
8937
+ }
8938
+
8939
+ var listeners = this._events[evt];
8940
+
8941
+ if (listeners.fn) {
8942
+ if (
8943
+ listeners.fn === fn &&
8944
+ (!once || listeners.once) &&
8945
+ (!context || listeners.context === context)
8946
+ ) {
8947
+ clearEvent(this, evt);
8948
+ }
8949
+ } else {
8950
+ for (var i = 0, events = [], length = listeners.length; i < length; i++) {
8951
+ if (
8952
+ listeners[i].fn !== fn ||
8953
+ (once && !listeners[i].once) ||
8954
+ (context && listeners[i].context !== context)
8955
+ ) {
8956
+ events.push(listeners[i]);
8957
+ }
8958
+ }
8959
+
8960
+ //
8961
+ // Reset the array, or remove it completely if we have no more listeners.
8962
+ //
8963
+ if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
8964
+ else clearEvent(this, evt);
8965
+ }
8966
+
8967
+ return this;
8968
+ };
8969
+
8970
+ /**
8971
+ * Remove all listeners, or those of the specified event.
8972
+ *
8973
+ * @param {(String|Symbol)} [event] The event name.
8974
+ * @returns {EventEmitter} `this`.
8975
+ * @public
8976
+ */
8977
+ EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
8978
+ var evt;
8979
+
8980
+ if (event) {
8981
+ evt = prefix ? prefix + event : event;
8982
+ if (this._events[evt]) clearEvent(this, evt);
8983
+ } else {
8984
+ this._events = new Events();
8985
+ this._eventsCount = 0;
8986
+ }
8987
+
8988
+ return this;
8989
+ };
8990
+
8991
+ //
8992
+ // Alias methods names because people roll like that.
8993
+ //
8994
+ EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
8995
+ EventEmitter.prototype.addListener = EventEmitter.prototype.on;
8996
+
8997
+ //
8998
+ // Expose the prefix.
8999
+ //
9000
+ EventEmitter.prefixed = prefix;
9001
+
9002
+ //
9003
+ // Allow `EventEmitter` to be imported as module namespace.
9004
+ //
9005
+ EventEmitter.EventEmitter = EventEmitter;
9006
+
9007
+ //
9008
+ // Expose the module.
9009
+ //
9010
+ {
9011
+ module.exports = EventEmitter;
9012
+ }
9013
+ });
9014
+
8658
9015
  // eslint-disable-next-line import/no-cycle
9016
+ function failureLoggedFetch(url, options = {}) {
9017
+ return fetch(url, options).then(async (r) => {
9018
+ var _a;
9019
+ if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
9020
+ console.error('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
9021
+ }
9022
+ return r;
9023
+ });
9024
+ }
8659
9025
  function fetchSessionInfoService(authVerificationUrl) {
8660
- return fetch(authVerificationUrl, {
9026
+ return failureLoggedFetch(authVerificationUrl, {
8661
9027
  credentials: 'include',
8662
9028
  });
8663
9029
  }
@@ -8665,12 +9031,14 @@
8665
9031
  return fetch(authEndpoint);
8666
9032
  }
8667
9033
  async function fetchAuthService(thoughtSpotHost, username, authToken) {
8668
- return fetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
9034
+ return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
8669
9035
  credentials: 'include',
9036
+ // We do not want to follow the redirect, as it starts giving a CORS error
9037
+ redirect: 'manual',
8670
9038
  });
8671
9039
  }
8672
9040
  async function fetchBasicAuthService(thoughtSpotHost, username, password) {
8673
- return fetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
9041
+ return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
8674
9042
  method: 'POST',
8675
9043
  headers: {
8676
9044
  'content-type': 'application/x-www-form-urlencoded',
@@ -8679,6 +9047,15 @@
8679
9047
  body: `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`,
8680
9048
  credentials: 'include',
8681
9049
  });
9050
+ }
9051
+ async function fetchLogoutService(thoughtSpotHost) {
9052
+ return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
9053
+ credentials: 'include',
9054
+ method: 'POST',
9055
+ headers: {
9056
+ 'x-requested-by': 'ThoughtSpot',
9057
+ },
9058
+ });
8682
9059
  }
8683
9060
 
8684
9061
  // eslint-disable-next-line import/no-mutable-exports
@@ -8696,7 +9073,19 @@
8696
9073
  OIDC_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
8697
9074
  TOKEN_LOGIN: '/callosum/v1/session/login/token',
8698
9075
  BASIC_LOGIN: '/callosum/v1/session/login',
9076
+ LOGOUT: '/callosum/v1/session/logout',
8699
9077
  };
9078
+ (function (AuthFailureType) {
9079
+ AuthFailureType["SDK"] = "SDK";
9080
+ AuthFailureType["NO_COOKIE_ACCESS"] = "NO_COOKIE_ACCESS";
9081
+ AuthFailureType["EXPIRY"] = "EXPIRY";
9082
+ AuthFailureType["OTHER"] = "OTHER";
9083
+ })(exports.AuthFailureType || (exports.AuthFailureType = {}));
9084
+ (function (AuthStatus) {
9085
+ AuthStatus["FAILURE"] = "FAILURE";
9086
+ AuthStatus["SUCCESS"] = "SUCCESS";
9087
+ AuthStatus["LOGOUT"] = "LOGOUT";
9088
+ })(exports.AuthStatus || (exports.AuthStatus = {}));
8700
9089
  /**
8701
9090
  * Check if we are logged into the ThoughtSpot cluster
8702
9091
  * @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
@@ -8716,6 +9105,17 @@
8716
9105
  sessionInfo = sessionDetails;
8717
9106
  initMixpanel(sessionInfo);
8718
9107
  }
9108
+ const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every time getAuthToken callback is called.' +
9109
+ 'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
9110
+ let prevAuthToken = null;
9111
+ function alertForDuplicateToken(authtoken) {
9112
+ if (prevAuthToken === authtoken) {
9113
+ // eslint-disable-next-line no-alert
9114
+ alert(DUPLICATE_TOKEN_ERR);
9115
+ throw new Error(DUPLICATE_TOKEN_ERR);
9116
+ }
9117
+ prevAuthToken = authtoken;
9118
+ }
8719
9119
  /**
8720
9120
  * Check if we are stuck at the SSO redirect URL
8721
9121
  */
@@ -8741,20 +9141,22 @@
8741
9141
  if (!authEndpoint && !getAuthToken) {
8742
9142
  throw new Error('Either auth endpoint or getAuthToken function must be provided');
8743
9143
  }
8744
- const loggedIn = await isLoggedIn(thoughtSpotHost);
8745
- if (!loggedIn) {
9144
+ loggedInStatus = await isLoggedIn(thoughtSpotHost);
9145
+ if (!loggedInStatus) {
8746
9146
  let authToken = null;
8747
9147
  if (getAuthToken) {
8748
9148
  authToken = await getAuthToken();
9149
+ alertForDuplicateToken(authToken);
8749
9150
  }
8750
9151
  else {
8751
9152
  const response = await fetchAuthTokenService(authEndpoint);
8752
9153
  authToken = await response.text();
8753
9154
  }
8754
- await fetchAuthService(thoughtSpotHost, username, authToken);
8755
- loggedInStatus = false;
9155
+ const resp = await fetchAuthService(thoughtSpotHost, username, authToken);
9156
+ // token login issues a 302 when successful
9157
+ loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
8756
9158
  }
8757
- loggedInStatus = true;
9159
+ return loggedInStatus;
8758
9160
  };
8759
9161
  /**
8760
9162
  * Perform basic authentication to the ThoughtSpot cluster using the cluster
@@ -8769,9 +9171,12 @@
8769
9171
  const loggedIn = await isLoggedIn(thoughtSpotHost);
8770
9172
  if (!loggedIn) {
8771
9173
  const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
8772
- loggedInStatus = response.status === 200;
9174
+ loggedInStatus = response.ok;
9175
+ }
9176
+ else {
9177
+ loggedInStatus = true;
8773
9178
  }
8774
- loggedInStatus = true;
9179
+ return loggedInStatus;
8775
9180
  };
8776
9181
  async function samlPopupFlow(ssoURL) {
8777
9182
  document.body.insertAdjacentHTML('beforeend', '<div id="ts-saml-auth"></div>');
@@ -8821,6 +9226,7 @@
8821
9226
  const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
8822
9227
  if (embedConfig.noRedirect) {
8823
9228
  await samlPopupFlow(ssoURL);
9229
+ loggedInStatus = true;
8824
9230
  return;
8825
9231
  }
8826
9232
  window.location.href = ssoURL;
@@ -8831,10 +9237,11 @@
8831
9237
  // again and the same JS will execute again.
8832
9238
  const ssoRedirectUrl = embedConfig.noRedirect
8833
9239
  ? `${thoughtSpotHost}/v2/#/embed/saml-complete`
8834
- : appendToUrlHash(window.location.href, SSO_REDIRECTION_MARKER_GUID);
9240
+ : getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
8835
9241
  // bring back the page to the same URL
8836
9242
  const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
8837
9243
  await doSSOAuth(embedConfig, ssoEndPoint);
9244
+ return loggedInStatus;
8838
9245
  };
8839
9246
  const doOIDCAuth = async (embedConfig) => {
8840
9247
  const { thoughtSpotHost } = embedConfig;
@@ -8842,10 +9249,17 @@
8842
9249
  // again and the same JS will execute again.
8843
9250
  const ssoRedirectUrl = embedConfig.noRedirect
8844
9251
  ? `${thoughtSpotHost}/v2/#/embed/saml-complete`
8845
- : appendToUrlHash(window.location.href, SSO_REDIRECTION_MARKER_GUID);
9252
+ : getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
8846
9253
  // bring back the page to the same URL
8847
9254
  const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
8848
9255
  await doSSOAuth(embedConfig, ssoEndPoint);
9256
+ return loggedInStatus;
9257
+ };
9258
+ const logout = async (embedConfig) => {
9259
+ const { thoughtSpotHost } = embedConfig;
9260
+ const response = await fetchLogoutService(thoughtSpotHost);
9261
+ loggedInStatus = false;
9262
+ return loggedInStatus;
8849
9263
  };
8850
9264
  /**
8851
9265
  * Perform authentication on the ThoughtSpot cluster
@@ -8863,26 +9277,55 @@
8863
9277
  case exports.AuthType.Basic:
8864
9278
  return doBasicAuth(embedConfig);
8865
9279
  default:
8866
- return Promise.resolve();
9280
+ return Promise.resolve(true);
8867
9281
  }
8868
9282
  };
8869
9283
 
8870
9284
  /* eslint-disable import/no-mutable-exports */
8871
9285
  let config = {};
9286
+ const CONFIG_DEFAULTS = {
9287
+ loginFailedMessage: 'Not logged in',
9288
+ authType: exports.AuthType.None,
9289
+ };
8872
9290
  let authPromise;
9291
+ const getEmbedConfig = () => config;
9292
+ const getAuthPromise = () => authPromise;
9293
+ let authEE;
9294
+ function notifyAuthSuccess() {
9295
+ if (!authEE) {
9296
+ console.error('SDK not initialized');
9297
+ return;
9298
+ }
9299
+ authEE.emit(exports.AuthStatus.SUCCESS);
9300
+ }
9301
+ function notifyAuthFailure(failureType) {
9302
+ if (!authEE) {
9303
+ console.error('SDK not initialized');
9304
+ return;
9305
+ }
9306
+ authEE.emit(exports.AuthStatus.FAILURE, failureType);
9307
+ }
9308
+ function notifyLogout() {
9309
+ if (!authEE) {
9310
+ console.error('SDK not initialized');
9311
+ return;
9312
+ }
9313
+ authEE.emit(exports.AuthStatus.LOGOUT);
9314
+ }
8873
9315
  /**
8874
9316
  * Perform authentication on the ThoughtSpot app as applicable.
8875
9317
  */
8876
9318
  const handleAuth = () => {
8877
- const authConfig = {
8878
- ...config,
8879
- thoughtSpotHost: getThoughtSpotHost(config),
8880
- };
8881
- authPromise = authenticate(authConfig);
9319
+ authPromise = authenticate(config);
9320
+ authPromise.then((isLoggedIn) => {
9321
+ if (!isLoggedIn) {
9322
+ notifyAuthFailure(exports.AuthFailureType.SDK);
9323
+ }
9324
+ }, () => {
9325
+ notifyAuthFailure(exports.AuthFailureType.SDK);
9326
+ });
8882
9327
  return authPromise;
8883
9328
  };
8884
- const getEmbedConfig = () => config;
8885
- const getAuthPromise = () => authPromise;
8886
9329
  /**
8887
9330
  * 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.
8888
9331
  * @param url The URL provided for prefetch
@@ -8908,10 +9351,18 @@
8908
9351
  * @param embedConfig The configuration object containing ThoughtSpot host,
8909
9352
  * authentication mechanism and so on.
8910
9353
  *
8911
- * @returns authPromise Promise which resolves when authentication is complete.
9354
+ * eg: authStatus = init(config);
9355
+ * authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
9356
+ *
9357
+ * @returns event emitter which emits events on authentication success, failure and logout. {@link AuthStatus}
8912
9358
  */
8913
9359
  const init = (embedConfig) => {
8914
- config = embedConfig;
9360
+ config = {
9361
+ ...CONFIG_DEFAULTS,
9362
+ ...embedConfig,
9363
+ thoughtSpotHost: getThoughtSpotHost(embedConfig),
9364
+ };
9365
+ authEE = new eventemitter3();
8915
9366
  handleAuth();
8916
9367
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
8917
9368
  authType: config.authType,
@@ -8920,7 +9371,30 @@
8920
9371
  if (config.callPrefetch) {
8921
9372
  prefetch(config.thoughtSpotHost);
8922
9373
  }
8923
- return authPromise;
9374
+ return authEE;
9375
+ };
9376
+ function disableAutoLogin() {
9377
+ config.autoLogin = false;
9378
+ }
9379
+ /**
9380
+ * Logout from ThoughtSpot. This also sets the autoLogin flag to false, to prevent
9381
+ * the SDK from automatically logging in again.
9382
+ *
9383
+ * You can call the `init` method again to re login, if autoLogin is set to true in this
9384
+ * second call it will be honored.
9385
+ *
9386
+ * @param doNotDisableAutoLogin This flag when passed will not disable autoLogin
9387
+ * @returns Promise which resolves when logout completes.
9388
+ * @version SDK: 1.10.1 | ThoughtSpot: *
9389
+ */
9390
+ const logout$1 = (doNotDisableAutoLogin = false) => {
9391
+ if (!doNotDisableAutoLogin) {
9392
+ disableAutoLogin();
9393
+ }
9394
+ return logout(config).then((isLoggedIn) => {
9395
+ notifyLogout();
9396
+ return isLoggedIn;
9397
+ });
8924
9398
  };
8925
9399
  let renderQueue = Promise.resolve();
8926
9400
  /**
@@ -9006,6 +9480,7 @@
9006
9480
  var _a, _b;
9007
9481
  // Store user session details sent by app.
9008
9482
  initSession(e.data);
9483
+ notifyAuthSuccess();
9009
9484
  // Expose only allowed details (eg: userGUID) back to SDK users.
9010
9485
  return {
9011
9486
  ...e,
@@ -9019,9 +9494,36 @@
9019
9494
  if (autoLogin) {
9020
9495
  handleAuth();
9021
9496
  }
9497
+ notifyAuthFailure(exports.AuthFailureType.EXPIRY);
9498
+ return e;
9499
+ }
9500
+ function processNoCookieAccess(e, containerEl) {
9501
+ const { loginFailedMessage, suppressNoCookieAccessAlert, } = getEmbedConfig();
9502
+ if (!suppressNoCookieAccessAlert) {
9503
+ // eslint-disable-next-line no-alert
9504
+ 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.');
9505
+ }
9506
+ // eslint-disable-next-line no-param-reassign
9507
+ containerEl.innerHTML = loginFailedMessage;
9508
+ notifyAuthFailure(exports.AuthFailureType.NO_COOKIE_ACCESS);
9509
+ return e;
9510
+ }
9511
+ function processAuthFailure(e, containerEl) {
9512
+ const { loginFailedMessage } = getEmbedConfig();
9513
+ // eslint-disable-next-line no-param-reassign
9514
+ containerEl.innerHTML = loginFailedMessage;
9515
+ notifyAuthFailure(exports.AuthFailureType.OTHER);
9022
9516
  return e;
9023
9517
  }
9024
- function getProcessData(type, e, thoughtSpotHost) {
9518
+ function processAuthLogout(e, containerEl) {
9519
+ const { loginFailedMessage } = getEmbedConfig();
9520
+ // eslint-disable-next-line no-param-reassign
9521
+ containerEl.innerHTML = loginFailedMessage;
9522
+ disableAutoLogin();
9523
+ notifyLogout();
9524
+ return e;
9525
+ }
9526
+ function processEventData(type, e, thoughtSpotHost, containerEl) {
9025
9527
  switch (type) {
9026
9528
  case exports.EmbedEvent.CustomAction:
9027
9529
  return processCustomAction(e, thoughtSpotHost);
@@ -9029,6 +9531,12 @@
9029
9531
  return processAuthInit(e);
9030
9532
  case exports.EmbedEvent.AuthExpire:
9031
9533
  return processAuthExpire(e);
9534
+ case exports.EmbedEvent.NoCookieAccess:
9535
+ return processNoCookieAccess(e, containerEl);
9536
+ case exports.EmbedEvent.AuthFailure:
9537
+ return processAuthFailure(e, containerEl);
9538
+ case exports.EmbedEvent.AuthLogout:
9539
+ return processAuthLogout(e, containerEl);
9032
9540
  }
9033
9541
  return e;
9034
9542
  }
@@ -9057,7 +9565,7 @@
9057
9565
  }
9058
9566
  }
9059
9567
 
9060
- 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$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};
9568
+ 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$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",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$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
9569
 
9062
9570
  /**
9063
9571
  * Copyright (c) 2022
@@ -9104,12 +9612,6 @@
9104
9612
  this.isError = false;
9105
9613
  this.viewConfig = viewConfig;
9106
9614
  this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
9107
- if (!this.embedConfig.suppressNoCookieAccessAlert) {
9108
- this.on(exports.EmbedEvent.NoCookieAccess, () => {
9109
- // eslint-disable-next-line no-alert
9110
- alert('Third party cookie access is blocked on this browser, please allow third party cookies for ThoughtSpot to work properly');
9111
- });
9112
- }
9113
9615
  }
9114
9616
  /**
9115
9617
  * Gets a reference to the root DOM node where
@@ -9186,7 +9688,7 @@
9186
9688
  const eventPort = this.getEventPort(event);
9187
9689
  const eventData = this.formatEventData(event, eventType);
9188
9690
  if (event.source === this.iFrame.contentWindow) {
9189
- this.executeCallbacks(eventType, getProcessData(eventType, eventData, this.thoughtSpotHost), eventPort);
9691
+ this.executeCallbacks(eventType, processEventData(eventType, eventData, this.thoughtSpotHost, this.el), eventPort);
9190
9692
  }
9191
9693
  });
9192
9694
  }
@@ -9305,7 +9807,11 @@
9305
9807
  type: exports.EmbedEvent.Init,
9306
9808
  });
9307
9809
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
9308
- (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then(() => {
9810
+ (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
9811
+ if (!isLoggedIn) {
9812
+ this.el.innerHTML = this.embedConfig.loginFailedMessage;
9813
+ return;
9814
+ }
9309
9815
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
9310
9816
  this.iFrame =
9311
9817
  this.iFrame || document.createElement('iframe');
@@ -9321,7 +9827,7 @@
9321
9827
  this.iFrame.mozallowfullscreen = true;
9322
9828
  const { height: frameHeight, width: frameWidth, ...restParams } = frameOptions;
9323
9829
  const width = getCssDimension(frameWidth || DEFAULT_EMBED_WIDTH);
9324
- const height = getCssDimension(frameWidth || DEFAULT_EMBED_HEIGHT);
9830
+ const height = getCssDimension(frameHeight || DEFAULT_EMBED_HEIGHT);
9325
9831
  setAttributes(this.iFrame, restParams);
9326
9832
  this.iFrame.style.width = `${width}`;
9327
9833
  this.iFrame.style.height = `${height}`;
@@ -9355,6 +9861,7 @@
9355
9861
  }).catch((error) => {
9356
9862
  nextInQueue();
9357
9863
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED);
9864
+ this.el.innerHTML = this.embedConfig.loginFailedMessage;
9358
9865
  this.handleError(error);
9359
9866
  });
9360
9867
  });
@@ -9926,6 +10433,7 @@
9926
10433
  exports.PinboardEmbed = PinboardEmbed;
9927
10434
  exports.SearchEmbed = SearchEmbed;
9928
10435
  exports.init = init;
10436
+ exports.logout = logout$1;
9929
10437
  exports.prefetch = prefetch;
9930
10438
 
9931
10439
  Object.defineProperty(exports, '__esModule', { value: true });