MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getTLSFetchOptions

Function getTLSFetchOptions

source code/utils/mtls.ts:119–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117 * Get fetch options with TLS configuration (mTLS + CA certs) for undici
118 */
119export function getTLSFetchOptions(): {
120 tls?: TLSConfig
121 dispatcher?: undici.Dispatcher
122} {
123 const mtlsConfig = getMTLSConfig()
124 const caCerts = getCACertificates()
125
126 if (!mtlsConfig && !caCerts) {
127 return {}
128 }
129
130 const tlsConfig: TLSConfig = {
131 ...mtlsConfig,
132 ...(caCerts && { ca: caCerts }),
133 }
134
135 if (typeof Bun !== 'undefined') {
136 return { tls: tlsConfig }
137 }
138 logForDebugging('TLS: Created undici agent with custom certificates')
139 // Create a custom undici Agent with TLS options. Lazy-required so that
140 // the ~1.5MB undici package is only loaded when mTLS/CA certs are configured.
141 // eslint-disable-next-line @typescript-eslint/no-require-imports
142 const undiciMod = require('undici') as typeof undici
143 const agent = new undiciMod.Agent({
144 connect: {
145 cert: tlsConfig.cert,
146 key: tlsConfig.key,
147 passphrase: tlsConfig.passphrase,
148 ...(tlsConfig.ca && { ca: tlsConfig.ca }),
149 },
150 pipelining: 1,
151 })
152
153 return { dispatcher: agent }
154}
155
156/**
157 * Clear the mTLS configuration cache.

Callers 2

getProxyFetchOptionsFunction · 0.85
configureGlobalAgentsFunction · 0.85

Calls 1

logForDebuggingFunction · 0.85

Tested by

no test coverage detected