digitalbazaar / did-method-key

A did-io driver for the DID "key" method
Other
25 stars 10 forks source link

Should this library throw errors from the `did:key` spec? #46

Open aljones15 opened 2 years ago

aljones15 commented 2 years ago

The did:key spec now contains multiple normative statements about did:key. While we do throw many errors related to those statements, we don't throw them in a way that conforms to the spec.

I'm proposing that checks that can be made at the general level of any did:key be made here and then checks related to key material be made in their respective libraries.

That means the following checks need to be made in this library:

The errors might be specific to the didResolver:

We can throw an error like this:

export class InvalidDid extends Error {
  constructor(message) {
    super(message);
    this.name = 'InvalidDidError';
    this.code = 'invalidDid';
  }
}

export class InvalidDidUrl extends Error {
  constructor(message) {
    super(message);
    this.name = 'InvalidDidUrlError';
    this.code = 'invalidDidUrl';
  }
}

Related: https://github.com/digitalbazaar/ed25519-verification-key-2020/issues/18 https://github.com/w3c-ccg/did-method-key/issues/60