1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

[AC-1492] Split export service (#7462)

* Split export service into vault and org export service

* Changed CLI logic to use split export logic

* correct unit tests

* Created individual export service, export service making the calls for org and ind vault

* Improved code readability

* Merged PasswordProtectedExport with Export methods to simplify calls

* Some small refactor

* [AC-1492] Managed collections export (#7556)

* Added managed collections export method
Added logic to show orgs on export that the user can export from

* Merge branch 'tools/AC-1492/split-export-services' into tools/AC-1492/export-flexible-collections

# Conflicts:
#	apps/web/src/app/admin-console/organizations/tools/vault-export/org-vault-export.component.ts
#	apps/web/src/app/tools/vault-export/export.component.ts

* Change export to use new organization.flexiblecollection flag

* Little refactor changing parameter names and reduzing the size of export.component.ts ngOnInit

* Removed unused service from export constructor and removed unnecessary default value from org export service parameter

* Simplified organizations selection for vault export to only verify if it has flexiblecollections

* removed unecessary services from ExportComponent constructor on popup

* Fixed possible race condition on managed export
This commit is contained in:
aj-rosado
2024-01-29 09:38:16 +00:00
committed by GitHub
parent 053053624f
commit d5de9cbeb2
17 changed files with 789 additions and 496 deletions

View File

@@ -32,7 +32,14 @@ export class ExportCommand {
);
}
const format = options.format ?? "csv";
let password = options.password;
// has password and format is 'json' => should have the same behaviour as 'encrypted_json'
// format is 'undefined' => Defaults to 'csv'
// Any other case => returns the options.format
const format =
password && options.format == "json" ? "encrypted_json" : options.format ?? "csv";
if (!this.isSupportedExportFormat(format)) {
return Response.badRequest(
`'${format}' is not a supported export format. Supported formats: ${EXPORT_FORMATS.join(
@@ -47,10 +54,18 @@ export class ExportCommand {
let exportContent: string = null;
try {
if (format === "encrypted_json") {
password = await this.promptPassword(password);
}
exportContent =
format === "encrypted_json"
? await this.getProtectedExport(options.password, options.organizationid)
: await this.getUnprotectedExport(format, options.organizationid);
options.organizationid == null
? await this.exportService.getExport(format, password)
: await this.exportService.getOrganizationExport(
options.organizationid,
format,
password,
);
const eventType = options.organizationid
? EventType.Organization_ClientExportedVault
@@ -62,17 +77,6 @@ export class ExportCommand {
return await this.saveFile(exportContent, options, format);
}
private async getProtectedExport(passwordOption: string | boolean, organizationId?: string) {
const password = await this.promptPassword(passwordOption);
return password == null
? await this.exportService.getExport("encrypted_json", organizationId)
: await this.exportService.getPasswordProtectedExport(password, organizationId);
}
private async getUnprotectedExport(format: ExportFormat, organizationId?: string) {
return this.exportService.getExport(format, organizationId);
}
private async saveFile(
exportContent: string,
options: program.OptionValues,