feat(app): add the Nostro app, a window for phones and desktops
Linux phones have no banking apps, and a command line is no answer on a phone. The app does everything the nostro command does and, like it, only talks to nostrod: it holds no key and no token. - Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens; Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics; nostro-app; and Nostro.DebugCommands for the --debug-api build. - Client: every method also in an asynchronous form for an sd-event loop, with DaemonMissing and OutcomeUnknown. - nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both Flatpaks cross-built for aarch64, and the licence texts they carry. - nostro-fake-system, a made-up bus and bank with a real nostrod on them, to look at the app against. The README's screenshots are taken on it. - The nostro command: an API key's environment is the key's own to say, so --sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL. The published contract changes in three places, before any release (design rule 10): - Transactions' query takes `stored`: answered from what nostrod has stored, without asking the bank. The app searches with it; before, every search was a call to bunq. - AddBunq's `environment` no longer chooses over what the key says of itself: a key of the other environment is refused. - SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one as DEACTIVATED however well it pays, and leaves it as it is when asked, without an error. The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved from one to the other (design rule 13). Transaction's schema is unchanged. Verified: the 17 tests pass with every line, function and region of what they link run, and the five lint runs are clean. Every screen was looked at on the made-up system, at a phone's and a desktop's sizes in the light and the dark look, on Plasma under Wayland. What is said of bunq's cards comes from its sandbox, with throwaway users, and from one real virtual card. Known to have been used against production: connecting, and reading accounts, payments and cards. Not known to have been tried: a payment from the app against bunq, OAuth against bunq, and anything on a phone. Building the app takes --graphics=, a Crafter.Graphics checkout on its branch claude/nostro-app, until that branch is merged and pinned here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
1ea50c50bc
commit
5b4037955b
106 changed files with 17804 additions and 289 deletions
|
|
@ -250,7 +250,17 @@ namespace {
|
|||
|
||||
Client bob = As(bus, bobUid);
|
||||
Check(bob.Connectors().empty(), "another user sees none of them");
|
||||
Equal(bob.AddBunq("key-bob", "", "sandbox").environment, std::string("sandbox"), "an environment named by the caller");
|
||||
// An API key says itself which environment it is of. One the caller names is held to that, before anyone is
|
||||
// asked and before the key goes anywhere: a real key is not shown to the sandbox.
|
||||
const auto prompted = [&bus] {
|
||||
std::lock_guard lock(bus.mutex);
|
||||
return bus.checks.size();
|
||||
};
|
||||
const std::size_t prompts = prompted();
|
||||
Throws<std::invalid_argument>([&bob] { bob.AddBunq("key-bob", "", "sandbox"); }, "that API key is a production key, not a sandbox one", "a key that is not a sandbox key is not sent to the sandbox");
|
||||
Throws<std::invalid_argument>([&bob] { bob.AddBunq("sandbox_key-bob", "", "production"); }, "that API key is a sandbox key, not a production one", "nor a sandbox key taken for a real one");
|
||||
Check(prompted() == prompts && bob.Connectors().empty(), "nobody is asked for a password for either, and nothing is connected");
|
||||
Equal(bob.AddBunq("key-bob", "", "production").environment, std::string("production"), "an environment named by the caller, which the key is of");
|
||||
Equal(alice.Connectors().size(), std::size_t{1}, "each user sees their own connectors");
|
||||
Equal(bob.Connectors().at(0).name, std::string("Bob"), "and only those");
|
||||
Equal(Slurp(state / "users" / std::to_string(aliceUid) / "owner"), std::string("alice\n"), "a user's directory says whose it is");
|
||||
|
|
@ -279,8 +289,16 @@ namespace {
|
|||
|
||||
alice.Accounts();
|
||||
Check(bus.LastCheck().action == "net.catcrafts.Nostro1.View" && Summary(bus) == "see your accounts and balances", "listing is the View action");
|
||||
alice.Transactions(aliceMain, {});
|
||||
const std::size_t listed = alice.Transactions(aliceMain, {}).size();
|
||||
Equal(Summary(bus), std::string("see your transactions"), "so are the transactions");
|
||||
// From what nostrod has stored alone: the bank is not asked, so what it has had since is not among it.
|
||||
bunq.AddPayment(bank.aliceMainId, 4200, "Carol", "NL65BUNQ2025222222", "since the last look");
|
||||
const std::size_t calls = bunq.Count("GET", "/user/");
|
||||
Equal(alice.Transactions(aliceMain, {.stored = true}).size(), listed, "a question about what is stored is answered from it");
|
||||
Check(bunq.Count("GET", "/user/") == calls && Summary(bus) == "see your transactions", "without a call to the bank, and after the same check");
|
||||
Equal(alice.Transactions(aliceMain, {.search = "since the last look", .stored = true}).size(), std::size_t{0}, "so a payment the bank has had since is not found there");
|
||||
Check(alice.Transactions(aliceMain, {.search = "since the last look"}).size() == 1 && bunq.Count("GET", "/user/") == calls + 1, "any other question asks the bank first, and finds it");
|
||||
Equal(alice.Transactions(aliceMain, {.search = "since the last look", .stored = true}).size(), std::size_t{1}, "after which it is stored");
|
||||
|
||||
alice.Request(aliceMain, bobIban, "Bob", 500, "back");
|
||||
Check(bus.LastCheck().action == "net.catcrafts.Nostro1.Change" && Summary(bus) == std::format("ask {} (Bob) for €5.00 into {} (Main)", bobIban, aliceMain), "asking for money is a Change");
|
||||
|
|
@ -337,6 +355,22 @@ namespace {
|
|||
Check(bus.LastCheck().action == "net.catcrafts.Nostro1.UnfreezeCard" && Summary(bus) == "unfreeze card **** 1234", "unfreezing one has an action of its own");
|
||||
alice.SetCardStatus(card, "STOLEN");
|
||||
Check(bus.LastCheck().action == "net.catcrafts.Nostro1.BlockCard" && Summary(bus) == "report card **** 1234 stolen, which blocks it for good", "and so does blocking one for good");
|
||||
|
||||
// A virtual card is not frozen or unfrozen: bunq would leave it as it is and answer as if it had been done. It
|
||||
// is refused before anyone is asked for a password, and bunq is not asked at all.
|
||||
const std::uint64_t number = bunq.AddCard(bank.alice, "DEACTIVATED", json{{"order_status", "VIRTUAL_DELIVERY"}, {"primary_account_numbers", json::array({json{{"four_digit", "4321"}}})}});
|
||||
const auto prompted = [&bus] {
|
||||
std::lock_guard lock(bus.mutex);
|
||||
return bus.checks.size();
|
||||
};
|
||||
const std::size_t prompts = prompted();
|
||||
const std::size_t changes = bunq.Count("PUT", "/user/");
|
||||
for(const std::string_view status : {"DEACTIVATED", "ACTIVE"}) {
|
||||
Throws<std::invalid_argument>([&alice, number, status] { alice.SetCardStatus(number, status); }, std::format("card {} is a virtual card, which bunq does not freeze or unfreeze when asked", number), "a virtual card is not frozen or unfrozen");
|
||||
}
|
||||
Check(prompted() == prompts && bunq.Count("PUT", "/user/") == changes, "nobody is asked for a password for it, and bunq is not asked");
|
||||
Equal(alice.SetCardStatus(number, "LOST").status, std::string("LOST"), "it is reported lost like any card");
|
||||
Check(bus.LastCheck().action == "net.catcrafts.Nostro1.BlockCard" && Summary(bus) == "report card **** 4321 lost, which blocks it for good", "which blocks it for good, after the password for that");
|
||||
}
|
||||
|
||||
void Outcomes(Fake::Bus& bus) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue