first commit

This commit is contained in:
Myk
2025-07-31 23:47:20 +03:00
commit 2186b278a0
5149 changed files with 537218 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
/**
* Response to a `/whoami` request.
* @category Models
*/
export interface IWhoAmI {
user_id: string;
device_id?: string;
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Account.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Account.js","sourceRoot":"","sources":["../../src/models/Account.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,38 @@
type BooleanCapability = {
enabled: boolean;
};
export interface MatrixCapabilities {
/**
* Is the user able to add, remove, or change 3PID associations on their account .
*/
"m.3pid_changes"?: BooleanCapability;
/**
* Is the user able to change their own password.
*/
"m.change_password"?: BooleanCapability;
/**
* Is the user able to generate single-use, time-limited tokens via the API.
*/
"m.get_login_token"?: BooleanCapability;
/**
* Is the user able to change their own avatar_url via profile endpoints.
*/
"m.set_avatar_url"?: BooleanCapability;
/**
* Is the user able to change their own display name via profile endpoints.
*/
"m.set_displayname"?: BooleanCapability;
/**
* Describes the default and available room versions a server supports, and at what level of stability.
*
* Any room version not marked as "stable" should be considered "unstable"
*/
"m.room_versions"?: {
"available": {
[version: string]: "stable" | string;
};
"default": string;
};
[key: string]: unknown;
}
export {};

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Capabilities.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Capabilities.js","sourceRoot":"","sources":["../../src/models/Capabilities.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,125 @@
import { PowerLevelsEventContent } from "./events/PowerLevelsEvent";
import { CreateEventContent } from "./events/CreateEvent";
/**
* "private_chat" sets:
* - join_rules to `invite`
* - history_visibility to `shared`
* - guest_access to `can_join`
*
* "trusted_private_chat" sets:
* - join_rules to `invite`
* - history_visibility to `shared`
* - guest_access to `can_join`
* - All invitees are given the same power level as the room creator.
*
* "public_chat" sets:
* - join_rules to `public`
* - history_visibility to `shared`
* - guest_access to `forbidden`
* @category Models
*/
export type RoomPreset = "private_chat" | "trusted_private_chat" | "public_chat";
/**
* "public" visibility indicates that the room will be shown in the published room list.
*
* "private" visibility indicates that the room will not be included in published room list.
* @category Models
*/
export type RoomVisibility = "public" | "private";
/**
* The options available when creating a room.
* @category Models
*/
export interface RoomCreateOptions {
/**
* Extra keys, such as m.federate, to be added to the content of the m.room.create event.
* The server will overwrite the following keys: `creator`, `room_version`.
* Future versions of the specification may allow the server to overwrite other keys.
*/
creation_content?: Omit<CreateEventContent, "creator">;
/**
* A list of state events to set in the new room.
* This allows the user to override the default state events set in the new room.
* The expected format of the state events are an object with `type`, `state_key` and `content` keys set.
* Takes precedence over events set by `preset`, but gets overridden by `name` and `topic` keys.
*/
initial_state?: {
/**
* The content of the event.
*/
content: any;
/**
* The state_key of the state event. Defaults to an empty string.
*/
state_key?: string;
/**
* The type of event to send.
*/
type: string;
}[];
/**
* A list of user IDs to invite to the room. This will tell the server to invite everyone in the list to the newly created room.
*/
invite?: string[];
invite_3pid?: {
/**
* The invitees third party identifier.
*/
address: string;
/**
* An access token previously registered with the identity server.
* Servers can treat this as optional to distinguish between r0.5-compatible clients and this specification version.
*/
id_access_token: string;
/**
* The hostname+port of the identity server which should be used for third party identifier lookups.
*/
id_server: string;
/**
* The kind of address being passed in the address field, for example `email`.
*/
medium: string;
}[];
/**
* This flag makes the server set the `is_direct` flag on the `m.room.member` events sent to the users in `invite` and `invite_3pid`.
*/
is_direct?: boolean;
/**
* If this is included, an `m.room.name` event will be sent into the room to indicate the name of the room.
*/
name?: string;
/**
* The power level content to override in the default power level event.
* This object is applied on top of the generated `m.room.power_levels` event content prior to it being sent to the room.
* Defaults to overriding nothing.
*/
power_level_content_override?: PowerLevelsEventContent;
/**
* Convenience parameter for setting various default state events based on a preset.
*
* If unspecified, the server should use the `visibility` to determine which preset to use.
* A visbility of `public` equates to a preset of `public_chat` and `private` visibility equates to a preset of `private_chat`.
*/
preset?: RoomPreset;
/**
* The desired room alias local part.
* If this is included, a room alias will be created and mapped to the newly created room.
* The alias will belong on the same homeserver which created the room.
*/
room_alias_name?: string;
/**
* The room version to set for the room.
* If not provided, the homeserver is to use its configured default.
* If provided, the homeserver will return a `400` error with the errcode `M_UNSUPPORTED_ROOM_VERSION` if it does not support the room version.
*/
room_version?: string;
/**
* If this is included, an `m.room.topic` event will be sent into the room to indicate the topic for the room.
*/
topic?: string;
/**
* Sets the visibility of the room
* Rooms default to private visibility if this key is not included.
*/
visibility?: RoomVisibility;
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=CreateRoom.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CreateRoom.js","sourceRoot":"","sources":["../../src/models/CreateRoom.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,172 @@
/**
* One time key algorithms.
* @category Models
*/
export declare enum OTKAlgorithm {
Signed = "signed_curve25519",
Unsigned = "curve25519"
}
/**
* Label for a one time key.
* @category Models
*/
export type OTKLabel<Algorithm extends OTKAlgorithm, ID extends string> = `${Algorithm}:${ID}`;
/**
* Signatures object.
* @category Models
*/
export interface Signatures {
[entity: string]: {
[keyLabel: string]: string;
};
}
/**
* Interface that can be extended by
* any object that needs a signature.
*/
export interface Signed {
signatures: Signatures;
}
/**
* A signed_curve25519 one time key.
* @category Models
*/
export interface SignedCurve25519OTK extends Signed {
key: string;
fallback?: boolean;
}
/**
* A fallback key.
* @category Models
*/
export interface FallbackKey {
keyId: string;
key: SignedCurve25519OTK & {
fallback: true;
};
}
/**
* One Time Keys structure model.
* @category Models
*/
export type OTKs = Record<OTKLabel<OTKAlgorithm.Signed, string>, SignedCurve25519OTK> & Record<OTKLabel<OTKAlgorithm.Unsigned, string>, string>;
/**
* The counts of each one time key by algorithm.
* @category Models
*/
export type OTKCounts = {
[alg in OTKAlgorithm]?: number;
};
/**
* The available encryption algorithms.
* @category Models
*/
export declare enum EncryptionAlgorithm {
OlmV1Curve25519AesSha2 = "m.olm.v1.curve25519-aes-sha2",
MegolmV1AesSha2 = "m.megolm.v1.aes-sha2"
}
/**
* The key algorithms for device keys.
* @category Models
*/
export declare enum DeviceKeyAlgorithm {
Ed25519 = "ed25519",
Curve25519 = "curve25519"
}
/**
* Label for a device key.
* @category Models
*/
export type DeviceKeyLabel<Algorithm extends DeviceKeyAlgorithm, ID extends string> = `${Algorithm}:${ID}`;
/**
* Represents a user's device.
* @category Models
*/
export interface UserDevice extends Signed {
user_id: string;
device_id: string;
algorithms: (EncryptionAlgorithm | string)[];
keys: Record<DeviceKeyLabel<DeviceKeyAlgorithm, string>, string>;
unsigned?: {
[k: string]: any;
device_display_name?: string;
};
}
/**
* Represents a user's own device.
* @category Models
*/
export interface OwnUserDevice {
device_id: string;
display_name?: string;
last_seen_ip?: string;
last_seen_ts?: number;
}
/**
* Device list response for a multi-user query.
* @category Models
*/
export interface MultiUserDeviceListResponse {
/**
* Federation failures, keyed by server name. The mapped object should be a standard
* error object.
*/
failures: {
[serverName: string]: any;
};
/**
* A map of user ID to device ID to device.
*/
device_keys: Record<string, Record<string, UserDevice>>;
}
/**
* One Time Key claim response.
* @category Models
*/
export interface OTKClaimResponse {
/**
* Federation failures, keyed by server name. The mapped object should be a standard
* error object.
*/
failures: {
[serverName: string]: any;
};
/**
* The claimed One Time Keys, as a map from user ID to device ID to key ID to OTK.
*/
one_time_keys: Record<string, Record<string, OTKs>>;
}
/**
* An encrypted Olm payload.
* @category Models
*/
export interface IOlmEncrypted {
algorithm: EncryptionAlgorithm.OlmV1Curve25519AesSha2;
sender_key: string;
ciphertext: {
[deviceCurve25519Key: string]: {
type: number;
body: string;
};
};
}
/**
* A to-device message.
* @category Models
*/
export interface IToDeviceMessage<T = any> {
type: string;
sender: string;
content: T;
}
/**
* Encrypted event content for a Megolm-encrypted m.room.encrypted event
* @category Models
*/
export interface IMegolmEncrypted {
algorithm: EncryptionAlgorithm.MegolmV1AesSha2;
sender_key: string;
ciphertext: string;
session_id: string;
device_id: string;
}

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeviceKeyAlgorithm = exports.EncryptionAlgorithm = exports.OTKAlgorithm = void 0;
/**
* One time key algorithms.
* @category Models
*/
var OTKAlgorithm;
(function (OTKAlgorithm) {
OTKAlgorithm["Signed"] = "signed_curve25519";
OTKAlgorithm["Unsigned"] = "curve25519";
})(OTKAlgorithm || (exports.OTKAlgorithm = OTKAlgorithm = {}));
/**
* The available encryption algorithms.
* @category Models
*/
var EncryptionAlgorithm;
(function (EncryptionAlgorithm) {
EncryptionAlgorithm["OlmV1Curve25519AesSha2"] = "m.olm.v1.curve25519-aes-sha2";
EncryptionAlgorithm["MegolmV1AesSha2"] = "m.megolm.v1.aes-sha2";
})(EncryptionAlgorithm || (exports.EncryptionAlgorithm = EncryptionAlgorithm = {}));
/**
* The key algorithms for device keys.
* @category Models
*/
var DeviceKeyAlgorithm;
(function (DeviceKeyAlgorithm) {
DeviceKeyAlgorithm["Ed25519"] = "ed25519";
DeviceKeyAlgorithm["Curve25519"] = "curve25519";
})(DeviceKeyAlgorithm || (exports.DeviceKeyAlgorithm = DeviceKeyAlgorithm = {}));
//# sourceMappingURL=Crypto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Crypto.js","sourceRoot":"","sources":["../../src/models/Crypto.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACpB,4CAA4B,CAAA;IAC5B,uCAAuB,CAAA;AAC3B,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AA+DD;;;GAGG;AACH,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC3B,8EAAuD,CAAA;IACvD,+DAAwC,CAAA;AAC5C,CAAC,EAHW,mBAAmB,mCAAnB,mBAAmB,QAG9B;AAED;;;GAGG;AACH,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC1B,yCAAmB,CAAA;IACnB,+CAAyB,CAAA;AAC7B,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B"}

View File

@@ -0,0 +1,19 @@
import { RoomEvent, RoomEventContent, StateEvent } from "./events/RoomEvent";
export interface EventContext {
/**
* The event that was used to build this context.
*/
event: RoomEvent<RoomEventContent>;
/**
* The events that happened before the contextual event.
*/
before: RoomEvent<RoomEventContent>[];
/**
* The events that happened after the contextual event.
*/
after: RoomEvent<RoomEventContent>[];
/**
* The state of the room at the point of the last event returned.
*/
state: StateEvent<RoomEventContent>[];
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=EventContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EventContext.js","sourceRoot":"","sources":["../../src/models/EventContext.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,20 @@
/**
* Information about a user on an identity server.
* @category Models
*/
export interface IdentityServerAccount {
user_id: string;
}
/**
* A stored invite on an identity server.
* @category Models
*/
export interface IdentityServerInvite {
display_name: string;
public_keys: {
public_key: string;
key_validity_url: string;
}[];
public_key: string;
token: string;
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IdentityServerModels.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"IdentityServerModels.js","sourceRoot":"","sources":["../../src/models/IdentityServerModels.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,51 @@
import { IJsonType } from "../helpers/Types";
import { Signed } from "./Crypto";
import { RoomEncryptionAlgorithm } from "./events/EncryptionEvent";
/**
* The kinds of key backup encryption algorithms allowed by the spec.
* @category Models
*/
export declare enum KeyBackupEncryptionAlgorithm {
MegolmBackupV1Curve25519AesSha2 = "m.megolm_backup.v1.curve25519-aes-sha2"
}
export interface ICurve25519AuthDataUnsigned {
public_key: string;
}
export type ICurve25519AuthData = ICurve25519AuthDataUnsigned & Signed;
export type IKeyBackupAuthData = IJsonType | ICurve25519AuthDataUnsigned;
/**
* Information about a server-side key backup,
* with its auth_data left unsigned.
*/
export interface IKeyBackupInfoUnsigned {
algorithm: string | KeyBackupEncryptionAlgorithm;
auth_data: IKeyBackupAuthData;
}
/**
* Information about a server-side key backup,
* with its auth_data signed by the entity that created it.
*/
export type IKeyBackupInfo = IKeyBackupInfoUnsigned & {
auth_data: Signed & IKeyBackupAuthData;
};
export type KeyBackupVersion = string;
export interface IKeyBackupVersion {
version: KeyBackupVersion;
}
export interface IKeyBackupUpdateResponse {
count: number;
etag: string;
}
export type IKeyBackupInfoRetrieved = IKeyBackupInfo & IKeyBackupVersion & IKeyBackupUpdateResponse;
export type IKeyBackupInfoUpdate = IKeyBackupInfo & Partial<IKeyBackupVersion>;
export interface IMegolmSessionDataExport {
algorithm: RoomEncryptionAlgorithm.MegolmV1AesSha2;
room_id: string;
sender_key: string;
session_id: string;
session_key: string;
sender_claimed_keys: {
[algorithm: string]: string;
};
forwarding_curve25519_key_chain: string[];
}

View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyBackupEncryptionAlgorithm = void 0;
/**
* The kinds of key backup encryption algorithms allowed by the spec.
* @category Models
*/
var KeyBackupEncryptionAlgorithm;
(function (KeyBackupEncryptionAlgorithm) {
KeyBackupEncryptionAlgorithm["MegolmBackupV1Curve25519AesSha2"] = "m.megolm_backup.v1.curve25519-aes-sha2";
})(KeyBackupEncryptionAlgorithm || (exports.KeyBackupEncryptionAlgorithm = KeyBackupEncryptionAlgorithm = {}));
//# sourceMappingURL=KeyBackup.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"KeyBackup.js","sourceRoot":"","sources":["../../src/models/KeyBackup.ts"],"names":[],"mappings":";;;AAIA;;;GAGG;AACH,IAAY,4BAEX;AAFD,WAAY,4BAA4B;IACpC,0GAA0E,CAAA;AAC9E,CAAC,EAFW,4BAA4B,4CAA5B,4BAA4B,QAEvC"}

View File

@@ -0,0 +1,42 @@
/**
* Response object for a batch send operation.
* @category Models
*/
export interface MSC2716BatchSendResponse {
/**
* List of historical state event IDs that were inserted
*/
state_events?: string[];
/**
* List of historical event IDs that were inserted
*/
events?: string[];
/**
* Chunk ID to be used in the next `sendHistoricalEventBatch` call.
*/
next_chunk_id: string;
}
/**
* Partial event content for an inserted MSC2716 event.
* @category Matrix event contents
*/
export interface MSC2716InsertionEventContent {
"org.matrix.msc2716.next_chunk_id": string;
"org.matrix.msc2716.historical": true;
}
/**
* Partial event content for a chunked MSC2716 event.
* @category Matrix event contents
*/
export interface MSC2716ChunkEventContent {
"org.matrix.msc2716.chunk_id": string;
"org.matrix.msc2716.historical": true;
}
/**
* Partial event content for a marked MSC2716 event.
* @category Matrix event contents
*/
export interface MSC2716MarkerEventContent {
"org.matrix.msc2716.insertion_id": string;
"org.matrix.msc2716.historical": true;
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=MSC2176.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MSC2176.js","sourceRoot":"","sources":["../../src/models/MSC2176.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,7 @@
export declare class MXCUrl {
domain: string;
mediaId: string;
static parse(mxcUrl: string): MXCUrl;
constructor(domain: string, mediaId: string);
toString(): string;
}

View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MXCUrl = void 0;
class MXCUrl {
domain;
mediaId;
static parse(mxcUrl) {
if (!mxcUrl?.toLowerCase()?.startsWith("mxc://")) {
throw Error("Not a MXC URI");
}
const [domain, ...mediaIdParts] = mxcUrl.slice("mxc://".length).split("/");
if (!domain) {
throw Error("missing domain component");
}
const mediaId = mediaIdParts?.join('/') ?? undefined;
if (!mediaId) {
throw Error("missing mediaId component");
}
return new MXCUrl(domain, mediaId);
}
constructor(domain, mediaId) {
this.domain = domain;
this.mediaId = mediaId;
}
toString() {
return `mxc://${this.domain}/${this.mediaId}`;
}
}
exports.MXCUrl = MXCUrl;
//# sourceMappingURL=MXCUrl.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MXCUrl.js","sourceRoot":"","sources":["../../src/models/MXCUrl.ts"],"names":[],"mappings":";;;AAAA,MAAa,MAAM;IAgBI;IAAuB;IAf1C,MAAM,CAAC,KAAK,CAAC,MAAc;QACvB,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE;YAC9C,MAAM,KAAK,CAAC,eAAe,CAAC,CAAC;SAChC;QACD,MAAM,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3E,IAAI,CAAC,MAAM,EAAE;YACT,MAAM,KAAK,CAAC,0BAA0B,CAAC,CAAC;SAC3C;QACD,MAAM,OAAO,GAAG,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC;QACrD,IAAI,CAAC,OAAO,EAAE;YACV,MAAM,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC5C;QACD,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,YAAmB,MAAc,EAAS,OAAe;QAAtC,WAAM,GAAN,MAAM,CAAQ;QAAS,YAAO,GAAP,OAAO,CAAQ;IAAI,CAAC;IAEvD,QAAQ;QACX,OAAO,SAAS,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;IAClD,CAAC;CACJ;AArBD,wBAqBC"}

View File

@@ -0,0 +1,45 @@
/**
* Represents an HTTP error from the Matrix server.
* @category Error handling
*/
export declare class MatrixError extends Error {
readonly body: {
errcode: string;
error: string;
retry_after_ms?: number;
};
readonly statusCode: number;
/**
* Parse a Retry-After header into a number of milliseconds.
* @see https://www.rfc-editor.org/rfc/rfc9110#field.retry-after
* @param header The value of a Retry-After header.
* @throws If the date could not be parsed.
*/
static parseRetryAfterHeader(header: string): number;
/**
* The Matrix error code
*/
readonly errcode: string;
/**
* Optional human-readable error message.
*/
readonly error: string;
/**
* If rate limited, the time in milliseconds to wait before retrying the request
*/
readonly retryAfterMs?: number;
/**
* Creates a new Matrix Error
* @param body The error body.
* @param statusCode The HTTP status code.
*/
constructor(body: {
errcode: string;
error: string;
retry_after_ms?: number;
}, statusCode: number, headers: Record<string, string>);
/**
* Developer-friendly error message.
*/
get message(): string;
}

View File

@@ -0,0 +1,73 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MatrixError = void 0;
const LogService_1 = require("../logging/LogService");
/**
* Represents an HTTP error from the Matrix server.
* @category Error handling
*/
class MatrixError extends Error {
body;
statusCode;
/**
* Parse a Retry-After header into a number of milliseconds.
* @see https://www.rfc-editor.org/rfc/rfc9110#field.retry-after
* @param header The value of a Retry-After header.
* @throws If the date could not be parsed.
*/
static parseRetryAfterHeader(header) {
// First try to parse as seconds
const retryAfterSeconds = parseInt(header, 10);
if (!Number.isNaN(retryAfterSeconds)) {
return retryAfterSeconds * 1000;
}
const retryAfterDate = new Date(header);
return retryAfterDate.getTime() - Date.now();
}
/**
* The Matrix error code
*/
errcode;
/**
* Optional human-readable error message.
*/
error;
/**
* If rate limited, the time in milliseconds to wait before retrying the request
*/
retryAfterMs;
/**
* Creates a new Matrix Error
* @param body The error body.
* @param statusCode The HTTP status code.
*/
constructor(body, statusCode, headers) {
super();
this.body = body;
this.statusCode = statusCode;
this.errcode = body.errcode;
this.error = body.error;
const retryAfterHeader = headers['retry-after'];
if (this.statusCode === 429 && retryAfterHeader) {
try {
this.retryAfterMs = MatrixError.parseRetryAfterHeader(retryAfterHeader);
}
catch (ex) {
// Could not parse...skip handling for now.
LogService_1.LogService.warn("MatrixError", "Could not parse Retry-After header from request.", ex);
}
}
// Fall back to the deprecated retry_after_ms property.
if (!this.retryAfterMs && body.retry_after_ms) {
this.retryAfterMs = body.retry_after_ms;
}
}
/**
* Developer-friendly error message.
*/
get message() {
return `${this.errcode}: ${this.error}`;
}
}
exports.MatrixError = MatrixError;
//# sourceMappingURL=MatrixError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MatrixError.js","sourceRoot":"","sources":["../../src/models/MatrixError.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAEnD;;;GAGG;AACH,MAAa,WAAY,SAAQ,KAAK;IAqCN;IAAmF;IApC/G;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,CAAC,MAAc;QACvC,gCAAgC;QAChC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE;YAClC,OAAO,iBAAiB,GAAG,IAAI,CAAC;SACnC;QACD,MAAM,cAAc,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,cAAc,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACa,OAAO,CAAS;IAEhC;;OAEG;IACa,KAAK,CAAS;IAE9B;;OAEG;IACa,YAAY,CAAU;IAEtC;;;;OAIG;IACH,YAA4B,IAAiE,EAAkB,UAAkB,EAAE,OAA+B;QAC9J,KAAK,EAAE,CAAC;QADgB,SAAI,GAAJ,IAAI,CAA6D;QAAkB,eAAU,GAAV,UAAU,CAAQ;QAE7H,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,MAAM,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;QAChD,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG,IAAI,gBAAgB,EAAE;YAC7C,IAAI;gBACA,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;aAC3E;YAAC,OAAO,EAAE,EAAE;gBACT,2CAA2C;gBAC3C,uBAAU,CAAC,IAAI,CAAC,aAAa,EAAE,kDAAkD,EAAE,EAAE,CAAC,CAAC;aAC1F;SACJ;QACD,uDAAuD;QACvD,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,cAAc,EAAE;YAC3C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC;SAC3C;IACL,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,GAAG,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;CACJ;AA9DD,kCA8DC"}

View File

@@ -0,0 +1,43 @@
import { MentionPill } from "..";
/**
* Profile information commonly associated with Matrix profiles
* @category Models
*/
export interface MatrixProfileInfo {
/**
* The display name of the user, if any.
*/
displayname?: string;
/**
* A URL to the user's avatar, if any.
*/
avatar_url?: string;
}
/**
* Represents a user's profile, possibly in a room.
* @category Models
*/
export declare class MatrixProfile {
private userId;
private profile;
/**
* Creates a new profile representation for a user.
* @param {string} userId The user ID the profile is for.
* @param {MatrixProfile} profile The profile itself.
*/
constructor(userId: string, profile: MatrixProfileInfo);
/**
* The display name for the user. This will always return a value, though it
* may be based upon their user ID if no explicit display name is set.
*/
get displayName(): string;
/**
* The avatar URL for the user. If the user does not have an avatar, this will
* be null.
*/
get avatarUrl(): string;
/**
* A mention pill for this user.
*/
get mention(): MentionPill;
}

View File

@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MatrixProfile = void 0;
const __1 = require("..");
/**
* Represents a user's profile, possibly in a room.
* @category Models
*/
class MatrixProfile {
userId;
profile;
/**
* Creates a new profile representation for a user.
* @param {string} userId The user ID the profile is for.
* @param {MatrixProfile} profile The profile itself.
*/
constructor(userId, profile) {
this.userId = userId;
this.profile = profile;
}
/**
* The display name for the user. This will always return a value, though it
* may be based upon their user ID if no explicit display name is set.
*/
get displayName() {
if (!this.profile?.displayname)
return new __1.UserID(this.userId).localpart;
return this.profile.displayname;
}
/**
* The avatar URL for the user. If the user does not have an avatar, this will
* be null.
*/
get avatarUrl() {
return this.profile?.avatar_url || null; // enforce null over boolean semantics
}
/**
* A mention pill for this user.
*/
get mention() {
return __1.MentionPill.withDisplayName(this.userId, this.displayName);
}
}
exports.MatrixProfile = MatrixProfile;
//# sourceMappingURL=MatrixProfile.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MatrixProfile.js","sourceRoot":"","sources":["../../src/models/MatrixProfile.ts"],"names":[],"mappings":";;;AAAA,0BAAyC;AAkBzC;;;GAGG;AACH,MAAa,aAAa;IAMF;IAAwB;IAL5C;;;;OAIG;IACH,YAAoB,MAAc,EAAU,OAA0B;QAAlD,WAAM,GAAN,MAAM,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAmB;IACtE,CAAC;IAED;;;OAGG;IACH,IAAW,WAAW;QAClB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW;YAAE,OAAO,IAAI,UAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,OAAO,EAAE,UAAU,IAAI,IAAI,CAAC,CAAC,sCAAsC;IACnF,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,eAAW,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACtE,CAAC;CACJ;AAhCD,sCAgCC"}

View File

@@ -0,0 +1,10 @@
/**
* An OpenID Connect token from the homeserver.
* @category Models
*/
export interface OpenIDConnectToken {
access_token: string;
expires_in: number;
matrix_server_name: string;
token_type: 'Bearer';
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=OpenIDConnect.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"OpenIDConnect.js","sourceRoot":"","sources":["../../src/models/OpenIDConnect.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,25 @@
/**
* Information about the policies (terms of service) a server may have.
* @category Models
*/
export interface Policies {
policies: {
[id: string]: Policy;
};
}
/**
* Information about a policy (terms of service) a server may have.
* @category Models
*/
export interface Policy {
version: string;
[language: string]: TranslatedPolicy | string;
}
/**
* Information about a (translated) policy (terms of service).
* @category Models
*/
export interface TranslatedPolicy {
name: string;
url: string;
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Policies.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Policies.js","sourceRoot":"","sources":["../../src/models/Policies.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,27 @@
/**
* Actions that can be guarded by power levels.
*/
export declare enum PowerLevelAction {
/**
* Power level required to ban other users.
*/
Ban = "ban",
/**
* Power level required to kick other users.
*/
Kick = "kick",
/**
* Power level required to redact events sent by other users. Users can redact
* their own messages regardless of this power level requirement, unless forbidden
* by the `events` section of the power levels content.
*/
RedactEvents = "redact",
/**
* Power level required to invite other users.
*/
Invite = "invite",
/**
* Power level required to notify the whole room with "@room".
*/
NotifyRoom = "notifications.room"
}

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PowerLevelAction = void 0;
/**
* Actions that can be guarded by power levels.
*/
var PowerLevelAction;
(function (PowerLevelAction) {
/**
* Power level required to ban other users.
*/
PowerLevelAction["Ban"] = "ban";
/**
* Power level required to kick other users.
*/
PowerLevelAction["Kick"] = "kick";
/**
* Power level required to redact events sent by other users. Users can redact
* their own messages regardless of this power level requirement, unless forbidden
* by the `events` section of the power levels content.
*/
PowerLevelAction["RedactEvents"] = "redact";
/**
* Power level required to invite other users.
*/
PowerLevelAction["Invite"] = "invite";
/**
* Power level required to notify the whole room with "@room".
*/
PowerLevelAction["NotifyRoom"] = "notifications.room";
})(PowerLevelAction || (exports.PowerLevelAction = PowerLevelAction = {}));
//# sourceMappingURL=PowerLevelAction.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PowerLevelAction.js","sourceRoot":"","sources":["../../src/models/PowerLevelAction.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,gBA2BX;AA3BD,WAAY,gBAAgB;IACxB;;OAEG;IACH,+BAAW,CAAA;IAEX;;OAEG;IACH,iCAAa,CAAA;IAEb;;;;OAIG;IACH,2CAAuB,CAAA;IAEvB;;OAEG;IACH,qCAAiB,CAAA;IAEjB;;OAEG;IACH,qDAAiC,CAAA;AACrC,CAAC,EA3BW,gBAAgB,gCAAhB,gBAAgB,QA2B3B"}

View File

@@ -0,0 +1,15 @@
/**
* Information on the bounds of a power level change a user can apply.
*/
export interface PowerLevelBounds {
/**
* Whether or not the user can even modify the power level of the user. This
* will be false if the user can't send power level events, or the user is
* unobtainably high in power.
*/
canModify: boolean;
/**
* The maximum possible power level the user can set on the target user.
*/
maximumPossibleLevel: number;
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=PowerLevelBounds.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PowerLevelBounds.js","sourceRoot":"","sources":["../../src/models/PowerLevelBounds.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,25 @@
import { PresenceEventContent, PresenceState } from "./events/PresenceEvent";
/**
* Presence information for a user.
* @category Models
*/
export declare class Presence {
protected presence: PresenceEventContent;
constructor(presence: PresenceEventContent);
/**
* The state for this presence update.
*/
get state(): PresenceState;
/**
* The status message which accompanies this presence. May be falsey.
*/
get statusMessage(): string;
/**
* How long ago in milliseconds this presence was changed. May be falsey.
*/
get lastActiveAgo(): number;
/**
* Whether or not the user is currently active.
*/
get currentlyActive(): boolean;
}

View File

@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Presence = void 0;
/**
* Presence information for a user.
* @category Models
*/
class Presence {
presence;
constructor(presence) {
this.presence = presence;
}
/**
* The state for this presence update.
*/
get state() {
return this.presence.presence;
}
/**
* The status message which accompanies this presence. May be falsey.
*/
get statusMessage() {
return this.presence.status_msg;
}
/**
* How long ago in milliseconds this presence was changed. May be falsey.
*/
get lastActiveAgo() {
return this.presence.last_active_ago;
}
/**
* Whether or not the user is currently active.
*/
get currentlyActive() {
return this.presence.currently_active;
}
}
exports.Presence = Presence;
//# sourceMappingURL=Presence.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Presence.js","sourceRoot":"","sources":["../../src/models/Presence.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,MAAa,QAAQ;IACK;IAAtB,YAAsB,QAA8B;QAA9B,aAAQ,GAAR,QAAQ,CAAsB;IACpD,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IAC1C,CAAC;CACJ;AA/BD,4BA+BC"}

View File

@@ -0,0 +1,8 @@
/**
* Representation of the server's supported specification versions and unstable feature flags.
* @category Models
*/
export type ServerVersions = {
unstable_features?: Record<string, boolean>;
versions: string[];
};

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=ServerVersions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ServerVersions.js","sourceRoot":"","sources":["../../src/models/ServerVersions.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,116 @@
import { MatrixClient } from "../MatrixClient";
import { SpaceChildEvent } from "./events/SpaceChildEvent";
/**
* Options to be specified when creating a Space.
* @category Models
*/
export interface SpaceCreateOptions {
/**
* The name of the space.
*/
name: string;
/**
* The topic/description for the space.
*/
topic?: string;
/**
* An MXC URI for the space's avatar.
*/
avatarUrl?: string;
/**
* Whether or not the space should be publicly joinable or not.
*/
isPublic: boolean;
/**
* Optional localpart for the alias of the space.
*/
localpart?: string;
/**
* User IDs to invite to the space upon creation.
*/
invites?: string[];
}
/**
* Options for displaying/handling a child room/space.
* @category Models
*/
export interface SpaceChildEntityOptions {
/**
* Whether or not the entity is intended to be a suggested entity.
*/
suggested?: boolean;
/**
* Servers to try and join through. When not provided, the SDK will try to
* determine a set.
*/
via?: string[];
/**
* A short string to differentiate the rendering order of entities.
* @see validateSpaceOrderString
*/
order?: string;
}
/**
* Options for creating a new child space or room.
* @category Models
*/
export type NewChildOpts = SpaceCreateOptions & SpaceChildEntityOptions;
/**
* A mapping of room ID to space child information.
* @category Models
*/
export interface SpaceEntityMap {
[roomId: string]: SpaceChildEvent;
}
/**
* An instance representing a Matrix Space. A space is tied to a room.
* @category Models
*/
export declare class Space {
readonly roomId: string;
readonly client: MatrixClient;
constructor(roomId: string, client: MatrixClient);
/**
* Creates a new child space under this space.
* @param {SpaceCreateOptions} opts The options for the new space.
* @returns {Promise<Space>} Resolves to the created space.
*/
createChildSpace(opts: NewChildOpts): Promise<Space>;
/**
* Adds a child space to the space. Must be joined to both spaces.
* @param {Space} space The space to add.
* @param {SpaceChildEntityOptions} childOpts Related options for the child's representation.
* @returns {Promise<Space>} Resolves when complete.
*/
addChildSpace(space: Space, childOpts?: SpaceChildEntityOptions): Promise<void>;
/**
* Removes a child space from the space. Must be joined to the current space (not needed for child space).
* @param {Space} space The space to remove.
* @returns {Promise<void>} Resolves when complete.
*/
removeChildSpace(space: Space): Promise<void>;
/**
* Adds a child room to the space. Must be joined to both the room and the space.
* @param {string} roomId The room ID to add.
* @param {SpaceChildEntityOptions} childOpts Additional options for the child space.
* @returns {Promise<void>} Resolves when complete.
*/
addChildRoom(roomId: string, childOpts?: SpaceChildEntityOptions): Promise<void>;
/**
* Removes a child room from the space. Must be joined to the current space (not needed for child room).
* @param {string} roomId The room ID to remove.
* @returns {Promise<void>} Resolves when complete.
*/
removeChildRoom(roomId: string): Promise<void>;
/**
* Gets all the child rooms on the space. These may be spaces or other rooms.
* @returns {Promise<SpaceEntityMap>} Resolves to a map of children for this space.
*/
getChildEntities(): Promise<SpaceEntityMap>;
/**
* Invite a user to the current space.
* @param {string} userId The user ID to invite.
* @returns {Promise<void>} Resolves when completed.
*/
inviteUser(userId: string): Promise<any>;
}

View File

@@ -0,0 +1,93 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Space = void 0;
const MatrixEntity_1 = require("../helpers/MatrixEntity");
const simple_validation_1 = require("../simple-validation");
const SpaceChildEvent_1 = require("./events/SpaceChildEvent");
/**
* An instance representing a Matrix Space. A space is tied to a room.
* @category Models
*/
class Space {
roomId;
client;
constructor(roomId, client) {
this.roomId = roomId;
this.client = client;
}
/**
* Creates a new child space under this space.
* @param {SpaceCreateOptions} opts The options for the new space.
* @returns {Promise<Space>} Resolves to the created space.
*/
async createChildSpace(opts) {
const space = await this.client.createSpace(opts);
await this.addChildSpace(space, opts);
return space;
}
/**
* Adds a child space to the space. Must be joined to both spaces.
* @param {Space} space The space to add.
* @param {SpaceChildEntityOptions} childOpts Related options for the child's representation.
* @returns {Promise<Space>} Resolves when complete.
*/
async addChildSpace(space, childOpts = {}) {
await this.addChildRoom(space.roomId, childOpts);
}
/**
* Removes a child space from the space. Must be joined to the current space (not needed for child space).
* @param {Space} space The space to remove.
* @returns {Promise<void>} Resolves when complete.
*/
async removeChildSpace(space) {
await this.removeChildRoom(space.roomId);
}
/**
* Adds a child room to the space. Must be joined to both the room and the space.
* @param {string} roomId The room ID to add.
* @param {SpaceChildEntityOptions} childOpts Additional options for the child space.
* @returns {Promise<void>} Resolves when complete.
*/
async addChildRoom(roomId, childOpts = {}) {
const via = childOpts.via ?? [new MatrixEntity_1.UserID(await this.client.getUserId()).domain];
const childContent = { via };
if (childOpts.suggested)
childContent.suggested = childOpts.suggested;
if (childOpts.order) {
(0, simple_validation_1.validateSpaceOrderString)(childOpts.order);
childContent.order = childOpts.order;
}
await this.client.sendStateEvent(this.roomId, "m.space.child", roomId, childContent);
}
/**
* Removes a child room from the space. Must be joined to the current space (not needed for child room).
* @param {string} roomId The room ID to remove.
* @returns {Promise<void>} Resolves when complete.
*/
async removeChildRoom(roomId) {
await this.client.sendStateEvent(this.roomId, "m.space.child", roomId, {});
}
/**
* Gets all the child rooms on the space. These may be spaces or other rooms.
* @returns {Promise<SpaceEntityMap>} Resolves to a map of children for this space.
*/
async getChildEntities() {
const roomState = await this.client.getRoomState(this.roomId);
const mapping = {};
roomState
.filter(s => s.type === "m.space.child")
.filter(s => s.content?.via)
.forEach(s => mapping[s.state_key] = new SpaceChildEvent_1.SpaceChildEvent(s));
return mapping;
}
/**
* Invite a user to the current space.
* @param {string} userId The user ID to invite.
* @returns {Promise<void>} Resolves when completed.
*/
async inviteUser(userId) {
return this.client.inviteUser(userId, this.roomId);
}
}
exports.Space = Space;
//# sourceMappingURL=Spaces.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Spaces.js","sourceRoot":"","sources":["../../src/models/Spaces.ts"],"names":[],"mappings":";;;AACA,0DAAiD;AACjD,4DAAgE;AAChE,8DAAmF;AA2EnF;;;GAGG;AACH,MAAa,KAAK;IACqB;IAAgC;IAAnE,YAAmC,MAAc,EAAkB,MAAoB;QAApD,WAAM,GAAN,MAAM,CAAQ;QAAkB,WAAM,GAAN,MAAM,CAAc;IACvF,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,gBAAgB,CAAC,IAAkB;QAC5C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAClD,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACtC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,aAAa,CAAC,KAAY,EAAE,YAAqC,EAAE;QAC5E,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,gBAAgB,CAAC,KAAY;QACtC,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,YAAY,CAAC,MAAc,EAAE,YAAqC,EAAE;QAC7E,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,IAAI,qBAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;QAChF,MAAM,YAAY,GAA2B,EAAE,GAAG,EAAE,CAAC;QAErD,IAAI,SAAS,CAAC,SAAS;YAAE,YAAY,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;QACtE,IAAI,SAAS,CAAC,KAAK,EAAE;YACjB,IAAA,4CAAwB,EAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAC1C,YAAY,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;SACxC;QAED,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACzF,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,MAAc;QACvC,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,gBAAgB;QACzB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9D,MAAM,OAAO,GAAmB,EAAE,CAAC;QACnC,SAAS;aACJ,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CAAC;aACvC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC;aAC3B,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,iCAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QACjE,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,UAAU,CAAC,MAAc;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;CACJ;AApFD,sBAoFC"}

View File

@@ -0,0 +1,8 @@
/**
* A Third Party Identifier (3PID or threepid)
* @category Models
*/
export interface Threepid {
kind: "email" | "msisdn" | string;
address: string;
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Threepid.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Threepid.js","sourceRoot":"","sources":["../../src/models/Threepid.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,27 @@
import { StateEvent } from "./RoomEvent";
/**
* The content definition for m.room.aliases events
* @category Matrix event contents
* @see AliasesEvent
*/
export interface AliasesEventContent {
/**
* The aliases this domain has published to the room.
*/
aliases: string[];
}
/**
* Represents an m.room.aliases state event
* @category Matrix events
*/
export declare class AliasesEvent extends StateEvent<AliasesEventContent> {
constructor(event: any);
/**
* The domain the aliases belong to.
*/
get forDomain(): string;
/**
* The aliases the domain has published to the room.
*/
get aliases(): string[];
}

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AliasesEvent = void 0;
const RoomEvent_1 = require("./RoomEvent");
/**
* Represents an m.room.aliases state event
* @category Matrix events
*/
class AliasesEvent extends RoomEvent_1.StateEvent {
constructor(event) {
super(event);
}
/**
* The domain the aliases belong to.
*/
get forDomain() {
return this.stateKey;
}
/**
* The aliases the domain has published to the room.
*/
get aliases() {
return this.content.aliases || [];
}
}
exports.AliasesEvent = AliasesEvent;
//# sourceMappingURL=AliasesEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AliasesEvent.js","sourceRoot":"","sources":["../../../src/models/events/AliasesEvent.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAczC;;;GAGG;AACH,MAAa,YAAa,SAAQ,sBAA+B;IAC7D,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IACtC,CAAC;CACJ;AAlBD,oCAkBC"}

View File

@@ -0,0 +1,23 @@
import { StateEvent } from "./RoomEvent";
/**
* The content definition for m.room.canonical_alias events
* @category Matrix event contents
* @see CanonicalAliasEvent
*/
export interface CanonicalAliasEventContent {
/**
* The canonical alias for the room.
*/
alias: string;
}
/**
* Represents an m.room.canonical_alias state event
* @category Matrix events
*/
export declare class CanonicalAliasEvent extends StateEvent<CanonicalAliasEventContent> {
constructor(event: any);
/**
* The alias the room is considering canonical
*/
get aliases(): string;
}

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CanonicalAliasEvent = void 0;
const RoomEvent_1 = require("./RoomEvent");
/**
* Represents an m.room.canonical_alias state event
* @category Matrix events
*/
class CanonicalAliasEvent extends RoomEvent_1.StateEvent {
constructor(event) {
super(event);
}
/**
* The alias the room is considering canonical
*/
get aliases() {
return this.content.alias;
}
}
exports.CanonicalAliasEvent = CanonicalAliasEvent;
//# sourceMappingURL=CanonicalAliasEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CanonicalAliasEvent.js","sourceRoot":"","sources":["../../../src/models/events/CanonicalAliasEvent.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAczC;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,sBAAsC;IAC3E,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC9B,CAAC;CACJ;AAXD,kDAWC"}

View File

@@ -0,0 +1,62 @@
import { StateEvent } from "./RoomEvent";
/**
* Information about the previous room.
* @category Matrix event info
* @see CreateEventContent
*/
export interface PreviousRoomInfo {
/**
* The old room ID.
*/
room_id: string;
/**
* The last known event ID in the old room.
*/
event_id: string;
}
/**
* The content definition for m.room.create events
* @category Matrix event contents
* @see CreateEvent
*/
export interface CreateEventContent extends Record<string, unknown> {
/**
* The user ID who created the room.
*/
creator: string;
/**
* Whether or not this room is federated. Default true.
*/
"m.federate"?: boolean;
/**
* The version of the room. Default "1".
*/
room_version?: string;
/**
* Information about the old room.
*/
predecessor?: PreviousRoomInfo;
/**
* The type of the room, if applicable. For example, `m.space`.
*/
type?: string;
}
/**
* Represents an m.room.create state event
* @category Matrix events
*/
export declare class CreateEvent extends StateEvent<CreateEventContent> {
constructor(event: any);
/**
* The user ID who created the room.
*/
get creator(): string;
/**
* The version of the room. Defaults to "1".
*/
get version(): string;
/**
* Whether or not the room is federated. Default true (federated).
*/
get federated(): boolean;
}

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateEvent = void 0;
const RoomEvent_1 = require("./RoomEvent");
/**
* Represents an m.room.create state event
* @category Matrix events
*/
class CreateEvent extends RoomEvent_1.StateEvent {
constructor(event) {
super(event);
}
/**
* The user ID who created the room.
*/
get creator() {
return this.content.creator || this.sender;
}
/**
* The version of the room. Defaults to "1".
*/
get version() {
return this.content.room_version || "1";
}
/**
* Whether or not the room is federated. Default true (federated).
*/
get federated() {
return this.content['m.federate'] !== false;
}
}
exports.CreateEvent = CreateEvent;
//# sourceMappingURL=CreateEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CreateEvent.js","sourceRoot":"","sources":["../../../src/models/events/CreateEvent.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAmDzC;;;GAGG;AACH,MAAa,WAAY,SAAQ,sBAA8B;IAC3D,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,GAAG,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,KAAK,CAAC;IAChD,CAAC;CACJ;AAzBD,kCAyBC"}

View File

@@ -0,0 +1,42 @@
import { RoomEvent } from "./RoomEvent";
import { EncryptionAlgorithm, IMegolmEncrypted } from "../Crypto";
/**
* The content definition for m.room.encrypted events
* @category Matrix event contents
* @see EncryptedRoomEvent
*/
export interface EncryptedRoomEventContent {
algorithm: EncryptionAlgorithm;
/**
* For m.megolm.v1.aes-sha2 messages. The sender's Curve25519 key.
*/
sender_key?: string;
/**
* For m.megolm.v1.aes-sha2 messages. The session ID established by the sender.
*/
session_id?: string;
/**
* For m.megolm.v1.aes-sha2 messages. The encrypted payload.
*/
ciphertext?: string;
/**
* For m.megolm.v1.aes-sha2 messages. The sender's device ID.
*/
device_id?: string;
}
/**
* Represents an m.room.encrypted room event
* @category Matrix events
*/
export declare class EncryptedRoomEvent extends RoomEvent<EncryptedRoomEventContent> {
constructor(event: any);
/**
* The encryption algorithm used on the event. Should match the m.room.encryption
* state config.
*/
get algorithm(): EncryptionAlgorithm;
/**
* The Megolm encrypted payload information.
*/
get megolmProperties(): IMegolmEncrypted;
}

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EncryptedRoomEvent = void 0;
const RoomEvent_1 = require("./RoomEvent");
/**
* Represents an m.room.encrypted room event
* @category Matrix events
*/
class EncryptedRoomEvent extends RoomEvent_1.RoomEvent {
constructor(event) {
super(event);
}
/**
* The encryption algorithm used on the event. Should match the m.room.encryption
* state config.
*/
get algorithm() {
return this.content.algorithm;
}
/**
* The Megolm encrypted payload information.
*/
get megolmProperties() {
return this.content;
}
}
exports.EncryptedRoomEvent = EncryptedRoomEvent;
//# sourceMappingURL=EncryptedRoomEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EncryptedRoomEvent.js","sourceRoot":"","sources":["../../../src/models/events/EncryptedRoomEvent.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAkCxC;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,qBAAoC;IACxE,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;;OAGG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,IAAW,gBAAgB;QACvB,OAAO,IAAI,CAAC,OAA2B,CAAC;IAC5C,CAAC;CACJ;AAnBD,gDAmBC"}

View File

@@ -0,0 +1,47 @@
import { StateEvent } from "./RoomEvent";
/**
* The kinds of room encryption algorithms allowed by the spec.
* @category Models
* @see EncryptionEvent
*/
export declare enum RoomEncryptionAlgorithm {
MegolmV1AesSha2 = "m.megolm.v1.aes-sha2"
}
/**
* The content definition for m.room.encryption events
* @category Matrix event contents
* @see EncryptionEvent
*/
export interface EncryptionEventContent {
/**
* The encryption algorithm for the room.
*/
algorithm: string | RoomEncryptionAlgorithm;
/**
* How long a session should be used before changing it.
*/
rotation_period_ms?: number;
/**
* How many messages should be sent before changing the session.
*/
rotation_period_msgs?: number;
}
/**
* Represents an m.room.encryption state event
* @category Matrix events
*/
export declare class EncryptionEvent extends StateEvent<EncryptionEventContent> {
constructor(event: any);
/**
* The encryption algorithm for the room.
*/
get algorithm(): string | RoomEncryptionAlgorithm;
/**
* How long a session should be used before changing it. Defaults to a week.
*/
get rotationPeriodMs(): number;
/**
* How many messages should be sent before a session changes. Defaults to 100.
*/
get rotationPeriodMessages(): number;
}

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EncryptionEvent = exports.RoomEncryptionAlgorithm = void 0;
const RoomEvent_1 = require("./RoomEvent");
/**
* The kinds of room encryption algorithms allowed by the spec.
* @category Models
* @see EncryptionEvent
*/
var RoomEncryptionAlgorithm;
(function (RoomEncryptionAlgorithm) {
RoomEncryptionAlgorithm["MegolmV1AesSha2"] = "m.megolm.v1.aes-sha2";
})(RoomEncryptionAlgorithm || (exports.RoomEncryptionAlgorithm = RoomEncryptionAlgorithm = {}));
/**
* Represents an m.room.encryption state event
* @category Matrix events
*/
class EncryptionEvent extends RoomEvent_1.StateEvent {
constructor(event) {
super(event);
}
/**
* The encryption algorithm for the room.
*/
get algorithm() {
return this.content.algorithm;
}
/**
* How long a session should be used before changing it. Defaults to a week.
*/
get rotationPeriodMs() {
return this.content.rotation_period_ms ?? 604800000; // 1 week
}
/**
* How many messages should be sent before a session changes. Defaults to 100.
*/
get rotationPeriodMessages() {
return this.content.rotation_period_msgs ?? 100;
}
}
exports.EncryptionEvent = EncryptionEvent;
//# sourceMappingURL=EncryptionEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EncryptionEvent.js","sourceRoot":"","sources":["../../../src/models/events/EncryptionEvent.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAEzC;;;;GAIG;AACH,IAAY,uBAEX;AAFD,WAAY,uBAAuB;IAC/B,mEAAwC,CAAA;AAC5C,CAAC,EAFW,uBAAuB,uCAAvB,uBAAuB,QAElC;AAwBD;;;GAGG;AACH,MAAa,eAAgB,SAAQ,sBAAkC;IACnE,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,IAAW,gBAAgB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,IAAI,SAAS,CAAC,CAAC,SAAS;IAClE,CAAC;IAED;;OAEG;IACH,IAAW,sBAAsB;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,IAAI,GAAG,CAAC;IACpD,CAAC;CACJ;AAzBD,0CAyBC"}

View File

@@ -0,0 +1,26 @@
/**
* A Matrix event.
* @category Matrix events
*/
export declare class MatrixEvent<T extends (Object | unknown) = unknown> {
protected event: any;
constructor(event: any);
/**
* The user ID who sent this event.
*/
get sender(): string;
/**
* The type of this event.
*/
get type(): string;
/**
* The content for this event. May have no properties.
*/
get content(): T;
/**
* Gets the raw event that this MatrixEvent is using.
* Note that there's no guarantees on formats here - it is the exact
* same input to the constructor.
*/
get raw(): any;
}

View File

@@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MatrixEvent = void 0;
/**
* A Matrix event.
* @category Matrix events
*/
class MatrixEvent {
event;
constructor(event) {
this.event = event;
}
/**
* The user ID who sent this event.
*/
get sender() {
return this.event['sender'];
}
/**
* The type of this event.
*/
get type() {
return this.event['type'];
}
/**
* The content for this event. May have no properties.
*/
get content() {
return this.event['content'] || {};
}
/**
* Gets the raw event that this MatrixEvent is using.
* Note that there's no guarantees on formats here - it is the exact
* same input to the constructor.
*/
get raw() {
return this.event;
}
}
exports.MatrixEvent = MatrixEvent;
//# sourceMappingURL=Event.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Event.js","sourceRoot":"","sources":["../../../src/models/events/Event.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,WAAW;IACE;IAAtB,YAAsB,KAAU;QAAV,UAAK,GAAL,KAAK,CAAK;IAChC,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACH,IAAW,GAAG;QACV,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;CACJ;AAjCD,kCAiCC"}

View File

@@ -0,0 +1,15 @@
/**
* Represents the different kinds of events a bot/appservice might see.
* @category Matrix events
*/
export declare enum EventKind {
/**
* A room event. This could be a message event or a state event, and is associated with
* a room.
*/
RoomEvent = "room",
/**
* An ephemeral event, such as typing notifications or presence.
*/
EphemeralEvent = "ephemeral"
}

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventKind = void 0;
/**
* Represents the different kinds of events a bot/appservice might see.
* @category Matrix events
*/
var EventKind;
(function (EventKind) {
/**
* A room event. This could be a message event or a state event, and is associated with
* a room.
*/
EventKind["RoomEvent"] = "room";
/**
* An ephemeral event, such as typing notifications or presence.
*/
EventKind["EphemeralEvent"] = "ephemeral";
})(EventKind || (exports.EventKind = EventKind = {}));
//# sourceMappingURL=EventKind.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EventKind.js","sourceRoot":"","sources":["../../../src/models/events/EventKind.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,SAWX;AAXD,WAAY,SAAS;IACjB;;;OAGG;IACH,+BAAkB,CAAA;IAElB;;OAEG;IACH,yCAA4B,CAAA;AAChC,CAAC,EAXW,SAAS,yBAAT,SAAS,QAWpB"}

View File

@@ -0,0 +1,14 @@
/**
* Thrown when an event is invalid.
* @category Matrix events
*/
export declare class InvalidEventError extends Error {
constructor(message?: string);
}
/**
* Thrown when an event is redacted.
* @category Matrix events
*/
export declare class EventRedactedError extends InvalidEventError {
constructor(message?: string);
}

View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventRedactedError = exports.InvalidEventError = void 0;
/**
* Thrown when an event is invalid.
* @category Matrix events
*/
class InvalidEventError extends Error {
constructor(message = null) {
super(message);
}
}
exports.InvalidEventError = InvalidEventError;
/**
* Thrown when an event is redacted.
* @category Matrix events
*/
class EventRedactedError extends InvalidEventError {
constructor(message = null) {
super(message);
}
}
exports.EventRedactedError = EventRedactedError;
//# sourceMappingURL=InvalidEventError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"InvalidEventError.js","sourceRoot":"","sources":["../../../src/models/events/InvalidEventError.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IACxC,YAAY,UAAkB,IAAI;QAC9B,KAAK,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;CACJ;AAJD,8CAIC;AAED;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,iBAAiB;IACrD,YAAY,UAAkB,IAAI;QAC9B,KAAK,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;CACJ;AAJD,gDAIC"}

View File

@@ -0,0 +1,29 @@
import { StateEvent } from "./RoomEvent";
/**
* The types of join rules that are valid in Matrix.
* @category Matrix event info
* @see JoinRulesEventContent
*/
export type JoinRule = "public" | "knock" | "invite" | "private";
/**
* The content definition for m.room.join_rules events
* @category Matrix event contents
* @see JoinRulesEvent
*/
export interface JoinRulesEventContent {
/**
* The join rule for the room.
*/
join_rule: JoinRule;
}
/**
* Represents an m.room.join_rules state event
* @category Matrix events
*/
export declare class JoinRulesEvent extends StateEvent<JoinRulesEventContent> {
constructor(event: any);
/**
* The join rule for the room.
*/
get rule(): JoinRule;
}

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JoinRulesEvent = void 0;
const RoomEvent_1 = require("./RoomEvent");
/**
* Represents an m.room.join_rules state event
* @category Matrix events
*/
class JoinRulesEvent extends RoomEvent_1.StateEvent {
constructor(event) {
super(event);
}
/**
* The join rule for the room.
*/
get rule() {
return this.content.join_rule;
}
}
exports.JoinRulesEvent = JoinRulesEvent;
//# sourceMappingURL=JoinRulesEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"JoinRulesEvent.js","sourceRoot":"","sources":["../../../src/models/events/JoinRulesEvent.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAqBzC;;;GAGG;AACH,MAAa,cAAe,SAAQ,sBAAiC;IACjE,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAClC,CAAC;CACJ;AAXD,wCAWC"}

View File

@@ -0,0 +1,59 @@
import { StateEvent } from "./RoomEvent";
/**
* The types of membership that are valid in Matrix.
* @category Matrix event info
* @see MembershipEventContent
*/
export type Membership = "join" | "leave" | "ban" | "invite";
/**
* The effective membership states a user can be in.
* @category Matrix event info
* @see MembershipEventContent
*/
export type EffectiveMembership = "join" | "leave" | "invite";
/**
* The content definition for m.room.member events
* @category Matrix event contents
* @see MembershipEvent
*/
export interface MembershipEventContent {
avatar_url?: string;
displayname?: string;
reason?: string;
membership: Membership;
is_direct?: boolean;
unsigned?: any;
third_party_invite?: {
display_name: string;
signed: any;
};
}
/**
* Represents an m.room.member state event
* @category Matrix events
*/
export declare class MembershipEvent extends StateEvent<MembershipEventContent> {
constructor(event: any);
/**
* True if the membership event targets the sender. False otherwise.
*
* This will typically by false for kicks and bans.
*/
get ownMembership(): boolean;
/**
* The reason why a user may have sent this membership.
*/
get reason(): string | undefined;
/**
* The user ID the membership affects.
*/
get membershipFor(): string;
/**
* The user's membership.
*/
get membership(): Membership;
/**
* The user's effective membership.
*/
get effectiveMembership(): EffectiveMembership;
}

View File

@@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MembershipEvent = void 0;
const RoomEvent_1 = require("./RoomEvent");
const InvalidEventError_1 = require("./InvalidEventError");
/**
* Represents an m.room.member state event
* @category Matrix events
*/
class MembershipEvent extends RoomEvent_1.StateEvent {
constructor(event) {
super(event);
}
/**
* True if the membership event targets the sender. False otherwise.
*
* This will typically by false for kicks and bans.
*/
get ownMembership() {
return this.membershipFor === this.sender;
}
/**
* The reason why a user may have sent this membership.
*/
get reason() {
return this.content.reason;
}
/**
* The user ID the membership affects.
*/
get membershipFor() {
return this.stateKey;
}
/**
* The user's membership.
*/
get membership() {
const membership = this.content.membership;
if (!membership)
throw new InvalidEventError_1.InvalidEventError("no membership field in content");
return membership;
}
/**
* The user's effective membership.
*/
get effectiveMembership() {
if (this.membership === "join")
return "join";
if (this.membership === "invite")
return "invite";
return "leave";
}
}
exports.MembershipEvent = MembershipEvent;
//# sourceMappingURL=MembershipEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MembershipEvent.js","sourceRoot":"","sources":["../../../src/models/events/MembershipEvent.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AACzC,2DAAwD;AAkCxD;;;GAGG;AACH,MAAa,eAAgB,SAAQ,sBAAkC;IACnE,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,aAAa,KAAK,IAAI,CAAC,MAAM,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QAC3C,IAAI,CAAC,UAAU;YAAE,MAAM,IAAI,qCAAiB,CAAC,gCAAgC,CAAC,CAAC;QAC/E,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,mBAAmB;QAC1B,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM;YAAE,OAAO,MAAM,CAAC;QAC9C,IAAI,IAAI,CAAC,UAAU,KAAK,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAClD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA7CD,0CA6CC"}

View File

@@ -0,0 +1,233 @@
import { RoomEvent } from "./RoomEvent";
/**
* The types of messages that are valid in Matrix.
* @category Matrix event info
* @see MessageEventContent
*/
export type MessageType = "m.text" | "m.emote" | "m.notice" | "m.image" | "m.file" | "m.audio" | "m.location" | "m.video" | string;
/**
* Information about a file in Matrix
* @category Matrix event info
* @see MessageEventContent
*/
export interface FileInfo {
/**
* The size of the file in bytes.
*/
size?: number;
/**
* The type of file.
*/
mimetype?: string;
}
/**
* Information about a thumbnail in Matrix
* @category Matrix event info
* @see MessageEventContent
*/
export interface ThumbnailInfo {
/**
* The size of the thumbnail in bytes.
*/
size?: number;
/**
* The type of thumbnail.
*/
mimetype?: string;
/**
* The intended height of the thumbnail in pixels.
*/
h: number;
/**
* The intended width of the thumbnail in pixels.
*/
w: number;
}
/**
* Information about a file's thumbnail.
* @category Matrix event info
* @see MessageEventContent
*/
export interface ThumbnailedFileInfo {
/**
* A URL to a thumbnail for the file, if unencrypted.
*/
thumbnail_url?: string;
/**
* The encrypted thumbnail file information, if encrypted.
*/
thumbnail_file?: EncryptedFile;
/**
* Information about the thumbnail. Optionally included if a thumbnail_url is specified.
*/
thumbnail_info?: ThumbnailInfo;
}
/**
* Information about a file that has a thumbnail
* @category Matrix event info
* @see MessageEventContent
*/
export interface FileWithThumbnailInfo extends FileInfo, ThumbnailedFileInfo {
}
/**
* Information about a file that has a width and height.
* @category Matrix event info
* @see MessageEventContent
*/
export interface DimensionalFileInfo extends FileWithThumbnailInfo {
/**
* The intended height of the media in pixels.
*/
h: number;
/**
* The intended width of the media in pixels.
*/
w: number;
}
/**
* Information about a file that has a time dimension.
* @category Matrix event info
* @see MessageEventContent
*/
export interface TimedFileInfo extends FileInfo {
/**
* The duration of the media in milliseconds.
*/
duration: number;
}
/**
* Information about a video file.
* @category Matrix event info
* @see MessageEventContent
*/
export interface VideoFileInfo extends DimensionalFileInfo, TimedFileInfo {
}
/**
* The content definition for m.room.message events with a type of m.audio
* @category Matrix event contents
* @see MessageEvent
*/
export interface AudioMessageEventContent extends FileMessageEventContent {
/**
* Information about the file.
*/
info?: TimedFileInfo;
}
/**
* The content definition for m.room.message events with a type of m.video
* @category Matrix event contents
* @see MessageEvent
*/
export interface VideoMessageEventContent extends FileMessageEventContent {
/**
* Information about the file.
*/
info?: VideoFileInfo;
}
/**
* The content definition for m.room.message events with a type of m.image
* @category Matrix event contents
* @see MessageEvent
*/
export interface ImageMessageEventContent extends FileMessageEventContent {
/**
* Information about the file.
*/
info?: DimensionalFileInfo;
}
/**
* The content definition for m.room.message events with a type of m.file
* @category Matrix event contents
* @see MessageEvent
*/
export interface FileMessageEventContent extends MessageEventContent {
/**
* Information about the file.
*/
info?: FileWithThumbnailInfo;
/**
* URL to the file, if unencrypted.
*/
url: string;
/**
* The encrypted file, if encrypted.
*/
file: EncryptedFile;
}
/**
* An encrypted file.
* @category Matrix event contents
* @see MessageEvent
*/
export interface EncryptedFile {
url: string;
key: {
kty: "oct";
key_ops: string[];
alg: "A256CTR";
k: string;
ext: true;
};
iv: string;
hashes: {
sha256: string;
};
v: "v2";
}
/**
* The content definition for m.room.message events with a type of m.location
* @category Matrix event contents
* @see MessageEvent
*/
export interface LocationMessageEventContent extends MessageEventContent {
/**
* Information about the location.
*/
info?: ThumbnailedFileInfo;
/**
* A geo URI of the location.
*/
geo_uri?: string;
}
/**
* The content definition for m.room.message events with types of m.text, m.emote, and m.notice
* @category Matrix event contents
* @see MessageEvent
*/
export interface TextualMessageEventContent extends MessageEventContent {
format?: string;
formatted_body?: string;
}
/**
* The content definition for m.room.message events
* @category Matrix event contents
* @see MessageEvent
*/
export interface MessageEventContent {
body: string;
msgtype: MessageType;
external_url?: string;
}
/**
* Represents an m.room.message room event
* @category Matrix events
*/
export declare class MessageEvent<T extends MessageEventContent> extends RoomEvent<T> {
constructor(event: any);
/**
* Whether or not the event is redacted (or looked redacted).
*/
get isRedacted(): boolean;
/**
* The message's type.
*/
get messageType(): MessageType;
/**
* The `body` of the message.
*/
get textBody(): string;
/**
* The `external_url` of the message, if it exists
*/
get externalUrl(): string | undefined;
}

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessageEvent = void 0;
const RoomEvent_1 = require("./RoomEvent");
const InvalidEventError_1 = require("./InvalidEventError");
/**
* Represents an m.room.message room event
* @category Matrix events
*/
class MessageEvent extends RoomEvent_1.RoomEvent {
constructor(event) {
super(event);
}
/**
* Whether or not the event is redacted (or looked redacted).
*/
get isRedacted() {
// Presume the event redacted if we're missing a body or message type
const noContent = !this.content.body && this.content.body !== "";
const noMsgtype = !this.content.msgtype && this.content.msgtype !== "";
return noContent || noMsgtype;
}
/**
* The message's type.
*/
get messageType() {
const type = this.content.msgtype;
if (!type && type !== "")
throw new InvalidEventError_1.EventRedactedError("missing msgtype");
return type;
}
/**
* The `body` of the message.
*/
get textBody() {
const body = this.content.body;
if (!body && body !== "")
throw new InvalidEventError_1.EventRedactedError("missing body");
return body;
}
/**
* The `external_url` of the message, if it exists
*/
get externalUrl() {
return this.content.external_url || undefined;
}
}
exports.MessageEvent = MessageEvent;
//# sourceMappingURL=MessageEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MessageEvent.js","sourceRoot":"","sources":["../../../src/models/events/MessageEvent.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,2DAAyD;AAuPzD;;;GAGG;AACH,MAAa,YAA4C,SAAQ,qBAAY;IACzE,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,qEAAqE;QACrE,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,EAAE,CAAC;QACjE,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,EAAE,CAAC;QACvE,OAAO,SAAS,IAAI,SAAS,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,EAAE;YAAE,MAAM,IAAI,sCAAkB,CAAC,iBAAiB,CAAC,CAAC;QAC1E,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAC/B,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,EAAE;YAAE,MAAM,IAAI,sCAAkB,CAAC,cAAc,CAAC,CAAC;QACvE,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,SAAS,CAAC;IAClD,CAAC;CACJ;AAvCD,oCAuCC"}

View File

@@ -0,0 +1,23 @@
import { StateEvent } from "./RoomEvent";
/**
* The content definition for m.room.pinned_events events
* @category Matrix event contents
* @see PinnedEventsEvent
*/
export interface PinnedEventsEventContent {
/**
* The event IDs that are pinned in the room.
*/
pinned: string[];
}
/**
* Represents an m.room.pinned_events state event
* @category Matrix events
*/
export declare class PinnedEventsEvent extends StateEvent<PinnedEventsEventContent> {
constructor(event: any);
/**
* The event IDs that are pinned in the room.
*/
get pinnedEventIds(): string[];
}

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PinnedEventsEvent = void 0;
const RoomEvent_1 = require("./RoomEvent");
/**
* Represents an m.room.pinned_events state event
* @category Matrix events
*/
class PinnedEventsEvent extends RoomEvent_1.StateEvent {
constructor(event) {
super(event);
}
/**
* The event IDs that are pinned in the room.
*/
get pinnedEventIds() {
return this.content.pinned || [];
}
}
exports.PinnedEventsEvent = PinnedEventsEvent;
//# sourceMappingURL=PinnedEventsEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PinnedEventsEvent.js","sourceRoot":"","sources":["../../../src/models/events/PinnedEventsEvent.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAczC;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,sBAAoC;IACvE,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;IACrC,CAAC;CACJ;AAXD,8CAWC"}

View File

@@ -0,0 +1,96 @@
import { StateEvent } from "./RoomEvent";
/**
* The content definition for m.room.power_levels events
* @category Matrix event contents
* @see PowerLevelsEvent
*/
export interface PowerLevelsEventContent {
/**
* The power level required to ban. Default 50.
*/
ban?: number;
/**
* A map of event types to the power level required to send them.
*/
events?: {
[eventType: string]: number;
};
/**
* The power level required to send events in the room. Default 50.
*/
events_default?: number;
/**
* The power level required to invite users to the room. Default 50.
*/
invite?: number;
/**
* The power level required to kick users from the room. Default 50.
*/
kick?: number;
/**
* The power level required to redact other people's events in the room. Default 50.
*/
redact?: number;
/**
* The power level required to send state events in the room. Default 50.
*/
state_default?: number;
/**
* A map of user IDs to power levels.
*/
users?: {
[userId: string]: number;
};
/**
* The power level of users not listed in `users`. Default 0.
*/
users_default?: number;
/**
* Power levels required to send certain kinds of notifications.
*/
notifications?: {
/**
* The power level required to send "@room" notifications. Default 50.
*/
room?: number;
};
}
/**
* Represents an m.room.power_levels state event
* @category Matrix events
*/
export declare class PowerLevelsEvent extends StateEvent<PowerLevelsEventContent> {
constructor(event: any);
/**
* The power level required to ban users.
*/
get banLevel(): number;
/**
* The power level required to invite users.
*/
get inviteLevel(): number;
/**
* The power level required to kick users.
*/
get kickLevel(): number;
/**
* The power level required to redact messages sent by other users.
*/
get redactLevel(): number;
/**
* The power level required to send "@room" notifications.
*/
get notifyWholeRoomLevel(): number;
/**
* The default power level for users.
*/
get defaultUserLevel(): number;
/**
* The default power level required to send state events.
*/
get defaultStateEventLevel(): number;
/**
* The default power level required to send room events.
*/
get defaultEventLevel(): number;
}

View File

@@ -0,0 +1,70 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PowerLevelsEvent = void 0;
const RoomEvent_1 = require("./RoomEvent");
function defaultNum(val, def) {
if (!val && val !== 0)
return def;
return val;
}
/**
* Represents an m.room.power_levels state event
* @category Matrix events
*/
class PowerLevelsEvent extends RoomEvent_1.StateEvent {
constructor(event) {
super(event);
}
/**
* The power level required to ban users.
*/
get banLevel() {
return defaultNum(this.content.ban, 50);
}
/**
* The power level required to invite users.
*/
get inviteLevel() {
return defaultNum(this.content.invite, 50);
}
/**
* The power level required to kick users.
*/
get kickLevel() {
return defaultNum(this.content.kick, 50);
}
/**
* The power level required to redact messages sent by other users.
*/
get redactLevel() {
return defaultNum(this.content.redact, 50);
}
/**
* The power level required to send "@room" notifications.
*/
get notifyWholeRoomLevel() {
if (!this.content.notifications)
return 50;
return defaultNum(this.content.notifications.room, 50);
}
/**
* The default power level for users.
*/
get defaultUserLevel() {
return defaultNum(this.content.users_default, 0);
}
/**
* The default power level required to send state events.
*/
get defaultStateEventLevel() {
return defaultNum(this.content.state_default, 50);
}
/**
* The default power level required to send room events.
*/
get defaultEventLevel() {
return defaultNum(this.content.events_default, 50);
}
}
exports.PowerLevelsEvent = PowerLevelsEvent;
//# sourceMappingURL=PowerLevelsEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PowerLevelsEvent.js","sourceRoot":"","sources":["../../../src/models/events/PowerLevelsEvent.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAgEzC,SAAS,UAAU,CAAC,GAAuB,EAAE,GAAW;IACpD,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAClC,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,sBAAmC;IACrE,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,IAAW,oBAAoB;QAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa;YAAE,OAAO,EAAE,CAAC;QAC3C,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,IAAW,gBAAgB;QACvB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,IAAW,sBAAsB;QAC7B,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,IAAW,iBAAiB;QACxB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IACvD,CAAC;CACJ;AA7DD,4CA6DC"}

View File

@@ -0,0 +1,56 @@
import { MatrixEvent } from "./Event";
/**
* The allowed states of presence in Matrix.
*
* * `online`: The default state when the user is connected to an event stream.
* * `unavailable`: The user is not reachable at this time e.g. they are idle.
* * `offline`: The user is not connected to an event stream or is explicitly suppressing their profile information from being sent.
*
* @category Matrix event info
* @see PresenceEventContent
*/
export type PresenceState = "online" | "offline" | "unavailable";
/**
* Event content for m.presence events
* @category Matrix event contents
* @see PresenceEvent
*/
export interface PresenceEventContent {
/**
* The avatar URL for the user, if any.
*/
avatar_url?: string;
/**
* The display name for the user, if any.
*/
displayname?: string;
/**
* How long ago the user performed some action, in milliseconds.
*/
last_active_ago?: number;
/**
* The user's presence state.
*
* @see {@link PresenceState} for a description of each presence key.
*/
presence: PresenceState;
/**
* Whether or not the user is currently active.
*/
currently_active?: boolean;
/**
* A status message associated with this presence.
*/
status_msg?: string;
}
/**
* Wraps a m.presence ephemeral event in Matrix
* @category Matrix events
*/
export declare class PresenceEvent extends MatrixEvent<PresenceEventContent> {
constructor(event: any);
/**
* The current presence state for the user.
*/
get presence(): PresenceState;
}

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PresenceEvent = void 0;
const Event_1 = require("./Event");
/**
* Wraps a m.presence ephemeral event in Matrix
* @category Matrix events
*/
class PresenceEvent extends Event_1.MatrixEvent {
constructor(event) {
super(event);
}
/**
* The current presence state for the user.
*/
get presence() {
return this.content.presence;
}
}
exports.PresenceEvent = PresenceEvent;
//# sourceMappingURL=PresenceEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PresenceEvent.js","sourceRoot":"","sources":["../../../src/models/events/PresenceEvent.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAqDtC;;;GAGG;AACH,MAAa,aAAc,SAAQ,mBAAiC;IAChE,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACjC,CAAC;CACJ;AAXD,sCAWC"}

View File

@@ -0,0 +1,28 @@
import { RoomEvent } from "./RoomEvent";
/**
* The content definition for m.room.redaction events
* @category Matrix event contents
* @see RedactionEvent
*/
export interface RedactionEventContent {
/**
* The event ID or IDs this event redacts.
*/
redacts?: string | string[];
}
/**
* Represents an m.room.redaction room event
* @category Matrix events
*/
export declare class RedactionEvent extends RoomEvent<RedactionEventContent> {
constructor(event: any);
/**
* The event ID this event redacts.
* @deprecated It is possible for multiple events to be redacted depending on the room version.
*/
get redactsEventId(): string;
/**
* The event IDs this event redacts.
*/
get redactsEventIds(): string[];
}

Some files were not shown because too many files have changed in this diff Show More