UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

40 lines (39 loc) • 1.51 kB
import { l as normalizeOptionalString } from "./string-coerce-6kR-86XC.mjs"; import { r as defaultRuntime } from "./runtime-BC29JSZp.mjs"; import { t as readSecretFromFile } from "./secret-file-2smgWNRI.mjs"; //#region src/cli/gateway-secret-options.ts function resolveGatewaySecretOption(params) { const direct = normalizeOptionalString(params.direct); const file = normalizeOptionalString(params.file); if (direct && file) throw new Error(`Use either ${params.directFlag} or ${params.fileFlag} for ${params.label}.`); if (file) return readSecretFromFile(file, params.label); return direct || void 0; } function warnGatewaySecretCliFlag(flag) { defaultRuntime.error(`Warning: ${flag} can be exposed via process listings. Prefer ${flag}-file or environment variables.`); } /** Normalize gateway token/password options and reject ambiguous direct+file pairs. */ function resolveGatewayAuthOptions(opts) { const gatewayToken = resolveGatewaySecretOption({ direct: opts.token, file: opts.tokenFile, directFlag: "--token", fileFlag: "--token-file", label: "Gateway token" }); const gatewayPassword = resolveGatewaySecretOption({ direct: opts.password, file: opts.passwordFile, directFlag: "--password", fileFlag: "--password-file", label: "Gateway password" }); if (opts.token) warnGatewaySecretCliFlag("--token"); if (opts.password) warnGatewaySecretCliFlag("--password"); return { gatewayToken, gatewayPassword }; } //#endregion export { resolveGatewayAuthOptions as t };