MCPcopy Index your code
hub / github.com/simstudioai/sim / createPinnedFetch

Function createPinnedFetch

apps/sim/lib/core/security/input-validation.server.ts:434–448  ·  view source on GitHub ↗
(resolvedIP: string)

Source from the content-addressed store, hash-verified

432 * calls (e.g. a provider tool loop) reuse its keep-alive connections.
433 */
434export function createPinnedFetch(resolvedIP: string): typeof fetch {
435 const dispatcher = new Agent({ connect: { lookup: createPinnedLookup(resolvedIP) } })
436
437 const pinned = async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
438 // double-cast-allowed: DOM RequestInfo/URL and undici fetch input types differ but are structurally compatible at runtime (Node's global fetch IS undici)
439 const undiciInput = input as unknown as Parameters<typeof undiciFetch>[0]
440 // double-cast-allowed: DOM RequestInit and undici RequestInit are structurally compatible at runtime but the TS types differ
441 const undiciInit: UndiciRequestInit = { ...(init as unknown as UndiciRequestInit), dispatcher }
442 const response = await undiciFetch(undiciInput, undiciInit)
443 // double-cast-allowed: undici Response and DOM Response are structurally compatible at runtime
444 return response as unknown as Response
445 }
446
447 return pinned
448}
449
450/**
451 * Performs a fetch with IP pinning to prevent DNS rebinding attacks.

Callers 7

index.tsFile · 0.90
index.tsFile · 0.90
index.tsFile · 0.90
constructorMethod · 0.90
detectMcpAuthTypeFunction · 0.90

Calls 1

createPinnedLookupFunction · 0.85

Tested by

no test coverage detected