UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.5 kB
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{r as resolveGatewayAuth}from"./auth-resolve-UwT9_UjV.mjs";import"./auth-BwgQGI6W.mjs";import{r as materializeGatewayAuthSecretRefs,t as canMaterializeGatewayAuthSecretRefsWithoutExec}from"./auth-config-utils-DPL9FCGM.mjs";import{t as randomToken}from"./random-token-CWOnwMog.mjs"; //!src/commands/doctor/shared/hooks-token-reuse-repair.ts async function repairHooksTokenReuseGatewayAuth(e,t=process.env,n=randomToken){const r=normalizeOptionalString(e.hooks?.token)??``;if(e.hooks?.enabled!==true||!r)return{config:e,changes:[]};const i={cfg:e,env:t,mode:e.gateway?.auth?.mode,hasTokenOverride:false,hasPasswordOverride:false,hasTokenFallback:Boolean(normalizeOptionalString(t.OPENCLAW_GATEWAY_TOKEN)),hasPasswordFallback:Boolean(normalizeOptionalString(t.OPENCLAW_GATEWAY_PASSWORD))};const a=await(canMaterializeGatewayAuthSecretRefsWithoutExec(i)?materializeGatewayAuthSecretRefs(i).catch(()=>e):e);const o=resolveGatewayAuth({authConfig:a.gateway?.auth,tailscaleMode:a.gateway?.tailscale?.mode??`off`,env:t});const s=o.mode===`token`?o.token:o.mode===`password`||o.mode===`trusted-proxy`?o.password:void 0;if(r!==(normalizeOptionalString(s)??``))return{config:e,changes:[]};const c=n();return{config:{...e,hooks:{...e.hooks,token:c}},changes:[`Rotated hooks.token because it reused active Gateway shared-secret auth. Update external hook senders to use the new hooks.token.`]}}export{repairHooksTokenReuseGatewayAuth};