(endpoint: string)
| 407 | }; |
| 408 | |
| 409 | const discoverProtectedResource = async (endpoint: string): Promise<string | null> => { |
| 410 | for (const url of protectedResourceMetadataUrls(endpoint)) { |
| 411 | try { |
| 412 | const response = await fetch(url, { |
| 413 | headers: { accept: "application/json" }, |
| 414 | signal: AbortSignal.timeout(5_000), |
| 415 | }); |
| 416 | if (!response.ok) continue; |
| 417 | const json = (await response.json()) as unknown; |
| 418 | if (!isObjectRecord(json) || typeof json.resource !== "string") continue; |
| 419 | if (resourceMatchesEndpoint(json.resource, endpoint)) return json.resource; |
| 420 | } catch { |
| 421 | continue; |
| 422 | } |
| 423 | } |
| 424 | return null; |
| 425 | }; |
| 426 | |
| 427 | const discoverMcpOAuthResourceOverrides = async ( |
| 428 | bindings: readonly Row[], |
no test coverage detected