fix(web): support SSH host key prompts

This commit is contained in:
t8y2 committed 2026-07-28 12:19:48 +08:00
1 parent cb9d0f7cbf
commit 8ac282cc37
14 files changed
+509 -32

No files matched your search

@@ -0,0 +1,25 @@
import { afterEach, describe, expect, it, vi } from "vitest";
afterEach(() => {
vi.unstubAllGlobals();
vi.resetModules();
});
describe("web SSH prompt API", () => {
it("posts the host-key resolution to the authenticated web endpoint", async () => {
const fetchMock = vi.fn().mockResolvedValue({
ok: true,
json: vi.fn().mockResolvedValue(null),
});
vi.stubGlobal("fetch", fetchMock);
const { resolveSshPrompt } = await import("@/lib/backend/http");
await resolveSshPrompt({ id: "prompt-1", action: "accept", remember: true });
expect(fetchMock).toHaveBeenCalledWith("/api/ssh/prompts/resolve", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ id: "prompt-1", action: "accept", remember: true }),
});
});
});
+1
View File
@@ -67,6 +67,7 @@ export const loadConnections = forward("loadConnections");
export const loadTunnelProfiles = forward("loadTunnelProfiles");
export const saveTunnelProfiles = forward("saveTunnelProfiles");
export const testTunnelProfile = forward("testTunnelProfile");
export const resolveSshPrompt = forward("resolveSshPrompt");
export const readKeychainPassword = forward("readKeychainPassword");
export const readKeychainPasswords = forward("readKeychainPasswords");
export const decryptConfig = forward("decryptConfig");
+5
View File
@@ -121,6 +121,7 @@ import type {
MongoGridFsFileInfo,
AppSupportInfo,
PromptTemplate,
SshPromptResolution,
} from "@/lib/backend/tauri";
import type { QueryEditability } from "@/lib/sql/sqlAnalysis";
import { isTerminalTransferProgress } from "@/lib/backend/transferProgress";
@@ -320,6 +321,10 @@ export async function testTunnelProfile(profile: TunnelProfile): Promise<string>
return post("/api/tunnel-profiles/test", profile);
}
export async function resolveSshPrompt(resolution: SshPromptResolution): Promise<void> {
await post("/api/ssh/prompts/resolve", resolution);
}
export async function readKeychainPassword(_service: string): Promise<string> {
return ""; // Not available in web backend
}
+11
View File
@@ -74,6 +74,13 @@ import type { CreateDatabaseSqlOptions } from "@/lib/database/createDatabaseSql"
import type { DatabaseNameSqlOptions, DatabasePropertyEditSqlOptions, DropTableChildObjectSqlOptions, DropObjectSqlOptions, DuplicateTableStructureSqlOptions, CopyTableDataSqlOptions, SchemaNameSqlOptions, TableAdminSqlOptions } from "@/lib/database/dbAdminSql";
import type { BuildDatabaseSqlExportOptions, BuildExportInsertStatementsOptions } from "@/lib/export/databaseExport";
export interface SshPromptResolution {
id: string;
action: "accept" | "reject" | "secret";
remember?: boolean;
secret?: string;
}
export interface AgentDriverInfo {
db_type: string;
label: string;
@@ -1280,6 +1287,10 @@ export async function testTunnelProfile(profile: TunnelProfile): Promise<string>
return invoke("test_tunnel_profile", { profile });
}
export async function resolveSshPrompt(resolution: SshPromptResolution): Promise<void> {
await invoke("resolve_ssh_prompt", { resolution });
}
export async function readKeychainPassword(service: string): Promise<string> {
return invoke("read_keychain_password", { service, account: null });
}