webssh2-server
Version:
A Websocket to SSH2 gateway using xterm.js, socket.io, ssh2
68 lines (67 loc) • 1.99 kB
TypeScript
import { EventEmitter } from 'events';
import type { Result } from '../types/result.js';
import { type ConnectionConfig, type ConnectionState, type ShellOptions, type ExecOptions } from './connection-factory.js';
export interface Stream extends EventEmitter {
setWindow?: (rows: number, cols: number, height?: number, width?: number) => void;
write?: (data: string | Buffer) => boolean;
end?: () => void;
stderr?: EventEmitter;
signal?: (signal: string) => boolean;
close?: () => void;
}
/**
* SSH Connection Adapter
* Handles all I/O operations for SSH connections
*/
export declare class SSHConnectionAdapter extends EventEmitter {
private client;
private state;
private stream;
private config;
constructor(id?: string);
/**
* Connect to SSH server
* I/O operation - returns Promise with Result
*/
connect(config: ConnectionConfig): Promise<Result<ConnectionState>>;
/**
* Create shell session
* I/O operation - returns Promise with Result
*/
shell(options: ShellOptions): Promise<Result<Stream>>;
/**
* Execute command
* I/O operation - returns Promise with Result
*/
exec(options: ExecOptions): Promise<Result<Stream>>;
/**
* Resize terminal window
* I/O operation - synchronous
*/
resizeTerminal(rows: number, cols: number, height?: number, width?: number): void;
/**
* Write data to stream
* I/O operation - synchronous
*/
write(data: string | Buffer): boolean;
/**
* End the connection
* I/O operation - synchronous
*/
disconnect(): void;
/**
* Get current connection state
* Pure operation - no side effects
*/
getState(): ConnectionState;
/**
* Check if connected
* Pure operation - no side effects
*/
isConnected(): boolean;
/**
* Get stream if available
* Pure operation - returns reference
*/
getStream(): Stream | null;
}