matrix-js-sdk icon indicating copy to clipboard operation
matrix-js-sdk copied to clipboard

`@matrix-org/matrix-sdk-crypto-wasm' does not provide an export named 'CollectStrategy'` when calling `client.initRustCrypto()` (Node)

Open chermme opened this issue 11 months ago • 5 comments

Hello, I'm trying to write a Matrix bot in Node. I've got everything working, except the encryption. I followed the docs, but when I'm trying to call client.initRustCrypto(), I'm getting the following error in the console:

file:///Users/petercherm/Git/pcherm/matrix-securityspy-bot/node_modules/matrix-js-sdk/lib/rust-crypto/RoomEncryptor.js:20
import { CollectStrategy, EncryptionAlgorithm, EncryptionSettings, HistoryVisibility as RustHistoryVisibility, RoomId, UserId } from "@matrix-org/matrix-sdk-crypto-wasm";
         ^^^^^^^^^^^^^^^
SyntaxError: The requested module '@matrix-org/matrix-sdk-crypto-wasm' does not provide an export named 'CollectStrategy'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:180:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:263:5)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)

I've got type: module in my package.json and also the following options in my tsconfig.json:

"target": "es2022"
"module": "NodeNext"
"moduleResolution": "nodenext"

I tried adding --experimental-wasm-modules --conditions=wasm-esm flags to node, but to no avail 😕

npm list matrix-js-sdk @matrix-org/matrix-sdk-crypto-wasm reports the following versions: └─┬ [email protected] └── @matrix-org/[email protected]

which I think is correct. I'm on Node v22.13.0

Does anyone have any idea why I might be getting that error?

Many thanks in advance. Peter.

chermme avatar Jan 27 '25 14:01 chermme

This sounds like the sort of thing that might have been fixed by https://github.com/matrix-org/matrix-rust-sdk-crypto-wasm/pull/189, which is, unfortunately, as yet unreleased

richvdh avatar Jan 27 '25 15:01 richvdh

Many thanks for your reply @richvdh. At least it's merged, so there's hope 😉

For the time being, I'll try implementing the legacy encryption.

chermme avatar Jan 27 '25 15:01 chermme

@richvdh out of curiosity, will you be releasing that change in v12 or v13 of @matrix-org/matrix-sdk-crypto-wasm?. If the latter, when do you think you'll be upgrading matrix-js-sdk to use v13?

chermme avatar Jan 28 '25 09:01 chermme

v13, I should think. And, er, sometime in the next couple of weeks, I should think

richvdh avatar Jan 28 '25 10:01 richvdh

installing v35.0.0 will fix it until the update arrives

ajbura avatar Feb 01 '25 11:02 ajbura