fix: close what the security review before the first release found

A review of the tree and its history before they are published found no
key and no bank data in them. It did find these, each closed here.

The password dialog could be emptied (daemon). Shown(), which makes a
payee's name fit for polkit's dialog, let an & through. GNOME's older
agent (polkit-gnome) and MATE's put the message into Pango markup
unescaped, where a bare & fails to parse and leaves the dialog without
a message: paying "Tom & Jerry", or an order an app names so at
checkout, asked for the password and showed no amount and no payee.
Line and paragraph separators passed too. Shown() now shows & as +,
leaves out what draws nothing or places text (control and format
characters, the separators, what Unicode ignores by default, private
use) and makes any run of spaces one space. An address is held to it
instead of made fit: an e-mail address the dialog could not show
unchanged is refused before anyone is asked, since "a&b@..." shown as
"a+b@..." is somebody else's address.

A refused caller could look (daemon). A call that names an account, a
card, a request, a draft or a connector had it looked up, at the bank
where that takes it, before polkit was asked. So a caller polkit
refused was told whether it was there ("no account is called ..."),
and had the bank asked. Such a call now asks for View first
(HandleLookup), a call that only sees looks its account up after its
yes, and the connectors are read, which refreshes the accounts at the
bank, on the first yes instead of on the first call.

An app at checkout was told too much (checkout). The refusal of an
order's reference with another amount named the amount on record, and
a refusal by the bank carried the call it answered, whose path has the
user's and the account's ids at bunq. Neither does now.

A key typed by hand could be read off the screen (app). The line under
a key field showed how the key begins and its last four characters,
which is every character of it as it is typed. It shows how the key
begins and how long it is.

Every change asks for the password (packaging, app). Change, the
action for what changes something and pays nobody, passed without a
password in an active session, so any program of the user's could
cancel a scheduled payment, ask for money in their name or freeze a
card. It asks now (auth_self), a draft saved and a card frozen
included: only View passes as shipped, and loosening is an
administrator's rule, of which the README has an example. The app says
of every change where it is confirmed (AsksPassword is gone), and the
request form sends on its button as the pay form does: its review
sheet would be a second confirmation of what the dialog confirms.

What is built is what was tested (build). Crafter.Network, Crafter.DB
and Crafter.LintRules are named at the commits the tests ran against.
Crafter.Thread still follows its branch, which Crafter.Network's own
project file names, and so does Crafter.Network in the app's debug
build, where Crafter.Debug names it too and crafter-build refuses a
module built twice. lib/json.hpp was nlohmann/json's develop branch at
95e9a593 less its last newline, and called 3.12.0: it is that file
byte for byte now, and called what it is.

The published contract changes with this, before any release (design
rule 10): an e-mail address the dialog cannot show as it is is
refused, a call that looks something up needs View as well as its own
action, the checkout's errors say less, and the policy asks for the
password for Change. The XML, the policy and ShouldServeEveryUser,
which now holds the policy to its defaults, change together.

Reproduced and verified on the fake bus and the fake bunq. The new
checks of ShouldServeEveryUser fail on the worker of before (50 of
them: the & shown, the lookups answered, the bank asked) and pass now.
crafter-build test (17 tests), lint for the library, the app and the
fake system, and tests/coverage.sh (every line, function and region)
pass. Looked at on the made-up system, 360x760 dp at scale 2, dark, on
KDE Wayland: the key form with a key typed, the request form with its
wait and its result, a card frozen, and About. No picture in the
README shows a screen that changed.

Not tried: bunq's sandbox, a real polkit agent, the Flatpak builds.
The README's example rule ran against a stand-in for polkit's rule
engine only.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-11-19 16:09:48 +01:00
commit 2e3739ff7a
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
23 changed files with 488 additions and 209 deletions

View file

@ -62,13 +62,13 @@ Everything is in `namespace Nostro`: the OpenSSL helpers in `Nostro::Crypto`, th
### nostrod, through Nostro::Client
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`:
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: as shipped only viewing passes in an active session, and everything else asks for the user's password each time, a draft saved, a request for money and a card frozen as much as a payment. An administrator's rule may ask for less. A call that names an account, a card, a request, a draft or a connector, and is not a call to see it, is checked twice: for viewing, before nostrod looks up what it names, and then for what it does. So a caller polkit does not let see the accounts gets `AccessDenied` for it, whether what it named is there or not. 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`; 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<Account>`) 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.
- 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<T>` (`std::function<void(Answer<T>)>`; `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<T>` 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.
- Errors: `std::invalid_argument` for what nostrod refused before doing anything (it names the problem, as the library's own messages do). That includes an e-mail address to pay or ask that the password dialog could not show exactly as it is: one with an `&`, a `<` or a `>` in it, with a character that draws nothing, or longer than 254 characters. A name is never refused for that: the dialog shows it without what draws nothing, with `&`, `<` and `>` replaced, and cut at 64 characters. `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
@ -76,8 +76,8 @@ nostrod is the system daemon that holds every local user's connectors, in a work
An app that only needs a customer to pay an order links `Nostro.Checkout` (`--product=checkout`, `import Nostro.Checkout;`), which has nothing of the library in it. nostrod pays the order from the account the user chose with `nostro checkout account <account>`, once the user has confirmed it at a password prompt that shows the amount, the payee, the reference and that account. The app never names nor sees the account.
- `Nostro::Checkout::Pay(Order{.payeeIban, .payeeName, .amount, .currency = "EUR", .reference}, timeout = 10min)` returns `Paid{paymentId, repeated}`. It blocks until the user has answered: call it off the UI thread. The payee is an IBAN alone, the amount positive minor units, the reference not empty.
- An order is paid once: `Pay` again with the same IBAN and reference, after a timeout or a crash, answers with the first payment and `repeated` set, without asking the user, and while the first call is still at the prompt the second waits for it. The same reference with another amount is refused. Any app the user runs with access to the checkout can learn this way whether an order was paid, so references should be hard to guess.
- It throws `Checkout::Cancelled` (the user did not confirm) and `Checkout::NoCheckoutAccount` (none chosen, or the chosen one is gone), both `Checkout::Error`, which every other refusal is, with the D-Bus `name`: `Checkout::errorInvalidArgument`, `errorBank` (its message says when it may have paid all the same), `errorFailed` (also for an earlier call whose outcome was lost, which may have paid), `org.freedesktop.DBus.Error.AccessDenied`, and `ServiceUnknown`, which means nostro is not installed. No answer within `timeout` is an `Error` saying the order may have been paid, and asking again is safe. Text that is not UTF-8 is a `std::invalid_argument`; a failure of the bus itself a `std::system_error`.
- An order is paid once: `Pay` again with the same IBAN and reference, after a timeout or a crash, answers with the first payment and `repeated` set, without asking the user, and while the first call is still at the prompt the second waits for it. The same reference with another amount is refused, without a word on which amount the order has. Any app the user runs with access to the checkout can learn this way whether an order was paid, so references should be hard to guess.
- It throws `Checkout::Cancelled` (the user did not confirm) and `Checkout::NoCheckoutAccount` (none chosen, or the chosen one is gone), both `Checkout::Error`, which every other refusal is, with the D-Bus `name`: `Checkout::errorInvalidArgument`, `errorBank` (its message is `bunq: ` and what bunq said, without the call it answered, which would name the user's account; it says when it may have paid all the same), `errorFailed` (also for an earlier call whose outcome was lost, which may have paid), `org.freedesktop.DBus.Error.AccessDenied`, and `ServiceUnknown`, which means nostro is not installed. No answer within `timeout` is an `Error` saying the order may have been paid, and asking again is safe. Text that is not UTF-8 is a `std::invalid_argument`; a failure of the bus itself a `std::system_error`.
- On the wire it is `net.catcrafts.Nostro1.Checkout`, its own bus name, with one method, `Pay(ssxssa{sv}) -> (ta{sv})`, published as `packaging/dbus/net.catcrafts.Nostro1.Checkout.xml` for apps in other languages. Options and results are dictionaries so they can grow: nostrod ignores options it does not know, and the client skips results it does not know. A Flatpak app asks for `--system-talk-name=net.catcrafts.Nostro1.Checkout`, which reaches nothing else of nostrod: the name is served by a connection of its own.
- A payment id is the paying bank's: confirm the money arrived with your own bank.

View file

@ -31,11 +31,11 @@ Five C++26 modules, and a sixth in one build:
| `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. |
| `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 names each dependency at a commit ("Dev environment"). 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/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. |
| `lib/json.hpp` | nlohmann/json (MIT), included in the global module fragment of `:Bunq` and of the `Connector`, `Bunq` and `BunqPayments` implementation units. Not a release: `single_include/nlohmann/json.hpp` as upstream's `develop` had it at commit `95e9a5931c828cd7306eff36090a5b38e0e3f598` (2026-09-25), which still calls itself 3.12.0, the release of 2025-04-11. It is that file byte for byte, so `git hash-object lib/json.hpp` gives its id there, `4981c3b02e0367e22419b17c37345873d7813076`: keep it so, and name the commit here and in `packaging/licenses/NOTICE` when it is replaced. |
| `tests/<Name>/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). |
@ -78,7 +78,7 @@ Partitions, from the bottom up (each imports only the ones above it):
- `: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`.
- `:Errors`: `Operation`, the polkit action of each (`ActionOf`) and whether money leaves an account by it (`MovesMoney`), and `Explain(error, operation)`, which turns an answer's error into `Guidance`. There is no asking whether an operation takes a password: as shipped every one but a reading does.
- `:App`: `Host` (what the program around the app gives it), `Loadable<T>`, `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`.
@ -100,8 +100,13 @@ The bunq connector end to end:
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 <uid> <name> …`, 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 `<state>/users/<uid>`, 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.
- **A worker** (`implementations/Nostro-Daemon-Worker.cpp`, `RunWorker`) is one user's library: `configPath` and `cachePath` are `<state>/users/<uid>`, 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.
- On the main interface nothing of the user's is read, and the bank is asked nothing, for a caller polkit has not said yes to. A call that sees something (`Transactions`, the listings) looks its account up in its work, after the yes. A call that must look something up to word its own question (a payment's account, a card, a request, a draft, a connector) goes through `HandleLookup`: polkit is asked for `View` first, worded as the listing of what is looked up, and the handler's body runs on its yes. So such a call makes two checks, of which the first has no dialog in an active session as shipped; where `View` takes a password it asks twice. The connectors themselves are read (`Load`, which refreshes each one's accounts at the bank) on the first yes, or for the first new order at checkout, and not on the first call.
- 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()`: nothing that draws nothing or places text (control and format characters, line and paragraph separators, what Unicode ignores by default, private use), any kind of space as one plain space, `<`, `>` and `&` replaced by `‹`, `›` and `+`, `$(` broken, 64 characters at most. The `&` matters as much as the brackets: GNOME's older agent and MATE's read the message as Pango markup, and show an empty dialog for one with a bare `&`. A summary names the address before the name. An address a caller gives is not made fit but held to it (`Counterparty`): one `Shown()` would change, up to 254 characters, is refused before anyone is asked, since an address shown otherwise than it is could be somebody else's.
- 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. An app at checkout is someone else than the user, and is told less: a refusal for another amount does not say which amount the order has, and an error of the connector's reaches it as `bunq: …`, without the call it answered, whose path names the user and the account at bunq (`ErrorFor`). The checkout is also the one place that reads before polkit is asked: an order it knows is answered from its record, and the account that pays a new one is chosen for the dialog to name.
- **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:
@ -110,8 +115,8 @@ The app end to end:
- 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.
- 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, and so does the request form (`SubmitRequest`, `request.submit`). A payment, a schedule, a draft and a request for money are each confirmed in polkit's dialog, which nostrod words from its own data; accepting a draft is confirmed there once more. The app's own review of a payment was taken out on 2026-11-19, as a second confirmation of what the dialog confirms, and the review of a request went the same day, when a request began to ask for the password: do not put either 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, is what one press on a detail sheet would do: revoking, accepting, rejecting, cancelling, a card reported lost, a connection removed. Each such sheet says that the system asks for the password, and while a change is under way its sheet says where to confirm it: every change asks for the password as shipped (design rule 9), so the app does not ask which do. Freezing and unfreezing a card go straight to the dialog. `ShouldDriveTheApp` holds each operation 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.
@ -125,7 +130,8 @@ The app end to end:
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 "<sha>"`) would pin them, as Crafter.Debug's build helper is, the second pragma.
- Every dependency `project.cpp` names is at a commit: Crafter.Network (nostro builds it `--no-quic`, so without msquic) and Crafter.DB are `GitProject`s with a `.commit`, and Crafter.LintRules and Crafter.Debug's build helper `#pragma crafter dependency` lines with `commit "<sha>"`. crafter-build clones each from `forgejo.catcrafts.net` once and builds from that clone, and the notes at the end of this file are those commits' notes. They were pinned on 2026-11-19, to what the tests had run against that day: a build runs each dependency's own `project.cpp` and links its code into the program that holds every user's bank keys. Moving one forward is a change to `project.cpp`, with the tests run again.
- Two things still follow a branch, so a build still needs the network. Crafter.Thread comes behind Crafter.Network, whose own project file names it without a commit: pinning it is Crafter.Network's to do. And the app's `--debug-api` build takes Crafter.Network without a commit, because Crafter.Debug does: with one library named two ways crafter-build stops with "module Crafter.Network is built twice for nostro-app", as tried on 2026-11-19.
- 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=<a Crafter.Graphics checkout's project.cpp>` 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 `<state>/users/<uid>/`: `connectors.json`, the transaction tables, `checkouts.cdb`, `checkout-account` and `owner`, with `<state>` 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.
@ -174,7 +180,7 @@ The app's packaging: `--packaging=flatpak` makes `bin/nostro-app-<variant>/files
| `ShouldTalkToBunq` | the connector: every user type, signatures, rate limits, session renewal, errors, accounts, the sync, cards, OAuth, old connectors |
| `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) |
| `ShouldServeEveryUser` | nostrod: users kept apart, a uid handed to a new user, every polkit answer and what each dialog says, what a dialog is kept free of and which addresses are refused for it, that a caller polkit refuses is told nothing of what is there and has the bank asked nothing, 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 with its defaults: only seeing passes without a password) |
| `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 |
@ -221,7 +227,7 @@ What a test cannot show (that the window draws what the frame says, in the right
- `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 <nostro-fake-system> <nostro-app>` 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.<IBAN>`, `account.pay`, `tabs.1`, `pay.to`, `pay.submit`, `request.review`, `review.confirm`, `done.close`, `card.<id>`, `settings.connections`, `connections.add`, `bank.bunq`, `way.key`, and `copy.<label>` for a line of a sheet (`copy.IBAN`), which a press copies. `get ui.regions` lists a screen's.
- A region's key is its name in the tests too: `nav.accounts`, `account.<IBAN>`, `account.pay`, `tabs.1`, `pay.to`, `pay.submit`, `request.submit`, `confirm.yes`, `done.close`, `card.<id>`, `settings.connections`, `connections.add`, `bank.bunq`, `way.key`, and `copy.<label>` for a line of a sheet (`copy.IBAN`), which a press copies. `get ui.regions` lists a screen's.
## Code style
@ -248,11 +254,11 @@ What a test cannot show (that the window draws what the frame says, in the right
6. **Synchronous HTTPS, one client per bank host.** `ClientHTTP1::Send` on the calling thread, a persistent connection for reads and a fresh one for every write, no thread pool, default TLS verification. A bank's own request function owns the protocol: signing, verifying, waiting out rate limits and renewing an expired session once. Every other error is an exception; whether to retry a write is the caller's decision, and an unknown outcome is reported as such. (Revised 2026-10-31: the retries moved from the transaction sync into the request function.)
7. **Signing is opt-in per bank.** `:Crypto` and `-lssl -lcrypto` are pulled in by `opensslEnabled`, the OR of the banks that sign; a bank that does not sign must not make the build depend on OpenSSL.
8. **The library is the product; the CLI and the app are thin clients.** `--lib` returns the library configuration; the CLI adds `main.cpp` alone, which parses `argv`, calls nostrod through `Client` and prints through the formatters, and nostrod adds `nostrod.cpp` alone. Logic goes into a partition (the daemon's into `:Daemon`), not into `main.cpp`. What the CLI and the app both need is the library's, not written twice: reading the address an OAuth redirect lands on, the end of a day a person typed, a card's status as bunq kept it (the check; what the app then says it words itself, in no bank's name). The app decides nothing nostrod should: what an account, a payee or an amount may be is nostrod's to refuse, and the app's own checks only spare the user a round trip. (Revised 2026-11-01: the CLI talks to nostrod, not to the bank. Revised 2026-11-19 for the app.)
9. **nostrod answers each caller for their own money, and asks polkit first.** The front maps a caller's uid, asked of the bus, to that uid's own worker process; nothing of one user's is ever in another's process. Every method has one polkit action, decided by what the call does (`View`, `Change`, `Pay`, `UnfreezeCard`, `BlockCard`, `Connectors`, `Checkout`), and the dialog's summary and details are built from the worker's own data after the call is read and checked, never from text the caller formatted: what the dialog shows is what gets paid. Every action is owned by `unix-user:nostro` in the policy, or polkit refuses nostrod's checks. Every method is `SD_BUS_VTABLE_UNPRIVILEGED`, since polkit decides, not sd-bus. It fails closed. No action keeps an authorization: polkit keeps one per process, so the CLI would ask every time anyway, and the app, which lives for hours, would not: an administrator's rule that keeps one (`auth_self_keep`) lets a running app pay for minutes without a password.
10. **The wire is a published contract.** `packaging/dbus/*.xml` is what nostrod serves (`ShouldServeEveryUser` compares them with its introspection), and apps in other languages generate their proxies from it. A method may be added; changing a method's signature or meaning means a new interface (`…Nostro2`). The checkout's `options` and `results` are dictionaries so that it can grow without one: unknown options are ignored, unknown results skipped. So is the query of `Transactions`: `stored` was added to it on 2026-11-19, and a nostrod from before ignores it and asks the bank, which is slower and no less right. A client must not lean on a new key for anything but speed. One meaning was narrowed all the same, on 2026-11-19, while no release had been published: `AddBunq`'s `environment` used to choose the environment over what the key says, and now only has a key of the other one refused. After a release that would have been `…Nostro2`'s to do.
9. **nostrod answers each caller for their own money, and asks polkit first.** The front maps a caller's uid, asked of the bus, to that uid's own worker process; nothing of one user's is ever in another's process. Every method has one polkit action, decided by what the call does (`View`, `Change`, `Pay`, `UnfreezeCard`, `BlockCard`, `Connectors`, `Checkout`), and the dialog's summary and details are built from the worker's own data after the call is read and checked, never from text the caller formatted: what the dialog shows is what gets paid. Before polkit's yes a worker reads nothing of the user's for the caller and asks the bank nothing: a call that has to look something up to word its question needs `View` first (`HandleLookup`), so it has two actions, and a caller who may not see the accounts cannot find out what is there, or have the bank asked, by trying to change it. The checkout, whose caller is an app, is the stated exception (see "Checkout" above). Every action is owned by `unix-user:nostro` in the policy, or polkit refuses nostrod's checks. Every method is `SD_BUS_VTABLE_UNPRIVILEGED`, since polkit decides, not sd-bus. It fails closed. Secure by default: as shipped only `View` passes without the user's password in an active session, and every other action asks for it every time (`auth_self`), `Change` too, down to a draft saved and a card frozen. That was decided on 2026-11-19; until then `Change` passed, on the reasoning that it pays nobody, which left any program of the user's free to cancel a scheduled payment or ask for money in their name. Loosening is an administrator's choice, made with a rule, and `ShouldServeEveryUser` holds the policy file to these defaults. No action keeps an authorization: polkit keeps one per process, so the CLI would ask every time anyway, and the app, which lives for hours, would not: an administrator's rule that keeps one (`auth_self_keep`) lets a running app pay for minutes without a password, and polkit's manual says a kept one holds whatever the next check's details are.
10. **The wire is a published contract.** `packaging/dbus/*.xml` is what nostrod serves (`ShouldServeEveryUser` compares them with its introspection), and apps in other languages generate their proxies from it. A method may be added; changing a method's signature or meaning means a new interface (`…Nostro2`). The checkout's `options` and `results` are dictionaries so that it can grow without one: unknown options are ignored, unknown results skipped. So is the query of `Transactions`: `stored` was added to it on 2026-11-19, and a nostrod from before ignores it and asks the bank, which is slower and no less right. A client must not lean on a new key for anything but speed. One meaning was narrowed all the same, on 2026-11-19, while no release had been published: `AddBunq`'s `environment` used to choose the environment over what the key says, and now only has a key of the other one refused. Four more were that day, after a security review and for the same reason: an e-mail address that the password dialog could not show as it is (`to`, `from`) is refused; a call that names an account, a card, a request, a draft or a connector, and is not a call to see it, needs `View` as well as its own action; the checkout's errors say less (no amount of the order on record, no call to the bank); and the policy has `Change` ask for the password in an active session, as every action but `View` does. After a release each would have been `…Nostro2`'s to do, or for the policy a change of defaults under users who had come to rely on the old ones.
11. **The app's logic is pure, and its window is thin.** `Nostro.Ui` and `Nostro.App` import no window library and read no device: a screen is a function from state to a frame, so a test builds it, reads what it says and taps it by name, and both stay at the coverage the library has. `Nostro.Ui.Shell`, `nostro-app.cpp` and the debug commands are the only code that needs a compositor. They decide nothing about money, are checked by looking ("Looking at the app"), and are outside the coverage figure. What would need a decision there goes into the toolkit or the app as a function a test can call. Crafter.Debug stays in the executable: `Debug::Use` reaches that configuration alone, and the window and the app only offer hooks.
12. **The app holds no secret and no say.** It has no key, no token and no file of its own, and its Flatpak no network. A key typed into it lives in a `Secret` field, which is drawn as dots, shown otherwise only as a fingerprint, never copied, and wiped when the form goes; it is passed to nostrod once, in a message marked sensitive. What moves money is confirmed in polkit's dialog, which nostrod words from its own data, and nowhere else: the pay form's button sends, and a program that drove the window would still meet the dialog. So what stands between a press and a payment is the system's policy for the `Pay` action, which asks for the password every time as shipped. Under an administrator's rule that answers it without asking, one press on Pay pays.
12. **The app holds no secret and no say.** It has no key, no token and no file of its own, and its Flatpak no network. A key typed into it lives in a `Secret` field, which is drawn as dots, shown otherwise only as a fingerprint (`Fingerprint`: how it begins and how long it is, and never how it ends, since the end of a key being typed by hand is what was typed last), never copied, and wiped when the form goes; it is passed to nostrod once, in a message marked sensitive. What moves money is confirmed in polkit's dialog, which nostrod words from its own data, and nowhere else: the pay form's button sends, and a program that drove the window would still meet the dialog. So what stands between a press and a payment is the system's policy for the `Pay` action, which asks for the password every time as shipped, as the policy for every other action but `View` does. Under an administrator's rule that answers it without asking, one press on Pay pays.
13. **The library is LGPL, the app is GPL.** LGPL-3.0-only: the module `Nostro`, `Nostro.Checkout`, the CLI, nostrod, their tests, the tests' fakes and the fake system, `project.cpp` and the packaging. A program under any licence can be built on the library and the checkout. GPL-3.0-only: `Nostro.Ui`, `Nostro.App`, `Nostro.Ui.Shell`, `nostro-app.cpp`, `Nostro.DebugCommands`, their seven tests and `tests/Support/Ui.inc`, the app's desktop entry and icon, and `docs/screenshots/`, the pictures of the app and the script that takes them: a program built from any of it is under the GPL as a whole. A new file gets the licence of what it is part of, in its first line. The dependency runs one way, and has to: nothing of the library imports or includes anything of the app, or the library could no longer be used under the LGPL. Code moves from the library into the app as it is; the other way it changes licence, which is Catcrafts' to decide for what Catcrafts wrote, and the author's for a patch that came in under the GPL alone. (Decided 2026-11-19.)
@ -282,8 +288,9 @@ The checklist, from the bunq connector:
- `connectors.json` is the crown jewels: the bunq API key or OAuth token, the installation and session tokens and the unencrypted RSA private key, as plain text. Its protection is `0600` in a `0700` directory, and installed, the directory of a system user of its own (`/var/lib/nostro`) under a service that keeps the rest of the system read-only to it; it is replaced by a synced rename, never rewritten in place. There is no encryption at rest: root, and a disk taken out of the machine, read it. Never print it, never log a token or a signature, never copy a real one into a scratch directory or a commit. The transaction tables are the user's financial history, kept private the same way by Crafter.DB.
- What nostrod does not stop: a program running as the user can still draw a dialog that looks like polkit's and ask for the password; only the system's own agent is the real one. On a session without a polkit agent (SSH, a TTY without one) nothing can confirm, so every call that needs a password is `Cancelled`. polkit logs the calling process's command line, which is why no secret is ever an argument.
- A worker makes itself undumpable, and the service sets `LimitCORE=0`: a core dump would hold the keys. A text that reaches a dialog goes through `Shown()`, so neither a payee's name nor a description can fake another amount or payee in it.
- The app is one of the programs nostrod keeps the user's bank from: it sees accounts and payments, which `View` allows any program of the user's in an active session, and nothing that could move money without the dialog. Its Flatpak has the compositor, the graphics device and `net.catcrafts.Nostro1` on the system bus, and no network, no files and no session bus beyond the portals. It makes itself undumpable, so another program of the user's cannot read a key out of it while it is typed. It writes no amount, IBAN or name to its log, which lands in the user's journal.
- What the shipped policy leaves open is looking: `View` needs no password in an active session, so any program of the user's there can read the accounts, payments, requests and cards. Everything else asks, `Change` included since 2026-11-19 (design rule 9). The README's "How Nostro runs" and "Security" say both plainly, and how a rule loosens it. polkit cannot tell the app from another program of the user's, so a rule that loosens an action loosens it for all of them; neither can nostrod, since whatever marks a process as the app (its executable, its Flatpak id, a unit's name) another program of the same user can wear, by starting the real app with its own code in it or on a display of its own.
- A worker makes itself undumpable, and the service sets `LimitCORE=0`: a core dump would hold the keys. A text that reaches a dialog goes through `Shown()`, so neither a payee's name nor a description can fake another amount or payee in it, start a line of its own, or leave an agent that reads its message as markup with nothing to show. What it cannot stop is a name that reads like part of the sentence ("Bob) from NL00… (Savings"): the summary puts the amount first and the paying account last for that reason.
- The app is one of the programs nostrod keeps the user's bank from: it sees accounts and payments, which `View` allows any program of the user's in an active session, and nothing that could pay or change anything at the bank without the dialog. Its Flatpak has the compositor, the graphics device and `net.catcrafts.Nostro1` on the system bus, and no network, no files and no session bus beyond the portals. It makes itself undumpable, so another program of the user's cannot read a key out of it while it is typed. It writes no amount, IBAN or name to its log, which lands in the user's journal.
- A build with `--debug-api` is none of that: every program of the user's can drive it and read what it shows, it logs what it is told, and a debugger can attach to it. It is for the made-up system and bunq's sandbox. `Ui_Type` refuses to type into a field that hides what it holds unless the text is a sandbox key (`sandbox_…`); nothing stops a hand from typing a real one into such a build, so do not. No Flatpak is made of it.
- The checkout answers a repeated order with its payment id without a dialog, so any app with access to the checkout can learn whether the user paid an order whose IBAN, reference and amount it knows (README, "Checkout for apps").
- A connector's `environment` decides between `api.bunq.com`, where `send` moves real money, and the sandbox. An API key says itself which it is of: a sandbox key starts with `sandbox_`, and anything else is production. Nobody chooses it: nostrod takes the key's own, and refuses an environment named otherwise before the key goes anywhere, so a real key is not sent to the sandbox by a slip (`OnAddBunq`); the CLI has no flag for it and the app's form no choice. An OAuth client has no such mark, so there the environment is named (`--sandbox`, the form's Production or Sandbox). Since 2026-11-19 production has been used to connect and to read accounts, payments and cards; these notes record no payment made on it, so try that with small amounts first.
@ -291,7 +298,7 @@ The checklist, from the bunq connector:
- A write is never replayed by the transport (fresh connection) and only resent by nostro after a 429, which bunq refuses before acting. An IBAN's check digits are verified before anything is sent.
- TLS is Crafter.Network's default `TLSClientCredentials{}`: the chain against the system store and the hostname. Do not reach for `insecureNoServerValidation`.
- The private key signs every request body (`SignBody`, RSA SHA-256). Key material lives in `Crypto::Key`s (freed with the last copy) for the process's life; there is no zeroisation.
- `project.cpp` executes the `project.cpp` of three unpinned dependencies (Crafter.Network, Crafter.DB, Crafter.LintRules) on every build, fetched from the Catcrafts Forgejo at HEAD, and the Flatpak build does the same with the network on; Crafter.Debug's build helper is the one that is pinned. The app's build adds Crafter.Graphics, which brings Crafter.Event, Crafter.Math, Crafter.Asset and the Khronos headers, unpinned, and its debug build Crafter.Debug's library with a Crafter.Network that has msquic in it. Pin a commit on each for a build that is reproducible and offline after the first fetch.
- `project.cpp` executes the `project.cpp` of each dependency on every build, and the Flatpak build does the same with the network on. Those it names itself are at a commit since 2026-11-19: Crafter.Network, Crafter.DB, Crafter.LintRules and Crafter.Debug's build helper ("Dev environment"). What still follows a branch, fetched from the Catcrafts Forgejo at HEAD: Crafter.Thread, which Crafter.Network names; in the app's build Crafter.Graphics, a checkout given with `--graphics=`, which brings Crafter.Event, Crafter.Math, Crafter.Asset and the Khronos headers, unpinned; and in its debug build Crafter.Debug's library with a Crafter.Network that has msquic in it. Pin those where they are named for a build that is reproducible and offline after the first fetch.
- `install.sh --repo` installs from an unsigned local repository, for a build of your own, and so does a bundle crafter-build made. A published Flatpak comes from the GPG-signed Catcrafts remote, which is how the README installs both: the remote `catcrafts`, added from `https://flatpak.catcrafts.net/catcrafts.flatpakrepo`, Crafter.Build's own remote. `install.sh` without `--repo` installs from that remote in the system installation, where nostrod runs from, and does not add it itself. On 2026-11-19 the remote did not carry nostro's two Flatpaks yet: the README describes the channel they are to be published on. The two `.flatpakref`s in `packaging/flatpak/` carry the same placeholder for the key as Crafter.Build's, for the publishing side to fill in.
- Input from the bank is parsed with nlohmann/json's `at()` and `get()`, which throw on a missing key or a wrong type: a malformed response is an exception, not undefined behaviour. `ParseAmount` and `ParseTimestamp` reject anything outside their grammar.
@ -314,6 +321,7 @@ The state of the code on 2026-11-19; each is a fact to work with.
- The notes of Crafter.Graphics, Crafter.Math and Crafter.Asset are in `AGENTS.md` only after a build of the app, and gone again after the next build of another product: crafter-build writes the section from what the build loaded.
- systemd's hardening and bubblewrap, which flatpak runs nostrod in, disagree in places, found on 2026-11-01 under `systemd-run --user`: bubblewrap needs `AF_NETLINK` (it brings up loopback), `@mount`, `unshare` and `setns`, and a `/proc` of its own; `RestrictSUIDSGID=` makes systemd answer `openat2()` with ENOSYS, which bubblewrap 0.13 does not fall back from. `nostrod.service` says which options are left out and why.
- polkit as seen on that day (polkit 127, Plasma): closing Plasma's dialog sends no `polkit.dismissed`, only `polkit.result` `auth_self`, so `Cancelled` is read from either; a kept authorization is the calling process's alone; the command line of the process asking is logged.
- Agents do not agree on what a message is. GNOME Shell's, Phosh's and LXDE's show it as plain text. polkit-gnome (the older GTK agent many desktops without one of their own start) and mate-polkit put it into Pango markup without escaping it, as read in their sources on 2026-11-19: a `<` starts a tag there, and a bare `&` makes the whole message fail to parse, which leaves the dialog without one. That is why `Shown()` replaces `&` as it does `<` and `>`, and cannot escape them instead: an agent that shows plain text would show the escape. How Plasma's agent reads its message was not established that day. Whatever is added to a summary goes through `Shown()`.
- sd-bus holds a vtable method's answer to the signature the vtable declares: an answer of another shape becomes `System.Error.ENOMSG`. A test that must send a malformed answer (`FakeCheckout` in `ShouldServeEveryUser`) registers a plain object (`sd_bus_add_object`) instead.
- A worker or nostrod killed with SIGKILL writes no coverage counts; both handle SIGTERM (systemd's stop signal too) by ending the loop, and the tests stop them that way.
- `--product=checkout` returns before the bank check, so it needs no `--banks=`; every other product does.

View file

@ -9,7 +9,9 @@ By making a open source app that interfaces with bank APIs.
Nostro keeps your bank connections out of reach of the programs you run. Its daemon, nostrod, runs as a system user of its own and holds the bank connections of every user of the machine, each user's in a process of its own. The Nostro app and the `nostro` command ask nostrod over the system bus, and nostrod asks polkit whether you may:
- Looking at accounts, transactions, requests and cards needs nothing more in your desktop session.
- Paying, scheduling a payment, accepting a request or a draft payment, unfreezing or blocking a card, and changing your bank connections ask for your password every time.
- Everything else asks for your password every time. That is whatever pays: a payment, a scheduled payment, a request or a draft payment you accept. And it is whatever changes something without paying anyone: asking someone for money, saving a draft payment, cancelling a scheduled payment, revoking a request you sent, rejecting a request or a draft payment, freezing, unfreezing or blocking a card, and changing your bank connections.
Nostro ships that strict on purpose: no program does anything at your bank without you. Whoever administers the machine can loosen it, see Security.
Your desktop draws the password dialog, and it says what it is for: the amount, who is paid, and from which account. Nothing secret goes on the command line: Nostro asks for an API key at a prompt. The app holds none of your keys either: one you type into it goes to nostrod and is forgotten.
@ -39,19 +41,20 @@ It does everything the `nostro` command does:
| An account, Activity | Its payments by day. Search a name, a description or an IBAN, or filter by an exact amount and by dates: that looks through the payments Nostro has read from the bank, as you type. A payment opens with all of its details, and can be paid again or asked back from there. |
| An account, Requests and Incoming | The requests for money you sent, each with its link to copy or open, which you can revoke; and the ones you received, to pay or reject. |
| An account, Scheduled and Drafts | The payments on a schedule, to cancel; and the draft payments, to accept or reject. |
| Pay | From which account, to an IBAN, an e-mail address or a phone number, how much, and what for: now, on a schedule, or as a draft. Its button sends it: a payment is confirmed in your system's password dialog, and a draft is saved at once, to be paid when it is accepted. |
| Request | Ask someone for money. The result has a link to send them. |
| Cards | Your cards and the account each pays from. Freeze or unfreeze one, or report it lost or stolen, which blocks it for good and is asked twice. |
| Pay | From which account, to an IBAN, an e-mail address or a phone number, how much, and what for: now, on a schedule, or as a draft. Its button sends it, and your system's password dialog is where you confirm it. A draft is paid only once it is accepted, which is confirmed there again. |
| Request | Ask someone for money. Its button sends it as Pay's does, confirmed in the same dialog, and the result has a link to send them. |
| Cards | Your cards and the account each pays from. Freeze or unfreeze one, or report it lost or stolen, which blocks it for good and is asked twice. Each is confirmed with your password. |
| Settings, Bank connections | Your connections and whether they work. Add one in three steps: your bank, how to connect to it, and what that asks for. bunq connects with an API key or through OAuth. Remove one, which logs it out and deletes its stored payments. |
| Settings, Pay at checkout from | The account apps are paid from at their checkout, see Checkout for apps. |
| Settings, About and security | What Nostro protects you from, and its version. |
- Which bank an account is with makes no difference to how the app shows it or pays from it. Only adding a connection, in the settings, is each bank's own. Until a bank is connected the app offers to connect one.
- A connection that its bank lets pay between your own accounts only, as bunq does one made through OAuth, is marked Limited. A payment from it to anyone else is saved as a draft, to approve in your bank's app.
- The app asks no second question before a payment: Pay sends it, and your system's password dialog is where you confirm it. That dialog is your system's, not the app's, and says what is paid, to whom and from which account: read it. Closing it pays nothing, and leaves the form as you filled it in.
- The app asks no second question before a payment or a request for money: the form's button sends it, and your system's password dialog is where you confirm it. That dialog is your system's, not the app's, and says what is paid, to whom and from which account: read it. Closing it pays nothing, and leaves the form as you filled it in.
- Every change is confirmed in that dialog. Where one press would do it, such as rejecting a request or cancelling a scheduled payment, the app asks first whether you mean it.
- A card's status is what its bank reports of it. A virtual card is shown as Virtual, and no more: the bank does not report whether one is frozen, and does not freeze or unfreeze one when Nostro asks, so do that in your bank's app. It can be reported lost or stolen like any card. For a plastic card, Deactivated is the bank's word for one that is frozen and for one that was never activated: the card's own sheet says so, and shows how far the bank is with the card.
- If the bank's answer to a payment gets lost on the way, the app says the payment may have been made and shows you the account's payments. It does not offer to try again.
- The app asks a phone's on-screen keyboard for digits at an amount, and to show and learn nothing of a key you type.
- The app asks a phone's on-screen keyboard for digits at an amount, and to show and learn nothing of a key you type. Of a key in its field the app itself shows how it begins and how long it is, and never how it ends.
- Your accounts, an account's lists and your cards are read again when you pull the page down at its top and let go, or with Refresh in the bar at the top.
- Press a line of a payment's, a request's or a card's details to copy what it says. An IBAN is copied without its spaces.
- With a keyboard: Tab and Shift+Tab move between what can be pressed, Enter presses it, Escape goes back, F5 or Ctrl+R reads the screen again, and Ctrl+F goes to the search. A long press or the right mouse button on a field offers paste, copy and select all.
@ -100,7 +103,7 @@ nostro checkout account [{account}] # the account apps may ask y
```
- `{account}` is an account's name or its IBAN. Use the IBAN when two accounts share a name.
- `{to}` and `{from}` are an IBAN, an e-mail address, or a phone number starting with `+`. IBANs are checked before anything is sent.
- `{to}` and `{from}` are an IBAN, an e-mail address, or a phone number starting with `+`. IBANs are checked before anything is sent. An e-mail address is refused when the password dialog could not show it exactly as it is: one with an `&`, a `<` or a `>` in it, or one longer than 254 characters.
- Amounts are in the smallest unit of your currency, so for EUR `1250` is €12.50.
- Dates are `YYYY-MM-DD` or `"YYYY-MM-DD hh:mm"`, in local time.
- `nostro cards` lists a virtual card as `VIRTUAL`. bunq does not say whether one is frozen and does not freeze or unfreeze one when asked, so `freeze` and `unfreeze` refuse it; `lost` and `stolen` work.
@ -143,7 +146,7 @@ const Nostro::Checkout::Paid paid = Nostro::Checkout::Pay({.payeeIban = "NL91ABN
`Pay` blocks until the user has answered, so call it off the UI thread. It throws `Nostro::Checkout::Cancelled`, `Nostro::Checkout::NoCheckoutAccount`, or `Nostro::Checkout::Error` with the D-Bus error name.
Any app the user runs with access to the checkout can ask whether an order was paid, by asking for it again with the same IBAN, reference and amount: it gets the payment id without a prompt. Nostro cannot tell which app is asking, so a reference should be hard to guess.
Any app the user runs with access to the checkout can ask whether an order was paid, by asking for it again with the same IBAN, reference and amount: it gets the payment id without a prompt. Nostro cannot tell which app is asking, so a reference should be hard to guess. With another amount it is refused without being told what the order was paid for, and an error from the bank says what the bank said, not which account it said it about.
## Contributing
@ -161,11 +164,34 @@ Please report security vuneribilities to jorijnvdgraaf@catcrafts.net before publ
What Nostro protects you from, and what it does not:
- Programs you run cannot read your bank connections, which belong to nostrod's own user, and cannot move money without your password. The Nostro app is one of those programs: it holds no key and no token.
- The password dialog is your desktop's. A program running as you could still draw one that looks the same, so type your password only for something you asked for, and check what the dialog says.
- Programs you run cannot read your bank connections, which belong to nostrod's own user, and cannot pay or change anything at your bank without your password. The Nostro app is one of those programs: it holds no key and no token.
- What needs no password in your desktop session is looking. Any program you run there can read your accounts, payments, requests and cards.
- The password dialog is your desktop's. A program running as you could still draw one that looks the same, so type your password only for something you asked for, and check what the dialog says. It shows the address that is paid whole and as it is. A name is cut off after 64 characters, and an `&` in one is shown as a `+`.
- Over SSH, or in any session without a polkit agent, nothing can ask for your password, so whatever needs it is refused.
- The bank connections are not encrypted on disk: root, and anyone holding the disk, can read them. Use full-disk encryption.
- An administrator can change what needs a password with polkit rules in `/etc/polkit-1/rules.d/`, for example an amount above which an administrator must approve a payment. Each dialog gives rules `amount_minor`, `currency`, `counterparty`, `account_iban` and `environment`, and at checkout `reference`.
### Asking for less, or for more
As shipped, everything but looking asks for your password, every time. That is the secure setting, and changing it is a choice for whoever administers the machine, made with polkit rules in `/etc/polkit-1/rules.d/`.
- The actions are `net.catcrafts.Nostro1.View` (looking), `Pay`, `Change` (what changes something and pays nobody: a request for money, a draft, a scheduled payment cancelled, a request revoked or rejected, a draft rejected, a card frozen), `UnfreezeCard`, `BlockCard`, `Connectors` and `Checkout`.
- Each check gives rules what it is about: `amount_minor`, `currency`, `counterparty`, `account_iban` and `environment` for a payment, a draft or a request for money, `reference` at checkout, and `card` and `status` for a card.
- A rule cannot tell the Nostro app from any other program you run. What it lets pass without a password, it lets pass for all of them.
- A rule can also ask for more, such as an administrator's approval above an amount. Where one makes looking take a password, a payment asks twice, since nostrod looks an account up only for someone who may see it.
This rule lets one user freeze a card without a password, from their own desktop session, and leaves everything else as it is:
```js
// /etc/polkit-1/rules.d/50-nostro.rules
polkit.addRule(function(action, subject) {
if (action.id == "net.catcrafts.Nostro1.Change" && action.lookup("status") == "DEACTIVATED" &&
subject.user == "alice" && subject.local && subject.active) {
return polkit.Result.YES;
}
});
```
Without the test of `status` it would let every change of that action pass. Do not have a rule keep an authorization (`AUTH_SELF_KEEP`): for some minutes polkit then lets the same program through for that action whatever it asks next, which under `Pay` is a payment to someone else.
## License

View file

@ -31,8 +31,12 @@ using namespace Crafter;
namespace fs = std::filesystem;
// One user's worker. Every call is read and checked first (the account, the counterparty, what is to be paid), then
// polkit decides with a summary built from the worker's own data, and only then does the call run. The wire carries
// bunq's types, so the worker works with bunq's connector directly.
// polkit decides with a summary built from the worker's own data, and only then does the call run. On nostrod's own
// interface nothing of the user's is read, and the bank is asked nothing, for a caller polkit has not said yes to: a
// call that must look something up to word its question asks first whether the caller may see the accounts
// (HandleLookup). The checkout is the one that reads before it asks: an order it knows is answered from its record,
// and the account that pays a new one is chosen for the dialog to name (OnPay). The wire carries bunq's types, so the
// worker works with bunq's connector directly.
namespace {
using Work = std::function<void(sd_bus_message* reply)>;
@ -161,6 +165,13 @@ namespace {
} catch(const std::exception& e) {
message = e.what();
}
// The connector says which call went wrong, "bunq POST /user/…/monetary-account/…/payment: …", and that names
// the user and the account at the bank. An app at checkout never sees the account, so it is told what the bank
// said and whether the payment may have been made all the same, and not what was asked of the bank.
const std::size_t said = message.find(": ");
if(Interface(call) == Checkout::interfaceName && message.starts_with("bunq ") && said != std::string::npos) {
message.replace(0, said, "bunq");
}
return ErrorReply(call, name, message);
}
@ -168,16 +179,46 @@ namespace {
sd_bus_send(nullptr, answer.get(), nullptr);
}
// Text from a caller or a bank, made fit for a password dialog: no control, zero-width or direction-changing
// characters, nothing a dialog could take for markup or polkit for one of its $(…) fields, and at most 64
// characters, so a long name cannot push what matters out of sight.
std::string Shown(std::string_view text) {
std::string out;
std::size_t characters = 0;
// The most a password dialog shows of a name, a description or a reference, in characters; and of an address,
// which it shows whole: the longest an e-mail address gets.
constexpr std::size_t shownLimit = 64;
constexpr std::size_t addressLimit = 254;
using Range = std::pair<std::uint32_t, std::uint32_t>;
// What draws nothing, or tells the reader's own text where to go: control and format characters, the line and
// paragraph separators, what Unicode leaves out of a display by default (soft hyphens, joiners, fillers, variation
// selectors, tags), surrogates, private use, and what is no character at all.
constexpr std::array<Range, 31> unshown = {{
{0x0000, 0x001F}, {0x007F, 0x009F}, {0x00AD, 0x00AD}, {0x034F, 0x034F}, {0x0600, 0x0605}, {0x061C, 0x061C}, {0x06DD, 0x06DD}, {0x070F, 0x070F},
{0x0890, 0x0891}, {0x08E2, 0x08E2}, {0x115F, 0x1160}, {0x17B4, 0x17B5}, {0x180B, 0x180F}, {0x200B, 0x200F}, {0x2028, 0x202E}, {0x2060, 0x206F},
{0x3164, 0x3164}, {0xD800, 0xF8FF}, {0xFDD0, 0xFDEF}, {0xFE00, 0xFE0F}, {0xFEFF, 0xFEFF}, {0xFFA0, 0xFFA0}, {0xFFF0, 0xFFFC}, {0xFFFE, 0xFFFF},
{0x110BD, 0x110BD}, {0x110CD, 0x110CD}, {0x13430, 0x1343F}, {0x1BCA0, 0x1BCA3}, {0x1D173, 0x1D17A}, {0xE0000, 0xE0FFF}, {0xF0000, 0xFFFFFFFF},
}};
// A space of any width, and the Braille pattern without a dot, which is one to the eye.
constexpr std::array<Range, 8> blank = {{
{0x0020, 0x0020}, {0x00A0, 0x00A0}, {0x1680, 0x1680}, {0x2000, 0x200A}, {0x202F, 0x202F}, {0x205F, 0x205F}, {0x2800, 0x2800}, {0x3000, 0x3000},
}};
bool Among(std::span<const Range> ranges, std::uint32_t code) {
return std::ranges::any_of(ranges, [code](const Range& range) { return code >= range.first && code <= range.second; });
}
// Text from a caller or a bank, made fit for a password dialog, which is where the user reads what a password is
// for. Nothing of `unshown`, so no text hides, turns around or starts a line of its own; a space of any kind is one
// plain space, and none leads or trails, so none pushes what follows onto another line; nothing a dialog could take
// for markup, or polkit for one of its $(…) fields; and at most `limit` characters, so a long name cannot push what
// matters out of sight. An & goes with < and >: an agent that reads its message as Pango markup, as GNOME's older
// one and MATE's do, shows nothing at all of a message with a bare & in it, the amount included.
std::string Shown(std::string_view text, std::size_t limit = shownLimit) {
// Each character as it is shown, up to the first that does not fit, which is there to say that there is more.
std::vector<std::string_view> shown;
bool spaced = false;
std::size_t i = 0;
// The text is UTF-8: D-Bus carries nothing else, and nlohmann's parser takes nothing else from the bank. A
// sequence is still never read past the end.
while(i < text.size()) {
while(i < text.size() && shown.size() <= limit) {
const std::uint8_t lead = static_cast<std::uint8_t>(text[i]);
const std::size_t length = std::min<std::size_t>(lead < 0x80 ? 1 : lead < 0xE0 ? 2 : lead < 0xF0 ? 3 : 4, text.size() - i);
std::uint32_t code = length == 1 ? lead : lead & (0xFF >> (length + 1));
@ -186,25 +227,25 @@ namespace {
}
const std::string_view character = text.substr(i, length);
i += length;
const bool hidden = code < 0x20 || code == 0x7F || (code >= 0x80 && code < 0xA0) || (code >= 0x200B && code <= 0x200F) || (code >= 0x202A && code <= 0x202E) || (code >= 0x2060 && code <= 0x2069) || code == 0xFEFF;
if(hidden) {
if(Among(unshown, code)) {
continue;
}
if(characters == 64) {
if(Among(blank, code)) {
spaced = !shown.empty();
continue;
}
// The one space that stands for however many there were; and one that keeps a $ and a ( apart.
if(std::exchange(spaced, false) || (code == '(' && !shown.empty() && shown.back() == "$")) {
shown.emplace_back(" ");
}
shown.push_back(code == '<' ? "‹" : code == '>' ? "›" : code == '&' ? "+" : character);
}
std::string out;
for(const std::string_view piece : shown | std::views::take(limit)) {
out += piece;
}
if(shown.size() > limit) {
out += "…";
break;
}
characters++;
if(code == '<') {
out += "‹";
} else if(code == '>') {
out += "›";
} else {
if(code == '(' && out.ends_with('$')) {
out += ' ';
}
out += character;
}
}
return out;
}
@ -223,9 +264,21 @@ namespace {
throw std::invalid_argument(std::format("unknown environment '{}': production or sandbox", name));
}
// Who a caller wants paid or asked. The address is what decides where the money goes, so the dialog shows it whole
// and as it is, or the call is refused before anyone is asked: an address that would read otherwise there than it
// is (one with an & reads as one with a +, which is somebody else's) could have the user confirm a payment to
// someone they did not mean. A name is only made fit to show.
BunqCounterparty Counterparty(std::string_view value, std::string_view name) {
BunqCounterparty party = BunqCounterparty::Parse(value, name);
if(Shown(party.value, addressLimit) != party.value) {
throw std::invalid_argument(std::format("'{}' cannot be paid or asked through nostro: the password dialog would not show that address as it is, since it holds an &, a <, a > or a $(, something that draws nothing, or more than {} characters", Shown(party.value), addressLimit));
}
return party;
}
// Who is paid or asked, as a dialog shows it: the address first, so a long name cannot hide it.
std::string Party(const BunqCounterparty& party) {
return party.name.empty() ? Shown(party.value) : std::format("{} ({})", Shown(party.value), Shown(party.name));
return party.name.empty() ? Shown(party.value, addressLimit) : std::format("{} ({})", Shown(party.value, addressLimit), Shown(party.name));
}
std::string Party(const BunqLabel& label) {
@ -278,7 +331,7 @@ namespace {
return {
{"amount_minor", std::to_string(amount)},
{"currency", std::string(GetCurrencyCode(currency))},
{"counterparty", Shown(counterparty)},
{"counterparty", Shown(counterparty, addressLimit)},
{"account_iban", account.iban},
{"environment", std::string(EnvironmentName(account.connector->environment))},
};
@ -346,7 +399,8 @@ namespace {
throw std::invalid_argument(std::format("no account is called or has IBAN '{}'", key));
}
// The user's connectors, read on the first call: the first call also records whose directory this is.
// The user's connectors, read for the first call polkit says yes to, or the first new order at checkout: that call
// also records whose directory this is. Reading them refreshes each one's accounts, which asks the bank.
void Load(Worker& worker) {
if(worker.loaded) {
return;
@ -380,6 +434,8 @@ namespace {
MessagePtr call;
Work work;
After after;
// What a yes is followed by in place of an answer: the rest of a call that asked before it looked (HandleLookup).
std::function<void()> next;
std::string action;
bool interactive = false;
std::string cancellation;
@ -416,6 +472,13 @@ namespace {
Leave(reply);
Leave(reply);
if(authorized) {
// The connectors are read for a caller polkit said yes to, and for no other: reading them asks the bank.
Load(worker);
if(check->next) {
// The call goes on to its own question, and is answered through that one.
check->next();
return 0;
}
answer = Answer(call, check->work);
} else if(challenge && !check->interactive) {
answer = ErrorReply(call, SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED, std::format("{} needs your password, and the call did not let nostrod ask for it", check->action));
@ -435,10 +498,11 @@ namespace {
return 0;
}
// Asks polkit whether the caller may do what `prompt` says, then runs `work` and answers; or answers why not; and
// then runs `after` with the answer. The check does not block: other calls are served while a password dialog is
// open.
std::int32_t Gate(Worker& worker, sd_bus_message* call, const Prompt& prompt, Work work, After after = {}) {
// Asks polkit whether the caller may do what `prompt` says. On a yes it runs `next` when there is one, which
// answers the call itself, and else runs `work` and answers with what that appended; on anything else it answers
// why not. Then it runs `after` with the answer it gave. The check does not block: other calls are served while a
// password dialog is open.
std::int32_t Ask(Worker& worker, sd_bus_message* call, const Prompt& prompt, Work work, After after, std::function<void()> next) {
const bool interactive = sd_bus_message_get_allow_interactive_authorization(call) > 0;
sd_bus_message* raw = nullptr;
ThrowOnSdBus(sd_bus_message_new_method_call(worker.system.get(), &raw, "org.freedesktop.PolicyKit1", "/org/freedesktop/PolicyKit1/Authority", "org.freedesktop.PolicyKit1.Authority", "CheckAuthorization"), "ask polkit");
@ -472,7 +536,7 @@ namespace {
std::string cancellation = std::format("nostro-{}-{}", getpid(), ++worker.checks);
Append(raw, cancellation);
std::unique_ptr<Check> check = std::make_unique<Check>(&worker, MessagePtr(sd_bus_message_ref(call)), std::move(work), std::move(after), std::string(prompt.action), interactive, std::move(cancellation));
std::unique_ptr<Check> check = std::make_unique<Check>(&worker, MessagePtr(sd_bus_message_ref(call)), std::move(work), std::move(after), std::move(next), std::string(prompt.action), interactive, std::move(cancellation));
ThrowOnSdBus(sd_bus_call_async(worker.system.get(), nullptr, raw, OnChecked, check.get(), Microseconds(worker.options.promptTimeout)), "ask polkit");
// OnChecked owns it now.
check.release();
@ -480,7 +544,14 @@ namespace {
return 1;
}
// Runs `body` for `call`: it answers through Gate, or throws, and then the call is answered with the error.
// Asks polkit whether the caller may do what `prompt` says, then runs `work` and answers; or answers why not; and
// then runs `after` with the answer.
std::int32_t Gate(Worker& worker, sd_bus_message* call, const Prompt& prompt, Work work, After after = {}) {
return Ask(worker, call, prompt, std::move(work), std::move(after), {});
}
// Runs `body` for `call`: it answers through Gate, or throws, and then the call is answered with the error. Nothing
// of the user's is read here: a body reads its arguments and asks polkit, and what it then does runs after a yes.
template<typename Body>
std::int32_t Handle(sd_bus_message* call, void* userdata, Body&& body) {
Worker& worker = *static_cast<Worker*>(userdata);
@ -489,7 +560,6 @@ namespace {
if(worker.refusal) {
throw Refused(*worker.refusal);
}
Load(worker);
return body(worker);
} catch(...) {
Deliver(ErrorFor(call, std::current_exception()));
@ -497,6 +567,21 @@ namespace {
}
}
// Runs `body` for a call that names something of the user's (an account, a card, a request, a draft, a connector)
// and is not a call to see it. Such a call's own question to polkit is worded from what was found, so the body
// looks it up first; and whether it is there is the user's to know, and finding it can take a question to the
// bank. Both are for a caller who may see the user's accounts: polkit is asked that first, as `seen` words it,
// and `body` runs on its yes. An active session has that yes without a dialog, as shipped; where seeing takes a
// password, such a call asks for it twice, once to look and once to act.
template<typename Body>
std::int32_t HandleLookup(sd_bus_message* call, void* userdata, std::string_view seen, Body body) {
return Handle(call, userdata, [call, seen, &body](Worker& worker) {
return Ask(worker, call, Prompt{actionView, std::string(seen), {}}, {}, {}, [&worker, body = std::move(body)] {
body(worker);
});
});
}
std::int32_t OnConnectors(sd_bus_message* call, void* userdata, sd_bus_error*) {
return Handle(call, userdata, [call](Worker& worker) {
return Gate(worker, call, Prompt{actionView, "see your bank connectors", {}}, [](sd_bus_message* reply) {
@ -551,7 +636,7 @@ namespace {
}
std::int32_t OnRemoveConnector(sd_bus_message* call, void* userdata, sd_bus_error*) {
return Handle(call, userdata, [call](Worker& worker) {
return HandleLookup(call, userdata, "see your bank connectors", [call](Worker& worker) {
const std::string key = Read<std::string>(call);
// By name, or by the number Connectors() lists it under.
std::vector<BunqConnector*> matches;
@ -598,9 +683,10 @@ namespace {
return Handle(call, userdata, [call](Worker& worker) {
const std::string account = Read<std::string>(call);
const TransactionQuery query = ReadQuery(call);
const AccountKey key = KeyOf(FindAccount(account));
return Gate(worker, call, Prompt{actionView, "see your transactions", {}}, [key, query](sd_bus_message* reply) {
BunqAccount& found = AccountBy(key);
// The account is looked up once polkit has said yes: whether there is one of that name is for a caller who
// may see the accounts, and finding it can take a question to the bank.
return Gate(worker, call, Prompt{actionView, "see your transactions", {}}, [account, query](sd_bus_message* reply) {
BunqAccount& found = FindAccount(account);
// What is new at the bank first: a call to it, which takes its time and which it counts. Not for a
// question about what is stored alone, as a search in a list just given is: that is answered at once.
if(!query.stored) {
@ -631,11 +717,11 @@ namespace {
};
std::int32_t OnSend(sd_bus_message* call, void* userdata, sd_bus_error*) {
return Handle(call, userdata, [call](Worker& worker) {
return HandleLookup(call, userdata, "see your accounts and balances", [call](Worker& worker) {
const Payment payment = Payment::Read(call);
const BunqAccount& account = FindAccount(payment.account);
RequirePositive(payment.amount);
const BunqCounterparty payee = BunqCounterparty::Parse(payment.counterparty, payment.name);
const BunqCounterparty payee = Counterparty(payment.counterparty, payment.name);
const Prompt prompt{actionPay, std::format("pay {} to {} from {}", FormatMoney(payment.amount, account.currency), Party(payee), Party(account)), PaymentDetails(account, payment.amount, account.currency, payee.value)};
return Gate(worker, call, prompt, [key = KeyOf(account), payment](sd_bus_message* reply) {
const BunqAccount& found = AccountBy(key);
@ -656,13 +742,13 @@ namespace {
}
std::int32_t OnSchedule(sd_bus_message* call, void* userdata, sd_bus_error*) {
return Handle(call, userdata, [call](Worker& worker) {
return HandleLookup(call, userdata, "see your accounts and balances", [call](Worker& worker) {
const Payment payment = Payment::Read(call);
const BunqSchedule schedule = Read<BunqSchedule>(call);
const BunqAccount& account = FindAccount(payment.account);
RequirePositive(payment.amount);
schedule.Check();
const BunqCounterparty payee = BunqCounterparty::Parse(payment.counterparty, payment.name);
const BunqCounterparty payee = Counterparty(payment.counterparty, payment.name);
const Prompt prompt{actionPay, std::format("schedule {} to {} from {}, {}", FormatMoney(payment.amount, account.currency), Party(payee), Party(account), When(schedule)), PaymentDetails(account, payment.amount, account.currency, payee.value)};
return Gate(worker, call, prompt, [key = KeyOf(account), payment, schedule](sd_bus_message* reply) {
const BunqAccount& found = AccountBy(key);
@ -673,11 +759,11 @@ namespace {
}
std::int32_t OnRequest(sd_bus_message* call, void* userdata, sd_bus_error*) {
return Handle(call, userdata, [call](Worker& worker) {
return HandleLookup(call, userdata, "see your accounts and balances", [call](Worker& worker) {
const Payment payment = Payment::Read(call);
const BunqAccount& account = FindAccount(payment.account);
RequirePositive(payment.amount);
const BunqCounterparty payer = BunqCounterparty::Parse(payment.counterparty, payment.name);
const BunqCounterparty payer = Counterparty(payment.counterparty, payment.name);
const Prompt prompt{actionChange, std::format("ask {} for {} into {}", Party(payer), FormatMoney(payment.amount, account.currency), Party(account)), PaymentDetails(account, payment.amount, account.currency, payer.value)};
return Gate(worker, call, prompt, [key = KeyOf(account), payment](sd_bus_message* reply) {
const BunqAccount& found = AccountBy(key);
@ -690,9 +776,10 @@ namespace {
template<typename List>
std::int32_t Listing(sd_bus_message* call, void* userdata, std::string_view what, List list) {
return Handle(call, userdata, [call, what, list](Worker& worker) {
const AccountKey key = KeyOf(FindAccount(Read<std::string>(call)));
return Gate(worker, call, Prompt{actionView, std::format("see your {}", what), {}}, [key, list](sd_bus_message* reply) {
Append(reply, list(AccountBy(key)));
const std::string account = Read<std::string>(call);
// Looked up once polkit has said yes, as in OnTransactions.
return Gate(worker, call, Prompt{actionView, std::format("see your {}", what), {}}, [account, list](sd_bus_message* reply) {
Append(reply, list(FindAccount(account)));
});
});
}
@ -716,7 +803,7 @@ namespace {
// Revoking a request or cancelling a schedule: a change to one object of one account.
template<typename Act>
std::int32_t Undo(sd_bus_message* call, void* userdata, std::string_view what, Act act) {
return Handle(call, userdata, [call, what, act](Worker& worker) {
return HandleLookup(call, userdata, "see your accounts and balances", [call, what, act](Worker& worker) {
const BunqAccount& account = FindAccount(Read<std::string>(call));
const std::uint64_t id = Read<std::uint64_t>(call);
const Prompt prompt{actionChange, std::format("{} {} of {}", what, id, Party(account)), {}};
@ -735,7 +822,7 @@ namespace {
}
std::int32_t OnRespondToRequest(sd_bus_message* call, void* userdata, sd_bus_error*) {
return Handle(call, userdata, [call](Worker& worker) {
return HandleLookup(call, userdata, "see your incoming requests for money", [call](Worker& worker) {
const BunqAccount& account = FindAccount(Read<std::string>(call));
const std::uint64_t id = Read<std::uint64_t>(call);
const bool accept = Read<bool>(call);
@ -751,11 +838,11 @@ namespace {
}
std::int32_t OnDraft(sd_bus_message* call, void* userdata, sd_bus_error*) {
return Handle(call, userdata, [call](Worker& worker) {
return HandleLookup(call, userdata, "see your accounts and balances", [call](Worker& worker) {
const Payment payment = Payment::Read(call);
const BunqAccount& account = FindAccount(payment.account);
RequirePositive(payment.amount);
const BunqCounterparty payee = BunqCounterparty::Parse(payment.counterparty, payment.name);
const BunqCounterparty payee = Counterparty(payment.counterparty, payment.name);
const Prompt prompt{actionChange, std::format("make a draft payment of {} to {} from {}, paid once someone accepts it", FormatMoney(payment.amount, account.currency), Party(payee), Party(account)), PaymentDetails(account, payment.amount, account.currency, payee.value)};
return Gate(worker, call, prompt, [key = KeyOf(account), payment](sd_bus_message* reply) {
const BunqAccount& found = AccountBy(key);
@ -766,7 +853,7 @@ namespace {
}
std::int32_t OnRespondToDraftPayment(sd_bus_message* call, void* userdata, sd_bus_error*) {
return Handle(call, userdata, [call](Worker& worker) {
return HandleLookup(call, userdata, "see your draft payments", [call](Worker& worker) {
const BunqAccount& account = FindAccount(Read<std::string>(call));
const std::uint64_t id = Read<std::uint64_t>(call);
const bool accept = Read<bool>(call);
@ -805,7 +892,7 @@ namespace {
}
std::int32_t OnSetCardStatus(sd_bus_message* call, void* userdata, sd_bus_error*) {
return Handle(call, userdata, [call](Worker& worker) {
return HandleLookup(call, userdata, "see your cards", [call](Worker& worker) {
const std::uint64_t card = Read<std::uint64_t>(call);
const std::string status = Read<std::string>(call);
// Unfreezing lets the card pay again; a card reported lost or stolen is blocked for good.
@ -872,7 +959,7 @@ namespace {
}
std::int32_t OnSetDefaultCheckoutAccount(sd_bus_message* call, void* userdata, sd_bus_error*) {
return Handle(call, userdata, [call](Worker& worker) {
return HandleLookup(call, userdata, "see your accounts and balances", [call](Worker& worker) {
const BunqAccount& account = FindAccount(Read<std::string>(call));
// bunq lets an OAuth connection pay the user's own accounts only, so through one no shop could be paid.
if(account.connector->IsOAuth()) {
@ -926,10 +1013,11 @@ namespace {
}
};
// One reference to one payee is one order, of one amount.
// One reference to one payee is one order, of one amount. Which amount the order has is not said: any app that
// knows the payee and the reference of an order another app had paid would learn from it what was paid for it.
void RequireSameOrder(std::int64_t amount, Currency currency, const Order& order) {
if(amount != order.amount || currency != order.currency) {
throw std::invalid_argument(std::format("reference {} to {} is an order of {}, not of {}: another order needs another reference", Shown(order.reference), order.payee.value, FormatMoney(amount, currency), FormatMoney(order.amount, order.currency)));
throw std::invalid_argument(std::format("reference {} to {} is an order of another amount than {}: another order needs another reference", Shown(order.reference), order.payee.value, FormatMoney(order.amount, order.currency)));
}
}
@ -1026,6 +1114,9 @@ namespace {
if(AnswerKnownOrder(worker, call, order)) {
return 1;
}
// The account that pays is chosen before the user is asked, since the dialog names it: an order not seen
// before has the connectors read for it, which no call of nostrod's own interface does before polkit's yes.
Load(worker);
// From here on, a call for the same order waits for this one, and Settle answers it.
worker.paying[order.Key()] = Paying{order.amount, order.currency, {}};
ChooseAccount(worker, call, order, [&worker, call, order](const Choice& choice) {

View file

@ -123,7 +123,7 @@ namespace Nostro::App {
template<typename T>
void App::Change(Operation operation, std::string member, std::string title, std::string account, std::function<Client::Pending(Client&, Client::Then<T>)> start, std::function<void(T&)> done) {
Wait(operation, std::move(title));
Wait(std::move(title));
try {
Client& bank = Nostrod();
changing = true;
@ -154,13 +154,14 @@ namespace Nostro::App {
}
}
// The wait for a change's answer, which is where the user confirms it when it needs their password.
void App::Wait(Operation operation, std::string title) {
// The wait for a change's answer, which is where the user confirms it: as nostro is shipped, every change asks for
// their password. Where an administrator's rule lets one pass, the answer is there before this is read.
void App::Wait(std::string title) {
Dialog working;
working.kind = Dialog::Kind::Working;
working.name = "working";
working.title = std::move(title);
working.text = {AsksPassword(operation) ? "Confirm it in your system's password dialog." : "One moment."};
working.text = {"Confirm it in your system's password dialog."};
Show(std::move(working));
}
@ -623,9 +624,9 @@ namespace Nostro::App {
Push(Page::Request);
}
// The pay form's button: what is filled in is checked, and sent. The app asks nothing more itself: a payment is
// confirmed in the system's password dialog, which nostrod words from its own data, and a draft is not paid until
// it is accepted, which is confirmed there too.
// The pay form's button: what is filled in is checked, and sent. The app asks nothing more itself: a payment, a
// schedule and a draft are each confirmed in the system's password dialog, which nostrod words from its own data,
// and a draft is not paid until it is accepted, which is confirmed there once more.
void App::SubmitPayment() {
payment.tried = true;
context.Invalidate();
@ -674,7 +675,11 @@ namespace Nostro::App {
}
}
void App::ReviewRequest() {
// The request form's button: what is filled in is checked, and sent, as the pay form's is. The app asks nothing
// more itself: a request is confirmed in the system's password dialog, which nostrod words from its own data (who
// is asked, for how much, and into which account). Until 2026-11-19 a request needed no password, and the app
// showed it for review first; with the dialog that would be a second confirmation of what the dialog confirms.
void App::SubmitRequest() {
request.tried = true;
context.Invalidate();
const std::optional<AccountRef> into = Find(requestInto);
@ -682,22 +687,7 @@ namespace Nostro::App {
if(!into || request.Check(into->account->currency, order).Any()) {
return;
}
const Currency currency = into->account->currency;
const std::string money = Money(order.amount, currency);
Dialog ask;
ask.kind = Dialog::Kind::Ask;
ask.name = "review";
ask.title = std::format("Ask {} for {}?", PartyName(order.from), money);
ask.lines.push_back({"Into", std::format("{} · {}", into->account->name, GroupIban(into->account->iban))});
ask.lines.push_back({"From", order.from.name.empty() ? GroupIban(order.from.value) : std::format("{} · {}", order.from.name, GroupIban(order.from.value))});
ask.lines.push_back({"Amount", money});
if(!order.description.empty()) {
ask.lines.push_back({"Description", order.description});
}
ask.text.push_back("Your bank asks them where it can reach them, and gives you a link to pay through where it has one.");
ask.choices.push_back({"review.confirm", "Ask", Ui::ButtonKind::Filled, true, {}, [this, key = into->key, currency, order] { SendRequest(key, currency, order); }});
ask.choices.push_back({"review.back", "Back", Ui::ButtonKind::Plain, true, {}, [this] { Close(); }});
Show(std::move(ask));
SendRequest(into->key, into->account->currency, order);
}
void App::SendRequest(const std::string& key, Currency currency, const RequestOrder& order) {
@ -778,9 +768,7 @@ namespace Nostro::App {
if(!detail.empty()) {
ask.text.push_back(std::move(detail));
}
if(AsksPassword(operation)) {
ask.text.push_back("Your system asks for your password to confirm it.");
}
ask.choices.push_back({"confirm.yes", std::move(confirm), MovesMoney(operation) ? Ui::ButtonKind::Filled : Ui::ButtonKind::Danger, true, {}, [this, operation, member = std::move(member), question, told = std::move(told), account = std::move(account), start = std::move(start)] {
Change<std::monostate>(operation, member, question, account, start, [this, operation, told, account](std::monostate&) {
if(MovesMoney(operation)) {

View file

@ -31,11 +31,6 @@ std::string_view App::ActionOf(Operation operation) noexcept {
}
}
bool App::AsksPassword(Operation operation) noexcept {
const std::string_view action = ActionOf(operation);
return action != Bus::actionView && action != Bus::actionChange;
}
bool App::MovesMoney(Operation operation) noexcept {
return ActionOf(operation) == Bus::actionPay;
}

View file

@ -4,6 +4,7 @@
module Nostro.App:Format_impl;
import std;
import Nostro;
import Nostro.Ui;
import :Format;
using namespace Nostro;
@ -197,12 +198,19 @@ std::string App::ScheduleLabel(const BunqSchedule& schedule, std::chrono::system
}
std::string App::Fingerprint(std::string_view secret) {
// Too short to show a part of without showing most of it.
if(secret.size() < 16) {
return "••••";
}
// Up to its first underscore, which is where a bunq key says what it is for ("sandbox_"), or its first four.
const std::size_t characters = Ui::CountCodepoints(secret);
const std::string length = characters == 1 ? std::string("1 character") : std::format("{} characters", characters);
// How it begins: up to its first underscore, which is where a bunq key says what it is for ("sandbox_"), and the
// four characters after that. Never how it ends: the end of what is in the field is what was typed last, so
// showing it would show every character of a key typed by hand, one after the other, to whoever watches.
const std::size_t mark = secret.find('_');
const std::string_view start = mark != std::string_view::npos && mark < 12 ? secret.substr(0, mark + 1) : secret.substr(0, 4);
return std::format("{}…{}", start, secret.substr(secret.size() - 4));
std::size_t begins = mark != std::string_view::npos && mark < 12 ? mark + 1 : 0;
for(std::size_t i = 0; i < 4; i++) {
begins = Ui::NextCodepoint(secret, begins);
}
// Too short to show a part of without showing most of it.
if(Ui::CountCodepoints(secret.substr(begins)) < 12) {
return length;
}
return std::format("{}… {}", secret.substr(0, begins), length);
}

View file

@ -511,7 +511,10 @@ namespace Nostro::App {
column.Advance(TextField(frame, Padded(frame, column.Next()), request.name, {.key = "request.name", .label = "Name", .placeholder = "Who is asked", .error = errors.name, .purpose = TextPurpose::Name}));
column.Advance(TextField(frame, Padded(frame, column.Next()), request.amount, {.key = "request.amount", .label = "Amount", .prefix = std::string(GetCurrencySymbol(currency)), .error = errors.amount}));
column.Advance(TextField(frame, Padded(frame, column.Next()), request.description, {.key = "request.description", .label = "Description", .placeholder = "What it is for"}));
Button(frame, Padded(frame, column.Take(frame.Dp(Size::control))), {.key = "request.review", .label = "Review", .enabled = into.has_value(), .onTap = [this] { ReviewRequest(); }});
column.Advance(Paragraph(frame, Padded(frame, column.Next()), "Your bank asks them where it can reach them, and gives you a link to pay through where it has one.", Muted(frame)));
// It sends what is filled in, and is named for that, as the pay form's button is: the system's password dialog
// is what confirms a request.
Button(frame, Padded(frame, column.Take(frame.Dp(Size::control))), {.key = "request.submit", .label = "Ask", .enabled = into.has_value(), .onTap = [this] { SubmitRequest(); }});
}
void App::CardsPage(Ui::Frame& frame, Ui::Column& column, Ui::Box viewport) {
@ -619,7 +622,7 @@ namespace Nostro::App {
void App::AboutPage(Ui::Frame& frame, Ui::Column& column) {
static constexpr std::array<std::string_view, 5> said = {
"Nostro is a banking client for Linux, phones first. It talks to your bank directly.",
"Programs you run cannot read your bank connections, which belong to a service of Nostro's own, and cannot move money without your password. This window is one of those programs: it holds no key and no token.",
"Programs you run cannot read your bank connections, which belong to a service of Nostro's own, and cannot pay or change anything at your bank without your password. What they can do is look at your accounts and payments. This window is one of those programs: it holds no key and no token.",
"The password dialog is your desktop's. A program running as you could draw one that looks the same, so type your password only for something you asked for, and read what the dialog says.",
"In a session where nothing can ask for your password, whatever needs it is refused.",
"The bank connections are not encrypted on disk: whoever holds the disk can read them. Use full-disk encryption.",

View file

@ -28,7 +28,7 @@ namespace {
<account> is an account's name or IBAN. <to> and <from> are an IBAN, an e-mail address, or a phone number
starting with +. Amounts are in the smallest unit of the account's currency: 1250 is 12.50. Dates are
YYYY-MM-DD or "YYYY-MM-DD hh:mm", in local time. A sandbox API key is recognised by its prefix.
nostrod does the work, and asks for your password before anything that moves money, a checkout included.)";
nostrod does the work, and asks for your password before it pays or changes anything, a checkout included.)";
// Positional arguments, with "--name value" options (and the "--sandbox" and "--help" flags) taken out wherever they are.
struct Arguments {

View file

@ -19,10 +19,11 @@ import :Errors;
// The rules that keep a bank's client honest are here. A press acts on what it went down on, and every action names
// what it is about by value: an IBAN or the bank's id, never a place in a list. One change at a time: while one is
// under way its sheet covers the screen, so nothing else can be asked for and nothing is sent twice. A payment from
// the form is sent by the form's own button, with no question of the app's before it: what confirms it is the system's
// password dialog, which nostrod words itself. What the app does ask about first (a request to send, a request or a
// draft to accept, a card to report) it shows built from the same values that are then sent. And an answer that leaves
// open whether money moved says so, and offers no button to try again.
// the form, and a request for money from its form, is sent by the form's own button, with no question of the app's
// before it: what confirms it is the system's password dialog, which nostrod words itself and which every change
// meets, as nostro is shipped. What the app does ask about first is what one press on a sheet would do (a request or a
// draft to accept or reject, a schedule to cancel, a card to report), and it shows that built from the same values that
// are then sent. And an answer that leaves open whether money moved says so, and offers no button to try again.
//
// Which bank an account is with makes no difference to any of it. A bank's own is in two places: what :Banks says of
// it, and the forms a connection to it is made with, which are the last pages of adding a connection in the settings
@ -220,7 +221,7 @@ export namespace Nostro::App {
template<typename T>
void Change(Operation operation, std::string member, std::string title, std::string account, std::function<Client::Pending(Client&, Client::Then<T>)> start, std::function<void(T&)> done);
void Failed(const Guidance& guidance, Operation operation, const std::string& account);
void Wait(Operation operation, std::string title);
void Wait(std::string title);
void Refresh(bool again = false);
void LoadAccounts(std::vector<ConnectorSummary> summaries, bool again);
@ -252,7 +253,7 @@ export namespace Nostro::App {
void OpenRequest(std::string account);
void SubmitPayment();
void SendPayment(const std::string& key, Currency currency, const PaymentOrder& order);
void ReviewRequest();
void SubmitRequest();
void SendRequest(const std::string& key, Currency currency, const RequestOrder& order);
void ShowTransaction(const std::string& key, const Transaction& transaction);
void ShowRequest(const std::string& key, const BunqPaymentRequest& request);

View file

@ -11,7 +11,8 @@ import Nostro;
// which a listing that got none never is.
export namespace Nostro::App {
// What nostrod is asked to do, as far as that decides whether it asks for a password and what an error to it means.
// What nostrod is asked to do, as far as that decides which polkit action it is checked for and what an error to
// it means.
enum class Operation : std::uint8_t {
Load, // any reading: accounts, payments, cards
Send,
@ -32,12 +33,11 @@ export namespace Nostro::App {
SetCheckoutAccount
};
// The polkit action nostrod checks before it does that (Bus::action…).
// The polkit action nostrod checks before it does that (Bus::action…). By the policy nostro installs the system
// asks for the user's password before every one of them but View, which is Load's alone: so every change is
// confirmed in the system's dialog, and the app says so of each without asking which. An administrator's rules may
// ask for less.
std::string_view ActionOf(Operation operation) noexcept;
// Whether the system asks for the user's password before it, by the policy nostro installs: in the user's own
// session only what moves money, unfreezes or blocks a card, or changes the connections. An administrator's rules
// may ask for more or less; this decides nothing but what the user is told to expect.
bool AsksPassword(Operation operation) noexcept;
// Whether money leaves an account by it.
bool MovesMoney(Operation operation) noexcept;

View file

@ -48,6 +48,7 @@ export namespace Nostro::App {
// When a scheduled payment runs: "Once on 3 Nov", "Every 2 weeks from 3 Nov until 1 Jan 2027".
std::string ScheduleLabel(const BunqSchedule& schedule, std::chrono::system_clock::time_point now);
// A secret said without saying it: how it begins and its last four characters, enough to tell two keys apart.
// A secret said without saying it: how it begins and how long it is ("sandbox_ab12… 64 characters"), enough to
// tell two keys apart and to see that all of one arrived. One too short for that is said by its length alone.
std::string Fingerprint(std::string_view secret);
}

View file

@ -9,11 +9,15 @@
Every call is answered for the calling user only, and authorised with polkit first
(packaging/system/net.catcrafts.Nostro1.policy): allow interactive authorization on your calls, so the user can be
asked for their password, and give them a timeout of minutes. Every reply ends with `notes`, the warnings the
library gave during the call, to show the user.
library gave during the call, to show the user. A call that names an account, a card, a request, a draft or a
connector, and is not a call to see it, is authorised twice: to see the accounts (the View action), before
nostrod looks up what the call names, and then for what the call does.
Conventions:
account an account's name or IBAN
to, from an IBAN, an e-mail address, or a phone number starting with +
to, from an IBAN, an e-mail address, or a phone number starting with +. The password dialog shows it whole
and as it is, so an e-mail address it could not show so is refused (InvalidArgument): one with
&, < or > in it, with a character that draws nothing, or longer than 254 characters
amount in the currency's smallest unit (1250 is 12.50), positive; balances and transactions are negative
when money goes out
currency an ISO code: "EUR"

View file

@ -17,7 +17,7 @@
</p>
<p>
This is the app. It holds no key of yours: your bank connections are kept by Nostro's service, where no program
you run can read them, and your system asks for your password before anything moves money. The service,
you run can read them, and your system asks for your password before anything is paid or changed. The service,
net.catcrafts.Nostrod, is installed for the whole system together with a few system files; Nostro's README says
how.
</p>

View file

@ -14,7 +14,7 @@
Nostro talks to your bank's API directly: accounts, transactions, payments, requests, schedules, draft payments
and cards, for bunq so far. Its daemon, nostrod, runs as a system user of its own and keeps every local user's
bank connections where no program of theirs can read them; the nostro command and the Nostro app ask it over the
system bus, and your password is asked for before anything moves money.
system bus, and your password is asked for before anything is paid or changed.
</p>
<p>
Apps can have Nostro pay an order at checkout, from an account you chose, once you have confirmed the payment.

View file

@ -9,8 +9,11 @@ The service with the nostro command (net.catcrafts.Nostrod):
its permissions to). The Crafter libraries linked in statically are under
the same licence: Crafter.Network with Crafter.Thread, and Crafter.DB.
Their source: https://forgejo.catcrafts.net/Catcrafts/<name>.
- nlohmann-json-MIT.txt: nlohmann/json 3.12.0, which Nostro carries
(lib/json.hpp) and compiles in.
- nlohmann-json-MIT.txt: nlohmann/json, which Nostro carries unchanged
(lib/json.hpp) and compiles in: its single header as the development
branch had it on 2026-09-25, after release 3.12.0, at commit
95e9a5931c828cd7306eff36090a5b38e0e3f598 of
https://github.com/nlohmann/json.
- LLVM-LICENSE.TXT: LLVM's libc++, libc++abi and libunwind in /app/lib
(the Apache License 2.0 with LLVM Exceptions, and for older code the
University of Illinois/NCSA licence).

View file

@ -8,13 +8,24 @@
Every action is owned by unix-user:nostro, the user nostrod runs as: polkit lets only root or an action's owner
check a call made by another user, or pass the details the dialog shows. $(summary) is what nostrod read for the
call itself, such as the amount, the payee and the account of a payment; the details amount_minor, currency,
counterparty, account_iban, environment and, at checkout, reference are there for rules (an amount above which an
administrator must approve, say).
counterparty, account_iban, environment, at checkout reference, and for a card card (its id) and status (ACTIVE,
DEACTIVATED, LOST or STOLEN) are there for rules (an amount above which an administrator must approve, say).
No action keeps an authorization: polkit ties a kept one to the calling process, so the CLI would ask every time
anyway. Viewing and the changes that move no money are free in an active session; whatever moves money (an app's
checkout included), unfreezes or blocks a card, or changes the bank connections or the account checkouts pay from
asks for the user's password every time.
anyway. Viewing is free in an active session, and nothing else is. Whatever pays (an app's checkout included),
whatever changes anything at the bank (a request for money, a draft, a schedule cancelled, a card frozen), and
whatever changes the bank connections or the account checkouts pay from asks for the user's password every time.
That is the default, and it is the strict one on purpose: no program of the user's does anything at their bank
without them. Loosening it is an administrator's choice, made with a rule, and polkit cannot tell one program of
a user's from another, so a rule that lets an action pass lets it pass for all of them. A rule that lets a card
be frozen without a password, for one, returns polkit.Result.YES for the action Change when
action.lookup("status") is "DEACTIVATED".
A call that names an account, a card, a request, a draft or a connector, and is not a call to see it, is checked
twice: for View, before nostrod looks up what it names, and then for what it does. A caller who may not see the
accounts so learns nothing of them by trying to change them. Where a rule makes View ask for a password, such a
call asks for it twice.
Install: /usr/share/polkit-1/actions/net.catcrafts.Nostro1.policy. Tune with rules in /etc/polkit-1/rules.d/. -->
<policyconfig>
@ -37,7 +48,7 @@
<defaults>
<allow_any>auth_self</allow_any>
<allow_inactive>auth_self</allow_inactive>
<allow_active>yes</allow_active>
<allow_active>auth_self</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.owner">unix-user:nostro</annotate>
</action>

View file

@ -3,7 +3,7 @@
# SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
#
# The nostro command: the CLI from the net.catcrafts.Nostrod Flatpak, run as you. It asks nostrod over the system bus,
# and your session's polkit agent asks for your password before anything moves money. Install: /usr/bin/nostro (a
# and your session's polkit agent asks for your password before anything is paid or changed. Install: /usr/bin/nostro (a
# package) or /usr/local/bin/nostro (install.sh).
# Before nostrod, nostro kept the bank's secrets in the user's own home, where every program they run can read them.

View file

@ -3,7 +3,10 @@
import std;
import Crafter.Build;
#pragma crafter dependency "https://forgejo.catcrafts.net/Catcrafts/Crafter.LintRules.git"
// Every dependency is named at a commit: a build runs each one's own project.cpp and links its code into the program
// that holds every user's bank keys, so what is built is what was built and tested here, not what a branch has come to
// since. Moving one forward is a change to this file, made with the tests run again. See also networkCommit below.
#pragma crafter dependency "https://forgejo.catcrafts.net/Catcrafts/Crafter.LintRules.git" commit "7d932892017800b4e1f1a15fe7aa49b3daee9ceb"
import Crafter.LintRules;
// What puts Crafter.Debug into the app under --debug-api, and into no other build.
#pragma crafter dependency "https://forgejo.catcrafts.net/Catcrafts/Crafter.Debug.git" commit "98e92c1976f32c6f9beb6ea38a0522a3bbdabed7" project "tooling/project.cpp"
@ -271,13 +274,20 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
if(!debugApi) {
networkArgs.emplace_back("--no-quic");
}
// The commits nostro is built and tested against (see the pragmas at the top). The app's debug build is the one
// that follows Crafter.Network's branch: Crafter.Debug names it without a commit, and crafter-build refuses a
// program that would hold two builds of one module ("module Crafter.Network is built twice"). That build is for
// the made-up system and the sandbox, and is not packaged. Crafter.Thread comes with Crafter.Network, whose own
// project file names it without a commit.
constexpr std::string_view networkCommit = "79a2f126292755142f22f7d109f38d52067f5449";
constexpr std::string_view dbCommit = "38c9076e1df71d9beebc95deded65d827b802f3d";
Configuration* network = GitProject({
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Network.git" },
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Network.git", .commit = debugApi ? std::string() : std::string(networkCommit) },
.args = networkArgs,
});
Configuration* db = GitProject({
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.DB.git" },
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.DB.git", .commit = std::string(dbCommit) },
.args = depArgs,
});

View file

@ -404,7 +404,8 @@ namespace {
Shows(d.ui, "The API key, from the bunq app", "a form without a key says so");
Equal(d.app.Screen(), std::string("add:bunq:key"), "and asks nostrod nothing");
Type(d, "key.key", aliceKey);
Shows(d.ui, std::format("Typed: {}", Fingerprint(aliceKey)), "what was typed is told by how it begins and ends");
Shows(d.ui, std::format("Typed: {}", Fingerprint(aliceKey)), "what was typed is told by how it begins and how long it is");
Hides(d.ui, aliceKey.substr(aliceKey.size() - 4), "and not by how it ends, which is what was typed last");
Hides(d.ui, aliceKey, "and never shown");
Hides(d.ui, "The API key, from the bunq app", "the error goes once there is a key");
Check(!Has(d, "key.ips"), "the allowed addresses are tucked away");
@ -540,9 +541,20 @@ namespace {
Shows(d.ui, "Bob's", "and what is shown is what there is");
// And once more while they are read again: the reading gives up, and says so.
before = Answers(d, "Connectors ok");
const auto viewChecks = [&bus] {
std::lock_guard lock(bus.mutex);
return std::ranges::count_if(bus.checks, [](const Fake::PolkitCheck& check) { return check.action == Bus::actionView; });
};
const std::ptrdiff_t viewed = viewChecks();
Tap(d, "bar.refresh");
Check(RunUntil(d.loop, [&d, before] { return Answers(d, "Connectors ok") > before; }), "the connections are read");
// Removing a connection looks it up first, for which nostrod asks polkit whether the caller may see: that is
// answered at once here, once the app's reading of the accounts is at polkit, which answers that a second
// later whatever it is set to meanwhile.
Check(RunUntil(d.loop, [&viewChecks, viewed] { return viewChecks() >= viewed + 2; }), "and the accounts are being read");
SetPolkit(bus, Fake::Polkit::Allow, Bus::actionView);
other.RemoveConnector("Bob");
SetPolkit(bus, Fake::Polkit::Slow, Bus::actionView);
Check(RunUntil(d.loop, [&d, before] { return Answers(d, "Connectors ok") > before + 1; }), "and read again");
other.AddBunq("key-bob", "*", "");
Settle(d);
@ -839,7 +851,7 @@ namespace {
Equal(Action(bus), std::string(Bus::actionPay), "after the password for paying");
Press(d, "done.close");
// A draft: made now, paid once someone accepts it, and no password for making it.
// A draft: made now, paid once someone accepts it. Making one is a change, and is confirmed like any.
Tap(d, "home.pay");
Type(d, "pay.to", "+31612345678");
Shows(d.ui, "Phone number", "a phone number is known for one");
@ -849,8 +861,8 @@ namespace {
Bottom(d);
Equal(d.ui.Find("pay.submit")->label, std::string("Save as draft"), "and the button says that it saves one");
Tap(d, "pay.submit");
Shows(d.ui, "Saving a draft of €2.00 to +31612345678", "a draft is saved at once");
Shows(d.ui, "One moment.", "and needs no password, so the wait says nothing of one");
Shows(d.ui, "Saving a draft of €2.00 to +31612345678", "a draft is saved from the form's button, with no question of the app's before it");
Shows(d.ui, "Confirm it in your system's password dialog.", "and confirmed where every change is");
Settle(d);
Shows(d.ui, "Drafted €2.00 to +31612345678", "and is made");
Shows(d.ui, "It is paid once it is accepted", "with what that means");
@ -901,24 +913,30 @@ namespace {
const std::string page = std::format("account:{}", aliceMain);
Tap(d, "home.request");
Equal(d.app.Screen(), std::string("request"), "asking starts from the accounts");
Tap(d, "request.review");
Bottom(d);
Shows(d.ui, "Your bank asks them where it can reach them", "what asking does is said on the form");
const Region* submit = d.ui.Find("request.submit");
Check(submit != nullptr && submit->label == "Ask", "whose button is named for what it does");
Tap(d, "request.submit");
Shows(d.ui, "Enter an amount", "a form that is empty says what it lacks");
Equal(d.app.Screen(), std::string("request"), "and asks nostrod nothing");
Top(d);
Tap(d, "request.into");
Tap(d, std::format("pick.{}", aliceMain));
Type(d, "request.from", bobIban);
Tap(d, "request.review");
Tap(d, "request.submit");
Shows(d.ui, "The name of the account's holder", "an IBAN needs a name here too");
Type(d, "request.name", "Bob");
Type(d, "request.amount", "5");
Type(d, "request.description", "back");
Tap(d, "request.review");
Equal(d.app.Screen(), std::string("request+review"), "a request is reviewed");
Shows(d.ui, "Ask Bob for €5.00?", "as what it is");
Shows(d.ui, std::format("Main · {}", GroupIban(aliceMain)), "and into which account");
Hides(d.ui, "Your system asks for your password", "it needs no password");
Tap(d, "review.back");
Tap(d, "request.review");
Press(d, "review.confirm");
// The button sends what is filled in, as the pay form's does: there is no review of the app's own, since the
// system's password dialog is what confirms a request.
Bottom(d);
Tap(d, "request.submit");
Equal(d.app.Screen(), std::string("request+working"), "a request is sent by the form's button, with no question of the app's before it");
Shows(d.ui, "Asking Bob for €5.00", "the change under way is shown as what it is");
Shows(d.ui, "Confirm it in your system's password dialog.", "with where to confirm it");
Settle(d);
Shows(d.ui, "Asked Bob for €5.00", "the request is made");
Equal(Action(bus), std::string(Bus::actionChange), "as a change that moves no money");
Shows(d.ui, "https://bunq.me/t/", "with the link anyone can pay through");
@ -940,10 +958,11 @@ namespace {
Tap(d, "home.request");
Type(d, "request.from", "+31612345678");
Type(d, "request.amount", "3");
Tap(d, "request.review");
Shows(d.ui, "Ask +31612345678 for €3.00?", "someone asked by phone number is named by it");
bunq.Fail(Fault{.method = "POST", .path = "/user/", .status = 500, .body = R"({"Error":[{"error_description":"Hiccup."}]})"});
Press(d, "review.confirm");
Bottom(d);
Tap(d, "request.submit");
Shows(d.ui, "Asking +31612345678 for €3.00", "someone asked by phone number is named by it");
Settle(d);
Shows(d.ui, "It may have been done", "a request without a clear answer may have been made");
Check(Has(d, "problem.activity"), "and the account is a press away");
Press(d, "problem.close");
@ -976,6 +995,7 @@ namespace {
Tap(d, "detail.revoke");
Equal(d.app.Screen(), std::format("{}+confirm", page), "taking it back is asked about first");
Shows(d.ui, "Revoke the request to Bob?", "by name");
Shows(d.ui, "Your system asks for your password", "and with where it is confirmed: no change is made without the password");
Tap(d, "confirm.no");
Equal(d.app.Screen(), page, "and can be thought better of");
Tap(d, row);
@ -1023,7 +1043,7 @@ namespace {
Tap(d, Row(d, "incoming.", 1));
Tap(d, "detail.reject");
Shows(d.ui, "Reject the request from Dave?", "rejecting is asked about first");
Hides(d.ui, "Your system asks for your password", "and needs no password");
Shows(d.ui, "Your system asks for your password", "and needs the password too, as every change does");
Press(d, "confirm.yes");
Shows(d.ui, "Request rejected", "a request rejected is said");
Shows(d.ui, "Rejected · rent", "and listed as such");
@ -1166,7 +1186,7 @@ namespace {
Check(Has(d, "detail.freeze") && !Has(d, "detail.unfreeze") && Has(d, "detail.lost") && Has(d, "detail.stolen"), "a card in use can be frozen or reported");
Tap(d, "detail.freeze");
Shows(d.ui, "Freezing card •••• 1234", "freezing is under way at once");
Shows(d.ui, "One moment.", "without a password");
Shows(d.ui, "Confirm it in your system's password dialog.", "and is confirmed there, as unfreezing is: the app freezes no card by itself");
Settle(d);
Shows(d.ui, "Card •••• 1234 is now Deactivated", "a frozen card is said");
Equal(Action(bus), std::string(Bus::actionChange), "as a change");
@ -1417,7 +1437,7 @@ namespace {
Type(d, "oauth.client", "fake-client");
Type(d, "oauth.redirect", "http://127.0.0.1/cb");
Type(d, "oauth.secret", "fake-secret");
Shows(d.ui, "Typed: ••••", "the secret is told by nothing of itself");
Shows(d.ui, "Typed: 11 characters", "the secret is told by nothing of itself but how long it is");
Hides(d.ui, "fake-secret", "and never shown");
Bottom(d);
Tap(d, "oauth.environment.1");

View file

@ -108,6 +108,13 @@ namespace {
return check.details.contains("summary") ? check.details.at("summary") : std::string();
}
// How often polkit was asked about something that takes a password as shipped: everything but seeing, which a
// call that names an account or a card asks about first, and which an active session has without a dialog.
std::size_t Asked(Fake::Bus& bus) {
std::lock_guard lock(bus.mutex);
return static_cast<std::size_t>(std::ranges::count_if(bus.checks, [](const Fake::PolkitCheck& check) { return check.action != Bus::actionView; }));
}
std::string Slurp(const fs::path& file) {
std::ifstream in(file);
return std::string(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>());
@ -198,7 +205,8 @@ namespace {
// The published contract: packaging/dbus/net.catcrafts.Nostro1.xml and net.catcrafts.Nostro1.Checkout.xml are the
// interfaces nostrod serves, each under its own name alone, and the polkit policy declares every action nostrod asks
// about and no other, each owned by the user nostrod runs as, with a dialog that uses no detail nostrod does not set.
// about and no other, each owned by the user nostrod runs as, with a dialog that uses no detail nostrod does not set,
// and each but seeing asking for the user's password as it is shipped.
void Contract(Fake::Bus& bus) {
const std::string served = Introspect(bus, name);
Check(Interface(served, name) == Interface(Slurp("packaging/dbus/net.catcrafts.Nostro1.xml"), name), std::format("packaging/dbus/net.catcrafts.Nostro1.xml is the interface nostrod serves, which is:\n{}", served));
@ -219,6 +227,10 @@ namespace {
const std::size_t id = action.find('"') + 1;
declared.emplace_back(action.substr(id, action.find('"', id) - id));
Check(action.contains("<annotate key=\"org.freedesktop.policykit.owner\">unix-user:nostro</annotate>"), std::format("{} is owned by the user nostrod runs as", declared.back()));
// Secure as shipped: in the user's own session only seeing passes without their password, everything else
// asks for it every time, and nothing passes from anywhere else. Loosening that is an administrator's rule.
const std::string_view inSession = declared.back() == Bus::actionView ? "<allow_active>yes</allow_active>" : "<allow_active>auth_self</allow_active>";
Check(action.contains(inSession) && action.contains("<allow_inactive>auth_self</allow_inactive>") && action.contains("<allow_any>auth_self</allow_any>"), std::format("{} asks for the user's password as shipped, unless it only looks, and keeps no authorization", declared.back()));
for(std::size_t key = action.find("$("); key != std::string_view::npos; key = action.find("$(", key + 1)) {
Check(action.substr(key).starts_with("$(summary)"), std::format("{} shows only details nostrod sets", declared.back()));
}
@ -283,10 +295,31 @@ namespace {
// markup or for polkit's $(…), at most 64 characters.
const std::string nasty = std::format("B\x01o\x7F" "b\xC2\x85\xE2\x80\x8B\xE2\x80\xAE\xE2\x81\xA6\xEF\xBB\xBF<i>$(amount_minor)</i>\xF0\x9F\x98\x80x{}", std::string(70, 'y'));
alice.Send(aliceMain, "x@y", nasty, 100, "");
Equal(Summary(bus), std::format("pay €1.00 to x@y (Bob‹i›$ (amount_minor)‹/i›😀x{}…) from {} (Main)", std::string(37, 'y'), aliceMain), "a name made safe to show");
Equal(Summary(bus), std::format("pay €1.00 to x@y (Bob‹i›$ (amount_minor)‹/i›😀x{}…) from {} (Main)", std::string(36, 'y'), aliceMain), "a name made safe to show");
// An agent that reads its message as markup shows nothing of one with a bare & in it, the amount included.
alice.Send(aliceMain, bobIban, "Tom & Jerry", 100, "");
Equal(Summary(bus), std::format("pay €1.00 to {} (Tom + Jerry) from {} (Main)", bobIban, aliceMain), "an & is shown as a +");
// Nothing starts a line of its own or leaves a gap: an em space first, then a soft hyphen, an Arabic letter
// mark, a space, a no-break space and a blank Braille pattern, a line and a paragraph separator, a tag, a
// private-use character and a variation selector, and two spaces last.
alice.Send(aliceMain, bobIban, "\xE2\x80\x83 Ann\xC2\xAD\xD8\x9C \xC2\xA0\xE2\xA0\x80Lee\xE2\x80\xA8\xE2\x80\xA9\xF3\xA0\x81\x81\xEE\x80\x80\xEF\xB8\x8F ", 100, "");
Equal(Summary(bus), std::format("pay €1.00 to {} (Ann Lee) from {} (Main)", bobIban, aliceMain), "what draws nothing is left out, and spaces of any kind are one space between words");
// D-Bus carries UTF-8 alone, so text that is not cannot even be sent.
Throws<std::invalid_argument>([&alice] { alice.Send(aliceMain, bobIban, "\xFF", 100, ""); }, "not UTF-8", "a name that is not UTF-8");
// An address decides where the money goes, so the dialog shows it whole and as it is, or nobody is asked: one
// with an & would read as one with a +, which is another address.
const std::size_t passwords = Asked(bus);
const std::string addressRefused = "the password dialog would not show that address as it is";
Throws<std::invalid_argument>([&alice] { alice.Send(aliceMain, "tom&jerry@example.com", "Tom", 100, ""); }, addressRefused, "an address with an &");
Throws<std::invalid_argument>([&alice] { alice.Request(aliceMain, "tom\xE2\x80\x8Bjerry@example.com", "Tom", 100, ""); }, addressRefused, "one with a character that draws nothing");
Throws<std::invalid_argument>([&alice] { alice.Draft(aliceMain, std::format("{}@example.com", std::string(250, 'a')), "Tom", 100, ""); }, addressRefused, "one longer than an address gets");
Throws<std::invalid_argument>([&alice, start = std::chrono::sys_days(std::chrono::year(2027) / 1 / 1)] { alice.Schedule(aliceMain, "<tom@example.com>", "Tom", 100, "", BunqSchedule{.start = start, .unit = "ONCE"}); }, addressRefused, "one in angle brackets");
Equal(Asked(bus), passwords, "and nobody is asked for a password for any of them");
const std::string longAddress = std::format("{}@example.com", std::string(70, 'a'));
alice.Send(aliceMain, longAddress, "Tom", 100, "");
Check(Summary(bus) == std::format("pay €1.00 to {} (Tom) from {} (Main)", longAddress, aliceMain) && bus.LastCheck().details.at("counterparty") == longAddress, "an address longer than a name may be is shown whole, and given to rules whole");
alice.Accounts();
Check(bus.LastCheck().action == "net.catcrafts.Nostro1.View" && Summary(bus) == "see your accounts and balances", "listing is the View action");
const std::size_t listed = alice.Transactions(aliceMain, {}).size();
@ -357,18 +390,14 @@ namespace {
Check(bus.LastCheck().action == "net.catcrafts.Nostro1.BlockCard" && Summary(bus) == "report card **** 1234 stolen, which blocks it for good", "and so does blocking one for good");
// A virtual card is not frozen or unfrozen: bunq would leave it as it is and answer as if it had been done. It
// is refused before anyone is asked for a password, and bunq is not asked at all.
// is refused before anyone is asked for a password, and bunq is not asked to change anything.
const std::uint64_t number = bunq.AddCard(bank.alice, "DEACTIVATED", json{{"order_status", "VIRTUAL_DELIVERY"}, {"primary_account_numbers", json::array({json{{"four_digit", "4321"}}})}});
const auto prompted = [&bus] {
std::lock_guard lock(bus.mutex);
return bus.checks.size();
};
const std::size_t prompts = prompted();
const std::size_t prompts = Asked(bus);
const std::size_t changes = bunq.Count("PUT", "/user/");
for(const std::string_view status : {"DEACTIVATED", "ACTIVE"}) {
Throws<std::invalid_argument>([&alice, number, status] { alice.SetCardStatus(number, status); }, std::format("card {} is a virtual card, which bunq does not freeze or unfreeze when asked", number), "a virtual card is not frozen or unfrozen");
}
Check(prompted() == prompts && bunq.Count("PUT", "/user/") == changes, "nobody is asked for a password for it, and bunq is not asked");
Check(Asked(bus) == prompts && bunq.Count("PUT", "/user/") == changes, "nobody is asked for a password for it, and bunq is not asked");
Equal(alice.SetCardStatus(number, "LOST").status, std::string("LOST"), "it is reported lost like any card");
Check(bus.LastCheck().action == "net.catcrafts.Nostro1.BlockCard" && Summary(bus) == "report card **** 4321 lost, which blocks it for good", "which blocks it for good, after the password for that");
}
@ -411,6 +440,67 @@ namespace {
Check(!quick.Connectors().empty(), "and the next call is answered");
}
// What a call names is looked up for a caller who may see the user's accounts, and for no other: one polkit
// refuses that is told nothing of what is there, and has the bank asked nothing.
void Lookups(Fake::Bus& bus, Fake::Bunq& bunq, pid_t nostrod) {
Client alice = As(bus, aliceUid);
const std::string_view accounts = "see your accounts and balances";
const BunqSchedule once{.start = std::chrono::sys_days(std::chrono::year(2027) / 1 / 1), .unit = "ONCE"};
// Each call, with something that is there or something that is not, and what polkit is asked to let it see.
const std::vector<std::tuple<std::string_view, std::function<void()>, std::string_view>> calls = {
{"a payment from an account nobody has", [&alice] { alice.Send("Nope", bobIban, "Bob", 100, ""); }, accounts},
{"a payment from an account there is", [&alice] { alice.Send(aliceMain, bobIban, "Bob", 100, ""); }, accounts},
{"a schedule", [&alice, &once] { alice.Schedule("Nope", bobIban, "Bob", 100, "", once); }, accounts},
{"a request for money", [&alice] { alice.Request("Nope", bobIban, "Bob", 100, ""); }, accounts},
{"a draft", [&alice] { alice.Draft("Nope", bobIban, "Bob", 100, ""); }, accounts},
{"revoking a request", [&alice] { alice.RevokeRequest("Nope", 1); }, accounts},
{"cancelling a schedule", [&alice] { alice.CancelScheduledPayment(aliceMain, 1); }, accounts},
{"answering a request", [&alice] { alice.RespondToRequest(aliceMain, 1, true); }, "see your incoming requests for money"},
{"answering a draft", [&alice] { alice.RespondToDraftPayment(aliceMain, 1, false); }, "see your draft payments"},
{"a card's status", [&alice] { alice.SetCardStatus(1, "LOST"); }, "see your cards"},
{"the account that pays at checkout", [&alice] { alice.SetDefaultCheckoutAccount("Nope"); }, accounts},
{"removing a connector", [&alice] { alice.RemoveConnector("Nobody"); }, "see your bank connectors"},
{"the transactions of an account nobody has", [&alice] { alice.Transactions("Nope", {}); }, "see your transactions"},
{"a listing of one", [&alice] { alice.Requests("Nope"); }, "see your requests for money"},
};
SetPolkit(bus, Fake::Polkit::Deny, Bus::actionView);
const std::size_t prompts = Asked(bus);
const std::size_t questions = bunq.Count("GET", "/user/");
for(const auto& [what, call, seen] : calls) {
const Failure refused = FailureOf(call);
Check(refused.name == SD_BUS_ERROR_ACCESS_DENIED && refused.message.contains("does not allow net.catcrafts.Nostro1.View"), std::format("{}, asked by a caller who may not see the accounts: {}", what, refused.message));
Check(bus.LastCheck().action == Bus::actionView && Summary(bus) == seen, std::format("{}: polkit is asked whether the caller may {}", what, seen));
}
Equal(Asked(bus), prompts, "nobody is asked for a password for any of it");
Equal(bunq.Count("GET", "/user/"), questions, "and the bank is asked nothing");
// Where seeing the accounts takes a password, a call that looks something up asks for it first.
SetPolkit(bus, Fake::Polkit::Dismiss, Bus::actionView);
Equal(FailureOf([&alice] { alice.Send(aliceMain, bobIban, "Bob", 100, ""); }).name, std::string(Bus::errorCancelled), "a password to look, not given");
SetPolkit(bus, Fake::Polkit::Password, Bus::actionView);
const std::string unasked = Raw(bus, name, name, "Send", false, [](sd_bus_message* call) {
sd_bus_message_append(call, "sssxs", aliceMain.c_str(), bobIban.c_str(), "Bob", std::int64_t{100}, "");
});
Equal(unasked, std::string(SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED), "or one the call did not let nostrod ask for");
Equal(Asked(bus), prompts, "and still nobody is asked about the payment itself");
Check(alice.Send(aliceMain, bobIban, "Bob", 100, "").id != 0, "given, the call goes on");
const std::pair<std::string, std::string> lastTwo = [&bus] {
std::lock_guard lock(bus.mutex);
return std::pair(bus.checks.at(bus.checks.size() - 2).action, bus.checks.back().action);
}();
Check(lastTwo.first == Bus::actionView && lastTwo.second == Bus::actionPay, "and asks twice: to look, and then to pay");
// A worker just started reads the user's connectors, which asks the bank, for the first caller polkit says
// yes to, and for none before.
KillWorkers(bus, nostrod);
SetPolkit(bus, Fake::Polkit::Deny, Bus::actionView);
const std::size_t before = bunq.Count("GET", "/user/");
Equal(FailureOf([&bus] { As(bus, aliceUid).Accounts(); }).name, std::string(SD_BUS_ERROR_ACCESS_DENIED), "a caller a new worker refuses");
Equal(bunq.Count("GET", "/user/"), before, "has the bank asked nothing either");
SetPolkit(bus, Fake::Polkit::Allow);
Check(!As(bus, aliceUid).Connectors().empty() && bunq.Count("GET", "/user/") > before, "the first caller polkit lets in has the connectors read");
}
void Concurrency(Fake::Bus& bus, Fake::Bunq& bunq, const Bank& bank) {
Client alice = As(bus, aliceUid);
Client again = As(bus, aliceUid);
@ -643,7 +733,10 @@ namespace {
};
Checkout::Order changed = order;
changed.amount = 1300;
refused(changed, "reference order-1 to NL91ABNA0417164300 is an order of €12.50, not of €13.00", "a reference paid for another amount");
refused(changed, "reference order-1 to NL91ABNA0417164300 is an order of another amount than €13.00", "a reference paid for another amount");
// Which amount it was paid for is not said: whoever knows an order's payee and reference could ask for it.
const Failure other = FailureOf([&pay, &changed] { pay(changed); });
Check(!other.message.contains("12.50") && !other.message.contains("1250"), std::format("and not for which amount: {}", other.message));
changed = order;
changed.payeeIban = "shop@example.com";
refused(changed, "checkout pays an IBAN, and 'shop@example.com' is none", "a payee that is no IBAN");
@ -664,7 +757,12 @@ namespace {
refusedOrder.reference = "order-2";
bunq.Fail(Fault{.method = "POST", .path = "/user/", .status = 400, .body = R"({"Error":[{"error_description":"Not enough money."}]})"});
const Failure poor = FailureOf([&pay, &refusedOrder] { pay(refusedOrder); });
Check(poor.name == Checkout::errorBank && poor.message.contains("Not enough money."), "bunq's refusal");
Check(poor.name == Checkout::errorBank && poor.message.contains("bunq: Not enough money. (400)"), std::format("bunq's refusal: {}", poor.message));
// The app is told what the bank said, and not which call it said it to: that names the user and the account.
const auto namesNoAccount = [](const Failure& failure) {
return !failure.message.contains("/user/") && !failure.message.contains("monetary-account") && !failure.message.contains(aliceMain);
};
Check(namesNoAccount(poor), std::format("without the user or the account at the bank: {}", poor.message));
Check(!pay(refusedOrder).repeated, "and the order paid when asked again");
// bunq's answer lost: the order may have been paid, and is not paid again.
@ -672,7 +770,7 @@ namespace {
lostOrder.reference = "order-3";
bunq.Fail(Fault{.method = "POST", .path = "/user/", .status = 500, .body = R"({"Error":[{"error_description":"Hiccup."}]})"});
const Failure hiccup = FailureOf([&pay, &lostOrder] { pay(lostOrder); });
Check(hiccup.name == Checkout::errorBank && hiccup.message.contains("may have been carried out"), std::format("an answer that may hide a payment: {}", hiccup.message));
Check(hiccup.name == Checkout::errorBank && hiccup.message.contains("may have been carried out") && namesNoAccount(hiccup), std::format("an answer that may hide a payment, also without the account: {}", hiccup.message));
const Failure lost = FailureOf([&pay, &lostOrder] { pay(lostOrder); });
Check(lost.name == Checkout::errorFailed && lost.message.contains("order order-3 to NL91ABNA0417164300 may have been paid already") && !lost.message.contains(aliceMain), std::format("such an order asked again, without the account: {}", lost.message));
@ -688,7 +786,7 @@ namespace {
std::this_thread::sleep_for(std::chrono::milliseconds(300));
changed = unconfirmed;
changed.amount = 99;
refused(changed, "is an order of €12.50, not of €0.99", "another amount while the order is being paid");
refused(changed, "is an order of another amount than €0.99", "another amount while the order is being paid");
const Checkout::Paid waited = pay(unconfirmed);
paying.join();
Check(first.paymentId != 0 && waited.paymentId == first.paymentId && !first.repeated && waited.repeated, "a retry while the first call is at the prompt gets the first call's payment");
@ -832,6 +930,7 @@ int main(int argc, char* argv[]) {
Users(bus, state);
Prompts(bus, bunq, bank);
Outcomes(bus);
Lookups(bus, bunq, nostrod);
Concurrency(bus, bunq, bank);
Errors(bus, bunq, bank, state);
Checkouts(bus, bunq, bank);

View file

@ -97,10 +97,20 @@ namespace {
Equal(ScheduleLabel(schedule, now), std::format("Every {} from 3 Nov", word), "each unit bunq has");
}
Equal(Fingerprint("short"), std::string("••••"), "a short secret shows nothing of itself");
Equal(Fingerprint("sandbox_ab12cd34ef56gh78"), std::string("sandbox_…gh78"), "a key shows what it is for and how it ends");
Equal(Fingerprint("abcdefghijklmnopqrst"), std::string("abcd…qrst"), "one without a mark its first four");
Equal(Fingerprint("abcdefghijklmn_opqrst"), std::string("abcd…qrst"), "and so one whose mark comes late");
Equal(Fingerprint("short"), std::string("5 characters"), "a short secret shows nothing of itself but how long it is");
Equal(Fingerprint("x"), std::string("1 character"), "one character is one");
Equal(Fingerprint("sandbox_ab12cd34ef56gh78"), std::string("sandbox_ab12… 24 characters"), "a key shows what it is for, how it goes on and how long it is");
Equal(Fingerprint("sandbox_ab12cd34ef56gh7"), std::string("23 characters"), "one that would show most of itself that way shows nothing of itself");
Equal(Fingerprint("abcdefghijklmnopqrst"), std::string("abcd… 20 characters"), "one without a mark its first four");
Equal(Fingerprint("abcdefghijklmn_opqrst"), std::string("abcd… 21 characters"), "and so one whose mark comes late");
Equal(Fingerprint("ééééééééééééééééé"), std::string("éééé… 17 characters"), "by characters, not by bytes");
// How a key ends is what was typed last: shown, a key typed by hand would be shown whole, a character at a
// time. So typing on changes nothing of what is shown but the count.
std::string typed = "sandbox_ab12cd34ef56gh78";
for(const char next : std::string_view("WXYZ")) {
typed += next;
Equal(Fingerprint(typed), std::format("sandbox_ab12… {} characters", typed.size()), "what is typed after the beginning is never shown");
}
}
void Reading() {
@ -313,21 +323,22 @@ namespace {
}
void Explaining() {
// What nostrod asks polkit for, per the policy nostro installs.
const std::array<std::tuple<Operation, std::string_view, bool, bool>, 17> operations = {{
{Operation::Load, Bus::actionView, false, false},
{Operation::Send, Bus::actionPay, true, true}, {Operation::Schedule, Bus::actionPay, true, true},
{Operation::PayRequest, Bus::actionPay, true, true}, {Operation::AcceptDraft, Bus::actionPay, true, true},
{Operation::Draft, Bus::actionChange, false, false}, {Operation::Request, Bus::actionChange, false, false},
{Operation::RevokeRequest, Bus::actionChange, false, false}, {Operation::RejectRequest, Bus::actionChange, false, false},
{Operation::CancelSchedule, Bus::actionChange, false, false}, {Operation::RejectDraft, Bus::actionChange, false, false},
{Operation::FreezeCard, Bus::actionChange, false, false},
{Operation::UnfreezeCard, Bus::actionUnfreezeCard, true, false}, {Operation::BlockCard, Bus::actionBlockCard, true, false},
{Operation::AddConnection, Bus::actionConnectors, true, false}, {Operation::RemoveConnection, Bus::actionConnectors, true, false},
{Operation::SetCheckoutAccount, Bus::actionConnectors, true, false},
// What nostrod asks polkit for, and whether money leaves an account by it. Only a reading is the View action,
// which is the one the policy nostro installs lets pass without a password.
const std::array<std::tuple<Operation, std::string_view, bool>, 17> operations = {{
{Operation::Load, Bus::actionView, false},
{Operation::Send, Bus::actionPay, true}, {Operation::Schedule, Bus::actionPay, true},
{Operation::PayRequest, Bus::actionPay, true}, {Operation::AcceptDraft, Bus::actionPay, true},
{Operation::Draft, Bus::actionChange, false}, {Operation::Request, Bus::actionChange, false},
{Operation::RevokeRequest, Bus::actionChange, false}, {Operation::RejectRequest, Bus::actionChange, false},
{Operation::CancelSchedule, Bus::actionChange, false}, {Operation::RejectDraft, Bus::actionChange, false},
{Operation::FreezeCard, Bus::actionChange, false},
{Operation::UnfreezeCard, Bus::actionUnfreezeCard, false}, {Operation::BlockCard, Bus::actionBlockCard, false},
{Operation::AddConnection, Bus::actionConnectors, false}, {Operation::RemoveConnection, Bus::actionConnectors, false},
{Operation::SetCheckoutAccount, Bus::actionConnectors, false},
}};
for(const auto& [operation, action, password, money] : operations) {
Check(ActionOf(operation) == action && AsksPassword(operation) == password && MovesMoney(operation) == money, std::format("operation {} asks for {}", std::to_underlying(operation), action));
for(const auto& [operation, action, money] : operations) {
Check(ActionOf(operation) == action && MovesMoney(operation) == money && (ActionOf(operation) == Bus::actionView) == (operation == Operation::Load), std::format("operation {} asks for {}", std::to_underlying(operation), action));
}
Guidance told = Explained(DaemonMissing("not there"), Operation::Load);