Skip to main content
reference

InboxClient

Wrapper class for the InboxApi.

Constructors

constructor

constructor(inboxId: string,endpoint: Endpoint,eventDispatcher: EventDispatcher)

NameTypeDescription
inboxIdstring
endpointEndpoint
eventDispatcherEventDispatcher

Fields

inboxId

get inboxId(): string

Static Methods

createInbox

Creates a new Inbox

static async createInbox(api: InboxApi, newInbox: {
contextId: string;
filesConfig: FilesConfig;
managers: UserWithPubKey[];
privateMeta: Uint8Array;
publicMeta: Uint8Array;
users: UserWithPubKey[];
})

NameTypeDescription
apiInboxApiInboxApi `InboxApi`
newInbox.contextIdstringID of the Context for the new Inbox
newInbox.filesConfigFilesConfigobject to override default file configuration
newInbox.managersUserWithPubKey[]list of `UserWithPubKey` objects which indicates who will have access (and management rights) to the created Inbox
newInbox.privateMetaUint8Array(encrypted) private Inbox metadata
newInbox.publicMetaUint8Array(unencrypted) public Inbox metadata
newInbox.usersUserWithPubKey[]list of `UserWithPubKey` objects which indicates who will have access to the created Inbox

TypeDescription
Promise<string> Created Inbox ID

deleteEntry

Deletes an entry from Inbox

static async deleteEntry(api: InboxApi, entryId: string)

NameTypeDescription
apiInboxApiInboxApi `InboxApi`
entryIdstringID of entry to delete

TypeDescription
Promise<void>

downloadFile

Downloads file from Inbox to your local environment

static async downloadFile(api: InboxApi, storeApi: StoreApi, file: {
fileId: string;
fileName: string;
progressCallback: (progress: number)=>void;
})

NameTypeDescription
apiInboxApiInboxApi `InboxApi`
storeApiStoreApiStoreApi `StoreApi`
file.fileIdstringFile ID
file.fileNamestringoptional name that will be assigned to the file
file.progressCallback(progress: number)=>voidOptional callback function to report progress

TypeDescription
Promise<void> a promise that resolves with void and download the file to the browser environment

getEntry

Gets an Inbox entry based on its ID

static async getEntry(api: InboxApi, entryId: string)

NameTypeDescription
apiInboxApiInboxApi `InboxApi`
entryIdstringId of the entry

TypeDescription
Promise<InboxEntry> `Promise<InboxEntry>

getFileContents

Get the content of given file

static async getFileContents(api: InboxApi, fileId: string, progressCallback: (progress: number)=>void)

NameTypeDescription
apiInboxApiInboxApi `InboxApi` instance
fileIdstringID of the file to get the content from
progressCallback(progress: number)=>voidoptional function to report progress

TypeDescription
Promise<Uint8Array> content of the file

getInboxes

Gets a list of Inboxes in the given Context.

static async getInboxes(api: InboxApi, contextId: string, pageIndex: number, options: ListOptions)

NameTypeDescription
apiInboxApiInboxApi `InboxApi`
contextIdstringID of the Context to get Inboxes from
pageIndexnumberindicates from which page the list should start
optionsListOptionsoptional options object

TypeDescription
Promise<PagingList<Inbox>> -

on

Registers an event listener for Inbox-related events.

static on(eventDispatcher: EventDispatcher, eventType: T, callback: (payload: Extract<InboxCreatedEvent, {type: T;}> | Extract<InboxUpdatedEvent, {type: T;}> | Extract<InboxDeletedEvent, {type: T;}>)=>void)

NameTypeDescription
eventDispatcherEventDispatcher
eventTypeTtype of event to listen for.
callback(payload: Extract<InboxCreatedEvent, {type: T;}> | Extract<InboxUpdatedEvent, {type: T;}> | Extract<InboxDeletedEvent, {type: T;}>)=>voidcallback function to execute when the event occurs.

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

streamRead

Reads a file and returns a stream handler along with its metadata.

static async streamRead(api: InboxApi, fileId: string)

NameTypeDescription
apiInboxApiInboxApi `InboxApi` instance
fileIdstringThe ID of the file to be read.

TypeDescription
Promise<StreamReader> A promise that resolves with an object containing the stream reader, file size, MIME type, and file name.

subscribeForInboxEvents

Subscribes to events related to inboxes: - `inboxCreated` - `inboxDeleted` - `inboxUpdated`

static async subscribeForInboxEvents(api: InboxApi, eventDispatcher: EventDispatcher)

NameTypeDescription
apiInboxApiInboxApi `InboxApi`
eventDispatcherEventDispatchereventDispatcher

TypeDescription
Promise<SubscribeForChannel<"inbox">> <'inbox'> `Promise<SubscribeForChannel<'inbox'>>

