@sloppyvoice/sdk is a TypeScript client library for the Sloppy Voice v2 protocol (sv1). It is for people writing bots, clients and test tools in TypeScript or JavaScript who don't want to reimplement the wire rules of the specification themselves: discovery, the HTTPS API conventions, the event WebSocket, errors, paging, idempotency, remote sessions at other servers, and the sv1-c1 cryptographic conventions. Server authors can use its wire types and verification helpers, but it is not a server.

The specification is authoritative. Where the SDK and the spec disagree, the SDK is wrong. The doc comments of exported functions cite the spec section each one implements. If you work in another language, the protocol guide covers the same ground without the SDK.

Version 0.1.0 speaks protocol version 1.0 (PROTOCOL_VERSION) over the WebSocket subprotocol sloppyv.v1. It is ESM only and has no runtime dependencies.

Scope of 0.1

The table lists what 0.1 implements for each part of the protocol, and what it leaves to you or to the platform. Where 0.1 reaches something it can't do, it throws SloppyVoiceError with the code sdk.not_implemented instead of silently succeeding. The last column lists every place 0.1 throws that code, and the parts that are simply absent.

Area Spec In 0.1 Yours to supply, or not implemented
Addresses and links 01 The SV local-part profile, domains, canonicalize, canonical-address checks, display names and confusable skeletons, sloppyv: URIs and HTTPS share links. On a runtime whose Unicode data is older than 16.0.0, the profile functions throw sdk.not_implemented (01 §1.4).
Discovery 02 DiscoveryResolver: native and web resolution, the _sloppyv TXT record and .well-known fallback, GET /v1/resolve and the pin admin endpoints, ServerMetadata validation, server keys, KeyRotation, delegation evidence, pinning and caching. dohTxtResolver, a DNS-over-HTTPS TXT resolver. The main entry point has no system DNS resolver, because browsers and Workers can't send DNS queries. Use nodeTxtResolver on Node, Deno and Bun (02 §5.2), dohTxtResolver on Cloudflare Workers, and on a web client its home server's GET /v1/resolve with DoH as the fallback (02 §5.4).
HTTPS API 03 FetchHttpClient: Authorization schemes, problem errors, retries, Retry-After and rate limits, Idempotency-Key, seq timelines and cursor paging, CORS-safe headers. —
Event WebSocket 03 EventSocket: session.hello and session.ready, subscriptions, heads, resume, resync, heartbeat, session.reauth, close codes and reconnecting, with typed events. —
Cryptographic conventions 04 base64url, UUIDv7, JWS (EdDSA) signing and strict verification, JWK thumbprints, labelled signatures, HKDF, AES-GCM, HPKE, SVF1 attachment encryption, and CPace with the built-in elligator2Generator. Argon2id: WebCrypto has none, so you supply an Argon2idProvider (04 §12). The primitives come from WebCrypto with no fallback (04 §14.6); without crypto.subtle they throw sdk.not_implemented.
Accounts and sign-in 05 AuthApi (PKCE, pushed authorization requests, code and refresh exchanges, sign-up, sign-out), HomeSession (silent refresh, refresh-token rotation, 401 recovery), botToken, and the me, devices, bots, profiles and providers APIs. Opening the authorize URL in a browser and receiving the redirect are your app's. webLocks, the cross-tab refresh lock of 05 §7.7, throws sdk.not_implemented where the platform has no Web Locks API.
Federation 06 RemoteSessionProvider: HomeAssertions, remote sessions, silent renewal and extension. FederationApi, DeviceProofs with a pluggable Ed25519 signer, and, for server authors, HomeAssertion and DeviceProof verification and S2S request-token creation and verification. The server-to-server endpoints (06 §8.1) are typed in @sloppyvoice/sdk/wire but not callable.
Identity 07 IdentityApi; verifying IdentityState; issuing and verifying IdentityCertificate, DeviceCertificate and DeviceRevocation; contact pins; safety numbers and verification QR codes (@sloppyvoice/sdk/crypto). —
Device setup and recovery 08 PairingApi with the QR payload, the 6-digit code, CPace and payload encryption; BackupApi with the recovery phrase and KeyBackup encryption; VaultApi with record keys, VaultKeyGrants and the merge rules. The backup key needs your Argon2idProvider. A KeyBackup whose v is not 1 throws sdk.not_implemented (08 §5.1), and so does a vault record type with no record-ID rule; all six types of 08 §8.6 have one.
Communities, roles and moderation 09, 10 CommunityApi and the myCommunities, channels, invites, roles, moderation, bans, reports and auditLog APIs; the permission registry and effective-permission algorithm of 10 §6. —
Messaging 11 MessagesApi and the reactions, readState, typing, presence, attachments and webhooks APIs; building and validating content objects; posting insecure and sealed carriers. —
Direct messages 12 DmsApi with the DM index, settings, blocks and message requests; DM IDs (@sloppyvoice/sdk/crypto). —
MLS 13 MlsApi and KeyPackagesApi (the Delivery Service endpoints), and everything of the profile that needs no group secrets: the TLS codec, group_id, the GroupContext extensions, the sv_device credential, server proposals, building and verifying KeyPackages, MLS-Exporter from an exporter secret. The MLS state machine (commits, Welcome processing, the key schedule, the ratchet tree). You plug in an RFC 9420 implementation as an MlsProvider; the placeholder unimplementedMlsProvider throws sdk.not_implemented for every operation.
Sealed messages and history 14 Sealing and opening messages given K_hist, creating and opening HistoryShares (@sloppyvoice/sdk/crypto), and HistoryApi. K_hist comes from the MLS exporter (exportHistoryKey), so secure contexts need an MlsProvider.
Calls 15 CallsApi and the relay /connect; leases and coverage, RelayTickets, the relay connection rules, CallContinuity (auto-rejoin and transmit state), the transmit gate, diagnostics. WebRTC itself (RTCPeerConnection, ICE, data channels) is the platform's; these modules say when to create, signal and close it.
Audio and video 16, 17 voice-dc/1 and video-dc/1 codecs with strict validation, sfu-rtp/1 constants, receiver lease enforcement and the video adaptation state machines (@sloppyvoice/sdk/media). Capture, encoding, the jitter buffer and mixing are the platform's.
Media encryption 18 SFrame headers, the KID layout, key derivation, AES-128-GCM encryption through WebCrypto, protecting and opening frames on each transport, replay and epoch bookkeeping, MediaAttestation (@sloppyvoice/sdk/media). The epoch secret comes from the MLS exporter, so secure calls need an MlsProvider. Wiring the transform into the platform's media pipeline is yours.
Notifications and push 19 NotificationsApi and PushApi: settings, notification records, event tickets, push registrations and the gateway call, and the pure rules of 19 (trigger priority, previews, badges). —
Testing — MockServer and MockNetwork (@sloppyvoice/sdk/testing): an in-memory server for insecure-mode flows that the real HTTP client, resolver and event socket run against. The mock does not implement secure mode, OAuth sign-in, roles and moderation, attachments, calls, notifications and several other features; the MockServer reference lists them.

The SDK is not a server, and it has no server-to-server client. Server authors get the wire types and the verification helpers listed above, such as RelayTicket signing and validation.

Entry points

Import Contents
@sloppyvoice/sdk SloppyVoiceClient and ServerClient, the HTTP client, errors, token providers, paging, the event socket, sign-in and remote sessions, every resource API, content and permission helpers, discovery, the calls modules, the MLS provider interface and every wire type.
@sloppyvoice/sdk/address Addresses, display names and links (01).
@sloppyvoice/sdk/discovery Discovery (02); also re-exported by the main entry point.
@sloppyvoice/sdk/crypto Encodings and suite sv1-c1 (04), identity verification and safety numbers (07), DM IDs (12), sealed messages and HistoryShares (14).
@sloppyvoice/sdk/media voice-dc/1, video-dc/1, SFrame and MediaAttestation helpers (16 to 18).
@sloppyvoice/sdk/wire Wire types, constants and error registries with no logic, and the composed EventMap; also re-exported by the main entry point.
@sloppyvoice/sdk/testing MockServer, MockNetwork, and the MockWebSocket and MockServerSocket they use.
@sloppyvoice/sdk/node Node-only helpers: nodeTxtResolver on node:dns/promises and loadPublicSuffixList. They also work on Deno and Bun.

