This library is intended to be used as a core library for developing own self sovereign identity based applications.
So why the name? "Vade" is an acronym for "VC and DID engine". It focuses on working with VCs and DIDs but does not hold much logic concerning their structure. Confused? Guessed as much, so what does does this library actually does is:
Vade
] instanceIt has been designed with the idea of offering a consistent interface to work with while supporting to move the actual work into plugins, which also helps to reduce the dependencies.
This library is currently under development and behavior as well as provided traits will most probably change over time.
First add vade
as a dependency to your Cargo.toml
. Then you can create new instances in your code (taken from our tests):
```rust extern crate vade;
use vade::Vade;
fn librarycanbe_created() { let _vade = Vade::new(); } ```
Okay, that did not do much yet. The core library also offers a simple in-memory cache, called [RustStorageCache
], which can be used when working with VC and DID documents, that are available offline and should just be stored and/or retrieved locally. So to use [RustStorageCache
] as a [VcResolver
], we just need to add it as a [VcResolver
] plugin:
```rust extern crate vade;
use vade::Vade; use vade::traits::VcResolver; use vade::plugin::ruststoragecache::RustStorageCache;
async fn libraryvccansetvcswithtworesolversvialibraryset() { let mut vade = Vade::new(); let storage = RustStorageCache::new(); library.registervcresolver(Box::from(storage));
match library.set_vc_document("example_key", "example_value").await {
Ok(()) => (),
Err(e) => panic!(format!("{}", e)),
}
let fetched = library.get_vc_document("example_key").await.unwrap();
assert!(fetched == "example_value");
} ```
Keep in mind, that the [RustStorageCache
] resolver can be considered a reference implementation about how resolvers may behave and that it does not validate integrity and validity of given documents. For features like these, you can implement your own resolvers by following the respective traits.
Plugins are the modules, that perform the actual work in the [Vade
] module. This project already has one plugin included [RustStorageCache
], which can be used as a refrence for creating own plugins.
Developing plugins for vade
is can be done by implementing one or more traits from [vade::library::traits
], e.g.
DidResolver
]VcResolver
]Logger
] (currently unclear if this plugin will be continued, but can be used for implementation tests)An example for a simple plugin can is the provided [RustStorageCache
]. This implements [DidResolver
] as well as [VcResolver
] functionalities. For your implementation you can of course decide to implement only a single trait in a plugin.
This plugin implements the following traits:
VcResolver
] - therefore it can handle VC documentsDidResolver
] - therefore it can handle DID documentsThis allows us to register it as these resolvers with
register_vc_resolver
]register_did_resolver
]respectively.
As soon as they are registered as a plugin for a certain type of operation, they are called for related operations (e.g. [get_vc_document
]) by the [Vade
] instance they are registered in.
This sections shows a short overview over the plugin related functions. For more details, have a look at the [Vade
] documentation.
These functions can be used to register new resolver plugins:
register_did_resolver
]register_vc_resolver
]These functions will call all registered plugins respectively and with given arguments (e.g. setting a DID will only call DID resolver functions, etc.):
set_did_document
]set_vc_document
]If multiple plugins are registered, awaits completion of all actions. First plugin, that fails lets this request fail.
These functions will call all registered plugins respectively and with given arguments (e.g. getting a DID will only call DID resolver functions, etc.):
get_did_document
]get_vc_document
]If multiple plugins are registered, first successful response will be used. Request will fail if all plugins failed.
These functions will call all registered plugins respectively and with given arguments (e.g. getting a DID will only call DID resolver functions, etc.):
check_did_document
]check_vc_document
]A document is considered as valid if at least one resolver confirms its validity. Resolvers may throw to indicate:
The current validation flow offers only a limited way of feedback for invalidity and may undergo further changes in future.
A plugin working with VCs and DIDs on evan.network called [vade-evan
] has been implemented. Its usage is equivalent to the description above, more details can be found on its project page.
You can also start writing your own plugin, by following the behavior outlined with the traits in this library.