Skip to main content
Import MeshServices from @offline-protocol/mesh-sdk. These signatures match v0.33.0. Read the integration guide for prerequisites and complete usage. From v0.29.0 a service request or response body is sealed in the MLS session with the other peer once that peer runs 0.29.0 or later and the session is confirmed; service_request_received and service_response_received then report encrypted: true. Discovery, the first request to a provider this device has never met, and requests to older peers are signed plaintext that every device carrying them can read. Keep their metadata and first-contact bodies non-sensitive. Your application authorizes callers and correlates responses. From v0.32.0 a service can be subscribed to. subscribeService takes a lease on one topic of a provider’s service, or on every topic matching a pattern, and publishServiceUpdate reaches every subscriber as it happens. Every subscription frame is sealed in the 1:1 MLS session with no plaintext fallback. Under the default restricted policy the provider’s application decides each request on service_subscribe_received; see service subscriptions.

Methods on this page

registerService

Registers a local service that this node offers for discovery by other peers.

unregisterService

Unregisters a local service. returns: true if the service was found and removed

discoverServices

Broadcasts a service discovery query to the mesh. Responses arrive asynchronously as service_discovered events. returns: Query ID for correlating responses

sendServiceRequest

Sends a service request to a specific provider peer. The response arrives as a service_response_received event. returns: Request ID for correlating the response

respondToServiceRequest

Responds to a service request from another peer. Call this after receiving a service_request_received event. returns: Message ID of the response

subscribeService

Subscribes to topic of serviceId on provider. Every subscription frame is sealed in the 1:1 MLS session, with no plaintext fallback; with no session yet one is started and the subscription waits for it. Updates arrive as service_update_received, state changes as service_subscription_changed. returns: The subscription id its events carry

unsubscribeService

Ends a subscription this device holds. false when there is none.

resyncServiceSubscription

Asks the provider for the whole state again, now.

serviceSubscriptions

The subscriptions this device holds on other devices.

setServiceSubscriptionPolicy

Sets who may subscribe to serviceId: restricted (the default) asks this app with service_subscribe_received; accept_all admits every peer with a session; rules admits allowPeers and members of allowGroups and asks or rejects everyone else by fallback.

acceptServiceSubscription

Accepts a subscriber this app was asked about.

rejectServiceSubscription

Rejects a subscriber this app was asked about.

endServiceSubscription

Ends a subscription another device holds on this one.

publishServiceUpdate

Publishes to a topic of a service registered on this device. With a key the topic is latest; without one it is log. Each subscriber is sent the update once over a live direct link, or through the reliable ladder across hops, where a latest value replaces the one queued before it for its key.

setServiceTopicCheckpoint

Sets a log topic’s checkpoint: a summary a subscriber that fell out of the buffer is sent instead of being told its history was lost.

clearServiceTopic

Starts a topic over; every subscriber is told before new state.

serviceSubscribers

The subscriptions other devices hold on serviceId, or on all.

Parameter and result types

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

SubscriptionMode

ServiceSubscriptionInfo

SubscriptionPolicy

ServicePublishReport

ServiceSubscriberInfo