1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00
Commit Graph

313 Commits

Author SHA1 Message Date
Richard van der Hoff
d0e90cd8c9 crypto: use memberlist to derive recipient list
When we send an encrypted message with Olm, we need to know who to send it
to. Currently that is based on a user list passed to setRoomEncryption. We want
to be able to change the list as people join and leave the room; I also want to
not have to keep the member list in local storage.

So, use the member list at the point of enabling encryption to set up sessions,
and at the point of sending a message to encrypt the message.

Further work here includes:

 * updating the react-sdk not to bother setting the member list
 * monitoring for new users/devices in the room, and setting up new sessions
   with them
2016-06-21 17:53:11 +01:00
Richard van der Hoff
7604bcc49a Support for marking devices as unverified
Mostly because it's useful for testing, to be honest.
2016-06-17 16:22:22 +01:00
Richard van der Hoff
2e4a8f4fa5 Change how MatrixEvent manages encrypted events
Make `MatrixEvent.event` contain the *encrypted* event, and keep the plaintext
payload in a separate `_clearEvent` property.

This achieves several aims:

* means that we have a record of the actual object which was received over
  the wire, which can be shown by clients for 'view source'.

* makes sent and received encrypted MatrixEvents more consistent (previously
  sent ones had `encryptedType` and `encryptedContent` properties, whereas
  received ones threw away the ciphertext).

* Avoids having to make two MatrixEvents in the receive path, and copying
  fields from one to the other.

*Hopefully* most clients have followed the advice given in the jsdoc of not
relying on MatrixEvent.event to get at events. If they haven't, I guess they'll
break in the face of encrypted events.

(The pushprocessor didn't follow this advice, so needed some tweaks.)
2016-06-09 18:23:54 +01:00
Richard van der Hoff
ce59b72308 Catch exceptions when encrypting events
If an exception was thrown by the encryption process, the event would be
queued, but the exception would not be handled. This meant that the event got
stuck as a grey 'sending' event in the UI.

Fixing this correctly is slightly more complex than just handling the exception
correctly. A naive approach would mean that the event would be shown as a red
'unsent' message, and clicking 'resend' would then send the message *in the
clear*. Hence, move the encryption to _sendEvent, where it will be called again
when the event is resent.
2016-06-09 17:18:29 +01:00
Richard van der Hoff
4bf24f0fe4 Client: add some logging to help understand what is going on 2016-06-09 17:18:22 +01:00
Richard van der Hoff
0ab3446d81 Emit an event when a device is verified
We will probably want to share device verification across our own devices at
some point, so this will be useful in the future.
2016-06-08 21:22:48 +01:00
Richard van der Hoff
adaf4bf92b Remove spurious TODO
we are doing this a different way
2016-06-08 18:34:15 +01:00
Richard van der Hoff
60519c4e6b client: add isEventSenderVerified()
Add a method which allows applications to check if the sender of an event is on
the list of verified senders.
2016-06-08 17:20:26 +01:00
Richard van der Hoff
21a62f37de Client: mark our own device as verified 2016-06-08 17:20:26 +01:00
Richard van der Hoff
9feeb0c580 Support for marking devices as verified
Add a 'verified' property to the response from MatrixClient.listDeviceKeys, and
add MatrixClient.setDeviceVerified to set it. Also changes the format of data
stored for user devices in the session store slightly (in a
backwards-compatible way).
2016-06-08 17:20:26 +01:00
Richard van der Hoff
7c3104b2ae client: fix bug marking all sent events as encrypted 2016-06-08 17:19:04 +01:00
Richard van der Hoff
9c47400a0c client: Document the type of the sessionStore 2016-06-07 23:44:12 +01:00
Richard van der Hoff
8c6e2591d9 Factor out OlmDevice from client.js
MatrixClient contains quite a lot of boilerplate for manipulating the Olm
things, which quite nicely factors out to a separate object.
2016-06-07 19:09:47 +01:00
Richard van der Hoff
17ec7daf23 MatrixClient: refactor uploadKeys
rewrite uploadKeys to require less looping and not to use deferreds.
2016-06-07 19:09:47 +01:00
Richard van der Hoff
b18a4ee16b client.js: Fix error handling in downloadKeys
Fix a bug in the error handling in downloadKeys: If the http request failed,
then the exception would get silently swallowed and the promise would never
resolve.

Also: tests!
2016-06-07 17:26:56 +01:00
Matthew Hodgson
0421e69f14 revert brand param at reg time 2016-06-02 12:33:09 +01:00
Matthew Hodgson
8b35ddae0a add 'brand' parameter to register() 2016-06-02 11:46:02 +01:00
David Baker
06486f7ad0 Fix c+p fails 2016-05-06 14:28:26 +01:00
David Baker
a9d8c58ea0 Add support for the openid interface 2016-05-06 13:58:10 +01:00
Richard van der Hoff
d87e5471fa Refactor the addition of events to rooms
... and add some sanity checks

Two things here:

1. Clean up the Room API for adding new events to the timeline. Where before
we had addEvents and addEventsToTimeline, whose purposes were unclear, we now
have addLiveEvents which must be used for adding events to the end of the live
timeline, and addEventsToTimeline which should be used for pagination (either
back-pagination of the live timeline, or pagination of an old timeline).

2. Add some sanity checks for the live timeline. Today we have seen problems
where somehow the live timeline had gained a forward pagination token, or the
live timeline had got joined to another timeline, leading to much confusion -
and I would like to notice these sooner.
2016-04-14 17:03:25 +01:00
Richard van der Hoff
950fce80c8 Whitespace fix
remove trailing ws
2016-04-14 16:09:51 +01:00
David Baker
dbc3a9a500 Merge pull request #125 from matrix-org/dbkr/get_pushers
Add methods to get (and set) pushers
2016-04-12 13:25:17 +01:00
David Baker
cff7c8a59f Add methods to get (and set) pushers 2016-04-12 13:11:00 +01:00
Matthew Hodgson
11e4760935 improve commentary 2016-04-08 22:00:07 +01:00
Matthew Hodgson
c469ff4c8d oops, fix sig 2016-04-03 01:19:34 +01:00
Matthew Hodgson
c7575f3f16 cache url preview results 2016-04-03 01:18:01 +01:00
Matthew Hodgson
415251dd70 WIP url previewing 2016-03-31 18:38:34 +01:00
Matthew Hodgson
e1415d9829 Merge pull request #117 from matrix-org/matthew/roomlist
get/setRoomVisibility API
2016-03-22 12:30:18 +00:00
Richard van der Hoff
19a12b3c79 Merge pull request #115 from matrix-org/rav/txnid_clashes
Include a counter in generated transaction IDs
2016-03-22 12:20:02 +00:00
Matthew Hodgson
bec41e4f94 incorporate review 2016-03-22 10:20:02 +00:00
Matthew Hodgson
5f177aeec4 get/setRoomVisibility API 2016-03-22 00:55:53 +00:00
Matthew Hodgson
fba4d5fb0a Merge pull request #114 from matrix-org/matthew/stop-peeking
API to stop peeking
2016-03-21 16:12:29 +00:00
Richard van der Hoff
dfc4b34d09 Include a counter in generated transaction IDs
Fixes a flaky test which sometimes failed due to sending two events in the same
millisecond.
2016-03-18 21:32:15 +00:00
Richard van der Hoff
ad9daecbd4 Pass the right options into SyncApi when peeking
When we peek into a room, we create its Room object. We need to make sure it is
created with the same options as we would if it were created via the /sync
calls.

Save the options passed in when startClient is called, and then pass them into
the SyncApi each time we create it.
2016-03-18 20:59:23 +00:00
Matthew Hodgson
d29302716d oops 2016-03-18 19:25:22 +00:00
Matthew Hodgson
6c7d13f8ce API to stop peeking 2016-03-18 19:22:34 +00:00
Richard van der Hoff
e15a2d138c Merge pull request #112 from matrix-org/rav/cancel_send
Support for cancelling pending events
2016-03-18 16:17:44 +00:00
Richard van der Hoff
8bc9c19278 Merge pull request #111 from matrix-org/rav/pending_event_list
Implement 'pendingEventList'
2016-03-18 16:17:30 +00:00
David Baker
ba1991aa8f Add more docs :) 2016-03-18 15:54:19 +00:00
David Baker
f4fd8d9ba6 Add a method to the js sdk to look up 3pids on the ID server. 2016-03-18 15:15:10 +00:00
Richard van der Hoff
02be0f659a Support for cancelling pending events
Implement client.cancelPendingEvent which will cancel queued or not_sent events
2016-03-17 22:15:46 +00:00
Richard van der Hoff
55d8f56f98 update docs 2016-03-17 17:53:20 +00:00
Richard van der Hoff
3c6bd4774d Refactor transmitted-messages code
This is some preparatory work for fixing up the problems with te timeline
ordering of unsent messages
(https://github.com/vector-im/vector-web/issues/1120). The functional changes
here should be minimal (bar an extra `Room.localEchoUpdated` when the local
echo is first added to the timeline).

Give `MatrixClient.sendEvent` its own entry point `Room.addPendingMessage`
instead of pushing it through `addEventsToTimeline`; this considerably
simplifies the implementation of the latter and also means that we can contain
the `_txnId` ming to MatrixClient.

Move the code which deals with a successful `/send` response from
`MatrixClient` into `Room.updatePendingEvent`, since it involves fiddling with
the innards of the Room.

Also adds a new EventStatus 'SENT' for events which have been successfully sent
but whose remote echo we still haven't received.
2016-03-17 14:26:36 +00:00
David Baker
6f7ed93b87 Merge pull request #100 from matrix-org/dbkr/session_logged_out
Add Session.logged_out event
2016-03-16 10:44:01 +00:00
Richard van der Hoff
07bbe358ea Clean up a codepath that was only used for crypto messages
Transmission of encrypted messages was happening somewhat differently to
normal messages. In particular, we weren't copying the 'unsigned' field when we
got the remote-echo, which meant the 'sync' code didn't correctly match up the
echo with the original.

The separate codepath was becoming a thorn in my side, so fix things up to
bring it back in line.
2016-03-15 15:07:26 +00:00
David Baker
5833654aa6 Add Session.logged_out event that fires whenever the current session is no longer valid and the user needs to log in again. Also null check _syncApi before trying to stop it. 2016-03-15 10:45:08 +00:00
Richard van der Hoff
4ae353d3d3 Raise localEchoUpdated events in more places
We need to know about more transitions for local-echo status changes, so raise
localEchoUpdated events for each transition.

Fixes an issue where we weren't turning failed transmissions red, because the
timeline wasn't being updated.
2016-03-10 12:07:27 +00:00
Mark Haines
066dd77aba Add setPushRuleActions method for setting the actions for push notification rules 2016-02-26 16:47:22 +00:00
David Baker
567716c4f7 Use more normal promise structure 2016-02-23 11:21:29 +00:00
David Baker
518e41c078 add docs 2016-02-23 11:08:07 +00:00