22 * Copyright (c) 2018-2024 Digital Bazaar, Inc. All rights reserved.
33 */
44import * as vc from '@digitalbazaar/vc' ;
5- import { checkStatus } from './status.js' ;
5+ import { checkStatus as _checkStatus } from './status.js' ;
66import { createDocumentLoader } from './documentLoader.js' ;
77import { createSuites } from './suites.js' ;
88
99export async function verifyCredential ( { config, credential, checks} = { } ) {
1010 const documentLoader = await createDocumentLoader ( { config} ) ;
1111 const suite = createSuites ( ) ;
1212
13+ // only check credential status when option is set
14+ const checkStatus = checks . includes ( 'credentialStatus' ) ?
15+ _checkStatus : undefined ;
16+
1317 const result = await vc . verifyCredential ( {
1418 credential,
1519 documentLoader,
1620 suite,
17- // only check credential status when option is set
18- checkStatus : checks . includes ( 'credentialStatus' ) ?
19- checkStatus : ( ) => ( { verified : true } )
21+ checkStatus
2022 } ) ;
2123 // if proof should have been checked but wasn't due to an error,
2224 // try to run the check again using the VC's issuance date
@@ -28,9 +30,7 @@ export async function verifyCredential({config, credential, checks} = {}) {
2830 documentLoader,
2931 suite,
3032 now : new Date ( credential . issuanceDate ) ,
31- // only check credential status when option is set
32- checkStatus : checks . includes ( 'credentialStatus' ) ?
33- checkStatus : ( ) => ( { verified : true } )
33+ checkStatus
3434 } ) ;
3535 if ( proofResult . verified ) {
3636 // overlay original (failed) results on top of proof results
@@ -57,7 +57,7 @@ export async function verifyPresentation({
5757 documentLoader : await createDocumentLoader ( { config} ) ,
5858 suite : createSuites ( ) ,
5959 unsignedPresentation : ! checks . includes ( 'proof' ) ,
60- checkStatus
60+ checkStatus : _checkStatus
6161 } ;
6262 return vc . verify ( verifyOptions ) ;
6363}
0 commit comments