Browser- and Node-compatible authenticated store-and-forward messaging, live WebSockets, peer payments, token settlement, permissions, quotes, and push-device registration.
npm install @bsv/message-box-client @bsv/sdk@bsv/sdk is a required peer. Node.js 22 or newer is supported.
Use SDK 2.4.1 or newer so BRC-29 sends accept both historical number[] and
binary Wallet Wire Uint8Array transaction results. Payment receipt also
recovers pending typed-array tokens serialized through JSON as numeric-key
objects.
import { MessageBoxClient } from '@bsv/message-box-client'
import { WalletClient } from '@bsv/sdk'
const wallet = new WalletClient()
const client = new MessageBoxClient({
walletClient: wallet,
host: 'https://message-box-us-1.bsvb.tech'
})
await client.sendMessage({
recipient: '025706528f0f6894b2ba505007267ccff1133e004452a1f6b72ac716f246216366',
messageBox: 'general_inbox',
body: { text: 'Hello' }
})
const messages = await client.listMessages({ messageBox: 'general_inbox' })
await client.acknowledgeMessage({
messageIds: messages.map(message => message.messageId)
})Initialization is automatic. Call init() only when explicit startup control
is useful.
MessageBoxClient — authenticated HTTP polling and live WebSocket deliveryPeerPayClient — BRC-29 payments, requests, responses, and refundsPeerTokenClient — token transport through pluggable settlement adaptersRemittanceAdapter — SDK remittance communication integrationConfigured hosts must be absolute HTTP(S) URLs without credentials, query strings, or fragments. HTTP is retained for operator-controlled local development. Untrusted overlay destinations require HTTPS and cannot target local, private, link-local, reserved, or documentation-only hosts.
Message Box remains accessible from arbitrary deployed browser origins by default. Server-side exact-origin allowlists or disabled CORS are operator opt-ins. CORS and CSP do not replace BRC-103 identity authentication, recipient-owned boxes, permissions, payment checks, quotas, or end-to-end message encryption.
The package publishes ESM, CommonJS, declarations, source maps, and a UMD
browser bundle. Exact-tarball validation exercises clean ESM/CommonJS
consumers, strict declaration resolution, publint, browser bundling through
Vite and esbuild, and bundle budgets. Source and tests are not published.