Commit graph

105 commits

Author SHA1 Message Date
lilia
a3ae3cab79 Use Promise.reject for simplicity
The following are equivalent, except that the first is longer and
invokes an extra function call.

```
return new Promise(function(resolve, reject) {
  reject(new Error("Unknown Group"));
});

return Promise.reject(new Error("Unknown Group"));
```
2015-07-14 13:39:36 -07:00
lilia
20586e2dcc Namespace events
Naming conflict was firing the error handler twice.

// FREEBIE
2015-07-13 13:03:43 -07:00
lilia
6e74ac9e28 Dispatch all network errors, not just auth errors
Also streamline the onError handler.
2015-07-13 13:03:43 -07:00
lilia
b40a8696b7 DRY up Promise creation in api.js
Since calls to ajax() are always wrapped in promises, we can internalize
that pattern in the ajax function itself.

// FREEBIE
2015-07-13 13:03:42 -07:00
lilia
3711e0a6cd Convert throwHumanError to custom error type
Now with 200% more helpful stack traces.

// FREEBIE
2015-07-13 13:03:41 -07:00
lilia
8745424d3a Fix outgoing identity key conflict handling
// FREEBIE
2015-07-06 15:11:35 -07:00
lilia
66ae3689c1 Fix decrypt error handling
This rejection-handler was resolving its promise rather than allowing
the rejection to bubble up.
2015-07-06 12:46:32 -07:00
lilia
f8ae5556d9 Fix standalone registration 2015-07-06 12:45:09 -07:00
lilia
5242108e15 Fix group update avatar handling
The avatar handler was being added to the list of promises too late,
so we were storing the raw avatar protobuf (Long id, bytes key) rather
than the downloaded/decrypted attachment data.

Fixes #280
2015-06-26 12:23:57 -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
db31835f68 Handle group sync for existing groups
// 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
f126e3b21b Work on auth error handling / reinstall 2015-06-25 13:24:31 -07:00
lilia
2f935dfd5e Add contact sync request protocol 2015-06-25 13:24:31 -07:00
lilia
f32ff58953 Add support for device name 2015-06-25 13:24:30 -07:00
lilia
8dc4e34aaf Bug and test fixes for contact sync
Closes #135

// FREEBIE
2015-06-18 13:48:32 -07:00
lilia
b0603bc91a Wrap message receiver for minimum api exposure
Initializing a message receiver opens the socket and starts listening
right away rather than requiring a separate call to connect. The only
other publicly accessible method is to query the socket status.

// FREEBIE
2015-06-17 12:29:40 -07:00
lilia
316838cfe9 Add tests and bug fixes for ContactBuffer 2015-06-17 12:29:40 -07:00
lilia
228ffe901d Update json formatting for legacy message requests
Legacy DataMessages are sent using the `body` field, new Content
messages are sent using the `content` field.

// FREEBIE
2015-06-17 12:29:39 -07:00
lilia
a833d62a71 Implement sync protocol changes
Update protobuf definitions and refactor message receive and decrypt
codepath to support new protocol, including various flavors of sync
messages (sent messages, contacts, and groups).

Also cleans up background.js and lets libtextsecure internalize
textsecure.processDecrypted and ensure that it is called before handing
DataMessages off to the application.

The Envelope structure now has a generic content field and a
legacyMessage field for backwards compatibility. We'll send outgoing
messages as legacy messages, and sync messages as "content" while
continuing to support both legacy and non-legacy messages on the receive
side until old clients have a chance to transition.
2015-06-17 12:29:39 -07:00
lilia
061d57c95a Fix string vs number comparison
Fix bug in device storage causing duplicate device messages after a 410.
2015-06-04 16:48:34 -07:00
lilia
a9549e2e0f Fix 410 handling
We need to close the existing session with an old registrationId.
2015-06-04 16:48:10 -07:00
lilia
7d08e1132d Fix close session 2015-06-04 14:48:59 -07:00
lilia
7e8b1319a5 Ignore sync contexts on messages not from ourselves
But process the rest of the message normally.
2015-05-20 12:42:13 -07:00
lilia
090cc84452 Do not include destination on group sync messages 2015-05-18 14:40:27 -07:00
lilia
d1bcafad65 Update libaxolotl 2015-05-15 16:30:22 -07:00
lilia
704c6ce779 Signaling key is now an array buffer 2015-05-15 11:39:22 -07:00
lilia
d230df5622 Move local identitykey and registrationid to indexeddb 2015-05-15 11:38:14 -07:00
lilia
fe1d78b5fa Load protobufs asynchronously. Fixes #223 2015-05-15 11:38:14 -07:00
lilia
7799bef86c Tweak key conflict error messages
Be generic, because sometimes it's not TextSecure, but Signal.
2015-05-07 17:43:30 -07:00
lilia
359b4a15a2 Move group storage to axolotl store
Add async get/put/removeGroup to axolotl store and let libtextsecure
use it for group state storage.
2015-05-06 17:49:23 -07:00
lilia
748f32022a Fix up refreshGroup 2015-05-06 13:49:20 -07:00
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
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
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