A library for ATProtocol identities.

chore: cleanup in advance of release

Signed-off-by: Nick Gerakines <nick.gerakines@gmail.com>

Changed files
+40 -43
crates
atproto-identity
atproto-oauth
src
atproto-oauth-axum
atproto-xrpcs-helloworld
src
+2 -4
crates/atproto-identity/src/bin/atproto-identity-resolve.rs
··· 6 6 use atproto_identity::{ 7 7 config::{CertificateBundles, DnsNameservers, default_env, optional_env, version}, 8 8 plc::query as plc_query, 9 - resolve::{InputType, HickoryDnsResolver, parse_input, resolve_subject}, 9 + resolve::{HickoryDnsResolver, InputType, parse_input, resolve_subject}, 10 10 web::query as web_query, 11 11 }; 12 12 use clap::Parser; ··· 75 75 for subject in args.subjects { 76 76 let resolved_did = resolve_subject(&http_client, &dns_resolver, &subject).await; 77 77 let resolved_did = match resolved_did { 78 - Ok(value) => { 79 - value 80 - } 78 + Ok(value) => value, 81 79 Err(err) => { 82 80 eprintln!("{err}"); 83 81 continue;
+1 -1
crates/atproto-identity/src/lib.rs
··· 49 49 #[cfg(feature = "lru")] 50 50 pub mod storage_lru; 51 51 pub mod validation; 52 - pub mod web; 52 + pub mod web;
+7 -13
crates/atproto-identity/src/resolve.rs
··· 39 39 use crate::web::query as web_query; 40 40 41 41 /// Trait for AT Protocol identity resolution. 42 - /// 42 + /// 43 43 /// Implementations must be thread-safe (Send + Sync) and usable in async environments. 44 44 /// This trait provides the core functionality for resolving AT Protocol subjects 45 45 /// (handles or DIDs) to their corresponding DID documents. ··· 91 91 tracing::debug!("Using custom DNS nameservers: {:?}", nameservers); 92 92 let nameserver_group = NameServerConfigGroup::from_ips_clear(nameservers, 53, true); 93 93 let resolver_config = ResolverConfig::from_parts(None, vec![], nameserver_group); 94 - Resolver::builder_with_config(resolver_config, TokioConnectionProvider::default()).build() 94 + Resolver::builder_with_config(resolver_config, TokioConnectionProvider::default()) 95 + .build() 95 96 } else { 96 97 tracing::debug!("Using system default DNS nameservers"); 97 98 Resolver::builder_tokio().unwrap().build() ··· 104 105 #[async_trait::async_trait] 105 106 impl DnsResolver for HickoryDnsResolver { 106 107 async fn resolve_txt(&self, domain: &str) -> Result<Vec<String>, ResolveError> { 107 - let lookup = self.resolver 108 + let lookup = self 109 + .resolver 108 110 .txt_lookup(domain) 109 111 .instrument(tracing::info_span!("txt_lookup")) 110 112 .await 111 113 .map_err(|error| ResolveError::DNSResolutionFailed { error })?; 112 114 113 - Ok(lookup 114 - .iter() 115 - .map(|record| record.to_string()) 116 - .collect()) 115 + Ok(lookup.iter().map(|record| record.to_string()).collect()) 117 116 } 118 117 } 119 118 ··· 141 140 142 141 let dids = txt_records 143 142 .iter() 144 - .filter_map(|record| { 145 - record 146 - .strip_prefix("did=") 147 - .map(|did| did.to_string()) 148 - }) 143 + .filter_map(|record| record.strip_prefix("did=").map(|did| did.to_string())) 149 144 .collect::<HashSet<String>>(); 150 145 151 146 if dids.len() > 1 { ··· 261 256 InputType::Plc(did) | InputType::Web(did) => Ok(did), 262 257 } 263 258 } 264 - 265 259 266 260 /// Core identity resolution components for AT Protocol subjects. 267 261 ///
+8 -10
crates/atproto-oauth-axum/src/bin/atproto-oauth-tool.rs
··· 37 37 38 38 #[cfg(feature = "hickory-dns")] 39 39 use atproto_identity::resolve::HickoryDnsResolver; 40 + use atproto_identity::resolve::IdentityResolver; 41 + use atproto_identity::resolve::InnerIdentityResolver; 42 + use atproto_identity::resolve::SharedIdentityResolver; 40 43 use atproto_oauth::{ 41 44 pkce, 42 45 resources::pds_resources, ··· 44 47 storage_lru::LruOAuthRequestStorage, 45 48 workflow::{OAuthClient, OAuthRequest, OAuthRequestState, oauth_init, oauth_refresh}, 46 49 }; 47 - use atproto_identity::resolve::InnerIdentityResolver; 48 - use atproto_identity::resolve::SharedIdentityResolver; 49 - use atproto_identity::resolve::IdentityResolver; 50 50 use atproto_oauth_axum::errors::OAuthLoginError; 51 51 use atproto_oauth_axum::{handle_complete::handle_oauth_callback, handle_jwks::handle_oauth_jwks}; 52 52 use atproto_oauth_axum::{handler_metadata::handle_oauth_metadata, state::OAuthClientConfig}; ··· 293 293 signing_key_storage.insert(public_signing_key, signing_key.clone()); 294 294 } 295 295 296 - let identity_resolver = Arc::new(SharedIdentityResolver( 297 - Arc::new(InnerIdentityResolver { 298 - dns_resolver: Arc::new(dns_resolver), 299 - http_client: http_client.clone(), 300 - plc_hostname: plc_hostname.clone(), 301 - }) 302 - )); 296 + let identity_resolver = Arc::new(SharedIdentityResolver(Arc::new(InnerIdentityResolver { 297 + dns_resolver: Arc::new(dns_resolver), 298 + http_client: http_client.clone(), 299 + plc_hostname: plc_hostname.clone(), 300 + }))); 303 301 304 302 let web_context = WebContext(Arc::new(InnerWebContext { 305 303 http_client: http_client.clone(),
+8 -3
crates/atproto-oauth-axum/src/handle_complete.rs
··· 7 7 8 8 use anyhow::Result; 9 9 use atproto_identity::{ 10 - key::{identify_key, KeyProvider}, storage::DidDocumentStorage, 10 + key::{KeyProvider, identify_key}, 11 + storage::DidDocumentStorage, 11 12 }; 12 13 use atproto_oauth::{ 13 - resources::pds_resources, storage::OAuthRequestStorage, workflow::{oauth_complete, OAuthClient} 14 + resources::pds_resources, 15 + storage::OAuthRequestStorage, 16 + workflow::{OAuthClient, oauth_complete}, 14 17 }; 15 18 use axum::{ 16 - extract::State, response::{IntoResponse, Response}, Form 19 + Form, 20 + extract::State, 21 + response::{IntoResponse, Response}, 17 22 }; 18 23 use http::StatusCode; 19 24 use serde::{Deserialize, Serialize};
-1
crates/atproto-oauth/src/lib.rs
··· 25 25 pub mod storage_lru; 26 26 /// OAuth workflow implementation for AT Protocol authorization flows. 27 27 pub mod workflow; 28 -
+14 -11
crates/atproto-xrpcs-helloworld/src/main.rs
··· 2 2 3 3 use anyhow::Result; 4 4 use async_trait::async_trait; 5 + use atproto_identity::resolve::SharedIdentityResolver; 5 6 use atproto_identity::{ 6 7 config::{CertificateBundles, DnsNameservers, default_env, optional_env, require_env, version}, 7 8 key::{KeyData, KeyProvider, identify_key, to_public}, 8 - resolve::{IdentityResolver, InnerIdentityResolver, HickoryDnsResolver}, 9 + resolve::{HickoryDnsResolver, IdentityResolver, InnerIdentityResolver}, 9 10 storage::DidDocumentStorage, 10 11 storage_lru::LruDidDocumentStorage, 11 12 }; 12 - use atproto_identity::resolve::SharedIdentityResolver; 13 13 use atproto_xrpcs::authorization::ResolvingAuthorization; 14 14 use axum::{ 15 - extract::{FromRef, Query, State}, response::{Html, IntoResponse, Response}, routing::get, Json, Router 15 + Json, Router, 16 + extract::{FromRef, Query, State}, 17 + response::{Html, IntoResponse, Response}, 18 + routing::get, 16 19 }; 17 20 use clap::Parser; 18 21 use http::{HeaderMap, StatusCode}; ··· 201 204 202 205 let service_did = ServiceDID(service_did); 203 206 204 - let identity_resolver = Arc::new(SharedIdentityResolver( 205 - Arc::new(InnerIdentityResolver { 206 - dns_resolver: Arc::new(dns_resolver), 207 - http_client: http_client.clone(), 208 - plc_hostname, 209 - }) 210 - )); 207 + let identity_resolver = Arc::new(SharedIdentityResolver(Arc::new(InnerIdentityResolver { 208 + dns_resolver: Arc::new(dns_resolver), 209 + http_client: http_client.clone(), 210 + plc_hostname, 211 + }))); 211 212 212 213 let web_context = WebContext(Arc::new(InnerWebContext { 213 214 http_client: http_client.clone(), ··· 259 260 } 260 261 261 262 // /.well-known/did.json 262 - async fn handle_wellknown_did_web(service_document: State<ServiceDocument>) -> Json<serde_json::Value> { 263 + async fn handle_wellknown_did_web( 264 + service_document: State<ServiceDocument>, 265 + ) -> Json<serde_json::Value> { 263 266 Json(service_document.0.0) 264 267 } 265 268