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 confirmIdentityWithRecoveryKey(key) → {Promise.<void>}
Confirm's the bot's identity by using a recovery key or passphrase.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
The recovery key or passphrase. |
Promise.<void>
# async createIdentity(key)
Creates the bot's cryptographic identity.
Note: only works if the bot does not have an existing cryptographic
identity, since this doesn't yet perform user interactive auth.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
The recovery key or passphrase. If omitted, a new recovery key will be created and set as the default recovery key. |
The recovery key.
# 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 enableKeyBackup(info) → {Promise.<void>}
Enable backing up of room keys.
Parameters:
| Name | Type | Description |
|---|---|---|
info |
IKeyBackupInfoRetrieved
|
The configuration for key backup behaviour, as returned by MatrixClient#getKeyBackupVersion. |
Resolves once backups have been enabled.
Promise.<void>
# 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>
# async exportRoomKeysForSession(roomId, sessionId)
Exports a set of keys for a given session.
Parameters:
| Name | Type | Description |
|---|---|---|
roomId |
The room ID for the session. | |
sessionId |
The session ID. |
An array of session keys.
# async getDefaultSecretStorageKey(key)
Create a `SecretStorageKey` from the given key, assuming it is the default
secret storage key.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
The recovery key or passphrase. |
The `SecretStorageKey`.
# isReady() → {boolean}
Whether or not the crypto client is ready to be used. If not ready, prepare() should be called.
- See:
-
- prepare
boolean
# async isRecoveryAvailable()
Has recovery been set up on this account.
Checks whether the account has a default Secret Storage key set up, and
has the cross-signing keys stored in Secret Storage. It does not check
the validity of the stored keys.
Whether recovery has been set up on this account.
# 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) → {Promise.<void>}
Handles a room event.
Parameters:
| Name | Type | Description |
|---|---|---|
roomId |
The room ID. | |
event |
The event. |
Promise.<void>
# 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>