Browse Source
* 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-typespull/6038/head
11 changed files with 264 additions and 83 deletions
@ -0,0 +1,40 @@
@@ -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; |
||||
} |
||||
} |
||||
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type"; |
||||
|
||||
export type BitwardenCsvExportType = { |
||||
type: string; |
||||
name: string; |
||||
notes: string; |
||||
fields: string; |
||||
reprompt: CipherRepromptType; |
||||
// Login props
|
||||
login_uri: string[]; |
||||
login_username: string; |
||||
login_password: string; |
||||
login_totp: string; |
||||
favorite: number | null; |
||||
}; |
||||
|
||||
export type BitwardenCsvIndividualExportType = BitwardenCsvExportType & { |
||||
folder: string | null; |
||||
}; |
||||
|
||||
export type BitwardenCsvOrgExportType = BitwardenCsvExportType & { |
||||
collections: string[] | null; |
||||
}; |
||||
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
import { |
||||
CipherWithIdExport, |
||||
CollectionWithIdExport, |
||||
FolderWithIdExport, |
||||
} from "@bitwarden/common/models/export"; |
||||
|
||||
// Base
|
||||
export type BitwardenJsonExport = { |
||||
encrypted: boolean; |
||||
items: CipherWithIdExport[]; |
||||
}; |
||||
|
||||
// Decrypted
|
||||
export type BitwardenUnEncryptedJsonExport = BitwardenJsonExport & { |
||||
encrypted: false; |
||||
}; |
||||
|
||||
export type BitwardenUnEncryptedIndividualJsonExport = BitwardenUnEncryptedJsonExport & { |
||||
folders: FolderWithIdExport[]; |
||||
}; |
||||
|
||||
export type BitwardenUnEncryptedOrgJsonExport = BitwardenUnEncryptedJsonExport & { |
||||
collections: CollectionWithIdExport[]; |
||||
}; |
||||
|
||||
// Account-encrypted
|
||||
export type BitwardenEncryptedJsonExport = BitwardenJsonExport & { |
||||
encrypted: true; |
||||
encKeyValidation_DO_NOT_EDIT: string; |
||||
}; |
||||
|
||||
export type BitwardenEncryptedIndividualJsonExport = BitwardenEncryptedJsonExport & { |
||||
folders: FolderWithIdExport[]; |
||||
}; |
||||
|
||||
export type BitwardenEncryptedOrgJsonExport = BitwardenEncryptedJsonExport & { |
||||
collections: CollectionWithIdExport[]; |
||||
}; |
||||
|
||||
// Password-protected
|
||||
export type BitwardenPasswordProtectedFileFormat = { |
||||
encrypted: boolean; |
||||
passwordProtected: boolean; |
||||
salt: string; |
||||
kdfIterations: number; |
||||
kdfMemory?: number; |
||||
kdfParallelism?: number; |
||||
kdfType: number; |
||||
encKeyValidation_DO_NOT_EDIT: string; |
||||
data: string; |
||||
}; |
||||
@ -1,11 +0,0 @@
@@ -1,11 +0,0 @@
|
||||
export interface BitwardenPasswordProtectedFileFormat { |
||||
encrypted: boolean; |
||||
passwordProtected: boolean; |
||||
salt: string; |
||||
kdfIterations: number; |
||||
kdfMemory?: number; |
||||
kdfParallelism?: number; |
||||
kdfType: number; |
||||
encKeyValidation_DO_NOT_EDIT: string; |
||||
data: string; |
||||
} |
||||
Loading…
Reference in new issue