@remnawave/node-contract 0.1.5 → 0.2.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/api/controllers/handler.ts +8 -0
- package/api/controllers/index.ts +1 -0
- package/build/api/controllers/handler.js +10 -0
- package/build/api/controllers/index.js +1 -0
- package/build/commands/handler/add-user.command.js +80 -0
- package/build/commands/handler/get-inbound-users-count.command.js +15 -0
- package/build/commands/handler/get-inbound-users.command.js +19 -0
- package/build/commands/handler/index.js +20 -0
- package/build/commands/handler/remove-user.command.js +17 -0
- package/build/commands/index.js +1 -0
- package/build/constants/errors/errors.js +5 -0
- package/commands/handler/add-user.command.ts +88 -0
- package/commands/handler/get-inbound-users-count.command.ts +17 -0
- package/commands/handler/get-inbound-users.command.ts +23 -0
- package/commands/handler/index.ts +4 -0
- package/commands/handler/remove-user.command.ts +19 -0
- package/commands/index.ts +1 -0
- package/constants/errors/errors.ts +5 -0
- package/package.json +1 -1
package/api/controllers/index.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HANDLER_ROUTES = exports.HANDLER_CONTROLLER = void 0;
|
|
4
|
+
exports.HANDLER_CONTROLLER = 'handler';
|
|
5
|
+
exports.HANDLER_ROUTES = {
|
|
6
|
+
REMOVE_USER: '/remove-user',
|
|
7
|
+
ADD_USER: '/add-user',
|
|
8
|
+
GET_INBOUND_USERS_COUNT: '/get-inbound-users-count',
|
|
9
|
+
GET_INBOUND_USERS: '/get-inbound-users',
|
|
10
|
+
};
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./stats"), exports);
|
|
18
18
|
__exportStar(require("./xray"), exports);
|
|
19
|
+
__exportStar(require("./handler"), exports);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddUserCommand = exports.CipherType = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
var CipherType;
|
|
6
|
+
(function (CipherType) {
|
|
7
|
+
CipherType[CipherType["UNKNOWN"] = 0] = "UNKNOWN";
|
|
8
|
+
CipherType[CipherType["AES_128_GCM"] = 5] = "AES_128_GCM";
|
|
9
|
+
CipherType[CipherType["AES_256_GCM"] = 6] = "AES_256_GCM";
|
|
10
|
+
CipherType[CipherType["CHACHA20_POLY1305"] = 7] = "CHACHA20_POLY1305";
|
|
11
|
+
CipherType[CipherType["XCHACHA20_POLY1305"] = 8] = "XCHACHA20_POLY1305";
|
|
12
|
+
CipherType[CipherType["NONE"] = 9] = "NONE";
|
|
13
|
+
CipherType[CipherType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
14
|
+
})(CipherType || (exports.CipherType = CipherType = {}));
|
|
15
|
+
var AddUserCommand;
|
|
16
|
+
(function (AddUserCommand) {
|
|
17
|
+
const BaseTrojanUser = zod_1.z.object({
|
|
18
|
+
type: zod_1.z.literal('trojan'),
|
|
19
|
+
tag: zod_1.z.string(),
|
|
20
|
+
username: zod_1.z.string(),
|
|
21
|
+
password: zod_1.z.string(),
|
|
22
|
+
level: zod_1.z.number().default(0),
|
|
23
|
+
});
|
|
24
|
+
const BaseVlessUser = zod_1.z.object({
|
|
25
|
+
type: zod_1.z.literal('vless'),
|
|
26
|
+
tag: zod_1.z.string(),
|
|
27
|
+
username: zod_1.z.string(),
|
|
28
|
+
uuid: zod_1.z.string(),
|
|
29
|
+
flow: zod_1.z.enum(['xtls-rprx-vision', '']),
|
|
30
|
+
level: zod_1.z.number().default(0),
|
|
31
|
+
});
|
|
32
|
+
const BaseShadowsocksUser = zod_1.z.object({
|
|
33
|
+
type: zod_1.z.literal('shadowsocks'),
|
|
34
|
+
tag: zod_1.z.string(),
|
|
35
|
+
username: zod_1.z.string(),
|
|
36
|
+
password: zod_1.z.string(),
|
|
37
|
+
cipherType: zod_1.z.nativeEnum(CipherType),
|
|
38
|
+
ivCheck: zod_1.z.boolean(),
|
|
39
|
+
level: zod_1.z.number().default(0),
|
|
40
|
+
});
|
|
41
|
+
const BaseShadowsocks2022User = zod_1.z.object({
|
|
42
|
+
type: zod_1.z.literal('shadowsocks2022'),
|
|
43
|
+
tag: zod_1.z.string(),
|
|
44
|
+
username: zod_1.z.string(),
|
|
45
|
+
key: zod_1.z.string(),
|
|
46
|
+
level: zod_1.z.number().default(0),
|
|
47
|
+
});
|
|
48
|
+
const BaseSocksUser = zod_1.z.object({
|
|
49
|
+
type: zod_1.z.literal('socks'),
|
|
50
|
+
tag: zod_1.z.string(),
|
|
51
|
+
username: zod_1.z.string(),
|
|
52
|
+
socks_username: zod_1.z.string(),
|
|
53
|
+
socks_password: zod_1.z.string(),
|
|
54
|
+
level: zod_1.z.number().default(0),
|
|
55
|
+
});
|
|
56
|
+
const BaseHttpUser = zod_1.z.object({
|
|
57
|
+
type: zod_1.z.literal('http'),
|
|
58
|
+
tag: zod_1.z.string(),
|
|
59
|
+
username: zod_1.z.string(),
|
|
60
|
+
http_username: zod_1.z.string(),
|
|
61
|
+
http_password: zod_1.z.string(),
|
|
62
|
+
level: zod_1.z.number().default(0),
|
|
63
|
+
});
|
|
64
|
+
AddUserCommand.RequestSchema = zod_1.z.object({
|
|
65
|
+
data: zod_1.z.discriminatedUnion('type', [
|
|
66
|
+
BaseTrojanUser,
|
|
67
|
+
BaseVlessUser,
|
|
68
|
+
BaseShadowsocksUser,
|
|
69
|
+
BaseShadowsocks2022User,
|
|
70
|
+
BaseSocksUser,
|
|
71
|
+
BaseHttpUser,
|
|
72
|
+
]),
|
|
73
|
+
});
|
|
74
|
+
AddUserCommand.ResponseSchema = zod_1.z.object({
|
|
75
|
+
response: zod_1.z.object({
|
|
76
|
+
success: zod_1.z.boolean(),
|
|
77
|
+
error: zod_1.z.string().nullable(),
|
|
78
|
+
}),
|
|
79
|
+
});
|
|
80
|
+
})(AddUserCommand || (exports.AddUserCommand = AddUserCommand = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetInboundUsersCountCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
var GetInboundUsersCountCommand;
|
|
6
|
+
(function (GetInboundUsersCountCommand) {
|
|
7
|
+
GetInboundUsersCountCommand.RequestSchema = zod_1.z.object({
|
|
8
|
+
tag: zod_1.z.string(),
|
|
9
|
+
});
|
|
10
|
+
GetInboundUsersCountCommand.ResponseSchema = zod_1.z.object({
|
|
11
|
+
response: zod_1.z.object({
|
|
12
|
+
count: zod_1.z.number(),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
})(GetInboundUsersCountCommand || (exports.GetInboundUsersCountCommand = GetInboundUsersCountCommand = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetInboundUsersCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
var GetInboundUsersCommand;
|
|
6
|
+
(function (GetInboundUsersCommand) {
|
|
7
|
+
GetInboundUsersCommand.RequestSchema = zod_1.z.object({
|
|
8
|
+
tag: zod_1.z.string(),
|
|
9
|
+
});
|
|
10
|
+
GetInboundUsersCommand.ResponseSchema = zod_1.z.object({
|
|
11
|
+
response: zod_1.z.object({
|
|
12
|
+
users: zod_1.z.array(zod_1.z.object({
|
|
13
|
+
username: zod_1.z.string(),
|
|
14
|
+
email: zod_1.z.string().optional(),
|
|
15
|
+
level: zod_1.z.number().optional(),
|
|
16
|
+
})),
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
})(GetInboundUsersCommand || (exports.GetInboundUsersCommand = GetInboundUsersCommand = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./add-user.command"), exports);
|
|
18
|
+
__exportStar(require("./get-inbound-users.command"), exports);
|
|
19
|
+
__exportStar(require("./get-inbound-users-count.command"), exports);
|
|
20
|
+
__exportStar(require("./remove-user.command"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RemoveUserCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
var RemoveUserCommand;
|
|
6
|
+
(function (RemoveUserCommand) {
|
|
7
|
+
RemoveUserCommand.RequestSchema = zod_1.z.object({
|
|
8
|
+
tag: zod_1.z.string(),
|
|
9
|
+
username: zod_1.z.string(),
|
|
10
|
+
});
|
|
11
|
+
RemoveUserCommand.ResponseSchema = zod_1.z.object({
|
|
12
|
+
response: zod_1.z.object({
|
|
13
|
+
success: zod_1.z.boolean(),
|
|
14
|
+
error: zod_1.z.string().nullable(),
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
})(RemoveUserCommand || (exports.RemoveUserCommand = RemoveUserCommand = {}));
|
package/build/commands/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./xray"), exports);
|
|
18
18
|
__exportStar(require("./stats"), exports);
|
|
19
|
+
__exportStar(require("./handler"), exports);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export enum CipherType {
|
|
4
|
+
UNKNOWN = 0,
|
|
5
|
+
AES_128_GCM = 5,
|
|
6
|
+
AES_256_GCM = 6,
|
|
7
|
+
CHACHA20_POLY1305 = 7,
|
|
8
|
+
XCHACHA20_POLY1305 = 8,
|
|
9
|
+
NONE = 9,
|
|
10
|
+
UNRECOGNIZED = -1,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export namespace AddUserCommand {
|
|
14
|
+
const BaseTrojanUser = z.object({
|
|
15
|
+
type: z.literal('trojan'),
|
|
16
|
+
tag: z.string(),
|
|
17
|
+
username: z.string(),
|
|
18
|
+
password: z.string(),
|
|
19
|
+
level: z.number().default(0),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const BaseVlessUser = z.object({
|
|
23
|
+
type: z.literal('vless'),
|
|
24
|
+
tag: z.string(),
|
|
25
|
+
username: z.string(),
|
|
26
|
+
uuid: z.string(),
|
|
27
|
+
flow: z.enum(['xtls-rprx-vision', '']),
|
|
28
|
+
level: z.number().default(0),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const BaseShadowsocksUser = z.object({
|
|
32
|
+
type: z.literal('shadowsocks'),
|
|
33
|
+
tag: z.string(),
|
|
34
|
+
username: z.string(),
|
|
35
|
+
password: z.string(),
|
|
36
|
+
cipherType: z.nativeEnum(CipherType),
|
|
37
|
+
ivCheck: z.boolean(),
|
|
38
|
+
level: z.number().default(0),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const BaseShadowsocks2022User = z.object({
|
|
42
|
+
type: z.literal('shadowsocks2022'),
|
|
43
|
+
tag: z.string(),
|
|
44
|
+
username: z.string(),
|
|
45
|
+
key: z.string(),
|
|
46
|
+
level: z.number().default(0),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const BaseSocksUser = z.object({
|
|
50
|
+
type: z.literal('socks'),
|
|
51
|
+
tag: z.string(),
|
|
52
|
+
username: z.string(),
|
|
53
|
+
socks_username: z.string(),
|
|
54
|
+
socks_password: z.string(),
|
|
55
|
+
level: z.number().default(0),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const BaseHttpUser = z.object({
|
|
59
|
+
type: z.literal('http'),
|
|
60
|
+
tag: z.string(),
|
|
61
|
+
username: z.string(),
|
|
62
|
+
http_username: z.string(),
|
|
63
|
+
http_password: z.string(),
|
|
64
|
+
level: z.number().default(0),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const RequestSchema = z.object({
|
|
68
|
+
data: z.discriminatedUnion('type', [
|
|
69
|
+
BaseTrojanUser,
|
|
70
|
+
BaseVlessUser,
|
|
71
|
+
BaseShadowsocksUser,
|
|
72
|
+
BaseShadowsocks2022User,
|
|
73
|
+
BaseSocksUser,
|
|
74
|
+
BaseHttpUser,
|
|
75
|
+
]),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
79
|
+
|
|
80
|
+
export const ResponseSchema = z.object({
|
|
81
|
+
response: z.object({
|
|
82
|
+
success: z.boolean(),
|
|
83
|
+
error: z.string().nullable(),
|
|
84
|
+
}),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
88
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export namespace GetInboundUsersCountCommand {
|
|
4
|
+
export const RequestSchema = z.object({
|
|
5
|
+
tag: z.string(),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
9
|
+
|
|
10
|
+
export const ResponseSchema = z.object({
|
|
11
|
+
response: z.object({
|
|
12
|
+
count: z.number(),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export namespace GetInboundUsersCommand {
|
|
4
|
+
export const RequestSchema = z.object({
|
|
5
|
+
tag: z.string(),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
9
|
+
|
|
10
|
+
export const ResponseSchema = z.object({
|
|
11
|
+
response: z.object({
|
|
12
|
+
users: z.array(
|
|
13
|
+
z.object({
|
|
14
|
+
username: z.string(),
|
|
15
|
+
email: z.string().optional(),
|
|
16
|
+
level: z.number().optional(),
|
|
17
|
+
}),
|
|
18
|
+
),
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export namespace RemoveUserCommand {
|
|
4
|
+
export const RequestSchema = z.object({
|
|
5
|
+
tag: z.string(),
|
|
6
|
+
username: z.string(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
response: z.object({
|
|
13
|
+
success: z.boolean(),
|
|
14
|
+
error: z.string().nullable(),
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
package/commands/index.ts
CHANGED