ockam_entity/worker/
request.rs

1use crate::{
2    AuthenticationProof, Changes, Contact, Lease, ProfileChangeEvent, ProfileIdentifier, TTL,
3};
4use cfg_if::cfg_if;
5use ockam_core::compat::{string::String, vec::Vec};
6use ockam_core::vault::Secret;
7use ockam_core::{Address, Message, Route};
8use serde::{Deserialize, Serialize};
9
10pub type EventAttribute = (String, String);
11pub type EventAttributes = Vec<EventAttribute>;
12pub type ByteVec = Vec<u8>;
13pub type Id = ProfileIdentifier;
14
15#[allow(clippy::large_enum_variant)]
16#[derive(Clone, Serialize, Deserialize, Message)]
17pub enum IdentityRequest {
18    CreateProfile(Address),
19    CreateAuthenticationProof(Id, ByteVec),
20    CreateKey(Id, String),
21    AddKey(Id, String, Secret),
22    GetProfilePublicKey(Id),
23    GetProfileSecretKey(Id),
24    GetPublicKey(Id, String),
25    GetSecretKey(Id, String),
26    GetChanges(Id),
27    GetContacts(Id),
28    GetContact(Id, Id),
29    RotateKey(Id),
30    AddChange(Id, ProfileChangeEvent),
31    VerifyAuthenticationProof(Id, ByteVec, Id, AuthenticationProof),
32    VerifyChanges(Id),
33    VerifyAndAddContact(Id, Contact),
34    VerifyContact(Id, Contact),
35    VerifyAndUpdateContact(Id, Id, Changes),
36    RemoveProfile(Id),
37    CreateSecureChannelListener(Id, Address, Address),
38    CreateSecureChannel(Id, Route, Address),
39    GetLease(Route, Id, String, String, TTL),
40    RevokeLease(Route, Id, Lease),
41    #[cfg(feature = "credentials")]
42    CredentialRequest(IdentityCredentialRequest),
43}
44
45cfg_if! {
46    if #[cfg(feature = "credentials")] {
47        use crate::{
48            BbsCredential, Credential, CredentialAttribute, CredentialFragment1, CredentialFragment2,
49            CredentialOffer, CredentialPresentation, CredentialProof, CredentialPublicKey,
50            CredentialRequest, CredentialSchema, EntityCredential, OfferId, PresentationManifest,
51            ProofRequestId,
52        };
53
54        #[derive(Clone, Serialize, Deserialize)]
55        pub enum IdentityCredentialRequest {
56            GetSigningKey(Id),
57            GetIssuerPublicKey(Id),
58            CreateOffer(Id, CredentialSchema),
59            CreateProofOfPossession(Id),
60            SignCredential(Id, CredentialSchema, Vec<CredentialAttribute>),
61            SignCredentialRequest(
62                Id,
63                CredentialRequest,
64                CredentialSchema,
65                Vec<(String, CredentialAttribute)>,
66                OfferId,
67            ),
68            AcceptCredentialOffer(Id, CredentialOffer, CredentialPublicKey),
69            CombineCredentialFragments(Id, CredentialFragment1, CredentialFragment2),
70            IsValidCredential(Id, BbsCredential, CredentialPublicKey),
71            PresentCredential(Id, BbsCredential, PresentationManifest, ProofRequestId),
72            CreateProofRequestId(Id),
73            VerifyProofOfPossession(Id, CredentialPublicKey, CredentialProof),
74            VerifyCredentialPresentation(
75                Id,
76                CredentialPresentation,
77                PresentationManifest,
78                ProofRequestId,
79            ),
80            AddCredential(Id, EntityCredential),
81            GetCredential(Id, Credential),
82        }
83    }
84}