public getCachedJwk()

in src/jwk.ts [217:237]


  public getCachedJwk(jwksUri: string, decomposedJwt: DecomposedJwt): Jwk {
    if (typeof decomposedJwt.header.kid !== "string") {
      throw new JwtWithoutValidKidError(
        "JWT header does not have valid kid claim"
      );
    }
    if (!this.jwksCache.has(jwksUri)) {
      throw new JwksNotAvailableInCacheError(
        `JWKS for uri ${jwksUri} not yet available in cache`
      );
    }
    const jwk = this.jwksCache
      .get(jwksUri)!
      .keys.find((key) => key.kid === decomposedJwt.header.kid);
    if (!jwk) {
      throw new KidNotFoundInJwksError(
        `JWK for kid ${decomposedJwt.header.kid} not found in the JWKS`
      );
    }
    return jwk;
  }