openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.08 kB
JavaScript
import{n as isRedactedSecretValue}from"./redact-sentinel-BwYTpV-q.mjs";
//!src/gateway/known-weak-gateway-secrets.ts
const KNOWN_WEAK_GATEWAY_TOKENS=/* @__PURE__ */ new Set([`change-me-to-a-long-random-token`,`change-me-now`]);const KNOWN_WEAK_GATEWAY_PASSWORDS=/* @__PURE__ */ new Set([`change-me-to-a-strong-password`]);function isInvalidGatewaySecret(e){return typeof e===`string`&&[``,`undefined`,`null`].includes(e.trim())}function getTrustedProxyPasswordRedactionWarning(e){if(e.mode!==`trusted-proxy`||!isRedactedSecretValue(e.password))return;return`Gateway optional password is a known redaction sentinel. Trusted-proxy authentication remains available, but local password fallback is unavailable. Replace or remove gateway.auth.password / OPENCLAW_GATEWAY_PASSWORD and restart the Gateway.`}function assertGatewayAuthNotKnownWeak(e,t,n){if(e.mode!==`token`&&e.mode!==`password`)return;const r=e.mode;const i=e[r]??(r===`token`?t:n);if(isRedactedSecretValue(i))throw new Error(`Gateway auth ${r} is a known redaction sentinel, not a credential. `+(r===`password`?`Replace gateway.auth.password, OPENCLAW_GATEWAY_PASSWORD, or its external secret source with a real password, then restart the Gateway.`:"Run `openclaw doctor --fix` to repair the Gateway token or replace the external secret, then restart and re-pair devices."));const a=r===`token`?KNOWN_WEAK_GATEWAY_TOKENS:KNOWN_WEAK_GATEWAY_PASSWORDS;if(isInvalidGatewaySecret(i)||typeof i===`string`&&a.has(i.trim()))throw new Error(`Invalid config: gateway auth ${r} is blank, a published example placeholder, or the literal string undefined/null. Generate a real secret (for example, \`openssl rand -hex 32\`) and `+(r===`token`?"update gateway.auth.token or its external source. For blank or undefined/null inline tokens, `openclaw doctor --fix --generate-gateway-token` can generate one.":`set OPENCLAW_GATEWAY_PASSWORD or gateway.auth.password (or its external source) before starting the gateway.`))}export{getTrustedProxyPasswordRedactionWarning as n,isInvalidGatewaySecret as r,assertGatewayAuthNotKnownWeak as t};