mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 02:33:46 +00:00
Remove legacy key support in vault code (#15348)
This commit is contained in:
@@ -170,7 +170,7 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
return combineLatest([
|
||||
this.encryptedCiphersState(userId).state$,
|
||||
this.localData$(userId),
|
||||
this.keyService.cipherDecryptionKeys$(userId, true),
|
||||
this.keyService.cipherDecryptionKeys$(userId),
|
||||
]).pipe(
|
||||
filter(([ciphers, _, keys]) => ciphers != null && keys != null), // Skip if ciphers haven't been loaded yor synced yet
|
||||
switchMap(() => this.getAllDecrypted(userId)),
|
||||
@@ -486,7 +486,7 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
return [decrypted, []];
|
||||
}
|
||||
|
||||
const keys = await firstValueFrom(this.keyService.cipherDecryptionKeys$(userId, true));
|
||||
const keys = await firstValueFrom(this.keyService.cipherDecryptionKeys$(userId));
|
||||
if (keys == null || (keys.userKey == null && Object.keys(keys.orgKeys).length === 0)) {
|
||||
// return early if there are no keys to decrypt with
|
||||
return null;
|
||||
@@ -1466,7 +1466,7 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
async getKeyForCipherKeyDecryption(cipher: Cipher, userId: UserId): Promise<UserKey | OrgKey> {
|
||||
return (
|
||||
(await this.keyService.getOrgKey(cipher.organizationId)) ||
|
||||
((await this.keyService.getUserKeyWithLegacySupport(userId)) as UserKey)
|
||||
((await this.keyService.getUserKey(userId)) as UserKey)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1598,7 +1598,7 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
// In the case of a cipher that is being shared with an organization, we want to decrypt the
|
||||
// cipher key with the user's key and then re-encrypt it with the organization's key.
|
||||
private async encryptSharedCipher(model: CipherView, userId: UserId): Promise<EncryptionContext> {
|
||||
const keyForCipherKeyDecryption = await this.keyService.getUserKeyWithLegacySupport(userId);
|
||||
const keyForCipherKeyDecryption = await this.keyService.getUserKey(userId);
|
||||
return await this.encrypt(model, userId, null, keyForCipherKeyDecryption);
|
||||
}
|
||||
|
||||
@@ -1673,12 +1673,12 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
|
||||
const encBuf = await EncArrayBuffer.fromResponse(attachmentResponse);
|
||||
const activeUserId = await firstValueFrom(this.accountService.activeAccount$);
|
||||
const userKey = await this.keyService.getUserKeyWithLegacySupport(activeUserId.id);
|
||||
const userKey = await this.keyService.getUserKey(activeUserId.id);
|
||||
const decBuf = await this.encryptService.decryptFileData(encBuf, userKey);
|
||||
|
||||
let encKey: UserKey | OrgKey;
|
||||
encKey = await this.keyService.getOrgKey(organizationId);
|
||||
encKey ||= (await this.keyService.getUserKeyWithLegacySupport()) as UserKey;
|
||||
encKey ||= (await this.keyService.getUserKey()) as UserKey;
|
||||
|
||||
const dataEncKey = await this.keyService.makeDataEncKey(encKey);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user