matrixbot_ezlogin/lib.rs
1//! matrixbot-ezlogin: "I wrote the login and E2EE bootstrap code for Matrix bots so you don’t have to."
2//!
3//! Writing a Matrix bot is easy, but supporting end-to-end encryption is extremely difficult.
4//!
5//! Not only because the bot must maintain a database to store encryption keys between sessions, but also because the bootstrap process requires a human to interactively type in or copy out the recovery key.
6//!
7//! Sadly, the [official Matrix SDK](matrix_sdk) doesn't provide a complete solution to bootstrap a Matrix bot, resulting in bot developers needing to waste time writing the authentication code again and again.
8//!
9//! Here, I publish this library called matrixbot-ezlogin, as a good starting point for every Matrix bot. So, you can skip the trouble and directly hop into the bot logic.
10//!
11//! # Two-stages of a bot
12//!
13//! In order to set up a Matrix bot with E2EE support, there are two steps:
14//!
15//! 1. Creating a Matrix session, setting up cross-signing keys, creating or recovering from a server-side backup, then exit. This step requires human intervention.
16//!
17//! 2. Restoring the Matrix session to run actual bot logic. This step is unattended and can be set to auto-start when computer boots up.
18//!
19//! # Components of matrixbot-ezlogin
20//!
21//! This library provides the functions [`setup`] (or [`setup_interactive`]) and [`login`] to simplify these two steps.
22//!
23//! Additionally, [`DuplexLog`] helps handling duplex terminal input / output. [`SyncHelper`] helps remembering sync tokens between process restarts.
24//!
25//! The `examples` folder contains a simple echo-bot for you to experience the feature of matrixbot-ezlogin, and serves as a good starting point to develop a new Matrix bot.
26
27mod auth;
28mod db;
29mod duplex_log;
30mod interactive;
31mod sync;
32
33pub use auth::{SetupConfig, login, logout, setup};
34pub use duplex_log::DuplexLog;
35pub use interactive::setup_interactive;
36pub use sync::SyncHelper;