Parakeet is a Rust-based Bluesky AppServer aiming to implement most of the functionality required to support the Bluesky client
appview atproto bluesky rust appserver
66
fork

Configure Feed

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

feat(did-resolver): useful finder functions

Mia a350f43a d8a7e285

+18 -9
+2 -5
consumer/src/backfill/mod.rs
··· 147 147 eyre::bail!("missing did doc"); 148 148 }; 149 149 150 - let Some(service) = did_doc 151 - .service 152 - .and_then(|services| services.into_iter().find(|svc| svc.id == PDS_SERVICE_ID)) 153 - else { 150 + let Some(service) = did_doc.find_service_by_id(PDS_SERVICE_ID) else { 154 151 eyre::bail!("DID doc contained no service endpoint"); 155 152 }; 156 153 157 - let pds_url = service.service_endpoint; 154 + let pds_url = service.service_endpoint.clone(); 158 155 159 156 // check the repo status before we attempt to resolve the handle. There's a case where we can't 160 157 // resolve the handle in the DID doc because the acc is already deleted.
+14
did-resolver/src/types.rs
··· 12 12 pub verification_method: Option<Vec<DidVerificationMethod>>, 13 13 } 14 14 15 + impl DidDocument { 16 + pub fn find_service_by_id(&self, service: &str) -> Option<&DidService> { 17 + self.service 18 + .as_ref() 19 + .and_then(|services| services.iter().find(|s| s.id == service)) 20 + } 21 + 22 + pub fn find_verif_method_by_type(&self, ty: &str) -> Option<&DidVerificationMethod> { 23 + self.verification_method 24 + .as_ref() 25 + .and_then(|methods| methods.iter().find(|m| m.ty == ty)) 26 + } 27 + } 28 + 15 29 #[derive(Debug, Deserialize)] 16 30 #[serde(rename_all = "camelCase")] 17 31 pub struct DidService {
+2 -4
parakeet/src/xrpc/jwt.rs
··· 60 60 let did_doc = self.resolver.resolve_did(did).await.ok()??; 61 61 62 62 // try find the multibase key 63 - let multikey = did_doc 64 - .verification_method 65 - .and_then(|vms| vms.into_iter().find(|vm| vm.ty == "Multikey"))?; 63 + let multikey = did_doc.find_verif_method_by_type("Multikey")?; 66 64 67 65 { 68 66 let mut l = self.key_cache.write().await; 69 67 l.insert(did.to_string(), multikey.public_key_multibase.clone()); 70 68 } 71 69 72 - Some(multikey.public_key_multibase) 70 + Some(multikey.public_key_multibase.clone()) 73 71 } 74 72 75 73 pub fn verify_jwt_multibase(&self, token: &str, multibase_key: &str) -> Option<Claims> {