()
| 22 | * @throws McpSsrfError if a request URL resolves to a blocked IP address |
| 23 | */ |
| 24 | export function createSsrfGuardedMcpFetch(): FetchLike { |
| 25 | return (async (url, init) => { |
| 26 | const target = typeof url === 'string' ? url : url.href |
| 27 | const resolvedIP = await validateMcpServerSsrf(target) |
| 28 | const pinnedFetch: FetchLike = resolvedIP ? createPinnedFetch(resolvedIP) : globalThis.fetch |
| 29 | return pinnedFetch(url, init) |
| 30 | }) satisfies FetchLike |
| 31 | } |
no test coverage detected