Classes
Members
# isReady
Whether or not the crypto client is ready to be used. If not ready, prepare() should be called.
- See:
-
- prepare
Methods
# async decryptMedia(file) → {Promise.<Buffer>}
Decrypts a previously-uploaded encrypted file, validating the fields along the way.
Parameters:
Name | Type | Description |
---|---|---|
file |
EncryptedFile
|
The file to decrypt. |
Resolves to the decrypted file contents.
Promise.<Buffer>
# async decryptRoomEvent(event, roomId) → {Promise.<RoomEvent.<unknown>>}
Decrypts a room event. Currently only supports Megolm-encrypted events (default for this SDK).
Parameters:
Name | Type | Description |
---|---|---|
event |
EncryptedRoomEvent
|
The encrypted event. |
roomId |
string
|
The room ID where the event was sent. |
Resolves to a decrypted room event, or rejects/throws with
an error if the event is undecryptable.
Promise.<RoomEvent.<unknown>>
# async encryptMedia(file) → {Object}
Encrypts a file for uploading in a room, returning the encrypted data and information
to include in a message event (except media URL) for sending.
Parameters:
Name | Type | Description |
---|---|---|
file |
Buffer
|
The file to encrypt. |
Resolves to the encrypted
contents and file information.
Object
# async encryptRoomEvent(roomId, eventType, content) → {Promise.<IMegolmEncrypted>}
Encrypts the details of a room event, returning an encrypted payload to be sent in an
`m.room.encrypted` event to the room. If needed, this function will send decryption keys
to the appropriate devices in the room (this happens when the Megolm session rotates or
gets created).
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string
|
The room ID to encrypt within. If the room is not encrypted, an error is thrown. |
eventType |
string
|
The event type being encrypted. |
content |
any
|
The event content being encrypted. |
Resolves to the encrypted content for an `m.room.encrypted` event.
Promise.<IMegolmEncrypted>
# isReady() → {boolean}
Whether or not the crypto client is ready to be used. If not ready, prepare() should be called.
- See:
-
- prepare
boolean
# async isRoomEncrypted(roomId) → {Promise.<boolean>}
Checks if a room is encrypted.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string
|
The room ID to check. |
Resolves to true if encrypted, false otherwise.
Promise.<boolean>
# async onRoomEvent(roomId, event)
Handles a room event.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
The room ID. | |
event |
The event. |
# async onRoomJoin(roomId)
Handles a room join.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
The room ID. |
# async prepare(roomIds)
Prepares the crypto client for usage.
Parameters:
Name | Type | Description |
---|---|---|
roomIds |
Array.<string>
|
The room IDs the MatrixClient is joined to. |
# async sign(obj) → {Promise.<Signatures>}
Signs an object using the device keys.
Parameters:
Name | Type | Description |
---|---|---|
obj |
object
|
The object to sign. |
The signatures for the object.
Promise.<Signatures>
# async updateSyncData(toDeviceMessages, otkCounts, unusedFallbackKeyAlgs, changedDeviceLists, leftDeviceLists) → {Promise.<void>}
Updates the client's sync-related data.
Parameters:
Name | Type | Description |
---|---|---|
toDeviceMessages |
Array.<IToDeviceMessage.<IOlmEncrypted>>
|
The to-device messages received. |
otkCounts |
OTKCounts
|
The current OTK counts. |
unusedFallbackKeyAlgs |
Array.<OTKAlgorithm>
|
The unused fallback key algorithms. |
changedDeviceLists |
Array.<string>
|
The user IDs which had device list changes. |
leftDeviceLists |
Array.<string>
|
The user IDs which the server believes we no longer need to track. |
Resolves when complete.
Promise.<void>