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:
Jorijn van der Graaf 2026-11-19 12:27:14 +01:00
commit 5b4037955b
106 changed files with 17804 additions and 289 deletions

View file

@ -66,8 +66,9 @@ namespace Fake {
std::uint64_t nextId = 1000;
std::uint32_t clock = 0;
std::size_t pageSize = 200; // a listing sends at most this many per page, whatever its count asks
std::chrono::milliseconds latency{0}; // how long every answer takes: a real bank is a network away
std::string scheduledName = "ScheduledPayment";
bool cardsActivate = true; // false: PUT card ACTIVE leaves the card as it is, as the sandbox does
bool cardsActivate = true; // false: PUT card ACTIVE leaves the card as it is, as bunq does for one that was never activated
struct Installation {
std::uint64_t id;
@ -179,7 +180,9 @@ namespace Fake {
json card = {
{"id", id},
{"status", status},
{"order_status", "VIRTUAL_DELIVERY"},
// Plastic the user has and activated, unless `extra` says otherwise: a virtual card is VIRTUAL_DELIVERY, and
// bunq has one as DEACTIVATED however it stands.
{"order_status", "DELIVERED_TO_CUSTOMER"},
{"product_type", "MASTERCARD_DEBIT"},
{"name_on_card", "J. Tester"},
{"second_line", "Nostro"},
@ -454,9 +457,13 @@ namespace Fake {
if(method == "PUT" && is({"user", "*", "card", "*"})) {
for(json& item : cards[self]) {
json& card = item.begin().value();
if(card.at("id").get<std::uint64_t>() == number(3)) {
// By its id, which what a test put among the cards to be skipped has none of.
if(card.value("id", std::uint64_t{0}) == number(3)) {
const std::string status = body.at("status").get<std::string>();
if(status != "ACTIVE" || cardsActivate) {
// As bunq does: a virtual card asked to freeze or to unfreeze is left as it is and answered
// without an error. Reporting it lost or stolen takes, as for any card.
const bool ignored = card.value("order_status", std::string()) == "VIRTUAL_DELIVERY" && (status == "ACTIVE" || status == "DEACTIVATED");
if(!ignored && (status != "ACTIVE" || cardsActivate)) {
card["status"] = status;
}
return {200, Response(json::array({item}))};
@ -629,6 +636,15 @@ namespace Fake {
}
Crafter::HTTPResponse Answer(const Crafter::HTTPRequest& request) {
// The bank's own time, before the lock: whoever reads or changes the bank meanwhile is not kept waiting.
std::chrono::milliseconds wait{0};
{
std::lock_guard lock(mutex);
wait = latency;
}
if(wait.count() > 0) {
std::this_thread::sleep_for(wait);
}
std::lock_guard lock(mutex);
std::string path = request.path.substr(0, request.path.find('?'));
const std::string query = request.path.contains('?') ? request.path.substr(request.path.find('?') + 1) : std::string();