ndn_security/did/
mod.rs

1//! NDN DID method — encode NDN names as W3C Decentralized Identifiers and
2//! resolve DID Documents over the NDN network or via bridged methods.
3//!
4//! # did:ndn encoding
5//!
6//! A `did:ndn` DID is the base64url (no padding) encoding of the complete NDN
7//! Name TLV wire format, including the outer `07 <length>` bytes:
8//!
9//! ```text
10//! did:ndn:<base64url(Name TLV)>
11//! ```
12//!
13//! This single form handles all NDN names unambiguously — GenericNameComponents,
14//! BLAKE3_DIGEST zone roots, versioned components, etc. — without type-specific
15//! special cases. See [`encoding`] for backward-compat parsing of older forms.
16//!
17//! # Resolution
18//!
19//! Use [`UniversalResolver`] to resolve any supported DID method:
20//!
21//! ```rust,no_run
22//! use ndn_security::did::{UniversalResolver, KeyDidResolver};
23//!
24//! # async fn example() -> Result<(), ndn_security::did::DidError> {
25//! let resolver = UniversalResolver::new();
26//! let doc = resolver.resolve_document("did:key:z6Mkfriq3r5SBo8EdoHpBVQBjEPdmBLWGcWHMU3KCi4bXD3m").await?;
27//! println!("{}", doc.id);
28//! # Ok(())
29//! # }
30//! ```
31//!
32//! # DID URL dereferencing
33//!
34//! ```rust,no_run
35//! use ndn_security::did::{DidUrl, deref_did_url};
36//! use ndn_security::did::document::DidDocument;
37//!
38//! # fn example(doc: &DidDocument) {
39//! let url = DidUrl::parse("did:ndn:com:acme:alice#key-0").unwrap();
40//! if let Some(resource) = deref_did_url(&url, doc) {
41//!     println!("found resource for fragment");
42//! }
43//! # }
44//! ```
45
46pub mod convert;
47pub mod document;
48pub mod encoding;
49pub mod metadata;
50pub mod resolver;
51pub mod url;
52
53// ── Re-exports ────────────────────────────────────────────────────────────────
54
55pub use convert::{
56    build_zone_did_document, build_zone_succession_document, cert_to_did_document,
57    did_document_to_trust_anchor,
58};
59pub use document::{
60    DidController, DidDocument, Service, ServiceEndpoint, VerificationMethod, VerificationRef,
61};
62pub use encoding::{did_to_name, name_to_did};
63pub use metadata::{
64    DidDocumentMetadata, DidResolutionError, DidResolutionMetadata, DidResolutionOptions,
65    DidResolutionResult,
66};
67pub use resolver::{DidError, DidResolver, KeyDidResolver, NdnDidResolver, UniversalResolver};
68pub use url::{DereferencedResource, DidUrl, deref_did_url, deref_did_url_or_document};