2021-12-20 15:47:17 +01:00
|
|
|
import IPC from "./ipc";
|
|
|
|
import NativeMessage from "./nativemessage";
|
2020-10-05 15:11:37 +02:00
|
|
|
|
2020-10-21 16:48:40 +02:00
|
|
|
// Proxy is a lightweight application which provides bi-directional communication
|
|
|
|
// between the browser extension and a running desktop application.
|
|
|
|
//
|
|
|
|
// Browser extension <-[native messaging]-> proxy <-[ipc]-> desktop
|
2020-11-23 18:37:04 +01:00
|
|
|
export class NativeMessagingProxy {
|
2021-12-20 15:47:17 +01:00
|
|
|
private ipc: IPC;
|
|
|
|
private nativeMessage: NativeMessage;
|
2020-10-05 15:11:37 +02:00
|
|
|
|
2021-12-20 15:47:17 +01:00
|
|
|
constructor() {
|
|
|
|
this.ipc = new IPC();
|
|
|
|
this.nativeMessage = new NativeMessage(this.ipc);
|
|
|
|
}
|
2020-10-05 15:11:37 +02:00
|
|
|
|
2021-12-20 15:47:17 +01:00
|
|
|
run() {
|
|
|
|
this.ipc.connect();
|
|
|
|
this.nativeMessage.listen();
|
2020-11-30 15:10:57 +01:00
|
|
|
|
2021-12-20 15:47:17 +01:00
|
|
|
this.ipc.onMessage = this.nativeMessage.send;
|
|
|
|
}
|
2020-10-05 15:11:37 +02:00
|
|
|
}
|