{"size": 701, "ext": "js", "max_stars_repo_path": "src/domain/verifier/useCases/getRevokedAssertions.js", "max_stars_repo_name": "davidlj95/cert-verifier-js", "max_stars_repo_stars_event_min_datetime": "2019-03-14T11:15:26.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-14T11:15:26.000Z", "max_issues_repo_path": "src/domain/verifier/useCases/getRevokedAssertions.js", "max_issues_repo_name": "davidlj95/cert-verifier-js", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/domain/verifier/useCases/getRevokedAssertions.js", "max_forks_repo_name": "davidlj95/cert-verifier-js", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.8636363636, "max_line_length": 72, "alphanum_fraction": 0.6990014265}
import { request } from '../../../services';
import { VerifierError } from '../../../models';
import { SUB_STEPS } from '../../../constants';
import { getText } from '../../i18n/useCases';

export default async function getRevokedAssertions (revocationListUrl) {
  if (!revocationListUrl) {
    return Promise.resolve([]);
  }

  const errorMessage = getText('errors', 'getRevokedAssertions');

  const response = await request({url: revocationListUrl}).catch(() => {
    throw new VerifierError(SUB_STEPS.parseIssuerKeys, errorMessage);
  });

  let issuerRevocationJson = JSON.parse(response);
  return issuerRevocationJson.revokedAssertions
    ? issuerRevocationJson.revokedAssertions
    : [];
}
