Commit Graph

304 Commits

Author SHA1 Message Date
lilia f774047935 Make libtextsecure group storage asynchronous 2015-05-06 13:11:12 -07:00
lilia 37c496f4f0 Close the provisioning socket 2015-05-05 17:44:59 -07:00
lilia 43d6efcd9e Don't save device objects to disk
Generate them from session and identity data. Save/delete pending prekey
data in an in-memory store and attach it to outgoing device objects.
2015-05-05 17:44:59 -07:00
lilia f413f03a6b Add getDeviceIds to axolotlstore
And add tests for getDeviceIds and removeAllSessions
2015-05-05 17:44:58 -07:00
lilia 121671c99f Store identity keys in indexeddb
Let device storage request them from axolotl store rather than storing a
copy.
2015-05-05 17:44:58 -07:00
lilia 7eda48f755 Move Session Storage to indexedDB 2015-05-05 17:44:58 -07:00
lilia 20ebc3f890 Move identity key storage functions to axolotl store 2015-05-05 17:44:58 -07:00
lilia f38b18ef63 Move Session storage to axolotlstore 2015-05-05 17:44:57 -07:00
lilia 9de1572ba6 Convert all storage.devices methods to be asynchronous 2015-05-05 17:44:57 -07:00
lilia 71715c95bc Async remove identity 2015-05-05 17:44:57 -07:00
lilia 26f1aa4db5 Async putSessionsForDevice 2015-05-05 17:44:57 -07:00
lilia 666f6baaca Async getSessionsForNumber 2015-05-05 17:44:56 -07:00
lilia 9e7d8c0a08 Rename textsecure.api and make it internal-only 2015-05-05 17:44:56 -07:00
lilia 45a61780af Fixup refreshPreKeys and call it whenever a prekey is deleted 2015-05-05 17:44:56 -07:00
lilia 7d0aeac8cb Use a worker to facilitate key generation 2015-05-05 17:44:55 -07:00
lilia f465bdddbf Add textsecure.AccountManager
This class should be used for account registration and for refreshing
prekeys for your account.
2015-05-05 17:44:55 -07:00
lilia a960acacc6 Add textsecure.refreshKeys
This helper checks the server for the number of remaining prekeys, then
generates more if there are fewer than 10 remaining.

// FREEBIE
2015-05-05 17:44:55 -07:00
lilia 96eafc7750 Integrate libaxolotl async storage changes
* Session records are now opaque strings, so treat them that way:
  - no more cross checking identity key and session records
  - Move hasOpenSession to axolotl wrapper
  - Remote registration ids must be fetched async'ly via protocol wrapper
* Implement async AxolotlStore using textsecure.storage
* Add some db stores and move prekeys and signed keys to indexeddb
* Add storage tests
* Rename identityKey storage key from libaxolotl25519KeyidentityKey to
  simply identityKey, since it's no longer hardcoded in libaxolotl
* Rework registration and key-generation, keeping logic in libtextsecure
  and rendering in options.js.
* Remove key_worker since workers are handled at the libaxolotl level
  now
2015-05-05 17:44:55 -07:00
lilia 8304aa903a Update libaxololt to a087b9e746e67995f16e077183cc0 2015-05-05 17:44:54 -07:00
lilia 2ff954d2f8 Fix api.js 2015-05-04 15:14:58 -07:00
lilia e4b49bde51 Add more websocket tests 2015-05-01 13:25:46 -07:00
lilia cc6a44f35d Fix tests 2015-05-01 12:13:03 -07:00
lilia 3ea254d0db Add TextSecureWebSocket tests 2015-04-30 16:59:16 -07:00
lilia 849a407433 Add mock-socket for testing socket stuff 2015-04-30 15:43:11 -07:00
lilia da34b8e0f8 Rename textsecure.websocket and make it internal-only 2015-04-30 15:07:35 -07:00
lilia 89c24cd2fa Move throwHumanError to api.js
It is only used there.
2015-04-30 12:26:13 -07:00
lilia 36b1e87214 Add textsecure.MessageReceiver
Encapsulate the websocket resources and socket setup process in a
friendly OO class. The MessageReceiver constructor expects an instance
of EventTarget on which to fire message events asynchronously. The
provider of the EventTarget can then add/remove listeners as desired.
2015-04-29 16:50:20 -07:00
lilia 37e09da1cc Remove unsued argument from getDeviceObject
Last usage of the `returnIdentityKey` argument was removed in 8b9a16852.
2015-04-20 17:20:58 -07:00
lilia bdecf5cc44 Generate key_worker.js
Instead of calling importScripts, which is prone to relative path
issues, generate the worker script with everything it needs included.
2015-04-15 15:38:57 -07:00
lilia 7af42a27c5 Fix registerKeys using array indices for key ids
preKeys is an array whose indices may or may not be keyId-based. Since
we have an inline keyId property, use that instead.
2015-04-15 15:23:08 -07:00
lilia bfe23d86aa Run key generation in a worker
Ground work for a smoother registration flow. Overall UX still needs
some polish but at least now we can have a progress gif or animation or
whatever. Also adds the phonenumber-confirmation step as a simple alert
box, which will be replaced with a nice dialogue in a later commit.
2015-03-26 10:49:52 -07:00
Matt Corallo 8b9a168524 Store session information separately 2015-03-25 11:56:28 -07:00
Matt Corallo e33c6fddda Do not rely on deviceObject.sessions anywhere in sendmessage 2015-03-25 11:56:27 -07:00
Matt Corallo 6c0f3ff1f0 Move session-storage logic to storage/devices from axolotl_wrapper 2015-03-25 11:56:27 -07:00
Matt Corallo 169097a409 Remove stale comments in axolotl_wrapper 2015-03-25 11:56:26 -07:00
Matt Corallo 89fefe4323 Create a textsecure.storage.impl to be overriden if desired 2015-03-25 11:56:26 -07:00
Matt Corallo 56bffdcfd3 Prefix libaxolotl-stored objects with "libaxolotl" 2015-03-25 11:56:26 -07:00
Matt Corallo 00cb420d37 Merge (un)encrypted storage layers 2015-03-25 11:56:25 -07:00
Matt Corallo 454b4726bd Replace load/decode/index around our own number with helpers 2015-03-25 11:54:55 -07:00
lilia 3759fe46e9 Account for -1 HTTPError code 2015-03-25 11:46:14 -07:00
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