mirror of
https://github.com/bitwarden/desktop.git
synced 2025-01-31 22:41:27 +01:00
Replace cosole logs with logService
This commit is contained in:
parent
24ef7e1ef6
commit
830c4a45ee
@ -119,7 +119,7 @@ export class Main {
|
|||||||
this.biometricMain = new BiometricDarwinMain(this.storageService, this.i18nService);
|
this.biometricMain = new BiometricDarwinMain(this.storageService, this.i18nService);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.nativeMessagingService = new NativeMessagingService(app.getPath('userData'), app.getAppPath());
|
this.nativeMessagingService = new NativeMessagingService(this.logService, app.getPath('userData'), app.getAppPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap() {
|
bootstrap() {
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import * as fs from 'fs';
|
import { promises as fs, existsSync } from 'fs';
|
||||||
import * as ipc from 'node-ipc';
|
import * as ipc from 'node-ipc';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as util from 'util';
|
import * as util from 'util';
|
||||||
|
|
||||||
|
import { LogService } from 'jslib/abstractions/log.service';
|
||||||
|
|
||||||
export class NativeMessagingService {
|
export class NativeMessagingService {
|
||||||
private connected = false;
|
private connected = false;
|
||||||
|
|
||||||
constructor(private userPath: string, private appPath: string) {}
|
constructor(private logService: LogService, private userPath: string, private appPath: string) {}
|
||||||
|
|
||||||
listen() {
|
listen() {
|
||||||
ipc.config.id = 'bitwarden';
|
ipc.config.id = 'bitwarden';
|
||||||
@ -47,32 +49,15 @@ export class NativeMessagingService {
|
|||||||
const firefoxJson = {...baseJson, ...{ 'allowed_origins': ['446900e4-71c2-419f-a6a7-df9c091e268b']}}
|
const firefoxJson = {...baseJson, ...{ 'allowed_origins': ['446900e4-71c2-419f-a6a7-df9c091e268b']}}
|
||||||
const chromeJson = {...baseJson, ...{ 'allowed_origins': ['chrome-extension://ijeheppnniijonkinoakkofcdhdfojda/']}}
|
const chromeJson = {...baseJson, ...{ 'allowed_origins': ['chrome-extension://ijeheppnniijonkinoakkofcdhdfojda/']}}
|
||||||
|
|
||||||
fs.mkdir(path.join(this.userPath, 'browsers'), (err) => console.log);
|
if (!existsSync(path.join(this.userPath, 'browsers'))) {
|
||||||
|
fs.mkdir(path.join(this.userPath, 'browsers'))
|
||||||
|
.catch(this.logService.error)
|
||||||
|
}
|
||||||
|
|
||||||
this.writeManifest('firefox.json', firefoxJson);
|
this.writeManifest('firefox.json', firefoxJson);
|
||||||
this.writeManifest('chrome.json', chromeJson);
|
this.writeManifest('chrome.json', chromeJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
private writeManifest(filename: string, manifest: object) {
|
|
||||||
fs.writeFile(
|
|
||||||
path.join(this.userPath, 'browsers', filename),
|
|
||||||
JSON.stringify(manifest, null, 2),
|
|
||||||
(err) => console.log
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private binaryName() {
|
|
||||||
switch (process.platform) {
|
|
||||||
case 'win32':
|
|
||||||
return 'app-win.exe'
|
|
||||||
case 'darwin':
|
|
||||||
return 'app-linux'
|
|
||||||
case 'linux':
|
|
||||||
default:
|
|
||||||
return 'app-macos'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup registry and/or directories
|
// Setup registry and/or directories
|
||||||
// TODO: Do other browsers use different directories?
|
// TODO: Do other browsers use different directories?
|
||||||
enableManifest() {
|
enableManifest() {
|
||||||
@ -89,6 +74,25 @@ export class NativeMessagingService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private writeManifest(filename: string, manifest: object) {
|
||||||
|
fs.writeFile(
|
||||||
|
path.join(this.userPath, 'browsers', filename),
|
||||||
|
JSON.stringify(manifest, null, 2)
|
||||||
|
).catch(this.logService.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
private binaryName() {
|
||||||
|
switch (process.platform) {
|
||||||
|
case 'win32':
|
||||||
|
return 'app-win.exe'
|
||||||
|
case 'darwin':
|
||||||
|
return 'app-linux'
|
||||||
|
case 'linux':
|
||||||
|
default:
|
||||||
|
return 'app-macos'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private createWindowsRegistry(check: string, location: string, jsonFile: string) {
|
private createWindowsRegistry(check: string, location: string, jsonFile: string) {
|
||||||
const regedit = require('regedit');
|
const regedit = require('regedit');
|
||||||
regedit.setExternalVBSLocation('resources/regedit/vbs');
|
regedit.setExternalVBSLocation('resources/regedit/vbs');
|
||||||
@ -97,6 +101,8 @@ export class NativeMessagingService {
|
|||||||
const createKey = util.promisify(regedit.createKey);
|
const createKey = util.promisify(regedit.createKey);
|
||||||
const putValue = util.promisify(regedit.putValue);
|
const putValue = util.promisify(regedit.putValue);
|
||||||
|
|
||||||
|
this.logService.debug(`Adding registry: ${location}`)
|
||||||
|
|
||||||
// Check installed
|
// Check installed
|
||||||
list(check)
|
list(check)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@ -115,6 +121,6 @@ export class NativeMessagingService {
|
|||||||
|
|
||||||
return putValue(obj);
|
return putValue(obj);
|
||||||
})
|
})
|
||||||
.catch()
|
.catch(this.logService.error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user