2018-07-27 22:44:20 +02:00
|
|
|
import { PasswordHistoryData } from "../data/passwordHistoryData";
|
2022-02-22 15:39:11 +01:00
|
|
|
import { PasswordHistoryView } from "../view/passwordHistoryView";
|
2018-07-27 22:44:20 +02:00
|
|
|
|
2018-10-04 20:38:15 +02:00
|
|
|
import Domain from "./domainBase";
|
2021-04-21 02:16:19 +02:00
|
|
|
import { EncString } from "./encString";
|
2020-12-22 16:53:48 +01:00
|
|
|
import { SymmetricCryptoKey } from "./symmetricCryptoKey";
|
2018-07-27 22:44:20 +02:00
|
|
|
|
|
|
|
export class Password extends Domain {
|
2021-04-21 02:16:19 +02:00
|
|
|
password: EncString;
|
2018-07-27 22:44:20 +02:00
|
|
|
lastUsedDate: Date;
|
|
|
|
|
2022-02-22 15:39:11 +01:00
|
|
|
constructor(obj?: PasswordHistoryData, alreadyEncrypted = false) {
|
2018-07-27 22:44:20 +02:00
|
|
|
super();
|
|
|
|
if (obj == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-12-22 16:53:48 +01:00
|
|
|
this.buildDomainModel(
|
2019-04-14 03:20:04 +02:00
|
|
|
this,
|
|
|
|
obj,
|
|
|
|
{
|
2018-07-27 22:44:20 +02:00
|
|
|
password: null,
|
2020-12-22 16:53:48 +01:00
|
|
|
},
|
|
|
|
alreadyEncrypted
|
|
|
|
);
|
2018-08-20 22:01:26 +02:00
|
|
|
this.lastUsedDate = new Date(obj.lastUsedDate);
|
2018-07-27 22:44:20 +02:00
|
|
|
}
|
|
|
|
|
2020-12-22 16:53:48 +01:00
|
|
|
decrypt(orgId: string, encKey?: SymmetricCryptoKey): Promise<PasswordHistoryView> {
|
2019-04-14 03:20:04 +02:00
|
|
|
return this.decryptObj(
|
|
|
|
new PasswordHistoryView(this),
|
2021-12-16 13:36:21 +01:00
|
|
|
{
|
2018-07-27 22:44:20 +02:00
|
|
|
password: null,
|
2021-12-16 13:36:21 +01:00
|
|
|
},
|
|
|
|
orgId,
|
|
|
|
encKey
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-07-27 22:44:20 +02:00
|
|
|
toPasswordHistoryData(): PasswordHistoryData {
|
|
|
|
const ph = new PasswordHistoryData();
|
2018-08-20 22:01:26 +02:00
|
|
|
ph.lastUsedDate = this.lastUsedDate.toISOString();
|
2018-07-27 22:44:20 +02:00
|
|
|
this.buildDataModel(this, ph, {
|
|
|
|
password: null,
|
|
|
|
});
|
|
|
|
return ph;
|
|
|
|
}
|
|
|
|
}
|