diff --git a/jslib b/jslib index 72bf18f369..2c414ce27a 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 72bf18f369068d36767794bdc0ca377f734cf373 +Subproject commit 2c414ce27a5c14f6cd7f86cfd07096a192d058ca diff --git a/package.json b/package.json index e74f26df40..7c6f203615 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/bw.ts b/src/bw.ts index 988912392e..3352f7cf07 100644 --- a/src/bw.ts +++ b/src/bw.ts @@ -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); } diff --git a/src/services/nodeEnvSecureStorage.service.ts b/src/services/nodeEnvSecureStorage.service.ts index 04a38537fe..56ecce472a 100644 --- a/src/services/nodeEnvSecureStorage.service.ts +++ b/src/services/nodeEnvSecureStorage.service.ts @@ -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(key: string): Promise { const value = await this.storageService.get(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;