mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-22 08:03:40 +00:00
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { useCallback } from "react";
|
|
import { netcattyBridge } from "../../infrastructure/services/netcattyBridge";
|
|
|
|
export const useKeychainBackend = () => {
|
|
const generateKeyPair = useCallback(async (options: { type: "RSA" | "ECDSA" | "ED25519"; bits?: number; comment?: string }) => {
|
|
const bridge = netcattyBridge.get();
|
|
return bridge?.generateKeyPair?.(options);
|
|
}, []);
|
|
|
|
const execCommand = useCallback(async (options: {
|
|
hostname: string;
|
|
username: string;
|
|
port?: number;
|
|
password?: string;
|
|
privateKey?: string;
|
|
command: string;
|
|
timeout?: number;
|
|
sshTcpConnectTimeoutMs?: number;
|
|
sshAuthReadyTimeoutMs?: number;
|
|
enableKeyboardInteractive?: boolean;
|
|
sessionId?: string;
|
|
// Algorithm settings — let the keychain "export public key" flow honor
|
|
// the same per-host SSH algorithm config the terminal uses, so a host
|
|
// that needs the ECDSA skip / legacy mode / advanced overrides works
|
|
// here too.
|
|
legacyAlgorithms?: boolean;
|
|
skipEcdsaHostKey?: boolean;
|
|
algorithmOverrides?: import("../../domain/models").HostAlgorithmOverrides;
|
|
}) => {
|
|
const bridge = netcattyBridge.get();
|
|
if (!bridge?.execCommand) throw new Error("execCommand unavailable");
|
|
return bridge.execCommand(options);
|
|
}, []);
|
|
|
|
return { generateKeyPair, execCommand };
|
|
};
|