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 validator #15

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Add validator #15

wants to merge 13 commits into from

Conversation

aljones15
Copy link

@aljones15 aljones15 commented Jun 14, 2019

This adds a validator for both Identifiers and Documents
that should conform to v0.13 of the DID Spec.
This is being used for the spec tests.

@dmitrizagidulin
Copy link
Contributor

dmitrizagidulin commented Jun 17, 2019

My main question about this PR is - why not use the did-veres-one driver's VeresOneDidDoc.validateDid() (or at least extract the validation logic there to a static method, and use it here)? I'm not sure it makes sense to duplicate a lot of that logic..

@aljones15
Copy link
Author

aljones15 commented Jun 17, 2019

My main question about this PR is - why not use the did-veres-one driver's VeresOneDidDoc.validateDid() (or at least extract the validation logic there to a static method, and use it here)? I'm not sure it makes sense to duplicate a lot of that logic..

was not aware that existed (I did look) so will look into that in a moment.

EDIT: actually did see VeresOneDoc validator, but I guess it seemed out of date or to specific.

@aljones15
Copy link
Author

aljones15 commented Jun 17, 2019

@dmitrizagidulin looks like the validation there is:

A. much more specific than this one:

https://github.com/veres-one/did-veres-one/blob/master/lib/VeresOneDidDoc.js

const VERES_DID_REGEX = /^(did:v1:)(test:)?(uuid|nym):(.+)/;
  • only accepts method-names uuid|test|nym (other implementations might use other method names)
  • has a version number on did (is that correct? EDIT: sorry v1 is the methodName)
    if(this.id && this.id.startsWith('urn:uuid:')) {
      return {valid: true}; // short-circuit, UUID URNs are fine as is
    }
  • returns true if the id starts with urn (no further validation)
if(mode === 'test' && didMode !== 'test') {
      return {
        error: new Error(`DID is invalid for test mode: "${this.id}".`),
        valid: false
      };
    }
  • has a mode

honestly I think that validator is alright for veres, but definitely not general enough for all implementors of the spec. Perhaps we should run this validator on the document then do the rest of the existing VeresOneDidDoc validation?

Others:

  • throws on uppercase did or methodName which is correct, but validator in this PR throws more specific errors.
  • does not validate for the actual document i.e. ['@context'] being there etc.
  • does not validate authentication, publicKeys, etc.

I guess the did identifier validation is good, but this seems more through or am I missing something?

@aljones15
Copy link
Author

aljones15 commented Jun 17, 2019

@dmitrizagidulin

Can the existing VeresOneDid validator pass the tests here:

w3c-ccg/did-test-suite#1

I think it would throw a few false positives etc.

p.s. thanks for reviewing this.

@aljones15 aljones15 requested a review from gannan08 June 18, 2019 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants