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>
99 lines
5.5 KiB
C++
99 lines
5.5 KiB
C++
// SPDX-License-Identifier: GPL-3.0-only
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
module Nostro.App:Errors_impl;
|
|
import std;
|
|
import Nostro;
|
|
import :Errors;
|
|
|
|
using namespace Nostro;
|
|
using namespace Nostro::App;
|
|
|
|
std::string_view App::ActionOf(Operation operation) noexcept {
|
|
switch(operation) {
|
|
case Operation::Send:
|
|
case Operation::Schedule:
|
|
case Operation::PayRequest:
|
|
case Operation::AcceptDraft: return Bus::actionPay;
|
|
case Operation::Draft:
|
|
case Operation::Request:
|
|
case Operation::RevokeRequest:
|
|
case Operation::RejectRequest:
|
|
case Operation::CancelSchedule:
|
|
case Operation::RejectDraft:
|
|
case Operation::FreezeCard: return Bus::actionChange;
|
|
case Operation::UnfreezeCard: return Bus::actionUnfreezeCard;
|
|
case Operation::BlockCard: return Bus::actionBlockCard;
|
|
case Operation::AddConnection:
|
|
case Operation::RemoveConnection:
|
|
case Operation::SetCheckoutAccount: return Bus::actionConnectors;
|
|
default: return Bus::actionView;
|
|
}
|
|
}
|
|
|
|
bool App::AsksPassword(Operation operation) noexcept {
|
|
const std::string_view action = ActionOf(operation);
|
|
return action != Bus::actionView && action != Bus::actionChange;
|
|
}
|
|
|
|
bool App::MovesMoney(Operation operation) noexcept {
|
|
return ActionOf(operation) == Bus::actionPay;
|
|
}
|
|
|
|
Guidance App::Explain(const std::exception_ptr& error, Operation operation) {
|
|
const bool reading = operation == Operation::Load;
|
|
const std::string where = MovesMoney(operation) ? "Look at the account's activity before trying again." : "Look at what is there before trying again.";
|
|
const auto unknown = [&where, operation](std::string_view said) {
|
|
return Guidance{Problem::Unknown, MovesMoney(operation) ? "It may have been paid" : "It may have been done", std::format("No clear answer came back: {}. {}", said, where), true, false};
|
|
};
|
|
const auto missing = [](std::string_view said) {
|
|
return Guidance{Problem::NoService, "Nostro's service is not running", std::format("Nostro keeps your bank connections in a service of its own, nostrod, which is not running and which the system could not start. Install nostrod and its system files as Nostro's README says, then try again. ({})", said), false, true};
|
|
};
|
|
try {
|
|
std::rethrow_exception(error);
|
|
} catch(const DaemonMissing& e) {
|
|
return missing(e.what());
|
|
} catch(const NoSystemBus& e) {
|
|
return {Problem::NoService, "The system bus cannot be reached", std::format("Nostro talks to its service, nostrod, over the system bus, and cannot connect to it: {}. Nothing can be shown or done without it.", e.what()), false, true};
|
|
} catch(const OutcomeUnknown& e) {
|
|
return unknown(e.what());
|
|
} catch(const std::invalid_argument& e) {
|
|
return {Problem::Input, "That cannot be done", std::format("{}. Nothing was sent.", e.what()), false, false};
|
|
} catch(const DaemonError& e) {
|
|
if(e.name == Bus::errorCancelled) {
|
|
return {Problem::NotConfirmed, "Not confirmed", "Nothing was done. If no password dialog appeared, nothing in this session can ask for your password: the desktop's authentication agent is not running.", false, false};
|
|
}
|
|
if(e.name == "org.freedesktop.DBus.Error.AccessDenied") {
|
|
return {Problem::NotAllowed, "Not allowed", std::format("{}. Nothing was done. Try again, or ask whoever manages this computer.", e.what()), false, reading};
|
|
}
|
|
if(e.name == "org.freedesktop.DBus.Error.InteractiveAuthorizationRequired") {
|
|
return {Problem::CannotAsk, "Could not ask for your password", "nostrod was not allowed to have the system ask for your password, so nothing was done. Nostro's README says how the service is set up.", false, false};
|
|
}
|
|
if(e.name == Bus::errorOAuthCannotPay) {
|
|
// What a bank answers a connection that it lets pay between the user's own accounts only.
|
|
return {Problem::OwnAccountsOnly, "This connection cannot pay others", "Your bank lets it pay between your own accounts only. Save the payment as a draft instead, and approve it in your bank's app.", false, false};
|
|
}
|
|
if(e.name == Bus::errorBank) {
|
|
return {Problem::Bank, "The bank refused", e.what(), false, reading};
|
|
}
|
|
if(e.name.starts_with("org.freedesktop.systemd1.") || e.name.starts_with("org.freedesktop.DBus.Error.Spawn.") || e.name == "org.freedesktop.DBus.Error.NameHasNoOwner") {
|
|
return missing(e.what());
|
|
}
|
|
if(e.name == "org.freedesktop.DBus.Error.NoReply" || e.name == "org.freedesktop.DBus.Error.Timeout") {
|
|
return {Problem::Late, "No answer yet", "nostrod took too long to answer, which the bank's own limits can cause. Try again in a moment.", false, true};
|
|
}
|
|
// nostrod's own word for a payment that ended without a clear answer, such as one its worker died under.
|
|
if(e.name == Bus::errorFailed && MovesMoney(operation)) {
|
|
return unknown(e.what());
|
|
}
|
|
return {Problem::Failed, "That did not work", e.what(), false, reading};
|
|
} catch(const std::system_error& e) {
|
|
// An answer that could not be read, or a connection that broke under the call.
|
|
if(!reading) {
|
|
return unknown(e.what());
|
|
}
|
|
return {Problem::Failed, "That did not work", e.what(), false, true};
|
|
} catch(const std::exception& e) {
|
|
return {Problem::Failed, "That did not work", e.what(), false, reading};
|
|
}
|
|
}
|