@simplito/privmx-webendpoint
Version:
PrivMX Web Endpoint library
71 lines (70 loc) • 2.15 kB
TypeScript
import { Connection } from "../service";
import { InboxEntryPayload } from "./inbox";
/**
* @class PublicConnection
* @classdesc A client for interacting with the PrivMX Endpoint API as a guest. The scope is limited to sending an entries to inboxes.
* @example
* // Initialize the PrivMX client
* await PrivmxClient.setup('/path/to/privmx/assets');
*
* // Connect to the PrivMX bridge
* const solutionId = 'your-solution-id';
* const bridgeUrl = 'https://your-bridge-url.com';
* const inboxId = 'your-inbox-id'
* const client = await PrivmxClient.connectPublic(solutionId, bridgeUrl);
*
* // Send entry
* const encoder = new TextEncoder();
* const encodedData = encoder.encode(JSON.stringify({ message: 'Hello, PrivMX!' }));
*
* await client.sendEntry(inboxId, {
* data: encodedData
* })
*
* // Disconnect when done
* await client.disconnect();
*/
export declare class PublicConnection {
private connection;
private threadApi;
private storeApi;
private inboxApi;
/**
* @constructor
* @param {Connection} connection - The connection object.
*/
constructor(connection: Connection);
/**
* @description Gets the connection object.
* @returns {Connection}
* @throws {Error} If there is no active connection.
*/
private getConnection;
/**
* @description Gets the Thread API.
* @returns {Promise<ThreadApi>}
*/
private getThreadApi;
/**
* @description Gets the Store API.
* @returns {Promise<StoreApi>}
*/
private getStoreApi;
/**
* @description Gets the Inbox API.
* @returns {Promise<InboxApi>}
*/
private getInboxApi;
/**
* @description Disconnects from the PrivMX bridge.
* @returns {Promise<void>}
*/
disconnect(): Promise<void>;
/**
* @description Sends an entry to the specified inbox.
* @param {string} inboxId - The ID of the inbox to send the entry to.
* @param {InboxEntryPayload} payload - The payload of the entry to send.
* @returns {Promise<void>}
*/
sendEntry(inboxId: string, payload: InboxEntryPayload): Promise<void>;
}