mirror of
https://github.com/bitwarden/browser
synced 2026-02-24 00:23:17 +00:00
Address tools feedback
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user