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:
parent
1ea50c50bc
commit
5b4037955b
106 changed files with 17804 additions and 289 deletions
|
|
@ -37,6 +37,10 @@ namespace Nostro {
|
|||
|
||||
// An error response from bunq, with its HTTP status (bunq also uses 466, 490 and 491) and error_description.
|
||||
export struct BunqError : std::runtime_error {
|
||||
// What ends the message of an error to a write that may have been carried out all the same: a 5xx, a lost
|
||||
// connection or an unreadable answer. It travels with nostrod's errors, so its clients can tell.
|
||||
static constexpr std::string_view maybeCarriedOut = "; the request may have been carried out, check before trying again";
|
||||
|
||||
std::uint16_t status;
|
||||
BunqError(std::uint16_t status, const std::string& message);
|
||||
};
|
||||
|
|
@ -94,6 +98,8 @@ namespace Nostro {
|
|||
|
||||
// Throws std::invalid_argument for a unit bunq does not know or `every` of 0, as Schedule would.
|
||||
void Check() const;
|
||||
// A unit as a person writes it, "monthly", as bunq names it: "MONTHLY". Check() decides whether bunq knows it.
|
||||
static std::string UnitFromWord(std::string_view word);
|
||||
};
|
||||
|
||||
// A payment bunq makes on a schedule (a bunq SchedulePayment).
|
||||
|
|
@ -126,13 +132,28 @@ namespace Nostro {
|
|||
std::uint64_t id;
|
||||
std::string kind; // bunq's object: CardDebit, CardCredit, ...
|
||||
std::string productType; // MASTERCARD_DEBIT, MAESTRO_DEBIT, ...
|
||||
std::string status; // ACTIVE, DEACTIVATED, LOST, STOLEN, CANCELLED, EXPIRED or PIN_TRIES_EXCEEDED
|
||||
std::string orderStatus;
|
||||
std::string status; // ACTIVE, DEACTIVATED, LOST, STOLEN, CANCELLED, EXPIRED or PIN_TRIES_EXCEEDED: of the plastic, see State()
|
||||
std::string orderStatus; // how far bunq is with making and delivering it: VIRTUAL_DELIVERY, ACCEPTED_FOR_PRODUCTION, DELIVERED_TO_CUSTOMER, ...
|
||||
std::string nameOnCard;
|
||||
std::string secondLine;
|
||||
std::string lastFour; // last four digits of the card number
|
||||
std::string expiry; // YYYY-MM-DD
|
||||
std::string iban; // the account it pays from
|
||||
|
||||
// Whether the card is a virtual one: bunq delivered it as a number and went no further, so there is no plastic
|
||||
// of it, or none yet.
|
||||
bool Virtual() const noexcept;
|
||||
// How the card stands, in one word: bunq's status, except that a virtual card that is not gone for good is
|
||||
// VIRTUAL. bunq has such a card as DEACTIVATED however well it pays, and leaves it so when it is asked to
|
||||
// freeze or to unfreeze it, without an error (a real card and the sandbox, 2026-11-19): DEACTIVATED is its
|
||||
// word for plastic that was not activated, and it gives a virtual card no status that says whether it is
|
||||
// frozen. Reporting one LOST or STOLEN does take.
|
||||
std::string_view State() const noexcept;
|
||||
// Throws std::runtime_error when bunq did not do what was asked: it kept another status than `wanted`, as it
|
||||
// does for a card that was never activated, or the card is a virtual one asked to freeze or unfreeze, which
|
||||
// bunq has as DEACTIVATED before and after. SetCardStatus answers with the card as bunq has it, which is not
|
||||
// always what was asked.
|
||||
void ExpectStatus(std::string_view wanted) const;
|
||||
};
|
||||
|
||||
export struct BunqAccount : public Account {
|
||||
|
|
@ -238,6 +259,10 @@ namespace Nostro {
|
|||
// OAuth: send the user to this URL, where they approve with the bunq app; bunq then redirects to
|
||||
// `redirectUri` with `code` and `state` in the query. `redirectUri` must be registered with the OAuth client.
|
||||
static std::string OAuthAuthorizationUrl(BunqEnvironment environment, std::string_view clientId, std::string_view redirectUri, std::string_view state);
|
||||
// The code in the address the browser was redirected to after that approval. Throws std::runtime_error when
|
||||
// bunq did not authorize (error= in it), when it has no code, or when its state is not `state`: a code from
|
||||
// anyone else's authorization is refused.
|
||||
static std::string OAuthCodeFromRedirect(std::string_view redirected, std::string_view state);
|
||||
// Exchanges the code from that redirect for an access token, which Create takes in place of an API key.
|
||||
static std::string OAuthExchangeCode(BunqEnvironment environment, std::string_view clientId, std::string_view clientSecret, std::string_view redirectUri, std::string_view code);
|
||||
|
||||
|
|
@ -347,7 +372,7 @@ struct std::formatter<Nostro::BunqDraftPayment> : std::formatter<std::string> {
|
|||
template<>
|
||||
struct std::formatter<Nostro::BunqCard> : std::formatter<std::string> {
|
||||
auto format(const Nostro::BunqCard& obj, std::format_context& ctx) const {
|
||||
return std::formatter<std::string>::format(std::format("{}\t{}\t{}\t**** {}\t{}\t{}\t{}\texpires {}", obj.id, obj.status, obj.productType, obj.lastFour, obj.nameOnCard, obj.secondLine, obj.iban, obj.expiry), ctx);
|
||||
return std::formatter<std::string>::format(std::format("{}\t{}\t{}\t**** {}\t{}\t{}\t{}\texpires {}", obj.id, obj.State(), obj.productType, obj.lastFour, obj.nameOnCard, obj.secondLine, obj.iban, obj.expiry), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue