From d9655c4f82a7d03eae265e061d74f4bdc5aabf23 Mon Sep 17 00:00:00 2001 From: addison Date: Tue, 2 Nov 2021 09:26:35 -0400 Subject: [PATCH] [bug] Add several missing awaits --- common/src/abstractions/cipher.service.ts | 2 +- common/src/abstractions/folder.service.ts | 2 +- common/src/abstractions/system.service.ts | 2 +- common/src/services/crypto.service.ts | 2 +- common/src/services/event.service.ts | 2 +- common/src/services/passwordGeneration.service.ts | 2 +- common/src/services/sync.service.ts | 2 +- common/src/services/system.service.ts | 4 ++-- common/src/services/token.service.ts | 4 ++-- common/src/services/vaultTimeout.service.ts | 12 ++++++------ electron/src/biometric.windows.main.ts | 6 +++--- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/common/src/abstractions/cipher.service.ts b/common/src/abstractions/cipher.service.ts index 031e22b1..0b7934ab 100644 --- a/common/src/abstractions/cipher.service.ts +++ b/common/src/abstractions/cipher.service.ts @@ -11,7 +11,7 @@ import { CipherView } from '../models/view/cipherView'; import { FieldView } from '../models/view/fieldView'; export abstract class CipherService { - clearCache: () => void; + clearCache: () => Promise; encrypt: (model: CipherView, key?: SymmetricCryptoKey, originalCipher?: Cipher) => Promise; encryptFields: (fieldsModel: FieldView[], key: SymmetricCryptoKey) => Promise; encryptField: (fieldModel: FieldView, key: SymmetricCryptoKey) => Promise; diff --git a/common/src/abstractions/folder.service.ts b/common/src/abstractions/folder.service.ts index 48997e5f..b676b421 100644 --- a/common/src/abstractions/folder.service.ts +++ b/common/src/abstractions/folder.service.ts @@ -7,7 +7,7 @@ import { TreeNode } from '../models/domain/treeNode'; import { FolderView } from '../models/view/folderView'; export abstract class FolderService { - clearCache: () => void; + clearCache: () => Promise; encrypt: (model: FolderView, key?: SymmetricCryptoKey) => Promise; get: (id: string) => Promise; getAll: () => Promise; diff --git a/common/src/abstractions/system.service.ts b/common/src/abstractions/system.service.ts index 93850618..203233f2 100644 --- a/common/src/abstractions/system.service.ts +++ b/common/src/abstractions/system.service.ts @@ -1,6 +1,6 @@ export abstract class SystemService { startProcessReload: () => Promise; cancelProcessReload: () => void; - clearClipboard: (clipboardValue: string, timeoutMs?: number) => void; + clearClipboard: (clipboardValue: string, timeoutMs?: number) => Promise; clearPendingClipboard: () => Promise; } diff --git a/common/src/services/crypto.service.ts b/common/src/services/crypto.service.ts index 51d743ae..ab74f9f1 100644 --- a/common/src/services/crypto.service.ts +++ b/common/src/services/crypto.service.ts @@ -364,7 +364,7 @@ export class CryptoService implements CryptoServiceAbstraction { } } - clearKeyPair(memoryOnly?: boolean): Promise { + async clearKeyPair(memoryOnly?: boolean): Promise { const keysToClear: Promise[] = [ this.stateService.setDecryptedPrivateKey(null), this.stateService.setPublicKey(null), diff --git a/common/src/services/event.service.ts b/common/src/services/event.service.ts index 388b64ab..44e6ce65 100644 --- a/common/src/services/event.service.ts +++ b/common/src/services/event.service.ts @@ -65,7 +65,7 @@ export class EventService implements EventServiceAbstraction { } async uploadEvents(): Promise { - const authed = this.stateService.getIsAuthenticated(); + const authed = await this.stateService.getIsAuthenticated(); if (!authed) { return; } diff --git a/common/src/services/passwordGeneration.service.ts b/common/src/services/passwordGeneration.service.ts index 6f8cb360..a93fb68d 100644 --- a/common/src/services/passwordGeneration.service.ts +++ b/common/src/services/passwordGeneration.service.ts @@ -332,7 +332,7 @@ export class PasswordGenerationService implements PasswordGenerationServiceAbstr return new Array(); } - if (this.stateService.getDecryptedPasswordGenerationHistory() != null) { + if (await this.stateService.getDecryptedPasswordGenerationHistory() != null) { const encrypted = await this.stateService.getEncryptedPasswordGenerationHistory(); const decrypted = await this.decryptHistory(encrypted); await this.stateService.setDecryptedPasswordGenerationHistory(decrypted); diff --git a/common/src/services/sync.service.ts b/common/src/services/sync.service.ts index a6490e43..a97f62cc 100644 --- a/common/src/services/sync.service.ts +++ b/common/src/services/sync.service.ts @@ -238,7 +238,7 @@ export class SyncService implements SyncServiceAbstraction { async syncDeleteSend(notification: SyncSendNotification): Promise { this.syncStarted(); - if (this.stateService.getIsAuthenticated()) { + if (await this.stateService.getIsAuthenticated()) { await this.sendService.delete(notification.id); this.messagingService.send('syncedDeletedSend', { sendId: notification.id }); this.syncCompleted(true); diff --git a/common/src/services/system.service.ts b/common/src/services/system.service.ts index 4316e76a..8a354b9e 100644 --- a/common/src/services/system.service.ts +++ b/common/src/services/system.service.ts @@ -49,7 +49,7 @@ export class SystemService implements SystemServiceAbstraction { } } - clearClipboard(clipboardValue: string, timeoutMs: number = null): void { + async clearClipboard(clipboardValue: string, timeoutMs: number = null): Promise { if (this.clearClipboardTimeout != null) { clearTimeout(this.clearClipboardTimeout); this.clearClipboardTimeout = null; @@ -57,7 +57,7 @@ export class SystemService implements SystemServiceAbstraction { if (Utils.isNullOrWhitespace(clipboardValue)) { return; } - this.stateService.getClearClipboard().then(clearSeconds => { + await this.stateService.getClearClipboard().then(clearSeconds => { if (clearSeconds == null) { return; } diff --git a/common/src/services/token.service.ts b/common/src/services/token.service.ts index dd60b478..8094f1e6 100644 --- a/common/src/services/token.service.ts +++ b/common/src/services/token.service.ts @@ -21,7 +21,7 @@ export class TokenService implements TokenServiceAbstraction { if (await this.skipTokenStorage() || clientId == null) { return; } - return this.stateService.setApiKeyClientId(clientId); + return await this.stateService.setApiKeyClientId(clientId); } async getClientId(): Promise { @@ -32,7 +32,7 @@ export class TokenService implements TokenServiceAbstraction { if (await this.skipTokenStorage() || clientSecret == null) { return; } - return this.stateService.setApiKeyClientSecret(clientSecret); + return await this.stateService.setApiKeyClientSecret(clientSecret); } async getClientSecret(): Promise { diff --git a/common/src/services/vaultTimeout.service.ts b/common/src/services/vaultTimeout.service.ts index 87914387..57acb9f8 100644 --- a/common/src/services/vaultTimeout.service.ts +++ b/common/src/services/vaultTimeout.service.ts @@ -44,7 +44,7 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction { // Keys aren't stored for a device that is locked or logged out. async isLocked(): Promise { // Handle never lock startup situation - if (await this.cryptoService.hasKeyStored(KeySuffixOptions.Auto) && !this.stateService.getEverBeenUnlocked()) { + if (await this.cryptoService.hasKeyStored(KeySuffixOptions.Auto) && !(await this.stateService.getEverBeenUnlocked())) { await this.cryptoService.getKey(KeySuffixOptions.Auto); } @@ -92,16 +92,16 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction { return; } - this.stateService.setBiometricLocked(true); - this.stateService.setEverBeenUnlocked(true); + await this.stateService.setBiometricLocked(true); + await this.stateService.setEverBeenUnlocked(true); await this.cryptoService.clearKey(false); await this.cryptoService.clearOrgKeys(true); await this.cryptoService.clearKeyPair(true); await this.cryptoService.clearEncKey(true); - this.folderService.clearCache(); - this.cipherService.clearCache(); - this.collectionService.clearCache(); + await this.folderService.clearCache(); + await this.cipherService.clearCache(); + await this.collectionService.clearCache(); this.searchService.clearIndex(); this.messagingService.send('locked'); if (this.lockedCallback != null) { diff --git a/electron/src/biometric.windows.main.ts b/electron/src/biometric.windows.main.ts index c541b7fe..2bf32388 100644 --- a/electron/src/biometric.windows.main.ts +++ b/electron/src/biometric.windows.main.ts @@ -25,9 +25,9 @@ export default class BiometricWindowsMain implements BiometricMain { // store error state so we can let the user know on the settings page this.isError = true; } - this.stateService.setEnableBiometric(supportsBiometric); - this.stateService.setBiometricText('unlockWithWindowsHello'); - this.stateService.setNoAutoPromptBiometricsText('noAutoPromptWindowsHello'); + await this.stateService.setEnableBiometric(supportsBiometric); + await this.stateService.setBiometricText('unlockWithWindowsHello'); + await this.stateService.setNoAutoPromptBiometricsText('noAutoPromptWindowsHello'); ipcMain.on('biometric', async (event: any, message: any) => { event.returnValue = await this.authenticateBiometric();