1
0
mirror of https://github.com/bitwarden/desktop synced 2026-01-19 17:03:18 +00:00

secure storage with keytar

This commit is contained in:
Kyle Spearrin
2018-02-11 00:36:32 -05:00
parent 1ef0d7a9a9
commit fa39ba2d2d
3 changed files with 5 additions and 7 deletions

View File

@@ -0,0 +1,29 @@
import { ipcRenderer } from 'electron';
import { StorageService } from 'jslib/abstractions/storage.service';
export class DesktopRendererSecureStorageService implements StorageService {
async get<T>(key: string): Promise<T> {
const val = ipcRenderer.sendSync('keytar', {
action: 'getPassword',
key: key,
});
return Promise.resolve(val != null ? JSON.parse(val) as T : null);
}
async save(key: string, obj: any): Promise<any> {
ipcRenderer.sendSync('keytar', {
action: 'setPassword',
key: key,
value: JSON.stringify(obj),
});
return Promise.resolve();
}
async remove(key: string): Promise<any> {
ipcRenderer.sendSync('keytar', {
action: 'deletePassword',
key: key,
});
return Promise.resolve();
}
}