feat: add plugin application runtime and unified instance authorization

This commit is contained in:
illusia committed 2026-11-03 20:13:01 +08:00
1 parent 8bca848c21
commit 3430a8a753
80 files changed
+2133 -1004

No files matched your search

+3 -1
View File
@@ -11,6 +11,7 @@ import { SkinStore } from "./skin-store.js";
import { createPluginAdminRouter } from "../plugins/admin-router.js";
import type { PluginRegistry } from "../plugins/registry.js";
import type { PluginStore } from "../plugins/store.js";
import type { PluginRuntime } from "../plugins/runtime.js";
export interface AdminConnectionRecord {
id: string;
@@ -43,6 +44,7 @@ export interface AdminRouterOptions {
skinStore?: SkinStore;
pluginRegistry?: PluginRegistry;
pluginStore?: PluginStore;
pluginRuntime?: PluginRuntime;
startedAt: number;
}
@@ -131,7 +133,7 @@ export function createAdminRouter(options: AdminRouterOptions): Router {
});
router.use(requireAdmin(options.sessions, options.service));
router.use("/plugins", createPluginAdminRouter({ registry: options.pluginRegistry, store: options.pluginStore,
router.use("/plugins", createPluginAdminRouter({ registry: options.pluginRegistry, store: options.pluginStore, runtime: options.pluginRuntime,
protect: [requireSameOrigin, requireCsrf(options.sessions)],
audit: (event, data) => options.service.database.addAudit(event, data),
}));
+3 -3
View File
@@ -94,9 +94,9 @@ export class TsAdminService {
welcomeMessage: server.virtualserver_welcomemessage ?? "", maxClients: numeric(server.virtualserver_maxclients),
uptimeSeconds: numeric(server.virtualserver_uptime), channelCount: channels.length, clientCount: voiceClients.length,
channels: channels.map(channel => ({ id: String(channel.id), parentID: String(channel.parentID), name: channel.name,
description: channel.description, totalClients: channelMembers.get(String(channel.id)) ?? 0, hasPassword: channel.hasPassword })),
clients: voiceClients.map(entry => ({ id: Number(entry.id), uid: entry.uid, nickname: entry.nickname, channelID: String(entry.channelID),
serverGroups: entry.serverGroups.map(String), away: entry.isAway, inputMuted: entry.isInputMuted ?? false, outputMuted: entry.isOutputMuted ?? false })),
description: channel.description ?? "", totalClients: channelMembers.get(String(channel.id)) ?? 0, hasPassword: channel.hasPassword })),
clients: voiceClients.map(entry => ({ id: Number(entry.id), uid: entry.uid ?? "", nickname: entry.nickname, channelID: String(entry.channelID),
serverGroups: (entry.serverGroups ?? []).map(String), away: entry.isAway ?? false, inputMuted: entry.isInputMuted ?? false, outputMuted: entry.isOutputMuted ?? false })),
groups: groups.status === "fulfilled" ? groups.value.filter(group => group.type === 1).map(group => ({ id: String(group.id), name: group.name })) : [],
bans: bans.status === "fulfilled" ? bans.value.map(ban => ({ id: String(ban.id), name: ban.name || ban.lastNickname,
uid: ban.uid, reason: ban.reason, durationSeconds: ban.durationMs / 1000, createdAt: ban.createdAt?.toISOString() ?? null })) : [],