Expand description
WebFinger (RFC 7033), the successor that honours finger by name.
Where finger returned whatever text a host felt like printing, WebFinger
returns a JSON Resource Descriptor: a subject, its aliases, and a list
of typed links. It is what resolves @alice@example.social on the
fediverse, and it is the discovery step in OpenID Connect.
§What this module does and does not do
WebFinger rides on HTTPS, and this crate does not contain an HTTP client. It implements the two spec-shaped halves and leaves the GET to the caller, who almost certainly has an HTTP stack already:
request_urlbuilds the well-known URI, with the resource and anyrelfilters correctly encoded;parsereads the JRD that comes back.
Perform the request with Accept: application/jrd+json (MEDIA_TYPE).
use finger_protocol::webfinger::{acct, request_url, parse};
let url = request_url("example.social", &acct("alice", "example.social"), &["self"]);
assert_eq!(
url,
"https://example.social/.well-known/webfinger\
?resource=acct%3Aalice%40example.social&rel=self"
);
// ... GET that URL, then:
let jrd = parse(r#"{"subject":"acct:alice@example.social",
"links":[{"rel":"self","type":"application/activity+json",
"href":"https://example.social/users/alice"}]}"#).unwrap();
assert_eq!(jrd.link("self").unwrap().href.as_deref(),
Some("https://example.social/users/alice"));Structs§
Constants§
- MEDIA_
TYPE - The media type of a JRD document, for the request’s
Acceptheader. - WELL_
KNOWN_ PATH - The path every WebFinger query is served from.
Functions§
- acct
- Build an
acct:URI (RFC 7565), the usual way to name a person. - parse
- Parse a JRD document.
- request_
url - Build the WebFinger request URL for a resource at a host.