1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-24 00:23:17 +00:00

Address tools feedback

This commit is contained in:
Bernd Schoolmann
2025-10-28 16:28:37 +01:00
parent e278511ed0
commit ca2bc2b9c5
8 changed files with 25 additions and 37 deletions

View File

@@ -87,7 +87,7 @@ export default class Domain {
domain: DomainEncryptableKeys<D>,
viewModel: ViewEncryptableKeys<V>,
props: EncryptableKeys<D, V>[],
userId: UserId,
userId: UserId | null,
orgId: string | null,
key: SymmetricCryptoKey | null = null,
_objectContext: string = "No Domain Context",
@@ -100,8 +100,10 @@ export default class Domain {
.orgKeys$(userId)
.pipe(map((orgKeys) => orgKeys![orgId as OrganizationId] ?? null)),
);
} else {
} else if (userId != null) {
key = await firstValueFrom(keyService.userKey$(userId));
} else {
throw new Error("No key or context provided for decryption");
}
}

View File

@@ -1,6 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { UserId } from "@bitwarden/user-core";
import { EncString } from "../../../../key-management/crypto/models/enc-string";
import Domain from "../../../../platform/models/domain/domain-base";
@@ -53,17 +52,17 @@ export class SendAccess extends Domain {
}
}
async decrypt(userId: UserId, key: SymmetricCryptoKey): Promise<SendAccessView> {
async decrypt(key: SymmetricCryptoKey): Promise<SendAccessView> {
const model = new SendAccessView(this);
await this.decryptObj<SendAccess, SendAccessView>(this, model, ["name"], userId, null, key);
await this.decryptObj<SendAccess, SendAccessView>(this, model, ["name"], null, null, key);
switch (this.type) {
case SendType.File:
model.file = await this.file.decrypt(userId, key);
model.file = await this.file.decrypt(key);
break;
case SendType.Text:
model.text = await this.text.decrypt(userId, key);
model.text = await this.text.decrypt(key);
break;
default:
break;

View File

@@ -2,8 +2,6 @@
// @ts-strict-ignore
import { Jsonify } from "type-fest";
import { UserId } from "@bitwarden/user-core";
import { EncString } from "../../../../key-management/crypto/models/enc-string";
import Domain from "../../../../platform/models/domain/domain-base";
import { SymmetricCryptoKey } from "../../../../platform/models/domain/symmetric-crypto-key";
@@ -35,12 +33,12 @@ export class SendFile extends Domain {
);
}
async decrypt(userId: UserId, key: SymmetricCryptoKey): Promise<SendFileView> {
async decrypt(key: SymmetricCryptoKey): Promise<SendFileView> {
return await this.decryptObj<SendFile, SendFileView>(
this,
new SendFileView(this),
["fileName"],
userId,
null,
null,
key,
);

View File

@@ -2,8 +2,6 @@
// @ts-strict-ignore
import { Jsonify } from "type-fest";
import { UserId } from "@bitwarden/user-core";
import { EncString } from "../../../../key-management/crypto/models/enc-string";
import Domain from "../../../../platform/models/domain/domain-base";
import { SymmetricCryptoKey } from "../../../../platform/models/domain/symmetric-crypto-key";
@@ -31,12 +29,12 @@ export class SendText extends Domain {
);
}
decrypt(userId: UserId, key: SymmetricCryptoKey): Promise<SendTextView> {
decrypt(key: SymmetricCryptoKey): Promise<SendTextView> {
return this.decryptObj<SendText, SendTextView>(
this,
new SendTextView(this),
["text"],
userId,
null,
null,
key,
);