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

Use log service for console messages (#221)

* Use logService for console messages

* Implement a base ConsoleLog service

Use this class as a default for other services that would like to output
to console. This service is overriden in CLI and Desktop to use CLI's
consoleLogService and electronLogService, respectively.

* Use browser-process-hrtime for timing

* test LogService implementations

* Ignore default import of hrtime

* Clean up imports. Require ConsoleLog injection

Co-authored-by: Matt Gibson <mdgibson@Matts-MBP.lan>
This commit is contained in:
Matt Gibson
2020-12-11 10:44:57 -06:00
committed by GitHub
parent 63fe38b3f4
commit 2c414ce27a
15 changed files with 269 additions and 85 deletions

View File

@@ -10,6 +10,7 @@ import { ProfileOrganizationResponse } from '../models/response/profileOrganizat
import { CryptoService as CryptoServiceAbstraction } from '../abstractions/crypto.service';
import { CryptoFunctionService } from '../abstractions/cryptoFunction.service';
import { LogService } from '../abstractions/log.service';
import { PlatformUtilsService } from '../abstractions/platformUtils.service';
import { StorageService } from '../abstractions/storage.service';
@@ -37,7 +38,9 @@ export class CryptoService implements CryptoServiceAbstraction {
private orgKeys: Map<string, SymmetricCryptoKey>;
constructor(private storageService: StorageService, private secureStorageService: StorageService,
private cryptoFunctionService: CryptoFunctionService, private platformUtilService: PlatformUtilsService) { }
private cryptoFunctionService: CryptoFunctionService, private platformUtilService: PlatformUtilsService,
private logService: LogService) {
}
async setKey(key: SymmetricCryptoKey): Promise<any> {
this.key = key;
@@ -546,14 +549,12 @@ export class CryptoService implements CryptoServiceAbstraction {
const theKey = this.resolveLegacyKey(encType, keyForEnc);
if (theKey.macKey != null && mac == null) {
// tslint:disable-next-line
console.error('mac required.');
this.logService.error('mac required.');
return null;
}
if (theKey.encType !== encType) {
// tslint:disable-next-line
console.error('encType unavailable.');
this.logService.error('encType unavailable.');
return null;
}
@@ -563,8 +564,7 @@ export class CryptoService implements CryptoServiceAbstraction {
fastParams.macKey, 'sha256');
const macsEqual = await this.cryptoFunctionService.compareFast(fastParams.mac, computedMac);
if (!macsEqual) {
// tslint:disable-next-line
console.error('mac failed.');
this.logService.error('mac failed.');
return null;
}
}
@@ -596,8 +596,7 @@ export class CryptoService implements CryptoServiceAbstraction {
const macsMatch = await this.cryptoFunctionService.compare(mac, computedMac);
if (!macsMatch) {
// tslint:disable-next-line
console.error('mac failed.');
this.logService.error('mac failed.');
return null;
}
}