DigitalWorldClient
Defined in: src/client.ts:1204
Represents a Digital World Client. Only directly construct this if you want to use custom modules. Normally, createClient should be used as it specifies ‘sensible’ defaults for these modules.
Extends
Section titled “Extends”Extended by
Section titled “Extended by”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DigitalWorldClient(
opts):DigitalWorldClient
Defined in: src/client.ts:1331
Parameters
Section titled “Parameters”Returns
Section titled “Returns”DigitalWorldClient
Overrides
Section titled “Overrides”Properties
Section titled “Properties”_unstable_shouldApplyMessageRetention
Section titled “_unstable_shouldApplyMessageRetention”
readonly_unstable_shouldApplyMessageRetention:boolean
Defined in: src/client.ts:1329
baseUrl
Section titled “baseUrl”baseUrl:
string
Defined in: src/client.ts:1259
callEventHandler?
Section titled “callEventHandler?”
optionalcallEventHandler?:CallEventHandler
Defined in: src/client.ts:1253
canSupport
Section titled “canSupport”canSupport:
Map<Feature,ServerSupport>
Defined in: src/client.ts:1290
clientRunning
Section titled “clientRunning”clientRunning:
boolean=false
Defined in: src/client.ts:1225
credentials
Section titled “credentials”credentials:
object
Defined in: src/client.ts:1214
userId
Section titled “userId”userId:
string|null
cryptoCallbacks
Section titled “cryptoCallbacks”cryptoCallbacks:
CryptoCallbacks
Defined in: src/client.ts:1252
deviceId
Section titled “deviceId”deviceId:
string|null
Defined in: src/client.ts:1213
digitalWorldRTC
Section titled “digitalWorldRTC”
readonlydigitalWorldRTC:DigitalWorldRTCSessionManager
Defined in: src/client.ts:1324
disableVoip
Section titled “disableVoip”disableVoip:
boolean
Defined in: src/client.ts:1261
enableEncryptedStateEvents
Section titled “enableEncryptedStateEvents”enableEncryptedStateEvents:
boolean
Defined in: src/client.ts:1250
Support MSC4362: Simplified Encrypted State Events.
The client must be recreated for changes to this setting to take effect reliably.
When this setting is true, if we find a state event that is encrypted (within a room that supports encrypted state), we will attempt to decrypt it as specified in MSC4362. If the user was in the room at the time an encrypted state event was received (meaning we have the key), even if this setting was set to false at the time it was received, recreating the client with this setting set to true will allow decrypting that event.
When this setting is false, any state event that is encrypted will not be decrypted, meaning it will have no effect. This matched the behaviour of a client that does not support MSC4362.
forceTURN
Section titled “forceTURN”forceTURN:
boolean=false
Defined in: src/client.ts:1256
groupCallEventHandler?
Section titled “groupCallEventHandler?”
optionalgroupCallEventHandler?:GroupCallEventHandler
Defined in: src/client.ts:1254
http:
DigitalWorldHttpApi<IHttpOpts&object>
Defined in: src/client.ts:1229
iceCandidatePoolSize
Section titled “iceCandidatePoolSize”iceCandidatePoolSize:
number=0
Defined in: src/client.ts:1257
idBaseUrl?
Section titled “idBaseUrl?”
optionalidBaseUrl?:string
Defined in: src/client.ts:1258
identityServer?
Section titled “identityServer?”
optionalidentityServer?:IIdentityServerProvider
Defined in: src/client.ts:1228
ignoredInvites
Section titled “ignoredInvites”
readonlyignoredInvites:IgnoredInvites
Defined in: src/client.ts:1322
isVoipWithNoMediaAllowed
Section titled “isVoipWithNoMediaAllowed”
readonlyisVoipWithNoMediaAllowed:boolean
Defined in: src/client.ts:1260
livekitServiceURL?
Section titled “livekitServiceURL?”
optionallivekitServiceURL?:string
Defined in: src/client.ts:1317
olmVersion
Section titled “olmVersion”olmVersion: [
number,number,number] |null=null
Defined in: src/client.ts:1210
pushProcessor
Section titled “pushProcessor”
readonlypushProcessor:PushProcessor
Defined in: src/client.ts:1293
pushRules?
Section titled “pushRules?”
optionalpushRules?:IPushRules
Defined in: src/client.ts:1283
reEmitter
Section titled “reEmitter”reEmitter:
TypedReEmitter<EmittedEvents,ClientEventHandlerMap>
Defined in: src/client.ts:1209
retentionPolicyService
Section titled “retentionPolicyService”
readonlyretentionPolicyService:RetentionPolicyService
Defined in: src/client.ts:1327
roomNameGenerator?
Section titled “roomNameGenerator?”
optionalroomNameGenerator?: (roomId,state) =>string|null
Defined in: src/client.ts:1282
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
Returns
Section titled “Returns”string | null
scheduler?
Section titled “scheduler?”
optionalscheduler?:DigitalWorldScheduler<ISendEventResponse>
Defined in: src/client.ts:1224
supportsCallTransfer
Section titled “supportsCallTransfer”supportsCallTransfer:
boolean=false
Defined in: src/client.ts:1255
timelineSupport
Section titled “timelineSupport”timelineSupport:
boolean=false
Defined in: src/client.ts:1226
urlPreviewCache
Section titled “urlPreviewCache”urlPreviewCache:
object={}
Defined in: src/client.ts:1227
Index Signature
Section titled “Index Signature”[key: string]: Promise<IPreviewUrlResponse>
useLivekitForGroupCalls
Section titled “useLivekitForGroupCalls”useLivekitForGroupCalls:
boolean
Defined in: src/client.ts:1263
usingExternalCrypto
Section titled “usingExternalCrypto”usingExternalCrypto:
boolean=false
Defined in: src/client.ts:1211
captureRejections
Section titled “captureRejections”
staticcaptureRejections:boolean
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:425
Value: boolean
Change the default captureRejections option on all new EventEmitter objects.
v13.4.0, v12.16.0
Inherited from
Section titled “Inherited from”TypedEventEmitter.captureRejections
captureRejectionSymbol
Section titled “captureRejectionSymbol”
readonlystaticcaptureRejectionSymbol: typeofcaptureRejectionSymbol
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:418
Value: Symbol.for('nodejs.rejection')
See how to write a custom rejection handler.
v13.4.0, v12.16.0
Inherited from
Section titled “Inherited from”TypedEventEmitter.captureRejectionSymbol
defaultMaxListeners
Section titled “defaultMaxListeners”
staticdefaultMaxListeners:number
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:464
By default, a maximum of 10 listeners can be registered for any single
event. This limit can be changed for individual EventEmitter instances
using the emitter.setMaxListeners(n) method. To change the default
for allEventEmitter instances, the events.defaultMaxListeners property
can be used. If this value is not a positive number, a RangeError is thrown.
Take caution when setting the events.defaultMaxListeners because the
change affects all EventEmitter instances, including those created before
the change is made. However, calling emitter.setMaxListeners(n) still has
precedence over events.defaultMaxListeners.
This is not a hard limit. The EventEmitter instance will allow
more listeners to be added but will output a trace warning to stderr indicating
that a “possible EventEmitter memory leak” has been detected. For any single
EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to
temporarily avoid this warning:
import { EventEmitter } from 'node:events';const emitter = new EventEmitter();emitter.setMaxListeners(emitter.getMaxListeners() + 1);emitter.once('event', () => { // do stuff emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));});The --trace-warnings command-line flag can be used to display the
stack trace for such warnings.
The emitted warning can be inspected with process.on('warning') and will
have the additional emitter, type, and count properties, referring to
the event emitter instance, the event’s name and the number of attached
listeners, respectively.
Its name property is set to 'MaxListenersExceededWarning'.
v0.11.2
Inherited from
Section titled “Inherited from”TypedEventEmitter.defaultMaxListeners
errorMonitor
Section titled “errorMonitor”
readonlystaticerrorMonitor: typeoferrorMonitor
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:411
This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.
Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no
regular 'error' listener is installed.
v13.6.0, v12.17.0
Inherited from
Section titled “Inherited from”TypedEventEmitter.errorMonitor
RESTORE_BACKUP_ERROR_BAD_KEY
Section titled “RESTORE_BACKUP_ERROR_BAD_KEY”
readonlystaticRESTORE_BACKUP_ERROR_BAD_KEY:"RESTORE_BACKUP_ERROR_BAD_KEY"="RESTORE_BACKUP_ERROR_BAD_KEY"
Defined in: src/client.ts:1205
Accessors
Section titled “Accessors”pollingTurnServers
Section titled “pollingTurnServers”Get Signature
Section titled “Get Signature”get pollingTurnServers():
boolean
Defined in: src/client.ts:5976
Returns
Section titled “Returns”boolean
secretStorage
Section titled “secretStorage”Get Signature
Section titled “Get Signature”get secretStorage():
ServerSideSecretStorage
Defined in: src/client.ts:2077
Access the server-side secret storage API for this client.
Returns
Section titled “Returns”Get Signature
Section titled “Get Signature”get store():
IStore
Defined in: src/client.ts:1454
Returns
Section titled “Returns”IStore
Set Signature
Section titled “Set Signature”set store(
newStore):void
Defined in: src/client.ts:1449
Parameters
Section titled “Parameters”newStore
Section titled “newStore”IStore
Returns
Section titled “Returns”void
Methods
Section titled “Methods”_unstable_cancelScheduledDelayedEvent()
Section titled “_unstable_cancelScheduledDelayedEvent()”_unstable_cancelScheduledDelayedEvent(
delayId,requestOptions?):Promise<EmptyObject>
Defined in: src/client.ts:3690
Cancel the scheduled delivery of the delayed event matching the provided delayId.
Note: This endpoint is unstable, and can throw an Error.
Check progress on MSC4140 for more details.
Parameters
Section titled “Parameters”delayId
Section titled “delayId”string
requestOptions?
Section titled “requestOptions?”IRequestOpts = {}
Returns
Section titled “Returns”Promise<EmptyObject>
Throws
Section titled “Throws”A M_NOT_FOUND error if no matching delayed event could be found.
_unstable_getDelayedEvents()
Section titled “_unstable_getDelayedEvents()”_unstable_getDelayedEvents(
status?,delayId?,fromToken?):Promise<DelayedEventInfo>
Defined in: src/client.ts:3633
Get information about delayed events owned by the requesting user.
Note: This endpoint is unstable, and can throw an Error.
Check progress on MSC4140 for more details.
Parameters
Section titled “Parameters”status?
Section titled “status?”"scheduled" | "finalised"
delayId?
Section titled “delayId?”string | string[]
fromToken?
Section titled “fromToken?”string
Returns
Section titled “Returns”Promise<DelayedEventInfo>
_unstable_getRTCTransports()
Section titled “_unstable_getRTCTransports()”_unstable_getRTCTransports():
Promise<Transport[]>
Defined in: src/client.ts:6204
Returns a set of configured RTC transports supported by the hub. Requires hub support for MSC4143.
Returns
Section titled “Returns”Promise<Transport[]>
Throws
Section titled “Throws”A M_NOT_FOUND error if not supported by the hub.
_unstable_getSharedRooms()
Section titled “_unstable_getSharedRooms()”_unstable_getSharedRooms(
userId):Promise<string[]>
Defined in: src/client.ts:6138
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.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
The userId to check.
Returns
Section titled “Returns”Promise<string[]>
Promise which resolves to an array of rooms
_unstable_restartScheduledDelayedEvent()
Section titled “_unstable_restartScheduledDelayedEvent()”_unstable_restartScheduledDelayedEvent(
delayId,requestOptions?):Promise<EmptyObject>
Defined in: src/client.ts:3706
Restart the scheduled delivery of the delayed event matching the given delayId.
Note: This endpoint is unstable, and can throw an Error.
Check progress on MSC4140 for more details.
Parameters
Section titled “Parameters”delayId
Section titled “delayId”string
requestOptions?
Section titled “requestOptions?”IRequestOpts = {}
Returns
Section titled “Returns”Promise<EmptyObject>
Throws
Section titled “Throws”A M_NOT_FOUND error if no matching delayed event could be found.
_unstable_sendDelayedEvent()
Section titled “_unstable_sendDelayedEvent()”_unstable_sendDelayedEvent<
K>(roomId,delayOpts,threadId,eventType,content,txnId?):Promise<SendDelayedEventResponse>
Defined in: src/client.ts:3488
Send a delayed timeline event.
Note: This endpoint is unstable, and can throw an Error.
Check progress on MSC4140 for more details.
Type Parameters
Section titled “Type Parameters”K extends keyof TimelineEvents
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
delayOpts
Section titled “delayOpts”threadId
Section titled “threadId”string | null
eventType
Section titled “eventType”K
content
Section titled “content”txnId?
Section titled “txnId?”string
Returns
Section titled “Returns”Promise<SendDelayedEventResponse>
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
_unstable_sendDelayedStateEvent()
Section titled “_unstable_sendDelayedStateEvent()”_unstable_sendDelayedStateEvent<
K>(roomId,delayOpts,eventType,content,stateKey?,opts?):Promise<SendDelayedEventResponse>
Defined in: src/client.ts:3565
Send a delayed state event.
Note: This endpoint is unstable, and can throw an Error.
Check progress on MSC4140 for more details.
Type Parameters
Section titled “Type Parameters”K extends keyof StateEvents
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
delayOpts
Section titled “delayOpts”eventType
Section titled “eventType”K
content
Section titled “content”StateEvents[K]
stateKey?
Section titled “stateKey?”string = ""
IRequestOpts = {}
Returns
Section titled “Returns”Promise<SendDelayedEventResponse>
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
_unstable_sendScheduledDelayedEvent()
Section titled “_unstable_sendScheduledDelayedEvent()”_unstable_sendScheduledDelayedEvent(
delayId,requestOptions?):Promise<EmptyObject>
Defined in: src/client.ts:3725
Immediately send the delayed event matching the given delayId, instead of waiting for its scheduled delivery.
Note: This endpoint is unstable, and can throw an Error.
Check progress on MSC4140 for more details.
Parameters
Section titled “Parameters”delayId
Section titled “delayId”string
requestOptions?
Section titled “requestOptions?”IRequestOpts = {}
Returns
Section titled “Returns”Promise<EmptyObject>
Throws
Section titled “Throws”A M_NOT_FOUND error if no matching delayed event could be found.
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
_unstable_sendStickyDelayedEvent()
Section titled “_unstable_sendStickyDelayedEvent()”_unstable_sendStickyDelayedEvent<
K>(roomId,stickDuration,delayOpts,threadId,eventType,content,txnId?):Promise<SendDelayedEventResponse>
Defined in: src/client.ts:3523
Send a delayed sticky timeline event.
Note: This endpoint is unstable, and can throw an Error.
Check progress on MSC4140 and
MSC4354 for more details.
Type Parameters
Section titled “Type Parameters”K extends keyof TimelineEvents
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
stickDuration
Section titled “stickDuration”number
delayOpts
Section titled “delayOpts”threadId
Section titled “threadId”string | null
eventType
Section titled “eventType”K
content
Section titled “content”TimelineEvents[K] & object
txnId?
Section titled “txnId?”string
Returns
Section titled “Returns”Promise<SendDelayedEventResponse>
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
_unstable_sendStickyEvent()
Section titled “_unstable_sendStickyEvent()”_unstable_sendStickyEvent<
K>(roomId,stickDuration,threadId,eventType,content,txnId?):Promise<ISendEventResponse>
Defined in: src/client.ts:3601
Send a sticky timeline event.
Note: This endpoint is unstable, and can throw an Error.
Check progress on MSC4354 for more details.
Type Parameters
Section titled “Type Parameters”K extends keyof TimelineEvents
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
stickDuration
Section titled “stickDuration”number
threadId
Section titled “threadId”string | null
eventType
Section titled “eventType”K
content
Section titled “content”TimelineEvents[K] & object
txnId?
Section titled “txnId?”string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
_unstable_updateDelayedEvent()
Section titled “_unstable_updateDelayedEvent()”_unstable_updateDelayedEvent(
delayId,action,requestOptions?):Promise<EmptyObject>
Defined in: src/client.ts:3667
Manage a delayed event associated with the given delay_id.
Note: This endpoint is unstable, and can throw an Error.
Check progress on MSC4140 for more details.
Parameters
Section titled “Parameters”delayId
Section titled “delayId”string
action
Section titled “action”requestOptions?
Section titled “requestOptions?”IRequestOpts = {}
Returns
Section titled “Returns”Promise<EmptyObject>
[captureRejectionSymbol]()?
Section titled “[captureRejectionSymbol]()?”
optional[captureRejectionSymbol]<K>(error,event, …args):void
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:103
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”Error
string | symbol
…AnyRest
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”TypedEventEmitter.[captureRejectionSymbol]
addListener()
Section titled “addListener()”addListener<
T>(event,listener):this
Defined in: src/models/typed-event-emitter.ts:70
Alias for on.
Type Parameters
Section titled “Type Parameters”T extends EventEmitterEvents | EmittedEvents
Parameters
Section titled “Parameters”T
listener
Section titled “listener”Listener<EmittedEvents, ClientEventHandlerMap, T>
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”addPushRule()
Section titled “addPushRule()”addPushRule(
scope,kind,ruleId,body):Promise<EmptyObject>
Defined in: src/client.ts:7826
Parameters
Section titled “Parameters”string
ruleId
Section titled “ruleId”string
Pick<IPushRule, "actions" | "conditions" | "pattern">
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: an empty object {}
addThreePidOnly()
Section titled “addThreePidOnly()”addThreePidOnly(
data):Promise<EmptyObject>
Defined in: src/client.ts:7573
Add a 3PID to your hub account. This API does not use an identity server, as the hub is expected to handle 3PID ownership validation.
Parameters
Section titled “Parameters”A object with 3PID validation data from having called
account/3pid/<medium>/requestToken on the hub.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object {}
agreeToTerms()
Section titled “agreeToTerms()”agreeToTerms(
serviceType,baseUrl,accessToken,termsUrls):Promise<EmptyObject>
Defined in: src/client.ts:8555
Parameters
Section titled “Parameters”serviceType
Section titled “serviceType”baseUrl
Section titled “baseUrl”string
accessToken
Section titled “accessToken”string
termsUrls
Section titled “termsUrls”string[]
Returns
Section titled “Returns”Promise<EmptyObject>
backPaginateRoomEventsSearch()
Section titled “backPaginateRoomEventsSearch()”backPaginateRoomEventsSearch<
T>(searchResults):Promise<T>
Defined in: src/client.ts:5696
Take a result from an earlier searchRoomEvents call, and backfill results.
Type Parameters
Section titled “Type Parameters”T extends ISearchResults
Parameters
Section titled “Parameters”searchResults
Section titled “searchResults”T
the results object to be updated
Returns
Section titled “Returns”Promise<T>
Promise which resolves: updated result object
ban(
roomId,userId,reason?):Promise<EmptyObject>
Defined in: src/client.ts:4233
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
userId
Section titled “userId”string
reason?
Section titled “reason?”string
Optional.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: TODO
bindThreePid()
Section titled “bindThreePid()”bindThreePid(
data):Promise<EmptyObject>
Defined in: src/client.ts:7589
Bind a 3PID for discovery onto an identity server via the hub. The identity server handles 3PID ownership validation and the hub records the new binding to track where all 3PIDs for the account are bound.
Parameters
Section titled “Parameters”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.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object {}
bulkLookupThreePids()
Section titled “bulkLookupThreePids()”bulkLookupThreePids(
query,identityAccessToken):Promise<{threepids: [string,string,string][]; }>
Defined in: src/client.ts:8384
Looks up the public Digital World ID mappings for multiple 3PIDs.
Parameters
Section titled “Parameters”[string, string][]
Array of arrays containing [medium, address]
identityAccessToken
Section titled “identityAccessToken”string
The access_token field of the Identity
Server /account/register response (see registerWithIdentityServer).
Returns
Section titled “Returns”Promise<{ threepids: [string, string, string][]; }>
Promise which resolves: Lookup results from IS.
cancelPendingEvent()
Section titled “cancelPendingEvent()”cancelPendingEvent(
event):void
Defined in: src/client.ts:2519
Cancel a queued or unsent event.
Parameters
Section titled “Parameters”Event to cancel
Returns
Section titled “Returns”void
Throws
Section titled “Throws”Error if the event is not in QUEUED, NOT_SENT or ENCRYPTING state
cancelUpload()
Section titled “cancelUpload()”cancelUpload(
upload):boolean
Defined in: src/client.ts:7322
Cancel a file upload in progress
Parameters
Section titled “Parameters”upload
Section titled “upload”Promise<UploadResponse>
The object returned from uploadContent
Returns
Section titled “Returns”boolean
true if canceled, otherwise false
checkTurnServers()
Section titled “checkTurnServers()”checkTurnServers():
Promise<boolean|undefined>
Defined in: src/client.ts:5981
Returns
Section titled “Returns”Promise<boolean | undefined>
claimOneTimeKeys()
Section titled “claimOneTimeKeys()”claimOneTimeKeys(
devices,keyAlgorithm?,timeout?):Promise<IClaimOTKsResult>
Defined in: src/client.ts:7966
Claim one-time keys
Parameters
Section titled “Parameters”devices
Section titled “devices”[string, string][]
a list of [userId, deviceId] pairs
keyAlgorithm?
Section titled “keyAlgorithm?”string = "signed_curve25519"
desired key type
timeout?
Section titled “timeout?”number
the time (in milliseconds) to wait for keys from remote servers
Returns
Section titled “Returns”Promise<IClaimOTKsResult>
Promise which resolves: result object. Rejects: with an error response (DigitalWorldError).
clearStores()
Section titled “clearStores()”clearStores(
args?):Promise<void>
Defined in: src/client.ts:1600
Clear any data out of the persistent stores used by the client.
Parameters
Section titled “Parameters”cryptoDatabasePrefix?
Section titled “cryptoDatabasePrefix?”string
The database name to use for indexeddb, defaults to ‘digital-world-messaging-sdk’.
Returns
Section titled “Returns”Promise<void>
Promise which resolves when the stores have been cleared.
createAlias()
Section titled “createAlias()”createAlias(
alias,roomId):Promise<EmptyObject>
Defined in: src/client.ts:7205
Create an alias to room ID mapping.
Parameters
Section titled “Parameters”string
The room alias to create.
roomId
Section titled “roomId”string
The room ID to link the alias to.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: an empty object {}
createCall()
Section titled “createCall()”createCall(
roomId):DigitalWorldCall|null
Defined in: src/client.ts:1765
Creates a new call. The place*Call methods on the returned call can be used to actually place a call
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room the call is to be placed in.
Returns
Section titled “Returns”DigitalWorldCall | null
the call or null if the browser doesn’t support calling.
createFilter()
Section titled “createFilter()”createFilter(
content):Promise<Filter>
Defined in: src/client.ts:5800
Create a new filter.
Parameters
Section titled “Parameters”content
Section titled “content”The HTTP body for the request
Returns
Section titled “Returns”Promise<Filter>
Promise which resolves to a Filter object.
createGroupCall()
Section titled “createGroupCall()”createGroupCall(
roomId,type,isPtt,intent,dataChannelsEnabled?,dataChannelOptions?):Promise<GroupCall>
Defined in: src/client.ts:1775
Creates a new group call and sends the associated state event to alert other members that the room now has a group call.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room the call is to be placed in.
boolean
intent
Section titled “intent”dataChannelsEnabled?
Section titled “dataChannelsEnabled?”boolean
dataChannelOptions?
Section titled “dataChannelOptions?”IGroupCallDataChannelOptions
Returns
Section titled “Returns”Promise<GroupCall>
createMessagesRequest()
Section titled “createMessagesRequest()”createMessagesRequest(
roomId,fromToken,limit?,dir,timelineFilter?):Promise<IMessagesResponse>
Defined in: src/client.ts:4905
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
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
fromToken
Section titled “fromToken”string | null
limit?
Section titled “limit?”number = 30
the maximum amount of events the retrieve
‘f’ or ‘b’
timelineFilter?
Section titled “timelineFilter?”the timeline filter to pass
Returns
Section titled “Returns”Promise<IMessagesResponse>
createRoom()
Section titled “createRoom()”createRoom(
options):Promise<{room_id:string; }>
Defined in: src/client.ts:6850
Create a new room.
Parameters
Section titled “Parameters”options
Section titled “options”a list of options to pass to the /createRoom API.
Returns
Section titled “Returns”Promise<{ room_id: string; }>
Promise which resolves: {room_id: {string}}
createThreadListMessagesRequest()
Section titled “createThreadListMessagesRequest()”createThreadListMessagesRequest(
roomId,fromToken,limit?,dir?,threadListType?,timelineFilter?):Promise<IMessagesResponse>
Defined in: src/client.ts:4951
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
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
fromToken
Section titled “fromToken”string | null
limit?
Section titled “limit?”number = 30
the maximum amount of events the retrieve
Direction = Direction.Backward
‘f’ or ‘b’
threadListType?
Section titled “threadListType?”ThreadFilterType | null
timelineFilter?
Section titled “timelineFilter?”the timeline filter to pass
Returns
Section titled “Returns”Promise<IMessagesResponse>
deactivateAccount()
Section titled “deactivateAccount()”deactivateAccount(
auth?,erase?):Promise<{id_server_unbind_result:IdServerUnbindResult; }>
Defined in: src/client.ts:6790
Deactivates the logged-in account. Obviously, further calls that require authorisation should fail after this method is called. The state of the DigitalWorldClient object is not affected: it is up to the caller to either reset or destroy the DigitalWorldClient after this method succeeds.
Parameters
Section titled “Parameters”Optional. Auth data to supply for User-Interactive auth.
erase?
Section titled “erase?”boolean
Optional. If set, send as erase attribute in the
JSON request body, indicating whether the account should be erased. Defaults
to false.
Returns
Section titled “Returns”Promise<{ id_server_unbind_result: IdServerUnbindResult; }>
Promise which resolves: On success, the empty object
deactivateSynapseUser()
Section titled “deactivateSynapseUser()”deactivateSynapseUser(
userId):Promise<ISynapseAdminDeactivateResponse>
Defined in: src/client.ts:6082
Deactivates a user using Synapse’s administrator API. This function is implementation specific and may change as a result.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
the User ID to deactivate.
Returns
Section titled “Returns”Promise<ISynapseAdminDeactivateResponse>
the deactivate response - see Synapse docs for information.
decryptEventIfNeeded()
Section titled “decryptEventIfNeeded()”decryptEventIfNeeded(
event,options?):Promise<void>
Defined in: src/client.ts:6419
Attempts to decrypt an event
Parameters
Section titled “Parameters”The event to decrypt
options?
Section titled “options?”Returns
Section titled “Returns”Promise<void>
A decryption promise
deleteAccountData()
Section titled “deleteAccountData()”deleteAccountData(
eventType):Promise<void>
Defined in: src/client.ts:2351
Parameters
Section titled “Parameters”eventType
Section titled “eventType”keyof AccountDataEvents
Returns
Section titled “Returns”Promise<void>
deleteAlias()
Section titled “deleteAlias()”deleteAlias(
alias):Promise<EmptyObject>
Defined in: src/client.ts:7222
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.
Parameters
Section titled “Parameters”string
The room alias to delete.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: an empty object {}.
deleteDevice()
Section titled “deleteDevice()”deleteDevice(
deviceId,auth?):Promise<EmptyObject>
Defined in: src/client.ts:7701
Delete the given device
Parameters
Section titled “Parameters”deviceId
Section titled “deviceId”string
device to delete
Optional. Auth data to supply for User-Interactive auth.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: result object
deleteExtendedProfileProperty()
Section titled “deleteExtendedProfileProperty()”deleteExtendedProfileProperty(
key):Promise<void>
Defined in: src/client.ts:7486
Delete a property on your extended profile.
Parameters
Section titled “Parameters”string
The key of the property to delete.
Returns
Section titled “Returns”Promise<void>
https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md
Throws
Section titled “Throws”An error if the server does not support MSC4133 OR the server disallows editing the user profile.
deleteKeysFromBackup()
Section titled “deleteKeysFromBackup()”Call Signature
Section titled “Call Signature”deleteKeysFromBackup(
roomId,sessionId,version?):Promise<void>
Defined in: src/client.ts:2140
Parameters
Section titled “Parameters”roomId
Section titled “roomId”undefined
sessionId
Section titled “sessionId”undefined
version?
Section titled “version?”string
Returns
Section titled “Returns”Promise<void>
Call Signature
Section titled “Call Signature”deleteKeysFromBackup(
roomId,sessionId,version?):Promise<void>
Defined in: src/client.ts:2141
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
sessionId
Section titled “sessionId”undefined
version?
Section titled “version?”string
Returns
Section titled “Returns”Promise<void>
Call Signature
Section titled “Call Signature”deleteKeysFromBackup(
roomId,sessionId,version?):Promise<void>
Defined in: src/client.ts:2142
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
sessionId
Section titled “sessionId”string
version?
Section titled “version?”string
Returns
Section titled “Returns”Promise<void>
deleteMultipleDevices()
Section titled “deleteMultipleDevices()”deleteMultipleDevices(
devices,auth?):Promise<EmptyObject>
Defined in: src/client.ts:7723
Delete multiple device
Parameters
Section titled “Parameters”devices
Section titled “devices”string[]
IDs of the devices to delete
Optional. Auth data to supply for User-Interactive auth.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: result object
deletePushRule()
Section titled “deletePushRule()”deletePushRule(
scope,kind,ruleId):Promise<EmptyObject>
Defined in: src/client.ts:7844
Parameters
Section titled “Parameters”string
ruleId
Section titled “ruleId”string
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: an empty object {}
deleteRoomTag()
Section titled “deleteRoomTag()”deleteRoomTag(
roomId,tagName):Promise<EmptyObject>
Defined in: src/client.ts:2595
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
tagName
Section titled “tagName”string
name of room tag to be removed
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object
deleteThreePid()
Section titled “deleteThreePid()”deleteThreePid(
medium,address):Promise<{id_server_unbind_result:IdServerUnbindResult; }>
Defined in: src/client.ts:7627
Parameters
Section titled “Parameters”medium
Section titled “medium”string
The threepid medium (eg. ‘email’)
address
Section titled “address”string
The threepid address (eg. ‘bob@example.com’) this must be as returned by getThreePids.
Returns
Section titled “Returns”Promise<{ id_server_unbind_result: IdServerUnbindResult; }>
Promise which resolves: The server response on success (generally the empty JSON object)
doesServerForceEncryptionForPreset()
Section titled “doesServerForceEncryptionForPreset()”doesServerForceEncryptionForPreset(
presetName):Promise<boolean>
Defined in: src/client.ts:6273
Query the server to see if it is forcing encryption to be enabled for a given room preset, based on the /versions response.
Parameters
Section titled “Parameters”presetName
Section titled “presetName”The name of the preset to check.
Returns
Section titled “Returns”Promise<boolean>
true if the server is forcing encryption for the preset.
doesServerSupportExtendedProfiles()
Section titled “doesServerSupportExtendedProfiles()”doesServerSupportExtendedProfiles():
Promise<boolean>
Defined in: src/client.ts:7360
Determine if the server supports extended profiles, as described by MSC4133.
Returns
Section titled “Returns”Promise<boolean>
true if supported, otherwise false
doesServerSupportThread()
Section titled “doesServerSupportThread()”doesServerSupportThread():
Promise<{fwdPagination:FeatureSupport;list:FeatureSupport;threads:FeatureSupport; }>
Defined in: src/client.ts:6286
Returns
Section titled “Returns”Promise<{ fwdPagination: FeatureSupport; list: FeatureSupport; threads: FeatureSupport; }>
doesServerSupportUnstableFeature()
Section titled “doesServerSupportUnstableFeature()”doesServerSupportUnstableFeature(
feature):Promise<boolean>
Defined in: src/client.ts:6259
Query the server to see if it lists support for an unstable feature in the /versions response
Parameters
Section titled “Parameters”feature
Section titled “feature”string
the feature name
Returns
Section titled “Returns”Promise<boolean>
true if the feature is supported
downloadKeysForUsers()
Section titled “downloadKeysForUsers()”downloadKeysForUsers(
userIds,token?):Promise<IDownloadKeyResult>
Defined in: src/client.ts:7939
Download device keys
Parameters
Section titled “Parameters”userIds
Section titled “userIds”string[]
list of users to get keys for
token?
Section titled “token?”sync token to pass in the query request, to help the HS give the most recent results
token?
Section titled “token?”string
Returns
Section titled “Returns”Promise<IDownloadKeyResult>
Promise which resolves: result object. Rejects: with an error response (DigitalWorldError).
emit()
Section titled “emit()”Call Signature
Section titled “Call Signature”emit<
T>(event, …args):boolean
Defined in: src/models/typed-event-emitter.ts:86
Synchronously calls each of the listeners registered for the event named
event, in the order they were registered, passing the supplied arguments
to each.
Type Parameters
Section titled “Type Parameters”T extends EmittedEvents
Parameters
Section titled “Parameters”T
The name of the event to emit
…Parameters<ClientEventHandlerMap[T]>
Arguments to pass to the listener
Returns
Section titled “Returns”boolean
true if the event had listeners, false otherwise.
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”emit<
T>(event, …args):boolean
Defined in: src/models/typed-event-emitter.ts:87
Synchronously calls each of the listeners registered for the event named
event, in the order they were registered, passing the supplied arguments
to each.
Type Parameters
Section titled “Type Parameters”T extends EmittedEvents
Parameters
Section titled “Parameters”T
The name of the event to emit
…Parameters<ClientEventHandlerMap[T]>
Arguments to pass to the listener
Returns
Section titled “Returns”boolean
true if the event had listeners, false otherwise.
Inherited from
Section titled “Inherited from”emitPromised()
Section titled “emitPromised()”Call Signature
Section titled “Call Signature”emitPromised<
T>(event, …args):Promise<boolean>
Defined in: src/models/typed-event-emitter.ts:98
Similar to emit but calls all listeners within a Promise.all and returns the promise chain
Type Parameters
Section titled “Type Parameters”T extends EmittedEvents
Parameters
Section titled “Parameters”T
The name of the event to emit
…Parameters<ClientEventHandlerMap[T]>
Arguments to pass to the listener
Returns
Section titled “Returns”Promise<boolean>
true if the event had listeners, false otherwise.
Inherited from
Section titled “Inherited from”TypedEventEmitter.emitPromised
Call Signature
Section titled “Call Signature”emitPromised<
T>(event, …args):Promise<boolean>
Defined in: src/models/typed-event-emitter.ts:102
Similar to emit but calls all listeners within a Promise.all and returns the promise chain
Type Parameters
Section titled “Type Parameters”T extends EmittedEvents
Parameters
Section titled “Parameters”T
The name of the event to emit
…Parameters<ClientEventHandlerMap[T]>
Arguments to pass to the listener
Returns
Section titled “Returns”Promise<boolean>
true if the event had listeners, false otherwise.
Inherited from
Section titled “Inherited from”TypedEventEmitter.emitPromised
encryptAndSendToDevice()
Section titled “encryptAndSendToDevice()”encryptAndSendToDevice(
eventType,devices,payload):Promise<void>
Defined in: src/client.ts:8472
This will encrypt the payload for all devices in the list and will queue it.
The type of the sent to-device message will be m.room.encrypted.
Parameters
Section titled “Parameters”eventType
Section titled “eventType”string
The type of event to send
devices
Section titled “devices”object[]
The list of devices to send the event to.
payload
Section titled “payload”ToDevicePayload
The payload to send. This will be encrypted.
Returns
Section titled “Returns”Promise<void>
Promise which resolves once queued there is no error feedback when sending fails.
eventNames()
Section titled “eventNames()”eventNames(): (
string|symbol)[]
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:967
Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbols.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();myEE.on('foo', () => {});myEE.on('bar', () => {});
const sym = Symbol('symbol');myEE.on(sym, () => {});
console.log(myEE.eventNames());// Prints: [ 'foo', 'bar', Symbol(symbol) ]Returns
Section titled “Returns”(string | symbol)[]
v6.0.0
Inherited from
Section titled “Inherited from”fetchCapabilities()
Section titled “fetchCapabilities()”fetchCapabilities():
Promise<Capabilities>
Defined in: src/client.ts:1964
Fetches the latest capabilities from the hub, ignoring any cached versions. The newly returned version is cached.
Returns
Section titled “Returns”Promise<Capabilities>
A promise which resolves to the capabilities of the hub
fetchRelations()
Section titled “fetchRelations()”fetchRelations(
roomId,eventId,relationType,eventType?,opts?):Promise<IRelationsResponse>
Defined in: src/client.ts:6877
Fetches relations for a given event
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
the room of the event
eventId
Section titled “eventId”string
the id of the event
relationType
Section titled “relationType”string | null
the rel_type of the relations requested
eventType?
Section titled “eventType?”string | null
the event type of the relations requested
IRelationsRequestOpts = ...
options with optional values for the request.
Returns
Section titled “Returns”Promise<IRelationsResponse>
the response, with chunk, prev_batch and, next_batch.
fetchRoomEvent()
Section titled “fetchRoomEvent()”fetchRoomEvent(
roomId,eventId):Promise<Partial<IEvent>>
Defined in: src/client.ts:6931
Get an event in a room by its event id.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
eventId
Section titled “eventId”string
Returns
Section titled “Returns”Promise<Partial<IEvent>>
Promise which resolves to an object containing the event.
forget()
Section titled “forget()”forget(
roomId,deleteRoom?):Promise<EmptyObject>
Defined in: src/client.ts:4243
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
deleteRoom?
Section titled “deleteRoom?”boolean = true
True to delete the room from the store on success. Default: true.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: {} an empty object.
generateClientSecret()
Section titled “generateClientSecret()”generateClientSecret():
string
Defined in: src/client.ts:6410
Generates a random string suitable for use as a client secret. This method is experimental and may change.
Returns
Section titled “Returns”string
A new client secret
getAccessToken()
Section titled “getAccessToken()”getAccessToken():
string|null
Defined in: src/client.ts:6479
Get the access token associated with this account.
Returns
Section titled “Returns”string | null
The access_token or null
getAccountData()
Section titled “getAccountData()”getAccountData<
K>(eventType):DigitalWorldEvent|undefined
Defined in: src/client.ts:2313
Get account data event of given type for the current user.
Type Parameters
Section titled “Type Parameters”K extends keyof AccountDataEvents
Parameters
Section titled “Parameters”eventType
Section titled “eventType”K
The event type
Returns
Section titled “Returns”DigitalWorldEvent | undefined
The contents of the given account data event
getAccountDataFromServer()
Section titled “getAccountDataFromServer()”getAccountDataFromServer<
K>(eventType):Promise<AccountDataEvents[K] |null>
Defined in: src/client.ts:2325
Get account data event of given type for the current user. This variant gets account data directly from the hub if the local store is not ready, which can be useful very early in startup before the initial sync.
Type Parameters
Section titled “Type Parameters”K extends keyof AccountDataEvents
Parameters
Section titled “Parameters”eventType
Section titled “eventType”K
The event type
Returns
Section titled “Returns”Promise<AccountDataEvents[K] | null>
Promise which resolves: The contents of the given account data event.
getAuthMetadata()
Section titled “getAuthMetadata()”getAuthMetadata():
Promise<ValidatedAuthMetadata>
Defined in: src/client.ts:8896
Discover and validate the auth metadata for the OAuth 2.0 API.
When successful, validated metadata is returned.
Returns
Section titled “Returns”Promise<ValidatedAuthMetadata>
validated authentication metadata
Throws
Section titled “Throws”when delegated auth config is invalid or unreachable
getCachedCapabilities()
Section titled “getCachedCapabilities()”getCachedCapabilities():
Capabilities|undefined
Defined in: src/client.ts:1954
Gets the cached capabilities of the hub. If none have been fetched yet, return undefined.
Returns
Section titled “Returns”Capabilities | undefined
The capabilities of the hub
getCanResetTimelineCallback()
Section titled “getCanResetTimelineCallback()”getCanResetTimelineCallback():
ResetTimelineCallback|undefined
Defined in: src/client.ts:6349
Get the callback set via setCanResetTimelineCallback.
Returns
Section titled “Returns”ResetTimelineCallback | undefined
The callback or null
getCapabilities()
Section titled “getCapabilities()”getCapabilities():
Promise<Capabilities>
Defined in: src/client.ts:1942
Gets the cached capabilities of the hub, returning cached ones if available. If there are no cached capabilities and none can be fetched, throw an exception.
Returns
Section titled “Returns”Promise<Capabilities>
Promise resolving with The capabilities of the hub
getCasLoginUrl()
Section titled “getCasLoginUrl()”getCasLoginUrl(
redirectUrl):string
Defined in: src/client.ts:6703
Parameters
Section titled “Parameters”redirectUrl
Section titled “redirectUrl”string
The URL to redirect to after the HS authenticates with CAS.
Returns
Section titled “Returns”string
The HS URL to hit to begin the CAS login process.
getClientWellKnown()
Section titled “getClientWellKnown()”getClientWellKnown():
IClientWellKnown|undefined
Defined in: src/client.ts:6095
Returns
Section titled “Returns”IClientWellKnown | undefined
getCrypto()
Section titled “getCrypto()”getCrypto():
CryptoApi|undefined
Defined in: src/client.ts:2087
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.
Returns
Section titled “Returns”CryptoApi | undefined
getCurrentUploads()
Section titled “getCurrentUploads()”getCurrentUploads():
Upload[]
Defined in: src/client.ts:7334
Get a list of all file uploads in progress
Returns
Section titled “Returns”Upload[]
Array of objects representing current uploads. Currently in progress is element 0. Keys:
- promise: The promise associated with the upload
- loaded: Number of bytes uploaded
- total: Total number of bytes to upload
getDevice()
Section titled “getDevice()”getDevice(
deviceId):Promise<IMyDevice>
Defined in: src/client.ts:7669
Gets specific device details for the logged-in user
Parameters
Section titled “Parameters”deviceId
Section titled “deviceId”string
device to query
Returns
Section titled “Returns”Promise<IMyDevice>
Promise which resolves: result object
getDeviceId()
Section titled “getDeviceId()”getDeviceId():
string|null
Defined in: src/client.ts:1704
Get the device ID of this client
Returns
Section titled “Returns”string | null
device ID
getDevices()
Section titled “getDevices()”getDevices():
Promise<{devices:IMyDevice[]; }>
Defined in: src/client.ts:7659
Gets all devices recorded for the logged-in user
Returns
Section titled “Returns”Promise<{ devices: IMyDevice[]; }>
Promise which resolves: result object
getDomain()
Section titled “getDomain()”getDomain():
string|null
Defined in: src/client.ts:1685
Get the domain for this client’s Digital World ID
Returns
Section titled “Returns”string | null
Domain of this Digital World ID
getEventMapper()
Section titled “getEventMapper()”getEventMapper(
options?):EventMapper
Defined in: src/client.ts:4564
Parameters
Section titled “Parameters”options?
Section titled “options?”MapperOpts
Returns
Section titled “Returns”EventMapper
getEventTimeline()
Section titled “getEventTimeline()”getEventTimeline(
timelineSet,eventId):Promise<EventTimeline|null>
Defined in: src/client.ts:4622
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.
Parameters
Section titled “Parameters”timelineSet
Section titled “timelineSet”The timelineSet to look for the event in, must be bound to a room
eventId
Section titled “eventId”string
The ID of the event to look for
Returns
Section titled “Returns”Promise<EventTimeline | null>
Promise which resolves: EventTimeline including the given event
getExtendedProfile()
Section titled “getExtendedProfile()”getExtendedProfile(
userId):Promise<Record<string,unknown>>
Defined in: src/client.ts:7395
Fetch a user’s extended profile, which may include additional keys. Always returns all available profile fields, irrespective of what profile fields are set in the sync filter.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
The user ID to fetch the profile of.
Returns
Section titled “Returns”Promise<Record<string, unknown>>
A set of keys to property values.
https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md
Throws
Section titled “Throws”An error if the server does not support MSC4133.
Throws
Section titled “Throws”A M_NOT_FOUND error if the profile could not be found.
getExtendedProfileProperty()
Section titled “getExtendedProfileProperty()”getExtendedProfileProperty(
userId,key):Promise<unknown>
Defined in: src/client.ts:7426
Fetch a specific key from the user’s extended profile by checking local cache (which is updated from the sync) and querying the server if no data is cached locally.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
The user ID to fetch the profile of.
string
The key of the property to fetch.
Returns
Section titled “Returns”Promise<unknown>
The property value.
https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md
Throws
Section titled “Throws”An error if the server does not support MSC4133.
Throws
Section titled “Throws”A M_NOT_FOUND error if the key was not set OR the profile could not be found.
getFallbackAuthUrl()
Section titled “getFallbackAuthUrl()”getFallbackAuthUrl(
loginType,authSessionId):string
Defined in: src/client.ts:6834
Get the fallback URL to use for unknown interactive-auth stages.
Parameters
Section titled “Parameters”loginType
Section titled “loginType”string
the type of stage being attempted
authSessionId
Section titled “authSessionId”string
the auth session ID provided by the hub
Returns
Section titled “Returns”string
HS URL to hit to for the fallback interface
getFilter()
Section titled “getFilter()”getFilter(
userId,filterId,allowCached):Promise<Filter>
Defined in: src/client.ts:5821
Retrieve a filter.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
The user ID of the filter owner
filterId
Section titled “filterId”string
The filter ID to retrieve
allowCached
Section titled “allowCached”boolean
True to allow cached filters to be returned. Default: True.
Returns
Section titled “Returns”Promise<Filter>
Promise which resolves: a Filter object
getGroupCallForRoom()
Section titled “getGroupCallForRoom()”getGroupCallForRoom(
roomId):GroupCall|null
Defined in: src/client.ts:1839
Get an existing group call for the provided room.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
Returns
Section titled “Returns”GroupCall | null
The group call or null if it doesn’t already exist.
getHubUrl()
Section titled “getHubUrl()”getHubUrl():
string
Defined in: src/client.ts:6450
Get the Hub URL of this client
Returns
Section titled “Returns”string
Hub URL of this client
getIdentityAccount()
Section titled “getIdentityAccount()”getIdentityAccount(
identityAccessToken):Promise<{user_id:string; }>
Defined in: src/client.ts:8427
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.
Parameters
Section titled “Parameters”identityAccessToken
Section titled “identityAccessToken”string
The access_token field of the Identity
Server /account/register response (see registerWithIdentityServer).
Returns
Section titled “Returns”Promise<{ user_id: string; }>
Promise which resolves: an object with account info.
getIdentityHashDetails()
Section titled “getIdentityHashDetails()”getIdentityHashDetails(
identityAccessToken):Promise<{algorithms:string[];lookup_pepper:string; }>
Defined in: src/client.ts:8220
Gets the V2 hashing information from the identity server. Primarily useful for lookups.
Parameters
Section titled “Parameters”identityAccessToken
Section titled “identityAccessToken”string
The access token for the identity server.
Returns
Section titled “Returns”Promise<{ algorithms: string[]; lookup_pepper: string; }>
The hashing information for the identity server.
getIdentityServerUrl()
Section titled “getIdentityServerUrl()”getIdentityServerUrl(
stripProto?):string|undefined
Defined in: src/client.ts:6459
Get the identity server URL of this client
Parameters
Section titled “Parameters”stripProto?
Section titled “stripProto?”boolean = false
whether or not to strip the protocol from the URL
Returns
Section titled “Returns”string | undefined
Identity server URL of this client
getIgnoredUsers()
Section titled “getIgnoredUsers()”getIgnoredUsers():
string[]
Defined in: src/client.ts:2373
Gets the users that are ignored by this client
Returns
Section titled “Returns”string[]
The array of users that are ignored (empty if none)
getJoinedRoomMembers()
Section titled “getJoinedRoomMembers()”getJoinedRoomMembers(
roomId):Promise<IJoinedMembersResponse>
Defined in: src/client.ts:7163
Retrieve membership info. for a room.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
ID of the room to get membership for
Returns
Section titled “Returns”Promise<IJoinedMembersResponse>
Promise which resolves: A list of currently joined users and their profile data.
getJoinedRooms()
Section titled “getJoinedRooms()”getJoinedRooms():
Promise<IJoinedRoomsResponse>
Defined in: src/client.ts:7151
Returns
Section titled “Returns”Promise<IJoinedRoomsResponse>
Promise which resolves: A list of the user’s current rooms
getKeyChanges()
Section titled “getKeyChanges()”getKeyChanges(
oldToken,newToken):Promise<{changed:string[];left:string[]; }>
Defined in: src/client.ts:7998
Ask the server for a list of users who have changed their device lists between a pair of sync tokens
Parameters
Section titled “Parameters”oldToken
Section titled “oldToken”string
newToken
Section titled “newToken”string
Returns
Section titled “Returns”Promise<{ changed: string[]; left: string[]; }>
Promise which resolves: result object. Rejects: with an error response (DigitalWorldError).
getLatestTimeline()
Section titled “getLatestTimeline()”getLatestTimeline(
timelineSet):Promise<EventTimeline|null>
Defined in: src/client.ts:4839
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.
Parameters
Section titled “Parameters”timelineSet
Section titled “timelineSet”The timelineSet to find or add the timeline to
Returns
Section titled “Returns”Promise<EventTimeline | null>
Promise which resolves: EventTimeline timeline with the latest events in the room
getLivekitServiceURL()
Section titled “getLivekitServiceURL()”getLivekitServiceURL():
string|undefined
Defined in: src/client.ts:1810
Returns
Section titled “Returns”string | undefined
getLocalAliases()
Section titled “getLocalAliases()”getLocalAliases(
roomId):Promise<{aliases:string[]; }>
Defined in: src/client.ts:7236
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.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room ID to get local aliases for.
Returns
Section titled “Returns”Promise<{ aliases: string[]; }>
Promise which resolves: an object with an aliases property, containing an array of local aliases
getMaxListeners()
Section titled “getMaxListeners()”getMaxListeners():
number
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:819
Returns the current max listener value for the EventEmitter which is either
set by emitter.setMaxListeners(n) or defaults to EventEmitter.defaultMaxListeners.
Returns
Section titled “Returns”number
v1.0.0
Inherited from
Section titled “Inherited from”TypedEventEmitter.getMaxListeners
getMediaConfig()
Section titled “getMediaConfig()”getMediaConfig(
useAuthenticatedMedia?):Promise<IMediaConfig>
Defined in: src/client.ts:2158
Get the config for the media repository.
Parameters
Section titled “Parameters”useAuthenticatedMedia?
Section titled “useAuthenticatedMedia?”boolean = false
If 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.
Returns
Section titled “Returns”Promise<IMediaConfig>
Promise which resolves with an object containing the config.
getMediaHandler()
Section titled “getMediaHandler()”getMediaHandler():
MediaHandler
Defined in: src/client.ts:1727
Returns
Section titled “Returns”MediaHandler
getNotifTimelineSet()
Section titled “getNotifTimelineSet()”getNotifTimelineSet():
EventTimelineSet|null
Defined in: src/client.ts:1924
Return the global notification EventTimelineSet, if any
Returns
Section titled “Returns”EventTimelineSet | null
the globl notification EventTimelineSet
getOpenIdToken()
Section titled “getOpenIdToken()”getOpenIdToken():
Promise<IOpenIDToken>
Defined in: src/client.ts:5899
Gets a bearer token from the hub that the user can present to a third party in order to prove their ownership of the account they are logged into.
Returns
Section titled “Returns”Promise<IOpenIDToken>
Promise which resolves: Token object
getOrCreateFilter()
Section titled “getOrCreateFilter()”getOrCreateFilter(
filterName,filter):Promise<string>
Defined in: src/client.ts:5845
Parameters
Section titled “Parameters”filterName
Section titled “filterName”string
filter
Section titled “filter”Returns
Section titled “Returns”Promise<string>
Filter ID
getPresence()
Section titled “getPresence()”getPresence(
userId):Promise<IStatusResponse>
Defined in: src/client.ts:4468
Parameters
Section titled “Parameters”userId
Section titled “userId”string
The user to get presence for
Returns
Section titled “Returns”Promise<IStatusResponse>
Promise which resolves: The presence state for this user.
getProfileInfo()
Section titled “getProfileInfo()”getProfileInfo(
userId,info?):Promise<{avatar_url?:string;displayname?:string; }>
Defined in: src/client.ts:7344
Parameters
Section titled “Parameters”userId
Section titled “userId”string
string
The kind of info to retrieve (e.g. ‘displayname’, ‘avatar_url’).
Returns
Section titled “Returns”Promise<{ avatar_url?: string; displayname?: string; }>
Promise which resolves: TODO
getPushActionsForEvent()
Section titled “getPushActionsForEvent()”getPushActionsForEvent(
event,forceRecalculate?):IActionsObject|null
Defined in: src/client.ts:4316
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.
Parameters
Section titled “Parameters”The event to get push actions for.
forceRecalculate?
Section titled “forceRecalculate?”boolean = false
forces to recalculate actions for an event Useful when an event just got decrypted
Returns
Section titled “Returns”IActionsObject | null
A dict of actions to perform.
getPushDetailsForEvent()
Section titled “getPushDetailsForEvent()”getPushDetailsForEvent(
event,forceRecalculate?):PushDetails|null
Defined in: src/client.ts:4332
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.
Parameters
Section titled “Parameters”The event to get push actions for.
forceRecalculate?
Section titled “forceRecalculate?”boolean = false
forces to recalculate actions for an event Useful when an event just got decrypted
Returns
Section titled “Returns”PushDetails | null
A dict of actions to perform.
getPushers()
Section titled “getPushers()”getPushers():
Promise<{pushers:IPusher[]; }>
Defined in: src/client.ts:7740
Gets all pushers registered for the logged-in user
Returns
Section titled “Returns”Promise<{ pushers: IPusher[]; }>
Promise which resolves: Array of objects representing pushers
getPushRules()
Section titled “getPushRules()”getPushRules():
Promise<IPushRules>
Defined in: src/client.ts:7804
Get the push rules for the account from the server.
Returns
Section titled “Returns”Promise<IPushRules>
Promise which resolves to the push rules.
getRefreshToken()
Section titled “getRefreshToken()”getRefreshToken():
string|null
Defined in: src/client.ts:6487
Get the refresh token associated with this account.
Returns
Section titled “Returns”string | null
The refresh_token or null
getRoom()
Section titled “getRoom()”getRoom(
roomId):Room|null
Defined in: src/client.ts:2173
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.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string | undefined
The room ID
Returns
Section titled “Returns”Room | null
The Room or null if it doesn’t exist or there is no data store.
getRoomDirectoryVisibility()
Section titled “getRoomDirectoryVisibility()”getRoomDirectoryVisibility(
roomId):Promise<{visibility:Visibility; }>
Defined in: src/client.ts:7261
Get the visibility of a room in the current HS’s room directory
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
Returns
Section titled “Returns”Promise<{ visibility: Visibility; }>
Promise which resolves: TODO
getRoomHierarchy()
Section titled “getRoomHierarchy()”getRoomHierarchy(
roomId,limit?,maxDepth?,suggestedOnly?,fromToken?):Promise<IRoomHierarchy>
Defined in: src/client.ts:8619
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.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The ID of the space-room to use as the root of the summary.
limit?
Section titled “limit?”number
The maximum number of rooms to return per page.
maxDepth?
Section titled “maxDepth?”number
The maximum depth in the tree from the root room to return.
suggestedOnly?
Section titled “suggestedOnly?”boolean = false
Whether to only return rooms with suggested=true.
fromToken?
Section titled “fromToken?”string
The opaque token to paginate a previous request.
Returns
Section titled “Returns”Promise<IRoomHierarchy>
the response, with next_batch & rooms fields.
getRoomIdForAlias()
Section titled “getRoomIdForAlias()”getRoomIdForAlias(
alias):Promise<{room_id:string;servers:string[]; }>
Defined in: src/client.ts:7248
Get room info for the given alias.
Parameters
Section titled “Parameters”string
The room alias to resolve.
Returns
Section titled “Returns”Promise<{ room_id: string; servers: string[]; }>
Promise which resolves: Object with room_id and servers.
getRoomPushRule()
Section titled “getRoomPushRule()”getRoomPushRule(
scope,roomId):IPushRule|undefined
Defined in: src/client.ts:5536
Get the room-kind push rule associated with a room.
Parameters
Section titled “Parameters”"global" | "device"
“global” or device-specific.
roomId
Section titled “roomId”string
the id of the room.
Returns
Section titled “Returns”IPushRule | undefined
the rule or undefined.
getRooms()
Section titled “getRooms()”getRooms():
Room[]
Defined in: src/client.ts:2184
Retrieve all known rooms.
Returns
Section titled “Returns”Room[]
A list of rooms, or an empty list if there is no data store.
getRoomSummary()
Section titled “getRoomSummary()”getRoomSummary(
roomIdOrAlias,via?):Promise<RoomSummary>
Defined in: src/client.ts:8776
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
Parameters
Section titled “Parameters”roomIdOrAlias
Section titled “roomIdOrAlias”string
The ID or alias of the room to get the summary of.
string[]
The list of servers which know about the room if only an ID was provided.
Returns
Section titled “Returns”Promise<RoomSummary>
getRoomTags()
Section titled “getRoomTags()”getRoomTags(
roomId):Promise<ITagsResponse>
Defined in: src/client.ts:2567
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
Returns
Section titled “Returns”Promise<ITagsResponse>
Promise which resolves: to an object keyed by tagId with objects containing a numeric order field.
getRoomUpgradeHistory()
Section titled “getRoomUpgradeHistory()”getRoomUpgradeHistory(
roomId,verifyLinks?,msc3946ProcessDynamicPredecessor?):Room[]
Defined in: src/client.ts:4015
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.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room ID to search from
verifyLinks?
Section titled “verifyLinks?”boolean = false
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.
msc3946ProcessDynamicPredecessor?
Section titled “msc3946ProcessDynamicPredecessor?”boolean = false
if true, look for m.room.predecessor state events as well as create events, and prefer predecessor events where they exist (MSC3946).
Returns
Section titled “Returns”Room[]
An array of rooms representing the upgrade history.
getSafeUserId()
Section titled “getSafeUserId()”getSafeUserId():
string
Defined in: src/client.ts:1673
Get the user-id of the logged-in user
Returns
Section titled “Returns”string
Digital World ID for the logged-in user
Throws
Section titled “Throws”Error if not logged in
getScheduler()
Section titled “getScheduler()”getScheduler():
DigitalWorldScheduler<ISendEventResponse> |undefined
Defined in: src/client.ts:1902
Return the provided scheduler, if any.
Returns
Section titled “Returns”DigitalWorldScheduler<ISendEventResponse> | undefined
The scheduler or undefined
getSessionId()
Section titled “getSessionId()”getSessionId():
string
Defined in: src/client.ts:1712
Get the session ID of this client
Returns
Section titled “Returns”string
session ID
getSsoLoginUrl()
Section titled “getSsoLoginUrl()”getSsoLoginUrl(
redirectUrl,loginType?,idpId?,action?):string
Defined in: src/client.ts:6716
Parameters
Section titled “Parameters”redirectUrl
Section titled “redirectUrl”string
The URL to redirect to after the HS authenticates with the SSO.
loginType?
Section titled “loginType?”string = "sso"
The type of SSO login we are doing (sso or cas). Defaults to ‘sso’.
idpId?
Section titled “idpId?”string
The ID of the Identity Provider being targeted, optional.
action?
Section titled “action?”the SSO flow to indicate to the IdP, optional.
Returns
Section titled “Returns”string
The HS URL to hit to begin the SSO login process.
getStateEvent()
Section titled “getStateEvent()”getStateEvent(
roomId,eventType,stateKey):Promise<Record<string,any>>
Defined in: src/client.ts:6996
Retrieve a state event.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
eventType
Section titled “eventType”string
stateKey
Section titled “stateKey”string
Returns
Section titled “Returns”Promise<Record<string, any>>
Promise which resolves: TODO
getSyncState()
Section titled “getSyncState()”getSyncState():
SyncState|null
Defined in: src/client.ts:1848
Get the current sync state.
Returns
Section titled “Returns”SyncState | null
the sync state, which may be null.
DigitalWorldClient#event:“sync”
getSyncStateData()
Section titled “getSyncStateData()”getSyncStateData():
SyncStateData|null
Defined in: src/client.ts:1859
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.
Returns
Section titled “Returns”SyncStateData | null
getTerms()
Section titled “getTerms()”getTerms(
serviceType,baseUrl):Promise<Terms>
Defined in: src/client.ts:8550
Parameters
Section titled “Parameters”serviceType
Section titled “serviceType”baseUrl
Section titled “baseUrl”string
Returns
Section titled “Returns”Promise<Terms>
getThirdpartyLocation()
Section titled “getThirdpartyLocation()”getThirdpartyLocation(
protocol,params):Promise<IThirdPartyLocation[]>
Defined in: src/client.ts:8523
Get information on how a specific place on a third party protocol may be reached.
Parameters
Section titled “Parameters”protocol
Section titled “protocol”string
The protocol given in getThirdpartyProtocols()
params
Section titled “params”Protocol-specific parameters, as given in the response to getThirdpartyProtocols()
searchFields?
Section titled “searchFields?”string[]
Returns
Section titled “Returns”Promise<IThirdPartyLocation[]>
Promise which resolves to the result object
getThirdpartyProtocols()
Section titled “getThirdpartyProtocols()”getThirdpartyProtocols():
Promise<{[protocol:string]:IProtocol; }>
Defined in: src/client.ts:8503
Get the third party protocols that can be reached using this HS
Returns
Section titled “Returns”Promise<{[protocol: string]: IProtocol; }>
Promise which resolves to the result object
getThirdpartyUser()
Section titled “getThirdpartyUser()”getThirdpartyUser(
protocol,params?):Promise<IThirdPartyUser[]>
Defined in: src/client.ts:8542
Get information on how a specific user on a third party protocol may be reached.
Parameters
Section titled “Parameters”protocol
Section titled “protocol”string
The protocol given in getThirdpartyProtocols()
params?
Section titled “params?”QueryDict
Protocol-specific parameters, as given in the response to getThirdpartyProtocols()
Returns
Section titled “Returns”Promise<IThirdPartyUser[]>
Promise which resolves to the result object
getThreadTimeline()
Section titled “getThreadTimeline()”getThreadTimeline(
timelineSet,eventId):Promise<EventTimeline|undefined>
Defined in: src/client.ts:4692
Parameters
Section titled “Parameters”timelineSet
Section titled “timelineSet”eventId
Section titled “eventId”string
Returns
Section titled “Returns”Promise<EventTimeline | undefined>
getThreePids()
Section titled “getThreePids()”getThreePids():
Promise<{threepids:IThreepid[]; }>
Defined in: src/client.ts:7560
Returns
Section titled “Returns”Promise<{ threepids: IThreepid[]; }>
Promise which resolves to a list of the user’s threepids.
getTurnServers()
Section titled “getTurnServers()”getTurnServers():
ITurnServer[]
Defined in: src/client.ts:5963
Get the TURN servers for this hub.
Returns
Section titled “Returns”The servers or an empty list.
getTurnServersExpiry()
Section titled “getTurnServersExpiry()”getTurnServersExpiry():
number
Defined in: src/client.ts:5972
Get the unix timestamp (in milliseconds) at which the current TURN credentials (from getTurnServers) expire
Returns
Section titled “Returns”number
The expiry timestamp in milliseconds
getUrlPreview()
Section titled “getUrlPreview()”getUrlPreview(
url,ts):Promise<IPreviewUrlResponse>
Defined in: src/client.ts:3940
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.
Parameters
Section titled “Parameters”string
The URL to get preview data for
number
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.
Returns
Section titled “Returns”Promise<IPreviewUrlResponse>
Promise which resolves: Object of OG metadata.
getUseE2eForGroupCall()
Section titled “getUseE2eForGroupCall()”getUseE2eForGroupCall():
boolean
Defined in: src/client.ts:1754
Returns true if to-device signalling for group calls will be encrypted with Olm. If false, it will be sent unencrypted.
Returns
Section titled “Returns”boolean
boolean Whether group call signalling will be encrypted
getUser()
Section titled “getUser()”getUser(
userId):User|null
Defined in: src/client.ts:2218
Retrieve a user.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
The user ID to retrieve.
Returns
Section titled “Returns”User | null
A user or null if there is no data store or the user does not exist.
getUserId()
Section titled “getUserId()”getUserId():
string|null
Defined in: src/client.ts:1663
Get the user-id of the logged-in user
Returns
Section titled “Returns”string | null
Digital World ID for the logged-in user, or null if not logged in
getUserIdLocalpart()
Section titled “getUserIdLocalpart()”getUserIdLocalpart():
string|null
Defined in: src/client.ts:1696
Get the local part of the current user ID e.g. “foo” in “@foo:bar”.
Returns
Section titled “Returns”string | null
The user ID localpart or null.
getUsers()
Section titled “getUsers()”getUsers():
User[]
Defined in: src/client.ts:2226
Retrieve all known users.
Returns
Section titled “Returns”User[]
A list of users, or an empty list if there is no data store.
getVersions()
Section titled “getVersions()”getVersions():
Promise<IServerVersions>
Defined in: src/client.ts:6220
Get the API versions supported by the server, along with any unstable APIs it supports
Returns
Section titled “Returns”Promise<IServerVersions>
The server /versions response
getVisibleRooms()
Section titled “getVisibleRooms()”getVisibleRooms(
msc3946ProcessDynamicPredecessor?):Room[]
Defined in: src/client.ts:2199
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.
Parameters
Section titled “Parameters”msc3946ProcessDynamicPredecessor?
Section titled “msc3946ProcessDynamicPredecessor?”boolean = false
if true, look for an m.room.predecessor state event and use it if found (MSC3946).
Returns
Section titled “Returns”Room[]
A list of rooms, or an empty list if there is no data store.
hasLazyLoadMembersEnabled()
Section titled “hasLazyLoadMembersEnabled()”hasLazyLoadMembersEnabled():
boolean
Defined in: src/client.ts:6328
Get if lazy loading members is being used.
Returns
Section titled “Returns”boolean
Whether or not members are lazy loaded by this client
identityHashedLookup()
Section titled “identityHashedLookup()”identityHashedLookup(
addressPairs,identityAccessToken):Promise<object[]>
Defined in: src/client.ts:8250
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.
Parameters
Section titled “Parameters”addressPairs
Section titled “addressPairs”[string, string][]
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"]
identityAccessToken
Section titled “identityAccessToken”string
The access token for the identity server.
Returns
Section titled “Returns”Promise<object[]>
A collection of address mappings to found Digital World IDs. Results where no user could be found will not be listed.
initRustCrypto()
Section titled “initRustCrypto()”initRustCrypto(
args?):Promise<void>
Defined in: src/client.ts:1988
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 DigitalWorldClient instances connected to
the same Indexed DB will cause data corruption and decryption failures. The application layer is responsible for
ensuring that only one DigitalWorldClient issue is instantiated at a time.
Parameters
Section titled “Parameters”cryptoDatabasePrefix?
Section titled “cryptoDatabasePrefix?”string
The database name to use for indexeddb, defaults to ‘digital-world-messaging-sdk’. Unused if useIndexedDB is ‘false’.
storageKey?
Section titled “storageKey?”Uint8Array<ArrayBufferLike>
A 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.
storagePassword?
Section titled “storagePassword?”string
An 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.
useIndexedDB?
Section titled “useIndexedDB?”boolean
True to use an indexeddb store, false to use an in-memory store. Defaults to ‘true’.
Returns
Section titled “Returns”Promise<void>
a Promise which will resolve when the crypto layer has been successfully initialised.
invite()
Section titled “invite()”invite(
roomId,userId,opts?):Promise<EmptyObject>
Defined in: src/client.ts:4104
Send an invite to the given user to join the given room.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The ID of the room to which the user should be invited.
userId
Section titled “userId”string
The ID of the user that should be invited.
string | InviteOpts
Optional reason object. For backwards compatibility, a string is also accepted, and will be interpreted as a reason.
Returns
Section titled “Returns”Promise<EmptyObject>
An empty object.
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
inviteByEmail()
Section titled “inviteByEmail()”inviteByEmail(
roomId,Promise<EmptyObject>
Defined in: src/client.ts:4129
Invite a user to a room based on their email address.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room to invite the user to.
string
The email address to invite.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: {} an empty object.
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
inviteByThreePid()
Section titled “inviteByThreePid()”inviteByThreePid(
roomId,medium,address):Promise<EmptyObject>
Defined in: src/client.ts:4143
Invite a user to a room based on a third-party identifier.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room to invite the user to.
medium
Section titled “medium”string
The medium to invite the user e.g. “email”.
address
Section titled “address”string
The address for the specified medium.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: {} an empty object.
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
isFallbackICEServerAllowed()
Section titled “isFallbackICEServerAllowed()”isFallbackICEServerAllowed():
boolean
Defined in: src/client.ts:6046
Get whether to allow a fallback ICE server should be used for negotiating a WebRTC connection if the hub doesn’t provide any servers. Defaults to false.
Returns
Section titled “Returns”boolean
isGuest()
Section titled “isGuest()”isGuest():
boolean
Defined in: src/client.ts:1882
Return whether the client is configured for a guest account.
Returns
Section titled “Returns”boolean
True if this is a guest access_token (or no token is supplied).
isInitialSyncComplete()
Section titled “isInitialSyncComplete()”isInitialSyncComplete():
boolean
Defined in: src/client.ts:1870
Whether the initial sync has completed.
Returns
Section titled “Returns”boolean
True if at least one sync has happened.
isKeyBackupKeyStored()
Section titled “isKeyBackupKeyStored()”isKeyBackupKeyStored():
Promise<Record<string,SecretStorageKeyDescriptionAesV1> |null>
Defined in: src/client.ts:2118
Check whether the key backup private key is stored in secret storage.
Returns
Section titled “Returns”Promise<Record<string, SecretStorageKeyDescriptionAesV1> | null>
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
isLoggedIn()
Section titled “isLoggedIn()”isLoggedIn():
boolean
Defined in: src/client.ts:6504
Returns
Section titled “Returns”boolean
true if there is a valid access_token for this client.
isRoomEncrypted()
Section titled “isRoomEncrypted()”isRoomEncrypted(
roomId):boolean
Defined in: src/client.ts:2099
Whether encryption is enabled for a room.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
the room id to query.
Returns
Section titled “Returns”boolean
whether encryption is enabled.
isSynapseAdministrator()
Section titled “isSynapseAdministrator()”isSynapseAdministrator():
Promise<boolean>
Defined in: src/client.ts:6057
Determines if the current user is an administrator of the Synapse hub. Returns false if untrue or the hub does not appear to be a Synapse hub. This function is implementation specific and may change as a result.
Returns
Section titled “Returns”Promise<boolean>
true if the user appears to be a Synapse administrator.
isUserIgnored()
Section titled “isUserIgnored()”isUserIgnored(
userId):boolean
Defined in: src/client.ts:2398
Gets whether or not a specific user is being ignored by this client.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
the user ID to check
Returns
Section titled “Returns”boolean
true if the user is ignored, false otherwise
isUsernameAvailable()
Section titled “isUsernameAvailable()”isUsernameAvailable(
username):Promise<boolean>
Defined in: src/client.ts:6523
Check whether a username is available prior to registration. An error response indicates an invalid/unavailable username.
Parameters
Section titled “Parameters”username
Section titled “username”string
The username to check the availability of.
Returns
Section titled “Returns”Promise<boolean>
Promise which resolves: to boolean of whether the username is available.
isVersionSupported()
Section titled “isVersionSupported()”isVersionSupported(
version):Promise<boolean>
Defined in: src/client.ts:6248
Check if a particular spec version is supported by the server.
Parameters
Section titled “Parameters”version
Section titled “version”string
The spec version (such as “r0.5.0”) to check for.
Returns
Section titled “Returns”Promise<boolean>
Whether it is supported
joinRoom()
Section titled “joinRoom()”joinRoom(
roomIdOrAlias,opts?):Promise<Room>
Defined in: src/client.ts:2409
Join a room. If you have already joined the room, this will no-op.
Parameters
Section titled “Parameters”roomIdOrAlias
Section titled “roomIdOrAlias”string
The room ID or room alias to join.
IJoinRoomOpts = {}
Options when joining the room.
Returns
Section titled “Returns”Promise<Room>
Promise which resolves: Room object.
kick()
Section titled “kick()”kick(
roomId,userId,reason?):Promise<EmptyObject>
Defined in: src/client.ts:4280
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
userId
Section titled “userId”string
reason?
Section titled “reason?”string
Optional.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: {} an empty object.
knockRoom()
Section titled “knockRoom()”knockRoom(
roomIdOrAlias,opts?):Promise<{room_id:string; }>
Defined in: src/client.ts:2472
Knock a room. If you have already knocked the room, this will no-op.
Parameters
Section titled “Parameters”roomIdOrAlias
Section titled “roomIdOrAlias”string
The room ID or room alias to knock.
KnockRoomOpts = {}
Options when knocking the room.
Returns
Section titled “Returns”Promise<{ room_id: string; }>
Promise which resolves: {room_id: {string}}
leave()
Section titled “leave()”leave(
roomId):Promise<EmptyObject>
Defined in: src/client.ts:4175
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: {} an empty object.
leaveRoomChain()
Section titled “leaveRoomChain()”leaveRoomChain(
roomId,includeFuture?):Promise<{[roomId:string]:Error|DigitalWorldError|null; }>
Defined in: src/client.ts:4190
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.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room ID to start leaving at
includeFuture?
Section titled “includeFuture?”boolean = true
If true, the whole chain (past and future) of upgraded rooms will be left.
Returns
Section titled “Returns”Promise<{[roomId: string]: Error | DigitalWorldError | null; }>
Promise which resolves when completed with an object keyed by room ID and value of the error encountered when leaving or null.
listenerCount()
Section titled “listenerCount()”listenerCount(
event):number
Defined in: src/models/typed-event-emitter.ts:115
Returns the number of listeners listening to the event named event.
Parameters
Section titled “Parameters”EventEmitterEvents | EmittedEvents
The name of the event being listened for
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”TypedEventEmitter.listenerCount
listeners()
Section titled “listeners()”listeners(
event):Function[]
Defined in: src/models/typed-event-emitter.ts:122
Returns a copy of the array of listeners for the event named event.
Parameters
Section titled “Parameters”EventEmitterEvents | EmittedEvents
Returns
Section titled “Returns”Function[]
Inherited from
Section titled “Inherited from”login()
Section titled “login()”login(
loginType,data):Promise<LoginResponse>
Defined in: src/client.ts:6668
Parameters
Section titled “Parameters”loginType
Section titled “loginType”string
Omit<LoginRequest, "type">
Returns
Section titled “Returns”Promise<LoginResponse>
Promise which resolves to a LoginResponse object
loginFlows()
Section titled “loginFlows()”loginFlows():
Promise<ILoginFlowsResponse>
Defined in: src/client.ts:6656
Returns
Section titled “Returns”Promise<ILoginFlowsResponse>
Promise which resolves to the available login flows
loginRequest()
Section titled “loginRequest()”loginRequest(
data):Promise<LoginResponse>
Defined in: src/client.ts:6756
Sends a POST /login request to the server.
If successful, this will create a new device and access token for the user.
Parameters
Section titled “Parameters”Credentials and other details for the login request.
Returns
Section titled “Returns”Promise<LoginResponse>
- DigitalWorldClient.loginFlows which makes a
GET /loginrequest. - https://spec.matrix.org/v1.13/client-server-api/#post_matrixclientv3login
loginWithPassword()
Section titled “loginWithPassword()”loginWithPassword(
user,password):Promise<LoginResponse>
Defined in: src/client.ts:6691
Parameters
Section titled “Parameters”string
password
Section titled “password”string
Returns
Section titled “Returns”Promise<LoginResponse>
Promise which resolves to a LoginResponse object
loginWithToken()
Section titled “loginWithToken()”loginWithToken(
token):Promise<LoginResponse>
Defined in: src/client.ts:6740
Parameters
Section titled “Parameters”string
Login token previously received from hub
Returns
Section titled “Returns”Promise<LoginResponse>
Promise which resolves to a LoginResponse object
logout()
Section titled “logout()”logout(
stopClient?):Promise<EmptyObject>
Defined in: src/client.ts:6769
Logs out the current session. Obviously, further calls that require authorisation should fail after this method is called. The state of the DigitalWorldClient object is not affected: it is up to the caller to either reset or destroy the DigitalWorldClient after this method succeeds.
Parameters
Section titled “Parameters”stopClient?
Section titled “stopClient?”boolean = false
whether to stop the client before calling /logout to prevent invalid token errors.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: On success, the empty object {}
lookupThreePid()
Section titled “lookupThreePid()”lookupThreePid(
medium,address,identityAccessToken):Promise<EmptyObject| {address:string;medium:string;mxid:string; }>
Defined in: src/client.ts:8337
Looks up the public Digital World ID mapping for a given 3rd party identifier from the identity server
Parameters
Section titled “Parameters”medium
Section titled “medium”string
The medium of the threepid, eg. ‘email’
address
Section titled “address”string
The textual address of the threepid
identityAccessToken
Section titled “identityAccessToken”string
The access_token field of the Identity
Server /account/register response (see registerWithIdentityServer).
Returns
Section titled “Returns”Promise<EmptyObject | { address: string; medium: string; mxid: string; }>
Promise which resolves: A threepid mapping object or the empty object if no mapping exists
makeTxnId()
Section titled “makeTxnId()”makeTxnId():
string
Defined in: src/client.ts:6513
Make up a new transaction id
Returns
Section titled “Returns”string
a new, unique, transaction id
members()
Section titled “members()”members(
roomId,includeMembership?,excludeMembership?,atEventId?):Promise<{[userId:string]:IStateEventWithRoomId[]; }>
Defined in: src/client.ts:6946
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
includeMembership?
Section titled “includeMembership?”string
the membership type to include in the response
excludeMembership?
Section titled “excludeMembership?”string
the membership type to exclude from the response
atEventId?
Section titled “atEventId?”string
the id of the event for which moment in the timeline the members should be returned for
Returns
Section titled “Returns”Promise<{[userId: string]: IStateEventWithRoomId[]; }>
Promise which resolves: dictionary of userid to profile information
mxcUrlToHttp()
Section titled “mxcUrlToHttp()”mxcUrlToHttp(
mxcUrl,width?,height?,resizeMethod?,allowDirectLinks?,allowRedirects?,useAuthentication?):string|null
Defined in: src/client.ts:4414
Turn an MXC URL into an HTTP one. This method is experimental and may change.
Parameters
Section titled “Parameters”mxcUrl
Section titled “mxcUrl”string
The MXC URL
width?
Section titled “width?”number
The desired width of the thumbnail.
height?
Section titled “height?”number
The desired height of the thumbnail.
resizeMethod?
Section titled “resizeMethod?”string
The thumbnail resize method to use, either “crop” or “scale”.
allowDirectLinks?
Section titled “allowDirectLinks?”boolean
If 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.
allowRedirects?
Section titled “allowRedirects?”boolean
If 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.
useAuthentication?
Section titled “useAuthentication?”boolean
If 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).
Returns
Section titled “Returns”string | null
the avatar URL or null.
off<
T>(event,listener):this
Defined in: src/models/typed-event-emitter.ts:129
Alias for removeListener
Type Parameters
Section titled “Type Parameters”T extends EventEmitterEvents | EmittedEvents
Parameters
Section titled “Parameters”T
listener
Section titled “listener”Listener<EmittedEvents, ClientEventHandlerMap, T>
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”on<
T>(event,listener):this
Defined in: src/models/typed-event-emitter.ts:150
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.
Type Parameters
Section titled “Type Parameters”T extends EventEmitterEvents | EmittedEvents
Parameters
Section titled “Parameters”T
The name of the event.
listener
Section titled “listener”Listener<EmittedEvents, ClientEventHandlerMap, T>
The callback function
Returns
Section titled “Returns”this
a reference to the EventEmitter, so that calls can be chained.
Inherited from
Section titled “Inherited from”once()
Section titled “once()”once<
T>(event,listener):this
Defined in: src/models/typed-event-emitter.ts:169
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.
Type Parameters
Section titled “Type Parameters”T extends EventEmitterEvents | EmittedEvents
Parameters
Section titled “Parameters”T
The name of the event.
listener
Section titled “listener”Listener<EmittedEvents, ClientEventHandlerMap, T>
The callback function
Returns
Section titled “Returns”this
a reference to the EventEmitter, so that calls can be chained.
Inherited from
Section titled “Inherited from”paginateEventTimeline()
Section titled “paginateEventTimeline()”paginateEventTimeline(
eventTimeline,opts):Promise<boolean>
Defined in: src/client.ts:5016
Take an EventTimeline, and back/forward-fill results.
Parameters
Section titled “Parameters”eventTimeline
Section titled “eventTimeline”timeline object to be updated
Returns
Section titled “Returns”Promise<boolean>
Promise which resolves to a boolean: false if there are no events and we reached either end of the timeline; else true.
patchExtendedProfile()
Section titled “patchExtendedProfile()”patchExtendedProfile(
profile):Promise<Record<string,unknown>>
Defined in: src/client.ts:7513
Update multiple properties on your extended profile. This will merge with any existing keys.
Parameters
Section titled “Parameters”profile
Section titled “profile”Record<string, unknown>
The profile object to merge with the existing profile.
Returns
Section titled “Returns”Promise<Record<string, unknown>>
The newly merged profile.
https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md
Throws
Section titled “Throws”An error if the server does not support MSC4133 OR the server disallows editing the user profile.
peekInRoom()
Section titled “peekInRoom()”peekInRoom(
roomId,limit?):Promise<Room>
Defined in: src/client.ts:5285
Peek into a room and receive updates about the room. This only works if the history visibility for the room is world_readable.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room to attempt to peek into.
limit?
Section titled “limit?”number = 20
The number of timeline events to initially retrieve.
Returns
Section titled “Returns”Promise<Room>
Promise which resolves: Room object
prependListener()
Section titled “prependListener()”prependListener<
T>(event,listener):this
Defined in: src/models/typed-event-emitter.ts:186
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.
Type Parameters
Section titled “Type Parameters”T extends EventEmitterEvents | EmittedEvents
Parameters
Section titled “Parameters”T
The name of the event.
listener
Section titled “listener”Listener<EmittedEvents, ClientEventHandlerMap, T>
The callback function
Returns
Section titled “Returns”this
a reference to the EventEmitter, so that calls can be chained.
Inherited from
Section titled “Inherited from”TypedEventEmitter.prependListener
prependOnceListener()
Section titled “prependOnceListener()”prependOnceListener<
T>(event,listener):this
Defined in: src/models/typed-event-emitter.ts:202
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.
Type Parameters
Section titled “Type Parameters”T extends EventEmitterEvents | EmittedEvents
Parameters
Section titled “Parameters”T
The name of the event.
listener
Section titled “listener”Listener<EmittedEvents, ClientEventHandlerMap, T>
The callback function
Returns
Section titled “Returns”this
a reference to the EventEmitter, so that calls can be chained.
Inherited from
Section titled “Inherited from”TypedEventEmitter.prependOnceListener
processAggregatedTimelineEvents()
Section titled “processAggregatedTimelineEvents()”processAggregatedTimelineEvents(
room?,events?):void
Defined in: src/client.ts:8825
Calls aggregation functions for event types that are aggregated Polls and location beacons
Parameters
Section titled “Parameters”room the events belong to
events?
Section titled “events?”timeline events to be processed
Returns
Section titled “Returns”void
processBeaconEvents()
Section titled “processBeaconEvents()”processBeaconEvents(
room?,events?):void
Defined in: src/client.ts:8814
Parameters
Section titled “Parameters”events?
Section titled “events?”Returns
Section titled “Returns”void
processThreadEvents()
Section titled “processThreadEvents()”processThreadEvents(
room,threadedEvents,toStartOfTimeline):void
Defined in: src/client.ts:8799
Processes a list of threaded events and adds them to their respective timelines
Parameters
Section titled “Parameters”the room the adds the threaded events
threadedEvents
Section titled “threadedEvents”an array of the threaded events
toStartOfTimeline
Section titled “toStartOfTimeline”boolean
the direction in which we want to add the events
Returns
Section titled “Returns”void
processThreadRoots()
Section titled “processThreadRoots()”processThreadRoots(
room,threadedEvents,toStartOfTimeline):void
Defined in: src/client.ts:8809
Processes a list of thread roots and creates a thread model
Parameters
Section titled “Parameters”the room to create the threads in
threadedEvents
Section titled “threadedEvents”an array of thread roots
toStartOfTimeline
Section titled “toStartOfTimeline”boolean
the direction
Returns
Section titled “Returns”void
publicRooms()
Section titled “publicRooms()”publicRooms(
params?):Promise<IPublicRoomsResponse>
Defined in: src/client.ts:7178
Get the public rooms list from the server. Supports pagination
Parameters
Section titled “Parameters”params?
Section titled “params?”Options for this request
Returns
Section titled “Returns”Promise<IPublicRoomsResponse>
Promise which resolves: IPublicRoomsResponse
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
queueToDevice()
Section titled “queueToDevice()”queueToDevice(
batch):Promise<void>
Defined in: src/client.ts:8494
Sends events directly to specific devices using the protocol’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.
Parameters
Section titled “Parameters”ToDeviceBatch
The to-device messages to send
Returns
Section titled “Returns”Promise<void>
rawListeners()
Section titled “rawListeners()”rawListeners(
event):Function[]
Defined in: src/models/typed-event-emitter.ts:243
Returns a copy of the array of listeners for the event named eventName,
including any wrappers (such as those created by .once()).
Parameters
Section titled “Parameters”EventEmitterEvents | EmittedEvents
Returns
Section titled “Returns”Function[]
Inherited from
Section titled “Inherited from”TypedEventEmitter.rawListeners
redactEvent()
Section titled “redactEvent()”Call Signature
Section titled “Call Signature”redactEvent(
roomId,eventId,txnId?,opts?):Promise<ISendEventResponse>
Defined in: src/client.ts:3148
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
eventId
Section titled “eventId”string
txnId?
Section titled “txnId?”string
transaction id. One will be made up if not supplied.
Redact options
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: TODO
Throws
Section titled “Throws”Error if called with with_rel_types (MSC3912) but the server does not support it.
Callers should check whether the server supports MSC3912 via DigitalWorldClient.canSupport.
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
Call Signature
Section titled “Call Signature”redactEvent(
roomId,threadId,eventId,txnId?,opts?):Promise<ISendEventResponse>
Defined in: src/client.ts:3154
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
threadId
Section titled “threadId”string | null
eventId
Section titled “eventId”string
txnId?
Section titled “txnId?”string
transaction id. One will be made up if not supplied.
Redact options
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: TODO
Throws
Section titled “Throws”Error if called with with_rel_types (MSC3912) but the server does not support it.
Callers should check whether the server supports MSC3912 via DigitalWorldClient.canSupport.
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
refreshToken()
Section titled “refreshToken()”refreshToken(
refreshToken):Promise<IRefreshTokenResponse>
Defined in: src/client.ts:6628
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.
Parameters
Section titled “Parameters”refreshToken
Section titled “refreshToken”string
The refresh token.
Returns
Section titled “Returns”Promise<IRefreshTokenResponse>
Promise which resolves to the new token.
register()
Section titled “register()”register(
username,password,sessionId,auth,bindThreepids?,guestAccessToken?,inhibitLogin?):Promise<RegisterResponse>
Defined in: src/client.ts:6544
Parameters
Section titled “Parameters”username
Section titled “username”string
password
Section titled “password”string
sessionId
Section titled “sessionId”string | null
session?
Section titled “session?”string
string
bindThreepids?
Section titled “bindThreepids?”Set key ‘email’ to true to bind any email threepid uses during registration in the identity server. Set ‘msisdn’ to true to bind msisdn.
email?
Section titled “email?”boolean
msisdn?
Section titled “msisdn?”boolean
guestAccessToken?
Section titled “guestAccessToken?”string
inhibitLogin?
Section titled “inhibitLogin?”boolean
Returns
Section titled “Returns”Promise<RegisterResponse>
Promise which resolves to a RegisterResponse object
registerGuest()
Section titled “registerGuest()”registerGuest(
body?):Promise<RegisterResponse>
Defined in: src/client.ts:6598
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(HUB_INSTANCE);const { user_id, device_id, access_token } = tmpClient.registerGuest();const client = createClient({ baseUrl: HUB_INSTANCE, accessToken: access_token, userId: user_id, deviceId: device_id,})client.setGuest(true);Parameters
Section titled “Parameters”JSON HTTP body to provide.
Returns
Section titled “Returns”Promise<RegisterResponse>
Promise which resolves: JSON object that contains:
{ user_id, device_id, access_token, home_server }
registerRequest()
Section titled “registerRequest()”registerRequest(
data,kind?):Promise<RegisterResponse>
Defined in: src/client.ts:6608
Parameters
Section titled “Parameters”parameters for registration request
string
type of user to register. may be “guest”
Returns
Section titled “Returns”Promise<RegisterResponse>
Promise which resolves: to the /register response
registerWithIdentityServer()
Section titled “registerWithIdentityServer()”registerWithIdentityServer(
hsOpenIdToken):Promise<{access_token:string;token:string; }>
Defined in: src/client.ts:8028
Register with an identity server using the OpenID token from the user’s Hub, which can be retrieved via DigitalWorldClient#getOpenIdToken.
Note that the /account/register endpoint (as well as IS authentication in
general) was added as part of the v2 API version.
Parameters
Section titled “Parameters”hsOpenIdToken
Section titled “hsOpenIdToken”Returns
Section titled “Returns”Promise<{ access_token: string; token: string; }>
Promise which resolves: with object containing an Identity Server access token.
relations()
Section titled “relations()”relations(
roomId,eventId,relationType,eventType?,opts?):Promise<{events:DigitalWorldEvent[];nextBatch?:string|null;originalEvent?:DigitalWorldEvent|null;prevBatch?:string|null; }>
Defined in: src/client.ts:6364
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.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
the room of the event
eventId
Section titled “eventId”string
the id of the event
relationType
Section titled “relationType”string | null
the rel_type of the relations requested
eventType?
Section titled “eventType?”string | null
the event type of the relations requested
IRelationsRequestOpts = ...
options with optional values for the request.
Returns
Section titled “Returns”Promise<{ events: DigitalWorldEvent[]; nextBatch?: string | null; originalEvent?: DigitalWorldEvent | null; prevBatch?: string | null; }>
an object with events as DigitalWorldEvent[] and optionally nextBatch if more relations are available.
removeAllListeners()
Section titled “removeAllListeners()”removeAllListeners(
event?):this
Defined in: src/models/typed-event-emitter.ts:219
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).
Parameters
Section titled “Parameters”event?
Section titled “event?”EventEmitterEvents | EmittedEvents
The name of the event. If undefined, all listeners everywhere are removed.
Returns
Section titled “Returns”this
a reference to the EventEmitter, so that calls can be chained.
Inherited from
Section titled “Inherited from”TypedEventEmitter.removeAllListeners
removeListener()
Section titled “removeListener()”removeListener<
T>(event,listener):this
Defined in: src/models/typed-event-emitter.ts:232
Removes the specified listener from the listener array for the event named event.
Type Parameters
Section titled “Type Parameters”T extends EventEmitterEvents | EmittedEvents
Parameters
Section titled “Parameters”T
listener
Section titled “listener”Listener<EmittedEvents, ClientEventHandlerMap, T>
Returns
Section titled “Returns”this
a reference to the EventEmitter, so that calls can be chained.
Inherited from
Section titled “Inherited from”TypedEventEmitter.removeListener
removePusher()
Section titled “removePusher()”removePusher(
pushKey,appId):Promise<EmptyObject>
Defined in: src/client.ts:7776
Removes an existing pusher
Parameters
Section titled “Parameters”pushKey
Section titled “pushKey”string
pushkey of pusher to remove
string
app_id of pusher to remove
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: Empty json object on success
reportEvent()
Section titled “reportEvent()”reportEvent(
roomId,eventId,score,reason):Promise<EmptyObject>
Defined in: src/client.ts:8583
Reports an event as inappropriate to the server, which may then notify the appropriate people.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room in which the event being reported is located.
eventId
Section titled “eventId”string
The event to report.
number
The score to rate this content as where -100 is most offensive and 0 is inoffensive.
reason
Section titled “reason”string
The reason the content is being reported. May be blank.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves to an empty object if successful
reportRoom()
Section titled “reportRoom()”reportRoom(
roomId,reason):Promise<EmptyObject>
Defined in: src/client.ts:8601
Reports a room as inappropriate to the server, which may then notify the appropriate people.
This API was introduced in protocol v1.13.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room being reported.
reason
Section titled “reason”string
The reason the room is being reported. May be blank.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves to an empty object if successful
requestAdd3pidEmailToken()
Section titled “requestAdd3pidEmailToken()”requestAdd3pidEmailToken(
clientSecret,sendAttempt,nextLink?):Promise<IRequestTokenResponse>
Defined in: src/client.ts:5408
Requests an email verification token for the purposes of adding a third party identifier to an account. This API requests a token from the hub. 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 hub).
Parameters
Section titled “Parameters”string
As requestEmailToken
clientSecret
Section titled “clientSecret”string
As requestEmailToken
sendAttempt
Section titled “sendAttempt”number
As requestEmailToken
nextLink?
Section titled “nextLink?”string
As requestEmailToken
Returns
Section titled “Returns”Promise<IRequestTokenResponse>
Promise which resolves: As requestEmailToken
requestAdd3pidMsisdnToken()
Section titled “requestAdd3pidMsisdnToken()”requestAdd3pidMsisdnToken(
phoneCountry,phoneNumber,clientSecret,sendAttempt,nextLink?):Promise<IRequestMsisdnTokenResponse>
Defined in: src/client.ts:5436
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.
Parameters
Section titled “Parameters”phoneCountry
Section titled “phoneCountry”string
As requestRegisterMsisdnToken
phoneNumber
Section titled “phoneNumber”string
As requestRegisterMsisdnToken
clientSecret
Section titled “clientSecret”string
As requestEmailToken
sendAttempt
Section titled “sendAttempt”number
As requestEmailToken
nextLink?
Section titled “nextLink?”string
As requestEmailToken
Returns
Section titled “Returns”Promise<IRequestMsisdnTokenResponse>
Promise which resolves: As requestEmailToken
requestEmailToken()
Section titled “requestEmailToken()”requestEmailToken(
clientSecret,sendAttempt,nextLink?,identityAccessToken?):Promise<IRequestTokenResponse>
Defined in: src/client.ts:8063
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.
Parameters
Section titled “Parameters”string
The email address to request a token for
clientSecret
Section titled “clientSecret”string
A secret binary string generated by the client. It is recommended this be around 16 ASCII characters.
sendAttempt
Section titled “sendAttempt”number
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.
nextLink?
Section titled “nextLink?”string
Optional If specified, the client will be redirected to this link after validation.
identityAccessToken?
Section titled “identityAccessToken?”string
The access_token field of the identity
server /account/register response (see registerWithIdentityServer).
Returns
Section titled “Returns”Promise<IRequestTokenResponse>
Promise which resolves: TODO
Throws
Section titled “Throws”Error if no identity server is set
requestLoginToken()
Section titled “requestLoginToken()”requestLoginToken(
auth?):Promise<LoginTokenPostResponse>
Defined in: src/client.ts:6815
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.
Parameters
Section titled “Parameters”Optional. Auth data to supply for User-Interactive auth.
Returns
Section titled “Returns”Promise<LoginTokenPostResponse>
Promise which resolves: On success, the token response or UIA auth data.
requestMsisdnToken()
Section titled “requestMsisdnToken()”requestMsisdnToken(
phoneCountry,phoneNumber,clientSecret,sendAttempt,nextLink?,identityAccessToken?):Promise<IRequestMsisdnTokenResponse>
Defined in: src/client.ts:8114
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.
Parameters
Section titled “Parameters”phoneCountry
Section titled “phoneCountry”string
The ISO 3166-1 alpha-2 code for the country in which phoneNumber should be parsed relative to.
phoneNumber
Section titled “phoneNumber”string
The phone number, in national or international format
clientSecret
Section titled “clientSecret”string
A secret binary string generated by the client. It is recommended this be around 16 ASCII characters.
sendAttempt
Section titled “sendAttempt”number
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.
nextLink?
Section titled “nextLink?”string
Optional If specified, the client will be redirected to this link after validation.
identityAccessToken?
Section titled “identityAccessToken?”string
The access_token field of the Identity
Server /account/register response (see registerWithIdentityServer).
Returns
Section titled “Returns”Promise<IRequestMsisdnTokenResponse>
Promise which resolves to an object with a sid string
Throws
Section titled “Throws”Error if no identity server is set
requestPasswordEmailToken()
Section titled “requestPasswordEmailToken()”requestPasswordEmailToken(
clientSecret,sendAttempt,nextLink?):Promise<IRequestTokenResponse>
Defined in: src/client.ts:5470
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 hub).
requestEmailToken calls the equivalent API directly on the identity server, therefore bypassing the password reset specific logic.
Parameters
Section titled “Parameters”string
As requestEmailToken
clientSecret
Section titled “clientSecret”string
As requestEmailToken
sendAttempt
Section titled “sendAttempt”number
As requestEmailToken
nextLink?
Section titled “nextLink?”string
As requestEmailToken
Returns
Section titled “Returns”Promise<IRequestTokenResponse>
Promise which resolves: As requestEmailToken
requestPasswordMsisdnToken()
Section titled “requestPasswordMsisdnToken()”requestPasswordMsisdnToken(
phoneCountry,phoneNumber,clientSecret,sendAttempt,nextLink):Promise<IRequestMsisdnTokenResponse>
Defined in: src/client.ts:5497
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.
Parameters
Section titled “Parameters”phoneCountry
Section titled “phoneCountry”string
As requestRegisterMsisdnToken
phoneNumber
Section titled “phoneNumber”string
As requestRegisterMsisdnToken
clientSecret
Section titled “clientSecret”string
As requestEmailToken
sendAttempt
Section titled “sendAttempt”number
As requestEmailToken
nextLink
Section titled “nextLink”string
As requestEmailToken
Returns
Section titled “Returns”Promise<IRequestMsisdnTokenResponse>
Promise which resolves: As requestEmailToken
requestRegisterEmailToken()
Section titled “requestRegisterEmailToken()”requestRegisterEmailToken(
clientSecret,sendAttempt,nextLink?):Promise<IRequestTokenResponse>
Defined in: src/client.ts:5347
Requests an email verification token for the purposes of registration. This API requests a token from the hub. 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
Parameters
Section titled “Parameters”string
As requestEmailToken
clientSecret
Section titled “clientSecret”string
As requestEmailToken
sendAttempt
Section titled “sendAttempt”number
As requestEmailToken
nextLink?
Section titled “nextLink?”string
As requestEmailToken
Returns
Section titled “Returns”Promise<IRequestTokenResponse>
Promise which resolves: As requestEmailToken
requestRegisterMsisdnToken()
Section titled “requestRegisterMsisdnToken()”requestRegisterMsisdnToken(
phoneCountry,phoneNumber,clientSecret,sendAttempt,nextLink?):Promise<IRequestMsisdnTokenResponse>
Defined in: src/client.ts:5375
Requests a text message verification token for the purposes of registration. This API requests a token from the hub. The doesServerRequireIdServerParam() method can be used to determine if the server requires the id_server parameter to be provided.
Parameters
Section titled “Parameters”phoneCountry
Section titled “phoneCountry”string
The ISO 3166-1 alpha-2 code for the country in which phoneNumber should be parsed relative to.
phoneNumber
Section titled “phoneNumber”string
The phone number, in national or international format
clientSecret
Section titled “clientSecret”string
As requestEmailToken
sendAttempt
Section titled “sendAttempt”number
As requestEmailToken
nextLink?
Section titled “nextLink?”string
As requestEmailToken
Returns
Section titled “Returns”Promise<IRequestMsisdnTokenResponse>
Promise which resolves: As requestEmailToken
resendEvent()
Section titled “resendEvent()”resendEvent(
event,room):Promise<ISendEventResponse>
Defined in: src/client.ts:2505
Resend an event. Will also retry any to-device messages waiting to be sent.
Parameters
Section titled “Parameters”The event to resend.
Optional. The room the event is in. Will update the timeline entry if provided.
Returns
Section titled “Returns”Promise<ISendEventResponse>
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
resetNotifTimelineSet()
Section titled “resetNotifTimelineSet()”resetNotifTimelineSet():
void
Defined in: src/client.ts:5248
Reset the notifTimelineSet entirely, paginating in some historical notifs as a starting point for subsequent pagination.
Returns
Section titled “Returns”void
retryImmediately()
Section titled “retryImmediately()”retryImmediately():
boolean
Defined in: src/client.ts:1913
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).
Returns
Section titled “Returns”boolean
True if this resulted in a request being retried.
roomInitialSync()
Section titled “roomInitialSync()”roomInitialSync(
roomId,limit):Promise<IRoomInitialSyncResponse>
Defined in: src/client.ts:7102
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
number
Returns
Section titled “Returns”Promise<IRoomInitialSyncResponse>
Promise which resolves: TODO
roomState()
Section titled “roomState()”roomState(
roomId):Promise<IStateEventWithRoomId[]>
Defined in: src/client.ts:6920
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
Returns
Section titled “Returns”Promise<IStateEventWithRoomId[]>
Promise which resolves: TODO
scrollback()
Section titled “scrollback()”scrollback(
room,limit?):Promise<Room>
Defined in: src/client.ts:4492
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).
Parameters
Section titled “Parameters”The room to get older messages in.
limit?
Section titled “limit?”number = 30
Optional. The maximum number of previous events to pull in. Default: 30.
Returns
Section titled “Returns”Promise<Room>
Promise which resolves: Room. If you are at the beginning
of the timeline, Room.oldState.paginationToken will be
null.
search()
Section titled “search()”search(
params,abortSignal?):Promise<ISearchResponse>
Defined in: src/client.ts:7898
Perform a server-side search.
Parameters
Section titled “Parameters”params
Section titled “params”the JSON object to pass to the request body.
next_batch?
Section titled “next_batch?”string
the batch token to pass in the query string
abortSignal?
Section titled “abortSignal?”AbortSignal
optional signal used to cancel the http request.
Returns
Section titled “Returns”Promise<ISearchResponse>
Promise which resolves to the search response object.
searchMessageText()
Section titled “searchMessageText()”searchMessageText(
opts):Promise<ISearchResponse>
Defined in: src/client.ts:5629
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<ISearchResponse>
searchRoomEvents()
Section titled “searchRoomEvents()”searchRoomEvents(
opts):Promise<ISearchResults>
Defined in: src/client.ts:5662
Perform a server-side search for room events.
The returned promise resolves to an object containing the fields:
- count: estimate of the number of results
- next_batch: token for back-pagination; if undefined, there are no more results
- highlights: a list of words to highlight from the stemming algorithm
- results: a list of results
Each entry in the results list is a SearchResult.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<ISearchResults>
Promise which resolves: result object
searchUserDirectory()
Section titled “searchUserDirectory()”searchUserDirectory(
options):Promise<IUserDirectoryResponse>
Defined in: src/client.ts:7290
Query the user directory with a term matching user IDs, display names and domains.
Parameters
Section titled “Parameters”options
Section titled “options”limit?
Section titled “limit?”number
the maximum number of results to return. The server will apply a limit if unspecified.
string
the term with which to search.
Returns
Section titled “Returns”Promise<IUserDirectoryResponse>
Promise which resolves: an array of results.
sendEmoteMessage()
Section titled “sendEmoteMessage()”Call Signature
Section titled “Call Signature”sendEmoteMessage(
roomId,body,txnId?):Promise<ISendEventResponse>
Defined in: src/client.ts:3296
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
string
txnId?
Section titled “txnId?”string
Optional.
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
Call Signature
Section titled “Call Signature”sendEmoteMessage(
roomId,threadId,body,txnId?):Promise<ISendEventResponse>
Defined in: src/client.ts:3297
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
threadId
Section titled “threadId”string | null
string
txnId?
Section titled “txnId?”string
Optional.
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
sendEvent()
Section titled “sendEvent()”Call Signature
Section titled “Call Signature”sendEvent<
K>(roomId,eventType,content,txnId?):Promise<ISendEventResponse>
Defined in: src/client.ts:2716
Send a timeline event.
Type Parameters
Section titled “Type Parameters”K extends keyof TimelineEvents
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room to send to.
eventType
Section titled “eventType”K
The event type.
content
Section titled “content”The event content.
txnId?
Section titled “txnId?”string
An optional ID to deduplicate requests in case of repeated attempts.
Returns
Section titled “Returns”Promise<ISendEventResponse>
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
Call Signature
Section titled “Call Signature”sendEvent<
K>(roomId,threadId,eventType,content,txnId?):Promise<ISendEventResponse>
Defined in: src/client.ts:2722
Send a timeline event.
Type Parameters
Section titled “Type Parameters”K extends keyof TimelineEvents
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room to send to.
threadId
Section titled “threadId”string | null
eventType
Section titled “eventType”K
The event type.
content
Section titled “content”The event content.
txnId?
Section titled “txnId?”string
An optional ID to deduplicate requests in case of repeated attempts.
Returns
Section titled “Returns”Promise<ISendEventResponse>
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
sendHtmlEmote()
Section titled “sendHtmlEmote()”Call Signature
Section titled “Call Signature”sendHtmlEmote(
roomId,body,htmlBody):Promise<ISendEventResponse>
Defined in: src/client.ts:3457
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
string
htmlBody
Section titled “htmlBody”string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
Call Signature
Section titled “Call Signature”sendHtmlEmote(
roomId,threadId,body,htmlBody):Promise<ISendEventResponse>
Defined in: src/client.ts:3458
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
threadId
Section titled “threadId”string | null
string
htmlBody
Section titled “htmlBody”string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
sendHtmlMessage()
Section titled “sendHtmlMessage()”Call Signature
Section titled “Call Signature”sendHtmlMessage(
roomId,body,htmlBody):Promise<ISendEventResponse>
Defined in: src/client.ts:3401
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
string
htmlBody
Section titled “htmlBody”string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
Call Signature
Section titled “Call Signature”sendHtmlMessage(
roomId,threadId,body,htmlBody):Promise<ISendEventResponse>
Defined in: src/client.ts:3402
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
threadId
Section titled “threadId”string | null
string
htmlBody
Section titled “htmlBody”string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
sendHtmlNotice()
Section titled “sendHtmlNotice()”Call Signature
Section titled “Call Signature”sendHtmlNotice(
roomId,body,htmlBody):Promise<ISendEventResponse>
Defined in: src/client.ts:3429
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
string
htmlBody
Section titled “htmlBody”string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
Call Signature
Section titled “Call Signature”sendHtmlNotice(
roomId,threadId,body,htmlBody):Promise<ISendEventResponse>
Defined in: src/client.ts:3430
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
threadId
Section titled “threadId”string | null
string
htmlBody
Section titled “htmlBody”string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
sendImageMessage()
Section titled “sendImageMessage()”Call Signature
Section titled “Call Signature”sendImageMessage(
roomId,url,info?,text?):Promise<ISendEventResponse>
Defined in: src/client.ts:3324
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
string
string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
Call Signature
Section titled “Call Signature”sendImageMessage(
roomId,threadId,url,info?,text?):Promise<ISendEventResponse>
Defined in: src/client.ts:3325
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
threadId
Section titled “threadId”string | null
string
string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
sendMessage()
Section titled “sendMessage()”Call Signature
Section titled “Call Signature”sendMessage(
roomId,content,txnId?):Promise<ISendEventResponse>
Defined in: src/client.ts:3210
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
content
Section titled “content”txnId?
Section titled “txnId?”string
Optional.
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to an ISendEventResponse object
Call Signature
Section titled “Call Signature”sendMessage(
roomId,threadId,content,txnId?):Promise<ISendEventResponse>
Defined in: src/client.ts:3211
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
threadId
Section titled “threadId”string | null
content
Section titled “content”txnId?
Section titled “txnId?”string
Optional.
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to an ISendEventResponse object
sendNotice()
Section titled “sendNotice()”Call Signature
Section titled “Call Signature”sendNotice(
roomId,body,txnId?):Promise<ISendEventResponse>
Defined in: src/client.ts:3267
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
string
txnId?
Section titled “txnId?”string
Optional.
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Call Signature
Section titled “Call Signature”sendNotice(
roomId,threadId,body,txnId?):Promise<ISendEventResponse>
Defined in: src/client.ts:3268
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
threadId
Section titled “threadId”string | null
string
txnId?
Section titled “txnId?”string
Optional.
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
sendReadReceipt()
Section titled “sendReadReceipt()”sendReadReceipt(
event,receiptType?,unthreaded?):Promise<EmptyObject|undefined>
Defined in: src/client.ts:3849
Send a read receipt.
Parameters
Section titled “Parameters”DigitalWorldEvent | null
The event that has been read.
receiptType?
Section titled “receiptType?”ReceiptType = ReceiptType.Read
other than ReceiptType.Read are experimental! Optional.
unthreaded?
Section titled “unthreaded?”boolean = false
Returns
Section titled “Returns”Promise<EmptyObject | undefined>
Promise which resolves: to an empty object {}
sendReceipt()
Section titled “sendReceipt()”sendReceipt(
event,receiptType,body?,unthreaded?):Promise<EmptyObject>
Defined in: src/client.ts:3812
Send a receipt.
Parameters
Section titled “Parameters”The event being acknowledged
receiptType
Section titled “receiptType”The kind of receipt e.g. “m.read”. Other than ReceiptType.Read are experimental!
Record<string, any>
Additional content to send alongside the receipt.
unthreaded?
Section titled “unthreaded?”boolean = false
An unthreaded receipt will clear room+thread notifications
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object {}
sendRtcDecline()
Section titled “sendRtcDecline()”sendRtcDecline(
roomId,notificationEventId):Promise<ISendEventResponse>
Defined in: src/client.ts:3920
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
notificationEventId
Section titled “notificationEventId”string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
sendStateEvent()
Section titled “sendStateEvent()”sendStateEvent<
K>(roomId,eventType,content,stateKey?,opts?):Promise<ISendEventResponse>
Defined in: src/client.ts:7019
Send a state event into a room
Type Parameters
Section titled “Type Parameters”K extends keyof StateEvents
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
ID of the room to send the event into
eventType
Section titled “eventType”K
type of the state event to send
content
Section titled “content”StateEvents[K]
content of the event to send
stateKey?
Section titled “stateKey?”string = ""
the stateKey to send into the room
IRequestOpts = {}
Options for the request function.
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: TODO
sendStickerMessage()
Section titled “sendStickerMessage()”Call Signature
Section titled “Call Signature”sendStickerMessage(
roomId,url,info?,text?):Promise<ISendEventResponse>
Defined in: src/client.ts:3360
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
string
string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
Call Signature
Section titled “Call Signature”sendStickerMessage(
roomId,threadId,url,info?,text?):Promise<ISendEventResponse>
Defined in: src/client.ts:3366
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
threadId
Section titled “threadId”string | null
string
string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to a ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
sendTextMessage()
Section titled “sendTextMessage()”Call Signature
Section titled “Call Signature”sendTextMessage(
roomId,body,txnId?):Promise<ISendEventResponse>
Defined in: src/client.ts:3240
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
string
txnId?
Section titled “txnId?”string
Optional.
Returns
Section titled “Returns”Promise<ISendEventResponse>
Call Signature
Section titled “Call Signature”sendTextMessage(
roomId,threadId,body,txnId?):Promise<ISendEventResponse>
Defined in: src/client.ts:3241
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
threadId
Section titled “threadId”string | null
string
txnId?
Section titled “txnId?”string
Optional.
Returns
Section titled “Returns”Promise<ISendEventResponse>
sendToDevice()
Section titled “sendToDevice()”sendToDevice(
eventType,contentMap,txnId?):Promise<EmptyObject>
Defined in: src/client.ts:8443
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.
Parameters
Section titled “Parameters”eventType
Section titled “eventType”string
type of event to send content to send. Map from user_id to device_id to content object.
contentMap
Section titled “contentMap”txnId?
Section titled “txnId?”string
transaction id. One will be made up if not supplied.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object {}
sendTyping()
Section titled “sendTyping()”sendTyping(
roomId,isTyping,timeoutMs):Promise<EmptyObject>
Defined in: src/client.ts:3980
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
isTyping
Section titled “isTyping”boolean
timeoutMs
Section titled “timeoutMs”number
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object {}
setAccessToken()
Section titled “setAccessToken()”setAccessToken(
token):void
Defined in: src/client.ts:6495
Set the access token associated with this account.
Parameters
Section titled “Parameters”string
The new access token.
Returns
Section titled “Returns”void
setAccountData()
Section titled “setAccountData()”setAccountData<
K>(eventType,content):Promise<EmptyObject>
Defined in: src/client.ts:2244
Set account data event for the current user, and wait for the result to be echoed over /sync.
Waiting for the remote echo ensures that a subsequent call to getAccountData will return the updated value.
If called before the client is started with startClient, logs a warning and falls back to setAccountDataRaw.
Retries the request up to 5 times in the case of an ConnectionError.
Type Parameters
Section titled “Type Parameters”K extends keyof AccountDataEvents
Parameters
Section titled “Parameters”eventType
Section titled “eventType”K
The event type
content
Section titled “content”Record<string, never> | AccountDataEvents[K]
the contents object for the event
Returns
Section titled “Returns”Promise<EmptyObject>
setAccountDataRaw()
Section titled “setAccountDataRaw()”setAccountDataRaw<
K>(eventType,content):Promise<EmptyObject>
Defined in: src/client.ts:2296
Set account data event for the current user, without waiting for the remote echo.
Type Parameters
Section titled “Type Parameters”K extends keyof AccountDataEvents
Parameters
Section titled “Parameters”eventType
Section titled “eventType”K
The event type
content
Section titled “content”Record<string, never> | AccountDataEvents[K]
the contents object for the event
Returns
Section titled “Returns”Promise<EmptyObject>
setAvatarUrl()
Section titled “setAvatarUrl()”setAvatarUrl(
url):Promise<EmptyObject>
Defined in: src/client.ts:4382
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: {} an empty object.
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
setCanResetTimelineCallback()
Section titled “setCanResetTimelineCallback()”setCanResetTimelineCallback(
cb):void
Defined in: src/client.ts:6341
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.
Parameters
Section titled “Parameters”The callback which will be invoked.
Returns
Section titled “Returns”void
setDeviceDetails()
Section titled “setDeviceDetails()”setDeviceDetails(
deviceId,body):Promise<EmptyObject>
Defined in: src/client.ts:7685
Update the given device
Parameters
Section titled “Parameters”deviceId
Section titled “deviceId”string
device to update
body of request
display_name
Section titled “display_name”string
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object {}
setDisplayName()
Section titled “setDisplayName()”setDisplayName(
name):Promise<EmptyObject>
Defined in: src/client.ts:4365
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: {} an empty object.
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
setExtendedProfile()
Section titled “setExtendedProfile()”setExtendedProfile(
profile):Promise<void>
Defined in: src/client.ts:7539
Set multiple properties on your extended profile. This will completely replace the existing profile, removing any unspecified keys.
Parameters
Section titled “Parameters”profile
Section titled “profile”Record<string, unknown>
The profile object to set.
Returns
Section titled “Returns”Promise<void>
https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md
Throws
Section titled “Throws”An error if the server does not support MSC4133 OR the server disallows editing the user profile.
setExtendedProfileProperty()
Section titled “setExtendedProfileProperty()”setExtendedProfileProperty(
key,value):Promise<void>
Defined in: src/client.ts:7461
Set a property on your extended profile.
Parameters
Section titled “Parameters”string
The key of the property to set.
unknown
The value to set on the property.
Returns
Section titled “Returns”Promise<void>
https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md
Throws
Section titled “Throws”An error if the server does not support MSC4133 OR the server disallows editing the user profile.
setFallbackICEServerAllowed()
Section titled “setFallbackICEServerAllowed()”setFallbackICEServerAllowed(
allow):void
Defined in: src/client.ts:6035
Set whether to allow a fallback ICE server should be used for negotiating a WebRTC connection if the hub doesn’t provide any servers. Defaults to false.
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”void
setForceTURN()
Section titled “setForceTURN()”setForceTURN(
force):void
Defined in: src/client.ts:1737
Set whether VoIP calls are forced to use only TURN candidates. This is the same as the forceTURN option when creating the client.
Parameters
Section titled “Parameters”boolean
True to force use of TURN servers
Returns
Section titled “Returns”void
setGuest()
Section titled “setGuest()”setGuest(
guest):void
Defined in: src/client.ts:1894
Set whether this client is a guest account. This method is experimental and may change without warning.
Parameters
Section titled “Parameters”boolean
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.
Returns
Section titled “Returns”void
setGuestAccess()
Section titled “setGuestAccess()”setGuestAccess(
roomId,opts):Promise<void>
Defined in: src/client.ts:5308
Set r/w flags for guest access in a room.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room to configure guest access in.
Options
Returns
Section titled “Returns”Promise<void>
Promise which resolves
setIdentityServerUrl()
Section titled “setIdentityServerUrl()”setIdentityServerUrl(
url?):void
Defined in: src/client.ts:6470
Set the identity server URL of this client
Parameters
Section titled “Parameters”string
New identity server URL
Returns
Section titled “Returns”void
setIgnoredUsers()
Section titled “setIgnoredUsers()”setIgnoredUsers(
userIds):Promise<EmptyObject>
Defined in: src/client.ts:2385
Sets the users that the current user should ignore.
Parameters
Section titled “Parameters”userIds
Section titled “userIds”string[]
the user IDs to ignore
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: an empty object
setLivekitServiceURL()
Section titled “setLivekitServiceURL()”setLivekitServiceURL(
newURL):void
Defined in: src/client.ts:1816
Parameters
Section titled “Parameters”newURL
Section titled “newURL”string
Returns
Section titled “Returns”void
setLocalNotificationSettings()
Section titled “setLocalNotificationSettings()”setLocalNotificationSettings(
deviceId,notificationSettings):Promise<EmptyObject>
Defined in: src/client.ts:7791
Persists local notification settings
Parameters
Section titled “Parameters”deviceId
Section titled “deviceId”string
notificationSettings
Section titled “notificationSettings”Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: an empty object
setMaxListeners()
Section titled “setMaxListeners()”setMaxListeners(
n):this
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:813
By default EventEmitters will print a warning if more than 10 listeners are
added for a particular event. This is a useful default that helps finding
memory leaks. The emitter.setMaxListeners() method allows the limit to be
modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.
Returns a reference to the EventEmitter, so that calls can be chained.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
v0.3.5
Inherited from
Section titled “Inherited from”TypedEventEmitter.setMaxListeners
setNotifTimelineSet()
Section titled “setNotifTimelineSet()”setNotifTimelineSet(
set):void
Defined in: src/client.ts:1932
Set the global notification EventTimelineSet
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
setPassword()
Section titled “setPassword()”setPassword(
authDict,newPassword,logoutDevices?):Promise<EmptyObject>
Defined in: src/client.ts:7643
Make a request to change your password.
Parameters
Section titled “Parameters”authDict
Section titled “authDict”newPassword
Section titled “newPassword”string
The new desired password.
logoutDevices?
Section titled “logoutDevices?”boolean
Should all sessions be logged out after the password change. Defaults to true.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object {}
setPowerLevel()
Section titled “setPowerLevel()”setPowerLevel(
roomId,userId,powerLevel):Promise<ISendEventResponse>
Defined in: src/client.ts:2636
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.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
the room to update power levels in
userId
Section titled “userId”string | string[]
the ID of the user or users to update power levels of
powerLevel
Section titled “powerLevel”number | undefined
the numeric power level to update given users to
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: to an ISendEventResponse object
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
setPresence()
Section titled “setPresence()”setPresence(
opts):Promise<void>
Defined in: src/client.ts:4451
Parameters
Section titled “Parameters”Options to apply
Returns
Section titled “Returns”Promise<void>
Promise which resolves
Throws
Section titled “Throws”If ‘presence’ isn’t a valid presence enum value.
setProfileInfo()
Section titled “setProfileInfo()”Call Signature
Section titled “Call Signature”setProfileInfo(
info,data):Promise<EmptyObject>
Defined in: src/client.ts:4349
Parameters
Section titled “Parameters”"avatar_url"
The kind of info to set (e.g. ‘avatar_url’)
The JSON object to set.
avatar_url
Section titled “avatar_url”string
Returns
Section titled “Returns”Promise<EmptyObject>
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
Call Signature
Section titled “Call Signature”setProfileInfo(
info,data):Promise<EmptyObject>
Defined in: src/client.ts:4350
Parameters
Section titled “Parameters”"displayname"
The kind of info to set (e.g. ‘avatar_url’)
The JSON object to set.
displayname
Section titled “displayname”string
Returns
Section titled “Returns”Promise<EmptyObject>
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
setPusher()
Section titled “setPusher()”setPusher(
pusher):Promise<EmptyObject>
Defined in: src/client.ts:7764
Adds a new pusher or updates an existing pusher
Parameters
Section titled “Parameters”pusher
Section titled “pusher”Object representing a pusher
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: Empty json object on success
setPushRuleActions()
Section titled “setPushRuleActions()”setPushRuleActions(
scope,kind,ruleId,actions):Promise<EmptyObject>
Defined in: src/client.ts:7876
Set the actions for a push notification rule.
Parameters
Section titled “Parameters”string
ruleId
Section titled “ruleId”string
actions
Section titled “actions”Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object {}
setPushRuleEnabled()
Section titled “setPushRuleEnabled()”setPushRuleEnabled(
scope,kind,ruleId,enabled):Promise<EmptyObject>
Defined in: src/client.ts:7858
Enable or disable a push notification rule.
Parameters
Section titled “Parameters”string
ruleId
Section titled “ruleId”string
enabled
Section titled “enabled”boolean
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object {}
setPushRules()
Section titled “setPushRules()”setPushRules(
rules):void
Defined in: src/client.ts:7815
Update the push rules for the account. This should be called whenever updated push rules are available.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
setRoomAccountData()
Section titled “setRoomAccountData()”setRoomAccountData<
K>(roomId,eventType,content):Promise<EmptyObject>
Defined in: src/client.ts:2611
Type Parameters
Section titled “Type Parameters”K extends keyof RoomAccountDataEvents
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
the ID of the room this event should be stored within
eventType
Section titled “eventType”K
event type to be set
content
Section titled “content”Record<string, never> | RoomAccountDataEvents[K]
event content
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object {}
setRoomDirectoryVisibility()
Section titled “setRoomDirectoryVisibility()”setRoomDirectoryVisibility(
roomId,visibility):Promise<EmptyObject>
Defined in: src/client.ts:7276
Set the visibility of a room in the current HS’s room directory
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
visibility
Section titled “visibility”“public” to make the room visible in the public directory, or “private” to make it invisible.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object {}
setRoomMutePushRule()
Section titled “setRoomMutePushRule()”setRoomMutePushRule(
scope,roomId,mute):Promise<void> |undefined
Defined in: src/client.ts:5555
Set a room-kind muting push rule in a room. The operation also updates DigitalWorldClient.pushRules at the end.
Parameters
Section titled “Parameters”"global" | "device"
“global” or device-specific.
roomId
Section titled “roomId”string
the id of the room.
boolean
the mute state.
Returns
Section titled “Returns”Promise<void> | undefined
Promise which resolves: result object
setRoomName()
Section titled “setRoomName()”setRoomName(
roomId,name):Promise<ISendEventResponse>
Defined in: src/client.ts:2545
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
string
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: TODO
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
setRoomReadMarkers()
Section titled “setRoomReadMarkers()”setRoomReadMarkers(
roomId,rmEventId,rrEvent?,rpEvent?):Promise<EmptyObject>
Defined in: src/client.ts:3878
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.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
ID of the room that has been read
rmEventId
Section titled “rmEventId”string
ID of the event that has been read
rrEvent?
Section titled “rrEvent?”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. The local echo of this receipt will be done if set. Optional.
rpEvent?
Section titled “rpEvent?”the m.read.private read receipt event for when we don’t want other users to see the read receipts. This is experimental. Optional.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: the empty object, {}.
setRoomReadMarkersHttpRequest()
Section titled “setRoomReadMarkersHttpRequest()”setRoomReadMarkersHttpRequest(
roomId,rmEventId,rrEventId?,rpEventId?):Promise<EmptyObject>
Defined in: src/client.ts:7122
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.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
ID of the room that has been read
rmEventId
Section titled “rmEventId”string
ID of the event that has been read
rrEventId?
Section titled “rrEventId?”string
ID 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.
rpEventId?
Section titled “rpEventId?”string
rpEvent the m.read.private read receipt event for when we don’t want other users to see the read receipts. This is experimental. Optional.
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: the empty object, {}.
setRoomTag()
Section titled “setRoomTag()”setRoomTag(
roomId,tagName,metadata?):Promise<EmptyObject>
Defined in: src/client.ts:2581
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
tagName
Section titled “tagName”string
name of room tag to be set
metadata?
Section titled “metadata?”ITagMetadata = {}
associated with that tag to be stored
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: to an empty object
setRoomTopic()
Section titled “setRoomTopic()”setRoomTopic(
roomId,topic?,htmlTopic?):Promise<ISendEventResponse>
Defined in: src/client.ts:2558
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room to update the topic in.
topic?
Section titled “topic?”string
The plaintext topic. May be empty to remove the topic.
htmlTopic?
Section titled “htmlTopic?”string
Optional.
Returns
Section titled “Returns”Promise<ISendEventResponse>
Promise which resolves: TODO
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
setSupportsCallTransfer()
Section titled “setSupportsCallTransfer()”setSupportsCallTransfer(
support):void
Defined in: src/client.ts:1745
Set whether to advertise transfer support to other parties on calls.
Parameters
Section titled “Parameters”support
Section titled “support”boolean
True to advertise the ‘m.call.transferee’ capability
Returns
Section titled “Returns”void
setSyncPresence()
Section titled “setSyncPresence()”setSyncPresence(
presence?):Promise<void>
Defined in: src/client.ts:4441
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.
Parameters
Section titled “Parameters”presence?
Section titled “presence?”the presence to specify to set_presence of sync calls
Returns
Section titled “Returns”Promise<void>
slidingSync()
Section titled “slidingSync()”slidingSync(
req,proxyBaseUrl?,abortSignal?):Promise<MSC3575SlidingSyncResponse>
Defined in: src/client.ts:8729
Perform a single MSC3575 sliding sync request.
Parameters
Section titled “Parameters”MSC3575SlidingSyncRequest
The request to make.
proxyBaseUrl?
Section titled “proxyBaseUrl?”string
The base URL for the sliding sync proxy.
abortSignal?
Section titled “abortSignal?”AbortSignal
Optional signal to abort request mid-flight.
Returns
Section titled “Returns”Promise<MSC3575SlidingSyncResponse>
The sliding sync response, or a standard error.
Throws
Section titled “Throws”on non 2xx status codes with an object with a field “httpStatus”:number.
startClient()
Section titled “startClient()”startClient(
opts?):Promise<void>
Defined in: src/client.ts:1465
High level helper method to begin syncing and poll for new events. To listen for these events, add a listener for ClientEvent.Event via DigitalWorldClient#on. Alternatively, listen for specific state change events.
Parameters
Section titled “Parameters”Options to apply when syncing.
Returns
Section titled “Returns”Promise<void>
stopClient()
Section titled “stopClient()”stopClient():
void
Defined in: src/client.ts:1559
High level helper method to stop the client from polling and allow a clean shutdown.
Returns
Section titled “Returns”void
stopPeeking()
Section titled “stopPeeking()”stopPeeking():
void
Defined in: src/client.ts:5294
Stop any ongoing room peeking.
Returns
Section titled “Returns”void
storeClientOptions()
Section titled “storeClientOptions()”storeClientOptions():
Promise<void>
Defined in: src/client.ts:6112
store client options with boolean/string/numeric values to know in the next session what flags the sync data was created with (e.g. lazy loading)
Returns
Section titled “Returns”Promise<void>
for store operation
submitMsisdnToken()
Section titled “submitMsisdnToken()”submitMsisdnToken(
sid,clientSecret,msisdnToken,identityAccessToken):Promise<{success:boolean; }>
Defined in: src/client.ts:8161
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.
Parameters
Section titled “Parameters”string
The sid given in the response to requestToken
clientSecret
Section titled “clientSecret”string
A secret binary string generated by the client. This must be the same value submitted in the requestToken call.
msisdnToken
Section titled “msisdnToken”string
The MSISDN token, as entered by the user.
identityAccessToken
Section titled “identityAccessToken”string | null
The access_token field of the Identity
Server /account/register response (see registerWithIdentityServer).
Some legacy identity servers had no authentication here.
Returns
Section titled “Returns”Promise<{ success: boolean; }>
Promise which resolves: Object, containing success boolean.
Throws
Section titled “Throws”Error if No identity server is set
submitMsisdnTokenOtherUrl()
Section titled “submitMsisdnTokenOtherUrl()”submitMsisdnTokenOtherUrl(
url,sid,clientSecret,msisdnToken):Promise<{success:boolean; }>
Defined in: src/client.ts:8200
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 hub validates 3PID ownership (as part of
requestAdd3pidMsisdnToken). The hub 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.
Parameters
Section titled “Parameters”string
The URL to submit the token to
string
The sid given in the response to requestToken
clientSecret
Section titled “clientSecret”string
A secret binary string generated by the client. This must be the same value submitted in the requestToken call.
msisdnToken
Section titled “msisdnToken”string
The MSISDN token, as entered by the user.
Returns
Section titled “Returns”Promise<{ success: boolean; }>
Promise which resolves: Object, containing success boolean.
supportsIntentionalMentions()
Section titled “supportsIntentionalMentions()”supportsIntentionalMentions():
boolean
Defined in: src/client.ts:8766
A helper to determine intentional mentions support
Returns
Section titled “Returns”boolean
a boolean to determine if intentional mentions are enabled on the server
supportsThreads()
Section titled “supportsThreads()”supportsThreads():
boolean
Defined in: src/client.ts:8757
A helper to determine thread support
Returns
Section titled “Returns”boolean
a boolean to determine if threads are enabled
supportsVoip()
Section titled “supportsVoip()”supportsVoip():
boolean
Defined in: src/client.ts:1720
Check if the runtime environment supports VoIP calling.
Returns
Section titled “Returns”boolean
True if VoIP is supported.
syncLeftRooms()
Section titled “syncLeftRooms()”syncLeftRooms():
Promise<Room[]>
Defined in: src/client.ts:5770
Populate the store with rooms the user has left.
Returns
Section titled “Returns”Promise<Room[]>
Promise which resolves: TODO - Resolved when the rooms have been added to the data store.
timestampToEvent()
Section titled “timestampToEvent()”timestampToEvent(
roomId,timestamp,dir):Promise<TimestampToEventResponse>
Defined in: src/client.ts:8846
Find the event_id closest to the given timestamp in the given direction.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
timestamp
Section titled “timestamp”number
Returns
Section titled “Returns”Promise<TimestampToEventResponse>
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
turnServer()
Section titled “turnServer()”turnServer():
Promise<ITurnServerResponse>
Defined in: src/client.ts:5955
Returns
Section titled “Returns”Promise<ITurnServerResponse>
Promise which resolves: ITurnServerResponse object
unban()
Section titled “unban()”unban(
roomId,userId):Promise<EmptyObject>
Defined in: src/client.ts:4260
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<EmptyObject>
Promise which resolves: Object (currently empty)
unbindThreePid()
Section titled “unbindThreePid()”unbindThreePid(
medium,address):Promise<{id_server_unbind_result:IdServerUnbindResult; }>
Defined in: src/client.ts:7605
Unbind a 3PID for discovery on an identity server via the hub. The hub removes its record of the binding to keep an updated record of where all 3PIDs for the account are bound.
Parameters
Section titled “Parameters”medium
Section titled “medium”string
The threepid medium (eg. ‘email’)
address
Section titled “address”string
The threepid address (eg. ‘bob@example.com’) this must be as returned by getThreePids.
Returns
Section titled “Returns”Promise<{ id_server_unbind_result: IdServerUnbindResult; }>
Promise which resolves: on success
unstable_createLiveBeacon()
Section titled “unstable_createLiveBeacon()”unstable_createLiveBeacon(
roomId,beaconInfoContent):Promise<ISendEventResponse>
Defined in: src/client.ts:2684
Create an m.beacon_info event
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
beaconInfoContent
Section titled “beaconInfoContent”Returns
Section titled “Returns”Promise<ISendEventResponse>
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
unstable_setLiveBeacon()
Section titled “unstable_setLiveBeacon()”unstable_setLiveBeacon(
roomId,beaconInfoContent):Promise<ISendEventResponse>
Defined in: src/client.ts:2700
Upsert a live beacon event using a specific m.beacon_info.* event variable type
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
string
beaconInfoContent
Section titled “beaconInfoContent”Returns
Section titled “Returns”Promise<ISendEventResponse>
Throws
Section titled “Throws”May throw a DigitalWorldSafetyError if content is deemed unsafe.
DigitalWorldSafetyError
unstableCreateFileTree()
Section titled “unstableCreateFileTree()”unstableCreateFileTree(
name):Promise<MSC3089TreeSpace>
Defined in: src/client.ts:8662
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.
Parameters
Section titled “Parameters”string
The name of the tree space.
Returns
Section titled “Returns”Promise<MSC3089TreeSpace>
Promise which resolves to the created space.
unstableGetFileTreeSpace()
Section titled “unstableGetFileTreeSpace()”unstableGetFileTreeSpace(
roomId):MSC3089TreeSpace|null
Defined in: src/client.ts:8703
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.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room ID to get a tree space reference for.
Returns
Section titled “Returns”MSC3089TreeSpace | null
The tree space, or null if not a tree space.
upgradeRoom()
Section titled “upgradeRoom()”upgradeRoom(
roomId,newVersion,additionalCreators?):Promise<{replacement_room:string; }>
Defined in: src/client.ts:6978
Upgrades a room to a new protocol version
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
newVersion
Section titled “newVersion”string
The target version to upgrade to
additionalCreators?
Section titled “additionalCreators?”string[]
an optional list of user IDs of users who should have the same permissions as the user performing the upgrade
Returns
Section titled “Returns”Promise<{ replacement_room: string; }>
Promise which resolves: Object with key ‘replacement_room’
uploadContent()
Section titled “uploadContent()”uploadContent(
file,opts?):Promise<UploadResponse>
Defined in: src/client.ts:7313
Upload a file to the media repository on the hub.
Parameters
Section titled “Parameters”XMLHttpRequestBodyInit
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.
options object
Returns
Section titled “Returns”Promise<UploadResponse>
Promise which resolves to response object, or rejects with an error (usually a DigitalWorldError).
uploadDeviceSigningKeys()
Section titled “uploadDeviceSigningKeys()”uploadDeviceSigningKeys(
auth?,keys?):Promise<EmptyObject>
Defined in: src/client.ts:8007
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<EmptyObject>
uploadKeySignatures()
Section titled “uploadKeySignatures()”uploadKeySignatures(
content):Promise<IUploadKeySignaturesResponse>
Defined in: src/client.ts:7924
Parameters
Section titled “Parameters”content
Section titled “content”Returns
Section titled “Returns”Promise<IUploadKeySignaturesResponse>
uploadKeysRequest()
Section titled “uploadKeysRequest()”uploadKeysRequest(
content,opts?):Promise<IKeysUploadResponse>
Defined in: src/client.ts:7920
Upload keys
Parameters
Section titled “Parameters”content
Section titled “content”body of upload request
void
this method no longer takes any opts, used to take opts.device_id but this was not removed from the spec as a redundant parameter
Returns
Section titled “Returns”Promise<IKeysUploadResponse>
Promise which resolves: result object. Rejects: with an error response (DigitalWorldError).
waitForClientWellKnown()
Section titled “waitForClientWellKnown()”waitForClientWellKnown():
Promise<IClientWellKnown>
Defined in: src/client.ts:6099
Returns
Section titled “Returns”Promise<IClientWellKnown>
waitUntilRoomReadyForGroupCalls()
Section titled “waitUntilRoomReadyForGroupCalls()”waitUntilRoomReadyForGroupCalls(
roomId):Promise<void>
Defined in: src/client.ts:1831
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.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room ID to wait for
Returns
Section titled “Returns”Promise<void>
A promise that resolves once existing group calls in the room have been processed.
whoami()
Section titled “whoami()”whoami():
Promise<IWhoamiResponse>
Defined in: src/client.ts:8836
Fetches information about the user for the configured access token.
Returns
Section titled “Returns”Promise<IWhoamiResponse>
whoisSynapseUser()
Section titled “whoisSynapseUser()”whoisSynapseUser(
userId):Promise<ISynapseAdminWhoisResponse>
Defined in: src/client.ts:6071
Performs a whois lookup on a user using Synapse’s administrator API. This function is implementation specific and may change as a result.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
the User ID to look up.
Returns
Section titled “Returns”Promise<ISynapseAdminWhoisResponse>
the whois response - see Synapse docs for information.
addAbortListener()
Section titled “addAbortListener()”
staticaddAbortListener(signal,resource):Disposable
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:403
Listens once to the abort event on the provided signal.
Listening to the abort event on abort signals is unsafe and may
lead to resource leaks since another third party with the signal can
call e.stopImmediatePropagation(). Unfortunately Node.js cannot change
this since it would violate the web standard. Additionally, the original
API makes it easy to forget to remove listeners.
This API allows safely using AbortSignals in Node.js APIs by solving these
two issues by listening to the event such that stopImmediatePropagation does
not prevent the listener from running.
Returns a disposable so that it may be unsubscribed from more easily.
import { addAbortListener } from 'node:events';
function example(signal) { let disposable; try { signal.addEventListener('abort', (e) => e.stopImmediatePropagation()); disposable = addAbortListener(signal, (e) => { // Do something when signal is aborted. }); } finally { disposable?.[Symbol.dispose](); }}Parameters
Section titled “Parameters”signal
Section titled “signal”AbortSignal
resource
Section titled “resource”(event) => void
Returns
Section titled “Returns”Disposable
Disposable that removes the abort listener.
v20.5.0
Inherited from
Section titled “Inherited from”TypedEventEmitter.addAbortListener
getEventListeners()
Section titled “getEventListeners()”
staticgetEventListeners(emitter,name):Function[]
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:325
Returns a copy of the array of listeners for the event named eventName.
For EventEmitters this behaves exactly the same as calling .listeners on
the emitter.
For EventTargets this is the only way to get the event listeners for the
event target. This is useful for debugging and diagnostic purposes.
import { getEventListeners, EventEmitter } from 'node:events';
{ const ee = new EventEmitter(); const listener = () => console.log('Events are fun'); ee.on('foo', listener); console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]}{ const et = new EventTarget(); const listener = () => console.log('Events are fun'); et.addEventListener('foo', listener); console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]}Parameters
Section titled “Parameters”emitter
Section titled “emitter”EventEmitter<DefaultEventMap> | EventTarget
string | symbol
Returns
Section titled “Returns”Function[]
v15.2.0, v14.17.0
Inherited from
Section titled “Inherited from”TypedEventEmitter.getEventListeners
getMaxListeners()
Section titled “getMaxListeners()”
staticgetMaxListeners(emitter):number
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:354
Returns the currently set max amount of listeners.
For EventEmitters this behaves exactly the same as calling .getMaxListeners on
the emitter.
For EventTargets this is the only way to get the max event listeners for the
event target. If the number of event handlers on a single EventTarget exceeds
the max set, the EventTarget will print a warning.
import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';
{ const ee = new EventEmitter(); console.log(getMaxListeners(ee)); // 10 setMaxListeners(11, ee); console.log(getMaxListeners(ee)); // 11}{ const et = new EventTarget(); console.log(getMaxListeners(et)); // 10 setMaxListeners(11, et); console.log(getMaxListeners(et)); // 11}Parameters
Section titled “Parameters”emitter
Section titled “emitter”EventEmitter<DefaultEventMap> | EventTarget
Returns
Section titled “Returns”number
v19.9.0
Inherited from
Section titled “Inherited from”TypedEventEmitter.getMaxListeners
listenerCount()
Section titled “listenerCount()”
staticlistenerCount(emitter,eventName):number
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:297
A class method that returns the number of listeners for the given eventName registered on the given emitter.
import { EventEmitter, listenerCount } from 'node:events';
const myEmitter = new EventEmitter();myEmitter.on('event', () => {});myEmitter.on('event', () => {});console.log(listenerCount(myEmitter, 'event'));// Prints: 2Parameters
Section titled “Parameters”emitter
Section titled “emitter”EventEmitter
The emitter to query
eventName
Section titled “eventName”string | symbol
The event name
Returns
Section titled “Returns”number
v0.9.12
Inherited from
Section titled “Inherited from”TypedEventEmitter.listenerCount
Call Signature
Section titled “Call Signature”
staticon(emitter,eventName,options?):AsyncIterator<any[]>
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:270
import { on, EventEmitter } from 'node:events';import process from 'node:process';
const ee = new EventEmitter();
// Emit later onprocess.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42);});
for await (const event of on(ee, 'foo')) { // The execution of this inner block is synchronous and it // processes one event at a time (even with await). Do not use // if concurrent execution is required. console.log(event); // prints ['bar'] [42]}// Unreachable hereReturns an AsyncIterator that iterates eventName events. It will throw
if the EventEmitter emits 'error'. It removes all listeners when
exiting the loop. The value returned by each iteration is an array
composed of the emitted event arguments.
An AbortSignal can be used to cancel waiting on events:
import { on, EventEmitter } from 'node:events';import process from 'node:process';
const ac = new AbortController();
(async () => { const ee = new EventEmitter();
// Emit later on process.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42); });
for await (const event of on(ee, 'foo', { signal: ac.signal })) { // The execution of this inner block is synchronous and it // processes one event at a time (even with await). Do not use // if concurrent execution is required. console.log(event); // prints ['bar'] [42] } // Unreachable here})();
process.nextTick(() => ac.abort());Use the close option to specify an array of event names that will end the iteration:
import { on, EventEmitter } from 'node:events';import process from 'node:process';
const ee = new EventEmitter();
// Emit later onprocess.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42); ee.emit('close');});
for await (const event of on(ee, 'foo', { close: ['close'] })) { console.log(event); // prints ['bar'] [42]}// the loop will exit after 'close' is emittedconsole.log('done'); // prints 'done'Parameters
Section titled “Parameters”emitter
Section titled “emitter”EventEmitter
eventName
Section titled “eventName”string | symbol
options?
Section titled “options?”StaticEventEmitterIteratorOptions
Returns
Section titled “Returns”AsyncIterator<any[]>
An AsyncIterator that iterates eventName events emitted by the emitter
v13.6.0, v12.16.0
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”
staticon(emitter,eventName,options?):AsyncIterator<any[]>
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:275
import { on, EventEmitter } from 'node:events';import process from 'node:process';
const ee = new EventEmitter();
// Emit later onprocess.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42);});
for await (const event of on(ee, 'foo')) { // The execution of this inner block is synchronous and it // processes one event at a time (even with await). Do not use // if concurrent execution is required. console.log(event); // prints ['bar'] [42]}// Unreachable hereReturns an AsyncIterator that iterates eventName events. It will throw
if the EventEmitter emits 'error'. It removes all listeners when
exiting the loop. The value returned by each iteration is an array
composed of the emitted event arguments.
An AbortSignal can be used to cancel waiting on events:
import { on, EventEmitter } from 'node:events';import process from 'node:process';
const ac = new AbortController();
(async () => { const ee = new EventEmitter();
// Emit later on process.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42); });
for await (const event of on(ee, 'foo', { signal: ac.signal })) { // The execution of this inner block is synchronous and it // processes one event at a time (even with await). Do not use // if concurrent execution is required. console.log(event); // prints ['bar'] [42] } // Unreachable here})();
process.nextTick(() => ac.abort());Use the close option to specify an array of event names that will end the iteration:
import { on, EventEmitter } from 'node:events';import process from 'node:process';
const ee = new EventEmitter();
// Emit later onprocess.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42); ee.emit('close');});
for await (const event of on(ee, 'foo', { close: ['close'] })) { console.log(event); // prints ['bar'] [42]}// the loop will exit after 'close' is emittedconsole.log('done'); // prints 'done'Parameters
Section titled “Parameters”emitter
Section titled “emitter”EventTarget
eventName
Section titled “eventName”string
options?
Section titled “options?”StaticEventEmitterIteratorOptions
Returns
Section titled “Returns”AsyncIterator<any[]>
An AsyncIterator that iterates eventName events emitted by the emitter
v13.6.0, v12.16.0
Inherited from
Section titled “Inherited from”once()
Section titled “once()”Call Signature
Section titled “Call Signature”
staticonce(emitter,eventName,options?):Promise<any[]>
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:184
Creates a Promise that is fulfilled when the EventEmitter emits the given
event or that is rejected if the EventEmitter emits 'error' while waiting.
The Promise will resolve with an array of all the arguments emitted to the
given event.
This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event
semantics and does not listen to the 'error' event.
import { once, EventEmitter } from 'node:events';import process from 'node:process';
const ee = new EventEmitter();
process.nextTick(() => { ee.emit('myevent', 42);});
const [value] = await once(ee, 'myevent');console.log(value);
const err = new Error('kaboom');process.nextTick(() => { ee.emit('error', err);});
try { await once(ee, 'myevent');} catch (err) { console.error('error happened', err);}The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the
’error' event itself, then it is treated as any other kind of event without
special handling:
import { EventEmitter, once } from 'node:events';
const ee = new EventEmitter();
once(ee, 'error') .then(([err]) => console.log('ok', err.message)) .catch((err) => console.error('error', err.message));
ee.emit('error', new Error('boom'));
// Prints: ok boomAn AbortSignal can be used to cancel waiting for the event:
import { EventEmitter, once } from 'node:events';
const ee = new EventEmitter();const ac = new AbortController();
async function foo(emitter, event, signal) { try { await once(emitter, event, { signal }); console.log('event emitted!'); } catch (error) { if (error.name === 'AbortError') { console.error('Waiting for the event was canceled!'); } else { console.error('There was an error', error.message); } }}
foo(ee, 'foo', ac.signal);ac.abort(); // Abort waiting for the eventee.emit('foo'); // Prints: Waiting for the event was canceled!Parameters
Section titled “Parameters”emitter
Section titled “emitter”EventEmitter
eventName
Section titled “eventName”string | symbol
options?
Section titled “options?”StaticEventEmitterOptions
Returns
Section titled “Returns”Promise<any[]>
v11.13.0, v10.16.0
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”
staticonce(emitter,eventName,options?):Promise<any[]>
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:189
Creates a Promise that is fulfilled when the EventEmitter emits the given
event or that is rejected if the EventEmitter emits 'error' while waiting.
The Promise will resolve with an array of all the arguments emitted to the
given event.
This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event
semantics and does not listen to the 'error' event.
import { once, EventEmitter } from 'node:events';import process from 'node:process';
const ee = new EventEmitter();
process.nextTick(() => { ee.emit('myevent', 42);});
const [value] = await once(ee, 'myevent');console.log(value);
const err = new Error('kaboom');process.nextTick(() => { ee.emit('error', err);});
try { await once(ee, 'myevent');} catch (err) { console.error('error happened', err);}The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the
’error' event itself, then it is treated as any other kind of event without
special handling:
import { EventEmitter, once } from 'node:events';
const ee = new EventEmitter();
once(ee, 'error') .then(([err]) => console.log('ok', err.message)) .catch((err) => console.error('error', err.message));
ee.emit('error', new Error('boom'));
// Prints: ok boomAn AbortSignal can be used to cancel waiting for the event:
import { EventEmitter, once } from 'node:events';
const ee = new EventEmitter();const ac = new AbortController();
async function foo(emitter, event, signal) { try { await once(emitter, event, { signal }); console.log('event emitted!'); } catch (error) { if (error.name === 'AbortError') { console.error('Waiting for the event was canceled!'); } else { console.error('There was an error', error.message); } }}
foo(ee, 'foo', ac.signal);ac.abort(); // Abort waiting for the eventee.emit('foo'); // Prints: Waiting for the event was canceled!Parameters
Section titled “Parameters”emitter
Section titled “emitter”EventTarget
eventName
Section titled “eventName”string
options?
Section titled “options?”StaticEventEmitterOptions
Returns
Section titled “Returns”Promise<any[]>
v11.13.0, v10.16.0
Inherited from
Section titled “Inherited from”setMaxListeners()
Section titled “setMaxListeners()”
staticsetMaxListeners(n?, …eventTargets):void
Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:369
import { setMaxListeners, EventEmitter } from 'node:events';
const target = new EventTarget();const emitter = new EventEmitter();
setMaxListeners(5, target, emitter);Parameters
Section titled “Parameters”number
A non-negative number. The maximum number of listeners per EventTarget event.
eventTargets
Section titled “eventTargets”…(EventEmitter<DefaultEventMap> | EventTarget)[]
Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, n is set as the default max for all newly created {EventTarget} and {EventEmitter}
objects.
Returns
Section titled “Returns”void
v15.4.0