2026-09-13 14:14:38 -04:00
|
|
|
import { WidgetApi } from "matrix-widget-api";
|
|
|
|
|
import { MatrixEvent } from "./models/event";
|
|
|
|
|
import { ISendEventResponse } from "./@types/requests";
|
|
|
|
|
import { MatrixClient, IMatrixClientCreateOpts, IStartClientOpts, SendToDeviceContentMap } from "./client";
|
|
|
|
|
import { SyncState } from "./sync";
|
|
|
|
|
import { Room } from "./models/room";
|
|
|
|
|
import { ToDeviceBatch } from "./models/ToDeviceMessage";
|
|
|
|
|
import { DeviceInfo } from "./crypto/deviceinfo";
|
|
|
|
|
import { IOlmDevice } from "./crypto/algorithms/megolm";
|
2026-09-12 23:57:45 -04:00
|
|
|
interface IStateEventRequest {
|
|
|
|
|
eventType: string;
|
|
|
|
|
stateKey?: string;
|
|
|
|
|
}
|
|
|
|
|
export interface ICapabilities {
|
|
|
|
|
/**
|
|
|
|
|
* Event types that this client expects to send.
|
|
|
|
|
*/
|
|
|
|
|
sendEvent?: string[];
|
|
|
|
|
/**
|
|
|
|
|
* Event types that this client expects to receive.
|
|
|
|
|
*/
|
|
|
|
|
receiveEvent?: string[];
|
|
|
|
|
/**
|
|
|
|
|
* Message types that this client expects to send, or true for all message
|
|
|
|
|
* types.
|
|
|
|
|
*/
|
|
|
|
|
sendMessage?: string[] | true;
|
|
|
|
|
/**
|
|
|
|
|
* Message types that this client expects to receive, or true for all
|
|
|
|
|
* message types.
|
|
|
|
|
*/
|
|
|
|
|
receiveMessage?: string[] | true;
|
|
|
|
|
/**
|
|
|
|
|
* Types of state events that this client expects to send.
|
|
|
|
|
*/
|
|
|
|
|
sendState?: IStateEventRequest[];
|
|
|
|
|
/**
|
|
|
|
|
* Types of state events that this client expects to receive.
|
|
|
|
|
*/
|
|
|
|
|
receiveState?: IStateEventRequest[];
|
|
|
|
|
/**
|
|
|
|
|
* To-device event types that this client expects to send.
|
|
|
|
|
*/
|
|
|
|
|
sendToDevice?: string[];
|
|
|
|
|
/**
|
|
|
|
|
* To-device event types that this client expects to receive.
|
|
|
|
|
*/
|
|
|
|
|
receiveToDevice?: string[];
|
|
|
|
|
/**
|
|
|
|
|
* Whether this client needs access to TURN servers.
|
|
|
|
|
* @defaultValue false
|
|
|
|
|
*/
|
|
|
|
|
turnServers?: boolean;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* A MatrixClient that routes its requests through the widget API instead of the
|
|
|
|
|
* real CS API.
|
|
|
|
|
* @experimental This class is considered unstable!
|
|
|
|
|
*/
|
|
|
|
|
export declare class RoomWidgetClient extends MatrixClient {
|
|
|
|
|
private readonly widgetApi;
|
|
|
|
|
private readonly capabilities;
|
|
|
|
|
private readonly roomId;
|
|
|
|
|
private room?;
|
|
|
|
|
private readonly widgetApiReady;
|
|
|
|
|
private lifecycle?;
|
|
|
|
|
private syncState;
|
2026-09-13 14:14:38 -04:00
|
|
|
constructor(widgetApi: WidgetApi, capabilities: ICapabilities, roomId: string, opts: IMatrixClientCreateOpts);
|
2026-09-12 23:57:45 -04:00
|
|
|
startClient(opts?: IStartClientOpts): Promise<void>;
|
|
|
|
|
stopClient(): void;
|
|
|
|
|
joinRoom(roomIdOrAlias: string): Promise<Room>;
|
2026-09-13 14:14:38 -04:00
|
|
|
protected encryptAndSendEvent(room: Room, event: MatrixEvent): Promise<ISendEventResponse>;
|
2026-09-12 23:57:45 -04:00
|
|
|
sendStateEvent(roomId: string, eventType: string, content: any, stateKey?: string): Promise<ISendEventResponse>;
|
2026-09-13 14:14:38 -04:00
|
|
|
sendToDevice(eventType: string, contentMap: SendToDeviceContentMap): Promise<{}>;
|
2026-09-12 23:57:45 -04:00
|
|
|
queueToDevice({ eventType, batch }: ToDeviceBatch): Promise<void>;
|
2026-09-13 14:14:38 -04:00
|
|
|
encryptAndSendToDevices(userDeviceInfoArr: IOlmDevice<DeviceInfo>[], payload: object): Promise<void>;
|
2026-09-12 23:57:45 -04:00
|
|
|
checkTurnServers(): Promise<boolean>;
|
|
|
|
|
getSyncState(): SyncState | null;
|
|
|
|
|
private setSyncState;
|
|
|
|
|
private ack;
|
|
|
|
|
private onEvent;
|
|
|
|
|
private onToDevice;
|
|
|
|
|
private watchTurnServers;
|
|
|
|
|
}
|
|
|
|
|
export {};
|
|
|
|
|
//# sourceMappingURL=embedded.d.ts.map
|