ceres: a small planet in a giant solar system
33
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 60 lines 1.6 kB view raw
1use axum::Json; 2use serde::Serialize; 3use std::env; 4 5#[derive(Serialize)] 6#[serde(rename_all = "camelCase")] 7pub struct DidDocument { 8 #[serde(rename = "@context")] 9 context: Vec<String>, 10 id: String, 11 verification_method: Vec<VerificationMethod>, 12 service: Vec<Service>, 13} 14 15#[derive(Serialize)] 16#[serde(rename_all = "camelCase")] 17struct VerificationMethod { 18 id: String, 19 #[serde(rename = "type")] 20 type_: String, 21 controller: String, 22 public_key_multibase: Option<String>, 23} 24 25#[derive(Serialize)] 26#[serde(rename_all = "camelCase")] 27struct Service { 28 id: String, 29 #[serde(rename = "type")] 30 type_: String, 31 service_endpoint: String, 32} 33 34pub async fn did_document() -> Json<DidDocument> { 35 let domain = 36 env::var("APP_VIEW_DOMAIN").unwrap_or_else(|_| "api.blacksky.community".to_string()); 37 let did_id = format!("did:web:{domain}"); 38 let endpoint = format!("https://{domain}"); 39 40 Json(DidDocument { 41 context: vec![ 42 "https://www.w3.org/ns/did/v1".to_string(), 43 "https://w3id.org/security/multikey/v1".to_string(), 44 ], 45 verification_method: vec![VerificationMethod { 46 id: format!("{did_id}#atproto"), 47 type_: "Multikey".to_string(), 48 controller: did_id.clone(), 49 public_key_multibase: Some( 50 "z42tusbpVy6BCE8tqcQAkvvRi9W3M7LEqLWNdTxtW2KicMNJ".to_string(), 51 ), 52 }], 53 service: vec![Service { 54 id: "#bsky_appview".to_string(), 55 type_: "BskyAppView".to_string(), 56 service_endpoint: endpoint, 57 }], 58 id: did_id, 59 }) 60}