@thoughtspot/visual-embed-sdk 1.29.1-alpha.1 → 1.29.2
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 +2 -1
- package/cjs/src/auth.d.ts +16 -28
- package/cjs/src/auth.d.ts.map +1 -1
- package/cjs/src/auth.js +56 -53
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/auth.spec.d.ts +0 -12
- package/cjs/src/auth.spec.d.ts.map +1 -1
- package/cjs/src/auth.spec.js +67 -89
- package/cjs/src/auth.spec.js.map +1 -1
- package/cjs/src/authToken.d.ts +2 -3
- package/cjs/src/authToken.d.ts.map +1 -1
- package/cjs/src/authToken.js +12 -13
- package/cjs/src/authToken.js.map +1 -1
- package/cjs/src/authToken.spec.d.ts +2 -0
- package/cjs/src/authToken.spec.d.ts.map +1 -0
- package/cjs/src/authToken.spec.js +29 -0
- package/cjs/src/authToken.spec.js.map +1 -0
- package/cjs/src/config.d.ts +0 -1
- package/cjs/src/config.d.ts.map +1 -1
- package/cjs/src/config.js +0 -2
- package/cjs/src/config.js.map +1 -1
- package/cjs/src/embed/app.d.ts +73 -43
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +45 -12
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +23 -4
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/base.d.ts +1 -7
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +9 -17
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +3 -2
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/embed.spec.js +0 -3
- package/cjs/src/embed/embed.spec.js.map +1 -1
- package/cjs/src/embed/embedConfig.d.ts +0 -2
- package/cjs/src/embed/embedConfig.d.ts.map +1 -1
- package/cjs/src/embed/embedConfig.js +0 -2
- package/cjs/src/embed/embedConfig.js.map +1 -1
- package/cjs/src/embed/events.spec.js +0 -3
- package/cjs/src/embed/events.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +14 -28
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +8 -8
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +79 -6
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/pinboard.spec.js +0 -3
- package/cjs/src/embed/pinboard.spec.js.map +1 -1
- package/cjs/src/embed/sage.d.ts +5 -21
- package/cjs/src/embed/sage.d.ts.map +1 -1
- package/cjs/src/embed/sage.js +2 -23
- package/cjs/src/embed/sage.js.map +1 -1
- package/cjs/src/embed/sage.spec.js +20 -34
- package/cjs/src/embed/sage.spec.js.map +1 -1
- package/cjs/src/embed/search-bar.d.ts +0 -11
- package/cjs/src/embed/search-bar.d.ts.map +1 -1
- package/cjs/src/embed/search-bar.js +0 -2
- package/cjs/src/embed/search-bar.js.map +1 -1
- package/cjs/src/embed/search.d.ts +60 -29
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +43 -9
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/search.spec.js +34 -1
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed-trigger.spec.js +0 -3
- package/cjs/src/embed/ts-embed-trigger.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +1 -31
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +34 -44
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +83 -16
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/errors.js +1 -1
- package/cjs/src/errors.js.map +1 -1
- package/cjs/src/index.d.ts +1 -3
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +1 -3
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/mixpanel-service.d.ts +1 -3
- package/cjs/src/mixpanel-service.d.ts.map +1 -1
- package/cjs/src/mixpanel-service.js +0 -2
- package/cjs/src/mixpanel-service.js.map +1 -1
- package/cjs/src/mixpanel-service.spec.js +0 -7
- package/cjs/src/mixpanel-service.spec.js.map +1 -1
- package/cjs/src/react/index.d.ts +2 -13
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +2 -13
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +15 -9
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/test/test-utils.d.ts +0 -2
- package/cjs/src/test/test-utils.d.ts.map +1 -1
- package/cjs/src/test/test-utils.js +0 -2
- package/cjs/src/test/test-utils.js.map +1 -1
- package/cjs/src/tokenizedFetch.d.ts +0 -1
- package/cjs/src/tokenizedFetch.d.ts.map +1 -1
- package/cjs/src/tokenizedFetch.js +0 -1
- package/cjs/src/tokenizedFetch.js.map +1 -1
- package/cjs/src/types.d.ts +276 -369
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +226 -299
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/authService/authService.d.ts +0 -2
- package/cjs/src/utils/authService/authService.d.ts.map +1 -1
- package/cjs/src/utils/authService/authService.js +0 -2
- package/cjs/src/utils/authService/authService.js.map +1 -1
- package/cjs/src/utils/authService/authService.spec.js +5 -18
- package/cjs/src/utils/authService/authService.spec.js.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.d.ts +2 -15
- package/cjs/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.js +9 -39
- package/cjs/src/utils/authService/tokenizedAuthService.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answer-queries.d.ts +3 -0
- package/cjs/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
- package/cjs/src/utils/graphql/answerService/answer-queries.js +75 -1
- package/cjs/src/utils/graphql/answerService/answer-queries.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.d.ts +37 -12
- package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.js +70 -14
- package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.spec.js +78 -0
- package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/cjs/src/utils/logger.d.ts.map +1 -1
- package/cjs/src/utils/logger.js +3 -5
- package/cjs/src/utils/logger.js.map +1 -1
- package/cjs/src/utils/processData.js +3 -3
- package/cjs/src/utils/processData.js.map +1 -1
- package/cjs/src/utils/processData.spec.js +3 -4
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/cjs/src/utils/processTrigger.d.ts +0 -1
- package/cjs/src/utils/processTrigger.d.ts.map +1 -1
- package/cjs/src/utils/processTrigger.js +0 -2
- package/cjs/src/utils/processTrigger.js.map +1 -1
- package/cjs/src/utils.d.ts +2 -10
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +19 -13
- package/cjs/src/utils.js.map +1 -1
- package/dist/src/auth.d.ts +16 -28
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/auth.spec.d.ts +0 -12
- package/dist/src/auth.spec.d.ts.map +1 -1
- package/dist/src/authToken.d.ts +2 -3
- package/dist/src/authToken.d.ts.map +1 -1
- package/dist/src/authToken.spec.d.ts +2 -0
- package/dist/src/authToken.spec.d.ts.map +1 -0
- package/dist/src/config.d.ts +0 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +73 -43
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +1 -7
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/embedConfig.d.ts +0 -2
- package/dist/src/embed/embedConfig.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +14 -28
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/sage.d.ts +5 -21
- package/dist/src/embed/sage.d.ts.map +1 -1
- package/dist/src/embed/search-bar.d.ts +0 -11
- package/dist/src/embed/search-bar.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +60 -29
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +1 -31
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/mixpanel-service.d.ts +1 -3
- package/dist/src/mixpanel-service.d.ts.map +1 -1
- package/dist/src/react/index.d.ts +2 -13
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/test/test-utils.d.ts +0 -2
- package/dist/src/test/test-utils.d.ts.map +1 -1
- package/dist/src/tokenizedFetch.d.ts +0 -1
- package/dist/src/tokenizedFetch.d.ts.map +1 -1
- package/dist/src/types.d.ts +276 -369
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/authService/authService.d.ts +0 -2
- package/dist/src/utils/authService/authService.d.ts.map +1 -1
- package/dist/src/utils/authService/tokenizedAuthService.d.ts +2 -15
- package/dist/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/dist/src/utils/graphql/answerService/answer-queries.d.ts +3 -0
- package/dist/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
- package/dist/src/utils/graphql/answerService/answerService.d.ts +37 -12
- package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/dist/src/utils/logger.d.ts.map +1 -1
- package/dist/src/utils/processTrigger.d.ts +0 -1
- package/dist/src/utils/processTrigger.d.ts.map +1 -1
- package/dist/src/utils.d.ts +2 -10
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +6935 -7012
- package/dist/tsembed-react.js +6928 -7002
- package/dist/tsembed.es.js +1961 -2240
- package/dist/tsembed.js +15248 -15519
- package/dist/visual-embed-sdk-react-full.d.ts +480 -648
- package/dist/visual-embed-sdk-react.d.ts +480 -648
- package/dist/visual-embed-sdk.d.ts +479 -636
- package/lib/package.json +2 -1
- package/lib/src/auth.d.ts +16 -28
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +53 -52
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.d.ts +0 -12
- package/lib/src/auth.spec.d.ts.map +1 -1
- package/lib/src/auth.spec.js +66 -88
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/authToken.d.ts +2 -3
- package/lib/src/authToken.d.ts.map +1 -1
- package/lib/src/authToken.js +12 -13
- package/lib/src/authToken.js.map +1 -1
- package/lib/src/authToken.spec.d.ts +2 -0
- package/lib/src/authToken.spec.d.ts.map +1 -0
- package/lib/src/authToken.spec.js +26 -0
- package/lib/src/authToken.spec.js.map +1 -0
- package/lib/src/config.d.ts +0 -1
- package/lib/src/config.d.ts.map +1 -1
- package/lib/src/config.js +0 -2
- package/lib/src/config.js.map +1 -1
- package/lib/src/embed/app.d.ts +73 -43
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +44 -11
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +24 -5
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +1 -7
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +8 -16
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +4 -3
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +0 -2
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/embedConfig.d.ts +0 -2
- package/lib/src/embed/embedConfig.d.ts.map +1 -1
- package/lib/src/embed/embedConfig.js +0 -2
- package/lib/src/embed/embedConfig.js.map +1 -1
- package/lib/src/embed/events.spec.js +0 -2
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +14 -28
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +9 -9
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +79 -6
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/pinboard.spec.js +0 -2
- package/lib/src/embed/pinboard.spec.js.map +1 -1
- package/lib/src/embed/sage.d.ts +5 -21
- package/lib/src/embed/sage.d.ts.map +1 -1
- package/lib/src/embed/sage.js +2 -23
- package/lib/src/embed/sage.js.map +1 -1
- package/lib/src/embed/sage.spec.js +20 -33
- package/lib/src/embed/sage.spec.js.map +1 -1
- package/lib/src/embed/search-bar.d.ts +0 -11
- package/lib/src/embed/search-bar.d.ts.map +1 -1
- package/lib/src/embed/search-bar.js +0 -2
- package/lib/src/embed/search-bar.js.map +1 -1
- package/lib/src/embed/search.d.ts +60 -29
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +43 -9
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +35 -2
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed-trigger.spec.js +0 -2
- package/lib/src/embed/ts-embed-trigger.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +1 -31
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +37 -47
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +83 -16
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/errors.js +1 -1
- package/lib/src/errors.js.map +1 -1
- package/lib/src/index.d.ts +1 -3
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +1 -3
- package/lib/src/index.js.map +1 -1
- package/lib/src/mixpanel-service.d.ts +1 -3
- package/lib/src/mixpanel-service.d.ts.map +1 -1
- package/lib/src/mixpanel-service.js +0 -2
- package/lib/src/mixpanel-service.js.map +1 -1
- package/lib/src/mixpanel-service.spec.js +0 -7
- package/lib/src/mixpanel-service.spec.js.map +1 -1
- package/lib/src/react/index.d.ts +2 -13
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +2 -12
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +16 -10
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/test/test-utils.d.ts +0 -2
- package/lib/src/test/test-utils.d.ts.map +1 -1
- package/lib/src/test/test-utils.js +0 -2
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/tokenizedFetch.d.ts +0 -1
- package/lib/src/tokenizedFetch.d.ts.map +1 -1
- package/lib/src/tokenizedFetch.js +0 -1
- package/lib/src/tokenizedFetch.js.map +1 -1
- package/lib/src/types.d.ts +276 -369
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +226 -299
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService/authService.d.ts +0 -2
- package/lib/src/utils/authService/authService.d.ts.map +1 -1
- package/lib/src/utils/authService/authService.js +0 -2
- package/lib/src/utils/authService/authService.js.map +1 -1
- package/lib/src/utils/authService/authService.spec.js +6 -19
- package/lib/src/utils/authService/authService.spec.js.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.d.ts +2 -15
- package/lib/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.js +8 -37
- package/lib/src/utils/authService/tokenizedAuthService.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answer-queries.d.ts +3 -0
- package/lib/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
- package/lib/src/utils/graphql/answerService/answer-queries.js +74 -0
- package/lib/src/utils/graphql/answerService/answer-queries.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.d.ts +37 -12
- package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.js +71 -15
- package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.spec.js +80 -2
- package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/lib/src/utils/logger.d.ts.map +1 -1
- package/lib/src/utils/logger.js +2 -3
- package/lib/src/utils/logger.js.map +1 -1
- package/lib/src/utils/processData.js +4 -4
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js +3 -4
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils/processTrigger.d.ts +0 -1
- package/lib/src/utils/processTrigger.d.ts.map +1 -1
- package/lib/src/utils/processTrigger.js +0 -2
- package/lib/src/utils/processTrigger.js.map +1 -1
- package/lib/src/utils.d.ts +2 -10
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +17 -12
- package/lib/src/utils.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +486 -647
- package/package.json +2 -1
- package/src/auth.spec.ts +72 -92
- package/src/auth.ts +62 -57
- package/src/authToken.spec.ts +31 -0
- package/src/authToken.ts +12 -12
- package/src/config.ts +0 -2
- package/src/embed/app.spec.ts +39 -5
- package/src/embed/app.ts +108 -50
- package/src/embed/base.spec.ts +5 -4
- package/src/embed/base.ts +30 -36
- package/src/embed/embed.spec.ts +0 -2
- package/src/embed/embedConfig.ts +0 -2
- package/src/embed/events.spec.ts +0 -2
- package/src/embed/liveboard.spec.ts +104 -11
- package/src/embed/liveboard.ts +25 -38
- package/src/embed/pinboard.spec.ts +0 -2
- package/src/embed/sage.spec.ts +20 -38
- package/src/embed/sage.ts +5 -38
- package/src/embed/search-bar.tsx +0 -11
- package/src/embed/search.spec.ts +48 -2
- package/src/embed/search.ts +94 -38
- package/src/embed/ts-embed-trigger.spec.ts +0 -3
- package/src/embed/ts-embed.spec.ts +109 -32
- package/src/embed/ts-embed.ts +68 -79
- package/src/errors.ts +1 -1
- package/src/index.ts +1 -3
- package/src/mixpanel-service.spec.ts +3 -12
- package/src/mixpanel-service.ts +1 -4
- package/src/react/index.spec.tsx +48 -67
- package/src/react/index.tsx +1 -13
- package/src/test/test-utils.ts +0 -2
- package/src/tokenizedFetch.ts +0 -1
- package/src/types.ts +276 -368
- package/src/utils/authService/authService.spec.ts +9 -22
- package/src/utils/authService/authService.ts +0 -2
- package/src/utils/authService/tokenizedAuthService.ts +8 -38
- package/src/utils/graphql/answerService/answer-queries.ts +77 -0
- package/src/utils/graphql/answerService/answerService.spec.ts +88 -2
- package/src/utils/graphql/answerService/answerService.ts +87 -16
- package/src/utils/logger.ts +2 -3
- package/src/utils/processData.spec.ts +3 -4
- package/src/utils/processData.ts +4 -4
- package/src/utils/processTrigger.ts +0 -2
- package/src/utils.ts +21 -13
- package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts +0 -2
- package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts.map +0 -1
- package/cjs/src/utils/authService/tokenizedAuthService.spec.js +0 -32
- package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +0 -1
- package/cjs/src/utils/sessionInfoService.d.ts +0 -66
- package/cjs/src/utils/sessionInfoService.d.ts.map +0 -1
- package/cjs/src/utils/sessionInfoService.js +0 -92
- package/cjs/src/utils/sessionInfoService.js.map +0 -1
- package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts +0 -2
- package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts.map +0 -1
- package/dist/src/utils/sessionInfoService.d.ts +0 -66
- package/dist/src/utils/sessionInfoService.d.ts.map +0 -1
- package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts +0 -2
- package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts.map +0 -1
- package/lib/src/utils/authService/tokenizedAuthService.spec.js +0 -29
- package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +0 -1
- package/lib/src/utils/sessionInfoService.d.ts +0 -66
- package/lib/src/utils/sessionInfoService.d.ts.map +0 -1
- package/lib/src/utils/sessionInfoService.js +0 -85
- package/lib/src/utils/sessionInfoService.js.map +0 -1
- package/src/utils/authService/tokenizedAuthService.spec.ts +0 -36
- package/src/utils/sessionInfoService.ts +0 -101
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtspot/visual-embed-sdk",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.2",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -175,6 +175,7 @@
|
|
|
175
175
|
"keywords": [
|
|
176
176
|
"thoughtspot",
|
|
177
177
|
"everywhere",
|
|
178
|
+
"embedded",
|
|
178
179
|
"embed",
|
|
179
180
|
"sdk",
|
|
180
181
|
"analytics"
|
package/src/auth.spec.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import * as authInstance from './auth';
|
|
2
|
-
import * as authTokenService from './authToken';
|
|
3
|
-
import * as EmbedConfig from './embed/embedConfig';
|
|
4
|
-
import * as mixPanelService from './mixpanel-service';
|
|
5
|
-
import { executeAfterWait } from './test/test-utils';
|
|
6
|
-
import { AuthType, EmbedEvent } from './types';
|
|
7
|
-
import * as checkReleaseVersionInBetaInstance from './utils';
|
|
8
2
|
import * as authService from './utils/authService/authService';
|
|
9
3
|
import * as tokenAuthService from './utils/authService/tokenizedAuthService';
|
|
10
|
-
import
|
|
11
|
-
import * as
|
|
4
|
+
import * as checkReleaseVersionInBetaInstance from './utils';
|
|
5
|
+
import * as mixPanelService from './mixpanel-service';
|
|
6
|
+
import * as EmbedConfig from './embed/embedConfig';
|
|
7
|
+
import { AuthType, EmbedEvent } from './types';
|
|
8
|
+
import { executeAfterWait } from './test/test-utils';
|
|
9
|
+
import { resetCachedAuthToken } from './authToken';
|
|
12
10
|
|
|
13
11
|
const thoughtSpotHost = 'http://localhost:3000';
|
|
14
12
|
const username = 'tsuser';
|
|
@@ -20,7 +18,7 @@ export const embedConfig: any = {
|
|
|
20
18
|
thoughtSpotHost,
|
|
21
19
|
username,
|
|
22
20
|
authEndpoint: 'auth',
|
|
23
|
-
authType: AuthType.
|
|
21
|
+
authType: AuthType.AuthServer,
|
|
24
22
|
getAuthToken: jest.fn(() => Promise.resolve(token)),
|
|
25
23
|
}),
|
|
26
24
|
doTokenAuthWithCookieDetect: {
|
|
@@ -114,47 +112,31 @@ export const mockSessionInfo = {
|
|
|
114
112
|
},
|
|
115
113
|
};
|
|
116
114
|
|
|
117
|
-
export const mockSessionInfoApiResponse = {
|
|
118
|
-
userGUID: '1234',
|
|
119
|
-
releaseVersion: 'test',
|
|
120
|
-
configInfo: {
|
|
121
|
-
isPublicUser: false,
|
|
122
|
-
mixpanelConfig: {
|
|
123
|
-
production: true,
|
|
124
|
-
devSdkKey: 'devKey',
|
|
125
|
-
prodSdkKey: 'prodKey',
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
|
|
130
115
|
describe('Unit test for auth', () => {
|
|
131
116
|
beforeEach(() => {
|
|
132
|
-
jest.resetAllMocks();
|
|
133
117
|
global.fetch = window.fetch;
|
|
134
118
|
});
|
|
135
119
|
afterEach(() => {
|
|
136
|
-
|
|
137
|
-
SessionService.resetCachedSessionInfo();
|
|
120
|
+
resetCachedAuthToken();
|
|
138
121
|
});
|
|
139
122
|
test('endpoints, SAML_LOGIN_TEMPLATE', () => {
|
|
140
123
|
const ssoTemplateUrl = authService.EndPoints.SAML_LOGIN_TEMPLATE(thoughtSpotHost);
|
|
141
124
|
expect(ssoTemplateUrl).toBe(`/callosum/v1/saml/login?targetURLPath=${thoughtSpotHost}`);
|
|
142
125
|
});
|
|
143
126
|
|
|
144
|
-
test('when session info giving response
|
|
145
|
-
jest.spyOn(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
expect(sessionInfo
|
|
149
|
-
await SessionService.getSessionInfo();
|
|
150
|
-
expect(tokenAuthService.fetchSessionInfoService).toHaveBeenCalledTimes(1);
|
|
127
|
+
test('when session info giving response', async () => {
|
|
128
|
+
jest.spyOn(mixPanelService, 'initMixpanel').mockImplementation(() => Promise.resolve());
|
|
129
|
+
authInstance.initSession(mockSessionInfo);
|
|
130
|
+
const sessionInfo = await authInstance.getSessionInfo();
|
|
131
|
+
expect(sessionInfo).toStrictEqual(mockSessionInfo);
|
|
151
132
|
});
|
|
152
133
|
|
|
153
134
|
test('Disable mixpanel when disableSDKTracking flag is set', () => {
|
|
135
|
+
jest.clearAllMocks();
|
|
136
|
+
jest.resetAllMocks();
|
|
154
137
|
jest.spyOn(mixPanelService, 'initMixpanel');
|
|
155
|
-
jest.spyOn(SessionService, 'getSessionInfo').mockReturnValue(mockSessionInfo);
|
|
156
138
|
jest.spyOn(EmbedConfig, 'getEmbedConfig').mockReturnValue({ disableSDKTracking: true });
|
|
157
|
-
authInstance.
|
|
139
|
+
authInstance.initSession(mockSessionInfo);
|
|
158
140
|
expect(mixPanelService.initMixpanel).not.toBeCalled();
|
|
159
141
|
});
|
|
160
142
|
|
|
@@ -181,22 +163,28 @@ describe('Unit test for auth', () => {
|
|
|
181
163
|
});
|
|
182
164
|
|
|
183
165
|
test('doTokenAuth: when user is loggedIn', async () => {
|
|
184
|
-
|
|
185
|
-
|
|
166
|
+
jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockImplementation(async () => ({
|
|
167
|
+
json: () => mockSessionInfo,
|
|
168
|
+
status: 200,
|
|
169
|
+
}));
|
|
170
|
+
jest.spyOn(authInstance, 'getSessionDetails').mockReturnValue(mockSessionInfo);
|
|
171
|
+
jest.spyOn(authInstance, 'initSession').mockReturnValue(null);
|
|
186
172
|
await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess('authToken'));
|
|
187
|
-
expect(
|
|
173
|
+
expect(tokenAuthService.fetchSessionInfoService).toBeCalled();
|
|
188
174
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
189
|
-
getAuthenticationTokenMock.mockRestore();
|
|
190
175
|
});
|
|
191
176
|
|
|
192
177
|
test('doTokenAuth: when user is not loggedIn & getAuthToken have response', async () => {
|
|
193
|
-
jest.spyOn(tokenAuthService, '
|
|
178
|
+
jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockImplementation(() => false);
|
|
179
|
+
jest.spyOn(authService, 'fetchAuthTokenService').mockImplementation(() => ({
|
|
180
|
+
text: () => Promise.resolve('abc'),
|
|
181
|
+
}));
|
|
194
182
|
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() => Promise.resolve({
|
|
195
183
|
status: 200,
|
|
196
|
-
ok: true,
|
|
197
184
|
}));
|
|
198
185
|
jest.spyOn(authService, 'verifyTokenService').mockResolvedValueOnce(true);
|
|
199
186
|
await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess('authToken2'));
|
|
187
|
+
expect(tokenAuthService.fetchSessionInfoService).toBeCalled();
|
|
200
188
|
expect(authService.fetchAuthService).toBeCalledWith(
|
|
201
189
|
thoughtSpotHost,
|
|
202
190
|
username,
|
|
@@ -205,25 +193,26 @@ describe('Unit test for auth', () => {
|
|
|
205
193
|
});
|
|
206
194
|
|
|
207
195
|
test('doTokenAuth: when user is not loggedIn & getAuthToken not present, isLoggedIn should called', async () => {
|
|
208
|
-
jest.spyOn(tokenAuthService, '
|
|
209
|
-
jest.spyOn(authService, 'fetchAuthTokenService').mockImplementation(() => ({
|
|
210
|
-
text: () => Promise.resolve('abc'),
|
|
211
|
-
}));
|
|
196
|
+
jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockImplementation(() => false);
|
|
197
|
+
jest.spyOn(authService, 'fetchAuthTokenService').mockImplementation(() => Promise.resolve({ text: () => Promise.resolve('abc') }));
|
|
212
198
|
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() => Promise.resolve({
|
|
213
199
|
status: 200,
|
|
214
200
|
ok: true,
|
|
215
201
|
}));
|
|
216
202
|
jest.spyOn(authService, 'verifyTokenService').mockResolvedValueOnce(true);
|
|
217
203
|
await authInstance.doTokenAuth(embedConfig.doTokenAuthFailureWithoutGetAuthToken);
|
|
218
|
-
expect(authService.fetchAuthTokenService).toBeCalledWith('auth');
|
|
219
204
|
await executeAfterWait(() => {
|
|
220
205
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
221
|
-
expect(
|
|
206
|
+
expect(tokenAuthService.fetchSessionInfoService).toBeCalled();
|
|
207
|
+
expect(authService.fetchAuthService).toBeCalledWith(
|
|
208
|
+
thoughtSpotHost,
|
|
209
|
+
username,
|
|
210
|
+
'authToken2',
|
|
211
|
+
);
|
|
222
212
|
});
|
|
223
213
|
});
|
|
224
214
|
|
|
225
215
|
test('doTokenAuth: Should raise error when duplicate token is used', async () => {
|
|
226
|
-
jest.spyOn(tokenAuthService, 'isActiveService').mockImplementation(async () => false);
|
|
227
216
|
jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockResolvedValue({
|
|
228
217
|
status: 401,
|
|
229
218
|
});
|
|
@@ -265,10 +254,8 @@ describe('Unit test for auth', () => {
|
|
|
265
254
|
ok: true,
|
|
266
255
|
}));
|
|
267
256
|
jest.spyOn(authService, 'verifyTokenService').mockResolvedValueOnce(true);
|
|
268
|
-
jest.spyOn(tokenAuthService, 'isActiveService').mockResolvedValueOnce(false);
|
|
269
|
-
jest.spyOn(tokenAuthService, 'isActiveService').mockResolvedValueOnce(false);
|
|
270
257
|
const isLoggedIn = await authInstance.doTokenAuth(embedConfig.doTokenAuthWithCookieDetect);
|
|
271
|
-
expect(tokenAuthService.
|
|
258
|
+
expect(tokenAuthService.fetchSessionInfoService).toHaveBeenCalledTimes(2);
|
|
272
259
|
expect(isLoggedIn).toBe(false);
|
|
273
260
|
});
|
|
274
261
|
|
|
@@ -291,6 +278,7 @@ describe('Unit test for auth', () => {
|
|
|
291
278
|
expect(await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess('authToken2'))).toBe(
|
|
292
279
|
true,
|
|
293
280
|
);
|
|
281
|
+
expect(tokenAuthService.fetchSessionInfoService).toBeCalled();
|
|
294
282
|
expect(authService.fetchAuthPostService).toBeCalledWith(
|
|
295
283
|
thoughtSpotHost,
|
|
296
284
|
username,
|
|
@@ -309,9 +297,20 @@ describe('Unit test for auth', () => {
|
|
|
309
297
|
});
|
|
310
298
|
|
|
311
299
|
it('when user is loggedIn', async () => {
|
|
312
|
-
|
|
300
|
+
spyOn(checkReleaseVersionInBetaInstance, 'checkReleaseVersionInBeta');
|
|
301
|
+
jest.spyOn(authInstance, 'getSessionDetails').mockReturnValue(mockSessionInfo);
|
|
302
|
+
jest.spyOn(authInstance, 'initSession').mockReturnValue(null);
|
|
303
|
+
jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockImplementation(
|
|
304
|
+
async () => ({
|
|
305
|
+
json: () => mockSessionInfo,
|
|
306
|
+
status: 200,
|
|
307
|
+
}),
|
|
308
|
+
);
|
|
313
309
|
await authInstance.doBasicAuth(embedConfig.doBasicAuth);
|
|
310
|
+
expect(tokenAuthService.fetchSessionInfoService).toBeCalled();
|
|
314
311
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
312
|
+
expect(authInstance.getSessionDetails).toBeCalled();
|
|
313
|
+
expect(authInstance.initSession).toBeCalled();
|
|
315
314
|
});
|
|
316
315
|
|
|
317
316
|
it('when user is not loggedIn', async () => {
|
|
@@ -322,7 +321,7 @@ describe('Unit test for auth', () => {
|
|
|
322
321
|
}));
|
|
323
322
|
|
|
324
323
|
await authInstance.doBasicAuth(embedConfig.doBasicAuth);
|
|
325
|
-
|
|
324
|
+
expect(tokenAuthService.fetchSessionInfoService).toBeCalled();
|
|
326
325
|
expect(authService.fetchBasicAuthService).toBeCalled();
|
|
327
326
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
328
327
|
});
|
|
@@ -350,8 +349,10 @@ describe('Unit test for auth', () => {
|
|
|
350
349
|
status: 200,
|
|
351
350
|
}),
|
|
352
351
|
);
|
|
353
|
-
jest.spyOn(
|
|
352
|
+
jest.spyOn(authInstance, 'getSessionDetails').mockReturnValue(mockSessionInfo);
|
|
353
|
+
jest.spyOn(authInstance, 'initSession').mockReturnValue(null);
|
|
354
354
|
await authInstance.doSamlAuth(embedConfig.doSamlAuth);
|
|
355
|
+
expect(tokenAuthService.fetchSessionInfoService).toBeCalled();
|
|
355
356
|
expect(window.location.hash).toBe('');
|
|
356
357
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
357
358
|
});
|
|
@@ -359,6 +360,7 @@ describe('Unit test for auth', () => {
|
|
|
359
360
|
it('when user is not loggedIn & isAtSSORedirectUrl is true', async () => {
|
|
360
361
|
jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockImplementation(() => Promise.reject());
|
|
361
362
|
await authInstance.doSamlAuth(embedConfig.doSamlAuth);
|
|
363
|
+
expect(tokenAuthService.fetchSessionInfoService).toBeCalled();
|
|
362
364
|
expect(window.location.hash).toBe('');
|
|
363
365
|
expect(authInstance.loggedInStatus).toBe(false);
|
|
364
366
|
});
|
|
@@ -372,6 +374,7 @@ describe('Unit test for auth', () => {
|
|
|
372
374
|
});
|
|
373
375
|
jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockImplementation(() => Promise.reject());
|
|
374
376
|
await authInstance.doSamlAuth(embedConfig.doSamlAuth);
|
|
377
|
+
expect(tokenAuthService.fetchSessionInfoService).toBeCalled();
|
|
375
378
|
expect(global.window.location.href).toBe(samalLoginUrl);
|
|
376
379
|
});
|
|
377
380
|
|
|
@@ -384,9 +387,14 @@ describe('Unit test for auth', () => {
|
|
|
384
387
|
});
|
|
385
388
|
spyOn(authInstance, 'samlCompletionPromise');
|
|
386
389
|
global.window.open = jest.fn();
|
|
387
|
-
jest.spyOn(tokenAuthService, '
|
|
388
|
-
.
|
|
389
|
-
.
|
|
390
|
+
jest.spyOn(tokenAuthService, 'fetchSessionInfoService')
|
|
391
|
+
.mockImplementationOnce(() => Promise.reject())
|
|
392
|
+
.mockImplementationOnce(async () => ({
|
|
393
|
+
json: () => mockSessionInfo,
|
|
394
|
+
status: 200,
|
|
395
|
+
}));
|
|
396
|
+
jest.spyOn(authInstance, 'getSessionDetails').mockReturnValue(mockSessionInfo);
|
|
397
|
+
jest.spyOn(authInstance, 'initSession').mockReturnValue(null);
|
|
390
398
|
expect(await authInstance.samlCompletionPromise).not.toBe(null);
|
|
391
399
|
expect(
|
|
392
400
|
await authInstance.doSamlAuth({
|
|
@@ -396,13 +404,15 @@ describe('Unit test for auth', () => {
|
|
|
396
404
|
document.getElementById('ts-auth-btn').click();
|
|
397
405
|
window.postMessage({ type: EmbedEvent.SAMLComplete }, '*');
|
|
398
406
|
await authInstance.samlCompletionPromise;
|
|
399
|
-
expect(
|
|
407
|
+
expect(tokenAuthService.fetchSessionInfoService).toBeCalled();
|
|
408
|
+
expect(authInstance.getSessionDetails).toBeCalled();
|
|
409
|
+
expect(authInstance.initSession).toBeCalled();
|
|
400
410
|
});
|
|
401
411
|
});
|
|
402
412
|
|
|
403
413
|
describe('doOIDCAuth', () => {
|
|
404
414
|
afterEach(() => {
|
|
405
|
-
|
|
415
|
+
resetCachedAuthToken();
|
|
406
416
|
delete global.window;
|
|
407
417
|
global.window = Object.create(originalWindow);
|
|
408
418
|
global.window.open = jest.fn();
|
|
@@ -412,6 +422,7 @@ describe('Unit test for auth', () => {
|
|
|
412
422
|
it('when user is not loggedIn & isAtSSORedirectUrl is true', async () => {
|
|
413
423
|
jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockImplementation(() => Promise.reject());
|
|
414
424
|
await authInstance.doOIDCAuth(embedConfig.doOidcAuth);
|
|
425
|
+
expect(tokenAuthService.fetchSessionInfoService).toBeCalled();
|
|
415
426
|
expect(window.location.hash).toBe('');
|
|
416
427
|
expect(authInstance.loggedInStatus).toBe(false);
|
|
417
428
|
});
|
|
@@ -454,7 +465,6 @@ describe('Unit test for auth', () => {
|
|
|
454
465
|
|
|
455
466
|
it('authenticate: when authType is Basic', async () => {
|
|
456
467
|
jest.spyOn(authInstance, 'doBasicAuth');
|
|
457
|
-
jest.spyOn(authService, 'fetchBasicAuthService').mockImplementation(() => Promise.resolve({ status: 200, ok: true }));
|
|
458
468
|
await authInstance.authenticate(embedConfig.basicAuthSuccess);
|
|
459
469
|
expect(authInstance.doBasicAuth).toBeCalled();
|
|
460
470
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
@@ -471,7 +481,6 @@ describe('Unit test for auth', () => {
|
|
|
471
481
|
});
|
|
472
482
|
|
|
473
483
|
it('doCookielessTokenAuth should resolve to true if valid token is passed', async () => {
|
|
474
|
-
jest.clearAllMocks();
|
|
475
484
|
jest.spyOn(authService, 'verifyTokenService').mockResolvedValueOnce(true);
|
|
476
485
|
const isLoggedIn = await authInstance.doCookielessTokenAuth(
|
|
477
486
|
embedConfig.doCookielessAuth('testToken'),
|
|
@@ -491,11 +500,11 @@ describe('Unit test for auth', () => {
|
|
|
491
500
|
authInstance.setAuthEE(testObject as any);
|
|
492
501
|
expect(authInstance.getAuthEE()).toBe(testObject);
|
|
493
502
|
});
|
|
494
|
-
it('getSessionDetails returns the correct details given sessionInfo',
|
|
503
|
+
it('getSessionDetails returns the correct details given sessionInfo', () => {
|
|
495
504
|
jest.clearAllMocks();
|
|
496
505
|
jest.restoreAllMocks();
|
|
497
506
|
|
|
498
|
-
|
|
507
|
+
const details = authInstance.getSessionDetails({
|
|
499
508
|
userGUID: '1234',
|
|
500
509
|
releaseVersion: '1',
|
|
501
510
|
configInfo: {
|
|
@@ -506,14 +515,13 @@ describe('Unit test for auth', () => {
|
|
|
506
515
|
},
|
|
507
516
|
},
|
|
508
517
|
});
|
|
509
|
-
const details = await SessionService.getSessionInfo();
|
|
510
518
|
expect(details).toEqual(
|
|
511
519
|
expect.objectContaining({
|
|
512
520
|
mixpanelToken: 'devKey',
|
|
513
521
|
}),
|
|
514
522
|
);
|
|
515
523
|
|
|
516
|
-
|
|
524
|
+
const details2 = authInstance.getSessionDetails({
|
|
517
525
|
configInfo: {
|
|
518
526
|
mixpanelConfig: {
|
|
519
527
|
devSdkKey: 'devKey',
|
|
@@ -522,38 +530,10 @@ describe('Unit test for auth', () => {
|
|
|
522
530
|
},
|
|
523
531
|
},
|
|
524
532
|
});
|
|
525
|
-
|
|
526
|
-
SessionService.resetCachedSessionInfo();
|
|
527
|
-
const details2 = await SessionService.getSessionInfo();
|
|
528
533
|
expect(details2).toEqual(
|
|
529
534
|
expect.objectContaining({
|
|
530
535
|
mixpanelToken: 'prodKey',
|
|
531
536
|
}),
|
|
532
537
|
);
|
|
533
538
|
});
|
|
534
|
-
|
|
535
|
-
test('notifyAuthSuccess if getSessionInfo returns data', async () => {
|
|
536
|
-
const dummyInfo = { test: 'dummy' };
|
|
537
|
-
jest.spyOn(SessionService, 'getSessionInfo').mockResolvedValueOnce(dummyInfo);
|
|
538
|
-
jest.spyOn(logger, 'error').mockResolvedValueOnce(true);
|
|
539
|
-
const emitSpy = jest.fn();
|
|
540
|
-
authInstance.setAuthEE({ emit: emitSpy } as any);
|
|
541
|
-
await authInstance.notifyAuthSuccess();
|
|
542
|
-
expect(logger.error).not.toBeCalled();
|
|
543
|
-
expect(emitSpy).toBeCalledWith(authInstance.AuthStatus.SUCCESS, dummyInfo);
|
|
544
|
-
authInstance.setAuthEE(null);
|
|
545
|
-
});
|
|
546
|
-
|
|
547
|
-
test('notifyAuthSuccess if getSessionInfo fails', async () => {
|
|
548
|
-
jest.spyOn(SessionService, 'getSessionInfo').mockImplementation(() => {
|
|
549
|
-
throw new Error('error');
|
|
550
|
-
});
|
|
551
|
-
jest.spyOn(logger, 'error');
|
|
552
|
-
const emitSpy = jest.fn();
|
|
553
|
-
authInstance.setAuthEE({ emit: emitSpy } as any);
|
|
554
|
-
await authInstance.notifyAuthSuccess();
|
|
555
|
-
expect(logger.error).toBeCalled();
|
|
556
|
-
expect(emitSpy).not.toBeCalled();
|
|
557
|
-
authInstance.setAuthEE(null);
|
|
558
|
-
});
|
|
559
539
|
});
|
package/src/auth.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
2
|
import { getAuthenticationToken, resetCachedAuthToken } from './authToken';
|
|
3
|
-
import { getEmbedConfig } from './embed/embedConfig';
|
|
4
3
|
import { initMixpanel } from './mixpanel-service';
|
|
5
4
|
import {
|
|
6
5
|
AuthType, DOMSelector, EmbedConfig, EmbedEvent,
|
|
@@ -12,10 +11,10 @@ import {
|
|
|
12
11
|
fetchAuthService,
|
|
13
12
|
fetchBasicAuthService,
|
|
14
13
|
fetchLogoutService,
|
|
14
|
+
fetchSessionInfoService,
|
|
15
15
|
} from './utils/authService';
|
|
16
|
-
import { isActiveService } from './utils/authService/tokenizedAuthService';
|
|
17
16
|
import { logger } from './utils/logger';
|
|
18
|
-
import {
|
|
17
|
+
import { getEmbedConfig } from './embed/embedConfig';
|
|
19
18
|
|
|
20
19
|
// eslint-disable-next-line import/no-mutable-exports
|
|
21
20
|
export let loggedInStatus = false;
|
|
@@ -23,15 +22,25 @@ export let loggedInStatus = false;
|
|
|
23
22
|
export let samlAuthWindow: Window = null;
|
|
24
23
|
// eslint-disable-next-line import/no-mutable-exports
|
|
25
24
|
export let samlCompletionPromise: Promise<void> = null;
|
|
26
|
-
|
|
25
|
+
let sessionInfo: sessionInfoInterface = null;
|
|
26
|
+
let sessionInfoResolver: (value: sessionInfoInterface) => void = null;
|
|
27
|
+
const sessionInfoPromise = new Promise((resolve: (value: sessionInfoInterface) => void) => {
|
|
28
|
+
sessionInfoResolver = resolve;
|
|
29
|
+
});
|
|
27
30
|
let releaseVersion = '';
|
|
28
31
|
|
|
29
32
|
export const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
|
|
30
33
|
|
|
34
|
+
interface sessionInfoInterface {
|
|
35
|
+
userGUID: any;
|
|
36
|
+
isPublicUser: any;
|
|
37
|
+
mixpanelToken: any;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
/**
|
|
32
42
|
* Enum for auth failure types. This is the parameter passed to the listner
|
|
33
43
|
* of {@link AuthStatus.FAILURE}.
|
|
34
|
-
*
|
|
35
44
|
* @group Authentication / Init
|
|
36
45
|
*/
|
|
37
46
|
export enum AuthFailureType {
|
|
@@ -43,7 +52,6 @@ export enum AuthFailureType {
|
|
|
43
52
|
|
|
44
53
|
/**
|
|
45
54
|
* Enum for auth status emitted by the emitter returned from {@link init}.
|
|
46
|
-
*
|
|
47
55
|
* @group Authentication / Init
|
|
48
56
|
*/
|
|
49
57
|
export enum AuthStatus {
|
|
@@ -67,7 +75,6 @@ export enum AuthStatus {
|
|
|
67
75
|
* Emitted when inPopup is true in the SAMLRedirect flow and the
|
|
68
76
|
* popup is waiting to be triggered either programmatically
|
|
69
77
|
* or by the trigger button.
|
|
70
|
-
*
|
|
71
78
|
* @version SDK: 1.19.0
|
|
72
79
|
*/
|
|
73
80
|
WAITING_FOR_POPUP = 'WAITING_FOR_POPUP',
|
|
@@ -75,20 +82,17 @@ export enum AuthStatus {
|
|
|
75
82
|
|
|
76
83
|
/**
|
|
77
84
|
* Event emitter returned from {@link init}.
|
|
78
|
-
*
|
|
79
85
|
* @group Authentication / Init
|
|
80
86
|
*/
|
|
81
87
|
export interface AuthEventEmitter {
|
|
82
88
|
/**
|
|
83
89
|
* Register a listener on Auth failure.
|
|
84
|
-
*
|
|
85
90
|
* @param event
|
|
86
91
|
* @param listener
|
|
87
92
|
*/
|
|
88
93
|
on(event: AuthStatus.FAILURE, listener: (failureType: AuthFailureType) => void): this;
|
|
89
94
|
/**
|
|
90
95
|
* Register a listener on Auth SDK success.
|
|
91
|
-
*
|
|
92
96
|
* @param event
|
|
93
97
|
* @param listener
|
|
94
98
|
*/
|
|
@@ -105,13 +109,11 @@ export interface AuthEventEmitter {
|
|
|
105
109
|
once(event: AuthStatus.SUCCESS, listener: (sessionInfo: any) => void): this;
|
|
106
110
|
/**
|
|
107
111
|
* Trigger an event on the emitter returned from init.
|
|
108
|
-
*
|
|
109
112
|
* @param {@link AuthEvent}
|
|
110
113
|
*/
|
|
111
114
|
emit(event: AuthEvent, ...args: any[]): boolean;
|
|
112
115
|
/**
|
|
113
116
|
* Remove listener from the emitter returned from init.
|
|
114
|
-
*
|
|
115
117
|
* @param event
|
|
116
118
|
* @param listener
|
|
117
119
|
* @param context
|
|
@@ -120,7 +122,6 @@ export interface AuthEventEmitter {
|
|
|
120
122
|
off(event: AuthStatus, listener: (...args: any[]) => void, context: any, once: boolean): this;
|
|
121
123
|
/**
|
|
122
124
|
* Remove all the event listeners
|
|
123
|
-
*
|
|
124
125
|
* @param event
|
|
125
126
|
*/
|
|
126
127
|
removeAllListeners(event: AuthStatus): this;
|
|
@@ -128,7 +129,6 @@ export interface AuthEventEmitter {
|
|
|
128
129
|
|
|
129
130
|
/**
|
|
130
131
|
* Events which can be triggered on the emitter returned from {@link init}.
|
|
131
|
-
*
|
|
132
132
|
* @group Authentication / Init
|
|
133
133
|
*/
|
|
134
134
|
export enum AuthEvent {
|
|
@@ -170,17 +170,12 @@ export function notifyAuthSDKSuccess(): void {
|
|
|
170
170
|
/**
|
|
171
171
|
*
|
|
172
172
|
*/
|
|
173
|
-
export
|
|
173
|
+
export function notifyAuthSuccess(): void {
|
|
174
174
|
if (!authEE) {
|
|
175
175
|
logger.error('SDK not initialized');
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
|
-
|
|
179
|
-
const sessionInfo = await getSessionInfo();
|
|
180
|
-
authEE.emit(AuthStatus.SUCCESS, sessionInfo);
|
|
181
|
-
} catch (e) {
|
|
182
|
-
logger.error('Failed to get session info');
|
|
183
|
-
}
|
|
178
|
+
authEE.emit(AuthStatus.SUCCESS, sessionInfo);
|
|
184
179
|
}
|
|
185
180
|
|
|
186
181
|
/**
|
|
@@ -206,46 +201,68 @@ export function notifyLogout(): void {
|
|
|
206
201
|
authEE.emit(AuthStatus.LOGOUT);
|
|
207
202
|
}
|
|
208
203
|
|
|
204
|
+
export const initSession = (sessionDetails: sessionInfoInterface) => {
|
|
205
|
+
const embedConfig = getEmbedConfig();
|
|
206
|
+
if (sessionInfo == null) {
|
|
207
|
+
sessionInfo = sessionDetails;
|
|
208
|
+
if (!embedConfig.disableSDKTracking) {
|
|
209
|
+
initMixpanel(sessionInfo);
|
|
210
|
+
}
|
|
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
|
+
releaseVersion: sessionInfoResp.releaseVersion,
|
|
226
|
+
clusterId: sessionInfoResp.configInfo.selfClusterId,
|
|
227
|
+
clusterName: sessionInfoResp.configInfo.selfClusterName,
|
|
228
|
+
...sessionInfoResp,
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
|
|
209
232
|
/**
|
|
210
233
|
* Check if we are logged into the ThoughtSpot cluster
|
|
211
|
-
*
|
|
212
234
|
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
213
235
|
*/
|
|
214
236
|
async function isLoggedIn(thoughtSpotHost: string): Promise<boolean> {
|
|
237
|
+
const authVerificationUrl = `${thoughtSpotHost}${EndPoints.AUTH_VERIFICATION}`;
|
|
238
|
+
let response = null;
|
|
215
239
|
try {
|
|
216
|
-
|
|
217
|
-
|
|
240
|
+
response = await fetchSessionInfoService(authVerificationUrl);
|
|
241
|
+
const sessionInfoResp = await response.json();
|
|
242
|
+
const sessionDetails = getSessionDetails(sessionInfoResp);
|
|
243
|
+
// Store user session details from session info
|
|
244
|
+
initSession(sessionDetails);
|
|
245
|
+
releaseVersion = sessionInfoResp.releaseVersion;
|
|
218
246
|
} catch (e) {
|
|
219
247
|
return false;
|
|
220
248
|
}
|
|
249
|
+
return response.status === 200;
|
|
221
250
|
}
|
|
222
251
|
|
|
223
252
|
/**
|
|
224
|
-
*
|
|
225
|
-
* This should be called after the cookie is set for cookie auth or
|
|
226
|
-
* after the token is set for cookieless.
|
|
227
|
-
*
|
|
228
|
-
* @return {Promise<void>}
|
|
229
|
-
* @example
|
|
230
|
-
* ```js
|
|
231
|
-
* await postLoginService();
|
|
232
|
-
* ```
|
|
233
|
-
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
253
|
+
* Return releaseVersion if available
|
|
234
254
|
*/
|
|
235
|
-
export
|
|
236
|
-
|
|
237
|
-
releaseVersion = sessionInfo.releaseVersion;
|
|
238
|
-
const embedConfig = getEmbedConfig();
|
|
239
|
-
if (!embedConfig.disableSDKTracking) {
|
|
240
|
-
initMixpanel(sessionInfo);
|
|
241
|
-
}
|
|
255
|
+
export function getReleaseVersion() {
|
|
256
|
+
return releaseVersion;
|
|
242
257
|
}
|
|
243
258
|
|
|
244
259
|
/**
|
|
245
|
-
* Return
|
|
260
|
+
* Return a promise that resolves with the session information when
|
|
261
|
+
* authentication is successful. And info is available.
|
|
262
|
+
* @group Global methods
|
|
246
263
|
*/
|
|
247
|
-
export function
|
|
248
|
-
return
|
|
264
|
+
export function getSessionInfo(): Promise<sessionInfoInterface> {
|
|
265
|
+
return sessionInfoPromise;
|
|
249
266
|
}
|
|
250
267
|
|
|
251
268
|
/**
|
|
@@ -269,7 +286,6 @@ function removeSSORedirectUrlMarker(): void {
|
|
|
269
286
|
|
|
270
287
|
/**
|
|
271
288
|
* Perform token based authentication
|
|
272
|
-
*
|
|
273
289
|
* @param embedConfig The embed configuration
|
|
274
290
|
*/
|
|
275
291
|
export const doTokenAuth = async (embedConfig: EmbedConfig): Promise<boolean> => {
|
|
@@ -280,15 +296,8 @@ export const doTokenAuth = async (embedConfig: EmbedConfig): Promise<boolean> =>
|
|
|
280
296
|
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
281
297
|
}
|
|
282
298
|
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
283
|
-
|
|
284
299
|
if (!loggedInStatus) {
|
|
285
|
-
|
|
286
|
-
try {
|
|
287
|
-
authToken = await getAuthenticationToken(embedConfig);
|
|
288
|
-
} catch (e) {
|
|
289
|
-
loggedInStatus = false;
|
|
290
|
-
throw e;
|
|
291
|
-
}
|
|
300
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
292
301
|
let resp;
|
|
293
302
|
try {
|
|
294
303
|
resp = await fetchAuthPostService(thoughtSpotHost, username, authToken);
|
|
@@ -308,7 +317,6 @@ export const doTokenAuth = async (embedConfig: EmbedConfig): Promise<boolean> =>
|
|
|
308
317
|
|
|
309
318
|
/**
|
|
310
319
|
* Validate embedConfig parameters required for cookielessTokenAuth
|
|
311
|
-
*
|
|
312
320
|
* @param embedConfig The embed configuration
|
|
313
321
|
*/
|
|
314
322
|
export const doCookielessTokenAuth = async (embedConfig: EmbedConfig): Promise<boolean> => {
|
|
@@ -335,7 +343,6 @@ export const doCookielessTokenAuth = async (embedConfig: EmbedConfig): Promise<b
|
|
|
335
343
|
*
|
|
336
344
|
* Warning: This feature is primarily intended for developer testing. It is
|
|
337
345
|
* strongly advised not to use this authentication method in production.
|
|
338
|
-
*
|
|
339
346
|
* @param embedConfig The embed configuration
|
|
340
347
|
*/
|
|
341
348
|
export const doBasicAuth = async (embedConfig: EmbedConfig): Promise<boolean> => {
|
|
@@ -395,7 +402,6 @@ async function samlPopupFlow(ssoURL: string, triggerContainer: DOMSelector, trig
|
|
|
395
402
|
|
|
396
403
|
/**
|
|
397
404
|
* Perform SAML authentication
|
|
398
|
-
*
|
|
399
405
|
* @param embedConfig The embed configuration
|
|
400
406
|
* @param ssoEndPoint
|
|
401
407
|
*/
|
|
@@ -482,7 +488,6 @@ export const logout = async (embedConfig: EmbedConfig): Promise<boolean> => {
|
|
|
482
488
|
|
|
483
489
|
/**
|
|
484
490
|
* Perform authentication on the ThoughtSpot cluster
|
|
485
|
-
*
|
|
486
491
|
* @param embedConfig The embed configuration
|
|
487
492
|
*/
|
|
488
493
|
export const authenticate = async (embedConfig: EmbedConfig): Promise<boolean> => {
|