Interface CryptoBackend

Common interface for the crypto implementations

Hierarchy

Implemented by

Properties

globalBlacklistUnverifiedDevices: boolean

Global override for whether the client should ever send encrypted messages to unverified devices. This provides the default for rooms which do not specify a value.

If true, all unverified devices will be blacklisted by default

globalErrorOnUnknownDevices: boolean

Whether sendMessage in a room with unknown and unverified devices should throw an error and not send the message. This has 'Global' for symmetry with setGlobalBlacklistUnverifiedDevices but there is currently no room-level equivalent for this setting.

Remarks

this is here, rather than in CryptoApi, because I don't think we're going to support it in the rust crypto implementation.

Methods

  • Encrypt an event according to the configuration of the room.

    Returns

    Promise which resolves when the event has been encrypted, or null if nothing was needed

    Parameters

    Returns Promise<void>

  • Discard any existing megolm session for the given room.

    This will ensure that a new session is created on the next call to prepareToEncrypt, or the next time a message is sent.

    This should not normally be necessary: it should only be used as a debugging tool if there has been a problem with encryption.

    Parameters

    • roomId: string

      the room to discard sessions for

    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>

  • Perform any background tasks that can be done before a message is ready to send, in order to speed up sending of the message.

    Parameters

    • room: Room

      the room the event is in

    Returns void

  • Called by the /sync loop whenever there are incoming to-device messages.

    The implementation may preprocess the received messages (eg, decrypt them) and return an updated list of messages for dispatch to the rest of the system.

    Note that, unlike ToDeviceEvent events, this is called on the raw to-device messages, rather than the results of any decryption attempts.

    Returns

    A list of preprocessed to-device messages.

    Parameters

    • oneTimeKeysCounts: Map<string, number>

      the received one time key counts

    Returns Promise<void>

  • Called by the /sync loop whenever there are incoming to-device messages.

    The implementation may preprocess the received messages (eg, decrypt them) and return an updated list of messages for dispatch to the rest of the system.

    Note that, unlike ToDeviceEvent events, this is called on the raw to-device messages, rather than the results of any decryption attempts.

    Returns

    A list of preprocessed to-device messages.

    Parameters

    • unusedFallbackKeys: Set<string>

      the received unused fallback keys

    Returns Promise<void>

  • Checks if the user has previously published cross-signing keys

    This means downloading the devicelist for the user and checking if the list includes the cross-signing pseudo-device.

    Returns

    true if the user has previously published cross-signing keys

    Returns Promise<boolean>

Generated using TypeDoc