1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
//! Framework-agnostic Rust library for serving Solid Protocol 0.11 pods.
//!
//! `solid-pod-rs` provides LDP resource and container semantics, Web Access
//! Control (WAC 1.x + 2.0), WebID profile documents, Solid-OIDC 0.1,
//! NIP-98 HTTP auth, and Solid Notifications 0.2 -- all without coupling
//! to a specific HTTP framework. Wire it into actix-web, axum, hyper, or
//! anything else; the crate never mounts routes itself. On top of the Solid
//! core it adds two composable **provenance primitives** ([`provenance`]):
//! cheap, always-on **git-marks** (every pod write captured as a git commit
//! + a PROV-O sidecar) and expensive, opt-in **block-trails** (a
//! Bitcoin-taproot-anchored, hash-chained state trail — [`mrc20`] /
//! [`bitcoin_tx`]) — and a routed, sovereign HTTP-402 economy: a `did:nostr`-keyed
//! [Web Ledger](payments), `acl:PaymentCondition` ([`wac`]) access gating, an MRC20
//! deposit path, and a peer order book + constant-product AMM ([`trading`]).
//! The HTTP routing for the 402 economy and the `_prov` provenance API lives in
//! the sibling [`solid-pod-rs-server`](https://docs.rs/solid-pod-rs-server). See
//! [ADR-059](https://docs.rs/crate/solid-pod-rs/latest/source/docs/adr/ADR-059-provenance-primitives-block-trails-git-marks.md).
//!
//! For a turnkey binary, use the sibling crate
//! [`solid-pod-rs-server`](https://docs.rs/solid-pod-rs-server).
//!
//! ## Feature flags
//!
//! | Flag | Default | Purpose |
//! |-------------------------|:-------:|-----------------------------------------------|
//! | `core` | off | Pure-logic surfaces only — wasm32 / CF Workers. |
//! | `std` | on | std lib (always; reserved for future no_std). |
//! | `embedded-docs` | off | Embed the Diataxis `docs/` tree as `pub static DOCS_DIR` (re-exports `include_dir`); consumed by `solid-pod-rs-server`'s MCP docs tools + docs.rs. |
//! | `tokio-runtime` | on | Tokio + tokio-tungstenite + futures-util. |
//! | `notifications` | on | WebSocketChannel2023 + WebhookChannel2023. |
//! | `fs-backend` | on | POSIX filesystem storage. |
//! | `memory-backend` | on | In-process `HashMap` storage (tests/demos). |
//! | `s3-backend` | off | AWS S3 / S3-compatible object stores. |
//! | `oidc` | off | Solid-OIDC 0.1 + DPoP. |
//! | `dpop-replay-cache` | off | DPoP `jti` replay cache (pulls `oidc`). |
//! | `nip98-schnorr` | off | BIP-340 signature verification for NIP-98. |
//! | `jss-v04` | off | JSS-parity umbrella (ADR-056); no-op alone — sub-features below switch one bounded context each on. |
//! | `acl-origin` | off | WAC `acl:origin` enforcement (pulls `jss-v04`). |
//! | `security-primitives` | off | SSRF guard + dotfile allowlist (pulls `jss-v04`). |
//! | `legacy-notifications` | off | `solid-0.1` WebSocket adapter (SolidOS). |
//! | `config-loader` | off | Layered config loader with `JSS_*` env vars + YAML/TOML. |
//! | `webhook-signing` | off | RFC 9421 Ed25519 webhook signing. |
//! | `rate-limit` | off | Sliding-window LRU rate limiter + CORS. |
//! | `quota` | off | Per-pod `.quota.json` sidecar (atomic writes). |
//! | `did-nostr-types` | off | Canonical did:nostr types (wasm32-safe). |
//! | `did-nostr` | off | did:nostr DID-Doc ↔ WebID resolver in [`interop`]. |
//! | `mrc20` | off | BIP-341 taproot key chaining + anchor verify/build for MRC20 / block-trails. |
//! | `lws-cid` | off | LWS 1.0 CID self-signed JWT verifier (ES256K). |
//! | `lws-cid-p256` | off | LWS-CID + ES256 (P-256) algorithm. |
//! | `lws-cid-eddsa` | off | LWS-CID + EdDSA (Ed25519) algorithm. |
//! | `lws-cid-full` | off | LWS-CID with all algorithms. |
//! | `provision-keys` | off | Gates the optional `ProvisionPlan::provision_keys` field (IdP key provisioner extension point). |
//! | `nip05-endpoint` | off | Pod-resident `GET /.well-known/nostr.json` (pulls `did-nostr`). |
//! | `export-jsonld` | off | JSON-LD time-chain pod export (`GET /api/exports/all`). |
//! | `git-auto-init` | off | `GitInitHook` trait + `provision_pod_ext` (on-demand `git init` on first push; impl in `solid-pod-rs-git`). |
//!
//! On `wasm32-unknown-unknown` targets the `getrandom` crate is pulled in with
//! its `js` feature (transitively required by `uuid`/`rand`) so randomness
//! resolves via `crypto.getRandomValues()`; this is a target-gated dependency,
//! not a cargo feature you enable.
//!
//! `core` consumers wire the crate via `default-features = false,
//! features = ["core"]` and get only the pure-logic surfaces (no
//! tokio, no reqwest, no DNS resolver, no filesystem). See
//! `RELEASE_NOTES.md` v0.4.0-alpha.3 for the absorbed surfaces map.
//!
//! ## Module overview
//!
//! | Module | Responsibility |
//! |-----------------|--------------------------------------------------------------|
//! | [`storage`] | `Storage` trait + FS / Memory / S3 backends. |
//! | [`ldp`] | Resources, containers, content negotiation, PATCH, `Prefer`. |
//! | [`wac`] | Access control evaluator + WAC 2.0 conditions framework. |
//! | [`webid`] | WebID profile documents (emits `solid:oidcIssuer` + CID). |
//! | [`mashlib`] | SolidOS data-browser HTML wrapper + data-island embed. |
//! | [`auth`] | NIP-98 HTTP auth + LWS-CID self-signed JWT verifier. |
//! | [`payments`] | HTTP 402, Web Ledgers, multi-chain TXO, payment store. |
//! | [`mrc20`] | MRC20 state chains, JCS, BIP-341 key chaining. |
//! | [`provenance`] | git-mark / block-trail provenance primitives + PROV-O. |
//! | [`trading`] | Peer-to-peer order book + AMM constant-product pool. |
//! | [`notifications`] | WebSocket, Webhook (RFC 9421 signed), legacy adapter. |
//! | [`error`] | Crate-wide [`PodError`] error type. |
//! | [`config`] | Layered configuration schema. |
//! | [`security`] | SSRF guard, dotfile allowlist, CORS, rate limiter. |
//! | [`quota`] | Per-pod byte-quota enforcement. |
//! | [`multitenant`] | `PodResolver` trait; path + subdomain modes. |
//! | [`interop`] | `.well-known/solid`, WebFinger, NodeInfo, did:nostr. |
//! | [`did_nostr_types`] | Canonical `did:nostr` types (wasm32-safe, `core`). |
//! | [`provision`] | Pod bootstrap (WebID + containers + type indexes + ACL). |
//!
//! ## Quick start
//!
//! ```rust,no_run
//! use solid_pod_rs::storage::memory::MemoryBackend;
//! use solid_pod_rs::{Storage, evaluate_access, AccessMode};
//! use bytes::Bytes;
//! use std::sync::Arc;
//!
//! # tokio::runtime::Runtime::new().unwrap().block_on(async {
//! // 1. Create a storage backend.
//! let store = Arc::new(MemoryBackend::new());
//!
//! // 2. PUT a resource.
//! store.put("/hello.txt", Bytes::from("world"), "text/plain").await.unwrap();
//!
//! // 3. GET it back.
//! let (body, meta) = store.get("/hello.txt").await.unwrap();
//! assert_eq!(&body[..], b"world");
//! assert_eq!(meta.content_type, "text/plain");
//!
//! // 4. WAC evaluation (no ACL document = deny by default).
//! let allowed = evaluate_access(None, Some("https://alice.example/profile/card#me"),
//! "/hello.txt", AccessMode::Read, None);
//! assert!(!allowed);
//! # });
//! ```
//!
//! ## Attribution
//!
//! Rust port of JavaScriptSolidServer. See NOTICE for provenance.
// ---------------------------------------------------------------------------
// Always-compiled (`core`) modules.
//
// Pure-logic surfaces: parsers, validators, type definitions. None of
// these reach for tokio, reqwest, or notify directly. Wasm32 / CF
// Workers consumers wire these via
// `default-features = false, features = ["core"]`.
// ---------------------------------------------------------------------------
/// Bitcoin taproot transaction building (block-trail write-side). The module's
/// own inner `#![cfg(all(feature = "mrc20", not(target_arch = "wasm32")))]`
/// gates it: it compiles to nothing on wasm or without the `mrc20` feature, so
/// the tx-building never leaks into the wasm `core` surface (ADR-059 D4).
// ---------------------------------------------------------------------------
// `did-nostr-types`-gated module.
//
// Canonical did:nostr types (NostrPubkey, DID-Doc renderers, ServiceEntry)
// behind a lightweight feature flag. No runtime deps — wasm32 / CF Workers
// consumers get these via `core`.
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// `tokio-runtime`-gated modules.
//
// These pull tokio (mpsc, fs, broadcast) or reqwest (HTTP client) and
// are unavailable to `core` consumers. They are wired in by the
// `default` feature set so the existing surface from 0.4.0-alpha.2 is
// preserved bit-for-bit on native builds.
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// JSS v0.0.190 Phase 1 port (issue #437) — scaffolds.
//
// Parity row 198. Default-off; function body is `todo!()`. Type
// surface is stable for downstream consumers (NRF,
// dreamlab-ai-website).
// ---------------------------------------------------------------------------
/// Transport-agnostic HTTP / WebSocket handler drivers. Consumers wire
/// these into their HTTP framework of choice. Feature-gated; present
/// only when at least one handler is enabled. Respects the F7
/// library-server boundary — this crate never mounts routes itself.
// ---------------------------------------------------------------------------
// `core` re-exports — always available.
// ---------------------------------------------------------------------------
pub use Nip98Verifier;
pub use ;
pub use PodError;
pub use ;
pub use ;
pub use ;
pub use SecurityMetrics;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// ---------------------------------------------------------------------------
// `tokio-runtime`-gated re-exports.
// ---------------------------------------------------------------------------
pub use ;
pub use FsQuotaStore;
pub use ;
pub use ;
pub use ;
// ---------------------------------------------------------------------------
// JSS v0.0.190 Phase 1 port — re-exports (scaffolds).
// ---------------------------------------------------------------------------
pub use ;
// ---------------------------------------------------------------------------
// Embedded documentation tree (feature = "embedded-docs")
// ---------------------------------------------------------------------------
/// Re-exported so dependants can name `include_dir::Dir` without taking a
/// direct dependency on the embedding crate.
pub use include_dir;
/// The crate's Diataxis `docs/` tree, embedded at compile time. It lives
/// here — inside the owning crate's package root — so dependants (notably
/// `solid-pod-rs-server`'s MCP `list_docs`/`read_docs` tools) serve it from
/// a self-contained binary even when built from the registry tarball, where
/// a `../solid-pod-rs/docs` path escape does not exist.
pub static DOCS_DIR: Dir =
include_dir!;