Connection
Class representing instance of Connection
Methods
createThreadApi
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Params
connection
Connection
Returns
Promise<ThreadApi> ·
undefined undefined
createStoreApi
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Params
connection
Connection
Returns
Promise<StoreApi> ·
undefined undefined
createInboxApi
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Params
connection
Connection
Returns
Promise<InboxApi> ·
undefined undefined
createKvdbApi
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Params
connection
Connection
Returns
Promise<KvdbApi> ·
undefined undefined
createEventApi
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Params
connection
Connection
Returns
Promise<EventApi> ·
undefined undefined
createStreamApi
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Params
connection
Connection
Returns
Promise<StreamApi> ·
undefined undefined
getEventLoop
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Returns
Promise<EventLoop> ·
undefined undefined
getConnectionId
Returns the numeric identifier of this connection inside the WASM core. The ID is assigned locally when the connection is established - no server round-trip happens here. Use it to correlate connection-scoped events (Event.connectionId) with the connection that produced them when the application holds several connections at once.
Returns
Promise<number> ·
connection ID matching the connectionId field of events delivered through EventQueue.waitEvent
listContexts
Lists the Contexts (application workspaces created in the PrivMX Bridge admin panel) that the connected user is a member of. Fetches the list from the Bridge; Context metadata is server-side administrative data, so no decryption is involved. A Context ID is the entry point for all content APIs - e.g. ThreadApi.createThread(contextId, …) or StoreApi.listStores(contextId, …) - so this is typically one of the first calls after EndpointFactory.connect.
Params
pagingQuery
PagingQuery
pagination and sorting; start with { skip: 0, limit: 100, sortOrder: "desc" } and page using skip or lastId
Returns
Promise<PagingList<Context>> ·
one page of Contexts plus totalAvailable; use Context.contextId in subsequent API calls
listContextUsers
Lists the users registered in the given Context together with their public keys. Fetches the membership list from the Bridge - user IDs and public keys are not secret, the server stores them in plaintext. Use it to build the users/managers arrays (UserWithPubKey[]) required when creating or updating containers such as Threads, Stores, Inboxes and KVDBs.
Params
contextId
string
Context to enumerate, from Context.contextId returned by listContexts
pagingQuery
PagingQuery
pagination and sorting of the user list
Returns
Promise<PagingList<UserInfo>> ·
one page of users; each entry carries user.userId and user.pubKey ready to be used in container ACLs
subscribeFor
Subscribes this connection to Context-level events matching the given subscription queries. Registers the subscriptions on the Bridge over the connection's event channel; matching events are then pushed by the server and surface through EventQueue.waitEvent. Required order: buildSubscriptionQuery (one query per event-type/selector pair) → subscribeFor(queries) → consume events from the EventQueue → unsubscribeFrom when no longer needed.
Params
subscriptionQueries
string[]
query strings produced by buildSubscriptionQuery; hand-written strings are not supported
Returns
Promise<string[]> ·
subscription IDs, index-aligned with subscriptionQueries - keep them to unsubscribeFrom later
unsubscribeFrom
Cancels event subscriptions previously created on this connection, so the server stops pushing the matching events. Subscriptions also end implicitly with disconnect; call this only to stop receiving a subset of events while keeping the connection alive.
Params
subscriptionIds
string[]
IDs returned by subscribeFor; unknown IDs cause a NativeError rejection
buildSubscriptionQuery
Builds a subscription-query string describing one class of Context events (e.g. "all custom Context events in Context X"). The query is assembled locally by the WASM core in the server's expected format - nothing is sent yet; pass the result to subscribeFor to activate it.
Params
eventType
ConnectionEventType
which Context event class to listen for
selectorType
ConnectionEventSelectorType
what selectorId refers to (e.g. a whole Context), narrowing the event scope
selectorId
string
ID of the selected scope - for a Context selector this is Context.contextId from listContexts
Returns
Promise<string> ·
query string consumed by subscribeFor
getThreadApi
Returns the Thread API (encrypted messaging) for this connection. Convenience for EndpointFactory.createThreadApi(connection) - both resolve the same cached per-connection instance; no server round-trip happens here.
Returns
Promise<ThreadApi> ·
the per-connection ThreadApi instance
getStoreApi
Returns the Store API (encrypted file storage) for this connection. Convenience for EndpointFactory.createStoreApi(connection); resolves the same cached per-connection instance.
Returns
Promise<StoreApi> ·
the per-connection StoreApi instance
getInboxApi
Returns the Inbox API (one-way encrypted submissions) for this connection. Convenience for EndpointFactory.createInboxApi(connection); resolves the same cached per-connection instance. Works on a guest connection from EndpointFactory.connectPublic.
Returns
Promise<InboxApi> ·
the per-connection InboxApi instance
getKvdbApi
Returns the KVDB API (encrypted key-value storage) for this connection. Convenience for EndpointFactory.createKvdbApi(connection); resolves the same cached per-connection instance.
Returns
Promise<KvdbApi> ·
the per-connection KvdbApi instance
getEventApi
Returns the Event API (custom encrypted Context events) for this connection. Convenience for EndpointFactory.createEventApi(connection); resolves the same cached per-connection instance.
Returns
Promise<EventApi> ·
the per-connection EventApi instance
getStreamApi
Returns the Stream API (E2EE WebRTC audio/video) for this connection. Convenience for EndpointFactory.createStreamApi(connection); resolves the same cached per-connection instance and wires up the WebRTC client stack on first use.
Returns
Promise<StreamApi> ·
the per-connection StreamApi instance
getEventManager
Returns the single EventManager for this connection. Subscribe to events of any module (Threads, Stores, Inboxes, KVDBs, custom events, user and connection-state) through it - build entries with the typed create*Subscription helpers and mix modules freely in one subscribe(). It is attached to the shared application-wide event loop (started on first use) and cached per connection, so repeated calls return the same manager (one dispatcher registration on the loop).
Returns
Promise<EventManager> ·
the per-connection event manager
disconnect
Closes the session with the Bridge and releases all native resources of this connection. Closes the server session, then invalidates and deletes every API instance created from this connection (ThreadApi, StoreApi, …, including WebRTC stream sessions and the E2EE worker of StreamApi) inside the WASM module - equivalent C++ objects are freed, so no manual per-API cleanup is needed. Call once when the user logs out or the application shuts down. This is the last step of the connection workflow; afterwards any method on this connection or its APIs throws an Error, and a fresh EndpointFactory.connect is required to continue.
setUserVerifier
Installs an application-defined callback used to verify the authors of received data against an external source of truth. Whenever the WASM core decrypts container data (messages, files, entries…), it batches the senders' userId/pubKey pairs and invokes your UserVerifierInterface.verify implementation; entries voted false are reported as unverified to the caller. Use it to defend against a malicious or compromised Bridge server substituting public keys - verify the key↔user binding in your application server or a PKI. Set it right after EndpointFactory.connect, before reading any container data.
Params
verifier
UserVerifierInterface
object whose verify(request) resolves to one boolean per request item (true = sender authentic)
Class representing instance of Connection
Methods
createThreadApi
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Params
connection
Connection
Returns
Promise<ThreadApi> ·
undefined undefined
createStoreApi
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Params
connection
Connection
Returns
Promise<StoreApi> ·
undefined undefined
createInboxApi
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Params
connection
Connection
Returns
Promise<InboxApi> ·
undefined undefined
createKvdbApi
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Params
connection
Connection
Returns
Promise<KvdbApi> ·
undefined undefined
createEventApi
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Params
connection
Connection
Returns
Promise<EventApi> ·
undefined undefined
createStreamApi
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Params
connection
Connection
Returns
Promise<StreamApi> ·
undefined undefined
getEventLoop
Per-connection services injected by EndpointFactory at construction, so Connection need not import the factory (breaking the cycle). Each createXApi resolves the connection's cached API instance; getEventLoop returns the shared application-wide event loop.
Returns
Promise<EventLoop> ·
undefined undefined
getConnectionId
Returns the numeric identifier of this connection inside the WASM core. The ID is assigned locally when the connection is established - no server round-trip happens here. Use it to correlate connection-scoped events (Event.connectionId) with the connection that produced them when the application holds several connections at once.
Returns
Promise<number> ·
connection ID matching the connectionId field of events delivered through EventQueue.waitEvent
listContexts
Lists the Contexts (application workspaces created in the PrivMX Bridge admin panel) that the connected user is a member of. Fetches the list from the Bridge; Context metadata is server-side administrative data, so no decryption is involved. A Context ID is the entry point for all content APIs - e.g. ThreadApi.createThread(contextId, …) or StoreApi.listStores(contextId, …) - so this is typically one of the first calls after EndpointFactory.connect.
Params
pagingQuery
PagingQuery
pagination and sorting; start with { skip: 0, limit: 100, sortOrder: "desc" } and page using skip or lastId
Returns
Promise<PagingList<Context>> ·
one page of Contexts plus totalAvailable; use Context.contextId in subsequent API calls
listContextUsers
Lists the users registered in the given Context together with their public keys. Fetches the membership list from the Bridge - user IDs and public keys are not secret, the server stores them in plaintext. Use it to build the users/managers arrays (UserWithPubKey[]) required when creating or updating containers such as Threads, Stores, Inboxes and KVDBs.
Params
contextId
string
Context to enumerate, from Context.contextId returned by listContexts
pagingQuery
PagingQuery
pagination and sorting of the user list
Returns
Promise<PagingList<UserInfo>> ·
one page of users; each entry carries user.userId and user.pubKey ready to be used in container ACLs
subscribeFor
Subscribes this connection to Context-level events matching the given subscription queries. Registers the subscriptions on the Bridge over the connection's event channel; matching events are then pushed by the server and surface through EventQueue.waitEvent. Required order: buildSubscriptionQuery (one query per event-type/selector pair) → subscribeFor(queries) → consume events from the EventQueue → unsubscribeFrom when no longer needed.
Params
subscriptionQueries
string[]
query strings produced by buildSubscriptionQuery; hand-written strings are not supported
Returns
Promise<string[]> ·
subscription IDs, index-aligned with subscriptionQueries - keep them to unsubscribeFrom later
unsubscribeFrom
Cancels event subscriptions previously created on this connection, so the server stops pushing the matching events. Subscriptions also end implicitly with disconnect; call this only to stop receiving a subset of events while keeping the connection alive.
Params
subscriptionIds
string[]
IDs returned by subscribeFor; unknown IDs cause a NativeError rejection
buildSubscriptionQuery
Builds a subscription-query string describing one class of Context events (e.g. "all custom Context events in Context X"). The query is assembled locally by the WASM core in the server's expected format - nothing is sent yet; pass the result to subscribeFor to activate it.
Params
eventType
ConnectionEventType
which Context event class to listen for
selectorType
ConnectionEventSelectorType
what selectorId refers to (e.g. a whole Context), narrowing the event scope
selectorId
string
ID of the selected scope - for a Context selector this is Context.contextId from listContexts
Returns
Promise<string> ·
query string consumed by subscribeFor
getThreadApi
Returns the Thread API (encrypted messaging) for this connection. Convenience for EndpointFactory.createThreadApi(connection) - both resolve the same cached per-connection instance; no server round-trip happens here.
Returns
Promise<ThreadApi> ·
the per-connection ThreadApi instance
getStoreApi
Returns the Store API (encrypted file storage) for this connection. Convenience for EndpointFactory.createStoreApi(connection); resolves the same cached per-connection instance.
Returns
Promise<StoreApi> ·
the per-connection StoreApi instance
getInboxApi
Returns the Inbox API (one-way encrypted submissions) for this connection. Convenience for EndpointFactory.createInboxApi(connection); resolves the same cached per-connection instance. Works on a guest connection from EndpointFactory.connectPublic.
Returns
Promise<InboxApi> ·
the per-connection InboxApi instance
getKvdbApi
Returns the KVDB API (encrypted key-value storage) for this connection. Convenience for EndpointFactory.createKvdbApi(connection); resolves the same cached per-connection instance.
Returns
Promise<KvdbApi> ·
the per-connection KvdbApi instance
getEventApi
Returns the Event API (custom encrypted Context events) for this connection. Convenience for EndpointFactory.createEventApi(connection); resolves the same cached per-connection instance.
Returns
Promise<EventApi> ·
the per-connection EventApi instance
getStreamApi
Returns the Stream API (E2EE WebRTC audio/video) for this connection. Convenience for EndpointFactory.createStreamApi(connection); resolves the same cached per-connection instance and wires up the WebRTC client stack on first use.
Returns
Promise<StreamApi> ·
the per-connection StreamApi instance
getEventManager
Returns the single EventManager for this connection. Subscribe to events of any module (Threads, Stores, Inboxes, KVDBs, custom events, user and connection-state) through it - build entries with the typed create*Subscription helpers and mix modules freely in one subscribe(). It is attached to the shared application-wide event loop (started on first use) and cached per connection, so repeated calls return the same manager (one dispatcher registration on the loop).
Returns
Promise<EventManager> ·
the per-connection event manager
disconnect
Closes the session with the Bridge and releases all native resources of this connection. Closes the server session, then invalidates and deletes every API instance created from this connection (ThreadApi, StoreApi, …, including WebRTC stream sessions and the E2EE worker of StreamApi) inside the WASM module - equivalent C++ objects are freed, so no manual per-API cleanup is needed. Call once when the user logs out or the application shuts down. This is the last step of the connection workflow; afterwards any method on this connection or its APIs throws an Error, and a fresh EndpointFactory.connect is required to continue.
setUserVerifier
Installs an application-defined callback used to verify the authors of received data against an external source of truth. Whenever the WASM core decrypts container data (messages, files, entries…), it batches the senders' userId/pubKey pairs and invokes your UserVerifierInterface.verify implementation; entries voted false are reported as unverified to the caller. Use it to defend against a malicious or compromised Bridge server substituting public keys - verify the key↔user binding in your application server or a PKI. Set it right after EndpointFactory.connect, before reading any container data.
Params
verifier
UserVerifierInterface
object whose verify(request) resolves to one boolean per request item (true = sender authentic)
We use cookies on our website. We use them to ensure proper functioning of the site and, if you agree, for purposes such as analytics, marketing, and targeting ads.