Nostro/interfaces/Nostro.App-Format.cppm
Jorijn van der Graaf 2e3739ff7a
fix: close what the security review before the first release found
A review of the tree and its history before they are published found no
key and no bank data in them. It did find these, each closed here.

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
2026-11-19 16:09:48 +01:00

54 lines
3.3 KiB
C++

// SPDX-License-Identifier: GPL-3.0-only
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
export module Nostro.App:Format;
import std;
import Nostro;
// How the app words what a bank gives it: money, dates as a person reads them in their own time zone, and a
// bank's capitals in plain words. English only; every such wording is here, and none of it names a bank.
export namespace Nostro::App {
// An IBAN in groups of four, as it is printed on a card; anything else as it is.
std::string GroupIban(std::string_view iban);
// What an account is found by, in the app and by nostrod: its IBAN, or its name where the bank gave it none.
std::string AccountKey(const Account& account);
// Who a payment is to or from, as a person would say it: by name, else by IBAN or address, and "Unknown" where
// the bank gives neither, as it does for someone it knows by a phone number alone.
std::string PartyName(const BunqLabel& party);
std::string PartyName(const BunqCounterparty& party);
// An amount as a person reads it, its thousands apart: "€12,500.00", "-€3.00".
std::string Money(std::int64_t minor, Currency currency);
// The same with a plus on what came in, as a list of payments shows it: "+€12.50", "-€3.00", "€0.00".
std::string SignedMoney(std::int64_t minor, Currency currency);
// The day a moment falls on in local time, as one number: moments of one day have the same.
std::int64_t LocalDay(std::chrono::system_clock::time_point time);
// That day as a list's heading: "Today", "Yesterday", "Monday 3 November", and with its year when that is not
// `now`'s.
std::string DayLabel(std::chrono::system_clock::time_point time, std::chrono::system_clock::time_point now);
// "3 Nov", and with its year when that is not `now`'s.
std::string ShortDate(std::chrono::system_clock::time_point time, std::chrono::system_clock::time_point now);
// "14:05".
std::string ClockTime(std::chrono::system_clock::time_point time);
// "3 November 2026, 14:05".
std::string FullTime(std::chrono::system_clock::time_point time);
// "2026-11-03", as a date field takes it.
std::string DateInput(std::chrono::system_clock::time_point time);
// What kind of payment the bank says one is ("MASTERCARD/PAYMENT"), in words; the bank's own for one not known.
std::string KindLabel(std::string_view kind);
// A status as the bank writes it ("PIN_TRIES_EXCEEDED"), in words: "Pin tries exceeded".
std::string StatusLabel(std::string_view status);
// A card's product ("MASTERCARD_DEBIT"), in words: "Mastercard debit".
std::string CardProduct(std::string_view productType);
// When a card expires, as its face has it: "11/30" for the bank's "2030-11-30"; anything else as the bank says it.
std::string CardExpiry(std::string_view expiry);
// When a scheduled payment runs: "Once on 3 Nov", "Every 2 weeks from 3 Nov until 1 Jan 2027".
std::string ScheduleLabel(const BunqSchedule& schedule, std::chrono::system_clock::time_point now);
// A secret said without saying it: how it begins and how long it is ("sandbox_ab12… 64 characters"), enough to
// tell two keys apart and to see that all of one arrived. One too short for that is said by its length alone.
std::string Fingerprint(std::string_view secret);
}