Adapter interfaces
The four adapter slots — local store, relay, remote object store, protocol manager — with the guarantees each implementation must provide.
Applies to @open-e2ee/signal-protocol-sdk 15.0.x. Public APIs and persisted formats follow semantic versioning.
Adapters are security boundaries, not convenience callbacks.
The SDK ships no persistence, no transport, and no account model. You inject them. The split the package draws: the client owns protocol coordination. The host application owns persistence, authentication, authorization, and product policy. Anything on your side of that line is yours to get right, and the protocol's guarantees depend on you getting it right.
The four slots
| Slot | Config field | Type from | Required | Role |
|---|---|---|---|---|
| Local store | adapters.storage | @open-e2ee/signal-protocol-sdk/local/store | Yes | Device-local protocol state |
| Relay | adapters.relay | @open-e2ee/signal-protocol-sdk/remote/signal-relay/types | No | Authenticated device, prekey, and envelope service |
| Remote object store | adapters.remoteObjectStore | @open-e2ee/signal-protocol-sdk/remote/object-store | No | Brokered encrypted-object operations |
| Protocol manager | adapters.protocolManager | @open-e2ee/signal-protocol-sdk/types | No | Advanced override; tests and specialized integrations |
Two adjacent interfaces are not adapter slots but appear alongside them:
| Interface | From | Role |
|---|---|---|
SignalProtocolLocalSecretVault | /local/vault | Small platform-managed bootstrap secrets |
SignalProtocolClientMediaConfig | client config media | Application-owned attachment bytes and caches |
Omitting relay gives you a local-only client: encryption and decryption work, but there is no sync, no prekey publication, and no delivery. Omitting remoteObjectStore disables attachment upload and download only.
SignalProtocolLocalStore
Device-local protocol state: identity keys, prekeys, session records, sender keys, sender-key handoff rows, Sesame device state, message records, the send log, receive records, and metadata. It is the one adapter you cannot skip.
It composes six narrower interfaces and adds maintenance operations:
| Composed interface | Covers |
|---|---|
ProtocolStore | Identity keys, prekeys, sessions, contact identity trust |
SesameStore | Per-device Sesame session state |
SenderKeyStore | Sender-key records for group messaging |
SenderKeyHandoffStore | One row for each device that holds a group's current sender key: recordSenderKeyHandoff, listSenderKeyHandoffs, invalidateSenderKeyHandoff, invalidateAccountSenderKeyHandoffs, listSenderKeyHandoffGroupIds, retainSenderKeyHandoffs |
MessageRecordStore | Message record bookkeeping for dedup and receipts, including rewriteMessageRecords(rewrite) |
SendLogStore | Resendable group content: a payload for each group send and a row for each recipient device, plus resend jobs and clearSendLog() |
Store-level additions: protection, an optional storeIdentity, getReceiveWork(), putReceiveWork(), listReceiveWork(), receiveWorkUsage(), completeReceiveWork(), clearAllKeys(), clearAllSessions(), deleteAllPreKeys(), getEcSignedPreKeyMaxId(), getKyberPreKeyMaxId(), getDetailedStats(), getMetadata(key), setMetadata(key, value), compareAndSetMetadata(key, expected, value), deleteMetadata(key).
protection declares how the store encrypts its data at rest (file-cipher, record-cipher, or none) and where its key is kept. Client creation fails when a store declares no protection, an unknown value, or a cipher without a key. A declaration adds no encryption. It must state what the store does. With storeIdentity set and Web Locks available, the client takes its session locks and group-send locks as Web Locks under that name.
ProtocolStore also carries the two operations that make trust changes atomic: commitSessionTrust(commit) and acceptContactIdentityRotationAndDeleteSessions(...).
What a correct implementation must guarantee
Protect local key material at rest. Identity private keys, prekey private keys, and session records are the whole secret. What "at rest" means is platform-specific: SQLCipher with a vault-held key on Expo, bare React Native, and Node, and a key in the same origin on the web. It is never nothing.
Keep contact identity trust decisions stable and explicit. A silent trust-state reset makes a detectable identity change undetectable. A lookup that returns "trusted" after a read failure has the same effect. Fail closed.
Persist linked-device identity state atomically. Startup verification must not enter a half-linked state. A crash between writes must not leave the device and account with different link states.
Preserve session record semantics. Do not treat sessions as opaque blobs without honoring update and archive behavior. Sessions have update rules and archive rules. A store that round-trips bytes but loses ordering, or that resurrects an archived session, breaks the ratchet.
Delete sender-key handoff rows in the write that causes the delete. A session archive, a session delete, a device-record delete, a group sender-key delete, and a contact identity rotation each delete the handoff rows of their device, group, or account. A group send gives the current key only to a listed device that has no row for it. A row that survives its delete therefore keeps the key from that device. A custom key-value backend must apply removeSenderKeyHandoffs inside atomicWrite.
Keep receive records under compare-and-set. putReceiveWork and completeReceiveWork take an expected revision and return false without a write on a mismatch. completeReceiveWork deletes the record and applies its metadata writes in one atomic write. Each ReceiveWorkRecord has the required fields messageId, senderUserId, and senderDeviceId. A custom store must set them on each record that it writes. The received key of a record holds senderUserId and timestamp only. A record that SDK 13.x wrote can also have senderDeviceId and contentDigest in that key. Accept both shapes until the next major SDK version after 14.0.0.
Keep each metadata value across a close and a reopen. compareAndSetMetadata must be atomic for one key. The group key sync ledger keeps its marks in metadata under the key prefix open-e2ee:group-key-sync:v1:. A store that loses a value causes one more GroupKeySync for each own device that the value marked.
Make the trust commit atomic. commitSessionTrust writes a session record and its trust decision together. If your backend can persist one without the other, the store is not correct. In the key-value store's own words, atomicWrite is a security boundary, not a batching optimization.
Session record format
Current persisted session format is version 4. The SDK rejects and resets older session formats instead of migrating them. It deletes the rejected session and establishes a new one. The peer sees a new session, not silent corruption. Plan for that on upgrade: see upgrades.
Shipped store adapters
| Subpath | Factory | Backing | Maturity |
|---|---|---|---|
/local/store/expo | expoStore(options?) | Expo SQLite with SQLCipher | Primary supported adapter |
/local/store/react-native | await reactNativeStore(options?) | op-sqlite with SQLCipher; database key in a secret vault | Supported; requires the op-sqlite SQLCipher build |
/local/store/node | await nodeStore({ directory, vault }) | better-sqlite3-multiple-ciphers with SQLCipher in directory; database key in the vault you pass | For Node, the Electron main process, and server-side use |
/local/store/web-sqlite | await webSqliteStore(options?) | SQLite3 Multiple Ciphers in the origin private file system; database key in a secret vault | Supported from 8.1.0; deployment requires the browser threat-model review |
/local/store/web | await indexedDbStore() | IndexedDB | Supported where the origin private file system is not available; deployment requires the browser threat-model review |
/local/store/key-value | keyValueStore({ storage, vault }) | Injected key-value storage; value key in a secret vault | Supported. Verify the injected backend with assertBackendConformance |
/local/store/memory | inMemoryStore() | In-memory | Development only; never ship it |
The Node store guide warns against one deployment shape explicitly: use a private directory on a local file system, and do not use a network file system. One process owns the database; an open in another process fails with SqliteStoreInUseError (KEY_STORAGE_ERROR).
The web adapter README defines the limit of browser encryption at rest. It is not an XSS defense. A script on your origin has access to the page's data.
Choosing between them: choosing adapters and local storage.
SignalProtocolRelayServer
An authenticated device, prekey, and envelope service. It is a transport and a directory, not a trusted party: the relay never needs message plaintext or device private keys. It does see routing metadata. Limits and metadata draws that boundary.
The interface extends KeyRotationService. Methods by group:
| Group | Methods |
|---|---|
| Envelope delivery | send, subscribe, markDelivered |
| Connection state | relayConnectionState, subscribeRelayConnectionState |
| Device registry | getDevices, registerDevice, removeDevice |
| Identity keys | provisionIdentityKey, rotateIdentityKey, getIdentityKey |
| Prekeys | uploadPreKeys, fetchPreKeyBundle, getPreKeyCount, getPreKeyInventory, clearStaleKemPreKeys, publishPlannedPreKeys |
| Group membership | getActiveDevices |
| Group state | createGroupState, getGroupState, getGroupChanges, getGroupJoinInfo, submitGroupChange |
| ZK credentials | issueAuthCredential, refreshGroupSendEndorsements? |
| Sealed sender | fetchSenderCertificate?, sendMultiRecipientUnidentified? |
Optional methods gate features rather than failing at runtime: without fetchSenderCertificate, isSealedSenderEnabled stays false.
What a correct implementation must guarantee
Bundle fetch must atomically consume one-time prekeys for concurrent callers. The contract states: "The relay must not hand out the same one-time prekey as if it were still unused." This is the most consequential requirement on this page. Serving a prekey twice degrades the initial-message forward secrecy that the handshake provides. If two clients call fetchPreKeyBundle concurrently, only one can receive a given one-time prekey. Use an atomic claim, conditional update, or transactional pop. Do not use a read followed by a delete.
Running out of one-time prekeys is a defined, safe state: the bundle falls back to the last-resort key. Serving a stale one is not.
The adapter must report the connection state of its envelope subscription. The interface requires relayConnectionState and subscribeRelayConnectionState, so a custom adapter must implement both. relayConnectionState reads stopped before subscribe and after its unsubscribe. The adapter replaces the value on each transition and keeps it stable between transitions.
subscribeRelayConnectionState(listener) calls the listener once for each new state and never with the current state. On reconnecting, reason names the site that failed and is never an error message.
A relay can wait for the work of each envelope. The onEnvelope callback of subscribe returns void | Promise<void>. The promise settles when the client has handled the envelope. A relay that waits for it acknowledges or accepts the envelope itself only when it resolves. When it rejects, a durable envelope that markDelivered did not acknowledge stays in the mailbox for a later delivery. The hosted transport works this way.
A retry request is an ordinary envelope. A client that cannot decrypt a message sends an identified envelope with messageType: 'retry_request' through send. The relay stores and delivers it like any other envelope. There is no separate retry-request channel. The payload is not encrypted. The client takes the requester from the envelope sender.
An envelope keeps one ID. Give each envelope one id, and keep that id on every redelivery. The client delivers content at most once by that id. A relay that assigns its own IDs delivers the SDK ID as clientMessageId with the envelope, on every delivery path. A retry request, its resend, and its null message carry their retry ID in clientMessageId, as <retry ID>:retry-request, <retry ID>:resend, and <retry ID>:null. From attempt 2, each ID adds :<n>, for example <retry ID>:retry-request:2. A resend or a null message has the attempt number of the request that it answers. For example, the answer to <retry ID>:retry-request:2 is <retry ID>:resend:2. A retry request for a failed envelope without an ID has no retry ID. Its clientMessageId is a new UUID. The client drops a retry request whose clientMessageId, or its id when it has none, does not name the retry ID in its payload.
A post can carry its operation epoch. Envelope.operationEpochMilliseconds and the operationEpochMilliseconds parameter of sendMultiRecipientUnidentified give the epoch that the relay admits the post by. Without it, the relay uses timestamp. A resend keeps the original timestamp. It therefore carries the epoch of its stored encryption in this field. When the relay refuses the stored bytes as expired, the client encrypts the resend again with a fresh epoch.
An envelope can name its content kind. Envelope.contentKind is message or receipt. The client sets receipt on each E2EE delivery, read, and viewed receipt. The optional last parameter of sendMultiRecipientUnidentified, contentKind, carries the same label for a sealed receipt. Without it, the envelope is a message. A relay can count by this label without reading the content.
Device registration, unlink, and stale cleanup must stay consistent across active identity types. ACI and PNI key material must not drift apart. A device removed for one identity type and left registered for the other is a routing bug that presents as undecryptable messages.
Linked-device slot assignment is server-owned, not client-owned. The server owns linked-device slot allocation. Clients must not choose linked deviceIds. registerDevice returns the assigned id. A relay that accepts a client-proposed deviceId lets a client collide with, or impersonate, an existing device slot.
Public-key reads and writes must enforce correct account ownership rules. Anyone may read a public identity key. Only the owning authenticated account may write one. An unauthorized write creates an identity-substitution vulnerability. The attacker becomes that account for any peer that has not verified a safety number.
Authentication is entirely yours. The SDK has no session token, user table, or authorization model. It does not verify a caller's claimed identity.
Relay paths
| Path | Entry | Maturity |
|---|---|---|
| OpenE2EE Signal Protocol Relay | createHostedSignalProtocolClient() from the package root | The hosted delivery service, built to work with this SDK: see Signal Protocol Relay |
| Custom transport | createSignalProtocolClient() with an application-owned SignalProtocolRelayServer | You build and operate the authenticated backend: see relay and prekeys |
The package contains no relay server implementation.
SignalProtocolRemoteObjectStore
Brokered encrypted-object operations. Optional. Required only for attachments.
The shape is deliberately indirect. The client asks for an operation by requestId, the broker resolves that to an objectId and a provider-side URL, and the provider key never reaches the client. The client uploads ciphertext it encrypted locally and receives an opaque handle back.
What a correct implementation must guarantee
The broker holds the provider credential. The client never does. If your implementation ships an S3 key to the device, you replace a broker with a public bucket.
Authorize every request against the calling account. Mapping requestId to objectId is an authorization decision. An unauthenticated or unscoped broker exposes every ciphertext object. Encryption protects content, but object membership and access patterns leak.
Do not accept a client-supplied objectId. Assignment is broker-owned for the same reason device slot assignment is server-owned.
Never handle plaintext or content keys. Encryption happens on the device before upload. The object store handles ciphertext bytes and nothing else.
Authorize deletion and remove the data. Attachment deletion propagates through deleteRemoteAttachment() and the linked-device sync path. A broker that reports success after a soft delete makes deletion and revocation a lie.
Shipped object-store adapters
| Subpath | Factory | Maturity |
|---|---|---|
/remote/object-store/convex-r2 | convexR2ObjectStore(config) | Supported |
/remote/object-store/s3 | s3ObjectStore(config), S3ObjectStoreBroker | Supported |
See attachments and object storage and the R2/S3 guide.
SignalProtocolManager
An override for the protocol coordination layer itself. Supplying one replaces the SDK's own session and ratchet orchestration.
This exists for tests, for instrumentation, and for integrations that must drive the protocol from an existing engine. It is not a customization point for ordinary applications, and the package ships no implementation to copy. If you use it to change behavior, first check ratchetConfig, protocol, and protocolStrategy for the required option.
SignalProtocolLocalSecretVault
Not an adapter slot on the client. A tiny interface used by store adapters that need a platform-managed bootstrap secret, such as a database wrapping key.
interface SignalProtocolLocalSecretVault {
getSecret(name: string): Promise<Uint8Array | null>;
setSecret(name: string, value: Uint8Array): Promise<void>;
deleteSecret(name: string): Promise<void>;
}Values are bytes, not strings. /local/vault/expo-secure-store ships an implementation over expo-secure-store. The scope is narrow by design: platform secret managers are appropriate for tiny keys and bootstrap values, but not full session databases. A typical key name is "signal-store-wrapping-key".
Next
- Choosing adapters: which shipped adapter fits your runtime
- Relay and prekeys: implementing the relay contract
- Local storage: implementing or configuring the store
- Package subpaths: where to import each type
API reference
The curated client surface — createSignalProtocolClient options, every SignalProtocolClient method by category, properties, hooks, and the standalone modules.
Package subpaths
The complete exports map of @open-e2ee/signal-protocol-sdk — every importable subpath, what it exports, and each entry's support status.