1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-17 08:43:27 +00:00

Copy jslib into Directory Connector [TI-6] (#262)

This commit is contained in:
Oscar Hinton
2022-04-28 16:41:07 +02:00
committed by GitHub
parent 2d02d54b56
commit 45d0192f82
694 changed files with 104863 additions and 14 deletions

View File

@@ -0,0 +1,77 @@
import { SendType } from "../../enums/sendType";
import { SendAccessResponse } from "../response/sendAccessResponse";
import { SendAccessView } from "../view/sendAccessView";
import Domain from "./domainBase";
import { EncString } from "./encString";
import { SendFile } from "./sendFile";
import { SendText } from "./sendText";
import { SymmetricCryptoKey } from "./symmetricCryptoKey";
export class SendAccess extends Domain {
id: string;
type: SendType;
name: EncString;
file: SendFile;
text: SendText;
expirationDate: Date;
creatorIdentifier: string;
constructor(obj?: SendAccessResponse) {
super();
if (obj == null) {
return;
}
this.buildDomainModel(
this,
obj,
{
id: null,
name: null,
expirationDate: null,
creatorIdentifier: null,
},
["id", "expirationDate", "creatorIdentifier"]
);
this.type = obj.type;
switch (this.type) {
case SendType.Text:
this.text = new SendText(obj.text);
break;
case SendType.File:
this.file = new SendFile(obj.file);
break;
default:
break;
}
}
async decrypt(key: SymmetricCryptoKey): Promise<SendAccessView> {
const model = new SendAccessView(this);
await this.decryptObj(
model,
{
name: null,
},
null,
key
);
switch (this.type) {
case SendType.File:
model.file = await this.file.decrypt(key);
break;
case SendType.Text:
model.text = await this.text.decrypt(key);
break;
default:
break;
}
return model;
}
}