* `matrix-client-crypto.spec.ts` only tested a very specific bit of crypto (olm
encryption). It goes back to the very early days, before Megolm was invented.
I've renamed it to `olm-encryption-spec.ts`.
* `megolm-integ.spec.ts` is more of a general crypto test; it was just called
`megolm` to distinguish it from the Olm tests above. Renamed to
`crypto.spec.ts`.
These are all called by the react-sdk when showing an encrypted event:
* `getEventEncryptionInfo`
* `checkUserTrust`
* `checkDeviceTrust`
I don't particularly want to keep this API, but as a rapid means to an end,
let's stub them for now.
This test seemed to be testing the behaviour of decrypting redacted events, but
that seems... strange. A redaction event cannot be encrypted (at least, there
is no spec for it), and it should be impossible to decrypt a (correctly)
redacted event, because such an event will lack a `ciphertext` property.
This test is just sticking a "redacted_because" property into a regular event,
which is a bit of a nonsense.
NOTE: This commit introduces a backwards-compatible API change.
Adds the ability to cancel `MegolmEncryption#prepareToEncrypt` by returning
a cancellation function. The bulk of the processing happens in
`getDevicesInRoom`, which now accepts a 'getter' that allows the caller to
indicate cancellation.
See https://github.com/matrix-org/matrix-js-sdk/issues/1255Closes#1255
Signed-off-by: Clark Fischer <clark.fischer@gmail.com>
Adds an async/promise-based version of `setImmediate`. Note that, despite being
poorly adopted, `setImmediate` is polyfilled, and should be more performant
than `sleep(0)`.
Signed-off-by: Clark Fischer <clark.fischer@gmail.com>
Adds a log line whenever we save a session and also adds an event
that's fired whenever we get a to-device event we can't decrypt
(hopefully the comment explains all).
The megolm tests were making a few assumptions which they really shouldn't; in
particular:
* They were creating mock events with event_ids not starting `$`, and lacking
`sender`, `origin_server_ts` and `unsigned` properties
* They were not including the (now) required `keys.ed25519` property inside
the ciphertext of an olm message.
These work ok currently, but they aren't really correct, and they cause
problems when testing the new rust implementation.
* Use a PrefixedLogger throughout `megolm.ts`
Rather than manually adding `in ${this.roomId}` to each log line, use a
PrefixedLogger to achieve the same effect more consistently.
* Clean up logging in megolm.ts
Where we log a list of devices, we don't need the whole deviceinfo, just the
device id. All that noise makes it very hard to read the logs.
* Log users that we find in the room when encrypting
* Reduce log verbosity on decryption retries
* Remove extensible events v1 field population on legacy events
With extensible events v2, affected events are now gated by a room version, so we don't need this code anymore.
The proposal has generally moved away from mixing m.room.message with extensible fields as well.
* Run prettier
* Remove unstable identifier from tests too
* Run prettier again