@thoughtspot/visual-embed-sdk 1.11.0-auth.10 → 1.11.0-auth.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/auth.d.ts +11 -0
- package/dist/src/embed/base.d.ts +15 -3
- package/dist/src/embed/ts-embed.d.ts +0 -1
- package/dist/src/types.d.ts +5 -0
- package/dist/src/utils/processData.d.ts +1 -1
- package/dist/tsembed.es.js +421 -20
- package/dist/tsembed.js +421 -20
- package/lib/package.json +2 -1
- package/lib/src/auth.d.ts +11 -0
- package/lib/src/auth.js +13 -0
- package/lib/src/auth.js.map +1 -1
- package/lib/src/embed/base.d.ts +15 -3
- package/lib/src/embed/base.js +34 -5
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +20 -2
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +0 -1
- package/lib/src/embed/ts-embed.js +4 -15
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/types.d.ts +5 -0
- package/lib/src/types.js +5 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/processData.d.ts +1 -1
- package/lib/src/utils/processData.js +27 -3
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js +85 -4
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +81 -3
- package/package.json +2 -1
- package/src/auth.ts +13 -0
- package/src/embed/base.spec.ts +22 -3
- package/src/embed/base.ts +47 -9
- package/src/embed/ts-embed.ts +9 -18
- package/src/types.ts +5 -0
- package/src/utils/processData.spec.ts +114 -4
- package/src/utils/processData.ts +41 -4
package/dist/src/auth.d.ts
CHANGED
|
@@ -12,6 +12,17 @@ export declare const EndPoints: {
|
|
|
12
12
|
BASIC_LOGIN: string;
|
|
13
13
|
LOGOUT: string;
|
|
14
14
|
};
|
|
15
|
+
export declare enum AuthFailureType {
|
|
16
|
+
SDK = "SDK",
|
|
17
|
+
NO_COOKIE_ACCESS = "NO_COOKIE_ACCESS",
|
|
18
|
+
EXPIRY = "EXPIRY",
|
|
19
|
+
OTHER = "OTHER"
|
|
20
|
+
}
|
|
21
|
+
export declare enum AuthStatus {
|
|
22
|
+
FAILURE = "FAILURE",
|
|
23
|
+
SUCCESS = "SUCCESS",
|
|
24
|
+
LOGOUT = "LOGOUT"
|
|
25
|
+
}
|
|
15
26
|
/**
|
|
16
27
|
* Return sessionInfo if available else make a loggedIn check to fetch the sessionInfo
|
|
17
28
|
*/
|
package/dist/src/embed/base.d.ts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022
|
|
3
|
+
*
|
|
4
|
+
* Base classes
|
|
5
|
+
*
|
|
6
|
+
* @summary Base classes
|
|
7
|
+
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
8
|
+
*/
|
|
9
|
+
import EventEmitter from 'eventemitter3';
|
|
1
10
|
import { EmbedConfig } from '../types';
|
|
11
|
+
import { AuthFailureType } from '../auth';
|
|
2
12
|
export declare let authPromise: Promise<boolean>;
|
|
13
|
+
export declare const getEmbedConfig: () => EmbedConfig;
|
|
14
|
+
export declare const getAuthPromise: () => Promise<boolean>;
|
|
15
|
+
export declare function notifyAuthSuccess(): void;
|
|
16
|
+
export declare function notifyAuthFailure(failureType: AuthFailureType): void;
|
|
3
17
|
/**
|
|
4
18
|
* Perform authentication on the ThoughtSpot app as applicable.
|
|
5
19
|
*/
|
|
6
20
|
export declare const handleAuth: () => Promise<boolean>;
|
|
7
|
-
export declare const getEmbedConfig: () => EmbedConfig;
|
|
8
|
-
export declare const getAuthPromise: () => Promise<boolean>;
|
|
9
21
|
/**
|
|
10
22
|
* Prefetches static resources from the specified URL. Web browsers can then cache the prefetched resources and serve them from the user's local disk to provide faster access to your app.
|
|
11
23
|
* @param url The URL provided for prefetch
|
|
@@ -19,7 +31,7 @@ export declare const prefetch: (url?: string) => void;
|
|
|
19
31
|
*
|
|
20
32
|
* @returns authPromise Promise which resolves when authentication is complete.
|
|
21
33
|
*/
|
|
22
|
-
export declare const init: (embedConfig: EmbedConfig) =>
|
|
34
|
+
export declare const init: (embedConfig: EmbedConfig) => EventEmitter;
|
|
23
35
|
export declare const logout: () => Promise<boolean>;
|
|
24
36
|
/**
|
|
25
37
|
* Renders functions in a queue, resolves to next function only after the callback next is called
|
|
@@ -143,7 +143,6 @@ export declare class TsEmbed {
|
|
|
143
143
|
*/
|
|
144
144
|
private shouldEncodeUrlQueryParams;
|
|
145
145
|
constructor(domSelector: DOMSelector, viewConfig?: ViewConfig);
|
|
146
|
-
private getLoginFiledMessage;
|
|
147
146
|
/**
|
|
148
147
|
* Gets a reference to the root DOM node where
|
|
149
148
|
* the embedded content will appear.
|
package/dist/src/types.d.ts
CHANGED
|
@@ -337,6 +337,11 @@ export declare enum EmbedEvent {
|
|
|
337
337
|
* The ThoughtSpot auth session has expired.
|
|
338
338
|
*/
|
|
339
339
|
AuthExpire = "ThoughtspotAuthExpired",
|
|
340
|
+
/**
|
|
341
|
+
* ThoughtSpot failed to validate the auth session.
|
|
342
|
+
* @hidden
|
|
343
|
+
*/
|
|
344
|
+
AuthFailure = "ThoughtspotAuthFailure",
|
|
340
345
|
/**
|
|
341
346
|
* The height of the embedded Liveboard or visualization has been computed.
|
|
342
347
|
* @return data - The height of the embedded Liveboard or visualization
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { EmbedEvent } from '../types';
|
|
2
2
|
export declare function processCustomAction(e: any, thoughtSpotHost: string): any;
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function processEventData(type: EmbedEvent, e: any, thoughtSpotHost: string, containerEl: Element): any;
|
package/dist/tsembed.es.js
CHANGED
|
@@ -306,6 +306,11 @@ var EmbedEvent;
|
|
|
306
306
|
* The ThoughtSpot auth session has expired.
|
|
307
307
|
*/
|
|
308
308
|
EmbedEvent["AuthExpire"] = "ThoughtspotAuthExpired";
|
|
309
|
+
/**
|
|
310
|
+
* ThoughtSpot failed to validate the auth session.
|
|
311
|
+
* @hidden
|
|
312
|
+
*/
|
|
313
|
+
EmbedEvent["AuthFailure"] = "ThoughtspotAuthFailure";
|
|
309
314
|
/**
|
|
310
315
|
* The height of the embedded Liveboard or visualization has been computed.
|
|
311
316
|
* @return data - The height of the embedded Liveboard or visualization
|
|
@@ -8686,6 +8691,349 @@ function initMixpanel(sessionInfo) {
|
|
|
8686
8691
|
}
|
|
8687
8692
|
}
|
|
8688
8693
|
|
|
8694
|
+
function createCommonjsModule(fn) {
|
|
8695
|
+
var module = { exports: {} };
|
|
8696
|
+
return fn(module, module.exports), module.exports;
|
|
8697
|
+
}
|
|
8698
|
+
|
|
8699
|
+
var eventemitter3 = createCommonjsModule(function (module) {
|
|
8700
|
+
|
|
8701
|
+
var has = Object.prototype.hasOwnProperty
|
|
8702
|
+
, prefix = '~';
|
|
8703
|
+
|
|
8704
|
+
/**
|
|
8705
|
+
* Constructor to create a storage for our `EE` objects.
|
|
8706
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
8707
|
+
*
|
|
8708
|
+
* @constructor
|
|
8709
|
+
* @private
|
|
8710
|
+
*/
|
|
8711
|
+
function Events() {}
|
|
8712
|
+
|
|
8713
|
+
//
|
|
8714
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
8715
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
8716
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
8717
|
+
// character to make sure that the built-in object properties are not
|
|
8718
|
+
// overridden or used as an attack vector.
|
|
8719
|
+
//
|
|
8720
|
+
if (Object.create) {
|
|
8721
|
+
Events.prototype = Object.create(null);
|
|
8722
|
+
|
|
8723
|
+
//
|
|
8724
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
8725
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
8726
|
+
//
|
|
8727
|
+
if (!new Events().__proto__) prefix = false;
|
|
8728
|
+
}
|
|
8729
|
+
|
|
8730
|
+
/**
|
|
8731
|
+
* Representation of a single event listener.
|
|
8732
|
+
*
|
|
8733
|
+
* @param {Function} fn The listener function.
|
|
8734
|
+
* @param {*} context The context to invoke the listener with.
|
|
8735
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
8736
|
+
* @constructor
|
|
8737
|
+
* @private
|
|
8738
|
+
*/
|
|
8739
|
+
function EE(fn, context, once) {
|
|
8740
|
+
this.fn = fn;
|
|
8741
|
+
this.context = context;
|
|
8742
|
+
this.once = once || false;
|
|
8743
|
+
}
|
|
8744
|
+
|
|
8745
|
+
/**
|
|
8746
|
+
* Add a listener for a given event.
|
|
8747
|
+
*
|
|
8748
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
8749
|
+
* @param {(String|Symbol)} event The event name.
|
|
8750
|
+
* @param {Function} fn The listener function.
|
|
8751
|
+
* @param {*} context The context to invoke the listener with.
|
|
8752
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
8753
|
+
* @returns {EventEmitter}
|
|
8754
|
+
* @private
|
|
8755
|
+
*/
|
|
8756
|
+
function addListener(emitter, event, fn, context, once) {
|
|
8757
|
+
if (typeof fn !== 'function') {
|
|
8758
|
+
throw new TypeError('The listener must be a function');
|
|
8759
|
+
}
|
|
8760
|
+
|
|
8761
|
+
var listener = new EE(fn, context || emitter, once)
|
|
8762
|
+
, evt = prefix ? prefix + event : event;
|
|
8763
|
+
|
|
8764
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
8765
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
8766
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
8767
|
+
|
|
8768
|
+
return emitter;
|
|
8769
|
+
}
|
|
8770
|
+
|
|
8771
|
+
/**
|
|
8772
|
+
* Clear event by name.
|
|
8773
|
+
*
|
|
8774
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
8775
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
8776
|
+
* @private
|
|
8777
|
+
*/
|
|
8778
|
+
function clearEvent(emitter, evt) {
|
|
8779
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
8780
|
+
else delete emitter._events[evt];
|
|
8781
|
+
}
|
|
8782
|
+
|
|
8783
|
+
/**
|
|
8784
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
8785
|
+
* `EventEmitter` interface.
|
|
8786
|
+
*
|
|
8787
|
+
* @constructor
|
|
8788
|
+
* @public
|
|
8789
|
+
*/
|
|
8790
|
+
function EventEmitter() {
|
|
8791
|
+
this._events = new Events();
|
|
8792
|
+
this._eventsCount = 0;
|
|
8793
|
+
}
|
|
8794
|
+
|
|
8795
|
+
/**
|
|
8796
|
+
* Return an array listing the events for which the emitter has registered
|
|
8797
|
+
* listeners.
|
|
8798
|
+
*
|
|
8799
|
+
* @returns {Array}
|
|
8800
|
+
* @public
|
|
8801
|
+
*/
|
|
8802
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
8803
|
+
var names = []
|
|
8804
|
+
, events
|
|
8805
|
+
, name;
|
|
8806
|
+
|
|
8807
|
+
if (this._eventsCount === 0) return names;
|
|
8808
|
+
|
|
8809
|
+
for (name in (events = this._events)) {
|
|
8810
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
8811
|
+
}
|
|
8812
|
+
|
|
8813
|
+
if (Object.getOwnPropertySymbols) {
|
|
8814
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
8815
|
+
}
|
|
8816
|
+
|
|
8817
|
+
return names;
|
|
8818
|
+
};
|
|
8819
|
+
|
|
8820
|
+
/**
|
|
8821
|
+
* Return the listeners registered for a given event.
|
|
8822
|
+
*
|
|
8823
|
+
* @param {(String|Symbol)} event The event name.
|
|
8824
|
+
* @returns {Array} The registered listeners.
|
|
8825
|
+
* @public
|
|
8826
|
+
*/
|
|
8827
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
8828
|
+
var evt = prefix ? prefix + event : event
|
|
8829
|
+
, handlers = this._events[evt];
|
|
8830
|
+
|
|
8831
|
+
if (!handlers) return [];
|
|
8832
|
+
if (handlers.fn) return [handlers.fn];
|
|
8833
|
+
|
|
8834
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
8835
|
+
ee[i] = handlers[i].fn;
|
|
8836
|
+
}
|
|
8837
|
+
|
|
8838
|
+
return ee;
|
|
8839
|
+
};
|
|
8840
|
+
|
|
8841
|
+
/**
|
|
8842
|
+
* Return the number of listeners listening to a given event.
|
|
8843
|
+
*
|
|
8844
|
+
* @param {(String|Symbol)} event The event name.
|
|
8845
|
+
* @returns {Number} The number of listeners.
|
|
8846
|
+
* @public
|
|
8847
|
+
*/
|
|
8848
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
8849
|
+
var evt = prefix ? prefix + event : event
|
|
8850
|
+
, listeners = this._events[evt];
|
|
8851
|
+
|
|
8852
|
+
if (!listeners) return 0;
|
|
8853
|
+
if (listeners.fn) return 1;
|
|
8854
|
+
return listeners.length;
|
|
8855
|
+
};
|
|
8856
|
+
|
|
8857
|
+
/**
|
|
8858
|
+
* Calls each of the listeners registered for a given event.
|
|
8859
|
+
*
|
|
8860
|
+
* @param {(String|Symbol)} event The event name.
|
|
8861
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
8862
|
+
* @public
|
|
8863
|
+
*/
|
|
8864
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
8865
|
+
var evt = prefix ? prefix + event : event;
|
|
8866
|
+
|
|
8867
|
+
if (!this._events[evt]) return false;
|
|
8868
|
+
|
|
8869
|
+
var listeners = this._events[evt]
|
|
8870
|
+
, len = arguments.length
|
|
8871
|
+
, args
|
|
8872
|
+
, i;
|
|
8873
|
+
|
|
8874
|
+
if (listeners.fn) {
|
|
8875
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
8876
|
+
|
|
8877
|
+
switch (len) {
|
|
8878
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
8879
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
8880
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
8881
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
8882
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
8883
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
8884
|
+
}
|
|
8885
|
+
|
|
8886
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
8887
|
+
args[i - 1] = arguments[i];
|
|
8888
|
+
}
|
|
8889
|
+
|
|
8890
|
+
listeners.fn.apply(listeners.context, args);
|
|
8891
|
+
} else {
|
|
8892
|
+
var length = listeners.length
|
|
8893
|
+
, j;
|
|
8894
|
+
|
|
8895
|
+
for (i = 0; i < length; i++) {
|
|
8896
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
8897
|
+
|
|
8898
|
+
switch (len) {
|
|
8899
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
8900
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
8901
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
8902
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
8903
|
+
default:
|
|
8904
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
8905
|
+
args[j - 1] = arguments[j];
|
|
8906
|
+
}
|
|
8907
|
+
|
|
8908
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
8909
|
+
}
|
|
8910
|
+
}
|
|
8911
|
+
}
|
|
8912
|
+
|
|
8913
|
+
return true;
|
|
8914
|
+
};
|
|
8915
|
+
|
|
8916
|
+
/**
|
|
8917
|
+
* Add a listener for a given event.
|
|
8918
|
+
*
|
|
8919
|
+
* @param {(String|Symbol)} event The event name.
|
|
8920
|
+
* @param {Function} fn The listener function.
|
|
8921
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
8922
|
+
* @returns {EventEmitter} `this`.
|
|
8923
|
+
* @public
|
|
8924
|
+
*/
|
|
8925
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
8926
|
+
return addListener(this, event, fn, context, false);
|
|
8927
|
+
};
|
|
8928
|
+
|
|
8929
|
+
/**
|
|
8930
|
+
* Add a one-time listener for a given event.
|
|
8931
|
+
*
|
|
8932
|
+
* @param {(String|Symbol)} event The event name.
|
|
8933
|
+
* @param {Function} fn The listener function.
|
|
8934
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
8935
|
+
* @returns {EventEmitter} `this`.
|
|
8936
|
+
* @public
|
|
8937
|
+
*/
|
|
8938
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
8939
|
+
return addListener(this, event, fn, context, true);
|
|
8940
|
+
};
|
|
8941
|
+
|
|
8942
|
+
/**
|
|
8943
|
+
* Remove the listeners of a given event.
|
|
8944
|
+
*
|
|
8945
|
+
* @param {(String|Symbol)} event The event name.
|
|
8946
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
8947
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
8948
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
8949
|
+
* @returns {EventEmitter} `this`.
|
|
8950
|
+
* @public
|
|
8951
|
+
*/
|
|
8952
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
8953
|
+
var evt = prefix ? prefix + event : event;
|
|
8954
|
+
|
|
8955
|
+
if (!this._events[evt]) return this;
|
|
8956
|
+
if (!fn) {
|
|
8957
|
+
clearEvent(this, evt);
|
|
8958
|
+
return this;
|
|
8959
|
+
}
|
|
8960
|
+
|
|
8961
|
+
var listeners = this._events[evt];
|
|
8962
|
+
|
|
8963
|
+
if (listeners.fn) {
|
|
8964
|
+
if (
|
|
8965
|
+
listeners.fn === fn &&
|
|
8966
|
+
(!once || listeners.once) &&
|
|
8967
|
+
(!context || listeners.context === context)
|
|
8968
|
+
) {
|
|
8969
|
+
clearEvent(this, evt);
|
|
8970
|
+
}
|
|
8971
|
+
} else {
|
|
8972
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
8973
|
+
if (
|
|
8974
|
+
listeners[i].fn !== fn ||
|
|
8975
|
+
(once && !listeners[i].once) ||
|
|
8976
|
+
(context && listeners[i].context !== context)
|
|
8977
|
+
) {
|
|
8978
|
+
events.push(listeners[i]);
|
|
8979
|
+
}
|
|
8980
|
+
}
|
|
8981
|
+
|
|
8982
|
+
//
|
|
8983
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
8984
|
+
//
|
|
8985
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
8986
|
+
else clearEvent(this, evt);
|
|
8987
|
+
}
|
|
8988
|
+
|
|
8989
|
+
return this;
|
|
8990
|
+
};
|
|
8991
|
+
|
|
8992
|
+
/**
|
|
8993
|
+
* Remove all listeners, or those of the specified event.
|
|
8994
|
+
*
|
|
8995
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
8996
|
+
* @returns {EventEmitter} `this`.
|
|
8997
|
+
* @public
|
|
8998
|
+
*/
|
|
8999
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
9000
|
+
var evt;
|
|
9001
|
+
|
|
9002
|
+
if (event) {
|
|
9003
|
+
evt = prefix ? prefix + event : event;
|
|
9004
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
9005
|
+
} else {
|
|
9006
|
+
this._events = new Events();
|
|
9007
|
+
this._eventsCount = 0;
|
|
9008
|
+
}
|
|
9009
|
+
|
|
9010
|
+
return this;
|
|
9011
|
+
};
|
|
9012
|
+
|
|
9013
|
+
//
|
|
9014
|
+
// Alias methods names because people roll like that.
|
|
9015
|
+
//
|
|
9016
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
9017
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
9018
|
+
|
|
9019
|
+
//
|
|
9020
|
+
// Expose the prefix.
|
|
9021
|
+
//
|
|
9022
|
+
EventEmitter.prefixed = prefix;
|
|
9023
|
+
|
|
9024
|
+
//
|
|
9025
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
9026
|
+
//
|
|
9027
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
9028
|
+
|
|
9029
|
+
//
|
|
9030
|
+
// Expose the module.
|
|
9031
|
+
//
|
|
9032
|
+
{
|
|
9033
|
+
module.exports = EventEmitter;
|
|
9034
|
+
}
|
|
9035
|
+
});
|
|
9036
|
+
|
|
8689
9037
|
// eslint-disable-next-line import/no-cycle
|
|
8690
9038
|
function failureLoggedFetch(url, options = {}) {
|
|
8691
9039
|
return fetch(url, options).then(async (r) => {
|
|
@@ -8747,6 +9095,19 @@ const EndPoints = {
|
|
|
8747
9095
|
BASIC_LOGIN: '/callosum/v1/session/login',
|
|
8748
9096
|
LOGOUT: '/callosum/v1/session/logout',
|
|
8749
9097
|
};
|
|
9098
|
+
var AuthFailureType;
|
|
9099
|
+
(function (AuthFailureType) {
|
|
9100
|
+
AuthFailureType["SDK"] = "SDK";
|
|
9101
|
+
AuthFailureType["NO_COOKIE_ACCESS"] = "NO_COOKIE_ACCESS";
|
|
9102
|
+
AuthFailureType["EXPIRY"] = "EXPIRY";
|
|
9103
|
+
AuthFailureType["OTHER"] = "OTHER";
|
|
9104
|
+
})(AuthFailureType || (AuthFailureType = {}));
|
|
9105
|
+
var AuthStatus;
|
|
9106
|
+
(function (AuthStatus) {
|
|
9107
|
+
AuthStatus["FAILURE"] = "FAILURE";
|
|
9108
|
+
AuthStatus["SUCCESS"] = "SUCCESS";
|
|
9109
|
+
AuthStatus["LOGOUT"] = "LOGOUT";
|
|
9110
|
+
})(AuthStatus || (AuthStatus = {}));
|
|
8750
9111
|
/**
|
|
8751
9112
|
* Check if we are logged into the ThoughtSpot cluster
|
|
8752
9113
|
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
@@ -8948,7 +9309,28 @@ const authenticate = async (embedConfig) => {
|
|
|
8948
9309
|
|
|
8949
9310
|
/* eslint-disable import/no-mutable-exports */
|
|
8950
9311
|
let config = {};
|
|
9312
|
+
const CONFIG_DEFAULTS = {
|
|
9313
|
+
loginFailedMessage: 'Login failed',
|
|
9314
|
+
authType: AuthType.None,
|
|
9315
|
+
};
|
|
8951
9316
|
let authPromise;
|
|
9317
|
+
const getEmbedConfig = () => config;
|
|
9318
|
+
const getAuthPromise = () => authPromise;
|
|
9319
|
+
let authEE;
|
|
9320
|
+
function notifyAuthSuccess() {
|
|
9321
|
+
if (!authEE) {
|
|
9322
|
+
console.error('SDK not initialized');
|
|
9323
|
+
return;
|
|
9324
|
+
}
|
|
9325
|
+
authEE.emit(AuthStatus.SUCCESS);
|
|
9326
|
+
}
|
|
9327
|
+
function notifyAuthFailure(failureType) {
|
|
9328
|
+
if (!authEE) {
|
|
9329
|
+
console.error('SDK not initialized');
|
|
9330
|
+
return;
|
|
9331
|
+
}
|
|
9332
|
+
authEE.emit(AuthStatus.FAILURE, failureType);
|
|
9333
|
+
}
|
|
8952
9334
|
/**
|
|
8953
9335
|
* Perform authentication on the ThoughtSpot app as applicable.
|
|
8954
9336
|
*/
|
|
@@ -8958,10 +9340,15 @@ const handleAuth = () => {
|
|
|
8958
9340
|
thoughtSpotHost: getThoughtSpotHost(config),
|
|
8959
9341
|
};
|
|
8960
9342
|
authPromise = authenticate(authConfig);
|
|
9343
|
+
authPromise.then((isLoggedIn) => {
|
|
9344
|
+
if (!isLoggedIn) {
|
|
9345
|
+
notifyAuthFailure(AuthFailureType.SDK);
|
|
9346
|
+
}
|
|
9347
|
+
}, () => {
|
|
9348
|
+
notifyAuthFailure(AuthFailureType.SDK);
|
|
9349
|
+
});
|
|
8961
9350
|
return authPromise;
|
|
8962
9351
|
};
|
|
8963
|
-
const getEmbedConfig = () => config;
|
|
8964
|
-
const getAuthPromise = () => authPromise;
|
|
8965
9352
|
/**
|
|
8966
9353
|
* 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.
|
|
8967
9354
|
* @param url The URL provided for prefetch
|
|
@@ -8990,7 +9377,8 @@ const prefetch = (url) => {
|
|
|
8990
9377
|
* @returns authPromise Promise which resolves when authentication is complete.
|
|
8991
9378
|
*/
|
|
8992
9379
|
const init = (embedConfig) => {
|
|
8993
|
-
config = embedConfig;
|
|
9380
|
+
config = { ...CONFIG_DEFAULTS, ...embedConfig };
|
|
9381
|
+
authEE = new eventemitter3();
|
|
8994
9382
|
handleAuth();
|
|
8995
9383
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
|
|
8996
9384
|
authType: config.authType,
|
|
@@ -8999,7 +9387,7 @@ const init = (embedConfig) => {
|
|
|
8999
9387
|
if (config.callPrefetch) {
|
|
9000
9388
|
prefetch(config.thoughtSpotHost);
|
|
9001
9389
|
}
|
|
9002
|
-
return
|
|
9390
|
+
return authEE;
|
|
9003
9391
|
};
|
|
9004
9392
|
const logout$1 = () => {
|
|
9005
9393
|
return logout(config);
|
|
@@ -9088,6 +9476,7 @@ function processAuthInit(e) {
|
|
|
9088
9476
|
var _a, _b;
|
|
9089
9477
|
// Store user session details sent by app.
|
|
9090
9478
|
initSession(e.data);
|
|
9479
|
+
notifyAuthSuccess();
|
|
9091
9480
|
// Expose only allowed details (eg: userGUID) back to SDK users.
|
|
9092
9481
|
return {
|
|
9093
9482
|
...e,
|
|
@@ -9101,9 +9490,28 @@ function processAuthExpire(e) {
|
|
|
9101
9490
|
if (autoLogin) {
|
|
9102
9491
|
handleAuth();
|
|
9103
9492
|
}
|
|
9493
|
+
notifyAuthFailure(AuthFailureType.EXPIRY);
|
|
9104
9494
|
return e;
|
|
9105
9495
|
}
|
|
9106
|
-
function
|
|
9496
|
+
function processNoCookieAccess(e, containerEl) {
|
|
9497
|
+
const { loginFailedMessage, suppressNoCookieAccessAlert, } = getEmbedConfig();
|
|
9498
|
+
if (!suppressNoCookieAccessAlert) {
|
|
9499
|
+
// eslint-disable-next-line no-alert
|
|
9500
|
+
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.');
|
|
9501
|
+
}
|
|
9502
|
+
// eslint-disable-next-line no-param-reassign
|
|
9503
|
+
containerEl.innerHTML = loginFailedMessage;
|
|
9504
|
+
notifyAuthFailure(AuthFailureType.NO_COOKIE_ACCESS);
|
|
9505
|
+
return e;
|
|
9506
|
+
}
|
|
9507
|
+
function processAuthFailure(e, containerEl) {
|
|
9508
|
+
const { loginFailedMessage } = getEmbedConfig();
|
|
9509
|
+
// eslint-disable-next-line no-param-reassign
|
|
9510
|
+
containerEl.innerHTML = loginFailedMessage;
|
|
9511
|
+
notifyAuthFailure(AuthFailureType.OTHER);
|
|
9512
|
+
return e;
|
|
9513
|
+
}
|
|
9514
|
+
function processEventData(type, e, thoughtSpotHost, containerEl) {
|
|
9107
9515
|
switch (type) {
|
|
9108
9516
|
case EmbedEvent.CustomAction:
|
|
9109
9517
|
return processCustomAction(e, thoughtSpotHost);
|
|
@@ -9111,6 +9519,10 @@ function getProcessData(type, e, thoughtSpotHost) {
|
|
|
9111
9519
|
return processAuthInit(e);
|
|
9112
9520
|
case EmbedEvent.AuthExpire:
|
|
9113
9521
|
return processAuthExpire(e);
|
|
9522
|
+
case EmbedEvent.NoCookieAccess:
|
|
9523
|
+
return processNoCookieAccess(e, containerEl);
|
|
9524
|
+
case EmbedEvent.AuthFailure:
|
|
9525
|
+
return processAuthFailure(e, containerEl);
|
|
9114
9526
|
}
|
|
9115
9527
|
return e;
|
|
9116
9528
|
}
|
|
@@ -9139,7 +9551,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
|
|
|
9139
9551
|
}
|
|
9140
9552
|
}
|
|
9141
9553
|
|
|
9142
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.11.0-auth.
|
|
9554
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.11.0-auth.11";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};
|
|
9143
9555
|
|
|
9144
9556
|
/**
|
|
9145
9557
|
* Copyright (c) 2022
|
|
@@ -9186,17 +9598,6 @@ class TsEmbed {
|
|
|
9186
9598
|
this.isError = false;
|
|
9187
9599
|
this.viewConfig = viewConfig;
|
|
9188
9600
|
this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
|
|
9189
|
-
this.on(EmbedEvent.NoCookieAccess, () => {
|
|
9190
|
-
if (!this.embedConfig.suppressNoCookieAccessAlert) {
|
|
9191
|
-
// eslint-disable-next-line no-alert
|
|
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';
|
|
9200
9601
|
}
|
|
9201
9602
|
/**
|
|
9202
9603
|
* Gets a reference to the root DOM node where
|
|
@@ -9273,7 +9674,7 @@ class TsEmbed {
|
|
|
9273
9674
|
const eventPort = this.getEventPort(event);
|
|
9274
9675
|
const eventData = this.formatEventData(event, eventType);
|
|
9275
9676
|
if (event.source === this.iFrame.contentWindow) {
|
|
9276
|
-
this.executeCallbacks(eventType,
|
|
9677
|
+
this.executeCallbacks(eventType, processEventData(eventType, eventData, this.thoughtSpotHost, this.el), eventPort);
|
|
9277
9678
|
}
|
|
9278
9679
|
});
|
|
9279
9680
|
}
|
|
@@ -9394,7 +9795,7 @@ class TsEmbed {
|
|
|
9394
9795
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
9395
9796
|
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
|
|
9396
9797
|
if (!isLoggedIn) {
|
|
9397
|
-
this.el.innerHTML = this.
|
|
9798
|
+
this.el.innerHTML = this.embedConfig.loginFailedMessage;
|
|
9398
9799
|
return;
|
|
9399
9800
|
}
|
|
9400
9801
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
|
|
@@ -9446,7 +9847,7 @@ class TsEmbed {
|
|
|
9446
9847
|
}).catch((error) => {
|
|
9447
9848
|
nextInQueue();
|
|
9448
9849
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED);
|
|
9449
|
-
this.el.innerHTML = this.
|
|
9850
|
+
this.el.innerHTML = this.embedConfig.loginFailedMessage;
|
|
9450
9851
|
this.handleError(error);
|
|
9451
9852
|
});
|
|
9452
9853
|
});
|