mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
pack main and renderer
This commit is contained in:
18
src/services/desktopSecureStorage.service.ts
Normal file
18
src/services/desktopSecureStorage.service.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { getPassword, setPassword, deletePassword } from 'keytar';
|
||||
|
||||
import { StorageService } from 'jslib/abstractions';
|
||||
|
||||
export class DesktopSecureStorageService implements StorageService {
|
||||
async get<T>(key: string): Promise<T> {
|
||||
const val: string = await getPassword('bitwarden', key);
|
||||
return val ? JSON.parse(val) as T : null
|
||||
}
|
||||
|
||||
async save(key: string, obj: any): Promise<any> {
|
||||
await setPassword('bitwarden', key, JSON.stringify(obj));
|
||||
}
|
||||
|
||||
async remove(key: string): Promise<any> {
|
||||
await deletePassword('bitwarden', key);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user