import React, { useMemo, useState, useCallback } from 'react'; import { SSHKey, KeyType, KeySource, KeyCategory, Identity, IdentityAuthMethod, Host } from '../types'; import { Key, Plus, Trash2, Shield, Search, LayoutGrid, List as ListIcon, ChevronDown, Fingerprint, FileKey, BadgeCheck, MoreHorizontal, ChevronRight, Eye, EyeOff, Copy, Download, Upload, User, UserPlus, ExternalLink, Info, Pencil, } from 'lucide-react'; import { Button } from './ui/button'; import { Input } from './ui/input'; import { Card, CardDescription, CardTitle } from './ui/card'; import { Label } from './ui/label'; import { Textarea } from './ui/textarea'; import { ScrollArea } from './ui/scroll-area'; import { cn } from '../lib/utils'; import { Popover, PopoverContent, PopoverTrigger } from './ui/popover'; import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuTrigger, } from './ui/context-menu'; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from './ui/collapsible'; import SelectHostPanel from './SelectHostPanel'; import { toast } from './ui/toast'; import { AsidePanel, AsidePanelContent } from './ui/aside-panel'; // Filter tab types type FilterTab = 'key' | 'certificate' | 'biometric' | 'fido2'; // Panel modes type PanelMode = | { type: 'closed' } | { type: 'view'; key: SSHKey } | { type: 'edit'; key: SSHKey } | { type: 'generate'; keyType: 'standard' | 'biometric' | 'fido2' } | { type: 'import' } | { type: 'identity'; identity?: Identity } | { type: 'export'; key: SSHKey }; interface KeychainManagerProps { keys: SSHKey[]; identities?: Identity[]; hosts?: Host[]; customGroups?: string[]; onSave: (key: SSHKey) => void; onUpdate: (key: SSHKey) => void; onDelete: (id: string) => void; onSaveIdentity?: (identity: Identity) => void; onDeleteIdentity?: (id: string) => void; onNewHost?: () => void; onSaveHost?: (host: Host) => void; onCreateGroup?: (groupPath: string) => void; } // Helper to generate mock key pair (in real app, use crypto APIs) const generateMockKeyPair = (type: KeyType, label: string, keySize?: number): { privateKey: string; publicKey: string } => { const typeMap: Record = { 'ED25519': 'ed25519', 'ECDSA': `ecdsa-sha2-nistp${keySize || 256}`, 'RSA': 'rsa', }; const randomId = crypto.randomUUID().replace(/-/g, '').substring(0, 32); // Generate size-appropriate random data for more realistic keys const keyLength = type === 'RSA' ? (keySize || 4096) / 8 : 32; const randomData = Array.from(crypto.getRandomValues(new Uint8Array(keyLength))) .map(b => b.toString(16).padStart(2, '0')).join(''); const privateKey = `-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW QyNTUxOQAAACB${randomId}AAAEC${randomData.substring(0, 64)} -----END OPENSSH PRIVATE KEY-----`; const publicKey = `ssh-${typeMap[type]} AAAAC3NzaC1lZDI1NTE5AAAAI${randomId.substring(0, 20)} ${label}@netcatty`; return { privateKey, publicKey }; }; // FIDO2 hardware key helper (YubiKey, etc.) const createFido2Credential = async (label: string): Promise<{ credentialId: string; publicKey: string; rpId: string; } | null> => { try { // Check if WebAuthn is supported if (!window.PublicKeyCredential) { throw new Error('WebAuthn is not supported in this environment'); } // Check if we're in a secure context if (!window.isSecureContext) { throw new Error('WebAuthn requires a secure context (HTTPS). Please run the app via localhost or HTTPS.'); } // For FIDO2 hardware keys, we use cross-platform authenticator let rpId: string; const hostname = window.location.hostname; if (!hostname || hostname === '' || hostname === 'localhost' || hostname === '127.0.0.1') { rpId = 'localhost'; } else { rpId = hostname; } const userId = new TextEncoder().encode(crypto.randomUUID()); const credential = await navigator.credentials.create({ publicKey: { challenge: crypto.getRandomValues(new Uint8Array(32)), rp: { name: 'Netcatty SSH Manager', id: rpId, }, user: { id: userId, name: label, displayName: label, }, pubKeyCredParams: [ { alg: -7, type: 'public-key' }, // ES256 (ECDSA P-256) { alg: -257, type: 'public-key' }, // RS256 (RSA) ], authenticatorSelection: { // cross-platform for hardware security keys like YubiKey authenticatorAttachment: 'cross-platform', residentKey: 'discouraged', userVerification: 'preferred', }, timeout: 180000, // 3 minutes attestation: 'none', }, }) as PublicKeyCredential; if (!credential) { return null; } const response = credential.response as AuthenticatorAttestationResponse; const credentialId = btoa(String.fromCharCode(...new Uint8Array(credential.rawId))); const publicKeyBytes = new Uint8Array(response.getPublicKey?.() || []); const publicKeyBase64 = btoa(String.fromCharCode(...publicKeyBytes)); // Format as OpenSSH sk-ecdsa key const publicKey = `sk-ecdsa-sha2-nistp256@openssh.com AAAAInNrLWVjZHNhLXNoYTItbmlzdHAyNTZAb3BlbnNzaC5jb20${publicKeyBase64.substring(0, 100)} ${label}@fido2`; return { credentialId, publicKey, rpId, }; } catch (error) { console.error('FIDO2 credential creation failed:', error); throw error; } }; // WebAuthn helper for Windows Hello const createBiometricCredential = async (label: string): Promise<{ credentialId: string; publicKey: string; rpId: string; } | null> => { try { // Check if WebAuthn is supported if (!window.PublicKeyCredential) { throw new Error('WebAuthn is not supported in this environment'); } // Check if we're in a secure context (HTTPS or localhost) if (!window.isSecureContext) { throw new Error('WebAuthn requires a secure context (HTTPS). This feature is not available in the current environment.'); } // Check if platform authenticator is available (Windows Hello, Touch ID, etc.) const available = await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable(); if (!available) { const isMacOS = navigator.platform.toLowerCase().includes('mac') || navigator.userAgent.toLowerCase().includes('mac'); throw new Error(`No platform authenticator available. Please ensure ${isMacOS ? 'Touch ID' : 'Windows Hello'} is set up in your system settings.`); } // For Electron apps, we need to handle the rpId carefully // The rpId must match the origin's effective domain let rpId: string; const hostname = window.location.hostname; // In Electron file:// protocol or localhost dev server if (!hostname || hostname === '' || hostname === 'localhost' || hostname === '127.0.0.1') { rpId = 'localhost'; } else { rpId = hostname; } const userId = new TextEncoder().encode(crypto.randomUUID()); const credential = await navigator.credentials.create({ publicKey: { challenge: crypto.getRandomValues(new Uint8Array(32)), rp: { name: 'Netcatty SSH Manager', id: rpId, }, user: { id: userId, name: label, displayName: label, }, pubKeyCredParams: [ { alg: -7, type: 'public-key' }, // ES256 (ECDSA P-256) ], authenticatorSelection: { authenticatorAttachment: 'platform', residentKey: 'discouraged', userVerification: 'preferred', }, timeout: 180000, // 3 minutes attestation: 'none', }, }) as PublicKeyCredential; if (!credential) { return null; } const response = credential.response as AuthenticatorAttestationResponse; // Convert credential ID to base64 const credentialId = btoa(String.fromCharCode(...new Uint8Array(credential.rawId))); // Extract public key from attestation (simplified - in production, parse CBOR properly) const publicKeyBytes = new Uint8Array(response.getPublicKey?.() || []); const publicKeyBase64 = btoa(String.fromCharCode(...publicKeyBytes)); // Format as OpenSSH sk-ecdsa key const publicKey = `sk-ecdsa-sha2-nistp256@openssh.com AAAAInNrLWVjZHNhLXNoYTItbmlzdHAyNTZAb3BlbnNzaC5jb20${publicKeyBase64.substring(0, 100)} ${label}@netcatty`; return { credentialId, publicKey, rpId, }; } catch (error) { console.error('WebAuthn credential creation failed:', error); throw error; } }; const KeychainManager: React.FC = ({ keys, identities = [], hosts = [], customGroups = [], onSave, onUpdate, onDelete, onSaveIdentity, onDeleteIdentity, onNewHost, onSaveHost, onCreateGroup, }) => { const [activeFilter, setActiveFilter] = useState('key'); const [search, setSearch] = useState(''); const [viewMode, setViewMode] = useState<'grid' | 'list'>('grid'); // Panel stack for navigation (supports back navigation) const [panelStack, setPanelStack] = useState([]); const panel = panelStack.length > 0 ? panelStack[panelStack.length - 1] : { type: 'closed' } as PanelMode; const [showHostSelector, setShowHostSelector] = useState(false); const [isExporting, setIsExporting] = useState(false); // Export panel state const [exportLocation, setExportLocation] = useState('.ssh'); const [exportFilename, setExportFilename] = useState('authorized_keys'); const [exportHost, setExportHost] = useState(null); const [exportAdvancedOpen, setExportAdvancedOpen] = useState(false); const [exportScript, setExportScript] = useState(`DIR="$HOME/$1" FILE="$DIR/$2" if [ ! -d "$DIR" ]; then mkdir -p "$DIR" chmod 700 "$DIR" fi if [ ! -f "$FILE" ]; then touch "$FILE" chmod 600 "$FILE" fi echo $3 >> "$FILE"`); // Detect if running on macOS const isMac = useMemo(() => { return navigator.platform.toLowerCase().includes('mac') || navigator.userAgent.toLowerCase().includes('mac'); }, []); // Biometric authentication label based on platform const biometricLabel = isMac ? 'TOUCH ID' : 'WINDOWS HELLO'; // Draft state for forms const [draftKey, setDraftKey] = useState>({}); const [draftIdentity, setDraftIdentity] = useState>({}); const [showPassphrase, setShowPassphrase] = useState(false); const [isGenerating, setIsGenerating] = useState(false); const [error, setError] = useState(null); // Filter keys based on active tab and search const filteredKeys = useMemo(() => { let result = keys; // Filter by tab switch (activeFilter) { case 'key': result = result.filter(k => k.source === 'generated' || k.source === 'imported'); break; case 'certificate': result = result.filter(k => k.category === 'certificate' || k.certificate); break; case 'biometric': result = result.filter(k => k.source === 'biometric'); break; case 'fido2': result = result.filter(k => k.source === 'fido2'); break; } // Filter by search if (search.trim()) { const s = search.toLowerCase(); result = result.filter(k => k.label.toLowerCase().includes(s) || k.type.toLowerCase().includes(s) || k.publicKey?.toLowerCase().includes(s) ); } return result; }, [keys, activeFilter, search]); // Filter identities based on search const filteredIdentities = useMemo(() => { if (!search.trim()) return identities; const s = search.toLowerCase(); return identities.filter(i => i.label.toLowerCase().includes(s) || i.username.toLowerCase().includes(s) ); }, [identities, search]); // Push a new panel onto the stack const pushPanel = useCallback((newPanel: PanelMode) => { setPanelStack(prev => [...prev, newPanel]); setError(null); }, []); // Pop the top panel from the stack (go back) const popPanel = useCallback(() => { setPanelStack(prev => { if (prev.length <= 1) { // Last panel, close everything setDraftKey({}); setDraftIdentity({}); setError(null); setShowPassphrase(false); setExportHost(null); setExportAdvancedOpen(false); return []; } return prev.slice(0, -1); }); }, []); // Close all panels const closePanel = useCallback(() => { setPanelStack([]); setDraftKey({}); setDraftIdentity({}); setError(null); setShowPassphrase(false); setExportHost(null); setExportAdvancedOpen(false); }, []); // Open panel for viewing key (replaces stack with single panel) const openKeyView = useCallback((key: SSHKey) => { setPanelStack([{ type: 'view', key }]); setDraftKey({ ...key }); setError(null); }, []); // Open panel for exporting key (pushes onto stack) const openKeyExport = useCallback((key: SSHKey) => { pushPanel({ type: 'export', key }); setExportHost(null); setExportLocation('.ssh'); setExportFilename('authorized_keys'); }, [pushPanel]); // Open panel for editing key (replaces stack) const openKeyEdit = useCallback((key: SSHKey) => { setPanelStack([{ type: 'edit', key }]); setDraftKey({ ...key }); setError(null); }, []); // Copy public key to clipboard const copyPublicKey = useCallback(async (key: SSHKey) => { if (key.publicKey) { try { await navigator.clipboard.writeText(key.publicKey); // Could add toast notification here } catch (err) { console.error('Failed to copy public key:', err); } } }, []); // Open panel for new identity const openNewIdentity = useCallback(() => { setPanelStack([{ type: 'identity' }]); setDraftIdentity({ id: '', label: '', username: '', authMethod: 'password', created: Date.now(), }); setError(null); }, []); // Open generate panel const openGenerate = useCallback((keyType: 'standard' | 'biometric' | 'fido2') => { const defaultType = (keyType === 'biometric' || keyType === 'fido2') ? 'ECDSA' : 'ED25519'; // Set default keySize based on type: ED25519 doesn't need size, RSA defaults to 4096, ECDSA to 256 const getDefaultKeySize = (type: string) => { if (type === 'ED25519') return undefined; if (type === 'RSA') return 4096; return 256; // ECDSA }; const getSource = () => { if (keyType === 'biometric') return 'biometric'; if (keyType === 'fido2') return 'fido2'; return 'generated'; }; setPanelStack([{ type: 'generate', keyType }]); setDraftKey({ id: '', label: '', type: defaultType, keySize: getDefaultKeySize(defaultType), privateKey: '', publicKey: '', source: getSource(), category: 'key', created: Date.now(), }); setError(null); }, []); // Open import panel const openImport = useCallback(() => { setPanelStack([{ type: 'import' }]); setDraftKey({ id: '', label: '', type: 'ED25519', privateKey: '', publicKey: '', source: 'imported', category: 'key', created: Date.now(), }); setError(null); }, []); // Handle standard key generation const handleGenerateStandard = useCallback(async () => { if (!draftKey.label?.trim()) { setError('Please enter a label for the key'); return; } setIsGenerating(true); setError(null); try { const keyType = draftKey.type as KeyType || 'ED25519'; const keySize = draftKey.keySize; // Use real key generation via Electron backend if (window.nebula?.generateKeyPair) { const result = await window.nebula.generateKeyPair({ type: keyType, bits: keySize, comment: `${draftKey.label.trim()}@netcatty`, }); if (!result.success || !result.privateKey || !result.publicKey) { throw new Error(result.error || 'Failed to generate key pair'); } const newKey: SSHKey = { id: crypto.randomUUID(), label: draftKey.label.trim(), type: keyType, keySize: keyType !== 'ED25519' ? keySize : undefined, privateKey: result.privateKey, publicKey: result.publicKey, passphrase: draftKey.passphrase, savePassphrase: draftKey.savePassphrase, source: 'generated', category: 'key', created: Date.now(), }; onSave(newKey); closePanel(); } else { throw new Error('Key generation not available - please ensure the app is running in Electron'); } } catch (err) { setError(err instanceof Error ? err.message : 'Failed to generate key'); } finally { setIsGenerating(false); } }, [draftKey, onSave, closePanel]); // Handle biometric key generation (Windows Hello) const handleGenerateBiometric = useCallback(async () => { if (!draftKey.label?.trim()) { setError('Please enter a label for the key'); return; } setIsGenerating(true); setError(null); try { const result = await createBiometricCredential(draftKey.label.trim()); if (!result) { throw new Error('Credential creation was cancelled'); } const newKey: SSHKey = { id: crypto.randomUUID(), label: draftKey.label.trim(), type: 'ECDSA', privateKey: '', // Biometric keys don't have exportable private keys publicKey: result.publicKey, credentialId: result.credentialId, rpId: result.rpId, source: 'biometric', category: 'key', created: Date.now(), }; onSave(newKey); closePanel(); } catch (err) { setError(err instanceof Error ? err.message : 'Failed to create biometric credential'); } finally { setIsGenerating(false); } }, [draftKey, onSave, closePanel]); // Handle FIDO2 hardware key registration const handleGenerateFido2 = useCallback(async () => { if (!draftKey.label?.trim()) { setError('Please enter a label for the security key'); return; } setIsGenerating(true); setError(null); try { const result = await createFido2Credential(draftKey.label.trim()); if (!result) { throw new Error('Security key registration was cancelled'); } const newKey: SSHKey = { id: crypto.randomUUID(), label: draftKey.label.trim(), type: 'ECDSA', privateKey: '', // Hardware keys don't expose private keys publicKey: result.publicKey, credentialId: result.credentialId, rpId: result.rpId, source: 'fido2', category: 'key', created: Date.now(), }; onSave(newKey); closePanel(); } catch (err) { setError(err instanceof Error ? err.message : 'Failed to register security key'); } finally { setIsGenerating(false); } }, [draftKey, onSave, closePanel]); // Handle key import const handleImport = useCallback(() => { if (!draftKey.label?.trim() || !draftKey.privateKey?.trim()) { setError('Label and private key are required'); return; } // Detect key type from private key content let detectedType: KeyType = 'ED25519'; const pk = draftKey.privateKey.toLowerCase(); if (pk.includes('rsa')) detectedType = 'RSA'; else if (pk.includes('ecdsa') || pk.includes('ec ')) detectedType = 'ECDSA'; else if (pk.includes('ed25519')) detectedType = 'ED25519'; const newKey: SSHKey = { id: crypto.randomUUID(), label: draftKey.label.trim(), type: draftKey.type as KeyType || detectedType, privateKey: draftKey.privateKey.trim(), publicKey: draftKey.publicKey?.trim() || undefined, certificate: draftKey.certificate?.trim() || undefined, passphrase: draftKey.passphrase, savePassphrase: draftKey.savePassphrase, source: 'imported', category: draftKey.certificate ? 'certificate' : 'key', created: Date.now(), }; onSave(newKey); closePanel(); }, [draftKey, onSave, closePanel]); // Handle save identity const handleSaveIdentity = useCallback(() => { if (!draftIdentity.label?.trim() || !draftIdentity.username?.trim()) { setError('Label and username are required'); return; } if (!onSaveIdentity) return; const newIdentity: Identity = { id: draftIdentity.id || crypto.randomUUID(), label: draftIdentity.label.trim(), username: draftIdentity.username.trim(), authMethod: draftIdentity.authMethod || 'password', password: draftIdentity.password, keyId: draftIdentity.keyId, created: draftIdentity.created || Date.now(), }; onSaveIdentity(newIdentity); closePanel(); }, [draftIdentity, onSaveIdentity, closePanel]); // Handle delete const handleDelete = useCallback((id: string) => { onDelete(id); if (panel.type === 'view' && panel.key.id === id) { closePanel(); } }, [onDelete, panel, closePanel]); // Handle delete identity const handleDeleteIdentity = useCallback((id: string) => { onDeleteIdentity?.(id); if (panel.type === 'identity' && panel.identity?.id === id) { closePanel(); } }, [onDeleteIdentity, panel, closePanel]); // Copy to clipboard const copyToClipboard = useCallback((text: string) => { navigator.clipboard.writeText(text); }, []); // Get icon for key source const getKeyIcon = (key: SSHKey) => { if (key.source === 'biometric') return ; if (key.source === 'fido2') return ; if (key.certificate) return ; return ; }; // Get key type display const getKeyTypeDisplay = (key: SSHKey) => { if (key.source === 'biometric') return isMac ? 'Touch ID' : 'Windows Hello'; if (key.source === 'fido2') return 'FIDO2'; return key.type; }; // File input ref for import const fileInputRef = React.useRef(null); // Handle file import const handleFileImport = useCallback((event: React.ChangeEvent) => { const file = event.target.files?.[0]; if (!file) return; const reader = new FileReader(); reader.onload = (e) => { const content = e.target?.result as string; if (content) { // Try to detect key type from content let detectedType: KeyType = 'ED25519'; const lc = content.toLowerCase(); if (lc.includes('rsa')) detectedType = 'RSA'; else if (lc.includes('ecdsa') || lc.includes('ec private')) detectedType = 'ECDSA'; else if (lc.includes('ed25519')) detectedType = 'ED25519'; // Extract label from filename (remove extension) const label = file.name.replace(/\.(pem|key|pub|ppk)$/i, ''); setDraftKey(prev => ({ ...prev, privateKey: content, label: prev.label || label, type: detectedType, })); } }; reader.readAsText(file); // Reset input so same file can be selected again event.target.value = ''; }, []); // Handle drag and drop const handleDrop = useCallback((event: React.DragEvent) => { event.preventDefault(); event.stopPropagation(); const file = event.dataTransfer.files?.[0]; if (!file) return; const reader = new FileReader(); reader.onload = (e) => { const content = e.target?.result as string; if (content) { let detectedType: KeyType = 'ED25519'; const lc = content.toLowerCase(); if (lc.includes('rsa')) detectedType = 'RSA'; else if (lc.includes('ecdsa') || lc.includes('ec private')) detectedType = 'ECDSA'; else if (lc.includes('ed25519')) detectedType = 'ED25519'; const label = file.name.replace(/\.(pem|key|pub|ppk)$/i, ''); setDraftKey(prev => ({ ...prev, privateKey: content, label: prev.label || label, type: detectedType, })); } }; reader.readAsText(file); }, []); const handleDragOver = useCallback((event: React.DragEvent) => { event.preventDefault(); event.stopPropagation(); }, []); return (
{/* Hidden file input */} {/* Main Content */}
{/* Toolbar */}
{/* Filter Tabs */}
{/* KEY button with split interaction: left=switch view, right=dropdown */}
{onSaveIdentity && ( )}
{/* CERTIFICATE button with split interaction */}
{/* Search and View Mode - hide search when panel is open */}
{panel.type === 'closed' && (
setSearch(e.target.value)} placeholder="Search..." className="h-9 pl-8 w-full" />
)}
{/* Keys Section */}

