UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.21 kB
import path from"node:path"; //!src/secrets/egress-proxy/environment.ts function createSecretEgressProxyEnvironment(e,t){return{HTTPS_PROXY:e,HTTP_PROXY:e,NODE_USE_ENV_PROXY:`1`,NODE_EXTRA_CA_CERTS:t,SSL_CERT_FILE:t,CURL_CA_BUNDLE:t,REQUESTS_CA_BUNDLE:t,GIT_SSL_CAINFO:t}}const SECRET_EGRESS_PROXY_ENV_KEYS=new Set(Object.keys(createSecretEgressProxyEnvironment(``,``)));function isSecretEgressProxyEnv(e,t,n=process.platform){const r=e[t];const i=n===`win32`?t.toUpperCase():t;if(!r||!SECRET_EGRESS_PROXY_ENV_KEYS.has(i))return false;if(i===`NODE_USE_ENV_PROXY`){const t=Object.keys(e).filter(t=>/^https?_proxy$/iu.test(t)&&e[t]);return r===`1`&&t.length>0&&t.every(t=>isSecretEgressProxyEnv(e,t,n))}if(i.endsWith(`_PROXY`))return URL.canParse(r)&&/^http:\/\/openclaw:[\w-]+@127\.0\.0\.1:\d+\/?$/u.test(r);const a=(n===`win32`?path.win32:path.posix).resolve(r);return/(?:^|[\\/])secret-egress-proxy[\\/]gateway-[^\\/]+[\\/].+/u.test(a)}function omitSecretEgressProxyEnvironment(e,t=process.platform){return Object.fromEntries(Object.entries(e).filter(([n])=>!isSecretEgressProxyEnv(e,n,t)))}export{isSecretEgressProxyEnv as n,omitSecretEgressProxyEnvironment as r,createSecretEgressProxyEnvironment as t};