Commit-Graf

91 commits

Upphovsman SHA1 Meddelande Datum
lilia
611bbaef35 Don't hardcode the attachment server url
There may come a day when we may need to change this url from the server
side. On that day, clients should continue to operate normally. The
service should be able to change attachment server locations without
requiring a client update.

// FREEBIE
2017-03-10 15:24:19 -08:00
lilia
43de0cc2ec Add attachment digests
// FREEBIE
2017-03-10 14:40:45 -08:00
lilia
cd0fe7037b Add replayable error for signed key failure
Disable message sending if signed key updates fail too many times, but
allow the user to retry sending.

// FREEBIE
2017-02-16 18:06:19 -08:00
lilia
86dbbc9f29 Allow null expireTimer in sendmessage 2016-10-05 19:09:20 +09:00
lilia
ad2174e279 Sync expirationStartTimestamp on outgoing messages
Linked devices need to know when to start the clock.
2016-09-29 16:17:01 -07:00
lilia
6074a29046 Send timer update messages when changing the timer 2016-09-29 16:17:01 -07:00
lilia
824b7417e9 Apply expireTimer to outgoing messages 2016-09-29 16:17:01 -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
d32a352d8a Use deviceIds/addresses instead of encodedNumbers
The getDeviceObjectsForNumber method returns device objects that contain
nothing but the encodedNumber property. Instead, just deal in deviceIds
until a SignalProtocolAddress is constructed to manage both the number
and deviceId.

// FREEBIE
2016-05-18 13:15:55 -07:00
lilia
0483fa2f97 Remove closeOpenSessionForDevice from protocol_wrapper
// FREEBIE
2016-05-14 23:26:33 -07:00
lilia
3e0bce2b21 Move, rename, and simplify toArrayBuffer helper
This function is only ever used to convert groupIds from strings to
array buffers in sendmessage.

// FREEBIE
2016-03-13 04:56:28 -07:00
lilia
2b7cbef8b1 Rename a function
Avoid confusing this operation with actual receipts, which are something
else.

// FREEBIE
2016-02-26 12:41:29 -08:00
lilia
c3bbdb393f Refactor media uploading step
Move this to its own function which encapsulates the error handling for
it.

// FREEBIE
2016-02-24 23:10:17 -08:00
lilia
44b1a6451d Add validation to Message class
// FREEBIE
2016-02-24 23:10:16 -08:00
lilia
781ada64ca Add libtextsecure support for syncing read messages
Plumbing for sending and receiving a new sync protobuf for marking
messages read on/from my other devices.

// FREEBIE
2016-02-22 17:11:17 -08:00
lilia
7e82d1295c Handle attachment upload errors
Adds a new kind of replayable error that handles retry of pre-encryption
failures, e.g., attachment upload.

Fixes #485

// FREEBIE
2016-02-09 13:21:32 -08:00
lilia
910e37649a Let group messages use new Message class
// FREEBIE
2016-02-08 17:07:49 -08:00
lilia
3bffdd96f5 Add sendMessage to handle sending from Message class
// FREEBIE
2016-02-08 17:07:49 -08:00
lilia
ecdfa09e97 Create a helper class for constructing messages
// FREEBIE
2016-02-08 17:07:48 -08:00
lilia
86132a38a8 Log envelopes and session end events
Help debug bad session errors by logging some envelope info about the
message we are about to decrypt. With this, if there is a decryption
error (e.g., bad mac or no session) it is clear from the logs what
number and device message sent the bad message.

Also log when we send and receive end session messages and when we close
sessions for certain devices.

// FREEBIE
2016-02-02 16:16:42 -08:00
lilia
bc576e18d5 Fix no delivery receipts on close session messages
// FREEBIE
2015-12-11 12:06:45 -08:00
lilia
e9949152bb Always return a promise from sendSyncMessage
// FREEBIE
2015-11-27 22:26:56 -08:00
lilia
07702c4ee5 Let the application layer send sync messages
Previously, libtextsecure would send a sync message automatically
when appropriate. This fails if any recipient has a key conflict
or if our network connection fails mid-send.

Instead, when appropriate, return a the DataMessage encoded as an array
buffer for later syncing. This lets the application choose when to send
it, which we now do after any successful send to a recipient, rather
than after all recipients are successfully sent to.

Eventually we should move the DataMessage protobuf construction and
group sending logic to the application layer entirely, in which case
we wouldn't need libtextsecure to construct the sync message either.

Fixes #408
2015-11-24 17:11:03 -08:00
lilia
5c37c3d6ce Change return type from sending messages
Pass the whole result from the outgoing message callback on to the
caller, and preserve the names of the members.

// FREEBIE
2015-11-24 17:05:25 -08:00
lilia
7b6820d2ac Refactor messageSender/OutgoingMessage
Move encrypt and transmit to OutgoingMessage
Restore per-number queueing to messageSender

// FREEBIE
2015-11-24 17:05:24 -08:00
lilia
4cc6b1ff9a Validate attachment urls
// FREEBIE
2015-11-24 16:20:07 -08:00
lilia
641a7dbc6d Update libaxolotl
encryptMessageFor now requires an array buffer instead of a protobuf.

By converting the message to an array buffer outside the Promise.all, we
avoid allocating a new copy for each device.

