// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL // the Matrix sign-in helpers that decide nothing about a server. They are kept // free of Quotient so they can be unit-tested without a Connection and without // the network, the same way MatrixTranslate is. #pragma once #include namespace koutnet::matrix { // the SSO redirect endpoint: the homeserver sends the browser here with a // loginToken in the query, and we hand that token to Connection::loginWithToken. // redirectUrl is where the homeserver should send the browser afterwards; it is // percent-encoded into the query so the whole thing stays one hop. QUrl ssoRedirectUrl(const QUrl &homeserver, const QUrl &redirectUrl); // A fresh unguessable value for the state that rides inside the SSO redirect. It // is embedded into the redirectUrl the browser is sent to and comes back with // the loginToken, tying the token to the attempt that started it: a // koutnet://sso callback from anywhere else carries no state and is refused. QString makeSsoState(); // Pulls the state a homeserver echoed back to the OS out of the callback URL. It // lands in the query where we put it, but like loginToken it may be moved to the // fragment depending on the server, so both are tried. False when there is no // state at all, which for a login callback means "forged" as far as we care. bool ssoCallbackState(const QUrl &url, QString *outState); // A Megolm recovery key is twelve groups of four base58 characters joined by // dashes - the form "unlock with security key" shows. A passphrase is anything // else, and telling the two apart up front lets unlockKeyBackup try the right // SSSS call first instead of always failing once and retrying. bool looksLikeRecoveryKey(const QString &candidate); }