Expand description
WebFinger (RFC 7033) primitives for ActivityPub account discovery.
WebFinger is the discovery mechanism used across the Fediverse to map
acct:user@host identifiers to ActivityPub actor URLs via a
/.well-known/webfinger endpoint returning a JSON Resource
Descriptor (JRD).
§Example (client)
use actpub_webfinger::{Account, resolve};
let client = reqwest::Client::new();
let account = Account::parse("acct:gargron@mastodon.social")?;
let jrd = resolve(&account, &client).await?;
if let Some(link) = jrd.activitypub_actor() {
println!("Actor URL: {}", link.href.as_ref().unwrap());
}§Example (server)
use actpub_webfinger::{Jrd, JrdLink, rels};
let jrd = Jrd::builder("acct:alice@example.com")
.alias("https://example.com/@alice")
.link(
JrdLink::builder(rels::ACTIVITYPUB_ACTOR)
.href("https://example.com/users/alice".parse().unwrap())
.media_type("application/activity+json")
.build(),
)
.build();
let json = serde_json::to_string(&jrd).unwrap();
assert!(json.contains(r#""subject":"acct:alice@example.com""#));Modules§
- rels
- Well-known
WebFingerlink relation types used in the Fediverse.
Structs§
- Account
- A Fediverse account identifier of the form
acct:user@host. - Jrd
- A
WebFingerJSON Resource Descriptor (JRD). - JrdBuilder
- Builder for
Jrdproduced byJrd::builder. - JrdLink
- A link entry inside a
Jrd. - JrdLink
Builder - Builder for
JrdLinkproduced byJrdLink::builder.
Enums§
Constants§
- DEFAULT_
CONNECT_ TIMEOUT client - Default TCP-connect timeout used by
recommended_client. - DEFAULT_
MAX_ BODY_ BYTES client - Default hard cap on the response body we will read from a
WebFingerendpoint. - DEFAULT_
REQUEST_ TIMEOUT client - Default end-to-end request timeout used by
recommended_client. - MEDIA_
TYPE - The IANA-registered media type for a
WebFingerJRD response. - WELL_
KNOWN_ PATH - The well-known URI path for the
WebFingerendpoint (RFC 7033 §4).
Functions§
- fetch_
at client - Fetches and parses a
Jrdfrom a specific URL, optionally verifying the returned subject. - fetch_
at_ with_ limit client fetch_atvariant that accepts an explicit body size cap.- recommended_
client client - Builds a
reqwest::Clientpre-configured for safeWebFingerresolution. - resolve
client - Resolves a Fediverse
Accountto itsJrdviaWebFinger.