mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 09:43:23 +00:00
63 lines
1.2 KiB
TypeScript
63 lines
1.2 KiB
TypeScript
import { FieldType } from "../../enums/fieldType";
|
|
import { LinkedIdType } from "../../enums/linkedIdType";
|
|
import { FieldData } from "../data/fieldData";
|
|
import { FieldView } from "../view/fieldView";
|
|
|
|
import Domain from "./domainBase";
|
|
import { EncString } from "./encString";
|
|
import { SymmetricCryptoKey } from "./symmetricCryptoKey";
|
|
|
|
export class Field extends Domain {
|
|
name: EncString;
|
|
value: EncString;
|
|
type: FieldType;
|
|
linkedId: LinkedIdType;
|
|
|
|
constructor(obj?: FieldData) {
|
|
super();
|
|
if (obj == null) {
|
|
return;
|
|
}
|
|
|
|
this.type = obj.type;
|
|
this.linkedId = obj.linkedId;
|
|
this.buildDomainModel(
|
|
this,
|
|
obj,
|
|
{
|
|
name: null,
|
|
value: null,
|
|
},
|
|
[]
|
|
);
|
|
}
|
|
|
|
decrypt(orgId: string, encKey?: SymmetricCryptoKey): Promise<FieldView> {
|
|
return this.decryptObj(
|
|
new FieldView(this),
|
|
{
|
|
name: null,
|
|
value: null,
|
|
},
|
|
orgId,
|
|
encKey
|
|
);
|
|
}
|
|
|
|
toFieldData(): FieldData {
|
|
const f = new FieldData();
|
|
this.buildDataModel(
|
|
this,
|
|
f,
|
|
{
|
|
name: null,
|
|
value: null,
|
|
type: null,
|
|
linkedId: null,
|
|
},
|
|
["type", "linkedId"]
|
|
);
|
|
return f;
|
|
}
|
|
}
|