Use proper logging, fix linting errors.
This commit is contained in:
parent
5b0b07f812
commit
d83e2bc117
|
@ -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);
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -1406,6 +1406,6 @@
|
||||||
"message": "Enable browser integration"
|
"message": "Enable browser integration"
|
||||||
},
|
},
|
||||||
"enableBrowserIntegrationDesc": {
|
"enableBrowserIntegrationDesc": {
|
||||||
"message": ""
|
"message": "Browser integration is used for biometrics in browser."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue