siera_agent/modules/wallet.rs
1use crate::error::Result;
2use async_trait::async_trait;
3use serde::{Deserialize, Serialize};
4
5/// Options that are supplied when querying a wallet for DIDs
6#[derive(Debug, Deserialize, Serialize)]
7pub struct Did {
8 /// The DID of interest
9 pub did: Option<String>,
10
11 // TODO: enum
12 /// The key type to query for eg. ed25519, bls12381g2
13 pub key_type: Option<String>,
14
15 // TODO: enum
16 /// DID method to query for. e.g. sov to only fetch indy/sov DIDs Available values : key, sov
17 pub method: Option<String>,
18
19 // TODO: enum
20 /// The DID posture specifying whether the DID is
21 /// the current public DID,
22 /// posted to ledger but current public DID,
23 /// or local to the wallet
24 /// Available values : public, posted, wallet_only
25 pub posture: Option<String>,
26
27 /// The verification key of interest
28 pub verkey: Option<String>,
29}
30
31/// Response from the cloudagent when requesting info about dids
32/// of a wallet
33#[derive(Debug, Deserialize, Serialize)]
34pub struct DidList(Vec<Did>);
35
36/// Response from the cloudagent when requesting info about dids
37/// of a wallet
38#[derive(Debug, Deserialize, Serialize)]
39pub struct DidResult(Did);
40
41/// Key type in a JSON format k,v pair
42#[derive(Debug, Deserialize, Serialize)]
43pub struct KeyType {
44 // TODO: enum
45 /// The key type to query for eg. ed25519, bls12381g2
46 pub key_type: String,
47}
48
49/// Options that are supplied when querying a wallet for DIDs
50#[derive(Debug, Deserialize, Serialize)]
51pub struct CreateLocalDidOptions {
52 /// DID method to query for. e.g. sov to only fetch indy/sov DIDs Available values : key, sov
53 pub method: String,
54
55 /// The key type to query for eg. ed25519, bls12381g2
56 pub options: KeyType,
57}
58
59/// Options that are supplied when querying a wallet for DIDs
60#[derive(Debug, Deserialize, Serialize)]
61pub struct DidEndpoint {
62 /// The DID of interest
63 pub did: String,
64
65 /// The endpoint url
66 pub endpoint: String,
67}
68
69/// Options that are supplied when querying a wallet for DIDs
70#[derive(Debug, Deserialize, Serialize)]
71pub struct SetDidEndpointOptions {
72 /// The DID of interest
73 pub did: String,
74
75 /// The endpoint url
76 pub endpoint: String,
77
78 ///The endpoint type eg. 'Endpoint'
79 pub endpoint_type: String,
80}
81
82/// Generic cloudagent basic message module
83#[async_trait]
84pub trait WalletModule {
85 /// Query a wallet for DIDs
86 async fn get_wallet_dids(&self, options: Did) -> Result<DidList>;
87
88 /// Create a local DID
89 async fn create_local_did(&self, options: CreateLocalDidOptions) -> Result<Did>;
90
91 /// Rotate key pair
92 async fn rotate_keypair(&self, did: String) -> Result<()>;
93
94 /// Fetch public did
95 async fn fetch_public_did(&self) -> Result<Did>;
96
97 /// Assign the current public DID
98 async fn assign_public_did(&self, did: String) -> Result<Did>;
99
100 /// Query DID endpoint of wallet
101 async fn fetch_did_endpoint(&self, did: String) -> Result<DidEndpoint>;
102
103 /// Set DID endpoint of wallet
104 async fn set_did_endpoint(&self, options: SetDidEndpointOptions) -> Result<()>;
105}