mirror of
https://github.com/bitwarden/desktop.git
synced 2024-11-24 11:55:50 +01:00
*Wip* Run proxy app through electron
This commit is contained in:
parent
4f466fba43
commit
efb7cc98ae
36
package.json
36
package.json
@ -32,7 +32,6 @@
|
|||||||
"build:main": "webpack --config webpack.main.js",
|
"build:main": "webpack --config webpack.main.js",
|
||||||
"build:renderer": "gulp prebuild:renderer && webpack --config webpack.renderer.js",
|
"build:renderer": "gulp prebuild:renderer && webpack --config webpack.renderer.js",
|
||||||
"build:renderer:watch": "gulp prebuild:renderer && webpack --config webpack.renderer.js --watch",
|
"build:renderer:watch": "gulp prebuild:renderer && webpack --config webpack.renderer.js --watch",
|
||||||
"build:proxy": "tsc --build proxy",
|
|
||||||
"electron": "npm run build:main && concurrently -k -n Main,Rend -c yellow,cyan \"electron --inspect=5858 ./build --watch\" \"npm run build:renderer:watch\"",
|
"electron": "npm run build:main && concurrently -k -n Main,Rend -c yellow,cyan \"electron --inspect=5858 ./build --watch\" \"npm run build:renderer:watch\"",
|
||||||
"clean:dist": "rimraf ./dist/*",
|
"clean:dist": "rimraf ./dist/*",
|
||||||
"clean:l10n": "git push origin --delete l10n_master",
|
"clean:l10n": "git push origin --delete l10n_master",
|
||||||
@ -43,15 +42,13 @@
|
|||||||
"pack:mac:masdev": "npm run clean:dist && electron-builder --mac mas-dev -p never",
|
"pack:mac:masdev": "npm run clean:dist && electron-builder --mac mas-dev -p never",
|
||||||
"pack:win": "npm run clean:dist && electron-builder --win --x64 --ia32 -p never -c.win.certificateSubjectName=\"8bit Solutions LLC\"",
|
"pack:win": "npm run clean:dist && electron-builder --win --x64 --ia32 -p never -c.win.certificateSubjectName=\"8bit Solutions LLC\"",
|
||||||
"pack:win:ci": "npm run clean:dist && electron-builder --win --x64 --ia32 -p never",
|
"pack:win:ci": "npm run clean:dist && electron-builder --win --x64 --ia32 -p never",
|
||||||
"pack:proxy": "pkg build/proxy/app.js --out-path build/proxies",
|
"dist:dir": "npm run build && npm run pack:dir",
|
||||||
"dist:dir": "npm run build && npm run dist:proxy && npm run pack:dir",
|
"dist:lin": "npm run build && npm run pack:lin",
|
||||||
"dist:lin": "npm run build && npm run dist:proxy && npm run pack:lin",
|
"dist:mac": "npm run build && npm run pack:mac",
|
||||||
"dist:mac": "npm run build && npm run dist:proxy && npm run pack:mac",
|
"dist:mac:mas": "npm run build && npm run pack:mac:mas",
|
||||||
"dist:mac:mas": "npm run build && npm run dist:proxy && npm run pack:mac:mas",
|
"dist:mac:masdev": "npm run build && npm run pack:mac:masdev",
|
||||||
"dist:mac:masdev": "npm run build && npm run dist:proxy && npm run pack:mac:masdev",
|
"dist:win": "npm run build && npm run pack:win",
|
||||||
"dist:win": "npm run build && npm run dist:proxy && npm run pack:win",
|
"dist:win:ci": "npm run build && npm run pack:win:ci",
|
||||||
"dist:win:ci": "npm run build && npm run dist:proxy && npm run pack:win:ci",
|
|
||||||
"dist:proxy": "npm run build:proxy && npm run pack:proxy",
|
|
||||||
"publish:lin": "npm run build && npm run clean:dist && electron-builder --linux --x64 -p always",
|
"publish:lin": "npm run build && npm run clean:dist && electron-builder --linux --x64 -p always",
|
||||||
"publish:mac": "npm run build && npm run clean:dist && electron-builder --mac -p always",
|
"publish:mac": "npm run build && npm run clean:dist && electron-builder --mac -p always",
|
||||||
"publish:mac:mas": "npm run dist:mac:mas && npm run upload:mas",
|
"publish:mac:mas": "npm run dist:mac:mas && npm run upload:mas",
|
||||||
@ -114,12 +111,6 @@
|
|||||||
"target": [
|
"target": [
|
||||||
"dmg",
|
"dmg",
|
||||||
"zip"
|
"zip"
|
||||||
],
|
|
||||||
"extraResources": [
|
|
||||||
{
|
|
||||||
"from": "build/proxies/app-macos",
|
|
||||||
"to": "proxy"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"win": {
|
"win": {
|
||||||
@ -130,10 +121,6 @@
|
|||||||
"appx"
|
"appx"
|
||||||
],
|
],
|
||||||
"extraResources": [
|
"extraResources": [
|
||||||
{
|
|
||||||
"from": "build/proxies/app-win.exe",
|
|
||||||
"to": "proxy.exe"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"from": "node_modules/regedit/vbs",
|
"from": "node_modules/regedit/vbs",
|
||||||
"to": "regedit/vbs",
|
"to": "regedit/vbs",
|
||||||
@ -157,13 +144,7 @@
|
|||||||
"Name": "Bitwarden",
|
"Name": "Bitwarden",
|
||||||
"Type": "Application",
|
"Type": "Application",
|
||||||
"GenericName": "Password Manager"
|
"GenericName": "Password Manager"
|
||||||
},
|
}
|
||||||
"extraResources": [
|
|
||||||
{
|
|
||||||
"from": "build/proxies/app-linux",
|
|
||||||
"to": "proxy"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"dmg": {
|
"dmg": {
|
||||||
"icon": "dmg.icns",
|
"icon": "dmg.icns",
|
||||||
@ -290,7 +271,6 @@
|
|||||||
"node-abi": "^2.9.0",
|
"node-abi": "^2.9.0",
|
||||||
"node-loader": "^0.6.0",
|
"node-loader": "^0.6.0",
|
||||||
"node-sass": "^4.13.1",
|
"node-sass": "^4.13.1",
|
||||||
"pkg": "^4.4.9",
|
|
||||||
"rimraf": "^2.6.2",
|
"rimraf": "^2.6.2",
|
||||||
"sass-loader": "^7.1.0",
|
"sass-loader": "^7.1.0",
|
||||||
"ts-loader": "^8.0.2",
|
"ts-loader": "^8.0.2",
|
||||||
|
4
proxy/global.d.ts
vendored
4
proxy/global.d.ts
vendored
@ -1,4 +0,0 @@
|
|||||||
declare module 'node-ipc' {
|
|
||||||
const x: any;
|
|
||||||
export = x;
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"emitDecoratorMetadata": true,
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"module": "CommonJS",
|
|
||||||
"target": "ES2016",
|
|
||||||
"allowJs": true,
|
|
||||||
"sourceMap": true,
|
|
||||||
"types": ["sweetalert2", "node"],
|
|
||||||
"baseUrl": ".",
|
|
||||||
"outDir": "../build/proxy",
|
|
||||||
"paths": {
|
|
||||||
"tldjs": [
|
|
||||||
"jslib/src/misc/tldjs.noop"
|
|
||||||
],
|
|
||||||
"jslib/*": [
|
|
||||||
"jslib/src/*"
|
|
||||||
],
|
|
||||||
"@angular/*": [
|
|
||||||
"node_modules/@angular/*"
|
|
||||||
],
|
|
||||||
"electron": [
|
|
||||||
"node_modules/electron"
|
|
||||||
],
|
|
||||||
"electron-log": [
|
|
||||||
"node_modules/electron-log"
|
|
||||||
],
|
|
||||||
"electron-store": [
|
|
||||||
"node_modules/electron-store"
|
|
||||||
],
|
|
||||||
"node": [
|
|
||||||
"node_modules/@types/node"
|
|
||||||
],
|
|
||||||
"duo_web_sdk": [
|
|
||||||
"node_modules/duo_web_sdk"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"angularCompilerOptions": {
|
|
||||||
"preserveWhitespaces": true
|
|
||||||
},
|
|
||||||
"exclude": [
|
|
||||||
"node_modules",
|
|
||||||
"jslib/node_modules",
|
|
||||||
"dist",
|
|
||||||
"dist-safari",
|
|
||||||
"jslib/dist",
|
|
||||||
"build",
|
|
||||||
"jslib/spec",
|
|
||||||
"jslib/src/cli",
|
|
||||||
"jslib/src/services/nodeApi.service.ts",
|
|
||||||
"jslib/src/services/lowdbStorage.service.ts"
|
|
||||||
]
|
|
||||||
}
|
|
11
src/main.ts
11
src/main.ts
@ -19,6 +19,7 @@ import { TrayMain } from 'jslib/electron/tray.main';
|
|||||||
import { UpdaterMain } from 'jslib/electron/updater.main';
|
import { UpdaterMain } from 'jslib/electron/updater.main';
|
||||||
import { WindowMain } from 'jslib/electron/window.main';
|
import { WindowMain } from 'jslib/electron/window.main';
|
||||||
import { NativeMessagingMain } from './main/nativeMessaging.main';
|
import { NativeMessagingMain } from './main/nativeMessaging.main';
|
||||||
|
import { NativeMessagingProxy } from './proxy/native-messaging-proxy';
|
||||||
|
|
||||||
export class Main {
|
export class Main {
|
||||||
logService: ElectronLogService;
|
logService: ElectronLogService;
|
||||||
@ -183,5 +184,11 @@ export class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const main = new Main();
|
console.error(process.argv);
|
||||||
main.bootstrap();
|
if (process.argv.some(arg => arg.indexOf('chrome-extension://') !== -1 || arg.indexOf('{') !== -1)) {
|
||||||
|
const proxy = new NativeMessagingProxy();
|
||||||
|
proxy.run();
|
||||||
|
} else {
|
||||||
|
const main = new Main();
|
||||||
|
main.bootstrap();
|
||||||
|
}
|
||||||
|
@ -6,8 +6,9 @@ ipc.config.retry = 1500;
|
|||||||
ipc.config.logger = console.warn; // Stdout is used for native messaging
|
ipc.config.logger = console.warn; // Stdout is used for native messaging
|
||||||
|
|
||||||
export default class IPC {
|
export default class IPC {
|
||||||
|
onMessage: (message: object) => void
|
||||||
|
|
||||||
private connected = false;
|
private connected = false;
|
||||||
public onMessage: (message: object) => void
|
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
ipc.connectTo('bitwarden', () => {
|
ipc.connectTo('bitwarden', () => {
|
@ -1,13 +1,11 @@
|
|||||||
import NativeMessage from './nativemessage';
|
import NativeMessage from './nativemessage';
|
||||||
import IPC from './ipc';
|
import IPC from './ipc';
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
|
||||||
|
|
||||||
// Proxy is a lightweight application which provides bi-directional communication
|
// Proxy is a lightweight application which provides bi-directional communication
|
||||||
// between the browser extension and a running desktop application.
|
// between the browser extension and a running desktop application.
|
||||||
//
|
//
|
||||||
// Browser extension <-[native messaging]-> proxy <-[ipc]-> desktop
|
// Browser extension <-[native messaging]-> proxy <-[ipc]-> desktop
|
||||||
class Proxy {
|
export class NativeMessagingProxy {
|
||||||
private ipc: IPC;
|
private ipc: IPC;
|
||||||
private nativeMessage: NativeMessage;
|
private nativeMessage: NativeMessage;
|
||||||
|
|
||||||
@ -23,6 +21,3 @@ class Proxy {
|
|||||||
this.ipc.onMessage = this.nativeMessage.send;
|
this.ipc.onMessage = this.nativeMessage.send;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const proxy = new Proxy();
|
|
||||||
proxy.run();
|
|
@ -1,5 +1,5 @@
|
|||||||
/* tslint:disable:no-console */
|
/* tslint:disable:no-console */
|
||||||
import IPC from 'ipc';
|
import IPC from './ipc';
|
||||||
|
|
||||||
// Mostly based on the example from MDN,
|
// Mostly based on the example from MDN,
|
||||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging
|
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging
|
Loading…
Reference in New Issue
Block a user