[vault] Provision: display offers (store display, outcome confirmed; display stores nothing, confirmed only for a display offer)
This commit is contained in:
@@ -27,6 +27,8 @@ pub enum Store {
|
||||
Claude,
|
||||
/// The cloud Claude Code store.
|
||||
Cloud,
|
||||
/// Shown once on the card and stored nowhere: a display offer (core 0.12.0).
|
||||
Display,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -46,6 +48,8 @@ pub enum Outcome {
|
||||
Invalid,
|
||||
/// Nobody answered within five minutes.
|
||||
Expired,
|
||||
/// A display offer: Mark typed the code the phone shows, Custos checked it and sent it (core 0.12.0).
|
||||
Confirmed,
|
||||
}
|
||||
|
||||
/// One audit entry. Append-only: nothing edits or removes one.
|
||||
@@ -133,6 +137,17 @@ impl ProvisionEntry {
|
||||
if self.code.len() != 6 || !self.code.bytes().all(|c| c.is_ascii_digit()) {
|
||||
return Err(Error::Provision("the match code is not six digits"));
|
||||
}
|
||||
// A display offer stores nothing; `confirmed` is its outcome and nobody else's.
|
||||
if self.store == Store::Display {
|
||||
if self.direction != Direction::Offer {
|
||||
return Err(Error::Provision("a display is an offer"));
|
||||
}
|
||||
if matches!(self.outcome, Outcome::Accepted | Outcome::Approved | Outcome::Generated) || self.replaced {
|
||||
return Err(Error::Provision("a display offer stores nothing"));
|
||||
}
|
||||
} else if self.outcome == Outcome::Confirmed {
|
||||
return Err(Error::Provision("only a display offer is confirmed"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user