diff --git a/jslib b/jslib index 8b26d90..3429b57 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 8b26d90e742966bff3dc9e57ecb104b59e48371b +Subproject commit 3429b57db42a3e1e9948b870bf24fcc02ebc8a99 diff --git a/src/bw.ts b/src/bw.ts index 0ad4803..e624fbb 100644 --- a/src/bw.ts +++ b/src/bw.ts @@ -102,7 +102,7 @@ export class Main { this.passwordGenerationService = new PasswordGenerationService(this.cryptoService, this.storageService); this.totpService = new TotpService(this.storageService, this.cryptoFunctionService); this.importService = new ImportService(this.cipherService, this.folderService, this.apiService, - this.i18nService); + this.i18nService, this.collectionService); this.exportService = new ExportService(this.folderService, this.cipherService, this.apiService); this.authService = new AuthService(this.cryptoService, this.apiService, this.userService, this.tokenService, this.appIdService, this.i18nService, this.platformUtilsService, this.messagingService, true); diff --git a/src/commands/import.command.ts b/src/commands/import.command.ts index d78469e..2672a1f 100644 --- a/src/commands/import.command.ts +++ b/src/commands/import.command.ts @@ -49,7 +49,7 @@ export class ImportCommand { return Response.badRequest('Invalid master password.'); } - const importer = await this.importService.getImporter(format); + const importer = await this.importService.getImporter(format, false); if (importer === null) { return Response.badRequest('Proper importer type required.'); } @@ -60,20 +60,19 @@ export class ImportCommand { return Response.badRequest('Import file was empty.'); } - const submitResult = await this.importService.import(importer, contents); - if (submitResult !== null) { - const res = new MessageResponse('Imported ' + filepath, null); - return Response.success(res); - } else { - return Response.badRequest(submitResult.message); + const err = await this.importService.import(importer, contents, null); + if (err == null) { + return Response.badRequest(err.message); } + const res = new MessageResponse('Imported ' + filepath, null); + return Response.success(res); } catch (err) { return Response.badRequest(err); } } private async list() { - const options = this.importService.importOptions.sort((a, b) => { + const options = this.importService.getImportOptions().sort((a, b) => { return a.id < b.id ? -1 : a.id > b.id ? 1 : 0; }).map((option) => option.id).join('\n'); const res = new MessageResponse('Supported input formats:', options);