Commit graph

64 commits

Author SHA1 Message Date
lilia
e52224e481 Remove libtextsecure's jquery dependency
Use only the finest, hand-crafted, artisanal XMLHttpRequests.
2015-03-25 10:32:14 -07:00
lilia
857eee5003 Divorce identity wipe from tryAgain functions
We'd like to live in a world where we can retry all the pending
conflicts in a conversation as a batch, which means we don't want to
wipe the identity key before processing each message. Thus, remove that
step from these handlers and encapsulate in a method on the conversation
model.
2015-03-18 16:29:02 -07:00
lilia
c642854ddf Extract app-level logic from libtextsecure
Ensure that both tryAgain functions return promises, allowing the
application to take appropriate action in the result of success or
failure. This lets us remove all dependency from libtextsecure on
app-level constructs like message objects/ids and the `extenion.trigger`
function.

Corresponding frontend changes to follow in another commit.
2015-03-18 16:29:02 -07:00
lilia
e88d4d8170 Tweak replayable errors
1. Return the value returned by the registered function, to expose the
underlying promise to the caller.

2. Stop accepting extra arguments to the replay function. The caller
should be able to do what they want with the returned promise instead.

3. Add a timestamp argument to the outgoing case, needed to re-try
sending a message.
2015-03-18 16:29:01 -07:00
Matt Corallo
d3c158f4cf Move libaxolotl out-of-tree 2015-03-17 14:43:23 -07:00
Matt Corallo
e2e06b2d3c Remove axolotl.storage usage from libtextsecure 2015-03-17 13:59:25 -07:00
lilia
b790f82849 Remove libaxolotl dependency on textsecure/errors.js
Let libaxolotl throw a generic error instead of a replayable error, and
add an helper function in libtextsecure's axolotl_wrapper to catch and
convert from the generic error to the replayable one. This allows the
ReplayableError to remain a libtextsecure-level concept only.

