All files / src/domain/verifier/useCases getDatesToValidate.ts

100% Statements 6/6
100% Branches 4/4
100% Functions 0/0
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                32x   29x             19x           32x     34x             32x    
import type { BlockcertsV3 } from '../../../models/BlockcertsV3';
 
export interface DatesToValidate {
  property: string;
  dateTimeStamp: string;
}
 
export default function getDatesToValidate (credential: BlockcertsV3): DatesToValidate[] {
  const dates: DatesToValidate[] = [];
  if (credential.validFrom) {
    dates.push({
      property: 'validFrom',
      dateTimeStamp: credential.validFrom
    });
  }
 
  if (credential.validUntil) {
    dates.push({
      property: 'validUntil',
      dateTimeStamp: credential.validUntil
    });
  }
 
  const proof = !Array.isArray(credential.proof) ? [credential.proof] : credential.proof;
  for (const proofItem of proof) {
    if (proofItem.created) {
      dates.push({
        property: `proof ${proofItem.cryptosuite ?? proofItem.type} created`,
        dateTimeStamp: proofItem.created
      });
    }
  }
 
  return dates;
}