1use serde::{Deserialize, Serialize};
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum SecurityMode {
18 Plain,
20 Signed,
22 AuthCrypt,
24 Any,
26}
27
28pub const PRESENTATION_MESSAGE_TYPE: &str = "https://tap.rsvp/schema/1.0#Presentation";
33
34pub const DIDCOMM_SIGNED: &str = "application/didcomm-signed+json";
35pub const DIDCOMM_ENCRYPTED: &str = "application/didcomm-encrypted+json";
36
37#[derive(Serialize, Deserialize, Debug)]
40pub struct Jws {
41 pub payload: String,
42 pub signatures: Vec<JwsSignature>,
43}
44
45#[derive(Serialize, Deserialize, Debug)]
46pub struct JwsSignature {
47 pub protected: String,
48 pub signature: String,
49 pub header: JwsHeader,
50}
51
52#[derive(Serialize, Deserialize, Debug)]
53pub struct JwsHeader {
54 pub kid: String,
55}
56
57#[derive(Serialize, Deserialize, Debug, Clone)]
59pub struct JwsProtected {
60 #[serde(default = "default_didcomm_signed")]
61 pub typ: String,
62 pub alg: String,
63}
64
65fn default_didcomm_signed() -> String {
67 DIDCOMM_SIGNED.to_string()
68}
69#[derive(Serialize, Deserialize, Debug)]
72pub struct Jwe {
73 pub ciphertext: String,
74 pub protected: String,
75 pub recipients: Vec<JweRecipient>,
76 pub tag: String,
77 pub iv: String,
78}
79
80#[derive(Serialize, Deserialize, Debug)]
81pub struct JweRecipient {
82 pub encrypted_key: String,
83 pub header: JweHeader,
84}
85
86#[derive(Serialize, Deserialize, Debug)]
87pub struct JweHeader {
88 pub kid: String,
89 #[serde(skip_serializing_if = "Option::is_none")]
90 pub sender_kid: Option<String>,
91}
92
93#[derive(Serialize, Deserialize, Debug)]
95pub struct JweProtected {
96 pub epk: EphemeralPublicKey,
97 pub apv: String,
98 #[serde(default = "default_didcomm_encrypted")]
99 pub typ: String,
100 pub enc: String,
101 pub alg: String,
102}
103
104fn default_didcomm_encrypted() -> String {
106 DIDCOMM_ENCRYPTED.to_string()
107}
108
109#[derive(Serialize, Deserialize, Debug)]
111#[serde(tag = "kty")]
112pub enum EphemeralPublicKey {
113 #[serde(rename = "EC")]
114 Ec { crv: String, x: String, y: String },
115 #[serde(rename = "OKP")]
116 Okp { crv: String, x: String },
117}