Keys

{filteredKeys.length} items
{filteredKeys.length === 0 ? (

{activeFilter === 'biometric' ? `Set up ${isMac ? 'Touch ID' : 'Windows Hello'}` : activeFilter === 'fido2' ? 'Add a security key' : 'Set up your keys'}

{activeFilter === 'biometric' ? `Create biometric SSH keys secured by ${isMac ? 'Touch ID' : 'Windows Hello'} for passwordless authentication.` : activeFilter === 'fido2' ? 'Connect a hardware security key (YubiKey, etc.) for enhanced security.' : 'Import or generate SSH keys for secure authentication.'}

{activeFilter === 'biometric' && ( )} {activeFilter === 'fido2' && ( )} {(activeFilter === 'key' || activeFilter === 'certificate') && (
)}
) : (
{filteredKeys.map((key) => (
openKeyView(key)} >
{getKeyIcon(key)}
{key.label}
Type {getKeyTypeDisplay(key)}
{viewMode === 'list' && ( )}
copyPublicKey(key)} disabled={!key.publicKey} > Copy Public Key openKeyExport(key)}> Key Export openKeyEdit(key)}> Edit handleDelete(key.id)} className="text-destructive focus:text-destructive" > Delete
))}
)}
{/* Identities Section */} {activeFilter === 'key' && filteredIdentities.length > 0 && (

Identities

{filteredIdentities.length} items
{filteredIdentities.map((identity) => (
{ setPanelStack([{ type: 'identity', identity }]); setDraftIdentity({ ...identity }); }} >
{identity.label || 'Add a label...'}
{identity.authMethod === 'password' ? 'Password' : identity.authMethod === 'key' ? 'Key' : identity.authMethod === 'certificate' ? 'Certificate' : 'FIDO2'}
{viewMode === 'list' && ( )}
))}
)}
{/* Slide-out Panel */} {panel.type !== 'closed' && ( 1} onBack={popPanel} actions={ (panel.type === 'view' || panel.type === 'identity') ? ( ) : undefined } > {/* Error Display */} {error && (
{error}
)} {/* Generate Biometric Key */} {panel.type === 'generate' && panel.keyType === 'biometric' && ( <> {/* Keyboard illustration */}
{['9', '0', ')', '-', '+', '='].map((k, i) => (
{k}
))}
back
{['I', 'O', 'P', '[', ']', '{', '}'].map((k, i) => (
{k}
))}

Biometric Key based on Secure Enclave Process built-in into your {isMac ? 'mac' : 'system'}. This key is not possible to copy or steal.

setDraftKey({ ...draftKey, label: e.target.value })} placeholder={isMac ? 'Touch ID' : 'Windows Hello'} />

ECDSA

256

)} {/* Register FIDO2 Hardware Key */} {panel.type === 'generate' && panel.keyType === 'fido2' && ( <> {/* Security key illustration */}

YubiKey or compatible device

Connect your hardware security key (YubiKey, Titan, etc.) and touch it when prompted. The private key never leaves the device.

setDraftKey({ ...draftKey, label: e.target.value })} placeholder="My YubiKey" />

ECDSA (Hardware-backed)

P-256

)} {/* Generate Standard Key */} {panel.type === 'generate' && panel.keyType === 'standard' && ( <>
setDraftKey({ ...draftKey, label: e.target.value })} placeholder="My SSH Key" />
{(['ED25519', 'ECDSA', 'RSA'] as KeyType[]).map((t) => ( ))}
{/* Key Size selector - only for RSA and ECDSA */} {(draftKey.type === 'RSA' || draftKey.type === 'ECDSA') && (
{(draftKey.type === 'RSA' ? [4096, 2048, 1024] : [256, 384, 521] ).map((size) => ( ))}
)}
setDraftKey({ ...draftKey, passphrase: e.target.value })} placeholder="Optional passphrase" className="pr-10" />
setDraftKey({ ...draftKey, savePassphrase: e.target.checked })} className="h-4 w-4 rounded border-border" />
)} {/* Import Key */} {panel.type === 'import' && ( <>
setDraftKey({ ...draftKey, label: e.target.value })} placeholder="Key label" />