diff --git a/jslib b/jslib index d56c5ff4f15..f16fc58d707 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit d56c5ff4f157b346500ceb0c256e88daaf4c4684 +Subproject commit f16fc58d707b9ed55355e62440fb95185f972090 diff --git a/src/commands/import.command.ts b/src/commands/import.command.ts index 51992f8b74a..f94c196210a 100644 --- a/src/commands/import.command.ts +++ b/src/commands/import.command.ts @@ -1,6 +1,4 @@ import * as program from 'commander'; -import * as inquirer from 'inquirer'; -import { CryptoService } from 'jslib/abstractions/crypto.service'; import { ImportService } from 'jslib/abstractions/import.service'; import { Response } from '../models/response'; @@ -9,41 +7,23 @@ import { MessageResponse } from '../models/response/messageResponse'; import { CliUtils } from '../utils'; export class ImportCommand { - constructor(private cryptoService: CryptoService, private importService: ImportService) { } + constructor(private importService: ImportService) { } - async run(format: string, filepath: string, password: string, cmd: program.Command): Promise { + async run(format: string, filepath: string, cmd: program.Command): Promise { if (cmd.formats || false) { return this.list(); } else { - return this.import(format, filepath, password); + return this.import(format, filepath); } } - private async import(format: string, filepath: string, password: string) { + private async import(format: string, filepath: string) { if (format == null || format === '') { return Response.badRequest('`format` was not provided.'); } if (filepath == null || filepath === '') { return Response.badRequest('`filepath` was not provided.'); } - if (password == null || password === '') { - const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({ - type: 'password', - name: 'password', - message: 'Master password:', - mask: '*', - }); - password = answer.password; - } - if (password == null || password === '') { - return Response.badRequest('Master password is required.'); - } - - const keyHash = await this.cryptoService.hashPassword(password, null); - const storedKeyHash = await this.cryptoService.getKeyHash(); - if (storedKeyHash == null || keyHash == null || storedKeyHash !== keyHash) { - return Response.badRequest('Invalid master password.'); - } const importer = await this.importService.getImporter(format, false); if (importer === null) { diff --git a/src/program.ts b/src/program.ts index 3e29725133f..5d8a68db6f1 100644 --- a/src/program.ts +++ b/src/program.ts @@ -371,7 +371,7 @@ export class Program { }); program - .command('import [format] [input] [password]') + .command('import [format] [input]') .description('Import vault data from a file.') .option('--formats', 'List formats') .on('--help', () => { @@ -379,12 +379,12 @@ export class Program { writeLn(''); writeLn(' bw import --formats'); writeLn(' bw import bitwardencsv ./from/source.csv'); - writeLn(' bw import keepass2xml keepass_backup.xml myPassword123'); + writeLn(' bw import keepass2xml keepass_backup.xml'); }) - .action(async (format, filepath, password, cmd) => { + .action(async (format, filepath, cmd) => { await this.exitIfLocked(); - const command = new ImportCommand(this.main.cryptoService, this.main.importService); - const response = await command.run(format, filepath, password, cmd); + const command = new ImportCommand(this.main.importService); + const response = await command.run(format, filepath, cmd); this.processResponse(response); });