Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pcherm opened this issue Jan 27, 2025 · 5 comments
Labels
A-Element-R Issues affecting the port of Element's crypto layer to Rust

Comments

@pcherm
Copy link

pcherm commented Jan 27, 2025

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:
└─┬ matrix-js-sdk@36.0.0
└── @matrix-org/matrix-sdk-crypto-wasm@12.1.0

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.

@dosubot dosubot bot added the A-Element-R Issues affecting the port of Element's crypto layer to Rust label Jan 27, 2025
@pcherm pcherm changed the title Getting error when calling client.initRustCrypto() (Node) Getting error when calling client.initRustCrypto() (Node) Jan 27, 2025
@richvdh
Copy link
Member

richvdh commented Jan 27, 2025

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

@pcherm
Copy link
Author

pcherm commented Jan 27, 2025

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.

@pcherm
Copy link
Author

pcherm commented Jan 28, 2025

@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?

@richvdh
Copy link
Member

richvdh commented Jan 28, 2025

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

@richvdh richvdh changed the title Getting error when calling client.initRustCrypto() (Node) @matrix-org/matrix-sdk-crypto-wasm' does not provide an export named 'CollectStrategy' when calling client.initRustCrypto() (Node) Jan 28, 2025
@ajbura
Copy link
Contributor

ajbura commented Feb 1, 2025

installing v35.0.0 will fix it until the update arrives

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Element-R Issues affecting the port of Element's crypto layer to Rust
Projects
None yet
Development

No branches or pull requests

3 participants