ndn_identity/
lib.rs

1//! NDN identity management — high-level lifecycle for NDN identities.
2//!
3//! `ndn-identity` provides [`NdnIdentity`]: a unified handle for an NDN
4//! signing identity that handles creation, enrollment via NDNCERT, persistent
5//! storage, and background certificate renewal.
6//!
7//! # Quick start
8//!
9//! ```rust,no_run
10//! use ndn_identity::NdnIdentity;
11//!
12//! # async fn example() -> Result<(), ndn_identity::IdentityError> {
13//! // Ephemeral (tests, quick prototypes)
14//! let identity = NdnIdentity::ephemeral("/com/example/alice")?;
15//!
16//! // Persistent — load or create
17//! let identity = NdnIdentity::open_or_create(
18//!     std::path::Path::new("/var/lib/ndn/identity"),
19//!     "/com/example/alice",
20//! )?;
21//!
22//! // Use the signer
23//! let signer = identity.signer()?;
24//! println!("Identity: {}", identity.name());
25//! println!("DID: {}", identity.did());
26//! # Ok(())
27//! # }
28//! ```
29//!
30//! # Fleet provisioning
31//!
32//! ```rust,no_run
33//! use ndn_identity::{NdnIdentity, DeviceConfig, FactoryCredential, RenewalPolicy};
34//! use std::time::Duration;
35//!
36//! # async fn example() -> Result<(), ndn_identity::IdentityError> {
37//! let identity = NdnIdentity::provision(DeviceConfig {
38//!     namespace: "/com/acme/fleet/VIN-123456".parse().unwrap(),
39//!     storage: Some("/var/lib/ndn/device".into()),
40//!     factory_credential: FactoryCredential::Token("factory-token-abc".to_string()),
41//!     ca_prefix: Some("/com/acme/fleet/CA".parse().unwrap()),
42//!     renewal: RenewalPolicy::WhenPercentRemaining(20),
43//!     delegate: vec![],
44//! }).await?;
45//! # Ok(())
46//! # }
47//! ```
48
49pub mod ca;
50pub mod device;
51pub mod enroll;
52pub mod error;
53pub mod identity;
54pub mod renewal;
55
56pub use ca::{NdncertCa, NdncertCaBuilder};
57pub use device::{DeviceConfig, FactoryCredential, RenewalPolicy};
58pub use enroll::{ChallengeParams, EnrollConfig};
59pub use error::IdentityError;
60pub use identity::NdnIdentity;