1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-31 23:53:37 +00:00

Response option outputs only json on stdout (#197)

* Use logService for console logging

* jslib signature updates

* Use most specific import path

* Include new jslib dependency

* Update jslib

Co-authored-by: Matt Gibson <mdgibson@Matts-MBP.lan>
This commit is contained in:
Matt Gibson
2020-12-14 11:29:17 -06:00
committed by GitHub
parent 6e05b87e88
commit 0330641a14
4 changed files with 16 additions and 14 deletions

View File

@@ -102,9 +102,10 @@ export class Main {
(level) => process.env.BITWARDENCLI_DEBUG !== 'true' && level <= LogLevelType.Info);
this.cryptoFunctionService = new NodeCryptoFunctionService();
this.storageService = new LowdbStorageService(this.logService, null, p, true);
this.secureStorageService = new NodeEnvSecureStorageService(this.storageService, () => this.cryptoService);
this.secureStorageService = new NodeEnvSecureStorageService(this.storageService, this.logService,
() => this.cryptoService);
this.cryptoService = new CryptoService(this.storageService, this.secureStorageService,
this.cryptoFunctionService, this.platformUtilsService);
this.cryptoFunctionService, this.platformUtilsService, this.logService);
this.appIdService = new AppIdService(this.storageService);
this.tokenService = new TokenService(this.storageService);
this.messagingService = new NoopMessagingService();
@@ -122,7 +123,7 @@ export class Main {
this.storageService, this.i18nService, this.cipherService);
this.collectionService = new CollectionService(this.cryptoService, this.userService, this.storageService,
this.i18nService);
this.searchService = new SearchService(this.cipherService);
this.searchService = new SearchService(this.cipherService, this.logService);
this.policyService = new PolicyService(this.userService, this.storageService);
this.sendService = new SendService(this.cryptoService, this.userService, this.apiService, this.storageService,
this.i18nService, this.cryptoFunctionService);
@@ -141,7 +142,7 @@ export class Main {
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,
this.vaultTimeoutService, true);
this.vaultTimeoutService, this.logService, true);
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
this.program = new Program(this);
}

View File

@@ -1,12 +1,13 @@
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { LogService } from 'jslib/abstractions/log.service';
import { StorageService } from 'jslib/abstractions/storage.service';
import { SymmetricCryptoKey } from 'jslib/models/domain';
import { ErrorResponse } from 'jslib/models/response';
import { SymmetricCryptoKey } from 'jslib/models/domain/symmetricCryptoKey';
import { Utils } from 'jslib/misc/utils';
export class NodeEnvSecureStorageService implements StorageService {
constructor(private storageService: StorageService, private cryptoService: () => CryptoService) { }
constructor(private storageService: StorageService, private logService: LogService,
private cryptoService: () => CryptoService) { }
async get<T>(key: string): Promise<T> {
const value = await this.storageService.get<string>(this.makeProtectedStorageKey(key));
@@ -53,15 +54,13 @@ export class NodeEnvSecureStorageService implements StorageService {
const decValue = await this.cryptoService().decryptFromBytes(
Utils.fromB64ToArray(encValue).buffer, sessionKey);
if (decValue == null) {
// tslint:disable-next-line
console.log('Failed to decrypt.');
this.logService.info('Failed to decrypt.');
return null;
}
return Utils.fromBufferToB64(decValue);
} catch (e) {
// tslint:disable-next-line
console.log('Decrypt error.');
this.logService.info('Decrypt error.');
return null;
}
}
@@ -78,8 +77,7 @@ export class NodeEnvSecureStorageService implements StorageService {
}
}
} catch (e) {
// tslint:disable-next-line
console.log('Session key is invalid.');
this.logService.info('Session key is invalid.');
}
return null;