From 15c061974ae164a9b6b0d159d35f0389711d0345 Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Fri, 31 May 2024 09:30:03 -0500 Subject: Parse connection token --- include/signer/noscrypt_signer.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include/signer') diff --git a/include/signer/noscrypt_signer.hpp b/include/signer/noscrypt_signer.hpp index d2135da..606438e 100644 --- a/include/signer/noscrypt_signer.hpp +++ b/include/signer/noscrypt_signer.hpp @@ -40,6 +40,9 @@ private: std::string _localPrivateKey; std::string _localPublicKey; + std::string _remotePublicKey; + std::string _bunkerSecret; + ///< A list of relays that will be used to connect to the remote signer. std::vector _relays; @@ -58,6 +61,24 @@ private: */ std::tuple _createLocalKeypair(); + /** + * @brief Parses the remote signer npub from a connection token provided by the signer. + * @param connectionToken A connection token beginning with `bunker://`. + * @returns The index of the first character of the connection token's query string, or -1 if + * no valid public key could be parsed. + * @remark This function updates the `_remotePublicKey` string in its class instance by side + * effect. + */ + int _parseRemotePublicKey(std::string connectionToken); + + /** + * @brief Parses a single query param from a connection token provided by a remote signer. + * @param param A single query param from the connection token of the form `key=value`. + * @remark This function updates the `_relays` vector and the `_bunkerSecret` string in its + * class instance by side effect. + */ + void _handleConnectionTokenParam(std::string param); + #pragma region Logging void _logNoscryptInitResult(NCResult initResult); -- cgit