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

Add verification event log mechanism to verify() operation (for fine-grained UI) #92

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 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
22 changes: 21 additions & 1 deletion lib/vc.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,22 @@ async function verifyCredential(options = {}) {
}
return _verifyCredential(options);
} catch(error) {
const result_array = [];
Copy link
Contributor

@dmitrizagidulin dmitrizagidulin Feb 24, 2021

Choose a reason for hiding this comment

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

Couple of comments here.
One, please rename result_array to log.

Two, move log into the results array's object, on the same level as credential, verified, etc.

result_array.push({
id: 'check_credential_required_field',
valid: false,
error,
result: {
verified: false,
results: [{credential, verified: false, error}],
error
},
});
return {
verified: false,
results: [{credential, verified: false, error}],
error
error,
result_array,
};
}
}
Expand Down Expand Up @@ -261,6 +273,8 @@ async function _verifyCredential(options = {}) {
'"credentialStatus".');
}

const result_array = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to log

result_array.push({id: 'check_credential_required_field', valid: true});
const documentLoader = options.documentLoader || defaultDocumentLoader;

const {controller} = options;
Expand All @@ -273,16 +287,22 @@ async function _verifyCredential(options = {}) {

// if verification has already failed, skip status check
if(!result.verified) {
result_array.push({id: 'verifies_data_signature_on_document', valid: false, error: result.results, result});
result.result_array = result_array;
return result;
}
result_array.push({id: 'verifies_data_signature_on_document', valid: true});

if(credential.credentialStatus) {
result.statusResult = await checkStatus(options);
if(!result.statusResult.verified) {
result.verified = false;
result_array.push({id: 'check_status', valid: false, error: new Error('Check status is failure'), result});
}
}

result_array.push({id: 'check_status', valid: true, result});
result.result_array = result_array;
return result;
}

Expand Down