Global

Members

(constant) DECRYPTION_CLASSES :Object.<string, function(new:module:crypto/algorithms/base.DecryptionAlgorithm)>

Source:
map of registered encryption algorithm classes. Map from string to DecryptionAlgorithm class
Type:

(constant) DEFAULT_TREE_POWER_LEVELS_TEMPLATE

Source:
The recommended defaults for a tree space's power levels. Note that this is UNSTABLE and subject to breaking changes without notice.

(constant) ENCRYPTION_CLASSES :Object.<string, function(new:module:crypto/algorithms/base.EncryptionAlgorithm)>

Source:
map of registered encryption algorithm classes. A map from string to EncryptionAlgorithm class
Type:

(constant) EVENT_VISIBILITY_CHANGE_TYPE

Source:
A type of message that affects visibility of a message, as per https://github.com/matrix-org/matrix-doc/pull/3531

(readonly) EventStatus :string

Source:
Enum for event statuses.
Type:
  • string

(constant) M_BEACON_INFO

Source:
Non-variable type for m.beacon_info event content

(constant) M_BEACON_INFO_VARIABLE

Source:
Variable event type for m.beacon_info

TreePermissions

Source:
Ease-of-use representation for power levels represented as simple roles. Note that this is UNSTABLE and subject to breaking changes without notice.

(constant) UNSTABLE_ELEMENT_FUNCTIONAL_USERS

Source:
Functional members type for declaring a purpose of room members (e.g. helpful bots). Note that this reference is UNSTABLE and subject to breaking changes, including its eventual removal. Schema (TypeScript): { service_members?: string[] } Example: { "service_members": [ "@helperbot:localhost", "@reminderbot:alice.tdl" ] }

(constant) UNSTABLE_MSC3088_ENABLED

