diff options
author | buttercat1791 <mjjurkoic@gmail.com> | 2024-05-28 09:29:39 -0500 |
---|---|---|
committer | buttercat1791 <mjjurkoic@gmail.com> | 2024-05-28 09:29:39 -0500 |
commit | 417383becd57e62108660c70872ac2024c1f29b2 (patch) | |
tree | c025eb80a36c9bf8aaf75e658d8d9b581fd3904b /include | |
parent | 9db92687fecd7528a6aa93e60bcbebc41342378c (diff) |
Add connection token generation
Diffstat (limited to 'include')
-rw-r--r-- | include/signer/noscrypt_signer.hpp | 13 | ||||
-rw-r--r-- | include/signer/signer.hpp | 23 |
2 files changed, 29 insertions, 7 deletions
diff --git a/include/signer/noscrypt_signer.hpp b/include/signer/noscrypt_signer.hpp index b4ea5f7..d2135da 100644 --- a/include/signer/noscrypt_signer.hpp +++ b/include/signer/noscrypt_signer.hpp @@ -26,8 +26,8 @@ public: void receiveConnection(std::string connectionToken) override; - void initiateConnection( - std::string relay, + std::string initiateConnection( + std::vector<std::string> relays, std::string name, std::string url, std::string description) override; @@ -39,6 +39,9 @@ private: std::string _localPrivateKey; std::string _localPublicKey; + + ///< A list of relays that will be used to connect to the remote signer. + std::vector<std::string> _relays; /** * @brief Initializes the noscrypt library context into the class's `context` property. @@ -57,11 +60,11 @@ private: #pragma region Logging - void _logNoscryptInitResult(NCResult result); + void _logNoscryptInitResult(NCResult initResult); - void _logNoscryptSecretKeyResult(NCResult result); + void _logNoscryptSecretValidationResult(NCResult secretValidationResult); - void _logNoscryptPublicKeyResult(NCResult result); + void _logNoscryptPubkeyGenerationResult(NCResult pubkeyGenerationResult); #pragma endregion }; diff --git a/include/signer/signer.hpp b/include/signer/signer.hpp index 319f739..c774d1d 100644 --- a/include/signer/signer.hpp +++ b/include/signer/signer.hpp @@ -2,6 +2,7 @@ #include <memory> #include <string> +#include <vector> #include "data/data.hpp" @@ -30,10 +31,28 @@ class INostrConnectSigner : public ISigner public: virtual ~INostrConnectSigner() = default; + /** + * @brief Establishes a connection to a remote signer using a connection token generated by the + * signer. + * @param connectionToken A connection token string beginning with `bunker://`, as defined by + * NIP-46. + * @remark A typical use case for this method would be for the user to paste a signer-generated + * connection token into a client application, which would then call this method to establish a + * connection to the remote signer. + */ virtual void receiveConnection(std::string connectionToken) = 0; - virtual void initiateConnection( - std::string relay, + /** + * @brief Generates a connection token that a remote signer may use to establish a connection + * to the client. + * @param relays A list of one or more relays the client will use to communicate with the + * remote signer. + * @returns A connection token string beginning with `nostrconnect://`, as specified by NIP-46, + * that may be provided to a remote signer to establish a connection to the client. Returns an + * empty string if the connection token generation fails. + */ + virtual std::string initiateConnection( + std::vector<std::string> relays, std::string name, std::string url, std::string description) = 0; |