import type { IMentions } from "../matrix.ts"; import type { RelationEvent } from "../types.ts"; import type { MatrixEvent } from "../models/event.ts"; import type { Room } from "../models/room.ts"; import { CallMembership } from "./CallMembership.ts"; import { type CallMembershipIdentityParts } from "./EncryptionManager.ts"; export type EncryptionKeyMapKey = string; export interface EncryptionKeyEntry { index: number; key: string; } /** * The mxID, deviceId and membership timestamp of a RTC session participant. */ export type ParticipantDeviceInfo = { userId: string; deviceId: string; membershipTs: number; }; /** * A type representing the information needed to decrypt video streams. */ export type InboundEncryptionSession = { key: Uint8Array; membership: CallMembershipIdentityParts; keyIndex: number; creationTS: number; }; /** * The information about the key used to encrypt video streams. */ export type OutboundEncryptionSession = { key: Uint8Array; creationTS: number; sharedWith: Array; keyId: number; }; export interface EncryptionKeysEventContent { keys: EncryptionKeyEntry[]; device_id: string; call_id: string; sent_ts?: number; } /** * The content of an `m.rtc.encryption_key` to-device event (sent with the unstable type * {@link EventType.CallEncryptionKeysPrefix}). * * @experimental Part of [MSC4143](https://github.com/matrix-org/matrix-spec-proposals/pull/4143). */ export interface EncryptionKeysToDeviceEventContent { /** The ID of the room that the slot is located in. */ room_id: string; /** * The `member.id` value of the sender's `m.rtc.member` event. * * Optional for backwards compatibility. */ member_id?: string; /** * The key material. * * Optional for backwards compatibility. */ media_key?: RTCEncryptionKeyMediaKey; /** * The key material in its deprecated format. * * @deprecated Use `media_key` instead unless you need backwards compatibility with older SDK versions. */ keys?: RTCEncryptionKeyMediaKey; member: { /** * The `member.id` value of the sender's `m.rtc.member` event. * * @deprecated Use `member_id` instead unless you need backwards compatibility with older SDK versions. */ id?: string; /** * The device ID the sender claims to have sent their membership event from. * * Still required for now because the widget API does not expose encryption metadata and state events * are never encrypted to begin with. Therefore, it would be impossible to determine the sending * device otherwise. */ claimed_device_id: string; }; } /** * The key material shared in an `m.rtc.encryption_key` to-device event. * * @experimental Part of [MSC4143](https://github.com/matrix-org/matrix-spec-proposals/pull/4143). */ export interface RTCEncryptionKeyMediaKey { /** * The rolling index of the key to distinguish it from other keys. The value is between 0 and 255 inclusive. */ index: number; /** The key in raw bytes encoded using unpadded base64. */ key: string; } /** * @deprecated Use `RTCNotificationType` instead. */ export type CallNotifyType = "ring" | "notify"; /** * @deprecated Use `IRTCNotificationContent` instead. */ export interface ICallNotifyContent { "application": string; "m.mentions": IMentions; "notify_type": CallNotifyType; "call_id": string; } export type RTCNotificationType = "ring" | "notification"; /** * Represents the intention of the call from the perspective of the sending user. * May be any string, although `"m.audio"` and `"m.video"` are the stable values * specified in MSC4196. * * @experimental Part of [MSC4196](https://github.com/matrix-org/matrix-spec-proposals/pull/4196). */ export type RTCCallIntent = "m.audio" | "m.video" | (string & {}); /** * Represents one kind of media a member's device is capable of handling. * May be any string, although `"m.render_audio"` and `"m.render_video"` are commonly accepted values. */ export type RTCCallCapability = "m.render_audio" | "m.render_video" | string; /** * The maximum `lifetime` of an RTC notification as per MSC4075. Larger values are capped to this. * * Exported for use within the js-sdk only. Not re-exported from `matrixrtc/index.ts`. * @internal */ export declare const RTC_NOTIFICATION_MAX_LIFETIME_MS: number; /** * The maximum amount by which a notification's `sender_ts` may lie ahead of its `origin_server_ts` * before the `lifetime` is measured from `origin_server_ts` instead, as per MSC4075. * * Exported for use within the js-sdk only. Not re-exported from `matrixrtc/index.ts`. * @internal */ export declare const RTC_NOTIFICATION_MAX_SENDER_TS_AHEAD_MS: number; /** * The context that is needed to evaluate the MSC4075 rules for receiving notifications. */ export interface RTCNotificationValidationContext { /** The room in which the notification was received. */ room: Pick; /** The user ID of the receiving (local) user. */ userId: string; /** The current time in milliseconds since the epoch. Defaults to `Date.now()`. */ now?: number; } /** * Computes the absolute timestamp at which an RTC notification stops being valid, as per MSC4075. * * The `lifetime` is measured from `sender_ts` unless `sender_ts` lies more than 20 seconds ahead of * `origin_server_ts`, in which case it is measured from `origin_server_ts` instead. Regardless of the basis, * the remaining lifetime is capped at 2 minutes. * * @param content The notification content. * @param originServerTs The `origin_server_ts` of the notification event. * @param now The current time in milliseconds since the epoch. Defaults to `Date.now()`. * @returns The timestamp (in milliseconds since the epoch) at which the notification expires. */ export declare function getCallNotificationExpiry(content: Pick, originServerTs: number, now?: number): number; /** * The subset of a notification event that {@link parseCallNotificationContent} needs. */ type RTCNotificationEvent = Pick; /** * Parses the content of a received `org.matrix.msc4075.rtc.notification` event. * * This checks that the content matches the schema of MSC4075, caps `lifetime` to 2 minutes and applies * the rules for receiving invites from MSC4075. * The notification is only considered valid if all of the following hold: * - It wasn't sent by the receiving user. * - It is the current entry in the room's sticky event map for its sender and slot and isn't a withdrawal. * - The slot it refers to exists and is open. * - Its lifetime hasn't elapsed (see {@link getCallNotificationExpiry}). * - Its `m.mentions` target the receiving user, either directly or via a room mention that the sender is * allowed to trigger. * - The receiving user has no joined `m.rtc.member` event for the slot in the sticky event map. * - Any left `m.rtc.member` event of the receiving user for the slot predates the notification. * - The receiving user has no sticky decline event referencing the notification. * * @param event The notification event. * @param context The context needed to evaluate the receiving rules. * @throws if the content is malformed or the notification isn't valid. * @returns A promise resolving to the parsed content. */ export declare function parseCallNotificationContent(event: RTCNotificationEvent, context: RTCNotificationValidationContext): Promise; /** * Interface for `org.matrix.msc4075.rtc.notification` events. * Don't cast event content to this directly. Use `parseCallNotificationContent` instead to validate the content first. */ export interface IRTCNotificationContent extends RelationEvent { /** * The `state_key` of the `m.rtc.slot` event that the notification refers to. * * Notifications predating this property omit it. `parseCallNotificationContent` fills it in from the * referenced membership event, so the parsed content always carries it. */ "slot_id": string; /** * The users targeted by the notification. Must either mention the room or at least one user. */ "m.mentions": IMentions; /** * @deprecated Not part of MSC4075 anymore. How to present a notification is up to the receiving client. */ "notification_type"?: RTCNotificationType; /** * @deprecated Not part of MSC4075 anymore. The initial intent of the calling user. */ "m.call.intent"?: RTCCallIntent; /** * The timestamp (in milliseconds since the epoch) at which the sending client created the event. */ "sender_ts": number; /** * The time (in milliseconds) that the notification is valid for, measured from `sender_ts`. */ "lifetime": number; /** * The sticky key as per MSC4354. Must be equal to `slot_id`. * * Optional because notifications predating MSC4354 omit it. */ "msc4354_sticky_key"?: string; } /** * MSC4310 decline event content for `org.matrix.msc4310.rtc.decline`. * Sent as a standard m.reference relation to an `org.matrix.msc4075.rtc.notification` event. */ export interface IRTCDeclineContent extends RelationEvent { /** * The sticky key as per MSC4354. Must be equal to the event ID of the notification being declined. * * Optional because servers without MSC4354 support can't deliver the decline as a sticky event. Such a * decline still counts, but only for devices that receive it directly, since it isn't re-delivered after * a gappy or initial sync. */ msc4354_sticky_key?: string; } export declare enum Status { Disconnected = "Disconnected", Connecting = "Connecting", Connected = "Connected", Disconnecting = "Disconnecting", Unknown = "Unknown" } /** * A type collecting call encryption statistics for a session. */ export type Statistics = { counters: { /** * The number of times we have sent a room event containing encryption keys. */ roomEventEncryptionKeysSent: number; /** * The number of times we have received a room event containing encryption keys. */ roomEventEncryptionKeysReceived: number; }; totals: { /** * The total age (in milliseconds) of all room events containing encryption keys that we have received. * We track the total age so that we can later calculate the average age of all keys received. * * @deprecated To-device key events no longer carry a timestamp, so this is not updated anymore and stays 0. */ roomEventEncryptionKeysReceivedTotalAge: number; }; }; export declare const isMyMembership: (m: CallMembership, userId: string, deviceId: string) => boolean; /** * A RTC transport is a JSON object that describes how to connect to a RTC member. */ export interface Transport { type: string; [key: string]: unknown; } /** * Event content for `org.matrix.msc4143.rtc.slot` state events. */ export interface RtcSlotEventContent { status: "open" | "closed"; application?: RtcSlotApplicationContent; encryption?: RtcSlotEncryptionContent; } /** * Content of the `application` object within `org.matrix.msc4143.rtc.slot` events. */ export interface RtcSlotApplicationContent { type: T; [key: string]: unknown; } export declare const RTC_SLOT_ENCRYPTION_PER_MEMBER = "org.matrix.msc4143.per_member"; /** * Content of the `encryption` object within `org.matrix.msc4143.rtc.slot` events. */ export interface RtcSlotEncryptionContent { type: typeof RTC_SLOT_ENCRYPTION_PER_MEMBER; [key: string]: unknown; } /** * The session description is used to identify a session. Used in the state event. */ export interface SlotDescription { /** * The application type. e.g. "m.call". */ application: string; /** * The application-specific slot ID. e.g. "ROOM". */ id: string; } export {}; //# sourceMappingURL=types.d.ts.map