Source:
Enabled flag for an [MSC3088](https://github.com/matrix-org/matrix-doc/pull/3088) room purpose. Note that this reference is UNSTABLE and subject to breaking changes, including its eventual removal.

(constant) UNSTABLE_MSC3088_PURPOSE

Source:
Identifier for an [MSC3088](https://github.com/matrix-org/matrix-doc/pull/3088) room purpose. Note that this reference is UNSTABLE and subject to breaking changes, including its eventual removal.

(constant) UNSTABLE_MSC3089_BRANCH

Source:
Branch (Leaf Reference) type for the index approach in a [MSC3089](https://github.com/matrix-org/matrix-doc/pull/3089) space-room. Note that this reference is UNSTABLE and subject to breaking changes, including its eventual removal.

(constant) UNSTABLE_MSC3089_LEAF

Source:
Leaf type for an event in a [MSC3089](https://github.com/matrix-org/matrix-doc/pull/3089) space-room. Note that this reference is UNSTABLE and subject to breaking changes, including its eventual removal.

(constant) UNSTABLE_MSC3089_TREE_SUBTYPE

Source:
Subtype for an [MSC3089](https://github.com/matrix-org/matrix-doc/pull/3089) space-room. Note that this reference is UNSTABLE and subject to breaking changes, including its eventual removal.

Methods

calculateKeyCheck(key, ivopt) → {Promise.<object>}

Source:
Calculate the MAC for checking the key.
Parameters:
Name Type Attributes Description
key Uint8Array the key to use
iv string <optional>
The initialization vector as a base64-encoded string. If omitted, a random initialization vector will be created.
Returns:
An object that contains, `mac` and `iv` properties.
Type
Promise.<object>

clearTimeout(key)

Source:
reimplementation of window.clearTimeout, which mirrors setTimeout
Parameters:
Name Type Description
key Number result from an earlier setTimeout call

createClient(opts) → {MatrixClient}

Source:
See:
Construct a Matrix Client. Similar to module:client.MatrixClient except that the 'request', 'store' and 'scheduler' dependencies are satisfied.
Parameters:
Name Type Description
opts Object | string The configuration options for this client. If this is a string, it is assumed to be the base URL. These configuration options will be passed directly to module:client.MatrixClient.
Properties
Name Type Attributes Description
store Object If not set, defaults to module:store/memory.MemoryStore.
scheduler Object If not set, defaults to module:scheduler~MatrixScheduler.
request requestFunction If not set, defaults to the function supplied to request which defaults to the request module from NPM.
cryptoStore module:crypto.store.base~CryptoStore <optional>
crypto store implementation. Calls the factory supplied to setCryptoStoreFactory if unspecified; or if no factory has been specified, uses a default implementation (indexeddb in the browser, in-memory otherwise).
Returns:
A new matrix client.
Type
MatrixClient

(async) decryptBrowser(data, key, name)

Source:
decrypt a string in the browser
Parameters:
Name Type Description
data object the encrypted data
Properties
Name Type Description
ciphertext string the ciphertext in base64
iv string the initialization vector in base64
mac string the HMAC in base64
key Uint8Array the encryption key to use
name string the name of the secret

(async) decryptNode(data, key, name)

Source:
decrypt a string in Node.js
Parameters:
Name Type Description
data object the encrypted data
Properties
Name Type Description
ciphertext string the ciphertext in base64
iv string the initialization vector in base64
mac string the HMAC in base64
key Uint8Array the encryption key to use
name string the name of the secret

(async) encryptBrowser(data, key, name, ivStr)

Source:
encrypt a string in Node.js
Parameters:
Name Type Description
data string the plaintext to encrypt
key Uint8Array the encryption key to use
name string the name of the secret
ivStr string the initialization vector to use

(async) encryptNode(data, key, name, ivStr)

Source:
encrypt a string in Node.js
Parameters:
Name Type Description
data string the plaintext to encrypt
key Uint8Array the encryption key to use
name string the name of the secret
ivStr string the initialization vector to use

exists(indexedDB, dbName) → {boolean}

Source:
Check if an IndexedDB database exists. The only way to do so is to try opening it, so we do that and then delete it did not exist before.
Parameters:
Name Type Description
indexedDB Object The `indexedDB` interface
dbName string The database name to test for
Returns:
Whether the database exists
Type
boolean

getRequest() → {requestFunction}

Source:
Return the currently-set request function.
Returns:
The current request function.
Type
requestFunction

registerAlgorithm(algorithm, encryptor, decryptor)

Source:
Registers an encryption/decryption class for a particular algorithm
Parameters:
Name Type Description
algorithm string algorithm tag to register for
encryptor class EncryptionAlgorithm implementation
decryptor class DecryptionAlgorithm implementation

request(r)

Source:
The function used to perform HTTP requests. Only use this if you want to use a different HTTP library, e.g. Angular's $http. This should be set prior to calling createClient.
Parameters:
Name Type Description
r requestFunction The request function to use.

requestKeysDuringVerification(baseApis, userId, deviceId)

Source:
Request cross-signing keys from another device during verification.
Parameters:
Name Type Description
baseApis MatrixClient base Matrix API interface
userId string The user ID being verified
deviceId string The device ID being verified

selectQuery(store, keyRangeopt, resultMapper) → {Promise.<Array.<T>>}

Source:
Helper method to collect results from a Cursor and promiseify it.
Parameters:
Name Type Attributes Description
store ObjectStore | Index The store to perform openCursor on.
keyRange IDBKeyRange <optional>
Optional key range to apply on the cursor.
resultMapper function A function which is repeatedly called with a Cursor. Return the data you want to keep.
Returns:
Resolves to an array of whatever you returned from resultMapper.
Type
Promise.<Array.<T>>

setCryptoStoreFactory(fac)

Source:
Configure a different factory to be used for creating crypto stores
Parameters:
Name Type Description
fac function a function which will return a new module:crypto.store.base~CryptoStore.

setNow(fopt)

Source:
Replace the function used by this module to get the current time. Intended for use by the unit tests.
Parameters:
Name Type Attributes Description
f function <optional>
function which should return a millisecond counter

setProp(obj, keyNesting, val)

Source:
Parameters:
Name Type Description
obj Object
keyNesting string
val *

setTimeout(func, delayMs) → {Number}

Source:
reimplementation of window.setTimeout, which will call the callback if the wallclock time goes past the deadline.
Parameters:
Name Type Description
func function callback to be called after a delay
delayMs Number number of milliseconds to delay by
Returns:
an identifier for this callback, which may be passed into clearTimeout later.
Type
Number

wrapRequest(wrapper)

Source:
Apply wrapping code around the request function. The wrapper function is installed as the new request handler, and when invoked it is passed the previous value, along with the options and callback arguments.
Parameters:
Name Type Description
wrapper requestWrapperFunction The wrapping function.

Type Definitions

EventDecryptionResult

Source:
Properties:
Name Type Attributes Description
clearEvent Object The plaintext payload for the event (typically containing type and content fields).
senderCurve25519Key string <nullable>
Key owned by the sender of this event. See module:models/event.MatrixEvent#getSenderKey.
claimedEd25519Key string <nullable>
ed25519 key claimed by the sender of this event. See module:models/event.MatrixEvent#getClaimedEd25519Key.
forwardingCurve25519KeyChain Array.<string> <nullable>
list of curve25519 keys involved in telling us about the senderCurve25519Key and claimedEd25519Key. See module:models/event.MatrixEvent#getForwardingCurve25519KeyChain.
The result of a (successful) call to decryptEvent.
Type:
  • Object

MakeBeaconInfoContent(timeout, isLiveopt, descriptionopt, assetTypeopt, timestampopt)

Source:
Beacon event helpers
Parameters:
Name Type Attributes Description
timeout number
isLive boolean <optional>
description string <optional>
assetType LocationAssetType <optional>
timestamp number <optional>

MBeaconEventContent

Source:
m.beacon event example https://github.com/matrix-org/matrix-spec-proposals/pull/3489 { "type": "m.beacon", "sender": "@matthew:matrix.org", "content": { "m.relates_to": { // from MSC2674: https://github.com/matrix-org/matrix-doc/pull/2674 "rel_type": "m.reference", // from MSC3267: https://github.com/matrix-org/matrix-doc/pull/3267 "event_id": "$beacon_info" }, "m.location": { "uri": "geo:51.5008,0.1247;u=35", "description": "Arbitrary beacon information" }, "m.ts": 1636829458432, } }
Type:
  • object

MBeaconInfoEventContent

Source:
m.beacon_info Event example from the spec https://github.com/matrix-org/matrix-spec-proposals/pull/3489 { "type": "m.beacon_info.@matthew:matrix.org.1", "state_key": "@matthew:matrix.org", "content": { "m.beacon_info": { "description": "The Matthew Tracker", // same as an `m.location` description "timeout": 86400000, // how long from the last event until we consider the beacon inactive in milliseconds }, "m.ts": 1436829458432, // creation timestamp of the beacon on the client "m.asset": { "type": "m.self" // the type of asset being tracked as per MSC3488 } } }
Type:
  • object

MessageVisibility

Source:
Message hiding, as specified by https://github.com/matrix-org/matrix-doc/pull/3531.
Type:

MLocationEventContent

Source:
The content for an m.location event
Type:
  • object

PushAction

Source:
Properties:
Name Type Description
notify boolean Whether this event should notify the user or not.
tweaks Object How this event should be notified.
Properties
Name Type Description
highlight boolean Whether this event should be highlighted on the UI.
sound boolean Whether this notification should produce a noise.
Type:
  • Object

requestCallback(err, response, body)

Source:
The request callback interface for performing HTTP requests. This matches the API for the request NPM module. The SDK will implement a callback which meets this interface in order to handle the HTTP response.
Parameters:
Name Type Description
err Error The error if one occurred, else falsey.
response Object The HTTP response which consists of {statusCode: {Number}, headers: {Object}}
body Object The parsed HTTP response body.

requestFunction(opts, callback)

Source:
The request function interface for performing HTTP requests. This matches the API for the request NPM module. The SDK will attempt to call this function in order to perform an HTTP request.
Parameters:
Name Type Description
opts Object The options for this HTTP request.
Properties
Name Type Description
uri string The complete URI.
method string The HTTP method.
qs Object The query parameters to append to the URI.
body Object The JSON-serializable object.
json boolean True if this is a JSON request.
_matrix_opts Object The underlying options set for MatrixHttpApi.
callback requestCallback The request callback.

requestWrapperFunction(origRequest, opts, callback)

Source:
A wrapper for the request function interface.
Parameters:
Name Type Description
origRequest requestFunction The underlying request function being wrapped
opts Object The options for this HTTP request, given in the same form as requestFunction.
callback requestCallback The request callback.

Events

"change" whenever the state of the request object has changed.

Source:
State machine for verification requests. Things that differ based on what channel is used to send and receive verification events are put in `InRoomChannel` or `ToDeviceChannel`.