release/1.3.1
md 35 lines 1.45 KB
Rendered Raw
1 # ed-onde-account
2
3 An Onde Inference account client for [Ed](https://crates.io/crates/ed-agent) agents.
4
5 It signs a user in to their Onde account, finds or creates their app, activates it, and returns
6 the Onde Cloud API key (`app_id:app_secret`) an agent authenticates with. Every call goes through
7 the ondeinference.com API, which keeps Onde's smbCloud credentials on the server, so nothing
8 secret ships in the app that embeds this crate.
9
10 ```rust
11 use ed_onde_account::{OndeAccount, SignIn};
12
13 let account = OndeAccount::new(); // https://ondeinference.com, production
14 match account.sign_in("me@example.com", "password").await? {
15 SignIn::Ready(token) => {
16 // Reuses the app named "My Agent", or creates and activates it.
17 let key = account.ensure_key(&token, "My Agent").await?;
18 println!("{}", key.as_str()); // app_id:app_secret
19 }
20 SignIn::NotFound => { /* no account yet */ }
21 SignIn::Incomplete { .. } => { /* e.g. the email isn't confirmed */ }
22 }
23 ```
24
25 - `sign_in`, `me`, `apps`, `create_app`, `activate` and `ensure_key`.
26 - `ensure_key` is idempotent: it never creates a second app with the same name.
27 - Errors are typed. `Error::Unauthorized` means the token expired and the user must sign in again;
28 `Error::Forbidden` means the account may not create apps.
29 - `AccessToken` and `ApiKey` redact themselves in `Debug` output.
30
31 Creating apps needs an Onde account that is allowed to, which every signed-up user is.
32
33 ## License
34
35 MIT OR Apache-2.0