1
0
mirror of https://github.com/bitwarden/cli synced 2025-12-27 21:43:15 +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

@@ -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;