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
//! The library behind `stratum`, the client for a Stratum node: the
//! administrator's commands on the loopback API, and a tenant's commands
//! through the gate.
//!
//! **Pre-release:** this is `0.1.0-alpha`. The commands, output and API may
//! change before 0.1.0, and nothing built on it has been deployed yet.
//!
//! A Stratum node serves an administrative API on loopback only. `stratum`
//! talks to that API over plain HTTP and holds the operator's own Nostr key;
//! it never sees the node key or the node's state volume, except that
//! `stratum setup` reads the bootstrap token file the operator points it at.
//! A tenant uses the same binary with their own key to join a node and to
//! read, write and export their pod through the node's gate.
//!
//! - **URLs.** [`LoopbackUrl`] accepts `http://` URLs whose host is an
//! IPv4 address in `127.0.0.0/8`, `[::1]` or `localhost`, and nothing
//! else: Step 1 has no TLS. `localhost` is connected to `127.0.0.1`
//! without a name lookup.
//! - **Operator keys.** [`generate_key_file`] writes a fresh key as one
//! `nsec1…` line to a file created exclusively with mode `0600`;
//! [`load_key_file`] refuses symbolic links and modes wider than `0600`.
//! The secret is never printed, logged or returned as text.
//! - **Changes.** [`parse_changes`] reads `--set path=value` arguments typed
//! by the schema in `stratum-node-config`.
//! - **Commands.** [`Session`] runs each command against one node: `status`,
//! `config` (`schema`, `show`, `preview`, `apply`), `setup`,
//! `sign-challenge`, `audit checkpoint`, `backup`, `invite`
//! (`create`, `list`, `revoke`), `member` (`list`, `show`, `repair`,
//! `cancel`, `suspend`, `resume`, `archive`, `remove`; see
//! [`SuspendOptions`] and [`RemoveOptions`]), `application` (`add`,
//! `list`, `withdraw`, `approve`, `disable`; see [`ApplicationAction`])
//! and `installations`.
//! Every authenticated request is signed with
//! [`NostrSecretKey::sign_request_with_nonce`](stratum_node_core::NostrSecretKey::sign_request_with_nonce)
//! over the exact URL, method and body bytes sent, with a fresh random
//! nonce so no two signings are the same event.
//! - **Tenant commands.** `join`, `pod` (`ls`, `get`, `put`, `rm`, `acl get`,
//! `acl put`), `export`, `profile init` and `profile show` take a
//! [`GateTarget`]: the node's
//! [`CanonicalOrigin`], which every request is signed for and named in
//! `Host`, and a loopback [`ConnectAddress`] the request is sent to over
//! plain HTTP. Every pod path is checked as a
//! [`PodPath`](stratum_node_core::PodPath) before anything is sent.
//! - **Applications.** `app` (`catalogue`, `install`, `list`, `show`,
//! `jobs`, `run`, `withdraw`, `cleanup`, `resume`) installs and withdraws
//! applications in the tenant's own pod. `install` ([`InstallOptions`])
//! checks the offered grant by rendering it again with
//! [`render_offered`](stratum_node_core::render_offered), reads the ACL
//! that governs each granted container, builds its new ACL (the owner's
//! control, existing rules kept, inherited `acl:default` rules
//! materialised, the offered rule), refuses any statement it does not
//! evaluate and any `Control` for the application, previews the diffs and
//! [`OPERATOR_STATEMENT`], writes each ACL conditionally after rereading
//! what governs it, reads it back, and consents only if every read-back
//! matches. `withdraw` and `cleanup` edit the installation's
//! authorisation out of each ACL with `If-Match` and report each
//! container as it is cleaned. Turtle is parsed with `oxttl`. Every `app`
//! command shows a withdrawn grant whose cleanup is not yet reported.
//! - **The public profile.** `join` and `profile init` write the card
//! `/pods/<pk>/profile/card` and its public-read ACL with the exact texts
//! of [`profile_card`](stratum_node_core::profile_card) and
//! [`profile_acl`](stratum_node_core::profile_acl), reading first and
//! creating only what is missing ([`ProfileInitOptions`]). `profile show`
//! reads anyone's card with an unsigned request and needs no key.
//! - **Exit codes.** Failures are [`CliError`]s, each mapped to a stable
//! code in [`exit`]; [`CliError::hint`] adds advice for the codes that
//! need it.
//!
//! The crate targets Unix: key files rely on Unix permission bits.
//!
//! # Example
//!
//! ```no_run
//! use stratum_node_cli::{Output, OutputFormat, Session};
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let output = Output::new(OutputFormat::Human);
//! let session = Session::new("http://127.0.0.1:7460".parse()?, Some("operator.nsec".into()), output);
//! let code = session.status().unwrap_or_else(|err| {
//! output.error(&err);
//! err.exit_code()
//! });
//! std::process::exit(i32::from(code));
//! # }
//! ```
compile_error!;
pub use ;
pub use ;
pub use ApplicationAction;
pub use ;
pub use CliError;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use PrivateFileError;
pub use ProfileInitOptions;
pub use ;
pub use ;
pub use ;
/// The default node URL: the loopback address the controller listens on by
/// default.
pub const DEFAULT_URL: &str = "http://127.0.0.1:7460";
/// Compiles the README's examples as doctests.
;