fleet/frontend/utilities/local.ts
Gabriel Hernandez a0c5102903
update auth token storage (#40504)
**Related issue:** Resolves #14401

# Checklist for submitter

this updates the mechanism of storing the auth token for a user that is
used for making requests and validating a user session. We change the
storage from local storage to a cookie. This allow a bit more security
and prepares for a future change where we will allow the browser to
handle setting and passing the auth token in the request.


- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
- [x] QA'd all new/changed functionality manually
2026-02-26 17:05:13 +00:00

20 lines
478 B
TypeScript

const {
window: { localStorage },
} = global;
const local = {
clear: (): void => {
localStorage.clear();
},
getItem: (itemName: string): string | null => {
return localStorage.getItem(`FLEET::${itemName}`);
},
setItem: (itemName: string, value: string): void => {
return localStorage.setItem(`FLEET::${itemName}`, value);
},
removeItem: (itemName: string): void => {
localStorage.removeItem(`FLEET::${itemName}`);
},
};
export default local;