1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use crate::{Changes, Contact, IdentityChangeEvent, IdentityIdentifier, Lease, TTL};
use ockam_core::compat::{string::String, vec::Vec};
use ockam_core::vault::{PublicKey, Secret};
use ockam_core::{async_trait, compat::boxed::Box, AsyncTryClone};
use ockam_core::{Result, Route};
pub type AuthenticationProof = Vec<u8>;
#[async_trait]
pub trait IdentityTrait: AsyncTryClone + Send + Sync + 'static {
async fn identifier(&self) -> Result<IdentityIdentifier>;
async fn create_key(&mut self, label: String) -> Result<()>;
async fn add_key(&mut self, label: String, secret: &Secret) -> Result<()>;
async fn rotate_root_secret_key(&mut self) -> Result<()>;
async fn get_root_secret_key(&self) -> Result<Secret>;
async fn get_secret_key(&self, label: String) -> Result<Secret>;
async fn get_root_public_key(&self) -> Result<PublicKey>;
async fn get_public_key(&self, label: String) -> Result<PublicKey>;
async fn create_auth_proof(&mut self, state_slice: &[u8]) -> Result<AuthenticationProof>;
async fn verify_auth_proof(
&mut self,
state_slice: &[u8],
peer_id: &IdentityIdentifier,
proof_slice: &[u8],
) -> Result<bool>;
async fn add_change(&mut self, change_event: IdentityChangeEvent) -> Result<()>;
async fn get_changes(&self) -> Result<Changes>;
async fn verify_changes(&mut self) -> Result<bool>;
async fn get_contacts(&self) -> Result<Vec<Contact>>;
async fn as_contact(&mut self) -> Result<Contact>;
async fn get_contact(&mut self, contact_id: &IdentityIdentifier) -> Result<Option<Contact>>;
async fn verify_contact(&mut self, contact: Contact) -> Result<bool>;
async fn verify_and_add_contact(&mut self, contact: Contact) -> Result<bool>;
async fn verify_and_update_contact(
&mut self,
contact_id: &IdentityIdentifier,
change_events: &[IdentityChangeEvent],
) -> Result<bool>;
async fn get_lease(
&self,
lease_manager_route: &Route,
org_id: String,
bucket: String,
ttl: TTL,
) -> Result<Lease>;
async fn revoke_lease(&mut self, lease_manager_route: &Route, lease: Lease) -> Result<()>;
}