(key: string, token: CachedToken)
| 50 | } |
| 51 | |
| 52 | function rememberToken(key: string, token: CachedToken): void { |
| 53 | if (TOKEN_CACHE.has(key)) TOKEN_CACHE.delete(key) |
| 54 | TOKEN_CACHE.set(key, token) |
| 55 | while (TOKEN_CACHE.size > TOKEN_CACHE_MAX_ENTRIES) { |
| 56 | const oldestKey = TOKEN_CACHE.keys().next().value |
| 57 | if (oldestKey === undefined) break |
| 58 | TOKEN_CACHE.delete(oldestKey) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | async function fetchAccessToken(req: ProxyRequest, requestId: string): Promise<string> { |
| 63 | const cacheKey = tokenCacheKey(req) |
no test coverage detected