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
mod did;
mod stage;
pub use did::document;
pub use stage::{run_stage, seed, stage_bytes};
use atproto_identity::key::{KeyData, KeyType, generate_key};
use reqwest::StatusCode;
use serde_json::Value;
use zkwid::lexicon::StrongRef;
#[derive(Clone)]
pub struct Host {
pub did: String,
pub base_url: String,
pub signing_key: KeyData,
pub n_url: String,
pub n_did: String,
pub http: reqwest::Client,
}
#[derive(Clone)]
pub struct Instance {
pub key: KeyData,
pub uri: String,
pub n_url: String,
pub n_did: String,
pub http: reqwest::Client,
}
impl Host {
pub fn new(
did: &str,
base_url: &str,
n_url: &str,
n_did: &str,
http: reqwest::Client,
) -> anyhow::Result<Self> {
Ok(Self {
did: did.to_string(),
base_url: base_url.to_string(),
signing_key: generate_key(KeyType::K256Private)?,
n_url: n_url.to_string(),
n_did: n_did.to_string(),
http,
})
}
pub fn router(&self) -> axum::Router {
did::router(self.did.clone(), self.signing_key.clone())
}
pub async fn challenge(&self, _repo: &str, _workload: &StrongRef) -> anyhow::Result<String> {
todo!()
}
pub async fn create_key(
&self,
_repo: &str,
_workload: &StrongRef,
_stages: &[Vec<u8>],
_instance: &str,
) -> anyhow::Result<Instance> {
todo!()
}
pub async fn delete_key(&self, _uri: &str) -> anyhow::Result<()> {
todo!()
}
}
impl Instance {
pub fn token(&self, _lxm: &str) -> anyhow::Result<String> {
todo!()
}
pub async fn call(&self, _lxm: &str, _body: &Value) -> anyhow::Result<(StatusCode, Value)> {
todo!()
}
}