4#include <nlohmann/json.hpp>
21enum class kind : std::uint16_t {
49 std::vector<std::vector<std::string>>
tags;
59 static auto deserialize(std::span<const std::byte> bytes) -> std::optional<event_data>;
67 static auto deserialize(
const std::string &json) -> std::optional<event_data>;
74 [[nodiscard]]
auto serialize() const -> std::vector<std::
byte>;
86 std::uint64_t timestamp,
87 const std::
string &signal_fingerprint,
88 const std::
string &capabilities = "mesh,nostr") ->
event_data;
99 std::uint64_t timestamp,
111 const std::
string &recipient_pubkey,
112 const std::
string &encrypted_payload) ->
event_data;
124 std::uint64_t timestamp,
125 const std::
string &recipient_pubkey,
126 const std::
string &prekey_bundle) ->
event_data;
160 static auto deserialize(
const std::string &json) -> std::optional<ok>;
178 static auto deserialize(
const std::string &json) -> std::optional<eose>;
204 static auto deserialize(const std::
string &json) -> std::optional<
req>;
238 static auto deserialize(const std::
string &json) -> std::optional<
event>;
242constexpr std::
size_t max_subscription_id_length = 64;
250inline auto validate_subscription_id(const std::
string &subscription_id) ->
void
252 if (subscription_id.empty()) {
throw std::invalid_argument(
"Subscription ID cannot be empty"); }
254 throw std::invalid_argument(
"Subscription ID exceeds maximum length of 64 characters");
constexpr auto bundle_announcement_minimum_version
Minimum protocol version required for bundle announcements.
constexpr std::size_t max_subscription_id_length
Maximum allowed subscription ID length.
kind
Nostr event kind identifiers.
@ identity_announcement
Radix: Node identity announcement.
@ node_status
Radix: Node status update.
@ bundle_announcement
Radix: Signal Protocol prekey bundle.
@ encrypted_dm
Encrypted direct message (NIP-04)
@ profile_metadata
User profile metadata (NIP-01)
@ contact_list
Contact list (NIP-02)
@ session_request
Radix: Session establishment request.
@ recommend_relay
Relay recommendation (NIP-01)
@ reaction
Reaction to an event (NIP-25)
@ encrypted_message
Radix: Encrypted message via Signal Protocol.
@ text_note
Text note/post (NIP-01)
@ parameterized_replaceable_start
Start of parameterized replaceable range.
End of Stored Events marker.
std::string subscription_id
Subscription this EOSE applies to.
static auto deserialize(const std::string &json) -> std::optional< eose >
Deserializes EOSE message from JSON.
Nostr event data structure.
static auto deserialize(const std::string &json) -> std::optional< event_data >
Deserializes event data from JSON string.
static auto create_identity_announcement(const std::string &sender_pubkey, std::uint64_t timestamp, const std::string &signal_fingerprint, const std::string &capabilities="mesh,nostr") -> event_data
Creates an identity announcement event.
std::string sig
Schnorr signature (64-byte hex)
std::string id
Event ID (32-byte hex hash)
static auto deserialize(std::span< const std::byte > bytes) -> std::optional< event_data >
Deserializes event data from byte array.
auto get_kind() const -> std::optional< enum kind >
Returns the event kind.
static auto create_session_request(const std::string &sender_pubkey, std::uint64_t timestamp, const std::string &recipient_pubkey, const std::string &prekey_bundle) -> event_data
Creates a session establishment request event.
auto serialize() const -> std::vector< std::byte >
Serializes event data to byte array.
static auto create_encrypted_message(std::uint64_t timestamp, const std::string &recipient_pubkey, const std::string &encrypted_payload) -> event_data
Creates an encrypted message event.
std::string content
Event content.
static auto create_bundle_announcement(const std::string &sender_pubkey, std::uint64_t timestamp, const std::string &bundle_hex) -> event_data
Creates a bundle announcement event.
std::string pubkey
Public key of event creator (32-byte hex)
auto is_radix_message() const -> bool
Checks if event is a Radix-specific message type.
std::uint64_t created_at
Unix timestamp.
std::vector< std::vector< std::string > > tags
Event tags (arbitrary string arrays)
Nostr EVENT message wrapper.
event_data data
The event itself.
std::string subscription_id
Subscription this event matches.
auto serialize() const -> std::string
Serializes event to JSON string.
static auto from_event_data(const event_data &evt) -> event
Creates an event message from event_data.
Nostr OK response message.
static auto deserialize(const std::string &json) -> std::optional< ok >
Deserializes OK message from JSON.
std::string message
Human-readable status message.
std::string event_id
ID of the event this responds to.
Nostr REQ subscription request.
auto serialize() const -> std::string
Serializes REQ to JSON string.
std::string subscription_id
Unique identifier for this subscription.
nlohmann::json filters
Filter criteria (NIP-01 format)