openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
36 lines (35 loc) • 1.91 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { _ as resolveSecretInputRef, p as normalizeSecretInputString } from "./types.secrets-BmNLLnHp.mjs";
//#region src/gateway/auth-token-source-conflict.ts
const GATEWAY_ENV_TOKEN = "OPENCLAW_GATEWAY_TOKEN";
const GATEWAY_SERVICE_KIND = "gateway";
function resolveGatewayAuthTokenSourceConflict(e) {
const t = normalizeOptionalString(e.env.OPENCLAW_GATEWAY_TOKEN);
if (!t) return null;
if (e.env.OPENCLAW_SERVICE_KIND?.trim() === GATEWAY_SERVICE_KIND) return null;
if (e.cfg.gateway?.mode === "remote") return null;
const n = e.cfg.gateway?.auth?.mode;
if (n === "password" || n === "none" || n === "trusted-proxy") return null;
const r = e.cfg.gateway?.auth?.token;
const { ref: i } = resolveSecretInputRef({
value: r,
defaults: e.cfg.secrets?.defaults
});
if (i?.source === "env" && i.id === GATEWAY_ENV_TOKEN) return null;
const a = i ? void 0 : normalizeSecretInputString(r);
if (!i && !a) return null;
if (a === t) return null;
const o = `${GATEWAY_ENV_TOKEN} conflicts with gateway.auth.token`;
const s = `${GATEWAY_ENV_TOKEN} is set while gateway.auth.token uses a different configured source. Configured local Gateway clients and the managed gateway service prefer gateway.auth.token. Environment credentials remain active for explicit environment URL and node-host targets, so a stale value can still authenticate against the wrong target.`;
const c = `Remove ${GATEWAY_ENV_TOKEN} from the shell, ~/.openclaw/.env, or launchctl env if gateway.auth.token is intended, or point gateway.auth.token at \${${GATEWAY_ENV_TOKEN}} if the environment variable should supply the token.`;
return {
checkId: "gateway.env_token_overrides_config",
severity: "warn",
title: o,
detail: s,
remediation: c,
diagnostic: `${o}. ${c}`
};
}
//#endregion
export { resolveGatewayAuthTokenSourceConflict as t };