-
Notifications
You must be signed in to change notification settings - Fork 79
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
https://turt2live.github.io/matrix-bot-sdk/tutorial-encryption-bots.html
can't get this example to work - getting error "Error: Can't find the room key to decrypt the event" for every new message in the room.
To Reproduce
Steps to reproduce the behavior:
npm install @matrix-org/olm matrix-js-sdk matrix-bot-sdk
- Have an encrypted private room
- Write down its ID
- Create a bot account
- Make sure that it hasn't any superfluous devices and E2E keys
- Log bot in to get an access token:
import * as sdk from "matrix-js-sdk"; const client = sdk.createClient({ baseUrl: "https://matrix.example.com", deviceId: 'YOURDEVICE', }); const loginResponse = await client.loginRequest({ type: "m.login.password", user: "@bot:example.com", password: "botSecurePassword", device_id: 'YOURDEVICE', }); console.log("Access Token:", loginResponse.access_token);
- Invite the bot to the room via Element
/invite @bot:example.com
- Accept invitation for bot (use any script applicable)
- Run a script from the example via
node
import * as sdk from "matrix-bot-sdk"; const homeserverUrl = "https://matrix.example.com"; const botAccessToken = "syt_..."; const storageProvider = new sdk.SimpleFsStorageProvider("./bot-storage/bot.json"); const cryptoProvider = new sdk.RustSdkCryptoStorageProvider("./bot-storage/crypto"); const client = new sdk.MatrixClient(homeserverUrl, botAccessToken, storageProvider, cryptoProvider); client.on("room.message", (roomId, event) => { if (!event['content']?.['msgtype']) return; console.log(event); }); client.start().then(() => console.log("Bot started!"));
- Send some messages from Element to the room
- See console
Expected behavior
console.log(event)
producing something meaningful.
Log snippet
(node:261538) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
MatrixHttpClient (REQ-2) { errcode: 'M_NOT_FOUND', error: 'Account data not found' }
MatrixClientLite End-to-end encryption enabled
Bot started!
MatrixClientLite Decryption error on !OktwJGBgCDQnsIALCM:example.com $LTGPVbZDtDvILZOGj4shj3Wu7RD63Vp2Cpz4HutAEt4 [Error: Can't find the room key to decrypt the event] {
code: 'GenericFailure'
}
MatrixClientLite Decryption error on !OktwJGBgCDQnsIALCM:example.com $9TZZVw_pLPGgZ2PaVCMxJhFiV2ot9srYJhuRk5-RYug [Error: Can't find the room key to decrypt the event] {
code: 'GenericFailure'
}
thememika
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working