KvdbApi
Class representing instance of KVDB API
Methods
createKvdb
Creates a new KVDB in the given Context and returns its ID. A container key is generated client-side and distributed to each listed user encrypted with ECIES on that user's public key; privateMeta is encrypted client-side before upload, while publicMeta is stored UNENCRYPTED on the Bridge server - never put secrets in it. First step of the KVDB workflow - write entries to the returned database with setEntry and adjust membership later with updateKvdb.
Params
contextId
string
Context to create the KVDB in, from Context.contextId returned by Connection.listContexts
users
UserWithPubKey[]
members allowed to read and write entries; build the userId/pubKey pairs from Connection.listContextUsers
managers
UserWithPubKey[]
members who can additionally update and delete the KVDB; same UserWithPubKey format as users
publicMeta
Uint8Array
metadata stored UNENCRYPTED on the server - no secrets here
privateMeta
Uint8Array
metadata encrypted client-side; readable only by KVDB members, the server sees ciphertext
policies
ContainerPolicy
access policy overrides for the new KVDB; omit to inherit the Context defaults
Returns
Promise<string> ·
ID of the created KVDB - pass it to setEntry, getEntry, listEntries and updateKvdb
updateKvdb
Replaces an existing KVDB's membership, metadata and policies. Re-runs the container-key distribution client-side: the key (a fresh one when forceGenerateNewKey is set) is encrypted per-user with ECIES on each member's public key; privateMeta is encrypted client-side, publicMeta is stored unencrypted on the server. This is a full overwrite, not a patch - fetch the current state with getKvdb first and resend every field. Set forceGenerateNewKey when removing users so they cannot decrypt future entries.
Params
kvdbId
string
KVDB to update - value returned by createKvdb or found in Kvdb.kvdbId from listKvdbs
users
UserWithPubKey[]
complete new list of members with access to the KVDB; users left out lose access
managers
UserWithPubKey[]
complete new list of members with update/delete rights over the KVDB
publicMeta
Uint8Array
metadata stored UNENCRYPTED on the server - no secrets here
privateMeta
Uint8Array
metadata encrypted client-side; readable only by KVDB members, the server sees ciphertext
version
number
current KVDB version, found in Kvdb.version from getKvdb - protects against concurrent updates
force
boolean
true skips the version check and overwrites unconditionally (last write wins)
forceGenerateNewKey
boolean
when true, a fresh container key is generated by the WASM core and redistributed, so members removed by this update cannot decrypt entries written afterwards - set it whenever you revoke access
policies
ContainerPolicy
new access policy overrides; omit to keep the current policy
deleteKvdb
Permanently deletes a KVDB together with all its entries. Sends a delete request to the Bridge; this is a server-side removal with no client-side crypto involved and it cannot be undone. Restricted to KVDB managers (see the managers list of createKvdb / updateKvdb). To remove individual entries instead, use deleteEntry or deleteEntries.
Params
kvdbId
string
KVDB to delete - value returned by createKvdb or found in Kvdb.kvdbId from listKvdbs
getKvdb
Fetches a single KVDB with its decrypted metadata, membership and entry count. Downloads the KVDB record from the Bridge and decrypts privateMeta locally with the member's container key; non-members cannot decrypt it. Use it to read the current version before updateKvdb, or to display database details to a member.
Params
kvdbId
string
KVDB to fetch - value returned by createKvdb or found in Kvdb.kvdbId from listKvdbs
Returns
Promise<Kvdb> ·
full KVDB data; pass Kvdb.version to updateKvdb and Kvdb.kvdbId to the entry methods
listKvdbs
Lists the KVDBs in a Context that the connected user is a member of. Fetches one page of KVDB records from the Bridge and decrypts each privateMeta locally with the member's keys; the server only ever serves ciphertext. Typically the first KVDB call on a connection - pick a kvdbId from the result for getEntry, setEntry or listEntries.
Params
contextId
string
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
Returns
Promise<PagingList<Kvdb>> ·
one page of KVDBs plus totalAvailable; use Kvdb.kvdbId in subsequent calls
getEntry
Fetches one entry by its key and returns it decrypted. The server looks the entry up by its plaintext key name; the value and privateMeta arrive as ciphertext and are decrypted locally with the KVDB's container key, and the author's secp256k1 ECDSA signature is verified. Use hasEntry to probe for existence without fetching, or listEntries to read many entries at once.
Params
kvdbId
string
KVDB holding the entry - value returned by createKvdb or found in Kvdb.kvdbId from listKvdbs
key
string
plaintext key name the entry was written under by setEntry; also discoverable via listEntriesKeys
Returns
Promise<KvdbEntry> ·
decrypted data, metadata, authorPubKey and the version to pass back to setEntry when updating
hasEntry
Checks whether an entry with the given key exists in a KVDB. A pure server-side lookup on the plaintext key name - no entry data is downloaded and no decryption happens. Cheaper than getEntry when only existence matters, e.g. before deciding between inserting and updating with setEntry.
Params
kvdbId
string
KVDB to probe - value returned by createKvdb or found in Kvdb.kvdbId from listKvdbs
key
string
plaintext key name to test, as written by setEntry
Returns
Promise<boolean> ·
true if an entry with that key exists - follow up with getEntry to read it
listEntriesKeys
Lists the key names of the entries stored in a KVDB. Key names live in plaintext on the server (that is what makes this listing possible without decryption) - only the keys travel back, no entry values are downloaded. Use it to enumerate a large database cheaply and fetch selected values with getEntry; use listEntries to get full entries directly.
Params
kvdbId
string
KVDB to enumerate - value returned by createKvdb or found in Kvdb.kvdbId from listKvdbs
pagingQuery
PagingQuery
pagination and sorting; start with { skip: 0, limit: 100, sortOrder: "desc" } and page using skip
Returns
Promise<PagingList<string>> ·
one page of plaintext key names plus totalAvailable; feed each key to getEntry or deleteEntry
listEntries
Lists full entries of a KVDB, decrypted for the member. Fetches one page of ciphertext entries from the Bridge and decrypts each value and privateMeta locally with the KVDB's container key, verifying the authors' signatures; per-entry problems are reported in KvdbEntry.statusCode rather than rejecting the whole page. Use it to read many values at once; for key names only, the lighter listEntriesKeys avoids downloading the values.
Params
kvdbId
string
KVDB to read - value returned by createKvdb or found in Kvdb.kvdbId from listKvdbs
pagingQuery
PagingQuery
pagination and sorting; start with { skip: 0, limit: 100, sortOrder: "desc" } and page using skip
Returns
Promise<PagingList<KvdbEntry>> ·
one page of decrypted entries plus totalAvailable; each entry's info.key and version feed setEntry updates
setEntry
Writes an entry under the given key - inserting it, or updating it when a version is supplied. The value (data) and privateMeta are encrypted client-side with the KVDB's container key and signed with the author's secp256k1 ECDSA key; publicMeta is signed but NOT encrypted, and the KEY NAME itself is stored in PLAINTEXT on the server for indexing - never put secrets in the key name or publicMeta. To update an existing entry, pass the current KvdbEntry.version from getEntry as version; readers retrieve the value with getEntry or listEntries.
Params
kvdbId
string
target KVDB - value returned by createKvdb or found in Kvdb.kvdbId from listKvdbs
key
string
name to store the entry under; PLAINTEXT on the server and visible in listEntriesKeys - no secrets here
publicMeta
Uint8Array
entry metadata signed but stored UNENCRYPTED on the server - no secrets here
privateMeta
Uint8Array
entry metadata encrypted client-side; readable only by KVDB members, the server sees ciphertext
data
Uint8Array
entry value, encrypted client-side with the KVDB's container key before upload
version
number
current entry version from KvdbEntry.version returned by getEntry - required when overwriting an existing entry; omit when inserting a new one
deleteEntry
Permanently deletes a single entry from a KVDB. A server-side removal addressed by the plaintext key name - no decryption is involved and the operation cannot be undone. For removing several entries in one round-trip use deleteEntries.
Params
kvdbId
string
KVDB holding the entry - value returned by createKvdb or found in Kvdb.kvdbId from listKvdbs
key
string
plaintext key name of the entry, as written by setEntry or listed by listEntriesKeys
deleteEntries
Deletes several entries of one KVDB in a single request and reports the outcome per key. A server-side batch removal addressed by plaintext key names - no decryption is involved; keys that fail (e.g. nonexistent) do not abort the rest of the batch. Prefer it over looping deleteEntry when clearing many keys, e.g. after listEntriesKeys.
Params
kvdbId
string
KVDB to delete from - value returned by createKvdb or found in Kvdb.kvdbId from listKvdbs
keys
string[]
plaintext key names to remove, as written by setEntry or listed by listEntriesKeys
Returns
Promise<DeleteEntriesResult> ·
map from each key to true/false deletion success - inspect it to retry or report failed keys
subscribeFor
Subscribes this connection to KVDB events matching the given subscription queries. Registers the subscriptions on the Bridge over the connection's event channel; matching events (entry created/updated/deleted, KVDB updated, …) are then pushed by the server and surface through EventQueue.waitEvent. Required order: buildSubscriptionQuery or buildSubscriptionQueryForSelectedEntry (one query per scope) → subscribeFor(queries) → consume events from the EventQueue → unsubscribeFrom when no longer needed.
Params
subscriptionQueries
string[]
query strings produced by buildSubscriptionQuery or buildSubscriptionQueryForSelectedEntry; hand-written strings are not supported
Returns
Promise<string[]> ·
subscription IDs, index-aligned with subscriptionQueries - keep them to unsubscribeFrom later
unsubscribeFrom
Cancels KVDB 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 KVDB events (e.g. "entry created in KVDB 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
KvdbEventType
which KVDB event class to listen for (KVDB create/update/delete, entry create/update/delete, …)
selectorType
KvdbEventSelectorType
what selectorId refers to (a Context, a KVDB or a single entry), narrowing the event scope
selectorId
string
ID of the selected scope - e.g. a KVDB ID returned by createKvdb or a Context ID from Connection.listContexts
Returns
Promise<string> ·
query string consumed by subscribeFor
buildSubscriptionQueryForSelectedEntry
Builds a subscription-query string scoped to a single KVDB entry, identified by its key. The query is assembled locally by the WASM core - the entry key is usable as a selector because key names are stored in plaintext on the server; nothing is sent until subscribeFor activates the query. Use it to watch one specific entry (e.g. a shared settings record) instead of every entry of the database via buildSubscriptionQuery.
Params
eventType
KvdbEventType
which KVDB event class to listen for - entry-level types such as entry update/delete are the useful ones here
kvdbId
string
KVDB holding the entry - value returned by createKvdb or found in Kvdb.kvdbId from listKvdbs
kvdbEntryKey
string
plaintext entry key name chosen by the application when calling setEntry (stored unencrypted server-side) - also found in listEntriesKeys results
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.