UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines • 1.93 kB
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{n as getActiveManagedProxyTlsOptions,r as getActiveManagedProxyUrl}from"./active-proxy-state-ud7hrGsU.mjs";import{s as resolveEnvHttpProxyUrl}from"./proxy-env-C0Jh7bHZ.mjs";import{readFileSync}from"node:fs";import{readFile as readFile$1}from"node:fs/promises"; //!src/infra/net/proxy/proxy-tls.ts function resolveManagedProxyCaFileForUrl(e){if(!e.proxyUrl||URL.parse(e.proxyUrl)?.protocol!==`https:`)return;return normalizeOptionalString(e.caFileOverride)??normalizeOptionalString(e.config?.tls?.caFile)}async function loadManagedProxyTlsOptions(e){if(!e)return;try{return{ca:await readFile$1(e,`utf8`)}}catch(t){throw new Error(`proxy CA file could not be read (${e}): ${formatErrorMessage(t)}`,{cause:t})}}function loadManagedProxyTlsOptionsSync(e){if(!e)return;try{return{ca:readFileSync(e,`utf8`)}}catch(t){throw new Error(`proxy CA file could not be read (${e}): ${formatErrorMessage(t)}`,{cause:t})}} //!src/infra/net/proxy/active-managed-proxy-tls.ts function normalizeProxyUrl(e){return e?URL.parse(e)?.href:void 0}function resolveManagedProxyUrl(e=process.env){const t=getActiveManagedProxyUrl();if(t)return t.href;if(e.OPENCLAW_PROXY_ACTIVE!==`1`)return;return normalizeProxyUrl(resolveEnvHttpProxyUrl(`https`,e))}function resolveActiveManagedProxyTlsOptions(e){const t=e?.env??process.env;const n=resolveManagedProxyUrl(t);const r=normalizeProxyUrl(e?.proxyUrl??resolveEnvHttpProxyUrl(`https`,t));if(!n||r!==n)return;const i=getActiveManagedProxyTlsOptions();if(i)return i;const a=resolveManagedProxyCaFileForUrl({proxyUrl:n,caFileOverride:t.OPENCLAW_PROXY_CA_FILE});try{return loadManagedProxyTlsOptionsSync(a)}catch{return}}export{resolveManagedProxyCaFileForUrl as i,loadManagedProxyTlsOptions as n,loadManagedProxyTlsOptionsSync as r,resolveActiveManagedProxyTlsOptions as t};