///
import { Readable, Writable } from "stream";
import { ConnectionOptions } from "tls";
import { FileInfo } from "./FileInfo";
import { FTPContext, FTPResponse } from "./FtpContext";
import { ProgressHandler, ProgressTracker } from "./ProgressTracker";
import { UploadCommand } from "./transfer";
export declare type AccessOptionsSecurity = boolean | "implicit";
export interface AccessOptions {
/** Host the client should connect to. Optional, default is "localhost". */
readonly host?: string;
/** Port the client should connect to. Optional, default is 21. */
readonly port?: number;
/** Username to use for login. Optional, default is "anonymous". */
readonly user?: string;
/** Password to use for login. Optional, default is "guest". */
readonly password?: string;
/** Use explicit FTPS over TLS. Optional, default is false. */
readonly secure?: AccessOptionsSecurity;
/** TLS options as in [tls.connect(options)](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback), optional. */
readonly secureOptions?: ConnectionOptions;
}
/** Prepares a data connection for transfer. */
export declare type TransferStrategy = (ftp: FTPContext) => Promise;
/** Parses raw directoy listing data. */
export declare type RawListParser = (rawList: string) => FileInfo[];
export interface UploadOptions {
/** Offset in the local file to start uploading from. */
localStart?: number;
/** Final byte position to include in upload from the local file. */
localEndInclusive?: number;
}
/**
* High-level API to interact with an FTP server.
*/
export declare class Client {
prepareTransfer: TransferStrategy;
parseList: RawListParser;
/**
* Multiple commands to retrieve a directory listing are possible. This instance
* will try all of them in the order presented the first time a directory listing
* is requested. After that, `availableListCommands` will hold only the first
* entry that worked.
*/
availableListCommands: string[];
/** Low-level API to interact with FTP server. */
readonly ftp: FTPContext;
/** Tracks progress of data transfers. */
protected _progressTracker: ProgressTracker;
/**
* Instantiate an FTP client.
*
* @param timeout Timeout in milliseconds, use 0 for no timeout. Optional, default is 30 seconds.
*/
constructor(timeout?: number);
/**
* Close the client and all open socket connections.
*
* Close the client and all open socket connections. The client can’t be used anymore after calling this method,
* you have to either reconnect with `access` or `connect` or instantiate a new instance to continue any work.
* A client is also closed automatically if any timeout or connection error occurs.
*/
close(): void;
/**
* Returns true if the client is closed and can't be used anymore.
*/
get closed(): boolean;
/**
* Connect (or reconnect) to an FTP server.
*
* This is an instance method and thus can be called multiple times during the lifecycle of a `Client`
* instance. Whenever you do, the client is reset with a new control connection. This also implies that
* you can reopen a `Client` instance that has been closed due to an error when reconnecting with this
* method. In fact, reconnecting is the only way to continue using a closed `Client`.
*
* @param host Host the client should connect to. Optional, default is "localhost".
* @param port Port the client should connect to. Optional, default is 21.
*/
connect(host?: string, port?: number, secureOptions?: ConnectionOptions): Promise;
/**
* Send an FTP command and handle the first response.
*/
send(command: string, ignoreErrorCodesDEPRECATED?: boolean): Promise;
/**
* Send an FTP command and ignore an FTP error response. Any other kind of error or timeout will still reject the Promise.
*
* @param command
*/
sendIgnoringError(command: string): Promise;
/**
* Upgrade the current socket connection to TLS.
*
* @param options TLS options as in `tls.connect(options)`, optional.
* @param command Set the authentication command. Optional, default is "AUTH TLS".
*/
useTLS(options?: ConnectionOptions, command?: string): Promise;
/**
* Login a user with a password.
*
* @param user Username to use for login. Optional, default is "anonymous".
* @param password Password to use for login. Optional, default is "guest".
*/
login(user?: string, password?: string): Promise;
/**
* Set the usual default settings.
*
* Settings used:
* * Binary mode (TYPE I)
* * File structure (STRU F)
* * Additional settings for FTPS (PBSZ 0, PROT P)
*/
useDefaultSettings(): Promise;
/**
* Convenience method that calls `connect`, `useTLS`, `login` and `useDefaultSettings`.
*
* This is an instance method and thus can be called multiple times during the lifecycle of a `Client`
* instance. Whenever you do, the client is reset with a new control connection. This also implies that
* you can reopen a `Client` instance that has been closed due to an error when reconnecting with this
* method. In fact, reconnecting is the only way to continue using a closed `Client`.
*/
access(options?: AccessOptions): Promise;
/**
* Get the current working directory.
*/
pwd(): Promise;
/**
* Get a description of supported features.
*
* This sends the FEAT command and parses the result into a Map where keys correspond to available commands
* and values hold further information. Be aware that your FTP servers might not support this
* command in which case this method will not throw an exception but just return an empty Map.
*/
features(): Promise