Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/deploy-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ jobs:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'

- name: Update npm
run: npm install -g npm@latest

- name: Install dependencies and build
working-directory: './libs/contract'
run: npm i && npm run prepublish

- name: Publish package on NPM
working-directory: './libs/contract'
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public

send-telegram-message:
name: Send Telegram message
Expand Down
2 changes: 1 addition & 1 deletion dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | b
ENV PATH="/root/.nvm/versions/node/v22.14.0/bin:${PATH}"

# Установка Xray
RUN curl -L https://raw.githubusercontent.com/remnawave/scripts/main/scripts/install-latest-xray.sh | bash -s -- v25.6.8
RUN curl -L https://raw.githubusercontent.com/remnawave/scripts/main/scripts/install-latest-xray.sh | bash -s -- v25.12.8


RUN mkdir -p /var/log/supervisor /var/lib/rnode/xray /app \
Expand Down
2 changes: 2 additions & 0 deletions libs/contract/api/controllers/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export const HANDLER_CONTROLLER = 'handler' as const;
export const HANDLER_ROUTES = {
REMOVE_USER: 'remove-user',
ADD_USER: 'add-user',
ADD_USERS: 'add-users',
REMOVE_USERS: 'remove-users',
GET_INBOUND_USERS_COUNT: 'get-inbound-users-count',
GET_INBOUND_USERS: 'get-inbound-users',
} as const;
2 changes: 2 additions & 0 deletions libs/contract/api/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const REST_API = {
REMOVE_USER: `${ROOT}/${CONTROLLERS.HANDLER_CONTROLLER}/${CONTROLLERS.HANDLER_ROUTES.REMOVE_USER}`,
GET_INBOUND_USERS_COUNT: `${ROOT}/${CONTROLLERS.HANDLER_CONTROLLER}/${CONTROLLERS.HANDLER_ROUTES.GET_INBOUND_USERS_COUNT}`,
GET_INBOUND_USERS: `${ROOT}/${CONTROLLERS.HANDLER_CONTROLLER}/${CONTROLLERS.HANDLER_ROUTES.GET_INBOUND_USERS}`,
ADD_USERS: `${ROOT}/${CONTROLLERS.HANDLER_CONTROLLER}/${CONTROLLERS.HANDLER_ROUTES.ADD_USERS}`,
REMOVE_USERS: `${ROOT}/${CONTROLLERS.HANDLER_CONTROLLER}/${CONTROLLERS.HANDLER_ROUTES.REMOVE_USERS}`,
},
VISION: {
UNBLOCK_IP: `${CONTROLLERS.VISION_CONTROLLER}/${CONTROLLERS.VISION_ROUTES.UNBLOCK_IP}`,
Expand Down
14 changes: 1 addition & 13 deletions libs/contract/commands/handler/add-user.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,9 @@ export namespace AddUserCommand {
ivCheck: z.boolean(),
});

const BaseShadowsocks2022User = z.object({
type: z.literal('shadowsocks2022'),
tag: z.string(),
username: z.string(),
key: z.string(),
});

export const RequestSchema = z.object({
data: z.array(
z.discriminatedUnion('type', [
BaseTrojanUser,
BaseVlessUser,
BaseShadowsocksUser,
BaseShadowsocks2022User,
]),
z.discriminatedUnion('type', [BaseTrojanUser, BaseVlessUser, BaseShadowsocksUser]),
),
hashData: z.object({
vlessUuid: z.string().uuid(),
Expand Down
57 changes: 57 additions & 0 deletions libs/contract/commands/handler/add-users.command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { z } from 'zod';

import { REST_API } from '../../api';

export namespace AddUsersCommand {
export const url = REST_API.HANDLER.ADD_USERS;

const BaseTrojanUser = z.object({
type: z.literal('trojan'),
tag: z.string(),
});

const BaseVlessUser = z.object({
type: z.literal('vless'),
tag: z.string(),
flow: z.enum(['xtls-rprx-vision', '']),
});

const BaseShadowsocksUser = z.object({
type: z.literal('shadowsocks'),
tag: z.string(),
});

export const RequestSchema = z.object({
affectedInboundTags: z.array(z.string()),
users: z.array(
z.object({
inboundData: z.array(
z.discriminatedUnion('type', [
BaseTrojanUser,
BaseVlessUser,
BaseShadowsocksUser,
]),
),

userData: z.object({
userId: z.string(),
hashUuid: z.string().uuid(),
vlessUuid: z.string().uuid(),
trojanPassword: z.string(),
ssPassword: z.string(),
}),
}),
),
});

export type Request = z.infer<typeof RequestSchema>;

export const ResponseSchema = z.object({
response: z.object({
success: z.boolean(),
error: z.string().nullable(),
}),
});

export type Response = z.infer<typeof ResponseSchema>;
}
2 changes: 2 additions & 0 deletions libs/contract/commands/handler/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './add-user.command';
export * from './add-users.command';
export * from './get-inbound-users-count.command';
export * from './get-inbound-users.command';
export * from './remove-user.command';
export * from './remove-users.command';
27 changes: 27 additions & 0 deletions libs/contract/commands/handler/remove-users.command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { z } from 'zod';

import { REST_API } from '../../api';

export namespace RemoveUsersCommand {
export const url = REST_API.HANDLER.REMOVE_USERS;

export const RequestSchema = z.object({
users: z.array(
z.object({
userId: z.string(),
hashUuid: z.string().uuid(),
}),
),
});

export type Request = z.infer<typeof RequestSchema>;

export const ResponseSchema = z.object({
response: z.object({
success: z.boolean(),
error: z.string().nullable(),
}),
});

export type Response = z.infer<typeof ResponseSchema>;
}
2 changes: 1 addition & 1 deletion libs/contract/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remnawave/node-contract",
"version": "0.6.1",
"version": "2.5.0",
"description": "A node-contract library for Remnawave Panel",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
Loading