Skip to content

Commit

Permalink
fix: changed the logic for getting validFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
sksadjad committed Feb 29, 2024
1 parent 5ed1003 commit 7a7940b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ describe('Database entities tests', (): void => {
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
})
expect(digitalCredential.credentialType).toEqual(CredentialType.VP)
expect(digitalCredential.validFrom).toEqual(new Date('2018-09-14T21:19:10.000Z'))
expect(digitalCredential.validFrom).toEqual(undefined)
expect(digitalCredential.documentFormat).toEqual(CredentialDocumentFormat.JSON_LD)
expect(digitalCredential.validUntil).toEqual(undefined)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
CredentialMapper,
decodeSdJwtVc,
DocumentFormat,
IProof,
IVerifiableCredential,
IVerifiablePresentation,
OriginalVerifiableCredential,
Expand Down Expand Up @@ -73,14 +72,8 @@ function getValidUntil(uniformDocument: IVerifiableCredential | IVerifiablePrese
}

function getValidFrom(uniformDocument: IVerifiableCredential | IVerifiablePresentation | SdJwtDecodedVerifiableCredentialPayload): Date | undefined {
let proof: IProof | undefined = undefined
if (uniformDocument.proof && !uniformDocument.vct) {
proof = Array.isArray(uniformDocument.proof) ? <IProof>uniformDocument.proof[0] : <IProof>uniformDocument.proof
}
if ('issuanceDate' in uniformDocument) {
return new Date(uniformDocument.issuanceDate)
} else if (proof && proof.created) {
return new Date(proof.created)
} else if ('validFrom' in uniformDocument) {
return new Date(uniformDocument['validFrom'])
} else if ('nbf' in uniformDocument) {
Expand Down

0 comments on commit 7a7940b

Please sign in to comment.