import type { S3Config, SyncedFile, WebDAVConfig } from "../../domain/sync"; import type { AppLockSettings } from "../../domain/appLock"; type AppLockRuntimeReason = 'startup' | 'idle' | 'manual' | 'background' | null; interface AppLockRuntimeState { initialized: boolean; locked: boolean; reason: AppLockRuntimeReason; version: number; lastLockedAt: number | null; lastUnlockedAt: number | null; lastActivityAt: number | null; } type AppLockSettingsMutationError = | { ok: false; error: 'empty-current' | 'empty-next' | 'incorrect' }; type AppLockUnlockResult = | { ok: true } | { ok: false; error: 'empty' | 'incorrect' }; type AppLockSystemUnlockStatus = { supported: boolean; available: boolean; enabled: boolean; platform: 'darwin' | 'win32' | 'unsupported'; label: 'Touch ID' | 'Windows Hello' | null; reason: string | null; }; type AppLockSystemUnlockResult = | { ok: true } | { ok: false; error: 'disabled' | 'not-locked' | 'unsupported' | 'unavailable' | 'cancelled' | 'failed' }; type AppLockSystemUnlockSettingsResult = | AppLockSettings | { ok: false; error: 'empty-current' | 'incorrect' | 'locked' | 'unsupported' | 'unavailable' | 'cancelled' | 'failed' }; declare global { interface NetcattyBridge { setTheme?(theme: 'light' | 'dark' | 'system'): Promise; setBackgroundColor?(color: string): Promise; setWindowOpacity?(opacity: number): Promise; setAppIconVariant?(variant: import('../../domain/appIconVariant').AppIconVariant): Promise; setLanguage?(language: string): Promise; // Window controls for custom title bar (Windows/Linux) windowMinimize?(): Promise; windowMaximize?(): Promise; windowClose?(): Promise; windowIsMaximized?(): Promise; windowIsFullscreen?(): Promise; windowFocus?(): Promise; setTerminalKeyboardFocus?(focused: boolean): void; setWindowTitle?(title: string): Promise; openSessionInNewWindow?(payload: { title: string; sourceSession: import("../../domain/models").TerminalSession; localShellType?: import("../../domain/models").TerminalSession['shellType']; }): Promise<{ success: boolean; error?: string }>; onOpenSessionInNewWindow?(cb: (payload: { title: string; sourceSession: import("../../domain/models").TerminalSession; localShellType?: import("../../domain/models").TerminalSession['shellType']; }) => void): () => void; onWindowCommandCloseRequested?(cb: () => void): () => void; onWindowFullScreenChanged?(cb: (isFullscreen: boolean) => void): () => void; onWindowShown?(cb: () => void): () => void; onWindowFocusRequested?(cb: () => void): () => void; onWindowWillHide?(cb: () => void): () => void; // Settings window openSettingsWindow?(): Promise; closeSettingsWindow?(): Promise; // Cross-window settings sync notifySettingsChanged?(payload: { key: string; value: unknown }): void; onSettingsChanged?(cb: (payload: { key: string; value: unknown }) => void): () => void; getAppLockRuntimeState?(): Promise; getAppLockSettings?(): Promise; setAppLockTimeoutMinutes?(timeoutMinutes: number): Promise; requestAppLockEnable?(): Promise; requestAppLockDisable?(currentPassword: string): Promise; requestAppLockReset?(currentPassword: string): Promise; requestAppLockPasswordChange?(input: { currentPassword?: string; nextPassword: string; }): Promise; setAppLockRuntimeLocked?(reason: Exclude): Promise; requestAppLockUnlock?(password: string): Promise; getAppLockSystemUnlockStatus?(): Promise; setAppLockSystemUnlockEnabled?(input: { enabled: boolean; currentPassword?: string; autoPromptEnabled?: boolean; }): Promise; requestAppLockSystemUnlock?(): Promise; reportAppLockActivity?(): Promise; onAppLockSettingsChanged?(cb: (settings: AppLockSettings) => void): () => void; onAppLockRuntimeStateChanged?(cb: (state: AppLockRuntimeState) => void): () => void; // Cloud sync master password (stored in-memory + persisted via Electron safeStorage) cloudSyncSetSessionPassword?(password: string): Promise; cloudSyncGetSessionPassword?(): Promise; onCloudSyncSessionPasswordAvailable?(callback: () => void): () => void; cloudSyncClearSessionPassword?(): Promise; // Cloud sync network operations (proxied via main process) cloudSyncWebdavInitialize?(config: WebDAVConfig): Promise<{ resourceId: string | null }>; cloudSyncWebdavUpload?( config: WebDAVConfig, syncedFile: SyncedFile ): Promise<{ resourceId: string }>; cloudSyncWebdavDownload?(config: WebDAVConfig): Promise<{ syncedFile: SyncedFile | null }>; cloudSyncWebdavDelete?(config: WebDAVConfig): Promise<{ ok: true }>; cloudSyncS3Initialize?(config: S3Config): Promise<{ resourceId: string | null }>; cloudSyncS3Upload?( config: S3Config, syncedFile: SyncedFile ): Promise<{ resourceId: string }>; cloudSyncS3Download?(config: S3Config): Promise<{ syncedFile: SyncedFile | null }>; cloudSyncS3Delete?(config: S3Config): Promise<{ ok: true }>; // Port Forwarding startPortForward?(options: PortForwardOptions): Promise; stopPortForward?(tunnelId: string): Promise; getPortForwardStatus?(tunnelId: string): Promise; listPortForwards?(): Promise<{ ruleId?: string; tunnelId: string; type: string; status: string; error?: string }[]>; getPortForwardSnapshot?(): Promise; subscribePortForwardRuntime?(): Promise; unsubscribePortForwardRuntime?(): Promise<{ success: boolean }>; subscribePortForward?(tunnelId: string): Promise<{ tunnelId: string; type?: string; status: 'inactive' | 'connecting' | 'active' | 'error'; error?: string; }>; stopAllPortForwards?(): Promise; stopPortForwardByRuleId?(ruleId: string): Promise<{ stopped: number; failed?: number; errors?: string[]; }>; onPortForwardStatus?(tunnelId: string, cb: PortForwardStatusCallback): () => void; onPortForwardRuntime?(cb: PortForwardRuntimeEventCallback): () => void; // Known Hosts readKnownHosts?(): Promise; // Open URL in default browser. Resolves when the URL is handled by // either the system browser or the in-app fallback BrowserWindow. // Rejects only in the rare case where both paths fail. openExternal?(url: string): Promise; openPath?(path: string): Promise<{ success: boolean; error?: string }>; // App info (name/version/platform) for About screens getAppInfo?(): Promise<{ name: string; version: string; platform: string }>; ptyGetChildProcesses?(sessionId: string): Promise>; confirmCloseBusy?(payload: { command: string; title?: string; message?: string; cancelLabel?: string; closeLabel?: string; }): Promise; getVaultBackupCapabilities?(): Promise<{ encryptionAvailable: boolean }>; createVaultBackup?(payload: { payload: import('./domain/sync').SyncPayload; reason: 'app_version_change' | 'before_restore'; sourceAppVersion?: string; targetAppVersion?: string; syncDataVersion?: number; maxCount?: number; }): Promise<{ created: boolean; backup: { id: string; createdAt: number; reason: 'app_version_change' | 'before_restore'; sourceAppVersion?: string; targetAppVersion?: string; fingerprint: string; preview: { hostCount: number; keyCount: number; snippetCount: number; noteCount: number; identityCount: number; portForwardingRuleCount: number; }; } | null; }>; listVaultBackups?(): Promise>; readVaultBackup?(payload: { id: string }): Promise<{ backup: { id: string; createdAt: number; reason: 'app_version_change' | 'before_restore'; sourceAppVersion?: string; targetAppVersion?: string; fingerprint: string; preview: { hostCount: number; keyCount: number; snippetCount: number; noteCount: number; identityCount: number; portForwardingRuleCount: number; }; }; payload: import('./domain/sync').SyncPayload; }>; trimVaultBackups?(payload: { maxCount: number }): Promise<{ deletedCount: number; keptCount: number }>; openVaultBackupDir?(): Promise<{ success: boolean; path: string }>; // Subscribe to main-process-driven "vault backups changed" events. // Returns an unsubscribe callback. Undefined in non-Electron builds. onVaultBackupsChanged?(handler: () => void): () => void; // Notify main process the renderer has mounted/painted (used to avoid initial blank screen). rendererReady?(): void; // Fired when an existing main renderer window is shown again from tray, // global hotkey, dock activation, or second-instance focusing. onAppLockReopen?(listener: () => void): () => void; // Quit guard: subscribe to main-process quit requests that query for dirty editors. // Listener is called with no arguments; return value is an unsubscribe function. onCheckDirtyEditors?(listener: () => void): () => void; // Report the dirty-check result back to the main process. reportDirtyEditorsResult?(hasDirty: boolean): void; onLanguageChanged?(cb: (language: string) => void): () => void; // Chain progress listener for jump host connections // Callback receives: (sessionId: string, currentHop: number, totalHops: number, hostLabel: string, status: string, error?: string) onChainProgress?(cb: (sessionId: string, hop: number, total: number, label: string, status: string, error?: string) => void): () => void; // Fired when a requested SSH connection reuse cannot be honored and the // session falls back to a regular fresh connection. onConnectionReuseFallback?(cb: (sessionId: string, sourceSessionId?: string) => void): () => void; // SFTP connection progress listener (auth method logs) onSftpConnectionProgress?(cb: (sessionId: string, label: string, status: string, detail?: string) => void): () => void; // OAuth callback server for cloud sync. `prepareOAuthCallback` binds the // loopback listener and returns the chosen port (preferred 45678, falls // back to an OS-assigned free port if busy). The caller then builds the // OAuth URL against `redirectUri`, opens the browser, and finally awaits // the code via `awaitOAuthCallback`. prepareOAuthCallback?(): Promise<{ sessionId: string; port: number; redirectUri: string }>; awaitOAuthCallback?(expectedState?: string, sessionId?: string): Promise<{ code: string; state?: string }>; cancelOAuthCallback?(sessionId?: string): Promise; // GitHub Device Flow (cloud sync) githubStartDeviceFlow?(options?: { clientId?: string; scope?: string }): Promise<{ deviceCode: string; userCode: string; verificationUri: string; expiresAt: number; interval: number; }>; githubPollDeviceFlowToken?(options: { clientId?: string; deviceCode: string; pollId?: string }): Promise<{ access_token?: string; token_type?: string; scope?: string; error?: string; error_description?: string; }>; githubCancelDeviceFlowPoll?(pollId: string): Promise; githubDownloadGistRawContent?(options: { accessToken: string; rawUrl: string }): Promise; // Google OAuth (cloud sync) - proxied via main process to avoid CORS googleExchangeCodeForTokens?(options: { clientId: string; clientSecret?: string; code: string; codeVerifier: string; redirectUri: string; }): Promise<{ accessToken: string; refreshToken?: string; expiresAt?: number; tokenType: string; scope?: string; }>; googleRefreshAccessToken?(options: { clientId: string; clientSecret?: string; refreshToken: string; }): Promise<{ accessToken: string; refreshToken: string; expiresAt?: number; tokenType: string; scope?: string; }>; googleGetUserInfo?(options: { accessToken: string }): Promise<{ id: string; email: string; name: string; picture?: string; }>; // Google Drive API (cloud sync) - proxied via main process to avoid CORS/COEP issues googleDriveFindSyncFile?(options: { accessToken: string; fileName?: string }): Promise<{ fileId: string | null }>; googleDriveCreateSyncFile?(options: { accessToken: string; fileName?: string; syncedFile: unknown }): Promise<{ fileId: string }>; googleDriveUpdateSyncFile?(options: { accessToken: string; fileId: string; syncedFile: unknown }): Promise<{ ok: true }>; googleDriveDownloadSyncFile?(options: { accessToken: string; fileId: string }): Promise<{ syncedFile: unknown | null }>; googleDriveDeleteSyncFile?(options: { accessToken: string; fileId: string }): Promise<{ ok: true }>; // OneDrive OAuth + Graph (cloud sync) - proxied via main process to avoid CORS onedriveExchangeCodeForTokens?(options: { clientId: string; code: string; codeVerifier: string; redirectUri: string; scope?: string; }): Promise<{ accessToken: string; refreshToken?: string; expiresAt?: number; tokenType: string; scope?: string; }>; onedriveRefreshAccessToken?(options: { clientId: string; refreshToken: string; scope?: string; }): Promise<{ accessToken: string; refreshToken: string; expiresAt?: number; tokenType: string; scope?: string; }>; onedriveGetUserInfo?(options: { accessToken: string }): Promise<{ id: string; email: string; name: string; avatarDataUrl?: string; }>; onedriveFindSyncFile?(options: { accessToken: string; fileName?: string }): Promise<{ fileId: string | null }>; onedriveUploadSyncFile?(options: { accessToken: string; fileName?: string; syncedFile: unknown }): Promise<{ fileId: string | null }>; onedriveDownloadSyncFile?(options: { accessToken: string; fileId?: string; fileName?: string }): Promise<{ syncedFile: unknown | null }>; onedriveDeleteSyncFile?(options: { accessToken: string; fileId: string }): Promise<{ ok: true }>; } } export {};