export function assertIsJwk()

in src/jwk.ts [99:121]


export function assertIsJwk(jwk: Json): asserts jwk is Jwk {
  if (!jwk) {
    throw new JwkValidationError("JWK empty");
  }
  if (!isJsonObject(jwk)) {
    throw new JwkValidationError("JWK should be an object");
  }

  for (const field of mandatoryJwkFieldNames) {
    // disable eslint rule because `field` is trusted
    // eslint-disable-next-line security/detect-object-injection
    if (typeof jwk[field] !== "string") {
      throw new JwkValidationError(`JWK ${field} should be a string`);
    }
  }
  for (const field of optionalJwkFieldNames) {
    // disable eslint rule because `field` is trusted
    // eslint-disable-next-line security/detect-object-injection
    if (field in jwk && typeof jwk[field] !== "string") {
      throw new JwkValidationError(`JWK ${field} should be a string`);
    }
  }
}