From 6dde23e6c66e846c64d49c5258f0dbf44e3d0374 Mon Sep 17 00:00:00 2001 From: Michael Jurkoic Date: Mon, 18 Mar 2024 21:28:19 -0500 Subject: Declare a signer interface --- include/nostr.hpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'include/nostr.hpp') diff --git a/include/nostr.hpp b/include/nostr.hpp index 645090a..3e60d7b 100644 --- a/include/nostr.hpp +++ b/include/nostr.hpp @@ -18,7 +18,9 @@ namespace nostr typedef std::vector RelayList; typedef std::unordered_map> TagMap; -// TODO: Add null checking to seralization and deserialization methods. +class ISigner; +class NostrService; + /** * @brief A Nostr event. * @remark All data transmitted over the Nostr protocol is encoded in JSON blobs. This struct @@ -40,7 +42,7 @@ struct Event * @returns A stringified JSON object representing the event. * @throws `std::invalid_argument` if the event object is invalid. */ - std::string serialize(); + std::string serialize(std::shared_ptr signer); /** * @brief Deserializes the event from a JSON string. @@ -103,6 +105,7 @@ private: class NostrService { +// TODO: Setup signer in the constructor. public: NostrService( std::shared_ptr appender, @@ -213,6 +216,9 @@ private: ///< The WebSocket client used to communicate with relays. std::shared_ptr _client; + ///< The signer used to sign Nostr events. + std::shared_ptr _signer; + ///< A mutex to protect the instance properties. std::mutex _propertyMutex; ///< The default set of Nostr relays to which the service will attempt to connect. @@ -287,4 +293,10 @@ private: */ void onEvent(std::string subscriptionId, Event event); }; + +class ISigner +{ +public: + virtual std::string generateSignature(std::shared_ptr event) = 0; +}; } // namespace nostr -- cgit