Remove pre-1.0 audit and protected request scaffolding

This commit is contained in:
npc0-hue
2026-08-20 23:42:02 +08:00
parent 40b35b05c7
commit a7e2e4c6c0
130 changed files with 526 additions and 3767 deletions
+13 -14
View File
@@ -1,31 +1,30 @@
import type { GameClientBridgeQueueRequest } from "../api/types";
export const scumManagementRCONProfileKey = "scum-client-manager";
export const scumManagementRCONCommandType = "management.rcon.request";
import type { SourceRCONCommandRequest } from "../api/types";
const maxManagementCommandBytes = 8192;
const managementCommandTtlMs = 120_000;
export function scumManagementRCONCommandRequest(serverInstanceId: string, command: string, sequence = Date.now()): GameClientBridgeQueueRequest {
export function scumSourceRCONCommandRequest(serverInstanceId: string, command: string, sequence = Date.now()): SourceRCONCommandRequest {
const stamp = Math.max(0, Math.floor(sequence));
return {
profileKey: scumManagementRCONProfileKey,
commandType: scumManagementRCONCommandType,
payload: { requestText: normalizeSCUMManagementCommand(command, "管理指令") },
kind: "command",
command: normalizeSCUMManagementCommand(command, "管理指令"),
idempotencyKey: `web:scum-rcon:${safeBridgeIdentifierPart(serverInstanceId)}:${stamp}`,
priority: 20,
expiresAt: new Date(stamp + managementCommandTtlMs).toISOString()
};
}
export function scumAnnouncementCommand(message: string): string {
return `#Announce ${validateSCUMManagementRCONText(message, "公告内容")}`;
export function scumSourceRCONChatRequest(serverInstanceId: string, message: string, sequence = Date.now()): SourceRCONCommandRequest {
const stamp = Math.max(0, Math.floor(sequence));
return {
kind: "chat",
chatType: 4,
message: validateSCUMManagementRCONText(message, "聊天内容"),
idempotencyKey: `web:scum-rcon-chat:${safeBridgeIdentifierPart(serverInstanceId)}:${stamp}`
};
}
export function validateSCUMManagementRCONText(value: string, label: string): string {
const normalized = value.trim();
if (!normalized || new TextEncoder().encode(normalized).byteLength > maxManagementCommandBytes || /[\u0000\r\n]/.test(normalized)) {
throw new Error(`${label}必须是受限的单行文本。`);
throw new Error(`${label}必须是单行文本。`);
}
return normalized;
}