1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-06 09:20:43 +01: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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

2
jslib

@ -1 +1 @@
Subproject commit 58be5796b0c2b19aacf52d4a1c179aeb80924443 Subproject commit 00acbce556c015fae9e6281ea7db2e704ec96c26

View File

@ -9,6 +9,7 @@ import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service'; import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.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 { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.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 { FolderWithIdRequest } from 'jslib-common/models/request/folderWithIdRequest';
import { OrganizationUserResetPasswordEnrollmentRequest } from 'jslib-common/models/request/organizationUserResetPasswordEnrollmentRequest'; import { OrganizationUserResetPasswordEnrollmentRequest } from 'jslib-common/models/request/organizationUserResetPasswordEnrollmentRequest';
import { PasswordRequest } from 'jslib-common/models/request/passwordRequest'; import { PasswordRequest } from 'jslib-common/models/request/passwordRequest';
import { SendWithIdRequest } from 'jslib-common/models/request/sendWithIdRequest';
import { UpdateKeyRequest } from 'jslib-common/models/request/updateKeyRequest'; import { UpdateKeyRequest } from 'jslib-common/models/request/updateKeyRequest';
@Component({ @Component({
@ -42,7 +44,7 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
userService: UserService, passwordGenerationService: PasswordGenerationService, userService: UserService, passwordGenerationService: PasswordGenerationService,
platformUtilsService: PlatformUtilsService, policyService: PolicyService, platformUtilsService: PlatformUtilsService, policyService: PolicyService,
private folderService: FolderService, private cipherService: CipherService, 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, super(i18nService, cryptoService, messagingService, userService, passwordGenerationService,
platformUtilsService, policyService); platformUtilsService, policyService);
} }
@ -164,6 +166,13 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
request.ciphers.push(new CipherWithIdRequest(cipher)); 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.apiService.postAccountKey(request);
await this.updateEmergencyAccesses(encKey[0]); await this.updateEmergencyAccesses(encKey[0]);