activitypub-federation-rust/README.md

57 lines
3.8 KiB
Markdown
Raw Normal View History

2022-06-02 16:47:12 +05:30
Activitypub-Federation
===
[![Build Status](https://drone.join-lemmy.org/api/badges/LemmyNet/activitypub-federation-rust/status.svg)](https://drone.join-lemmy.org/LemmyNet/activitypub-federation-rust)
2022-06-02 17:44:36 +05:30
[![Crates.io](https://img.shields.io/crates/v/activitypub-federation.svg)](https://crates.io/crates/activitypub-federation)
2022-06-02 16:47:12 +05:30
2022-06-02 17:44:36 +05:30
A high-level framework for [ActivityPub](https://www.w3.org/TR/activitypub/) federation in Rust, extracted from [Lemmy](https://join-lemmy.org/). The goal is that this library can take care of almost everything related to federation for different projects. For now it is still far away from that goal, and has many rough edges that need to be smoothed.
2022-06-02 16:47:12 +05:30
You can join the Matrix channel [#activitystreams:matrix.asonix.dog](https://matrix.to/#/%23activitystreams:matrix.asonix.dog?via=matrix.asonix.dog) to discuss about Activitypub in Rust.
2022-11-28 19:28:28 +05:30
2022-06-02 16:47:12 +05:30
## Features
- ObjectId type, wraps the `id` url and allows for type safe fetching of objects, both from database and HTTP
- Queue for activity sending, handles HTTP signatures, retry with exponential backoff, all in background workers
- Inbox for receiving activities, verifies HTTP signatures, performs other basic checks and helps with routing
2022-06-02 17:44:36 +05:30
- Data structures for federation are defined by the user, not the library. This gives you maximal flexibility, and lets you accept only messages which your code can handle. Others are rejected automatically during deserialization.
2022-06-02 16:47:12 +05:30
- Generic error type (unfortunately this was necessary)
- various helpers for verification, (de)serialization, context etc
2022-06-02 17:44:36 +05:30
## How to use
2023-01-07 03:55:28 +05:30
To get started, have a look at the [API documentation](https://docs.rs/activitypub_federation/latest/activitypub_federation/)
and [example code](https://github.com/LemmyNet/activitypub-federation-rust/tree/main/examples). You can also find some [ActivityPub resources in the Lemmy documentation](https://join-lemmy.org/docs/en/contributing/resources.html#activitypub-resources).
If anything is unclear, please open an issue for clarification. For a more advanced implementation,
take a look at the [Lemmy federation code](https://github.com/LemmyNet/lemmy/tree/main/crates/apub).
Currently supported frameworks include [actix](https://actix.rs/) and [axum](https://github.com/tokio-rs/axum):
**actix:**
```toml
activitypub_federation = { version = "*", features = ["actix"] }
```
**axum:**
```toml
activitypub_federation = { version = "*", features = ["axum"] }
```
2022-06-02 17:44:36 +05:30
2022-06-02 16:47:12 +05:30
## Roadmap
Things to work on in the future:
2022-06-02 17:44:36 +05:30
- **Improve documentation and example**: Some things could probably be documented better. The example code should be simplified. where possible.
2022-06-02 16:47:12 +05:30
- **Simplify generics**: The library uses a lot of generic parameters, where clauses and associated types. It should be possible to simplify them.
- **Improve macro**: The macro is implemented very badly and doesn't have any error handling.
- **Generate HTTP endpoints**: It would be possible to generate HTTP endpoints automatically for each actor.
- **Support for other web frameworks**: Can be implemented using feature flags if other projects require it.
- **Signed fetch**: JSON can only be fetched by authenticated actors, which means that fetches from blocked instances can also be blocked. In combination with the previous point, this could be handled entirely in the library.
- **Helpers for testing**: Lemmy has a pretty useful test suite which (de)serializes json from other projects, to ensure that federation remains compatible. Helpers for this could be added to the library.
- **[Webfinger](https://datatracker.ietf.org/doc/html/rfc7033) support**: Not part of the Activitypub standard, but often used together for user discovery.
- **Remove request_counter from API**: It should be handled internally and not exposed. Maybe as part of `Data` struct.
2022-06-02 17:44:36 +05:30
-
2022-06-02 16:47:12 +05:30
## License
Licensed under [AGPLv3](LICENSE).