openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
21 lines (20 loc) • 1.29 kB
JavaScript
import { s as hasConfiguredSecretInput } from "./types.secrets-_0JOMGE5.js";
//#region src/gateway/auth-mode-policy.ts
const EXPLICIT_GATEWAY_AUTH_MODE_REQUIRED_ERROR = "Invalid config: gateway.auth.token and gateway.auth.password are both configured, but gateway.auth.mode is unset. Set gateway.auth.mode to token or password.";
/** Returns true when local gateway auth config needs an explicit token/password mode. */
function hasAmbiguousGatewayAuthModeConfig(cfg) {
const auth = cfg.gateway?.auth;
if (!auth) return false;
if (typeof auth.mode === "string" && auth.mode.trim().length > 0) return false;
const defaults = cfg.secrets?.defaults;
const tokenConfigured = hasConfiguredSecretInput(auth.token, defaults);
const passwordConfigured = hasConfiguredSecretInput(auth.password, defaults);
return tokenConfigured && passwordConfigured;
}
/** Throws the public config error used by setup, doctor, and gateway startup validation. */
function assertExplicitGatewayAuthModeWhenBothConfigured(cfg) {
if (!hasAmbiguousGatewayAuthModeConfig(cfg)) return;
throw new Error(EXPLICIT_GATEWAY_AUTH_MODE_REQUIRED_ERROR);
}
//#endregion
export { assertExplicitGatewayAuthModeWhenBothConfigured as n, hasAmbiguousGatewayAuthModeConfig as r, EXPLICIT_GATEWAY_AUTH_MODE_REQUIRED_ERROR as t };