1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

[PM-3685] Remove ipcRenderer from electron-renderer-storage (#6481)

* [PM-3685] Remove ipcRenderer from renderer-storage

* Break out storage and keytar into separate functions
This commit is contained in:
Daniel García
2023-10-23 12:27:49 +02:00
committed by GitHub
parent c2613af4f6
commit 55bc275f40
3 changed files with 32 additions and 42 deletions

View File

@@ -4,6 +4,27 @@ import { DeviceType, ThemeType } from "@bitwarden/common/enums";
import { isDev, isWindowsStore } from "../utils";
const storage = {
get: <T>(key: string): Promise<T> => ipcRenderer.invoke("storageService", { action: "get", key }),
has: (key: string): Promise<boolean> =>
ipcRenderer.invoke("storageService", { action: "has", key }),
save: (key: string, obj: any): Promise<void> =>
ipcRenderer.invoke("storageService", { action: "save", key, obj }),
remove: (key: string): Promise<void> =>
ipcRenderer.invoke("storageService", { action: "remove", key }),
};
const passwords = {
get: (key: string, keySuffix: string): Promise<string> =>
ipcRenderer.invoke("keytar", { action: "getPassword", key, keySuffix }),
has: (key: string, keySuffix: string): Promise<boolean> =>
ipcRenderer.invoke("keytar", { action: "hasPassword", key, keySuffix }),
set: (key: string, keySuffix: string, value: string): Promise<void> =>
ipcRenderer.invoke("keytar", { action: "setPassword", key, keySuffix, value }),
delete: (key: string, keySuffix: string): Promise<void> =>
ipcRenderer.invoke("keytar", { action: "deletePassword", key, keySuffix }),
};
export default {
versions: {
app: (): Promise<string> => ipcRenderer.invoke("appVersion"),
@@ -27,6 +48,9 @@ export default {
}
});
},
storage,
passwords,
};
function deviceType(): DeviceType {