1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-21 11:53:34 +00:00
Files
browser/apps/desktop/src/platform/services/electron-renderer-secure-storage.service.ts
Daniel García 55bc275f40 [PM-3685] Remove ipcRenderer from electron-renderer-storage (#6481)
* [PM-3685] Remove ipcRenderer from renderer-storage

* Break out storage and keytar into separate functions
2023-10-23 12:27:49 +02:00

23 lines
982 B
TypeScript

import { AbstractStorageService } from "@bitwarden/common/platform/abstractions/storage.service";
import { StorageOptions } from "@bitwarden/common/platform/models/domain/storage-options";
export class ElectronRendererSecureStorageService implements AbstractStorageService {
async get<T>(key: string, options?: StorageOptions): Promise<T> {
const val = await ipc.platform.passwords.get(key, options?.keySuffix ?? "");
return val != null ? (JSON.parse(val) as T) : null;
}
async has(key: string, options?: StorageOptions): Promise<boolean> {
const val = await ipc.platform.passwords.has(key, options?.keySuffix ?? "");
return !!val;
}
async save(key: string, obj: any, options?: StorageOptions): Promise<any> {
await ipc.platform.passwords.set(key, options?.keySuffix ?? "", JSON.stringify(obj));
}
async remove(key: string, options?: StorageOptions): Promise<any> {
await ipc.platform.passwords.delete(key, options?.keySuffix ?? "");
}
}