Files
opsxshell/shared/types/session.types.ts
T

145 lines
3.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Session Types - 统一的会话类型定义
* 在主进程和渲染进程间共享
*/
// 认证方式
export type AuthType = 'password' | 'key' | 'agent'
/** Persisted session protocol. Missing/undefined means SSH (legacy rows). */
export type SessionProtocol = 'ssh' | 'rdp' | 'vnc'
// 代理类型
export type ProxyType = 'none' | 'http' | 'socks5'
// 代理配置
export interface ProxyConfig {
type: ProxyType
host: string
port: number
username?: string
password?: string
}
/** Jump host / bastion credentials (ProxyJump-style) */
export interface JumpHostConfig {
host: string
port?: number
username: string
password?: string
privateKey?: string
passphrase?: string
authType?: AuthType
/** Optional proxy used only when reaching the jump host */
proxy?: ProxyConfig
}
// 会话配置 (用于快速连接)
export interface SSHConnectionConfig {
host: string
port: number
username: string
password?: string
privateKey?: string
passphrase?: string
authType?: AuthType
proxy?: ProxyConfig
/** 连接成功后自动发送到 shell 的命令(可含片段变量) */
startupCommand?: string
/** 单跳板(兼容);多跳请用 jumpHosts */
jumpHost?: JumpHostConfig
/** 有序跳板链:第一跳 → … → 最后一跳 → 目标 */
jumpHosts?: JumpHostConfig[]
/** TCP connect and SSH handshake timeout in seconds. */
timeoutSeconds?: number
/** Enable SSH protocol keepalive for this connection. */
keepAlive?: boolean
/** 单跳板会话 ID(兼容) */
jumpSessionId?: string
/** 有序跳板会话 ID 链(优先于 jumpSessionId) */
jumpSessionIds?: string[]
}
// 持久化会话
export interface Session {
id: string
name: string
host: string
port: number
username: string
authType: AuthType
/** Defaults to ssh when omitted (legacy sessions). */
protocol?: SessionProtocol
password?: string // 加密存储
/** 私钥路径或 PEM 正文;落盘时由 Rust 加密 */
privateKey?: string
passphrase?: string // 私钥密码(加密存储)
proxy?: ProxyConfig // 代理配置
/** 连接成功后自动执行的启动命令 */
startupCommand?: string
/** 单跳板会话 ID(兼容) */
jumpSessionId?: string
/** 有序跳板会话 ID 链 JSON 持久化 */
jumpSessionIds?: string[]
/** 内联单跳板(兼容) */
jumpHost?: JumpHostConfig
/** 内联多跳板链 */
jumpHosts?: JumpHostConfig[]
/** RDP domain (optional). */
domain?: string
/** RDP security mode. */
security?: 'nla' | 'tls' | 'rdp' | 'auto'
/** Desktop resolution hint (RDP/VNC). */
width?: number
height?: number
/**
* Detected or manual remote OS / distro icon id
* (ubuntu, debian, windows, vnc, linux, …).
*/
distro?: string
/** Human-readable OS from PRETTY_NAME (e.g. Ubuntu 24.04.4 LTS). */
osPrettyName?: string
group?: string
tags?: string[]
/** Manual display order within the group; missing rows keep storage order after ordered ones. */
sortOrder?: number
createdAt?: number
updatedAt?: number
}
/** One row of a batch sidebar reorder: position and optional group move. `group: null` moves back to default. */
export interface SessionReorderEntry {
id: string
sortOrder: number
group?: string | null
}
// 会话创建请求
export interface SessionCreateRequest {
name: string
host: string
port: number
username: string
authType: AuthType
protocol?: SessionProtocol
password?: string
privateKey?: string
passphrase?: string
proxy?: ProxyConfig
startupCommand?: string
jumpSessionId?: string
jumpSessionIds?: string[]
jumpHost?: JumpHostConfig
jumpHosts?: JumpHostConfig[]
domain?: string
security?: 'nla' | 'tls' | 'rdp' | 'auto'
width?: number
height?: number
distro?: string
group?: string
tags?: string[]
}
// 会话更新请求
export type SessionUpdateRequest = Partial<Omit<Session, 'id' | 'createdAt' | 'updatedAt'>>