mirror of
https://github.com/ente-io/ente.git
synced 2025-05-24 20:19:17 +00:00
34 lines
830 B
TypeScript
34 lines
830 B
TypeScript
export enum SESSION_KEYS {
|
|
ENCRYPTION_KEY = "encryptionKey",
|
|
KEY_ENCRYPTION_KEY = "keyEncryptionKey",
|
|
}
|
|
|
|
export const setKey = (key: SESSION_KEYS, value: object) => {
|
|
if (typeof sessionStorage === "undefined") {
|
|
return null;
|
|
}
|
|
sessionStorage.setItem(key, JSON.stringify(value));
|
|
};
|
|
|
|
export const getKey = (key: SESSION_KEYS) => {
|
|
if (typeof sessionStorage === "undefined") {
|
|
return null;
|
|
}
|
|
const value = sessionStorage.getItem(key);
|
|
return value && JSON.parse(value);
|
|
};
|
|
|
|
export const removeKey = (key: SESSION_KEYS) => {
|
|
if (typeof sessionStorage === "undefined") {
|
|
return null;
|
|
}
|
|
sessionStorage.removeItem(key);
|
|
};
|
|
|
|
export const clearKeys = () => {
|
|
if (typeof sessionStorage === "undefined") {
|
|
return null;
|
|
}
|
|
sessionStorage.clear();
|
|
};
|