3xui-api-client 2.1.0 โ†’ 3.0.1

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
@@ -1,146 +1,185 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
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
-
106
- ## [1.0.0] - 2025-06-20
107
-
108
- ### Added
109
- - Complete API client library for 3x-ui panel management
110
- - Authentication with automatic session management
111
- - Inbound management (5 methods): getInbounds, getInbound, addInbound, updateInbound, deleteInbound
112
- - Client management (7 methods): addClient, updateClient, deleteClient, getClientTrafficsByEmail, getClientTrafficsById, getClientIps, clearClientIps
113
- - Traffic management (4 methods): resetClientTraffic, resetAllTraffics, resetAllClientTraffics, deleteDepletedClients
114
- - System operations (2 methods): getOnlineClients, createBackup
115
- - Comprehensive error handling and automatic re-authentication
116
- - TypeScript definitions for better developer experience
117
- - ESM module support alongside CommonJS
118
- - Complete documentation and wiki guides
119
- - Interactive testing suite with 19 test files
120
- - Security best practices implementation
121
-
122
- ### Features
123
- - ๐Ÿ” Secure session-based authentication
124
- - ๐Ÿ”„ Automatic login retry on session expiry
125
- - ๐Ÿ“Š Complete API coverage (19 routes tested and working)
126
- - ๐Ÿ›ก๏ธ Server-side only design for security
127
- - ๐Ÿ“š Comprehensive documentation with real-world examples
128
- - ๐Ÿงช Extensive testing suite with actual API responses
129
- - ๐Ÿ“ TypeScript support for better DX
130
- - ๐Ÿ”— Both CommonJS and ESM module support
131
-
132
- ### Security
133
- - No vulnerabilities in dependencies
134
- - Secure session cookie handling
135
- - Server-side only architecture
136
- - Input validation and error handling
137
- - Automatic timeout and retry mechanisms
138
-
139
- ## [Unreleased]
140
-
141
- ### Planned
142
- - GitHub Actions CI/CD pipeline
143
- - Automated semantic releases
144
- - Enhanced unit test coverage
145
- - Performance benchmarking tools
146
- - Advanced monitoring and analytics
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [3.0.1] - 2026-06-07
9
+
10
+ ### Fixed
11
+ - Re-release as 3.0.1 โ€” version 3.0.0 was previously published and unpublished, making it permanently blocked on npm.
12
+
13
+ ## [3.0.0] - 2026-06-07
14
+
15
+ ### Added
16
+ - ๐Ÿ”‘ **API Token Authentication** โ€” Pass `token` or `apiToken` in options to authenticate via Bearer token instead of cookie-based login. Resolves compatibility with 3x-ui v3.0.2+ where the legacy login mechanism changed. ([#1](https://github.com/iamhelitha/3xui-api-client/issues/1))
17
+ - ๐Ÿ†• **Object-style constructor** โ€” `new ThreeXUI(url, { username, password, token })` as an alternative to the positional `(url, user, pass)` signature.
18
+ - ๐Ÿ“ก **48 new Modern API routes** (3x-ui v2.x/v3.x endpoints):
19
+ - **Clients** (25 routes): `getClients`, `getPagedClients`, `getClient`, `getClientTraffic`, `getSubLinks`, `getClientLinks`, `addModernClient`, `updateModernClient`, `deleteModernClient`, `attachClientToInbounds`, `detachClientFromInbounds`, `resetAllModernClientTraffics`, `deleteDepletedModernClients`, bulk operations (`bulkAdjust`, `bulkDel`, `bulkCreate`, `bulkAttach`, `bulkDetach`, `bulkResetTraffic`), `resetModernClientTrafficByEmail`, `updateModernClientTrafficByEmail`, `getModernClientIps`, `clearModernClientIps`, `getOnlines`, `getModernLastOnline`
20
+ - **Client Groups** (7 routes): `getGroups`, `getGroupEmails`, `createGroup`, `renameGroup`, `deleteGroup`, `bulkAddGroups`, `bulkRemoveGroups`
21
+ - **Nodes** (9 routes): `getNodes`, `getNode`, `getNodeHistory`, `addNode`, `updateNode`, `deleteNode`, `setNodeEnable`, `testNode`, `probeNode`
22
+ - **Custom Geo** (7 routes): `getCustomGeos`, `getGeoAliases`, `addCustomGeo`, `updateCustomGeo`, `deleteCustomGeo`, `downloadCustomGeo`, `updateAllCustomGeo`
23
+
24
+ ### Changed
25
+ - Constructor signature extended to accept an options object as the second argument (fully backward compatible โ€” existing `(url, user, pass)` usage is unchanged).
26
+ - `_request()` and `login()` skip cookie-based auth flow when a token is configured.
27
+ - `isSessionValid()` returns `true` immediately when token auth is active.
28
+
29
+ ### Fixed
30
+ - ESLint errors (trailing whitespace, missing curly braces) introduced in new route additions.
31
+ - Indentation inconsistency in TypeScript declarations (`updateClientWithCredentials`).
32
+
33
+ ### Backward Compatibility
34
+ - All existing `(url, username, password)` constructor calls continue to work without any changes.
35
+ - All 55 original API routes are unchanged.
36
+ - Verified against older 3x-ui servers โ€” cookie-based login, session management, and all core routes function identically.
37
+
38
+ ## [2.1.1] - 2025-11-30
39
+
40
+ ### Fixed
41
+ - ๐Ÿ› **Login Response**: `login()` method now explicitly returns the `cookie` in the response object, making it easier to store sessions in databases.
42
+ - ๐Ÿ”ง **Configuration Auto-fix**: Automatically detects and fixes `PANEL_URL` configuration errors (removing trailing `/panel`) to prevent 404 errors.
43
+
44
+ ### Documentation
45
+ - ๐Ÿ“ **Configuration Guide**: Added critical warning about `PANEL_URL` format in README.
46
+
47
+ ## [2.1.0] - 2025-08-30
48
+
49
+ ### Added
50
+ - ๐Ÿ”ฅ **Firestore Session Store Support** - Custom session handler for Firebase Firestore integration
51
+ - ๐Ÿ“ **Enhanced Wiki Documentation** - Comprehensive guides with real-world examples and integration patterns
52
+ - ๐Ÿ” **Client Identifier Clarification** - Clear documentation that 'email' field is an identifier, not a real email address
53
+
54
+ ### Enhanced
55
+ - ๐Ÿ“š **Authentication Guide** - Added detailed session/cookie flow documentation and Firestore integration example
56
+ - ๐Ÿ‘ฅ **Client Management Guide** - Clarified email field semantics and added identifier generation examples
57
+ - ๐Ÿ› ๏ธ **Inbound Management Guide** - Added protocol-specific authentication method explanations
58
+ - ๐Ÿ  **Home Documentation** - Improved navigation and cross-references between guides
59
+
60
+ ### Documentation
61
+ - **Session Management**: Added comprehensive Firestore adapter example with cleanup patterns
62
+ - **API Flow Clarification**: Documented that all API calls automatically include stored session cookies
63
+ - **Client Identifiers**: Clarified that 'email' fields use random strings (e.g., '5yhuih4hg93') for privacy
64
+ - **Integration Examples**: Enhanced web integration patterns for Express.js and Next.js
65
+ - **Security Best Practices**: Consolidated security guidance in Authentication Guide
66
+
67
+ ### Removed
68
+ - Removed any references to email generation functionality for clarity
69
+ - Cleaned up duplicate content across wiki files
70
+
71
+ ### Fixed
72
+ - Corrected misconceptions about email field usage in 3x-ui
73
+ - Improved consistency across documentation
74
+
75
+ ## [2.0.0] - 2025-06-25
76
+
77
+ ### Added
78
+ - ๐ŸŽฏ **Built-in Credential Generation System** - Automatic generation of random passwords, UUIDs, and client identifiers
79
+ - ๐Ÿ”ง **Advanced Session Management** - Intelligent session caching, automatic renewal, and multi-server support
80
+ - ๐ŸŒ **Web Integration Support** - Express.js and Next.js middleware for seamless web app integration
81
+ - ๐Ÿ›ก๏ธ **Enhanced Security Framework** - Input validation, security monitoring, and secure headers management
82
+ - ๐Ÿ“ฆ **Modular Architecture** - New `src/` directory structure with specialized modules:
83
+ - `CredentialGenerator.js` - Random credential generation utilities
84
+ - `SessionManager.js` - Advanced session handling and caching
85
+ - `WebMiddleware.js` - Express/Next.js integration helpers
86
+ - `ProtocolBuilders.js` - Automated inbound configuration builders
87
+ - `SecurityEnhancer.js` - Security validation and monitoring
88
+
89
+ ### Enhanced
90
+ - ๐Ÿ” **Improved Authentication** - More robust session handling with automatic recovery
91
+ - ๐Ÿ“Š **Better Error Handling** - Enhanced error messages and recovery mechanisms
92
+ - ๐ŸŽจ **Developer Experience** - Improved TypeScript definitions and code documentation
93
+ - ๐Ÿงช **Testing Framework** - Updated test suite with better coverage and reliability
94
+ - ๐Ÿ“ **Documentation** - Comprehensive wiki updates with practical examples
95
+
96
+ ### New Features
97
+ - **Credential Generation**:
98
+ - Random password generation with customizable complexity
99
+ - UUID v4 generation for unique client identifiers
100
+ - Secure random string generation for API keys
101
+ - Email-like identifier generation for client management
102
+
103
+ - **Session Management**:
104
+ - Intelligent session caching with TTL support
105
+ - Multi-server session handling
106
+ - Automatic session renewal and cleanup
107
+ - Database-ready session storage format
108
+
109
+ - **Web Integration**:
110
+ - Express.js middleware for route protection
111
+ - Next.js API route helpers
112
+ - Automatic cookie management
113
+ - Request/response transformation utilities
114
+
115
+ - **Protocol Builders**:
116
+ - Automated VLESS configuration generation
117
+ - VMess protocol setup helpers
118
+ - Trojan and Shadowsocks builders
119
+ - Reality and WireGuard configuration support
120
+
121
+ ### Changed
122
+ - **Breaking Change**: Enhanced API structure with new module organization
123
+ - **Package Structure**: Moved from monolithic to modular architecture
124
+ - **Dependencies**: Updated to latest stable versions
125
+ - **Configuration**: Improved configuration options and defaults
126
+
127
+ ### Security
128
+ - Enhanced input validation and sanitization
129
+ - Improved session security with automatic cleanup
130
+ - Better error handling to prevent information leakage
131
+ - Security monitoring and alerting capabilities
132
+
133
+ ### Developer Experience
134
+ - Better TypeScript support with comprehensive type definitions
135
+ - Improved documentation with real-world examples
136
+ - Enhanced testing framework with automated validation
137
+ - ESLint configuration for code quality
138
+
139
+ ### Performance
140
+ - Optimized session management with intelligent caching
141
+ - Reduced API call overhead through better request batching
142
+ - Improved memory usage with automatic cleanup
143
+ - Faster authentication flow with session reuse
144
+
145
+ ## [1.0.0] - 2025-06-20
146
+
147
+ ### Added
148
+ - Complete API client library for 3x-ui panel management
149
+ - Authentication with automatic session management
150
+ - Inbound management (5 methods): getInbounds, getInbound, addInbound, updateInbound, deleteInbound
151
+ - Client management (7 methods): addClient, updateClient, deleteClient, getClientTrafficsByEmail, getClientTrafficsById, getClientIps, clearClientIps
152
+ - Traffic management (4 methods): resetClientTraffic, resetAllTraffics, resetAllClientTraffics, deleteDepletedClients
153
+ - System operations (2 methods): getOnlineClients, createBackup
154
+ - Comprehensive error handling and automatic re-authentication
155
+ - TypeScript definitions for better developer experience
156
+ - ESM module support alongside CommonJS
157
+ - Complete documentation and wiki guides
158
+ - Interactive testing suite with 19 test files
159
+ - Security best practices implementation
160
+
161
+ ### Features
162
+ - ๐Ÿ” Secure session-based authentication
163
+ - ๐Ÿ”„ Automatic login retry on session expiry
164
+ - ๐Ÿ“Š Complete API coverage (19 routes tested and working)
165
+ - ๐Ÿ›ก๏ธ Server-side only design for security
166
+ - ๐Ÿ“š Comprehensive documentation with real-world examples
167
+ - ๐Ÿงช Extensive testing suite with actual API responses
168
+ - ๐Ÿ“ TypeScript support for better DX
169
+ - ๐Ÿ”— Both CommonJS and ESM module support
170
+
171
+ ### Security
172
+ - No vulnerabilities in dependencies
173
+ - Secure session cookie handling
174
+ - Server-side only architecture
175
+ - Input validation and error handling
176
+ - Automatic timeout and retry mechanisms
177
+
178
+ ## [Unreleased]
179
+
180
+ ### Planned
181
+ - GitHub Actions CI/CD pipeline
182
+ - Automated semantic releases
183
+ - Enhanced unit test coverage
184
+ - Performance benchmarking tools
185
+ - Advanced monitoring and analytics
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Helitha Guruge
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Helitha Guruge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.