Endpoint
Class with the static factory methods to create instances of Connection and APIs
Methods
setup
Loads the Endpoint's WebAssembly assets and initializes the library. Must complete before any other Endpoint call; safe to call multiple times - concurrent and repeated calls share one initialization (a failed attempt may be retried). Injects a script tag loading endpoint-wasm-module.js (from assetsBasePath or the explicit wasmModuleUrl), instantiates the C++/WASM module (spawning workerCount async-engine worker threads on SharedArrayBuffer, which requires COOP/COEP headers; the .wasm is located via wasmUrl when given), and registers the WebCrypto-based engine the native core uses for all cryptography. Call once at application startup, before connect / connectPublic. Workflow: setup → connect → createThreadApi / createStoreApi / … → Connection.disconnect.
Params
options
string | EndpointSetupOptions
options object, or the assetsBasePath string alone (legacy form). Use the per-asset URL fields of EndpointSetupOptions for bundler-native loading.
getEventQueue
Returns the application-wide EventQueue used to receive server events pushed over active connections. The queue lives in the WASM core and is shared by all connections; this call only resolves the singleton wrapper (no server round-trip). Use it after subscribing to events (e.g. ThreadApi.subscribeFor) and drive it with EventQueue.waitEvent - or let getEventManager run the loop and dispatch typed callbacks for you.
Returns
Promise<EventQueue> ·
the global event queue singleton (same instance on every call)
getEventLoop
Returns the application-wide event loop - the single running consumer of the global EventQueue that dispatches incoming server events to the per-connection EventManagers (connection.getEventManager()). Started lazily on the first call and reused thereafter (one loop per application). Internal plumbing - applications use connection.getEventManager() instead.
Returns
Promise<EventLoop> ·
the shared, already-running event loop
createCryptoApi
Returns the standalone Crypto API for key generation, signing and symmetric encryption. CryptoApi runs entirely client-side in the WASM core (secp256k1 keys, ECDSA signatures, AES symmetric encryption) - it needs no connection and never contacts a server. Use it before connect to generate or derive the user's private key (e.g. derivePrivateKey2 from a password), or any time the application needs raw cryptographic operations.
Returns
Promise<CryptoApi> ·
the CryptoApi singleton (same instance on every call)
connect
Opens an authenticated session with a PrivMX Bridge server and returns the Connection all other APIs are created from. Performs an ECDHE handshake with the Bridge that encrypts the transport layer and proves the user's identity with their secp256k1 private key - the key itself never leaves the browser; the server only ever sees the derived public key. An authenticated WebSocket event channel is opened for server-pushed events. Requires setup to have completed. Next steps: createThreadApi / createStoreApi / … with the returned connection; call Connection.disconnect when done. For account-less guests (e.g. a public contact form) use connectPublic instead.
Params
userPrivKey
string
user's secp256k1 private key in WIF format - generate with CryptoApi.generatePrivateKey() or derive from credentials with CryptoApi.derivePrivateKey2(); the matching public key must be registered in the Context for content access to work
solutionId
string
ID of the Solution, found in the PrivMX Bridge admin panel next to the Bridge URL
bridgeUrl
string
base URL of the PrivMX Bridge instance, e.g. https://bridge.example.com
verificationOptions
PKIVerificationOptions
expected Bridge instance ID / public key, letting the client detect a spoofed Bridge server during the handshake
Returns
Promise<Connection> ·
authenticated connection - pass it to the createXApi factory methods
connectPublic
Opens an anonymous guest session with a PrivMX Bridge server - no user account or private key required. Generates a random ephemeral secp256k1 key client-side for the transport handshake; the session is unauthenticated (user ID <anonymous>) and uses plain HTTP requests instead of the WebSocket event channel. A guest connection cannot decrypt container keys, so Threads/Stores/KVDBs are inaccessible. Its purpose is the Inbox write path: create an InboxApi with createInboxApi and submit entries via prepareEntry/sendEntry (entries are encrypted client-side with the Inbox's public key, so only Inbox members can read them). Typical for public contact/submission forms.
Params
solutionId
string
ID of the Solution, found in the PrivMX Bridge admin panel next to the Bridge URL
bridgeUrl
string
base URL of the PrivMX Bridge instance, e.g. https://bridge.example.com
verificationOptions
PKIVerificationOptions
expected Bridge instance ID / public key, letting the client detect a spoofed Bridge server during the handshake
Returns
Promise<Connection> ·
guest connection - pass it to createInboxApi
createThreadApi
Returns the Thread API (encrypted messaging) for the given connection. Resolved from the connection's container - the first call instantiates the WASM-side ThreadApi object, subsequent calls return the same cached instance; no server round-trip happens here. Use it for everything message-related: createThread, sendMessage, listMessages, Thread event subscriptions.
Params
connection
Connection
connection returned by connect; the API stops working (throws) after connection.disconnect()
Returns
Promise<ThreadApi> ·
the per-connection ThreadApi instance
createStoreApi
Returns the Store API (encrypted file storage) for the given connection. Resolved from the connection's container - the first call instantiates the WASM-side StoreApi object, subsequent calls return the same cached instance; no server round-trip happens here. Use it for everything file-related: createStore, file upload (createFile → writeToFile → closeFile), download (openFile → readFromFile), Store event subscriptions.
Params
connection
Connection
connection returned by connect; the API stops working (throws) after connection.disconnect()
Returns
Promise<StoreApi> ·
the per-connection StoreApi instance
createInboxApi
Returns the Inbox API (one-way encrypted submissions) for the given connection. Resolved from the connection's container together with its internal ThreadApi/StoreApi dependencies; the first call instantiates the WASM-side object, subsequent calls return the same cached instance. Use it to manage Inboxes on an authenticated connection, or to submit entries (prepareEntry → sendEntry) on a guest connection from connectPublic.
Params
connection
Connection
connection returned by connect or connectPublic; the API stops working (throws) after connection.disconnect()
Returns
Promise<InboxApi> ·
the per-connection InboxApi instance
createInboxApi
Params
connection
Connection
connection returned by connect or connectPublic
_threadApi
ThreadApi
ignored - resolved internally instead
_storeApi
StoreApi
ignored - resolved internally instead
Returns
Promise<InboxApi> ·
the per-connection InboxApi instance
createInboxApi
Params
connection
Connection
connection returned by connect or connectPublic
_threadApi
ThreadApi
ignored - resolved internally instead
_storeApi
StoreApi
ignored - resolved internally instead
Returns
Promise<InboxApi> ·
the per-connection InboxApi instance
createKvdbApi
Returns the KVDB API (encrypted key-value storage) for the given connection. Resolved from the connection's container - the first call instantiates the WASM-side KvdbApi object, subsequent calls return the same cached instance; no server round-trip happens here. Use it for structured key-value data: createKvdb, setEntry, getEntry, listEntriesKeys, KVDB event subscriptions.
Params
connection
Connection
connection returned by connect; the API stops working (throws) after connection.disconnect()
Returns
Promise<KvdbApi> ·
the per-connection KvdbApi instance
createEventApi
Returns the Event API (custom encrypted Context events) for the given connection. Resolved from the connection's container - the first call instantiates the WASM-side EventApi object, subsequent calls return the same cached instance; no server round-trip happens here. Use it to broadcast application-defined events (emitEvent) to selected Context members - each event is encrypted client-side for its recipients - and to subscribe to such events from others.
Params
connection
Connection
connection returned by connect; the API stops working (throws) after connection.disconnect()
Returns
Promise<EventApi> ·
the per-connection EventApi instance
createStreamApi
Returns the Stream API (end-to-end encrypted WebRTC audio/video) for the given connection. Resolved from the connection's container; besides the WASM-side object, the first call wires up the WebRTC client stack (peer-connection managers, the E2EE web worker performing per-frame AES-256-GCM encryption, audio metering). All of it is torn down automatically by connection.disconnect(). Use it for live media: joinStreamRoom → createStream → addStreamTrack → publishStream, and createSubscriberStream for receiving.
Params
connection
Connection
connection returned by connect; the API stops working (throws) after connection.disconnect()
Returns
Promise<StreamApi> ·
the per-connection StreamApi instance
createStreamApi
Params
connection
Connection
connection returned by connect
_eventApi
EventApi
ignored - resolved internally instead
Returns
Promise<StreamApi> ·
the per-connection StreamApi instance
createStreamApi
Params
connection
Connection
connection returned by connect
_eventApi
EventApi
ignored - resolved internally instead
Returns
Promise<StreamApi> ·
the per-connection StreamApi instance
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.