Remove pre-1.0 audit and protected request scaffolding
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user