openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.32 kB
JavaScript
import{r as defaultRuntime}from"./runtime-DIcLIHcp.mjs";import{a as isConfigReadFailure,n as createConfigReadError}from"./io.invalid-config-B2POcxOa.mjs";import{s as readConfigFileSnapshot}from"./io.runtime-BvSeVFIY.mjs";import"./config-DkZ8y8Gv.mjs";import{r as resolveGatewayAuth}from"./auth-resolve-UwT9_UjV.mjs";import{t as assertGatewayAuthNotKnownWeak}from"./known-weak-gateway-secrets-CjFHNxY3.mjs";import"./auth-BwgQGI6W.mjs";import{t as assertExplicitGatewayAuthModeWhenBothConfigured}from"./auth-mode-policy-BwBhFxiZ.mjs";import{r as isTerminalInteractive}from"./terminal-interactivity-ijJuF5PT.mjs";import{t as resolveCommandSecretRefsViaGateway}from"./command-secret-gateway-DRP7S338.mjs";
//!src/commands/gateway-auth-token.ts
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({observe:false,pluginValidation:`core-only`});if(!t.valid){if(isConfigReadFailure(t))throw createConfigReadError(t);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`)}export{gatewayAuthTokenCommand};