mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-16 01:21:48 +01:00
rotate sends from original key to rotated key (#9130)
This commit is contained in:
parent
8e97c1c8e4
commit
4ae208fabc
@ -263,18 +263,26 @@ export class SendService implements InternalSendServiceAbstraction {
|
|||||||
throw new Error("New user key is required for rotation.");
|
throw new Error("New user key is required for rotation.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const originalUserKey = await this.cryptoService.getUserKey();
|
||||||
|
|
||||||
const req = await firstValueFrom(
|
const req = await firstValueFrom(
|
||||||
this.sends$.pipe(concatMap(async (sends) => this.toRotatedKeyRequestMap(sends, newUserKey))),
|
this.sends$.pipe(
|
||||||
|
concatMap(async (sends) => this.toRotatedKeyRequestMap(sends, originalUserKey, newUserKey)),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
// separate return for easier debugging
|
// separate return for easier debugging
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async toRotatedKeyRequestMap(sends: Send[], newUserKey: UserKey) {
|
private async toRotatedKeyRequestMap(
|
||||||
|
sends: Send[],
|
||||||
|
originalUserKey: UserKey,
|
||||||
|
rotateUserKey: UserKey,
|
||||||
|
) {
|
||||||
const requests = await Promise.all(
|
const requests = await Promise.all(
|
||||||
sends.map(async (send) => {
|
sends.map(async (send) => {
|
||||||
const sendKey = await this.encryptService.decryptToBytes(send.key, newUserKey);
|
const sendKey = await this.encryptService.decryptToBytes(send.key, originalUserKey);
|
||||||
send.key = await this.encryptService.encrypt(sendKey, newUserKey);
|
send.key = await this.encryptService.encrypt(sendKey, rotateUserKey);
|
||||||
return new SendWithIdRequest(send);
|
return new SendWithIdRequest(send);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user