siera_agent/modules/
credential.rs

1use async_trait::async_trait;
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4
5use crate::error::Result;
6
7/// Response structure gotten from the cloudagent when offering a credential
8#[derive(Debug, Serialize, Deserialize)]
9pub struct CredentialOfferResponse {
10    /// Whether it should auto issue the credential
11    pub auto_issue: bool,
12
13    /// Whether it should auto offer the credential
14    pub auto_offer: bool,
15
16    /// The conneciton id used to send the credential to
17    pub connection_id: String,
18
19    /// When the credential offer was created
20    pub created_at: String,
21
22    /// The credential definition id used for the credential
23    pub credential_definition_id: String,
24
25    /// Returned credential exchange id used for further credential functionality
26    pub credential_exchange_id: String,
27
28    /// The credential offer object
29    pub credential_offer: Value,
30
31    /// Dictionary of the credential offer
32    pub credential_offer_dict: Value,
33
34    /// Dictionary of the credential proposal
35    pub credential_proposal_dict: Value,
36
37    /// Who initiated the credential offer
38    pub initiator: String,
39
40    /// Your role in the credential offer flow
41    pub role: String,
42
43    /// Which schema was used when offering the credential
44    pub schema_id: String,
45
46    /// What the state is in the credential offer flow
47    pub state: String,
48
49    /// Thread id to refer to this offer
50    pub thread_id: String,
51
52    /// Last time the credential offer was updated
53    pub updated_at: String,
54}
55
56/// Options when offering a credential
57pub struct CredentialOfferOptions {
58    /// Connection id to send the credential to
59    pub connection_id: String,
60
61    /// Credential definition id used a blueprint for the credential
62    pub cred_def_id: String,
63
64    /// Keys that are in the credential definition that must be filled in
65    pub keys: Vec<String>,
66
67    /// Values for the keys
68    /// these are index-matched
69    pub values: Vec<String>,
70}
71
72/// Generic cloudagent credential module
73#[async_trait]
74pub trait CredentialModule {
75    /// Send a credential offer to the connection id supplied in the options
76    async fn send_offer(&self, options: CredentialOfferOptions) -> Result<CredentialOfferResponse>;
77}