1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

Initial PoC for browser <-> desktop communication

This commit is contained in:
Hinton
2020-10-05 15:11:37 +02:00
parent 38ecc3b74b
commit f09a788103
13 changed files with 960 additions and 4 deletions

View File

@@ -0,0 +1,33 @@
import * as ipc from 'node-ipc';
export class NativeMessagingService {
private connected = false;
listen() {
ipc.config.id = 'bitwarden';
ipc.config.retry = 1500;
ipc.serve(() => {
ipc.server.on('message', (data: any, socket: any) => {
ipc.log('got a message : ', data);
ipc.server.emit(socket, 'message', data + ' world!');
});
ipc.server.on('connect', () => {
this.connected = true;
})
ipc.server.on(
'socket.disconnected',
(socket: any, destroyedSocketID: any) => {
this.connected = false;
ipc.log(
'client ' + destroyedSocketID + ' has disconnected!'
);
}
);
});
ipc.server.start();
}
}