Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions apps/desktop/src/autofill/services/ssh-agent.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,11 @@ export class SshAgentService implements OnDestroy {

return of([message, account.id]);
}),
// This switchMap handles fetching the ciphers from the vault.
switchMap(([message, userId]: [Record<string, unknown>, UserId]) =>
from(this.cipherService.getAllDecrypted(userId)).pipe(
map((ciphers) => [message, ciphers] as const),
),
),
// This concatMap handles showing the dialog to approve the request.
concatMap(async ([message, ciphers]) => {
concatMap(async ([message, userId]: [Record<string, unknown>, UserId]) => {
const ciphers = await firstValueFrom(
this.cipherService.cipherViews$(userId).pipe(filter((ciphers) => ciphers !== null)),
);
const cipherId = message.cipherId as string;
const isListRequest = message.isListRequest as boolean;
const requestId = message.requestId as number;
Expand Down Expand Up @@ -235,14 +232,22 @@ export class SshAgentService implements OnDestroy {
}

const activeAccount = await firstValueFrom(this.accountService.activeAccount$);
if (activeAccount == null) {
await ipc.platform.sshAgent.clearKeys();
return;
}
const authStatus = await firstValueFrom(
this.authService.authStatusFor$(activeAccount.id),
);
if (authStatus !== AuthenticationStatus.Unlocked) {
return;
}

const ciphers = await this.cipherService.getAllDecrypted(activeAccount.id);
const ciphers = await firstValueFrom(
this.cipherService
.cipherViews$(activeAccount.id)
.pipe(filter((ciphers) => ciphers !== null)),
);
if (ciphers == null) {
await ipc.platform.sshAgent.lock();
return;
Expand Down
Loading