fix(gateway): resolve CI TypeScript errors and address review feedback

This commit is contained in:
winter.loo 2026-03-16 01:27:18 +08:00
parent dfce4052dc
commit cb4d03bb86
3 changed files with 8 additions and 6 deletions

View File

@ -203,8 +203,9 @@ export function isNodeCommandAllowed(params: {
if (!params.allowlist.has(command)) {
return { ok: false, reason: "command not allowlisted" };
}
if (Array.isArray(params.declaredCommands) && params.declaredCommands.length > 0) {
if (!params.declaredCommands.includes(command)) {
const { declaredCommands } = params;
if (Array.isArray(declaredCommands) && declaredCommands.length > 0) {
if (!declaredCommands.includes(command)) {
return { ok: false, reason: "command not declared by node" };
}
} else {

View File

@ -1003,15 +1003,16 @@ export const nodeHandlers: GatewayRequestHandlers = {
`node wake done node=${nodeId} req=${wakeReqId} connected=true totalMs=${totalDurationMs}`,
);
}
const session = nodeSession;
const cfg = loadConfig();
const allowlist = resolveNodeCommandAllowlist(cfg, nodeSession);
const allowlist = resolveNodeCommandAllowlist(cfg, session);
const allowed = isNodeCommandAllowed({
command,
declaredCommands: nodeSession.commands,
declaredCommands: session.commands,
allowlist,
});
if (!allowed.ok) {
const hint = buildNodeCommandRejectionHint(allowed.reason, command, nodeSession);
const hint = buildNodeCommandRejectionHint(allowed.reason, command, session);
respond(
false,
undefined,

View File

@ -123,7 +123,7 @@ export function ensureGlobalUndiciStreamTimeouts(opts?: { timeoutMs?: number }):
const connect = resolveConnectOptions(autoSelectFamily);
try {
if (kind === "env-proxy") {
const proxyConnect = { keepAlive: false, ...connect };
const proxyConnect = { ...connect, keepAlive: false };
const proxyOptions = {
bodyTimeout: timeoutMs,
headersTimeout: timeoutMs,