Meeco / hedera-did-sdk-js

Javascript SDK for managing DID Documents & Verifiable Credentials
Apache License 2.0
1 stars 4 forks source link

Add support for resolving DID documents from IPFS #35

Closed zbarbuto closed 1 year ago

zbarbuto commented 1 year ago

Adds support for resolving DID documents stored on IPFS.

The message envelope the same format as the DIDOwner message:

{
  "message": {
    "timestamp": "2023-06-30T03:04:15.511Z",
    "operation": "create",
    "did": "did:hedera:testnet:IDENTIFIER_0.0.1",
    "event": "<base-64-event>"
  },
  "signature": "F01PZwvZaueAo.....K8qAQ=="
}

where the event will decode to:

{
  "DIDDocument":
    {
      "id": "did:hedera:testnet:IDENTIFIER_0.0.1#did-document",
      "type": "DID-Document",
      "cid":"<IPFS_CID>",
       "url":"https://ipfs.io/ipfs/<IPFS_CID>"
    }
}

The resolver will treat this message as a complete overwrite of the current did document to use the document fetched from IPFS. At the moment, it treats the message as "This is now my did document" regardless of any prior events. However, this could easily be changed to require a DELETE first if needed, as with the current CREATE operation.

This is a breaking change as the signature of the DIDDocument constructor has changed and processing messages now has to be called separately (as the process needs to be asynchronous so that any external documents can be fetched).

Some tests were already failing when I checked out the repo so I'm not sure about whether or not that's to do with my setup or not.

derek-meeco commented 1 year ago

@zbarbuto , can you resolve conflict since Pr #34 please 🙏

zbarbuto commented 1 year ago

Have rebased

derek-meeco commented 1 year ago

rebased again with last changes to tests in https://github.com/Meeco/did-sdk-js/pull/36

zbarbuto commented 1 year ago

Maybe DID_DOCUMENT could be used for both then and Document key could simply be removed? Only if that does not impose too many changes around the rest of the codebase.

For backwards compatibility wouldn't make more sense to use Document for both since this is a "new" event? Although maybe it's nice to keep them separate to ensure actions revolving around a completed document are their own thing?

linasi commented 1 year ago

For backwards compatibility wouldn't make more sense to use Document for both since this is a "new" event? Although maybe it's nice to keep them separate to ensure actions revolving around a completed document are their own thing?

Backwards compatibility was already broken by changing DID format with one of the previous PRs so I thought it might make sense to update this as well. I like the argument about keeping thing separate for completed document tho.