TBD54566975 / web5-go

Apache License 2.0
10 stars 6 forks source link

Update `PortableDID` Part 1 #19

Closed mistermoe closed 7 months ago

mistermoe commented 7 months ago

Overview

This PR is part 1 of 3 to introduce changes discussed here: https://github.com/TBD54566975/web5-spec/issues/112#issuecomment-1924691567.

[!IMPORTANT] Prioritizing the changes in this first PR because it includes stuff that i need in order to implement did:web which is necessary to unblock a bunch of work for the upcoming week. Details on what was and wasn't included in the sections below

What's Included

changed ToKeys and FromKeys to ToPortableDID and FromPortableDID respectively

ToKeys and FromKeys no longer made sense because PortableDID includes more than just keys.


ToPortableDID no longer throws if the BearerDID's Key Manager cannot export keys. Instead, PrivateKeys is omitted.

This makes it so BearerDID created using HSM based key manager's can still be exported to a PortableDID. This is useful because there's still necessary state even when re-inflating a BearerDID with an HSM based key manager


added Document field to PortableDID

Including the DID Document allows us to import a DID without making potential network calls and also does not require DIDs to be published prior to exporting them.


changed VerificationMethod field to PrivateKeys

Now that we have the DID Document, including what was previously in VerificationMethod is duplicative

added Metadata. Used to store method-specific properties


What's Not Included

FromPortableDID doesn't accept an optional KeyManager arg yet

Will likely move this function to method-specific packages to accommodate method-specific metadata. Also haven't decided how to share functional options yet.


PortableDID.Metadata doesn't include an explicit published property yet.

This is simply because i can't remember a detail we discussed in the meeting where we decided all of these thangs. will double back with @frankhinek and @amika-sq and then make the appropriate change

What's Weird Right Now

FromPortableDID and ToPortableDID are in the did package right now which makes calling these functions from outside the package look like did.FromPortableDID and did.ToPortableDID. It's not evident what representation of DID you're going to or from just by reading the line of code.