UNPKG

webssh2-server

Version:

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

67 lines (66 loc) 2.1 kB
import type { Result } from '../types/result.js'; import type { AuthCredentials } from '../types/contracts/v1/socket.js'; /** * Terminal settings that can be extracted from credentials */ export interface TerminalSettings { term?: string; cols?: number; rows?: number; } /** * Required credential fields */ interface RequiredFields { username: string; host: string; port: number; } /** * SSH Authentication method type */ export type SSHAuthMethod = 'password' | 'privateKey' | 'both' | 'none'; /** * Credential validation error */ export declare class CredentialError extends Error { readonly field?: string | undefined; constructor(message: string, field?: string | undefined); } /** * Validate and extract required credential fields * @param raw - Raw credential data * @returns Result with required fields or error * @pure */ export declare function validateRequiredFields(raw: Record<string, unknown>): Result<RequiredFields, CredentialError>; /** * Extract authentication method from credentials * @param raw - Raw credential data * @returns Authentication method * @pure */ export declare function extractAuthMethod(raw: Record<string, unknown>): SSHAuthMethod; /** * Extract optional terminal settings from credentials * @param raw - Raw credential data * @returns Terminal settings (never null) * @pure */ export declare function extractOptionalTerminalSettings(raw: Record<string, unknown>): TerminalSettings; /** * Extract and validate authentication credentials from raw data * @param raw - Raw credential data * @returns Result with AuthCredentials or error * @pure */ export declare function extractAuthCredentials(raw: Record<string, unknown>): Result<AuthCredentials, CredentialError>; /** * Convert Credentials (all optional) to AuthCredentials format * This is a compatibility function for existing auth providers * @param raw - Raw credential data * @returns AuthCredentials or null if invalid * @pure */ export declare function convertToAuthCredentials(raw: Record<string, unknown>): AuthCredentials | null; export {};