1
0
mirror of https://github.com/bitwarden/jslib synced 2026-01-01 08:03:17 +00:00

Convert sendSync with invoke

This commit is contained in:
Hinton
2022-04-25 15:53:31 +02:00
parent 3b8ea9f97d
commit 45a09002f3
2 changed files with 11 additions and 14 deletions

View File

@@ -183,13 +183,12 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
return await this.stateService.getEnableBiometric();
}
authenticateBiometric(): Promise<boolean> {
return new Promise((resolve) => {
const val = ipcRenderer.sendSync("biometric", {
action: "authenticate",
});
resolve(val);
async authenticateBiometric(): Promise<boolean> {
const val = await ipcRenderer.invoke("biometric", {
action: "authenticate",
});
return val;
}
getDefaultSystemTheme() {

View File

@@ -5,39 +5,37 @@ import { StorageOptions } from "jslib-common/models/domain/storageOptions";
export class ElectronRendererSecureStorageService implements StorageService {
async get<T>(key: string, options?: StorageOptions): Promise<T> {
const val = ipcRenderer.sendSync("keytar", {
const val = await ipcRenderer.invoke("keytar", {
action: "getPassword",
key: key,
keySuffix: options?.keySuffix ?? "",
});
return Promise.resolve(val != null ? (JSON.parse(val) as T) : null);
return val != null ? (JSON.parse(val) as T) : null;
}
async has(key: string, options?: StorageOptions): Promise<boolean> {
const val = ipcRenderer.sendSync("keytar", {
const val = await ipcRenderer.invoke("keytar", {
action: "hasPassword",
key: key,
keySuffix: options?.keySuffix ?? "",
});
return Promise.resolve(!!val);
return !!val;
}
async save(key: string, obj: any, options?: StorageOptions): Promise<any> {
ipcRenderer.sendSync("keytar", {
await ipcRenderer.invoke("keytar", {
action: "setPassword",
key: key,
keySuffix: options?.keySuffix ?? "",
value: JSON.stringify(obj),
});
return Promise.resolve();
}
async remove(key: string, options?: StorageOptions): Promise<any> {
ipcRenderer.sendSync("keytar", {
await ipcRenderer.invoke("keytar", {
action: "deletePassword",
key: key,
keySuffix: options?.keySuffix ?? "",
});
return Promise.resolve();
}
}