Skip to main content
reference

ContextInboxes

Provides a wrapper for functions used to manage Inboxes in given Context.

Constructors

constructor

constructor(_endpoint: Endpoint,_eventDispatcher: EventDispatcher)

NameTypeDescription
_endpointEndpoint
_eventDispatcherEventDispatcher

Methods

deleteEntry

Deletes an Inbox entry based on its ID.

async deleteEntry(entryId: string)

NameTypeDescription
entryIdstringID of the entry

TypeDescription
Promise<void> `Promise<InboxEntry>

downloadFile

Downloads file from Inbox to your local environment. On platforms that support FileAPI 'showFilePicker' method it will fetch file in chunks. Otherwise, the file will be downloaded to memory first.

async downloadFile(file: {
fileId: string;
fileName: string;
progressCallback: (progress: number)=>void;
})

NameTypeDescription
file.fileIdstringFile ID
file.fileNamestringoptional name that will be assigned to the file
file.progressCallback(progress: number)=>voidoptional callback function called after fetching each file chunk

TypeDescription
Promise<void>

getEntry

Gets an Inbox entry based on its ID.

async getEntry(entryId: string)

NameTypeDescription
entryIdstringID of the entry

TypeDescription
Promise<InboxEntry> `Promise<InboxEntry>

getFileContents

Gets the content of given file. File is fetched in chunks and stored in memory.

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

NameTypeDescription
fileIdstringID of the file to get the content from
progressCallback(progress: number)=>voidoptional callback function called after fetching each file chunk

TypeDescription
Promise<Uint8Array> content of the file

list

Lists Inboxes the user has access to.

async list(query: {
contextId: string;
options: ListOptions;
pageIndex: number;
})

NameTypeDescription
query.contextIdstringindicates from which Context should Inboxes be fetched
query.optionsListOptionsoptional options object
query.pageIndexnumberindicates from which page the list should start

TypeDescription
Promise<PagingList<Inbox>> `PagingList<Inbox>

new

Creates a new Inbox inside Context.

async new(newInbox: {
contextId: string;
filesConfig: FilesConfig;
managers: UserWithPubKey[];
privateMeta: Uint8Array;
publicMeta: Uint8Array;
users: UserWithPubKey[];
})

NameTypeDescription
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.privateMetaUint8Arrayoptional (encrypted) private Inbox metadata
newInbox.publicMetaUint8Arrayoptional (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

on

Registers an event listener for Inbox-related events.

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

NameTypeDescription
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

subscribeForInboxEvents

Subscribes to events related to Inboxes: - `inboxCreated` - `inboxDeleted` - `inboxStatsChanged` - `inboxUpdated`

async subscribeForInboxEvents()

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

unsubscribeFromInboxEvents

Unsubscribes and removes all registered callbacks for events related to Inboxes

async unsubscribeFromInboxEvents()

TypeDescription
Promise<void>