1
0
mirror of https://github.com/bitwarden/web synced 2025-12-06 00:03:28 +00:00

[send.key] Update send.key when rotating account enc key (#1049)

* Update send.key when rotating account enc key

* Update jslib
This commit is contained in:
Thomas Rittson
2021-07-19 20:14:24 +10:00
committed by GitHub
parent d85ee9780f
commit 5e7e035eec
2 changed files with 11 additions and 2 deletions

2
jslib

Submodule jslib updated: 58be5796b0...00acbce556

View File

@@ -9,6 +9,7 @@ import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SendService } from 'jslib-common/abstractions/send.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
@@ -27,6 +28,7 @@ import { EmergencyAccessUpdateRequest } from 'jslib-common/models/request/emerge
import { FolderWithIdRequest } from 'jslib-common/models/request/folderWithIdRequest';
import { OrganizationUserResetPasswordEnrollmentRequest } from 'jslib-common/models/request/organizationUserResetPasswordEnrollmentRequest';
import { PasswordRequest } from 'jslib-common/models/request/passwordRequest';
import { SendWithIdRequest } from 'jslib-common/models/request/sendWithIdRequest';
import { UpdateKeyRequest } from 'jslib-common/models/request/updateKeyRequest';
@Component({
@@ -42,7 +44,7 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
userService: UserService, passwordGenerationService: PasswordGenerationService,
platformUtilsService: PlatformUtilsService, policyService: PolicyService,
private folderService: FolderService, private cipherService: CipherService,
private syncService: SyncService, private apiService: ApiService) {
private syncService: SyncService, private apiService: ApiService, private sendService: SendService) {
super(i18nService, cryptoService, messagingService, userService, passwordGenerationService,
platformUtilsService, policyService);
}
@@ -164,6 +166,13 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
request.ciphers.push(new CipherWithIdRequest(cipher));
}
const sends = await this.sendService.getAll();
await Promise.all(sends.map(async send => {
const cryptoKey = await this.cryptoService.decryptToBytes(send.key, null);
send.key = await this.cryptoService.encrypt(cryptoKey, encKey[0]) ?? send.key;
request.sends.push(new SendWithIdRequest(send));
}));
await this.apiService.postAccountKey(request);
await this.updateEmergencyAccesses(encKey[0]);