mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 14:53:33 +00:00
[PM-18042] Build request response structure (#15163)
* feat: add support for discover command * feat: make client public to allow RPC * feat: update SDK
This commit is contained in:
@@ -1346,7 +1346,7 @@ export default class MainBackground {
|
||||
this.inlineMenuFieldQualificationService = new InlineMenuFieldQualificationService();
|
||||
|
||||
this.ipcContentScriptManagerService = new IpcContentScriptManagerService(this.configService);
|
||||
this.ipcService = new IpcBackgroundService(this.logService);
|
||||
this.ipcService = new IpcBackgroundService(this.platformUtilsService, this.logService);
|
||||
|
||||
this.endUserNotificationService = new DefaultEndUserNotificationService(
|
||||
this.stateProvider,
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";
|
||||
import { IpcMessage, isIpcMessage, IpcService } from "@bitwarden/common/platform/ipc";
|
||||
import {
|
||||
IpcClient,
|
||||
IpcCommunicationBackend,
|
||||
IncomingMessage,
|
||||
OutgoingMessage,
|
||||
ipcRegisterDiscoverHandler,
|
||||
IpcClient,
|
||||
} from "@bitwarden/sdk-internal";
|
||||
|
||||
import { BrowserApi } from "../browser/browser-api";
|
||||
@@ -13,7 +15,10 @@ import { BrowserApi } from "../browser/browser-api";
|
||||
export class IpcBackgroundService extends IpcService {
|
||||
private communicationBackend?: IpcCommunicationBackend;
|
||||
|
||||
constructor(private logService: LogService) {
|
||||
constructor(
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private logService: LogService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -60,11 +65,18 @@ export class IpcBackgroundService extends IpcService {
|
||||
{
|
||||
Web: { id: sender.tab.id },
|
||||
},
|
||||
message.message.topic,
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
await super.initWithClient(new IpcClient(this.communicationBackend));
|
||||
|
||||
if (this.platformUtilsService.isDev()) {
|
||||
await ipcRegisterDiscoverHandler(this.client, {
|
||||
version: await this.platformUtilsService.getApplicationVersion(),
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
this.logService.error("[IPC] Initialization failed", e);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import { inject } from "@angular/core";
|
||||
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";
|
||||
import { IpcMessage, IpcService, isIpcMessage } from "@bitwarden/common/platform/ipc";
|
||||
import {
|
||||
IncomingMessage,
|
||||
IpcClient,
|
||||
IpcCommunicationBackend,
|
||||
ipcRegisterDiscoverHandler,
|
||||
OutgoingMessage,
|
||||
} from "@bitwarden/sdk-internal";
|
||||
|
||||
export class WebIpcService extends IpcService {
|
||||
private logService = inject(LogService);
|
||||
private platformUtilsService = inject(PlatformUtilsService);
|
||||
private communicationBackend?: IpcCommunicationBackend;
|
||||
|
||||
override async init() {
|
||||
@@ -68,6 +71,12 @@ export class WebIpcService extends IpcService {
|
||||
});
|
||||
|
||||
await super.initWithClient(new IpcClient(this.communicationBackend));
|
||||
|
||||
if (this.platformUtilsService.isDev()) {
|
||||
await ipcRegisterDiscoverHandler(this.client, {
|
||||
version: await this.platformUtilsService.getApplicationVersion(),
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
this.logService.error("[IPC] Initialization failed", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user