3xui-api-client 1.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 CHANGED
@@ -5,6 +5,104 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.1.0] - 2025-08-30
9
+
10
+ ### Added
11
+ - ๐Ÿ”ฅ **Firestore Session Store Support** - Custom session handler for Firebase Firestore integration
12
+ - ๐Ÿ“ **Enhanced Wiki Documentation** - Comprehensive guides with real-world examples and integration patterns
13
+ - ๐Ÿ” **Client Identifier Clarification** - Clear documentation that 'email' field is an identifier, not a real email address
14
+
15
+ ### Enhanced
16
+ - ๐Ÿ“š **Authentication Guide** - Added detailed session/cookie flow documentation and Firestore integration example
17
+ - ๐Ÿ‘ฅ **Client Management Guide** - Clarified email field semantics and added identifier generation examples
18
+ - ๐Ÿ› ๏ธ **Inbound Management Guide** - Added protocol-specific authentication method explanations
19
+ - ๐Ÿ  **Home Documentation** - Improved navigation and cross-references between guides
20
+
21
+ ### Documentation
22
+ - **Session Management**: Added comprehensive Firestore adapter example with cleanup patterns
23
+ - **API Flow Clarification**: Documented that all API calls automatically include stored session cookies
24
+ - **Client Identifiers**: Clarified that 'email' fields use random strings (e.g., '5yhuih4hg93') for privacy
25
+ - **Integration Examples**: Enhanced web integration patterns for Express.js and Next.js
26
+ - **Security Best Practices**: Consolidated security guidance in Authentication Guide
27
+
28
+ ### Removed
29
+ - Removed any references to email generation functionality for clarity
30
+ - Cleaned up duplicate content across wiki files
31
+
32
+ ### Fixed
33
+ - Corrected misconceptions about email field usage in 3x-ui
34
+ - Improved consistency across documentation
35
+
36
+ ## [2.0.0] - 2025-06-25
37
+
38
+ ### Added
39
+ - ๐ŸŽฏ **Built-in Credential Generation System** - Automatic generation of random passwords, UUIDs, and client identifiers
40
+ - ๐Ÿ”ง **Advanced Session Management** - Intelligent session caching, automatic renewal, and multi-server support
41
+ - ๐ŸŒ **Web Integration Support** - Express.js and Next.js middleware for seamless web app integration
42
+ - ๐Ÿ›ก๏ธ **Enhanced Security Framework** - Input validation, security monitoring, and secure headers management
43
+ - ๐Ÿ“ฆ **Modular Architecture** - New `src/` directory structure with specialized modules:
44
+ - `CredentialGenerator.js` - Random credential generation utilities
45
+ - `SessionManager.js` - Advanced session handling and caching
46
+ - `WebMiddleware.js` - Express/Next.js integration helpers
47
+ - `ProtocolBuilders.js` - Automated inbound configuration builders
48
+ - `SecurityEnhancer.js` - Security validation and monitoring
49
+
50
+ ### Enhanced
51
+ - ๐Ÿ” **Improved Authentication** - More robust session handling with automatic recovery
52
+ - ๐Ÿ“Š **Better Error Handling** - Enhanced error messages and recovery mechanisms
53
+ - ๐ŸŽจ **Developer Experience** - Improved TypeScript definitions and code documentation
54
+ - ๐Ÿงช **Testing Framework** - Updated test suite with better coverage and reliability
55
+ - ๐Ÿ“ **Documentation** - Comprehensive wiki updates with practical examples
56
+
57
+ ### New Features
58
+ - **Credential Generation**:
59
+ - Random password generation with customizable complexity
60
+ - UUID v4 generation for unique client identifiers
61
+ - Secure random string generation for API keys
62
+ - Email-like identifier generation for client management
63
+
64
+ - **Session Management**:
65
+ - Intelligent session caching with TTL support
66
+ - Multi-server session handling
67
+ - Automatic session renewal and cleanup
68
+ - Database-ready session storage format
69
+
70
+ - **Web Integration**:
71
+ - Express.js middleware for route protection
72
+ - Next.js API route helpers
73
+ - Automatic cookie management
74
+ - Request/response transformation utilities
75
+
76
+ - **Protocol Builders**:
77
+ - Automated VLESS configuration generation
78
+ - VMess protocol setup helpers
79
+ - Trojan and Shadowsocks builders
80
+ - Reality and WireGuard configuration support
81
+
82
+ ### Changed
83
+ - **Breaking Change**: Enhanced API structure with new module organization
84
+ - **Package Structure**: Moved from monolithic to modular architecture
85
+ - **Dependencies**: Updated to latest stable versions
86
+ - **Configuration**: Improved configuration options and defaults
87
+
88
+ ### Security
89
+ - Enhanced input validation and sanitization
90
+ - Improved session security with automatic cleanup
91
+ - Better error handling to prevent information leakage
92
+ - Security monitoring and alerting capabilities
93
+
94
+ ### Developer Experience
95
+ - Better TypeScript support with comprehensive type definitions
96
+ - Improved documentation with real-world examples
97
+ - Enhanced testing framework with automated validation
98
+ - ESLint configuration for code quality
99
+
100
+ ### Performance
101
+ - Optimized session management with intelligent caching
102
+ - Reduced API call overhead through better request batching
103
+ - Improved memory usage with automatic cleanup
104
+ - Faster authentication flow with session reuse
105
+
8
106
  ## [1.0.0] - 2025-06-20
