ceres: a small planet in a giant solar system
1use std::sync::Arc;
2
3use jacquard::client::credential_session::SessionKey;
4use jacquard::client::{AtpSession, CredentialAgent, MemorySessionStore};
5use jacquard::{prelude::JacquardResolver, types::did::Did};
6use jacquard_axum::service_auth::{ServiceAuth, ServiceAuthConfig};
7
8use crate::storage::DbRef;
9
10pub type AppAgent = CredentialAgent<MemorySessionStore<SessionKey, AtpSession>, JacquardResolver>;
11
12#[derive(Clone)]
13pub struct AppState {
14 pub service_auth: ServiceAuthConfig<JacquardResolver>,
15 pub reqwest_client: reqwest::Client,
16 pub agent: Arc<AppAgent>,
17 pub resolver: JacquardResolver,
18 pub forwarded_app_view: Option<String>,
19 pub constellation_host: String,
20 pub db: DbRef,
21}
22
23impl ServiceAuth for AppState {
24 type Resolver = JacquardResolver;
25
26 fn service_did(&self) -> &Did<'_> {
27 ServiceAuth::service_did(&self.service_auth)
28 }
29
30 fn resolver(&self) -> &Self::Resolver {
31 ServiceAuth::resolver(&self.service_auth)
32 }
33
34 fn require_lxm(&self) -> bool {
35 ServiceAuth::require_lxm(&self.service_auth)
36 }
37}