MCPcopy
hub / github.com/CodebuffAI/codebuff / lookupIpinfoPrivacy

Function lookupIpinfoPrivacy

web/src/server/free-mode-country.ts:383–407  ·  view source on GitHub ↗
(params: {
  ip: string
  token: string
  fetch: typeof globalThis.fetch
})

Source from the content-addressed store, hash-verified

381}
382
383export async function lookupIpinfoPrivacy(params: {
384 ip: string
385 token: string
386 fetch: typeof globalThis.fetch
387}): Promise<FreeModeIpPrivacy | null> {
388 const cached = ipinfoPrivacyCache.get(params.ip)
389 if (cached && cached.expiresAt > Date.now()) {
390 return cached.privacy
391 }
392
393 const response = await params.fetch(
394 `https://api.ipinfo.io/lookup/${encodeURIComponent(params.ip)}?token=${encodeURIComponent(params.token)}`,
395 )
396 if (!response.ok) {
397 return null
398 }
399
400 const data = (await response.json()) as Record<string, unknown>
401 const signals = privacySignalsFromIpinfo(data)
402 const privacy = {
403 signals,
404 }
405 setIpinfoPrivacyCache(params.ip, privacy)
406 return privacy
407}
408
409export async function lookupSpurIpPrivacy(params: {
410 ip: string

Callers 2

getFreeModeCountryAccessFunction · 0.85

Calls 3

privacySignalsFromIpinfoFunction · 0.85
setIpinfoPrivacyCacheFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected