MCPcopy Index your code
hub / github.com/codeaashu/claude-code / startUpstreamProxyRelay

Function startUpstreamProxyRelay

src/upstreamproxy/relay.ts:155–174  ·  view source on GitHub ↗
(opts: {
  wsUrl: string
  sessionId: string
  token: string
})

Source from the content-addressed store, hash-verified

153 * container runs the CLI under Node, not Bun.
154 */
155export async function startUpstreamProxyRelay(opts: {
156 wsUrl: string
157 sessionId: string
158 token: string
159}): Promise<UpstreamProxyRelay> {
160 const authHeader =
161 'Basic ' + Buffer.from(`${opts.sessionId}:${opts.token}`).toString('base64')
162 // WS upgrade itself is auth-gated (proto authn: PRIVATE_API) — the gateway
163 // wants the session-ingress JWT on the upgrade request, separate from the
164 // Proxy-Authorization that rides inside the tunneled CONNECT.
165 const wsAuthHeader = `Bearer ${opts.token}`
166
167 const relay =
168 typeof Bun !== 'undefined'
169 ? startBunRelay(opts.wsUrl, authHeader, wsAuthHeader)
170 : await startNodeRelay(opts.wsUrl, authHeader, wsAuthHeader)
171
172 logForDebugging(`[upstreamproxy] relay listening on 127.0.0.1:${relay.port}`)
173 return relay
174}
175
176function startBunRelay(
177 wsUrl: string,

Callers 1

initUpstreamProxyFunction · 0.85

Calls 4

startBunRelayFunction · 0.85
startNodeRelayFunction · 0.85
logForDebuggingFunction · 0.85
toStringMethod · 0.65

Tested by

no test coverage detected