3xui-api-client 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/index.d.ts +437 -416
- package/index.js +715 -655
- package/package.json +113 -113
- package/src/builders/ProtocolBuilders.js +5 -1
- package/src/security/SecurityEnhancer.js +325 -1
package/index.d.ts
CHANGED
|
@@ -1,416 +1,437 @@
|
|
|
1
|
-
// Type definitions for 3xui-api-client v2.0.0
|
|
2
|
-
|
|
3
|
-
declare module '3xui-api-client' {
|
|
4
|
-
import { AxiosInstance } from 'axios';
|
|
5
|
-
|
|
6
|
-
// ===========================================
|
|
7
|
-
// CORE INTERFACES
|
|
8
|
-
// ===========================================
|
|
9
|
-
|
|
10
|
-
export interface ThreeXUIOptions {
|
|
11
|
-
sessionManager?: SessionManager | SessionConfig;
|
|
12
|
-
autoGenerateCredentials?: boolean;
|
|
13
|
-
timeout?: number;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export interface
|
|
210
|
-
path?: string;
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export interface
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
static
|
|
284
|
-
static
|
|
285
|
-
static
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
static
|
|
294
|
-
static
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
export
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
export function
|
|
342
|
-
export function
|
|
343
|
-
|
|
344
|
-
export
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
1
|
+
// Type definitions for 3xui-api-client v2.0.0
|
|
2
|
+
|
|
3
|
+
declare module '3xui-api-client' {
|
|
4
|
+
import { AxiosInstance } from 'axios';
|
|
5
|
+
|
|
6
|
+
// ===========================================
|
|
7
|
+
// CORE INTERFACES
|
|
8
|
+
// ===========================================
|
|
9
|
+
|
|
10
|
+
export interface ThreeXUIOptions {
|
|
11
|
+
sessionManager?: SessionManager | SessionConfig;
|
|
12
|
+
autoGenerateCredentials?: boolean;
|
|
13
|
+
timeout?: number;
|
|
14
|
+
maxRequestsPerMinute?: number;
|
|
15
|
+
maxLoginAttemptsPerHour?: number;
|
|
16
|
+
isDevelopment?: boolean;
|
|
17
|
+
enableCSP?: boolean;
|
|
18
|
+
userAgent?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface LoginResponse {
|
|
22
|
+
success: boolean;
|
|
23
|
+
fromCache?: boolean;
|
|
24
|
+
headers?: any;
|
|
25
|
+
data: any;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface InboundConfig {
|
|
29
|
+
remark: string;
|
|
30
|
+
port: number;
|
|
31
|
+
protocol: string;
|
|
32
|
+
settings: any;
|
|
33
|
+
streamSettings?: any;
|
|
34
|
+
listen?: string;
|
|
35
|
+
enable?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ClientConfig {
|
|
39
|
+
id: number;
|
|
40
|
+
settings: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// ===========================================
|
|
44
|
+
// CREDENTIAL GENERATION INTERFACES
|
|
45
|
+
// ===========================================
|
|
46
|
+
|
|
47
|
+
export interface CredentialOptions {
|
|
48
|
+
email?: string;
|
|
49
|
+
passwordLength?: number;
|
|
50
|
+
level?: number;
|
|
51
|
+
alterId?: number;
|
|
52
|
+
flow?: string;
|
|
53
|
+
method?: string;
|
|
54
|
+
username?: string;
|
|
55
|
+
limitIp?: number;
|
|
56
|
+
totalGB?: number;
|
|
57
|
+
expiryTime?: number;
|
|
58
|
+
enable?: boolean;
|
|
59
|
+
subId?: string;
|
|
60
|
+
allowedIPs?: string[];
|
|
61
|
+
keepAlive?: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface VLESSCredentials {
|
|
65
|
+
id: string;
|
|
66
|
+
email: string;
|
|
67
|
+
flow: string;
|
|
68
|
+
encryption: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface VMESSCredentials {
|
|
72
|
+
id: string;
|
|
73
|
+
email: string;
|
|
74
|
+
level: number;
|
|
75
|
+
alterId: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface TrojanCredentials {
|
|
79
|
+
password: string;
|
|
80
|
+
email: string;
|
|
81
|
+
level: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface ShadowsocksCredentials {
|
|
85
|
+
method: string;
|
|
86
|
+
password: string;
|
|
87
|
+
email: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface WireGuardCredentials {
|
|
91
|
+
privateKey: string;
|
|
92
|
+
publicKey: string;
|
|
93
|
+
allowedIPs: string[];
|
|
94
|
+
keepAlive: number;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface SocksCredentials {
|
|
98
|
+
user: string;
|
|
99
|
+
pass: string;
|
|
100
|
+
email: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface ValidationResult {
|
|
104
|
+
valid: boolean;
|
|
105
|
+
errors: string[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface WireGuardKeys {
|
|
109
|
+
privateKey: string;
|
|
110
|
+
publicKey: string;
|
|
111
|
+
generateClientConfig: (allowedIPs?: string[]) => any;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface RealityKeys {
|
|
115
|
+
privateKey: string;
|
|
116
|
+
publicKey: string;
|
|
117
|
+
generateRealityConfig: (dest?: string, serverNames?: string[]) => any;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// ===========================================
|
|
121
|
+
// SESSION MANAGEMENT INTERFACES
|
|
122
|
+
// ===========================================
|
|
123
|
+
|
|
124
|
+
export interface SessionConfig {
|
|
125
|
+
sessionTTL?: number;
|
|
126
|
+
autoRefresh?: boolean;
|
|
127
|
+
refreshThreshold?: number;
|
|
128
|
+
store?: SessionStore;
|
|
129
|
+
redis?: any;
|
|
130
|
+
redisOptions?: any;
|
|
131
|
+
database?: any;
|
|
132
|
+
databaseOptions?: any;
|
|
133
|
+
customHandler?: any;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface SessionStore {
|
|
137
|
+
get(key: string): Promise<any>;
|
|
138
|
+
set(key: string, value: any, ttl?: number): Promise<void>;
|
|
139
|
+
delete(key: string): Promise<void>;
|
|
140
|
+
clear(): Promise<void>;
|
|
141
|
+
exists(key: string): Promise<boolean>;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface SessionManager {
|
|
145
|
+
generateSessionKey(baseURL: string, username: string): string;
|
|
146
|
+
storeSession(baseURL: string, username: string, sessionData: any): Promise<string>;
|
|
147
|
+
getSession(baseURL: string, username: string): Promise<any>;
|
|
148
|
+
hasValidSession(baseURL: string, username: string): Promise<boolean>;
|
|
149
|
+
shouldRefreshSession(session: any): boolean;
|
|
150
|
+
deleteSession(baseURL: string, username: string): Promise<void>;
|
|
151
|
+
clearAllSessions(): Promise<void>;
|
|
152
|
+
getStats(): Promise<any>;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// ===========================================
|
|
156
|
+
// WEB MIDDLEWARE INTERFACES
|
|
157
|
+
// ===========================================
|
|
158
|
+
|
|
159
|
+
export interface ExpressMiddlewareConfig {
|
|
160
|
+
baseURL: string;
|
|
161
|
+
username: string;
|
|
162
|
+
password: string;
|
|
163
|
+
sessionManager?: SessionManager;
|
|
164
|
+
sessionKey?: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface NextJSConfig {
|
|
168
|
+
baseURL: string;
|
|
169
|
+
username: string;
|
|
170
|
+
password: string;
|
|
171
|
+
sessionManager?: SessionManager;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface ReactHookMethods {
|
|
175
|
+
generateCredentials(protocol: string, options?: CredentialOptions): Promise<any>;
|
|
176
|
+
addClientWithCredentials(inboundId: number, protocol: string, options?: CredentialOptions): Promise<any>;
|
|
177
|
+
getInbounds(): Promise<any[]>;
|
|
178
|
+
getClientTraffic(email: string): Promise<any>;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// ===========================================
|
|
182
|
+
// PROTOCOL BUILDER INTERFACES
|
|
183
|
+
// ===========================================
|
|
184
|
+
|
|
185
|
+
export interface BuilderConfig {
|
|
186
|
+
protocol: string;
|
|
187
|
+
settings: any;
|
|
188
|
+
streamSettings?: any;
|
|
189
|
+
remark?: string;
|
|
190
|
+
port?: number;
|
|
191
|
+
listen?: string;
|
|
192
|
+
enable?: boolean;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface TLSOptions {
|
|
196
|
+
serverName?: string;
|
|
197
|
+
certificates?: any[];
|
|
198
|
+
certFile?: string;
|
|
199
|
+
keyFile?: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface RealityOptions {
|
|
203
|
+
keys?: RealityKeys;
|
|
204
|
+
dest?: string;
|
|
205
|
+
serverNames?: string[];
|
|
206
|
+
shortIds?: string[];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface WebSocketOptions {
|
|
210
|
+
path?: string;
|
|
211
|
+
headers?: Record<string, string>;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface HTTP2Options {
|
|
215
|
+
path?: string;
|
|
216
|
+
host?: string[];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface GRPCOptions {
|
|
220
|
+
serviceName?: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// ===========================================
|
|
224
|
+
// MAIN CLASS
|
|
225
|
+
// ===========================================
|
|
226
|
+
|
|
227
|
+
export default class ThreeXUI {
|
|
228
|
+
constructor(baseURL: string, username: string, password: string, options?: ThreeXUIOptions);
|
|
229
|
+
|
|
230
|
+
// Authentication
|
|
231
|
+
login(forceRefresh?: boolean): Promise<LoginResponse>;
|
|
232
|
+
logout(): Promise<void>;
|
|
233
|
+
|
|
234
|
+
// Credential Generation Methods
|
|
235
|
+
generateCredentials(protocol: string, options?: CredentialOptions): VLESSCredentials | VMESSCredentials | TrojanCredentials | ShadowsocksCredentials | WireGuardCredentials | SocksCredentials;
|
|
236
|
+
generateUUID(secure?: boolean): string;
|
|
237
|
+
generatePassword(length?: number, options?: any): string;
|
|
238
|
+
generateBulkCredentials(protocol: string, count: number, options?: CredentialOptions): any[];
|
|
239
|
+
getShadowsocksCiphers(): string[];
|
|
240
|
+
getRecommendedShadowsocksCipher(): string;
|
|
241
|
+
generateWireGuardKeys(): WireGuardKeys;
|
|
242
|
+
generateRealityKeys(): RealityKeys;
|
|
243
|
+
generatePort(min?: number, max?: number): number;
|
|
244
|
+
validateCredentials(credentials: any, protocol: string): ValidationResult;
|
|
245
|
+
|
|
246
|
+
// Security helpers
|
|
247
|
+
getSecurityStats(): any;
|
|
248
|
+
clearBlockedIPs(): void;
|
|
249
|
+
validateCredentialStrength(credential: string, type: 'password' | 'uuid' | 'port'): { isValid: boolean; issues: string[]; strength: 'weak' | 'medium' | 'strong' };
|
|
250
|
+
generateSecureToken(): string;
|
|
251
|
+
setDevelopmentMode(enabled: boolean): void;
|
|
252
|
+
|
|
253
|
+
// Enhanced Client Management
|
|
254
|
+
addClientWithCredentials(inboundId: number, protocol: string, options?: CredentialOptions): Promise<any>;
|
|
255
|
+
updateClientWithCredentials(clientId: string, inboundId: number, options?: CredentialOptions): Promise<any>;
|
|
256
|
+
|
|
257
|
+
// Session Management
|
|
258
|
+
getSessionStats(): Promise<any>;
|
|
259
|
+
clearAllSessions(): Promise<void>;
|
|
260
|
+
isSessionValid(): Promise<boolean>;
|
|
261
|
+
|
|
262
|
+
// Original API Methods
|
|
263
|
+
getInbounds(): Promise<any>;
|
|
264
|
+
getInbound(id: number): Promise<any>;
|
|
265
|
+
addInbound(inboundConfig: InboundConfig): Promise<any>;
|
|
266
|
+
deleteInbound(id: number): Promise<any>;
|
|
267
|
+
updateInbound(id: number, inboundConfig: InboundConfig): Promise<any>;
|
|
268
|
+
addClient(clientConfig: ClientConfig): Promise<any>;
|
|
269
|
+
deleteClient(inboundId: number, clientId: string): Promise<any>;
|
|
270
|
+
updateClient(clientId: string, clientConfig: ClientConfig): Promise<any>;
|
|
271
|
+
getClientTrafficsByEmail(email: string): Promise<any>;
|
|
272
|
+
getClientTrafficsById(id: number): Promise<any>;
|
|
273
|
+
getClientIps(email: string): Promise<any>;
|
|
274
|
+
clearClientIps(email: string): Promise<any>;
|
|
275
|
+
resetClientTraffic(inboundId: number, email: string): Promise<any>;
|
|
276
|
+
resetAllTraffics(): Promise<any>;
|
|
277
|
+
resetAllClientTraffics(inboundId: number): Promise<any>;
|
|
278
|
+
deleteDepletedClients(inboundId: number): Promise<any>;
|
|
279
|
+
getOnlineClients(): Promise<any>;
|
|
280
|
+
createBackup(): Promise<any>;
|
|
281
|
+
|
|
282
|
+
// Static exports
|
|
283
|
+
static CredentialGenerator: typeof CredentialGenerator;
|
|
284
|
+
static SessionManager: typeof SessionManager;
|
|
285
|
+
static createSessionManager: (options?: SessionConfig) => SessionManager;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// ===========================================
|
|
289
|
+
// CREDENTIAL GENERATOR CLASS
|
|
290
|
+
// ===========================================
|
|
291
|
+
|
|
292
|
+
export class CredentialGenerator {
|
|
293
|
+
static generateUUID(): string;
|
|
294
|
+
static generateSecureUUID(): string;
|
|
295
|
+
static generatePassword(length?: number, options?: any): string;
|
|
296
|
+
static generateShadowsocks2022PSK(method?: string): string;
|
|
297
|
+
static generateWireGuardKeys(): WireGuardKeys;
|
|
298
|
+
static generateRealityKeys(): RealityKeys;
|
|
299
|
+
static generateUsername(prefix?: string): string;
|
|
300
|
+
static getRecommendedShadowsocksCipher(): string;
|
|
301
|
+
static getShadowsocksCipherMethods(): string[];
|
|
302
|
+
static generatePort(min?: number, max?: number): number;
|
|
303
|
+
static generateRealityShortId(): string;
|
|
304
|
+
static generateForProtocol(protocol: string, options?: CredentialOptions): any;
|
|
305
|
+
static generateBulk(protocol: string, count: number, options?: CredentialOptions): any[];
|
|
306
|
+
static validateCredentials(credentials: any, protocol: string): ValidationResult;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// ===========================================
|
|
310
|
+
// SESSION MANAGEMENT CLASSES
|
|
311
|
+
// ===========================================
|
|
312
|
+
|
|
313
|
+
export class SessionStore {
|
|
314
|
+
get(key: string): Promise<any>;
|
|
315
|
+
set(key: string, value: any, ttl?: number): Promise<void>;
|
|
316
|
+
delete(key: string): Promise<void>;
|
|
317
|
+
clear(): Promise<void>;
|
|
318
|
+
exists(key: string): Promise<boolean>;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export class MemorySessionStore extends SessionStore {
|
|
322
|
+
constructor();
|
|
323
|
+
getStats(): any;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export class RedisSessionStore extends SessionStore {
|
|
327
|
+
constructor(redisClient: any, options?: any);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export class DatabaseSessionStore extends SessionStore {
|
|
331
|
+
constructor(database: any, options?: any);
|
|
332
|
+
cleanupExpired(): Promise<number>;
|
|
333
|
+
static getCreateTableSQL(tableName?: string): string;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export class CustomSessionHandler {
|
|
337
|
+
constructor(handlers: any);
|
|
338
|
+
validate(key: string): Promise<boolean>;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function createSessionManager(options?: SessionConfig): SessionManager;
|
|
342
|
+
export function createMemoryStore(): MemorySessionStore;
|
|
343
|
+
export function createRedisStore(redisClient: any, options?: any): RedisSessionStore;
|
|
344
|
+
export function createDatabaseStore(database: any, options?: any): DatabaseSessionStore;
|
|
345
|
+
export function createCustomHandler(handlers: any): CustomSessionHandler;
|
|
346
|
+
|
|
347
|
+
// ===========================================
|
|
348
|
+
// WEB MIDDLEWARE EXPORTS
|
|
349
|
+
// ===========================================
|
|
350
|
+
|
|
351
|
+
export function createExpressMiddleware(config: ExpressMiddlewareConfig): any;
|
|
352
|
+
export function withThreeXUI(config: NextJSConfig, handler: any): any;
|
|
353
|
+
export function createReactHook(apiEndpoint?: string): ReactHookMethods;
|
|
354
|
+
export function createNextjsRoutes(config: NextJSConfig): any;
|
|
355
|
+
|
|
356
|
+
export const SessionConfig: {
|
|
357
|
+
memory(): SessionConfig;
|
|
358
|
+
redis(redisClient: any, options?: any): SessionConfig;
|
|
359
|
+
database(database: any, options?: any): SessionConfig;
|
|
360
|
+
custom(handlers: any): SessionConfig;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
// ===========================================
|
|
364
|
+
// PROTOCOL BUILDERS
|
|
365
|
+
// ===========================================
|
|
366
|
+
|
|
367
|
+
export class BaseBuilder {
|
|
368
|
+
constructor();
|
|
369
|
+
remark(remark: string): this;
|
|
370
|
+
port(port: number): this;
|
|
371
|
+
randomPort(min?: number, max?: number): this;
|
|
372
|
+
listen(listen?: string): this;
|
|
373
|
+
enable(enabled?: boolean): this;
|
|
374
|
+
build(): BuilderConfig;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export class VLESSBuilder extends BaseBuilder {
|
|
378
|
+
addClient(options?: CredentialOptions): this;
|
|
379
|
+
network(network: string): this;
|
|
380
|
+
tls(options?: TLSOptions): this;
|
|
381
|
+
reality(options?: RealityOptions): this;
|
|
382
|
+
websocket(options?: WebSocketOptions): this;
|
|
383
|
+
http2(options?: HTTP2Options): this;
|
|
384
|
+
grpc(options?: GRPCOptions): this;
|
|
385
|
+
flow(flow: string): this;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export class VMESSBuilder extends BaseBuilder {
|
|
389
|
+
addClient(options?: CredentialOptions): this;
|
|
390
|
+
network(network: string): this;
|
|
391
|
+
tls(options?: TLSOptions): this;
|
|
392
|
+
websocket(options?: WebSocketOptions): this;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export class TrojanBuilder extends BaseBuilder {
|
|
396
|
+
addClient(options?: CredentialOptions): this;
|
|
397
|
+
tls(options?: TLSOptions): this;
|
|
398
|
+
fallbacks(fallbacks: any[]): this;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export class ShadowsocksBuilder extends BaseBuilder {
|
|
402
|
+
method(method: string): this;
|
|
403
|
+
password(password?: string): this;
|
|
404
|
+
generatePassword(length?: number): this;
|
|
405
|
+
network(network: string): this;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export class WireGuardBuilder extends BaseBuilder {
|
|
409
|
+
serverKeys(keys?: WireGuardKeys): this;
|
|
410
|
+
address(addresses: string | string[]): this;
|
|
411
|
+
addPeer(options?: any): this;
|
|
412
|
+
mtu(mtu: number): this;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export class ProtocolBuilder {
|
|
416
|
+
static vless(): VLESSBuilder;
|
|
417
|
+
static vmess(): VMESSBuilder;
|
|
418
|
+
static trojan(): TrojanBuilder;
|
|
419
|
+
static shadowsocks(): ShadowsocksBuilder;
|
|
420
|
+
static wireguard(): WireGuardBuilder;
|
|
421
|
+
static templates: {
|
|
422
|
+
vlessReality(options?: any): BuilderConfig;
|
|
423
|
+
vmessWsTls(options?: any): BuilderConfig;
|
|
424
|
+
trojanTls(options?: any): BuilderConfig;
|
|
425
|
+
shadowsocks(options?: any): BuilderConfig;
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Optional: expose security helpers for advanced users
|
|
430
|
+
export const SecurityEnhancer: {
|
|
431
|
+
InputValidator: any;
|
|
432
|
+
SecureHeaders: any;
|
|
433
|
+
SecurityMonitor: any;
|
|
434
|
+
CredentialSecurity: any;
|
|
435
|
+
ErrorSecurity: any;
|
|
436
|
+
};
|
|
437
|
+
}
|