1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00:00

support for encrypted json export (#216)

* support for encrypted json export

* adjust filename prefix for encrypted formats

* flip if logic

* remove format param from encrypted export

* encryptedFormat getter
This commit is contained in:
Kyle Spearrin
2020-12-03 15:20:38 -05:00
committed by GitHub
parent abb54f0073
commit 93a3053f54
15 changed files with 263 additions and 61 deletions

View File

@@ -17,13 +17,17 @@ export class ExportComponent {
formPromise: Promise<string>;
masterPassword: string;
format: 'json' | 'csv' = 'json';
format: 'json' | 'encrypted_json' | 'csv' = 'json';
showPassword = false;
constructor(protected cryptoService: CryptoService, protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService, protected exportService: ExportService,
protected eventService: EventService, protected win: Window) { }
get encryptedFormat() {
return this.format === 'encrypted_json';
}
async submit() {
if (this.masterPassword == null || this.masterPassword === '') {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
@@ -63,7 +67,16 @@ export class ExportComponent {
}
protected getFileName(prefix?: string) {
return this.exportService.getFileName(prefix, this.format);
let extension = this.format;
if (this.format === 'encrypted_json') {
if (prefix == null) {
prefix = 'encrypted';
} else {
prefix = 'encrypted_' + prefix;
}
extension = 'json';
}
return this.exportService.getFileName(prefix, extension);
}
protected async collectEvent(): Promise<any> {