mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 14:53:33 +00:00
[PM-16837] Fix agent only loading when featureflag is on during startup (#12742)
* Fix ssh generation and import not being available when agent feature-flag is disabled * Fix agent only loading when featureflag is on during startup
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
// @ts-strict-ignore
|
// @ts-strict-ignore
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
import { app, ipcMain } from "electron";
|
import { app } from "electron";
|
||||||
import { Subject, firstValueFrom } from "rxjs";
|
import { Subject, firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
import { AccountServiceImplementation } from "@bitwarden/common/auth/services/account.service";
|
import { AccountServiceImplementation } from "@bitwarden/common/auth/services/account.service";
|
||||||
@@ -257,12 +257,7 @@ export class Main {
|
|||||||
this.clipboardMain = new ClipboardMain();
|
this.clipboardMain = new ClipboardMain();
|
||||||
this.clipboardMain.init();
|
this.clipboardMain.init();
|
||||||
|
|
||||||
ipcMain.handle("sshagent.init", async (event: any, message: any) => {
|
|
||||||
if (this.sshAgentService == null) {
|
|
||||||
this.sshAgentService = new MainSshAgentService(this.logService, this.messagingService);
|
this.sshAgentService = new MainSshAgentService(this.logService, this.messagingService);
|
||||||
this.sshAgentService.init();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
new EphemeralValueStorageService();
|
new EphemeralValueStorageService();
|
||||||
new SSOLocalhostCallbackService(this.environmentService, this.messagingService);
|
new SSOLocalhostCallbackService(this.environmentService, this.messagingService);
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ export class MainSshAgentService {
|
|||||||
return sshagent.importKey(privateKey, password);
|
return sshagent.importKey(privateKey, password);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ipcMain.handle("sshagent.init", async (event: any, message: any) => {
|
||||||
|
this.init();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle("sshagent.isloaded", async (event: any) => {
|
||||||
|
return this.agentState != null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ const sshAgent = {
|
|||||||
});
|
});
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
isLoaded(): Promise<boolean> {
|
||||||
|
return ipcRenderer.invoke("sshagent.isloaded");
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const powermonitor = {
|
const powermonitor = {
|
||||||
|
|||||||
@@ -61,8 +61,20 @@ export class SshAgentService implements OnDestroy {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
const isSshAgentFeatureEnabled = await this.configService.getFeatureFlag(FeatureFlag.SSHAgent);
|
this.configService
|
||||||
if (isSshAgentFeatureEnabled) {
|
.getFeatureFlag$(FeatureFlag.SSHAgent)
|
||||||
|
.pipe(
|
||||||
|
concatMap(async (enabled) => {
|
||||||
|
if (enabled && !(await ipc.platform.sshAgent.isLoaded())) {
|
||||||
|
return this.initSshAgent();
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
takeUntil(this.destroy$),
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async initSshAgent() {
|
||||||
await ipc.platform.sshAgent.init();
|
await ipc.platform.sshAgent.init();
|
||||||
|
|
||||||
this.messageListener
|
this.messageListener
|
||||||
@@ -222,7 +234,6 @@ export class SshAgentService implements OnDestroy {
|
|||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.destroy$.next();
|
this.destroy$.next();
|
||||||
|
|||||||
Reference in New Issue
Block a user