Skip to main content
Import OfflineProtocol from @offline-protocol/mesh-sdk. These signatures match v0.27.0. Read the integration guide for prerequisites and complete usage.

Methods on this page

sendMessage

Sends a message returns: Message ID throws: Error if message fails to send

forwardMessage

Forwards a message to a new recipient with original sender attribution. Creates a new message with the original content and attaches forwarding metadata tracking the original sender, message ID, timestamp, and forward count. returns: New message ID throws: Error if forwarding fails

sendConnectionRequest

Sends a connection request params.recipient must be the target’s canonical address (off1…): the value they derived from their own identity key, which is also what neighbor_discovered reports as peer_id. The returned message id is the correlation key for the request’s outcome events: connection_request_undeliverable (recipient offline or retry budget exhausted), message_delivered (reached the recipient’s device), and message_failed (generic retry exhaustion, fires alongside the typed event). The recipient’s answer arrives as connection_accepted / connection_rejected, which correlate by peer id (accepted_by / rejected_by), not by message id. returns: Message ID throws: Error if request fails to send

acceptConnectionRequest

Accepts a connection request returns: Message ID throws: Error if acceptance fails to send

rejectConnectionRequest

Rejects a connection request returns: Message ID throws: Error if rejection fails to send

cancelConnectionRequest

Cancels a previously sent connection request returns: Message ID throws: Error if cancellation fails to send

getMessageStats

Gets message delivery statistics returns: Array of message delivery statistics throws: Error if stats retrieval fails

getDeliverySuccessRate

Gets the delivery success rate returns: Success rate as a number between 0 and 1 throws: Error if retrieval fails

getMedianLatency

Gets the median message delivery latency returns: Median latency in milliseconds, or null if no data available throws: Error if retrieval fails

getMedianHops

Gets the median hop count for delivered messages returns: Median hop count, or null if no data available throws: Error if retrieval fails

receiveMessage

Polls for the next received message returns: Message object if available, null otherwise throws: Error if polling fails

sendPresenceUpdate

Sends a presence update to a peer. returns: Message ID

checkInternetPresence

Asks the internet relay for a peer’s presence (one-shot CheckPresence).

Contract

  • Always fresh. The SDK never throttles or dedupes manual checks: every accepted call sends a new CheckPresence frame to the relay, regardless of how recently the same peer was queried. (The automatic watch loop’s tick/TTL policy does not apply here.)
  • Fire-and-event. The answer arrives as a presence_updated event with source: 'internet' (including last_seen_ms when the relay knows it) rather than in the returned promise. Every relay answer re-emits the event even when nothing changed: safe to drive a chat-header refresh from. Subscribe before calling; events have no replay.
  • Exceptions. The core suppresses presence for blocked peers and your own user id: for those, this resolves true (the query was sent) but no presence_updated follows. And true means the query reached the socket, not that an answer will arrive: a connection dropped before the relay replies loses the answer (call again).
  • Rate limiting is never bypassed, force or not: the SDK’s client-side limiter mirrors the relay’s per-connection budget, and an over-budget frame would be dropped server-side after a locally “successful” write: strictly worse than deferring.
options.force is for chat open/focus: exactly when the app wants a fresh header, the socket is often still resuming from background. A non-forced call fails fast (false) in that window; a forced call is parked and retried until the transport is authenticated and the limiter admits it (up to ~8s), only then resolving false. On a stopped transport (no reconnect coming) even forced calls fail fast. Forced checks stay one-shot: they never join the SDK’s automatic watch set. returns: true once the socket accepted the query (write-confirmed on iOS, enqueue-confirmed on Android, the closest OkHttp offers); false otherwise, an empty userId (never sent), or not connected+authenticated / rate-limiter-deferred past the force deadline (non-forced: immediately; safe to retry) throws: when the internet transport was never initialized (enable it via transports.internet before calling)

sendTypingIndicator

Sends a typing indicator to a peer. returns: Message ID

sendReadReceipt

Sends a read receipt to a peer. returns: Message ID

blockUser

Blocks a user. Messages from blocked users are silently dropped at the protocol level.

unblockUser

Unblocks a previously blocked user.

getBlockedUsers

Returns the list of blocked user IDs. returns: Array of blocked user IDs

isUserBlocked

Checks if a specific user is blocked. returns: true if the user is blocked

Parameter and result types

Import these types from the same SDK package. Event payloads and configuration types are linked below.

SendMessageParams

MessagePriority

ContentType

ReplyContext

MediaMetadata

ForwardInfo

ForwardMessageParams

SendConnectionRequestParams

AcceptConnectionRequestParams

RejectConnectionRequestParams

CancelConnectionRequestParams

MessageDeliveryStats

TransportType