-
-
Notifications
You must be signed in to change notification settings - Fork 591
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
Update to WebAssembly-powered Olm #743
Conversation
wasm Olm has a new interface: it now has an init method that needs to be called and the promise it returns waited on before the Olm module is used. Support that, and allow Crypto etc to be imported whether Olm is enabled or not. Change whether olm is enabled to be async since now it will be unavailable if the async module init fails. Don't call getOlmVersion() until the Olm.init() is done.
looks plausible to me :) |
By doing `Olm = global.Olm` on script load, we require that Olm is available right from the start, which isn't really necessary. As long as it appears some time before we actually want to use it, this is fine (we can probably assume it's not going to go away again..?) This means Riot doesn't need to faff about making sure olm is loaded before starting anything else.
spec/unit/crypto.spec.js
Outdated
it("Crypto exposes the correct olm library version", function() { | ||
console.log(Crypto); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debugging line should be taken out
spec/unit/crypto.spec.js
Outdated
it("Crypto exposes the correct olm library version", function() { | ||
console.log(Crypto); | ||
expect(Crypto.getOlmVersion()[0]).toEqual(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will need to s/2/3/
since we'll need to bump the major version for olm due to backward incompatible API changes
@@ -124,6 +128,8 @@ utils.inherits(Crypto, EventEmitter); | |||
* Returns a promise which resolves once the crypto module is ready for use. | |||
*/ | |||
Crypto.prototype.init = async function() { | |||
await global.Olm.init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we wrapped this in an if (global.Olm.init)
, would everything still work with older versions of Olm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm - probably. Not sure whether or not its worth trying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test failures are probably because the CI image needs to be updated with the newer olm (which may cause every other PR to fail, until they all get updated.)
Requires https://github.com/matrix-org/olm-backup/pull/57 to be released (after which we can bump the Olm version here)
Mostly this just changes over to use the aync init of olm.