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

provide default implementation for did resolver #187

Open
Christiantyemele opened this issue Sep 26, 2024 · 1 comment · May be fixed by #188
Open

provide default implementation for did resolver #187

Christiantyemele opened this issue Sep 26, 2024 · 1 comment · May be fixed by #188
Assignees

Comments

@Christiantyemele
Copy link
Collaborator

No description provided.

@Christiantyemele
Copy link
Collaborator Author

Christiantyemele commented Sep 26, 2024

This issue comes as and adjustment to the current didresolver which i find weird to for a did resolver to take a did document before resolution

#[async_trait]
impl DIDResolver for LocalDIDResolver {
    async fn resolve(&self, did: &str) -> Result<Option<DIDDoc>> {
        if did == self.diddoc.id {
            return Ok(Some(self.diddoc.clone()));
        }

        if !did.starts_with("did:key:") {
            return Err(Error::new(
                ErrorKind::Unsupported,
                DIDResolutionError::MethodNotSupported,
            ));
        }

        let method = DidKey::new_full(true, PublicKeyFormat::Jwk);

        match method.expand(did) {
            Ok(diddoc) => Ok(Some(
                serde_json::from_value(json!(Document {
                    service: Some(vec![]),
                    ..diddoc
                }))
                .expect("Should easily convert between DID document representations."),
            )),
            Err(err) => Err(Error::new(ErrorKind::DIDNotResolved, err)),
        }
    }
}

@Christiantyemele Christiantyemele self-assigned this Sep 26, 2024
@Christiantyemele Christiantyemele linked a pull request Sep 26, 2024 that will close this issue
@Christiantyemele Christiantyemele changed the title implement did resolver which does not need did document provide default implementation for did resolver Sep 26, 2024
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 a pull request may close this issue.

1 participant