Typed Event Emitter class which can act as a Base Model for all our model and communication events. This makes it much easier for us to distinguish between events, as we now need to properly type this, so that our events are not stringly-based and prone to silly typos.

Hierarchy

Constructors

Properties

crossSigningInfo: {
    [userId: string]: ICrossSigningInfo;
} = {}

Type declaration

cryptoStore: CryptoStore
deviceTrackingStatus: {
    [userId: string]: TrackingStatus;
} = {}

Type declaration

devices: {
    [userId: string]: {
        [deviceId: string]: IDevice;
    };
} = {}

Type declaration

  • [userId: string]: {
        [deviceId: string]: IDevice;
    }
dirty: boolean = false
hasFetched: null | boolean = null
keyDownloadChunkSize: number = 250
keyDownloadsInProgressByUser: Map<string, Promise<void>> = ...
resolveSavePromise: null | ((saved: boolean) => void) = null
savePromise: null | Promise<boolean> = null
savePromiseTime: null | number = null
saveTimer: null | Timeout = null
syncToken: null | string = null
userByIdentityKey: Record<string, string> = {}

Methods

  • Fire off download update requests for the given users, and update the device list tracking status for them, and the keyDownloadsInProgressByUser map for them.

    Returns

    resolves when all the users listed have been updated. rejects if there was a problem updating any of the users.

    Parameters

    • users: string[]

      list of userIds

    Returns Promise<void>

  • Ensures up to date keys for a list of users are stored in the session store, downloading and storing them if they're not (or if forceDownload is true).

    Returns

    A promise which resolves to a map userId->deviceId->DeviceInfo.

    Parameters

    • userIds: string[]

      The users to fetch.

    • forceDownload: boolean

      Always download the keys even if cached.

    Returns Promise<DeviceInfoMap>

  • Find a device by curve25519 identity key

    Parameters

    • algorithm: string

      encryption algorithm

    • senderKey: string

      curve25519 key to match

    Returns null | DeviceInfo

  • Returns a list of all user IDs the DeviceList knows about

    Returns

    All known user IDs

    Returns string[]

  • Get the stored device data for a user, in raw object form

    Returns

    deviceId->{object} devices, or undefined if there is no data for this user.

    Parameters

    • userId: string

      the user to get data for

    Returns Record<string, IDevice>

  • Get the stored keys for a single device

    Returns

    device, or undefined if we don't know about this device

    Parameters

    • userId: string
    • deviceId: string

    Returns undefined | DeviceInfo

  • Get the stored device keys for a user id

    Returns

    list of devices, or null if we haven't managed to get a list of devices for this user yet.

    Parameters

    • userId: string

      the user to list keys for.

    Returns null | DeviceInfo[]

  • Gets the sync token last set with setSyncToken

    Returns

    The sync token

    Returns null | string

  • Get a user ID by one of their device's curve25519 identity key

    Returns

    user ID

    Parameters

    • algorithm: string

      encryption algorithm

    • senderKey: string

      curve25519 key to match

    Returns null | string

  • Mark the cached device list for the given user outdated.

    If we are not tracking this user's devices, we'll do nothing. Otherwise we flag the user as needing an update.

    This doesn't actually set off an update, so that several users can be batched together. Call refreshOutdatedDeviceLists() for that.

    Parameters

    • userId: string

    Returns void

  • If we have users who have outdated device lists, start key downloads for them

    Returns

    which completes when the download completes; normally there is no need to wait for this (it's mostly for the unit tests).

    Returns Promise<void>

  • Save the device tracking state to storage, if any changes are pending other than updating the sync token

    The actual save will be delayed by a short amount of time to aggregate multiple writes to the database.

    Returns

    true if the data was saved, false if it was not (eg. because no changes were pending). The promise will only resolve once the data is saved, so may take some time to resolve.

    Parameters

    • delay: number = 500

      Time in ms before which the save actually happens. By default, the save is delayed for a short period in order to batch multiple writes, but this behaviour can be disabled by passing 0.

    Returns Promise<boolean>

  • Set the stored device data for a user, in raw object form Used only by internal class DeviceListUpdateSerialiser

    Parameters

    • userId: string

      the user to get data for

    • devices: Record<string, IDevice>

      deviceId->{object} the new devices

    Returns void

  • Sets the sync token that the app will pass as the 'since' to the /sync endpoint next time it syncs. The sync token must always be set after any changes made as a result of data in that sync since setting the sync token to a newer one will mean those changed will not be synced from the server if a new client starts up with that data.

    Parameters

    • st: null | string

      The sync token

    Returns void

  • flag the given user for device-list tracking, if they are not already.

    This will mean that a subsequent call to refreshOutdatedDeviceLists() will download the device list for the user, and that subsequent calls to invalidateUserDeviceList will trigger more updates.

    Parameters

    • userId: string

    Returns void

  • Set all users we're currently tracking to untracked

    This will flag each user whose devices we are tracking as in need of an update.

    Returns void

  • Mark the given user as no longer being tracked for device-list updates.

    This won't affect any in-progress downloads, which will still go on to complete; it will just mean that we don't think that we have an up-to-date list for future calls to downloadKeys.

    Parameters

    • userId: string

    Returns void

  • Replaces the list of devices for a user with the given device list

    Parameters

    • userId: string

      The user ID

    • devices: Record<string, IDevice>

      New device info for user

    Returns void

Generated using TypeDoc