Skip to content

IndexedDBCryptoStore

Defined in: src/crypto/store/indexeddb-crypto-store.ts:46

An implementation of CryptoStore, which is normally backed by an indexeddb, but with fallback to MemoryCryptoStore.

  • CryptoStore

new IndexedDBCryptoStore(indexedDB, dbName): IndexedDBCryptoStore

Defined in: src/crypto/store/indexeddb-crypto-store.ts:116

Create a new IndexedDBCryptoStore

IDBFactory

global indexedDB instance

string

name of db to connect to

IndexedDBCryptoStore

static STORE_ACCOUNT: string = "account"

Defined in: src/crypto/store/indexeddb-crypto-store.ts:47


static STORE_BACKUP: string = "sessions_needing_backup"

Defined in: src/crypto/store/indexeddb-crypto-store.ts:55


static STORE_DEVICE_DATA: string = "device_data"

Defined in: src/crypto/store/indexeddb-crypto-store.ts:53


static STORE_INBOUND_GROUP_SESSIONS: string = "inbound_group_sessions"

Defined in: src/crypto/store/indexeddb-crypto-store.ts:49


static STORE_INBOUND_GROUP_SESSIONS_WITHHELD: string = "inbound_group_sessions_withheld"

Defined in: src/crypto/store/indexeddb-crypto-store.ts:50


static STORE_PARKED_SHARED_HISTORY: string = "parked_shared_history"

Defined in: src/crypto/store/indexeddb-crypto-store.ts:52


static STORE_ROOMS: string = "rooms"

Defined in: src/crypto/store/indexeddb-crypto-store.ts:54


static STORE_SESSIONS: string = "sessions"

Defined in: src/crypto/store/indexeddb-crypto-store.ts:48


STORE_SHARED_HISTORY_INBOUND_GROUP_SESSIONS

Section titled “STORE_SHARED_HISTORY_INBOUND_GROUP_SESSIONS”

static STORE_SHARED_HISTORY_INBOUND_GROUP_SESSIONS: string = "shared_history_inbound_group_sessions"

Defined in: src/crypto/store/indexeddb-crypto-store.ts:51

countEndToEndSessions(txn, func): void

Defined in: src/crypto/store/indexeddb-crypto-store.ts:356

Returns the number of end-to-end sessions in the store

IDBTransaction

An active transaction. See doTxn().

(count) => void

Called with the count of sessions

void

CryptoStore.countEndToEndSessions


deleteAllData(): Promise<void>

Defined in: src/crypto/store/indexeddb-crypto-store.ts:229

Delete all data from this store.

Promise<void>

resolves when the store has been cleared.

CryptoStore.deleteAllData


doTxn<T>(mode, stores, func, log?): Promise<T>

Defined in: src/crypto/store/indexeddb-crypto-store.ts:552

Perform a transaction on the crypto store. Any store methods that require a transaction (txn) object to be passed in may only be called within a callback of either this function or one of the store functions operating on the same transaction.

T

Mode

‘readwrite’ if you need to call setter functions with this transaction. Otherwise, ‘readonly’.

Iterable<string>

List IndexedDBCryptoStore.STORE_* options representing all types of object that will be accessed or written to with this transaction.

(txn) => T

Function called with the transaction object: an opaque object that should be passed to store functions.

Logger

A possibly customised log

Promise<T>

Promise that resolves with the result of the func when the transaction is complete. If the backend is async (ie. the indexeddb backend) any of the callback functions throwing an exception will cause this promise to reject with that exception. On synchronous backends, the exception will propagate to the caller of the getFoo method.

CryptoStore.doTxn


getAccount(txn, func): void

Defined in: src/crypto/store/indexeddb-crypto-store.ts:291

IDBTransaction

(accountPickle) => void

void

CryptoStore.getAccount


getCrossSigningKeys(txn, func): void

Defined in: src/crypto/store/indexeddb-crypto-store.ts:314

Get the public part of the cross-signing keys (eg. self-signing key, user signing key).

IDBTransaction

An active transaction. See doTxn().

(keys) => void

Called with the account keys object: { key_type: base64 encoded seed } where key type = user_signing_key_seed or self_signing_key_seed

void

CryptoStore.getCrossSigningKeys


getEndToEndInboundGroupSession(senderCurve25519Key, sessionId, txn, func): void

Defined in: src/crypto/store/indexeddb-crypto-store.ts:460

Retrieve the end-to-end inbound group session for a given server key and session ID

string

The sender’s curve 25519 key

string

The ID of the session

IDBTransaction

An active transaction. See doTxn().

(groupSession, groupSessionWithheld) => void

Called with A map from sessionId to Base64 end-to-end session.

void

CryptoStore.getEndToEndInboundGroupSession


