wip
1use alloc::{string::String, vec::Vec};
2use serde::{Deserialize, Serialize};
3
4#[allow(clippy::large_enum_variant)]
5#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
6pub enum Request {
7 Exit,
8 GetDidKey {
9 index: u32,
10 display: bool,
11 },
12 SignPlcOperation {
13 key_index: u32,
14 operation: PlcOperation,
15 previous: Option<SignedPlcOperation>,
16 },
17}
18
19#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
20#[serde(rename_all = "camelCase")]
21pub struct PlcOperation {
22 pub r#type: String,
23 pub rotation_keys: Vec<String>,
24 pub verification_methods: VerificationMethods,
25 pub also_known_as: Vec<String>,
26 pub services: Services,
27 pub prev: Option<String>,
28}
29
30impl PlcOperation {
31 pub fn signed(self, sig: String) -> SignedPlcOperation {
32 SignedPlcOperation {
33 r#type: self.r#type,
34 rotation_keys: self.rotation_keys,
35 verification_methods: self.verification_methods,
36 also_known_as: self.also_known_as,
37 services: self.services,
38 prev: self.prev,
39 sig,
40 }
41 }
42}
43
44#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
45#[serde(rename_all = "camelCase")]
46pub struct SignedPlcOperation {
47 pub r#type: String,
48 pub rotation_keys: Vec<String>,
49 pub verification_methods: VerificationMethods,
50 pub also_known_as: Vec<String>,
51 pub services: Services,
52 pub prev: Option<String>,
53 pub sig: String,
54}
55
56#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
57#[serde(rename_all = "camelCase")]
58pub struct VerificationMethods {
59 pub atproto: String,
60}
61
62#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
63pub struct Services {
64 pub atproto_pds: Service,
65}
66
67#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
68#[serde(rename_all = "camelCase")]
69pub struct Service {
70 pub r#type: String,
71 pub endpoint: String,
72}
73
74#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
75pub enum Response {
76 DidKey(Vec<u8>),
77 Signature(Vec<u8>),
78 Error(String),
79}