StoreApi
Class representing instance of Stores API
Methods
createStore
Creates a new Store in the given Context and returns the new Store's ID. A random container key is generated client-side and encrypted separately for each listed user with ECIES using their public key - the server stores only the encrypted per-user key entries and cannot read the key. privateMeta is encrypted client-side with the container key; publicMeta is stored unencrypted on the server. Entry point of the file workflow: follow with createFile to upload files and listFiles to enumerate them. Adjust members or metadata later with updateStore.
Params
contextId
string
ID of the Context to create the Store in, from Context.contextId returned by Connection.listContexts
users
UserWithPubKey[]
members allowed to access files in the Store; build the entries from Connection.listContextUsers
managers
UserWithPubKey[]
members who can additionally update or delete the Store; build the entries from Connection.listContextUsers
publicMeta
Uint8Array
metadata stored unencrypted on the server - readable by the Bridge, so never place secrets here
privateMeta
Uint8Array
metadata encrypted client-side with the container key; only Store members can decrypt it
policies
ContainerPolicy
fine-grained access rules (who may create, update or delete files) overriding the Context defaults
Returns
Promise<string> ·
ID of the new Store - pass to createFile, listFiles, getStore or updateStore
updateStore
Replaces the member lists, metadata and (optionally) the encryption key of an existing Store. The container key list is re-encrypted for the new user set (ECIES on each user's public key). With forceGenerateNewKey a fresh container key is generated, so removed users cannot decrypt content added after the update. The update is a full replacement, not a diff - fetch the current state with getStore, modify it, and pass the Store's version back so concurrent modifications are detected. Set forceGenerateNewKey whenever you remove users.
Params
storeId
string
ID of the Store to update, returned by createStore or from Store.storeId in listStores
users
UserWithPubKey[]
full replacement list of members allowed to access files; users missing from this list lose access
managers
UserWithPubKey[]
full replacement list of members with management rights (update / delete the Store)
publicMeta
Uint8Array
new metadata stored unencrypted on the server - never place secrets here
privateMeta
Uint8Array
new metadata encrypted client-side with the container key
version
number
current Store version, from Store.version returned by getStore - lets the server reject stale updates
force
boolean
true skips the version check and overwrites any concurrent modification
forceGenerateNewKey
boolean
when true, a fresh container key is generated by the WASM core and redistributed, so users removed by this update cannot decrypt content added afterwards - set it whenever you revoke access
policies
ContainerPolicy
new access policies; omit to keep the current ones
deleteStore
Permanently deletes a Store together with all the files it contains. The server removes the Store record, its encrypted per-user key entries and every stored file ciphertext - there is no undo. Requires management rights to the Store (see the managers list of createStore / updateStore). To merely revoke access, keep the Store and remove users with updateStore instead.
Params
storeId
string
ID of the Store to delete, returned by createStore or from Store.storeId in listStores
getStore
Fetches a single Store with its metadata, member lists and version. Downloads the Store record from the Bridge and decrypts privateMeta client-side with the user's copy of the container key; publicMeta arrives as stored, unencrypted. Use it to display Store details or to obtain the current version required by updateStore.
Params
storeId
string
ID of the Store to fetch, returned by createStore or from Store.storeId in listStores
Returns
Promise<Store> ·
decrypted Store data - version feeds updateStore; storeId feeds createFile and listFiles
listStores
Lists the Stores of a Context that the user is a member of, one page at a time. Downloads the Store records from the Bridge and decrypts each privateMeta client-side with the corresponding container key. Typically the first StoreApi call after connecting - pick a Store from the result and enumerate its files with listFiles.
Params
contextId
string
ID of the Context to enumerate, from Context.contextId returned by Connection.listContexts
pagingQuery
PagingQuery
pagination and sorting; start with { skip: 0, limit: 100, sortOrder: "desc" } and page using skip or lastId
Returns
Promise<PagingList<Store>> ·
one page of Stores plus totalAvailable; use Store.storeId with createFile or listFiles
createFile
Starts the upload of a new file into a Store and returns a write handle. A random 256-bit file key is generated client-side; each chunk written through the handle is encrypted with AES-256-CBC (PKCS#7) under a per-chunk key derived as SHA-256(fileKey || chunkIndex), with a random IV and an HMAC-SHA-256 tag per chunk - the server stores only ciphertext. First step of the upload workflow: createFile → writeToFile (repeat per chunk) → closeFile. The file is not visible to other members until closeFile commits it.
Params
storeId
string
ID of the Store to create the file in, returned by createStore or from Store.storeId in listStores
publicMeta
Uint8Array
file metadata stored unencrypted on the server - readable by the Bridge, so never place secrets here
privateMeta
Uint8Array
file metadata encrypted client-side; only Store members can decrypt it
size
number
declared total file size in bytes - the sum of all chunks subsequently passed to writeToFile
randomWriteSupport
boolean
true lays the file out so that later arbitrary-position writes via seekInFile + writeToFile are possible; defaults to sequential-only
Returns
Promise<number> ·
write handle consumed by writeToFile, seekInFile and finally closeFile
updateFile
Starts replacing the content and metadata of an existing file and returns a write handle. Works like createFile for an existing file: chunks written through the handle are encrypted client-side (AES-256-CBC with per-chunk keys derived from the file key and per-chunk HMAC-SHA-256 tags) and the server keeps only ciphertext. Use it to overwrite a file in place while keeping its ID stable for other members; follow with writeToFile (repeat per chunk) and closeFile to commit. To change only metadata, use the cheaper updateFileMeta.
Params
fileId
string
ID of the file to replace, returned by closeFile or from File.info.fileId in listFiles
publicMeta
Uint8Array
new file metadata stored unencrypted on the server - never place secrets here
privateMeta
Uint8Array
new file metadata encrypted client-side with the Store's container key
size
number
declared total size in bytes of the replacement content written via writeToFile
Returns
Promise<number> ·
write handle consumed by writeToFile and finally closeFile
updateFileMeta
Replaces only the metadata of an existing file, leaving its content untouched. The metadata is re-encrypted client-side with the Store's current container key and committed in a single call - content chunks are not touched, so this is much cheaper than updateFile. Use it to rename a file or update application-level attributes without re-uploading content. To replace the content too, use updateFile.
Params
fileId
string
ID of the file to update, returned by closeFile or from File.info.fileId in listFiles
publicMeta
Uint8Array
new file metadata stored unencrypted on the server - never place secrets here
privateMeta
Uint8Array
new file metadata encrypted client-side with the Store's container key
writeToFile
Writes the next chunk of data to a file opened for writing. The chunk is encrypted client-side with AES-256-CBC under a per-chunk key derived as SHA-256(fileKey || chunkIndex), with a random IV and an HMAC-SHA-256 tag - only ciphertext leaves the browser. Call repeatedly between createFile (or updateFile) and closeFile until the declared size has been written; nothing is visible to other members until closeFile commits. Writing at an arbitrary position (after seekInFile) requires the file to have been created with randomWriteSupport = true.
Params
fileHandle
number
write handle returned by createFile or updateFile
dataChunk
Uint8Array
next slice of the file content, appended at the handle's current cursor position
truncate
boolean
true cuts the file off at current position + dataChunk length, discarding any data beyond it
deleteFile
Permanently deletes a file from its Store. The server removes the file record and all its ciphertext chunks - there is no undo. Requires sufficient rights in the Store (see createStore policies). To replace content instead of deleting, use updateFile.
Params
fileId
string
ID of the file to delete, returned by closeFile or from File.info.fileId in listFiles
getFile
Fetches a single file's metadata (not its content). Downloads the encrypted file record from the Bridge and decrypts privateMeta client-side with the Store's container key; publicMeta and size information arrive as stored. Use it to display file details or to resolve a file ID delivered by an event subscription (subscribeFor); to read the content, follow with openFile and readFromFile.
Params
fileId
string
ID of the file to fetch, returned by closeFile or from File.info.fileId in listFiles
Returns
Promise<File> ·
decrypted file record - info.fileId feeds openFile, updateFile and updateFileMeta
listFiles
Lists the files of a Store, one page at a time. Downloads the file records from the Bridge and decrypts each privateMeta client-side with the Store's container key - content is not downloaded. Use it to render a file browser; read a chosen file with openFile + readFromFile.
Params
storeId
string
ID of the Store to enumerate, returned by createStore or from Store.storeId in listStores
pagingQuery
PagingQuery
pagination and sorting; start with { skip: 0, limit: 100, sortOrder: "desc" } and page using skip or lastId
Returns
Promise<PagingList<File>> ·
one page of files plus totalAvailable; use File.info.fileId with openFile or updateFile
openFile
Opens a file for reading and returns a read handle. Fetches the encrypted file metadata and decrypts it locally with the Store's container key to recover the file key - content chunks are then fetched and decrypted on demand by readFromFile. First step of the download workflow: openFile → readFromFile (repeat per chunk) → closeFile; reposition with seekInFile if needed.
Params
fileId
string
ID of the file to read, returned by closeFile or from File.info.fileId in listFiles
Returns
Promise<number> ·
read handle consumed by readFromFile, seekInFile, syncFile and finally closeFile
readFromFile
Reads and decrypts the next portion of an opened file. Verify-then-decrypt: each chunk's HMAC-SHA-256 tag is checked before AES decryption, so tampered ciphertext is rejected instead of being returned. The handle's cursor advances by the read length, or stops at the end of the file. Call repeatedly after openFile until fewer bytes than length are returned; jump to another offset with seekInFile.
Params
fileHandle
number
read handle returned by openFile
length
number
number of bytes to read from the current cursor position; the result may be shorter near the end of the file
Returns
Promise<Uint8Array> ·
decrypted file content starting at the cursor - concatenate successive reads to reconstruct the file
seekInFile
Moves the cursor of an opened file handle to an absolute position. Only the local cursor changes - no data is transferred until the next readFromFile or writeToFile. Use it for range reads (e.g. resuming a download). Seeking a write handle to perform arbitrary-position writes requires the file to have been created with randomWriteSupport = true in createFile.
Params
fileHandle
number
handle returned by openFile, createFile or updateFile
position
number
absolute offset in bytes from the start of the file where the next read/write begins
closeFile
Closes a file handle and, for write handles, commits the upload. For a write handle this finalizes pending writes, computes the file checksum, encrypts the file metadata (including the file key and chunk layout) with the Store's container key and commits - only then does the file become visible to other Store members. For a read handle it simply releases the native resources. Always the last step of both workflows: createFile / updateFile → writeToFile → closeFile, and openFile → readFromFile → closeFile.
Params
fileHandle
number
handle returned by createFile, updateFile or openFile
Returns
Promise<string> ·
ID of the closed file - pass to getFile, openFile or updateFileMeta
syncFile
Refreshes an open file handle with the newest file state from the server. Refetches the server-side file record so the handle sees updates committed concurrently by other members (e.g. a finished updateFile from another session). Use it on long-lived read handles before continuing to read when the file may have changed; without it the handle keeps the state from openFile time.
Params
fileHandle
number
handle returned by openFile, createFile or updateFile
subscribeFor
Subscribes this connection to Store events matching the given subscription queries. Registers the subscriptions on the Bridge over the connection's event channel; matching events are then pushed by the server and surface through EventQueue.waitEvent. Required order: buildSubscriptionQuery (one query per event-type/selector pair) → subscribeFor(queries) → consume events from the EventQueue → unsubscribeFrom when no longer needed.
Params
subscriptionQueries
string[]
query strings produced by buildSubscriptionQuery; hand-written strings are not supported
Returns
Promise<string[]> ·
subscription IDs, index-aligned with subscriptionQueries - keep them to unsubscribeFrom later
unsubscribeFrom
Cancels Store event subscriptions previously created on this connection, so the server stops pushing the matching events. Subscriptions also end implicitly when the connection is closed; call this only to stop receiving a subset of events while keeping the connection alive.
Params
subscriptionIds
string[]
IDs returned by subscribeFor; unknown IDs cause a NativeError rejection
buildSubscriptionQuery
Builds a subscription-query string describing one class of Store events (e.g. "all file events in Store X"). The query is assembled locally by the WASM core in the server's expected format - nothing is sent yet; pass the result to subscribeFor to activate it.
Params
eventType
StoreEventType
which Store event class to listen for (Store create/update/delete, file events, …)
selectorType
StoreEventSelectorType
what selectorId refers to (e.g. a whole Context or a single Store), narrowing the event scope
selectorId
string
ID of the selected scope - a Store ID returned by createStore or a Context ID from Connection.listContexts, depending on selectorType
Returns
Promise<string> ·
query string consumed by subscribeFor
We use cookies on our website. We use them to ensure proper functioning of the site and, if you agree, for purposes such as analytics, marketing, and targeting ads.