<>ts-stack
Get StartedArchitecturePackagesSpecsGuides
⌘K
Reference
Home
Get StartedOverviewInstallChoose your stackKey concepts
ArchitectureOverviewStack layersBEEF (BRC-62)BRC-100 Wallet InterfaceIdentity & AuthConformance pipeline
PackagesOverviewSDKWalletNetworkOverlaysMessaging
@bsv/message-box-client@bsv/authsocket@bsv/authsocket-client@bsv/paymail
MiddlewareHelpers
InfrastructureOverviewmessage-box-serveroverlay-serveruhrp-server-basicuhrp-server-cloud-bucketwabwallet-infrachaintracks-serverwebrtpay-relay
SpecsOverviewBRC-100 Wallet InterfaceOverlay HTTPMessage-box HTTPAuthsocket (WebSocket)BRC-31 Auth HandshakeBRC-29 Peer PaymentBRC-121 / HTTP 402ARC BroadcastMerkle ServiceStorage AdapterGASP SyncUHRPAir-Gap Optical (BRC-141)
ConformanceOverviewVector catalogTS runnerContributing vectors
GuidesOverviewIdentity, DIDs and credentialsIdentity migrationBuild a wallet-aware appRun an overlay nodePeer-to-peer messagingHTTP 402 payments
ReferenceOverviewBRC indexRepository health
AboutVersioningContributingDoc agentDocumentation sources
npmhttps://www.npmjs.com/package/@bsv/group-messagingv0.2.0experimentalAPI reference (TypeDoc) ↗
Loading…
Edit this page on GitHub
© 2026 BSV Blockchain. ts-stack is open-source.
GitHubContributingVersioning

@bsv/group-messaging

End-to-end encrypted group messaging for BRC-100 wallets. Group state is MLS (RFC 9420) by way of ts-mls, and each member's MLS credential is bound to their wallet's own secp256k1 identity, so a peer cannot join a group under a name that is not theirs.

The library opens no database and no network connection of its own. It uses the storage and transport the host already has.

⚠️ Security status

Early release, 0.x. ts-mls, the cryptographic core, states that it has not undergone a formal security audit, and that inherits. The wallet attestation layer on top of it has been reviewed by reading and its forgery paths are covered by tests, which is not an audit. There has been no interop testing against another MLS implementation, and ts-mls is pinned exactly rather than by range because its releases have changed the key schedule inside a minor bump.

Provided as-is. Use at your own discretion.

Install

bash
pnpm add @bsv/group-messaging @bsv/sdk

@bsv/sdk is a required peer dependency. Node.js 22 or newer; runs in the browser; ESM and CommonJS entry points.

Quick start

ts
import { GroupMessagingClient } from '@bsv/group-messaging'
import { WalletClient } from '@bsv/sdk'

const client = await GroupMessagingClient.create({
  wallet: new WalletClient(),
  storage: sqlDriver,
  transport: messageBoxClient
})

const minted = await client.keyPackages.create()
const group = await client.createGroup({
  chatId: 'project-alpha',
  members: [bobKeyPackage],
  privateKeyPackage: minted.privateKeyPackage
})

const messageId = await group.sendText('hello')
client.on('message', ({ chatId, sender, content, messageId }) => {
  /* … */
})

What a consumer supplies

InputAccepts
walleta BRC-100 WalletClient, a KeyDeriver, or a bare root PrivateKey
storagea SqlDriver, an IDBDatabase, a Map, a StorageProvider, "memory", or "indexeddb"
transporta MessageBoxClient, a TransportBackend, or a TransportService

Storage is scoped to the client's identity, so one host database serves however many accounts the wallet manages.

Three things worth knowing before you build on it

A KeyPackage is an entry ticket, not a chat key. It is consumed once, when its holder enters a group, and a successful createGroup or joinFromWelcome retires it and emits keyPackageConsumed naming the ref. That event is the signal for the host to destroy the private half, which this library never holds.

Live socket delivery is additive, never a replacement. MessageBoxTransport accepts live: true, which layers a socket over a slower polling backstop. The socket cannot be a sole source: joinRoom replays no backlog, so anything sent while it was down is only ever seen by a poll.

A message id is derived, not chosen. messageIdOf is the sha-256 of the MLS application message in lower-case hex, so a sender and every recipient reach the same id independently and a sender cannot pick its own. It is what replyTo and a reaction's reference name. Every send returns it, every message event carries it, and a send that failed carries it on both the deliveryFailed event and the BroadcastError it rejects with.

The id is the digest of one ciphertext, so it belongs to that encryption rather than to the message as a thing a person sent. A retry of the same bytes keeps it; the same text encrypted again is a different message with a different id. A host that re-encrypts a stored backlog — replaying history to a member who was not there for it — must carry the ids it stored rather than recompute them, or every reply and reaction pointing into that backlog stops resolving. The scheme borrows the derived-not-chosen idea from draft-ietf-mimi-content but not its construction, and the two are not interoperable.

templates/ ships alongside dist/, to read and copy rather than import. There is deliberately no export subpath for it: the files are .ts, and Node does not strip types inside node_modules, so importing the package path would fail at runtime where a copy does not. These are copy-paste starting points for the machinery the library deliberately does not own — client lifecycle, the KeyPackage shelf, a message transcript, a WebCrypto conformance probe and a managed invitation exchange. They are source to copy rather than API, and carry no compatibility promise.

See the package README for the full invitation handshake, the KeyPackage lifecycle, and the events a consumer should handle.