MCPcopy
hub / github.com/simstudioai/sim / fetchWithDNSPinning

Function fetchWithDNSPinning

apps/sim/lib/webhooks/providers/microsoft-teams.ts:77–101  ·  view source on GitHub ↗
(
  url: string,
  accessToken: string,
  requestId: string
)

Source from the content-addressed store, hash-verified

75}
76
77async function fetchWithDNSPinning(
78 url: string,
79 accessToken: string,
80 requestId: string
81): Promise<SecureFetchResponse | null> {
82 try {
83 const urlValidation = await validateUrlWithDNS(url, 'contentUrl')
84 if (!urlValidation.isValid) {
85 logger.warn(`[${requestId}] Invalid content URL: ${urlValidation.error}`, { url })
86 return null
87 }
88 const headers: Record<string, string> = {}
89 if (accessToken) {
90 headers.Authorization = `Bearer ${accessToken}`
91 }
92 const response = await secureFetchWithPinnedIP(url, urlValidation.resolvedIP!, { headers })
93 return response
94 } catch (error) {
95 logger.error(`[${requestId}] Error fetching URL with DNS pinning`, {
96 error: toError(error).message,
97 url: sanitizeUrlForLog(url),
98 })
99 return null
100 }
101}
102
103/**
104 * Format Microsoft Teams Graph change notification

Callers 1

Calls 6

validateUrlWithDNSFunction · 0.90
secureFetchWithPinnedIPFunction · 0.90
toErrorFunction · 0.90
sanitizeUrlForLogFunction · 0.90
errorMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected