Commit Graph

596 Commits (99f7f17e73373d8fcdfcea14673570cd0febd4a9)

Author SHA1 Message Date
lilia a258f1a66b Refactor number parsing and validation
Refactor libphonenumber.validateNumber into libphonenumber.parseNumber,
which encapsulates the try-catch pattern used in number parsing and
returns an object of info about the input number rather tha throwing
since we expect to get some invalid number inputs the user is typing.

In the conversation model,
  * Separate phone number validation from search token updating.
  * Perform token update before save if the number was valid.
  * Stop storing unneeded number variants as conversation properties.

// FREEBIE
lilia 3d98b54027 Create contact from number with common punctuation
The 'Create new contact' option should now appear for numbers including
parens and other common punctuation.

// FREEBIE
lilia 0b95606eff Display nicely formatted phone numbers
In conversation headers and as titles for contacts with no name. Updated
tests accordingly.

// FREEBIE
lilia 717108d17f Add regression test for
// FREEBIE
lilia 038e263023 Fix the build
1. Update chrome version because v40 fails to clear the session store
2. Add message view to test page and fix bad reference to chrome
3. Update the message view template in tests with new timestmap markup

// FREEBIE
lilia 80d32103d1 Clear session store when re-registering
When we re-register, our deviceId might change, which makes our sessions
are no longer valid since the recipient will see us as a new device.

Fixes 
lilia 69bbaac3b9 Fix conversation model test
// FREEBIE
lilia 87ce3241c8 Remove script-tag for nonexistant test
// FREEBIE
lilia 78d7296f84 Fix tests
// FREEBIE
lilia f764445c86 Remove erroneous license file and headers
We only use GPLV3 around here.

// FREEBIE
lilia 17e515f886 Add identity key conflict tests
lilia 9a4a91b5b5 Fix avatar test
lilia a2abfe38a4 Fix tests
lilia 029c9754f0 Fix tests
lilia 915612114b Remove general get/put/remove methods from AxolotlStore
lilia d0e262d7cb AxolotlStore stores groups in indexeddb
lilia f413f03a6b Add getDeviceIds to axolotlstore
And add tests for getDeviceIds and removeAllSessions
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
Tara Vancil 074bb66a4c Add tests for messages model.
Closes 
lilia 5a46300581 Reorder database.js include in test
lilia 026f110d36 Delete the database once, before tests run
Tara Vancil d65e0e5eda Add tests for message and conversation models
Closes 
lilia c526dbda5f Set up production build task
`grunt copy`

Closes 
lilia 254131488e Render emoji in conversation and inbox views.
lilia 1321a90667 Rename Whisper.View#attributes
Avoid colliding with Backbone.View attributes, which is a list of attrs
to set on the html element for a view.
lilia dc1b09f59d Auto-link urls in message bodies
And watch out for xss.

Closes 
lilia fc6c8c0f3e Fix tests
lilia 1bb480f6ea DRY up a common view pattern
Define a Whisper.View base class that automatically parses and renders
templates and attributes defined by the subclass. This saves us a good
number of lines of code as well as some marginal memory overhead, since
we are no longer saving per-instance copies of template strings.
lilia 4cefd17ac6 Remove unused view
lilia e96aa2f06e Remove obsolete script tags
For the recently deleted notifications.js
lilia 90140556e4 Fix tests
lilia 711e211e20 Remove bootstrap tagsinput
lilia d107c3b839 Fix tests
lilia 55802f2087 Remove obsolete note on test page
Actually this page totally works from file:// now.
Matt Corallo e7f3e52b6c Remove NaCL!
Matt Corallo 5785f4033c Compile curve25519/webcrypto into libtextsecure.js
Matt Corallo 899d756469 Split tests between libtextsecure and main
Matt Corallo 8ad1a38b5b Move js files around for libtextsecure split
Matt Corallo 444b765dfc Remove unused function in _test.js
Matt Corallo fb03879d02 Re-add v3 testvectors with fixed sauce
lilia 5c2006e159 Fix build: Revert "Update some of the testvectors to v3"
This reverts commit 33429bd6f7.
Matt Corallo 33429bd6f7 Update some of the testvectors to v3
Matt Corallo 2b0866ee1f Bring protocol_test back in-line with new APIs
lilia 3d6c251fd1 Group avatars
lilia d52db8fe6f Render group updates
Not pretty, but it works. Also allows for later localization.
Copy/behavior is borrowed from the Android client.

