@thoughtspot/visual-embed-sdk 1.20.2 → 1.20.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.
- package/README.md +1 -1
- package/cjs/package.json +171 -0
- package/cjs/src/auth.d.ts +183 -0
- package/cjs/src/auth.d.ts.map +1 -0
- package/cjs/src/auth.js +457 -0
- package/cjs/src/auth.js.map +1 -0
- package/cjs/src/auth.spec.d.ts +13 -0
- package/cjs/src/auth.spec.d.ts.map +1 -0
- package/cjs/src/auth.spec.js +397 -0
- package/cjs/src/auth.spec.js.map +1 -0
- package/cjs/src/config.d.ts +22 -0
- package/cjs/src/config.d.ts.map +1 -0
- package/cjs/src/config.js +70 -0
- package/cjs/src/config.js.map +1 -0
- package/cjs/src/config.spec.d.ts +5 -0
- package/cjs/src/config.spec.d.ts.map +1 -0
- package/cjs/src/config.spec.js +65 -0
- package/cjs/src/config.spec.js.map +1 -0
- package/cjs/src/embed/app.d.ts +168 -0
- package/cjs/src/embed/app.d.ts.map +1 -0
- package/cjs/src/embed/app.js +215 -0
- package/cjs/src/embed/app.js.map +1 -0
- package/cjs/src/embed/app.spec.d.ts +2 -0
- package/cjs/src/embed/app.spec.d.ts.map +1 -0
- package/cjs/src/embed/app.spec.js +239 -0
- package/cjs/src/embed/app.spec.js.map +1 -0
- package/cjs/src/embed/base.d.ts +79 -0
- package/cjs/src/embed/base.d.ts.map +1 -0
- package/cjs/src/embed/base.js +229 -0
- package/cjs/src/embed/base.js.map +1 -0
- package/cjs/src/embed/base.spec.d.ts +2 -0
- package/cjs/src/embed/base.spec.d.ts.map +1 -0
- package/cjs/src/embed/base.spec.js +198 -0
- package/cjs/src/embed/base.spec.js.map +1 -0
- package/cjs/src/embed/embed.spec.d.ts +2 -0
- package/cjs/src/embed/embed.spec.d.ts.map +1 -0
- package/cjs/src/embed/embed.spec.js +74 -0
- package/cjs/src/embed/embed.spec.js.map +1 -0
- package/cjs/src/embed/events.spec.d.ts +2 -0
- package/cjs/src/embed/events.spec.d.ts.map +1 -0
- package/cjs/src/embed/events.spec.js +238 -0
- package/cjs/src/embed/events.spec.js.map +1 -0
- package/cjs/src/embed/liveboard.d.ts +150 -0
- package/cjs/src/embed/liveboard.d.ts.map +1 -0
- package/cjs/src/embed/liveboard.js +168 -0
- package/cjs/src/embed/liveboard.js.map +1 -0
- package/cjs/src/embed/liveboard.spec.d.ts +2 -0
- package/cjs/src/embed/liveboard.spec.d.ts.map +1 -0
- package/cjs/src/embed/liveboard.spec.js +229 -0
- package/cjs/src/embed/liveboard.spec.js.map +1 -0
- package/cjs/src/embed/pinboard.spec.d.ts +2 -0
- package/cjs/src/embed/pinboard.spec.d.ts.map +1 -0
- package/cjs/src/embed/pinboard.spec.js +148 -0
- package/cjs/src/embed/pinboard.spec.js.map +1 -0
- package/cjs/src/embed/search-bar.d.ts +50 -0
- package/cjs/src/embed/search-bar.d.ts.map +1 -0
- package/cjs/src/embed/search-bar.js +63 -0
- package/cjs/src/embed/search-bar.js.map +1 -0
- package/cjs/src/embed/search.d.ts +129 -0
- package/cjs/src/embed/search.d.ts.map +1 -0
- package/cjs/src/embed/search.js +121 -0
- package/cjs/src/embed/search.js.map +1 -0
- package/cjs/src/embed/search.spec.d.ts +2 -0
- package/cjs/src/embed/search.spec.d.ts.map +1 -0
- package/cjs/src/embed/search.spec.js +238 -0
- package/cjs/src/embed/search.spec.js.map +1 -0
- package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts +2 -0
- package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts.map +1 -0
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js +103 -0
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js.map +1 -0
- package/cjs/src/embed/ts-embed.d.ts +323 -0
- package/cjs/src/embed/ts-embed.d.ts.map +1 -0
- package/cjs/src/embed/ts-embed.js +719 -0
- package/cjs/src/embed/ts-embed.js.map +1 -0
- package/cjs/src/embed/ts-embed.spec.d.ts +2 -0
- package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -0
- package/cjs/src/embed/ts-embed.spec.js +771 -0
- package/cjs/src/embed/ts-embed.spec.js.map +1 -0
- package/cjs/src/errors.d.ts +7 -0
- package/cjs/src/errors.d.ts.map +1 -0
- package/cjs/src/errors.js +10 -0
- package/cjs/src/errors.js.map +1 -0
- package/cjs/src/index.d.ts +18 -0
- package/cjs/src/index.d.ts.map +1 -0
- package/cjs/src/index.js +42 -0
- package/cjs/src/index.js.map +1 -0
- package/cjs/src/mixpanel-service.d.ts +29 -0
- package/cjs/src/mixpanel-service.d.ts.map +1 -0
- package/cjs/src/mixpanel-service.js +76 -0
- package/cjs/src/mixpanel-service.js.map +1 -0
- package/cjs/src/mixpanel-service.spec.d.ts +2 -0
- package/cjs/src/mixpanel-service.spec.d.ts.map +1 -0
- package/cjs/src/mixpanel-service.spec.js +63 -0
- package/cjs/src/mixpanel-service.spec.js.map +1 -0
- package/cjs/src/react/all-types-export.d.ts +3 -0
- package/cjs/src/react/all-types-export.d.ts.map +1 -0
- package/cjs/src/react/all-types-export.js +29 -0
- package/cjs/src/react/all-types-export.js.map +1 -0
- package/cjs/src/react/all-types-export.spec.d.ts +2 -0
- package/cjs/src/react/all-types-export.spec.d.ts.map +1 -0
- package/cjs/src/react/all-types-export.spec.js +13 -0
- package/cjs/src/react/all-types-export.spec.js.map +1 -0
- package/cjs/src/react/index.d.ts +95 -0
- package/cjs/src/react/index.d.ts.map +1 -0
- package/cjs/src/react/index.js +121 -0
- package/cjs/src/react/index.js.map +1 -0
- package/cjs/src/react/index.spec.d.ts +3 -0
- package/cjs/src/react/index.spec.d.ts.map +1 -0
- package/cjs/src/react/index.spec.js +138 -0
- package/cjs/src/react/index.spec.js.map +1 -0
- package/cjs/src/react/util.d.ts +19 -0
- package/cjs/src/react/util.d.ts.map +1 -0
- package/cjs/src/react/util.js +25 -0
- package/cjs/src/react/util.js.map +1 -0
- package/cjs/src/test/test-utils.d.ts +48 -0
- package/cjs/src/test/test-utils.d.ts.map +1 -0
- package/cjs/src/test/test-utils.js +108 -0
- package/cjs/src/test/test-utils.js.map +1 -0
- package/cjs/src/types.d.ts +2020 -0
- package/cjs/src/types.d.ts.map +1 -0
- package/cjs/src/types.js +1543 -0
- package/cjs/src/types.js.map +1 -0
- package/cjs/src/utils/answerService.d.ts +10 -0
- package/cjs/src/utils/answerService.d.ts.map +1 -0
- package/cjs/src/utils/answerService.js +61 -0
- package/cjs/src/utils/answerService.js.map +1 -0
- package/cjs/src/utils/answerService.spec.d.ts +2 -0
- package/cjs/src/utils/answerService.spec.d.ts.map +1 -0
- package/cjs/src/utils/answerService.spec.js +31 -0
- package/cjs/src/utils/answerService.spec.js.map +1 -0
- package/cjs/src/utils/authService.d.ts +37 -0
- package/cjs/src/utils/authService.d.ts.map +1 -0
- package/cjs/src/utils/authService.js +106 -0
- package/cjs/src/utils/authService.js.map +1 -0
- package/cjs/src/utils/authService.spec.d.ts +2 -0
- package/cjs/src/utils/authService.spec.d.ts.map +1 -0
- package/cjs/src/utils/authService.spec.js +72 -0
- package/cjs/src/utils/authService.spec.js.map +1 -0
- package/cjs/src/utils/processData.d.ts +16 -0
- package/cjs/src/utils/processData.d.ts.map +1 -0
- package/cjs/src/utils/processData.js +110 -0
- package/cjs/src/utils/processData.js.map +1 -0
- package/cjs/src/utils/processData.spec.d.ts +2 -0
- package/cjs/src/utils/processData.spec.d.ts.map +1 -0
- package/cjs/src/utils/processData.spec.js +142 -0
- package/cjs/src/utils/processData.spec.js.map +1 -0
- package/cjs/src/utils/processTrigger.d.ts +10 -0
- package/cjs/src/utils/processTrigger.d.ts.map +1 -0
- package/cjs/src/utils/processTrigger.js +63 -0
- package/cjs/src/utils/processTrigger.js.map +1 -0
- package/cjs/src/utils/processTrigger.spec.d.ts +2 -0
- package/cjs/src/utils/processTrigger.spec.d.ts.map +1 -0
- package/cjs/src/utils/processTrigger.spec.js +58 -0
- package/cjs/src/utils/processTrigger.spec.js.map +1 -0
- package/cjs/src/utils.d.ts +68 -0
- package/cjs/src/utils.d.ts.map +1 -0
- package/cjs/src/utils.js +196 -0
- package/cjs/src/utils.js.map +1 -0
- package/cjs/src/utils.spec.d.ts +5 -0
- package/cjs/src/utils.spec.d.ts.map +1 -0
- package/cjs/src/utils.spec.js +98 -0
- package/cjs/src/utils.spec.js.map +1 -0
- package/dist/src/auth.d.ts +54 -5
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/auth.spec.d.ts +3 -0
- package/dist/src/auth.spec.d.ts.map +1 -1
- package/dist/src/config.d.ts +1 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +35 -6
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +20 -9
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +17 -5
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/search-bar.d.ts +3 -0
- package/dist/src/embed/search-bar.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +9 -1
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +65 -7
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/mixpanel-service.d.ts +8 -0
- package/dist/src/mixpanel-service.d.ts.map +1 -1
- package/dist/src/react/all-types-export.d.ts +3 -0
- package/dist/src/react/all-types-export.d.ts.map +1 -0
- package/dist/src/react/all-types-export.spec.d.ts +2 -0
- package/dist/src/react/all-types-export.spec.d.ts.map +1 -0
- package/dist/src/react/index.d.ts +72 -0
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/react/util.d.ts +4 -0
- package/dist/src/react/util.d.ts.map +1 -1
- package/dist/src/test/test-utils.d.ts +11 -2
- package/dist/src/test/test-utils.d.ts.map +1 -1
- package/dist/src/types.d.ts +499 -96
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/answerService.d.ts +7 -0
- package/dist/src/utils/answerService.d.ts.map +1 -1
- package/dist/src/utils/authService.d.ts +30 -0
- package/dist/src/utils/authService.d.ts.map +1 -1
- package/dist/src/utils/processData.d.ts +12 -0
- package/dist/src/utils/processData.d.ts.map +1 -1
- package/dist/src/utils/processTrigger.d.ts +7 -0
- package/dist/src/utils/processTrigger.d.ts.map +1 -1
- package/dist/src/utils.d.ts +12 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +28024 -0
- package/dist/tsembed-react.js +27966 -0
- package/dist/tsembed.es.js +18114 -305
- package/dist/tsembed.js +18088 -327
- package/dist/visual-embed-sdk-react-full.d.ts +3092 -0
- package/dist/visual-embed-sdk-react.d.ts +2781 -0
- package/dist/visual-embed-sdk.d.ts +2944 -0
- package/lib/package.json +15 -14
- package/lib/src/auth.d.ts +54 -5
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +91 -31
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.d.ts +3 -0
- package/lib/src/auth.spec.d.ts.map +1 -1
- package/lib/src/auth.spec.js +37 -6
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/config.d.ts +1 -0
- package/lib/src/config.d.ts.map +1 -1
- package/lib/src/config.js +5 -3
- package/lib/src/config.js.map +1 -1
- package/lib/src/config.spec.js.map +1 -1
- package/lib/src/embed/app.d.ts +35 -6
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +55 -16
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +41 -12
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +20 -9
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +31 -15
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +1 -1
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +17 -5
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +49 -37
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +37 -30
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/pinboard.spec.js +14 -26
- package/lib/src/embed/pinboard.spec.js.map +1 -1
- package/lib/src/embed/search-bar.d.ts +3 -0
- package/lib/src/embed/search-bar.d.ts.map +1 -1
- package/lib/src/embed/search-bar.js +5 -6
- package/lib/src/embed/search-bar.js.map +1 -1
- package/lib/src/embed/search.d.ts +9 -1
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +18 -14
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +16 -19
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/searchEmbed-basic-auth.spec.js +4 -0
- package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +65 -7
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +154 -77
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +46 -24
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/errors.d.ts.map +1 -1
- package/lib/src/errors.js.map +1 -1
- package/lib/src/index.d.ts +2 -2
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +4 -4
- package/lib/src/index.js.map +1 -1
- package/lib/src/mixpanel-service.d.ts +8 -0
- package/lib/src/mixpanel-service.d.ts.map +1 -1
- package/lib/src/mixpanel-service.js +13 -1
- package/lib/src/mixpanel-service.js.map +1 -1
- package/lib/src/mixpanel-service.spec.js.map +1 -1
- package/lib/src/react/all-types-export.d.ts +3 -0
- package/lib/src/react/all-types-export.d.ts.map +1 -0
- package/lib/src/react/all-types-export.js +5 -0
- package/lib/src/react/all-types-export.js.map +1 -0
- package/lib/src/react/all-types-export.spec.d.ts +2 -0
- package/lib/src/react/all-types-export.spec.d.ts.map +1 -0
- package/lib/src/react/all-types-export.spec.js +10 -0
- package/lib/src/react/all-types-export.spec.js.map +1 -0
- package/lib/src/react/index.d.ts +72 -0
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +79 -7
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +27 -6
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/react/util.d.ts +4 -0
- package/lib/src/react/util.d.ts.map +1 -1
- package/lib/src/react/util.js +4 -0
- package/lib/src/react/util.js.map +1 -1
- package/lib/src/test/test-utils.d.ts +11 -2
- package/lib/src/test/test-utils.d.ts.map +1 -1
- package/lib/src/test/test-utils.js +36 -25
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/types.d.ts +499 -96
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +374 -68
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/answerService.d.ts +7 -0
- package/lib/src/utils/answerService.d.ts.map +1 -1
- package/lib/src/utils/answerService.js +7 -0
- package/lib/src/utils/answerService.js.map +1 -1
- package/lib/src/utils/answerService.spec.js.map +1 -1
- package/lib/src/utils/authService.d.ts +30 -0
- package/lib/src/utils/authService.d.ts.map +1 -1
- package/lib/src/utils/authService.js +39 -2
- package/lib/src/utils/authService.js.map +1 -1
- package/lib/src/utils/authService.spec.js.map +1 -1
- package/lib/src/utils/processData.d.ts +12 -0
- package/lib/src/utils/processData.d.ts.map +1 -1
- package/lib/src/utils/processData.js +33 -5
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils/processTrigger.d.ts +7 -0
- package/lib/src/utils/processTrigger.d.ts.map +1 -1
- package/lib/src/utils/processTrigger.js +17 -3
- package/lib/src/utils/processTrigger.js.map +1 -1
- package/lib/src/utils/processTrigger.spec.js.map +1 -1
- package/lib/src/utils.d.ts +12 -0
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +24 -19
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/package.json +15 -14
- package/src/auth.spec.ts +83 -133
- package/src/auth.ts +148 -115
- package/src/config.spec.ts +2 -4
- package/src/config.ts +5 -3
- package/src/embed/app.spec.ts +57 -14
- package/src/embed/app.ts +91 -36
- package/src/embed/base.spec.ts +3 -9
- package/src/embed/base.ts +51 -53
- package/src/embed/embed.spec.ts +5 -6
- package/src/embed/liveboard.spec.ts +56 -37
- package/src/embed/liveboard.ts +66 -64
- package/src/embed/pinboard.spec.ts +26 -29
- package/src/embed/search-bar.tsx +10 -8
- package/src/embed/search.spec.ts +31 -21
- package/src/embed/search.ts +26 -20
- package/src/embed/searchEmbed-basic-auth.spec.ts +22 -28
- package/src/embed/ts-embed.spec.ts +99 -144
- package/src/embed/ts-embed.ts +188 -162
- package/src/errors.ts +3 -6
- package/src/index.ts +6 -10
- package/src/mixpanel-service.spec.ts +1 -3
- package/src/mixpanel-service.ts +13 -1
- package/src/react/index.spec.tsx +66 -13
- package/src/react/index.tsx +111 -62
- package/src/react/util.ts +8 -4
- package/src/test/test-utils.ts +43 -39
- package/src/types.ts +498 -98
- package/src/utils/answerService.spec.ts +3 -5
- package/src/utils/answerService.ts +21 -17
- package/src/utils/authService.spec.ts +26 -41
- package/src/utils/authService.ts +47 -21
- package/src/utils/processData.spec.ts +26 -59
- package/src/utils/processData.ts +36 -14
- package/src/utils/processTrigger.spec.ts +1 -6
- package/src/utils/processTrigger.ts +18 -9
- package/src/utils.spec.ts +8 -12
- package/src/utils.ts +25 -26
- package/lib/src/visual-embed-sdk.d.ts +0 -2419
package/src/auth.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
|
+
import _ from 'lodash';
|
|
2
3
|
import { initMixpanel } from './mixpanel-service';
|
|
3
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
AuthType, DOMSelector, EmbedConfig, EmbedEvent, Param,
|
|
6
|
+
} from './types';
|
|
4
7
|
import { getDOMNode, getRedirectUrl } from './utils';
|
|
5
8
|
// eslint-disable-next-line import/no-cycle
|
|
6
9
|
import {
|
|
@@ -18,30 +21,35 @@ export let loggedInStatus = false;
|
|
|
18
21
|
export let samlAuthWindow: Window = null;
|
|
19
22
|
// eslint-disable-next-line import/no-mutable-exports
|
|
20
23
|
export let samlCompletionPromise: Promise<void> = null;
|
|
21
|
-
let sessionInfo:
|
|
22
|
-
let sessionInfoResolver: (value:
|
|
23
|
-
const sessionInfoPromise = new Promise((resolve) => {
|
|
24
|
+
let sessionInfo: sessionInfoInterface = null;
|
|
25
|
+
let sessionInfoResolver: (value: sessionInfoInterface) => void = null;
|
|
26
|
+
const sessionInfoPromise = new Promise((resolve:(value: sessionInfoInterface) => void) => {
|
|
24
27
|
sessionInfoResolver = resolve;
|
|
25
28
|
});
|
|
26
29
|
let releaseVersion = '';
|
|
27
30
|
|
|
28
|
-
export const SSO_REDIRECTION_MARKER_GUID =
|
|
29
|
-
'5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
|
|
31
|
+
export const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
|
|
30
32
|
|
|
31
33
|
export const EndPoints = {
|
|
32
34
|
AUTH_VERIFICATION: '/callosum/v1/session/info',
|
|
33
|
-
SAML_LOGIN_TEMPLATE: (targetUrl: string) =>
|
|
34
|
-
|
|
35
|
-
OIDC_LOGIN_TEMPLATE: (targetUrl: string) =>
|
|
36
|
-
`/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
|
|
35
|
+
SAML_LOGIN_TEMPLATE: (targetUrl: string) => `/callosum/v1/saml/login?targetURLPath=${targetUrl}`,
|
|
36
|
+
OIDC_LOGIN_TEMPLATE: (targetUrl: string) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
|
|
37
37
|
TOKEN_LOGIN: '/callosum/v1/session/login/token',
|
|
38
38
|
BASIC_LOGIN: '/callosum/v1/session/login',
|
|
39
39
|
LOGOUT: '/callosum/v1/session/logout',
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
interface sessionInfoInterface {
|
|
43
|
+
userGUID: any;
|
|
44
|
+
isPublicUser: any;
|
|
45
|
+
mixpanelToken: any;
|
|
46
|
+
[key:string]:any;
|
|
47
|
+
}
|
|
48
|
+
|
|
42
49
|
/**
|
|
43
50
|
* Enum for auth failure types. This is the parameter passed to the listner
|
|
44
51
|
* of {@link AuthStatus.FAILURE}.
|
|
52
|
+
*
|
|
45
53
|
* @group Authentication / Init
|
|
46
54
|
*/
|
|
47
55
|
export enum AuthFailureType {
|
|
@@ -53,6 +61,7 @@ export enum AuthFailureType {
|
|
|
53
61
|
|
|
54
62
|
/**
|
|
55
63
|
* Enum for auth status emitted by the emitter returned from {@link init}.
|
|
64
|
+
*
|
|
56
65
|
* @group Authentication / Init
|
|
57
66
|
*/
|
|
58
67
|
export enum AuthStatus {
|
|
@@ -76,6 +85,7 @@ export enum AuthStatus {
|
|
|
76
85
|
* Emitted when inPopup: true in the SAMLRedirect flow.
|
|
77
86
|
* And, we are waiting for popup to be triggered either programatically
|
|
78
87
|
* or by the trigger button.
|
|
88
|
+
*
|
|
79
89
|
* @version SDK: 1.19.0
|
|
80
90
|
*/
|
|
81
91
|
WAITING_FOR_POPUP = 'WAITING_FOR_POPUP',
|
|
@@ -83,28 +93,37 @@ export enum AuthStatus {
|
|
|
83
93
|
|
|
84
94
|
/**
|
|
85
95
|
* Event emitter returned from {@link init}.
|
|
96
|
+
*
|
|
86
97
|
* @group Authentication / Init
|
|
87
98
|
*/
|
|
88
99
|
export interface AuthEventEmitter {
|
|
89
100
|
/**
|
|
90
|
-
*
|
|
101
|
+
* Register a listener on Auth failure.
|
|
102
|
+
*
|
|
103
|
+
* @param event
|
|
104
|
+
* @param listener
|
|
105
|
+
*/
|
|
106
|
+
on(event: AuthStatus.FAILURE, listener: (failureType: AuthFailureType) => void): this;
|
|
107
|
+
/**
|
|
108
|
+
* Register a listener on Auth SDK success.
|
|
109
|
+
*
|
|
91
110
|
* @param event
|
|
92
111
|
* @param listener
|
|
93
112
|
*/
|
|
94
113
|
on(
|
|
95
|
-
event: AuthStatus.
|
|
96
|
-
listener: (failureType: AuthFailureType) => void,
|
|
97
|
-
): this;
|
|
98
|
-
on(
|
|
99
|
-
event:
|
|
100
|
-
| AuthStatus.SDK_SUCCESS
|
|
101
|
-
| AuthStatus.LOGOUT
|
|
102
|
-
| AuthStatus.WAITING_FOR_POPUP,
|
|
114
|
+
event: AuthStatus.SDK_SUCCESS | AuthStatus.LOGOUT | AuthStatus.WAITING_FOR_POPUP,
|
|
103
115
|
listener: () => void,
|
|
104
116
|
): this;
|
|
105
117
|
on(event: AuthStatus.SUCCESS, listener: (sessionInfo: any) => void): this;
|
|
118
|
+
once(event: AuthStatus.FAILURE, listener: (failureType: AuthFailureType) => void): this;
|
|
119
|
+
once(
|
|
120
|
+
event: AuthStatus.SDK_SUCCESS | AuthStatus.LOGOUT | AuthStatus.WAITING_FOR_POPUP,
|
|
121
|
+
listener: () => void,
|
|
122
|
+
): this;
|
|
123
|
+
once(event: AuthStatus.SUCCESS, listener: (sessionInfo: any) => void): this;
|
|
106
124
|
/**
|
|
107
125
|
* Trigger an event on the emitter returned from init.
|
|
126
|
+
*
|
|
108
127
|
* @param {@link AuthEvent}
|
|
109
128
|
*/
|
|
110
129
|
emit(event: AuthEvent): void;
|
|
@@ -112,6 +131,7 @@ export interface AuthEventEmitter {
|
|
|
112
131
|
|
|
113
132
|
/**
|
|
114
133
|
* Events which can be triggered on the emitter returned from {@link init}.
|
|
134
|
+
*
|
|
115
135
|
* @group Authentication / Init
|
|
116
136
|
*/
|
|
117
137
|
export enum AuthEvent {
|
|
@@ -124,16 +144,24 @@ export enum AuthEvent {
|
|
|
124
144
|
|
|
125
145
|
let authEE: EventEmitter<AuthStatus | AuthEvent>;
|
|
126
146
|
|
|
147
|
+
/**
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
127
150
|
export function getAuthEE(): EventEmitter<AuthStatus | AuthEvent> {
|
|
128
151
|
return authEE;
|
|
129
152
|
}
|
|
130
153
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
154
|
+
/**
|
|
155
|
+
*
|
|
156
|
+
* @param eventEmitter
|
|
157
|
+
*/
|
|
158
|
+
export function setAuthEE(eventEmitter: EventEmitter<AuthStatus | AuthEvent>): void {
|
|
134
159
|
authEE = eventEmitter;
|
|
135
160
|
}
|
|
136
161
|
|
|
162
|
+
/**
|
|
163
|
+
*
|
|
164
|
+
*/
|
|
137
165
|
export function notifyAuthSDKSuccess(): void {
|
|
138
166
|
if (!authEE) {
|
|
139
167
|
console.error('SDK not initialized');
|
|
@@ -142,6 +170,9 @@ export function notifyAuthSDKSuccess(): void {
|
|
|
142
170
|
authEE.emit(AuthStatus.SDK_SUCCESS);
|
|
143
171
|
}
|
|
144
172
|
|
|
173
|
+
/**
|
|
174
|
+
*
|
|
175
|
+
*/
|
|
145
176
|
export function notifyAuthSuccess(): void {
|
|
146
177
|
if (!authEE) {
|
|
147
178
|
console.error('SDK not initialized');
|
|
@@ -150,6 +181,10 @@ export function notifyAuthSuccess(): void {
|
|
|
150
181
|
authEE.emit(AuthStatus.SUCCESS, sessionInfo);
|
|
151
182
|
}
|
|
152
183
|
|
|
184
|
+
/**
|
|
185
|
+
*
|
|
186
|
+
* @param failureType
|
|
187
|
+
*/
|
|
153
188
|
export function notifyAuthFailure(failureType: AuthFailureType): void {
|
|
154
189
|
if (!authEE) {
|
|
155
190
|
console.error('SDK not initialized');
|
|
@@ -158,6 +193,9 @@ export function notifyAuthFailure(failureType: AuthFailureType): void {
|
|
|
158
193
|
authEE.emit(AuthStatus.FAILURE, failureType);
|
|
159
194
|
}
|
|
160
195
|
|
|
196
|
+
/**
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
161
199
|
export function notifyLogout(): void {
|
|
162
200
|
if (!authEE) {
|
|
163
201
|
console.error('SDK not initialized');
|
|
@@ -166,8 +204,31 @@ export function notifyLogout(): void {
|
|
|
166
204
|
authEE.emit(AuthStatus.LOGOUT);
|
|
167
205
|
}
|
|
168
206
|
|
|
207
|
+
export const initSession = (sessionDetails: sessionInfoInterface) => {
|
|
208
|
+
if (_.isNull(sessionInfo)) {
|
|
209
|
+
sessionInfo = sessionDetails;
|
|
210
|
+
initMixpanel(sessionInfo);
|
|
211
|
+
sessionInfoResolver(sessionInfo);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export const getSessionDetails = (sessionInfoResp: any):sessionInfoInterface => {
|
|
216
|
+
const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
|
|
217
|
+
const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
|
|
218
|
+
const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
|
|
219
|
+
? prodMixpanelToken
|
|
220
|
+
: devMixpanelToken;
|
|
221
|
+
return {
|
|
222
|
+
userGUID: sessionInfoResp.userGUID,
|
|
223
|
+
mixpanelToken,
|
|
224
|
+
isPublicUser: sessionInfoResp.configInfo.isPublicUser,
|
|
225
|
+
...sessionInfoResp,
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
|
|
169
229
|
/**
|
|
170
230
|
* Check if we are logged into the ThoughtSpot cluster
|
|
231
|
+
*
|
|
171
232
|
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
172
233
|
*/
|
|
173
234
|
async function isLoggedIn(thoughtSpotHost: string): Promise<boolean> {
|
|
@@ -176,6 +237,9 @@ async function isLoggedIn(thoughtSpotHost: string): Promise<boolean> {
|
|
|
176
237
|
try {
|
|
177
238
|
response = await fetchSessionInfoService(authVerificationUrl);
|
|
178
239
|
const sessionInfoResp = await response.json();
|
|
240
|
+
const sessionDetails = getSessionDetails(sessionInfoResp);
|
|
241
|
+
// Store user session details from session info
|
|
242
|
+
initSession(sessionDetails);
|
|
179
243
|
releaseVersion = sessionInfoResp.releaseVersion;
|
|
180
244
|
} catch (e) {
|
|
181
245
|
return false;
|
|
@@ -191,24 +255,22 @@ export function getReleaseVersion() {
|
|
|
191
255
|
}
|
|
192
256
|
|
|
193
257
|
/**
|
|
194
|
-
* Return a promise that resolves with the session information when
|
|
195
|
-
* successful. And info is available.
|
|
258
|
+
* Return a promise that resolves with the session information when
|
|
259
|
+
* authentication is successful. And info is available.
|
|
260
|
+
*
|
|
196
261
|
* @group Global methods
|
|
197
262
|
*/
|
|
198
|
-
export function getSessionInfo(): Promise<
|
|
263
|
+
export function getSessionInfo(): Promise<sessionInfoInterface> {
|
|
199
264
|
return sessionInfoPromise;
|
|
200
265
|
}
|
|
201
266
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
initMixpanel(sessionInfo);
|
|
205
|
-
sessionInfoResolver(sessionInfo);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const DUPLICATE_TOKEN_ERR =
|
|
209
|
-
'Duplicate token, please issue a new token every time getAuthToken callback is called.' +
|
|
210
|
-
'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
|
|
267
|
+
const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every time getAuthToken callback is called.'
|
|
268
|
+
+ 'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
|
|
211
269
|
let prevAuthToken: string = null;
|
|
270
|
+
/**
|
|
271
|
+
*
|
|
272
|
+
* @param authtoken
|
|
273
|
+
*/
|
|
212
274
|
function alertForDuplicateToken(authtoken: string) {
|
|
213
275
|
if (prevAuthToken === authtoken) {
|
|
214
276
|
// eslint-disable-next-line no-alert
|
|
@@ -230,18 +292,14 @@ function isAtSSORedirectUrl(): boolean {
|
|
|
230
292
|
*/
|
|
231
293
|
function removeSSORedirectUrlMarker(): void {
|
|
232
294
|
// Note (sunny): This will leave a # around even if it was not in the URL
|
|
233
|
-
// to begin with. Trying to remove the hash by changing window.location will
|
|
234
|
-
// the page which we don't want. We'll live with adding an
|
|
235
|
-
// parent page URL until we find any use case where
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
'',
|
|
239
|
-
);
|
|
295
|
+
// to begin with. Trying to remove the hash by changing window.location will
|
|
296
|
+
// reload the page which we don't want. We'll live with adding an
|
|
297
|
+
// unnecessary hash to the parent page URL until we find any use case where
|
|
298
|
+
// that creates an issue.
|
|
299
|
+
window.location.hash = window.location.hash.replace(SSO_REDIRECTION_MARKER_GUID, '');
|
|
240
300
|
}
|
|
241
301
|
|
|
242
|
-
export const getAuthenticaionToken = async (
|
|
243
|
-
embedConfig: EmbedConfig,
|
|
244
|
-
): Promise<any> => {
|
|
302
|
+
export const getAuthenticaionToken = async (embedConfig: EmbedConfig): Promise<any> => {
|
|
245
303
|
const { authEndpoint, getAuthToken } = embedConfig;
|
|
246
304
|
let authToken = null;
|
|
247
305
|
if (getAuthToken) {
|
|
@@ -256,40 +314,30 @@ export const getAuthenticaionToken = async (
|
|
|
256
314
|
|
|
257
315
|
/**
|
|
258
316
|
* Perform token based authentication
|
|
317
|
+
*
|
|
259
318
|
* @param embedConfig The embed configuration
|
|
260
319
|
*/
|
|
261
|
-
export const doTokenAuth = async (
|
|
262
|
-
embedConfig: EmbedConfig,
|
|
263
|
-
): Promise<boolean> => {
|
|
320
|
+
export const doTokenAuth = async (embedConfig: EmbedConfig): Promise<boolean> => {
|
|
264
321
|
const {
|
|
265
|
-
thoughtSpotHost,
|
|
266
|
-
username,
|
|
267
|
-
authEndpoint,
|
|
268
|
-
getAuthToken,
|
|
322
|
+
thoughtSpotHost, username, authEndpoint, getAuthToken,
|
|
269
323
|
} = embedConfig;
|
|
270
324
|
if (!authEndpoint && !getAuthToken) {
|
|
271
|
-
throw new Error(
|
|
272
|
-
'Either auth endpoint or getAuthToken function must be provided',
|
|
273
|
-
);
|
|
325
|
+
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
274
326
|
}
|
|
275
327
|
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
276
328
|
if (!loggedInStatus) {
|
|
277
329
|
const authToken = await getAuthenticaionToken(embedConfig);
|
|
278
330
|
let resp;
|
|
279
331
|
try {
|
|
280
|
-
resp = await fetchAuthPostService(
|
|
281
|
-
thoughtSpotHost,
|
|
282
|
-
username,
|
|
283
|
-
authToken,
|
|
284
|
-
);
|
|
332
|
+
resp = await fetchAuthPostService(thoughtSpotHost, username, authToken);
|
|
285
333
|
} catch (e) {
|
|
286
334
|
resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
287
335
|
}
|
|
288
336
|
// token login issues a 302 when successful
|
|
289
337
|
loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
|
|
290
338
|
if (loggedInStatus && embedConfig.detectCookieAccessSlow) {
|
|
291
|
-
// When 3rd party cookie access is blocked, this will fail because
|
|
292
|
-
// not be sent with the call.
|
|
339
|
+
// When 3rd party cookie access is blocked, this will fail because
|
|
340
|
+
// cookies will not be sent with the call.
|
|
293
341
|
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
294
342
|
}
|
|
295
343
|
}
|
|
@@ -298,16 +346,13 @@ export const doTokenAuth = async (
|
|
|
298
346
|
|
|
299
347
|
/**
|
|
300
348
|
* Validate embedConfig parameters required for cookielessTokenAuth
|
|
349
|
+
*
|
|
301
350
|
* @param embedConfig The embed configuration
|
|
302
351
|
*/
|
|
303
|
-
export const doCookielessTokenAuth = async (
|
|
304
|
-
embedConfig: EmbedConfig,
|
|
305
|
-
): Promise<boolean> => {
|
|
352
|
+
export const doCookielessTokenAuth = async (embedConfig: EmbedConfig): Promise<boolean> => {
|
|
306
353
|
const { authEndpoint, getAuthToken } = embedConfig;
|
|
307
354
|
if (!authEndpoint && !getAuthToken) {
|
|
308
|
-
throw new Error(
|
|
309
|
-
'Either auth endpoint or getAuthToken function must be provided',
|
|
310
|
-
);
|
|
355
|
+
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
311
356
|
}
|
|
312
357
|
return Promise.resolve(true);
|
|
313
358
|
};
|
|
@@ -318,19 +363,14 @@ export const doCookielessTokenAuth = async (
|
|
|
318
363
|
*
|
|
319
364
|
* Warning: This feature is primarily intended for developer testing. It is
|
|
320
365
|
* strongly advised not to use this authentication method in production.
|
|
366
|
+
*
|
|
321
367
|
* @param embedConfig The embed configuration
|
|
322
368
|
*/
|
|
323
|
-
export const doBasicAuth = async (
|
|
324
|
-
embedConfig: EmbedConfig,
|
|
325
|
-
): Promise<boolean> => {
|
|
369
|
+
export const doBasicAuth = async (embedConfig: EmbedConfig): Promise<boolean> => {
|
|
326
370
|
const { thoughtSpotHost, username, password } = embedConfig;
|
|
327
371
|
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
328
372
|
if (!loggedIn) {
|
|
329
|
-
const response = await fetchBasicAuthService(
|
|
330
|
-
thoughtSpotHost,
|
|
331
|
-
username,
|
|
332
|
-
password,
|
|
333
|
-
);
|
|
373
|
+
const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
334
374
|
loggedInStatus = response.ok;
|
|
335
375
|
if (embedConfig.detectCookieAccessSlow) {
|
|
336
376
|
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
@@ -341,11 +381,13 @@ export const doBasicAuth = async (
|
|
|
341
381
|
return loggedInStatus;
|
|
342
382
|
};
|
|
343
383
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
384
|
+
/**
|
|
385
|
+
*
|
|
386
|
+
* @param ssoURL
|
|
387
|
+
* @param triggerContainer
|
|
388
|
+
* @param triggerText
|
|
389
|
+
*/
|
|
390
|
+
async function samlPopupFlow(ssoURL: string, triggerContainer: DOMSelector, triggerText: string) {
|
|
349
391
|
const openPopup = () => {
|
|
350
392
|
if (samlAuthWindow === null || samlAuthWindow.closed) {
|
|
351
393
|
samlAuthWindow = window.open(
|
|
@@ -360,15 +402,13 @@ async function samlPopupFlow(
|
|
|
360
402
|
authEE?.emit(AuthStatus.WAITING_FOR_POPUP);
|
|
361
403
|
const containerEl = getDOMNode(triggerContainer);
|
|
362
404
|
if (containerEl) {
|
|
363
|
-
containerEl.innerHTML =
|
|
364
|
-
'<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
|
|
405
|
+
containerEl.innerHTML = '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
|
|
365
406
|
const authElem = document.getElementById('ts-auth-btn');
|
|
366
407
|
authElem.textContent = triggerText;
|
|
367
408
|
authElem.addEventListener('click', openPopup, { once: true });
|
|
368
409
|
}
|
|
369
|
-
samlCompletionPromise =
|
|
370
|
-
|
|
371
|
-
new Promise<void>((resolve, reject) => {
|
|
410
|
+
samlCompletionPromise = samlCompletionPromise
|
|
411
|
+
|| new Promise<void>((resolve, reject) => {
|
|
372
412
|
window.addEventListener('message', (e) => {
|
|
373
413
|
if (e.data.type === EmbedEvent.SAMLComplete) {
|
|
374
414
|
(e.source as Window).close();
|
|
@@ -383,12 +423,11 @@ async function samlPopupFlow(
|
|
|
383
423
|
|
|
384
424
|
/**
|
|
385
425
|
* Perform SAML authentication
|
|
426
|
+
*
|
|
386
427
|
* @param embedConfig The embed configuration
|
|
428
|
+
* @param ssoEndPoint
|
|
387
429
|
*/
|
|
388
|
-
const doSSOAuth = async (
|
|
389
|
-
embedConfig: EmbedConfig,
|
|
390
|
-
ssoEndPoint: string,
|
|
391
|
-
): Promise<void> => {
|
|
430
|
+
const doSSOAuth = async (embedConfig: EmbedConfig, ssoEndPoint: string): Promise<void> => {
|
|
392
431
|
const { thoughtSpotHost } = embedConfig;
|
|
393
432
|
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
394
433
|
if (loggedIn) {
|
|
@@ -414,7 +453,7 @@ const doSSOAuth = async (
|
|
|
414
453
|
embedConfig.authTriggerContainer,
|
|
415
454
|
embedConfig.authTriggerText,
|
|
416
455
|
);
|
|
417
|
-
loggedInStatus =
|
|
456
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
418
457
|
return;
|
|
419
458
|
}
|
|
420
459
|
|
|
@@ -423,20 +462,18 @@ const doSSOAuth = async (
|
|
|
423
462
|
|
|
424
463
|
export const doSamlAuth = async (embedConfig: EmbedConfig) => {
|
|
425
464
|
const { thoughtSpotHost } = embedConfig;
|
|
426
|
-
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
427
|
-
// again and the same JS will execute again.
|
|
465
|
+
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
466
|
+
// loaded again and the same JS will execute again.
|
|
428
467
|
const ssoRedirectUrl = embedConfig.inPopup
|
|
429
468
|
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
430
469
|
: getRedirectUrl(
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
470
|
+
window.location.href,
|
|
471
|
+
SSO_REDIRECTION_MARKER_GUID,
|
|
472
|
+
embedConfig.redirectPath,
|
|
473
|
+
);
|
|
435
474
|
|
|
436
475
|
// bring back the page to the same URL
|
|
437
|
-
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(
|
|
438
|
-
encodeURIComponent(ssoRedirectUrl),
|
|
439
|
-
)}`;
|
|
476
|
+
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
440
477
|
|
|
441
478
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
442
479
|
return loggedInStatus;
|
|
@@ -444,21 +481,18 @@ export const doSamlAuth = async (embedConfig: EmbedConfig) => {
|
|
|
444
481
|
|
|
445
482
|
export const doOIDCAuth = async (embedConfig: EmbedConfig) => {
|
|
446
483
|
const { thoughtSpotHost } = embedConfig;
|
|
447
|
-
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
448
|
-
// again and the same JS will execute again.
|
|
449
|
-
const ssoRedirectUrl =
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
);
|
|
484
|
+
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
485
|
+
// loaded again and the same JS will execute again.
|
|
486
|
+
const ssoRedirectUrl = embedConfig.noRedirect || embedConfig.inPopup
|
|
487
|
+
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
488
|
+
: getRedirectUrl(
|
|
489
|
+
window.location.href,
|
|
490
|
+
SSO_REDIRECTION_MARKER_GUID,
|
|
491
|
+
embedConfig.redirectPath,
|
|
492
|
+
);
|
|
457
493
|
|
|
458
494
|
// bring back the page to the same URL
|
|
459
|
-
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(
|
|
460
|
-
encodeURIComponent(ssoRedirectUrl),
|
|
461
|
-
)}`;
|
|
495
|
+
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
462
496
|
|
|
463
497
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
464
498
|
return loggedInStatus;
|
|
@@ -473,11 +507,10 @@ export const logout = async (embedConfig: EmbedConfig): Promise<boolean> => {
|
|
|
473
507
|
|
|
474
508
|
/**
|
|
475
509
|
* Perform authentication on the ThoughtSpot cluster
|
|
510
|
+
*
|
|
476
511
|
* @param embedConfig The embed configuration
|
|
477
512
|
*/
|
|
478
|
-
export const authenticate = async (
|
|
479
|
-
embedConfig: EmbedConfig,
|
|
480
|
-
): Promise<boolean> => {
|
|
513
|
+
export const authenticate = async (embedConfig: EmbedConfig): Promise<boolean> => {
|
|
481
514
|
const { authType } = embedConfig;
|
|
482
515
|
switch (authType) {
|
|
483
516
|
case AuthType.SSO:
|
package/src/config.spec.ts
CHANGED
|
@@ -59,8 +59,7 @@ describe('getThoughtSpotHost', () => {
|
|
|
59
59
|
expect(
|
|
60
60
|
getThoughtSpotHost({
|
|
61
61
|
...embedConfig,
|
|
62
|
-
thoughtSpotHost:
|
|
63
|
-
'http://1.2.3.4:8088/v2/?foo=bar&baz=42#myhash',
|
|
62
|
+
thoughtSpotHost: 'http://1.2.3.4:8088/v2/?foo=bar&baz=42#myhash',
|
|
64
63
|
}),
|
|
65
64
|
).toBe('http://1.2.3.4:8088/v2');
|
|
66
65
|
});
|
|
@@ -70,8 +69,7 @@ describe('getThoughtSpotHost', () => {
|
|
|
70
69
|
getThoughtSpotHost({
|
|
71
70
|
...embedConfig,
|
|
72
71
|
authType: AuthType.SAML,
|
|
73
|
-
thoughtSpotHost:
|
|
74
|
-
'http://1.2.3.4:8088/v2/?foo=bar&baz=42#myhash',
|
|
72
|
+
thoughtSpotHost: 'http://1.2.3.4:8088/v2/?foo=bar&baz=42#myhash',
|
|
75
73
|
}),
|
|
76
74
|
).toBe('http://1.2.3.4:8088/v2');
|
|
77
75
|
});
|
package/src/config.ts
CHANGED
|
@@ -23,6 +23,7 @@ const urlRegex = new RegExp(
|
|
|
23
23
|
/**
|
|
24
24
|
* Parse and construct the ThoughtSpot hostname or IP address
|
|
25
25
|
* from the embed configuration object.
|
|
26
|
+
*
|
|
26
27
|
* @param config
|
|
27
28
|
*/
|
|
28
29
|
export const getThoughtSpotHost = (config: EmbedConfig): string => {
|
|
@@ -51,9 +52,10 @@ export const getV2BasePath = (config: EmbedConfig): string => {
|
|
|
51
52
|
|
|
52
53
|
const tsHost = getThoughtSpotHost(config);
|
|
53
54
|
|
|
54
|
-
// This is to handle when e2e's. Search is run on pods for
|
|
55
|
-
// with baseUrl=https://localhost:8443.
|
|
56
|
-
// This is to handle when the developer is developing in their local
|
|
55
|
+
// This is to handle when e2e's. Search is run on pods for
|
|
56
|
+
// comp-blink-test-pipeline with baseUrl=https://localhost:8443.
|
|
57
|
+
// This is to handle when the developer is developing in their local
|
|
58
|
+
// environment.
|
|
57
59
|
if (tsHost.includes('://localhost') && !tsHost.includes(':8443')) {
|
|
58
60
|
return '';
|
|
59
61
|
}
|