Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.
import { ipcRenderer } from "electron";
import { AbstractStorageService } from "@bitwarden/common/abstractions/storage.service";
import { StorageOptions } from "@bitwarden/common/models/domain/storage-options";
export class ElectronRendererSecureStorageService implements AbstractStorageService {
async get<T>(key: string, options?: StorageOptions): Promise<T> {
const val = await ipcRenderer.invoke("keytar", {
action: "getPassword",
key: key,
keySuffix: options?.keySuffix ?? "",
});
return val != null ? (JSON.parse(val) as T) : null;
}
async has(key: string, options?: StorageOptions): Promise<boolean> {
action: "hasPassword",
return !!val;
async save(key: string, obj: any, options?: StorageOptions): Promise<any> {
await ipcRenderer.invoke("keytar", {
action: "setPassword",
value: JSON.stringify(obj),
async remove(key: string, options?: StorageOptions): Promise<any> {
action: "deletePassword",