@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.
Files changed (402) hide show
  1. package/README.md +1 -1
  2. package/cjs/package.json +2 -1
  3. package/cjs/src/auth.d.ts +16 -28
  4. package/cjs/src/auth.d.ts.map +1 -1
  5. package/cjs/src/auth.js +56 -53
  6. package/cjs/src/auth.js.map +1 -1
  7. package/cjs/src/auth.spec.d.ts +0 -12
  8. package/cjs/src/auth.spec.d.ts.map +1 -1
  9. package/cjs/src/auth.spec.js +67 -89
  10. package/cjs/src/auth.spec.js.map +1 -1
  11. package/cjs/src/authToken.d.ts +2 -3
  12. package/cjs/src/authToken.d.ts.map +1 -1
  13. package/cjs/src/authToken.js +12 -13
  14. package/cjs/src/authToken.js.map +1 -1
  15. package/cjs/src/authToken.spec.d.ts +2 -0
  16. package/cjs/src/authToken.spec.d.ts.map +1 -0
  17. package/cjs/src/authToken.spec.js +29 -0
  18. package/cjs/src/authToken.spec.js.map +1 -0
  19. package/cjs/src/config.d.ts +0 -1
  20. package/cjs/src/config.d.ts.map +1 -1
  21. package/cjs/src/config.js +0 -2
  22. package/cjs/src/config.js.map +1 -1
  23. package/cjs/src/embed/app.d.ts +73 -43
  24. package/cjs/src/embed/app.d.ts.map +1 -1
  25. package/cjs/src/embed/app.js +45 -12
  26. package/cjs/src/embed/app.js.map +1 -1
  27. package/cjs/src/embed/app.spec.js +23 -4
  28. package/cjs/src/embed/app.spec.js.map +1 -1
  29. package/cjs/src/embed/base.d.ts +1 -7
  30. package/cjs/src/embed/base.d.ts.map +1 -1
  31. package/cjs/src/embed/base.js +9 -17
  32. package/cjs/src/embed/base.js.map +1 -1
  33. package/cjs/src/embed/base.spec.js +3 -2
  34. package/cjs/src/embed/base.spec.js.map +1 -1
  35. package/cjs/src/embed/embed.spec.js +0 -3
  36. package/cjs/src/embed/embed.spec.js.map +1 -1
  37. package/cjs/src/embed/embedConfig.d.ts +0 -2
  38. package/cjs/src/embed/embedConfig.d.ts.map +1 -1
  39. package/cjs/src/embed/embedConfig.js +0 -2
  40. package/cjs/src/embed/embedConfig.js.map +1 -1
  41. package/cjs/src/embed/events.spec.js +0 -3
  42. package/cjs/src/embed/events.spec.js.map +1 -1
  43. package/cjs/src/embed/liveboard.d.ts +14 -28
  44. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  45. package/cjs/src/embed/liveboard.js +8 -8
  46. package/cjs/src/embed/liveboard.js.map +1 -1
  47. package/cjs/src/embed/liveboard.spec.js +79 -6
  48. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  49. package/cjs/src/embed/pinboard.spec.js +0 -3
  50. package/cjs/src/embed/pinboard.spec.js.map +1 -1
  51. package/cjs/src/embed/sage.d.ts +5 -21
  52. package/cjs/src/embed/sage.d.ts.map +1 -1
  53. package/cjs/src/embed/sage.js +2 -23
  54. package/cjs/src/embed/sage.js.map +1 -1
  55. package/cjs/src/embed/sage.spec.js +20 -34
  56. package/cjs/src/embed/sage.spec.js.map +1 -1
  57. package/cjs/src/embed/search-bar.d.ts +0 -11
  58. package/cjs/src/embed/search-bar.d.ts.map +1 -1
  59. package/cjs/src/embed/search-bar.js +0 -2
  60. package/cjs/src/embed/search-bar.js.map +1 -1
  61. package/cjs/src/embed/search.d.ts +60 -29
  62. package/cjs/src/embed/search.d.ts.map +1 -1
  63. package/cjs/src/embed/search.js +43 -9
  64. package/cjs/src/embed/search.js.map +1 -1
  65. package/cjs/src/embed/search.spec.js +34 -1
  66. package/cjs/src/embed/search.spec.js.map +1 -1
  67. package/cjs/src/embed/ts-embed-trigger.spec.js +0 -3
  68. package/cjs/src/embed/ts-embed-trigger.spec.js.map +1 -1
  69. package/cjs/src/embed/ts-embed.d.ts +1 -31
  70. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  71. package/cjs/src/embed/ts-embed.js +34 -44
  72. package/cjs/src/embed/ts-embed.js.map +1 -1
  73. package/cjs/src/embed/ts-embed.spec.js +83 -16
  74. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  75. package/cjs/src/errors.js +1 -1
  76. package/cjs/src/errors.js.map +1 -1
  77. package/cjs/src/index.d.ts +1 -3
  78. package/cjs/src/index.d.ts.map +1 -1
  79. package/cjs/src/index.js +1 -3
  80. package/cjs/src/index.js.map +1 -1
  81. package/cjs/src/mixpanel-service.d.ts +1 -3
  82. package/cjs/src/mixpanel-service.d.ts.map +1 -1
  83. package/cjs/src/mixpanel-service.js +0 -2
  84. package/cjs/src/mixpanel-service.js.map +1 -1
  85. package/cjs/src/mixpanel-service.spec.js +0 -7
  86. package/cjs/src/mixpanel-service.spec.js.map +1 -1
  87. package/cjs/src/react/index.d.ts +2 -13
  88. package/cjs/src/react/index.d.ts.map +1 -1
  89. package/cjs/src/react/index.js +2 -13
  90. package/cjs/src/react/index.js.map +1 -1
  91. package/cjs/src/react/index.spec.js +15 -9
  92. package/cjs/src/react/index.spec.js.map +1 -1
  93. package/cjs/src/test/test-utils.d.ts +0 -2
  94. package/cjs/src/test/test-utils.d.ts.map +1 -1
  95. package/cjs/src/test/test-utils.js +0 -2
  96. package/cjs/src/test/test-utils.js.map +1 -1
  97. package/cjs/src/tokenizedFetch.d.ts +0 -1
  98. package/cjs/src/tokenizedFetch.d.ts.map +1 -1
  99. package/cjs/src/tokenizedFetch.js +0 -1
  100. package/cjs/src/tokenizedFetch.js.map +1 -1
  101. package/cjs/src/types.d.ts +276 -369
  102. package/cjs/src/types.d.ts.map +1 -1
  103. package/cjs/src/types.js +226 -299
  104. package/cjs/src/types.js.map +1 -1
  105. package/cjs/src/utils/authService/authService.d.ts +0 -2
  106. package/cjs/src/utils/authService/authService.d.ts.map +1 -1
  107. package/cjs/src/utils/authService/authService.js +0 -2
  108. package/cjs/src/utils/authService/authService.js.map +1 -1
  109. package/cjs/src/utils/authService/authService.spec.js +5 -18
  110. package/cjs/src/utils/authService/authService.spec.js.map +1 -1
  111. package/cjs/src/utils/authService/tokenizedAuthService.d.ts +2 -15
  112. package/cjs/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
  113. package/cjs/src/utils/authService/tokenizedAuthService.js +9 -39
  114. package/cjs/src/utils/authService/tokenizedAuthService.js.map +1 -1
  115. package/cjs/src/utils/graphql/answerService/answer-queries.d.ts +3 -0
  116. package/cjs/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
  117. package/cjs/src/utils/graphql/answerService/answer-queries.js +75 -1
  118. package/cjs/src/utils/graphql/answerService/answer-queries.js.map +1 -1
  119. package/cjs/src/utils/graphql/answerService/answerService.d.ts +37 -12
  120. package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  121. package/cjs/src/utils/graphql/answerService/answerService.js +70 -14
  122. package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
  123. package/cjs/src/utils/graphql/answerService/answerService.spec.js +78 -0
  124. package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
  125. package/cjs/src/utils/logger.d.ts.map +1 -1
  126. package/cjs/src/utils/logger.js +3 -5
  127. package/cjs/src/utils/logger.js.map +1 -1
  128. package/cjs/src/utils/processData.js +3 -3
  129. package/cjs/src/utils/processData.js.map +1 -1
  130. package/cjs/src/utils/processData.spec.js +3 -4
  131. package/cjs/src/utils/processData.spec.js.map +1 -1
  132. package/cjs/src/utils/processTrigger.d.ts +0 -1
  133. package/cjs/src/utils/processTrigger.d.ts.map +1 -1
  134. package/cjs/src/utils/processTrigger.js +0 -2
  135. package/cjs/src/utils/processTrigger.js.map +1 -1
  136. package/cjs/src/utils.d.ts +2 -10
  137. package/cjs/src/utils.d.ts.map +1 -1
  138. package/cjs/src/utils.js +19 -13
  139. package/cjs/src/utils.js.map +1 -1
  140. package/dist/src/auth.d.ts +16 -28
  141. package/dist/src/auth.d.ts.map +1 -1
  142. package/dist/src/auth.spec.d.ts +0 -12
  143. package/dist/src/auth.spec.d.ts.map +1 -1
  144. package/dist/src/authToken.d.ts +2 -3
  145. package/dist/src/authToken.d.ts.map +1 -1
  146. package/dist/src/authToken.spec.d.ts +2 -0
  147. package/dist/src/authToken.spec.d.ts.map +1 -0
  148. package/dist/src/config.d.ts +0 -1
  149. package/dist/src/config.d.ts.map +1 -1
  150. package/dist/src/embed/app.d.ts +73 -43
  151. package/dist/src/embed/app.d.ts.map +1 -1
  152. package/dist/src/embed/base.d.ts +1 -7
  153. package/dist/src/embed/base.d.ts.map +1 -1
  154. package/dist/src/embed/embedConfig.d.ts +0 -2
  155. package/dist/src/embed/embedConfig.d.ts.map +1 -1
  156. package/dist/src/embed/liveboard.d.ts +14 -28
  157. package/dist/src/embed/liveboard.d.ts.map +1 -1
  158. package/dist/src/embed/sage.d.ts +5 -21
  159. package/dist/src/embed/sage.d.ts.map +1 -1
  160. package/dist/src/embed/search-bar.d.ts +0 -11
  161. package/dist/src/embed/search-bar.d.ts.map +1 -1
  162. package/dist/src/embed/search.d.ts +60 -29
  163. package/dist/src/embed/search.d.ts.map +1 -1
  164. package/dist/src/embed/ts-embed.d.ts +1 -31
  165. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  166. package/dist/src/index.d.ts +1 -3
  167. package/dist/src/index.d.ts.map +1 -1
  168. package/dist/src/mixpanel-service.d.ts +1 -3
  169. package/dist/src/mixpanel-service.d.ts.map +1 -1
  170. package/dist/src/react/index.d.ts +2 -13
  171. package/dist/src/react/index.d.ts.map +1 -1
  172. package/dist/src/test/test-utils.d.ts +0 -2
  173. package/dist/src/test/test-utils.d.ts.map +1 -1
  174. package/dist/src/tokenizedFetch.d.ts +0 -1
  175. package/dist/src/tokenizedFetch.d.ts.map +1 -1
  176. package/dist/src/types.d.ts +276 -369
  177. package/dist/src/types.d.ts.map +1 -1
  178. package/dist/src/utils/authService/authService.d.ts +0 -2
  179. package/dist/src/utils/authService/authService.d.ts.map +1 -1
  180. package/dist/src/utils/authService/tokenizedAuthService.d.ts +2 -15
  181. package/dist/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
  182. package/dist/src/utils/graphql/answerService/answer-queries.d.ts +3 -0
  183. package/dist/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
  184. package/dist/src/utils/graphql/answerService/answerService.d.ts +37 -12
  185. package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  186. package/dist/src/utils/logger.d.ts.map +1 -1
  187. package/dist/src/utils/processTrigger.d.ts +0 -1
  188. package/dist/src/utils/processTrigger.d.ts.map +1 -1
  189. package/dist/src/utils.d.ts +2 -10
  190. package/dist/src/utils.d.ts.map +1 -1
  191. package/dist/tsembed-react.es.js +6935 -7012
  192. package/dist/tsembed-react.js +6928 -7002
  193. package/dist/tsembed.es.js +1961 -2240
  194. package/dist/tsembed.js +15248 -15519
  195. package/dist/visual-embed-sdk-react-full.d.ts +480 -648
  196. package/dist/visual-embed-sdk-react.d.ts +480 -648
  197. package/dist/visual-embed-sdk.d.ts +479 -636
  198. package/lib/package.json +2 -1
  199. package/lib/src/auth.d.ts +16 -28
  200. package/lib/src/auth.d.ts.map +1 -1
  201. package/lib/src/auth.js +53 -52
  202. package/lib/src/auth.js.map +1 -1
  203. package/lib/src/auth.spec.d.ts +0 -12
  204. package/lib/src/auth.spec.d.ts.map +1 -1
  205. package/lib/src/auth.spec.js +66 -88
  206. package/lib/src/auth.spec.js.map +1 -1
  207. package/lib/src/authToken.d.ts +2 -3
  208. package/lib/src/authToken.d.ts.map +1 -1
  209. package/lib/src/authToken.js +12 -13
  210. package/lib/src/authToken.js.map +1 -1
  211. package/lib/src/authToken.spec.d.ts +2 -0
  212. package/lib/src/authToken.spec.d.ts.map +1 -0
  213. package/lib/src/authToken.spec.js +26 -0
  214. package/lib/src/authToken.spec.js.map +1 -0
  215. package/lib/src/config.d.ts +0 -1
  216. package/lib/src/config.d.ts.map +1 -1
  217. package/lib/src/config.js +0 -2
  218. package/lib/src/config.js.map +1 -1
  219. package/lib/src/embed/app.d.ts +73 -43
  220. package/lib/src/embed/app.d.ts.map +1 -1
  221. package/lib/src/embed/app.js +44 -11
  222. package/lib/src/embed/app.js.map +1 -1
  223. package/lib/src/embed/app.spec.js +24 -5
  224. package/lib/src/embed/app.spec.js.map +1 -1
  225. package/lib/src/embed/base.d.ts +1 -7
  226. package/lib/src/embed/base.d.ts.map +1 -1
  227. package/lib/src/embed/base.js +8 -16
  228. package/lib/src/embed/base.js.map +1 -1
  229. package/lib/src/embed/base.spec.js +4 -3
  230. package/lib/src/embed/base.spec.js.map +1 -1
  231. package/lib/src/embed/embed.spec.js +0 -2
  232. package/lib/src/embed/embed.spec.js.map +1 -1
  233. package/lib/src/embed/embedConfig.d.ts +0 -2
  234. package/lib/src/embed/embedConfig.d.ts.map +1 -1
  235. package/lib/src/embed/embedConfig.js +0 -2
  236. package/lib/src/embed/embedConfig.js.map +1 -1
  237. package/lib/src/embed/events.spec.js +0 -2
  238. package/lib/src/embed/events.spec.js.map +1 -1
  239. package/lib/src/embed/liveboard.d.ts +14 -28
  240. package/lib/src/embed/liveboard.d.ts.map +1 -1
  241. package/lib/src/embed/liveboard.js +9 -9
  242. package/lib/src/embed/liveboard.js.map +1 -1
  243. package/lib/src/embed/liveboard.spec.js +79 -6
  244. package/lib/src/embed/liveboard.spec.js.map +1 -1
  245. package/lib/src/embed/pinboard.spec.js +0 -2
  246. package/lib/src/embed/pinboard.spec.js.map +1 -1
  247. package/lib/src/embed/sage.d.ts +5 -21
  248. package/lib/src/embed/sage.d.ts.map +1 -1
  249. package/lib/src/embed/sage.js +2 -23
  250. package/lib/src/embed/sage.js.map +1 -1
  251. package/lib/src/embed/sage.spec.js +20 -33
  252. package/lib/src/embed/sage.spec.js.map +1 -1
  253. package/lib/src/embed/search-bar.d.ts +0 -11
  254. package/lib/src/embed/search-bar.d.ts.map +1 -1
  255. package/lib/src/embed/search-bar.js +0 -2
  256. package/lib/src/embed/search-bar.js.map +1 -1
  257. package/lib/src/embed/search.d.ts +60 -29
  258. package/lib/src/embed/search.d.ts.map +1 -1
  259. package/lib/src/embed/search.js +43 -9
  260. package/lib/src/embed/search.js.map +1 -1
  261. package/lib/src/embed/search.spec.js +35 -2
  262. package/lib/src/embed/search.spec.js.map +1 -1
  263. package/lib/src/embed/ts-embed-trigger.spec.js +0 -2
  264. package/lib/src/embed/ts-embed-trigger.spec.js.map +1 -1
  265. package/lib/src/embed/ts-embed.d.ts +1 -31
  266. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  267. package/lib/src/embed/ts-embed.js +37 -47
  268. package/lib/src/embed/ts-embed.js.map +1 -1
  269. package/lib/src/embed/ts-embed.spec.js +83 -16
  270. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  271. package/lib/src/errors.js +1 -1
  272. package/lib/src/errors.js.map +1 -1
  273. package/lib/src/index.d.ts +1 -3
  274. package/lib/src/index.d.ts.map +1 -1
  275. package/lib/src/index.js +1 -3
  276. package/lib/src/index.js.map +1 -1
  277. package/lib/src/mixpanel-service.d.ts +1 -3
  278. package/lib/src/mixpanel-service.d.ts.map +1 -1
  279. package/lib/src/mixpanel-service.js +0 -2
  280. package/lib/src/mixpanel-service.js.map +1 -1
  281. package/lib/src/mixpanel-service.spec.js +0 -7
  282. package/lib/src/mixpanel-service.spec.js.map +1 -1
  283. package/lib/src/react/index.d.ts +2 -13
  284. package/lib/src/react/index.d.ts.map +1 -1
  285. package/lib/src/react/index.js +2 -12
  286. package/lib/src/react/index.js.map +1 -1
  287. package/lib/src/react/index.spec.js +16 -10
  288. package/lib/src/react/index.spec.js.map +1 -1
  289. package/lib/src/test/test-utils.d.ts +0 -2
  290. package/lib/src/test/test-utils.d.ts.map +1 -1
  291. package/lib/src/test/test-utils.js +0 -2
  292. package/lib/src/test/test-utils.js.map +1 -1
  293. package/lib/src/tokenizedFetch.d.ts +0 -1
  294. package/lib/src/tokenizedFetch.d.ts.map +1 -1
  295. package/lib/src/tokenizedFetch.js +0 -1
  296. package/lib/src/tokenizedFetch.js.map +1 -1
  297. package/lib/src/types.d.ts +276 -369
  298. package/lib/src/types.d.ts.map +1 -1
  299. package/lib/src/types.js +226 -299
  300. package/lib/src/types.js.map +1 -1
  301. package/lib/src/utils/authService/authService.d.ts +0 -2
  302. package/lib/src/utils/authService/authService.d.ts.map +1 -1
  303. package/lib/src/utils/authService/authService.js +0 -2
  304. package/lib/src/utils/authService/authService.js.map +1 -1
  305. package/lib/src/utils/authService/authService.spec.js +6 -19
  306. package/lib/src/utils/authService/authService.spec.js.map +1 -1
  307. package/lib/src/utils/authService/tokenizedAuthService.d.ts +2 -15
  308. package/lib/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
  309. package/lib/src/utils/authService/tokenizedAuthService.js +8 -37
  310. package/lib/src/utils/authService/tokenizedAuthService.js.map +1 -1
  311. package/lib/src/utils/graphql/answerService/answer-queries.d.ts +3 -0
  312. package/lib/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
  313. package/lib/src/utils/graphql/answerService/answer-queries.js +74 -0
  314. package/lib/src/utils/graphql/answerService/answer-queries.js.map +1 -1
  315. package/lib/src/utils/graphql/answerService/answerService.d.ts +37 -12
  316. package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  317. package/lib/src/utils/graphql/answerService/answerService.js +71 -15
  318. package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
  319. package/lib/src/utils/graphql/answerService/answerService.spec.js +80 -2
  320. package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
  321. package/lib/src/utils/logger.d.ts.map +1 -1
  322. package/lib/src/utils/logger.js +2 -3
  323. package/lib/src/utils/logger.js.map +1 -1
  324. package/lib/src/utils/processData.js +4 -4
  325. package/lib/src/utils/processData.js.map +1 -1
  326. package/lib/src/utils/processData.spec.js +3 -4
  327. package/lib/src/utils/processData.spec.js.map +1 -1
  328. package/lib/src/utils/processTrigger.d.ts +0 -1
  329. package/lib/src/utils/processTrigger.d.ts.map +1 -1
  330. package/lib/src/utils/processTrigger.js +0 -2
  331. package/lib/src/utils/processTrigger.js.map +1 -1
  332. package/lib/src/utils.d.ts +2 -10
  333. package/lib/src/utils.d.ts.map +1 -1
  334. package/lib/src/utils.js +17 -12
  335. package/lib/src/utils.js.map +1 -1
  336. package/lib/src/visual-embed-sdk.d.ts +486 -647
  337. package/package.json +2 -1
  338. package/src/auth.spec.ts +72 -92
  339. package/src/auth.ts +62 -57
  340. package/src/authToken.spec.ts +31 -0
  341. package/src/authToken.ts +12 -12
  342. package/src/config.ts +0 -2
  343. package/src/embed/app.spec.ts +39 -5
  344. package/src/embed/app.ts +108 -50
  345. package/src/embed/base.spec.ts +5 -4
  346. package/src/embed/base.ts +30 -36
  347. package/src/embed/embed.spec.ts +0 -2
  348. package/src/embed/embedConfig.ts +0 -2
  349. package/src/embed/events.spec.ts +0 -2
  350. package/src/embed/liveboard.spec.ts +104 -11
  351. package/src/embed/liveboard.ts +25 -38
  352. package/src/embed/pinboard.spec.ts +0 -2
  353. package/src/embed/sage.spec.ts +20 -38
  354. package/src/embed/sage.ts +5 -38
  355. package/src/embed/search-bar.tsx +0 -11
  356. package/src/embed/search.spec.ts +48 -2
  357. package/src/embed/search.ts +94 -38
  358. package/src/embed/ts-embed-trigger.spec.ts +0 -3
  359. package/src/embed/ts-embed.spec.ts +109 -32
  360. package/src/embed/ts-embed.ts +68 -79
  361. package/src/errors.ts +1 -1
  362. package/src/index.ts +1 -3
  363. package/src/mixpanel-service.spec.ts +3 -12
  364. package/src/mixpanel-service.ts +1 -4
  365. package/src/react/index.spec.tsx +48 -67
  366. package/src/react/index.tsx +1 -13
  367. package/src/test/test-utils.ts +0 -2
  368. package/src/tokenizedFetch.ts +0 -1
  369. package/src/types.ts +276 -368
  370. package/src/utils/authService/authService.spec.ts +9 -22
  371. package/src/utils/authService/authService.ts +0 -2
  372. package/src/utils/authService/tokenizedAuthService.ts +8 -38
  373. package/src/utils/graphql/answerService/answer-queries.ts +77 -0
  374. package/src/utils/graphql/answerService/answerService.spec.ts +88 -2
  375. package/src/utils/graphql/answerService/answerService.ts +87 -16
  376. package/src/utils/logger.ts +2 -3
  377. package/src/utils/processData.spec.ts +3 -4
  378. package/src/utils/processData.ts +4 -4
  379. package/src/utils/processTrigger.ts +0 -2
  380. package/src/utils.ts +21 -13
  381. package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts +0 -2
  382. package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts.map +0 -1
  383. package/cjs/src/utils/authService/tokenizedAuthService.spec.js +0 -32
  384. package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +0 -1
  385. package/cjs/src/utils/sessionInfoService.d.ts +0 -66
  386. package/cjs/src/utils/sessionInfoService.d.ts.map +0 -1
  387. package/cjs/src/utils/sessionInfoService.js +0 -92
  388. package/cjs/src/utils/sessionInfoService.js.map +0 -1
  389. package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts +0 -2
  390. package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts.map +0 -1
  391. package/dist/src/utils/sessionInfoService.d.ts +0 -66
  392. package/dist/src/utils/sessionInfoService.d.ts.map +0 -1
  393. package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts +0 -2
  394. package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts.map +0 -1
  395. package/lib/src/utils/authService/tokenizedAuthService.spec.js +0 -29
  396. package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +0 -1
  397. package/lib/src/utils/sessionInfoService.d.ts +0 -66
  398. package/lib/src/utils/sessionInfoService.d.ts.map +0 -1
  399. package/lib/src/utils/sessionInfoService.js +0 -85
  400. package/lib/src/utils/sessionInfoService.js.map +0 -1
  401. package/src/utils/authService/tokenizedAuthService.spec.ts +0 -36
  402. 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.1-alpha.1",
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 { logger } from './utils/logger';
11
- import * as SessionService from './utils/sessionInfoService';
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.TrustedAuthToken,
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
- authTokenService.resetCachedAuthToken();
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, it is cached', async () => {
145
- jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockResolvedValueOnce(mockSessionInfoApiResponse);
146
- const sessionInfo = await SessionService.getSessionInfo();
147
- expect(sessionInfo.mixpanelToken).toEqual('prodKey');
148
- expect(sessionInfo.isPublicUser).toEqual(false);
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.postLoginService();
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
- const getAuthenticationTokenMock = jest.spyOn(authTokenService, 'getAuthenticationToken');
185
- jest.spyOn(tokenAuthService, 'isActiveService').mockImplementation(async () => true);
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(authTokenService.getAuthenticationToken).not.toBeCalled();
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, 'isActiveService').mockImplementation(async () => false);
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, 'isActiveService').mockImplementation(async () => false);
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(authService.fetchAuthService).toBeCalledWith(thoughtSpotHost, username, 'abc');
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.isActiveService).toHaveBeenCalledTimes(2);
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
- jest.spyOn(tokenAuthService, 'isActiveService').mockResolvedValueOnce(true);
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
- // expect(tokenAuthService.fetchSessionInfoService).toBeCalled();
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(tokenAuthService, 'isActiveService').mockReturnValue(true);
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, 'isActiveService')
388
- .mockReturnValueOnce(false)
389
- .mockReturnValueOnce(true);
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(authInstance.loggedInStatus).toBe(true);
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
- authTokenService.resetCachedAuthToken();
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', async () => {
503
+ it('getSessionDetails returns the correct details given sessionInfo', () => {
495
504
  jest.clearAllMocks();
496
505
  jest.restoreAllMocks();
497
506
 
498
- jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockReturnValue({
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
- jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockReturnValue({
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 { getSessionInfo } from './utils/sessionInfoService';
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 async function notifyAuthSuccess(): Promise<void> {
173
+ export function notifyAuthSuccess(): void {
174
174
  if (!authEE) {
175
175
  logger.error('SDK not initialized');
176
176
  return;
177
177
  }
178
- try {
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
- const response = await isActiveService(thoughtSpotHost);
217
- return response;
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
- * Services to be called after the login is successful,
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 async function postLoginService(): Promise<void> {
236
- const sessionInfo = await getSessionInfo();
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 releaseVersion if available
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 getReleaseVersion() {
248
- return releaseVersion;
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
- let authToken: string;
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> => {