Class IndexedDBCryptoStore

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

Implements

Hierarchy

  • IndexedDBCryptoStore

Implements

Constructors

Properties

backend?: CryptoStore
backendPromise?: Promise<CryptoStore>
dbName: string

name of db to connect to

indexedDB: IDBFactory

global indexedDB instance

STORE_ACCOUNT: string = 'account'
STORE_BACKUP: string = 'sessions_needing_backup'
STORE_DEVICE_DATA: string = 'device_data'
STORE_INBOUND_GROUP_SESSIONS: string = 'inbound_group_sessions'
STORE_INBOUND_GROUP_SESSIONS_WITHHELD: string = 'inbound_group_sessions_withheld'
STORE_PARKED_SHARED_HISTORY: string = 'parked_shared_history'
STORE_ROOMS: string = 'rooms'
STORE_SESSIONS: string = 'sessions'
STORE_SHARED_HISTORY_INBOUND_GROUP_SESSIONS: string = 'shared_history_inbound_group_sessions'

Methods

  • Adds an end-to-end inbound group session to the store. If there already exists an inbound group session with the same senderCurve25519Key and sessionID, the session will not be added.

    Parameters

    • senderCurve25519Key: string

      The sender's curve 25519 key

    • sessionId: string

      The ID of the session

    • sessionData: InboundGroupSessionData

      The session data structure

    • txn: IDBTransaction

      An active transaction. See doTxn().

    Returns void

  • Add a shared-history group session for a room.

    Parameters

    • roomId: string

      The room that the key belongs to

    • senderKey: string

      The sender's curve 25519 key

    • sessionId: string

      The ID of the session

    • Optional txn: IDBTransaction

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

    Returns void

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

    Parameters

    • txn: IDBTransaction

      An active transaction. See doTxn().

    • func: ((count: number) => void)

      Called with the count of sessions

        • (count: number): void
        • Parameters

          • count: number

          Returns void

    Returns void

  • 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.

    Returns

    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.

    Type Parameters

    • T

    Parameters

    • mode: Mode

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

    • stores: Iterable<string>

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

    • func: ((txn: IDBTransaction) => T)

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

        • (txn: IDBTransaction): T
        • Parameters

          • txn: IDBTransaction

          Returns T

    • Optional log: PrefixedLogger

      A possibly customised log

    Returns Promise<T>

  • Parameters

    • txn: IDBTransaction
    • func: ((accountPickle: null | string) => void)
        • (accountPickle: null | string): void
        • Parameters

          • accountPickle: null | string

          Returns void

    Returns void

  • Fetches all inbound group sessions in the store

    Parameters

    • txn: IDBTransaction

      An active transaction. See doTxn().

    • func: ((session: null | ISession) => void)

      Called once for each group session in the store with an object having keys {senderKey, sessionId, sessionData}, then once with null to indicate the end of the list.

        • (session: null | ISession): void
        • Parameters

          Returns void

    Returns void

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

    Parameters

    • txn: IDBTransaction

      An active transaction. See doTxn().

    • func: ((keys: null | Record<string, ICrossSigningKey>) => 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 void

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

    Parameters

    • deviceKey: string

      The public key of the other device.

    • sessionId: string

      The ID of the session to retrieve

    • txn: IDBTransaction

      An active transaction. See doTxn().

    • func: ((session: null | ISessionInfo) => 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 void

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

    Parameters

    • deviceKey: string

      The public key of the other device.

    • txn: IDBTransaction

      An active transaction. See doTxn().

    • func: ((sessions: {
          [sessionId: string]: ISessionInfo;
      }) => 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.

        • (sessions: {
              [sessionId: string]: ISessionInfo;
          }): void
        • Parameters

          Returns void

    Returns void

  • Get the shared-history group session for a room.

    Returns

    Resolves to an array of [senderKey, sessionId]

    Parameters

    • roomId: string

      The room that the key belongs to

    • Optional txn: IDBTransaction

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

    Returns Promise<[senderKey: string, sessionId: string][]>

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

    Parameters

    • txn: IDBTransaction

      An active transaction. See doTxn().

    • accountPickle: string

      The new account pickle to store.

    Returns void

  • Store the state of all tracked devices This contains devices for each user, a tracking state for each user and a sync token matching the point in time the snapshot represents. These all need to be written out in full each time such that the snapshot is always consistent, so they are stored in one object.

    Parameters

    • deviceData: IDeviceData
    • txn: IDBTransaction

      An active transaction. See doTxn().

    Returns void

  • 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

    • senderCurve25519Key: string

      The sender's curve 25519 key

    • sessionId: string

      The ID of the session

    • sessionData: InboundGroupSessionData

      The session data structure

    • txn: IDBTransaction

      An active transaction. See doTxn().

    Returns void

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

    Parameters

    • deviceKey: string

      The public key of the other device.

    • sessionId: string

      The ID for this end-to-end session.

    • sessionInfo: ISessionInfo

      Session information object

    • txn: IDBTransaction

      An active transaction. See doTxn().

    Returns void

Generated using TypeDoc