Skip to content

swiyu-admin-ch/didresolver

Repository files navigation

Public Beta banner

DID resolver

Build and Test CodeQL Analysis OSV-Scanner Clippy Analysis

Latest version of the DID methods might not be supported yet

An official Swiss Government project made by the Federal Office of Information Technology, Systems and Telecommunication FOITT as part of the electronic identity (e-ID) project.

This project contains a DID resolver which allows to resolve the following DID methods:

Table of contents

Overview

This repository is part of the ecosystem developed for the future official Swiss e-ID. The goal of this repository is to engage with the community and collaborate on developing the Swiss ecosystem for e-ID and other credentials. We warmly encourage you to engage with us by creating an issue in the repository.

For more information about the project please visit the introduction for the Public Beta or the Open Source Community repository.

Using the library

The library can be used either directly in rust as is or through the different built bindings which are published in different submodules

Rust

The library can be used directly in rust by adding the following dependency to your Cargo.toml:

[dependencies]
# Alternatively, feel free to so use tag=<ANY_EXISTING_VERSION> instead of branch="main"
didresolver = { git="https://github.com/swiyu-admin-ch/didresolver.git", branch="main" }
ureq = "3.0.12"

# Optional: For manipulating the json content in the example
serde_json = "1.0.215"

Additional language bindings

General information how the bindings are generated can be found in the UniFFI user guide

The library is also available in other languages. Please consult the documentation of the subsequent repositories for more information:

Example

In the example the following steps are shown:

  1. Convert supplied DID string into the standard did representation, if possible
  2. Fetch a raw DID log, using the url embedded in the did object created previously, if available
  3. Try resolving the raw DOD log into a DID doc
  4. Explore different parts of the received DID doc
use didresolver::did::Did;

fn main() {
    let did = Did::new(String::from("did:webvh:QmXi8p2LNXA6kbc2brwdpXwGETHCrPoFk15yPbLaAu27Pj:gist.githubusercontent.com:vst-bit:20c3f59d8179e324a6e29aef45240db4:raw:7870280f80dfcfb7459ee1488df4ab33f2bcf709"))
        .expect("invalid DID supplied");

    let url = did.get_https_url();

    let did_log = ureq::get(&url)
        .call()
        .expect("Failed to call did url")
        .into_body()
        .read_to_string()
        .expect("Failed to read DID to string");

    let did_doc_extended = match did.resolve_all(did_log) {
        Ok(v) => v,
        Err(reason) => panic!("Error occurred during resolution: {}", reason),
    };

    did_doc_extended.get_did_doc().get_verification_method().iter().for_each(|method| {
        println!(
            "id: {}, publicKey: {:?}, publicKeyJwk: {:?}",
            method.id, method.public_key_multibase, method.public_key_jwk
        )
    });
}

Crate's hierarchical structure

Such structure may be easily obtained by simply running cargo-modules structure --lib --package did:

crate didresolver
└── mod did: pub
    ├── struct Did: pub
    │   ├── fn get_https_url: pub
    │   ├── fn get_method: pub
    │   ├── fn get_parts: pub
    │   ├── fn get_scid: pub
    │   ├── fn get_url: pub
    │   ├── fn new: pub
    │   ├── fn resolve: pub
    │   └── fn resolve_all: pub
    ├── enum DidMethod: pub
    │   ├── fn get_https_url: pub
    │   ├── fn get_scid: pub
    │   └── fn new_did_resolver_impl: pub(self)
    ├── enum DidResolveError: pub
    │   └── const fn kind: pub
    └── enum DidResolveErrorKind: pub

Internal dependencies

Dependencies

The graph is also available in other layouts: circo, dot, fdp, neato, sfdp, twopi

Benchmarks

All the relevant reports are available here.

Missing Features and Known Issues

The swiyu Public Beta Trust Infrastructure was deliberately released at an early stage to enable future ecosystem participants. The feature roadmap shows the current discrepancies between Public Beta and the targeted productive Trust Infrastructure. There may still be minor bugs or security vulnerabilities in the test system. These are marked as ‘KnownIssues’ in each repository.

Contributions and feedback

We welcome any feedback on the code regarding both the implementation and security aspects. Please follow the guidelines for contributing found in CONTRIBUTING.md.

License

This project is licensed under the terms of the MIT license. See the LICENSE file for details.

About

DID resolver built for swiyu, the Swiss e-ID Trust Infrastructure

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors