Commit graph

355 commits

Author SHA1 Message Date
lilia
6e3014895b Fix cryptojs hmac implementation
Apparently the bowerized version of cryptojs's WordArray.create doesn't
handle arraybuffers correctly.
2014-10-31 21:10:02 -07:00
lilia
6e86a2b7cf Switch libphonenumber to bower 2014-10-31 20:59:30 -07:00
lilia
508c59e05c Rename bower_components
To components. Because tab-completion works better when there aren't two
things starting with bower, and shorter names are nicer to deal with in
general.
2014-10-30 16:53:08 -07:00
lilia
ca7ba43b13 Fix overly hidden elements on registration page
Latest bootstrap css is really aggressive about hiding things.
2014-10-30 14:20:42 -07:00
lilia
800e5ab703 Pass protobuf attachment ids as strings
Latest protobuf.js requires that we pass in the sign value when making
longs from strings, ex: dcodeIO.Long.fromString(id, true);

However, it does the string->long conversion automatically if its given
a string for a fixed64 field, so we can pass our string ids right in!
ftw
2014-10-29 23:18:29 -07:00
lilia
9c568ed0b8 Don't warn on missing message bodies
A message can be blank if it has an attachment
2014-10-29 20:50:51 -07:00
lilia
df0eaf622a Clean up test files
Moved all test code into /test. Renamed test.js to crypto_test.js.
(Let's try to keep test files topical.) Merged test_views.html and
test.html into a single test/index.html.

Todo: use Grunt to generate test/index.html from index.html and files
found in /test. Also, write more tests.
2014-10-29 16:05:51 -07:00
lilia
987744cd79 Default avatars
Someday you'll be able to edit your avatar. Until then, put a bird on
it.
2014-10-29 16:05:51 -07:00
lilia
2a7d3996bb Remove unused popup.html
And popup.js is now index.js, illustrating its importance as the titular
javascript file.
2014-10-28 22:47:48 -07:00
lilia
1c76c0b546 Move storage objects to their own files
Greatly reduce the size of the ignominiously named helpers.js.
2014-10-28 22:47:48 -07:00
lilia
b92c5bb84e Unused function 2014-10-28 19:15:01 -07:00
lilia
ddd6f1a944 remove another unused function 2014-10-27 02:09:46 -07:00
lilia
80e3fadcb1 Remove unused *MACWithVersionByte functions 2014-10-26 21:27:08 -07:00
lilia
39505c81b1 Finish up webcrypto integration, Fixes #72
We now correctly and opportunistically use the webcrypto API if
available, polyfilling if it's not detected. This change also includes a
layer of abstraction over the webcrypto interface so we no longer have
to deal with key-imports or algorithm names all over the place. Since we
no longer support AES-CTR, code outside this file can simply call
`textsecure.subtle.<encrypt|decrypt|sign>(key, data [, iv])`.
2014-10-26 20:29:10 -07:00
lilia
244e051fc3 Add importKey to webcrypto.js 2014-10-26 15:54:19 -07:00
Matt Corallo
37ef492642 Remove now-broken axolotl test 2014-10-26 03:44:55 -07:00
Matt Corallo
2e7b5b46e3 Remove AES-CTR entirely 2014-10-26 03:41:11 -07:00
Matt Corallo
da0c63fb1b Add (untested) AES-CBC switch from v3 (fs loss resulted in old tested version being lost) 2014-10-26 03:40:00 -07:00
Matt Corallo
3a39602385 Fix borked spacing in webcrypto.js 2014-10-26 03:23:34 -07:00
Matt Corallo
73f867f7de rm useless GPL, license testvectors under X11 (ie 3-c MIT + advertising provision) 2014-10-26 02:59:59 -07:00
Matt Corallo
68a42a6ae7 Give up on webcrypto :( 2014-10-26 02:46:13 -07:00
lilia
21225b2074 Save outgoing attachments 2014-10-26 00:30:20 -07:00
lilia
b69db59ad4 Fix buffer concatenation
TypedArray.prototype.set doesn't handle ArrayBuffers correctly (it
writes all zeros). Instead, wrap each ArrayBuffer in a typed array
for concatenation.
2014-10-25 23:07:14 -07:00
lilia
e07759a93c Fix CBC encryption, test 2014-10-25 20:45:21 -07:00
lilia
e35148add8 No, jQuery, don't processData!
processData (default: true)
Type: Boolean
By default, data passed in to the data option as an object (technically,
anything other than a string) will be processed and transformed into a
query string, fitting to the default content-type
"application/x-www-form-urlencoded". If you want to send a DOMDocument,
or other non-processed data, set this option to false.

https://api.jquery.com/jQuery.ajax/
2014-10-25 19:48:54 -07:00
lilia
211129475c Fix attachment ids
Parse attachment ids out of the attachment pointer url and return them
as strings because the copy parsed by JSON suffers a loss of precision.
Convert them to and from the format expected by the protobuf using
facilities from decodeIO.Long.
2014-10-25 18:12:20 -07:00
lilia
eebb14599f Well that's handy 2014-10-25 18:12:07 -07:00
lilia
674b173c59 Add support for cbc encryption 2014-10-24 19:09:58 -07:00
lilia
229007040c Basic frontend support for image attachments 2014-10-24 18:53:55 -07:00
lilia
d362d0d978 Autoscroll conversation views
Scroll to the bottom (most recent) message in the conversation when it
is opened, when we send a message, and when we receive a message.
2014-10-24 14:49:42 -07:00
lilia
4675cdf3f2 Webcrypto won't go down without a fight
Turns out that assigning a new object to window.crypto.subtle
is not so easy. That's probably a good thing.
2014-10-23 21:30:36 -07:00
lilia
a4b25f7df1 Disable the real webcrypto
Sadly, we are not quite compliant with the WC3 webcrypto spec
due to our insistance on passing around key data in plain old
ArrayBuffers.

Also converted whitespace.
2014-10-23 21:15:27 -07:00
lilia
d67b723f4f Highlight the selected thread 2014-10-22 17:26:37 -07:00
lilia
19dac1f3df Decorate incoming group messages
with numbers and image placeholders, so you know who's saying what.
2014-10-22 16:30:27 -07:00
lilia
78166365c7 Fix new message number validation 2014-10-22 16:07:16 -07:00
lilia
838283f28b Send acks instead of closing and opening the socket
Hopefully the real fix for #67 until we get protocol-level pings from
the wc3 api.
2014-10-22 12:38:30 -07:00
lilia
6e2a85ccf1 wip new message phone number validation 2014-10-22 12:05:33 -07:00
lilia
e831c649bd Require a mandatory websocket reset once a minute
Compensate for the lack of keepalives in the WebSocket API.

Fixes #67
2014-10-21 19:57:53 -07:00
lilia
a3bf40e852 Shorten websocket time out. Fixes #67 2014-10-21 14:26:14 -07:00
lilia
3a00e49791 Open the most recent conversation on load 2014-10-20 17:49:41 -07:00
lilia
1023ea1732 Refactor textsecure.protos -> textsecure.protobuf
DRY up protobuf declarations and move to a slightly briefer naming
convention.

Also dropped some ArrayBuffer -> string conversions as
ProtoBuf.js handles ArrayBuffers just fine, and in fact, more
efficiently than strings.

Finally, dropped the btoa() wrappers, because that incurs an extra
string -> string conversion before the protobuf's internal string ->
array buffer conversion. In lieu of btoa, we can simply pass in the
optional string encoding argument to the protobuf's decode method,
which in these cases should be 'binary'.

Related: #17
2014-10-20 15:11:16 -07:00
lilia
03cc667e48 Standardize some whitespace
The preferred style is 4 spaces.
2014-10-20 15:09:36 -07:00
Arnaud Benard
e568e2c528 Fixes #61 - Order by timestamps with tests 2014-10-20 02:07:46 -07:00
lilia
cc5327dbc9 Fix group loop
All the group messages were being sent to the last recipient in the
list, due to the persistence of `var number` in later loops and async
calls. An easy mistake to make, when you use for instead of each.
2014-10-18 15:00:43 -07:00
lilia
ac5c359053 Fix strange loop in sendMessageProto
Don't declare a new `var i`  within the scope of an existing `var i`.

Fixes #63
2014-10-17 16:57:33 -07:00
lilia
cd55c0a1f1 Put groupid back in id field also 2014-10-17 14:32:37 -07:00
lilia
0bd5f3e3c2 If for some reason a group has no name, provide a default 2014-10-17 13:25:39 -07:00
lilia
0036e4ef74 Store group ids as strings 2014-10-17 13:11:08 -07:00
lilia
8288e298fc Group ids should be converted to ArrayBuffers for transport 2014-10-17 12:52:46 -07:00
lilia
143254cec8 Group ids are stored in groupId 2014-10-16 17:50:36 -07:00
lilia
bbe57ef0bf Stringify incoming group ids
Otherwise when we try to make their local storage keys they look like:
"egroupByteBuffer(offset=4,markedOffset=-1,length=28,capacity=112)"
2014-10-16 17:39:45 -07:00
lilia
4f21bbd21f Use textsecure.messaging to create groups
Not textsecure.storage. Sigh. Also accomodate the fact that
the group id is not returned directly, but rather at the end
of a promise chain.
2014-10-16 14:15:13 -07:00
lilia
fa4c385598 Make initial timestamp on a thread match the 1st message 2014-10-16 14:13:03 -07:00
lilia
f14cd2eed1 Don't validate presence of thread id
It's undefined until the first save();
2014-10-16 14:11:51 -07:00
lilia
7e9c0e2394 Group ids should be strings (or stringables)
ArrayBuffer was a bad choice.
2014-10-16 13:38:33 -07:00
lilia
6db3eeb52e Convert incoming timestamps into numbers
Fixes #59

protip: don't use << for anything over 2^32. The operands of all bitwise
operators are converted to signed 32-bit integers
2014-10-16 12:32:02 -07:00
lilia
d7edfd4efb Remove reference to undefined function 2014-10-15 18:10:27 -07:00
lilia
43f4f6cf99 Open a group's view after it's created 2014-10-14 21:35:40 -07:00
lilia
320d1f18ae Fix exception when protbuf-encoding groupIds
An exception is thrown when protobuf tries to encode a number as the
group id, which is declared to have type 'bytes'.

Fix by make it an ArrayBuffer instead, and increase the length to 16,
which is what the Android client uses:

c632b32ff8/src/org/thoughtcrime/securesms/database/GroupDatabase.java (L222)
2014-10-14 19:33:33 -07:00
lilia
5b0573293f Fix references to GroupContext Type ENUM values 2014-10-14 19:07:00 -07:00
lilia
01f9fc1f17 More frontend groups fixes 2014-10-14 19:06:35 -07:00
lilia
e89e691957 Fix bug in groupId generation
Previously, if calling createNewGroup with an undefined groupId,
no groupId was generated.

This occurred because no entry for "group" + undefined exists in
localStorage, which caused this code to think undefined was a
valid group id.

Fixed by adding `|| groupId == undefined` to the while clause.
Also decoupled the groupId collision check for clarity.
2014-10-14 15:47:51 -07:00
lilia
dc41ebf701 Small frontend fixes for the new group view 2014-10-14 15:47:51 -07:00
lilia
2bd77693e1 Refactor options page and style using bootstrap 2014-10-14 13:59:43 -07:00
lilia
81e4af5827 Move phonenumbery utils to libphonenumber object
Slowly whittling away at helpers.js...
2014-10-13 22:49:39 -07:00
lilia
9fc14cfa30 Remove erroneous comment re: MDN copyright
In fact, the code samples we have copied from MDN are declared to be
public domain (see link below):

  "Code samples added on or after August 20, 2010 are in the public
  domain."

https://developer.mozilla.org/en-US/docs/MDN/About#Copyrights_and_licenses

AFAICT we're using code from this page, last updated 10/4/14:
https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
2014-10-10 17:25:40 -07:00
lilia
75e78caec8 Function-wrap options.js 2014-10-10 16:58:44 -07:00
lilia
683c373943 Relaxes verification code validation
When codes are sent they are formatted as xxx-xxx. Previously when I
would paste these from GVoice they failed validation thanks to the dash
and whatever whitespace I happened to grab.
2014-10-10 16:32:22 -07:00
lilia
27708cd8d7 Switch to staging. -ca is now production 2014-10-10 16:32:15 -07:00
lilia
0f4b53c176 Update records list in BBLocalStorage on fetch
Previously, would only update the known messages.
2014-10-09 20:08:28 -07:00
lilia
2288f8adc1 Fix new group ui not showing 2014-10-09 19:02:52 -07:00
lilia
266600e5ab There's no need to wrap this function inside a function afaict 2014-10-09 18:54:23 -07:00
lilia
ae98b8680f Fix whitespace in popup.js
Our official standard is 4 space indentation.
2014-10-09 18:43:58 -07:00
lilia
ef066ea9d2 Make conversations open when they are created 2014-09-04 00:21:18 -07:00
lilia
230d24a69e Views already have a #remove() 2014-09-04 00:21:02 -07:00
lilia
db86abdf70 Add list view tests
Also,
 * moved fetch out of the list view
 * removed unused #last() function
 * put test setup lines in their own tiny file.
 * added data-cover to view script tags for code coveage reports.
2014-09-04 00:18:15 -07:00
lilia
ad7456b367 Refactor away this poorly named and overloaded file 2014-08-31 18:18:13 -07:00
lilia
b9640a54bd Move new convo stuff to its own file 2014-08-31 18:02:39 -07:00
lilia
9af18ce6ae Encapsulate page layout js
The layout class is the only class that should have knowledge of
page-level constant markup, such as #gutter and #contacts, and
should be pretty much the only place we find elements by id (with
the exception of template elements).

This change removes references to #gutter from views. Rather than
hardcoding assumptions about page layout, view elements should
ask the layout to insert themselves into the main content area by
calling Whisper.Layout.setContent.
2014-08-31 17:46:01 -07:00
lilia
5ddcc516e4 remove extra insertion, it's already happening 2014-08-25 19:01:18 -07:00
lilia
2f0b0f7a1b Get overflow scrolls working
Had to resort to a resize event handler.
A bit slow at times, but it works.
2014-08-25 19:01:13 -07:00
lilia
546cdf82cb Fix some markup issues
* Remove spurious search div
* Fix nested uls
* Use class name selected, not closed (the inverse)
* Restor nacl div
2014-08-25 18:59:22 -07:00
lilia
c2beda8e40 Get single recipient message composition working again 2014-08-25 18:55:51 -07:00
lilia
c034ac8267 Refactor components for the main content section
Each conversation views now manages its own separate elements
rather than all binding to a shared #conversation element, and
similarly for message composition ui.

Also includes the beginnings of group creation UI (not working yet),
featuring bootstrap-tagsinput field for entering group recipients
2014-08-25 18:54:55 -07:00
lilia
8d83a8fb27 This element is constant, so let's bootstrap it 2014-08-25 18:48:12 -07:00
lilia
5f74a60364 Format thread timestamps 2014-08-25 18:48:12 -07:00
lilia
44f272a181 Get messages sending with new ui
Also convert index.html to 4-space indentation.
2014-07-27 15:04:12 -10:00
lilia
95c31629b7 get frontend rendering with new markup/css 2014-07-27 12:16:58 -10:00
lilia
850a91c77d Fix message sending 2014-07-27 11:35:49 -10:00
lilia
0741c74618 Don't recreate views unnecessarily
Let ConversationListItemView save a reference to its corresponding
ConversationView. This lets it render or delegate/undelegate events
when opening and closing a conversation.

Similarly for ConversationView itself, which contains a MessageListView.
2014-07-27 11:35:49 -10:00
lilia
9d0be46a53 Close an open conversation before opening another 2014-07-27 11:35:49 -10:00
lilia
bbb5d56516 Don't reopen a currently selected conversation 2014-07-27 11:35:49 -10:00
lilia
98cfc1b701 Remove old convo compose view 2014-07-27 11:35:49 -10:00
lilia
511b121a2f Refactor conversation view into two classes
One that resides in the left hand column as a list item, and another
which displays in the main column and handles ui events therein.
2014-07-27 11:35:49 -10:00
lilia
6ff6ef07a9 Parse the template before binding render to an event 2014-07-27 11:35:49 -10:00
lilia
d615a5a18b Let list view changes the color of selected conversations 2014-07-27 11:35:49 -10:00
lilia
dc957415c2 Cull dead code
Most of this no longer needed because of templating and list views.
2014-07-27 11:35:49 -10:00
lilia
9082781e09 Make header and footer/form work without overflowing 2014-07-27 11:35:49 -10:00
lilia
df95a7f71a Move ui init out of nacl callback and remove some lines that no longer apply 2014-07-27 11:35:49 -10:00
lilia
def32f42d4 New layout/design
Two column layout and style tweaks. Templatized conversation views.
Generalized list view.
2014-07-27 11:35:48 -10:00
lilia
6d5e32bca8 Don't make a new collection on every call to thread.messages() 2014-07-27 11:35:48 -10:00
lilia
7e20838128 Rename file 2014-07-27 11:35:48 -10:00
lilia
4724c96ecb Use $.find so these locals can go away 2014-07-27 11:35:48 -10:00
lilia
2e3d89ef78 Use mustache template for message rendering 2014-07-27 11:35:48 -10:00
lilia
25fecc949e Condense some code using Backbone.View's event framework 2014-07-27 11:35:48 -10:00
lilia
06ff6c3087 Let thread collection double as contacts db
When a thread is 'destroyed' from the UI we delete its messages and mark
the thread as inactive, (in other words, keep it around as contact info).
Additionally, we only load active threads when initializing the UI, and
reactivate threads when new messages are added to them.

Conflicts:
	js/models/messages.js
	js/models/threads.js
	js/views/conversations/show.js
2014-07-27 11:35:48 -10:00
lilia
c6b79236d9 Fix whitespace, lint 2014-07-27 11:35:48 -10:00
lilia
ebf1b3352f Use separate message collections for each thread to facilitate lookup and lazy loading 2014-07-27 11:35:48 -10:00
Matt Corallo
d6d17eaf19 Remove unused function 2014-07-27 02:33:17 -04:00
Matt Corallo
3696214edc Add missing localStorage.clear() 2014-07-27 02:30:00 -04:00
Matt Corallo
28779e0b35 Fix tests by returning promises 2014-07-27 02:05:25 -04:00
Matt Corallo
90eb9cb0c8 Remove ping, update to latest spec proposal 2014-07-26 18:15:24 -04:00
Matt Corallo
f6f35c5b61 Fix a missing function and dont blow up on delivery receipts 2014-07-26 01:53:24 -04:00
Matt Corallo
d9f53d4c01 Fix not-allowed inline scripts error 2014-07-26 01:37:47 -04:00
Matt Corallo
a6b0d1f84b Add entirely untested secondary device init 2014-07-26 01:32:05 -04:00
lilia
2751d0e884 Such tests. Very mocha. Much chai. Amaze!!!
ERHMAGERRRD testing frameworks are so the best. Removed all our custom
code for ensuring test exclusivity and doneness and isolating callbacks
and everything. mocha does it all for us, and makes it pretty.

Also rather than return a long chain of promises that eventually resolve
to truthiness, we now use chai to make assertions about what is good and
right in the world.

Recommended reading:
  https://visionmedia.github.io/mocha
  http://chaijs.com/api/assert/
2014-07-25 18:01:19 -10:00
Matt Corallo
6455da5c9a Refactor a bunch of stuff re: session closing, add test cases 2014-07-25 19:55:49 -04:00
Matt Corallo
c427da04f0 Add closeSession tests as Alice and fix re-requesting prekeys 2014-07-24 20:15:27 -04:00
Matt Corallo
6f3ee151f3 Add a BOB test-case around session closure 2014-07-24 17:11:53 -04:00
Matt Corallo
a6426194ef Update BOB test cases 2014-07-24 06:42:41 -04:00
Matt Corallo
957587bd9a Add identity keys to MAC, begin updating test cases 2014-07-24 06:29:11 -04:00
Matt Corallo
eab0911d3d I lied, there is no verification tag 2014-07-24 05:14:38 -04:00
Matt Corallo
85f33345ab Move test shuffling to js/testvectors.js 2014-07-23 20:29:45 -04:00
Matt Corallo
0088721343 Move AXOLOTL test vectors to js/testvectors.js 2014-07-23 18:22:16 -04:00
Matt Corallo
07f79cb4bf Fix tester 2014-07-23 03:59:22 -04:00
Matt Corallo
7013c5e031 First steps towards BOB test vectors 2014-07-23 03:57:50 -04:00
Matt Corallo
ebcfd4736e Fix session lookup in duplicate prekeymessage case 2014-07-23 03:36:11 -04:00
Matt Corallo
5040bfbe44 Fix pending verifications 2014-07-23 02:53:31 -04:00
Matt Corallo
a76ae2f1f8 Add verification tags, make alice tests strict(ish) again 2014-07-23 02:49:47 -04:00
Matt Corallo
287b55120d First cut of ALICE test vectors 2014-07-23 01:49:13 -04:00
Matt Corallo
a8908646aa Fix null flags in v3 2014-07-22 21:38:48 -04:00
Matt Corallo
0d4ae6a8cb Fix undefined variable in for's (browser update to strict mode?) 2014-07-22 21:33:35 -04:00
Matt Corallo
de83429962 v3 steps 2014-07-22 21:23:52 -04:00
Matt Corallo
66bf371aa7 Use staging server (ie update to server keys v2) and protocolv3 2014-07-22 21:23:35 -04:00
Matt Corallo
53f8ac9ad9 Generate signed keys (breaks registration) 2014-07-22 21:23:35 -04:00
Matt Corallo
4c3ee6f23b Compare equality w/o getString (in the future) 2014-07-22 21:23:35 -04:00
Matt Corallo
3190fe97f9 HMAC Update for Protov3 2014-07-22 21:23:35 -04:00
Matt Corallo
b5c6e3d101 JS ed25519 2014-07-20 16:49:40 -04:00
Matt Corallo
b94ba6b726 USE_NACL = true 2014-07-20 16:49:40 -04:00
Matt Corallo
7d27df9868 Report testing done 2014-07-20 16:29:42 -04:00
Matt Corallo
a2da4fffb0 Remove useless function 2014-07-17 18:13:32 -04:00
Marco
13a9329bcf improved number validation (based on google's libphonenumber) 2014-06-29 16:39:05 -07:00
Matt Corallo
92514ad08f Fix missing baseKey 2014-06-09 20:27:09 -04:00
Matt Corallo
ceca03c5d0 Close chainKey.key 2014-06-09 20:27:09 -04:00
lilia
ce3c5eb909 Refactor conversation list view
Pull apart UI classes for displaying and creating threads.
Also get rid of ugly alert popup in favor of Whisper.notify.
2014-06-07 16:31:40 -07:00
Matt Corallo
1ec6b0aed6 Better TODO wording 2014-06-05 22:34:01 -04:00
Matt Corallo
12a849957a Refresh groups on (probably) new identity key (maybe more often?) 2014-06-05 22:28:30 -04:00
Matt Corallo
0f126fc0f8 Keep track of number->groups, add TODO to refresh, other tweaks 2014-06-05 21:05:42 -04:00
Matt Corallo
e495e8e3db Group updates to match real protocol and get better checking 2014-06-05 19:20:09 -04:00
lilia
ec900e0ea4 Fix double display of outgoing messages 2014-06-03 20:05:41 -07:00