|
1 |
| -import * as tls from 'tls' |
2 |
| -import { Stats } from 'fs' |
3 |
| -import { EventEmitter } from 'events'; |
| 1 | +import * as tls from "tls"; |
| 2 | +import { Stats } from "fs"; |
| 3 | +import { EventEmitter } from "events"; |
4 | 4 |
|
5 | 5 | export class FileSystem {
|
6 |
| - |
7 |
| - readonly connection: FtpConnection; |
8 |
| - readonly root: string; |
9 |
| - readonly cwd: string; |
10 |
| - |
11 |
| - constructor(connection: FtpConnection, {root, cwd}?: { |
12 |
| - root: any; |
13 |
| - cwd: any; |
14 |
| - }); |
15 |
| - |
16 |
| - currentDirectory(): string; |
17 |
| - |
18 |
| - get(fileName: string): Promise<any>; |
19 |
| - |
20 |
| - list(path?: string): Promise<any>; |
21 |
| - |
22 |
| - chdir(path?: string): Promise<string>; |
23 |
| - |
24 |
| - write(fileName: string, {append, start}?: { |
25 |
| - append?: boolean; |
26 |
| - start?: any; |
27 |
| - }): any; |
28 |
| - |
29 |
| - read(fileName: string, {start}?: { |
30 |
| - start?: any; |
31 |
| - }): Promise<any>; |
32 |
| - |
33 |
| - delete(path: string): Promise<any>; |
34 |
| - |
35 |
| - mkdir(path: string): Promise<any>; |
36 |
| - |
37 |
| - rename(from: string, to: string): Promise<any>; |
38 |
| - |
39 |
| - chmod(path: string, mode: string): Promise<any>; |
40 |
| - |
41 |
| - getUniqueName(fileName: string): string; |
| 6 | + readonly connection: FtpConnection; |
| 7 | + readonly root: string; |
| 8 | + readonly cwd: string; |
| 9 | + |
| 10 | + constructor( |
| 11 | + connection: FtpConnection, |
| 12 | + { |
| 13 | + root, |
| 14 | + cwd, |
| 15 | + }?: { |
| 16 | + root: any; |
| 17 | + cwd: any; |
| 18 | + } |
| 19 | + ); |
| 20 | + |
| 21 | + currentDirectory(): string; |
| 22 | + |
| 23 | + get(fileName: string): Promise<any>; |
| 24 | + |
| 25 | + list(path?: string): Promise<any>; |
| 26 | + |
| 27 | + chdir(path?: string): Promise<string>; |
| 28 | + |
| 29 | + write( |
| 30 | + fileName: string, |
| 31 | + { |
| 32 | + append, |
| 33 | + start, |
| 34 | + }?: { |
| 35 | + append?: boolean; |
| 36 | + start?: any; |
| 37 | + } |
| 38 | + ): any; |
| 39 | + |
| 40 | + read( |
| 41 | + fileName: string, |
| 42 | + { |
| 43 | + start, |
| 44 | + }?: { |
| 45 | + start?: any; |
| 46 | + } |
| 47 | + ): Promise<any>; |
| 48 | + |
| 49 | + delete(path: string): Promise<any>; |
| 50 | + |
| 51 | + mkdir(path: string): Promise<any>; |
| 52 | + |
| 53 | + rename(from: string, to: string): Promise<any>; |
| 54 | + |
| 55 | + chmod(path: string, mode: string): Promise<any>; |
| 56 | + |
| 57 | + getUniqueName(fileName: string): string; |
42 | 58 | }
|
43 | 59 |
|
44 | 60 | export class GeneralError extends Error {
|
@@ -74,93 +90,96 @@ export class ConnectorError extends Error {
|
74 | 90 | }
|
75 | 91 |
|
76 | 92 | export class FtpConnection extends EventEmitter {
|
77 |
| - server: FtpServer; |
78 |
| - id: string; |
79 |
| - log: any; |
80 |
| - transferType: string; |
81 |
| - encoding: string; |
82 |
| - bufferSize: boolean; |
83 |
| - readonly ip: string; |
84 |
| - restByteCount: number | undefined; |
85 |
| - secure: boolean |
86 |
| - |
87 |
| - close (code: number, message: number): Promise<any> |
88 |
| - login (username: string, password: string): Promise<any> |
89 |
| - reply (options: number | Object, ...letters: Array<any>): Promise<any> |
90 |
| - |
| 93 | + server: FtpServer; |
| 94 | + id: string; |
| 95 | + log: any; |
| 96 | + transferType: string; |
| 97 | + encoding: string; |
| 98 | + bufferSize: boolean; |
| 99 | + readonly ip: string; |
| 100 | + restByteCount: number | undefined; |
| 101 | + secure: boolean; |
| 102 | + |
| 103 | + close(code: number, message: number): Promise<any>; |
| 104 | + login(username: string, password: string): Promise<any>; |
| 105 | + reply(options: number | Object, ...letters: Array<any>): Promise<any>; |
91 | 106 | }
|
92 | 107 |
|
93 | 108 | export interface FtpServerOptions {
|
94 |
| - url?: string, |
95 |
| - pasv_min?: number, |
96 |
| - pasv_max?: number, |
97 |
| - pasv_url?: string, |
98 |
| - greeting?: string | string[], |
99 |
| - tls?: tls.SecureContextOptions | false, |
100 |
| - anonymous?: boolean, |
101 |
| - blacklist?: Array<string>, |
102 |
| - whitelist?: Array<string>, |
103 |
| - file_format?: (stat: Stats) => string | Promise<string> | "ls" | "ep", |
104 |
| - log?: any, |
105 |
| - timeout?: number |
| 109 | + url?: string; |
| 110 | + pasv_min?: number; |
| 111 | + pasv_max?: number; |
| 112 | + pasv_url?: string; |
| 113 | + greeting?: string | string[]; |
| 114 | + tls?: tls.SecureContextOptions | false; |
| 115 | + anonymous?: boolean; |
| 116 | + blacklist?: Array<string>; |
| 117 | + whitelist?: Array<string>; |
| 118 | + file_format?: (stat: Stats) => string | Promise<string> | "ls" | "ep"; |
| 119 | + log?: any; |
| 120 | + timeout?: number; |
106 | 121 | }
|
107 | 122 |
|
108 | 123 | export class FtpServer extends EventEmitter {
|
109 |
| - constructor(options?: FtpServerOptions); |
110 |
| - |
111 |
| - readonly isTLS: boolean; |
112 |
| - |
113 |
| - listen(): any; |
114 |
| - |
115 |
| - emitPromise(action: any, ...data: any[]): Promise<any>; |
116 |
| - |
117 |
| - // emit is exported from super class |
118 |
| - |
119 |
| - setupTLS(_tls: boolean): boolean | { |
120 |
| - cert: string; |
121 |
| - key: string; |
122 |
| - ca: string |
123 |
| - }; |
124 |
| - |
125 |
| - setupGreeting(greet: string): string[]; |
126 |
| - |
127 |
| - setupFeaturesMessage(): string; |
128 |
| - |
129 |
| - disconnectClient(id: string): Promise<any>; |
130 |
| - |
131 |
| - close(): any; |
132 |
| - |
133 |
| - on(event: "login", listener: ( |
134 |
| - data: { |
135 |
| - connection: FtpConnection, |
136 |
| - username: string, |
137 |
| - password: string |
138 |
| - }, |
139 |
| - resolve: (config: { |
140 |
| - fs?: FileSystem, |
141 |
| - root?: string, |
142 |
| - cwd?: string, |
143 |
| - blacklist?: Array<string>, |
144 |
| - whitelist?: Array<string> |
145 |
| - }) => void, |
146 |
| - reject: (err?: Error) => void |
147 |
| - ) => void): this; |
148 |
| - |
149 |
| - on(event: "disconnect", listener: ( |
150 |
| - data: { |
151 |
| - connection: FtpConnection, |
152 |
| - id: string |
153 |
| - } |
154 |
| - ) => void): this; |
155 |
| - |
156 |
| - on(event: "client-error", listener: ( |
157 |
| - data: { |
158 |
| - connection: FtpConnection, |
159 |
| - context: string, |
160 |
| - error: Error, |
161 |
| - } |
162 |
| - ) => void): this; |
| 124 | + constructor(options?: FtpServerOptions); |
| 125 | + |
| 126 | + readonly isTLS: boolean; |
| 127 | + |
| 128 | + listen(): any; |
| 129 | + |
| 130 | + emitPromise(action: any, ...data: any[]): Promise<any>; |
| 131 | + |
| 132 | + // emit is exported from super class |
| 133 | + |
| 134 | + setupTLS(_tls: boolean): |
| 135 | + | boolean |
| 136 | + | { |
| 137 | + cert: string; |
| 138 | + key: string; |
| 139 | + ca: string; |
| 140 | + }; |
| 141 | + |
| 142 | + setupGreeting(greet: string): string[]; |
| 143 | + |
| 144 | + setupFeaturesMessage(): string; |
| 145 | + |
| 146 | + disconnectClient(id: string): Promise<any>; |
| 147 | + |
| 148 | + close(): any; |
| 149 | + |
| 150 | + on( |
| 151 | + event: "login", |
| 152 | + listener: ( |
| 153 | + data: { |
| 154 | + connection: FtpConnection; |
| 155 | + username: string; |
| 156 | + password: string; |
| 157 | + }, |
| 158 | + resolve: (config: { |
| 159 | + fs?: FileSystem; |
| 160 | + root?: string; |
| 161 | + cwd?: string; |
| 162 | + blacklist?: Array<string>; |
| 163 | + whitelist?: Array<string>; |
| 164 | + }) => void, |
| 165 | + reject: (err?: Error) => void |
| 166 | + ) => void |
| 167 | + ): this; |
| 168 | + |
| 169 | + on( |
| 170 | + event: "disconnect", |
| 171 | + listener: (data: { connection: FtpConnection; id: string }) => void |
| 172 | + ): this; |
| 173 | + |
| 174 | + on( |
| 175 | + event: "client-error", |
| 176 | + listener: (data: { |
| 177 | + connection: FtpConnection; |
| 178 | + context: string; |
| 179 | + error: Error; |
| 180 | + }) => void |
| 181 | + ): this; |
163 | 182 | }
|
164 | 183 |
|
165 |
| -export {FtpServer as FtpSrv}; |
| 184 | +export { FtpServer as FtpSrv }; |
166 | 185 | export default FtpServer;
|
0 commit comments