openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
19 lines (18 loc) • 951 B
JavaScript
import { o as hasConfiguredSecretInput } from "./types.secrets-BmNLLnHp.mjs";
//#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.";
function hasAmbiguousGatewayAuthModeConfig(e) {
const t = e.gateway?.auth;
if (!t) return false;
if (typeof t.mode === "string" && t.mode.trim().length > 0) return false;
const n = e.secrets?.defaults;
const r = hasConfiguredSecretInput(t.token, n);
const i = hasConfiguredSecretInput(t.password, n);
return r && i;
}
function assertExplicitGatewayAuthModeWhenBothConfigured(e) {
if (!hasAmbiguousGatewayAuthModeConfig(e)) return;
throw new Error(EXPLICIT_GATEWAY_AUTH_MODE_REQUIRED_ERROR);
}
//#endregion
export { hasAmbiguousGatewayAuthModeConfig as n, assertExplicitGatewayAuthModeWhenBothConfigured as t };