1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-27 18:13:29 +00:00

Merge branch 'PS-55-EncryptedExport' into PS55-6-22

This commit is contained in:
CarleyDiaz-Bitwarden
2022-06-22 15:50:29 -04:00
24 changed files with 812 additions and 39 deletions

View File

@@ -3,7 +3,7 @@ import { EventView } from "../models/view/eventView";
export type ExportFormat = "csv" | "json" | "encrypted_json";
export abstract class ExportService {
getExport: (format?: ExportFormat, organizationId?: string) => Promise<string>;
getExport: (format?: ExportFormat, organizationId?: string, password?: string) => Promise<string>;
getPasswordProtectedExport: (password: string, organizationId?: string) => Promise<string>;
getOrganizationExport: (organizationId: string, format?: ExportFormat) => Promise<string>;
getEventExport: (events: EventView[]) => Promise<string>;

View File

@@ -0,0 +1,9 @@
export abstract class UserVerificationPromptService {
protectedFields: () => string[];
showUserVerificationPrompt: (
confirmDescription?: string,
confirmButtonText?: string,
modalTitle?: string
) => Promise<boolean>;
enabled: () => Promise<boolean>;
}

View File

@@ -0,0 +1,4 @@
export enum EncryptedExportType {
AccountEncrypted = 0,
FileEncrypted = 1,
}

View File

@@ -36,13 +36,19 @@ export class ExportService implements ExportServiceAbstraction {
private cryptoFunctionService: CryptoFunctionService
) {}
async getExport(format: ExportFormat = "csv", organizationId?: string): Promise<string> {
async getExport(
format: ExportFormat = "csv",
organizationId?: string,
password?: string
): Promise<string> {
if (organizationId) {
return await this.getOrganizationExport(organizationId, format);
}
if (format === "encrypted_json") {
return this.getEncryptedExport();
return password == undefined || password == ""
? this.getEncryptedExport()
: this.getPasswordProtectedExport(password);
} else {
return this.getDecryptedExport(format);
}