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

Function getVantaAccessToken

apps/sim/tools/vanta/utils.ts:221–246  ·  view source on GitHub ↗
(
  params: VantaTokenParams,
  options?: { forceRefresh?: boolean }
)

Source from the content-addressed store, hash-verified

219 * flight, since that exchange yields an equally fresh token.
220 */
221export async function getVantaAccessToken(
222 params: VantaTokenParams,
223 options?: { forceRefresh?: boolean }
224): Promise<string> {
225 const cacheKey = await vantaTokenCacheKey(params)
226 if (!options?.forceRefresh) {
227 const cached = vantaTokenCache.get(cacheKey)
228 if (cached && cached.expiresAt > Date.now()) {
229 return cached.token
230 }
231 }
232
233 const inFlight = vantaTokenExchanges.get(cacheKey)
234 if (inFlight) {
235 return inFlight
236 }
237
238 vantaTokenCache.delete(cacheKey)
239 const exchange = exchangeVantaToken(params, cacheKey)
240 vantaTokenExchanges.set(cacheKey, exchange)
241 try {
242 return await exchange
243 } finally {
244 vantaTokenExchanges.delete(cacheKey)
245 }
246}
247
248/**
249 * Performs an authenticated Vanta API request. When the request comes back

Callers 1

fetchVantaWithAuthFunction · 0.85

Calls 5

vantaTokenCacheKeyFunction · 0.85
exchangeVantaTokenFunction · 0.85
getMethod · 0.65
deleteMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected