From 10ff47b0c960db39f1791fc5e86cd32e9cc5f08e Mon Sep 17 00:00:00 2001 From: Juliana Kang Date: Wed, 20 Nov 2024 09:02:53 -0500 Subject: [PATCH] fix: Remove existing Tagular cookie with outdated domain metadata (#34) --- audit-ci.json | 3 ++- src/cohesion/helpers.js | 7 ++++++- src/payment/PaymentPage.test.jsx | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/audit-ci.json b/audit-ci.json index 9ef402b2d..7edb4b42a 100644 --- a/audit-ci.json +++ b/audit-ci.json @@ -12,7 +12,8 @@ "GHSA-9wv6-86v2-598j", "GHSA-m6fv-jmcg-4jfg", "GHSA-cm22-4g7w-348p", - "GHSA-c7qv-q95q-8v27" + "GHSA-c7qv-q95q-8v27", + "GHSA-3xgq-45jj-v275" ], "moderate": true } diff --git a/src/cohesion/helpers.js b/src/cohesion/helpers.js index c66c9ae55..3db71fc43 100644 --- a/src/cohesion/helpers.js +++ b/src/cohesion/helpers.js @@ -27,9 +27,14 @@ export const getCorrelationID = () => { paramId = uuidv4(); } + // If the tagular correlation ID cookie was set before we added the change to + // specify the domain, it was automatically added to the current domain. + // Always delete the cookie with the current domain + new Cookies().remove(COOKIE_NAME, { domain: window.location.hostname, path: '/' }); + const expirationDate = new Date(); expirationDate.setMinutes(expirationDate.getMinutes() + 30); // 30 mins expiration from now - new Cookies().set(COOKIE_NAME, paramId, { expires: expirationDate, domain: `.${getDomain()}` }); + new Cookies().set(COOKIE_NAME, paramId, { expires: expirationDate, domain: `.${getDomain()}`, path: '/' }); return paramId; }; diff --git a/src/payment/PaymentPage.test.jsx b/src/payment/PaymentPage.test.jsx index f99de8d37..4a0bf6284 100644 --- a/src/payment/PaymentPage.test.jsx +++ b/src/payment/PaymentPage.test.jsx @@ -43,6 +43,10 @@ jest.mock('universal-cookie', () => { set(cookieName) { return MockCookies.result[cookieName]; } + + remove() { + return undefined; + } } return MockCookies; });