From 2e3739ff7ab150e2d5df38295363b5e46b78b1ab Mon Sep 17 00:00:00 2001
From: Jorijn van der Graaf
Date: Thu, 19 Nov 2026 16:09:48 +0100
Subject: [PATCH] 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
---
AGENTS.consumer.md | 8 +-
AGENTS.template.md | 40 ++--
README.md | 48 ++++-
implementations/Nostro-Daemon-Worker.cpp | 203 +++++++++++++-----
implementations/Nostro.App-App.cpp | 42 ++--
implementations/Nostro.App-Errors.cpp | 5 -
implementations/Nostro.App-Format.cpp | 22 +-
implementations/Nostro.App-Screens.cpp | 7 +-
implementations/main.cpp | 2 +-
interfaces/Nostro.App-App.cppm | 13 +-
interfaces/Nostro.App-Errors.cppm | 12 +-
interfaces/Nostro.App-Format.cppm | 3 +-
lib/json.hpp | 2 +-
packaging/dbus/net.catcrafts.Nostro1.xml | 8 +-
.../flatpak/net.catcrafts.Nostro.metainfo.xml | 2 +-
.../net.catcrafts.Nostrod.metainfo.xml | 2 +-
packaging/licenses/NOTICE | 7 +-
packaging/system/net.catcrafts.Nostro1.policy | 23 +-
packaging/system/nostro | 2 +-
project.cpp | 16 +-
tests/ShouldDriveTheApp/main.cpp | 60 ++++--
tests/ShouldServeEveryUser/main.cpp | 125 +++++++++--
tests/ShouldValidateForms/main.cpp | 47 ++--
23 files changed, 489 insertions(+), 210 deletions(-)
diff --git a/AGENTS.consumer.md b/AGENTS.consumer.md
index 3ec2831..45e6578 100644
--- a/AGENTS.consumer.md
+++ b/AGENTS.consumer.md
@@ -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`) 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` (`std::function)>`; `std::monostate` for a method that answers nothing). It returns a `[[nodiscard]] Client::Pending` at once and calls `then` from the loop when nostrod answers. `Answer` holds the `result` or the `std::exception_ptr` the blocking call would have thrown (`Get()` returns the one or rethrows the other, `Failed()`, `Error()`), and that call's `notes`; an error answer carries none, and notes are collected per user by nostrod's worker, so they can be another call's of the same user. Destroying the `Pending`, or `Cancel()`, drops the answer (`then` is not called) without undoing the call, which nostrod and bunq carry on with; `Active()` says whether `then` is still to come. A `then` that throws is reported through `Note`. Calling one without `Attach` throws `std::logic_error`. Once the connection is gone (`Connected()` false), make a new client: a closed connection answers nothing it still awaited.
-- Errors: `std::invalid_argument` for what nostrod refused before doing anything (it names the problem, as the library's own messages do); `DaemonError`, a `std::runtime_error` with the D-Bus error `name`, for the rest: `Bus::errorBank` (bunq's refusal, as bunq said it), `Bus::errorOAuthCannotPay`, `Bus::errorCancelled` (the user closed the password dialog), `Bus::errorNoCheckoutAccount`, `Bus::errorFailed`, `org.freedesktop.DBus.Error.AccessDenied` (the system's policy, or polkit not answering) and `InteractiveAuthorizationRequired`. A missing nostrod is `DaemonMissing`, a `std::runtime_error` saying it is not running. A call that moves money or changes something and gets no answer in time, or that bunq answered with an error ending in `BunqError::maybeCarriedOut` (a 5xx: the payment may have been made), is `OutcomeUnknown`, a `std::runtime_error` saying it may have been carried out: check before trying again. Text that is not UTF-8 is a `std::invalid_argument` before anything is sent.
+- 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 `, 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.
diff --git a/AGENTS.template.md b/AGENTS.template.md
index 899bf2e..4a1155a 100644
--- a/AGENTS.template.md
+++ b/AGENTS.template.md
@@ -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//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`, `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 …`, a socketpair end as fd 3, D-Bus peer to peer over it), and passes a copy of the call on, from the caller's unique name and allowing a dialog only when the caller did. The answer is relayed when it comes, so one user's open dialog holds up nobody. A worker that dies under a call is answered `Failed` with "may have been carried out". It holds no connector and no secret. It ends once idle with no worker left, on SIGTERM, or when the bus goes; D-Bus activation starts it again.
-- **A worker** (`implementations/Nostro-Daemon-Worker.cpp`, `RunWorker`) is one user's library: `configPath` and `cachePath` are `/users/`, the connectors are read on the first call, and it is not dumpable. A directory records whose it is (`owner`): a uid that logind now names differently, after a user was deleted and another given their uid, is refused. Every handler reads and checks the call first (the account, the counterparty, what is to be paid, or for a request or a draft the object as bunq has it), builds a `Prompt` (the polkit action, a summary from its own data, and details for polkit rules), and hands it to `Gate`. `Gate` asks polkit asynchronously (`CheckAuthorization` about the caller's bus name, cancelled if it does not answer in time) and runs the call's work only once polkit says yes. It fails closed: no polkit, an error or a timeout is `AccessDenied`. A dialog the user closed is `Cancelled`, which polkit says with `polkit.dismissed` or, from Plasma's agent, `polkit.result` `auth_…`. A challenge to a call that allowed no dialog is `InteractiveAuthorizationRequired`. Every answer of the main interface ends with the notes. A summary's text from a caller or the bank goes through `Shown()` (no control, invisible or direction characters, `<` and `>` replaced, `$(` broken, 64 characters at most) and names the address before the name. The worker ends once idle with no dialog open, on SIGTERM, or when the front goes.
-- **Checkout** (the same file): `Order::Read` refuses a payee that is not an IBAN, an amount that is not positive, an unknown currency or an empty reference. An order already in `checkouts.cdb` (a Crafter.DB table, `CheckoutRecord`) is answered with its payment, `repeated`, without a dialog, or refused when its amount differs, or when its payment is still 0: a payment whose outcome was lost. An order being paid makes the next call for it wait, and `Settle` gives it the first call's answer. `ChooseAccount` picks the account (the one in `checkout-account`, set by `SetDefaultCheckoutAccount`; an account of an OAuth connector is refused there) and answers through a continuation, so an account picker can take its place later. The dialog (`net.catcrafts.Nostro1.Checkout`) shows the order and that account. `PayOrder` records the order, with no payment, before it pays, and takes the record away again only when bunq refused before doing anything, below 500.
+- **A worker** (`implementations/Nostro-Daemon-Worker.cpp`, `RunWorker`) is one user's library: `configPath` and `cachePath` are `/users/`, 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 ""`) 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 ""`. 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=` for now: the app asks the input method for a field's purpose and hints, which Crafter.Graphics has on its branch `claude/nostro-app` and not yet on master. Once that is merged, name it as a `GitProject` at a pinned commit in `project.cpp` and drop the flag.
- The app's `--debug-api` build links Crafter.Debug, which talks QUIC: that one build has Crafter.Network with msquic (crafter-build builds it with CMake once, for minutes, and keeps it in its cache), and its binaries carry a runpath into that cache.
- Where the connectors live depends on who runs the library. nostrod's worker keeps each user's under `/users//`: `connectors.json`, the transaction tables, `checkouts.cdb`, `checkout-account` and `owner`, with `` from `--state`, else `$XDG_DATA_HOME`, else `$HOME/.local/share`. Installed, that is `/var/lib/nostro/.var/app/net.catcrafts.Nostrod/data/`, readable by the user `nostro` alone. The library used directly reads `connectors.json` from `$XDG_CONFIG_HOME/.config/nostro/` (sic, see "Gotchas") or `$HOME/.config/nostro/`, and keeps the transaction tables under `$XDG_CACHE_HOME/nostro/transactions/` or `$HOME/.cache/nostro/transactions/`. A real connectors file holds a real API key: point every experiment elsewhere.
@@ -174,7 +180,7 @@ The app's packaging: `--packaging=flatpak` makes `bin/nostro-app-/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 ` plays one `--poke` script per picture and writes the five files beside itself. It names what it taps by its place, so it is looked over, picture by picture, after a change to a screen it shows. The made-up bank dates its payments back from now: every taking has other days and times in it. Four of the five are in the dark look and one in the light one, and everything the made-up bank holds is in English, people's names too, as the app is: both as asked for on 2026-11-19, so new made-up data is written in English.
-- A region's key is its name in the tests too: `nav.accounts`, `account.`, `account.pay`, `tabs.1`, `pay.to`, `pay.submit`, `request.review`, `review.confirm`, `done.close`, `card.`, `settings.connections`, `connections.add`, `bank.bunq`, `way.key`, and `copy.
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.
diff --git a/packaging/flatpak/net.catcrafts.Nostrod.metainfo.xml b/packaging/flatpak/net.catcrafts.Nostrod.metainfo.xml
index cdc0010..a6a866d 100644
--- a/packaging/flatpak/net.catcrafts.Nostrod.metainfo.xml
+++ b/packaging/flatpak/net.catcrafts.Nostrod.metainfo.xml
@@ -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.
Apps can have Nostro pay an order at checkout, from an account you chose, once you have confirmed the payment.
diff --git a/packaging/licenses/NOTICE b/packaging/licenses/NOTICE
index d1b5a1c..ffcfde3 100644
--- a/packaging/licenses/NOTICE
+++ b/packaging/licenses/NOTICE
@@ -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/.
-- 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).
diff --git a/packaging/system/net.catcrafts.Nostro1.policy b/packaging/system/net.catcrafts.Nostro1.policy
index ec9dada..01bbb95 100644
--- a/packaging/system/net.catcrafts.Nostro1.policy
+++ b/packaging/system/net.catcrafts.Nostro1.policy
@@ -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/. -->
@@ -37,7 +48,7 @@
auth_selfauth_self
- yes
+ auth_selfunix-user:nostro
diff --git a/packaging/system/nostro b/packaging/system/nostro
index 7229e0e..8e781d6 100755
--- a/packaging/system/nostro
+++ b/packaging/system/nostro
@@ -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.
diff --git a/project.cpp b/project.cpp
index 2963df3..a5e432c 100644
--- a/project.cpp
+++ b/project.cpp
@@ -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 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,
});
diff --git a/tests/ShouldDriveTheApp/main.cpp b/tests/ShouldDriveTheApp/main.cpp
index 12c9880..d651063 100644
--- a/tests/ShouldDriveTheApp/main.cpp
+++ b/tests/ShouldDriveTheApp/main.cpp
@@ -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");
diff --git a/tests/ShouldServeEveryUser/main.cpp b/tests/ShouldServeEveryUser/main.cpp
index a5b89f8..f75b34f 100644
--- a/tests/ShouldServeEveryUser/main.cpp
+++ b/tests/ShouldServeEveryUser/main.cpp
@@ -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::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(in), std::istreambuf_iterator());
@@ -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("unix-user:nostro"), 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 ? "yes" : "auth_self";
+ Check(action.contains(inSession) && action.contains("auth_self") && action.contains("auth_self"), 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$(amount_minor)\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([&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([&alice] { alice.Send(aliceMain, "tom&jerry@example.com", "Tom", 100, ""); }, addressRefused, "an address with an &");
+ Throws([&alice] { alice.Request(aliceMain, "tom\xE2\x80\x8Bjerry@example.com", "Tom", 100, ""); }, addressRefused, "one with a character that draws nothing");
+ Throws([&alice] { alice.Draft(aliceMain, std::format("{}@example.com", std::string(250, 'a')), "Tom", 100, ""); }, addressRefused, "one longer than an address gets");
+ Throws([&alice, start = std::chrono::sys_days(std::chrono::year(2027) / 1 / 1)] { alice.Schedule(aliceMain, "", "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([&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::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 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);
diff --git a/tests/ShouldValidateForms/main.cpp b/tests/ShouldValidateForms/main.cpp
index 6ed7e39..c22968b 100644
--- a/tests/ShouldValidateForms/main.cpp
+++ b/tests/ShouldValidateForms/main.cpp
@@ -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, 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, 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);