x3ui-api 1.1.0 → 1.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x3ui-api",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "API client for x3ui panel",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -1,5 +1,6 @@
1
1
  import {AxiosInstance} from "axios";
2
2
  import {
3
+ ClientSettings,
3
4
  DeepPartial,
4
5
  InboundConfig,
5
6
  LoginResponse,
@@ -20,6 +21,8 @@ export default class X3UIClient {
20
21
 
21
22
  addInbound(config: Omit<InboundConfig, 'id'>): Promise<InboundConfig>;
22
23
 
24
+ addClient(id: number, client: DeepPartial<ClientSettings>): Promise<void>;
25
+
23
26
  updateInbound(id: number, config: DeepPartial<InboundConfig>): Promise<void>;
24
27
 
25
28
  deleteInbound(id: number): Promise<void>;
@@ -160,7 +160,18 @@ module.exports = class X3UIClient {
160
160
  if (!this.isAuthed) {
161
161
  await this.login();
162
162
  }
163
- const response = await this.client.post('/panel/api/server/getNewX25519Cert');
163
+ const response = await this.client.get('/panel/api/server/getNewX25519Cert');
164
+ return response.data.obj;
165
+ }
166
+
167
+ async addClient(id, client) {
168
+ if (!this.isAuthed) {
169
+ await this.login();
170
+ }
171
+ const response = await this.client.post(`/panel/api/inbounds/addClient`, {
172
+ id,
173
+ settings: JSON.stringify({clients: [client]})
174
+ });
164
175
  return response.data.obj;
165
176
  }
166
177
  }
package/src/index.d.ts CHANGED
@@ -31,11 +31,11 @@ export interface InboundConfig {
31
31
  listen: string;
32
32
  port: number;
33
33
  protocol: string;
34
- settings: string | InboundSettings;
35
- streamSettings: string | StreamSettings;
34
+ settings: InboundSettings;
35
+ streamSettings: StreamSettings;
36
36
  tag: string;
37
- sniffing: string | SniffingSettings;
38
- allocate: string | AllocateSettings;
37
+ sniffing: SniffingSettings;
38
+ allocate: AllocateSettings;
39
39
  }
40
40
 
41
41
  export interface AllocateSettings {
@@ -100,7 +100,8 @@ export interface InboundSettings {
100
100
 
101
101
  export interface ClientSettings {
102
102
  id: string;
103
- flow: string;
103
+ flow?: string;
104
+ security?: string;
104
105
  email: string;
105
106
  limitIp: number;
106
107
  totalGB: number;