1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

feat: add support for IPC client managed session storage

This commit is contained in:
Andreas Coroiu
2025-11-06 09:27:22 +01:00
parent a66227638e
commit b125c7e680
7 changed files with 70 additions and 5 deletions

View File

@@ -131,7 +131,7 @@ import {
} from "@bitwarden/common/platform/abstractions/storage.service";
import { SystemService as SystemServiceAbstraction } from "@bitwarden/common/platform/abstractions/system.service";
import { ActionsService } from "@bitwarden/common/platform/actions/actions-service";
import { IpcService } from "@bitwarden/common/platform/ipc";
import { IpcService, IpcSessionRepository } from "@bitwarden/common/platform/ipc";
import { Message, MessageListener, MessageSender } from "@bitwarden/common/platform/messaging";
// eslint-disable-next-line no-restricted-imports -- Used for dependency creation
import { SubjectMessageSender } from "@bitwarden/common/platform/messaging/internal";
@@ -1476,7 +1476,12 @@ export default class MainBackground {
);
this.ipcContentScriptManagerService = new IpcContentScriptManagerService(this.configService);
this.ipcService = new IpcBackgroundService(this.platformUtilsService, this.logService);
const ipcSessionRepository = new IpcSessionRepository(this.stateProvider);
this.ipcService = new IpcBackgroundService(
this.platformUtilsService,
this.logService,
ipcSessionRepository,
);
this.endUserNotificationService = new DefaultEndUserNotificationService(
this.stateProvider,

View File

@@ -8,6 +8,7 @@ import {
OutgoingMessage,
ipcRegisterDiscoverHandler,
IpcClient,
IpcSessionRepository,
} from "@bitwarden/sdk-internal";
import { BrowserApi } from "../browser/browser-api";
@@ -18,6 +19,7 @@ export class IpcBackgroundService extends IpcService {
constructor(
private platformUtilsService: PlatformUtilsService,
private logService: LogService,
private sessionRepository: IpcSessionRepository,
) {
super();
}
@@ -70,7 +72,9 @@ export class IpcBackgroundService extends IpcService {
);
});
await super.initWithClient(new IpcClient(this.communicationBackend));
await super.initWithClient(
IpcClient.newWithClientManagedSessions(this.communicationBackend, this.sessionRepository),
);
if (this.platformUtilsService.isDev()) {
await ipcRegisterDiscoverHandler(this.client, {

View File

@@ -3,7 +3,12 @@ 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 {
IpcMessage,
IpcService,
isIpcMessage,
IpcSessionRepository,
} from "@bitwarden/common/platform/ipc";
import {
IncomingMessage,
IpcClient,
@@ -15,6 +20,7 @@ import {
export class WebIpcService extends IpcService {
private logService = inject(LogService);
private platformUtilsService = inject(PlatformUtilsService);
private sessionRepository = inject(IpcSessionRepository);
private communicationBackend?: IpcCommunicationBackend;
override async init() {
@@ -70,7 +76,9 @@ export class WebIpcService extends IpcService {
);
});
await super.initWithClient(new IpcClient(this.communicationBackend));
await super.initWithClient(
IpcClient.newWithClientManagedSessions(this.communicationBackend, this.sessionRepository),
);
if (this.platformUtilsService.isDev()) {
await ipcRegisterDiscoverHandler(this.client, {