9
107
 
10
108
  ### Added
@@ -43,6 +141,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
43
141
  ### Planned
44
142
  - GitHub Actions CI/CD pipeline
45
143
  - Automated semantic releases
46
- - Unit test coverage with Jest
47
- - ESLint configuration
48
- - Contribution guidelines
144
+ - Enhanced unit test coverage
145
+ - Performance benchmarking tools
146
+ - Advanced monitoring and analytics
package/README.md CHANGED
@@ -20,6 +20,12 @@ A Node.js client library for 3x-ui panel API that provides easy-to-use methods f
20
20
  npm install 3xui-api-client
21
21
  ```
22
22
 
23
+ ## Context7 MCP Integration
24
+
25
+ This library can be implemented with the help of [Context7 MCP](https://context7.com/iamhelitha/3xui-api-client). Use the package name `3xui-api-client` to get context and documentation through Context7's Model Context Protocol integration.
26
+
27
+ Learn more about [Context7 MCP](https://context7.com) for enhanced development experience.
28
+
23
29
  ## Quick Start
24
30
 
25
31
  ```javascript
@@ -153,7 +159,7 @@ const clientConfig = {
153
159
  settings: JSON.stringify({
154
160
  clients: [{
155
161
  id: "client-uuid-here",
156
- email: "user@example.com",
162
+ email: "user23c5n7",
157
163
  limitIp: 0,
158
164
  totalGB: 0,
159
165
  expiryTime: 0,
@@ -184,7 +190,7 @@ const result = await client.deleteClient(inboundId, clientUUID);
184
190
 
185
191
  #### Get Client Traffic by Email
186
192
  ```javascript
187
- const traffic = await client.getClientTrafficsByEmail("user@example.com");
193
+ const traffic = await client.getClientTrafficsByEmail("user23c5n7");
188
194
  console.log('Client traffic:', traffic);
189
195
  ```
190
196
 
@@ -197,17 +203,17 @@ console.log('Client traffic:', traffic);
197
203
  #### Manage Client IPs
198
204
  ```javascript
199
205
  // Get client IPs
200
- const ips = await client.getClientIps("user@example.com");
206
+ const ips = await client.getClientIps("user23c5n7");
201
207
 
202
208
  // Clear client IPs
203
- const result = await client.clearClientIps("user@example.com");
209
+ const result = await client.clearClientIps("user23c5n7");
204
210
  ```
205
211
 
206
212
  ### Traffic Management (โœ… Tested & Working)
207
213
 
208
214
  #### Reset Individual Client Traffic
209
215
  ```javascript
210
- const result = await client.resetClientTraffic(inboundId, "user@example.com");
216
+ const result = await client.resetClientTraffic(inboundId, "user23c5n7");
211
217
  ```
212
218
 
213
219
  #### Reset All Traffic (Global)
@@ -239,151 +245,16 @@ const result = await client.createBackup();
239
245
  console.log('Backup created:', result);
240
246
  ```
241
247
 
242
- ## Use Cases
243
-
244
- ### VPN Service Provider
245
- ```javascript
246
- const ThreeXUI = require('3xui-api-client');
247
-
248
- class VPNServiceManager {
249
- constructor() {
250
- this.client = new ThreeXUI(process.env.XUI_URL, process.env.XUI_USER, process.env.XUI_PASS);
251
- }
252
-
253
- // Create new customer account
254
- async createCustomerAccount(email, dataLimitGB = 50) {
255
- // 1. Get available inbound
256
- const inbounds = await this.client.getInbounds();
257
- const activeInbound = inbounds.obj.find(i => i.enable);
258
-
259
- // 2. Add client to inbound
260
- const clientConfig = {
261
- id: activeInbound.id,
262
- settings: JSON.stringify({
263
- clients: [{
264
- id: this.generateUUID(),
265
- email: email,
266
- limitIp: 2,
267
- totalGB: dataLimitGB,
268
- expiryTime: Date.now() + (30 * 24 * 60 * 60 * 1000), // 30 days
269
- enable: true
270
- }]
271
- })
272
- };
273
-
274
- return await this.client.addClient(clientConfig);
275
- }
276
-
277
- // Monthly billing cycle
278
- async processBillingCycle() {
279
- const inbounds = await this.client.getInbounds();
280
-
281
- for (const inbound of inbounds.obj) {
282
- if (inbound.clientStats) {
283
- for (const client of inbound.clientStats) {
284
- // Reset traffic for active subscriptions
285
- await this.client.resetClientTraffic(inbound.id, client.email);
286
- }
287
- }
288
- }
289
- }
290
-
291
- // Monitor usage and send alerts
292
- async monitorUsage() {
293
- const onlineClients = await this.client.getOnlineClients();
294
-
295
- for (const client of onlineClients.obj || []) {
296
- const traffic = await this.client.getClientTrafficsByEmail(client.email);
297
-
298
- if (traffic.obj && traffic.obj.total > (40 * 1024 * 1024 * 1024)) { // 40GB
299
- console.log(`โš ๏ธ Client ${client.email} approaching data limit`);
300
- // Send notification to customer
301
- }
302
- }
303
- }
304
- }
305
- ```
306
-
307
- ### Server Administration
308
- ```javascript
309
- class ServerAdmin {
310
- constructor() {
311
- this.client = new ThreeXUI(process.env.XUI_URL, process.env.XUI_USER, process.env.XUI_PASS);
312
- }
313
-
314
- // Daily maintenance
315
- async dailyMaintenance() {
316
- // 1. Create backup
317
- await this.client.createBackup();
318
-
319
- // 2. Clean up depleted clients
320
- const inbounds = await this.client.getInbounds();
321
- for (const inbound of inbounds.obj) {
322
- await this.client.deleteDepletedClients(inbound.id);
323
- }
324
-
325
- // 3. Generate usage report
326
- const report = await this.generateUsageReport();
327
- console.log('Daily Report:', report);
328
- }
329
-
330
- // Setup new VPN server
331
- async setupNewServer(port, protocol = 'vless') {
332
- const serverConfig = {
333
- remark: `VPN-Server-${port}`,
334
- port: port,
335
- protocol: protocol,
336
- settings: {
337
- clients: [],
338
- decryption: "none",
339
- fallbacks: []
340
- },
341
- streamSettings: {
342
- network: "tcp",
343
- security: "reality",
344
- realitySettings: {
345
- dest: "google.com:443",
346
- serverNames: ["google.com"]
347
- }
348
- }
349
- };
350
-
351
- return await this.client.addInbound(serverConfig);
352
- }
353
- }
354
- ```
355
-
356
- ### Real-Time Monitoring Dashboard
357
- ```javascript
358
- class MonitoringDashboard {
359
- constructor() {
360
- this.client = new ThreeXUI(process.env.XUI_URL, process.env.XUI_USER, process.env.XUI_PASS);
361
- }
248
+ ## Documentation
362
249
 
363
- async getDashboardData() {
364
- const [inbounds, onlineClients] = await Promise.all([
365
- this.client.getInbounds(),
366
- this.client.getOnlineClients()
367
- ]);
368
-
369
- return {
370
- totalInbounds: inbounds.obj.length,
371
- activeInbounds: inbounds.obj.filter(i => i.enable).length,
372
- totalClients: inbounds.obj.reduce((sum, i) => sum + (i.clientStats?.length || 0), 0),
373
- onlineClients: onlineClients.obj?.length || 0,
374
- totalTraffic: inbounds.obj.reduce((sum, i) => sum + i.total, 0)
375
- };
376
- }
250
+ For comprehensive guides, examples, and implementation patterns, visit our [Wiki](https://github.com/iamhelitha/3xui-api-client/wiki):
377
251
 
378
- // WebSocket endpoint for real-time updates
379
- async startRealTimeUpdates(ws) {
380
- setInterval(async () => {
381
- const data = await this.getDashboardData();
382
- ws.send(JSON.stringify(data));
383
- }, 30000); // Update every 30 seconds
384
- }
385
- }
386
- ```
252
+ - ๐Ÿ“š [**Use Cases & Examples**](https://github.com/iamhelitha/3xui-api-client/wiki/Use-Cases) - VPN service provider, server administration, monitoring dashboards
253
+ - ๐Ÿ” [**Authentication Guide**](https://github.com/iamhelitha/3xui-api-client/wiki/Authentication-Guide) - Secure login and session management
254
+ - ๐ŸŒ [**Inbound Management**](https://github.com/iamhelitha/3xui-api-client/wiki/Inbound-Management) - Server configuration and setup
255
+ - ๐Ÿ‘ฅ [**Client Management**](https://github.com/iamhelitha/3xui-api-client/wiki/Client-Management) - User account operations
256
+ - ๐Ÿ“Š [**Traffic Management**](https://github.com/iamhelitha/3xui-api-client/wiki/Traffic-Management) - Usage monitoring and billing
257
+ - โš™๏ธ [**System Operations**](https://github.com/iamhelitha/3xui-api-client/wiki/System-Operations) - Backup and maintenance
387
258
 
388
259
  ## Error Handling
389
260
 
@@ -425,9 +296,7 @@ npm run test:login
425
296
  npm test
426
297
  ```
427
298
 
428
- ## Documentation
429
299
 
430
- For detailed guides and examples, visit our [Wiki](https://github.com/iamhelitha/3xui-api-client/wiki).
431
300
 
432
301
  ## License
433
302