Skip to main content
reference

Endpoint

Wrapper class for Privmx Endpoint.

Constructors

constructor

constructor(_coreApi: Connection,connectionId: string,label: string)

NameTypeDescription
_coreApiConnection
connectionIdstring
labelstring

Fields

inboxes

Provides functions to manage Inboxes.

get inboxes(): ContextInboxes

stores

Provides functions to manage Stores.

get stores(): ContextStores

threads

Provides functions to manage Threads.

get threads(): ContextThreads

Static Methods

connect

Connects to Bridge using provided config.

static async connect(connectionConfig: {
bridgeUrl: string;
label: string;
privKey: string;
solutionId: string;
})

NameTypeDescription
connectionConfig.bridgeUrlstringURL of PrivMX Bridge instance
connectionConfig.labelstringoptional label to set if you're using multiple connections; if you're not - `connectionId` will be used by default
connectionConfig.privKeystringPrivate Key in WIF format; you have to register their Private Key before users can connect to Bridge
connectionConfig.solutionIdstringID of Solution to connect to

TypeDescription
Promise<Endpoint> `Promise<Endpoint>

connectPublic

Connects to the Bridge publicly using provided config. This method of connecting to PrivMX Bridge doesn't require registering private keys earlier, they are created while connecting. Public connection exposes limited set of Endpoint method.

static async connectPublic(connectionConfig: {
bridgeUrl: string;
label: string;
solutionId: string;
})

NameTypeDescription
connectionConfig.bridgeUrlstringURL of PrivMX Bridge instance
connectionConfig.labelstringoptional label to set if you're using multiple connections; if you're not - `connectionId` will be used by default
connectionConfig.solutionIdstringID of Solution to connect to

TypeDescription
Promise<PublicConnection> `Promise<Endpoint>

connection

Function for getting current active connection.

static connection(label: string)

NameTypeDescription
labelstringoptional label passed during `Endpoint.connect`

TypeDescription
Endpoint

getDefaultConnectionId

static getDefaultConnectionId()

TypeDescription
string default connection ID/label which is called by

getEventQueue

Gets instance of `EventQueue`.

static async getEventQueue()

TypeDescription
Promise<EventQueue> EventQueue `Promise<EventQueue>

publicConnection

Returns a wrapper for functions that can be used in a public(guest) connection.

static publicConnection(label: string)

NameTypeDescription
labelstring

TypeDescription
PublicConnection `AnonymousConnection`

setDefaultConnectionId

Sets the default connection ID.

static setDefaultConnectionId(id: string)

NameTypeDescription
idstring

TypeDescription
void

startEventLoop

Starts new event loop if there isn't already one.

static async startEventLoop(options: {
debug: boolean;
})

NameTypeDescription
options.debugboolean(optional) if set to true, console will log incoming caught events

TypeDescription
Promise<void>

stopEventLoop

Stops current event loop, unsubscribes from all channels and removes all event handlers.

static async stopEventLoop()

TypeDescription
Promise<void>

Methods

connectionType

Returns the type of current connection.

connectionType()

TypeDescription
"public" | "user" `user`

disconnect

Disconnects user from the Bridge.

async disconnect()

TypeDescription
Promise<void>

getInboxApi

Gets instance of InboxApi associated with current connection.

async getInboxApi()

TypeDescription
Promise<InboxApi> InboxApi `Promise<InboxApi>

getStoreApi

Gets instance of StoreApi associated with current connection.

async getStoreApi()

TypeDescription
Promise<StoreApi> StoreApi Promise<`StoreApi`>

getThreadApi

Gets instance of ThreadApi associated with current connection.

async getThreadApi()

