1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! `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] endpoint returning a JSON Resource
//! Descriptor (JRD).
//!
//! # Example (client)
//!
//! ```no_run
//! # #[cfg(feature = "client")]
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! 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());
//! }
//! # Ok(()) }
//! ```
//!
//! # 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""#));
//! ```
//!
//! [endpoint]: https://datatracker.ietf.org/doc/html/rfc7033#section-4
pub use Account;
pub use ;
pub use Error;
pub use ;
/// Crate [`Result`] alias with the default error type set to [`Error`].
pub type Result<T, E = Error> = Result;
/// The IANA-registered media type for a `WebFinger` JRD response.
pub const MEDIA_TYPE: &str = "application/jrd+json";
/// The well-known URI path for the `WebFinger` endpoint (RFC 7033 ยง4).
pub const WELL_KNOWN_PATH: &str = "/.well-known/webfinger";