1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01: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:mac": "npm run symlink:lin",
"symlink:lin": "rm -rf ./jslib && ln -s ../jslib ./jslib", "symlink:lin": "rm -rf ./jslib && ln -s ../jslib ./jslib",
"build": "webpack", "build": "webpack",
"build:debug": "npm run build && node --inspect ./build/bw.js",
"build:watch": "webpack --watch", "build:watch": "webpack --watch",
"build:prod": "cross-env NODE_ENV=production webpack", "build:prod": "cross-env NODE_ENV=production webpack",
"build:prod:watch": "cross-env NODE_ENV=production webpack --watch", "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:win": "pkg . --targets win-x64 --output ./dist/windows/bw.exe",
"package:mac": "pkg . --targets macos-x64 --output ./dist/macos/bw", "package:mac": "pkg . --targets macos-x64 --output ./dist/macos/bw",
"package:lin": "pkg . --targets linux-x64 --output ./dist/linux/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": "npm run build:prod && npm run clean && npm run package",
"dist:win": "npm run build:prod && npm run clean && npm run package:win", "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", "dist:mac": "npm run build:prod && npm run clean && npm run package:mac",
@ -73,6 +75,7 @@
}, },
"dependencies": { "dependencies": {
"big-integer": "1.6.36", "big-integer": "1.6.36",
"browser-process-hrtime": "1.0.0",
"chalk": "2.4.1", "chalk": "2.4.1",
"commander": "2.18.0", "commander": "2.18.0",
"form-data": "2.3.2", "form-data": "2.3.2",

View File

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

View File

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