Commit graph

2035 commits

Author SHA1 Message Date
Scott Nonnenberg
6b11f67dc6
Move logging to disk via bunyan
- Logging is available in main process as well as renderer process, and
  entries all go to one set of rotating files. Log entries in the
  renderer process go to DevTools as well as the console. Entries from
  the main process only show up in the console.
- We save three days of logs, one day per file in %userData%/logs
- The 'debug' object store is deleted in a new database migration
- Timestamps and level included in the new log we generate for publish
  as well as the devtools
- The bunyan API is exposed via windows.log (providing the ability to
  log at different levels, and save objects instead of just text), so we
  can move our code to it over time.

FREEBIE
2017-09-25 15:00:34 -07:00
Scott Nonnenberg
9db0cb49c4 setTimeout/setImmediate workaround for linux hangs (#1497)
FREEBIE
2017-09-22 11:06:52 -07:00
Lilia
42f2142e36 Fix RangeError on non-file drag/drop events (#1498)
ConversationView responds to drag/drop events by forwarding them to its file
input. The file input stops propagation and handles the event only if the data
transfer is type file. This means that any other data type (text, img, etc...)
causes an recursive loop of event propagation, eventually resulting in logging a
"RangeError: Maximum call stack size exceeded".

Fix by only forwarding files to the file input.

// FREEBIE
2017-09-22 09:44:09 -07:00
Scott Nonnenberg
2786baf2b5 Additional logging when we can't decrypt a user's profile (#1483)
Found a number of 'Illegal buffer' errors in an Electron log submitted
today. As far as I can tell, these same profiles are succeedig for me,
so it's time to collect more data.

FREEBIE
2017-09-18 15:33:08 -07:00
Lilia
4449a5f110 Upgrade emoji support (#1482)
* Upgrade emoji deps and move to node_modules

Add support for Emoji 3.0 and switch from bower to yarn for managing emoji
dependencies.

// FREEBIE

* Delete old emoji deps

// FREEBIE

* Don't copy emoji on windows

It is no longer necessary since the symlinked image dir is gone.

// FREEBIE

* Update emoji test

// FREEBIE

* Fix emoji tests; remove all overrides of emoji-js functions

FREEBIE
2017-09-15 13:22:11 -07:00
Scott Nonnenberg
48f625c392
Move app theming from index to app view (#1479)
Apply theming one level higher so it applies to the debug log.

// FREEBIE
2017-09-14 17:48:15 -07:00
Lilia
f698d0bc51
Better install view error handling (#1472)
If linking fails because an http request didn't connect, show a message and
allow the user to start over.

// FREEBIE
2017-09-14 17:04:03 -07:00
Lilia
fc952fbaf6
Handle provisioning messages with no profile key (#1470)
This can happen while linking to an older mobile client.

// FREEBIE
2017-09-14 17:04:03 -07:00
Lilia
c832324cb9
Trigger empty event on keepalive timeout (#1466) 2017-09-14 17:04:03 -07:00
Scott Nonnenberg
420cfc46be
Additional logging to help track down socket disconnect problems (#1469)
FREEBIE
2017-09-14 17:04:03 -07:00
Lilia
ae190fed44
Profiles (#1453)
* Add AES-GCM encryption for profiles

With tests.

* Add profileKey to DataMessage protobuf

// FREEBIE

* Decrypt and save profile names

// FREEBIE

* Save incoming profile keys

* Move pad/unpad to crypto module

// FREEBIE

* Support fetching avatars from the cdn

// FREEBIE

* Translate failed authentication errors

When AES-GCM authentication fails, webcrypto returns a very generic error. The
same error is thrown for invalid length inputs, but our earlier checks in
decryptProfile should rule out those failure modes and leave us safe to assume
that we either had bad ciphertext or the wrong key.

// FREEBIE

* Handle profile avatars (wip) and log decrypt errors

// FREEBIE

* Display profile avatars

Synced contact avatars will still override profile avatars.

* Display profile names in convo list

Only if we don't have a synced contact name.

// FREEBIE

* Make cdn url an environment config

Use different ones for staging and production

// FREEBIE

* Display profile name in conversation header

* Display profile name in group messages

* Update conversation header if profile avatar changes

// FREEBIE

* Style profile names small with ~

* Save profileKeys from contact sync messages

// FREEBIE

* Save profile keys from provisioning messages

For standalone accounts, generate a random profile key.

// FREEBIE

* Special case for one-time sync of our profile key

Android will use a contact sync message to sync a profile key from Android
clients who have just upgraded and generated their profile key. Normally we
should receive this data in a provisioning message.

// FREEBIE

* Infer profile sharing from synced data messages

* Populate profile keys on outgoing messages

Requires that `profileSharing` be set on the conversation.

// FREEBIE

* Support for the profile key update flag

When receiving a message with this flag, don't init a message record, just
process the profile key and move on.

// FREEBIE

* Display profile names in group member list

* Refresh contact's profile on profile key changes

// FREEBIE

* Catch errors on profile save

// FREEBIE

* Save our own synced contact info

Don't return early if we get a contact sync for our own number

// FREEBIE
2017-09-14 17:04:00 -07:00
Scott Nonnenberg
02571b7ae9
Copy audio-related files into js/ instead of symlinking them (#1456)
This adds a new copy:deps task into the overall default task, and it
needs to be run before running the product for the first time, and after
upgrading audio-related deps.

FREEBIE
2017-09-14 17:03:18 -07:00
Scott Nonnenberg
db869c6ce4
Scroll to bottom when adding a new message (#1450)
Added a comment to try to make this easier to understand as you read it.

FREEBIE
2017-09-14 17:03:18 -07:00
Lilia
1b444a5e23
Make os notifications respect our sound setting (#1445)
This removes our custom notification sound in favor of the system sound, and
ensures that the system sound is disabled if the user unchecks the audio
notification option.

// FREEBIE
2017-09-14 17:03:18 -07:00
Michael Kirk
f389380b26
scroll only when needed (#1441)
I believe this was just a simple typo

// FREEBIE
2017-09-14 17:03:18 -07:00
Scott Nonnenberg
af81b1a045
Fix unlinked loading screen hang, fix error dialog on start (#1440)
* main.js: check for truthiness of mainwindow, not === null

FREEBIE

* background.js: Connect to websocket even if we are unlinked

We know registration isn't done, but it has been done before. So instead
of sitting tight, we connect to the socket to start everything up and
attempt to the websocket once more.

FREEBIE
2017-09-14 17:03:18 -07:00
Lilia
50c470e53d
Certificate pinning via node XMLHttpRequest implementation (#1394)
* Add certificate pinning on https service requests

Make https requests to the server using node apis instead of browser apis, so we
can specify our own CA list, which contains only our own CA.

This protects us from MITM by a rogue CA.

As a bonus, this let's us drop the use of non-standard ports and just use good
ol' default 443 all the time, at least for http requests.

// FREEBIE

* Make certificateAuthorities an option on requests

Modify node-based xhr implementation based on driverdan/node-XMLHttpRequest,
adding support for setting certificate authorities on each request.

This allows us to pin our master CA for requests to the server and cdn but not
to the s3 attachment server, for instance. Also fix an exception when sending
binary data in a request: it is submitted as an array buffer, and must be
converted to a node Buffer since we are now using a node based request api.

// FREEBIE

* Import node-based xhr implementation

Add a copy of https://github.com/driverdan/node-XMLHttpRequest@86ff70e, and
expose it to the renderer in the preload script.

In later commits this module will be extended to support custom certificate
authorities.

// FREEBIE

* Support "arraybuffer" responseType on requests

When fetching attachments, we want the result as binary data rather than a utf8
string. This lets our node-based XMLHttpRequest honor the responseType property
if it is set on the xhr.

Note that naively using the raw `.buffer` from a node Buffer won't work, since
it is a reuseable backing buffer that is often much larger than the actual
content defined by the Buffer's offset and length.

Instead, we'll prepare a return buffer based on the response's content length
header, and incrementally write chunks of data into it as they arrive.

// FREEBIE

* Switch to self-signed server endpoint

* Log more error info on failed requests

With the node-based xhr, relevant error info are stored in statusText and
responseText when a request fails.

// FREEBIE

* Add node-based websocket w/ support for custom CA

// FREEBIE

* Support handling array buffers instead of blobs

Our node-based websocket calls onmessage with an arraybuffer instead of a blob.
For robustness (on the off chance we switch or update the socket implementation
agian) I've kept the machinery for converting blobs to array buffers.

// FREEBIE

* Destroy all wacky server ports

// FREEBIE
2017-09-14 17:03:17 -07:00
Scott Nonnenberg
7a2c8e815c
Import: Wait until db writes resolve before saying we're done (#1401)
FREEBIE
2017-09-14 17:03:17 -07:00
Scott Nonnenberg
5099ca0ccd
Merge locale-provided strings into english for failover support
FREEBIE
2017-09-14 17:03:17 -07:00
Scott Nonnenberg
e8c7e31363
Multi-error, multi-language, and cross-platform spell-check
FREEBIE
2017-09-14 17:03:17 -07:00
lilia
ff1bad674e
Fix exception in install view
These lines throw TypeErrors for previously registered clients.

// FREEBIE
2017-09-14 17:03:17 -07:00
Scott Nonnenberg
ac237b9e31
AppView: Store initialLoadComplete value for late openInbox
FREEBIE
2017-09-14 17:03:17 -07:00
Scott Nonnenberg
90cc0949b6
InstallView: Refactor step numbers into enum
FREEBIE
2017-09-14 17:03:16 -07:00
Scott Nonnenberg
7f8ade7747
Remove migration-related functionality, leaving export stuff
FREEBIE
2017-09-14 17:03:14 -07:00
Scott Nonnenberg
413fba80af
Separate dir selection from import, better import button text
This allows us to show the 'import in progress' screen only when the
user has successfully selected a directory.

FREEBIE
2017-09-14 17:02:46 -07:00
Scott Nonnenberg
0fbe43c2dc
Protobufs: More logging on failure to load protobufs, fix tests
FREEBIE
2017-09-14 17:02:45 -07:00
Scott Nonnenberg
ff1cb3598d
Remove step 1 of previous setup flow, replaced by choice screen
FREEBIE
2017-09-14 17:02:45 -07:00
Scott Nonnenberg
ba347744ff
Import: choice on first startup, workflow, ported to Node.js fs API
FREEBIE
2017-09-14 17:02:43 -07:00
Scott Nonnenberg
9c8fe1a9d8
Reschedule all timers on time travel, set interval back to 1000ms
FREEBIE
2017-09-14 16:53:53 -07:00
Scott Nonnenberg
bc437095f6
Calm time travel checks, don't continually reschedule key rotation
FREEBIE
2017-09-14 16:53:53 -07:00
Scott Nonnenberg
f37af04818
AppView.createInbox() - set this.inboxView immediately to be ready
If the 'empty' event is fired between the updateInbox() call and the
new InboxView() call afterwards, then the loading screen will never go
away. We fix that by immediately creating the InboxView but only adding
it to the DOM when the backing data is ready.

FREEBIE
2017-09-14 16:53:53 -07:00
Scott Nonnenberg
eaf31705cc
A number of fixes for loading screen, recent rebase
FREEBIE
2017-09-14 16:53:52 -07:00
lilia
854374dc7c
Remove the old debug log menu item 2017-09-14 16:53:52 -07:00
lilia
11633d7d87
Make debug log available from the installer
Move debug log from inbox view to app view so it can be opened regardless of
whether we are showing the inbox view or the installer.

// FREEBIE
2017-09-14 16:53:52 -07:00
lilia
04e40043d2
Add View -> Debug Log to menu bar
Just send an event from the main process to the renderer,
The latter routes it the appropriate view method.

For now it's a no-op unless the main window exists and it is showing the inbox,
which will be addressed in a future commit.

// FREEBIE
2017-09-14 16:53:52 -07:00
Scott Nonnenberg
bd3b8ae9f8
Note how many debug logs we have after we load them from DB
FREEBIE
2017-09-14 16:53:52 -07:00
Scott Nonnenberg
87a1fcc406
Fix trimming of debug log: remove first, use proper iteration var
FREEBIE
2017-09-14 16:53:52 -07:00
Scott Nonnenberg
e4ceb21002
Use two interations instead of while loop for trimming log
FREEBIE
2017-09-14 16:53:51 -07:00
lilia
02df917f3a
Fix $name$ in confirmation dialogs
Our i18n shim supports multiple substitutions if you give it an array of strings
to use as replacements.

// FREEBIE
2017-09-14 16:53:51 -07:00
Scott Nonnenberg
8f0b0b121a
Add missing comma in ConversationView event list
FREEBIE
2017-09-14 16:53:49 -07:00
Scott Nonnenberg
3a3aa3efb6
Remove test/protos symlink, use window.PROTO_ROOT for config 2017-09-14 16:53:48 -07:00
Scott Nonnenberg
4402a91976
Use correct locale, fall back to en if we don't have translations
FREEBIE
2017-09-14 16:53:47 -07:00
lilia
a2b2bd4bf3
Fix relative paths
// FREEBIE
2017-09-14 16:53:46 -07:00
lilia
26cece71c6
Prepopulate phone number on standalone page 2017-09-14 16:53:46 -07:00
lilia
4c5835e0af
Remove remaining call to extension.notification.update 2017-09-14 16:53:45 -07:00
lilia
7c6da5a157
Make 'Restart Signal' actually restart Signal
Previously it would just reload the page.

// FREEBIE
2017-09-14 16:53:45 -07:00
lilia
d85ccbad4f
Remove extension.notification 2017-09-14 16:53:45 -07:00
lilia
bd7f4febaa
Remove dead code
These are all unused, obsolete, or no-op functions at this point.

// FREEBIE
2017-09-14 16:53:45 -07:00
lilia
c4ccf7c8e3
Inline setUnreadCount
// FREEBIE
2017-09-14 16:53:44 -07:00
lilia
29b07950a3
Fix scroll reset after clicking on a notification 2017-09-14 16:53:43 -07:00
lilia
2528acc717
Remove platform-specific links from install flow
Mostly to satisfy the mac app store.

// FREEBIE
2017-09-14 16:53:43 -07:00
lilia
e65007e297
Tweak default notification content
Change the placeholder content for when notifications are configured for
count-only or sender-only. Remove some options that are no longer
supported.

// FREEBIE
2017-09-14 16:53:43 -07:00
lilia
79872be9f5
Unfurl notifications
Since we no longer have support for list-style notifications, stop
coalescing notifications into batches and just show contents of the last
message received. Also open the window when clicking on a notification
if it has previously been closed.

// FREEBIE
2017-09-14 16:53:43 -07:00
lilia
4d981c439a
Remove number validation from install view
Allows our special cased test numbers to link desktop clients.

// FREEBIE
2017-09-14 16:53:42 -07:00
lilia
76cd650577
Restore missing contactsync listeners
Fix installer getting stuck on "Generating Keys"

// FREEBIE
2017-09-14 16:53:42 -07:00
lilia
d2179b2c3f
Conversation view handles drag n drop events
By forwarding them to its file input.

// FREEBIE
2017-09-14 16:53:41 -07:00
Scott Nonnenberg
601081c1b8
More refactoring to reduce global event dependencies
All Whisper.events listeners are now defined and bound in background.js,
and we no longer need global methods for opening the inbox and
conversation views, as those are handled by AppView or internally by
InboxView.

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
8d32a3bebd
Remove dead code
This view doesn't contain any elements with class openInbox.

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
4b96722d52
Hide initially empty error in standalone view
// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
008e978b8a
Make standalone registration more accessible
Add buttons for switching between the linking flow and the standalone
registration flow. The button and standalone registration are only
availble in a development environment.

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
a2e0fa59c1
Collect references to Whisper.events
Fixup

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
f7c7e2251d
Remove unused method
This is now handled in AppView

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
0c9cca08ba
Draw attention to the window on new messages
// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
ea930d53ae
Set badge count
This is displayed on the launcher icon on linux/mac

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
d025b57656
Remove unused method 2017-09-14 16:53:41 -07:00
lilia
6b70aecf29
Fix opening a conversation from notification 2017-09-14 16:53:40 -07:00
lilia
b6e5439860
Fix saving attachments
// FREEBIE
2017-09-14 16:53:39 -07:00
lilia
878b15c288
Add node version to debug log
The chrome, electron, and signal versions are already included in the
user agent string.

// FREEBIE
2017-09-14 16:53:39 -07:00
lilia
112f5a00ca
Delete unused files
// FREEBIE
2017-09-14 16:53:39 -07:00
lilia
de3816b094
Get standalone registration working in development
Whisper.events.trigger('openStandalone') to open the standalone
registration view.

// FREEBIE
2017-09-14 16:53:39 -07:00
lilia
3a9f4f0df3
Flatten database migrations
We can compress or toss out most of these one-off data migrations since
everyone starts from scratch with electron.

// FREEBIE
2017-09-14 16:53:39 -07:00
lilia
a55c61a3ba
Use local var environment rather than NODE_ENV
Traditionally, NODE_ENV refers to an environment variable. For clarity,
let's keep it that way and don't reuse it in the renderer. Also, add a
note about explicitly overriding env vars for node-config.

// FREEBIE
2017-09-14 16:53:38 -07:00
lilia
e7e030a5e2
Build expiration date
Add the buildExpiration config and add it to the renderer's config
object. Use grunt to write the build expiration to
config/local-production.json which will override the default value (no
expiration) in production. Finally, run this grunt task as part of the
build process.

// FREEBIE
2017-09-14 16:53:38 -07:00
lilia
c83dbc1bf0
Rename window.env to window.config
Also normalize to camelCase for configs.

// FREEBIE
2017-09-14 16:53:38 -07:00
lilia
6574958087
Remove check for open windows
We now live in a single-window world.

// FREEBIE
2017-09-14 16:53:38 -07:00
lilia
e4e41140c4
Refactor app view
Introduce a top level view for navigating between the inbox and the
installer, enabling an in-window relink flow. Navigation is driven
through the openInbox and openInstaller global events.

// FREEBIE
2017-09-14 16:53:37 -07:00
lilia
3f5505907f
Fix setUnreadCount 2017-09-14 16:53:37 -07:00
lilia
75dbc27cfa
Fix i18n of timer options
It is important to return something falsey in the case where there is
no translation.

// FREEBIE
2017-09-14 16:53:37 -07:00
lilia
72c3dc286c
Remove onLaunched handler
This is now handled outside the renderer.

// FREEBIE
2017-09-14 16:53:37 -07:00
lilia
83a020cc5e
Move focus listeners to their own file
// FREEBIE
2017-09-14 16:53:37 -07:00
lilia
7e1bee1082
Configure app/build using node config
Add environment-specific configs under `./config` and integrate with the
build system. Also changes package.json `files` from blacklist to
whitelist.

// FREEBIE
2017-09-14 16:53:36 -07:00
lilia
34042415e9
Database logging cancels persistent debug log storage
Database logging is helpful as a debugging tool, but it creates an
infinite loop with the debug log, which wants to write to the database,
which wants to write to the log, which wants to write to the database,
which wants to write to the log, which wants to write to the database,
which wants to write to the log, which wants to write to the database...

// FREEBIE
2017-09-14 16:53:36 -07:00
lilia
a381d9c975
Fix focus detection 2017-09-14 16:53:36 -07:00
lilia
5650748961
Fix pre-populated device name 2017-09-14 16:53:36 -07:00
lilia
25b0fbd949
Fix exceptions on window close
The stopListening function was being passed the close event as an
argument, which caused it to throw.

// FREEBIE
2017-09-14 16:53:36 -07:00
lilia
49cdc98386
Fix lightbox 2017-09-14 16:53:35 -07:00
lilia
acd19fd759
Fix inbox styles 2017-09-14 16:53:35 -07:00
lilia
86d703bc87
Fix debug log 2017-09-14 16:53:35 -07:00
lilia
63657db3be
Quick fix for i18n
Just use the english locale for now. Load locale data from the
filesystem in the main process and pass it to the renderer preload
script via ipc. Note that we need the locale data to be available by the
time view scripts are loaded.

// FREEBIE
2017-09-14 16:53:35 -07:00
lilia
88893079d2
Fix restart 2017-09-14 16:53:35 -07:00
lilia
2bbd0d58c6
Separate development and production environments
Set NODE_ENV at run time or build time to switch the app between dev and
production modes.

At build time, the current NODE_ENV will be included in the packaged
app's package.json file. At runtime we read NODE_ENV from package.json,
but also allow the local environment variable to override. A query
string parsed by a preload script exposes the value to the renderer,
which then determines whether we use the staging or production server.
Additionally, different environments have different user data
directories.

// FREEBIE
2017-09-14 16:53:35 -07:00
lilia
285b5ce062
Get install flow working in main window
// FREEBIE
2017-09-14 16:53:35 -07:00
lilia
6686621b0b
Fix file dialog 2017-09-14 16:53:34 -07:00
lilia
5a6e65d11b
Merge index.html into background.html
Nothing stops us from rendering the inbox in the background page, since
it is no longer a background page at all. TODO: intercept window close
events to hide this window instead of closing it unless the app is quit
explicitly.

// FREEBIE
2017-09-14 16:53:34 -07:00
lilia
859d49b3f4
Use relative paths
// FREEBIE
2017-09-14 16:53:34 -07:00
lilia
95e809636a
Quick fix for undefined references to chrome.* 2017-09-14 16:53:34 -07:00
Scott Nonnenberg
ff6dc786f9 Force full contact/group import on next launch if not first run (#1476)
* Force full contact/group import on next launch (if not first run)

FREEBIE

* Don't update contact sync key in storage on every reconnect

FREEBIE
2017-09-14 12:08:10 -07:00
Scott Nonnenberg
00e1a6a36a Export: Improve usability - timing expectations, install button (#1474)
Because export might take a couple minutes, we now set expectations
that it might take 'several minutes' instead of just 'please wait.'

We also promote 'Install new Signal Desktop' from a text link in the
instructions to a button. This is important on the 'Completed' screen
because it is bigger and to the left of the 'Export Again' button, which
previously drew primary focus on that screen.

Lastly, we also remove the title-specific element of the support link,
so we're resilient to title changes in the future.

FREEBIE
2017-09-13 13:33:40 -07:00
Scott Nonnenberg
1e694fe8d7 Log entry max to 2k, remove logging in hot codepaths (#1459)
On a recent trip through a CPU profile taken while Signal Desktop
churned through a large backlog of messages, it was clear that
console.log was a major source of time spent, primarily the sort
operation required after every new entry is added to the Backbone
collection. So, three different techniques to combat this:

1) Reduce the maximum number of entries in the collection from 5k to 2k
2) No more logging of add/update/remove queue in MessageReceiver
3) No more log entries in Message.handleDataMessage main codepath

FREEBIE
2017-09-12 09:34:49 -07:00
Scott Nonnenberg
69af8d2651 Don't show notification for verified state change with yourself (#1454)
* Don't show notifications for verified state change with yourself

It's confusing to users, and it really doesn't mean anything anyway.

FREEBIE

* Add log statement that we've suppressed a verified notification

FREEBIE
2017-09-08 11:14:01 -07:00