Skip to main content

solid_pod_rs_nostr/
lib.rs

1//! # solid-pod-rs-nostr
2//!
3//! `did:nostr` DID documents, WebID ↔ did:nostr resolver, and an
4//! embedded Nostr relay (NIP-01, NIP-11, NIP-16) for solid-pod-rs.
5//!
6//! This sibling crate rounds out the Solid / Nostr bridge introduced in
7//! the library core:
8//!
9//! - The core [`solid_pod_rs::auth::nip98`] verifies NIP-98 HTTP auth
10//!   signatures.
11//! - The core [`solid_pod_rs::interop::did_nostr`] (feature `did-nostr`)
12//!   ships a low-level Tier-1 DID Doc renderer and a TTL-cached WebID
13//!   resolver for server-side lookup of outside pubkeys.
14//! - **This crate** adds the full operator surface: Tier-3 DID Docs
15//!   with `alsoKnownAs` + service entries, bidirectional
16//!   WebID ↔ did:nostr resolution (including HTML JSON-LD islands and
17//!   Turtle fallback), and a self-contained NIP-01/11/16 relay with a
18//!   pluggable event store and a `tokio-tungstenite` WebSocket wire
19//!   handler.
20//!
21//! PARITY-CHECKLIST targets: rows 89, 90, 101, 132.
22//!
23//! ## Module layout
24//!
25//! - [`did`]      — `did:nostr` URIs + Tier 1 / Tier 3 document renderers.
26//! - [`resolver`] — bidirectional `did:nostr` ↔ WebID resolver with SSRF guard.
27//! - [`relay`]    — NIP-01 event envelope, filter matching, replaceable-event
28//!   semantics (NIP-16), broadcast-channel live dispatch, NIP-11
29//!   relay-info document.
30//! - [`ws`]       — WebSocket wire protocol on top of `tokio-tungstenite`.
31//! - [`error`]    — error types for each domain.
32//!
33//! ## Quick-start
34//!
35//! ```no_run
36//! use std::sync::Arc;
37//! use solid_pod_rs_nostr::{
38//!     NostrPubkey, render_did_document_tier1, well_known_path, Relay,
39//! };
40//!
41//! // DID Document publication.
42//! let pk = NostrPubkey::from_hex(
43//!     "1111111111111111111111111111111111111111111111111111111111111111",
44//! )
45//! .unwrap();
46//! let doc = render_did_document_tier1(&pk);
47//! let path = well_known_path(&pk); // "/.well-known/did/nostr/…json"
48//! let _ = (doc, path);
49//!
50//! // Relay.
51//! let relay = Arc::new(Relay::in_memory());
52//! let _info = relay.info().clone(); // serve at GET / (Accept: application/nostr+json)
53//! ```
54
55#![doc = include_str!("../README.md")]
56#![forbid(unsafe_code)]
57
58pub mod did;
59pub mod error;
60pub mod relay;
61pub mod resolver;
62pub mod ws;
63
64pub use did::{
65    did_nostr_uri, render_did_document_tier1, render_did_document_tier3, well_known_path,
66    NostrPubkey, ServiceEntry,
67};
68pub use error::{DidError, RelayError, ResolverError};
69pub use relay::{
70    is_ephemeral, is_parameterised_replaceable, is_replaceable, Event, EventStore, Filter,
71    InMemoryEventStore, Relay, RelayInfo,
72};
73pub use resolver::{DefaultSsrfCheck, NostrWebIdResolver, SsrfCheck};
74pub use ws::{dispatch_message, serve_relay_ws, serve_relay_ws_stream};