Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check BitstringStatusList credentialStatus. #81

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# bedrock-vc-verifier ChangeLog

## 21.1.0 - 2024-11-dd

### Added
- Support checking `BitstringStatusList` credential status checks.

## 21.0.3 - 2024-08-26

### Fixed
Expand Down
16 changes: 8 additions & 8 deletions lib/di.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
* Copyright (c) 2018-2024 Digital Bazaar, Inc. All rights reserved.
*/
import * as vc from '@digitalbazaar/vc';
import {checkStatus} from './status.js';
import {checkStatus as _checkStatus} from './status.js';
import {createDocumentLoader} from './documentLoader.js';
import {createSuites} from './suites.js';

export async function verifyCredential({config, credential, checks} = {}) {
const documentLoader = await createDocumentLoader({config});
const suite = createSuites();

// only check credential status when option is set
const checkStatus = checks.includes('credentialStatus') ?
_checkStatus : () => ({verified: true});

const result = await vc.verifyCredential({
credential,
documentLoader,
suite,
// only check credential status when option is set
checkStatus: checks.includes('credentialStatus') ?
checkStatus : () => ({verified: true})
checkStatus
});
// if proof should have been checked but wasn't due to an error,
// try to run the check again using the VC's issuance date
Expand All @@ -28,9 +30,7 @@ export async function verifyCredential({config, credential, checks} = {}) {
documentLoader,
suite,
now: new Date(credential.issuanceDate),
// only check credential status when option is set
checkStatus: checks.includes('credentialStatus') ?
checkStatus : () => ({verified: true})
checkStatus
});
if(proofResult.verified) {
// overlay original (failed) results on top of proof results
Expand All @@ -57,7 +57,7 @@ export async function verifyPresentation({
documentLoader: await createDocumentLoader({config}),
suite: createSuites(),
unsignedPresentation: !checks.includes('proof'),
checkStatus
checkStatus: _checkStatus
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this needs the same checkStatus wrapper as above in verifyCredential. Probably need more presentation related tests.

Copy link
Member Author

@dlongley dlongley Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could change it to that, but that would I think change the existing behavior. It's probably more consistent to do it that way and perhaps even a bug that it wasn't behaving that way before, but I'd rather avoid changing it right now in this PR.

};
return vc.verify(verifyOptions);
}
18 changes: 13 additions & 5 deletions lib/status.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
/*!
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2019-2024 Digital Bazaar, Inc. All rights reserved.
*/
import {
checkStatus as bitstringStatusListCheckStatus,
statusTypeMatches as bitstringStatusListStatusTypeMatches
} from '@digitalbazaar/vc-bitstring-status-list';
import {
checkStatus as revocationListCheckStatus,
statusTypeMatches as revocationListStatusTypeMatches
} from '@digitalbazaar/vc-revocation-list';
import {
checkStatus as statusListCheckStatus,
statusTypeMatches as statusListStatusTypeMatches
checkStatus as statusList2020CheckStatus,
statusTypeMatches as statusList2020StatusTypeMatches
} from '@digitalbazaar/vc-status-list';
import assert from 'assert-plus';

const handlerMap = new Map();
handlerMap.set('BitstringStatusListEntry', {
checkStatus: bitstringStatusListCheckStatus,
statusTypeMatches: bitstringStatusListStatusTypeMatches
});
handlerMap.set('RevocationList2020Status', {
checkStatus: revocationListCheckStatus,
statusTypeMatches: revocationListStatusTypeMatches
});
handlerMap.set('StatusList2021Entry', {
checkStatus: statusListCheckStatus,
statusTypeMatches: statusListStatusTypeMatches
checkStatus: statusList2020CheckStatus,
statusTypeMatches: statusList2020StatusTypeMatches
});

export async function checkStatus(options = {}) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@digitalbazaar/eddsa-2022-cryptosuite": "^1.0.0",
"@digitalbazaar/eddsa-rdfc-2022-cryptosuite": "^1.1.0",
"@digitalbazaar/vc": "^7.0.0",
"@digitalbazaar/vc-bitstring-status-list": "^2.0.0",
"@digitalbazaar/vc-revocation-list": "^7.0.0",
"@digitalbazaar/vc-status-list": "^8.0.0",
"assert-plus": "^1.0.0",
Expand Down
Loading