1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-06 05:28:51 +02: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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 14 deletions

2
jslib

@ -1 +1 @@
Subproject commit 72bf18f369068d36767794bdc0ca377f734cf373
Subproject commit 2c414ce27a5c14f6cd7f86cfd07096a192d058ca

View File

@ -25,6 +25,7 @@
"symlink:mac": "npm run symlink:lin",
"symlink:lin": "rm -rf ./jslib && ln -s ../jslib ./jslib",
"build": "webpack",
"build:debug": "npm run build && node --inspect ./build/bw.js",
"build:watch": "webpack --watch",
"build:prod": "cross-env NODE_ENV=production webpack",
"build:prod:watch": "cross-env NODE_ENV=production webpack --watch",
@ -32,6 +33,7 @@
"package:win": "pkg . --targets win-x64 --output ./dist/windows/bw.exe",
"package:mac": "pkg . --targets macos-x64 --output ./dist/macos/bw",
"package:lin": "pkg . --targets linux-x64 --output ./dist/linux/bw",
"debug": "node --inspect ./build/bw.js",
"dist": "npm run build:prod && npm run clean && npm run package",
"dist:win": "npm run build:prod && npm run clean && npm run package:win",
"dist:mac": "npm run build:prod && npm run clean && npm run package:mac",
@ -73,6 +75,7 @@
},
"dependencies": {
"big-integer": "1.6.36",
"browser-process-hrtime": "1.0.0",
"chalk": "2.4.1",
"commander": "2.18.0",
"form-data": "2.3.2",

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;