TypeDescription
Promise<ThreadApi> ThreadApi `Promise<ThreadApi>

inbox

Provides a wrapper to manage given Inbox.

inbox(inboxId: string)

NameTypeDescription
inboxIdstringID of the Inbox

TypeDescription
GenericInbox `GenericInbox`

listContexts

Returns list of Contexts the users has access to.

async listContexts(pageIndex: number, options: ListOptions)

NameTypeDescription
pageIndexnumberindicates from which page should list start
optionsListOptionsoptional options for listing data (default value pageSize: 100, sort: 'desc')

TypeDescription
Promise<PagingList<Context>> `PagingList<Context>

on

Registers an event listener for connection-related events.

on(eventType: T, callback: (payload: Extract<ThreadCreatedEvent, {type: T;}> | Extract<ThreadUpdatedEvent, {type: T;}> | Extract<ThreadDeletedEvent, {type: T;}> | Extract<ThreadStatsEvent, {type: T;}> | Extract<ThreadNewMessageEvent, {type: T;}> | Extract<ThreadMessageDeletedEvent, {type: T;}> | Extract<ThreadMessageUpdatedEvent, {type: T;}> | Extract<StoreFileCreatedEvent, {type: T;}> | Extract<StoreFileUpdatedEvent, {type: T;}> | Extract<StoreFileDeletedEvent, {type: T;}> | Extract<StoreCreatedEvent, {type: T;}> | Extract<StoreUpdatedEvent, {type: T;}> | Extract<StoreDeletedEvent, {type: T;}> | Extract<StoreStatsChangedEvent, {type: T;}> | Extract<InboxEntryCreatedEvent, {type: T;}> | Extract<InboxEntryDeletedEvent, {type: T;}> | Extract<InboxCreatedEvent, {type: T;}> | Extract<InboxUpdatedEvent, {type: T;}> | Extract<InboxDeletedEvent, {type: T;}> | Extract<ConnectedEvent, {type: T;}> | Extract<LibDisconnectedEvent, {type: T;}> | Extract<DisconnectedEvent, {type: T;}> | Extract<BreakEvent, {type: T;}>)=>void)

NameTypeDescription
eventTypeTtype of event to listen for
callback(payload: Extract<ThreadCreatedEvent, {type: T;}> | Extract<ThreadUpdatedEvent, {type: T;}> | Extract<ThreadDeletedEvent, {type: T;}> | Extract<ThreadStatsEvent, {type: T;}> | Extract<ThreadNewMessageEvent, {type: T;}> | Extract<ThreadMessageDeletedEvent, {type: T;}> | Extract<ThreadMessageUpdatedEvent, {type: T;}> | Extract<StoreFileCreatedEvent, {type: T;}> | Extract<StoreFileUpdatedEvent, {type: T;}> | Extract<StoreFileDeletedEvent, {type: T;}> | Extract<StoreCreatedEvent, {type: T;}> | Extract<StoreUpdatedEvent, {type: T;}> | Extract<StoreDeletedEvent, {type: T;}> | Extract<StoreStatsChangedEvent, {type: T;}> | Extract<InboxEntryCreatedEvent, {type: T;}> | Extract<InboxEntryDeletedEvent, {type: T;}> | Extract<InboxCreatedEvent, {type: T;}> | Extract<InboxUpdatedEvent, {type: T;}> | Extract<InboxDeletedEvent, {type: T;}> | Extract<ConnectedEvent, {type: T;}> | Extract<LibDisconnectedEvent, {type: T;}> | Extract<DisconnectedEvent, {type: T;}> | Extract<BreakEvent, {type: T;}>)=>voidcallback function to execute when the event occurs

TypeDescription
SubscribeForChannel<"connection"> & { removeEventListener: ()=>void; } object containing the

store

Provides a wrapper to manage a given Store.

store(storeId: string)

NameTypeDescription
storeIdstringID of the Store

TypeDescription
GenericStore `GenericStore`

thread

Provides a wrapper to manage given Thread.

thread(threadId: string)

NameTypeDescription
threadIdstringID of the Thread

TypeDescription
GenericThread `GenericThread`