import type { Server } from 'node:net' const EventEmitter = import('events').EventEmitter export class FileSystem { readonly connection: FtpConnection readonly root: string readonly cwd: string constructor( connection: FtpConnection, { root, cwd }?: { root: any cwd: any } ) currentDirectory(): string get(fileName: string): Promise list(path?: string): Promise chdir(path?: string): Promise write( fileName: string, { append, start }?: { append?: boolean start?: any } ): any read( fileName: string, { start }?: { start?: any } ): Promise delete(path: string): Promise mkdir(path: string): Promise rename(from: string, to: string): Promise chmod(path: string, mode: string): Promise getUniqueName(fileName: string): string } export class GeneralError extends Error { /** * @param message The error message. * @param code Default value is `400`. */ constructor(message: string, code?: number) } export class SocketError extends Error { /** * @param message The error message. * @param code Default value is `500`. */ constructor(message: string, code?: number) } export class FileSystemError extends Error { /** * @param message The error message. * @param code Default value is `400`. */ constructor(message: string, code?: number) } export class ConnectorError extends Error { /** * @param message The error message. * @param code Default value is `400`. */ constructor(message: string, code?: number) } export class FtpConnection extends EventEmitter { server: FtpServer id: string log: any transferType: string encoding: string bufferSize: boolean readonly ip: string restByteCount: number | undefined secure: boolean close(code: number, message: number): Promise login(username: string, password: string): Promise reply(options: number | Object, ...letters: Array): Promise } export interface FtpServerOptions { url?: string pasv_min?: number pasv_max?: number pasv_url?: string random_pasv_port?: boolean greeting?: string | string[] tls?: import('tls').SecureContextOptions | false anonymous?: boolean blacklist?: Array whitelist?: Array file_format?: ((stat: import('fs').Stats) => string) | 'ls' | 'ep' log?: any timeout?: number } export class FtpServer extends EventEmitter { server: Server constructor(options?: FtpServerOptions) readonly isTLS: boolean listen(): any emitPromise(action: any, ...data: any[]): Promise // emit is exported from super class setupTLS(_tls: boolean): | boolean | { cert: string key: string ca: string } setupGreeting(greet: string): string[] setupFeaturesMessage(): string disconnectClient(id: string): Promise close(): any on( event: 'login', listener: ( data: { connection: FtpConnection username: string password: string }, resolve: (config: { fs?: FileSystem root?: string cwd?: string blacklist?: Array whitelist?: Array }) => void, reject: (err?: Error) => void ) => void ): this on(event: 'disconnect', listener: (data: { connection: FtpConnection; id: string }) => void): this on( event: 'client-error', listener: (data: { connection: FtpConnection; context: string; error: Error }) => void ): this } export { FtpServer as FtpSrv } export default FtpServer