Somewhat unrelatedly, but nearby, fix some whitespace and add missing
semicolon.
2015-03-17 13:59:24 -07:00
lilia
676ad04958 Add device storage method to wipe an identity 2015-03-17 13:59:24 -07:00
lilia
9e04910124 Recompile curve25519 with emcc 1.29.0
Now with actual malloc/free implementations. Had to drop back to -O1
optimization because the ed25519 signature test broke with -O2. :(

Closes #153

The toolchain install and build process, for reference:
```
wget https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz
tar xvfz emsdk-portable.tar.gz
cd emsdk-portable
./emsdk update
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
cd ../TextSecure-Browser
grunt build
```
2015-03-16 16:07:47 -07:00
lilia
b9969b14b6 Always reconnect the socket except when there is an error
Turns out we can get ABNORMAL_CODE (1006) for disconnects where (for
instance) we pause the background page too long. However, in these cases
there is no preceeding ErrorEvent. In contrast, when we have bad
authentication credentials, there is an ErrorEvent. Thus, this change
ensures that we only reconnect if there was no Error.
2015-03-11 14:12:25 -07:00
lilia
0cbad730ce Don't send keepalive if socket has closed
Also shorten the timeout to see if it improves websocket connection
reliability.
2015-03-11 14:12:25 -07:00
lilia
2b073f3365 Reset keepalive timer if we're about to send
No sense in sending more keepalives than necessary.
2015-03-11 11:12:14 -07:00
lilia
7e5e558ad5 Bump keepalive to 60s 2015-03-10 18:14:12 -07:00
lilia
fd6e2954f7 Curtail over-zealous websocket reconnects
Closes #173

Previously, in the event of a failed websocket auth, we would attempt to
reconnect once a second ad infinitum. This changeset ensures that we
only reconnect automatically if the socket closed 'normally' as
indicated by the code on the socket's CloseEvent. Otherwise, show a
'Websocket closed' error on the inbox view.

Ideally we would show a more contextual error (ie, 'Unauthorized'), but
unfortunately the actual server response code is not available to our
code. It can be observed in the console output from the background page,
but programmatically, we only receive the WebSocket CloseEvent codes
listed here:
https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes

The websocket error message is displayed by a normally-hidden but ever
present socket status element. Clicking this element will immediately
refresh the background page, which will try again to open the websocket
connection.
2015-03-09 16:04:26 -07:00
Matt Corallo
2277b41639 Remove non-existant device messages 2015-02-26 12:13:56 -08:00
Matt Corallo
5abf3073d5 Check END_SESSION messages in processDecrypted 2015-02-26 12:11:05 -08:00
Matt Corallo
29192edcb8 Ignore END_SESSION on messages with a sync context 2015-02-26 12:11:04 -08:00
Matt Corallo
9c3f8a1868 Dont send group-update right before we quit the group
Fixes #166
2015-02-25 15:59:49 -08:00
lilia
b1035c23e5 Preserve whitespace in _concat files
This is a whitespace-only change. The diff is best viewed
with the `--patience` flag.

Some component library sources include trailing whitespace and carriage
returns which were excluded from these compiled files, (but somehow
still included in the final libtextsecure build). Although superfluous,
excluding these characters from these files means that I end up with
spurious changes whenever I rebuild them.
2015-02-20 15:34:49 -08:00
Matt Corallo
f2853d00e6 Merge pull request #167 from WhisperSystems/sync
Sync outgoing individual and group messages
2015-02-20 12:39:26 -08:00
lilia
f860cb4492 Return end session messages to the frontend
So we can save them in the message history, and because the caller
expects a promise.
2015-02-20 10:30:43 -08:00
lilia
40351fcc54 Sync outgoing messages
When sending an constrct a copy of the PushMessageContent protobuf, add
a SyncMessageContext, and send it to ourselves. Do this for all kinds of
group messages, and individual text/media messages, but not closeSession
messages as the latter are device-specific.

Do not sync messages if we are the primary device, which should only be
supported in development. Normal web clients must be paired with a
android or ios master device, and even in dev, a primary/standalone web
client does not support linking additional devices.
2015-02-17 14:10:42 -08:00
Matt Corallo
b45c09470f Merge pull request #155 from WhisperSystems/closeSession
Fix textsecure.closeSession
2015-02-13 10:44:06 -08:00
lilia
0e8a5806a8 Fix textsecure.closeSession
sendIndividualProto requires a timestamp.
2015-02-12 22:12:48 -08:00
lilia
65c70a9117 Fix provisioning flow
Fix undefined axolotl.protobufs.ProvisionMessage, referenced in
libaxolotl/protocol.js
2015-02-12 16:41:04 -08:00
Matt Corallo
148410a826 Move jquery dep from libaxolotl to libaxolotl tests 2015-02-12 15:12:02 -08:00
Matt Corallo
44a094c324 Re-run concat 2015-02-12 15:12:01 -08:00
Matt Corallo
1e318a8293 Add missing TODO 2015-02-12 15:12:01 -08:00
Matt Corallo
b356403061 De-duplicate registrationId in deviceObject 2015-02-12 15:12:01 -08:00
Matt Corallo
92d0de6837 [de]serialize sessions storage in device storage 2015-02-12 15:12:01 -08:00
Matt Corallo
1bef1ce5d3 Split out identity key storage from session storage 2015-02-12 15:12:01 -08:00
Matt Corallo
298c8624b2 Move test vectors to libaxolotl 2015-02-12 15:12:01 -08:00
Matt Corallo
7e3f1ef452 Actually store on removeDeviceIds 2015-02-12 15:12:00 -08:00
Matt Corallo
1806210b26 Rewrite most of the device storage stuff 2015-02-12 15:12:00 -08:00
Matt Corallo
f1f5914879 Re-run concat 2015-02-12 15:12:00 -08:00
Matt Corallo
bfb3e7751e Add missing validity check to device storage 2015-02-12 15:12:00 -08:00
Matt Corallo
30dd13e8e3 Return a function instead of a session in decryptWhisperMessage 2015-02-12 15:12:00 -08:00
Matt Corallo
3e648b0ea0 Move groups storage back to libtextsecure 2015-02-12 15:12:00 -08:00
Matt Corallo
04b2a13a75 Naively move device/session storage to wrapper 2015-02-12 15:11:59 -08:00
Matt Corallo
870e5dc9dc Remove all external non-test deps on libaxolotl/crypto 2015-02-12 15:11:59 -08:00
Matt Corallo
7d2d2d92fc Copy getRandomBytes from libaxolotl to libtextsecure 2015-02-12 15:11:59 -08:00
Matt Corallo
12844590f5 Move prekey sigcheck to libaxolotl 2015-02-12 15:11:59 -08:00
Matt Corallo
cb6cb4ff89 Re-add jquery as it is needed for our test runners 2015-02-12 15:11:59 -08:00
Matt Corallo
8398a52c20 Re-run concat 2015-02-12 15:11:58 -08:00
Matt Corallo
bb32a51d66 s/textsecure.protocol/axolotl.protocol/ 2015-02-12 15:11:58 -08:00
Matt Corallo
c1907b14eb Use axolotl.api for a few more things in libaxolotl/protocol.js 2015-02-12 15:11:58 -08:00
Matt Corallo
403ae4376d Move attachment/websocket [en|de]cryption to libtextsecure 2015-02-12 15:11:58 -08:00
Matt Corallo
a9617068a2 Move key updating and retry handling to libtextsecure 2015-02-12 15:11:58 -08:00
Matt Corallo
184b1ec89c Move protocol protobufs to libaxolotl/, handling DeviceControl 2015-02-12 15:11:58 -08:00
Matt Corallo
66cf5b08db Naively move textsecure.crypto into axolotl.crypto 2015-02-12 15:11:58 -08:00