From 42db4eb0ac291ec7d8a1833f009fed545ad6db76 Mon Sep 17 00:00:00 2001 From: Jacob Fink Date: Fri, 9 Jun 2023 08:52:02 -0400 Subject: [PATCH] remove old EncKey methods from crypto service --- .../app/settings/change-email.component.ts | 4 +-- .../change-kdf-confirmation.component.ts | 4 +-- .../vault/individual-vault/vault.component.ts | 2 +- .../vault/components/attachments.component.ts | 2 +- .../platform/abstractions/crypto.service.ts | 2 -- .../src/platform/services/crypto.service.ts | 27 ------------------- 6 files changed, 6 insertions(+), 35 deletions(-) diff --git a/apps/web/src/app/settings/change-email.component.ts b/apps/web/src/app/settings/change-email.component.ts index 40f1be17115..696c924beec 100644 --- a/apps/web/src/app/settings/change-email.component.ts +++ b/apps/web/src/app/settings/change-email.component.ts @@ -42,8 +42,8 @@ export class ChangeEmailComponent implements OnInit { } async submit() { - const hasEncKey = await this.cryptoService.hasEncKey(); - if (!hasEncKey) { + const hasUserKey = await this.cryptoService.hasUserKey(); + if (!hasUserKey) { this.platformUtilsService.showToast("error", null, this.i18nService.t("updateKey")); return; } diff --git a/apps/web/src/app/settings/change-kdf/change-kdf-confirmation.component.ts b/apps/web/src/app/settings/change-kdf/change-kdf-confirmation.component.ts index 53abeb4623f..30dab42f966 100644 --- a/apps/web/src/app/settings/change-kdf/change-kdf-confirmation.component.ts +++ b/apps/web/src/app/settings/change-kdf/change-kdf-confirmation.component.ts @@ -46,8 +46,8 @@ export class ChangeKdfConfirmationComponent { async submit() { this.loading = true; - const hasEncKey = await this.cryptoService.hasEncKey(); - if (!hasEncKey) { + const hasUserKey = await this.cryptoService.hasUserKey(); + if (!hasUserKey) { this.platformUtilsService.showToast("error", null, this.i18nService.t("updateKey")); return; } diff --git a/apps/web/src/app/vault/individual-vault/vault.component.ts b/apps/web/src/app/vault/individual-vault/vault.component.ts index 176fb3fcb36..f3968cf249b 100644 --- a/apps/web/src/app/vault/individual-vault/vault.component.ts +++ b/apps/web/src/app/vault/individual-vault/vault.component.ts @@ -195,7 +195,7 @@ export class VaultComponent implements OnInit, OnDestroy { const canAccessPremium = await this.stateService.getCanAccessPremium(); this.showPremiumCallout = !this.showVerifyEmail && !canAccessPremium && !this.platformUtilsService.isSelfHost(); - this.showUpdateKey = !(await this.cryptoService.hasEncKey()); + this.showUpdateKey = !(await this.cryptoService.hasUserKey()); const cipherId = getCipherIdFromParams(params); if (!cipherId) { diff --git a/libs/angular/src/vault/components/attachments.component.ts b/libs/angular/src/vault/components/attachments.component.ts index e4daf6e37f3..bdb494dfd2b 100644 --- a/libs/angular/src/vault/components/attachments.component.ts +++ b/libs/angular/src/vault/components/attachments.component.ts @@ -192,7 +192,7 @@ export class AttachmentsComponent implements OnInit { this.cipherDomain = await this.loadCipher(); this.cipher = await this.cipherDomain.decrypt(); - this.hasUpdatedKey = await this.cryptoService.hasEncKey(); + this.hasUpdatedKey = await this.cryptoService.hasUserKey(); const canAccessPremium = await this.stateService.getCanAccessPremium(); this.canAccessAttachments = canAccessPremium || this.cipher.organizationId != null; diff --git a/libs/common/src/platform/abstractions/crypto.service.ts b/libs/common/src/platform/abstractions/crypto.service.ts index c71d53b1f7f..b60c414880f 100644 --- a/libs/common/src/platform/abstractions/crypto.service.ts +++ b/libs/common/src/platform/abstractions/crypto.service.ts @@ -119,7 +119,5 @@ export abstract class CryptoService { decryptToBytes: (encString: EncString, key?: SymmetricCryptoKey) => Promise; decryptToUtf8: (encString: EncString, key?: SymmetricCryptoKey) => Promise; decryptFromBytes: (encBuffer: EncArrayBuffer, key: SymmetricCryptoKey) => Promise; - setEncKey: (encKey: string) => Promise; - hasEncKey: () => Promise; clearEncKey: (memoryOnly?: boolean, userId?: string) => Promise; } diff --git a/libs/common/src/platform/services/crypto.service.ts b/libs/common/src/platform/services/crypto.service.ts index efe96150196..b591b0cbe81 100644 --- a/libs/common/src/platform/services/crypto.service.ts +++ b/libs/common/src/platform/services/crypto.service.ts @@ -1161,33 +1161,6 @@ export class CryptoService implements CryptoServiceAbstraction { return this.encryptService.decryptToBytes(encBuffer, key); } - /** - * @deprecated use SetUserKey instead - */ - async setEncKey(encKey: string): Promise { - if (encKey == null) { - return; - } - - await this.stateService.setDecryptedCryptoSymmetricKey(null); - await this.stateService.setEncryptedCryptoSymmetricKey(encKey); - } - - /** - * @deprecated use getUserKey instead - */ - @sequentialize(() => "getEncKey") - getEncKey(key: SymmetricCryptoKey = null): Promise { - return this.getEncKeyHelper(key); - } - - /** - * @deprecated use hasUserKey instead - */ - async hasEncKey(): Promise { - return (await this.stateService.getEncryptedCryptoSymmetricKey()) != null; - } - /** * @deprecated use clearKey instead */