diff --git a/jslib b/jslib index a7bbdf9c93..9f26f9f377 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit a7bbdf9c9391c8d58fee0231e1d4cfe34af55cdb +Subproject commit 9f26f9f37771f8f450b380b4c05ffd5d9164f099 diff --git a/src/commands/export.command.ts b/src/commands/export.command.ts index 6c943a3efc..ac632fc54a 100644 --- a/src/commands/export.command.ts +++ b/src/commands/export.command.ts @@ -3,7 +3,6 @@ import * as inquirer from 'inquirer'; import { CryptoService } from 'jslib/abstractions/crypto.service'; import { ExportService } from 'jslib/abstractions/export.service'; -import { UserService } from 'jslib/abstractions/user.service'; import { Response } from '../models/response'; import { MessageResponse } from '../models/response/messageResponse'; @@ -11,8 +10,7 @@ import { MessageResponse } from '../models/response/messageResponse'; import { CliUtils } from '../utils'; export class ExportCommand { - constructor(private cryptoService: CryptoService, private userService: UserService, - private exportService: ExportService) { } + constructor(private cryptoService: CryptoService, private exportService: ExportService) { } async run(password: string, cmd: program.Command): Promise { if (password == null || password === '') { @@ -28,9 +26,7 @@ export class ExportCommand { return Response.badRequest('Master password is required.'); } - const email = await this.userService.getEmail(); - const key = await this.cryptoService.makeKey(password, email); - const keyHash = await this.cryptoService.hashPassword(password, key); + const keyHash = await this.cryptoService.hashPassword(password, null); const storedKeyHash = await this.cryptoService.getKeyHash(); if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) { const csv = await this.exportService.getExport('csv'); diff --git a/src/commands/import.command.ts b/src/commands/import.command.ts index 2672a1ff87..51992f8b74 100644 --- a/src/commands/import.command.ts +++ b/src/commands/import.command.ts @@ -2,7 +2,6 @@ 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 { UserService } from 'jslib/abstractions/user.service'; import { Response } from '../models/response'; import { MessageResponse } from '../models/response/messageResponse'; @@ -10,8 +9,7 @@ import { MessageResponse } from '../models/response/messageResponse'; import { CliUtils } from '../utils'; export class ImportCommand { - constructor(private cryptoService: CryptoService, private userService: UserService, - private importService: ImportService) { } + constructor(private cryptoService: CryptoService, private importService: ImportService) { } async run(format: string, filepath: string, password: string, cmd: program.Command): Promise { if (cmd.formats || false) { @@ -41,9 +39,7 @@ export class ImportCommand { return Response.badRequest('Master password is required.'); } - const email = await this.userService.getEmail(); - const key = await this.cryptoService.makeKey(password, email); - const keyHash = await this.cryptoService.hashPassword(password, key); + 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.'); diff --git a/src/commands/unlock.command.ts b/src/commands/unlock.command.ts index 288ea91e69..0180892e2c 100644 --- a/src/commands/unlock.command.ts +++ b/src/commands/unlock.command.ts @@ -30,7 +30,9 @@ export class UnlockCommand { this.setNewSessionKey(); const email = await this.userService.getEmail(); - const key = await this.cryptoService.makeKey(password, email); + const kdf = await this.userService.getKdf(); + const kdfIterations = await this.userService.getKdfIterations(); + const key = await this.cryptoService.makeKey(password, email, kdf, kdfIterations); const keyHash = await this.cryptoService.hashPassword(password, key); const storedKeyHash = await this.cryptoService.getKeyHash(); if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) { diff --git a/src/program.ts b/src/program.ts index 592247d20b..3e29725133 100644 --- a/src/program.ts +++ b/src/program.ts @@ -383,8 +383,7 @@ export class Program { }) .action(async (format, filepath, password, cmd) => { await this.exitIfLocked(); - const command = new ImportCommand(this.main.cryptoService, - this.main.userService, this.main.importService); + const command = new ImportCommand(this.main.cryptoService, this.main.importService); const response = await command.run(format, filepath, password, cmd); this.processResponse(response); }); @@ -404,8 +403,7 @@ export class Program { }) .action(async (password, cmd) => { await this.exitIfLocked(); - const command = new ExportCommand(this.main.cryptoService, this.main.userService, - this.main.exportService); + const command = new ExportCommand(this.main.cryptoService, this.main.exportService); const response = await command.run(password, cmd); this.processResponse(response); });