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

Function getBridgeSession

source code/bridge/createSession.ts:192–246  ·  view source on GitHub ↗
(
  sessionId: string,
  opts?: { baseUrl?: string; getAccessToken?: () => string | undefined },
)

Source from the content-addressed store, hash-verified

190 * makes the Sessions API return 404.
191 */
192export async function getBridgeSession(
193 sessionId: string,
194 opts?: { baseUrl?: string; getAccessToken?: () => string | undefined },
195): Promise<{ environment_id?: string; title?: string } | null> {
196 const { getClaudeAIOAuthTokens } = await import('../utils/auth.js')
197 const { getOrganizationUUID } = await import('../services/oauth/client.js')
198 const { getOauthConfig } = await import('../constants/oauth.js')
199 const { getOAuthHeaders } = await import('../utils/teleport/api.js')
200 const { default: axios } = await import('axios')
201
202 const accessToken =
203 opts?.getAccessToken?.() ?? getClaudeAIOAuthTokens()?.accessToken
204 if (!accessToken) {
205 logForDebugging('[bridge] No access token for session fetch')
206 return null
207 }
208
209 const orgUUID = await getOrganizationUUID()
210 if (!orgUUID) {
211 logForDebugging('[bridge] No org UUID for session fetch')
212 return null
213 }
214
215 const headers = {
216 ...getOAuthHeaders(accessToken),
217 'anthropic-beta': 'ccr-byoc-2025-07-29',
218 'x-organization-uuid': orgUUID,
219 }
220
221 const url = `${opts?.baseUrl ?? getOauthConfig().BASE_API_URL}/v1/sessions/${sessionId}`
222 logForDebugging(`[bridge] Fetching session ${sessionId}`)
223
224 let response
225 try {
226 response = await axios.get<{ environment_id?: string; title?: string }>(
227 url,
228 { headers, timeout: 10_000, validateStatus: s => s < 500 },
229 )
230 } catch (err: unknown) {
231 logForDebugging(
232 `[bridge] Session fetch request failed: ${errorMessage(err)}`,
233 )
234 return null
235 }
236
237 if (response.status !== 200) {
238 const detail = extractErrorDetail(response.data)
239 logForDebugging(
240 `[bridge] Session fetch failed with status ${response.status}${detail ? `: ${detail}` : ''}`,
241 )
242 return null
243 }
244
245 return response.data
246}
247
248/**
249 * Archive a bridge session via POST /v1/sessions/{id}/archive.

Callers 2

fetchSessionTitleFunction · 0.85
bridgeMainFunction · 0.85

Calls 6

logForDebuggingFunction · 0.85
getOrganizationUUIDFunction · 0.85
getOAuthHeadersFunction · 0.85
getOauthConfigFunction · 0.85
extractErrorDetailFunction · 0.85
errorMessageFunction · 0.50

Tested by

no test coverage detected