From 5e7e035eec3587fd007d2d30779d639ff9f10d39 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Mon, 19 Jul 2021 20:14:24 +1000 Subject: [PATCH] [send.key] Update send.key when rotating account enc key (#1049) * Update send.key when rotating account enc key * Update jslib --- jslib | 2 +- src/app/settings/change-password.component.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/jslib b/jslib index 58be5796b0..00acbce556 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 58be5796b0c2b19aacf52d4a1c179aeb80924443 +Subproject commit 00acbce556c015fae9e6281ea7db2e704ec96c26 diff --git a/src/app/settings/change-password.component.ts b/src/app/settings/change-password.component.ts index 3c2a092f22..e76f5c6f1c 100644 --- a/src/app/settings/change-password.component.ts +++ b/src/app/settings/change-password.component.ts @@ -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]);