1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 13:23:34 +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:
Andreas Coroiu
2025-06-26 14:01:31 +02:00
committed by GitHub
parent 473ab3a1f7
commit 71d4f989b7
6 changed files with 30 additions and 9 deletions

View File

@@ -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,

View File

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

View File

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

View File

@@ -4,7 +4,7 @@ import { IpcClient, IncomingMessage, OutgoingMessage } from "@bitwarden/sdk-inte
export abstract class IpcService {
private _client?: IpcClient;
protected get client(): IpcClient {
get client(): IpcClient {
if (!this._client) {
throw new Error("IpcService not initialized");
}

8
package-lock.json generated
View File

@@ -24,7 +24,7 @@
"@angular/platform-browser": "19.2.14",
"@angular/platform-browser-dynamic": "19.2.14",
"@angular/router": "19.2.14",
"@bitwarden/sdk-internal": "0.2.0-main.203",
"@bitwarden/sdk-internal": "0.2.0-main.213",
"@electron/fuses": "1.8.0",
"@emotion/css": "11.13.5",
"@koa/multer": "3.1.0",
@@ -4589,9 +4589,9 @@
"link": true
},
"node_modules/@bitwarden/sdk-internal": {
"version": "0.2.0-main.203",
"resolved": "https://registry.npmjs.org/@bitwarden/sdk-internal/-/sdk-internal-0.2.0-main.203.tgz",
"integrity": "sha512-AcRX2odnabnx16VF+K7naEZ3R4Tv/o8mVsVhrvwOTG+TEBUxR1BzCoE2r+l0+iz1zV32UV2YHeLZvyCB2/KftA==",
"version": "0.2.0-main.213",
"resolved": "https://registry.npmjs.org/@bitwarden/sdk-internal/-/sdk-internal-0.2.0-main.213.tgz",
"integrity": "sha512-/AUpdQQ++tLsH9dJDFQcIDihCpsI+ikdZuYwbztSXPp7piCnLk71f7r10yMPGQ8OEOF49mMEbLCG+dJKpBqeRg==",
"license": "GPL-3.0",
"dependencies": {
"type-fest": "^4.41.0"

View File

@@ -160,7 +160,7 @@
"@angular/platform-browser": "19.2.14",
"@angular/platform-browser-dynamic": "19.2.14",
"@angular/router": "19.2.14",
"@bitwarden/sdk-internal": "0.2.0-main.203",
"@bitwarden/sdk-internal": "0.2.0-main.213",
"@electron/fuses": "1.8.0",
"@emotion/css": "11.13.5",
"@koa/multer": "3.1.0",