From a11512553b580043d17cf1b6f5de3aa89df769b3 Mon Sep 17 00:00:00 2001 From: jbhanu-thoughtspot <53254394+jbhanu-thoughtspot@users.noreply.github.com> Date: Tue, 24 Sep 2024 22:10:37 -0700 Subject: [PATCH] SCAL-225725 - Fixed failing /info for non-cookieless calls (#27) Co-authored-by: Aditya Mittal <114516106+adityamittal3107@users.noreply.github.com> --- package-lock.json | 12 ++++++------ package.json | 6 +++--- src/tokenizedFetch.ts | 6 +++++- src/utils/authService/authService.spec.ts | 4 +++- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index bc725cda..a06db62f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@thoughtspot/visual-embed-sdk", - "version": "1.32.3", + "version": "1.32.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@thoughtspot/visual-embed-sdk", - "version": "1.32.3", + "version": "1.32.8", "license": "ThoughtSpot Development Tools End User License Agreement", "dependencies": { "algoliasearch": "^4.10.5", @@ -18,7 +18,7 @@ "gatsby-plugin-vercel": "^1.0.3", "html-react-parser": "^1.4.12", "lodash": "^4.17.21", - "mixpanel-browser": "^2.45.0", + "mixpanel-browser": "2.47.0", "ts-deepmerge": "^6.0.2", "tslib": "^2.5.3", "use-deep-compare-effect": "^1.8.1" @@ -14356,9 +14356,9 @@ } }, "node_modules/mixpanel-browser": { - "version": "2.45.0", - "resolved": "https://registry.npmjs.org/mixpanel-browser/-/mixpanel-browser-2.45.0.tgz", - "integrity": "sha512-PQ1DaTk68yyYtLA0iejmzPA9iNDhT4uIZpqZjRTw7HWpYfl123fydHb2laKanaKjm8YDmrGGz3+xZ4Q6joogyg==" + "version": "2.47.0", + "resolved": "https://registry.npmjs.org/mixpanel-browser/-/mixpanel-browser-2.47.0.tgz", + "integrity": "sha512-Ldrva0fRBEIFWmEibBQO1PulfpJVF3pf28Guk09lDirDaSQqqU/xs9zQLwN2rL5VwVtsP1aD3JaCgaa98EjojQ==" }, "node_modules/mkdirp": { "version": "0.5.6", diff --git a/package.json b/package.json index fcb420b5..477f386a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@thoughtspot/visual-embed-sdk", - "version": "1.32.7", + "version": "1.32.8", "description": "ThoughtSpot Embed SDK", "module": "lib/src/index.js", "main": "dist/tsembed.js", @@ -38,7 +38,7 @@ "size-limit": [ { "path": "dist/tsembed.js", - "limit": "48 kB" + "limit": "49 kB" } ], "scripts": { @@ -77,7 +77,7 @@ "gatsby-plugin-vercel": "^1.0.3", "html-react-parser": "^1.4.12", "lodash": "^4.17.21", - "mixpanel-browser": "^2.45.0", + "mixpanel-browser": "2.47.0", "ts-deepmerge": "^6.0.2", "tslib": "^2.5.3", "use-deep-compare-effect": "^1.8.1" diff --git a/src/tokenizedFetch.ts b/src/tokenizedFetch.ts index 8c8edb77..69bf462b 100644 --- a/src/tokenizedFetch.ts +++ b/src/tokenizedFetch.ts @@ -22,7 +22,11 @@ import { AuthType } from './types'; export const tokenizedFetch: typeof fetch = async (input, init): Promise => { const embedConfig = getEmbedConfig(); if (embedConfig.authType !== AuthType.TrustedAuthTokenCookieless) { - return fetch(input, init); + return fetch(input, { + // ensure cookies are included for the non cookie-less api calls. + credentials: 'include', + ...init, + }); } const req = new Request(input, init); diff --git a/src/utils/authService/authService.spec.ts b/src/utils/authService/authService.spec.ts index 957a57a1..90fa7a43 100644 --- a/src/utils/authService/authService.spec.ts +++ b/src/utils/authService/authService.spec.ts @@ -29,7 +29,9 @@ describe('Unit test for authService', () => { const response = await fetchSessionInfoService(thoughtSpotHost); expect(response.success).toBe(true); expect(fetch).toHaveBeenCalledTimes(1); - expect(fetch).toBeCalledWith(`${thoughtSpotHost}${EndPoints.SESSION_INFO}`, {}); + expect(fetch).toBeCalledWith(`${thoughtSpotHost}${EndPoints.SESSION_INFO}`, { + credentials: 'include', + }); }); test('fetchAuthTokenService', async () => {