Nostro/interfaces/Nostro.App-Format.cppm

53 lines
3.2 KiB
Text
Raw Normal View History

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>
2026-11-19 12:27:14 +01:00
// 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 its last four characters, enough to tell two keys apart.
std::string Fingerprint(std::string_view secret);
}