Skip to main content

Crate actpub_webfinger

Crate actpub_webfinger 

Source
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 WebFinger link relation types used in the Fediverse.

Structs§

Account
A Fediverse account identifier of the form acct:user@host.
Jrd
A WebFinger JSON Resource Descriptor (JRD).
JrdBuilder
Builder for Jrd produced by Jrd::builder.
JrdLink
A link entry inside a Jrd.
JrdLinkBuilder
Builder for JrdLink produced by JrdLink::builder.

Enums§

Error
All failure modes for crate.

Constants§

DEFAULT_MAX_BODY_BYTESclient
Default hard cap on the response body we will read from a WebFinger endpoint.
MEDIA_TYPE
The IANA-registered media type for a WebFinger JRD response.
WELL_KNOWN_PATH
The well-known URI path for the WebFinger endpoint (RFC 7033 §4).

Functions§

fetch_atclient
Fetches and parses a Jrd from a specific URL, optionally verifying the returned subject.
fetch_at_with_limitclient
fetch_at variant that accepts an explicit body size cap.
recommended_clientclient
Builds a reqwest::Client pre-configured for safe WebFinger resolution.
resolveclient
Resolves a Fediverse Account to its Jrd via WebFinger.

Type Aliases§

Result
Crate Result alias with the default error type set to Error.