From 564fcdfe0e3b58d394923a2ed647c1a13cbdc090 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Sat, 21 Nov 2026 06:39:19 +0100 Subject: [PATCH 1/5] build: add the pre-push review's configuration .review-gates/config.json configures Crafter.Review's pre-push review for this repository. Its commits mode lists four lenses: repo-better-solution, repo-bug-prover, repo-security and repo-facts. For each it names a section of this repository's own, under .review-gates/lenses/. It sets requireSigned, forbids AI attribution trailers, and lists fourteen gate0 commands: the version check, the tests, a build of each product and five lint runs. It names no authors: a patch that came by mail, as the README asks for one, keeps its author. One of the five lint runs is new to the guide: the daemon's, whose sources list implementations/nostrod.cpp, which the other four's do not. "Code style" and the command list name it. .gitignore gains the review's two generated directories. AGENTS.template.md gains the directory in its table and two commit guidelines about the review, puts the review into the release recipe before the tag, names the two generated directories among what is never committed, and loses the sentence that asked for a Co-Authored-By trailer on a commit an agent wrote. --- .gitignore | 2 + .review-gates/config.json | 48 +++++++++ .review-gates/lenses/repo-better-solution.md | 58 ++++++++++ .review-gates/lenses/repo-bug-prover.md | 90 ++++++++++++++++ .review-gates/lenses/repo-facts.md | 61 +++++++++++ .review-gates/lenses/repo-security.md | 105 +++++++++++++++++++ AGENTS.template.md | 12 ++- 7 files changed, 372 insertions(+), 4 deletions(-) create mode 100644 .review-gates/config.json create mode 100644 .review-gates/lenses/repo-better-solution.md create mode 100644 .review-gates/lenses/repo-bug-prover.md create mode 100644 .review-gates/lenses/repo-facts.md create mode 100644 .review-gates/lenses/repo-security.md diff --git a/.gitignore b/.gitignore index 86e8d21..bfcadc3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ bin/ build/ # written by every build from AGENTS.template.md /AGENTS.md +.review-gates/push/ +.review-gates/trees/ diff --git a/.review-gates/config.json b/.review-gates/config.json new file mode 100644 index 0000000..7e24633 --- /dev/null +++ b/.review-gates/config.json @@ -0,0 +1,48 @@ +{ + "base": "origin/master", + "rangeFrom": "upstream", + "aiTrailers": "forbid", + "requireSigned": true, + "lenses": { + "repo-better-solution": { + "section": ".review-gates/lenses/repo-better-solution.md" + }, + "repo-bug-prover": { + "section": ".review-gates/lenses/repo-bug-prover.md" + }, + "repo-security": { + "section": ".review-gates/lenses/repo-security.md" + }, + "repo-facts": { + "section": ".review-gates/lenses/repo-facts.md" + } + }, + "modes": { + "commits": { + "kind": "commits", + "lenses": [ + "repo-better-solution", + "repo-bug-prover", + "repo-security", + "repo-facts" + ], + "effort": "xhigh" + } + }, + "gate0": [ + "packaging/flatpak/release-version.sh", + "crafter-build test --banks=bunq", + "CPLUS_INCLUDE_PATH=/app/include/c++/v1 crafter-build lint --banks=bunq", + "crafter-build --banks=bunq", + "crafter-build --banks=bunq --lib", + "crafter-build --banks=bunq --product=daemon", + "CPLUS_INCLUDE_PATH=/app/include/c++/v1 crafter-build lint --banks=bunq --product=daemon", + "crafter-build --product=checkout", + "crafter-build --banks=bunq --product=fake-system", + "CPLUS_INCLUDE_PATH=/app/include/c++/v1 crafter-build lint --banks=bunq --product=fake-system", + "crafter-build --banks=bunq --product=app", + "CPLUS_INCLUDE_PATH=/app/include/c++/v1 crafter-build lint --banks=bunq --product=app", + "crafter-build --banks=bunq --product=app --debug-api", + "CPLUS_INCLUDE_PATH=/app/include/c++/v1 crafter-build lint --banks=bunq --product=app --debug-api" + ] +} diff --git a/.review-gates/lenses/repo-better-solution.md b/.review-gates/lenses/repo-better-solution.md new file mode 100644 index 0000000..e3c101b --- /dev/null +++ b/.review-gates/lenses/repo-better-solution.md @@ -0,0 +1,58 @@ +## This repository: Nostro + +A banking client for Linux that holds people's bank keys and moves +their money. The stated design is `README.md` (the manual), +`AGENTS.template.md` (the contributor guide; `AGENTS.md` is written +from it and the dependencies' notes by every crafter-build run, and is +not in the tree), `AGENTS.consumer.md` (the notes agents in a consumer +of the library get) and the contracts the guide names: the interfaces +under `interfaces/`, `Transaction` for the bytes on disk, +`packaging/dbus/*.xml` and +`packaging/system/net.catcrafts.Nostro1.policy` for the system bus. The +guide's "Design rules" and "Security considerations" are the owner's +decisions: a range that departs from one without saying so is a +finding; whether one should change is the owner's call, not a defect of +the range. + +The layers are the guide's "Project overview": the library and its +connectors, nostrod's front and its workers, the CLI, +`Nostro.Checkout`, the toolkit, the app, the window, `project.cpp`, the +packaging and the one workflow. Read there, and in design rules 1, 8, +11, 12 and 13, what belongs in which before judging where a change +sits. The questions this repository adds to the charter's: +- Does a client decide what nostrod should (design rule 8)? The guide + has the app's own checks only spare the user a round trip. +- Does logic sit in a `main`, or twice, in the CLI and in the app, + where design rule 8 wants it in a partition of the library? +- Does the window (`Nostro.Ui.Shell`, `implementations/nostro-app.cpp`, + `Nostro.DebugCommands`) decide something that design rule 11 wants in + the toolkit or the app, as a function a test can call? +- Does anything of the library, nostrod, the CLI or `Nostro.Checkout` + import or include anything of the app (design rule 13)? +- Does a bank's own code sit where the guide's "Adding a bank" puts it? + +Search first: +- The partitions' own helpers, which the guide's "Project overview" + lists partition by partition, before a new one beside them. +- What the tree already depends on, before a hand-rolled copy: + Crafter.Network, Crafter.DB, Crafter.Graphics, libsystemd's sd-bus + and sd-event, OpenSSL and the vendored `lib/json.hpp`. +- The system's own mechanisms, before one of nostro's: polkit's policy + and an administrator's rules, D-Bus activation and systemd, Flatpak's + permissions. The guide's "The app end to end" says which + confirmations of the app's own were taken out and which are the + design: a range that puts one of the former back is a finding. + +Commit shape here: the guide's "Commit and PR guidelines", its "Testing +instructions" and design rule 5 say what a change brings with it. A +range that leaves one of those things behind is a finding. + +Compatibility: the guide's "Dev environment" says what an install keeps +on disk and where, design rule 5 what may change in the transaction +tables, and design rule 10 what may change on the bus. Judge a range +against an install that is not fresh: files an earlier release wrote +under nostrod's state directory, a client and a nostrod a release +apart, system files (`packaging/system/`) older than the Flatpaks, a +consumer built against `AGENTS.consumer.md` as it was. A range that +works only on a fresh install, or breaks one of these without +documenting it where its users read, is a finding. diff --git a/.review-gates/lenses/repo-bug-prover.md b/.review-gates/lenses/repo-bug-prover.md new file mode 100644 index 0000000..86bbf90 --- /dev/null +++ b/.review-gates/lenses/repo-bug-prover.md @@ -0,0 +1,90 @@ +## This repository: Nostro + +The execution contexts to enumerate, beside the charter's. Each names +where to read how it behaves. The guide (`AGENTS.template.md`) +describes most of them under "Project overview"; where the guide and +the code disagree, the code wins. +- The processes: nostrod's front (`RunDaemon`, + `implementations/Nostro-Daemon.cpp`), a worker per user (`RunWorker`, + `implementations/Nostro-Daemon-Worker.cpp`), the CLI + (`implementations/main.cpp`), the app, and a consumer that runs the + library in a process of its own. Ask of each what happens when + another ends under a call, is absent, is late or comes back, and when + a caller leaves while its dialog is open. +- Callbacks from C: what sd-bus, sd-event and libwayland call back + returns into C. Read in the caller what a return value means there, + and ask what an exception that leaves the callback would do. +- Waits in the middle of a call: the worker's `Gate` and `HandleLookup` + ask polkit and go on when it answers, which a person may do minutes + later or never. Ask what else arrives meanwhile, and what the call + was checked against that has moved by then. +- The bank's protocol: `BunqConnector::Call` in + `implementations/Nostro-Bunq.cpp`. Read there what is sent again and + when, what is verified and what is not, and what a failure says about + whether a write went through. Then ask, for the path the range + touches, what a second sending pays twice. The checkout's record + (`PayOrder`) is the same question on disk. +- Money, text and time from outside: amounts (`ParseAmount`, + `FormatAmount`; design rule 3), text from the bank or a caller on its + way to a dialog, a terminal or a screen (`Shown()`, the toolkit's + `:Text` and `:Edit`), JSON from the bank, and days a person typed + (`ParseLocalDate`, `ParseLocalDateEnd`). Attack the edges: overflow, + a sign, zero, bytes that are not UTF-8, a DST change, a time zone + that is not the test's. +- Files: `connectors.json` and its lock + (`implementations/Nostro-Connector.cpp`), the Crafter.DB tables + (`implementations/Nostro-Account.cpp`, and the checkout's in the + worker), a state directory an earlier release wrote. What Crafter.DB + does about a second writer, an order, a flush and a migration is its + own: read it, do not recall it. +- The app (`Nostro.App` on `Nostro.Ui`): state changed by nostrod's + answers and by input, and frames built from it. How a press, the + focus and a frame built in between relate is in + `implementations/Nostro.Ui-Context.cpp` (`Invalidate`, `Stale`). The + cases to attack: a list that changed under the finger, an answer + between press and release, a sheet that takes the focus, a second + press while a change is under way, an answer for a screen the user + has left, a `Pending` dropped or moved, the same state at each of the + three window sizes. +- The window (`Nostro.Ui.Shell`, `implementations/nostro-app.cpp`): + listeners that run inside a dispatch (`Loop::Guard`, `Defer`). Ask + what a listener that resizes or closes the window it was called for + leaves behind. The guide says no test opens a window. +- One source, several builds: `project.cpp` returns one product per + run and sets the defines that gate code. Code behind a define, or in + a product the tests do not build, is still the range's code. aarch64 + is a cross build by the scripts in `packaging/flatpak/`. +- Packaging and the workflow, as scripts: + `packaging/system/install.sh` and `uninstall.sh`, the Arch package's + install script, the two aarch64 scripts, `release-version.sh` and the + workflow's jobs. Ask what each sees on a system that holds an earlier + install, and after a step that failed half way. +- Tests: `tests/Support/FakeBunq.inc` and `FakeBus.inc` are nostro's + reading of bunq, the bus, logind and polkit, not those systems. A + test that passes because the fake is more lenient than what it stands + for proves nothing about the code. + +Semantics to read on disk rather than recall: libsystemd's headers +(`/run/host/usr/include/systemd/sd-bus.h`, `sd-bus-vtable.h`, +`sd-event.h`); OpenSSL's (`/run/host/usr/include/openssl/`); the format +of a polkit policy (`/run/host/usr/share/polkit-1/policyconfig-1.dtd`); +libc++ and clang as the host installs them +(`/run/host/usr/include/c++/v1`, +`/run/host/usr/lib/clang//include`); the vendored `lib/json.hpp`; +and the Crafter libraries as crafter-build cloned them +(`~/.cache/crafter.build/external/-/`). Several clones may +sit side by side. For the ones `project.cpp` names at a commit +(Crafter.Network outside the `--debug-api` build, Crafter.DB, +Crafter.Graphics, Crafter.LintRules and Crafter.Debug's build helper), +a clone's `.git/HEAD`, or the ref it names, says whether that clone is +at the commit. The others follow a branch (the guide's "Dev +environment" says which): a semantic of one of those is unverified. A +crafter-build that runs as a Flatpak keeps its clones in that app's own +directory, which is not readable from here, and compiles with an LLVM +of its own: a semantic of a dependency that has no readable clone at +the pinned commit is unverified, and where one may differ between LLVM +releases the host's headers settle it for the host's build only. Not on +disk: bunq's API (the guide's "Gotchas" record what was seen in its +sandbox, and the fake is no evidence of the bank), and how polkit and +its agents, systemd, bubblewrap and Flatpak behave beyond their +headers. A semantic only they settle is unverified. diff --git a/.review-gates/lenses/repo-facts.md b/.review-gates/lenses/repo-facts.md new file mode 100644 index 0000000..2554fc0 --- /dev/null +++ b/.review-gates/lenses/repo-facts.md @@ -0,0 +1,61 @@ +## This repository: Nostro + +- A claim that a tree passes the version check, the tests or lint, or + builds a product, traces to the Gate 0 log among the evidence paths + INPUTS names: each command with its exit code and the sha it ran at. + A claim of a run anywhere else traces to a capture of that run that + names the commit, or is unverifiable: bunq's sandbox or production, a + phone, a compositor or a look at the window (which screens, at which + sizes, on what), a polkit agent's dialog, the installed Flatpaks and + system files, the aarch64 cross build, CI, the coverage figures + (`tests/coverage.sh`), a session of the `--debug-api` build. +- The guide asks a commit to say how a bug was reproduced, how a + connector was tried against the bank and how a change to a screen was + looked at. Each such sentence is a tested claim by the rule above, + not a formality. +- A test a message names is a name in `project.cpp`'s lists and a + `tests//main.cpp` whose checks pin what the message says. The + tests talk to a fake bunq and a fake system bus of their own + (`tests/Support/`): a passing test shows what nostro does with what + the fake answers, never what bunq, polkit, logind or a compositor + does. +- `AGENTS.md` is generated from `AGENTS.template.md` and the + dependencies' `AGENTS.consumer.md` and is not in the tree: a claim + about it is checked against those sources. `AGENTS.consumer.md` + reaches the agents of the library's consumers on their next build: + every sentence in it is a claim about the code at the commit that + writes it. +- The guide dates what it records ("on 2026-11-19 ..."). A dated + sentence the range adds claims that the thing was done, seen or + decided that day, which is no later than its commit's date, and what + it says was run or seen traces like any tested claim. +- A claim about a contract is checked against the contract: + - the wire against `packaging/dbus/*.xml` and the method tables in + `interfaces/Nostro-Bus.cppm`; + - a polkit default against + `packaging/system/net.catcrafts.Nostro1.policy`; + - the size or fingerprint of `Transaction` against the + `static_assert`s in `implementations/Nostro-Account.cpp`; + - a Flatpak's permissions against + `packaging/flatpak/net.catcrafts.Nostrod.yaml`, `project.cpp` and + `packaging/flatpak/build-aarch64.sh`; + - a dependency's commit against `project.cpp`; + - the vendored `lib/json.hpp` against the upstream commit the guide + and `packaging/licenses/NOTICE` name and the blob id the guide + gives (`git hash-object`); + - the version against `NOSTRO_VERSION` in `project.cpp` and the + newest `` of + `packaging/flatpak/net.catcrafts.Nostro.metainfo.xml`. +- A `` entry in that metainfo is the release notes users read: + every sentence in it is a claim about the code since the previous + tag. +- The README is the manual. Its CLI section is a claim about + `implementations/main.cpp`, "The app" about the screens, and "How + Nostro runs" and "Security" about nostrod and the shipped policy. + "Installing" speaks of a published channel that is not on disk: what + it says of the remote, and of what a release carries, is unverifiable + from here, a note naming what would settle it. +- A statement of how bunq behaves (the guide's "Gotchas", a comment, a + message) says where it was seen, the sandbox or production, and + traces to a capture, or is unverifiable. bunq's specification is not + on disk. diff --git a/.review-gates/lenses/repo-security.md b/.review-gates/lenses/repo-security.md new file mode 100644 index 0000000..3fe0af2 --- /dev/null +++ b/.review-gates/lenses/repo-security.md @@ -0,0 +1,105 @@ +## This repository: Nostro + +Nostro holds people's bank keys and moves their money. Its stated +security model is `README.md` ("How Nostro runs", "Checkout for apps", +"Security"), the contributor guide `AGENTS.template.md` ("nostrod end +to end", design rules 4, 9, 10 and 12, "Security considerations"; +`AGENTS.md` is generated from it and is not in the tree) and the files +that are the model as shipped: +`packaging/system/net.catcrafts.Nostro1.policy` (each polkit action and +its defaults), `packaging/system/net.catcrafts.Nostro1.conf` (who may +own and call the two bus names), `packaging/system/nostrod.service` +(the user nostrod runs as and its hardening), the two Flatpaks' +permissions (nostrod's in `packaging/flatpak/net.catcrafts.Nostrod.yaml`, +the app's in `project.cpp`, and both again in +`packaging/flatpak/build-aarch64.sh`), `packaging/dbus/*.xml` (the +wire) and `.forgejo/workflows/flatpak.yaml`. These are the owner's +decisions: a range that weakens one without saying so is a finding; +whether one should change is the owner's call. Write the standard of +Method 1 from them as they are at HEAD, not from this section. + +The charter's web classes (CORS, cookies, CSRF, headers, uploads) have +no counterpart here: "not here", with that reason. Their counterparts +are the bus policy, the polkit action, a Flatpak's permissions, the +unit's hardening and a file's mode. + +The actors to write down, each with what the model above lets it do: a +local user, whom nostrod knows by the uid the bus gives for the caller; +any program that user runs, the CLI and the app among them, which +neither polkit nor nostrod can tell apart; an app at checkout; the +bank; polkit and its agent; an administrator, and root; a build, which +runs each dependency's `project.cpp`; the workflow's two jobs. + +The decision points, each with where to read it: +- Who the caller is, and whose data a call reaches: the front + (`implementations/Nostro-Daemon.cpp`) and a worker's start + (`RunWorker`). +- What needs polkit's yes, and what is read or asked of the bank + before it: the worker's `Handle`, `Gate`, `HandleLookup` and `Prompt` + (`implementations/Nostro-Daemon-Worker.cpp`), design rule 9 and the + policy file. For a hunk there: what does a caller that polkit refuses + learn from the answer or the error, and what did the bank see? +- What the dialog says against what is then done: the summary, and the + details a polkit rule reads, are built in the worker (`Prompt`, + `Shown()`, `Counterparty`). A new field, or a new way for text from a + caller or the bank to reach a summary, is an input to attack: markup, + a control or bidirectional character, a line break, a second amount + or payee. A detail that can differ from what the call then does is a + way past an administrator's rule. +- The checkout (`Order::Read`, `ChooseAccount`, `PayOrder`, + `ErrorFor`), which the guide states as the exception to design + rule 9: what does an app learn that the README's "Checkout for apps" + does not already give it? +- Secrets (design rule 4): where a key, a token or the private key is + read, kept and passed (`CreatePrivateFile`, `ReadSecret`, a `Secret` + field, the sensitive mark on a message), and where one could surface: + a `Note`, an exception's message, a D-Bus error, a formatter, a log, + a core dump, a command line. +- The bank's side (`BunqConnector::Call`, `EnsureServerPublicKey`, + `OnAddBunq`): what is verified before it is used, what decides + between production and the sandbox, and what is sent again. A path + that can pay twice, or pay what was not shown, is a finding here as + well as the bug-prover's. +- The app and its debug build (design rule 12, and what the guide's + "Security considerations" say of `--debug-api`): debug code reachable + in another build, a Flatpak made of the debug build, or a loosening + of what `Ui_Type` refuses, is a finding. +- What is built and shipped: a dependency the range has `project.cpp` + name without a commit (the guide's "Dev environment" says which still + follow a branch, and why), a pin moved without the range saying to + what and why, a `lib/json.hpp` that is not upstream's file (the guide + names the commit and the blob id, and `git hash-object` settles it), + a Flatpak permission added, a hardening option dropped from the unit, + a secret or an echo of the environment added to the workflow, a step + of `check` that reaches what `publish` mounts. + +Stated limits are not findings. The README's "Security" and the guide's +"Security considerations" say what nostro does not protect against. A +range that leaves one as it is inherits it (`pre-existing`). One that +widens it, or builds on it, owns it. And one that changes what a user +is protected from changes the README's "Security" in the same range. + +What the tests pin is evidence to read. `ShouldServeEveryUser` is where +the policy file, the published XML and what a refused caller is told +are held; the guide's table of tests says what else it covers. A +protection the range adds, without a check there that fails without +it, is the `pK:absent` slot's. The fake bus answers as polkit whatever +the test told it to: it shows what nostrod does with an answer, not +what polkit answers. + +Semantics to read on disk rather than recall: libsystemd's headers +(`/run/host/usr/include/systemd/sd-bus.h`, `sd-bus-vtable.h`); the +format of a polkit policy +(`/run/host/usr/share/polkit-1/policyconfig-1.dtd`); OpenSSL's headers +(`/run/host/usr/include/openssl/`); Crafter.Network and Crafter.DB as +crafter-build cloned them +(`~/.cache/crafter.build/external/-/`, at the commit +`project.cpp` names for each outside the `--debug-api` build; a clone's +`.git/HEAD`, or the ref it names, says which commit it is at). A +crafter-build that runs as a Flatpak keeps its clones in that app's own +directory, which is not readable from here: a control that rests on a +dependency without a readable clone at the pinned commit is +`unverified`. Not on disk: what polkit answers and how each agent shows +a message (the guide's "Gotchas" record what was read and seen), what +systemd's options and Flatpak's permissions enforce, and bunq's API. A +control only they settle is `unverified`, with what would settle it. diff --git a/AGENTS.template.md b/AGENTS.template.md index f4384e9..dd21a73 100644 --- a/AGENTS.template.md +++ b/AGENTS.template.md @@ -41,6 +41,7 @@ Five C++26 modules, and a sixth in one build: | `docs/screenshots/` | The README's pictures of the app, on a phone's screen and in a desktop window, and `take.sh`, which takes them again on the made-up system; see "Looking at the app". | | `README.md`, `LICENSE`, `LICENSE.GPL` | The manual; the LGPL version 3, which the library, nostrod and the CLI are under, and the GPL version 3, which the LGPL adds its permissions to and which the app is under (design rule 13). | | `AGENTS.template.md`, `AGENTS.consumer.md` | The source of this file, and the notes for consumers. `AGENTS.md` is gitignored: edit the template. | +| `.review-gates/` | The pre-push review's `config.json` and this repository's lens sections (`lenses/`), read by Crafter.Review. Its `push/` and `trees/` are generated and gitignored. | | `.vscode/` | A build task and an lldb launch configuration, both stale; see "Gotchas". | | `bin/`, `build/` | Generated and gitignored. The library and the CLI are both named `nostro`, so one build leaves two `bin/nostro----/` directories: the library's (`libnostro.a`, the PCMs, `std.pcm`) and the executable's (`nostro`). Glob for the one holding `nostro`. nostrod builds into `bin/nostrod-…/`, the checkout library into `bin/nostro-checkout-…/`, the app into `bin/nostro-app-…/` with its fonts and Crafter.Graphics' shaders beside it (`bin/nostro-app-core-…/` is `Nostro.App`'s library), or under `files/bin/` there when it is packaged as a Flatpak. `build/crafter-debug` is the launcher of Crafter.Debug's client, `build/fake-system/` the state of the made-up system `run fake` starts, `build/flatpak-apps/` what `install` and `bundle` make of the app. | @@ -157,6 +158,7 @@ crafter-build clean # delete bin/ and build/ crafter-build test --banks=bunq # the tests in tests/, against a fake bunq; none talks to bunq itself tests/coverage.sh [profile runtime] # the tests with coverage: a report per file and every line no test ran crafter-build lint --banks=bunq # the Crafter.LintRules lite rules project.cpp registers, report only +crafter-build lint --banks=bunq --product=daemon # the same over nostrod's own source crafter-build lint --banks=bunq --product=app [--debug-api] # the same over the toolkit, the app and its window flatpak run --filesystem= org.flatpak.Builder --user --force-clean --repo=/repo --state-dir=/state /build packaging/flatpak/net.catcrafts.Nostrod.yaml crafter-build --banks=bunq --product=app --packaging=flatpak --march=x86-64-v3 --mtune=generic bundle # the app's Flatpak as one file; `install` installs it for you instead @@ -174,7 +176,7 @@ The app's packaging: `--packaging=flatpak` makes `bin/nostro-app-/files - `check`, for a pull request and a run by hand: the version check, the tests, the lint of the library, the CLI and the tests, and then both Flatpaks for aarch64. It runs cold and mounts nothing of the host. - `publish`, for a pushed tag `X.Y.Z`: the release checks, the tests and both Flatpaks. It then commits the two as `stable` into the Catcrafts Flatpak repository on the runner's host (`/var/www/flatpak`, signed with the key under `/etc/crafter-flatpak`, under the lock the other publishing workflows hold), puts each one's `.flatpakref` beside it with the repository's key in it, and makes release `X.Y.Z` on the forge with the two bundles, the ref files and their checksums. -A release is a tag, as it is for Crafter.Build and imsd-messages: a push without one runs nothing. `packaging/flatpak/release-version.sh` holds `NOSTRO_VERSION` in `project.cpp` to the newest `` of the app's metainfo, whose description is the release notes. For a tag it also checks that the tag is that version, annotated, signed by the owner as Forgejo verifies it, on master, and newer than every release there is. So a release is: bump both, commit, `git tag -s X.Y.Z -m 'Nostro X.Y.Z'`, and push master and the tag together. +A release is a tag, as it is for Crafter.Build and imsd-messages: a push without one runs nothing. `packaging/flatpak/release-version.sh` holds `NOSTRO_VERSION` in `project.cpp` to the newest `` of the app's metainfo, whose description is the release notes. For a tag it also checks that the tag is that version, annotated, signed by the owner as Forgejo verifies it, on master, and newer than every release there is. So a release is: bump both, commit, take that commit through the pre-push review until the owner approves its hash ("Commit and PR guidelines"), `git tag -s X.Y.Z -m 'Nostro X.Y.Z'` on the approved commit, and push master and the tag together. The workflow was written on 2026-11-19 and pushed without having run once: its first run is its test. What it needs, and how each stood that day: @@ -249,7 +251,7 @@ What a test cannot show (that the window draws what the frame says, in the right ## Code style -- `crafter-build lint --banks=bunq` reports nothing, and neither does it with `--product=app`, with `--debug-api` added, and with `--product=fake-system`: the first reaches the library, the CLI and the tests, and only the others the toolkit's, the app's and the window's sources. A finding at a C boundary (`main`'s `argv`, a `char*` an OpenSSL or POSIX call hands out) is suppressed with `// lint-disable-next-line ` and a comment saying why; anything else is fixed. The rules that need an AST cannot parse a file that `#include`s a standard header before `import std;` (the twelve that include `json.hpp`: four in the library, seven tests and the fake system), because the lint's libclang does not find libc++'s headers, so lint exits 1 for those alone until Crafter.Build issue #46 is fixed. Until then, name the headers through the environment and every rule runs on every file: `CPLUS_INCLUDE_PATH=`, which is `/app/include/c++/v1` in crafter-build's Flatpak (`flatpak run --env=CPLUS_INCLUDE_PATH=/app/include/c++/v1 net.catcrafts.CrafterBuild lint …`). Prefer C headers (``, not ``) elsewhere. Tests are linted like the rest. `const-local` sees `bool` and the built-in types, not `std::size_t` or `std::int32_t`: those are made `const` by hand. Lint a product after building it: the AST rules read that product's module files, and against ones from before a change they report nonsense, such as a vector of a type they do not find yet as a local that is never modified. +- `crafter-build lint --banks=bunq` reports nothing, and neither does it with `--product=daemon`, with `--product=app`, with `--debug-api` added, and with `--product=fake-system`: the first reaches the library, the CLI and the tests, the daemon's lists `implementations/nostrod.cpp` among its sources, and only the app's two reach the toolkit's, the app's and the window's sources. A finding at a C boundary (`main`'s `argv`, a `char*` an OpenSSL or POSIX call hands out) is suppressed with `// lint-disable-next-line ` and a comment saying why; anything else is fixed. The rules that need an AST cannot parse a file that `#include`s a standard header before `import std;` (the twelve that include `json.hpp`: four in the library, seven tests and the fake system), because the lint's libclang does not find libc++'s headers, so lint exits 1 for those alone until Crafter.Build issue #46 is fixed. Until then, name the headers through the environment and every rule runs on every file: `CPLUS_INCLUDE_PATH=`, which is `/app/include/c++/v1` in crafter-build's Flatpak (`flatpak run --env=CPLUS_INCLUDE_PATH=/app/include/c++/v1 net.catcrafts.CrafterBuild lint …`). Prefer C headers (``, not ``) elsewhere. Tests are linted like the rest. `const-local` sees `bool` and the built-in types, not `std::size_t` or `std::int32_t`: those are made `const` by hand. Lint a product after building it: the AST rules read that product's module files, and against ones from before a change they report nonsense, such as a vector of a type they do not find yet as a local that is never modified. - The first two lines of every source are `// SPDX-License-Identifier: LGPL-3.0-only`, or `GPL-3.0-only` in a source of the app (design rule 13 says which is which), and `// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®`, then a blank line. `project.cpp` carries them too. - Four-space indentation, LF, K&R braces with `} else {`, one declaration per statement. `if(`, `for(`, `while(`, `switch(` without a space in most files (`:Utils` has the space; match the file). Lines run long rather than wrap. - `import std;` everywhere; `#include`s only in a global module fragment (`module;` first), and only for OpenSSL, the vendored `json.hpp`, sd-bus and sd-event, and the POSIX calls of `:File`, `:Connector` and nostrod. `namespace fs = std::filesystem;` where paths appear. @@ -293,14 +295,16 @@ The checklist, from the bunq connector: ## Commit and PR guidelines - Patches go by mail to jorijnvdgraaf@catcrafts.net, as the README says. Branch off `master`. -- Take the commit voice from the sibling Crafter repositories: `type(scope): imperative summary` with `feat`, `fix`, `refactor`, `docs` or `build`, and the partition or the CLI as the scope (`bunq`, `account`, `currency`, `connector`, `file`, `bus`, `client`, `daemon`, `checkout`, `cli`, `ui`, `app`, `shell`, `debug`, `build`, `packaging`). The body says what was wrong, why, and how it was verified against the sandbox. Add a `Co-Authored-By:` trailer when an agent wrote it. +- Take the commit voice from the sibling Crafter repositories: `type(scope): imperative summary` with `feat`, `fix`, `refactor`, `docs` or `build`, and the partition or the CLI as the scope (`bunq`, `account`, `currency`, `connector`, `file`, `bus`, `client`, `daemon`, `checkout`, `cli`, `ui`, `app`, `shell`, `debug`, `build`, `packaging`). The body says what was wrong, why, and how it was verified against the sandbox. - The README is the manual: keep its CLI section true to `main.cpp` and "The app" true to the screens: what the one can do, the other can. Update `AGENTS.consumer.md` in the same change when a signature, a path, a default, a file format or an error behaviour consumers lean on changes; consumers pick it up on their next build. - A change to how the app looks or is laid out says in its commit how it was looked at: which screens, at which sizes, on what. When it changes a screen the README shows, the pictures are taken again (`docs/screenshots/take.sh`) in the same commit. - The app's version is `NOSTRO_VERSION` in `project.cpp`, and the newest release in `packaging/flatpak/net.catcrafts.Nostro.metainfo.xml` is the same: `packaging/flatpak/release-version.sh` fails on a tree where they differ, and CI runs it first. - A change to `Transaction` is a schema change (design rule 5), and the commit message says so. - A change to the D-Bus interfaces or the polkit policy changes the published contract (design rule 10); the XML, the policy and the test that holds them change together. - A change that moves code between the library and the app moves it between two licences (design rule 13), and its commit message says so. -- Never commit `bin/`, `build/`, `AGENTS.md`, or a `connectors.json`. +- Every push of new commits to `master` goes through Crafter.Review's pre-push review first, and goes out only once the owner approves the frozen hash. Run `crafter-review init` once in a fresh checkout or worktree: it writes the `/prepush` skill that drives the review, and the skill stays untracked. The lenses it runs are the approach, the bug-prover, the security lens and the commit truth, each with this repository's own section (`.review-gates/lenses/`): a lesson of a review that is nostro's goes into the section of the lens that should have caught it. CI does not run for a plain push, so the review's gate0, the commands in `.review-gates/config.json`, is the check before one: the version check, the tests, a build of each product, and the five lint runs "Code style" names. +- Every commit of a pushed range is GPG-signed and carries neither a `Co-Authored-By:` nor an `Assisted-by:` trailer in its message, whoever the trailer names. `freeze` refuses a range with a commit that breaks either (`requireSigned` and `aiTrailers` in `.review-gates/config.json`). The config names no `authors`, so who wrote a commit is not checked: a patch that came by mail keeps its author. +- Never commit `bin/`, `build/`, `AGENTS.md`, `.review-gates/push/`, `.review-gates/trees/`, or a `connectors.json`. ## Security considerations From 25d991658ff6d6763e2e9dfeec060016e39f1e6b Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Sun, 22 Nov 2026 13:31:18 +0100 Subject: [PATCH 2/5] docs: cut the README down to what a reader needs first The README had grown to 2,940 words (`wc -w README.md`): a table of the app's screens with a list of notes on how the app behaves under it, the checkout's method with its rules, errors and examples, and a subsection on polkit rules with one written out. It is 1,170 words now. What stays is what a reader needs to choose, install and use Nostro, and what they must know for their money's sake: how nostrod keeps the bank connections, the app's pictures with four notes under them, installing, the CLI's commands, a paragraph on the checkout that points at the interface's XML, and "Security" as a list whose last line points at the polkit policy. The README's warning against a rule that keeps an authorization moves into the comment of that policy file, which already describes the rule the README wrote out. The guide's commit guidelines now say that the README is kept short, and where what does not go into it goes. Two of the guide's sentences spoke of what the README says of each screen: the one is gone, the other no longer names the README. A third cited the README for what an app with access to the checkout can learn of an order, which the README no longer says: it stands without the citation. --- AGENTS.template.md | 10 +- README.md | 119 +++--------------- packaging/system/net.catcrafts.Nostro1.policy | 4 +- 3 files changed, 25 insertions(+), 108 deletions(-) diff --git a/AGENTS.template.md b/AGENTS.template.md index dd21a73..c35c089 100644 --- a/AGENTS.template.md +++ b/AGENTS.template.md @@ -124,7 +124,7 @@ The app end to end: - Accounts go to nostrod by IBAN, by name where the bank gave none; a connection by name, or by its number from a fresh `Accounts` listing when two share a name. - Which bank an account is with makes no difference outside the settings. No screen there names a bank, or a way to connect to one, in the app's own words: it says "your bank". `ShouldDriveTheApp` fails on a frame that does, excepting what nostrod and the bank say themselves: a note about a connector, a refusal with the call it refused, a link the bank made. What does differ by bank is asked of `:Banks`: a connection that pays between the user's own accounts only, as bunq's through OAuth, is `Connection::ownAccountsOnly`. It is marked Limited, a payment from it to anyone else is saved as a draft, and it cannot pay a request or a shop. - Adding a connection is three pages, from the settings and from the welcome alike: the banks (`add`), the bank's ways (`add:bunq`) and the way's form (`add:bunq:key`). The first two are built from `:Banks`. The form is the bank's own to draw and to check, in a file of the bank's (`Nostro.App-Bunq.cpp`), and its button ends in `App::Connect`, which is every bank's. -- **The screens** (`implementations/Nostro.App-Screens.cpp`, and a bank's own forms in that bank's file) are functions from that state to a frame. A window under 600 dp wide shows one page at a time, with the app's places along its bottom; a wider one has them down its left side, and from 900 dp the accounts too. A screen that shows the bank's own state (the accounts, an account, the cards) reads it again four ways, all one action (`Refresher`): Refresh in the bar, F5, Ctrl+R, and the page pulled down at its top. The README's "The app" says what each screen is for. +- **The screens** (`implementations/Nostro.App-Screens.cpp`, and a bank's own forms in that bank's file) are functions from that state to a frame. A window under 600 dp wide shows one page at a time, with the app's places along its bottom; a wider one has them down its left side, and from 900 dp the accounts too. A screen that shows the bank's own state (the accounts, an account, the cards) reads it again four ways, all one action (`Refresher`): Refresh in the bar, F5, Ctrl+R, and the page pulled down at its top. - **The window** (`Nostro.Ui.Shell`) is one sd-event loop that carries the compositor's connection, nostrod's bus, the desktop portal's bus and the timers. `Window` turns Crafter.Graphics' events into the `Context`'s, bringing time up to each and building a stale frame again first, and does what the `Context` wants afterwards (`Settle`, which the loop calls from a post source after every source that ran). A frame is drawn only when the compositor asks for one after something changed, or when it waits for one itself, having asked for another size (`onFrameOwed`): an idle window draws nothing. `Canvas` turns a `DrawList` into Crafter.Graphics' items, one dispatch per batch, from a pool of buffers per frame in flight. `Portal` reads the desktop's colour scheme and accent, and asks the desktop to open an address. - **`nostro-app`** puts them together, and has what looking at the window without a hand on it takes: `--size`, `--scale` (a phone's density on a desktop's display), `--theme`, `--route`, `--screenshot`, `--poke` and `--gallery`. It makes itself undumpable once the portal has seen it. Closing the window while a change is under way takes the window down and keeps the process until the answer has come. @@ -231,7 +231,7 @@ The bunq sandbox is still the check for what a fake cannot show. Since nostrod ( 4. A new sandbox account holds €0 and no payments. Fund it with `nostro request sugardaddy@bunq.com "Sugar Daddy" 50000`: it is paid within seconds. A hundred rows at once: `POST …/payment-batch` with `{"payments": […]}` (more than 200 exercises the paging). `curl` can call as the same user with the `sessionToken` from the scratch file, and sign with `openssl dgst -sha256 -sign` over the body using its `privateKey` PEM, base64, in `X-Bunq-Client-Signature`. A sandbox card (`POST /v1/user/{id}/card-debit` with `type: MASTERCARD`, `product_type: MASTERCARD_DEBIT`, a `name_on_card` out of `GET /v1/user/{id}/card-name` and a `pin_code_assignment`) stays a virtual one, `DEACTIVATED` at `VIRTUAL_DELIVERY`, whatever it is set to: `nostro cards` lists it as `VIRTUAL`, `cards freeze` and `unfreeze` are refused for it, and `cards lost` and `stolen` can be tried on it. OAuth stops at the token exchange: approving needs a person and the bunq app. 5. bunq allows 3 GETs, 5 POSTs and 2 PUTs per three seconds per endpoint and one session per 30 seconds; nostro waits a 429 out, so a burst of runs is slow rather than failing. Concurrent nostro processes queue on `connectors.lock`, so two never hold the same account's table. -The app against the sandbox takes both Flatpaks installed and a hand on the window: every row of the README's "The app" from the window, with real polkit dialogs. That had not been done on 2026-11-19; nor had anything on a phone. +The app against the sandbox takes both Flatpaks installed and a hand on the window, with real polkit dialogs. That had not been done on 2026-11-19; nor had anything on a phone. A bug fix comes with a test that fails without it, and states in its commit how it was reproduced; a new bank comes with tests against a fake of it and with the same check against its sandbox or live API. @@ -296,7 +296,7 @@ The checklist, from the bunq connector: - Patches go by mail to jorijnvdgraaf@catcrafts.net, as the README says. Branch off `master`. - Take the commit voice from the sibling Crafter repositories: `type(scope): imperative summary` with `feat`, `fix`, `refactor`, `docs` or `build`, and the partition or the CLI as the scope (`bunq`, `account`, `currency`, `connector`, `file`, `bus`, `client`, `daemon`, `checkout`, `cli`, `ui`, `app`, `shell`, `debug`, `build`, `packaging`). The body says what was wrong, why, and how it was verified against the sandbox. -- The README is the manual: keep its CLI section true to `main.cpp` and "The app" true to the screens: what the one can do, the other can. Update `AGENTS.consumer.md` in the same change when a signature, a path, a default, a file format or an error behaviour consumers lean on changes; consumers pick it up on their next build. +- The README is the manual, and is kept short: keep its CLI section true to `main.cpp` and what it says of the app true to the screens, and give a new feature a line there, or none. What a standard says is linked, not retold. How a screen works goes into this guide, what a caller needs into `AGENTS.consumer.md`, and what an administrator needs into the comment of `packaging/system/net.catcrafts.Nostro1.policy`. Update `AGENTS.consumer.md` in the same change when a signature, a path, a default, a file format or an error behaviour consumers lean on changes; consumers pick it up on their next build. - A change to how the app looks or is laid out says in its commit how it was looked at: which screens, at which sizes, on what. When it changes a screen the README shows, the pictures are taken again (`docs/screenshots/take.sh`) in the same commit. - The app's version is `NOSTRO_VERSION` in `project.cpp`, and the newest release in `packaging/flatpak/net.catcrafts.Nostro.metainfo.xml` is the same: `packaging/flatpak/release-version.sh` fails on a tree where they differ, and CI runs it first. - A change to `Transaction` is a schema change (design rule 5), and the commit message says so. @@ -310,11 +310,11 @@ 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. -- 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. +- 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 the policy file's comment 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"). +- 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. - 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. - Request bodies are `nlohmann::json` values serialised once (`dump` with invalid UTF-8 replaced), and the signature covers those exact bytes; nothing is spliced into JSON text by hand. Responses are used only after their server signature verifies. - 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. diff --git a/README.md b/README.md index ad3457f..6974d4d 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,16 @@ By making a open source app that interfaces with bank APIs. ## How Nostro runs -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: +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 them for every user of the machine. 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. -- 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. +- Looking at accounts, payments, requests and cards needs nothing more in your desktop session. +- Everything else asks for your password every time: whatever pays, and whatever changes something at your bank or in your bank connections. 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. ## The app -The app is a window for a phone or a desktop. On a phone it shows one page at a time, with Accounts, Cards and Settings along the bottom; in a wider window those are down the side, with your accounts beside them. It follows your desktop's light or dark look and its accent colour. +A window for a phone or a desktop, in your desktop's light or dark look. It does everything the `nostro` command does. On a phone, in the dark look: @@ -33,36 +31,14 @@ In a desktop window, in the light look and in the dark one: The accounts and the people in these pictures are made up. -It does everything the `nostro` command does: - -| In the app | What it is for | -|---|---| -| Accounts | Your accounts by bank connection, with their balances. Pay and Request start from any of them. | -| 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, 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. +- The Pay and Request forms send on their button, and your system's password dialog is where you confirm it: read what it says. Closing the dialog pays nothing. - 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 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. 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. -- The app needs nostrod installed (see Installing). Without it, it says so and how to get it. +- Press a line of a payment's, a request's or a card's details to copy it. +- With a keyboard: Tab moves, Enter presses, Escape goes back, F5 reads the screen again and Ctrl+F searches. ## Installing -nostrod and the `nostro` command come as a Flatpak, `net.catcrafts.Nostrod`, installed for the whole system. A Flatpak cannot install a few system files Nostro needs: nostrod's user, its D-Bus and polkit policies, its systemd unit, and the `nostro` command. Install both as root. The Flatpak comes from the Catcrafts Flatpak repository, which the first line adds: +nostrod and the `nostro` command come as a Flatpak, `net.catcrafts.Nostrod`, installed for the whole system. A Flatpak cannot install a few system files Nostro needs: nostrod's user, its D-Bus and polkit policies, its systemd unit, and the `nostro` command. Install both as root: ``` flatpak remote-add --system --if-not-exists catcrafts https://flatpak.catcrafts.net/catcrafts.flatpakrepo @@ -70,15 +46,13 @@ flatpak install --system catcrafts net.catcrafts.Nostrod # the Flatpak packaging/system/install.sh # the system files ``` -The app is a Flatpak of its own, `net.catcrafts.Nostro`, in the same repository, which each user can install for themselves: +The app is a Flatpak of its own, `net.catcrafts.Nostro`, which each user can install for themselves; `install.sh --app` installs it for every user instead: ``` flatpak remote-add --user --if-not-exists catcrafts https://flatpak.catcrafts.net/catcrafts.flatpakrepo flatpak install --user catcrafts net.catcrafts.Nostro ``` -`packaging/system/install.sh --app` installs it for every user instead, together with the rest. The app can reach your display, your graphics card and nostrod, and nothing else: no network and none of your files. - `packaging/system/uninstall.sh` removes everything again. Your bank connections stay in `/var/lib/nostro` until you give it `--purge`. ## CLI @@ -102,11 +76,9 @@ nostro cards [freeze|unfreeze|lost|stolen {card id}] nostro checkout account [{account}] # the account apps may ask you to pay from, see Checkout ``` -- `{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. 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. +- `{account}` is an account's name or its IBAN. `{to}` and `{from}` are an IBAN, an e-mail address, or a phone number starting with `+`. - 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. ## Supported banks @@ -114,39 +86,7 @@ nostro checkout account [{account}] # the account apps may ask y ## Checkout for apps -An app, such as a shop, can have the user's Nostro pay an order. Nostro pays it from the account the user chose once, in the app's settings or with `nostro checkout account {account}`, after the user has confirmed the payment with their password at a prompt that shows the amount, the payee, the reference and that account. The app never names or sees the account, and gets back only the payment's id. An account connected through OAuth cannot pay a shop, so it cannot be chosen. - -Apps talk to `net.catcrafts.Nostro1.Checkout` on the system bus. A Flatpak app asks for it with `--system-talk-name=net.catcrafts.Nostro1.Checkout` in its finish-args, which reaches nothing else of Nostro. The interface is one method, documented in [packaging/dbus/net.catcrafts.Nostro1.Checkout.xml](packaging/dbus/net.catcrafts.Nostro1.Checkout.xml): - -``` -Pay(payeeIban s, payeeName s, amount x, currency s, reference s, options a{sv}) -> (paymentId t, results a{sv}) -``` - -- The payee is an IBAN. The amount is in the currency's smallest unit (`1250` is €12.50), and the currency is `EUR`. The reference is your order number: it becomes the payment's description, and it tells orders apart. -- Allow interactive authorization on the call, make the call asynchronously, and give it a timeout of minutes, because the user may take a while at the prompt. -- An order is paid once. Calling `Pay` again with the same IBAN and reference, after a timeout or a crash, returns the first payment with `repeated` set to true in `results`, without asking the user. While the user is still at the prompt, the second call waits for the first. The same reference with another amount is refused. -- `net.catcrafts.Nostro1.Error.Cancelled` means the user did not confirm, and `NoCheckoutAccount` that they have not chosen an account. `org.freedesktop.DBus.Error.ServiceUnknown` means Nostro is not installed. The XML lists the other errors. -- Ignore keys you do not know in `results`, because later versions may add some. Nostro ignores options it does not know. -- A payment id is not a receipt. Confirm the money arrived with your own bank. - -From a shell: - -``` -busctl call --system --timeout=10min net.catcrafts.Nostro1.Checkout /net/catcrafts/Nostro1 \ - net.catcrafts.Nostro1.Checkout Pay 'ssxssa{sv}' NL91ABNA0417164300 'Shop BV' 1250 EUR order-1234 0 -``` - -Generate a proxy from the XML with `gdbus-codegen` (GLib and GTK), `qdbusxml2cpp` (Qt) or `zbus-xmlgen` (Rust). A C++ app built with Crafter.Build can depend on Nostro with `--product=checkout` instead. That builds the `Nostro.Checkout` module alone, which links only libsystemd: - -```cpp -import Nostro.Checkout; - -const Nostro::Checkout::Paid paid = Nostro::Checkout::Pay({.payeeIban = "NL91ABNA0417164300", .payeeName = "Shop BV", .amount = 1250, .reference = "order-1234"}); -``` - -`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. 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. +An app, such as a shop, can have Nostro pay an order from the account you chose for that, in the app's settings or with `nostro checkout account {account}`, once you confirm the payment with your password. It calls `Pay` of `net.catcrafts.Nostro1.Checkout` on the system bus, which [packaging/dbus/net.catcrafts.Nostro1.Checkout.xml](packaging/dbus/net.catcrafts.Nostro1.Checkout.xml) documents, or links the `Nostro.Checkout` module (`crafter-build --product=checkout`). It gets a payment id back, which is not a receipt: confirm the money arrived with your own bank. ## Contributing @@ -164,41 +104,16 @@ 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 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 `+`. +- Programs you run cannot read your bank connections, and cannot pay or change anything at your bank without your password. They can look: in your desktop session any of them can read your accounts, payments, requests and cards. +- The app is one of those programs. It holds no key, and its Flatpak has no network and none of your files. +- The password dialog is your desktop's. A program could draw one that looks the same, so type your password only for something you asked for, and read what the dialog says. - 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. - -### 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. +- The bank connections are not encrypted on disk: use full-disk encryption. +- An administrator can change what asks for a password, with polkit rules for the actions in [the policy](packaging/system/net.catcrafts.Nostro1.policy). A rule cannot tell Nostro from any other program you run, and one that lets `Pay` or `Change` pass makes one press on a form a payment or a draft. ## License -Nostro has two licences, and each source file says in its first line which one it is under: - -- The library, nostrod, the `nostro` command and the checkout library are LGPL-3.0-only, see [LICENSE](LICENSE). A program under another licence can be built on the library or the checkout. -- The app is GPL-3.0-only, see [LICENSE.GPL](LICENSE.GPL): its screens, the toolkit they are built with and its window (the modules `Nostro.Ui`, `Nostro.App` and `Nostro.Ui.Shell`, and `nostro-app`). A program built from any of it is under the GPL as a whole. +The library, nostrod, the `nostro` command and the checkout library are LGPL-3.0-only, see [LICENSE](LICENSE). The app is GPL-3.0-only, see [LICENSE.GPL](LICENSE.GPL): the modules `Nostro.Ui`, `Nostro.App` and `Nostro.Ui.Shell`, and `nostro-app`. The app is set in Noto Sans, under the SIL Open Font License ([assets/OFL.txt](assets/OFL.txt)); [packaging/licenses/NOTICE](packaging/licenses/NOTICE) lists what else the Flatpaks carry. diff --git a/packaging/system/net.catcrafts.Nostro1.policy b/packaging/system/net.catcrafts.Nostro1.policy index 01bbb95..e43f0e7 100644 --- a/packaging/system/net.catcrafts.Nostro1.policy +++ b/packaging/system/net.catcrafts.Nostro1.policy @@ -20,7 +20,9 @@ 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". + action.lookup("status") is "DEACTIVATED"; without that test of status it would let every change 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. 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 From b43ab124a6badf78b310ec34b9417d40ba066c8d Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Sun, 22 Nov 2026 13:35:51 +0100 Subject: [PATCH 3/5] feat: open payto links on the pay form, and take the checkout over D-Bus out An app could have nostrod pay an order: it called Pay of net.catcrafts.Nostro1.Checkout on the system bus, and nostrod paid from an account the user had chosen, after a dialog of its own. On 2026-11-22 the owner decided that a link takes its place. The app registers for payto links (RFC 8905), so that an app or a website can hand one to the desktop, and shows a link as its pay form filled in. The link: - The app's desktop entry takes the scheme (Exec=nostro-app %u, MimeType=x-scheme-handler/payto), and nostro-app takes an argument that is no option as a link: it overwrites it in argv and hands it to App::Open once the app has started. - ReadPaymentLink (Nostro.App:Forms) reads payto://iban/ with the options amount, receiver-name and message, and refuses a link rather than guess at it, in a sentence of the app's own with nothing of the link in it. Among what it refuses: an IBAN whose check digits do not hold, one of the three options given twice, instruction, a comma in the amount, and a name or a message with a code point that is Unshown, or Blank and no plain space. - A link that is read waits until the accounts are read and DefaultCheckoutAccount has answered or failed, with a line on the accounts' page. Then App::TakeLink fills in the pay form, which says in a banner that a link filled it in, and with more than one account opens it under the choice of accounts that the form's From row has. A link pays nothing: the form's button sends, and polkit's dialog confirms as for any payment (design rule 12, and 14, which is new). - Unshown and Blank are the two tables the worker's Shown() works from. They move into Nostro:Utils, where the app's reader asks them too. The move is within the library. The reader holds a link's name to those two and to no more of Shown(): a name with an & is read, and the dialog shows it with a + as it does any name. The checkout: - nostrod serves one interface under one bus name. Gone are net.catcrafts.Nostro1.Checkout with its XML and its activation file, the polkit action Checkout, the module Nostro.Checkout with --product=checkout, and the worker's record of orders. That changes the published contract after a release, 0.0.0, and design rule 10 records it as the owner's decision. - DefaultCheckoutAccount and SetDefaultCheckoutAccount keep their names and signatures. The account they keep is where a link's pay form starts: nostrod's dialog for choosing it says "have pay links start from", the app's setting reads "Pay links start from", and `nostro checkout account` prints "pay links start from". - The D-Bus policy still lets nostrod own the old name: the nostrod of 0.0.0 asks for it when it starts, and the system files can be newer than the Flatpak it runs from. install.sh removes the old name's activation file. A user's checkouts.cdb is read by nothing any more, and is left where it is. - The Arch package stops installing the checkout's two files, and its pkgrel goes up to 2. Where makepkg -si finds a package of the version already built it installs that one again, which would bring the activation file back. The guide now says that pkgrel goes up with a change to what the package installs. - Bus::Interface goes too: the worker called it in two places, to tell a call to the checkout from one to the main interface. The review's own files follow. gate0 loses the build of --product=checkout, and the three lens sections that named the checkout no longer do, and ask about a link. The README has "Pay links" in place of "Checkout for apps", and AGENTS.consumer.md says what the app reads of a link. Its line on lib/json.hpp no longer gives a release: the file is of none, and the guide names its commit. The pay form and the accounts' page change only by a banner each, shown while a link is in play, which docs/screenshots/take.sh never has: the README's pictures stand. Tests: ShouldValidateForms reads and refuses links and fills the form from one. ShouldDriveTheApp opens links against a real nostrod on the fake bus: before the accounts are known, with no account, with one and with several, with the accounts known and the system bus gone, for a second user whose first connection pays their own accounts only, one that cannot be read, one whose name has an &, and through polkit's dialog to the payment. It now counts nostrod's answers to hold that the account pay links start from is read again once a connection is removed: the check it had there passed without that. ShouldHandleMoneyAndText holds the two tables at the ends of their ranges. ShouldServeEveryUser holds that nostrod serves no checkout, that the bus's policy lets an older nostrod own the old name, and the account pay links start from. ShouldRunCommands holds the CLI's wording. The review's gate0 passes at this commit: the version check, 17 tests, the builds of the CLI, the library, nostrod, the fake system, the app and its --debug-api build, and five lint runs that report nothing. tests/coverage.sh reports lines, functions and regions at 100.00%. Looked at on 2026-11-22 on the made-up system (run fake), on a desktop (KWin at a scale of 1.85). At 420x760, at --scale 3 --size 360x760 and at 1100x720 in the light look: a link's pay form under the choice of accounts, the form after a tap beside that choice, and the accounts' page while a link waits, its line above the rows that stand in for the accounts (--bank-delay 10000). At 420x760: that line above what the page says when the accounts cannot be read (--polkit deny) and above the accounts themselves (--polkit slow, the link opened in the running app), the settings' row and page for the account pay links start from, the sheet for a link that cannot be read, and with --empty the sheet for no account. --- .review-gates/config.json | 1 - .review-gates/lenses/repo-better-solution.md | 7 +- .review-gates/lenses/repo-bug-prover.md | 10 +- .review-gates/lenses/repo-security.md | 14 +- AGENTS.consumer.md | 35 +- AGENTS.template.md | 75 ++-- README.md | 18 +- implementations/Nostro-Bus.cpp | 4 - implementations/Nostro-Client.cpp | 4 +- implementations/Nostro-Daemon-Worker.cpp | 326 ++------------- implementations/Nostro-Daemon.cpp | 28 +- implementations/Nostro.App-App.cpp | 106 ++++- implementations/Nostro.App-Forms.cpp | 170 ++++++++ implementations/Nostro.App-Screens.cpp | 19 +- implementations/Nostro.Checkout.cpp | 121 ------ implementations/Nostro.DebugCommands.cpp | 18 + implementations/main.cpp | 12 +- implementations/nostro-app.cpp | 25 +- interfaces/Nostro-Bus.cppm | 27 +- interfaces/Nostro-Client.cppm | 4 +- interfaces/Nostro-Utils.cppm | 35 ++ interfaces/Nostro.App-App.cppm | 17 +- interfaces/Nostro.App-Forms.cppm | 29 +- interfaces/Nostro.Checkout.cppm | 73 ---- packaging/arch/PKGBUILD | 4 +- .../dbus/net.catcrafts.Nostro1.Checkout.xml | 54 --- packaging/dbus/net.catcrafts.Nostro1.xml | 14 +- .../flatpak/net.catcrafts.Nostro.desktop | 3 +- .../net.catcrafts.Nostrod.metainfo.xml | 3 - packaging/system/install.sh | 8 +- .../net.catcrafts.Nostro1.Checkout.service | 8 - packaging/system/net.catcrafts.Nostro1.conf | 9 +- packaging/system/net.catcrafts.Nostro1.policy | 23 +- packaging/system/nostrod.service | 8 +- packaging/system/uninstall.sh | 1 + project.cpp | 38 +- tests/ShouldAnswerAsynchronously/main.cpp | 2 +- tests/ShouldDriveTheApp/main.cpp | 392 +++++++++++++++++- tests/ShouldHandleMoneyAndText/main.cpp | 33 +- tests/ShouldRunCommands/main.cpp | 10 +- tests/ShouldServeEveryUser/main.cpp | 258 ++---------- tests/ShouldValidateForms/main.cpp | 182 +++++++- 42 files changed, 1234 insertions(+), 994 deletions(-) delete mode 100644 implementations/Nostro.Checkout.cpp delete mode 100644 interfaces/Nostro.Checkout.cppm delete mode 100644 packaging/dbus/net.catcrafts.Nostro1.Checkout.xml delete mode 100644 packaging/system/net.catcrafts.Nostro1.Checkout.service diff --git a/.review-gates/config.json b/.review-gates/config.json index 7e24633..b64b28b 100644 --- a/.review-gates/config.json +++ b/.review-gates/config.json @@ -37,7 +37,6 @@ "crafter-build --banks=bunq --lib", "crafter-build --banks=bunq --product=daemon", "CPLUS_INCLUDE_PATH=/app/include/c++/v1 crafter-build lint --banks=bunq --product=daemon", - "crafter-build --product=checkout", "crafter-build --banks=bunq --product=fake-system", "CPLUS_INCLUDE_PATH=/app/include/c++/v1 crafter-build lint --banks=bunq --product=fake-system", "crafter-build --banks=bunq --product=app", diff --git a/.review-gates/lenses/repo-better-solution.md b/.review-gates/lenses/repo-better-solution.md index e3c101b..f8f2f37 100644 --- a/.review-gates/lenses/repo-better-solution.md +++ b/.review-gates/lenses/repo-better-solution.md @@ -16,7 +16,7 @@ the range. The layers are the guide's "Project overview": the library and its connectors, nostrod's front and its workers, the CLI, -`Nostro.Checkout`, the toolkit, the app, the window, `project.cpp`, the +the toolkit, the app, the window, `project.cpp`, the packaging and the one workflow. Read there, and in design rules 1, 8, 11, 12 and 13, what belongs in which before judging where a change sits. The questions this repository adds to the charter's: @@ -27,9 +27,10 @@ sits. The questions this repository adds to the charter's: - Does the window (`Nostro.Ui.Shell`, `implementations/nostro-app.cpp`, `Nostro.DebugCommands`) decide something that design rule 11 wants in the toolkit or the app, as a function a test can call? -- Does anything of the library, nostrod, the CLI or `Nostro.Checkout` - import or include anything of the app (design rule 13)? +- Does anything of the library, nostrod or the CLI import or include + anything of the app (design rule 13)? - Does a bank's own code sit where the guide's "Adding a bank" puts it? +- Does a link do more than fill in the pay form (design rule 14)? Search first: - The partitions' own helpers, which the guide's "Project overview" diff --git a/.review-gates/lenses/repo-bug-prover.md b/.review-gates/lenses/repo-bug-prover.md index 86bbf90..8c58be3 100644 --- a/.review-gates/lenses/repo-bug-prover.md +++ b/.review-gates/lenses/repo-bug-prover.md @@ -22,19 +22,19 @@ the code disagree, the code wins. `implementations/Nostro-Bunq.cpp`. Read there what is sent again and when, what is verified and what is not, and what a failure says about whether a write went through. Then ask, for the path the range - touches, what a second sending pays twice. The checkout's record - (`PayOrder`) is the same question on disk. + touches, what a second sending pays twice. - Money, text and time from outside: amounts (`ParseAmount`, `FormatAmount`; design rule 3), text from the bank or a caller on its way to a dialog, a terminal or a screen (`Shown()`, the toolkit's - `:Text` and `:Edit`), JSON from the bank, and days a person typed + `:Text` and `:Edit`), a link (`ReadPaymentLink`), JSON from the bank, + and days a person typed (`ParseLocalDate`, `ParseLocalDateEnd`). Attack the edges: overflow, a sign, zero, bytes that are not UTF-8, a DST change, a time zone that is not the test's. - Files: `connectors.json` and its lock (`implementations/Nostro-Connector.cpp`), the Crafter.DB tables - (`implementations/Nostro-Account.cpp`, and the checkout's in the - worker), a state directory an earlier release wrote. What Crafter.DB + (`implementations/Nostro-Account.cpp`), + a state directory an earlier release wrote. What Crafter.DB does about a second writer, an order, a flush and a migration is its own: read it, do not recall it. - The app (`Nostro.App` on `Nostro.Ui`): state changed by nostrod's diff --git a/.review-gates/lenses/repo-security.md b/.review-gates/lenses/repo-security.md index 3fe0af2..5e753a2 100644 --- a/.review-gates/lenses/repo-security.md +++ b/.review-gates/lenses/repo-security.md @@ -1,9 +1,9 @@ ## This repository: Nostro Nostro holds people's bank keys and moves their money. Its stated -security model is `README.md` ("How Nostro runs", "Checkout for apps", +security model is `README.md` ("How Nostro runs", "Pay links", "Security"), the contributor guide `AGENTS.template.md` ("nostrod end -to end", design rules 4, 9, 10 and 12, "Security considerations"; +to end", design rules 4, 9, 10, 12 and 14, "Security considerations"; `AGENTS.md` is generated from it and is not in the tree) and the files that are the model as shipped: `packaging/system/net.catcrafts.Nostro1.policy` (each polkit action and @@ -26,7 +26,8 @@ unit's hardening and a file's mode. The actors to write down, each with what the model above lets it do: a local user, whom nostrod knows by the uid the bus gives for the caller; any program that user runs, the CLI and the app among them, which -neither polkit nor nostrod can tell apart; an app at checkout; the +neither polkit nor nostrod can tell apart; whoever wrote a link the app +is opened with; the bank; polkit and its agent; an administrator, and root; a build, which runs each dependency's `project.cpp`; the workflow's two jobs. @@ -46,10 +47,9 @@ The decision points, each with where to read it: a control or bidirectional character, a line break, a second amount or payee. A detail that can differ from what the call then does is a way past an administrator's rule. -- The checkout (`Order::Read`, `ChooseAccount`, `PayOrder`, - `ErrorFor`), which the guide states as the exception to design - rule 9: what does an app learn that the README's "Checkout for apps" - does not already give it? +- A link (`ReadPaymentLink`, `App::Open`, `TakeLink`; design rule 14): + what does whoever wrote one decide that the pay form does not show + the user, and what does it learn back? - Secrets (design rule 4): where a key, a token or the private key is read, kept and passed (`CreatePrivateFile`, `ReadSecret`, a `Secret` field, the sensitive mark on a message), and where one could surface: diff --git a/AGENTS.consumer.md b/AGENTS.consumer.md index 9223b26..9dba527 100644 --- a/AGENTS.consumer.md +++ b/AGENTS.consumer.md @@ -1,17 +1,18 @@ ## nostro -nostro is a banking client for Linux in four parts. The library is a C++26 module, `import Nostro;`, that talks to a bank's API directly (bunq so far), keeps the credentials in one private JSON file, caches transactions in Crafter.DB tables, and lists, syncs, pays, requests and schedules. nostrod is a system daemon that runs that library for every local user, one worker process each, behind D-Bus and polkit. The `nostro` CLI and the Nostro app, a window for a phone or a desktop, are clients of nostrod. The app's own modules (`Nostro.Ui`, `Nostro.App`, `Nostro.Ui.Shell`) are built for the app and its tests alone, and are GPL-3.0-only where the library is LGPL-3.0-only: `--lib` does not hand them to a consumer. A consumer does one of three things: +nostro is a banking client for Linux in four parts. The library is a C++26 module, `import Nostro;`, that talks to a bank's API directly (bunq so far), keeps the credentials in one private JSON file, caches transactions in Crafter.DB tables, and lists, syncs, pays, requests and schedules. nostrod is a system daemon that runs that library for every local user, one worker process each, behind D-Bus and polkit. The `nostro` CLI and the Nostro app, a window for a phone or a desktop, are clients of nostrod. The app's own modules (`Nostro.Ui`, `Nostro.App`, `Nostro.Ui.Shell`) are built for the app and its tests alone, and are GPL-3.0-only where the library is LGPL-3.0-only: `--lib` does not hand them to a consumer. A consumer does one of two things: - links the library and holds the credentials itself, in its own process (`--lib --banks=bunq`); -- talks to nostrod through `Nostro::Client` (`--lib --banks=bunq --dbus`), as the CLI does; -- or, as an app that only needs a customer to pay an order, links the `Nostro.Checkout` module alone (`--product=checkout`), see "Checkout". +- or talks to nostrod through `Nostro::Client` (`--lib --banks=bunq --dbus`), as the CLI does. -Everything is in `namespace Nostro`: the OpenSSL helpers in `Nostro::Crypto`, the D-Bus names and wire in `Nostro::Bus`, the checkout in `Nostro::Checkout`. Linux only (Crafter.DB, the POSIX calls in its file layer, libsystemd), built by crafter-build's clang 23 with `import std;`. LGPL-3.0-only; `lib/json.hpp` is nlohmann/json 3.12.0 (MIT). The README is the user-facing manual; these notes are its `AGENTS.consumer.md`: a fix to them goes there, not into the copy crafter-build writes. +An app that only wants a customer to pay an order links nothing of nostro: it opens a link, see "Having a customer pay". + +Everything is in `namespace Nostro`: the OpenSSL helpers in `Nostro::Crypto`, the D-Bus names and wire in `Nostro::Bus`. Linux only (Crafter.DB, the POSIX calls in its file layer, libsystemd), built by crafter-build's clang 23 with `import std;`. LGPL-3.0-only; `lib/json.hpp` is nlohmann/json (MIT). The README is the user-facing manual; these notes are its `AGENTS.consumer.md`: a fix to them goes there, not into the copy crafter-build writes. ### Building against it - `GitProject` with nostro's repository, or `LocalProject({ .projectFile = "/project.cpp", .args = nostroArgs })` for a checkout, into `cfg.dependencies`. `nostroArgs` is your own `ProjectArgs()` plus `--lib` and `--banks=bunq`, built once inside `CrafterBuildProject`: without `--lib` nostro's `project.cpp` returns the CLI executable configuration (with the library as its dependency, which you cannot import from), and without `--banks=` it throws "must enable atleast one bank" and the whole build stops at load. `--banks=` is a comma-separated list and `bunq` is the only name it accepts. -- `--dbus` with `--lib` adds the partitions that talk to nostrod, `:Bus`, `:Client` and `:Daemon`, and links `-lsystemd` (sd-bus) for you; it needs bunq on, since the wire carries bunq's types. Without it the library does not depend on libsystemd. `--product=checkout` instead returns the `nostro-checkout` library alone: the module `Nostro.Checkout`, needing neither `--lib` nor `--banks=`, and linking libsystemd and nothing else of nostro's (no OpenSSL, Crafter.Network or Crafter.DB). +- `--dbus` with `--lib` adds the partitions that talk to nostrod, `:Bus`, `:Client` and `:Daemon`, and links `-lsystemd` (sd-bus) for you; it needs bunq on, since the wire carries bunq's types. Without it the library does not depend on libsystemd. - nostro strips its own args (`--lib`, `--banks=`, `--dbus`, `--product=`, `--debug-api`, `--coverage`, `--profile-runtime=`) from what it hands its dependencies and forwards the rest, adding `--no-quic` for Crafter.Network: nostro speaks HTTP/1.1 only, and msquic would tie the binary to the building user's cache. A consumer that also loads Crafter.Network gives it that same list, `--no-quic` included, and Crafter.DB the list without it, or the build stops with two loads that disagree on their args. - nostro's `project.cpp` loads two build helpers by `#pragma crafter dependency`, Crafter.LintRules and, at a pinned commit, Crafter.Debug's: loading nostro fetches and builds both for the host, whatever is built of it. Crafter.Debug's library itself is only in nostro's own app, under `--debug-api`. - What comes with it: Crafter.Network (with Crafter.Thread behind it), Crafter.DB, `-lssl -lcrypto`, and with `--dbus` `-lsystemd`, all as link flags you do not declare. Nothing in nostro uses the thread pool, so `ThreadPool::Start()` is not needed for it. @@ -26,6 +27,7 @@ Everything is in `namespace Nostro`: the OpenSSL helpers in `Nostro::Crypto`, th - `ParseTimestamp("2026-10-31 12:34:56.123456")` is a `std::chrono::system_clock::time_point`, read as UTC: exactly `YYYY-MM-DD HH:MM:SS`, optionally `.` and one to six fraction digits, no zone, or `std::runtime_error("malformed timestamp '…'")`. `FormatTimestamp` is its inverse, bunq's format. libc++'s `system_clock` ticks in microseconds, which is also what the tables store. - For dates a person types: `ParseLocalDate("2026-10-31")` or `ParseLocalDate("2026-10-31 09:30")` in the local time zone (through `mktime`), or `std::runtime_error` naming the format; `ParseLocalDate(day, 1)` is the midnight that ends `day`, counted by the calendar, so a day the clocks change is 23 or 25 hours, and `ParseLocalDateEnd(text)` the last moment a range ending at `text` includes (the end of that day for a date alone). `FormatLocalTime(time)` is `"YYYY-MM-DD hh:mm"` in local time. - `UrlEncode` percent-encodes all but RFC 3986's unreserved characters; `UrlDecode` undoes it and reads `+` as a space; `QueryParameter(url, name)` is the decoded value from the query string, or `std::nullopt`. `EscB(text)` escapes text for inside a JSON string literal; nostro itself no longer builds JSON by hand. +- `Unshown(codePoint)` is whether a Unicode code point draws nothing or tells text where to go, and `Blank(codePoint)` whether it is a space of any width, U+0020 among them, or U+2800, the Braille pattern without a dot. Both are `constexpr` and `noexcept` and take a `std::uint32_t`; decoding UTF-8 is yours. nostrod's worker drops the first from what it puts into a password dialog, and turns a run of the second into one plain space, none leading or trailing. ### Connectors, the config file and the process @@ -68,18 +70,18 @@ nostrod is the system daemon that holds every local user's connectors, in a work - 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). 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. +- 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::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 +### Having a customer pay -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. +An app that wants a customer to pay an order links nothing of nostro and calls nothing of nostrod: it opens a `payto://iban/…` link (RFC 8905), and the Nostro app shows it as its pay form filled in, for the user to check, change and confirm with their password. What the app reads of a link: -- `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, 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. +- `payto://iban/?amount=EUR:12.50&receiver-name=&message=`, the values percent-encoded, which `UrlEncode` does. A BIC and a `/` may come before the IBAN, and are left out. The amount is `EUR`, a colon and digits, with a point and one or two more digits or without, as `FormatAmount(1250, Currency::Euro)` writes one (`12.50`); without `amount` the user fills it in. The name is at most 70 code points, the message 140, and the link 4096 bytes. +- A link the app refuses gets a sentence of the app's own, with nothing of the link in it. Among what it refuses: an IBAN whose check digits do not hold; `amount`, `receiver-name` or `message` given twice, where an option's name counts with its escapes undone and in small letters; `instruction`; a `#`; a `%` that is no escape in one of those values; a name or a message that is not UTF-8, or has a code point in it that is `Unshown`, a noncharacter (the last two of a plane), or `Blank` and no plain space; a currency other than EUR; an amount that is zero, or has a sign, a space or a comma in it. Other options are passed over. +- A `+` in a value is read as a space (`UrlDecode`): write `%20` for a space and `%2B` for a plus. +- The app tells whoever opened the link nothing. See the payment arrive at your own bank. +- The checkout over D-Bus that 0.0.0 has is gone: `net.catcrafts.Nostro1.Checkout`, the module `Nostro.Checkout` and `--product=checkout`, which is now an unknown product, and with them `Bus::actionCheckout`, `Bus::checkoutMethods` and `Bus::errorNoCheckoutAccount`. `Client::DefaultCheckoutAccount` and `SetDefaultCheckoutAccount` stayed: the account they keep is where the app's pay form starts for a link. ### Errors @@ -96,7 +98,7 @@ An app that only needs a customer to pay an order links `Nostro.Checkout` (`--pr ### Testing a consumer - Point `XDG_CONFIG_HOME` and `XDG_CACHE_HOME` at a scratch directory before the process starts, or set `Nostro::configPath` and `cachePath` first thing in `main`. No `connectors.json` needs seeding. -- A consumer of `Client` or of `Nostro.Checkout` needs nostrod on a system bus, and a build sandbox has none. nostro's `tests/Support/FakeBus.inc` is one in the test's own process: the bus driver, logind and polkit (with scripted answers: allow, a password, deny, a closed dialog, none, slow), giving each connection a uid of the test's choosing. Set `DBUS_SYSTEM_BUS_ADDRESS` to `Fake::Bus::Address(path)` before any thread starts, and start nostrod as a process of its own: `tests/ShouldServeEveryUser` compiles `implementations/nostrod.cpp` in with its `main` renamed and runs its own executable again as nostrod (`Fake::StartNostrod`), pointed at a fake bunq through the environment (`Fake::Bunq::ExportRedirect`, `RedirectFromEnvironment`). +- A consumer of `Client` needs nostrod on a system bus, and a build sandbox has none. nostro's `tests/Support/FakeBus.inc` is one in the test's own process: the bus driver, logind and polkit (with scripted answers: allow, a password, deny, a closed dialog, absent, silent or slow), giving each connection of the test's own process a uid of the test's choosing (nostrod's keep their own). Set `DBUS_SYSTEM_BUS_ADDRESS` to `Fake::Bus::Address(path)` before any thread starts, and start nostrod as a process of its own: `tests/ShouldServeEveryUser` compiles `implementations/nostrod.cpp` in with its `main` renamed and runs its own executable again as nostrod (`Fake::StartNostrod`), pointed at a fake bunq through the environment (`Fake::Bunq::ExportRedirect`, `RedirectFromEnvironment`). - Without bunq: `RedirectTo` a fake (see "For tests" above), as every one of nostro's own tests does. - A throwaway bunq user: `POST https://public-api.sandbox.bunq.com/v1/sandbox-user-person` (or `-company`) without authentication returns `Response[0].ApiKey.api_key`. Pass it to `Create` with `"*"` and `EnvironmentOfKey(key)`, then `SaveConnectors()`. The new account holds €0; `account.Request("sugardaddy@bunq.com", "Sugar Daddy", 50000, Currency::Euro, "…")` is paid within seconds, and the payment appears in the next `GetNewTransactions(account)`. A second user to pay to comes from the same endpoint: its IBAN is on its account, and its e-mail and phone aliases are in the creation response. - Rate limits are waited out, but a burst slows everything down; keep test runs light, and let one process end before the next starts (the lock makes it wait anyway). @@ -108,10 +110,9 @@ An app that only needs a customer to pay an order links `Nostro.Checkout` (`--pr - the bunq types: `BunqEnvironment`, `BunqEndpoint`, `BunqError`, `BunqCounterparty`, `BunqLabel`, `BunqPaymentRequest`, `BunqIncomingRequest`, `BunqSchedule`, `BunqScheduledPayment`, `BunqDraftPayment`, `BunqCard`; - `EnabledBanks` and `tuple_for` in `:Banks`; - `ParseAmount`, `FormatAmount`, `FormatMoney`, `GetCurrency`, `GetCurrencyCode`, `GetCurrencySymbol` and `GetCurrencyDecimals`; -- in `:Utils`: `ParseTimestamp`, `FormatTimestamp`, `ParseLocalDate`, `ParseLocalDateEnd`, `FormatLocalTime`, `UrlEncode`, `UrlDecode`, `QueryParameter` and `EscB`; +- in `:Utils`: `ParseTimestamp`, `FormatTimestamp`, `ParseLocalDate`, `ParseLocalDateEnd`, `FormatLocalTime`, `UrlEncode`, `UrlDecode`, `QueryParameter`, `Unshown`, `Blank` and `EscB`; - `FindTransactions` (not Query, Load or List), `SaveTransactions` and `GetLastTransactionTime`; - `TransactionQuery` with `search`, `amount`, `from`, `to`, `limit` and `stored`; - in `Nostro::Crypto`: `Key`, `OwnKey`, `SignBody`, `VerifyBody`, `CreateKey` (a `std::tuple`, the public PEM second), `LoadKeyFromPem`, `LoadPublicKeyFromPem`, `PrivateKeyToPem`, `PublicKeyToPem`, `RandomHex` and `ThrowOnOpenssl`; - `configPath`, `cachePath`, `CreatePrivateFile` and `ReadSecret`; -- for nostrod: `Client` (`System`, `Attach`, `Connected`, `TakeNotes`, `DefaultCheckoutAccount`, `SetDefaultCheckoutAccount`, and `Client::Pending` and `Client::Then`), `Answer`, `DaemonError`, `DaemonMissing`, `OutcomeUnknown`, `ConnectorSummary`, `AddedConnector`, `ConnectorAccounts`, `ConnectorCards`, `Created`, and `Bus::busName`, `Bus::errorBank` and the other `Bus::error…` names; -- for checkout: `Nostro::Checkout::Pay`, `Order`, `Paid`, `Error`, `Cancelled`, `NoCheckoutAccount`, and the module `Nostro.Checkout`, with a dot. +- for nostrod: `Client` (`System`, `Attach`, `Connected`, `TakeNotes`, `DefaultCheckoutAccount`, `SetDefaultCheckoutAccount`, and `Client::Pending` and `Client::Then`), `Answer`, `DaemonError`, `DaemonMissing`, `OutcomeUnknown`, `ConnectorSummary`, `AddedConnector`, `ConnectorAccounts`, `ConnectorCards`, `Created`, and `Bus::busName`, `Bus::errorBank` and the other `Bus::error…` names. diff --git a/AGENTS.template.md b/AGENTS.template.md index c35c089..8b634cf 100644 --- a/AGENTS.template.md +++ b/AGENTS.template.md @@ -6,36 +6,34 @@ Guidance for coding agents and contributors working on nostro itself. The [READM nostro is a banking client for Linux, phones first: a library that talks to bank APIs directly; nostrod, a system daemon that runs it for every local user behind D-Bus and polkit, so no program of the user's can read the bank's secrets or move money without the user's password; a small CLI that only talks to nostrod; and the app, a window for a phone or a desktop that only talks to nostrod too and does everything the CLI does. Linux phones have no banking apps; nostro is the open-source answer, one connector per bank. -Five C++26 modules, and a sixth in one build: +Four C++26 modules, and a fifth in one build: - `Nostro`, the library: twelve partitions behind the umbrella and ten implementation units. -- `Nostro.Checkout`, for apps that have nostrod pay an order. - `Nostro.Ui`, the toolkit the app's screens are built with. It imports `std` alone. - `Nostro.App`, the app without its window: what it knows, what is filled in, and its screens. - `Nostro.Ui.Shell`, which puts the toolkit on a display, on Crafter.Graphics and one sd-event loop. - `Nostro.DebugCommands`, what an agent drives the app with: in the app's `--debug-api` build and no other. -`project.cpp` makes one product per build: the static library `nostro` with the CLI `nostro` (`implementations/main.cpp`), `nostrod` (`--product=daemon`, `implementations/nostrod.cpp`), the app `nostro-app` (`--product=app`, `implementations/nostro-app.cpp`), the static library `nostro-checkout` (`--product=checkout`), or `nostro-fake-system` (`--product=fake-system`, `tests/FakeSystem/main.cpp`), a made-up system to look at the app against. The bunq connector is the only bank so far and the model for the next one. The library depends on Crafter.Network (HTTPS to the bank), Crafter.DB (the local transaction tables and the checkout record), OpenSSL (request signing, response verification), libsystemd (sd-bus and sd-event, for nostrod and its clients) and a vendored nlohmann/json; the app adds Crafter.Graphics (a Wayland window, Vulkan, the input) and two Noto Sans fonts. It ships as two Flatpaks: `net.catcrafts.Nostrod`, that systemd runs nostrod from as the system user `nostro` and that holds the CLI, and `net.catcrafts.Nostro`, the app. +`project.cpp` makes one product per build: the static library `nostro` with the CLI `nostro` (`implementations/main.cpp`), `nostrod` (`--product=daemon`, `implementations/nostrod.cpp`), the app `nostro-app` (`--product=app`, `implementations/nostro-app.cpp`), or `nostro-fake-system` (`--product=fake-system`, `tests/FakeSystem/main.cpp`), a made-up system to look at the app against. The bunq connector is the only bank so far and the model for the next one. The library depends on Crafter.Network (HTTPS to the bank), Crafter.DB (the local transaction tables), OpenSSL (request signing, response verification), libsystemd (sd-bus and sd-event, for nostrod and its clients) and a vendored nlohmann/json; the app adds Crafter.Graphics (a Wayland window, Vulkan, the input) and two Noto Sans fonts. It ships as two Flatpaks: `net.catcrafts.Nostrod`, that systemd runs nostrod from as the system user `nostro` and that holds the CLI, and `net.catcrafts.Nostro`, the app. | Path | What lives there | |---|---| | `interfaces/Nostro.cppm` | The umbrella: `export import`s every partition; `:Bunq` and `:Crypto` only under their defines, `:Bus`, `:Client` and `:Daemon` only under `NOSTRO_DBUS_ENABLED`. | | `interfaces/Nostro-.cppm` | One partition per file, `Nostro:`. | -| `implementations/Nostro-.cpp` | The implementation units, `Nostro:_impl`: `Account`, `File` and `Connector` always; `Bunq`, `BunqPayments` (`Nostro-Bunq-Payments.cpp`: counterparties, payments, drafts, requests, schedules) and `Crypto` when their bank is enabled; `Bus`, `Client`, `Daemon` (nostrod's front) and `DaemonWorker` (`Nostro-Daemon-Worker.cpp`: a user's worker, the polkit gate, the checkout) under D-Bus. | -| `interfaces/Nostro.Checkout.cppm`, `implementations/Nostro.Checkout.cpp` | The module `Nostro.Checkout`: the checkout's names and wire, and a blocking `Pay` over sd-bus. A module of its own, so `--product=checkout` builds it without the rest. | +| `implementations/Nostro-.cpp` | The implementation units, `Nostro:_impl`: `Account`, `File` and `Connector` always; `Bunq`, `BunqPayments` (`Nostro-Bunq-Payments.cpp`: counterparties, payments, drafts, requests, schedules) and `Crypto` when their bank is enabled; `Bus`, `Client`, `Daemon` (nostrod's front) and `DaemonWorker` (`Nostro-Daemon-Worker.cpp`: a user's worker and the polkit gate) under D-Bus. | | `implementations/main.cpp` | The CLI, a client of nostrod: `argv` parsing (positional arguments, `--name value` options, `--sandbox`), one function per command over `Client`, output through the `std::formatter`s, the notes on stderr, errors caught in `main` and printed with exit status 1. | | `implementations/nostrod.cpp` | nostrod's `main`: `--state`, `--idle`, `--prompt-timeout`, and `--worker ` for the worker processes it starts itself. | | `interfaces/Nostro.Ui.cppm`, `interfaces/Nostro.Ui-.cppm`, `implementations/Nostro.Ui-.cpp` | The toolkit, `Nostro.Ui`: ten partitions, seven of them with an implementation unit. Ported from imsd-messages (ca5cd72d), which is Catcrafts' and GPL-3.0-only like it. | | `interfaces/Nostro.App.cppm`, `interfaces/Nostro.App-.cppm`, `implementations/Nostro.App-.cpp` | `Nostro.App`: `:Banks`, `:Format`, `:Forms`, `:Errors` and `:App`. `:App` has three implementation units: `Nostro.App-App.cpp` (state, nostrod's answers, navigation, actions), `Nostro.App-Screens.cpp` (the screens) and `Nostro.App-Bunq.cpp` (bunq's two forms for adding a connection, and what their buttons do). | | `interfaces/Nostro.Ui.Shell.cppm`, `interfaces/Nostro.Ui.Shell-.cppm`, `implementations/Nostro.Ui.Shell-.cpp` | `Nostro.Ui.Shell`: `:Loop`, `:Canvas`, `:Window` and `:Portal`. The one part that needs a compositor and a graphics device. | -| `implementations/nostro-app.cpp` | The app's `main`: the command line, the parts put together, the toolkit's gallery (`--gallery`) and a player of input scripts (`--poke`). | +| `implementations/nostro-app.cpp` | The app's `main`: the command line, with the link the desktop starts it with, 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=`, `--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/dbus/` | The published D-Bus interface, `net.catcrafts.Nostro1.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`. | | `.forgejo/workflows/flatpak.yaml` | The one workflow: the tests and both aarch64 Flatpaks for a pull request or a run by hand, and for a signed tag `X.Y.Z` their publication; see "Releasing". | -| `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, the two scripts that cross-build both Flatpaks for aarch64, and `release-version.sh`, which checks what a tree releases; the licence texts the Flatpaks carry, with a `NOTICE` of what each covers; the Arch package of the system files, `nostro-system`. | +| `packaging/flatpak/`, `packaging/licenses/`, `packaging/arch/` | nostrod's Flatpak manifest (on crafter-build's Flatpak as its base app), each Flatpak's metainfo and `.flatpakref`, the app's desktop entry (which is also what registers it for `payto` links) and icon, the two scripts that cross-build both Flatpaks for aarch64, and `release-version.sh`, which checks what a tree releases; 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 (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". | @@ -43,12 +41,12 @@ Five C++26 modules, and a sixth in one build: | `AGENTS.template.md`, `AGENTS.consumer.md` | The source of this file, and the notes for consumers. `AGENTS.md` is gitignored: edit the template. | | `.review-gates/` | The pre-push review's `config.json` and this repository's lens sections (`lenses/`), read by Crafter.Review. Its `push/` and `trees/` are generated and gitignored. | | `.vscode/` | A build task and an lldb launch configuration, both stale; see "Gotchas". | -| `bin/`, `build/` | Generated and gitignored. The library and the CLI are both named `nostro`, so one build leaves two `bin/nostro----/` directories: the library's (`libnostro.a`, the PCMs, `std.pcm`) and the executable's (`nostro`). Glob for the one holding `nostro`. nostrod builds into `bin/nostrod-…/`, the checkout library into `bin/nostro-checkout-…/`, the app into `bin/nostro-app-…/` with its fonts and Crafter.Graphics' shaders beside it (`bin/nostro-app-core-…/` is `Nostro.App`'s library), or under `files/bin/` there when it is packaged as a Flatpak. `build/crafter-debug` is the launcher of Crafter.Debug's client, `build/fake-system/` the state of the made-up system `run fake` starts, `build/flatpak-apps/` what `install` and `bundle` make of the app. | +| `bin/`, `build/` | Generated and gitignored. The library and the CLI are both named `nostro`, so one build leaves two `bin/nostro----/` directories: the library's (`libnostro.a`, the PCMs, `std.pcm`) and the executable's (`nostro`). Glob for the one holding `nostro`. nostrod builds into `bin/nostrod-…/`, the app into `bin/nostro-app-…/` with its fonts and Crafter.Graphics' shaders beside it (`bin/nostro-app-core-…/` is `Nostro.App`'s library), or under `files/bin/` there when it is packaged as a Flatpak. `build/crafter-debug` is the launcher of Crafter.Debug's client, `build/fake-system/` the state of the made-up system `run fake` starts, `build/flatpak-apps/` what `install` and `bundle` make of the app. | Partitions, from the bottom up (each imports only the ones above it): - `:Currency`: `Currency` (an `enum class : std::uint16_t` with `Euro` alone), `GetCurrency` (from `"EUR"` or `"eur"`, throws for anything else), `GetCurrencyCode`, `GetCurrencySymbol`, `GetCurrencyDecimals`, `ParseAmount` (decimal string to minor units), `FormatAmount` (back) and `FormatMoney` (`-€1.02`), all `constexpr`, and `std::formatter`, which prints the symbol. -- `:Utils`: `ParseTimestamp` and `FormatTimestamp` (bunq's `YYYY-MM-DD HH:MM:SS[.ffffff]`, UTC), `ParseLocalDate`, `ParseLocalDateEnd` and `FormatLocalTime` (dates a person types and reads, local time through `mktime`/`localtime`), `UrlEncode`, `UrlDecode` and `QueryParameter` (for OAuth), `EscB` (JSON string escaping, no longer used by nostro itself), and `Note` with its replaceable `noteSink`, where every warning of the library goes (stderr by default). +- `:Utils`: `ParseTimestamp` and `FormatTimestamp` (bunq's `YYYY-MM-DD HH:MM:SS[.ffffff]`, UTC), `ParseLocalDate`, `ParseLocalDateEnd` and `FormatLocalTime` (dates a person types and reads, local time through `mktime`/`localtime`), `UrlEncode`, `UrlDecode` and `QueryParameter` (for OAuth; the app reads a link's options with `UrlDecode` too), `Unshown` and `Blank` (code points that draw nothing or place text, and spaces of any width: the worker's `Shown()` and the app's `ReadPaymentLink` both ask them), `EscB` (JSON string escaping, no longer used by nostro itself), and `Note` with its replaceable `noteSink`, where the library's warnings go (stderr by default). - `:Transaction`: the `Transaction` aggregate, which is also the row type of the Crafter.DB tables: `version = 2` (`id` and `kind` added on 2026-10-31), `orderedBy = &Transaction::timePoint`, `using Previous = TransactionV1` (unexported, kept for the migration), and its `std::formatter` (one tab-separated line). - `:Account`: `TransactionQuery` and `Account` (`name`, `bic`, `iban`, `currency`, `balance` in minor units) with the three methods over the transaction store and the static `ForgetTransactions` (which closes this process's open tables under a storage key before deleting them), and the `std::formatter` for `Account` and everything derived from it. The implementation unit owns the Crafter.DB tables and pins the schema with two `static_assert`s. - `:File`: `GetConfigPath`, `GetCachePath`, the globals `configPath` and `cachePath` they initialise at static-init time, `CreatePrivateFile` (a `0600` file in a `0700` directory), and `ReadSecret` (a line from stdin, not echoed on a terminal). @@ -56,12 +54,10 @@ Partitions, from the bottom up (each imports only the ones above it): - `:Bunq` (under `NOSTRO_BUNQ_ENABLED`; `json.hpp` and `openssl/types.h` in the global module fragment; the implementation units import Crafter.Network): `BunqEnvironment`, `BunqError` (with `maybeCarriedOut`, the end of an error to a write that may have happened all the same), `BunqCounterparty`, the listing types (`BunqLabel`, `BunqPaymentRequest`, `BunqIncomingRequest`, `BunqSchedule`, `BunqScheduledPayment`, `BunqDraftPayment`, `BunqCard`) and their formatters, `BunqAccount : Account` (`id`, `type`, `connector`, the payment calls), `BunqConnector` (environment, keys, tokens, user, `accounts`, the raw `Get`/`Post`/`Put`/`Delete`/`List`, the static deque `connectors`, `Create`, `Remove`, the OAuth helpers, and `Endpoint`/`RedirectTo` with `BunqEndpoint`), `to_json`/`from_json`, and the unexported `BunqJson` helpers both implementation units share. - `:Banks`: `tuple_for(f)` and `EnabledBanks`, the `std::tuple` of enabled connector types; every generic loop in the CLI and in `:Connector` is a `tuple_for`. - `:Connector`: `Connector::SaveConnectors()` and `LoadConnectors()`, `connectors.json` out (synced, then renamed into place) and in, both under the process-wide `connectors.lock`. -- `:Bus` (under `NOSTRO_DBUS_ENABLED`; `sd-bus.h` in the global module fragment): the wire nostrod and its clients share. The names, the error names (the checkout's from `Nostro.Checkout`), the polkit actions, the method tables `methods` and `checkoutMethods` (member, signatures, argument names, sensitive), the result structs (`ConnectorSummary`, `AddedConnector`, `ConnectorAccounts`, `ConnectorCards`, `Created`), `Wire` with `Append` and `Read` for every type that travels (a struct as its members, a time as microseconds, a currency as its code, an optional as an array of zero or one), `AppendQuery`/`ReadQuery`, `Vtable`, `ThrowOnSdBus`, and the `BusPtr`/`MessagePtr`/`Error` owners. +- `:Bus` (under `NOSTRO_DBUS_ENABLED`; `sd-bus.h` in the global module fragment): the wire nostrod and its clients share. The names, the error names, the polkit actions, the method table `methods` (member, signatures, argument names, sensitive), the result structs (`ConnectorSummary`, `AddedConnector`, `ConnectorAccounts`, `ConnectorCards`, `Created`), `Wire` with `Append` and `Read` for every type that travels (a struct as its members, a time as microseconds, a currency as its code, an optional as an array of zero or one), `AppendQuery`/`ReadQuery`, `Vtable`, `ThrowOnSdBus`, and the `BusPtr`/`MessagePtr`/`Error` owners. - `:Client`: `Client::System()`, one method per method of `net.catcrafts.Nostro1` in a blocking and an asynchronous form (`Attach`, `Client::Pending`, `Answer`), `TakeNotes()`, `DaemonError`, `DaemonMissing` and `OutcomeUnknown`. - `:Daemon`: `DaemonOptions`, `RunDaemon` (the front) and `RunWorker` (one user's worker). -`Nostro.Checkout`, a module of its own that imports nothing of `Nostro`: the checkout's bus name, interface, `Pay`'s signatures and argument names, the error names apps tell apart, `Order`, `Paid`, `Error` with `Cancelled` and `NoCheckoutAccount`, and `Pay`. `:Bus` and the daemon take their names from it. - `Nostro.Ui`, in `namespace Nostro::Ui`, draws nothing and reads no device: a screen is a function that fills a `Frame`. Its partitions, from the bottom up: - `:Geometry`: `Point`, `Box`, `Insets`, `Color`, `Metrics` (the display's scale, `Dp()`) and `SizeClass`: compact under 600 dp wide, medium under 900, expanded from there. Everything is in physical pixels; dp exists in the design's constants and is turned into pixels where it is used (`frame.Dp()`). @@ -79,7 +75,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`. +- `:Forms`: what is typed, read (`ReadAmount`, `ReadParty`, `ReadDay`, `ReadCount`), what a link that asks for a payment is read as or refused for (`ReadPaymentLink`, `PaymentLink`), 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`) 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`. @@ -101,15 +97,15 @@ 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. +- **The front** (`implementations/Nostro-Daemon.cpp`, `RunDaemon`) is one sd-event loop with one system bus connection, which owns `net.catcrafts.Nostro1` and serves that interface. Every method 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/`, 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. + - 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, 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 account pay links start from** (the same file): `SetDefaultCheckoutAccount` writes the chosen account to `checkout-account`, as its connector's storage key and its id, under the `Connectors` action, and refuses an account of an OAuth connector. `DefaultCheckoutAccount` reads it back under `View`: none when none is chosen, or when the account is gone. The worker does nothing else with it: it is where the app's pay form starts when a link opens it (design rule 14). The two methods and the file are named after the checkout over D-Bus that paid from that account until it was taken out (design rule 10). +- **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. The app end to end: @@ -124,9 +120,10 @@ The app end to end: - Accounts go to nostrod by IBAN, by name where the bank gave none; a connection by name, or by its number from a fresh `Accounts` listing when two share a name. - Which bank an account is with makes no difference outside the settings. No screen there names a bank, or a way to connect to one, in the app's own words: it says "your bank". `ShouldDriveTheApp` fails on a frame that does, excepting what nostrod and the bank say themselves: a note about a connector, a refusal with the call it refused, a link the bank made. What does differ by bank is asked of `:Banks`: a connection that pays between the user's own accounts only, as bunq's through OAuth, is `Connection::ownAccountsOnly`. It is marked Limited, a payment from it to anyone else is saved as a draft, and it cannot pay a request or a shop. - Adding a connection is three pages, from the settings and from the welcome alike: the banks (`add`), the bank's ways (`add:bunq`) and the way's form (`add:bunq:key`). The first two are built from `:Banks`. The form is the bank's own to draw and to check, in a file of the bank's (`Nostro.App-Bunq.cpp`), and its button ends in `App::Connect`, which is every bank's. + - A link fills in the pay form, and does nothing else (design rule 14). `Open(link)` has `ReadPaymentLink` read it: a link that cannot be read gets a sheet with the reason (`…+link`), over wherever the user is. One that can be read is kept apart from the form (`waiting`), with a line on the accounts' page saying that it waits, until the accounts have been read and `DefaultCheckoutAccount` has answered or failed. Then `TakeLink` fills the form in (`PaymentForm::Fill`) and opens it, from that account where one is chosen, else from the first account whose connection pays anybody. With more than one account the form opens under its choice of accounts (`pay+accounts`, `Picking::PayFrom`): a tap beside that sheet or Escape keeps the account the form started from. The form says that a link filled it in (`PaymentForm::linked`, the banner `pay.linked`). A user who is no longer on the accounts' page when the accounts arrive is told that the link was not opened, and keeps their place; with no account to pay from a sheet says so. - **The screens** (`implementations/Nostro.App-Screens.cpp`, and a bank's own forms in that bank's file) are functions from that state to a frame. A window under 600 dp wide shows one page at a time, with the app's places along its bottom; a wider one has them down its left side, and from 900 dp the accounts too. A screen that shows the bank's own state (the accounts, an account, the cards) reads it again four ways, all one action (`Refresher`): Refresh in the bar, F5, Ctrl+R, and the page pulled down at its top. - **The window** (`Nostro.Ui.Shell`) is one sd-event loop that carries the compositor's connection, nostrod's bus, the desktop portal's bus and the timers. `Window` turns Crafter.Graphics' events into the `Context`'s, bringing time up to each and building a stale frame again first, and does what the `Context` wants afterwards (`Settle`, which the loop calls from a post source after every source that ran). A frame is drawn only when the compositor asks for one after something changed, or when it waits for one itself, having asked for another size (`onFrameOwed`): an idle window draws nothing. `Canvas` turns a `DrawList` into Crafter.Graphics' items, one dispatch per batch, from a pool of buffers per frame in flight. `Portal` reads the desktop's colour scheme and accent, and asks the desktop to open an address. -- **`nostro-app`** puts them together, and has what looking at the window without a hand on it takes: `--size`, `--scale` (a phone's density on a desktop's display), `--theme`, `--route`, `--screenshot`, `--poke` and `--gallery`. It makes itself undumpable once the portal has seen it. Closing the window while a change is under way takes the window down and keeps the process until the answer has come. +- **`nostro-app`** puts them together, and has what looking at the window without a hand on it takes: `--size`, `--scale` (a phone's density on a desktop's display), `--theme`, `--route`, `--screenshot`, `--poke` and `--gallery`. An argument that is no option is a link: it is overwritten in `argv` once it is copied, and handed to `App::Open` when the app has started. It makes itself undumpable once the portal has seen it. Closing the window while a change is under way takes the window down and keeps the process until the answer has come. ## Dev environment @@ -136,7 +133,7 @@ crafter-build is the only build tool. It compiles with its clang 23 and libc++, - Three 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. Crafter.Event, Crafter.Math, Crafter.Asset and the Khronos headers come behind Crafter.Graphics in the same way. 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. Until 2026-11-20 `--product=app` took a checkout of Crafter.Graphics to build against (`--graphics=`), for a change that was not on its master yet. The flag is gone: `project.cpp` passes one it is given on to the dependencies like any arg it does not know. - 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. +- Where the connectors live depends on who runs the library. nostrod's worker keeps each user's under `/users//`: `connectors.json`, the transaction tables, `checkout-account` and `owner`, with `` from `--state`, else `$XDG_DATA_HOME`, else `$HOME/.local/share`. Installed, that is `/var/lib/nostro/.var/app/net.catcrafts.Nostrod/data/`, readable by the user `nostro` alone. The library used directly reads `connectors.json` from `$XDG_CONFIG_HOME/.config/nostro/` (sic, see "Gotchas") or `$HOME/.config/nostro/`, and keeps the transaction tables under `$XDG_CACHE_HOME/nostro/transactions/` or `$HOME/.cache/nostro/transactions/`. A real connectors file holds a real API key: point every experiment elsewhere. - No test uses the system bus: they run on `tests/Support/FakeBus.inc`. Running anything by hand that talks to `net.catcrafts.Nostro1` reaches the installed nostrod, if there is one, and its dialogs: the CLI, and the app, which reads the accounts as soon as it starts. A Flatpak sandbox with the system bus (`flatpak run`) sets `DBUS_SYSTEM_BUS_ADDRESS` itself, over an `--env` of yours: keep a sandboxed experiment off the bus with `--nosocket=system-bus`. To look at the app, run it on the made-up system, `nostro-fake-system`, which sets that address for what it starts ("Looking at the app"). - To read a `constexpr` value such as `DB::Layout::fingerprint`, `static_assert(x == 0)` it and read "expression evaluates to" in the error. @@ -145,7 +142,6 @@ crafter-build is the only build tool. It compiles with its clang 23 and libc++, ```bash crafter-build --banks=bunq # the library, then the CLI: bin/nostro-/nostro crafter-build --banks=bunq --product=daemon # nostrod: bin/nostrod-/nostrod -crafter-build --product=checkout # the Nostro.Checkout library alone; no bank needed crafter-build --banks=bunq --lib # the library alone (what a consumer builds), without D-Bus crafter-build --banks=bunq --lib --dbus # the library with :Bus, :Client and :Daemon crafter-build --banks=bunq --product=app # the app: bin/nostro-app-/nostro-app @@ -165,7 +161,7 @@ crafter-build --banks=bunq --product=app --packaging=flatpak --march=x86-64-v3 - packaging/flatpak/make-aarch64-sysroot.sh && packaging/flatpak/build-aarch64.sh # both Flatpaks for aarch64, into a repository ``` -`--banks=` is mandatory except for `--product=checkout`: without it `project.cpp` throws "must enable atleast one bank" and nothing is built; an unknown name throws "unknown connector", an unknown product "unknown product". flatpak-builder needs crafter-build's own Flatpak (`net.catcrafts.CrafterBuild`, stable) installed as its base app, the network during the build, and, run as a Flatpak itself, `--filesystem=` for a build directory outside your home, or the build commands cannot find it. Install the result for a test with `sudo packaging/system/install.sh --repo /repo`. CI is `.forgejo/workflows/flatpak.yaml` ("Releasing" below): it runs for a pull request, by hand and for a release's tag, so a plain push is tested by nobody but whoever pushed it. The tests run every line, function and region of the library, the CLI, nostrod, the toolkit and the app without its window (2026-11-19), and a change keeps them doing so; the README's rule for contributed connectors applies on top: not blind, also tried against the sandbox or the live API ("Testing instructions"). +`--banks=` is mandatory: without it `project.cpp` throws "must enable atleast one bank" and nothing is built; an unknown name throws "unknown connector", an unknown product "unknown product". flatpak-builder needs crafter-build's own Flatpak (`net.catcrafts.CrafterBuild`, stable) installed as its base app, the network during the build, and, run as a Flatpak itself, `--filesystem=` for a build directory outside your home, or the build commands cannot find it. Install the result for a test with `sudo packaging/system/install.sh --repo /repo`. CI is `.forgejo/workflows/flatpak.yaml` ("Releasing" below): it runs for a pull request, by hand and for a release's tag, so a plain push is tested by nobody but whoever pushed it. The tests run every line, function and region of the library, the CLI, nostrod, the toolkit and the app without its window (2026-11-19), and a change keeps them doing so; the README's rule for contributed connectors applies on top: not blind, also tried against the sandbox or the live API ("Testing instructions"). The app's packaging: `--packaging=flatpak` makes `bin/nostro-app-/files/` (the program with its fonts and shaders in `bin/`, the C++ runtime in `lib/`, the desktop entry, icon, metainfo and licences in `share/`), `bundle` a `.flatpak` beside it and `install` an installation for the user who runs it; both print the permissions, which `project.cpp` lists. That is x86_64, on the Platform crafter-build's Flatpak runs on. For aarch64, a phone, there is no crafter-build to build with, so both Flatpaks are cross builds: `make-aarch64-sysroot.sh` makes a sysroot of the Freedesktop Sdk for aarch64 with LLVM's libc++ (in `~/.cache/nostro-flatpak`, or `$NOSTRO_FLATPAK_CACHE`), and `build-aarch64.sh ` builds the CLI, nostrod and the app against it and assembles `net.catcrafts.Nostrod` and `net.catcrafts.Nostro` into an OSTree repository, which `install.sh --repo --app` installs on the phone. The app's permissions are in two places because of it, `project.cpp` and that script: change them together. @@ -200,7 +196,7 @@ Only aarch64 is published, a phone's architecture. An x86_64 machine builds its | `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, 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) | +| `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, that a dialog left open holds up no other call, the account pay links start from, 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 | @@ -243,9 +239,10 @@ What a test cannot show (that the window draws what the frame says, in the right - Without a hand on it: `nostro-app --size 420x760 --theme light --route account: --poke "wait:2500;tap:110,200;shot:"` plays input into the window library's own events, so the window's listeners run as for a real pointer, and writes screenshots. Steps are separated by `;` and positions are in dp: `tap:x,y`, `hold:x,y,ms`, `drag:x1,y1,x2,y2,ms`, `move:x,y`, `press:x,y` and `release` (a finger kept down between them), `right:x,y`, `wheel:x,y,detents`, `key:Name`, `text:…`, `preedit:…`, `delete:before,after`, `resize:w,h`, `wait:ms`, `shot:file`. `--scale 3 --size 360x760` draws a phone's screen on a desktop's display. `--gallery widgets|list|text` shows the toolkit's widgets in the app's place and asks nostrod nothing. The player stamps what it plays with the host's clock, and what a real pointer sends carries the compositor's: a pointer that crosses the window while a script runs can make the script's taps miss, as one did on 2026-11-20, so keep it off the window, and read a run that went wrong for a `wl_pointer.enter` (`WAYLAND_DEBUG=1`). - With an agent's hand on it: the `--debug-api` build and `./build/crafter-debug` (the Crafter.Debug notes at the end of this file). `crafter-build … --debug-api run fake [the fake system's options] [-- the app's options]` starts the app on the fake system, in the background since it does not exit. Then: - `get app.screen`, `get ui.texts` (every line the screen shows), `get ui.regions` (what can be pressed, by key, in dp), `get 'window.*'`; - - `call Ui_Tap key=account.pay`, `Ui_Type text=…` into the field that has the focus, `Ui_Key key=Tab`, `Ui_LongPress`, `Ui_Focus`, `Ui_TapAt`, `Ui_Drag`, `Ui_Wheel`, `App_Navigate route=cards`, `Ui_Theme scheme=dark`, `Window_Resize width= height=`; + - `call Ui_Tap key=account.pay`, `Ui_Type text=…` into the field that has the focus, `Ui_Key key=Tab`, `Ui_LongPress`, `Ui_Focus`, `Ui_TapAt`, `Ui_Drag`, `Ui_Wheel`, `App_Navigate route=cards`, `App_Open link=payto://iban/…`, `Ui_Theme scheme=dark`, `Window_Resize width= height=`; - `wait 'app.busy == false'` after anything that asks nostrod, `wait 'app.changing == false'` after a change; the events are `Screen`, `AnswerArrived`, `Changing` and `FrameRendered`; - `screenshot`, and `log --level warn` for the checks: a frame that overflowed the window's buffers, something pressable under 48 dp on a phone's size. +- A link is looked at by starting the app with one, after `--` like the app's options: `… run fake -- --size 420x760 'payto://iban/NL36BUNQ2100000044?amount=EUR:12.50&receiver-name=Swift%20Cycles&message=Order%201234'`, whose IBAN is an account at the made-up bank. `get app.screen` is then `pay+accounts`. - 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.submit`, `confirm.yes`, `done.close`, `card.`, `settings.connections`, `connections.add`, `bank.bunq`, `way.key`, and `copy.