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

secure storage with env session key

This commit is contained in:
Kyle Spearrin
2018-05-15 21:11:58 -04:00
parent e8a3325ec9
commit 807cca2bd2
6 changed files with 109 additions and 19 deletions

View File

@@ -8,11 +8,15 @@ import { TwoFactorEmailRequest } from 'jslib/models/request/twoFactorEmailReques
import { ApiService } from 'jslib/abstractions/api.service';
import { AuthService } from 'jslib/abstractions/auth.service';
import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service';
import { Response } from '../models/response';
import { Utils } from 'jslib/misc/utils';
export class LoginCommand {
constructor(private authService: AuthService, private apiService: ApiService) { }
constructor(private authService: AuthService, private apiService: ApiService,
private cryptoFunctionService: CryptoFunctionService) { }
async run(email: string, password: string, cmd: program.Command) {
if (email == null || email === '') {
@@ -46,6 +50,7 @@ export class LoginCommand {
}
try {
await this.setNewSessionKey();
let response: AuthResult = null;
if (twoFactorToken != null && twoFactorMethod != null) {
response = await this.authService.logInComplete(email, password, twoFactorMethod,
@@ -106,4 +111,9 @@ export class LoginCommand {
return Response.error(e);
}
}
private async setNewSessionKey() {
const key = await this.cryptoFunctionService.randomBytes(64);
process.env.BW_SESSION = Utils.fromBufferToB64(key);
}
}