Interface SyncCryptoCallbacksInternal

The methods which crypto implementations should expose to the Sync api

interface SyncCryptoCallbacks {
    markAllTrackedUsersAsDirty(): Promise<void>;
    onCryptoEvent(room: Room, event: MatrixEvent): Promise<void>;
    onSyncCompleted(syncState: OnSyncCompletedData): void;
    preprocessToDeviceMessages(
        events: IToDeviceEvent[],
    ): Promise<IToDeviceEvent[]>;
    processDeviceLists(deviceLists: IDeviceLists): Promise<void>;
    processKeyCounts(
        oneTimeKeysCounts?: Record<string, number>,
        unusedFallbackKeys?: string[],
    ): Promise<void>;
}

Hierarchy (View Summary)

Methods

  • Mark all tracked user's device lists as dirty.

    This method will cause additional /keys/query requests on the server, so should be used only when the client has desynced tracking device list deltas from the server. In MSC4186: Simplified Sliding Sync, this can happen when the server expires the connection.

    Returns Promise<void>

  • Called by the /sync loop whenever an m.room.encryption event is received.

    This is called before RoomStateEvents are emitted for any of the events in the /sync response (even if the other events technically happened first). This works around a problem if the client uses a RoomStateEvent (typically a membership event) as a trigger to send a message in a new room (or one where encryption has been newly enabled): that would otherwise leave the crypto layer confused because it expects crypto to be set up, but it has not yet been.

    Parameters

    • room: Room

      in which the event was received

    • event: MatrixEvent

      encryption event to be processed

    Returns Promise<void>

  • Called by the /sync loop when one time key counts and unused fallback key details are received.

    Parameters

    • OptionaloneTimeKeysCounts: Record<string, number>

      the received one time key counts

    • OptionalunusedFallbackKeys: string[]

      the received unused fallback keys

    Returns Promise<void>