This will allow the key backup flow to propagate errors for things like version
mismatches more easily.
In addition, it raises the limit of keys sent per request from 10 to 200 to cut
down on the number of requests.
* Start a new Olm sessions with a device when we get an undecryptable
message on it.
* Send a dummy message on that sessions such that the other end knows
about it.
* Re-send any outstanding keyshare requests for that device.
Also includes a unit test for megolm that isn't very related but came
out as a result anyway.
Includes https://github.com/matrix-org/matrix-js-sdk/pull/776
Fixes https://github.com/vector-im/riot-web/issues/3822
* Don't _maybeSendKeyBackup() as soon as we enable them: we shouldn't
have anything to send anyway until we mark all sessions for backup,
which we do just afterwards, so leave that to trigger the upload
(otherwise the uploading triggered by backupAll just returns
straight away because a backup is already in progress).
* Pass delay & retry params to _maybeSendKeyBackup(): we want the
all-key upload to happen straight away so pass in delay=0, and
we also don't want to retry on a timer if the the user is waiting.
* If we fail due to an HTTP 400 or similar, don't swallow the error.
* Use the right indexeddb store
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.
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.
we were only bailing out when receiving a non JSON-identical m.room.encryption event.
When receiving an identical event, the algorithm in _roomEncryptors would be reset,
generating a new megolm session every time this happens (there is a LL synapse bug
where this happens on every sync).
As the _roomList is backed by indexeddb you might already have a config without the algorithm being present though,
so we first check for the room encryptor algorithm being present. If so, always bail out as setRoomEncryption was
already called for the given room.
If no algorithm is present, still check if the config is not being changed.
Also setup the roomlist and room encryption synchronously before awaiting
the indexeddb operation to store the room encryption config in roomlist.