mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-17 15:37:57 +01:00
wip: remove IPC service complexity
The code was making some wrong assumptions about how IPC is going to work. I'm removing everything and starting the content-script instead
This commit is contained in:
parent
3abc28aeb1
commit
0c74f97920
3
apps/browser/src/platform/ipc/ipc-background.service.ts
Normal file
3
apps/browser/src/platform/ipc/ipc-background.service.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { IpcService } from "@bitwarden/platform";
|
||||
|
||||
export class IpcForegroundService extends IpcService {}
|
@ -1,25 +0,0 @@
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
import { IpcLink, IpcMessage, IpcService } from "@bitwarden/platform";
|
||||
import { Destination, Manager } from "@bitwarden/sdk-internal";
|
||||
|
||||
export class IpcForegroundService extends IpcService {
|
||||
private static LinkToBackground = new IpcLink(
|
||||
async (data) => {
|
||||
await chrome.runtime.sendMessage({ payload: data } as IpcMessage);
|
||||
},
|
||||
new Observable<Uint8Array>((subscriber) => {
|
||||
const listener = (message: IpcMessage) => {
|
||||
subscriber.next(message.payload);
|
||||
};
|
||||
chrome.runtime.onMessage.addListener(listener);
|
||||
|
||||
return () => chrome.runtime.onMessage.removeListener(listener);
|
||||
}),
|
||||
[Destination.BrowserBackground],
|
||||
);
|
||||
|
||||
protected override async registerLinks(manager: Manager): Promise<void> {
|
||||
await manager.register_link(IpcForegroundService.LinkToBackground);
|
||||
}
|
||||
}
|
@ -3,9 +3,5 @@ import { Manager } from "@bitwarden/sdk-internal";
|
||||
export abstract class IpcService {
|
||||
protected manager = new Manager();
|
||||
|
||||
async init() {
|
||||
await this.registerLinks(this.manager);
|
||||
}
|
||||
|
||||
protected abstract registerLinks(manager: Manager): Promise<void>;
|
||||
async init() {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user