Commit graph

57 commits

Author SHA1 Message Date
Lilia
52cc8355a6 Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler

* Rename the delivery receipt event

For less ambiguity with read receipts.

* Rename synced read event

For less ambiguity with read receipts from other Signal users.

* Add support for incoming receipt messages

Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.

// FREEBIE

* Rename ReadReceipts to ReadSyncs

* Render read messages with blue double checks

* Send read receipts to senders of incoming messages

// FREEBIE

* Move ReadSyncs to their own file

// FREEBIE

* Fixup old comments on read receipts (now read syncs)

And some variable renaming for extra clarity.

// FREEBIE

* Add global setting for read receipts

Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.

// FREEBIE

* Sync read receipt setting from mobile

Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.

// FREEBIE

* Send receipt messages silently

Avoid generating phantom messages on ios

// FREEBIE

* Save recipients on the outgoing message models

For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.

// FREEBIE

* Fix conversation type in profile key update handling

// FREEBIE

* Set recipients on synced sent messages

* Render saved recipients in message detail if available

For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.

// FREEBIE

* Record who has been successfully sent to

// FREEBIE

* Record who a message has been delivered to

* Invert the not-clickable class

* Fix readReceipt setting sync when linking

* Render per recipient sent/delivered/read status

In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.

*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.

// FREEBIE

* Add configuration sync request

Send these requests in a one-off fashion when:
  1. We have just setup from a chrome app import
  2. We have just upgraded to read-receipt support

// FREEBIE

* Expose sendRequestConfigurationSyncMessage

// FREEBIE

* Fix handling of incoming delivery receipts - union with array