getEndToEndRooms(txn, func): void

Defined in: src/crypto/store/indexeddb-crypto-store.ts:516

Get an object of roomId->roomInfo for all e2e rooms in the store

IDBTransaction

An active transaction. See doTxn().

(rooms) => void

Function called with the end-to-end encrypted rooms

void

CryptoStore.getEndToEndRooms


getEndToEndSession(deviceKey, sessionId, txn, func): void

Defined in: src/crypto/store/indexeddb-crypto-store.ts:372

Retrieve a specific end-to-end session between the logged-in user and another device.

string

The public key of the other device.

string

The ID of the session to retrieve

IDBTransaction

An active transaction. See doTxn().

(session) => void

Called with A map from sessionId to session information object with ‘session’ key being the Base64 end-to-end session and lastReceivedMessageTs being the timestamp in milliseconds at which the session last received a message.

void

CryptoStore.getEndToEndSession


getEndToEndSessions(deviceKey, txn, func): void

Defined in: src/crypto/store/indexeddb-crypto-store.ts:392

Retrieve the end-to-end sessions between the logged-in user and another device.

string

The public key of the other device.

IDBTransaction

An active transaction. See doTxn().

(sessions) => void

Called with A map from sessionId to session information object with ‘session’ key being the Base64 end-to-end session and lastReceivedMessageTs being the timestamp in milliseconds at which the session last received a message.

void

CryptoStore.getEndToEndSessions


getSecretStorePrivateKey<K>(txn, func, type): void

Defined in: src/crypto/store/indexeddb-crypto-store.ts:326

K extends "m.megolm_backup.v1"

IDBTransaction

An active transaction. See doTxn().

(key) => void

Called with the private key

K

A key type

void

CryptoStore.getSecretStorePrivateKey


markSessionsNeedingBackup(sessions, txn?): Promise<void>

Defined in: src/crypto/store/indexeddb-crypto-store.ts:526

Mark sessions as needing to be backed up.

ISession[]

The sessions that need to be backed up.

IDBTransaction

An active transaction. See doTxn(). (optional)

Promise<void>

resolves when the sessions are marked

CryptoStore.markSessionsNeedingBackup


startup(): Promise<CryptoStore>

Defined in: src/crypto/store/indexeddb-crypto-store.ts:141

Ensure the database exists and is up-to-date, or fall back to a local storage or in-memory store.

This must be called before the store can be used.

Promise<CryptoStore>

resolves to either an IndexedDBCryptoStoreBackend.Backend, or a MemoryCryptoStore

CryptoStore.startup


storeAccount(txn, accountPickle): void

Defined in: src/crypto/store/indexeddb-crypto-store.ts:302

Write the account pickle to the store. This requires an active transaction. See doTxn().

IDBTransaction

An active transaction. See doTxn().

string

The new account pickle to store.

void

CryptoStore.storeAccount


storeEndToEndInboundGroupSession(senderCurve25519Key, sessionId, sessionData, txn): void

Defined in: src/crypto/store/indexeddb-crypto-store.ts:478

Writes an end-to-end inbound group session to the store. If there already exists an inbound group session with the same senderCurve25519Key and sessionID, it will be overwritten.

string

The sender’s curve 25519 key

string

The ID of the session

InboundGroupSessionData

The session data structure

IDBTransaction

An active transaction. See doTxn().

void

CryptoStore.storeEndToEndInboundGroupSession


storeEndToEndSession(deviceKey, sessionId, sessionInfo, txn): void

Defined in: src/crypto/store/indexeddb-crypto-store.ts:407

Store a session between the logged-in user and another device

string

The public key of the other device.

string

The ID for this end-to-end session.

ISessionInfo

Session information object

IDBTransaction

An active transaction. See doTxn().

void

CryptoStore.storeEndToEndSession


storeSecretStorePrivateKey<K>(txn, type, key): void

Defined in: src/crypto/store/indexeddb-crypto-store.ts:341

Write the cross-signing private keys back to the store

K extends "m.megolm_backup.v1"

IDBTransaction

An active transaction. See doTxn().

K

The type of cross-signing private key to store

SecretStorePrivateKeys[K]

keys object as getCrossSigningKeys()

void

CryptoStore.storeSecretStorePrivateKey


static exists(indexedDB, dbName): Promise<boolean>

Defined in: src/crypto/store/indexeddb-crypto-store.ts:57

IDBFactory

string

Promise<boolean>


static existsAndIsNotMigrated(indexedDb, dbName): Promise<boolean>

Defined in: src/crypto/store/indexeddb-crypto-store.ts:65

Utility to check if a legacy crypto store exists and has not been migrated. Returns true if the store exists and has not been migrated, false otherwise.

IDBFactory

string

Promise<boolean>