1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

Use proper logging, fix linting errors.

This commit is contained in:
Hinton 2020-10-12 21:34:41 +02:00
parent 5b0b07f812
commit d83e2bc117
4 changed files with 13 additions and 10 deletions

View File

@ -28,11 +28,9 @@ export default class IPC {
this.onMessage(message);
});
/*
ipc.of.bitwarden.on('error', (err: any) => {
console.error('error', err);
});
*/
});
}

View File

@ -129,7 +129,7 @@ const environmentService = new EnvironmentService(apiService, storageService, no
const eventService = new EventService(storageService, apiService, userService, cipherService);
const systemService = new SystemService(storageService, vaultTimeoutService, messagingService, platformUtilsService,
null);
const nativeMessagingService = new NativeMessagingService(cryptoService, platformUtilsService)
const nativeMessagingService = new NativeMessagingService(cryptoService, platformUtilsService, logService);
const analytics = new Analytics(window, () => isDev(), platformUtilsService, storageService, appIdService);
containerService.attachToGlobal(window);

View File

@ -1406,6 +1406,6 @@
"message": "Enable browser integration"
},
"enableBrowserIntegrationDesc": {
"message": ""
"message": "Browser integration is used for biometrics in browser."
}
}

View File

@ -1,9 +1,14 @@
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { PlatformUtilsService } from 'jslib/abstractions';
import { ipcRenderer } from 'electron';
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { LogService } from 'jslib/abstractions/log.service';
const MessageValidTimeout = 10 * 1000;
export class NativeMessagingService {
constructor(private cryptoService: CryptoService, private platformUtilService: PlatformUtilsService) {
constructor(private cryptoService: CryptoService, private platformUtilService: PlatformUtilsService, private logService: LogService) {
ipcRenderer.on('nativeMessaging', async (event: any, message: any) => {
this.messageHandler(message);
});
@ -12,8 +17,8 @@ export class NativeMessagingService {
private async messageHandler(rawMessage: any) {
const message = JSON.parse(await this.cryptoService.decryptToUtf8(rawMessage));
if (Math.abs(message.timestamp - Date.now()) > 10*1000) {
console.error("MESSAGE IS TO OLD");
if (Math.abs(message.timestamp - Date.now()) > MessageValidTimeout) {
this.logService.error('NativeMessage is to old, ignoring.');
return;
}
@ -33,7 +38,7 @@ export class NativeMessagingService {
break;
default:
console.error('UNKNOWN COMMAND')
this.logService.error('NativeMessage, got unknown command.');
}
}