FREEBIE
2017-10-04 15:28:43 -07:00
Lilia
fc952fbaf6
Handle provisioning messages with no profile key (#1470)
This can happen while linking to an older mobile client.

// FREEBIE
2017-09-14 17:04:03 -07:00
Lilia
ae190fed44
Profiles (#1453)
* Add AES-GCM encryption for profiles

With tests.

* Add profileKey to DataMessage protobuf

// FREEBIE

* Decrypt and save profile names

// FREEBIE

* Save incoming profile keys

* Move pad/unpad to crypto module

// FREEBIE

* Support fetching avatars from the cdn

// FREEBIE

* Translate failed authentication errors

When AES-GCM authentication fails, webcrypto returns a very generic error. The
same error is thrown for invalid length inputs, but our earlier checks in
decryptProfile should rule out those failure modes and leave us safe to assume
that we either had bad ciphertext or the wrong key.

// FREEBIE

* Handle profile avatars (wip) and log decrypt errors

// FREEBIE

* Display profile avatars

Synced contact avatars will still override profile avatars.

* Display profile names in convo list

Only if we don't have a synced contact name.

// FREEBIE

* Make cdn url an environment config

Use different ones for staging and production

// FREEBIE

* Display profile name in conversation header

* Display profile name in group messages

* Update conversation header if profile avatar changes

// FREEBIE

* Style profile names small with ~

* Save profileKeys from contact sync messages

// FREEBIE

* Save profile keys from provisioning messages

For standalone accounts, generate a random profile key.

// FREEBIE

* Special case for one-time sync of our profile key

Android will use a contact sync message to sync a profile key from Android
clients who have just upgraded and generated their profile key. Normally we
should receive this data in a provisioning message.

// FREEBIE

* Infer profile sharing from synced data messages

* Populate profile keys on outgoing messages

Requires that `profileSharing` be set on the conversation.

// FREEBIE

* Support for the profile key update flag

When receiving a message with this flag, don't init a message record, just
process the profile key and move on.

// FREEBIE

* Display profile names in group member list

* Refresh contact's profile on profile key changes

// FREEBIE

* Catch errors on profile save

// FREEBIE

* Save our own synced contact info

Don't return early if we get a contact sync for our own number

// FREEBIE
2017-09-14 17:04:00 -07:00
Lilia
50c470e53d
Certificate pinning via node XMLHttpRequest implementation (#1394)
* Add certificate pinning on https service requests

Make https requests to the server using node apis instead of browser apis, so we
can specify our own CA list, which contains only our own CA.

This protects us from MITM by a rogue CA.

As a bonus, this let's us drop the use of non-standard ports and just use good
ol' default 443 all the time, at least for http requests.

// FREEBIE

* Make certificateAuthorities an option on requests

Modify node-based xhr implementation based on driverdan/node-XMLHttpRequest,
adding support for setting certificate authorities on each request.

This allows us to pin our master CA for requests to the server and cdn but not
to the s3 attachment server, for instance. Also fix an exception when sending
binary data in a request: it is submitted as an array buffer, and must be
converted to a node Buffer since we are now using a node based request api.

// FREEBIE

* Import node-based xhr implementation

Add a copy of https://github.com/driverdan/node-XMLHttpRequest@86ff70e, and
expose it to the renderer in the preload script.

In later commits this module will be extended to support custom certificate
authorities.

// FREEBIE

* Support "arraybuffer" responseType on requests

When fetching attachments, we want the result as binary data rather than a utf8
string. This lets our node-based XMLHttpRequest honor the responseType property
if it is set on the xhr.

Note that naively using the raw `.buffer` from a node Buffer won't work, since
it is a reuseable backing buffer that is often much larger than the actual
content defined by the Buffer's offset and length.

Instead, we'll prepare a return buffer based on the response's content length
header, and incrementally write chunks of data into it as they arrive.

// FREEBIE

* Switch to self-signed server endpoint

* Log more error info on failed requests

With the node-based xhr, relevant error info are stored in statusText and
responseText when a request fails.

// FREEBIE

* Add node-based websocket w/ support for custom CA

// FREEBIE

* Support handling array buffers instead of blobs

Our node-based websocket calls onmessage with an arraybuffer instead of a blob.
For robustness (on the off chance we switch or update the socket implementation
agian) I've kept the machinery for converting blobs to array buffers.

// FREEBIE

* Destroy all wacky server ports

// FREEBIE
2017-09-14 17:03:17 -07:00
Scott Nonnenberg
9db0a58260 Whenever adding something to a queue, include a timeout
No more wedged queues!

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
4a1dc46ab3 Fixes to get local verification and sync messages working
FREEBIE
2017-08-04 12:03:25 -07:00
lilia
261ec003ee Account manager calls saveIdentityWithAtttributes
saveIdentityWithAtttributes allows directly setting all properties of an
identity key record. In AccountManager we use it to save our own identity
key after a new registration.

Previously we would remove the existing key first in order to coerce firstUse to
true, but now we can simply set it explicitly, along with a VERIFIED status.

// FREEBIE
2017-08-04 12:03:25 -07:00
lilia
4e4aedd4ba Pass in non/blockingApproval args to saveIdentity
Multiple cases here:
1. setting our own key on registration
1. changing identities from a safety number change dialog

Note that removeIdentityKey runs before saveIdentity, so we'll always end up
with firstUse: true on our own key.

// FREEBIE
2017-08-04 12:03:25 -07:00
lilia
dcfc4701c2 Tweak socket event logging 2017-04-13 13:15:42 -07:00
lilia
e1662f8537 Drop unneeded binds
There are no references to `this` in these functions.

// FREEBIE
2017-02-22 01:17:21 -08:00
lilia
7cbaac5590 Provisioning socket events don't block AccountManager tasks
// FREEBIE
2017-02-22 01:17:21 -08:00
lilia
38a830c561 Fixup account manager task queue
Such that it still pumps tasks if one of them throws/rejects.

// FREEBIE
2017-02-22 01:17:20 -08:00
lilia
b92dd45a22 Add signed key rotation and deletion routines
// FREEBIE
2017-02-16 18:06:19 -08:00
lilia
dfc292ac70 Serialize prekey refreshes & other account mgmt
Fixes #1060

// FREEBIE
2017-02-14 15:24:09 -08:00
lilia
7e06e014c4 Add debug logging for #1030
// FREEBIE
2017-02-03 21:28:01 -08:00
lilia
7b3b01bdf6 Refactor registration event
Make AccountManager into an event target for better separation between
app and service-library handling of registration events.
2016-09-20 13:42:33 -07:00
lilia
b1afb79a14 Set theme based on master device userAgent
// FREEBIE
2016-09-15 16:28:46 -07:00
lilia
0487fa3cd1 Add server fallback port 8443
// FREEBIE
2016-09-08 14:31:19 -07:00
lilia
f8e176fd40 Dedupe methods
Define textsecure.crypto in terms of libsignal.crypto.

// FREEBIE
2016-05-18 13:15:57 -07:00
lilia
148bd32671 Update libsignal-protocol v0.10.0
* Changes policy for old session deletion
* Renames putIdentityKey to saveIdentity
* Remove device messages

// FREEBIE
2016-05-18 11:11:11 -07:00
lilia
ffa702c934 Update libsignal-protocol v0.9.0
* Exposes crypto APIs.
* Move worker methods to libsigna.worker.
* Move ProvisioningCipher to libtextsecure.
2016-05-17 12:03:37 -07:00
lilia
92293f9da9 Update libsignal-protocol v0.5.0
Renames libsignal.util to libsignal.KeyHelper.

// FREEBIE
2016-05-13 19:47:39 -07:00
lilia
9a1a3bdf64 Rename axolotl to libsignal
// FREEBIE
2016-04-22 13:43:30 -07:00
lilia
1d60dc38fb Rename axolotl storage
// FREEBIE
2016-04-22 13:43:30 -07:00
lilia
1fe5d63015 Update protocol libs
Rename storage functions

// FREEBIE
2016-04-21 18:36:16 -07:00
lilia
960519d296 Add debug logging
// FREEBIE
2016-03-29 12:35:37 -07:00
lilia
a9cba1471a Update our own key on re-install
Previously we would delete our own key from the trust store when
re-linking, in case it changed. We can also immediately take one step
further and store the new key. Typically this happens in the course of
requesting sync info from the master device, except in the case of
standalone clients.

Closes #596

// FREEBIE
2016-01-21 19:25:55 -08:00
lilia
cf85c5e25e Fix key conflict with self after master device re-install
Fix bug where re-installing would cause sync messages to fail and
produce unresolvable error indicators on messages that were actually
sent.

// FREEBIE
2015-11-24 16:20:07 -08:00
lilia
80d32103d1 Clear session store when re-registering
When we re-register, our deviceId might change, which makes our sessions
are no longer valid since the recipient will see us as a new device.

Fixes #388
2015-11-04 13:52:47 -08:00
lilia
9b12d8a978 Reconnect provisioning socket
If the provisioning socket closes, reconnect and generate a new qr code.
Fixes #371

// FREEBIE
2015-10-23 18:33:07 -07:00
lilia
1aee065c2c Fix registration
Previously would fail to register keys by using the wrong username.
The username should be <number>.<deviceid> once we've confirmed our
account and received a deviceId from the server.

// FREEBIE
2015-10-01 20:43:30 -07:00
lilia
9de23a967b Fix dropping the first websocket message 2015-10-01 18:33:49 -07:00
lilia
3fcd980c23 Add websocket error and close event handlers 2015-10-01 18:33:49 -07:00
lilia
98aa5156b0 Refactor TextSecureServer for storage
Following the pattern from previous commit, let the server class accept
a url and login credentials from the caller. Then integrate into
MessageReceiver and AccountManager.

// FREEBIE
2015-10-01 18:33:48 -07:00
lilia
c8e51563a0 Refactor initial sync codepath to application layer
To reduce dependence on the message sending module, AccountManager
should send no sync requests itself.
2015-09-24 10:38:58 -07:00
lilia
f764445c86 Remove erroneous license file and headers
We only use GPLV3 around here.

// FREEBIE
2015-09-07 14:58:42 -07:00
lilia
0b98043c1c Add a worker
Offload all the asm.js code to a second thread. This is usually the
source of intermittent frontend freezes when running single-threaded.
2015-08-26 16:09:58 -07:00
lilia
4fc4573de4 Don't try to sync after single device registration
There's no other device to sync to. :p
2015-07-31 11:11:23 -07:00
lilia
b3d93ab334 Request group sync when pairing
Whoops, missed a step. Fixes #319. Fixes #276.

// FREEBIE
2015-07-29 19:06:19 -07:00
lilia
56b6375f97 Use new provisioning socket keepalive path
This new endpoint should always issue a response to a provisioning
socket so if we don't receive one we should assume the connection has
been lost.

Closes #318
2015-07-29 13:37:17 -07:00
lilia
1a06cb5cbe Update consumers of WebsocketResources 2015-07-28 14:58:55 -07:00
lilia
cd363bd84d Integrate keepalives into websocket resources 2015-07-28 13:07:34 -07:00
lilia
7d2b41db11 Add auto-disconnect config to keepalive constructor
Disconnects on no keepalive response by default.

// FREEBIE
2015-07-27 20:17:00 -07:00
lilia
d9fe783488 Accept close code/message via websocket/resources 2015-07-27 19:30:51 -07:00
lilia
8170a7baae WebSocketResource exposes socket.close()
Allows for simplification of the keepalive construct.
2015-07-27 18:51:48 -07:00
lilia
d9d4e281cc Keepalive provisioning socket
Fixes #315

// FREEBIE
2015-07-27 18:16:47 -07:00
lilia
f8ae5556d9 Fix standalone registration 2015-07-06 12:45:09 -07:00
lilia
4c40861728 Fix reinstalls
Delay saving of new account info until we confirm with the server.
Explicitly delete old account info beforehand.

// FREEBIE
2015-06-25 13:24:32 -07:00
lilia
5925c2fe84 Support for group sync
Protocol and handling is all analogous to contact sync: Multiple
GroupDetails structs are packed into a single attachment blob and parsed
on our end. We don't display the synced groups in the conversation list
until a new message is sent to one of them.

// FREEBIE
2015-06-25 13:24:32 -07:00
lilia
2f935dfd5e Add contact sync request protocol 2015-06-25 13:24:31 -07:00