Merge branch 'main' into autofill/pm-6426-create-alarms-manager-and-update-usage-of-long-lived-timeouts-rework

This commit is contained in:
Cesar Gonzalez 2024-05-11 19:27:14 -05:00 committed by GitHub
commit 72cc3a3296
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 7 deletions

View File

@ -56,14 +56,16 @@ export class VaultCollectionRowComponent {
}
get permissionText() {
if (this.collection.id != Unassigned && !(this.collection as CollectionAdminView).assigned) {
return this.i18nService.t("noAccess");
} else {
if (this.collection.id == Unassigned && this.organization?.canEditUnassignedCiphers()) {
return this.i18nService.t("canEdit");
}
if ((this.collection as CollectionAdminView).assigned) {
const permissionList = getPermissionList(this.organization?.flexibleCollections);
return this.i18nService.t(
permissionList.find((p) => p.perm === convertToPermission(this.collection))?.labelId,
);
}
return this.i18nService.t("noAccess");
}
get permissionTooltip() {

View File

@ -263,18 +263,26 @@ export class SendService implements InternalSendServiceAbstraction {
throw new Error("New user key is required for rotation.");
}
const originalUserKey = await this.cryptoService.getUserKey();
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
return req;
}
private async toRotatedKeyRequestMap(sends: Send[], newUserKey: UserKey) {
private async toRotatedKeyRequestMap(
sends: Send[],
originalUserKey: UserKey,
rotateUserKey: UserKey,
) {
const requests = await Promise.all(
sends.map(async (send) => {
const sendKey = await this.encryptService.decryptToBytes(send.key, newUserKey);
send.key = await this.encryptService.encrypt(sendKey, newUserKey);
const sendKey = await this.encryptService.decryptToBytes(send.key, originalUserKey);
send.key = await this.encryptService.encrypt(sendKey, rotateUserKey);
return new SendWithIdRequest(send);
}),
);