unsubscribeFromInboxEvents

Unsubscribes from Inbox related events on this Inbox

static async unsubscribeFromInboxEvents(api: InboxApi, eventDispatcher: EventDispatcher)

NameTypeDescription
apiInboxApiInboxApi `InboxApi`
eventDispatcherEventDispatchereventDispatcher

TypeDescription
Promise<void> a promise that resolves with void

Methods

deleteInbox

Deletes current Inbox

async deleteInbox()

TypeDescription
Promise<void> a promise that resolves with void

getInboxInfo

Fetches info about current Inbox

async getInboxInfo()

TypeDescription
Promise<Inbox> `Inbox`

getPublicView

Fetches inbox public meta.

async getPublicView()

TypeDescription
Promise<InboxPublicView>

listEntries

Gets a list of entries from current Inbox.

async listEntries(pageIndex: number, options: ListOptions)

NameTypeDescription
pageIndexnumber
optionsListOptionsoptional `options` object

TypeDescription
Promise<PagingList<InboxEntry>> `PagingList<InboxEntry>

on

Registers an event listener for Inbox entry-related events.

on(eventType: T, callback: (payload: Extract<InboxEntryCreatedEvent, {type: T;}> | Extract<InboxEntryDeletedEvent, {type: T;}>)=>void)

NameTypeDescription
eventTypeTtype of event to listen for.
callback(payload: Extract<InboxEntryCreatedEvent, {type: T;}> | Extract<InboxEntryDeletedEvent, {type: T;}>)=>voidcallback function to execute when the event occurs.

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

sendData

Sends data and optional files to an Inbox.

async sendData(entry: InboxEntryPayload)

NameTypeDescription
entryInboxEntryPayload`InboxEntryPayload` object

TypeDescription
Promise<void> A promise that resolves when the data and files have been successfully sent to the Inbox.

subscribeForEntryEvents

Subscribes to entry events on given Inbox: - `inboxNewEntry` - `inboxEntryDeleted`

async subscribeForEntryEvents()

TypeDescription
Promise<SubscribeForChannel<"inboxEntries">> <'inboxEntries'> `Promise<SubscribeForChannel<'inboxEntries'>>

unsubscribeFromEntryEvents

Unsubscribes from events related to entries on this Inbox

async unsubscribeFromEntryEvents()

TypeDescription
Promise<void> a promise that resolves with void

updateInbox

Updates an existing Inbox.

async updateInbox(updatedData: {
filesConfig: FilesConfig;
managers: UserWithPubKey[];
options: {
force: boolean;
forceGenerateNewKey: boolean;
};
privateMeta: Uint8Array;
publicMeta: Uint8Array;
users: UserWithPubKey[];
version: number;
})

NameTypeDescription
updatedData.filesConfigFilesConfigobject to override default file configuration. Provide undefined if you want to leave the default configuration.
updatedData.managersUserWithPubKey[]list of `UserWithPubKey` objects which indicates who will have access (and management rights) to the updated Inbox
updatedData.options{ force: boolean; forceGenerateNewKey: boolean; }
updatedData.privateMetaUint8Array(encrypted) private Inbox metadata
updatedData.publicMetaUint8Array(unencrypted) public Inbox metadata
updatedData.usersUserWithPubKey[]list of `UserWithPubKey` objects which indicates who will have access to the updated Inbox
updatedData.versionnumbercurrent version of the updated Inbox

TypeDescription
Promise<void>