| 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright (c) 2026 UtopiaIA |
| 3 | |
| 4 | //! The BraidHub protocol, version 1: what the hub and the client (`braid |
| 5 | //! login`, `braid hub …`, and landing in a linked repository) say to each |
| 6 | //! other. `docs/hub.md` is the prose of the same contract. |
| 7 | //! |
| 8 | //! - [`names`]: owners, repository names and ref globs. |
| 9 | //! - [`token`]: the `brd_<id>_<secret>` token format. |
| 10 | //! - [`scope`]: what a token's scopes reach and allow. |
| 11 | //! - [`stream`]: the `application/x-braid-objects` object stream. |
| 12 | //! - [`api`]: the JSON bodies of the routes of sections 1 to 14. |
| 13 | //! - [`cards`]: repositories and accounts as lists hold them. |
| 14 | //! - [`browse`], [`history`], [`explore`], [`social`], [`issues`], |
| 15 | //! [`requests`], [`forks`], [`notifications`], [`moderation`] and |
| 16 | //! [`onboard`]: the bodies of sections 15 to 23. |
| 17 | //! - [`verify`]: keeping a default branch green, section 25. |
| 18 | //! - [`json`]: conflicts and changes as the CLI prints them, so a landing on |
| 19 | //! the hub reports exactly what a local landing does. |
| 20 | //! - [`limits`]: what one request may carry or ask for. |
| 21 | |
| 22 | #![forbid(unsafe_code)] |
| 23 | |
| 24 | pub mod api; |
| 25 | pub mod browse; |
| 26 | pub mod cards; |
| 27 | pub mod explore; |
| 28 | pub mod forks; |
| 29 | pub mod history; |
| 30 | pub mod issues; |
| 31 | pub mod json; |
| 32 | pub mod limits; |
| 33 | pub mod moderation; |
| 34 | pub mod names; |
| 35 | pub mod notifications; |
| 36 | pub mod onboard; |
| 37 | pub mod requests; |
| 38 | pub mod scope; |
| 39 | pub mod social; |
| 40 | pub mod stream; |
| 41 | pub mod token; |
| 42 | pub mod verify; |
| 43 | |
| 44 | mod hex; |
| 45 | |
| 46 | pub use names::{NameError, RepoPath}; |
| 47 | pub use scope::{ParsedScope, Right, ScopeError, ScopeRepo}; |
| 48 | pub use token::{Token, TokenError}; |
| 49 | |
| 50 | /// The protocol version this crate speaks: the `v1` of every route. |
| 51 | pub const VERSION: u32 = 1; |
| 52 | |
| 53 | /// The media type of an object stream. |
| 54 | pub const OBJECTS_MEDIA_TYPE: &str = "application/x-braid-objects"; |
| 55 | |
| 56 | /// The header naming an object's kind on `GET` and `PUT` of `o/{id}`. |
| 57 | pub const KIND_HEADER: &str = "Braid-Kind"; |
| 58 | |
| 59 | /// The header naming a git object's kind on `GET git/o/{sha1}`. |
| 60 | pub const GIT_KIND_HEADER: &str = "Git-Kind"; |
| 61 | |
| 62 | /// The media type of the ref watch. |
| 63 | pub const EVENTS_MEDIA_TYPE: &str = "text/event-stream"; |
| 64 | |
| 65 | /// The public hub, used when nothing else is configured. |
| 66 | pub const DEFAULT_HUB_URL: &str = "https://braidhub.elffuss.com"; |