matrix-js-sdk
Version:
Matrix Client-Server SDK for Javascript
81 lines • 3.07 kB
TypeScript
/**
* This file is a secondary entrypoint for the js-sdk library, exposing utilities which might be useful for writing tests.
*
* In general, it should not be included in runtime applications.
*
* @packageDocumentation
*/
import { IContent, IUnsigned, MatrixEvent } from "./models/event";
import { EventType } from "./@types/event";
import { DecryptionFailureCode } from "./crypto-api";
/**
* Create a {@link MatrixEvent}.
*
* @param opts - Values for the event.
*/
export declare function mkMatrixEvent(opts: {
/** Room ID of the event. */
roomId: string;
/** The sender of the event. */
sender: string;
/** The type of the event. */
type: EventType | string;
/** Optional `state_key` for the event. If unspecified, a non-state event is created. */
stateKey?: string;
/** Optional `origin_server_ts` for the event. If unspecified, the timestamp will be set to 0. */
ts?: number;
/** Optional `event_id` for the event. If provided will be used as event ID; else an ID is generated. */
eventId?: string;
/** Content of the event. */
content: IContent;
/** Optional `unsigned` data for the event. */
unsigned?: IUnsigned;
}): MatrixEvent;
/**
* Create a `MatrixEvent` representing a successfully-decrypted `m.room.encrypted` event.
*
* @param opts - Values for the event.
*/
export declare function mkEncryptedMatrixEvent(opts: {
/** Room ID of the event. */
roomId: string;
/** The sender of the event. */
sender: string;
/** The type the event will have, once it has been decrypted. */
plainType: EventType | string;
/** The content the event will have, once it has been decrypted. */
plainContent: IContent;
/** Optional `event_id` for the event. If provided will be used as event ID; else an ID is generated. */
eventId?: string;
}): Promise<MatrixEvent>;
/**
* Create a `MatrixEvent` representing a `m.room.encrypted` event which could not be decrypted.
*
* @param opts - Values for the event.
*/
export declare function mkDecryptionFailureMatrixEvent(opts: {
/** Room ID of the event. */
roomId: string;
/** The sender of the event. */
sender: string;
/** The reason code for the failure */
code: DecryptionFailureCode;
/** A textual reason for the failure */
msg: string;
/** Optional `event_id` for the event. If provided will be used as event ID; else an ID is generated. */
eventId?: string;
}): Promise<MatrixEvent>;
/**
* Given an event previously returned by {@link mkDecryptionFailureMatrixEvent}, simulate a successful re-decryption
* attempt.
*
* @param mxEvent - The event that will be decrypted.
* @param opts - New data for the successful decryption.
*/
export declare function decryptExistingEvent(mxEvent: MatrixEvent, opts: {
/** The type the event will have, once it has been decrypted. */
plainType: EventType | string;
/** The content the event will have, once it has been decrypted. */
plainContent: IContent;
}): Promise<void>;
//# sourceMappingURL=testing.d.ts.map