Inboxes
Class representing instance of Inboxes API
Methods
createInbox
Creates a new Inbox.
createInbox(contextId, users, managers, publicMeta, privateMeta, filesConfig)
Name | Type | Description |
---|---|---|
contextId | string | ID of the Context of the new Inbox |
users | UserWithPubKey[] | vector of UserWithPubKey structs which indicates who will have access to the created Inbox |
managers | UserWithPubKey[] | vector of UserWithPubKey structs which indicates who will have access (and management rights) to the created Inbox |
publicMeta | Uint8Array | public (unencrypted) metadata |
privateMeta | Uint8Array | private (encrypted) metadata |
filesConfig | FilesConfig | undefined | struct to override default file configuration |
Type | Description |
---|---|
Promise<string> | ID of the created Inbox |
updateInbox
Updates an existing Inbox.
updateInbox(inboxId, users, managers, publicMeta, privateMeta, filesConfig, version, force, forceGenerateNewKey)
Name | Type | Description |
---|---|---|
inboxId | string | ID of the Inbox to update |
users | UserWithPubKey[] | vector of UserWithPubKey structs which indicates who will have access to the created Inbox |
managers | UserWithPubKey[] | vector of UserWithPubKey structs which indicates who will have access (and management rights) to the created Inbox |
publicMeta | Uint8Array | public (unencrypted) metadata |
privateMeta | Uint8Array | private (encrypted) metadata |
filesConfig | FilesConfig | undefined | struct to override default files configuration |
version | number | current version of the updated Inbox |
force | boolean | force update (without checking version) |
forceGenerateNewKey | boolean | force to regenerate a key for the Inbox |
getInbox
Gets a single Inbox by given Inbox ID.
getInbox(inboxId)
Name | Type | Description |
---|---|---|
inboxId | string | ID of the Inbox to get |
Type | Description |
---|---|
Promise<Inbox> | struct containing information about the Inbox |
listInboxes
Gets s list of Inboxes in given Context.
listInboxes(contextId, pagingQuery)
Name | Type | Description |
---|---|---|
contextId | string | ID of the Context to get Inboxes from |
pagingQuery | PagingQuery | struct with list query parameters |
Type | Description |
---|---|
Promise<PagingList<Inbox>> | struct containing list of Inboxes |
getInboxPublicView
Gets public data of given Inbox. You do not have to be logged in to call this function.
getInboxPublicView(inboxId)
Name | Type | Description |
---|---|---|
inboxId | string | ID of the Inbox to get |
Type | Description |
---|---|
Promise<InboxPublicView> | struct containing public accessible information about the Inbox |
deleteInbox
Deletes an Inbox by given Inbox ID.
deleteInbox(inboxId)
Name | Type | Description |
---|---|---|
inboxId | string | ID of the Inbox to delete |
prepareEntry
Prepares a request to send data to an Inbox. You do not have to be logged in to call this function.
prepareEntry(inboxId, data, inboxFileHandles, userPrivKey)
Name | Type | Description |
---|---|---|
inboxId | string | ID of the Inbox to which the request applies |
data | Uint8Array | entry data to send |
inboxFileHandles | number[] | optional list of file handles that will be sent with the request |
userPrivKey | string | undefined | optional sender's private key which can be used later to encrypt data for that sender |
Type | Description |
---|---|
Promise<number> | Inbox handle |
sendEntry
Sends data to an Inbox. You do not have to be logged in to call this function.
sendEntry(inboxHandle)
Name | Type | Description |
---|---|---|
inboxHandle | number | ID of the Inbox to which the request applies |
readEntry
Gets an entry from an Inbox.
readEntry(inboxEntryId)
Name | Type | Description |
---|---|---|
inboxEntryId | string | ID of an entry to read from the Inbox |
Type | Description |
---|---|
Promise<InboxEntry> | struct containing data of the selected entry stored in the Inbox |
listEntries
Gets list of entries in given Inbox.
listEntries(inboxId, pagingQuery)
Name | Type | Description |
---|---|---|
inboxId | string | ID of the Inbox |
pagingQuery | PagingQuery | struct with list query parameters |
Type | Description |
---|---|
Promise<PagingList<InboxEntry>> | struct containing list of entries |
deleteEntry
Delete an entry from an Inbox.
deleteEntry(inboxEntryId)
Name | Type | Description |
---|---|---|
inboxEntryId | string | ID of an entry to delete from the Inbox |
createFileHandle
Creates a file handle to send a file to an Inbox. You do not have to be logged in to call this function.
createFileHandle(publicMeta, privateMeta, fileSize)
Name | Type | Description |
---|---|---|
publicMeta | Uint8Array | public file metadata |
privateMeta | Uint8Array | private file metadata |
fileSize | number | size of the file to send |
Type | Description |
---|---|
Promise<number> | file handle |
writeToFile
Sends a file's data chunk to an Inbox. (note: To send the entire file - divide it into pieces of the desired size and call the function for each fragment.) You do not have to be logged in to call this function.
writeToFile(inboxHandle, inboxFileHandle, dataChunk)
Name | Type | Description |
---|---|---|
inboxHandle | number | ID of the Inbox to which the request applies |
inboxFileHandle | number | handle to the file where the uploaded chunk belongs |
dataChunk | Uint8Array | - file chunk to send |
openFile
Opens a file to read.
openFile(fileId)
Name | Type | Description |
---|---|---|
fileId | string | ID of the file to read |
Type | Description |
---|---|
Promise<number> | handle to read file data |
readFromFile
Reads file data.
readFromFile(fileHandle, length)
Name | Type | Description |
---|---|---|
fileHandle | number | handle to the file |
length | number | size of data to read |
Type | Description |
---|---|
Promise<Uint8Array> | buffer with file data chunk |
seekInFile
Moves file's read cursor.
seekInFile(fileHandle, position)
Name | Type | Description |
---|---|---|
fileHandle | number | handle to the file |
position | number | sets new cursor position |
closeFile
Closes a file by given handle.
closeFile(fileHandle)
Name | Type | Description |
---|---|---|
fileHandle | number | handle to the file |
subscribeForInboxEvents
Subscribes for the Inbox module main events.
subscribeForInboxEvents()
unsubscribeFromInboxEvents
Unsubscribes from the Inbox module main events.
unsubscribeFromInboxEvents()
subscribeForEntryEvents
Subscribes for events in given Inbox.
subscribeForEntryEvents(inboxId)
Name | Type | Description |
---|---|---|
inboxId | string | ID of the Inbox to subscribe |
unsubscribeFromEntryEvents
Unsubscribes from events in given Inbox.
unsubscribeFromEntryEvents(inboxId)
Name | Type | Description |
---|---|---|
inboxId | string | ID of the Inbox to unsubscribe |