prelogin kdf info
This commit is contained in:
parent
e11b749f6f
commit
acd562e18c
2
jslib
2
jslib
|
@ -1 +1 @@
|
||||||
Subproject commit a7bbdf9c9391c8d58fee0231e1d4cfe34af55cdb
|
Subproject commit 9f26f9f37771f8f450b380b4c05ffd5d9164f099
|
|
@ -3,7 +3,6 @@ import * as inquirer from 'inquirer';
|
||||||
|
|
||||||
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
||||||
import { ExportService } from 'jslib/abstractions/export.service';
|
import { ExportService } from 'jslib/abstractions/export.service';
|
||||||
import { UserService } from 'jslib/abstractions/user.service';
|
|
||||||
|
|
||||||
import { Response } from '../models/response';
|
import { Response } from '../models/response';
|
||||||
import { MessageResponse } from '../models/response/messageResponse';
|
import { MessageResponse } from '../models/response/messageResponse';
|
||||||
|
@ -11,8 +10,7 @@ import { MessageResponse } from '../models/response/messageResponse';
|
||||||
import { CliUtils } from '../utils';
|
import { CliUtils } from '../utils';
|
||||||
|
|
||||||
export class ExportCommand {
|
export class ExportCommand {
|
||||||
constructor(private cryptoService: CryptoService, private userService: UserService,
|
constructor(private cryptoService: CryptoService, private exportService: ExportService) { }
|
||||||
private exportService: ExportService) { }
|
|
||||||
|
|
||||||
async run(password: string, cmd: program.Command): Promise<Response> {
|
async run(password: string, cmd: program.Command): Promise<Response> {
|
||||||
if (password == null || password === '') {
|
if (password == null || password === '') {
|
||||||
|
@ -28,9 +26,7 @@ export class ExportCommand {
|
||||||
return Response.badRequest('Master password is required.');
|
return Response.badRequest('Master password is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const email = await this.userService.getEmail();
|
const keyHash = await this.cryptoService.hashPassword(password, null);
|
||||||
const key = await this.cryptoService.makeKey(password, email);
|
|
||||||
const keyHash = await this.cryptoService.hashPassword(password, key);
|
|
||||||
const storedKeyHash = await this.cryptoService.getKeyHash();
|
const storedKeyHash = await this.cryptoService.getKeyHash();
|
||||||
if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) {
|
if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) {
|
||||||
const csv = await this.exportService.getExport('csv');
|
const csv = await this.exportService.getExport('csv');
|
||||||
|
|
|
@ -2,7 +2,6 @@ import * as program from 'commander';
|
||||||
import * as inquirer from 'inquirer';
|
import * as inquirer from 'inquirer';
|
||||||
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
||||||
import { ImportService } from 'jslib/abstractions/import.service';
|
import { ImportService } from 'jslib/abstractions/import.service';
|
||||||
import { UserService } from 'jslib/abstractions/user.service';
|
|
||||||
|
|
||||||
import { Response } from '../models/response';
|
import { Response } from '../models/response';
|
||||||
import { MessageResponse } from '../models/response/messageResponse';
|
import { MessageResponse } from '../models/response/messageResponse';
|
||||||
|
@ -10,8 +9,7 @@ import { MessageResponse } from '../models/response/messageResponse';
|
||||||
import { CliUtils } from '../utils';
|
import { CliUtils } from '../utils';
|
||||||
|
|
||||||
export class ImportCommand {
|
export class ImportCommand {
|
||||||
constructor(private cryptoService: CryptoService, private userService: UserService,
|
constructor(private cryptoService: CryptoService, private importService: ImportService) { }
|
||||||
private importService: ImportService) { }
|
|
||||||
|
|
||||||
async run(format: string, filepath: string, password: string, cmd: program.Command): Promise<Response> {
|
async run(format: string, filepath: string, password: string, cmd: program.Command): Promise<Response> {
|
||||||
if (cmd.formats || false) {
|
if (cmd.formats || false) {
|
||||||
|
@ -41,9 +39,7 @@ export class ImportCommand {
|
||||||
return Response.badRequest('Master password is required.');
|
return Response.badRequest('Master password is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const email = await this.userService.getEmail();
|
const keyHash = await this.cryptoService.hashPassword(password, null);
|
||||||
const key = await this.cryptoService.makeKey(password, email);
|
|
||||||
const keyHash = await this.cryptoService.hashPassword(password, key);
|
|
||||||
const storedKeyHash = await this.cryptoService.getKeyHash();
|
const storedKeyHash = await this.cryptoService.getKeyHash();
|
||||||
if (storedKeyHash == null || keyHash == null || storedKeyHash !== keyHash) {
|
if (storedKeyHash == null || keyHash == null || storedKeyHash !== keyHash) {
|
||||||
return Response.badRequest('Invalid master password.');
|
return Response.badRequest('Invalid master password.');
|
||||||
|
|
|
@ -30,7 +30,9 @@ export class UnlockCommand {
|
||||||
|
|
||||||
this.setNewSessionKey();
|
this.setNewSessionKey();
|
||||||
const email = await this.userService.getEmail();
|
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 keyHash = await this.cryptoService.hashPassword(password, key);
|
||||||
const storedKeyHash = await this.cryptoService.getKeyHash();
|
const storedKeyHash = await this.cryptoService.getKeyHash();
|
||||||
if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) {
|
if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) {
|
||||||
|
|
|
@ -383,8 +383,7 @@ export class Program {
|
||||||
})
|
})
|
||||||
.action(async (format, filepath, password, cmd) => {
|
.action(async (format, filepath, password, cmd) => {
|
||||||
await this.exitIfLocked();
|
await this.exitIfLocked();
|
||||||
const command = new ImportCommand(this.main.cryptoService,
|
const command = new ImportCommand(this.main.cryptoService, this.main.importService);
|
||||||
this.main.userService, this.main.importService);
|
|
||||||
const response = await command.run(format, filepath, password, cmd);
|
const response = await command.run(format, filepath, password, cmd);
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
});
|
});
|
||||||
|
@ -404,8 +403,7 @@ export class Program {
|
||||||
})
|
})
|
||||||
.action(async (password, cmd) => {
|
.action(async (password, cmd) => {
|
||||||
await this.exitIfLocked();
|
await this.exitIfLocked();
|
||||||
const command = new ExportCommand(this.main.cryptoService, this.main.userService,
|
const command = new ExportCommand(this.main.cryptoService, this.main.exportService);
|
||||||
this.main.exportService);
|
|
||||||
const response = await command.run(password, cmd);
|
const response = await command.run(password, cmd);
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue