1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-26 17:43:22 +00:00
Files
browser/libs/common/src/tools/send/models/domain/send-file.ts
Bernd Schoolmann 395e4f2c05 [PM-27591] Remove orgid in vault decryption code (#17099)
* Remove orgid in vault decryption code

* Remove folder usage without provided key

* Fix folder test

* Fix build

* Fix build

* Fix build

* Fix tests

* Update spec to not use EncString decrypt

* Fix tests

* Fix test

* Fix test

* Remove comment

* Remove org id parameter
2025-12-08 07:09:43 -07:00

55 lines
1.3 KiB
TypeScript

// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { Jsonify } from "type-fest";
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";
import { SendFileData } from "../data/send-file.data";
import { SendFileView } from "../view/send-file.view";
export class SendFile extends Domain {
id: string;
size: string;
sizeName: string;
fileName: EncString;
constructor(obj?: SendFileData) {
super();
if (obj == null) {
return;
}
this.size = obj.size;
this.buildDomainModel(
this,
obj,
{
id: null,
sizeName: null,
fileName: null,
},
["id", "sizeName"],
);
}
async decrypt(key: SymmetricCryptoKey): Promise<SendFileView> {
return await this.decryptObj<SendFile, SendFileView>(
this,
new SendFileView(this),
["fileName"],
key,
);
}
static fromJSON(obj: Jsonify<SendFile>) {
if (obj == null) {
return null;
}
return Object.assign(new SendFile(), obj, {
fileName: EncString.fromJSON(obj.fileName),
});
}
}