Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixes "url" argument must be of type string with nodejs 20 #378

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: indent ftp-srv.d.ts with 2 space
lygstate committed Aug 24, 2024
commit 8fd7136fadd6e502fe4ae0ef9fe6475f1f6d7aad
259 changes: 139 additions & 120 deletions ftp-srv.d.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,60 @@
import * as tls from 'tls'
import { Stats } from 'fs'
import { EventEmitter } from 'events';
import * as tls from "tls";
import { Stats } from "fs";
import { EventEmitter } from "events";

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<any>;

list(path?: string): Promise<any>;

chdir(path?: string): Promise<string>;

write(fileName: string, {append, start}?: {
append?: boolean;
start?: any;
}): any;

read(fileName: string, {start}?: {
start?: any;
}): Promise<any>;

delete(path: string): Promise<any>;

mkdir(path: string): Promise<any>;

rename(from: string, to: string): Promise<any>;

chmod(path: string, mode: string): Promise<any>;

getUniqueName(fileName: string): string;
readonly connection: FtpConnection;
readonly root: string;
readonly cwd: string;

constructor(
connection: FtpConnection,
{
root,
cwd,
}?: {
root: any;
cwd: any;
}
);

currentDirectory(): string;

get(fileName: string): Promise<any>;

list(path?: string): Promise<any>;

chdir(path?: string): Promise<string>;

write(
fileName: string,
{
append,
start,
}?: {
append?: boolean;
start?: any;
}
): any;

read(
fileName: string,
{
start,
}?: {
start?: any;
}
): Promise<any>;

delete(path: string): Promise<any>;

mkdir(path: string): Promise<any>;

rename(from: string, to: string): Promise<any>;

chmod(path: string, mode: string): Promise<any>;

getUniqueName(fileName: string): string;
}

export class GeneralError extends Error {
@@ -74,93 +90,96 @@ export class ConnectorError extends Error {
}

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<any>
login (username: string, password: string): Promise<any>
reply (options: number | Object, ...letters: Array<any>): Promise<any>

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<any>;
login(username: string, password: string): Promise<any>;
reply(options: number | Object, ...letters: Array<any>): Promise<any>;
}

export interface FtpServerOptions {
url?: string,
pasv_min?: number,
pasv_max?: number,
pasv_url?: string,
greeting?: string | string[],
tls?: tls.SecureContextOptions | false,
anonymous?: boolean,
blacklist?: Array<string>,
whitelist?: Array<string>,
file_format?: (stat: Stats) => string | Promise<string> | "ls" | "ep",
log?: any,
timeout?: number
url?: string;
pasv_min?: number;
pasv_max?: number;
pasv_url?: string;
greeting?: string | string[];
tls?: tls.SecureContextOptions | false;
anonymous?: boolean;
blacklist?: Array<string>;
whitelist?: Array<string>;
file_format?: (stat: Stats) => string | Promise<string> | "ls" | "ep";
log?: any;
timeout?: number;
}

export class FtpServer extends EventEmitter {
constructor(options?: FtpServerOptions);

readonly isTLS: boolean;

listen(): any;

emitPromise(action: any, ...data: any[]): Promise<any>;

// 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<any>;

close(): any;

on(event: "login", listener: (
data: {
connection: FtpConnection,
username: string,
password: string
},
resolve: (config: {
fs?: FileSystem,
root?: string,
cwd?: string,
blacklist?: Array<string>,
whitelist?: Array<string>
}) => 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;
constructor(options?: FtpServerOptions);

readonly isTLS: boolean;

listen(): any;

emitPromise(action: any, ...data: any[]): Promise<any>;

// 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<any>;

close(): any;

on(
event: "login",
listener: (
data: {
connection: FtpConnection;
username: string;
password: string;
},
resolve: (config: {
fs?: FileSystem;
root?: string;
cwd?: string;
blacklist?: Array<string>;
whitelist?: Array<string>;
}) => 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 { FtpServer as FtpSrv };
export default FtpServer;