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
|
|
@ -520,7 +520,13 @@ namespace {
|
|||
std::string apiKey = Read<std::string>(call);
|
||||
std::string allowedIps = Read<std::string>(call);
|
||||
const std::string requested = Read<std::string>(call);
|
||||
const BunqEnvironment environment = requested.empty() ? BunqConnector::EnvironmentOfKey(apiKey) : ParseEnvironment(requested);
|
||||
// The key says itself which environment it is of, by how it starts. One the caller names is held to that,
|
||||
// before anyone is asked and before the key goes anywhere: sent to the environment it is not of, a key
|
||||
// would only be refused there, after a real one had been shown to the sandbox.
|
||||
const BunqEnvironment environment = BunqConnector::EnvironmentOfKey(apiKey);
|
||||
if(!requested.empty() && ParseEnvironment(requested) != environment) {
|
||||
throw std::invalid_argument(std::format("that API key is a {} key, not a {} one: a sandbox key starts with sandbox_, and no other key does", EnvironmentName(environment), requested));
|
||||
}
|
||||
const Prompt prompt{actionConnectors, std::format("add a bunq connector ({})", EnvironmentName(environment)), {{"environment", std::string(EnvironmentName(environment))}}};
|
||||
return Gate(worker, call, prompt, [apiKey = std::move(apiKey), allowedIps = std::move(allowedIps), environment](sd_bus_message* reply) {
|
||||
AppendAdded(reply, BunqConnector::Create(std::string(apiKey), allowedIps, environment));
|
||||
|
|
@ -556,7 +562,7 @@ namespace {
|
|||
}
|
||||
}
|
||||
if(matches.size() != 1) {
|
||||
throw std::invalid_argument(matches.empty() ? std::format("no connector is called or numbered '{}'", key) : std::format("{} connectors are called '{}': use the number `nostro connectors` shows", matches.size(), key));
|
||||
throw std::invalid_argument(matches.empty() ? std::format("no connector is called or numbered '{}'", key) : std::format("{} connectors are called '{}': use its number in the list of connectors", matches.size(), key));
|
||||
}
|
||||
const std::string storageKey = matches.front()->StorageKey();
|
||||
const Prompt prompt{actionConnectors, std::format("remove the bunq connector '{}' and its stored transactions", Shown(matches.front()->name)), {}};
|
||||
|
|
@ -595,7 +601,11 @@ namespace {
|
|||
const AccountKey key = KeyOf(FindAccount(account));
|
||||
return Gate(worker, call, Prompt{actionView, "see your transactions", {}}, [key, query](sd_bus_message* reply) {
|
||||
BunqAccount& found = AccountBy(key);
|
||||
found.connector->GetNewTransactions(found);
|
||||
// What is new at the bank first: a call to it, which takes its time and which it counts. Not for a
|
||||
// question about what is stored alone, as a search in a list just given is: that is answered at once.
|
||||
if(!query.stored) {
|
||||
found.connector->GetNewTransactions(found);
|
||||
}
|
||||
Append(reply, found.FindTransactions(found.StorageKey(), query));
|
||||
});
|
||||
});
|
||||
|
|
@ -812,6 +822,12 @@ namespace {
|
|||
for(BunqConnector& bank : BunqConnector::connectors) {
|
||||
for(const BunqCard& found : bank.Cards()) {
|
||||
if(found.id == card) {
|
||||
// bunq does not freeze or unfreeze a virtual card when asked, and answers as if nothing were
|
||||
// wrong, with the card DEACTIVATED as it has it all along: a freeze answered so would look as
|
||||
// if it had worked. Refused before anyone is asked for a password.
|
||||
if(found.Virtual() && change->second.first != actionBlockCard) {
|
||||
throw std::invalid_argument(std::format("card {} is a virtual card, which bunq does not freeze or unfreeze when asked: do that in the bunq app", card));
|
||||
}
|
||||
const std::string lastFour = Shown(found.lastFour);
|
||||
const Prompt prompt{change->second.first, std::vformat(change->second.second, std::make_format_args(lastFour)), {{"card", std::to_string(card)}, {"status", status}}};
|
||||
return Gate(worker, call, prompt, [storageKey = bank.StorageKey(), card, status](sd_bus_message* reply) {
|
||||
|
|
@ -1000,7 +1016,7 @@ namespace {
|
|||
if(const BunqAccount* chosen = CheckoutAccount(worker)) {
|
||||
then(KeyOf(*chosen));
|
||||
} else {
|
||||
then(std::make_exception_ptr(NoCheckoutAccount("no account is chosen to pay checkouts from, or it is gone: `nostro checkout account <account>` chooses one")));
|
||||
then(std::make_exception_ptr(NoCheckoutAccount("no account is chosen to pay checkouts from, or it is gone: choose one in Nostro's settings, or with `nostro checkout account`")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue