diff --git a/libs/common/src/auth/services/auth.service.ts b/libs/common/src/auth/services/auth.service.ts index fd2027d54e2..ae7661458ef 100644 --- a/libs/common/src/auth/services/auth.service.ts +++ b/libs/common/src/auth/services/auth.service.ts @@ -296,13 +296,14 @@ export class AuthService implements AuthServiceAbstraction { key: string, requestApproved: boolean ): Promise { + // TODO: This currently depends on always having the Master Key and MP Hash + // We need to change this to using a different method (possibly server auth code + user sym key) const pubKey = Utils.fromB64ToArray(key); - // TODO(Jake): Do we need to support old encryption model here? - const userSymKey = await this.cryptoService.getUserKeyFromMemory(); - if (!userSymKey) { - throw new Error("User key not found"); + const masterKey = await this.cryptoService.getMasterKey(); + if (!masterKey) { + throw new Error("Master key not found"); } - const encryptedKey = await this.cryptoService.rsaEncrypt(userSymKey.encKey, pubKey.buffer); + const encryptedKey = await this.cryptoService.rsaEncrypt(masterKey.encKey, pubKey.buffer); const encryptedMasterPasswordHash = await this.cryptoService.rsaEncrypt( Utils.fromUtf8ToArray(await this.stateService.getKeyHash()), pubKey.buffer diff --git a/libs/common/src/platform/models/domain/account-keys.spec.ts b/libs/common/src/platform/models/domain/account-keys.spec.ts index f20c40c9a71..88183229f55 100644 --- a/libs/common/src/platform/models/domain/account-keys.spec.ts +++ b/libs/common/src/platform/models/domain/account-keys.spec.ts @@ -4,7 +4,6 @@ import { Utils } from "../../misc/utils"; import { AccountKeys, EncryptionPair } from "./account"; import { SymmetricCryptoKey } from "./symmetric-crypto-key"; -//TODO(Jake): Fix tests describe("AccountKeys", () => { describe("toJSON", () => { it("should serialize itself", () => {