vade/
vade_plugin.rs

1/*
2  Copyright (c) 2018-present evan GmbH.
3
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7
8      http://www.apache.org/licenses/LICENSE-2.0
9
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15*/
16
17use async_trait::async_trait;
18
19/// Wrapper enum for a plugins return value
20pub enum VadePluginResultValue<T> {
21    /// Plugin does not implement this function. This is returned by default as the
22    /// [`VadePlugin`](https://docs.rs/vade/*/vade/trait.VadePlugin.html)
23    /// trait offers a default implementation for every function (which returns `NotImplemented`).
24    /// So if a function is not explicitly implemented by a plugin itself, a call to this function
25    /// will return `NotImplemented`.
26    NotImplemented,
27    /// Plugin implements function but is not "interested" in fulfilling function call.
28    /// This mostly signs that the responding plugin does not resolve/handle given method,
29    /// e.g. a plugin may resolve dids with prefix `did:example123` and not dids with
30    /// prefix `did:example456`.
31    Ignored,
32    /// Plugin handled request and returned a value of type `T`. Note that `Success` values can be
33    /// unwrapped. So if you know, that a plugin implements a function and handles requests of your
34    /// method, you can call
35    /// [`unwrap`](https://docs.rs/vade/*/vade/enum.VadePluginResultValue.html#method.unwrap) on it
36    /// to fetch the underlying value of type `T`.
37    Success(T),
38}
39
40impl<T> VadePluginResultValue<T> {
41    /// Unwraps inner value like:
42    /// - `Success(T)` unwraps successfully to `T`
43    /// - `NotImplemented` and `Ignored` unwrap to errors
44    pub fn unwrap(self) -> T {
45        match self {
46            VadePluginResultValue::Success(val) => val,
47            VadePluginResultValue::NotImplemented => {
48                panic!("called `VadePluginResultValue::unwrap()` on a `NotImplemented` value")
49            }
50            VadePluginResultValue::Ignored => {
51                panic!("called `VadePluginResultValue::unwrap()` on a `Ignored` value")
52            }
53        }
54    }
55}
56
57/// ## About
58///
59/// The plugins are the bread and butter of the underlying [`Vade`] logic. [`Vade`] is your single
60/// point of contact in your application and all your calls are executed against it. [`Vade`] itself
61/// manages the plugins, delegates calls to them and filters the results. The actual logic
62/// concerning specific DID methods resides in the plugins and they are responsible for implementing
63/// argument handling, resolving DIDs, etc.
64///
65/// ## Call delegation
66///
67/// All functions of the [`VadePlugin`] trait have a counterpart with the same name but a slightly
68/// different signature in [`Vade`] that will delegate calls to the plugins' functions with the same
69/// name. While the plugin returns a `VadePluginResultValue<T>`result, [`Vade`] will return
70/// a `Vec<T>` result. [`Vade`]'s result is the list of all results from all plugins that did
71/// implement the called function and did not ignore the request.
72///
73/// For example [`did_create`](https://docs.rs/vade/*/vade/struct.Vade.html#method.did_create)
74/// / [`did_create`](https://docs.rs/vade/*/vade/trait.VadePlugin.html#method.did_create):
75///
76/// [`Vade`]'s function:
77///
78/// ```ignored
79/// pub async fn did_create(
80///     &mut self,
81///     did_method: &str,
82///     options: &str,
83///     payload: &str,
84///     ) -> Result<Vec<Option<String>>, Box<dyn std::error::Error>> {
85///     // ...
86/// }
87/// ```
88///
89/// Will call all [`VadePlugin`]s' functions:
90///
91/// ```ignored
92/// pub async fn did_create(
93///     &mut self,
94///     did_method: &str,
95///     options: &str,
96///     payload: &str,
97/// ) -> Result<Vec<Option<String>>, Box<dyn std::error::Error>> {
98///     // ...
99/// }
100/// ```
101///
102/// ## Result Values of Plugins
103///
104/// Plugins return results with the type [`VadePluginResultValue`], which has 3 Variants:
105///
106/// - [`NotImplemented`], for functions not implemented in a plugin
107/// - [`Ignored`], for functions implemented in a plugin but ignore the request (e.g. due to an unknown method)
108/// - [`Success`], for successful requests' results
109///
110/// ## Example
111///
112/// A simple plugin could look like this:
113///
114/// ```rust
115/// use async_trait::async_trait;
116/// use vade::{VadePlugin, VadePluginResultValue};
117///
118/// struct ExamplePlugin { }
119///
120/// impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
121///
122/// #[async_trait(?Send)]
123/// impl VadePlugin for ExamplePlugin {
124///     async fn did_create(
125///         &mut self,
126///         _did_method: &str,
127///         _options: &str,
128///         _payload: &str,
129///     ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
130///         Ok(VadePluginResultValue::Success(Some(
131///             r#"{ "id": "did:example123:456" }"#.to_string(),
132///         )))
133///     }
134/// }
135/// ```
136///
137/// There is no need to implement all [`VadePlugin`] functions, unimplemented functions will be
138/// ignored. Also make sure to return [`Ignored`], your function is not responsible for a given
139/// did or method.
140///
141/// [`Ignored`]: https://docs.rs/vade/*/vade/enum.VadePluginResultValue.html#variant.Ignored
142/// [`NotImplemented`]: https://docs.rs/vade/*/vade/enum.VadePluginResultValue.html#variant.NotImplemented
143/// [`Success`]: https://docs.rs/vade/*/vade/enum.VadePluginResultValue.html#variant.Success
144/// [`Vade`]: https://docs.rs/vade/*/vade/struct.Vade.html
145/// [`VadePlugin`]: https://docs.rs/vade/*/vade/trait.VadePlugin.html
146/// [`VadePluginResultValue`]: https://docs.rs/vade/*/vade/enum.VadePluginResultValue.html
147
148#[async_trait(?Send)]
149#[allow(unused_variables)] // to keep proper names for documentation and derived implementations
150pub trait VadePlugin {
151    /// Creates a new DID. May also persist a DID document for it, depending on plugin implementation.
152    ///
153    /// # Arguments
154    ///
155    /// * `did_method` - did method to cater to, usually also used by plugins to decide if a plugins will process the request
156    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
157    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
158    ///
159    /// # Example
160    ///
161    /// ```
162    /// use vade::{VadePlugin, VadePluginResultValue};
163    /// // use some_crate:ExamplePlugin;
164    /// # struct ExamplePlugin { }
165    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
166    /// # impl VadePlugin for ExamplePlugin {}
167    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
168    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
169    ///     let result = ep.did_create("did:example", "", "").await?;
170    ///     if let VadePluginResultValue::Success(Some(value)) = result {
171    ///         println!("created new did: {}", &value);
172    ///     }
173    ///     Ok(())
174    /// }
175    /// ```
176    async fn did_create(
177        &mut self,
178        did_method: &str,
179        options: &str,
180        payload: &str,
181    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
182        Ok(VadePluginResultValue::NotImplemented)
183    }
184
185    /// Fetch data about a DID. This usually returns a DID document.
186    ///
187    /// # Arguments
188    ///
189    /// * `did` - did to fetch data for
190    ///
191    /// # Example
192    ///
193    /// ```
194    /// use vade::{VadePlugin, VadePluginResultValue};
195    /// // use some_crate:ExamplePlugin;
196    /// # struct ExamplePlugin { }
197    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
198    /// # impl VadePlugin for ExamplePlugin {}
199    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
200    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
201    ///     let result = ep.did_resolve("did:example:123").await?;
202    ///     if let VadePluginResultValue::Success(Some(value)) = result {
203    ///         println!("got did: {}", &value);
204    ///     }
205    ///     Ok(())
206    /// }
207    /// ```
208    async fn did_resolve(
209        &mut self,
210        _did: &str,
211    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
212        Ok(VadePluginResultValue::NotImplemented)
213    }
214
215    /// Updates data related to a DID. May also persist a DID document for it, depending on plugin implementation.
216    ///
217    /// # Arguments
218    ///
219    /// * `did` - DID to update data for
220    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
221    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
222    ///
223    /// # Example
224    ///
225    /// ```
226    /// use vade::{VadePlugin, VadePluginResultValue};
227    /// // use some_crate:ExamplePlugin;
228    /// # struct ExamplePlugin { }
229    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
230    /// # impl VadePlugin for ExamplePlugin {}
231    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
232    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
233    ///     let result = ep.did_update("did:example", "", "").await?;
234    ///     if let VadePluginResultValue::Success(Some(value)) = result {
235    ///         println!("updated did: {}", &value);
236    ///     }
237    ///     Ok(())
238    /// }
239    /// ```
240    async fn did_update(
241        &mut self,
242        did: &str,
243        options: &str,
244        payload: &str,
245    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
246        Ok(VadePluginResultValue::NotImplemented)
247    }
248
249    /// Processes a DIDComm message as received, usually also prepares a matching response for it.
250    ///
251    /// This response **may** be sent, depending on the configuration and implementation of
252    /// underlying plugins, but it is usually also returned as response to this request.
253    ///
254    /// # Arguments
255    ///
256    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
257    /// * `payload` - JSON string with information for the request (usually a raw DIDComm message)
258    ///
259    /// # Example
260    ///
261    /// ```
262    /// use vade::{VadePlugin, VadePluginResultValue};
263    /// // use some_crate:ExamplePlugin;
264    /// # struct ExamplePlugin { }
265    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
266    /// # impl VadePlugin for ExamplePlugin {}
267    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
268    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
269    ///     let result = ep.didcomm_receive("", "").await?;
270    ///     if let VadePluginResultValue::Success(Some(value)) = result {
271    ///         println!("received DIDComm message: {}", &value);
272    ///     }
273    ///     Ok(())
274    /// }
275    /// ```
276    async fn didcomm_receive(
277        &mut self,
278        options: &str,
279        payload: &str,
280    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
281        Ok(VadePluginResultValue::NotImplemented)
282    }
283
284    /// Processes a DIDComm message as received, this may prepare a matching response for it
285    /// if the DIDComm message can be interpreted and answered by a plugin's implementation.
286    ///
287    /// It **may** be sent, depending on the configuration and implementation of underlying plugins.
288    ///
289    /// # Arguments
290    ///
291    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
292    /// * `payload` - JSON string with information for the request (usually a raw DIDComm message)
293    ///
294    /// # Example
295    ///
296    /// ```
297    /// use vade::{VadePlugin, VadePluginResultValue};
298    /// // use some_crate:ExamplePlugin;
299    /// # struct ExamplePlugin { }
300    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
301    /// # impl VadePlugin for ExamplePlugin {}
302    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
303    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
304    ///     let result = ep.didcomm_send("", "").await?;
305    ///     if let VadePluginResultValue::Success(Some(value)) = result {
306    ///         println!("prepared DIDComm message: {}", &value);
307    ///     }
308    ///     Ok(())
309    /// }
310    /// ```
311    async fn didcomm_send(
312        &mut self,
313        options: &str,
314        payload: &str,
315    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
316        Ok(VadePluginResultValue::NotImplemented)
317    }
318
319    /// Runs a custom function, this allows to use `Vade`s API for custom calls, that do not belong
320    /// to `Vade`s core functionality but may be required for a projects use cases.
321    ///
322    /// # Arguments
323    ///
324    /// * `method` - method to call a function for (e.g. "did:example")
325    /// * `function` - function to call (e.g. "test connection")
326    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
327    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
328    ///
329    /// # Example
330    ///
331    /// ```
332    /// use vade::{VadePlugin, VadePluginResultValue};
333    /// // use some_crate:ExamplePlugin;
334    /// # struct ExamplePlugin { }
335    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
336    /// # impl VadePlugin for ExamplePlugin {}
337    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
338    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
339    ///     let result = ep.run_custom_function("did:example", "test connection", "", "").await?;
340    ///     if let VadePluginResultValue::Success(Some(value)) = result {
341    ///         println!("connection status: {}", &value);
342    ///     }
343    ///     Ok(())
344    /// }
345    /// ```
346    async fn run_custom_function(
347        &mut self,
348        method: &str,
349        function: &str,
350        options: &str,
351        payload: &str,
352    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
353        Ok(VadePluginResultValue::NotImplemented)
354    }
355
356    /// Creates a new zero-knowledge proof credential definition. A credential definition holds cryptographic key material
357    /// and is needed by an issuer to issue a credential, thus needs to be created before issuance. A credential definition
358    /// is always bound to one credential schema.
359    ///
360    /// # Arguments
361    ///
362    /// * `method` - method to create a credential definition for (e.g. "did:example")
363    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
364    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
365    ///
366    /// # Example
367    ///
368    /// ```
369    /// use vade::{VadePlugin, VadePluginResultValue};
370    /// // use some_crate:ExamplePlugin;
371    /// # struct ExamplePlugin { }
372    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
373    /// # impl VadePlugin for ExamplePlugin {}
374    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
375    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
376    ///     let result = ep.vc_zkp_create_credential_definition("did:example", "", "").await?;
377    ///     if let VadePluginResultValue::Success(Some(value)) = result {
378    ///         println!("successfully created a credential definition: {}", &value);
379    ///     }
380    ///     Ok(())
381    /// }
382    /// ```
383    async fn vc_zkp_create_credential_definition(
384        &mut self,
385        did_method: &str,
386        options: &str,
387        payload: &str,
388    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
389        Ok(VadePluginResultValue::NotImplemented)
390    }
391
392    /// Creates a new zero-knowledge proof credential offer. This message is the response to a credential proposal.
393    ///
394    /// # Arguments
395    ///
396    /// * `method` - method to create a credential offer for (e.g. "did:example")
397    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
398    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
399    ///
400    /// # Example
401    ///
402    /// ```
403    /// use vade::{VadePlugin, VadePluginResultValue};
404    /// // use some_crate:ExamplePlugin;
405    /// # struct ExamplePlugin { }
406    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
407    /// # impl VadePlugin for ExamplePlugin {}
408    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
409    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
410    ///     let result = ep.vc_zkp_create_credential_offer("did:example", "", "").await?;
411    ///     if let VadePluginResultValue::Success(Some(value)) = result {
412    ///         println!("created a credential offer: {}", &value);
413    ///     }
414    ///     Ok(())
415    /// }
416    async fn vc_zkp_create_credential_offer(
417        &mut self,
418        method: &str,
419        options: &str,
420        payload: &str,
421    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
422        Ok(VadePluginResultValue::NotImplemented)
423    }
424
425    /// Creates a new zero-knowledge proof credential proposal. This message is the first in the
426    /// credential issuance flow.
427    ///
428    /// # Arguments
429    ///
430    /// * `method` - method to create a credential proposal for (e.g. "did:example")
431    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
432    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
433    ///
434    /// # Example
435    ///
436    /// ```
437    /// use vade::{VadePlugin, VadePluginResultValue};
438    /// // use some_crate:ExamplePlugin;
439    /// # struct ExamplePlugin { }
440    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
441    /// # impl VadePlugin for ExamplePlugin {}
442    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
443    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
444    ///     let result = ep.vc_zkp_create_credential_proposal("did:example", "", "").await?;
445    ///     if let VadePluginResultValue::Success(Some(value)) = result {
446    ///         println!("created a credential proposal: {}", &value);
447    ///     }
448    ///     Ok(())
449    /// }
450    /// ```
451    async fn vc_zkp_create_credential_proposal(
452        &mut self,
453        method: &str,
454        options: &str,
455        payload: &str,
456    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
457        Ok(VadePluginResultValue::NotImplemented)
458    }
459
460    /// Creates a new zero-knowledge proof credential schema. The schema specifies properties a credential
461    /// includes, both optional and mandatory.
462    ///
463    /// # Arguments
464    ///
465    /// * `method` - method to create a credential schema for (e.g. "did:example")
466    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
467    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
468    ///
469    /// # Example
470    ///
471    /// ```
472    /// use vade::{VadePlugin, VadePluginResultValue};
473    /// // use some_crate:ExamplePlugin;
474    /// # struct ExamplePlugin { }
475    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
476    /// # impl VadePlugin for ExamplePlugin {}
477    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
478    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
479    ///     let result = ep.vc_zkp_create_credential_schema("did:example", "", "").await?;
480    ///     if let VadePluginResultValue::Success(Some(value)) = result {
481    ///         println!("created a credential schema: {}", &value);
482    ///     }
483    ///     Ok(())
484    /// }
485    /// ```
486    async fn vc_zkp_create_credential_schema(
487        &mut self,
488        method: &str,
489        options: &str,
490        payload: &str,
491    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
492        Ok(VadePluginResultValue::NotImplemented)
493    }
494
495    /// Creates a new revocation registry definition. The definition consists of a public and a private part.
496    /// The public part holds the cryptographic material needed to create non-revocation proofs. The private part
497    /// needs to reside with the registry owner and is used to revoke credentials.
498    ///
499    /// # Arguments
500    ///
501    /// * `method` - method to create a revocation registry definition for (e.g. "did:example")
502    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
503    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
504    ///
505    /// # Example
506    ///
507    /// ```
508    /// use vade::{VadePlugin, VadePluginResultValue};
509    /// // use some_crate:ExamplePlugin;
510    /// # struct ExamplePlugin { }
511    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
512    /// # impl VadePlugin for ExamplePlugin {}
513    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
514    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
515    ///     let result = ep.vc_zkp_create_revocation_registry_definition("did:example", "", "").await?;
516    ///     if let VadePluginResultValue::Success(Some(value)) = result {
517    ///         println!("created a revocation registry definition: {}", &value);
518    ///     }
519    ///     Ok(())
520    /// }
521    /// ```
522    async fn vc_zkp_create_revocation_registry_definition(
523        &mut self,
524        method: &str,
525        options: &str,
526        payload: &str,
527    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
528        Ok(VadePluginResultValue::NotImplemented)
529    }
530
531    /// Updates a revocation registry for a zero-knowledge proof. This step is necessary after revocation one or
532    /// more credentials.
533    ///
534    /// # Arguments
535    ///
536    /// * `method` - method to update a revocation registry for (e.g. "did:example")
537    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
538    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
539    ///
540    /// # Example
541    ///
542    /// ```
543    /// use vade::{VadePlugin, VadePluginResultValue};
544    /// // use some_crate:ExamplePlugin;
545    /// # struct ExamplePlugin { }
546    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
547    /// # impl VadePlugin for ExamplePlugin {}
548    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
549    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
550    ///     let result = ep.vc_zkp_update_revocation_registry("did:example", "", "").await?;
551    ///     if let VadePluginResultValue::Success(Some(value)) = result {
552    ///         println!("updated revocation registry: {}", &value);
553    ///     }
554    ///     Ok(())
555    /// }
556    /// ```
557    async fn vc_zkp_update_revocation_registry(
558        &mut self,
559        method: &str,
560        options: &str,
561        payload: &str,
562    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
563        Ok(VadePluginResultValue::NotImplemented)
564    }
565
566    /// Issues a new credential. This requires an issued schema, credential definition, an active revocation
567    /// registry and a credential request message.
568    ///
569    /// # Arguments
570    ///
571    /// * `method` - method to issue a credential for (e.g. "did:example")
572    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
573    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
574    ///
575    /// # Example
576    ///
577    /// ```
578    /// use vade::{VadePlugin, VadePluginResultValue};
579    /// // use some_crate:ExamplePlugin;
580    /// # struct ExamplePlugin { }
581    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
582    /// # impl VadePlugin for ExamplePlugin {}
583    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
584    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
585    ///     let result = ep.vc_zkp_issue_credential("did:example", "", "").await?;
586    ///     if let VadePluginResultValue::Success(Some(value)) = result {
587    ///         println!("issued credential: {}", &value);
588    ///     }
589    ///     Ok(())
590    /// }
591    /// ```
592    async fn vc_zkp_issue_credential(
593        &mut self,
594        method: &str,
595        options: &str,
596        payload: &str,
597    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
598        Ok(VadePluginResultValue::NotImplemented)
599    }
600
601    /// Finishes a credential, e.g. by incorporating the prover's master secret into the credential signature after issuance.
602    ///
603    /// # Arguments
604    ///
605    /// * `method` - method to update a finish credential for (e.g. "did:example")
606    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
607    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
608    ///
609    /// # Example
610    ///
611    /// ```
612    /// use vade::{VadePlugin, VadePluginResultValue};
613    /// // use some_crate:ExamplePlugin;
614    /// # struct ExamplePlugin { }
615    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
616    /// # impl VadePlugin for ExamplePlugin {}
617    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
618    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
619    ///     let result = ep.vc_zkp_finish_credential("did:example", "", "").await?;
620    ///     if let VadePluginResultValue::Success(Some(value)) = result {
621    ///         println!("finished credential: {}", &value);
622    ///     }
623    ///     Ok(())
624    /// }
625    /// ```
626    async fn vc_zkp_finish_credential(
627        &mut self,
628        method: &str,
629        options: &str,
630        payload: &str,
631    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
632        Ok(VadePluginResultValue::NotImplemented)
633    }
634
635    /// Presents a proof for a zero-knowledge proof credential. A proof presentation is the response to a
636    /// proof request.
637    ///
638    /// # Arguments
639    ///
640    /// * `method` - method to presents a proof for (e.g. "did:example")
641    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
642    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
643    ///
644    /// # Example
645    ///
646    /// ```
647    /// use vade::{VadePlugin, VadePluginResultValue};
648    /// // use some_crate:ExamplePlugin;
649    /// # struct ExamplePlugin { }
650    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
651    /// # impl VadePlugin for ExamplePlugin {}
652    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
653    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
654    ///     let result = ep.vc_zkp_present_proof("did:example", "", "").await?;
655    ///     if let VadePluginResultValue::Success(Some(value)) = result {
656    ///         println!("created a proof presentation: {}", &value);
657    ///     }
658    ///     Ok(())
659    /// }
660    /// ```
661    async fn vc_zkp_present_proof(
662        &mut self,
663        method: &str,
664        options: &str,
665        payload: &str,
666    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
667        Ok(VadePluginResultValue::NotImplemented)
668    }
669
670    /// Proposes a zero-knowledge proof for one or more credentials issued under one or more specific schemas.
671    ///
672    /// # Arguments
673    ///
674    /// * `method` - method to propose a proof for (e.g. "did:example")
675    /// * `options` - JSON string with additional information supporting the proposal (e.g. authentication data)
676    /// * `payload` - JSON string with information for the proposal (e.g. actual data to write)
677    ///
678    /// # Example
679    ///
680    /// ```
681    /// use vade::{VadePlugin, VadePluginResultValue};
682    /// // use some_crate:ExamplePlugin;
683    /// # struct ExamplePlugin { }
684    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
685    /// # impl VadePlugin for ExamplePlugin {}
686    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
687    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
688    ///     let result = ep.vc_zkp_propose_proof("did:example", "", "").await?;
689    ///     if let VadePluginResultValue::Success(Some(value)) = result {
690    ///         println!("created proof proposal: {}", &value);
691    ///     }
692    ///     Ok(())
693    /// }
694    /// ```
695    async fn vc_zkp_propose_proof(
696        &mut self,
697        method: &str,
698        options: &str,
699        payload: &str,
700    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
701        Ok(VadePluginResultValue::NotImplemented)
702    }
703
704    /// Requests a credential. This message is the response to a credential offering.
705    ///
706    /// # Arguments
707    ///
708    /// * `method` - method to request a credential for (e.g. "did:example")
709    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
710    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
711    ///
712    /// # Example
713    ///
714    /// ```
715    /// use vade::{VadePlugin, VadePluginResultValue};
716    /// // use some_crate:ExamplePlugin;
717    /// # struct ExamplePlugin { }
718    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
719    /// # impl VadePlugin for ExamplePlugin {}
720    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
721    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
722    ///     let result = ep.vc_zkp_request_credential("did:example", "", "").await?;
723    ///     if let VadePluginResultValue::Success(Some(value)) = result {
724    ///         println!("created credential request: {}", &value);
725    ///     }
726    ///     Ok(())
727    /// }
728    /// ```
729    async fn vc_zkp_request_credential(
730        &mut self,
731        method: &str,
732        options: &str,
733        payload: &str,
734    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
735        Ok(VadePluginResultValue::NotImplemented)
736    }
737
738    /// Requests a zero-knowledge proof for one or more credentials issued under one or more specific schemas.
739    ///
740    /// # Arguments
741    ///
742    /// * `method` - method to request a proof for (e.g. "did:example")
743    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
744    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
745    ///
746    /// # Example
747    ///
748    /// ```
749    /// use vade::{VadePlugin, VadePluginResultValue};
750    /// // use some_crate:ExamplePlugin;
751    /// # struct ExamplePlugin { }
752    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
753    /// # impl VadePlugin for ExamplePlugin {}
754    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
755    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
756    ///     let result = ep.vc_zkp_request_proof("did:example", "", "").await?;
757    ///     if let VadePluginResultValue::Success(Some(value)) = result {
758    ///         println!("created proof request: {}", &value);
759    ///     }
760    ///     Ok(())
761    /// }
762    /// ```
763    async fn vc_zkp_request_proof(
764        &mut self,
765        method: &str,
766        options: &str,
767        payload: &str,
768    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
769        Ok(VadePluginResultValue::NotImplemented)
770    }
771
772    /// Revokes a credential. After revocation the published revocation registry needs to be updated with information
773    /// returned by this function.
774    ///
775    /// # Arguments
776    ///
777    /// * `method` - method to revoke a credential for (e.g. "did:example")
778    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
779    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
780    ///
781    /// # Example
782    ///
783    /// ```
784    /// use vade::{VadePlugin, VadePluginResultValue};
785    /// // use some_crate:ExamplePlugin;
786    /// # struct ExamplePlugin { }
787    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
788    /// # impl VadePlugin for ExamplePlugin {}
789    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
790    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
791    ///     let result = ep.vc_zkp_revoke_credential("did:example", "", "").await?;
792    ///     if let VadePluginResultValue::Success(Some(value)) = result {
793    ///         println!("revoked credential: {}", &value);
794    ///     }
795    ///     Ok(())
796    /// }
797    /// ```
798    async fn vc_zkp_revoke_credential(
799        &mut self,
800        method: &str,
801        options: &str,
802        payload: &str,
803    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
804        Ok(VadePluginResultValue::NotImplemented)
805    }
806
807    /// Verifies one or multiple proofs sent in a proof presentation.
808    ///
809    /// # Arguments
810    ///
811    /// * `method` - method to verify a proof for (e.g. "did:example")
812    /// * `options` - JSON string with additional information supporting the request (e.g. authentication data)
813    /// * `payload` - JSON string with information for the request (e.g. actual data to write)
814    ///
815    /// # Example
816    ///
817    /// ```
818    /// use vade::{VadePlugin, VadePluginResultValue};
819    /// // use some_crate:ExamplePlugin;
820    /// # struct ExamplePlugin { }
821    /// # impl ExamplePlugin { pub fn new() -> Self { ExamplePlugin {} } }
822    /// # impl VadePlugin for ExamplePlugin {}
823    /// async fn example() -> Result<(), Box<dyn std::error::Error>> {
824    ///     let mut ep: ExamplePlugin = ExamplePlugin::new();
825    ///     let result = ep.vc_zkp_verify_proof("did:example", "", "").await?;
826    ///     if let VadePluginResultValue::Success(Some(value)) = result {
827    ///         println!("verified proof: {}", &value);
828    ///     }
829    ///     Ok(())
830    /// }
831    /// ```
832    async fn vc_zkp_verify_proof(
833        &mut self,
834        method: &str,
835        options: &str,
836        payload: &str,
837    ) -> Result<VadePluginResultValue<Option<String>>, Box<dyn std::error::Error>> {
838        Ok(VadePluginResultValue::NotImplemented)
839    }
840}