UNPKG

webssh2-server

Version:

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

71 lines (70 loc) 2.07 kB
import type { Config } from '../types/config.js'; import type { Result } from '../types/result.js'; /** * SSH Credentials structure */ export interface SshCredentials { username: string; password?: string; privateKey?: string; passphrase?: string; } /** * Authentication result with credentials and metadata */ export interface AuthResult { credentials: SshCredentials; usedBasicAuth: boolean; source: 'config' | 'basicAuth'; } /** * Basic auth credentials from request */ export interface BasicAuthCredentials { name?: string; pass?: string; } /** * Check if config has valid user credentials * Pure function - no side effects * * @param config - Application configuration * @returns True if config contains valid credentials */ export declare function hasConfigCredentials(config: Config): boolean; /** * Extract credentials from configuration * Pure function - no side effects * * @param config - Application configuration * @returns SSH credentials from config or null */ export declare function extractConfigCredentials(config: Config): SshCredentials | null; /** * Process basic auth credentials * Pure function - no side effects * * @param credentials - Basic auth credentials * @returns Processed SSH credentials */ export declare function processBasicAuthCredentials(credentials: BasicAuthCredentials): SshCredentials; /** * Process authentication from config or basic auth * Pure function - returns Result type * * @param config - Application configuration * @param basicAuth - Optional basic auth credentials * @returns Result with auth credentials or error */ export declare function processAuthentication(config: Config, basicAuth?: BasicAuthCredentials | null): Result<AuthResult, { code: number; message: string; }>; /** * Create session data from authentication result * Pure function - no side effects * * @param authResult - Authentication result * @returns Session data object */ export declare function createSessionData(authResult: AuthResult): Record<string, unknown>;