Only @sloppyvoice/sdk/node uses Node modules, and it imports them dynamically, so a browser bundle never pulls them in.

Runtimes

0.1 runs on Node 22.12 or later, current browsers, Deno, Bun and Cloudflare Workers. It needs only standard platform APIs that all of these have: fetch, the WHATWG WebSocket, crypto.subtle, crypto.getRandomValues, TextEncoder and TextDecoder, URL, AbortController, setTimeout, structuredClone and queueMicrotask. For tests, the client options replace fetch, the WebSocket constructor, the clock, the timers, the sleep between HTTP retries and the jitter source; cryptographic randomness always comes from crypto.getRandomValues.

Three runtime features are checked rather than assumed:

  • Unicode 16.0.0 or later, which addresses and domains need (01 §1.4). Node 22.12 ships ICU 76, which has it; on an older engine the address profile functions throw sdk.not_implemented instead of accepting addresses they can't check.
  • WebCrypto. The SDK has no fallback implementations of the primitives (04 §14.6), so without crypto.subtle the crypto functions throw sdk.not_implemented.
  • Web Locks, only for webLocks, which web clients with several tabs use to serialize token refreshes (05 §7.7).

On Node, Deno and Bun, pass nodeTxtResolver() as txt so the client can run native discovery (02 §5.2); on Cloudflare Workers, pass dohTxtResolver({ url }) instead. A web client can't query DNS: it passes homeBaseUrl, the base URL of the server that served it, and the client resolves other domains through that server's GET /v1/resolve, with an optional DoH resolver as the fallback (02 §5.4). Runtimes and bundling covers each runtime in detail.

Install

The package is served from this site, not from the npm registry. Install the tarball by URL:

npm install https://developer.sloppyvoice.com/downloads/sloppyvoice-sdk-0.1.0.tgz

It installs as @sloppyvoice/sdk, with type declarations and the TypeScript source. The downloads page lists each file's SHA-256, so you can download the tarball, check it, and install the local file instead.

For a page without a build step, download sloppyvoice-sdk-0.1.0.mjs, a single ES module, serve it from your own origin and import it by path:

import { SloppyVoiceClient, staticToken } from './sloppyvoice-sdk-0.1.0.mjs'

The browser module is built from the main entry point only, so it exports what @sloppyvoice/sdk exports (which includes /discovery and /wire) and nothing from /address, /crypto, /media, /testing or /node. Use the tarball and a bundler if you need those in a browser.

A first program

A bot on Node that finds its home server, reads its own account, and reports any SDK error by its code:

import { SloppyVoiceClient, botToken, isSloppyVoiceError } from '@sloppyvoice/sdk'
import { nodeTxtResolver } from '@sloppyvoice/sdk/node'

const sv = new SloppyVoiceClient({
  client: 'hello-bot/1.0',
  home: 'sloppyvoice.com',
  auth: botToken(process.env.SV_BOT_TOKEN!),
  txt: nodeTxtResolver(),
})

try {
  const home = await sv.home()
  const { account } = await home.me.get()
  console.log(`Signed in as ${account.address} on ${home.domain}`)
} catch (e) {
  if (isSloppyVoiceError(e)) console.error(e.code, e.detail)
  else throw e
} finally {
  await sv.close()
}

The bot token is only ever sent to the bot's home server. When you call sv.serverFor(address) for an address on another server, the client gets a remote session there from a HomeAssertion the home server signs, and that server only ever sees its own token (03 §3.2 rule 3).

More

The SDK guides, in sidebar order:

Reference and downloads:

  • API reference: every exported class, function, type and constant, by entry point.
  • Downloads: the tarball, the browser module, the licence and their SHA-256 sums.
  • Protocol guide: how the wire protocol works, independent of the SDK.