mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
[PM-3040] [BEEEP] Extend json-export to include passwordhistory and vault item dates (created, updated, deleted) (#5917)
* Add password history to json exports Change callout to not mention missing password history any longer * Added item meta dates to json exports Added vault items creation-/revision-/deleted-dates to json exports * Removed unnecessary promises * Add bitwarden-json-export types Define types Use types in vault-export-service Move existing password-protected type to export-types * Use bitwarden-json-export types in bitwarden-json-importer * Clean up passwordHistory if needed * Define and use bitwarden-csv-export-types
This commit is contained in:
committed by
GitHub
parent
b56bb19c02
commit
15f29c5fb1
@@ -8,6 +8,7 @@ import { CardExport } from "./card.export";
|
||||
import { FieldExport } from "./field.export";
|
||||
import { IdentityExport } from "./identity.export";
|
||||
import { LoginExport } from "./login.export";
|
||||
import { PasswordHistoryExport } from "./password-history.export";
|
||||
import { SecureNoteExport } from "./secure-note.export";
|
||||
|
||||
export class CipherExport {
|
||||
@@ -26,6 +27,10 @@ export class CipherExport {
|
||||
req.card = null;
|
||||
req.identity = null;
|
||||
req.reprompt = CipherRepromptType.None;
|
||||
req.passwordHistory = [];
|
||||
req.creationDate = null;
|
||||
req.revisionDate = null;
|
||||
req.deletedDate = null;
|
||||
return req;
|
||||
}
|
||||
|
||||
@@ -63,6 +68,13 @@ export class CipherExport {
|
||||
break;
|
||||
}
|
||||
|
||||
if (req.passwordHistory != null) {
|
||||
view.passwordHistory = req.passwordHistory.map((ph) => PasswordHistoryExport.toView(ph));
|
||||
}
|
||||
|
||||
view.creationDate = req.creationDate;
|
||||
view.revisionDate = req.revisionDate;
|
||||
view.deletedDate = req.deletedDate;
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -96,6 +108,13 @@ export class CipherExport {
|
||||
break;
|
||||
}
|
||||
|
||||
if (req.passwordHistory != null) {
|
||||
domain.passwordHistory = req.passwordHistory.map((ph) => PasswordHistoryExport.toDomain(ph));
|
||||
}
|
||||
|
||||
domain.creationDate = req.creationDate;
|
||||
domain.revisionDate = req.revisionDate;
|
||||
domain.deletedDate = req.deletedDate;
|
||||
return domain;
|
||||
}
|
||||
|
||||
@@ -112,6 +131,10 @@ export class CipherExport {
|
||||
card: CardExport;
|
||||
identity: IdentityExport;
|
||||
reprompt: CipherRepromptType;
|
||||
passwordHistory: PasswordHistoryExport[] = null;
|
||||
revisionDate: Date = null;
|
||||
creationDate: Date = null;
|
||||
deletedDate: Date = null;
|
||||
|
||||
// Use build method instead of ctor so that we can control order of JSON stringify for pretty print
|
||||
build(o: CipherView | CipherDomain) {
|
||||
@@ -152,5 +175,17 @@ export class CipherExport {
|
||||
this.identity = new IdentityExport(o.identity);
|
||||
break;
|
||||
}
|
||||
|
||||
if (o.passwordHistory != null) {
|
||||
if (o instanceof CipherView) {
|
||||
this.passwordHistory = o.passwordHistory.map((ph) => new PasswordHistoryExport(ph));
|
||||
} else {
|
||||
this.passwordHistory = o.passwordHistory.map((ph) => new PasswordHistoryExport(ph));
|
||||
}
|
||||
}
|
||||
|
||||
this.creationDate = o.creationDate;
|
||||
this.revisionDate = o.revisionDate;
|
||||
this.deletedDate = o.deletedDate;
|
||||
}
|
||||
}
|
||||
|
||||
40
libs/common/src/models/export/password-history.export.ts
Normal file
40
libs/common/src/models/export/password-history.export.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { EncString } from "../../platform/models/domain/enc-string";
|
||||
import { Password } from "../../vault/models/domain/password";
|
||||
import { PasswordHistoryView } from "../../vault/models/view/password-history.view";
|
||||
|
||||
export class PasswordHistoryExport {
|
||||
static template(): PasswordHistoryExport {
|
||||
const req = new PasswordHistoryExport();
|
||||
req.password = null;
|
||||
req.lastUsedDate = null;
|
||||
return req;
|
||||
}
|
||||
|
||||
static toView(req: PasswordHistoryExport, view = new PasswordHistoryView()) {
|
||||
view.password = req.password;
|
||||
view.lastUsedDate = req.lastUsedDate;
|
||||
return view;
|
||||
}
|
||||
|
||||
static toDomain(req: PasswordHistoryExport, domain = new Password()) {
|
||||
domain.password = req.password != null ? new EncString(req.password) : null;
|
||||
domain.lastUsedDate = req.lastUsedDate;
|
||||
return domain;
|
||||
}
|
||||
|
||||
password: string;
|
||||
lastUsedDate: Date = null;
|
||||
|
||||
constructor(o?: PasswordHistoryView | Password) {
|
||||
if (o == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (o instanceof PasswordHistoryView) {
|
||||
this.password = o.password;
|
||||
} else {
|
||||
this.password = o.password?.encryptedString;
|
||||
}
|
||||
this.lastUsedDate = o.lastUsedDate;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user