Remove ContentFrame references

This commit is contained in:
Jazz Turner-Baggs 2025-12-15 14:47:07 -08:00
parent d37302c6e1
commit 755c40c9ae
No known key found for this signature in database
4 changed files with 19 additions and 6 deletions

View File

@ -82,7 +82,7 @@ proc main() {.async.} =
# Perform OOB Introduction: Raya -> Saro # Perform OOB Introduction: Raya -> Saro
let raya_bundle = raya.createIntroBundle() let raya_bundle = raya.createIntroBundle()
discard await saro.newPrivateConversation(raya_bundle, initTextFrame("Init").toContentFrame()) discard await saro.newPrivateConversation(raya_bundle, initTextFrame("Init").toContentFrame().toBytes())
await sleepAsync(20.seconds) # Run for some time await sleepAsync(20.seconds) # Run for some time

View File

@ -186,7 +186,7 @@ proc getConversation*(client: Client, convoId: string): Conversation =
result = client.conversations[convoId] result = client.conversations[convoId]
proc newPrivateConversation*(client: Client, proc newPrivateConversation*(client: Client,
introBundle: IntroBundle, content: ContentFrame): Future[Option[ChatError]] {.async.} = introBundle: IntroBundle, content: Content): Future[Option[ChatError]] {.async.} =
## Creates a private conversation with the given `IntroBundle`. ## Creates a private conversation with the given `IntroBundle`.
## `IntroBundles` are provided out-of-band. ## `IntroBundles` are provided out-of-band.
let remote_pubkey = loadPublicKeyFromBytes(introBundle.ident).get() let remote_pubkey = loadPublicKeyFromBytes(introBundle.ident).get()

View File

@ -23,7 +23,8 @@ import convo_type
import message import message
import ../../naxolotl as nax import ../../naxolotl as nax
const TopicPrefixPrivateV1 = "/convo/private/"
type type
ReceivedPrivateV1Message* = ref object of ReceivedMessage ReceivedPrivateV1Message* = ref object of ReceivedMessage
@ -43,7 +44,7 @@ type
proc derive_topic(participant: PublicKey): string = proc derive_topic(participant: PublicKey): string =
## Derives a topic from the participants' public keys. ## Derives a topic from the participants' public keys.
return "/convo/private/" & participant.get_addr() return TopicPrefixPrivateV1 & participant.get_addr()
proc getTopicInbound*(self: PrivateV1): string = proc getTopicInbound*(self: PrivateV1): string =
## Returns the topic where the local client is listening for messages ## Returns the topic where the local client is listening for messages
@ -53,6 +54,17 @@ proc getTopicOutbound*(self: PrivateV1): string =
## Returns the topic where the remote recipient is listening for messages ## Returns the topic where the remote recipient is listening for messages
return derive_topic(self.participant) return derive_topic(self.participant)
## Parses the topic to extract the conversation ID.
proc parseTopic*(topic: string): Result[string, ChatError] =
if not topic.startsWith(TopicPrefixPrivateV1):
return err(ChatError(code: errTopic, context: "Invalid topic prefix"))
let id = topic.split('/')[^1]
if id == "":
return err(ChatError(code: errTopic, context: "Empty conversation ID"))
return ok(id)
proc allParticipants(self: PrivateV1): seq[PublicKey] = proc allParticipants(self: PrivateV1): seq[PublicKey] =
return @[self.owner.getPubkey(), self.participant] return @[self.owner.getPubkey(), self.participant]
@ -255,7 +267,7 @@ proc initPrivateV1Sender*(sender:Identity,
ds: WakuClient, ds: WakuClient,
participant: PublicKey, participant: PublicKey,
seedKey: array[32, byte], seedKey: array[32, byte],
content: ContentFrame, content: Content,
deliveryAckCb: proc(conversation: Conversation, msgId: string): Future[void] {.async.} = nil): (PrivateV1, EncryptedPayload) = deliveryAckCb: proc(conversation: Conversation, msgId: string): Future[void] {.async.} = nil): (PrivateV1, EncryptedPayload) =
let convo = initPrivateV1(sender, ds, participant, seedKey, "default", true, deliveryAckCb) let convo = initPrivateV1(sender, ds, participant, seedKey, "default", true, deliveryAckCb)

View File

@ -11,6 +11,7 @@ import
conversations, conversations,
conversation_store, conversation_store,
crypto, crypto,
delivery/waku_client,
errors, errors,
identity, identity,
proto_types, proto_types,
@ -104,7 +105,7 @@ proc newPrivateInvite(initator_static: PublicKey,
################################################# #################################################
## Establish a PrivateConversation with a remote client ## Establish a PrivateConversation with a remote client
proc inviteToPrivateConversation*(self: Inbox, ds: Wakuclient, remote_static: PublicKey, remote_ephemeral: PublicKey, content: ContentFrame ) : Future[PrivateV1] {.async.} = proc inviteToPrivateConversation*(self: Inbox, ds: Wakuclient, remote_static: PublicKey, remote_ephemeral: PublicKey, content: Content ) : Future[PrivateV1] {.async.} =
# Create SeedKey # Create SeedKey
# TODO: Update key derivations when noise is integrated # TODO: Update key derivations when noise is integrated
var local_ephemeral = generateKey() var local_ephemeral = generateKey()