Experimental
Experimental
The widget api to use for communication.
The capabilities the widget client will request.
The room id the widget is associated with.
The configuration options for this client.
Whether to send a content loaded widget action immediately after initial setup.
Set to false
if the widget uses waitForIFrameLoad=true
(in this case the client does not expect a content loaded action at all),
or if the the widget wants to send the ContentLoaded
action at a later point in time after the initial setup.
Experimental
baseOptional
Experimental
callProtected
Optional
Experimental
canExperimental
canProtected
Experimental
canProtected
Optional
Experimental
checkProtected
Optional
Experimental
clientExperimental
clientProtected
Optional
Experimental
clientProtected
Optional
Experimental
clientProtected
Optional
Experimental
clientExperimental
credentialsExperimental
cryptoExperimental
deviceProtected
Experimental
fallbackICEServerExperimental
forceTURNOptional
Experimental
groupExperimental
httpExperimental
iceOptional
Experimental
idOptional
Experimental
identityReadonly
Experimental
ignoredProtected
Experimental
isReadonly
Experimental
isOptional
Experimental
livekitReadonly
Experimental
matrixRTCProtected
Experimental
mediaProtected
Experimental
notifExperimental
olmProtected
Experimental
ongoingProtected
Experimental
peekProtected
Experimental
pushOptional
Experimental
pushExperimental
reOptional
Experimental
roomOptional
Experimental
schedulerProtected
Optional
Experimental
serverProtected
Experimental
sessionExperimental
supportsProtected
Optional
Experimental
syncProtected
Experimental
syncedProtected
Optional
Experimental
syncExperimental
timelineProtected
Experimental
turnProtected
Experimental
turnProtected
Experimental
txnExperimental
urlExperimental
useExperimental
usingProtected
Optional
Experimental
verificationStatic
Readonly
Experimental
RESTORE_Experimental
Experimental
Access the server-side secret storage API for this client.
Experimental
Get all pending delayed events for the calling user.
Note: This endpoint is unstable, and can throw an Error
.
Check progress on MSC4140 for more details.
Optional
fromToken: stringExperimental
Gets a set of room IDs in common with another user.
Note: This endpoint is unstable, and can throw an Error
.
Check progress on MSC2666 for more details.
The userId to check.
Promise which resolves to an array of rooms
Experimental
Send a delayed timeline event.
Note: This endpoint is unstable, and can throw an Error
.
Check progress on MSC4140 for more details.
Optional
txnId: stringExperimental
This currently relies on an unstable MSC (MSC4140).
Experimental
This currently relies on an unstable MSC (MSC4140).
Experimental
Alias for on.
Experimental
Promise which resolves: an empty object {}
Experimental
Add a 3PID to your homeserver account. This API does not use an identity server, as the homeserver is expected to handle 3PID ownership validation.
A object with 3PID validation data from having called
account/3pid/<medium>/requestToken
on the homeserver.
Promise which resolves: to an empty object {}
Experimental
Experimental
Take a result from an earlier searchRoomEvents call, and backfill results.
the results object to be updated
Promise which resolves: updated result object
Experimental
Optional
reason: stringOptional.
Promise which resolves: TODO
Experimental
Bind a 3PID for discovery onto an identity server via the homeserver. The identity server handles 3PID ownership validation and the homeserver records the new binding to track where all 3PIDs for the account are bound.
A object with 3PID validation data from having called
validate/<medium>/requestToken
on the identity server. It should also
contain id_server
and id_access_token
fields as well.
Promise which resolves: to an empty object {}
Protected
buildExperimental
Construct a SyncApiOptions for this client, suitable for passing into the SyncApi constructor
Experimental
Looks up the public Matrix ID mappings for multiple 3PIDs.
Array of arrays containing [medium, address]
The access_token
field of the Identity
Server /account/register
response (see registerWithIdentityServer).
Promise which resolves: Lookup results from IS.
Experimental
Cancel a queued or unsent event.
Event to cancel
Experimental
Cancel a file upload in progress
The object returned from uploadContent
true if canceled, otherwise false
Experimental
Claim one-time keys
a list of [userId, deviceId] pairs
desired key type
Optional
timeout: numberthe time (in milliseconds) to wait for keys from remote servers
Promise which resolves: result object. Rejects: with an error response (MatrixError).
Experimental
Create an alias to room ID mapping.
The room alias to create.
The room ID to link the alias to.
Promise which resolves: an empty object {}
Experimental
Creates a new call. The place*Call methods on the returned call can be used to actually place a call
The room the call is to be placed in.
the call or null if the browser doesn't support calling.
Experimental
Create a new filter.
The HTTP body for the request
Promise which resolves to a Filter object.
Experimental
Creates a new group call and sends the associated state event to alert other members that the room now has a group call.
The room the call is to be placed in.
Optional
dataChannelsEnabled: booleanOptional
dataChannelOptions: IGroupCallDataChannelOptionsExperimental
Makes a request to /messages with the appropriate lazy loading filter set. XXX: if we do get rid of scrollback (as it's not used at the moment), we could inline this method again in paginateEventTimeline as that would then be the only call-site
Experimental
Create a new room.
a list of options to pass to the /createRoom API.
Promise which resolves: {room_id: {string}}
Experimental
Makes a request to /messages with the appropriate lazy loading filter set. XXX: if we do get rid of scrollback (as it's not used at the moment), we could inline this method again in paginateEventTimeline as that would then be the only call-site
the maximum amount of events the retrieve
'f' or 'b'
Optional
timelineFilter: Filterthe timeline filter to pass
Experimental
Deactivates the logged-in account. Obviously, further calls that require authorisation should fail after this method is called. The state of the MatrixClient object is not affected: it is up to the caller to either reset or destroy the MatrixClient after this method succeeds.
Optional
auth: AuthDictOptional. Auth data to supply for User-Interactive auth.
Optional
erase: booleanOptional. If set, send as erase
attribute in the
JSON request body, indicating whether the account should be erased. Defaults
to false.
Promise which resolves: On success, the empty object
Experimental
Deactivates a user using Synapse's administrator API. This function is implementation specific and may change as a result.
the User ID to deactivate.
the deactivate response - see Synapse docs for information.
Experimental
Attempts to decrypt an event
The event to decrypt
Optional
options: IDecryptOptionsA decryption promise
Experimental
Experimental
Delete an alias to room ID mapping. This alias must be on your local server, and you must have sufficient access to do this operation.
The room alias to delete.
Promise which resolves: an empty object {}
.
Experimental
Delete the given device
device to delete
Optional
auth: AuthDictOptional. Auth data to supply for User-Interactive auth.
Promise which resolves: result object
Experimental
Optional
version: stringExperimental
Optional
version: stringExperimental
Optional
version: stringExperimental
Delete multiple device
IDs of the devices to delete
Optional
auth: AuthDictOptional. Auth data to supply for User-Interactive auth.
Promise which resolves: result object
Experimental
Promise which resolves: an empty object {}
Experimental
name of room tag to be removed
Promise which resolves: to an empty object
Experimental
The threepid medium (eg. 'email')
The threepid address (eg. 'bob@example.com') this must be as returned by getThreePids.
Promise which resolves: The server response on success (generally the empty JSON object)
Experimental
Query the server to see if it is forcing encryption to be enabled for a given room preset, based on the /versions response.
The name of the preset to check.
true if the server is forcing encryption for the preset.
Experimental
Experimental
Download device keys
list of users to get keys for
sync token to pass in the query request, to help the HS give the most recent results
Promise which resolves: result object. Rejects: with an error response (MatrixError).
Experimental
Synchronously calls each of the listeners registered for the event named
event
, in the order they were registered, passing the supplied arguments
to each.
The name of the event to emit
Arguments to pass to the listener
true
if the event had listeners, false
otherwise.
Experimental
Synchronously calls each of the listeners registered for the event named
event
, in the order they were registered, passing the supplied arguments
to each.
The name of the event to emit
Arguments to pass to the listener
true
if the event had listeners, false
otherwise.
Experimental
Similar to emit
but calls all listeners within a Promise.all
and returns the promise chain
The name of the event to emit
Arguments to pass to the listener
true
if the event had listeners, false
otherwise.
Experimental
Similar to emit
but calls all listeners within a Promise.all
and returns the promise chain
The name of the event to emit
Arguments to pass to the listener
true
if the event had listeners, false
otherwise.
Protected
encryptExperimental
encrypts the event if necessary; adds the event to the queue, or sends it; marks the event as sent/unsent
returns a promise which resolves with the result of the send request
Experimental
Simply sends a delayed event without encrypting it. TODO: Allow encrypted delayed events, and encrypt them properly
Properties of the delay for this event.
returns a promise which resolves with the result of the delayed send request
Experimental
Fetches the latest capabilities from the homeserver, ignoring any cached versions. The newly returned version is cached.
A promise which resolves to the capabilities of the homeserver
Protected
fetchExperimental
Fetches relations for a given event
the room of the event
the id of the event
the rel_type of the relations requested
Optional
eventType: null | stringthe event type of the relations requested
options with optional values for the request.
the response, with chunk, prev_batch and, next_batch.
Experimental
True to delete the room from the store on success. Default: true.
Promise which resolves: {}
an empty object.
Experimental
Get account data event of given type for the current user.
The event type
The contents of the given account data event
Experimental
Get account data event of given type for the current user. This variant gets account data directly from the homeserver if the local store is not ready, which can be useful very early in startup before the initial sync.
The event type
Promise which resolves: The contents of the given account data event.
Experimental
Discover and validate delegated auth configuration
validated authentication metadata and optionally signing keys
Experimental
Gets the cached capabilities of the homeserver. If none have been fetched yet, return undefined.
The capabilities of the homeserver
Experimental
Get the callback set via setCanResetTimelineCallback
.
The callback or null
Experimental
Gets the cached capabilities of the homeserver, returning cached ones if available. If there are no cached capabilities and none can be fetched, throw an exception.
Promise resolving with The capabilities of the homeserver
Experimental
Experimental
Access the crypto API for this client.
If end-to-end encryption has been enabled for this client (via initRustCrypto),
returns an object giving access to the crypto API. Otherwise, returns undefined
.
Experimental
Get a list of all file uploads in progress
Array of objects representing current uploads. Currently in progress is element 0. Keys:
Experimental
Optional
options: MapperOptsExperimental
Get an EventTimeline for the given event
If the EventTimelineSet object already has the given event in its store, the corresponding timeline will be returned. Otherwise, a /context request is made, and used to construct an EventTimeline. If the event does not belong to this EventTimelineSet then undefined will be returned.
The timelineSet to look for the event in, must be bound to a room
The ID of the event to look for
Promise which resolves: EventTimeline including the given event
Experimental
Get the fallback URL to use for unknown interactive-auth stages.
the type of stage being attempted
the auth session ID provided by the homeserver
HS URL to hit to for the fallback interface
Experimental
Retrieve a filter.
The user ID of the filter owner
The filter ID to retrieve
True to allow cached filters to be returned. Default: True.
Promise which resolves: a Filter object
Experimental
Get account info from the identity server. This is useful as a neutral check to verify that other APIs are likely to approve access by testing that the token is valid, terms have been agreed, etc.
The access_token
field of the Identity
Server /account/register
response (see registerWithIdentityServer).
Promise which resolves: an object with account info.
Experimental
Gets the V2 hashing information from the identity server. Primarily useful for lookups.
The access token for the identity server.
The hashing information for the identity server.
Experimental
Retrieve membership info. for a room.
ID of the room to get membership for
Promise which resolves: A list of currently joined users and their profile data.
Experimental
Promise which resolves: A list of the user's current rooms
Experimental
Ask the server for a list of users who have changed their device lists between a pair of sync tokens
Promise which resolves: result object. Rejects: with an error response (MatrixError).
Experimental
Get an EventTimeline for the latest events in the room. This will just
call /messages
to get the latest message in the room, then use
client.getEventTimeline(...)
to construct a new timeline from it.
The timelineSet to find or add the timeline to
Promise which resolves: EventTimeline timeline with the latest events in the room
Experimental
Gets the local aliases for the room. Note: this includes all local aliases, unlike the curated list from the m.room.canonical_alias state event.
The room ID to get local aliases for.
Promise which resolves: an object with an aliases
property, containing an array of local aliases
Experimental
Get the config for the media repository.
Promise which resolves with an object containing the config.
Experimental
Experimental
Return the global notification EventTimelineSet, if any
the globl notification EventTimelineSet
Experimental
Gets a bearer token from the homeserver that the user can present to a third party in order to prove their ownership of the Matrix account they are logged into.
Promise which resolves: Token object
Experimental
The user to get presence for
Promise which resolves: The presence state for this user.
Experimental
Optional
info: stringThe kind of info to retrieve (e.g. 'displayname', 'avatar_url').
Promise which resolves: TODO
Experimental
Obtain a dict of actions which should be performed for this event according to the push rules for this user. Caches the dict on the event.
The event to get push actions for.
forces to recalculate actions for an event Useful when an event just got decrypted
A dict of actions to perform.
Experimental
Obtain a dict of actions which should be performed for this event according to the push rules for this user. Caches the dict on the event.
The event to get push actions for.
forces to recalculate actions for an event Useful when an event just got decrypted
A dict of actions to perform.
Experimental
Get the push rules for the account from the server.
Promise which resolves to the push rules.
Experimental
Get the room for the given room ID. This function will return a valid room for any room for which a Room event has been emitted. Note in particular that other events, eg. RoomState.members will be emitted for a room before this function will return the given room.
The room ID
The Room or null if it doesn't exist or there is no data store.
Experimental
Get the visibility of a room in the current HS's room directory
Promise which resolves: TODO
Experimental
Fetches or paginates a room hierarchy as defined by MSC2946.
Falls back gracefully to sourcing its data from getSpaceSummary
if this API is not yet supported by the server.
The ID of the space-room to use as the root of the summary.
Optional
limit: numberThe maximum number of rooms to return per page.
Optional
maxDepth: numberThe maximum depth in the tree from the root room to return.
Whether to only return rooms with suggested=true.
Optional
fromToken: stringThe opaque token to paginate a previous request.
the response, with next_batch & rooms fields.
Experimental
Fetches the summary of a room as defined by an initial version of MSC3266 and implemented in Synapse Proposed at https://github.com/matrix-org/matrix-doc/pull/3266
The ID or alias of the room to get the summary of.
Optional
via: string[]The list of servers which know about the room if only an ID was provided.
Experimental
Promise which resolves: to an object keyed by tagId with objects containing a numeric order field.
Experimental
Determines the history of room upgrades for a given room, as far as the client can see. Returns an array of Rooms where the first entry is the oldest and the last entry is the newest (likely current) room. If the provided room is not found, this returns an empty list. This works in both directions, looking for older and newer rooms of the given room.
The room ID to search from
If true, the function will only return rooms which can be proven to be linked. For example, rooms which have a create event pointing to an old room which the client is not aware of or doesn't have a matching tombstone would not be returned.
if true, look for m.room.predecessor state events as well as create events, and prefer predecessor events where they exist (MSC3946).
An array of rooms representing the upgrade history.
Experimental
Return the provided scheduler, if any.
The scheduler or undefined
Experimental
The URL to redirect to after the HS authenticates with the SSO.
The type of SSO login we are doing (sso or cas). Defaults to 'sso'.
Optional
idpId: stringThe ID of the Identity Provider being targeted, optional.
Optional
action: SSOActionthe SSO flow to indicate to the IdP, optional.
The HS URL to hit to begin the SSO login process.
Experimental
Returns the additional data object associated with the current sync state, or null if there is no such data. Sync errors, if available, are put in the 'error' key of this object.
Experimental
Experimental
Get information on how a specific place on a third party protocol may be reached.
The protocol given in getThirdpartyProtocols()
Protocol-specific parameters, as given in the response to getThirdpartyProtocols()
Promise which resolves to the result object
Experimental
Get information on how a specific user on a third party protocol may be reached.
The protocol given in getThirdpartyProtocols()
Optional
params: QueryDictProtocol-specific parameters, as given in the response to getThirdpartyProtocols()
Promise which resolves to the result object
Experimental
Experimental
Get the TURN servers for this homeserver.
The servers or an empty list.
Experimental
Get a preview of the given URL as of (roughly) the given point in time, described as an object with OpenGraph keys and associated values. Attributes may be synthesized where actual OG metadata is lacking. Caches results to prevent hammering the server.
The URL to get preview data for
The preferred point in time that the preview should describe (ms since epoch). The preview returned will either be the most recent one preceding this timestamp if available, or failing that the next most recent available preview.
Promise which resolves: Object of OG metadata.
Experimental
Get the API versions supported by the server, along with any unstable APIs it supports
The server /versions response
Experimental
Retrieve all rooms that should be displayed to the user This is essentially getRooms() with some rooms filtered out, eg. old versions of rooms that have been replaced or (in future) other rooms that have been marked at the protocol level as not to be displayed to the user.
if true, look for an m.room.predecessor state event and use it if found (MSC3946).
A list of rooms, or an empty list if there is no data store.
Experimental
Performs a hashed lookup of addresses against the identity server. This is only supported on identity servers which have at least the version 2 API.
An array of 2 element arrays.
The first element of each pair is the address, the second is the 3PID medium.
Eg: ["email@example.org", "email"]
The access token for the identity server.
A collection of address mappings to found MXIDs. Results where no user could be found will not be listed.
Experimental
Initialise support for end-to-end encryption in this client, using the rust matrix-sdk-crypto.
WARNING: the cryptography stack is not thread-safe. Having multiple MatrixClient
instances connected to
the same Indexed DB will cause data corruption and decryption failures. The application layer is responsible for
ensuring that only one MatrixClient
issue is instantiated at a time.
Optional
storageKey?: Uint8ArrayA key with which to encrypt the indexeddb store. If provided, it must be exactly
32 bytes of data, and must be the same each time the client is initialised for a given device.
If both this and storagePassword
are unspecified, the store will be unencrypted.
Optional
storagePassword?: stringAn alternative to storageKey
. A password which will be used to derive a key to
encrypt the store with. Deriving a key from a password is (deliberately) a slow operation, so prefer
to pass a storageKey
directly where possible.
Optional
useIndexedDB?: booleanTrue to use an indexeddb store, false to use an in-memory store. Defaults to 'true'.
a Promise which will resolve when the crypto layer has been successfully initialised.
Experimental
Optional
reason: stringOptional.
Promise which resolves: {}
an empty object.
Experimental
Invite a user to a room based on their email address.
The room to invite the user to.
The email address to invite.
Promise which resolves: {}
an empty object.
Experimental
Invite a user to a room based on a third-party identifier.
The room to invite the user to.
The medium to invite the user e.g. "email".
The address for the specified medium.
Promise which resolves: {}
an empty object.
Experimental
Check whether the key backup private key is stored in secret storage.
map of key name to key info the secret is encrypted with, or null if it is not present or not encrypted with a trusted key
Experimental
Whether encryption is enabled for a room.
the room id to query.
whether encryption is enabled.
Not correctly supported for Rust Cryptography. Use CryptoApi.isEncryptionEnabledInRoom and/or Room.hasEncryptionStateEvent.
Experimental
Determines if the current user is an administrator of the Synapse homeserver. Returns false if untrue or the homeserver does not appear to be a Synapse homeserver. This function is implementation specific and may change as a result.
true if the user appears to be a Synapse administrator.
Experimental
Check whether a username is available prior to registration. An error response indicates an invalid/unavailable username.
The username to check the availability of.
Promise which resolves: to boolean of whether the username is available.
Experimental
Optional
reason: stringOptional.
Promise which resolves: {}
an empty object.
Experimental
Knock a room. If you have already knocked the room, this will no-op.
The room ID or room alias to knock.
Options when knocking the room.
Promise which resolves: {room_id: {string}}
Experimental
Promise which resolves: {}
an empty object.
Experimental
Leaves all rooms in the chain of room upgrades based on the given room. By
default, this will leave all the previous and upgraded rooms, including the
given room. To only leave the given room and any previous rooms, keeping the
upgraded (modern) rooms untouched supply false
to includeFuture
.
The room ID to start leaving at
If true, the whole chain (past and future) of upgraded rooms will be left.
Promise which resolves when completed with an object keyed by room ID and value of the error encountered when leaving or null.
Experimental
Returns the number of listeners listening to the event named event
.
The name of the event being listened for
Experimental
Returns a copy of the array of listeners for the event named event
.
Experimental
Promise which resolves to a LoginResponse object
This method has unintuitive behaviour: it updates the MatrixClient
instance with some of the
returned credentials. Instead, call loginRequest and create a new MatrixClient
instance using the
results. See https://github.com/matrix-org/matrix-js-sdk/issues/4502.
Experimental
Promise which resolves to the available login flows
Experimental
Sends a POST /login
request to the server.
If successful, this will create a new device and access token for the user.
Credentials and other details for the login request.
GET /login
request.Experimental
Promise which resolves to a LoginResponse object
This method has unintuitive behaviour: it updates the MatrixClient
instance with some of the
returned credentials. Instead, call loginRequest with data.type: "m.login.password"
, and create a new
MatrixClient
instance using the results. See https://github.com/matrix-org/matrix-js-sdk/issues/4502.
Experimental
Login token previously received from homeserver
Promise which resolves to a LoginResponse object
This method has unintuitive behaviour: it updates the MatrixClient
instance with some of the
returned credentials. Instead, call loginRequest with data.type: "m.login.token"
, and create a new
MatrixClient
instance using the results. See https://github.com/matrix-org/matrix-js-sdk/issues/4502.
Experimental
Logs out the current session. Obviously, further calls that require authorisation should fail after this method is called. The state of the MatrixClient object is not affected: it is up to the caller to either reset or destroy the MatrixClient after this method succeeds.
whether to stop the client before calling /logout to prevent invalid token errors.
Promise which resolves: On success, the empty object {}
Experimental
Looks up the public Matrix ID mapping for a given 3rd party identifier from the identity server
The medium of the threepid, eg. 'email'
The textual address of the threepid
The access_token
field of the Identity
Server /account/register
response (see registerWithIdentityServer).
Promise which resolves: A threepid mapping object or the empty object if no mapping exists
Experimental
Optional
includeMembership: stringthe membership type to include in the response
Optional
excludeMembership: stringthe membership type to exclude from the response
Optional
atEventId: stringthe id of the event for which moment in the timeline the members should be returned for
Promise which resolves: dictionary of userid to profile information
Experimental
Turn an MXC URL into an HTTP one. This method is experimental and may change.
The MXC URL
Optional
width: numberThe desired width of the thumbnail.
Optional
height: numberThe desired height of the thumbnail.
Optional
resizeMethod: stringThe thumbnail resize method to use, either "crop" or "scale".
Optional
allowDirectLinks: booleanIf true, return any non-mxc URLs directly. Fetching such URLs will leak information about the user to anyone they share a room with. If false, will return null for such URLs.
Optional
allowRedirects: booleanIf true, the caller supports the URL being 307 or
308 redirected to another resource upon request. If false, redirects
are not expected. Implied true
when useAuthentication
is true
.
Optional
useAuthentication: booleanIf true, the caller supports authenticated
media and wants an authentication-required URL. Note that server support
for authenticated media will not be checked - it is the caller's responsibility
to do so before calling this function. Note also that useAuthentication
implies allowRedirects
. Defaults to false (unauthenticated endpoints).
the avatar URL or null.
Experimental
Alias for removeListener
Experimental
Adds the listener
function to the end of the listeners array for the
event named event
.
No checks are made to see if the listener
has already been added. Multiple calls
passing the same combination of event
and listener
will result in the listener
being added, and called, multiple times.
By default, event listeners are invoked in the order they are added. The prependListener method can be used as an alternative to add the event listener to the beginning of the listeners array.
The name of the event.
The callback function
a reference to the EventEmitter
, so that calls can be chained.
Experimental
Adds a one-time listener
function for the event named event
. The
next time event
is triggered, this listener is removed and then invoked.
Returns a reference to the EventEmitter
, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The prependOnceListener method can be used as an alternative to add the event listener to the beginning of the listeners array.
The name of the event.
The callback function
a reference to the EventEmitter
, so that calls can be chained.
Experimental
Take an EventTimeline, and back/forward-fill results.
timeline object to be updated
Promise which resolves to a boolean: false if there are no events and we reached either end of the timeline; else true.
Experimental
Update multiple properties on your extended profile. This will merge with any existing keys.
The profile object to merge with the existing profile.
The newly merged profile.
Experimental
Peek into a room and receive updates about the room. This only works if the history visibility for the room is world_readable.
The room to attempt to peek into.
The number of timeline events to initially retrieve.
Promise which resolves: Room object
Experimental
Adds the listener
function to the beginning of the listeners array for the
event named event
.
No checks are made to see if the listener
has already been added. Multiple calls
passing the same combination of event
and listener
will result in the listener
being added, and called, multiple times.
The name of the event.
The callback function
a reference to the EventEmitter
, so that calls can be chained.
Experimental
Adds a one-timelistener
function for the event named event
to the beginning of the listeners array.
The next time event
is triggered, this listener is removed, and then invoked.
The name of the event.
The callback function
a reference to the EventEmitter
, so that calls can be chained.
Experimental
Calls aggregation functions for event types that are aggregated Polls and location beacons
Optional
room: Roomroom the events belong to
Optional
events: MatrixEvent[]timeline events to be processed
Experimental
Optional
room: RoomOptional
events: MatrixEvent[]Internal
helper for searchRoomEvents and backPaginateRoomEventsSearch. Processes the response from the API call and updates the searchResults
searchResults
Experimental
Processes a list of threaded events and adds them to their respective timelines
the room the adds the threaded events
an array of the threaded events
the direction in which we want to add the events
Experimental
Processes a list of thread roots and creates a thread model
the room to create the threads in
an array of thread roots
the direction
Experimental
Options for this request
Promise which resolves: IPublicRoomsResponse
Experimental
Sends events directly to specific devices using Matrix's to-device messaging system. The batch will be split up into appropriately sized batches for sending and stored in the store so they can be retried later if they fail to send. Retries will happen automatically.
The to-device messages to send
Experimental
Returns a copy of the array of listeners for the event named eventName
,
including any wrappers (such as those created by .once()
).
Experimental
Optional
txnId: stringtransaction id. One will be made up if not supplied.
Optional
opts: IRedactOptsRedact options
Promise which resolves: TODO
Experimental
Optional
txnId: stringtransaction id. One will be made up if not supplied.
Optional
opts: IRedactOptsRedact options
Promise which resolves: TODO
Experimental
Refreshes an access token using a provided refresh token. The refresh token must be valid for the current access token known to the client instance.
Note that this function will not cause a logout if the token is deemed unknown by the server - the caller is responsible for managing logout actions on error.
The refresh token.
Promise which resolves to the new token.
Experimental
Optional
bindThreepids: { email?: boolean; msisdn?: boolean }Set key 'email' to true to bind any email threepid uses during registration in the identity server. Set 'msisdn' to true to bind msisdn.
Optional
guestAccessToken: stringOptional
inhibitLogin: booleanPromise which resolves to a RegisterResponse object
Experimental
Register a guest account.
This method returns the auth info needed to create a new authenticated client,
Remember to call setGuest(true)
on the (guest-)authenticated client, e.g:
const tmpClient = await sdk.createClient(MATRIX_INSTANCE);
const { user_id, device_id, access_token } = tmpClient.registerGuest();
const client = createClient({
baseUrl: MATRIX_INSTANCE,
accessToken: access_token,
userId: user_id,
deviceId: device_id,
})
client.setGuest(true);
JSON HTTP body to provide.
Promise which resolves: JSON object that contains:
{ user_id, device_id, access_token, home_server }
Experimental
parameters for registration request
Optional
kind: stringtype of user to register. may be "guest"
Promise which resolves: to the /register response
Experimental
Register with an identity server using the OpenID token from the user's Homeserver, which can be retrieved via MatrixClient#getOpenIdToken.
Note that the /account/register
endpoint (as well as IS authentication in
general) was added as part of the v2 API version.
Promise which resolves: with object containing an Identity Server access token.
Experimental
Returns relations for a given event. Handles encryption transparently, with the caveat that the amount of events returned might be 0, even though you get a nextBatch. When the returned promise resolves, all messages should have finished trying to decrypt.
the room of the event
the id of the event
the rel_type of the relations requested
Optional
eventType: null | stringthe event type of the relations requested
options with optional values for the request.
an object with events
as MatrixEvent[]
and optionally nextBatch
if more relations are available.
Experimental
Removes all listeners, or those of the specified event
.
It is bad practice to remove listeners added elsewhere in the code,
particularly when the EventEmitter
instance was created by some other
component or module (e.g. sockets or file streams).
Optional
event: EventEmitterEvents | EmittedEventsThe name of the event. If undefined, all listeners everywhere are removed.
a reference to the EventEmitter
, so that calls can be chained.
Experimental
Removes the specified listener
from the listener array for the event named event
.
a reference to the EventEmitter
, so that calls can be chained.
Experimental
Removes an existing pusher
pushkey of pusher to remove
app_id of pusher to remove
Promise which resolves: Empty json object on success
Experimental
Reports an event as inappropriate to the server, which may then notify the appropriate people.
The room in which the event being reported is located.
The event to report.
The score to rate this content as where -100 is most offensive and 0 is inoffensive.
The reason the content is being reported. May be blank.
Promise which resolves to an empty object if successful
Experimental
Requests an email verification token for the purposes of adding a third party identifier to an account. This API requests a token from the homeserver. The doesServerRequireIdServerParam() method can be used to determine if the server requires the id_server parameter to be provided. If an account with the given email address already exists and is associated with an account other than the one the user is authed as, it will either send an email to the address informing them of this or return M_THREEPID_IN_USE (which one is up to the homeserver).
As requestEmailToken
As requestEmailToken
As requestEmailToken
Optional
nextLink: stringAs requestEmailToken
Promise which resolves: As requestEmailToken
Experimental
Requests a text message verification token for the purposes of adding a third party identifier to an account. This API proxies the identity server /validate/email/requestToken API, adding specific behaviour for the addition of phone numbers to an account, as requestAdd3pidEmailToken.
As requestRegisterMsisdnToken
As requestRegisterMsisdnToken
As requestEmailToken
As requestEmailToken
Optional
nextLink: stringAs requestEmailToken
Promise which resolves: As requestEmailToken
Experimental
Requests an email verification token directly from an identity server.
This API is used as part of binding an email for discovery on an identity
server. The validation data that results should be passed to the
bindThreePid
method to complete the binding process.
The email address to request a token for
A secret binary string generated by the client. It is recommended this be around 16 ASCII characters.
If an identity server sees a duplicate request with the same sendAttempt, it will not send another email. To request another email to be sent, use a larger value for the sendAttempt param as was used in the previous request.
Optional
nextLink: stringOptional If specified, the client will be redirected to this link after validation.
Optional
identityAccessToken: stringThe access_token
field of the identity
server /account/register
response (see registerWithIdentityServer).
Promise which resolves: TODO
Experimental
Make a request for an m.login.token
to be issued as per
https://spec.matrix.org/v1.7/client-server-api/#post_matrixclientv1loginget_token
The server may require User-Interactive auth.
Optional
auth: AuthDictOptional. Auth data to supply for User-Interactive auth.
Promise which resolves: On success, the token response or UIA auth data.
Experimental
Requests a MSISDN verification token directly from an identity server.
This API is used as part of binding a MSISDN for discovery on an identity
server. The validation data that results should be passed to the
bindThreePid
method to complete the binding process.
The ISO 3166-1 alpha-2 code for the country in which phoneNumber should be parsed relative to.
The phone number, in national or international format
A secret binary string generated by the client. It is recommended this be around 16 ASCII characters.
If an identity server sees a duplicate request with the same sendAttempt, it will not send another SMS. To request another SMS to be sent, use a larger value for the sendAttempt param as was used in the previous request.
Optional
nextLink: stringOptional If specified, the client will be redirected to this link after validation.
Optional
identityAccessToken: stringThe access_token
field of the Identity
Server /account/register
response (see registerWithIdentityServer).
Promise which resolves to an object with a sid string
Experimental
Requests an email verification token for the purposes of resetting the password on an account. This API proxies the identity server /validate/email/requestToken API, adding specific behaviour for the password resetting. Specifically, if no account with the given email address exists, it may either return M_THREEPID_NOT_FOUND or send an email to the address informing them of this (which one is up to the homeserver).
requestEmailToken calls the equivalent API directly on the identity server, therefore bypassing the password reset specific logic.
As requestEmailToken
As requestEmailToken
As requestEmailToken
Optional
nextLink: stringAs requestEmailToken
Promise which resolves: As requestEmailToken
Experimental
Requests a text message verification token for the purposes of resetting the password on an account. This API proxies the identity server /validate/email/requestToken API, adding specific behaviour for the password resetting, as requestPasswordEmailToken.
As requestRegisterMsisdnToken
As requestRegisterMsisdnToken
As requestEmailToken
As requestEmailToken
As requestEmailToken
Promise which resolves: As requestEmailToken
Experimental
Requests an email verification token for the purposes of registration. This API requests a token from the homeserver. The doesServerRequireIdServerParam() method can be used to determine if the server requires the id_server parameter to be provided.
Parameters and return value are as for requestEmailToken
As requestEmailToken
As requestEmailToken
As requestEmailToken
Optional
nextLink: stringAs requestEmailToken
Promise which resolves: As requestEmailToken
Experimental
Requests a text message verification token for the purposes of registration. This API requests a token from the homeserver. The doesServerRequireIdServerParam() method can be used to determine if the server requires the id_server parameter to be provided.
The ISO 3166-1 alpha-2 code for the country in which phoneNumber should be parsed relative to.
The phone number, in national or international format
As requestEmailToken
As requestEmailToken
Optional
nextLink: stringAs requestEmailToken
Promise which resolves: As requestEmailToken
Experimental
Resend an event. Will also retry any to-device messages waiting to be sent.
The event to resend.
Optional. The room the event is in. Will update the timeline entry if provided.
Promise which resolves: to an ISendEventResponse object
Experimental
Retry a backed off syncing request immediately. This should only be used when the user explicitly attempts to retry their lost connection. Will also retry any outbound to-device messages currently in the queue to be sent (retries of regular outgoing events are handled separately, per-event).
True if this resulted in a request being retried.
Experimental
Promise which resolves: TODO
Experimental
Promise which resolves: TODO
Experimental
Retrieve older messages from the given room and put them in the timeline.
If this is called multiple times whilst a request is ongoing, the same Promise will be returned. If there was a problem requesting scrollback, there will be a small delay before another request can be made (to prevent tight-looping when there is no connection).
The room to get older messages in.
Optional. The maximum number of previous events to pull in. Default: 30.
Promise which resolves: Room. If you are at the beginning
of the timeline, Room.oldState.paginationToken
will be
null
.
Experimental
Perform a server-side search.
the JSON object to pass to the request body.
Optional
next_batch?: stringthe batch token to pass in the query string
Optional
abortSignal: AbortSignaloptional signal used to cancel the http request.
Promise which resolves to the search response object.
Experimental
Experimental
Perform a server-side search for room events.
The returned promise resolves to an object containing the fields:
Each entry in the results list is a SearchResult.
Promise which resolves: result object
Experimental
Query the user directory with a term matching user IDs, display names and domains.
Optional
limit?: numberthe maximum number of results to return. The server will apply a limit if unspecified.
the term with which to search.
Promise which resolves: an array of results.
Experimental
Optional
txnId: stringOptional.
Promise which resolves: to a ISendEventResponse object
Experimental
Optional
txnId: stringOptional.
Promise which resolves: to a ISendEventResponse object
Experimental
Optional
txnId: stringExperimental
Optional
txnId: stringExperimental
Promise which resolves: to a ISendEventResponse object
Experimental
Promise which resolves: to a ISendEventResponse object
Experimental
Promise which resolves: to a ISendEventResponse object
Experimental
Promise which resolves: to a ISendEventResponse object
Experimental
Promise which resolves: to a ISendEventResponse object
Experimental
Promise which resolves: to a ISendEventResponse object
Experimental
Optional
info: ImageInfoOptional
text: stringPromise which resolves: to a ISendEventResponse object
Experimental
Optional
info: ImageInfoOptional
text: stringPromise which resolves: to a ISendEventResponse object
Experimental
Optional
txnId: stringOptional.
Promise which resolves: to an ISendEventResponse object
Experimental
Optional
txnId: stringOptional.
Promise which resolves: to an ISendEventResponse object
Experimental
Optional
txnId: stringOptional.
Promise which resolves: to a ISendEventResponse object
Experimental
Optional
txnId: stringOptional.
Promise which resolves: to a ISendEventResponse object
Experimental
Send a read receipt.
The event that has been read.
other than ReceiptType.Read are experimental! Optional.
Promise which resolves: to an empty object {}
Experimental
Send a receipt.
The event being acknowledged
The kind of receipt e.g. "m.read". Other than ReceiptType.Read are experimental!
Optional
body: Record<string, any>Additional content to send alongside the receipt.
An unthreaded receipt will clear room+thread notifications
Promise which resolves: to an empty object {}
Experimental
Send a state event into a room
ID of the room to send the event into
type of the state event to send
content of the event to send
the stateKey to send into the room
Promise which resolves: TODO
Experimental
Optional
info: ImageInfoOptional
text: stringPromise which resolves: to a ISendEventResponse object
Experimental
Optional
info: ImageInfoOptional
text: stringPromise which resolves: to a ISendEventResponse object
Experimental
Optional
txnId: stringOptional.
Experimental
Optional
txnId: stringOptional.
Experimental
Send an event to a specific list of devices. This is a low-level API that simply wraps the HTTP API call to send to-device messages. We recommend using queueToDevice() which is a higher level API.
type of event to send content to send. Map from user_id to device_id to content object.
Promise which resolves: to an empty object {}
Experimental
Send an event to a specific list of devices via the widget API. Optionally encrypts the event.
If you are using a full MatrixClient you would be calling ().encryptToDeviceMessages() followed by MatrixClient.queueToDevice.
However, this is combined into a single step when running as an embedded widget client. So, we expose this method for those that need it.
Type of the event to send.
Whether the event should be encrypted.
The content to send. Map from user_id to device_id to content object.
Experimental
Promise which resolves: to an empty object {}
Experimental
Set account data event for the current user. It will retry the request up to 5 times.
The event type
the contents object for the event
Promise which resolves: an empty object
Experimental
Promise which resolves: {}
an empty object.
Experimental
Set a function which is called when /sync returns a 'limited' response. It is called with a room ID and returns a boolean. It should return 'true' if the SDK can SAFELY remove events from this room. It may not be safe to remove events if there are other references to the timelines for this room, e.g because the client is actively viewing events in this room. Default: returns false.
The callback which will be invoked.
Experimental
Update the given device
device to update
body of request
Promise which resolves: to an empty object {}
Experimental
Promise which resolves: {}
an empty object.
Experimental
Set multiple properties on your extended profile. This will completely replace the existing profile, removing any unspecified keys.
The profile object to set.
Experimental
Set whether this client is a guest account. This method is experimental and may change without warning.
True if this is a guest account. if the token is a macaroon, it should be encoded in it that it is a 'guest' access token, which means that the SDK can determine this entirely without the dev manually flipping this flag.
Experimental
Set r/w flags for guest access in a room.
The room to configure guest access in.
Options
Promise which resolves
Experimental
Sets the users that the current user should ignore.
the user IDs to ignore
Promise which resolves: an empty object
Experimental
Persists local notification settings
Promise which resolves: an empty object
Experimental
Set the global notification EventTimelineSet
Experimental
Make a request to change your password.
The new desired password.
Optional
logoutDevices: booleanShould all sessions be logged out after the password change. Defaults to true.
Promise which resolves: to an empty object {}
Experimental
Set a power level to one or multiple users.
Will apply changes atop of current power level event from local state if running & synced, falling back
to fetching latest from the /state/
API.
the room to update power levels in
the ID of the user or users to update power levels of
the numeric power level to update given users to
Promise which resolves: to an ISendEventResponse object
Experimental
Options to apply
Promise which resolves
Experimental
The kind of info to set (e.g. 'avatar_url')
The JSON object to set.
Experimental
The kind of info to set (e.g. 'avatar_url')
The JSON object to set.
Experimental
Adds a new pusher or updates an existing pusher
Object representing a pusher
Promise which resolves: Empty json object on success
Experimental
Set the actions for a push notification rule.
Promise which resolves: to an empty object {}
Experimental
Enable or disable a push notification rule.
Promise which resolves: to an empty object {}
Experimental
Update the push rules for the account. This should be called whenever updated push rules are available.
Experimental
event type to be set
event content
Promise which resolves: to an empty object {}
Experimental
Set the visibility of a room in the current HS's room directory
"public" to make the room visible in the public directory, or "private" to make it invisible.
Promise which resolves: to an empty object {}
Experimental
Set a room-kind muting push rule in a room. The operation also updates MatrixClient.pushRules at the end.
"global" or device-specific.
the id of the room.
the mute state.
Promise which resolves: result object
Experimental
Promise which resolves: TODO
Experimental
Set a marker to indicate the point in a room before which the user has read every
event. This can be retrieved from room account data (the event type is m.fully_read
)
and displayed as a horizontal line in the timeline that is visually distinct to the
position of the user's own read receipt.
ID of the room that has been read
ID of the event that has been read
Optional
rrEvent: MatrixEventthe event tracked by the read receipt. This is here for convenience because the RR and the RM are commonly updated at the same time as each other. The local echo of this receipt will be done if set. Optional.
Optional
rpEvent: MatrixEventthe m.read.private read receipt event for when we don't want other users to see the read receipts. This is experimental. Optional.
Promise which resolves: the empty object, {}
.
Experimental
Set a marker to indicate the point in a room before which the user has read every
event. This can be retrieved from room account data (the event type is m.fully_read
)
and displayed as a horizontal line in the timeline that is visually distinct to the
position of the user's own read receipt.
ID of the room that has been read
ID of the event that has been read
Optional
rrEventId: stringID of the event tracked by the read receipt. This is here for convenience because the RR and the RM are commonly updated at the same time as each other. Optional.
Optional
rpEventId: stringrpEvent the m.read.private read receipt event for when we don't want other users to see the read receipts. This is experimental. Optional.
Promise which resolves: the empty object, {}
.
Experimental
name of room tag to be set
associated with that tag to be stored
Promise which resolves: to an empty object
Experimental
The room to update the topic in.
Optional
topic: stringThe plaintext topic. May be empty to remove the topic.
Optional
htmlTopic: stringOptional.
Promise which resolves: TODO
Experimental
Specify the set_presence value to be used for subsequent calls to the Sync API. This has an advantage over calls to the PUT /presence API in that it doesn't clobber status_msg set by other devices.
Optional
presence: SetPresencethe presence to specify to set_presence of sync calls
Experimental
Perform a single MSC3575 sliding sync request.
The request to make.
Optional
proxyBaseUrl: stringThe base URL for the sliding sync proxy.
Optional
abortSignal: AbortSignalOptional signal to abort request mid-flight.
The sliding sync response, or a standard error.
Experimental
High level helper method to begin syncing and poll for new events. To listen for these events, add a listener for ClientEvent.Event via MatrixClient#on. Alternatively, listen for specific state change events.
Options to apply when syncing.
Experimental
Submits a MSISDN token to the identity server
This is used when submitting the code sent by SMS to a phone number. The identity server has an equivalent API for email but the js-sdk does not expose this, since email is normally validated by the user clicking a link rather than entering a code.
The sid given in the response to requestToken
A secret binary string generated by the client. This must be the same value submitted in the requestToken call.
The MSISDN token, as enetered by the user.
The access_token
field of the Identity
Server /account/register
response (see registerWithIdentityServer).
Some legacy identity servers had no authentication here.
Promise which resolves: Object, containing success boolean.
Experimental
Submits a MSISDN token to an arbitrary URL.
This is used when submitting the code sent by SMS to a phone number in the
newer 3PID flow where the homeserver validates 3PID ownership (as part of
requestAdd3pidMsisdnToken
). The homeserver response may include a
submit_url
to specify where the token should be sent, and this helper can
be used to pass the token to this URL.
The URL to submit the token to
The sid given in the response to requestToken
A secret binary string generated by the client. This must be the same value submitted in the requestToken call.
The MSISDN token, as enetered by the user.
Promise which resolves: Object, containing success boolean.
Experimental
Find the event_id closest to the given timestamp in the given direction.
Resolves: A promise of an object containing the event_id and origin_server_ts of the closest event to the timestamp in the given direction
Experimental
Promise which resolves: ITurnServerResponse object
Experimental
Promise which resolves: Object (currently empty)
Experimental
Unbind a 3PID for discovery on an identity server via the homeserver. The homeserver removes its record of the binding to keep an updated record of where all 3PIDs for the account are bound.
The threepid medium (eg. 'email')
The threepid address (eg. 'bob@example.com') this must be as returned by getThreePids.
Promise which resolves: on success
Experimental
Create an m.beacon_info event
Experimental
Upsert a live beacon event using a specific m.beacon_info.* event variable type
string
Experimental
Creates a new file tree space with the given name. The client will pick defaults for how it expects to be able to support the remaining API offered by the returned class.
Note that this is UNSTABLE and may have breaking changes without notice.
The name of the tree space.
Promise which resolves to the created space.
Experimental
Gets a reference to a tree space, if the room ID given is a tree space. If the room does not appear to be a tree space then null is returned.
Note that this is UNSTABLE and may have breaking changes without notice.
The room ID to get a tree space reference for.
The tree space, or null if not a tree space.
Protected
updateExperimental
Experimental
Upgrades a room to a new protocol version
The target version to upgrade to
Promise which resolves: Object with key 'replacement_room'
Experimental
Upload a file to the media repository on the homeserver.
The object to upload. On a browser, something that can be sent to XMLHttpRequest.send (typically a File). Under node.js, a a Buffer, String or ReadStream.
Optional
opts: UploadOptsoptions object
Promise which resolves to response object, as determined by this.opts.onlyData, opts.rawResponse, and opts.onlyContentUri. Rejects with an error (usually a MatrixError).
Experimental
Optional
auth: AuthDictOptional
keys: CrossSigningKeysExperimental
Experimental
Upload keys
body of upload request
Optional
opts: voidthis method no longer takes any opts, used to take opts.device_id but this was not removed from the spec as a redundant parameter
Promise which resolves: result object. Rejects: with an error response (MatrixError).
Experimental
Experimental
Wait until an initial state for the given room has been processed by the client and the client is aware of any ongoing group calls. Awaiting on the promise returned by this method before calling getGroupCallForRoom() avoids races where getGroupCallForRoom is called before the state for that room has been processed. It does not, however, fix other races, eg. two clients both creating a group call at the same time.
The room ID to wait for
A promise that resolves once existing group calls in the room have been processed.
Experimental
Fetches information about the user for the configured access token.
Experimental
Performs a whois lookup on a user using Synapse's administrator API. This function is implementation specific and may change as a result.
the User ID to look up.
the whois response - see Synapse docs for information.
A MatrixClient that routes its requests through the widget API instead of the real CS API. This class is considered unstable!