in src/jwk.ts [197:215]
public async getJwks(jwksUri: string): Promise<Jwks> {
const existingFetch = this.fetchingJwks.get(jwksUri);
if (existingFetch) {
return existingFetch;
}
const jwksPromise = this.fetcher.fetch(jwksUri).then((res) => {
assertIsJwks(res);
return res;
});
this.fetchingJwks.set(jwksUri, jwksPromise);
let jwks: Jwks;
try {
jwks = await jwksPromise;
} finally {
this.fetchingJwks.delete(jwksUri);
}
this.jwksCache.set(jwksUri, jwks);
return jwks;
}