whodis-react-storage-browser
Version:
React hooks and components for secure, best practices authentication in seconds
24 lines • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteSynchronizationCookie = void 0;
const simple_cookie_client_1 = require("simple-cookie-client");
/**
* delete the synchronization cookie
*
* usecases
* - browser detects that the anti-csrf token is not in sync w/ auth token -> delete the sync cookie to inform server that user is logged out
*
* note
* - decodes the synchronization token to extract the domain and path to correctly delete it
*/
const deleteSynchronizationCookie = () => {
// lookup it's current value
const synchronizationCookie = (0, simple_cookie_client_1.getCookie)({ name: 'synchronization' });
if (!synchronizationCookie)
return; // if it doesn't exist, nothing to delete
// delete it
const domain = synchronizationCookie.value.split(':')[1];
(0, simple_cookie_client_1.deleteCookie)({ name: 'synchronization', domain, path: '/' });
};
exports.deleteSynchronizationCookie = deleteSynchronizationCookie;
//# sourceMappingURL=deleteSynchronizationCookie.js.map