pub struct NodeStore { /* private fields */ }Implementations§
Source§impl NodeStore
impl NodeStore
Sourcepub fn open(path: &Path) -> Result<Self, String>
pub fn open(path: &Path) -> Result<Self, String>
Opens the registry, empty when the file does not exist. A file that exists and does not parse is an error, not an empty registry: silently forgetting every enrolled node would re-open every enrollment token.
Sourcepub fn mint_token(
&mut self,
name: &str,
projects: Vec<String>,
ttl_secs: i64,
now_secs: i64,
) -> Result<(String, i64), String>
pub fn mint_token( &mut self, name: &str, projects: Vec<String>, ttl_secs: i64, now_secs: i64, ) -> Result<(String, i64), String>
Mints a single-use enrollment token. Returns the plaintext once.
Sourcepub fn enroll(
&mut self,
token: &str,
pubkey_hex: &str,
listen: Option<ListenInfo>,
now_secs: i64,
now_iso: &str,
) -> Result<NodeRecord, String>
pub fn enroll( &mut self, token: &str, pubkey_hex: &str, listen: Option<ListenInfo>, now_secs: i64, now_iso: &str, ) -> Result<NodeRecord, String>
Spends a token and registers the node’s public key.
Sourcepub fn authenticate(
&mut self,
node_id: &str,
method: &str,
path: &str,
ts_ms: i64,
body: &[u8],
sig_hex: &str,
now_ms: i64,
) -> Result<NodeRecord, AuthError>
pub fn authenticate( &mut self, node_id: &str, method: &str, path: &str, ts_ms: i64, body: &[u8], sig_hex: &str, now_ms: i64, ) -> Result<NodeRecord, AuthError>
Checks a signed request and, on success, advances the node’s replay mark.
Sourcepub fn hub_node_key(&mut self) -> Result<(String, String), String>
pub fn hub_node_key(&mut self) -> Result<(String, String), String>
The hub’s transport key for listening nodes as (seed, public), made on
first use.
Sourcepub fn listening(&self) -> Vec<NodeRecord>
pub fn listening(&self) -> Vec<NodeRecord>
Active nodes the hub has to dial.
Sourcepub fn mark_polled(&mut self, id: &str, now_iso: &str)
pub fn mark_polled(&mut self, id: &str, now_iso: &str)
Notes that the hub polled id just now.
pub fn list(&self) -> Vec<NodeRecord>
pub fn get(&self, id: &str) -> Option<NodeRecord>
Sourcepub fn find(&self, name_or_id: &str) -> Option<NodeRecord>
pub fn find(&self, name_or_id: &str) -> Option<NodeRecord>
Finds an active node by name or id.
pub fn revoke(&mut self, id: &str, now_iso: &str) -> Result<NodeRecord, String>
Source§impl NodeStore
impl NodeStore
Sourcepub fn set_approval_policy(
&mut self,
id: &str,
policy: &str,
) -> Result<NodeRecord, String>
pub fn set_approval_policy( &mut self, id: &str, policy: &str, ) -> Result<NodeRecord, String>
Sets whether every push to a node is held for a human.
Sourcepub fn usable_approval(
&self,
node_id: &str,
target: &str,
sha: &str,
now_secs: i64,
) -> Option<ApprovalRecord>
pub fn usable_approval( &self, node_id: &str, target: &str, sha: &str, now_secs: i64, ) -> Option<ApprovalRecord>
The approval for exactly these bytes, if there is one and it can still be used: approved, within its lifetime, for an active node.
Sourcepub fn approval_for(
&self,
node_id: &str,
target: &str,
sha: &str,
) -> Option<ApprovalRecord>
pub fn approval_for( &self, node_id: &str, target: &str, sha: &str, ) -> Option<ApprovalRecord>
The newest request for these bytes in any state.
Sourcepub fn request_approval(
&mut self,
node_id: &str,
target: &TargetReport,
sha: &str,
from_seq: Option<i64>,
to_seq: Option<i64>,
now_secs: i64,
now_iso: &str,
) -> Result<ApprovalRecord, String>
pub fn request_approval( &mut self, node_id: &str, target: &TargetReport, sha: &str, from_seq: Option<i64>, to_seq: Option<i64>, now_secs: i64, now_iso: &str, ) -> Result<ApprovalRecord, String>
Opens a request for a human, unless one for the same bytes is already open, decided, or spent. A consumed or expired request for the same bytes (a revert) opens a fresh one: an old yes does not cover a later push.
Sourcepub fn decide(
&mut self,
approval_id: &str,
approve: bool,
by: &str,
now_secs: i64,
now_iso: &str,
) -> Result<ApprovalRecord, String>
pub fn decide( &mut self, approval_id: &str, approve: bool, by: &str, now_secs: i64, now_iso: &str, ) -> Result<ApprovalRecord, String>
A human’s answer. Only a pending request can be decided: an approval is never revived, and a decision on stale bytes is a decision on a request the hub no longer asks for.
Sourcepub fn add_approver(
&mut self,
pubkey_hex: &str,
label: &str,
now_iso: &str,
) -> Result<Approver, String>
pub fn add_approver( &mut self, pubkey_hex: &str, label: &str, now_iso: &str, ) -> Result<Approver, String>
Registers a device whose signature counts as the owner’s approval.
Sourcepub fn remove_approver(&mut self, fp_prefix: &str) -> Result<Approver, String>
pub fn remove_approver(&mut self, fp_prefix: &str) -> Result<Approver, String>
Removes a device by (a prefix of at least 8 characters of) its fingerprint.
Nodes set to device approval lose their only approver if this was the
last one: they fall back to required, so nothing is left unapprovable and
nothing silently becomes approvable by the hub alone.
pub fn approvers(&self) -> Vec<Approver>
Sourcepub fn decide_signed(
&mut self,
approval_id: &str,
signed: SignedApproval,
now_secs: i64,
now_iso: &str,
) -> Result<ApprovalRecord, String>
pub fn decide_signed( &mut self, approval_id: &str, signed: SignedApproval, now_secs: i64, now_iso: &str, ) -> Result<ApprovalRecord, String>
A human’s yes, signed on their own device. The hub holds no key that could have made it: it checks the signature against the registered devices, that the token names exactly this request (node, target, bytes, request id), and that its lifetime is no longer than the hub’s own.