// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL // KOutNet - KWallet-backed secret storage. // // only the values that must never touch a config file live here: the Ed25519 // identity keypair, the group passphrase, the per-group keys, the Matrix // access tokens and the at-rest encryption key of the chat history. #pragma once #include #include namespace koutnet { // Secrets are plain entries in the "KOutNet" folder of the application wallet, // locked with the login keyring and maintained by kwalletd - no file of our own // to steal. // // with no wallet reachable (CI container, non-KDE desktop, Windows) the store // fails hard rather than finding a readable second-best place: reads miss, // writes are refused while isAvailable() is false, and the identity is clearly // a throwaway that lasts one session. // // Test mode and setInMemoryOnly() keep everything in this process instead, // which is what every suite under src/tests switches on in its main(). class SecretStore { public: // Keeps every secret in this process and never touches the wallet. On by // default in QStandardPaths test mode; the suites still call it, so the // isolation never depends on test mode alone. static void setInMemoryOnly(bool enabled); static bool isInMemoryOnly(); // False when every secret would be lost on exit: the wallet is unreachable // and this session is not in the controlled in-memory mode. static bool isAvailable(); static bool read(const QString &key, QString *outValue); static bool write(const QString &key, const QString &value); static bool remove(const QString &key); // Deletes plaintext leftovers of the given absolute QSettings keys and // confirms against the file on disk that they are really gone. True also // when there was nothing to delete, so callers can run it on every start. static bool purgePlaintextConfigKeys(const QStringList &keys, QString *outDetail); static QString lastError(); }; } // namespace koutnet