UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

44 lines (43 loc) • 2.4 kB
import { r as defaultRuntime } from "./runtime-B-SLYP-m.mjs"; import { s as readConfigFileSnapshot } from "./io.runtime-DsJ2dLCQ.mjs"; import "./config-CMA-J084.mjs"; import { t as assertGatewayAuthNotKnownWeak } from "./known-weak-gateway-secrets-DrP6ACfl.mjs"; import { r as resolveGatewayAuth } from "./auth-resolve-C6_i-P4T.mjs"; import "./auth-dV1bLOjr.mjs"; import { t as assertExplicitGatewayAuthModeWhenBothConfigured } from "./auth-mode-policy-Dn8RauUH.mjs"; import { r as isTerminalInteractive } from "./terminal-interactivity-B_L_vZTP.mjs"; import { t as resolveCommandSecretRefsViaGateway } from "./command-secret-gateway-Dh_PhH7v.mjs"; //#region src/commands/gateway-auth-token.ts /** Reveal the configured shared Gateway token only to an explicitly interactive operator. */ async function gatewayAuthTokenCommand(e = defaultRuntime) { if (!isTerminalInteractive()) throw new Error("Refusing to print the Gateway token outside an interactive terminal. Run `openclaw gateway auth-token --show` directly in a terminal on the Gateway host."); const t = await readConfigFileSnapshot(); if (!t.valid) throw new Error("Gateway config is invalid. Run `openclaw doctor --fix`, then try again."); const n = t.sourceConfig ?? t.config; if (n.gateway?.mode === "remote") throw new Error("This command must run on the Gateway host; the current config is in remote mode."); const r = process.env; assertExplicitGatewayAuthModeWhenBothConfigured(n); const i = resolveGatewayAuth({ authConfig: n.gateway?.auth, env: r, tailscaleMode: n.gateway?.tailscale?.mode }); if (i.mode !== "token") throw new Error(`Gateway auth mode is ${i.mode}; there is no active shared token to reveal.`); const { resolvedConfig: a } = await resolveCommandSecretRefsViaGateway({ config: n, commandName: "gateway auth-token", targetIds: /* @__PURE__ */ new Set(["gateway.auth.token"]), mode: "enforce_resolved", allowedPaths: /* @__PURE__ */ new Set(["gateway.auth.token"]) }); const o = resolveGatewayAuth({ authConfig: a.gateway?.auth, env: r, tailscaleMode: a.gateway?.tailscale?.mode }); if (o.mode !== "token" || !o.token) throw new Error("No configured Gateway token is available. Run `openclaw doctor --generate-gateway-token`, restart the Gateway, then try again."); assertGatewayAuthNotKnownWeak(o); e.writeStdout(`${o.token}\n`); } //#endregion export { gatewayAuthTokenCommand };