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.
Implements
Section titled “Implements”CryptoStore
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new IndexedDBCryptoStore(
indexedDB,dbName):IndexedDBCryptoStore
Defined in: src/crypto/store/indexeddb-crypto-store.ts:116
Create a new IndexedDBCryptoStore
Parameters
Section titled “Parameters”indexedDB
Section titled “indexedDB”IDBFactory
global indexedDB instance
dbName
Section titled “dbName”string
name of db to connect to
Returns
Section titled “Returns”IndexedDBCryptoStore
Properties
Section titled “Properties”STORE_ACCOUNT
Section titled “STORE_ACCOUNT”
staticSTORE_ACCOUNT:string="account"
Defined in: src/crypto/store/indexeddb-crypto-store.ts:47
STORE_BACKUP
Section titled “STORE_BACKUP”
staticSTORE_BACKUP:string="sessions_needing_backup"
Defined in: src/crypto/store/indexeddb-crypto-store.ts:55
STORE_DEVICE_DATA
Section titled “STORE_DEVICE_DATA”
staticSTORE_DEVICE_DATA:string="device_data"
Defined in: src/crypto/store/indexeddb-crypto-store.ts:53
STORE_INBOUND_GROUP_SESSIONS
Section titled “STORE_INBOUND_GROUP_SESSIONS”
staticSTORE_INBOUND_GROUP_SESSIONS:string="inbound_group_sessions"
Defined in: src/crypto/store/indexeddb-crypto-store.ts:49
STORE_INBOUND_GROUP_SESSIONS_WITHHELD
Section titled “STORE_INBOUND_GROUP_SESSIONS_WITHHELD”
staticSTORE_INBOUND_GROUP_SESSIONS_WITHHELD:string="inbound_group_sessions_withheld"
Defined in: src/crypto/store/indexeddb-crypto-store.ts:50
STORE_PARKED_SHARED_HISTORY
Section titled “STORE_PARKED_SHARED_HISTORY”
staticSTORE_PARKED_SHARED_HISTORY:string="parked_shared_history"
Defined in: src/crypto/store/indexeddb-crypto-store.ts:52
STORE_ROOMS
Section titled “STORE_ROOMS”
staticSTORE_ROOMS:string="rooms"
Defined in: src/crypto/store/indexeddb-crypto-store.ts:54
STORE_SESSIONS
Section titled “STORE_SESSIONS”
staticSTORE_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”
staticSTORE_SHARED_HISTORY_INBOUND_GROUP_SESSIONS:string="shared_history_inbound_group_sessions"
Defined in: src/crypto/store/indexeddb-crypto-store.ts:51
Methods
Section titled “Methods”countEndToEndSessions()
Section titled “countEndToEndSessions()”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
Parameters
Section titled “Parameters”IDBTransaction
An active transaction. See doTxn().
(count) => void
Called with the count of sessions
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”CryptoStore.countEndToEndSessions
deleteAllData()
Section titled “deleteAllData()”deleteAllData():
Promise<void>
Defined in: src/crypto/store/indexeddb-crypto-store.ts:229
Delete all data from this store.
Returns
Section titled “Returns”Promise<void>
resolves when the store has been cleared.
Implementation of
Section titled “Implementation of”CryptoStore.deleteAllData
doTxn()
Section titled “doTxn()”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.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”Mode
‘readwrite’ if you need to call setter functions with this transaction. Otherwise, ‘readonly’.
stores
Section titled “stores”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
Returns
Section titled “Returns”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.
Implementation of
Section titled “Implementation of”CryptoStore.doTxn
getAccount()
Section titled “getAccount()”getAccount(
txn,func):void
Defined in: src/crypto/store/indexeddb-crypto-store.ts:291
Parameters
Section titled “Parameters”IDBTransaction
(accountPickle) => void
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”CryptoStore.getAccount
getCrossSigningKeys()
Section titled “getCrossSigningKeys()”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).
Parameters
Section titled “Parameters”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
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”CryptoStore.getCrossSigningKeys
getEndToEndInboundGroupSession()
Section titled “getEndToEndInboundGroupSession()”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
Parameters
Section titled “Parameters”senderCurve25519Key
Section titled “senderCurve25519Key”string
The sender’s curve 25519 key
sessionId
Section titled “sessionId”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.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”CryptoStore.getEndToEndInboundGroupSession
getEndToEndRooms()
Section titled “getEndToEndRooms()”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
Parameters
Section titled “Parameters”IDBTransaction
An active transaction. See doTxn().
(rooms) => void
Function called with the end-to-end encrypted rooms
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”CryptoStore.getEndToEndRooms
getEndToEndSession()
Section titled “getEndToEndSession()”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.
Parameters
Section titled “Parameters”deviceKey
Section titled “deviceKey”string
The public key of the other device.
sessionId
Section titled “sessionId”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.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”CryptoStore.getEndToEndSession
getEndToEndSessions()
Section titled “getEndToEndSessions()”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.
Parameters
Section titled “Parameters”deviceKey
Section titled “deviceKey”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.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”CryptoStore.getEndToEndSessions
getSecretStorePrivateKey()
Section titled “getSecretStorePrivateKey()”getSecretStorePrivateKey<
K>(txn,func,type):void
Defined in: src/crypto/store/indexeddb-crypto-store.ts:326
Type Parameters
Section titled “Type Parameters”K extends "m.megolm_backup.v1"
Parameters
Section titled “Parameters”IDBTransaction
An active transaction. See doTxn().
(key) => void
Called with the private key
K
A key type
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”CryptoStore.getSecretStorePrivateKey
markSessionsNeedingBackup()
Section titled “markSessionsNeedingBackup()”markSessionsNeedingBackup(
sessions,txn?):Promise<void>
Defined in: src/crypto/store/indexeddb-crypto-store.ts:526
Mark sessions as needing to be backed up.
Parameters
Section titled “Parameters”sessions
Section titled “sessions”ISession[]
The sessions that need to be backed up.
IDBTransaction
An active transaction. See doTxn(). (optional)
Returns
Section titled “Returns”Promise<void>
resolves when the sessions are marked
Implementation of
Section titled “Implementation of”CryptoStore.markSessionsNeedingBackup
startup()
Section titled “startup()”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.
Returns
Section titled “Returns”Promise<CryptoStore>
resolves to either an IndexedDBCryptoStoreBackend.Backend, or a MemoryCryptoStore
Implementation of
Section titled “Implementation of”CryptoStore.startup
storeAccount()
Section titled “storeAccount()”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().
Parameters
Section titled “Parameters”IDBTransaction
An active transaction. See doTxn().
accountPickle
Section titled “accountPickle”string
The new account pickle to store.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”CryptoStore.storeAccount
storeEndToEndInboundGroupSession()
Section titled “storeEndToEndInboundGroupSession()”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.
Parameters
Section titled “Parameters”senderCurve25519Key
Section titled “senderCurve25519Key”string
The sender’s curve 25519 key
sessionId
Section titled “sessionId”string
The ID of the session
sessionData
Section titled “sessionData”InboundGroupSessionData
The session data structure
IDBTransaction
An active transaction. See doTxn().
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”CryptoStore.storeEndToEndInboundGroupSession
storeEndToEndSession()
Section titled “storeEndToEndSession()”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
Parameters
Section titled “Parameters”deviceKey
Section titled “deviceKey”string
The public key of the other device.
sessionId
Section titled “sessionId”string
The ID for this end-to-end session.
sessionInfo
Section titled “sessionInfo”ISessionInfo
Session information object
IDBTransaction
An active transaction. See doTxn().
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”CryptoStore.storeEndToEndSession
storeSecretStorePrivateKey()
Section titled “storeSecretStorePrivateKey()”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
Type Parameters
Section titled “Type Parameters”K extends "m.megolm_backup.v1"
Parameters
Section titled “Parameters”IDBTransaction
An active transaction. See doTxn().
K
The type of cross-signing private key to store
SecretStorePrivateKeys[K]
keys object as getCrossSigningKeys()
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”CryptoStore.storeSecretStorePrivateKey
exists()
Section titled “exists()”
staticexists(indexedDB,dbName):Promise<boolean>
Defined in: src/crypto/store/indexeddb-crypto-store.ts:57
Parameters
Section titled “Parameters”indexedDB
Section titled “indexedDB”IDBFactory
dbName
Section titled “dbName”string
Returns
Section titled “Returns”Promise<boolean>
existsAndIsNotMigrated()
Section titled “existsAndIsNotMigrated()”
staticexistsAndIsNotMigrated(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.
Parameters
Section titled “Parameters”indexedDb
Section titled “indexedDb”IDBFactory
dbName
Section titled “dbName”string
Returns
Section titled “Returns”Promise<boolean>