1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-14 07:23:45 +00:00

Remove inividual user key states and migrate to account cryptographic state

This commit is contained in:
Bernd Schoolmann
2026-01-01 15:12:25 +01:00
parent 2665a29f2d
commit dc75f19fcb
40 changed files with 355 additions and 561 deletions

View File

@@ -180,7 +180,6 @@ export class DefaultSetInitialPasswordService implements SetInitialPasswordServi
if (!keyPair[1].encryptedString) {
throw new Error("encrypted private key not found. Could not set private key in state.");
}
await this.keyService.setPrivateKey(keyPair[1].encryptedString, userId);
await this.accountCryptographicStateService.setAccountCryptographicState(
{
V1: {

View File

@@ -397,7 +397,6 @@ describe("DefaultSetInitialPasswordService", () => {
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
expect(keyService.setPrivateKey).toHaveBeenCalledWith(keyPair[1].encryptedString, userId);
expect(
accountCryptographicStateService.setAccountCryptographicState,
).toHaveBeenCalledWith(
@@ -640,7 +639,9 @@ describe("DefaultSetInitialPasswordService", () => {
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
expect(keyService.setPrivateKey).not.toHaveBeenCalled();
expect(
accountCryptographicStateService.setAccountCryptographicState,
).not.toHaveBeenCalled();
});
it("should set the local master key hash to state", async () => {

View File

@@ -759,12 +759,13 @@ const safeProviders: SafeProvider[] = [
AccountServiceAbstraction,
StateProvider,
KdfConfigService,
AccountCryptographicStateService,
],
}),
safeProvider({
provide: SecurityStateService,
useClass: DefaultSecurityStateService,
deps: [StateProvider],
deps: [AccountCryptographicStateService],
}),
safeProvider({
provide: RestrictedItemTypesService,
@@ -1692,6 +1693,7 @@ const safeProviders: SafeProvider[] = [
SdkService,
ApiServiceAbstraction,
ConfigService,
AccountCryptographicStateService,
],
}),
safeProvider({