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

Function lookupSpurIpPrivacy

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

Source from the content-addressed store, hash-verified

407}
408
409export async function lookupSpurIpPrivacy(params: {
410 ip: string
411 token: string
412 fetch: typeof globalThis.fetch
413}): Promise<FreeModeIpPrivacy | null> {
414 const cached = spurPrivacyCache.get(params.ip)
415 if (cached && cached.expiresAt > Date.now()) {
416 return cached.privacy
417 }
418
419 const response = await params.fetch(
420 `https://api.spur.us/v2/context/${encodeURIComponent(params.ip)}`,
421 {
422 headers: {
423 Token: params.token,
424 },
425 },
426 )
427 if (!response.ok) {
428 return null
429 }
430
431 const data = (await response.json()) as Record<string, unknown>
432 const privacy = {
433 signals: privacySignalsFromSpur(data),
434 }
435 setSpurPrivacyCache(params.ip, privacy)
436 return privacy
437}
438
439async function lookupSpurPrivacyStatus(
440 clientIp: string,

Callers 2

lookupSpurPrivacyStatusFunction · 0.85

Calls 3

privacySignalsFromSpurFunction · 0.85
setSpurPrivacyCacheFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected