()
| 127 | let inflight: Promise<CacheEntry> | null = null; |
| 128 | |
| 129 | const refresh = (): Promise<CacheEntry> => { |
| 130 | if (inflight) return inflight; |
| 131 | inflight = (async () => { |
| 132 | const jwks = await fetchJwksOnce(url, fetchImpl(), timeoutMs); |
| 133 | const next: CacheEntry = { |
| 134 | jwks, |
| 135 | fetchedAt: Date.now(), |
| 136 | resolver: createLocalJWKSet(jwks), |
| 137 | }; |
| 138 | entry = next; |
| 139 | return next; |
| 140 | })().finally(() => { |
| 141 | inflight = null; |
| 142 | }); |
| 143 | return inflight; |
| 144 | }; |
| 145 | |
| 146 | const ensureFresh = async (forceRefresh: boolean): Promise<CacheEntry> => { |
| 147 | if (forceRefresh) return refresh(); |
no test coverage detected