decentralized-identity / trustdidweb

Trust DID Web (did:tdw)
https://identity.foundation/trustdidweb/
Other
26 stars 10 forks source link

Relative path resolution #13

Closed andrewwhitehead closed 3 months ago

andrewwhitehead commented 8 months ago

The DID spec does not outline a process for resolving a generic DID URL, ie. a DID with a path attachment (did:method/relative/path), leaving this up to specific DID methods. It does specify service and relativeRef DID parameters that can be used to resolve paths via service endpoints. An example from the did:web Anoncreds method:

did:method:domain?service=anoncreds&relativeRef=/v1/schema/5762v4VZxFMLB5n9X4Upr3gXaCKTa8PztDDCnroauSsR

Now we could define a simple alias as part of this DID method, and automatically map any DID URL of of the form {DID}/service/{SERVICE}{PATH}{?PARAMS} (for example). In this case the above resource might be represented as:

did:method:domain/service/anoncreds/v1/schema/5762v4VZxFMLB5n9X4Upr3gXaCKTa8PztDDCnroauSsR

On resolution it would simply be transformed into the original format before proceeding. Parameters such as hl (hashlink) should be preserved when this happens, for processing during the resolution process, but not added to the resulting URL.

For more flexibility we could enable path prefixes to be mapped by one or more methods. For example, a service entry of a recognized type:

{
    "id":"#index",
    "type": "PathResolution", 
    "serviceEndpoint": {
        "anoncreds/v1": "https://external-service/me/anoncreds/v1",
        "didcomm/v1": "did:myagent?service=didcomm",
        "*": "/" 
    }
}

or an external file defining the mappings:

{
    "id":"#index",
    "type": "PathResolution", 
    "serviceEndpoint": "/index.jsonld"
}
swcurran commented 7 months ago

Is the idea for this to add this such that it can be used for any DID Method? E.g. that it not be specific to a web-based DID method, but for any DID Method?

With a web-based DID method, it is dead simple and obvious to say that a DID path is just simple text transformation extending the existing DID —> HTTPS transformation. That is what is proposed for the did:webs spec — copying from the text:

  1. The controller of the DID MAY place arbitrary files into the folder structure below the root did:webs folder.
  2. The DID URL for the signed file MUST be of the form <did:webs DID>/path/to/file.
  3. The HTTPS path to the file MUST be <HTTPS URL conversion of did:webs identifier>/path/to/file.

That has the benefit that it eliminates the need for a service endpoint — the interpretation is (as the DID Core spec says…) left to the DID Method.

brianorwhatever commented 7 months ago

Where did we land on this today? Do we need a service to do the relative path stuff or can we define the path behaviour in this method?

swcurran commented 7 months ago

The summary that I got:

Whether to use a hashlink, or it a header is returned or not is up to the Controller.

I think it is up to the resolver implementation based on the DID URL spec to decide how far to go in resolving a passed in DID URL — should it return the DIDDoc, the resulting URI or resolve the URI? I’m not sure of that.

brianorwhatever commented 7 months ago

I still can't quite make heads or tails of this. Suppose I have a local file named /farms/happy-farm/sheep.json that I want to host in a similar folder structure. Where do I put it and do I need to put anything in my DID Document?

swcurran commented 7 months ago

Here is how I understand it:

{
    "id":”#farms",
    "type": "PathResolution", 
    "serviceEndpoint": { "https://aviary.io/farms" }
}

Does that work?

It leaves off the obvious use case of just being able to trivially put any file “adjacent" to the DIDDoc (didlog.txt) — which I personally think should be a default. It would be nice to have a way to express that without having to:

swcurran commented 6 months ago

I think we can close this issue with what is in the draft spec. now -- https://bcgov.github.io/trustdidweb/#did-url-resolution.

swcurran commented 4 months ago

Mostly complete, with a need to formalize the handling of files when the DID Log File's location is .well-known. Over to @andrewwhitehead to propose the handling for that -- and how that impacts the service entry.

swcurran commented 3 months ago

Resolved -- description is in the specification, as is the service definition.