auths_core/lib.rs
1// crate-level allow during curve-agnostic refactor.
2#![allow(clippy::disallowed_methods)]
3#![warn(clippy::too_many_lines, clippy::cognitive_complexity)]
4#![warn(missing_docs)]
5//! # auths-core
6//!
7//! Core cryptographic primitives and secure key storage for Auths.
8//!
9//! This crate provides:
10//! - **Secure key storage** via platform keychains (macOS, Windows, Linux)
11//! - **Signing operations** through the [`signing::SecureSigner`] trait
12//! - **Passphrase handling** with [`signing::PassphraseProvider`] abstraction
13//! - **Error types** for all failure modes
14//!
15//! ## Quick Start
16//!
17//! ```rust,ignore
18//! use auths_core::storage::keychain::get_platform_keychain;
19//! use auths_core::signing::{StorageSigner, SecureSigner};
20//!
21//! // Get the platform-appropriate keychain
22//! let keychain = get_platform_keychain()?;
23//! let signer = StorageSigner::new(keychain);
24//!
25//! // Sign with a stored key
26//! let signature = signer.sign_with_alias("my-key", &provider, b"message")?;
27//! ```
28//!
29//! ## Feature Flags
30//!
31//! - `keychain-linux-secretservice` — Enable Linux Secret Service backend
32//! - `keychain-windows` — Enable Windows Credential Manager backend
33//! - `keychain-file-fallback` — Enable encrypted file storage fallback
34//! - `crypto-secp256k1` — Enable secp256k1/BIP340 for Nostr
35//! - `test-utils` — Export test utilities (e.g., in-memory keychain for testing)
36//!
37//! ## Platform Support
38//!
39//! | Platform | Keychain | Feature Required |
40//! |----------|----------|-----------------|
41//! | macOS/iOS | Keychain Services | (default) |
42//! | Linux | Secret Service | `keychain-linux-secretservice` |
43//! | Windows | Credential Manager | `keychain-windows` |
44//! | Any | Encrypted file | `keychain-file-fallback` |
45
46// The `test-utils` feature swaps in deliberately weak Argon2 KDF parameters
47// (m=8 KiB, t=1) so test suites run fast; it must never reach a shipping build.
48// `debug_assertions` is off in `--release`, so this fails the compile if
49// `test-utils` is ever enabled in a release build.
50#[cfg(all(feature = "test-utils", not(debug_assertions)))]
51compile_error!(
52 "the `test-utils` feature enables weak KDF parameters and must not be in a release build"
53);
54
55pub mod agent;
56pub mod api;
57pub mod config;
58pub mod crypto;
59pub mod error;
60pub mod pairing;
61pub mod paths;
62pub mod ports;
63pub mod proto;
64pub mod server;
65pub mod signing;
66pub mod storage;
67#[cfg(any(test, feature = "test-utils"))]
68#[allow(clippy::unwrap_used, clippy::expect_used)]
69pub mod testing;
70pub mod trust;
71pub mod utils;
72pub mod witness;
73
74pub use agent::{AgentCore, AgentHandle, AgentSession};
75// IMPORTANT: These agent client functions use Unix domain sockets and are only
76// available on Unix. Do NOT remove this #[cfg(unix)] — it will break Windows CI.
77#[cfg(unix)]
78pub use agent::{
79 AgentStatus, add_identity, agent_sign, check_agent_status, list_identities,
80 remove_all_identities,
81};
82pub use crypto::{EncryptionAlgorithm, SignerKey};
83pub use error::{AgentError, AuthsErrorInfo};
84pub use signing::{KeychainPassphraseProvider, PrefilledPassphraseProvider};