solid_pod_rs_git/lib.rs
1//! # solid-pod-rs-git
2//!
3//! Git HTTP smart-protocol backend for
4//! [`solid-pod-rs`](https://crates.io/crates/solid-pod-rs).
5//!
6//! ## Modules
7//!
8//! - [`service`] — Framework-agnostic [`GitHttpService`] that speaks `git-http-backend` CGI.
9//! - [`auth`] — `Basic nostr:<token>` and NIP-98 bearer auth extractors.
10//! - [`guard`] — Path-traversal rejection and repo-slug extraction.
11//! - [`config`] — Git repository config helpers (`receive.denyCurrentBranch`, etc.).
12//! - [`identity`] — Pod-git-root agent identity ([`write_agent_identity`]): canonical `agent.did.json` + `git config nostr.privkey` (ADR-124 §5.3).
13//! - [`mark`] — [`ShellGitMarker`]: native `GitMarker` (write-as-commit provenance).
14//! - [`error`] — [`GitError`] enum with HTTP status-code mapping.
15//!
16//! ## Quick start
17//!
18//! ```no_run
19//! use std::path::PathBuf;
20//! use solid_pod_rs_git::{GitHttpService, BasicNostrExtractor};
21//!
22//! # async fn run() {
23//! // Create the service rooted at a pod's data directory.
24//! let service = GitHttpService::new(PathBuf::from("/var/pods/alice"))
25//! .with_auth(BasicNostrExtractor::new());
26//!
27//! // In your HTTP router, translate framework types to GitRequest and call:
28//! // let response = service.handle(git_request).await;
29//! # }
30//! ```
31//!
32//! ## Feature flags
33//!
34//! | Flag | Purpose |
35//! |-------------------|-------------------------------------------------|
36//! | `with-git-binary` | Enable integration tests that need the `git` CLI and `git-http-backend` CGI binary. Unit tests always run. |
37//!
38//! ## Architecture
39//!
40//! The crate is framework-agnostic: [`GitHttpService`] consumes a
41//! [`GitRequest`] and produces a [`GitResponse`]. The embedding HTTP
42//! server (axum, actix-web, hyper, ...) translates between its native
43//! types and these. Internally the service spawns `git http-backend`
44//! (path overridable via `GIT_HTTP_BACKEND_PATH`) and shuttles bytes.
45
46#![doc = include_str!("../README.md")]
47#![deny(unsafe_code)]
48#![warn(missing_docs)]
49#![warn(rust_2018_idioms)]
50
51pub mod api;
52pub mod auth;
53pub mod config;
54pub mod error;
55pub mod guard;
56pub mod identity;
57pub mod init;
58pub mod mark;
59pub mod service;
60
61pub use api::{
62 git_add, git_branches, git_commit, git_create_branch, git_diff, git_discard, git_log,
63 git_status, git_unstage, resolve_commit, BranchInfo, ChangeType, CommitEntry, CommitResult,
64 FileStatus, ResolvedCommit, StatusReport,
65};
66pub use auth::{AuthError, BasicNostrExtractor, GitAuth};
67pub use config::{find_git_dir, GitDir};
68pub use error::GitError;
69pub use guard::{extract_repo_slug, path_safe};
70pub use identity::{
71 write_agent_identity, AgentIdentityWritten, AGENT_DID_FILE, NOSTR_PRIVKEY_KEY,
72};
73pub use init::GitAutoInit;
74pub use mark::ShellGitMarker;
75pub use service::{GitHttpService, GitRequest, GitResponse, DEFAULT_GIT_HTTP_BACKEND};