UNPKG

matrix-js-sdk

Version:
89 lines 4.04 kB
import { OlmMachine, HistoryVisibility as RustHistoryVisibility } from "@matrix-org/matrix-sdk-crypto-wasm"; import { IContent, MatrixEvent } from "../models/event"; import { Room } from "../models/room"; import { KeyClaimManager } from "./KeyClaimManager"; import { RoomMember } from "../models/room-member"; import { HistoryVisibility } from "../@types/partials"; import { OutgoingRequestsManager } from "./OutgoingRequestsManager"; /** * RoomEncryptor: responsible for encrypting messages to a given room * * @internal */ export declare class RoomEncryptor { private readonly olmMachine; private readonly keyClaimManager; private readonly outgoingRequestManager; private readonly room; private encryptionSettings; private readonly prefixedLogger; /** whether the room members have been loaded and tracked for the first time */ private lazyLoadedMembersResolved; /** * Ensures that there is only one encryption operation at a time for that room. * * An encryption operation is either a {@link prepareForEncryption} or an {@link encryptEvent} call. */ private currentEncryptionPromise; /** * @param olmMachine - The rust-sdk's OlmMachine * @param keyClaimManager - Our KeyClaimManager, which manages the queue of one-time-key claim requests * @param outgoingRequestManager - The OutgoingRequestManager, which manages the queue of outgoing requests. * @param room - The room we want to encrypt for * @param encryptionSettings - body of the m.room.encryption event currently in force in this room */ constructor(olmMachine: OlmMachine, keyClaimManager: KeyClaimManager, outgoingRequestManager: OutgoingRequestsManager, room: Room, encryptionSettings: IContent); /** * Handle a new `m.room.encryption` event in this room * * @param config - The content of the encryption event */ onCryptoEvent(config: IContent): void; /** * Handle a new `m.room.member` event in this room * * @param member - new membership state */ onRoomMembership(member: RoomMember): void; /** * Prepare to encrypt events in this room. * * This ensures that we have a megolm session ready to use and that we have shared its key with all the devices * in the room. * * @param globalBlacklistUnverifiedDevices - When `true`, it will not send encrypted messages to unverified devices */ prepareForEncryption(globalBlacklistUnverifiedDevices: boolean): Promise<void>; /** * Encrypt an event for this room, or prepare for encryption. * * This will ensure that we have a megolm session for this room, share it with the devices in the room, and * then, if an event is provided, encrypt it using the session. * * @param event - Event to be encrypted, or null if only preparing for encryption (in which case we will pre-share the room key). * @param globalBlacklistUnverifiedDevices - When `true`, it will not send encrypted messages to unverified devices */ encryptEvent(event: MatrixEvent | null, globalBlacklistUnverifiedDevices: boolean): Promise<void>; /** * Prepare to encrypt events in this room. * * This ensures that we have a megolm session ready to use and that we have shared its key with all the devices * in the room. * * @param logger - a place to write diagnostics to * @param globalBlacklistUnverifiedDevices - When `true`, it will not send encrypted messages to unverified devices */ private ensureEncryptionSession; /** * Discard any existing group session for this room */ forceDiscardSession(): Promise<void>; private encryptEventInner; } /** * Convert a HistoryVisibility to a RustHistoryVisibility * @param visibility - HistoryVisibility enum * @returns a RustHistoryVisibility enum */ export declare function toRustHistoryVisibility(visibility: HistoryVisibility): RustHistoryVisibility; //# sourceMappingURL=RoomEncryptor.d.ts.map