bitwarden-estensione-browser/libs/common/src/models/domain/password.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.0 KiB
TypeScript
Raw Normal View History

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
import Domain from "./domainBase";
import { EncString } from "./encString";
import { SymmetricCryptoKey } from "./symmetricCryptoKey";
2018-07-27 22:44:20 +02:00
export class Password extends Domain {
password: EncString;
2018-07-27 22:44:20 +02:00
lastUsedDate: Date;
constructor(obj?: PasswordHistoryData) {
2018-07-27 22:44:20 +02:00
super();
if (obj == null) {
return;
}
this.buildDomainModel(this, obj, {
password: null,
});
2018-08-20 22:01:26 +02:00
this.lastUsedDate = new Date(obj.lastUsedDate);
2018-07-27 22:44:20 +02: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;
}
}