export function assertIsJwks()

in src/jwk.ts [81:97]


export function assertIsJwks(jwks: Json): asserts jwks is Jwks {
  if (!jwks) {
    throw new JwksValidationError("JWKS empty");
  }
  if (!isJsonObject(jwks)) {
    throw new JwksValidationError("JWKS should be an object");
  }
  if (!Object.keys(jwks).includes("keys")) {
    throw new JwksValidationError("JWKS does not include keys");
  }
  if (!Array.isArray((jwks as { keys: Json }).keys)) {
    throw new JwksValidationError("JWKS keys should be an array");
  }
  for (const jwk of (jwks as { keys: Json[] }).keys) {
    assertIsJwk(jwk);
  }
}