... instead of having it call event.setClearData.
The main advantage of this is that it fixes a race condition, wherein apps
could see `event.isDecrypting()` to be true, but in fact the event had been
decrypted (and there was no `Event.decrypted` event on its way).
We're also fixing another race, wherein if the first attempt to decrypt failed,
a call to `attemptDecryption` would race against the first call and a second
attempt to decrypt would never happen.
This also gives a cleaner interface to MatrixEvent, at the expense of making
the `megolm` unit test a bit more hoop-jumpy.
Convert base to an es6 module with es6 classes, for clarity and to help with
jsdoccing.
Complications are:
* jsdoc gets confused by `export class`, so the exports are separated.
* turns out that extending Error is a bit difficult, so instanceof doesn't work
on derived Error classes. This only really affects us in one place (app-side
code shouldn't be doing instanceofs anyway), so just use `name` instead.
In an attempt to make the rageshake logs a bit more useful, try to make the
logging a bit saner. Firstly, make sure we log every decryption failure, and
log it exactly once, rather than in several places. Also record when we receive
megolm keys. Also add some more explicit logging in the sync loop.