UNPKG

webssh2-server

Version:

A Websocket to SSH2 gateway using xterm.js, socket.io, ssh2

162 lines (161 loc) 3.6 kB
/** * Redux-style action definitions for state management */ import type { ConnectionId, UserId } from '../types/branded.js'; /** * Authentication actions */ export type AuthAction = { type: 'AUTH_REQUEST'; payload: { method: string; username?: string; }; } | { type: 'AUTH_SUCCESS'; payload: { username: string; method: string; userId?: UserId; }; } | { type: 'AUTH_FAILURE'; payload: { error: string; method: string; }; } | { type: 'AUTH_LOGOUT'; } | { type: 'AUTH_CLEAR_ERROR'; }; /** * Connection actions */ export type ConnectionAction = { type: 'CONNECTION_START'; payload: { host: string; port: number; }; } | { type: 'CONNECTION_ESTABLISHED'; payload: { connectionId: ConnectionId; }; } | { type: 'CONNECTION_ERROR'; payload: { error: string; }; } | { type: 'CONNECTION_CLOSED'; payload: { reason?: string; }; } | { type: 'CONNECTION_ACTIVITY'; }; /** * Terminal actions */ export type TerminalAction = { type: 'TERMINAL_INIT'; payload: { term: string; rows: number; cols: number; environment: Record<string, string>; cwd: string | null; }; } | { type: 'TERMINAL_RESIZE'; payload: { rows: number; cols: number; }; } | { type: 'TERMINAL_SET_TERM'; payload: { term: string; }; } | { type: 'TERMINAL_SET_ENV'; payload: { environment: Record<string, string>; }; } | { type: 'TERMINAL_UPDATE_ENV'; payload: { environment: Record<string, string>; }; } | { type: 'TERMINAL_SET_CWD'; payload: { cwd: string; }; } | { type: 'TERMINAL_DESTROY'; payload: {}; }; /** * Metadata actions */ export type MetadataAction = { type: 'METADATA_SET_CLIENT'; payload: { clientIp: string; userAgent: string; }; } | { type: 'METADATA_UPDATE'; payload: { userId?: UserId | null; clientIp?: string | null; userAgent?: string | null; updatedAt?: number; }; } | { type: 'METADATA_UPDATE_TIMESTAMP'; }; /** * Combined action type */ export type SessionAction = AuthAction | ConnectionAction | TerminalAction | MetadataAction | { type: 'SESSION_RESET'; } | { type: 'SESSION_END'; }; /** * Action creator helpers */ export declare const actions: { auth: { request: (method: string, username?: string) => AuthAction; success: (username: string, method: string, userId?: UserId) => AuthAction; failure: (error: string, method: string) => AuthAction; logout: () => AuthAction; clearError: () => AuthAction; }; connection: { start: (host: string, port: number) => ConnectionAction; established: (connectionId: ConnectionId) => ConnectionAction; error: (error: string) => ConnectionAction; closed: (reason?: string) => ConnectionAction; activity: () => ConnectionAction; }; terminal: { resize: (rows: number, cols: number) => TerminalAction; setTerm: (term: string) => TerminalAction; setEnv: (environment: Record<string, string>) => TerminalAction; setCwd: (cwd: string) => TerminalAction; }; metadata: { setClient: (clientIp: string, userAgent: string) => MetadataAction; updateTimestamp: () => MetadataAction; }; session: { reset: () => SessionAction; end: () => SessionAction; }; };