Endpoint
Wrapper class for Privmx Endpoint.
Constructors
constructor
constructor(_coreApi: Connection,connectionId: string,label: string)
Name | Type | Description |
---|---|---|
_coreApi | Connection | |
connectionId | string | |
label | string |
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;
})
Name | Type | Description |
---|---|---|
connectionConfig.bridgeUrl | string | URL of PrivMX Bridge instance |
connectionConfig.label | string | optional label to set if you're using multiple connections; if you're not - `connectionId` will be used by default |
connectionConfig.privKey | string | Private Key in WIF format; you have to register their Private Key before users can connect to Bridge |
connectionConfig.solutionId | string | ID of Solution to connect to |
Type | Description |
---|---|
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;
})
Name | Type | Description |
---|---|---|
connectionConfig.bridgeUrl | string | URL of PrivMX Bridge instance |
connectionConfig.label | string | optional label to set if you're using multiple connections; if you're not - `connectionId` will be used by default |
connectionConfig.solutionId | string | ID of Solution to connect to |
Type | Description |
---|---|
Promise<PublicConnection> | `Promise<Endpoint> |
connection
Function for getting current active connection.
static connection(label: string)
Name | Type | Description |
---|---|---|
label | string | optional label passed during `Endpoint.connect` |
Type | Description |
---|---|
Endpoint |
getDefaultConnectionId
static getDefaultConnectionId()
Type | Description |
---|---|
string | default connection ID/label which is called by |
getEventQueue
Gets instance of `EventQueue`.
static async getEventQueue()
Type | Description |
---|---|
Promise<EventQueue> | EventQueue `Promise<EventQueue> |
publicConnection
Returns a wrapper for functions that can be used in a public(guest) connection.
static publicConnection(label: string)
Name | Type | Description |
---|---|---|
label | string |
Type | Description |
---|---|
PublicConnection | `AnonymousConnection` |
setDefaultConnectionId
Sets the default connection ID.
static setDefaultConnectionId(id: string)
Name | Type | Description |
---|---|---|
id | string |
Type | Description |
---|---|
void |
startEventLoop
Starts new event loop if there isn't already one.
static async startEventLoop(options: {
debug: boolean;
})
Name | Type | Description |
---|---|---|
options.debug | boolean | (optional) if set to true, console will log incoming caught events |
Type | Description |
---|---|
Promise<void> |
stopEventLoop
Stops current event loop, unsubscribes from all channels and removes all event handlers.
static async stopEventLoop()
Type | Description |
---|---|
Promise<void> |
Methods
connectionType
Returns the type of current connection.
connectionType()
Type | Description |
---|---|
"public" | "user" | `user` |
disconnect
Disconnects user from the Bridge.
async disconnect()
Type | Description |
---|---|
Promise<void> |
getInboxApi
Gets instance of InboxApi associated with current connection.
async getInboxApi()
Type | Description |
---|---|
Promise<InboxApi> | InboxApi `Promise<InboxApi> |
getStoreApi
Gets instance of StoreApi associated with current connection.
async getStoreApi()
Type | Description |
---|---|
Promise<StoreApi> | StoreApi Promise<`StoreApi`> |
getThreadApi
Gets instance of ThreadApi associated with current connection.
async getThreadApi()
Type | Description |
---|---|
Promise<ThreadApi> | ThreadApi `Promise<ThreadApi> |
inbox
Provides a wrapper to manage given Inbox.
inbox(inboxId: string)
Name | Type | Description |
---|---|---|
inboxId | string | ID of the Inbox |
Type | Description |
---|---|
GenericInbox | `GenericInbox` |
listContexts
Returns list of Contexts the users has access to.
async listContexts(pageIndex: number, options: ListOptions)
Name | Type | Description |
---|---|---|
pageIndex | number | indicates from which page should list start |
options | ListOptions | optional options for listing data (default value pageSize: 100, sort: 'desc') |
Type | Description |
---|---|
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)
Name | Type | Description |
---|---|---|
eventType | T | type 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;}>)=>void | callback function to execute when the event occurs |
Type | Description |
---|---|
SubscribeForChannel<"connection"> & {
removeEventListener: ()=>void;
} | object containing the |
store
Provides a wrapper to manage a given Store.
store(storeId: string)
Name | Type | Description |
---|---|---|
storeId | string | ID of the Store |
Type | Description |
---|---|
GenericStore | `GenericStore` |
thread
Provides a wrapper to manage given Thread.
thread(threadId: string)
Name | Type | Description |
---|---|---|
threadId | string | ID of the Thread |
Type | Description |
---|---|
GenericThread | `GenericThread` |