1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-28 12:35:40 +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); this.onMessage(message);
}); });
/*
ipc.of.bitwarden.on('error', (err: any) => { ipc.of.bitwarden.on('error', (err: any) => {
console.error('error', err); 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 eventService = new EventService(storageService, apiService, userService, cipherService);
const systemService = new SystemService(storageService, vaultTimeoutService, messagingService, platformUtilsService, const systemService = new SystemService(storageService, vaultTimeoutService, messagingService, platformUtilsService,
null); null);
const nativeMessagingService = new NativeMessagingService(cryptoService, platformUtilsService) const nativeMessagingService = new NativeMessagingService(cryptoService, platformUtilsService, logService);
const analytics = new Analytics(window, () => isDev(), platformUtilsService, storageService, appIdService); const analytics = new Analytics(window, () => isDev(), platformUtilsService, storageService, appIdService);
containerService.attachToGlobal(window); containerService.attachToGlobal(window);

View File

@ -1406,6 +1406,6 @@
"message": "Enable browser integration" "message": "Enable browser integration"
}, },
"enableBrowserIntegrationDesc": { "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 { 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 { 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) => { ipcRenderer.on('nativeMessaging', async (event: any, message: any) => {
this.messageHandler(message); this.messageHandler(message);
}); });
@ -12,8 +17,8 @@ export class NativeMessagingService {
private async messageHandler(rawMessage: any) { private async messageHandler(rawMessage: any) {
const message = JSON.parse(await this.cryptoService.decryptToUtf8(rawMessage)); const message = JSON.parse(await this.cryptoService.decryptToUtf8(rawMessage));
if (Math.abs(message.timestamp - Date.now()) > 10*1000) { if (Math.abs(message.timestamp - Date.now()) > MessageValidTimeout) {
console.error("MESSAGE IS TO OLD"); this.logService.error('NativeMessage is to old, ignoring.');
return; return;
} }
@ -33,7 +38,7 @@ export class NativeMessagingService {
break; break;
default: default:
console.error('UNKNOWN COMMAND') this.logService.error('NativeMessage, got unknown command.');
} }
} }