Inboxes
Class representing instance of Inboxes API
Methods
createInbox
Creates a new Inbox.
createInbox ( contextId , users , managers , publicMeta , privateMeta , filesConfig , policies )
Params 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
struct to override default file configuration policies ContainerWithoutItemPolicy
Inbox policies
Returns Type Description Promise<string>
ID of the created Inbox
updateInbox
Updates an existing Inbox.
updateInbox ( inboxId , users , managers , publicMeta , privateMeta , filesConfig , version , force , forceGenerateNewKey , policies )
Params 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 policies ContainerWithoutItemPolicy
Inbox policies
getInbox
Gets a single Inbox by given Inbox ID.
Params Name Type Description inboxId string
ID of the Inbox to get
Returns Type Description Promise<Inbox>
struct containing information about the Inbox
listInboxes
Gets s list of Inboxes in given Context.
listInboxes ( contextId , pagingQuery )
Params Name Type Description contextId string
ID of the Context to get Inboxes from pagingQuery PagingQuery
struct with list query parameters
Returns 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 )
Params Name Type Description inboxId string
ID of the Inbox to get
Returns Type Description Promise<InboxPublicView>
struct containing public accessible information about the Inbox
deleteInbox
Deletes an Inbox by given Inbox ID.
Params 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 )
Params 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
Returns Type Description Promise<number>
Inbox handle
sendEntry
Sends data to an Inbox. You do not have to be logged in to call this function.
Params Name Type Description inboxHandle number
ID of the Inbox to which the request applies
readEntry
Gets an entry from an Inbox.
Params Name Type Description inboxEntryId string
ID of an entry to read from the Inbox
Returns 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 )
Params Name Type Description inboxId string
ID of the Inbox pagingQuery PagingQuery
struct with list query parameters
Returns Type Description Promise<PagingList<InboxEntry>>
struct containing list of entries
deleteEntry
Delete an entry from an Inbox.
deleteEntry ( inboxEntryId )
Params 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 )
Params Name Type Description publicMeta Uint8Array
public file metadata privateMeta Uint8Array
private file metadata fileSize number
size of the file to send
Returns 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 )
Params Name Type Description inboxHandle number
Handle to the prepared Inbox entry inboxFileHandle number
handle to the file where the uploaded chunk belongs dataChunk Uint8Array
- file chunk to send
openFile
Opens a file to read.
Params Name Type Description fileId string
ID of the file to read
Returns Type Description Promise<number>
handle to read file data
readFromFile
Reads file data. Single read call moves the files's cursor position by declared length or set it at the end of the file.
readFromFile ( fileHandle , length )
Params Name Type Description fileHandle number
handle to the file length number
size of data to read
Returns Type Description Promise<Uint8Array>
buffer with file data chunk
seekInFile
Moves file's read cursor.
seekInFile ( fileHandle , position )
Params Name Type Description fileHandle number
handle to the file position number
sets new cursor position
closeFile
Closes a file by given handle.
Params Name Type Description fileHandle number
handle to the file
Returns Type Description Promise<string>
ID of closed 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 )
Params Name Type Description inboxId string
ID of the Inbox to subscribe
unsubscribeFromEntryEvents
Unsubscribes from events in given Inbox.
unsubscribeFromEntryEvents ( inboxId )
Params Name Type Description inboxId string
ID of the Inbox to unsubscribe