From 167f404f917c2df3299d38ce5a816c71484f3197 Mon Sep 17 00:00:00 2001 From: Jacob Fink Date: Mon, 26 Jun 2023 10:18:33 -0400 Subject: [PATCH] check storage for user key if missing in memory --- .../emergency-access/emergency-access.component.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/web/src/app/auth/settings/emergency-access/emergency-access.component.ts b/apps/web/src/app/auth/settings/emergency-access/emergency-access.component.ts index a6c5c0dab0..932e54b102 100644 --- a/apps/web/src/app/auth/settings/emergency-access/emergency-access.component.ts +++ b/apps/web/src/app/auth/settings/emergency-access/emergency-access.component.ts @@ -12,6 +12,7 @@ import { EmergencyAccessGranteeDetailsResponse, EmergencyAccessGrantorDetailsResponse, } from "@bitwarden/common/auth/models/response/emergency-access.response"; +import { KeySuffixOptions } from "@bitwarden/common/enums"; import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; @@ -302,7 +303,11 @@ export class EmergencyAccessComponent implements OnInit { // Encrypt the user key with the grantees public key, and send it to bitwarden for escrow. private async doConfirmation(details: EmergencyAccessGranteeDetailsResponse) { - const userKey = await this.cryptoService.getUserKeyFromMemory(); + let userKey = await this.cryptoService.getUserKeyFromMemory(); + userKey ||= await this.cryptoService.getUserKeyFromStorage(KeySuffixOptions.Auto); + if (!userKey) { + throw new Error("No user key found"); + } const publicKeyResponse = await this.apiService.getUserPublicKey(details.granteeId); const publicKey = Utils.fromB64ToArray(publicKeyResponse.publicKey);