Files
Netcatty/application/state/useKeychainBackend.ts
T
陈大猫 951a89e91e Enable opt-in MFA for SSH exec export (#172)
Add execCommand options to opt into keyboard-interactive auth and wire MFA only
for export-key flows, preserving non-interactive exec usage elsewhere.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 01:32:41 +08:00

29 lines
883 B
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;
enableKeyboardInteractive?: boolean;
sessionId?: string;
}) => {
const bridge = netcattyBridge.get();
if (!bridge?.execCommand) throw new Error("execCommand unavailable");
return bridge.execCommand(options);
}, []);
return { generateKeyPair, execCommand };
};