feat(app): add the Nostro app, a window for phones and desktops

Linux phones have no banking apps, and a command line is no answer on a
phone. The app does everything the nostro command does and, like it, only
talks to nostrod: it holds no key and no token.

- Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported
  from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens;
  Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics;
  nostro-app; and Nostro.DebugCommands for the --debug-api build.
- Client: every method also in an asynchronous form for an sd-event loop,
  with DaemonMissing and OutcomeUnknown.
- nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes
  net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both
  Flatpaks cross-built for aarch64, and the licence texts they carry.
- nostro-fake-system, a made-up bus and bank with a real nostrod on them, to
  look at the app against. The README's screenshots are taken on it.
- The nostro command: an API key's environment is the key's own to say, so
  --sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL.

The published contract changes in three places, before any release (design
rule 10):
- Transactions' query takes `stored`: answered from what nostrod has stored,
  without asking the bank. The app searches with it; before, every search was
  a call to bunq.
- AddBunq's `environment` no longer chooses over what the key says of itself:
  a key of the other environment is refused.
- SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one
  as DEACTIVATED however well it pays, and leaves it as it is when asked,
  without an error.

The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved
from one to the other (design rule 13). Transaction's schema is unchanged.

Verified: the 17 tests pass with every line, function and region of what they
link run, and the five lint runs are clean. Every screen was looked at on the
made-up system, at a phone's and a desktop's sizes in the light and the dark
look, on Plasma under Wayland. What is said of bunq's cards comes from its
sandbox, with throwaway users, and from one real virtual card. Known to have
been used against production: connecting, and reading accounts, payments and
cards. Not known to have been tried: a payment from the app against bunq,
OAuth against bunq, and anything on a phone.

Building the app takes --graphics=, a Crafter.Graphics checkout on its branch
claude/nostro-app, until that branch is merged and pinned here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-11-19 12:27:14 +01:00
commit 5b4037955b
106 changed files with 17804 additions and 289 deletions

View file

@ -3,20 +3,29 @@
# SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
#
# Installs nostro for every user of this machine: the system files nostrod needs (its user, its D-Bus and polkit
# policies, its systemd unit, the nostro command) and the net.catcrafts.Nostro Flatpak, system-wide. Run as root.
# policies, its systemd unit, the nostro command) and the net.catcrafts.Nostrod Flatpak, system-wide. Run as root.
#
# install.sh the Flatpak from the system remote "catcrafts" (packaging/flatpak/net.catcrafts.Nostro.flatpakref
# sets it up: flatpak install --system net.catcrafts.Nostro.flatpakref)
# install.sh --repo DIR the Flatpak from a local repository, as flatpak-builder --repo=DIR makes one, for testing
# install.sh the Flatpaks from the system remote "catcrafts", the Catcrafts Flatpak repository, added with
# flatpak remote-add --system --if-not-exists catcrafts https://flatpak.catcrafts.net/catcrafts.flatpakrepo
# install.sh --repo DIR the Flatpaks from a local repository, as flatpak-builder --repo=DIR makes one, for testing
# install.sh --app the Nostro app too, net.catcrafts.Nostro, for every user (each user can install it for
# themselves instead)
#
# Running it again updates. packaging/arch/PKGBUILD installs the same files from a package; uninstall.sh removes them.
# Running it again updates. nostrod's Flatpak was net.catcrafts.Nostro until the app took that id: this moves the state a
# nostrod installed under it kept, and removes that Flatpak. packaging/arch/PKGBUILD installs the same system files from
# a package; uninstall.sh removes them.
set -eu
here=$(cd "$(dirname "$0")" && pwd)
repo=
if [ "${1:-}" = --repo ]; then
repo=$(cd "${2:?--repo needs a directory}" && pwd)
fi
app=false
while [ $# -gt 0 ]; do
case "$1" in
--repo) repo=$(cd "${2:?--repo needs a directory}" && pwd); shift 2 ;;
--app) app=true; shift ;;
*) echo "install.sh: unknown argument '$1'" >&2; exit 2 ;;
esac
done
install -Dm644 "$here/nostro.sysusers" /usr/lib/sysusers.d/nostro.conf
systemd-sysusers /usr/lib/sysusers.d/nostro.conf
@ -26,17 +35,39 @@ install -Dm644 "$here/net.catcrafts.Nostro1.Checkout.service" /usr/share/dbus-1/
install -Dm644 "$here/net.catcrafts.Nostro1.policy" /usr/share/polkit-1/actions/net.catcrafts.Nostro1.policy
install -Dm644 "$here/nostrod.service" /etc/systemd/system/nostrod.service
install -Dm755 "$here/nostro" /usr/local/bin/nostro
systemctl daemon-reload
if [ -n "$repo" ]; then
# A local repository is unsigned: for a build of your own, never for one from elsewhere.
flatpak remote-add --system --if-not-exists --no-gpg-verify nostro-local "file://$repo"
flatpak install --system -y --noninteractive --or-update nostro-local net.catcrafts.Nostro//stable
else
flatpak install --system -y --noninteractive --or-update catcrafts net.catcrafts.Nostro//stable
# A nostrod already running keeps the old files until it ends: stop it, and the next call starts the new one. Stopped, it
# also leaves its state alone while that moves.
systemctl stop nostrod.service
# flatpak keeps an app's data under the app's id, so nostrod's state followed the Flatpak's old id.
apps=/var/lib/nostro/.var/app
if [ -d "$apps/net.catcrafts.Nostro" ]; then
if [ -e "$apps/net.catcrafts.Nostrod" ]; then
echo "install.sh: both $apps/net.catcrafts.Nostro and $apps/net.catcrafts.Nostrod exist; keep the one that holds the bank connections as net.catcrafts.Nostrod, remove the other, and run this again" >&2
exit 1
fi
mv "$apps/net.catcrafts.Nostro" "$apps/net.catcrafts.Nostrod"
echo "moved nostrod's state from $apps/net.catcrafts.Nostro to $apps/net.catcrafts.Nostrod"
fi
# The app's Flatpak runs nostro-app; the old nostrod Flatpak ran nostro.
if flatpak info --system --show-metadata net.catcrafts.Nostro 2>/dev/null | grep -qx 'command=nostro'; then
flatpak uninstall --system -y --noninteractive net.catcrafts.Nostro
fi
remote=catcrafts
if [ -n "$repo" ]; then
# A local repository is unsigned: for a build of your own, never for one from elsewhere. The remote may be left from
# an earlier run with another directory.
remote=nostro-local
flatpak remote-add --system --if-not-exists --no-gpg-verify nostro-local "file://$repo"
flatpak remote-modify --system --no-gpg-verify --url="file://$repo" nostro-local
fi
flatpak install --system -y --noninteractive --or-update "$remote" net.catcrafts.Nostrod//stable
if [ "$app" = true ]; then
flatpak install --system -y --noninteractive --or-update "$remote" net.catcrafts.Nostro//stable
fi
systemctl daemon-reload
busctl call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus ReloadConfig
# A nostrod already running keeps the old files until it ends; stop it, and the next call starts the new one.
systemctl try-restart nostrod.service
echo "nostro is installed: nostrod starts with the first call, such as 'nostro connectors add bunq'"

