From 4548364c2c6739f3988e91c6c1ea37c5c8769514 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Wed, 16 Jul 2025 21:41:17 +0200 Subject: [PATCH] Remove introduced function --- .../master-password.service.abstraction.ts | 4 +++ .../services/master-password.service.spec.ts | 26 ----------------- .../services/master-password.service.ts | 28 ------------------- 3 files changed, 4 insertions(+), 54 deletions(-) diff --git a/libs/common/src/key-management/master-password/abstractions/master-password.service.abstraction.ts b/libs/common/src/key-management/master-password/abstractions/master-password.service.abstraction.ts index 33717545443..dc9f1a7daee 100644 --- a/libs/common/src/key-management/master-password/abstractions/master-password.service.abstraction.ts +++ b/libs/common/src/key-management/master-password/abstractions/master-password.service.abstraction.ts @@ -84,6 +84,7 @@ export abstract class InternalMasterPasswordServiceAbstraction extends MasterPas /** * Set the master key for the user. * Note: Use {@link clearMasterKey} to clear the master key. + * @deprecated * @param masterKey The master key. * @param userId The user ID. * @throws If the user ID or master key is missing. @@ -91,6 +92,7 @@ export abstract class InternalMasterPasswordServiceAbstraction extends MasterPas abstract setMasterKey: (masterKey: MasterKey, userId: UserId) => Promise; /** * Clear the master key for the user. + * @deprecated * @param userId The user ID. * @throws If the user ID is missing. */ @@ -98,6 +100,7 @@ export abstract class InternalMasterPasswordServiceAbstraction extends MasterPas /** * Set the master key hash for the user. * Note: Use {@link clearMasterKeyHash} to clear the master key hash. + * @deprecated * @param masterKeyHash The master key hash. * @param userId The user ID. * @throws If the user ID or master key hash is missing. @@ -105,6 +108,7 @@ export abstract class InternalMasterPasswordServiceAbstraction extends MasterPas abstract setMasterKeyHash: (masterKeyHash: string, userId: UserId) => Promise; /** * Clear the master key hash for the user. + * @deprecated * @param userId The user ID. * @throws If the user ID is missing. */ diff --git a/libs/common/src/key-management/master-password/services/master-password.service.spec.ts b/libs/common/src/key-management/master-password/services/master-password.service.spec.ts index 7b4c0c3eb75..3ca67b0b082 100644 --- a/libs/common/src/key-management/master-password/services/master-password.service.spec.ts +++ b/libs/common/src/key-management/master-password/services/master-password.service.spec.ts @@ -287,30 +287,4 @@ describe("MasterPasswordService", () => { }); }); }); - - describe("getDecryptedUserKeyWithMasterPassword", () => { - const password = "test-password"; - const kdfConfig = new PBKDF2KdfConfig(600_000); - const userKey = makeSymmetricCryptoKey(64, 2) as UserKey; - - beforeEach(() => { - kdfConfigService.getKdfConfig$.mockReturnValue(of(kdfConfig)); - jest.spyOn(sut, "unwrapUserKeyFromMasterPasswordUnlockData").mockResolvedValue(userKey); - }); - - it("throws if password is null or empty", async () => { - await expect( - sut.getDecryptedUserKeyWithMasterPassword(null as unknown as string, userId), - ).rejects.toThrow("Password is required."); - await expect(sut.getDecryptedUserKeyWithMasterPassword("", userId)).rejects.toThrow( - "Password is required.", - ); - }); - - it("throws if userId is null", async () => { - await expect( - sut.getDecryptedUserKeyWithMasterPassword(password, null as unknown as UserId), - ).rejects.toThrow("User ID is required."); - }); - }); }); diff --git a/libs/common/src/key-management/master-password/services/master-password.service.ts b/libs/common/src/key-management/master-password/services/master-password.service.ts index 3075e0f4041..199919eae27 100644 --- a/libs/common/src/key-management/master-password/services/master-password.service.ts +++ b/libs/common/src/key-management/master-password/services/master-password.service.ts @@ -109,9 +109,6 @@ export class MasterPasswordService implements InternalMasterPasswordServiceAbstr } // TODO: Remove this method and decrypt directly in the service instead - /** - * @deprecated This will be made private - */ async getMasterKeyEncryptedUserKey(userId: UserId): Promise { if (userId == null) { throw new Error("User ID is required."); @@ -122,31 +119,6 @@ export class MasterPasswordService implements InternalMasterPasswordServiceAbstr return EncString.fromJSON(key); } - async getDecryptedUserKeyWithMasterPassword(password: string, userId: UserId): Promise { - if (password == null || password === "") { - throw new Error("Password is required."); - } - if (userId == null) { - throw new Error("User ID is required."); - } - - const masterKeyWrappedUserKey = (await this.getMasterKeyEncryptedUserKey( - userId, - )) as MasterKeyWrappedUserKey; - const kdf = await firstValueFrom(this.kdfConfigService.getKdfConfig$(userId)); - const salt = this.emailToSalt( - await firstValueFrom( - this.accountService.accounts$.pipe(map((accounts) => accounts[userId].email)), - ), - ); - - return this.unwrapUserKeyFromMasterPasswordUnlockData(password, { - salt, - kdf, - masterKeyWrappedUserKey, - }); - } - emailToSalt(email: string): MasterPasswordSalt { return email.toLowerCase().trim() as MasterPasswordSalt; }