x3ui-api 1.0.8-1 → 1.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/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  A Node.js client for interacting with the x3ui panel API. This library provides a simple interface to manage X-UI inbounds, clients, and system statistics.
4
4
 
5
+ ## Requirements
6
+
7
+ - x3-ui v2.7.0 or higher (for lover x3-ui versions, use v1.0.9-1 version of this library)
8
+
5
9
  ## Installation
6
10
 
7
11
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x3ui-api",
3
- "version": "1.0.8-1",
3
+ "version": "1.1.0",
4
4
  "description": "API client for x3ui panel",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -11,8 +11,8 @@
11
11
  "author": "",
12
12
  "license": "MIT",
13
13
  "dependencies": {
14
- "axios": "^1.8.2",
15
- "form-data": "^4.0.0"
14
+ "axios": "1.12.0",
15
+ "form-data": "4.0.4"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/node": "^20.11.5"
@@ -46,7 +46,7 @@ module.exports = class X3UIClient {
46
46
  if (!this.isAuthed) {
47
47
  await this.login();
48
48
  }
49
- const response = await this.client.post('/server/status');
49
+ const response = await this.client.post('/panel/api/server/status');
50
50
  return response.data.obj;
51
51
  }
52
52
 
@@ -153,13 +153,14 @@ module.exports = class X3UIClient {
153
153
 
154
154
  /**
155
155
  * Get new X25519 certificate
156
+ * @deprecated Use {@link getNewVlessEnc} for new versions of X3-UI
156
157
  * @returns {Promise<{privateKey: string, publicKey: string}>} New X25519 key pair
157
158
  */
158
159
  async getNewX25519Cert() {
159
160
  if (!this.isAuthed) {
160
161
  await this.login();
161
162
  }
162
- const response = await this.client.post('/server/getNewX25519Cert');
163
+ const response = await this.client.post('/panel/api/server/getNewX25519Cert');
163
164
  return response.data.obj;
164
165
  }
165
166
  }
@@ -65,6 +65,13 @@ export default class VmessBuilder {
65
65
  */
66
66
  getClientLink(clientIndex?: number, host?: string): string;
67
67
 
68
+ /**
69
+ * Get connection link for a client
70
+ * @param email Email of the client
71
+ * @param host Optional host address (defaults to listenIP or 'localhost')
72
+ */
73
+ getClientLinkByEmail(email: string, host?: string): string;
74
+
68
75
  /**
69
76
  * Generate a random port number
70
77
  */
@@ -130,6 +130,14 @@ module.exports = class VmessBuilder {
130
130
  return client.getLink(host || this.listenIP || 'localhost', port || this.port);
131
131
  }
132
132
 
133
+ getClientLinkByEmail(email, host) {
134
+ const client = this.clients.find(client => client.email === email);
135
+ if (!client) {
136
+ throw new Error('Client not found');
137
+ }
138
+ return client.getLink(host || this.listenIP || 'localhost', this.port);
139
+ }
140
+
133
141
  generateRandomPort() {
134
142
  return Math.floor(Math.random() * (65535 - 1024) + 1024);
135
143
  }
@@ -87,6 +87,13 @@ export default class WireguardBuilder {
87
87
  * @returns A formatted connection link string
88
88
  */
89
89
  getClientLink(clientIndex?: number, host?: string, port?: number): string;
90
+
91
+ /**
92
+ * Get connection link for a client
93
+ * @param email Email of the client
94
+ * @param host Optional host address (defaults to listenIP or 'localhost')
95
+ */
96
+ getClientLinkByEmail(email: string, host?: string): string;
90
97
 
91
98
  /**
92
99
  * Generates a configuration file for a client.
@@ -132,6 +132,14 @@ module.exports = class WireguardBuilder {
132
132
  return client.getLink(host || this.listenIP || 'localhost', port || this.port);
133
133
  }
134
134
 
135
+ getClientLinkByEmail(email, host) {
136
+ const client = this.clients.find(client => client.email === email);
137
+ if (!client) {
138
+ throw new Error('Client not found');
139
+ }
140
+ return client.getLink(host || this.listenIP || 'localhost', this.port);
141
+ }
142
+
135
143
  getClientConfig(clientIndex = 0, host, port) {
136
144
  if (clientIndex < 0 || clientIndex >= this.clients.length) {
137
145
  throw new Error('Invalid client index');