Add verification event log mechanism to verify() operation (for fine-grained UI)#92
Add verification event log mechanism to verify() operation (for fine-grained UI)#92lomkovsky wants to merge 3 commits intodigitalbazaar:mainfrom
Conversation
|
Context: What this PR is trying to do is add additional finer-grained results to the The idea is, verify() would return an additional, optional const {valid, log} = await vc.verify({...});Where the [
{id: 'issuer_check', valid: true},
{id: 'expiration_check', valid: false, error: new Error('Credential has expired')},
]So, currently, verify() returns a boolean pass/fail, plus an array of errors. But for the purposes of a typical verification UI, it's useful to display a set of checks / errors, regarding which steps of verification passed or failed. This is a non-breaking (additive) change to the verify() API that I think might be really useful. |
lib/vc.js
Outdated
| } | ||
| return _verifyCredential(options); | ||
| } catch(error) { | ||
| const result_array = []; |
There was a problem hiding this comment.
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.
lib/vc.js
Outdated
| '"credentialStatus".'); | ||
| } | ||
|
|
||
| const result_array = []; |
| } | ||
| } | ||
|
|
||
| log.push({id: 'check_status', valid: true}); |
There was a problem hiding this comment.
Wouldn't this line overwrite line 302, since we are not returning after we push that log entry?
| } catch(error) { | ||
| const log = []; | ||
| log.push({ | ||
| id: 'check_credential_required_field', |
There was a problem hiding this comment.
Should we include user-friendly event descriptions in these log entries as well or do you think the ID-description mapping responsibility should be left to the client code?
|
Left a couple comments above, but generally, I support the utility this PR provides 👍 |
|
I propose we close this PR (it'll be replaced by the downstream PR digitalcredentials#4 -- once we test it and get initial deployment feedback, stabilize the API, etc, I'll make an upstream PR to this lib). |
No description provided.