Skip to content

Commit 7037ec0

Browse files
committed
Add BitstringStatusList credential status checking.
1 parent a87567e commit 7037ec0

File tree

4 files changed

+143
-293
lines changed

4 files changed

+143
-293
lines changed

lib/di.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
* Copyright (c) 2018-2024 Digital Bazaar, Inc. All rights reserved.
33
*/
44
import * as vc from '@digitalbazaar/vc';
5-
import {checkStatus} from './status.js';
5+
import {checkStatus as _checkStatus} from './status.js';
66
import {createDocumentLoader} from './documentLoader.js';
77
import {createSuites} from './suites.js';
88

99
export 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
}

lib/status.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
/*!
2-
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2019-2024 Digital Bazaar, Inc. All rights reserved.
33
*/
4+
import {
5+
checkStatus as bitstringStatusListCheckStatus,
6+
statusTypeMatches as bitstringStatusListStatusTypeMatches
7+
} from '@digitalbazaar/vc-bitstring-status-list';
48
import {
59
checkStatus as revocationListCheckStatus,
610
statusTypeMatches as revocationListStatusTypeMatches
711
} from '@digitalbazaar/vc-revocation-list';
812
import {
9-
checkStatus as statusListCheckStatus,
10-
statusTypeMatches as statusListStatusTypeMatches
13+
checkStatus as statusList2020CheckStatus,
14+
statusTypeMatches as statusList2020StatusTypeMatches
1115
} from '@digitalbazaar/vc-status-list';
1216
import assert from 'assert-plus';
1317

1418
const handlerMap = new Map();
19+
handlerMap.set('BitstringStatusListEntry', {
20+
checkStatus: bitstringStatusListCheckStatus,
21+
statusTypeMatches: bitstringStatusListStatusTypeMatches
22+
});
1523
handlerMap.set('RevocationList2020Status', {
1624
checkStatus: revocationListCheckStatus,
1725
statusTypeMatches: revocationListStatusTypeMatches
1826
});
1927
handlerMap.set('StatusList2021Entry', {
20-
checkStatus: statusListCheckStatus,
21-
statusTypeMatches: statusListStatusTypeMatches
28+
checkStatus: statusList2020CheckStatus,
29+
statusTypeMatches: statusList2020StatusTypeMatches
2230
});
2331

2432
export async function checkStatus(options = {}) {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@digitalbazaar/eddsa-2022-cryptosuite": "^1.0.0",
3838
"@digitalbazaar/eddsa-rdfc-2022-cryptosuite": "^1.1.0",
3939
"@digitalbazaar/vc": "^7.0.0",
40+
"@digitalbazaar/vc-bitstring-status-list": "^2.0.0",
4041
"@digitalbazaar/vc-revocation-list": "^7.0.0",
4142
"@digitalbazaar/vc-status-list": "^8.0.0",
4243
"assert-plus": "^1.0.0",

0 commit comments

Comments
 (0)