// FREEBIE
2015-11-17 16:58:31 -08:00
lilia
a3d29a92bb Reject messages sent to groups with no members
If you're the last member of the group, it doesn't make sense to send
messages to it. Previously, we would wait forever for a callback,
causing a stuck pending state indicator.

// FREEBIE
2015-11-06 18:51:18 -08:00
lilia
12276e691b Refactor contents of sendMessageProto
This function dynamically declares a bunch of functions which bind to
its input arguments. Instead, use a new prototypal class to define
these functions within the context of a particular message.

// FREEBIE
2015-10-23 15:53:20 -07:00
lilia
a2c7ac0df9 Serialize message sending per-recipient
Add a pendingMessages object to MessageSender. This object holds
one promise per recipient number. We init this promise with
Promise.resolve(), and chain on promises for message sending, replacing
the previous promise with the newly chained promise each time. If the
current promise resolves and finds that it is still the last promise
in the chain, it removes itself.
2015-10-23 15:53:19 -07:00
lilia
816a206892 Refactor sendMessageToDevices
Split into separate encrypt and transmit functions. Let the encryption
function also handle all wire formatting (ie, jsonification and base64
encoding), which simplifes TextSecureServer.sendMessages, removes a
TODO, and lets us save fewer params to make network errors replayable.

// FREEBIE
2015-10-10 16:36:30 -07:00
lilia
a32f3ff1f6 More work on replayable errors
Expose a button that does that retries outgoing messages if possible.

// FREEBIE
2015-10-02 18:31:07 -07:00
lilia
5bf608598c Fix MessageSender prototype
// FREEBIE
2015-10-02 15:02:25 -07:00
lilia
978b3d1a98 DRY up tryMessageAgain
// FREEBIE
2015-10-01 18:43:20 -07:00
lilia
fbb65d1988 Add replayable network errors
Support for manual message retry.

// FREEBIE
2015-10-01 18:43:20 -07:00
lilia
bc03bdbfc4 Move tryMessageAgain to MessageReceiver
`tryMessageAgain` is the routine called when re-trying a message that
failed to decrypt due to an IncomingIdentityKeyError. This handling
needs to move to MessageReceiver because it depends on
`processDecrypted` to handle incoming message protos, which depends
on a server instance in order to download attachments.

// FREEBIE
2015-10-01 18:43:19 -07:00
lilia
0fc673f25f Refactor sendmessage for prototypality
// FREEBIE
2015-10-01 18:43:18 -07:00
lilia
a8f4bac2f7 Let makeAttachmentPointer resolve falsey arguments
Internalizing this pattern to the makeAttachmentPointer function lets us
DRY it up throughout the file.

// FREEBIE
2015-10-01 18:33:50 -07:00
lilia
9e9d767a30 Add MessageSender
textsecure.MessageSender takes server url and credentials and returns
a message sending interface configured for that server.

Used a wrapper function to insert a TextSecureServer instance into
sendmessage.js code at runtime. This will result in function duplication
between different MessageSender objects, pending further refactoring to
use prototypal inheritence.

// FREEBIE
2015-10-01 18:33:48 -07:00
lilia
04c5f83485 Un-nest libtextsecure errors
Fix inconsistency in error format, where we sometimes get an unexpected
Error object and sometimes get a wrapper object containing an Error.

Also start saving network errors.

// FREEBIE
2015-09-30 12:44:11 -07:00
lilia
1879e73c76 Allow one more retry if we get a 409
Handle cases where we get a 409 (missing/extra devices), handle it, then
get a 410 (stale devices by registration id).

// FREEBIE
2015-09-28 14:10:50 -07:00
lilia
6123c419d0 Remove refreshGroup
1. This is nonstandard behavior, not supported by any other clients. It
   may help sometimes but will also cause bugs (see 2)

2. iOS doesn't handle group updates with missing fields. all fields must
   be populated, and libtextsecure doesn't have any knowledge of the group
   name or avatar, so these updates will clobber group state on iOS.

// FREEBIE
2015-09-23 16:45:09 -07:00
lilia
94e1c2d123 Remove check for .humanError property
This property is no longer used by any of our errors.

// FREEBIE
2015-09-23 16:45:09 -07:00
lilia
6547538458 Use foreach instead of a loop
This syntax makes plain that the function is not used anywhere else,
and increases linearity/readability.

// FREEBIE
2015-09-23 16:45:08 -07:00
lilia
acaf7b8de2 Refactor relay consistency check
Check the device list for relay consitency and throw an exception before
attempting to encrypt to any of the mismatched devices.

// FREEBIE
2015-09-23 16:45:08 -07:00
lilia
bafc61600c Refactor sendMessageToDevices
Leverage map and Promise.all for more concise and linear code flow.
2015-09-23 16:45:07 -07:00
lilia
1d370857fc Remove unused callback arguments
Unused since d0fd3e94 afaict.

// FREEBIE
2015-09-23 16:07:21 -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
4f1ce4c493 Assume unknown recipients are single-device
Start by requesting keys for only the master device, then handle 410 as
needed. Single-device users are the more common case and this strategy
lets us avoid requesting/expending one of our own device keys when
establishing a session with sibling devices.

// FREEBIE
2015-08-05 16:06:28 -07:00