1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-18 15:47: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:
Andreas Coroiu 2024-12-17 10:36:56 +01:00
parent 3abc28aeb1
commit 0c74f97920
No known key found for this signature in database
GPG Key ID: E70B5FFC81DFEC1A
3 changed files with 4 additions and 30 deletions

View File

@ -0,0 +1,3 @@
import { IpcService } from "@bitwarden/platform";
export class IpcForegroundService extends IpcService {}

View File

@ -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);
}
}

View File

@ -3,9 +3,5 @@ import { Manager } from "@bitwarden/sdk-internal";
export abstract class IpcService { export abstract class IpcService {
protected manager = new Manager(); protected manager = new Manager();
async init() { async init() {}
await this.registerLinks(this.manager);
}
protected abstract registerLinks(manager: Manager): Promise<void>;
} }