View file

@ -2,7 +2,7 @@
# SPDX-License-Identifier: LGPL-3.0-only
# SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
#
# The nostro command: the CLI from the net.catcrafts.Nostro Flatpak, run as you. It asks nostrod over the system bus,
# The nostro command: the CLI from the net.catcrafts.Nostrod Flatpak, run as you. It asks nostrod over the system bus,
# and your session's polkit agent asks for your password before anything moves money. Install: /usr/bin/nostro (a
# package) or /usr/local/bin/nostro (install.sh).
@ -16,4 +16,4 @@ for old in "${XDG_CONFIG_HOME:-$HOME/.config}/nostro/connectors.json" "${XDG_CON
fi
done
exec /usr/bin/flatpak run --system net.catcrafts.Nostro//stable "$@"
exec /usr/bin/flatpak run --system net.catcrafts.Nostrod//stable "$@"

View file

@ -3,7 +3,7 @@
#
# nostrod: every local user's bank connections, one worker process per user, behind net.catcrafts.Nostro1 and
# net.catcrafts.Nostro1.Checkout on the system bus. The first call starts it (D-Bus activation), and it ends by itself
# once idle, so an updated Flatpak takes over at the next call. It runs from the net.catcrafts.Nostro Flatpak as the
# once idle, so an updated Flatpak takes over at the next call. It runs from the net.catcrafts.Nostrod Flatpak as the
# system user nostro, whose home, the state directory, holds the connections: no other user can read it.
#
# The hardening is what bubblewrap, which flatpak runs the daemon in, works under. Not here, because it breaks it:
@ -20,7 +20,7 @@ Type=dbus
BusName=net.catcrafts.Nostro1
User=nostro
Group=nostro
ExecStart=/usr/bin/flatpak run --system --no-session-bus --die-with-parent --command=nostrod net.catcrafts.Nostro//stable
ExecStart=/usr/bin/flatpak run --system --no-session-bus --die-with-parent --command=nostrod net.catcrafts.Nostrod//stable
StateDirectory=nostro
StateDirectoryMode=0700
# flatpak run needs a runtime directory, which a system user does not have.

View file

@ -8,7 +8,12 @@
set -u
systemctl stop nostrod.service 2>/dev/null
flatpak uninstall --system -y --noninteractive net.catcrafts.Nostro 2>/dev/null
flatpak uninstall --system -y --noninteractive net.catcrafts.Nostrod 2>/dev/null
# A nostrod installed before the Nostro app took its id, net.catcrafts.Nostro. The app itself stays: it is an app like
# any other, removed with flatpak uninstall.
if flatpak info --system --show-metadata net.catcrafts.Nostro 2>/dev/null | grep -qx 'command=nostro'; then
flatpak uninstall --system -y --noninteractive net.catcrafts.Nostro 2>/dev/null
fi
flatpak remote-delete --system nostro-local 2>/dev/null
rm -f /usr/share/dbus-1/system.d/net.catcrafts.Nostro1.conf \
/usr/share/dbus-1/system-services/net.catcrafts.Nostro1.service \