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

Resolve did:web #24

Merged
merged 1 commit into from
Dec 5, 2023
Merged

Resolve did:web #24

merged 1 commit into from
Dec 5, 2023

Conversation

amika-sq
Copy link
Contributor

@amika-sq amika-sq commented Dec 1, 2023

Resolve did:web DIDs using Spruce's did-web crate. Uses our DidResolutionResult implementation so that the resolved DIDDocument & all respective metadata is in the expected format according to the community draft resolution spec here.

Resolves #12

Base automatically changed from did-jwk-finally to main December 4, 2023 20:59
}

#[tokio::test]
async fn resolution_success() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this doing a real resolution? should it be mocked?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a real resolution. I can add a mock if we want to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, Spruce is testing mocked responses here: https://github.com/spruceid/ssi/blob/main/did-web/src/lib.rs#L197-L218

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually prefer not mocking but I believe we're mocking elsewhere in our libs. Just flagging because the test could fail even if it's correct, since it relies on an external resource. if there's a way to distinguish network tests somehow that would be useful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I second the intuition of finding a way to distinguish an integration test vs a unit test, though maybe unnecessary at this stage and we could stub in a GitHub Issue on a backlog to address later

Copy link
Contributor

@andresuribe87 andresuribe87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!


#[tokio::test]
async fn resolution_success() {
let did_uri = "did:web:tbd.website";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to add a test like did:web:users.tbddev.org:demo which should resolve to https://users.tbddev.org/demo/did.json

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed 👍

It's strange to me that this test actually passes, though I see the result.did_document.expect("did_document not found") below. Does the did:web spec allow non-error resolution wherein the no-results case is indicated by an empty/null document? Seems weird to me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this valid? I'm trying to use https://dev.uniresolver.io/ and it's not able to resolve this 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe uniresolver doesn't support DID web!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a little digging. Resolving this DID currently fails because it's using an unknown VerificationMethod property publicKeyHex. This doesn't appear in the spec: https://www.w3.org/TR/did-core/#verification-method-properties

Is there another spec that does include this? If so, why have these diverged?

@decentralgabe maybe you have some extra insight here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amika-sq it's not included in the default context for did-core, but it is included in the security vocab here -- https://github.com/w3c-ccg/security-vocab/pull/40/files

this means to make that did web valid it would have to add the context like this

{
  "@context": ["https://w3id.org/did/v1", "https://w3id.org/security/v3-unstable"],
  "id": "did:web:users.tbddev.org:demo",
  "verificationMethod": [
    {
      "id": "did:web:users.tbddev.org:demo#key-0",
      "type": "EcdsaSecp256k1VerificationKey2019",
      "publicKeyHex": "04e8e82698e64db79e13dc6e7478f47a5fe867c4acd6fa8928b0c93c763a02fd6c54a622de247cc04449531429dbb6a2373b6c685a8e1326913e0531e5f649208d"
    }
  ]
}

or not use hex

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really we should be using JWKs everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! I went ahead and added a task in the backlog for this here: #39

I'm thinking we can add one specifically for testing purposes here so that we have a reliable way to always resolve.

Copy link
Contributor

@KendallWeihe KendallWeihe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice this lgtm, but I think we should make the change @andresuribe87 suggested around the non-empty resolution

@amika-sq amika-sq merged commit bddbe25 into main Dec 5, 2023
7 checks passed
@amika-sq amika-sq deleted the did-web branch December 5, 2023 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement did:web resolution
4 participants