From 5b4037955bd938f00cb766241ae14ac36372b625 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Thu, 19 Nov 2026 12:27:14 +0100 Subject: [PATCH] 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 --- AGENTS.consumer.md | 34 +- AGENTS.template.md | 200 +- README.md | 127 +- assets/NotoSans-Medium.ttf | Bin 0 -> 619976 bytes assets/NotoSans-Regular.ttf | Bin 0 -> 621572 bytes assets/OFL.txt | 93 + docs/screenshots/desktop-account.png | Bin 0 -> 90598 bytes docs/screenshots/desktop-payment-dark.png | Bin 0 -> 90395 bytes docs/screenshots/phone-account.png | Bin 0 -> 91206 bytes docs/screenshots/phone-accounts.png | Bin 0 -> 75683 bytes docs/screenshots/phone-pay.png | Bin 0 -> 51968 bytes docs/screenshots/take.sh | 55 + implementations/Nostro-Account.cpp | 4 + implementations/Nostro-Bunq-Payments.cpp | 6 + implementations/Nostro-Bunq.cpp | 38 +- implementations/Nostro-Bus.cpp | 7 + implementations/Nostro-Client.cpp | 390 +++- implementations/Nostro-Daemon-Worker.cpp | 24 +- implementations/Nostro.App-App.cpp | 1139 ++++++++++ implementations/Nostro.App-Banks.cpp | 60 + implementations/Nostro.App-Bunq.cpp | 118 ++ implementations/Nostro.App-Errors.cpp | 99 + implementations/Nostro.App-Format.cpp | 208 ++ implementations/Nostro.App-Forms.cpp | 318 +++ implementations/Nostro.App-Screens.cpp | 780 +++++++ implementations/Nostro.DebugCommands.cpp | 388 ++++ implementations/Nostro.Ui-Context.cpp | 907 ++++++++ implementations/Nostro.Ui-Draw.cpp | 103 + implementations/Nostro.Ui-Edit.cpp | 223 ++ implementations/Nostro.Ui-Gesture.cpp | 207 ++ implementations/Nostro.Ui-Text.cpp | 245 +++ implementations/Nostro.Ui-Theme.cpp | 54 + implementations/Nostro.Ui-Widgets.cpp | 664 ++++++ implementations/Nostro.Ui.Shell-Canvas.cpp | 325 +++ implementations/Nostro.Ui.Shell-Loop.cpp | 285 +++ implementations/Nostro.Ui.Shell-Portal.cpp | 198 ++ implementations/Nostro.Ui.Shell-Window.cpp | 489 +++++ implementations/main.cpp | 38 +- implementations/nostro-app.cpp | 671 ++++++ interfaces/Nostro-Account.cppm | 4 + interfaces/Nostro-Bunq.cppm | 31 +- interfaces/Nostro-Client.cppm | 106 +- interfaces/Nostro-Utils.cppm | 6 + interfaces/Nostro.App-App.cppm | 341 +++ interfaces/Nostro.App-Banks.cppm | 57 + interfaces/Nostro.App-Errors.cppm | 73 + interfaces/Nostro.App-Format.cppm | 53 + interfaces/Nostro.App-Forms.cppm | 175 ++ interfaces/Nostro.App.cppm | 15 + interfaces/Nostro.DebugCommands.cppm | 62 + interfaces/Nostro.Ui-Context.cppm | 310 +++ interfaces/Nostro.Ui-Draw.cppm | 120 ++ interfaces/Nostro.Ui-Edit.cppm | 86 + interfaces/Nostro.Ui-Geometry.cppm | 126 ++ interfaces/Nostro.Ui-Gesture.cppm | 124 ++ interfaces/Nostro.Ui-Input.cppm | 82 + interfaces/Nostro.Ui-Layout.cppm | 73 + interfaces/Nostro.Ui-Text.cppm | 74 + interfaces/Nostro.Ui-Theme.cppm | 66 + interfaces/Nostro.Ui-Widgets.cppm | 188 ++ interfaces/Nostro.Ui.Shell-Canvas.cppm | 157 ++ interfaces/Nostro.Ui.Shell-Loop.cppm | 164 ++ interfaces/Nostro.Ui.Shell-Portal.cppm | 65 + interfaces/Nostro.Ui.Shell-Window.cppm | 118 ++ interfaces/Nostro.Ui.Shell.cppm | 14 + interfaces/Nostro.Ui.cppm | 19 + packaging/arch/PKGBUILD | 2 +- packaging/arch/nostro-system.install | 17 +- packaging/dbus/net.catcrafts.Nostro1.xml | 16 +- packaging/flatpak/build-aarch64.sh | 139 ++ packaging/flatpak/make-aarch64-sysroot.sh | 138 ++ .../flatpak/net.catcrafts.Nostro.desktop | 17 + .../flatpak/net.catcrafts.Nostro.flatpakref | 4 +- .../flatpak/net.catcrafts.Nostro.metainfo.xml | 45 +- packaging/flatpak/net.catcrafts.Nostro.svg | 13 + .../flatpak/net.catcrafts.Nostrod.flatpakref | 13 + .../net.catcrafts.Nostrod.metainfo.xml | 28 + ...Nostro.yaml => net.catcrafts.Nostrod.yaml} | 39 +- packaging/licenses/LLVM-LICENSE.TXT | 279 +++ packaging/licenses/NOTICE | 36 + .../Vulkan-Utility-Libraries-Apache-2.0.txt | 202 ++ packaging/licenses/libevdev-COPYING.txt | 32 + packaging/licenses/nlohmann-json-MIT.txt | 27 + packaging/licenses/stb-LICENSE.txt | 47 + .../licenses/wayland-protocols-NOTICE.txt | 127 ++ packaging/system/install.sh | 65 +- packaging/system/nostro | 4 +- packaging/system/nostrod.service | 4 +- packaging/system/uninstall.sh | 7 +- project.cpp | 261 ++- tests/FakeSystem/main.cpp | 266 +++ tests/ShouldAnswerAsynchronously/main.cpp | 398 ++++ tests/ShouldBuildFrames/main.cpp | 1236 +++++++++++ tests/ShouldDriveTheApp/main.cpp | 1870 +++++++++++++++++ tests/ShouldEditText/main.cpp | 195 ++ tests/ShouldLayOutWidgets/main.cpp | 466 ++++ tests/ShouldRecognizeGestures/main.cpp | 150 ++ tests/ShouldRunCommands/main.cpp | 21 +- tests/ShouldServeEveryUser/main.cpp | 38 +- tests/ShouldTalkToBunq/main.cpp | 23 + tests/ShouldValidateForms/main.cpp | 426 ++++ tests/ShouldWrapText/main.cpp | 152 ++ tests/Support/FakeBunq.inc | 24 +- tests/Support/FakeBus.inc | 14 + tests/Support/Ui.inc | 54 + tests/coverage.sh | 14 +- 106 files changed, 17815 insertions(+), 300 deletions(-) create mode 100644 assets/NotoSans-Medium.ttf create mode 100644 assets/NotoSans-Regular.ttf create mode 100644 assets/OFL.txt create mode 100644 docs/screenshots/desktop-account.png create mode 100644 docs/screenshots/desktop-payment-dark.png create mode 100644 docs/screenshots/phone-account.png create mode 100644 docs/screenshots/phone-accounts.png create mode 100644 docs/screenshots/phone-pay.png create mode 100755 docs/screenshots/take.sh create mode 100644 implementations/Nostro.App-App.cpp create mode 100644 implementations/Nostro.App-Banks.cpp create mode 100644 implementations/Nostro.App-Bunq.cpp create mode 100644 implementations/Nostro.App-Errors.cpp create mode 100644 implementations/Nostro.App-Format.cpp create mode 100644 implementations/Nostro.App-Forms.cpp create mode 100644 implementations/Nostro.App-Screens.cpp create mode 100644 implementations/Nostro.DebugCommands.cpp create mode 100644 implementations/Nostro.Ui-Context.cpp create mode 100644 implementations/Nostro.Ui-Draw.cpp create mode 100644 implementations/Nostro.Ui-Edit.cpp create mode 100644 implementations/Nostro.Ui-Gesture.cpp create mode 100644 implementations/Nostro.Ui-Text.cpp create mode 100644 implementations/Nostro.Ui-Theme.cpp create mode 100644 implementations/Nostro.Ui-Widgets.cpp create mode 100644 implementations/Nostro.Ui.Shell-Canvas.cpp create mode 100644 implementations/Nostro.Ui.Shell-Loop.cpp create mode 100644 implementations/Nostro.Ui.Shell-Portal.cpp create mode 100644 implementations/Nostro.Ui.Shell-Window.cpp create mode 100644 implementations/nostro-app.cpp create mode 100644 interfaces/Nostro.App-App.cppm create mode 100644 interfaces/Nostro.App-Banks.cppm create mode 100644 interfaces/Nostro.App-Errors.cppm create mode 100644 interfaces/Nostro.App-Format.cppm create mode 100644 interfaces/Nostro.App-Forms.cppm create mode 100644 interfaces/Nostro.App.cppm create mode 100644 interfaces/Nostro.DebugCommands.cppm create mode 100644 interfaces/Nostro.Ui-Context.cppm create mode 100644 interfaces/Nostro.Ui-Draw.cppm create mode 100644 interfaces/Nostro.Ui-Edit.cppm create mode 100644 interfaces/Nostro.Ui-Geometry.cppm create mode 100644 interfaces/Nostro.Ui-Gesture.cppm create mode 100644 interfaces/Nostro.Ui-Input.cppm create mode 100644 interfaces/Nostro.Ui-Layout.cppm create mode 100644 interfaces/Nostro.Ui-Text.cppm create mode 100644 interfaces/Nostro.Ui-Theme.cppm create mode 100644 interfaces/Nostro.Ui-Widgets.cppm create mode 100644 interfaces/Nostro.Ui.Shell-Canvas.cppm create mode 100644 interfaces/Nostro.Ui.Shell-Loop.cppm create mode 100644 interfaces/Nostro.Ui.Shell-Portal.cppm create mode 100644 interfaces/Nostro.Ui.Shell-Window.cppm create mode 100644 interfaces/Nostro.Ui.Shell.cppm create mode 100644 interfaces/Nostro.Ui.cppm create mode 100755 packaging/flatpak/build-aarch64.sh create mode 100755 packaging/flatpak/make-aarch64-sysroot.sh create mode 100644 packaging/flatpak/net.catcrafts.Nostro.desktop create mode 100644 packaging/flatpak/net.catcrafts.Nostro.svg create mode 100644 packaging/flatpak/net.catcrafts.Nostrod.flatpakref create mode 100644 packaging/flatpak/net.catcrafts.Nostrod.metainfo.xml rename packaging/flatpak/{net.catcrafts.Nostro.yaml => net.catcrafts.Nostrod.yaml} (54%) create mode 100644 packaging/licenses/LLVM-LICENSE.TXT create mode 100644 packaging/licenses/NOTICE create mode 100644 packaging/licenses/Vulkan-Utility-Libraries-Apache-2.0.txt create mode 100644 packaging/licenses/libevdev-COPYING.txt create mode 100644 packaging/licenses/nlohmann-json-MIT.txt create mode 100644 packaging/licenses/stb-LICENSE.txt create mode 100644 packaging/licenses/wayland-protocols-NOTICE.txt create mode 100644 tests/FakeSystem/main.cpp create mode 100644 tests/ShouldAnswerAsynchronously/main.cpp create mode 100644 tests/ShouldBuildFrames/main.cpp create mode 100644 tests/ShouldDriveTheApp/main.cpp create mode 100644 tests/ShouldEditText/main.cpp create mode 100644 tests/ShouldLayOutWidgets/main.cpp create mode 100644 tests/ShouldRecognizeGestures/main.cpp create mode 100644 tests/ShouldValidateForms/main.cpp create mode 100644 tests/ShouldWrapText/main.cpp create mode 100644 tests/Support/Ui.inc diff --git a/AGENTS.consumer.md b/AGENTS.consumer.md index e3ac438..3ec2831 100644 --- a/AGENTS.consumer.md +++ b/AGENTS.consumer.md @@ -1,6 +1,6 @@ ## nostro -nostro is a banking client for Linux in three parts. The library is a C++26 module, `import Nostro;`, that talks to a bank's API directly (bunq so far), keeps the credentials in one private JSON file, caches transactions in Crafter.DB tables, and lists, syncs, pays, requests and schedules. nostrod is a system daemon that runs that library for every local user, one worker process each, behind D-Bus and polkit. The `nostro` CLI is a client of nostrod. A consumer does one of three things: +nostro is a banking client for Linux in four parts. The library is a C++26 module, `import Nostro;`, that talks to a bank's API directly (bunq so far), keeps the credentials in one private JSON file, caches transactions in Crafter.DB tables, and lists, syncs, pays, requests and schedules. nostrod is a system daemon that runs that library for every local user, one worker process each, behind D-Bus and polkit. The `nostro` CLI and the Nostro app, a window for a phone or a desktop, are clients of nostrod. The app's own modules (`Nostro.Ui`, `Nostro.App`, `Nostro.Ui.Shell`) are built for the app and its tests alone, and are GPL-3.0-only where the library is LGPL-3.0-only: `--lib` does not hand them to a consumer. A consumer does one of three things: - links the library and holds the credentials itself, in its own process (`--lib --banks=bunq`); - talks to nostrod through `Nostro::Client` (`--lib --banks=bunq --dbus`), as the CLI does; @@ -12,7 +12,8 @@ Everything is in `namespace Nostro`: the OpenSSL helpers in `Nostro::Crypto`, th - `GitProject` with nostro's repository, or `LocalProject({ .projectFile = "/project.cpp", .args = nostroArgs })` for a checkout, into `cfg.dependencies`. `nostroArgs` is your own `ProjectArgs()` plus `--lib` and `--banks=bunq`, built once inside `CrafterBuildProject`: without `--lib` nostro's `project.cpp` returns the CLI executable configuration (with the library as its dependency, which you cannot import from), and without `--banks=` it throws "must enable atleast one bank" and the whole build stops at load. `--banks=` is a comma-separated list and `bunq` is the only name it accepts. - `--dbus` with `--lib` adds the partitions that talk to nostrod, `:Bus`, `:Client` and `:Daemon`, and links `-lsystemd` (sd-bus) for you; it needs bunq on, since the wire carries bunq's types. Without it the library does not depend on libsystemd. `--product=checkout` instead returns the `nostro-checkout` library alone: the module `Nostro.Checkout`, needing neither `--lib` nor `--banks=`, and linking libsystemd and nothing else of nostro's (no OpenSSL, Crafter.Network or Crafter.DB). -- nostro strips its own args (`--lib`, `--banks=`, `--dbus`, `--product=`, `--coverage`, `--profile-runtime=`) from what it hands its dependencies and forwards the rest, adding `--no-quic` for Crafter.Network: nostro speaks HTTP/1.1 only, and msquic would tie the binary to the building user's cache. A consumer that also loads Crafter.Network gives it that same list, `--no-quic` included, and Crafter.DB the list without it, or the build stops with two loads that disagree on their args. +- nostro strips its own args (`--lib`, `--banks=`, `--dbus`, `--product=`, `--graphics=`, `--debug-api`, `--coverage`, `--profile-runtime=`) from what it hands its dependencies and forwards the rest, adding `--no-quic` for Crafter.Network: nostro speaks HTTP/1.1 only, and msquic would tie the binary to the building user's cache. A consumer that also loads Crafter.Network gives it that same list, `--no-quic` included, and Crafter.DB the list without it, or the build stops with two loads that disagree on their args. +- nostro's `project.cpp` loads two build helpers by `#pragma crafter dependency`, Crafter.LintRules and, at a pinned commit, Crafter.Debug's: loading nostro fetches and builds both for the host, whatever is built of it. Crafter.Debug's library itself is only in nostro's own app, under `--debug-api`. - What comes with it: Crafter.Network (with Crafter.Thread behind it), Crafter.DB, `-lssl -lcrypto`, and with `--dbus` `-lsystemd`, all as link flags you do not declare. Nothing in nostro uses the thread pool, so `ThreadPool::Start()` is not needed for it. - Defines do not cross a dependency. nostro compiles with `NOSTRO_BUNQ_ENABLED`, `NOSTRO_OPENSSL_ENABLED` and, under `--dbus`, `NOSTRO_DBUS_ENABLED`, and the PCMs carry the result: `import Nostro;` exports `BunqConnector` and `Client`, and `EnabledBanks` lists bunq, whatever your configuration defines (nostro's own CLI compiles without them). Your own `#ifdef NOSTRO_BUNQ_ENABLED` sees it only when you push the same `Define` into your `cfg.defines`, as nostro's CLI configuration does with `execfg.defines = libcfg.defines`. - `import Nostro;` is enough for everything below; nothing exposed needs `import Crafter.Network;` or `import Crafter.DB;`. The raw bunq calls (`Get`, `Post`, `Put`, `Delete`, `List`) take and return `nlohmann::json`: hold the result in `auto`, and include `lib/json.hpp` where you have to name or build one. @@ -23,7 +24,7 @@ Everything is in `namespace Nostro`: the OpenSSL helpers in `Nostro::Crypto`, th - `Currency` is an `enum class` with `Euro` alone. `GetCurrency("EUR")` (or `"eur"`) is the only parse; anything else throws `std::runtime_error("unsupported currency '…'")`. `RefreshAccounts` skips a bank account in another currency with a `Note` instead. `GetCurrencyCode` gives `"EUR"`, `GetCurrencySymbol` `"€"`, `GetCurrencyDecimals` 2; `std::format("{}", Currency::Euro)` is the symbol. All `constexpr`. - Amounts and balances are `std::int64_t` in the minor unit, so `1250` is €12.50, outgoing negative. `ParseAmount("12.50", Currency::Euro)` is `1250`: an optional leading `-`, digits, an optional `.` with at most `decimals` digits, nothing else, or `std::runtime_error("malformed amount '…'")`. `FormatAmount(1250, Currency::Euro)` is `"12.50"`, `FormatAmount(-5, …)` `"-0.05"`, and `FormatMoney(-102, …)` `"-€1.02"`, the sign before the symbol. All `constexpr`. - `ParseTimestamp("2026-10-31 12:34:56.123456")` is a `std::chrono::system_clock::time_point`, read as UTC: exactly `YYYY-MM-DD HH:MM:SS`, optionally `.` and one to six fraction digits, no zone, or `std::runtime_error("malformed timestamp '…'")`. `FormatTimestamp` is its inverse, bunq's format. libc++'s `system_clock` ticks in microseconds, which is also what the tables store. -- For dates a person types: `ParseLocalDate("2026-10-31")` or `ParseLocalDate("2026-10-31 09:30")` in the local time zone (through `mktime`), or `std::runtime_error` naming the format; `ParseLocalDate(day, 1)` is the midnight that ends `day`, counted by the calendar, so a day the clocks change is 23 or 25 hours. `FormatLocalTime(time)` is `"YYYY-MM-DD hh:mm"` in local time. +- For dates a person types: `ParseLocalDate("2026-10-31")` or `ParseLocalDate("2026-10-31 09:30")` in the local time zone (through `mktime`), or `std::runtime_error` naming the format; `ParseLocalDate(day, 1)` is the midnight that ends `day`, counted by the calendar, so a day the clocks change is 23 or 25 hours, and `ParseLocalDateEnd(text)` the last moment a range ending at `text` includes (the end of that day for a date alone). `FormatLocalTime(time)` is `"YYYY-MM-DD hh:mm"` in local time. - `UrlEncode` percent-encodes all but RFC 3986's unreserved characters; `UrlDecode` undoes it and reads `+` as a space; `QueryParameter(url, name)` is the decoded value from the query string, or `std::nullopt`. `EscB(text)` escapes text for inside a JSON string literal; nostro itself no longer builds JSON by hand. ### Connectors, the config file and the process @@ -37,26 +38,26 @@ Everything is in `namespace Nostro`: the OpenSSL helpers in `Nostro::Crypto`, th - Generic code over the enabled banks is `tuple_for([&]() { for (Bank& bank : Bank::connectors) { … } });`, a template lambda. Every `Bank` has `static constexpr std::string connectorId` (`"bunq"`), `static std::deque connectors`, `using Account`, `std::vector accounts`, `std::string name`, `TestConnector()`, `RefreshAccounts()`, `RefreshSession()`, `GetNewTransactions()` and `GetNewTransactions(account)`, `Logout()`, `StorageKey()`, a static `Create(…)` and `Remove(bank)`, and formats as its name. Its accounts have `StorageKey()` and format as `namebic iban€12.50` (`std::format` works on `Account` and on every type derived from it). Anything else, such as requests or cards, is bunq's own; `if constexpr (requires { account.Requests(); })` is how nostro's CLI asks. - `Account { name, bic, iban, currency, balance }` plus the transaction store, keyed by a storage key you pass as the `connector` argument. For bunq that is `account.StorageKey()`, `bunq///`. - `GetLastTransactionTime(key)`: the newest stored `timePoint`, `time_point::min()` for an empty or new table. - - `SaveTransactions(key, std::vector)`: sorts by time, appends the rows newer than the last stored one, flushes. At the last stored timestamp a row is appended when its `id` is not stored there yet. When a row stored there has no id (version 1 data), everything at that timestamp is taken as stored. Older rows are dropped silently. - - `FindTransactions(key, TransactionQuery)`: newest first, at most `limit`. `TransactionQuery` takes designated initialisers: `.search` (ASCII case-insensitive substring of the counterparty name, the description or the IBAN; empty matches all), `.amount` (`std::optional`, exact, minor units, negative for outgoing), `.from` and `.to` (inclusive `time_point`s, the whole range by default), `.limit` (100). The time range is a binary search on the ordered table; the rest is a backwards scan that stops at `limit`. + - `SaveTransactions(key, std::vector)`: sorts by time, appends the rows newer than the last stored one and flushes; a call that brings nothing new writes nothing. At the last stored timestamp a row is appended when its `id` is not stored there yet. When a row stored there has no id (version 1 data), everything at that timestamp is taken as stored. Older rows are dropped silently. + - `FindTransactions(key, TransactionQuery)`: newest first, at most `limit`. `TransactionQuery` takes designated initialisers: `.search` (ASCII case-insensitive substring of the counterparty name, the description or the IBAN; empty matches all), `.amount` (`std::optional`, exact, minor units, negative for outgoing), `.from` and `.to` (inclusive `time_point`s, the whole range by default), `.limit` (100), and `.stored` (false), which is for nostrod and which `FindTransactions` does not look at: it never asks a bank. The time range is a binary search on the ordered table; the rest is a backwards scan that stops at `limit`: measured at 1.5 µs over 20 rows and 4 ms over 100 000 when nothing matches. - The tables are `/transactions//.cdb`, with a `/` in the name written as `_`, opened on first use and kept open for the rest of the process, or until `Account::ForgetTransactions(key)` closes and deletes every table under `key` (a connector's storage key covers all its accounts; `Remove` calls it). A renamed account starts a new table and syncs again. Tables written before 2026-10-31 sit at `/transactions/bunq/.cdb` and are no longer read. - `Transaction { name, bic, iban, description, currency, amount, timePoint, id, kind }` is an aggregate and the on-disk row type (`version = 2`, `orderedBy = timePoint`, 120 bytes). `id` is the bank's own id as text and `kind` its classification (bunq's `"MASTERCARD/PAYMENT"`, `"EBA_SDD/SDD"`); both are empty in rows migrated from version 1. A version 1 table migrates on its first open and keeps `.v1.bak`. Do not add members to it from outside. ### The bunq connector -- **Two environments.** `BunqConnector::environment` is `BunqEnvironment::Production` (`api.bunq.com`, real money) or `Sandbox` (`public-api.sandbox.bunq.com`). `BunqConnector::EnvironmentOfKey(key)` is `Sandbox` for a key starting `sandbox_`; an OAuth token does not say, so the caller decides. Only the sandbox has been exercised (2026-10-31). `BunqConnector::Endpoint(environment)` is the `BunqEndpoint` (`host`, `port`, `caPem`) its calls go to. Each endpoint has one `ClientHTTP1`, shared by its connectors; every call is synchronous on the calling thread and the client serves one caller at a time, so keep bunq calls on one thread. +- **Two environments.** `BunqConnector::environment` is `BunqEnvironment::Production` (`api.bunq.com`, real money) or `Sandbox` (`public-api.sandbox.bunq.com`). `BunqConnector::EnvironmentOfKey(key)` is `Sandbox` for a key starting `sandbox_`; an OAuth token does not say, so the caller decides. Production has been used to connect and to read since 2026-11-19; before that only the sandbox was. `BunqConnector::Endpoint(environment)` is the `BunqEndpoint` (`host`, `port`, `caPem`) its calls go to. Each endpoint has one `ClientHTTP1`, shared by its connectors; every call is synchronous on the calling thread and the client serves one caller at a time, so keep bunq calls on one thread. - **For tests:** `BunqConnector::RedirectTo(BunqEndpoint{.host = "127.0.0.1", .port = …, .caPem = …})` sends every API and OAuth token call there for the rest of the process, whatever the environment. nostro's own tests point it at `tests/Support/FakeBunq.inc`, an in-process bunq that a consumer's test can include as well (after `lib/json.hpp`, `import std;`, `import Nostro;` and `import Crafter.Network;`). - `BunqConnector::Create(std::string&& apiKey, std::string_view allowedIps, BunqEnvironment environment)` registers an installation with a fresh RSA-2048 key, the device with the key and opens a session. `allowedIps` is a plain comma-separated list (`"203.0.113.4, 198.51.100.7"`), `"*"` for any address (it makes the key a wildcard key, which a phone with a changing address needs), or empty for the address the call comes from. It returns a reference into `BunqConnector::connectors`, a `std::deque`, so a later `Create` leaves earlier references and every account's `connector` pointer valid. The same bunq user (`ownerId`) in the same environment connected the same way replaces the old connector, logging its session out: that is how a key is renewed. Connected the other way (API key against OAuth), `Create` logs the new session out and throws, because every account would otherwise be listed twice. Follow it with `Connector::SaveConnectors()` or the connector is gone at exit. - `BunqConnector::Remove(connector)` deletes its stored transactions (through `Account::ForgetTransactions`, which first closes the tables this process has open, so the same user added again syncs into new files) and erases it from `connectors`, re-pointing the remaining accounts; references to other connectors you held are invalidated, as with any `deque::erase` in the middle. It does not log out: call `Logout()` first (`DELETE /v1/session/{sessionId}`, not renewed; a session already gone counts as logged out). Then `SaveConnectors()`. - After `LoadConnectors` or `Create` a connector has `environment`, `name` (bunq's `display_name` of the user; for OAuth of the user who granted access), `id` (the user id in API paths; for OAuth the `UserApiKey`'s own), `ownerId`, `userType` (`UserPerson`, `UserCompany`, `UserApiKey` or `UserPaymentServiceProvider`; `IsOAuth()` is `UserApiKey`), `sessionToken`, `sessionId`, `installationToken`, `privateKey` and `serverPublicKey` (`Crypto::Key`, a `std::shared_ptr`), `apiKey`, and `accounts` of `BunqAccount` (`Account` plus `id`, bunq's object `type` such as `MonetaryAccountSavings`, and a `connector` back-pointer). -- Every call goes through `Get`, `Post`, `Put` or `Delete` (a path below `/v1`, or a pagination URL) and `List` (every item of a listing, pages of 200 followed through `older_url`, newest first). Bodies are signed. Every 2xx must carry a valid `x-bunq-server-signature` for the stored server key, which an old connector fetches before its first call, or the call throws. A 429 is waited out: 3 s up to five times, 31 s up to twice for `session-server`. A 401, or a 403 "Insufficient authentication.", opens a new session once, saves, and retries. A POST, PUT or DELETE goes over a new connection, because `ClientHTTP1` would replay one on a reused connection after a read timeout. When the outcome of such a write is unknown (a transport error, a 5xx, an unreadable or unverifiable answer), the error ends in `; the request may have been carried out, check before trying again`. Any other error response is a `BunqError`. +- Every call goes through `Get`, `Post`, `Put` or `Delete` (a path below `/v1`, or a pagination URL) and `List` (every item of a listing, pages of 200 followed through `older_url`, newest first). Bodies are signed. Every 2xx must carry a valid `x-bunq-server-signature` for the stored server key, which an old connector fetches before its first call, or the call throws. A 429 is waited out: 3 s up to five times, 31 s up to twice for `session-server`. A 401, or a 403 "Insufficient authentication.", opens a new session once, saves, and retries. A POST, PUT or DELETE goes over a new connection, because `ClientHTTP1` would replay one on a reused connection after a read timeout. When the outcome of such a write is unknown (a transport error, a 5xx, an unreadable or unverifiable answer), the error ends in `; the request may have been carried out, check before trying again`, which is `BunqError::maybeCarriedOut`. Any other error response is a `BunqError`. - `RefreshAccounts()` rebuilds `accounts` from scratch (references into it go stale): every `MonetaryAccount…` type whose status is `ACTIVE` or `BLOCKED`, the IBAN alias as `iban`, `BUNQNL2A` as `bic` for a bunq IBAN. `TestConnector()` is `GET /v1/user/{id}` and returns `false` on any exception rather than throwing. `GetNewTransactions(account)` (and `GetNewTransactions()` for all) pages the payments newest first until one older than the last stored row, fills `id` and `kind` (`"/"`), and calls `SaveTransactions(account.StorageKey(), …)`; the first sync walks the whole history, 200 a call. - On a `BunqAccount`, amounts are positive minor units, or `std::invalid_argument`. Counterparties go through `BunqCounterparty::Parse(value, name)`: an `@` makes an e-mail address, a leading `+` a phone number (spaces, dashes and brackets dropped), anything else an IBAN. An IBAN is upper-cased, has its spaces removed and its check digits verified, so a typo throws `std::invalid_argument` before anything is sent. bunq needs `name` for an IBAN outside bunq. - - `Send`, `Draft` (one-entry draft payment, paid once someone accepts it) and `Schedule(…, BunqSchedule)` return bunq's id. `BunqSchedule { start, end, unit ("ONCE", "HOURLY", "DAILY", "WEEKLY", "MONTHLY", "YEARLY"), every }` is UTC; an unknown unit or `every == 0` throws `std::invalid_argument`. + - `Send`, `Draft` (one-entry draft payment, paid once someone accepts it) and `Schedule(…, BunqSchedule)` return bunq's id. `BunqSchedule { start, end, unit ("ONCE", "HOURLY", "DAILY", "WEEKLY", "MONTHLY", "YEARLY"), every }` is UTC; an unknown unit or `every == 0` throws `std::invalid_argument`. `BunqSchedule::UnitFromWord("monthly")` is `"MONTHLY"`, for a unit a person typed. - `Request(from, name, amount, currency, description)` asks for money with bunq.me allowed and returns a `BunqPaymentRequest`, whose `shareUrl` anyone can pay through. When reading it back fails, the request still exists: it comes back `PENDING` without a share URL, with a `Note`. - The listings, newest first: `Requests()` (sent, `BunqPaymentRequest`), `IncomingRequests()` (`BunqIncomingRequest`, incoming SEPA direct debits included as `DIRECT_DEBIT`), `ScheduledPayments()`, `DraftPayments()`. One of each, as bunq has it now: `IncomingRequest(id)` and `DraftPayment(id)`. The answers: `RevokeRequest(id)`, `CancelScheduledPayment(id)`, and two that take the object you showed the user: `RespondToRequest(shown, accept)` pays `shown.amount` and `shown.currency`, whatever the request asks by then, and `RespondToDraftPayment(shown, accept)` sends `shown.updated` (bunq's own timestamp, kept as text), so bunq refuses an answer to a draft that changed since. Read it, show it, answer with what you read. A request has one id on each side: the asker's inquiry id is not the payer's response id. -- `Cards()` lists the user's cards (`BunqCard`: `id`, `status`, `productType`, `lastFour`, `expiry`, the paying `iban`, …). `SetCardStatus(id, "DEACTIVATED" | "ACTIVE" | "LOST" | "STOLEN")` returns the card as bunq has it afterwards, which can differ from the request without an error: a card that was never activated stays `DEACTIVATED`. -- OAuth instead of an API key: `OAuthAuthorizationUrl(environment, clientId, redirectUri, state)` is where the user approves with the bunq app. bunq then redirects to `redirectUri` with `code` and `state` (check `state` yourself). `OAuthExchangeCode(environment, clientId, clientSecret, redirectUri, code)` returns the access token, which `Create` takes in place of an API key. bunq grants OAuth payments between the user's own accounts, draft payments, cards, and creating requests, but no paying of incoming ones. The exchange was verified up to bunq refusing a fake code; a full approval needs a person and the bunq app. +- `Cards()` lists the user's cards (`BunqCard`: `id`, `status`, `orderStatus`, `productType`, `lastFour`, `expiry`, the paying `iban`, …). `status` is bunq's, and is about the plastic: `card.State()` is how the card stands in one word, which is `status` except for a virtual card (`card.Virtual()`: its `orderStatus` is `VIRTUAL_DELIVERY`), which is `VIRTUAL` until it is gone for good. bunq has a virtual card as `DEACTIVATED` however well it pays, and nothing says whether one is frozen. The `std::formatter` prints `State()`. `SetCardStatus(id, "DEACTIVATED" | "ACTIVE" | "LOST" | "STOLEN")` returns the card as bunq has it afterwards, which can differ from the request without an error: a card that was never activated stays `DEACTIVATED`, and a virtual card is left as it is when asked to freeze or unfreeze. `card.ExpectStatus(asked)` throws `std::runtime_error` saying so in either case. Through nostrod, `Client::SetCardStatus` refuses to freeze or unfreeze a virtual card with `std::invalid_argument`, before anyone is asked for a password. +- OAuth instead of an API key: `OAuthAuthorizationUrl(environment, clientId, redirectUri, state)` is where the user approves with the bunq app. bunq then redirects to `redirectUri` with `code` and `state`: `OAuthCodeFromRedirect(redirectedAddress, state)` returns the code, or throws `std::runtime_error` when bunq did not authorize (`error=`), the address has no code, or its `state` is another. `OAuthExchangeCode(environment, clientId, clientSecret, redirectUri, code)` returns the access token, which `Create` takes in place of an API key. bunq grants OAuth payments between the user's own accounts, draft payments, cards, and creating requests, but no paying of incoming ones. The exchange was verified up to bunq refusing a fake code; a full approval needs a person and the bunq app. - Every type above formats with `std::format` as one tab-separated line (a draft adds a line per entry), the way nostro's CLI prints them. ### nostrod, through Nostro::Client @@ -64,9 +65,10 @@ Everything is in `namespace Nostro`: the OpenSSL helpers in `Nostro::Crypto`, th nostrod is the system daemon that holds every local user's connectors, in a worker process per user under its own state directory, which the users cannot read. It answers `net.catcrafts.Nostro1` on the system bus (published as `packaging/dbus/net.catcrafts.Nostro1.xml`), for the calling user only, after asking polkit: viewing and the changes that move no money pass in an active session, while paying, scheduling, accepting a request or a draft, unfreezing or blocking a card, changing the connectors and choosing the checkout account ask for the user's password each time. A front end that should not hold the credentials itself (`--dbus`) talks to it through `Nostro::Client`: - `Client::System(timeout = 10min)` connects to the system bus with interactive authorization allowed, so polkit can ask for the password, and a call timeout long enough for the user and for bunq's rate limits. D-Bus starts nostrod with the first call. Keep one `Client` per thread; it is not shared between threads. -- One method per D-Bus method, with nostro's own types: `Connectors()` (`ConnectorSummary`: `name`, `bank`, `environment`, `auth` "api key" or "oauth", `working`), `AddBunq(apiKey, allowedIps, environment)` and `AddBunqOAuth(environment, clientId, clientSecret, redirectUri, code)` (`AddedConnector`; an empty environment takes the key's), `RemoveConnector(name or number)`, `Accounts()` (`ConnectorAccounts`), `Transactions(account, TransactionQuery)` (synced first), `Send`, `Schedule`, `Draft` (`Created`: bunq's `id` and the `currency`), `Request` (`BunqPaymentRequest`), the listings, `RevokeRequest`, `RespondToRequest(account, id, accept)`, `CancelScheduledPayment`, `RespondToDraftPayment(account, id, accept)`, `Cards()` (`ConnectorCards`), `SetCardStatus(card, status)`, `DefaultCheckoutAccount()` (`std::optional`) and `SetDefaultCheckoutAccount(account)`. `account` is an account's name or IBAN. Accepting a request or a draft pays it as nostrod read it to show the user. +- One method per D-Bus method, with nostro's own types: `Connectors()` (`ConnectorSummary`: `name`, `bank`, `environment`, `auth` "api key" or "oauth", `working`), `AddBunq(apiKey, allowedIps, environment)` and `AddBunqOAuth(environment, clientId, clientSecret, redirectUri, code)` (`AddedConnector`; for `AddBunq` leave the environment empty: nostrod takes the one the key is of, and naming one only has a key of the other refused with `std::invalid_argument`, before anything is sent), `RemoveConnector(name or number)`, `Accounts()` (`ConnectorAccounts`), `Transactions(account, TransactionQuery)` (nostrod asks the bank for what is new first, a call to the bank that takes its time and that the bank counts; with `.stored = true` it answers from what it has stored alone, in milliseconds: for a search in a list just read, or more of it. A nostrod from before 2026-11-19 ignores `stored` and asks the bank), `Send`, `Schedule`, `Draft` (`Created`: bunq's `id` and the `currency`), `Request` (`BunqPaymentRequest`), the listings, `RevokeRequest`, `RespondToRequest(account, id, accept)`, `CancelScheduledPayment`, `RespondToDraftPayment(account, id, accept)`, `Cards()` (`ConnectorCards`), `SetCardStatus(card, status)`, `DefaultCheckoutAccount()` (`std::optional`) and `SetDefaultCheckoutAccount(account)`. `account` is an account's name or IBAN. Accepting a request or a draft pays it as nostrod read it to show the user. - `TakeNotes()` returns, and clears, the library's warnings from the calls so far (a connector unavailable, a request made but not read back): show them. -- Errors: `std::invalid_argument` for what nostrod refused before doing anything (it names the problem, as the library's own messages do); `DaemonError`, a `std::runtime_error` with the D-Bus error `name`, for the rest: `Bus::errorBank` (bunq's refusal, as bunq said it), `Bus::errorOAuthCannotPay`, `Bus::errorCancelled` (the user closed the password dialog), `Bus::errorNoCheckoutAccount`, `Bus::errorFailed`, `org.freedesktop.DBus.Error.AccessDenied` (the system's policy, or polkit not answering) and `InteractiveAuthorizationRequired`. A missing nostrod is a `std::runtime_error` saying it is not running; a call that moves money or changes something and gets no answer in time is a `std::runtime_error` saying it may have been carried out; text that is not UTF-8 is a `std::invalid_argument` before anything is sent. +- Every method also has an asynchronous form, for a program with an event loop that must not wait minutes on a password dialog: `client.Attach(sd_event*)` once (a second `Attach` throws), then call the method with a last argument `Then` (`std::function)>`; `std::monostate` for a method that answers nothing). It returns a `[[nodiscard]] Client::Pending` at once and calls `then` from the loop when nostrod answers. `Answer` holds the `result` or the `std::exception_ptr` the blocking call would have thrown (`Get()` returns the one or rethrows the other, `Failed()`, `Error()`), and that call's `notes`; an error answer carries none, and notes are collected per user by nostrod's worker, so they can be another call's of the same user. Destroying the `Pending`, or `Cancel()`, drops the answer (`then` is not called) without undoing the call, which nostrod and bunq carry on with; `Active()` says whether `then` is still to come. A `then` that throws is reported through `Note`. Calling one without `Attach` throws `std::logic_error`. Once the connection is gone (`Connected()` false), make a new client: a closed connection answers nothing it still awaited. +- Errors: `std::invalid_argument` for what nostrod refused before doing anything (it names the problem, as the library's own messages do); `DaemonError`, a `std::runtime_error` with the D-Bus error `name`, for the rest: `Bus::errorBank` (bunq's refusal, as bunq said it), `Bus::errorOAuthCannotPay`, `Bus::errorCancelled` (the user closed the password dialog), `Bus::errorNoCheckoutAccount`, `Bus::errorFailed`, `org.freedesktop.DBus.Error.AccessDenied` (the system's policy, or polkit not answering) and `InteractiveAuthorizationRequired`. A missing nostrod is `DaemonMissing`, a `std::runtime_error` saying it is not running. A call that moves money or changes something and gets no answer in time, or that bunq answered with an error ending in `BunqError::maybeCarriedOut` (a 5xx: the payment may have been made), is `OutcomeUnknown`, a `std::runtime_error` saying it may have been carried out: check before trying again. Text that is not UTF-8 is a `std::invalid_argument` before anything is sent. - The API key and the OAuth client secret travel once, in messages marked sensitive. Read them with `ReadSecret`, never from `argv`, which every local user can read and polkit logs. ### Checkout @@ -102,14 +104,14 @@ An app that only needs a customer to pay an order links `Nostro.Checkout` (`--pr ### Names to get right -`Connector::LoadConnectors` and `SaveConnectors` are statics on a struct with nothing else. On `BunqConnector`: `connectorId` is `"bunq"`, `connectors` the static deque, `Create` and `Remove` the static constructor and remover, plus `EnvironmentOfKey`, `OAuthAuthorizationUrl` and `OAuthExchangeCode`, `Get`/`Post`/`Put`/`Delete`/`List`, `RefreshSession`, `RefreshAccounts`, `GetNewTransactions`, `TestConnector`, `Logout`, `Cards`, `SetCardStatus`, `StorageKey`, `IsOAuth`, `Endpoint` and `RedirectTo`. On `BunqAccount`: `Send`, `Draft`, `Schedule`, `Request`, `Requests`, `IncomingRequests`, `ScheduledPayments`, `DraftPayments`, `IncomingRequest`, `DraftPayment`, `RevokeRequest`, `RespondToRequest`, `CancelScheduledPayment`, `RespondToDraftPayment`, `Path` and `StorageKey`. On `Account`, the static `ForgetTransactions`. The warnings: `Note` and `noteSink`. Other names: +`Connector::LoadConnectors` and `SaveConnectors` are statics on a struct with nothing else. On `BunqConnector`: `connectorId` is `"bunq"`, `connectors` the static deque, `Create` and `Remove` the static constructor and remover, plus `EnvironmentOfKey`, `OAuthAuthorizationUrl`, `OAuthCodeFromRedirect` and `OAuthExchangeCode`, `Get`/`Post`/`Put`/`Delete`/`List`, `RefreshSession`, `RefreshAccounts`, `GetNewTransactions`, `TestConnector`, `Logout`, `Cards`, `SetCardStatus`, `StorageKey`, `IsOAuth`, `Endpoint` and `RedirectTo`. On `BunqAccount`: `Send`, `Draft`, `Schedule`, `Request`, `Requests`, `IncomingRequests`, `ScheduledPayments`, `DraftPayments`, `IncomingRequest`, `DraftPayment`, `RevokeRequest`, `RespondToRequest`, `CancelScheduledPayment`, `RespondToDraftPayment`, `Path` and `StorageKey`. On `Account`, the static `ForgetTransactions`. The warnings: `Note` and `noteSink`. Other names: - the bunq types: `BunqEnvironment`, `BunqEndpoint`, `BunqError`, `BunqCounterparty`, `BunqLabel`, `BunqPaymentRequest`, `BunqIncomingRequest`, `BunqSchedule`, `BunqScheduledPayment`, `BunqDraftPayment`, `BunqCard`; - `EnabledBanks` and `tuple_for` in `:Banks`; - `ParseAmount`, `FormatAmount`, `FormatMoney`, `GetCurrency`, `GetCurrencyCode`, `GetCurrencySymbol` and `GetCurrencyDecimals`; -- in `:Utils`: `ParseTimestamp`, `FormatTimestamp`, `ParseLocalDate`, `FormatLocalTime`, `UrlEncode`, `UrlDecode`, `QueryParameter` and `EscB`; +- in `:Utils`: `ParseTimestamp`, `FormatTimestamp`, `ParseLocalDate`, `ParseLocalDateEnd`, `FormatLocalTime`, `UrlEncode`, `UrlDecode`, `QueryParameter` and `EscB`; - `FindTransactions` (not Query, Load or List), `SaveTransactions` and `GetLastTransactionTime`; -- `TransactionQuery` with `search`, `amount`, `from`, `to` and `limit`; +- `TransactionQuery` with `search`, `amount`, `from`, `to`, `limit` and `stored`; - in `Nostro::Crypto`: `Key`, `OwnKey`, `SignBody`, `VerifyBody`, `CreateKey` (a `std::tuple`, the public PEM second), `LoadKeyFromPem`, `LoadPublicKeyFromPem`, `PrivateKeyToPem`, `PublicKeyToPem`, `RandomHex` and `ThrowOnOpenssl`; - `configPath`, `cachePath`, `CreatePrivateFile` and `ReadSecret`; -- for nostrod: `Client` (`System`, `TakeNotes`, `DefaultCheckoutAccount`, `SetDefaultCheckoutAccount`), `DaemonError`, `ConnectorSummary`, `AddedConnector`, `ConnectorAccounts`, `ConnectorCards`, `Created`, and `Bus::busName`, `Bus::errorBank` and the other `Bus::error…` names; +- for nostrod: `Client` (`System`, `Attach`, `Connected`, `TakeNotes`, `DefaultCheckoutAccount`, `SetDefaultCheckoutAccount`, and `Client::Pending` and `Client::Then`), `Answer`, `DaemonError`, `DaemonMissing`, `OutcomeUnknown`, `ConnectorSummary`, `AddedConnector`, `ConnectorAccounts`, `ConnectorCards`, `Created`, and `Bus::busName`, `Bus::errorBank` and the other `Bus::error…` names; - for checkout: `Nostro::Checkout::Pay`, `Order`, `Paid`, `Error`, `Cancelled`, `NoCheckoutAccount`, and the module `Nostro.Checkout`, with a dot. diff --git a/AGENTS.template.md b/AGENTS.template.md index e3882c2..899bf2e 100644 --- a/AGENTS.template.md +++ b/AGENTS.template.md @@ -1,10 +1,21 @@ # AGENTS.md -Guidance for coding agents and contributors working on nostro itself. The [README](README.md) is the user-facing manual (what nostro is for, the CLI, how to contribute a bank), and [AGENTS.consumer.md](AGENTS.consumer.md) is what agents working in a *consumer* of the library read: crafter-build copies it into the dependency-notes section of the consumer's `AGENTS.md` on every build. When any of the three disagrees with the code, the code wins; the interfaces under `interfaces/` are the contract, `Transaction` in `interfaces/Nostro-Transaction.cppm` is the contract for the bytes on disk, and `packaging/dbus/*.xml` with `packaging/system/net.catcrafts.Nostro1.policy` are the contract on the system bus, which a test holds to what nostrod serves. This file is written by crafter-build from `AGENTS.template.md`; the section at its end holds the notes of the libraries nostro builds against (Crafter.Network, Crafter.DB), straight from their repositories. +Guidance for coding agents and contributors working on nostro itself. The [README](README.md) is the user-facing manual (what nostro is for, the CLI, how to contribute a bank), and [AGENTS.consumer.md](AGENTS.consumer.md) is what agents working in a *consumer* of the library read: crafter-build copies it into the dependency-notes section of the consumer's `AGENTS.md` on every build. When any of the three disagrees with the code, the code wins; the interfaces under `interfaces/` are the contract, `Transaction` in `interfaces/Nostro-Transaction.cppm` is the contract for the bytes on disk, and `packaging/dbus/*.xml` with `packaging/system/net.catcrafts.Nostro1.policy` are the contract on the system bus, which a test holds to what nostrod serves. This file is written by crafter-build from `AGENTS.template.md`; the section at its end holds the notes of what the last build loaded, straight from their repositories: Crafter.Network, Crafter.DB and Crafter.Debug on every build (the debug flag Crafter.Debug's notes speak of is `--debug-api`, and it is the app's alone), and Crafter.Graphics with Crafter.Math and Crafter.Asset after a build of the app. ## Project overview -nostro is a banking client for Linux, phones first: a library that talks to bank APIs directly; nostrod, a system daemon that runs it for every local user behind D-Bus and polkit, so no program of the user's can read the bank's secrets or move money without the user's password; and a small CLI that only talks to nostrod. Linux phones have no banking apps; nostro is the open-source answer, one connector per bank. One C++26 module, `Nostro`, with twelve partitions behind the umbrella and ten implementation units, and a second module, `Nostro.Checkout`, for apps that have nostrod pay an order. `project.cpp` makes one product per build: the static library `nostro` with the CLI `nostro` (`implementations/main.cpp`), `nostrod` (`--product=daemon`, `implementations/nostrod.cpp`), or the static library `nostro-checkout` (`--product=checkout`). The bunq connector is the only bank so far and the model for the next one. It depends on Crafter.Network (HTTPS to the bank), Crafter.DB (the local transaction tables and the checkout record), OpenSSL (request signing, response verification), libsystemd (sd-bus and sd-event, for nostrod and its clients) and a vendored nlohmann/json. It ships as a Flatpak, `net.catcrafts.Nostro`, that systemd runs nostrod from as the system user `nostro`. +nostro is a banking client for Linux, phones first: a library that talks to bank APIs directly; nostrod, a system daemon that runs it for every local user behind D-Bus and polkit, so no program of the user's can read the bank's secrets or move money without the user's password; a small CLI that only talks to nostrod; and the app, a window for a phone or a desktop that only talks to nostrod too and does everything the CLI does. Linux phones have no banking apps; nostro is the open-source answer, one connector per bank. + +Five C++26 modules, and a sixth in one build: + +- `Nostro`, the library: twelve partitions behind the umbrella and ten implementation units. +- `Nostro.Checkout`, for apps that have nostrod pay an order. +- `Nostro.Ui`, the toolkit the app's screens are built with. It imports `std` alone. +- `Nostro.App`, the app without its window: what it knows, what is filled in, and its screens. +- `Nostro.Ui.Shell`, which puts the toolkit on a display, on Crafter.Graphics and one sd-event loop. +- `Nostro.DebugCommands`, what an agent drives the app with: in the app's `--debug-api` build and no other. + +`project.cpp` makes one product per build: the static library `nostro` with the CLI `nostro` (`implementations/main.cpp`), `nostrod` (`--product=daemon`, `implementations/nostrod.cpp`), the app `nostro-app` (`--product=app`, `implementations/nostro-app.cpp`), the static library `nostro-checkout` (`--product=checkout`), or `nostro-fake-system` (`--product=fake-system`, `tests/FakeSystem/main.cpp`), a made-up system to look at the app against. The bunq connector is the only bank so far and the model for the next one. The library depends on Crafter.Network (HTTPS to the bank), Crafter.DB (the local transaction tables and the checkout record), OpenSSL (request signing, response verification), libsystemd (sd-bus and sd-event, for nostrod and its clients) and a vendored nlohmann/json; the app adds Crafter.Graphics (a Wayland window, Vulkan, the input) and two Noto Sans fonts. It ships as two Flatpaks: `net.catcrafts.Nostrod`, that systemd runs nostrod from as the system user `nostro` and that holds the CLI, and `net.catcrafts.Nostro`, the app. | Path | What lives there | |---|---| @@ -14,34 +25,64 @@ nostro is a banking client for Linux, phones first: a library that talks to bank | `interfaces/Nostro.Checkout.cppm`, `implementations/Nostro.Checkout.cpp` | The module `Nostro.Checkout`: the checkout's names and wire, and a blocking `Pay` over sd-bus. A module of its own, so `--product=checkout` builds it without the rest. | | `implementations/main.cpp` | The CLI, a client of nostrod: `argv` parsing (positional arguments, `--name value` options, `--sandbox`), one function per command over `Client`, output through the `std::formatter`s, the notes on stderr, errors caught in `main` and printed with exit status 1. | | `implementations/nostrod.cpp` | nostrod's `main`: `--state`, `--idle`, `--prompt-timeout`, and `--worker ` for the worker processes it starts itself. | -| `project.cpp` | The build description: reads `--banks=`, `--lib`, `--dbus`, `--product=`, `--coverage` and `--profile-runtime=`, forwards the other args to the dependencies (with `--no-quic` for Crafter.Network), returns the product. | +| `interfaces/Nostro.Ui.cppm`, `interfaces/Nostro.Ui-.cppm`, `implementations/Nostro.Ui-.cpp` | The toolkit, `Nostro.Ui`: ten partitions, seven of them with an implementation unit. Ported from imsd-messages (ca5cd72d), which is Catcrafts' and GPL-3.0-only like it. | +| `interfaces/Nostro.App.cppm`, `interfaces/Nostro.App-.cppm`, `implementations/Nostro.App-.cpp` | `Nostro.App`: `:Banks`, `:Format`, `:Forms`, `:Errors` and `:App`. `:App` has three implementation units: `Nostro.App-App.cpp` (state, nostrod's answers, navigation, actions), `Nostro.App-Screens.cpp` (the screens) and `Nostro.App-Bunq.cpp` (bunq's two forms for adding a connection, and what their buttons do). | +| `interfaces/Nostro.Ui.Shell.cppm`, `interfaces/Nostro.Ui.Shell-.cppm`, `implementations/Nostro.Ui.Shell-.cpp` | `Nostro.Ui.Shell`: `:Loop`, `:Canvas`, `:Window` and `:Portal`. The one part that needs a compositor and a graphics device. | +| `implementations/nostro-app.cpp` | The app's `main`: the command line, the parts put together, the toolkit's gallery (`--gallery`) and a player of input scripts (`--poke`). | +| `interfaces/Nostro.DebugCommands.cppm`, `implementations/Nostro.DebugCommands.cpp` | The commands, watches, events and checks of the app's `--debug-api` build; see "Looking at the app". | +| `assets/` | Noto Sans Regular and Medium with their licence (`OFL.txt`); the app's build puts the fonts beside the executable. | +| `project.cpp` | The build description: reads `--banks=`, `--lib`, `--dbus`, `--product=`, `--graphics=`, `--debug-api`, `--coverage` and `--profile-runtime=`, forwards the other args to the dependencies (with `--no-quic` for Crafter.Network, except in the app's debug build), returns the product. It also holds what the app is as a Flatpak (`app.flatpak`) and the `fake` run script. | | `packaging/dbus/` | The published D-Bus interfaces, `net.catcrafts.Nostro1.xml` and `net.catcrafts.Nostro1.Checkout.xml`. | | `packaging/system/` | What a Flatpak cannot install: the polkit policy, the D-Bus policy and activation files, `nostrod.service`, the sysusers entry, the `nostro` command, `install.sh` and `uninstall.sh`. | -| `packaging/flatpak/`, `packaging/arch/` | The Flatpak manifest (on crafter-build's Flatpak as its base app), metainfo and `.flatpakref`; the Arch package of the system files, `nostro-system`. | +| `packaging/flatpak/`, `packaging/licenses/`, `packaging/arch/` | nostrod's Flatpak manifest (on crafter-build's Flatpak as its base app), each Flatpak's metainfo and `.flatpakref`, the app's desktop entry and icon, and the two scripts that cross-build both Flatpaks for aarch64; the licence texts the Flatpaks carry, with a `NOTICE` of what each covers; the Arch package of the system files, `nostro-system`. | | `lib/json.hpp` | nlohmann/json 3.12.0 (MIT), included in the global module fragment of `:Bunq` and of the `Connector`, `Bunq` and `BunqPayments` implementation units. | -| `tests//main.cpp`, `tests/Support/`, `tests/coverage.sh` | The tests, their checks, fake bunq and fake system bus, and the coverage run; see "Testing instructions". | -| `README.md`, `LICENSE`, `LICENSE.GPL` | The manual; LGPL-3.0-only and the GPL it incorporates. | +| `tests//main.cpp`, `tests/Support/`, `tests/FakeSystem/`, `tests/coverage.sh` | The tests, their checks, fake bunq and fake system bus, the made-up system built from those, and the coverage run; see "Testing instructions". | +| `docs/screenshots/` | The README's pictures of the app, on a phone's screen and in a desktop window, and `take.sh`, which takes them again on the made-up system; see "Looking at the app". | +| `README.md`, `LICENSE`, `LICENSE.GPL` | The manual; the LGPL version 3, which the library, nostrod and the CLI are under, and the GPL version 3, which the LGPL adds its permissions to and which the app is under (design rule 13). | | `AGENTS.template.md`, `AGENTS.consumer.md` | The source of this file, and the notes for consumers. `AGENTS.md` is gitignored: edit the template. | | `.vscode/` | A build task and an lldb launch configuration, both stale; see "Gotchas". | -| `bin/`, `build/` | Generated and gitignored. The library and the CLI are both named `nostro`, so one build leaves two `bin/nostro----/` directories: the library's (`libnostro.a`, the PCMs, `std.pcm`) and the executable's (`nostro`). Glob for the one holding `nostro`. nostrod builds into `bin/nostrod-…/`, the checkout library into `bin/nostro-checkout-…/`. | +| `bin/`, `build/` | Generated and gitignored. The library and the CLI are both named `nostro`, so one build leaves two `bin/nostro----/` directories: the library's (`libnostro.a`, the PCMs, `std.pcm`) and the executable's (`nostro`). Glob for the one holding `nostro`. nostrod builds into `bin/nostrod-…/`, the checkout library into `bin/nostro-checkout-…/`, the app into `bin/nostro-app-…/` with its fonts and Crafter.Graphics' shaders beside it (`bin/nostro-app-core-…/` is `Nostro.App`'s library), or under `files/bin/` there when it is packaged as a Flatpak. `build/crafter-debug` is the launcher of Crafter.Debug's client, `build/fake-system/` the state of the made-up system `run fake` starts, `build/flatpak-apps/` what `install` and `bundle` make of the app. | Partitions, from the bottom up (each imports only the ones above it): - `:Currency`: `Currency` (an `enum class : std::uint16_t` with `Euro` alone), `GetCurrency` (from `"EUR"` or `"eur"`, throws for anything else), `GetCurrencyCode`, `GetCurrencySymbol`, `GetCurrencyDecimals`, `ParseAmount` (decimal string to minor units), `FormatAmount` (back) and `FormatMoney` (`-€1.02`), all `constexpr`, and `std::formatter`, which prints the symbol. -- `:Utils`: `ParseTimestamp` and `FormatTimestamp` (bunq's `YYYY-MM-DD HH:MM:SS[.ffffff]`, UTC), `ParseLocalDate` and `FormatLocalTime` (dates a person types and reads, local time through `mktime`/`localtime`), `UrlEncode`, `UrlDecode` and `QueryParameter` (for OAuth), `EscB` (JSON string escaping, no longer used by nostro itself), and `Note` with its replaceable `noteSink`, where every warning of the library goes (stderr by default). +- `:Utils`: `ParseTimestamp` and `FormatTimestamp` (bunq's `YYYY-MM-DD HH:MM:SS[.ffffff]`, UTC), `ParseLocalDate`, `ParseLocalDateEnd` and `FormatLocalTime` (dates a person types and reads, local time through `mktime`/`localtime`), `UrlEncode`, `UrlDecode` and `QueryParameter` (for OAuth), `EscB` (JSON string escaping, no longer used by nostro itself), and `Note` with its replaceable `noteSink`, where every warning of the library goes (stderr by default). - `:Transaction`: the `Transaction` aggregate, which is also the row type of the Crafter.DB tables: `version = 2` (`id` and `kind` added on 2026-10-31), `orderedBy = &Transaction::timePoint`, `using Previous = TransactionV1` (unexported, kept for the migration), and its `std::formatter` (one tab-separated line). - `:Account`: `TransactionQuery` and `Account` (`name`, `bic`, `iban`, `currency`, `balance` in minor units) with the three methods over the transaction store and the static `ForgetTransactions` (which closes this process's open tables under a storage key before deleting them), and the `std::formatter` for `Account` and everything derived from it. The implementation unit owns the Crafter.DB tables and pins the schema with two `static_assert`s. - `:File`: `GetConfigPath`, `GetCachePath`, the globals `configPath` and `cachePath` they initialise at static-init time, `CreatePrivateFile` (a `0600` file in a `0700` directory), and `ReadSecret` (a line from stdin, not echoed on a terminal). - `:Crypto` (under `NOSTRO_OPENSSL_ENABLED`; OpenSSL headers in the global module fragment), in `namespace Nostro::Crypto`: `ThrowOnOpenssl`, `Key` (`std::shared_ptr` freeing itself) and `OwnKey`, `SignBody` (RSA SHA-256, base64) and `VerifyBody` (its check against a public key), `CreateKey` (RSA 2048 and its public PEM), `LoadKeyFromPem`, `LoadPublicKeyFromPem`, `PrivateKeyToPem`, `PublicKeyToPem`, `RandomHex` (the OAuth `state`). -- `:Bunq` (under `NOSTRO_BUNQ_ENABLED`; `json.hpp` and `openssl/types.h` in the global module fragment; the implementation units import Crafter.Network): `BunqEnvironment`, `BunqError`, `BunqCounterparty`, the listing types (`BunqLabel`, `BunqPaymentRequest`, `BunqIncomingRequest`, `BunqSchedule`, `BunqScheduledPayment`, `BunqDraftPayment`, `BunqCard`) and their formatters, `BunqAccount : Account` (`id`, `type`, `connector`, the payment calls), `BunqConnector` (environment, keys, tokens, user, `accounts`, the raw `Get`/`Post`/`Put`/`Delete`/`List`, the static deque `connectors`, `Create`, `Remove`, the OAuth helpers, and `Endpoint`/`RedirectTo` with `BunqEndpoint`), `to_json`/`from_json`, and the unexported `BunqJson` helpers both implementation units share. +- `:Bunq` (under `NOSTRO_BUNQ_ENABLED`; `json.hpp` and `openssl/types.h` in the global module fragment; the implementation units import Crafter.Network): `BunqEnvironment`, `BunqError` (with `maybeCarriedOut`, the end of an error to a write that may have happened all the same), `BunqCounterparty`, the listing types (`BunqLabel`, `BunqPaymentRequest`, `BunqIncomingRequest`, `BunqSchedule`, `BunqScheduledPayment`, `BunqDraftPayment`, `BunqCard`) and their formatters, `BunqAccount : Account` (`id`, `type`, `connector`, the payment calls), `BunqConnector` (environment, keys, tokens, user, `accounts`, the raw `Get`/`Post`/`Put`/`Delete`/`List`, the static deque `connectors`, `Create`, `Remove`, the OAuth helpers, and `Endpoint`/`RedirectTo` with `BunqEndpoint`), `to_json`/`from_json`, and the unexported `BunqJson` helpers both implementation units share. - `:Banks`: `tuple_for(f)` and `EnabledBanks`, the `std::tuple` of enabled connector types; every generic loop in the CLI and in `:Connector` is a `tuple_for`. - `:Connector`: `Connector::SaveConnectors()` and `LoadConnectors()`, `connectors.json` out (synced, then renamed into place) and in, both under the process-wide `connectors.lock`. - `:Bus` (under `NOSTRO_DBUS_ENABLED`; `sd-bus.h` in the global module fragment): the wire nostrod and its clients share. The names, the error names (the checkout's from `Nostro.Checkout`), the polkit actions, the method tables `methods` and `checkoutMethods` (member, signatures, argument names, sensitive), the result structs (`ConnectorSummary`, `AddedConnector`, `ConnectorAccounts`, `ConnectorCards`, `Created`), `Wire` with `Append` and `Read` for every type that travels (a struct as its members, a time as microseconds, a currency as its code, an optional as an array of zero or one), `AppendQuery`/`ReadQuery`, `Vtable`, `ThrowOnSdBus`, and the `BusPtr`/`MessagePtr`/`Error` owners. -- `:Client`: `Client::System()`, one method per method of `net.catcrafts.Nostro1`, `TakeNotes()`, and `DaemonError`. +- `:Client`: `Client::System()`, one method per method of `net.catcrafts.Nostro1` in a blocking and an asynchronous form (`Attach`, `Client::Pending`, `Answer`), `TakeNotes()`, `DaemonError`, `DaemonMissing` and `OutcomeUnknown`. - `:Daemon`: `DaemonOptions`, `RunDaemon` (the front) and `RunWorker` (one user's worker). `Nostro.Checkout`, a module of its own that imports nothing of `Nostro`: the checkout's bus name, interface, `Pay`'s signatures and argument names, the error names apps tell apart, `Order`, `Paid`, `Error` with `Cancelled` and `NoCheckoutAccount`, and `Pay`. `:Bus` and the daemon take their names from it. +`Nostro.Ui`, in `namespace Nostro::Ui`, draws nothing and reads no device: a screen is a function that fills a `Frame`. Its partitions, from the bottom up: + +- `:Geometry`: `Point`, `Box`, `Insets`, `Color`, `Metrics` (the display's scale, `Dp()`) and `SizeClass`: compact under 600 dp wide, medium under 900, expanded from there. Everything is in physical pixels; dp exists in the design's constants and is turned into pixels where it is used (`frame.Dp()`). +- `:Text`: UTF-8 by code point, `TextMeasure` (three functions, which the window supplies and a test fixes), `TextWidth`, `Ellipsize`, `CenteredBaseline`, and `WordWrapper` with its cache. +- `:Edit`: `EditState`, a field's text with its cursor, its selection and the word an input method is composing, and `FieldKind` (`Text`, `Plain`, `Decimal`, `Digits`, `Secret`). A `Secret` is never copied or shown, and wipes its buffer when it goes. +- `:Gesture`: `GestureDetector` (tap, long press, drag, fling), `ScrollState`, `EventClock`, `FrameWait`. +- `:Draw`: `DrawList`: boxes, circles and text in five layers (`Background`, `Content`, `Chrome`, `Overlay`, `Popup`), split into batches at a clip and wherever a shape follows text it overlaps, since the window draws a batch's shapes before its text. +- `:Theme`: `Theme::Light()`, `Dark()` and `Accent()`, and the design's sizes (`TextSize`, `Size`). +- `:Input`: `Key`, `Modifiers`, `TextPurpose`, `TextHint`, `TextInputRequest`. +- `:Context`: `Region` (a box, a key that names it across frames, a role, what a press does), `Frame` (one frame's draw list, regions, shortcuts and scrolling areas), and `Context`, which keeps what outlives a frame (the focus, each list's position, the press that is down, a menu, a notice, what was put off with `At`) and turns pointer, key and text events into the regions' actions. `Take()` says what the window is to do next (`Wants`: a frame, a timer, the on-screen keyboard, the clipboard). What a sheet covers is out of reach of a finger and of the keyboard alike: a frame that puts a sheet (a scrim below the topmost layer) over what had the focus takes the focus from it, so neither Enter nor typing reaches under a sheet; a menu is no sheet, and leaves its field the focus. A scrolling area a screen marks `Refreshable` gives way when it is dragged down at its top (`Pulled()`), and runs its action when it is let go 64 dp down. `Tap(key)` and `LongPress(key)` are for a test or a debugger. +- `:Layout`: `Column`, `Row`, `Centered`. +- `:Widgets`: functions that draw into a frame and name its regions: `Label`, `Paragraph`, `Button`, `ListRow`, `ValueRow`, `TextField`, `Segmented`, `Tabs`, `Banner`, `Chip`, `Skeleton`, `TopBar`, `NavBar`, `Sidebar`, `Sheet`. + +`Nostro.App`, in `namespace Nostro::App`, imports `Nostro` and `Nostro.Ui`: + +- `:Banks`: what is a bank's own, for each bank the app can connect: `Bank` (what nostrod calls it, its name, its ways in) and `Way` (a way to connect: its title, the form it is filled in on, where what was given is revoked, and whether a connection made that way pays between the user's own accounts only). They are found by nostrod's names for them (`Banks`, `FindBank`, `FindWay`, `BankName`, `WayName`, `OwnAccountsOnly`, `Revoking`); a bank or a way that nostrod has and the app does not know is said by nostrod's name for it. Not the library's `Nostro:Banks`, which is the banks a build has. +- `:Format`: how the app words what a bank gives it: `Money` (`€12,500.00`), `GroupIban`, `PartyName`, `DayLabel`, `ShortDate`, `KindLabel`, `StatusLabel`, `CardExpiry`, `ScheduleLabel`, `Fingerprint`. English only; every such wording is here, and none of it names a bank. +- `:Forms`: what is typed, read (`ReadAmount`, `ReadParty`, `ReadDay`, `ReadCount`), and the forms with their checks: `PaymentForm`, `RequestForm` and `FilterForm`, which are any bank's, and the two a connection to bunq is made with, `BunqKeyForm` and `BunqOAuthForm`. +- `:Errors`: `Operation`, the polkit action of each (`ActionOf`, `AsksPassword`, `MovesMoney`), and `Explain(error, operation)`, which turns an answer's error into `Guidance`. +- `:App`: `Host` (what the program around the app gives it), `Loadable`, `Connection`, and the class `App`. + +`Nostro.Ui.Shell`, in `namespace Nostro::Ui::Shell`, imports Crafter.Graphics and `Nostro.Ui`, and nothing of the library or the app: `:Loop` (`Loop`, `Timer`, `Defer`, `WaylandSource`, `FrameDriver`), `:Canvas` (`Fonts`, `Canvas`), `:Window` and `:Portal`. + The bunq connector end to end: - **Requests** (`implementations/Nostro-Bunq.cpp`): every call goes through the private `BunqConnector::Call`, behind the public `Get`, `Post`, `Put`, `Delete` and `List`. It talks to `BunqConnector::Endpoint(environment)`: `api.bunq.com` or `public-api.sandbox.bunq.com` by the connector's environment, or wherever `RedirectTo` sent everything (the tests' fake), with one `ClientHTTP1` per endpoint. @@ -53,6 +94,7 @@ The bunq connector end to end: - **Connecting:** `Create(apiKey, allowedIps, environment)` makes an RSA key, then `POST /installation` (installation token and server key), `POST /device-server` with `permitted_ips` as a JSON array, and `RefreshSession()`. The session is `POST /session-server`, signed: the token, the session id, and the user from `UserPerson`, `UserCompany`, `UserPaymentServiceProvider` or, for OAuth, `UserApiKey` (its own id in paths, `ownerId` and the name from `granted_by_user`). - **Accounts and history:** `RefreshAccounts()` lists every `MonetaryAccount…` type that is `ACTIVE` or `BLOCKED`. `GetNewTransactions(account)` pages the payments newest first until one older than the last stored row, and hands them to `Account::SaveTransactions` under `account.StorageKey()`. - **Payments** (`implementations/Nostro-Bunq-Payments.cpp`): `BunqCounterparty::Parse` reads an IBAN (check digits verified), an e-mail address or a phone number. `Send`, `Draft`, `Schedule` and `Request` build their bodies from it, the listings read bunq's objects into the listing types, and the responses are PUTs or a DELETE. Accepting a request or a draft takes the object as it was read and shown (`IncomingRequest(id)`, `DraftPayment(id)`), so what gets paid is what the user saw. +- **Cards:** a card is read with bunq's `status` and `order_status`, and `BunqCard::State()` is what to call how it stands: bunq's status, but `VIRTUAL` for a virtual card (`Virtual()`: its order status is `VIRTUAL_DELIVERY`) that is not gone for good, since bunq has one as `DEACTIVATED` however well it pays. The CLI and the app show that. bunq leaves a virtual card as it is when asked to freeze or unfreeze it, and answers as if it had been done: nostrod refuses that before anyone is asked for a password, and `ExpectStatus` does not take the unchanged card for a frozen one. - **OAuth:** `OAuthAuthorizationUrl` and `OAuthExchangeCode` (the token endpoint reads query parameters only). The token then goes to `Create` like an API key. nostrod end to end: @@ -60,15 +102,34 @@ nostrod end to end: - **The front** (`implementations/Nostro-Daemon.cpp`, `RunDaemon`) is one sd-event loop with two system bus connections. One owns `net.catcrafts.Nostro1` and serves that interface. The other owns `net.catcrafts.Nostro1.Checkout` and serves the checkout alone: a Flatpak allowed to talk to that name can call its owner's unique name too, and on that connection there is nothing else. Every method of both is one forwarding handler. It asks the bus for the caller's uid (`GetConnectionCredentials`), and logind for that uid's name, starts the uid's worker if there is none (`posix_spawn` of `/proc/self/exe --worker …`, a socketpair end as fd 3, D-Bus peer to peer over it), and passes a copy of the call on, from the caller's unique name and allowing a dialog only when the caller did. The answer is relayed when it comes, so one user's open dialog holds up nobody. A worker that dies under a call is answered `Failed` with "may have been carried out". It holds no connector and no secret. It ends once idle with no worker left, on SIGTERM, or when the bus goes; D-Bus activation starts it again. - **A worker** (`implementations/Nostro-Daemon-Worker.cpp`, `RunWorker`) is one user's library: `configPath` and `cachePath` are `/users/`, the connectors are read on the first call, and it is not dumpable. A directory records whose it is (`owner`): a uid that logind now names differently, after a user was deleted and another given their uid, is refused. Every handler reads and checks the call first (the account, the counterparty, what is to be paid, or for a request or a draft the object as bunq has it), builds a `Prompt` (the polkit action, a summary from its own data, and details for polkit rules), and hands it to `Gate`. `Gate` asks polkit asynchronously (`CheckAuthorization` about the caller's bus name, cancelled if it does not answer in time) and runs the call's work only once polkit says yes. It fails closed: no polkit, an error or a timeout is `AccessDenied`. A dialog the user closed is `Cancelled`, which polkit says with `polkit.dismissed` or, from Plasma's agent, `polkit.result` `auth_…`. A challenge to a call that allowed no dialog is `InteractiveAuthorizationRequired`. Every answer of the main interface ends with the notes. A summary's text from a caller or the bank goes through `Shown()` (no control, invisible or direction characters, `<` and `>` replaced, `$(` broken, 64 characters at most) and names the address before the name. The worker ends once idle with no dialog open, on SIGTERM, or when the front goes. - **Checkout** (the same file): `Order::Read` refuses a payee that is not an IBAN, an amount that is not positive, an unknown currency or an empty reference. An order already in `checkouts.cdb` (a Crafter.DB table, `CheckoutRecord`) is answered with its payment, `repeated`, without a dialog, or refused when its amount differs, or when its payment is still 0: a payment whose outcome was lost. An order being paid makes the next call for it wait, and `Settle` gives it the first call's answer. `ChooseAccount` picks the account (the one in `checkout-account`, set by `SetDefaultCheckoutAccount`; an account of an OAuth connector is refused there) and answers through a continuation, so an account picker can take its place later. The dialog (`net.catcrafts.Nostro1.Checkout`) shows the order and that account. `PayOrder` records the order, with no payment, before it pays, and takes the record away again only when bunq refused before doing anything, below 500. -- **The client** (`implementations/Nostro-Client.cpp`) allows interactive authorization and waits 10 minutes by default; nostrod's `InvalidArgument` becomes `std::invalid_argument`, `ServiceUnknown` a "not running" message, a write without an answer "may have been carried out", and the rest a `DaemonError` with its name. `Nostro.Checkout`'s `Pay` does the same for the checkout with its own types. +- **The client** (`implementations/Nostro-Client.cpp`) allows interactive authorization and waits 10 minutes by default. Each method is one `MethodCall` (member, whether it changes anything, how its answer is read) and one append helper, shared by the blocking form (`Run`: `sd_bus_call`) and the asynchronous one (`Start`: `sd_bus_call_async` on a bus attached to the caller's sd-event loop, whose non-floating slot the returned `Pending` owns; the slot frees what waits for the answer, and `OnReply` reads the answer into an `Answer` and calls `then`, never throwing into sd-bus). nostrod's `InvalidArgument` becomes `std::invalid_argument`, `ServiceUnknown` `DaemonMissing`, a write without an answer, or one bunq answered with an error ending in `BunqError::maybeCarriedOut`, `OutcomeUnknown`, and the rest a `DaemonError` with its name. `Nostro.Checkout`'s `Pay` does the same for the checkout with its own types. + +The app end to end: + +- **The app** (`App::App(Ui::Context&, Host)`) asks nostrod through the asynchronous `Client` and never waits for it: an answer changes its state and invalidates the frame. `Build(frame)` builds the screen the user is on, `Screen()` names it (`accounts`, `account:+filter`), `Navigate(route)` goes to one, and `Busy()` and `Changing()` say what is under way. + - Of each kind of reading one call is in flight, and the newest asked for meanwhile waits for it: dropping a call does not stop the worker's HTTPS, and bunq allows 3 GETs per 3 seconds. + - The bank is asked for an account's payments when its list is first shown, when it is read again (Refresh, F5, the pull) and after a change to the account. A search, a filter and "Show more" are questions about that list, put to what nostrod has stored (`LoadActivity(key, true)`, the query's `stored`): they are answered in milliseconds, so a search runs with every letter typed. Where no list is shown, because none was read yet or the reading failed, a search does go to the bank, once the typing has stopped for 400 ms or at Enter. A search therefore finds what the list had when it was last read, not what the bank has had since. + - One change at a time: a sheet shows it under way and then its outcome, and nothing else can be asked for meanwhile, so nothing is sent twice. Three things hold that: the sheet covers the screen and cannot be sent away; the toolkit takes the focus from whatever a sheet covers, so the key that pressed a button does not press it again from under the sheet; and `Navigate` refuses while a change is under way. + - The pay form sends on its button (`SubmitPayment`, the region `pay.submit`, named for what it does: Pay, Schedule or Save as draft), with no question of the app's own before it. A payment and a schedule are confirmed in polkit's dialog, which nostrod words from its own data; a draft is saved at once, since accepting it is what gets confirmed. The app's own review of a payment was taken out on 2026-11-19, as a second confirmation of what the dialog confirms: do not put one back. Closing polkit's dialog is how a payment is backed out of: nothing is paid, and the form stays as it was filled in. + - What the app does ask about first, in an `Ask` sheet built from the values that are then sent: a request before it is sent, which polkit confirms with no password in an active session, and what a detail sheet offers (revoking, accepting, rejecting, cancelling, a card reported lost, a connection removed). While a change is under way its sheet says where to confirm it when its action asks for a password (`AsksPassword`), and `ShouldDriveTheApp` holds that to the action nostrod's check names. + - An answer that leaves open whether money moved says so, shows the way to the account's activity, and offers no button to try again. + - An action names what it is about by value, an IBAN or the bank's id, never by a place in a list: a press acts on what it went down on, and a list changes under the finger when an answer arrives. + - Accounts go to nostrod by IBAN, by name where the bank gave none; a connection by name, or by its number from a fresh `Accounts` listing when two share a name. + - Which bank an account is with makes no difference outside the settings. No screen there names a bank, or a way to connect to one, in the app's own words: it says "your bank". `ShouldDriveTheApp` fails on a frame that does, excepting what nostrod and the bank say themselves: a note about a connector, a refusal with the call it refused, a link the bank made. What does differ by bank is asked of `:Banks`: a connection that pays between the user's own accounts only, as bunq's through OAuth, is `Connection::ownAccountsOnly`. It is marked Limited, a payment from it to anyone else is saved as a draft, and it cannot pay a request or a shop. + - Adding a connection is three pages, from the settings and from the welcome alike: the banks (`add`), the bank's ways (`add:bunq`) and the way's form (`add:bunq:key`). The first two are built from `:Banks`. The form is the bank's own to draw and to check, in a file of the bank's (`Nostro.App-Bunq.cpp`), and its button ends in `App::Connect`, which is every bank's. +- **The screens** (`implementations/Nostro.App-Screens.cpp`, and a bank's own forms in that bank's file) are functions from that state to a frame. A window under 600 dp wide shows one page at a time, with the app's places along its bottom; a wider one has them down its left side, and from 900 dp the accounts too. A screen that shows the bank's own state (the accounts, an account, the cards) reads it again four ways, all one action (`Refresher`): Refresh in the bar, F5, Ctrl+R, and the page pulled down at its top. The README's "The app" says what each screen is for. +- **The window** (`Nostro.Ui.Shell`) is one sd-event loop that carries the compositor's connection, nostrod's bus, the desktop portal's bus and the timers. `Window` turns Crafter.Graphics' events into the `Context`'s, bringing time up to each and building a stale frame again first, and does what the `Context` wants afterwards (`Settle`, which the loop calls from a post source after every source that ran). A frame is drawn only when the compositor asks for one after something changed: an idle window draws nothing. `Canvas` turns a `DrawList` into Crafter.Graphics' items, one dispatch per batch, from a pool of buffers per frame in flight. `Portal` reads the desktop's colour scheme and accent, and asks the desktop to open an address. +- **`nostro-app`** puts them together, and has what looking at the window without a hand on it takes: `--size`, `--scale` (a phone's density on a desktop's display), `--theme`, `--route`, `--screenshot`, `--poke` and `--gallery`. It makes itself undumpable once the portal has seen it. Closing the window while a change is under way takes the window down and keeps the process until the answer has come. ## Dev environment -crafter-build is the only build tool. It compiles with its clang 23 and libc++, `-std=c++26` and `import std;`, and links `-lssl -lcrypto`, and `-lsystemd` for anything with D-Bus in it (libsystemd's `sd-bus.h` and `sd-event.h`; crafter-build's Flatpak SDK has them). Packaging uses flatpak-builder. +crafter-build is the only build tool. It compiles with its clang 23 and libc++, `-std=c++26` and `import std;`, and links `-lssl -lcrypto`, and `-lsystemd` for anything with D-Bus in it (libsystemd's `sd-bus.h` and `sd-event.h`; crafter-build's Flatpak SDK has them). nostrod's Flatpak is made by flatpak-builder, the app's by crafter-build itself (`--packaging=flatpak`; `project.cpp` was written against crafter-build 6.3.0), and the aarch64 ones by the two scripts in `packaging/flatpak/`. -- Every build needs the network: Crafter.Network (with Crafter.Thread behind it; nostro builds it `--no-quic`, so without msquic) and Crafter.DB are `GitProject`s on their default branches, and Crafter.LintRules a `#pragma crafter dependency` of `project.cpp`, so each build `git pull`s them from `forgejo.catcrafts.net`, and the notes at the end of this file follow their HEAD. A `.commit` (in the pragma, `commit ""`) would pin them. -- Where the connectors live depends on who runs the library. nostrod's worker keeps each user's under `/users//`: `connectors.json`, the transaction tables, `checkouts.cdb`, `checkout-account` and `owner`, with `` from `--state`, else `$XDG_DATA_HOME`, else `$HOME/.local/share`. Installed, that is `/var/lib/nostro/.var/app/net.catcrafts.Nostro/data/`, readable by the user `nostro` alone. The library used directly reads `connectors.json` from `$XDG_CONFIG_HOME/.config/nostro/` (sic, see "Gotchas") or `$HOME/.config/nostro/`, and keeps the transaction tables under `$XDG_CACHE_HOME/nostro/transactions/` or `$HOME/.cache/nostro/transactions/`. A real connectors file holds a real API key: point every experiment elsewhere. -- No test uses the system bus: they run on `tests/Support/FakeBus.inc`. Running anything by hand that talks to `net.catcrafts.Nostro1` reaches the installed nostrod, if there is one, and its dialogs. A Flatpak sandbox with the system bus (`flatpak run`, `flatpak build`) sets `DBUS_SYSTEM_BUS_ADDRESS` itself, over an `--env` of yours: keep a sandboxed experiment off the bus with `--nosocket=system-bus`. +- Every build needs the network: Crafter.Network (with Crafter.Thread behind it; nostro builds it `--no-quic`, so without msquic) and Crafter.DB are `GitProject`s on their default branches, and Crafter.LintRules a `#pragma crafter dependency` of `project.cpp`, so each build `git pull`s them from `forgejo.catcrafts.net`, and the notes at the end of this file follow their HEAD. A `.commit` (in the pragma, `commit ""`) would pin them, as Crafter.Debug's build helper is, the second pragma. +- The app needs a Wayland compositor and a Vulkan device to run, and nothing else of nostro does. No test opens a window. `--product=app` takes `--graphics=` for now: the app asks the input method for a field's purpose and hints, which Crafter.Graphics has on its branch `claude/nostro-app` and not yet on master. Once that is merged, name it as a `GitProject` at a pinned commit in `project.cpp` and drop the flag. +- The app's `--debug-api` build links Crafter.Debug, which talks QUIC: that one build has Crafter.Network with msquic (crafter-build builds it with CMake once, for minutes, and keeps it in its cache), and its binaries carry a runpath into that cache. +- Where the connectors live depends on who runs the library. nostrod's worker keeps each user's under `/users//`: `connectors.json`, the transaction tables, `checkouts.cdb`, `checkout-account` and `owner`, with `` from `--state`, else `$XDG_DATA_HOME`, else `$HOME/.local/share`. Installed, that is `/var/lib/nostro/.var/app/net.catcrafts.Nostrod/data/`, readable by the user `nostro` alone. The library used directly reads `connectors.json` from `$XDG_CONFIG_HOME/.config/nostro/` (sic, see "Gotchas") or `$HOME/.config/nostro/`, and keeps the transaction tables under `$XDG_CACHE_HOME/nostro/transactions/` or `$HOME/.cache/nostro/transactions/`. A real connectors file holds a real API key: point every experiment elsewhere. +- No test uses the system bus: they run on `tests/Support/FakeBus.inc`. Running anything by hand that talks to `net.catcrafts.Nostro1` reaches the installed nostrod, if there is one, and its dialogs: the CLI, and the app, which reads the accounts as soon as it starts. A Flatpak sandbox with the system bus (`flatpak run`) sets `DBUS_SYSTEM_BUS_ADDRESS` itself, over an `--env` of yours: keep a sandboxed experiment off the bus with `--nosocket=system-bus`. To look at the app, run it on the made-up system, `nostro-fake-system`, which sets that address for what it starts ("Looking at the app"). - To read a `constexpr` value such as `DB::Layout::fingerprint`, `static_assert(x == 0)` it and read "expression evaluates to" in the error. ## Build, test and style commands @@ -79,20 +140,29 @@ crafter-build --banks=bunq --product=daemon # nostrod: bin/nostrod-/n crafter-build --product=checkout # the Nostro.Checkout library alone; no bank needed crafter-build --banks=bunq --lib # the library alone (what a consumer builds), without D-Bus crafter-build --banks=bunq --lib --dbus # the library with :Bus, :Client and :Daemon +crafter-build --banks=bunq --product=app --graphics=/project.cpp # the app: bin/nostro-app-/nostro-app +crafter-build --banks=bunq --product=fake-system # nostro-fake-system: a fake bus and a fake bunq with nostrod on them +crafter-build --banks=bunq --product=app --graphics=… --debug-api # the app with Crafter.Debug, the fake system, and build/crafter-debug +crafter-build --banks=bunq --product=app --graphics=… --debug-api run fake [-- ] # that app on the fake system crafter-build --debug --banks=bunq # debug build crafter-build -v --banks=bunq # with the compiler commands crafter-build clean # delete bin/ and build/ crafter-build test --banks=bunq # the tests in tests/, against a fake bunq; none talks to bunq itself tests/coverage.sh [profile runtime] # the tests with coverage: a report per file and every line no test ran crafter-build lint --banks=bunq # the Crafter.LintRules lite rules project.cpp registers, report only -flatpak run --filesystem= org.flatpak.Builder --user --force-clean --repo=/repo --state-dir=/state /build packaging/flatpak/net.catcrafts.Nostro.yaml +crafter-build lint --banks=bunq --product=app --graphics=… [--debug-api] # the same over the toolkit, the app and its window +flatpak run --filesystem= org.flatpak.Builder --user --force-clean --repo=/repo --state-dir=/state /build packaging/flatpak/net.catcrafts.Nostrod.yaml +crafter-build --banks=bunq --product=app --graphics=… --packaging=flatpak --march=x86-64-v3 --mtune=generic bundle # the app's Flatpak as one file; `install` installs it for you instead +packaging/flatpak/make-aarch64-sysroot.sh && packaging/flatpak/build-aarch64.sh # both Flatpaks for aarch64, into a repository ``` -`--banks=` is mandatory except for `--product=checkout`: without it `project.cpp` throws "must enable atleast one bank" and nothing is built; an unknown name throws "unknown connector", an unknown product "unknown product". flatpak-builder needs crafter-build's own Flatpak (`net.catcrafts.CrafterBuild`, stable) installed as its base app, the network during the build, and, run as a Flatpak itself, `--filesystem=` for a build directory outside your home, or the build commands cannot find it. Install the result for a test with `sudo packaging/system/install.sh --repo /repo`. There is no CI. The tests run every line, function and region of nostro's own sources (2026-11-01), and a change keeps them doing so; the README's rule for contributed connectors applies on top: not blind, also tried against the sandbox or the live API ("Testing instructions"). +`--banks=` is mandatory except for `--product=checkout`: without it `project.cpp` throws "must enable atleast one bank" and nothing is built; an unknown name throws "unknown connector", an unknown product "unknown product". flatpak-builder needs crafter-build's own Flatpak (`net.catcrafts.CrafterBuild`, stable) installed as its base app, the network during the build, and, run as a Flatpak itself, `--filesystem=` for a build directory outside your home, or the build commands cannot find it. Install the result for a test with `sudo packaging/system/install.sh --repo /repo`. There is no CI. The tests run every line, function and region of the library, the CLI, nostrod, the toolkit and the app without its window (2026-11-19), and a change keeps them doing so; the README's rule for contributed connectors applies on top: not blind, also tried against the sandbox or the live API ("Testing instructions"). + +The app's packaging: `--packaging=flatpak` makes `bin/nostro-app-/files/` (the program with its fonts and shaders in `bin/`, the C++ runtime in `lib/`, the desktop entry, icon, metainfo and licences in `share/`), `bundle` a `.flatpak` beside it and `install` an installation for the user who runs it; both print the permissions, which `project.cpp` lists. That is x86_64, on the Platform crafter-build's Flatpak runs on. For aarch64, a phone, there is no crafter-build to build with, so both Flatpaks are cross builds: `make-aarch64-sysroot.sh` makes a sysroot of the Freedesktop Sdk for aarch64 with LLVM's libc++ (in `~/.cache/nostro-flatpak`, or `$NOSTRO_FLATPAK_CACHE`), and `build-aarch64.sh ` builds the CLI, nostrod and the app against it and assembles `net.catcrafts.Nostrod` and `net.catcrafts.Nostro` into an OSTree repository, which `install.sh --repo --app` installs on the phone. The app's permissions are in two places because of it, `project.cpp` and that script: change them together. ## Testing instructions -`crafter-build test --banks=bunq` builds and runs `tests//main.cpp` for each name in `project.cpp`'s list, each linked against the library, in parallel; a test exits 0 when every check passed and prints each failed one with its line. They are: +`crafter-build test --banks=bunq` builds and runs `tests//main.cpp` for each name in `project.cpp`'s lists, each linked against what it tests (the library, the toolkit, or the app without its window), in parallel; a test exits 0 when every check passed and prints each failed one with its line. None needs Crafter.Graphics, a compositor or a graphics device. They are: | Test | What it covers | |---|---| @@ -105,36 +175,66 @@ flatpak run --filesystem= org.flatpak.Builder --user --force-clean --repo=< | `ShouldMoveMoney` | payments, drafts, schedules and requests, and their formatters | | `ShouldRunCommands` | the CLI: `implementations/main.cpp` compiled in with its `main` renamed, every command run in-process against a real nostrod on the fake bus | | `ShouldServeEveryUser` | nostrod: users kept apart, a uid handed to a new user, every polkit answer and what each dialog says, calls that wait on each other or do not, the checkout and its retries, the checkout client, workers that die, idle exits, every error as the client gets it, and the published contract (the XML and the polkit policy) | +| `ShouldAnswerAsynchronously` | the client's asynchronous calls from an sd-event loop: each method once against a real nostrod on the fake bus, every way an answer fails (refused, cancelled, bunq's refusal, a 5xx to a payment, no answer in time, no nostrod, an answer that cannot be read), notes in the answer, and dropping, cancelling, moving and assigning a `Pending` | +| `ShouldWrapText` | `Nostro.Ui:Text`: UTF-8, measuring, cutting with an ellipsis, wrapping and its cache | +| `ShouldEditText` | `:Edit`: typing, the cursor and the selection, each kind of field and what it refuses, the composing text, a secret wiped | +| `ShouldRecognizeGestures` | `:Gesture`: taps, long presses, drags and flings, a list's motion and its ends, the event clock | +| `ShouldBuildFrames` | `:Draw`, `:Theme` and `:Context`: batches, regions and what a press on each does, the focus and the keyboard, fields with the input method and the clipboard, scrolling, menus, notices, what is put off | +| `ShouldLayOutWidgets` | `:Layout` and `:Widgets`: each widget in every state it has: what it draws, where, in which colours, and what a press on it does | +| `ShouldValidateForms` | `Nostro.App`'s `:Banks`, `:Format`, `:Forms` and `:Errors`: every wording, every reading with what it refuses, each form's checks, what each error means for each operation, and what the app knows of each bank and says of one it does not know | +| `ShouldDriveTheApp` | the app against a real nostrod on the fake bus: every screen and every flow tapped by key and read as text, each polkit answer, each operation's action, the steps of adding a connection, nostrod missing, late, dying and coming back, an account that vanishes, the three window sizes, and that no screen outside the settings names a bank | How they are built: -- `tests/Support/Check.inc` holds the checks (`Check`, `Equal`, `Throws`) and a temporary `Directory`; `tests/Support/FakeBunq.inc` is a bunq in the test's own process, HTTPS on 127.0.0.1 with Crafter.Network's self-signed certificate. It signs what it answers, checks the client's signatures, keeps users, accounts, payments, requests, schedules, drafts and cards, and fails on request (`Fake::Fault`). `BunqConnector::RedirectTo` points nostro at it; each test has a port of its own (47301 to 47305), and port 443 on 127.0.0.1 stands for a host that refuses the connection. +- `tests/Support/Check.inc` holds the checks (`Check`, `Equal`, `Throws`) and a temporary `Directory`; `tests/Support/FakeBunq.inc` is a bunq in the test's own process, HTTPS on 127.0.0.1 with Crafter.Network's self-signed certificate. It signs what it answers, checks the client's signatures, keeps users, accounts, payments, requests, schedules, drafts and cards, and fails on request (`Fake::Fault`). `BunqConnector::RedirectTo` points nostro at it; each test has a port of its own (47301 to 47307; `nostro-fake-system` takes 47390 unless told another), and port 443 on 127.0.0.1 stands for a host that refuses the connection. +- `tests/Support/Ui.inc` is what the toolkit's and the app's tests build frames with: a font of known sizes (`Test::FixedMeasure`: every code point half its size wide), so every position is exact, and the reading of a frame (`Shows`, `Hides`, `Said`, `TapAt`). A test builds a frame (`Context::Begin`, the screen, `End`), reads the draw list's text and the regions, and acts by key (`Context::Tap`) or by point. +- `ShouldDriveTheApp` runs the app as a window would, without one: a `Context` of a phone's size, a `Client` on an sd-event loop, nostrod on the fake bus with the fake bunq behind it. A tap is by a region's key, and what a screen says is the draw list's text. Every frame it builds on a phone's size is also held to one rule of the design: whatever can be pressed is at least 48 dp wide and tall. - `tests/Support/FakeBus.inc` is a system bus in the test's own process, an sd-bus server on a unix socket: it routes calls by name with the caller's unique name, and plays the bus driver (`GetConnectionCredentials` with the uid the test chose for a connection of its own process, the real one for nostrod's), logind (`GetUser` and the user's `Name`) and polkit (each check recorded; allow, a password, deny, a closed dialog, absent, silent or slow, per action). The two nostrod tests start their own executable again as nostrod (`Fake::StartNostrod`, with `NOSTRO_TEST_ROLE` set; its `main` then runs `implementations/nostrod.cpp`'s, compiled in with `main` renamed), which finds the fake bunq through the environment (`Fake::Bunq::ExportRedirect`, `RedirectFromEnvironment`). Everything a child reads from the environment is set before any thread starts. A worker that cannot be spawned is made with `prlimit` on nostrod (`Fake::Limit`), and workers are stopped with SIGTERM, which they handle, so their coverage counts are written. - What a disk or a kernel will not do on demand (`flock` failing or interrupted, `fsync` failing, a chosen OAuth state from `RAND_bytes`) the test defines itself as an `extern "C"` function: the linker takes it over libc's or OpenSSL's, and it calls the real one through `dlsym(RTLD_NEXT, …)` when nothing is scripted. A file size limit (`RLIMIT_FSIZE`) makes a write fail part way. - Each test sets `configPath` and `cachePath` to a temporary directory first, and `TZ` where it formats local time. -Coverage is clang's source-based coverage: `tests/coverage.sh` builds with `--coverage`, runs the tests with `LLVM_PROFILE_FILE` set (with `%p`, so nostrod and every worker write their own), merges the profiles and reports with `llvm-cov`, leaving `build/coverage/sources.txt` annotated. A toolchain without compiler-rt's profile library, which crafter-build's Flatpak lacks, takes one as the script's argument (`--profile-runtime=` to `project.cpp`). On 2026-11-01 lines, functions and regions were all at 100% and branches at 95%: what is left is mostly defensive checks no input can flip and per-instantiation counts in `main.cpp`'s templates. +Coverage is clang's source-based coverage: `tests/coverage.sh` builds with `--coverage`, runs the tests with `LLVM_PROFILE_FILE` set (with `%p`, so nostrod and every worker write their own), merges the profiles and reports with `llvm-cov`, leaving `build/coverage/sources.txt` annotated. A toolchain without compiler-rt's profile library, which crafter-build's Flatpak lacks, takes one as the script's argument (`--profile-runtime=` to `project.cpp`). On 2026-11-19 lines, functions and regions were all at 100% and branches at 96%: what is left is mostly defensive checks no input can flip and per-instantiation counts in templates. + +The figure covers what a test links: the library, the CLI, nostrod, `Nostro.Ui` and `Nostro.App`, and the script fails when a source of those two is missing from the report. It leaves out what needs a compositor and a graphics device, by design rule 11: `Nostro.Ui.Shell`, `implementations/nostro-app.cpp` and `Nostro.DebugCommands`, and with them `tests/FakeSystem/main.cpp`. Those are looked at instead, see "Looking at the app". A few things clang's coverage does that cost time once: an `if` without an `else` has no region for the missing arm, only a branch; each arm of a `?:` is a region; a template or a generic lambda is counted per instantiation; and an inline function in a module interface that assigns an aggregate from a temporary leaves an uncovered implicit `operator=` record, so such bodies go into implementation units. The bunq sandbox is still the check for what a fake cannot show. Since nostrod (2026-11-01) the CLI needs an installed nostrod: build the Flatpak, install it with `sudo packaging/system/install.sh --repo /repo`, and use the CLI as yourself; real polkit dialogs then ask for your password. A second local user shows the separation. The library alone still runs from an isolated config and cache, never from `~/.config/nostro`. The recipe, as it worked on 2026-10-31 with the CLI of then, which held the connectors itself: 1. Build (in place or in a scratch copy made with `rsync -a --exclude build/ --exclude bin/ --exclude .git/`) and run the binary with `XDG_CONFIG_HOME` and `XDG_CACHE_HOME` pointing into a scratch directory. No `connectors.json` needs seeding. 2. Throwaway users: `POST https://public-api.sandbox.bunq.com/v1/sandbox-user-person` (or `-company`) with no authentication returns `Response[0].ApiKey.api_key`; `nostro connectors add bunq`, given the key on stdin, recognises the sandbox by its prefix. The response also holds the user's e-mail and phone aliases, for paying by those. Make two, so there is someone to pay; sandbox accounts are all called "Bank Account", so name them by IBAN. 3. The CLI reaches every bunq call (`nostro help` lists them). Session renewal is tried by ending the session behind nostro's back (`DELETE /v1/session/0` with the stored `sessionToken`), signature checking by putting another public key in `serverPublicKey`. -4. A new sandbox account holds €0 and no payments. Fund it with `nostro request sugardaddy@bunq.com "Sugar Daddy" 50000`: it is paid within seconds. A hundred rows at once: `POST …/payment-batch` with `{"payments": […]}` (more than 200 exercises the paging). `curl` can call as the same user with the `sessionToken` from the scratch file, and sign with `openssl dgst -sha256 -sign` over the body using its `privateKey` PEM, base64, in `X-Bunq-Client-Signature`. A sandbox virtual card (`POST /v1/user/{id}/card-debit` with `order_status: VIRTUAL_DELIVERY`) cannot be activated through the API, so `cards unfreeze` can only show bunq keeping it `DEACTIVATED`. OAuth stops at the token exchange: approving needs a person and the bunq app. +4. A new sandbox account holds €0 and no payments. Fund it with `nostro request sugardaddy@bunq.com "Sugar Daddy" 50000`: it is paid within seconds. A hundred rows at once: `POST …/payment-batch` with `{"payments": […]}` (more than 200 exercises the paging). `curl` can call as the same user with the `sessionToken` from the scratch file, and sign with `openssl dgst -sha256 -sign` over the body using its `privateKey` PEM, base64, in `X-Bunq-Client-Signature`. A sandbox card (`POST /v1/user/{id}/card-debit` with `type: MASTERCARD`, `product_type: MASTERCARD_DEBIT`, a `name_on_card` out of `GET /v1/user/{id}/card-name` and a `pin_code_assignment`) stays a virtual one, `DEACTIVATED` at `VIRTUAL_DELIVERY`, whatever it is set to: `nostro cards` lists it as `VIRTUAL`, `cards freeze` and `unfreeze` are refused for it, and `cards lost` and `stolen` can be tried on it. OAuth stops at the token exchange: approving needs a person and the bunq app. 5. bunq allows 3 GETs, 5 POSTs and 2 PUTs per three seconds per endpoint and one session per 30 seconds; nostro waits a 429 out, so a burst of runs is slow rather than failing. Concurrent nostro processes queue on `connectors.lock`, so two never hold the same account's table. +The app against the sandbox takes both Flatpaks installed and a hand on the window: every row of the README's "The app" from the window, with real polkit dialogs. That had not been done on 2026-11-19; nor had anything on a phone. + A bug fix comes with a test that fails without it, and states in its commit how it was reproduced; a new bank comes with tests against a fake of it and with the same check against its sandbox or live API. +### Looking at the app + +What a test cannot show (that the window draws what the frame says, in the right place, on a real display; the pointer, a finger, the keyboard, the input method) is looked at, on a made-up system so that nobody's bank is in it: + +- `nostro-fake-system` (`--product=fake-system`, `tests/FakeSystem/main.cpp`) is the tests' fake bus and fake bunq with a real nostrod on them: `nostro-fake-system [--dir ] [--port ] [--polkit allow|password|deny|dismiss|absent|silent|slow] [--empty] [--run ]`. It fills the bank with a made-up user (three accounts, three months of payments, three cards of which one is frozen and one virtual, a request sent and one received, a schedule, a draft, and a second connection through OAuth), and runs the program with `DBUS_SYSTEM_BUS_ADDRESS` pointing at the fake bus. `--empty` starts from the welcome and prints the made-up bank's API key; `--polkit` is what every request for a password is answered with; `--bank-delay ` is how long the made-up bank takes over each answer. +- Without a hand on it: `nostro-app --size 420x760 --theme light --route account: --poke "wait:2500;tap:110,200;shot:"` plays input into the window library's own events, so the window's listeners run as for a real pointer, and writes screenshots. Steps are separated by `;` and positions are in dp: `tap:x,y`, `hold:x,y,ms`, `drag:x1,y1,x2,y2,ms`, `move:x,y`, `press:x,y` and `release` (a finger kept down between them), `right:x,y`, `wheel:x,y,detents`, `key:Name`, `text:…`, `preedit:…`, `delete:before,after`, `resize:w,h`, `wait:ms`, `shot:file`. `--scale 3 --size 360x760` draws a phone's screen on a desktop's display. `--gallery widgets|list|text` shows the toolkit's widgets in the app's place and asks nostrod nothing. +- With an agent's hand on it: the `--debug-api` build and `./build/crafter-debug` (the Crafter.Debug notes at the end of this file). `crafter-build … --debug-api run fake [the fake system's options] [-- the app's options]` starts the app on the fake system, in the background since it does not exit. Then: + - `get app.screen`, `get ui.texts` (every line the screen shows), `get ui.regions` (what can be pressed, by key, in dp), `get 'window.*'`; + - `call Ui_Tap key=account.pay`, `Ui_Type text=…` into the field that has the focus, `Ui_Key key=Tab`, `Ui_LongPress`, `Ui_Focus`, `Ui_TapAt`, `Ui_Drag`, `Ui_Wheel`, `App_Navigate route=cards`, `Ui_Theme scheme=dark`, `Window_Resize width= height=`; + - `wait 'app.busy == false'` after anything that asks nostrod, `wait 'app.changing == false'` after a change; the events are `Screen`, `AnswerArrived`, `Changing` and `FrameRendered`; + - `screenshot`, and `log --level warn` for the checks: a frame that overflowed the window's buffers, something pressable under 48 dp on a phone's size. +- The README's screenshots are taken that way too, on the made-up system so that nobody's bank is in them: `docs/screenshots/take.sh ` plays one `--poke` script per picture and writes the five files beside itself. It names what it taps by its place, so it is looked over, picture by picture, after a change to a screen it shows. The made-up bank dates its payments back from now: every taking has other days and times in it. Four of the five are in the dark look and one in the light one, and everything the made-up bank holds is in English, people's names too, as the app is: both as asked for on 2026-11-19, so new made-up data is written in English. +- A region's key is its name in the tests too: `nav.accounts`, `account.`, `account.pay`, `tabs.1`, `pay.to`, `pay.submit`, `request.review`, `review.confirm`, `done.close`, `card.`, `settings.connections`, `connections.add`, `bank.bunq`, `way.key`, and `copy.