feat(host): web assistants per company, joined to the remote door (P15 B3)
WebAssistants is the switch per company: turning one on makes the link's address, starts the books server's remote door at it (the door listens on 127.0.0.1 and gives the app its per-start secret), offers the company, and hands the link the door; turning off withdraws the company and, with none left, closes the line first and then the door. A new address stops the door, makes a new label, and restarts the door at the new issuer, so every token made at the old address is refused. The switches are kept in a private file and put back for the companies that are open at the next start. Nothing is half-on after a failed step. The line runs in the window's process (the viewer owner holds it), so it ends with the window and never outlives the books it offers. THIRD-PARTY-NOTICES.txt is regenerated with scripts/notices.sh: the app now links instant-acme, the relay crate's client side and hickory-proto. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
0f9420aa30
commit
861ed57d82
8 files changed
+2085
-26
No files matched your search
@@ -76,13 +76,22 @@ struct ViewerOwner {
|
||||
/// 3.1): started with the window, closed with it. All of what is done
|
||||
/// with it is `AppHost`'s, which the tests drive.
|
||||
server: ledger_host::app_server::AppHost,
|
||||
/// Web assistants: the switch per company, the address and the line to
|
||||
/// the relay (ledger-host web.rs), in this window's process: the line
|
||||
/// ends with the window.
|
||||
web: ledger_host::web::WebAssistants,
|
||||
}
|
||||
|
||||
#[cfg(feature = "gui")]
|
||||
impl ViewerOwner {
|
||||
fn new(common: ledger_host::commands::Common) -> Self {
|
||||
let server = ledger_host::app_server::AppHost::new(common.root.clone());
|
||||
Self { common, server }
|
||||
let web = ledger_host::web::WebAssistants::new(common.root.clone());
|
||||
Self {
|
||||
common,
|
||||
server,
|
||||
web,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +102,11 @@ impl ledger_gui::owner::Owner for ViewerOwner {
|
||||
}
|
||||
|
||||
fn serve_start(&self, open: &[String]) -> Result<(), String> {
|
||||
self.server.start(open)
|
||||
self.server.start(open)?;
|
||||
// What was on when the window closed is on again, for the
|
||||
// companies that are open.
|
||||
self.web.restore(&self.server, open);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn serve_host_holds(&self) -> bool {
|
||||
@@ -105,7 +118,9 @@ impl ledger_gui::owner::Owner for ViewerOwner {
|
||||
}
|
||||
|
||||
fn serve_open(&self, book: &str) -> Result<Option<String>, String> {
|
||||
self.server.open_book(book)
|
||||
let opened = self.server.open_book(book)?;
|
||||
self.web.restore(&self.server, &[book.to_string()]);
|
||||
Ok(opened)
|
||||
}
|
||||
|
||||
fn serve_close(&self, book: &str) -> Result<Option<String>, String> {
|
||||
@@ -117,6 +132,8 @@ impl ledger_gui::owner::Owner for ViewerOwner {
|
||||
}
|
||||
|
||||
fn serve_stop(&self) -> Result<Option<String>, String> {
|
||||
// The line closes first: nothing arrives for books that are closing.
|
||||
self.web.shutdown();
|
||||
self.server.stop(ledger_host::app_server::STOP_WAIT)
|
||||
}
|
||||
|
||||
@@ -207,6 +224,39 @@ impl ledger_gui::owner::Owner for ViewerOwner {
|
||||
self.server.web_set_post(approval, post)
|
||||
}
|
||||
|
||||
fn web_state(&self, book: &str) -> Option<ledger_gui::owner::WebConnect> {
|
||||
use ledger_gui::owner::WebStep;
|
||||
let s = self.web.state(book);
|
||||
Some(ledger_gui::owner::WebConnect {
|
||||
on: s.on,
|
||||
step: match s.step {
|
||||
ledger_link::Step::Off => WebStep::Off,
|
||||
ledger_link::Step::GettingAddress => WebStep::GettingAddress,
|
||||
ledger_link::Step::Connecting => WebStep::Connecting,
|
||||
ledger_link::Step::GettingCertificate => WebStep::GettingCertificate,
|
||||
ledger_link::Step::Connected => WebStep::Connected,
|
||||
},
|
||||
address: s.address,
|
||||
connector: s.connector,
|
||||
words: s.words,
|
||||
problem: s.problem,
|
||||
needs_person: s.needs_person,
|
||||
kept: s.kept,
|
||||
})
|
||||
}
|
||||
|
||||
fn web_turn_on(&self, book: &str) -> Result<String, String> {
|
||||
self.web.turn_on(&self.server, book)
|
||||
}
|
||||
|
||||
fn web_turn_off(&self, book: &str) -> Result<String, String> {
|
||||
self.web.turn_off(&self.server, book)
|
||||
}
|
||||
|
||||
fn web_new_address(&self, _book: &str) -> Result<String, String> {
|
||||
self.web.new_address(&self.server)
|
||||
}
|
||||
|
||||
fn serve_revoke(&self, book: &str, name: &str, id: &str) -> Result<String, String> {
|
||||
self.server.revoke_token(book, name, id)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user