Skip to content

Commit

Permalink
fix: Remove existing Tagular cookie with outdated domain metadata (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
julianajlk authored Nov 20, 2024
1 parent 70da326 commit 10ff47b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion audit-ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
7 changes: 6 additions & 1 deletion src/cohesion/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 4 additions & 0 deletions src/payment/PaymentPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ jest.mock('universal-cookie', () => {
set(cookieName) {
return MockCookies.result[cookieName];
}

remove() {
return undefined;
}
}
return MockCookies;
});
Expand Down

0 comments on commit 10ff47b

Please sign in to comment.