Closes 
Fixes 
Matt Corallo 2d41385369 Remove last \t in crypto_test.js
Matt Corallo 2c781e5b62 s/\t/ /g in test/index.html
Matt Corallo 28aa0a5508 s/\t/ /g in fake_api.js
Matt Corallo 1f8b8cd0ea s/\t/ /g in testvectors.js
lilia 1a4811fcef Fix tests
lilia 4a401f07f3 Rewrite ReplayableErrors
ReplayableErrors make it easy for the frontend to handle identity key
errors by wrapping the necessary steps into one convenient little
replay() callback function.

The frontend remains agnostic to what those steps are. It just calls
replay() once the user has acknowledged the key change.

The protocol layer is responsible for registering the callbacks needed
by the IncomingIdentityKeyError and OutgoingIdentityKeyError.
Daniel Reichert 46ec7c966f Add test coverage of isEqual function
lilia 7b23e24b71 Add stringview license info and script tags
Closes 
lilia ee0d7edc0b WebSocket-Resources / websocket refactor
This commit provides the javascript complement to
[WebSocket-Resources](https://github.com/WhisperSystems/WebSocket-Resources),
allowing us to use a bi-directional request-response framework over
websockets.

See websocket-resources.js and websocket-resources_test.js
for usage details.

Along the way I also factored the websocket keepalive and reconnect
logic into its own file/wrapper object.
lilia bf22da209f Fix tests
lilia fd3a72d435 Destroy all globals
Well, not *all* globals..
lilia 470346c9c4 Save incoming messages and pass to frontend asynchronously
After a message is saved asynchronsly, fire an event and pass the
message attributes to frontend listeners via the chrome-runtime API.

This behavior is similar to the 'storage' event fired by localStorage.
lilia ced295a630 Move message and conversation storage to IndexedDB
Getting up and running with IndexedDB was pretty easy, thanks to
backbone. The tricky part was making reads and writes asynchronous.
In that process I did some refactoring on Whisper.Threads, which
has been renamed Conversations for consistency with the view names.

This change also adds the unlimitedStorage permission.
Arlo Breault 5638b20046 Expose test results to sauce
* Do what blanket does, adding another level of indirection in the
   reporting.
lilia 94634fc77a Remove nativeclient from test page
Native client won't work on Sauce. Removing for now. TODO: find a
way to gracefully disable native client in the Sauce environment.
Daniel Reichert 6125f7cbbb Add basic test coverage of toArrayBuffer function
lilia b9859ad9d4 Add some license headers
lilia 28290477f4 Nicer timestamps with momentjs
This dependency may be a little heavy for our current use case, but we can
roll with it for now and find something slimmer if it turns out yagni.

Closes 
Closes 
lilia 18378d8097 Fold nacl-common into components
lilia db69bacff1 Do fewer string conversions in tests
lilia e190582d9e Build CryptoJS components into webcrypto.js
We only depend on cryptojs for this webcrypto polyfill, so let Grunt
concatenate them into one file.

The reference in the getString helper isn't needed since we use the
built in string converters on CryptoJS's word arrays.
lilia 4518d03f43 Move protocol test to end of suite and extend timeout
The keygen test works without native client, but it takes a loooooong
tiiiiiiime.
lilia 2f58ea5f3a Fixup curve25519 module
Rename methods on the curve25519 interface to be a bit more high level.
Cleanup emscripten wrapper class, wrap long lines and such. Also add a
grunt task alias for building the emscripten compiled curve
implementation.
lilia a1a528ccdd Finish abstracting native client
Firstly, don't initialize textsecure.nativclient unless the browser
supports it. The mimetype-check trick is hewn from nacl-common.js.

Secondly, nativeclient crypto functions will all automatically wait for
the module to load before sending messages, so we needn't register any
onload callbacks outside nativeclient.js. (Previously, if you wanted to
do crypto with native client, you would have to register a call back and
wait for the module to load.) Now that the native client crypto is
encapsulated behind a nice interface, it can handle all that
onload-callback jazz internally: if the module isn't loaded when you
call a nativeclient function, return a promise that waits for the load
callback, and eventually resolves with the result of the requested
command. This removes the need for textsecure.registerOnLoadCallback.

Finally, although native client has its quirks, it's significantly
faster than the alternative (emscripten compiled js), so this commit
also lets the crypto backend use native client opportunistically, if
it's available, falling back to js if not, which should make us
compatible with older versions of chrome and chromium.
lilia 30dd43a959 Remove stray debugging test
lilia b4f4f87a7c Add emscripten-compiled curve25519 module
Build with `grunt compile && grunt concat:curve25519` after installing
emscripten.

Enable by either (a) not loading nativeclient.js or (b) setting
`textsecure.NATIVE_CLIENT = false` before loading nativeclient.js.
lilia 3d27c98845 Remove stray curve25519.js include
lilia 7c25ff845b Simplify a test
Protobufs are loaded already
lilia 69c52d51b3 Abstract out curve25519 tests
Also rename the internal variable in crypto.js to be a little more
explicit about which curve we're dealing with.
lilia df0e52a893 Split crypto_test into crypto, protocol and helpers tests
lilia 9f676af9bb Refactor crypto.js and native client interface
NB: this diff is best viewed with --ignore-whitespace

Distills crypto.js down to the hard cryptoey bones. It pulls from
webcrypto for aes and hmac, and from native client for curve25519 stuff
or potentially another object implementing the handful of needed
curve25519 functions.

Everything else formerly known as crypto, including session storage and
management, axolotl, etc.. is now protocol.js. The separation is not
quite perfect, but it's a big step.

nativeclient.js now enables talking to the native client module through
a high level interface as well as registering callbacks that will be
executed once the module is loaded. And it has tests!

Finally, this commit removes all references to the "testing_only"
object, preferring to run tests on textsecure.crypto instead.
lilia f7d92ccb5b Bowerize backbone.localstorage
lilia 6e86a2b7cf Switch libphonenumber to bower
lilia 6b034e951a Make the concat list explicit
Since I decided to preen mocha and chai, we can no longer generate the
concat file list from the preen config. We must instead explicitly list
the modules we want to concatenate. I placed this config in bower.json
so that most of the time, we won't need to change the Gruntfile.

Also added a concatenation task for test page dependencies.
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.
lilia 6e739a8a77 Add mustache to bower
lilia b351e8cea0 Switch mocha and chai to bower components
lilia 73f4f64351 Grunt preen and concat
Set up grunt with tasks for:
  * preen - deletes unused files from bower_components, configured in
      bower.json
  * concat - concatenates preened bower components, configured
      automagically from the preen config

It's worth noting that this setup assumes the order of files within a
package doesn't matter. This is usually true since we often include only
one file from the package.
lilia c8ad65efe0 Switch to bower dependencies
Checks in only the files we actually need from bower_components.
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.
lilia 245dc5b248 Update message view test
lilia cb89ac1071 Fix view test nacl path
lilia 1c76c0b546 Move storage objects to their own files
Greatly reduce the size of the ignominiously named helpers.js.
Arnaud Benard e568e2c528 Fixes - Order by timestamps with tests
lilia 0cf5ae3bbf Reorganize message view test a bit
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.
lilia 4ccb2b2f98 Add a page for testing views.
Matt Corallo 87b626d42a Fix blanket popup
Matt Corallo 615fa1075c Fix blanket for plugin (http://stackoverflow.com/questions/23022686)
Matt Corallo 5e3b7e9db8 Add missing blanket-js file
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/