Commit Graph

284 Commits

Author SHA1 Message Date
Scott Nonnenberg deb9bab086
Remove duplicate showWindow method (#1918) 2018-01-03 18:18:13 -08:00
Scott Nonnenberg 5cf320e429
Show window if hidden when second instance attempts to start (#1897) 2017-12-14 12:27:52 -08:00
Jon Roberts bc399c6777 a slightly more reasonable min-width (#1863) 2017-12-14 11:31:07 -08:00
Scott Nonnenberg b17a67ec65
Support pass-through proxies with HTTPS_PROXY env var (#1878)
We've simplified; HTTPS_PROXY or https_proxy is used for all requests.

We also require that only our self-signed certificates are used for
secure traffic. That rules out all SSL-terminating MITM proxies, since
we don't trust their root certificate.

Once we're sure that this system works for people, we'll improve config
on MacOS and Windows.
2017-12-08 10:38:01 -08:00
Scott Nonnenberg f013eed9d1
Merge branch 'master' into development
Bringing beta up to date with production v1.0.40
2017-12-04 16:08:19 -08:00
Scott Nonnenberg c195ba2630
Save prekeys optimistically, track confirms, new clean behavior (#1846)
* Re-enable libtextsecure unit tests, get passing, run in CI

* Save prekeys optimistically, track confirmed, new clean behavior

* Eliminate potential conflicts when rotating on startup

* Remove last symlink: get libtextsecure tests running on windows
2017-12-01 13:35:39 -08:00
Scott Nonnenberg 6cb8b99637
Harden our handling of config.json, verify that window is visible (#1830)
* Validate config-provided locatio against available screens

* Increase buffer around screen from 10px to 100px

* Protect against null mainWindow, fix height/width typo

* Properly handle missing x and y

* Move to _.isNumber for checking x and y

* Use greater than or less than to allow for y = 0, exactly 100px
2017-11-30 11:58:00 -08:00
johannes karoff 89297af5d2 add urgency hints for linux platform (#1820) 2017-11-27 15:14:48 -08:00
Martino Pilia cd50fe3123 Add a tray icon to the application (#1676)
This commit adds a tray icon to the application, shown in the system
tray bar, that can be used to minimise the application window.  This
is a common feature on most desktop messaging apps (e.g. Telegram
Desktop or Slack) and allows to save space in the system task bar.

The tray icon provides a context menu that contains a button to
show/hide the application window, and a button to quit the
application. When the tray icon is clicked, the visibility of the
window is toggled.  When the close (x) button of the window is
pressed, the application is not terminated but minimised to the tray
icon instead (it can be terminated by using the "Quit" entry in the
File menu or in the context menu of the tray icon).

The tray icon is disabled by default, and two command line arguments
are available to enable it:
  --use-tray-icon: enables the tray icon
  --start-in-tray: enables the tray icon and the application starts
                   minimised in the tray bar

Resolves: #1480
2017-11-27 14:48:09 -08:00
Scott Nonnenberg cdfdd6b381
Fix notifications: windows -> window, serialize false setting 2017-11-22 14:32:39 -08:00
Scott Nonnenberg 16ad94148a
Introduce library for notifications on downlevel windows (#1812) 2017-11-22 13:50:52 -08:00
Scott Nonnenberg 0e328f3911
Merge branch 'master' into development
This catches the development branch up with v1.0.39 in master.
2017-11-21 18:25:59 -08:00
Scott Nonnenberg 1c455c83e0
Set parent window for about/new version, escape to close (#1795)
* Set parent window for about/new version, escape to close

* Exclude jquery from jshint run
2017-11-21 15:23:18 -08:00
Scott Nonnenberg 48ec4003dd
Use icon from /images for window creation (#1738) 2017-11-08 19:11:33 -08:00
Scott Nonnenberg 1fdaa00660
Add icon to the window manually on creation (#1735)
This supplements the work we already do to tell the OS about our icon.
2017-11-08 17:33:20 -08:00
Scott Nonnenberg 30c5b62687
Don't call createWindow before the app is ready for it (#1665) 2017-11-02 08:13:41 -07:00
Scott Nonnenberg c94d4efd18
Beta versions support: SxS support, in-app env/instance display (#1606)
* Script for beta config; unique data dir, in-app env/type display

To release a beta build, increment the version and add -beta-N to the
end, then go through all the standard release activities.

The prepare-build npm script then updates key bits of the package.json
to ensure that the beta build can be installed alongside a production
build. This includes a new name ('Signal Beta') and a different location
for application data.

Note: Beta builds can be installed alongside production builds.

As part of this, a couple new bits of data are shown across the app:

- Environment (development or test, not shown if production)
- App Instance (disabled in production; used for multiple accounts)

These are shown in:

- The window title - both environment and app instance. You can tell
  beta builds because the app name, preceding these data bits, is
  different.
- The about window - both environment and app instance. You can tell
  beta builds from the version number.
- The header added to the debug log - just environment. The version
  number will tell us if it's a beta build, and app instance isn't
  helpful.

* Turn on single-window mode in non-production modes

Because it's really frightening when you see 'unable to read from db'
errors in the console.

* aply.sh: More instructions for initial setup and testing

* Gruntfile: Get consistent with use of package.json datas

* Linux: manually update desktop keys, since macros not available
2017-10-30 13:57:13 -07:00
Scott Nonnenberg 07d19d12c2 Reduce logging when the window moves (#1568) 2017-10-18 11:57:48 -07:00
Scott Nonnenberg 75cece3358 Improve OS menu (#1563)
* Remove reload options, new file/help menus, tools/log at bottom

* Further menus refactor: install handlers at template creation

* WIP: Further tune menus, add custom about window

* New About window, new help menu items, menu labels now i18n

* Default device name on registration is now computer hostname

The OS of the device makes sense for those of us testing across a lot of
different OSes. And maybe for a user with just one desktop device. But
most users with multiple desktop devices are using the same OS for both.

* About window: Only show window when content is ready

* Fix typo in app/menu.js
2017-10-13 16:49:16 -07:00
Axel 3dc3667b45 Add setting to hide menu bar (#1551)
* Add setting to hide menu bar

Add a setting in the themes section to hide the menu bar.
The menu bar is not needed in everyday use and might not fit in with
signals dark theme. The hidden menu bar can still be shown by pressing
alt.
autoHideMenuBar is added to windowConfig and saved and restored on
startup to prevent flickering.

* Trigger events only when related setting changes

Set the event to trigger on instanciation of the view.
Notification settings no longer reapply the theme or menu bar settings.

* Save window state when closing the window

When not moving or resizing the window, no BrowserWindow config would be
created and saved.
2017-10-13 11:39:18 -07:00
Lilia 23700e1776 Re-enable fullscreen on OSX (#1525)
* Re-enable fullscreen on OSX

We were inadvertantly disabling the fullscreen button due to a quick of the
BrowserWindow api. Add some guards to make sure we no longer save or use a
previously-stored `fullscreen: false` in our window configs.

// FREEBIE

* Use logger.info instead of console.log

Note the use of stringify to make config object safe for bunyan
https://github.com/trentm/node-bunyan#log-method-api

// FREEBIE
2017-10-03 11:07:40 -07:00
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
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 272955b9d6
focus() visible window on show-window instead of show() (#1455)
When clicking on a notification in Windows when a window had been stuck
to one side of the screen using Snap, the window would be repositioned.

Fixes #1453

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
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 8243f25e5a
Fix auto-update dialog now that locale-loading has been changed
FREEBIE
2017-09-14 16:53:52 -07:00
Scott Nonnenberg 53d1e7e6c7
Load locale information only after application's 'ready' event
FREEBIE
2017-09-14 16:53:51 -07:00
David Balatero a6af40e9f9
Couple of semicolons to match style 2017-09-14 16:53:51 -07:00
David Balatero 8f30e13ec1
Rename autoupdate -> auto_update, remove redundancy 2017-09-14 16:53:51 -07:00
David Balatero ceaff68d55
Refactor locale to only expose the data we care about 2017-09-14 16:53:51 -07:00
David Balatero 5e5ca80a6e
Refactor configuration out into reusable files 2017-09-14 16:53:51 -07:00
David Balatero ed831dacd0
Refactor external source files to live in app/ 2017-09-14 16:53:50 -07:00
David Balatero db62494109
Force app to quit on Mac when we auto update 2017-09-14 16:53:50 -07:00
David Balatero 07d8b862db
Use app interface to get the version 2017-09-14 16:53:50 -07:00
David Balatero 1b2e94b100
Add a fallback message when no locale is set 2017-09-14 16:53:50 -07:00
David Balatero 9a7f4ae41c
Show dialog box when there's an update for download 2017-09-14 16:53:50 -07:00
David Balatero 9c21c3c7e6
Enforce a minimum window size 2017-09-14 16:53:50 -07:00
Scott Nonnenberg 0ad35cc0e6
Move electron-config init below our change to appData path 2017-09-14 16:53:48 -07:00
Scott Nonnenberg 69d4a77f1e
Remember window position, size, and maximized/fullscreen status
FREEBIE
2017-09-14 16:53:48 -07:00
Scott Nonnenberg fd8b8910a3
Eliminate HIDE_DEV_TOOLS environment variable. Hide in test env.
FREEBIE
2017-09-14 16:53:47 -07:00
Scott Nonnenberg f31125eccc
process.env.NODE_ENV -> environment
FREEBIE
2017-09-14 16:53:47 -07:00
Scott Nonnenberg 255ba58b2e
Enable complete exit of Electron process after `grunt unit-tests`
FREEBIE
2017-09-14 16:53:47 -07:00
Scott Nonnenberg 5635095d1a
Initial version of `grunt unit-tests`, tests from command-line
FREEBIE
2017-09-14 16:53:47 -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
Scott Nonnenberg b4e3cc0e6c
Load test page and run tests on start when NODE_ENV=test
FREEBIE
2017-09-14 16:53:46 -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 2ccd8c21f3
Limit hidden window behavior to osx
Only on osx is it customary to remain running in the background when the
window is closed.

// FREEBIE
2017-09-14 16:53:45 -07:00
lilia cfb1e62603
Fix menu on non-darwin 2017-09-14 16:53:45 -07:00
lilia b5649a6874
Add ability to unhide the window from the renderer
via ipc, for instance if a notification is clicked but the window is
closed/hidden.

// FREEBIE
2017-09-14 16:53:43 -07:00
lilia d018fa63ff
Add Show option under the Window menu
Window > Show will reveal the mainWindow after it has been closed.

// FREEBIE
2017-09-14 16:53:42 -07:00
lilia d71250b752
More main process logging
// FREEBIE
2017-09-14 16:53:42 -07:00
lilia b66a887184
Don't check for updates in the MAS build
// FREEBIE
2017-09-14 16:53:42 -07:00
lilia ade5e593a7
Add some logging to main process startup sequence
// FREEBIE
2017-09-14 16:53:42 -07:00
lilia c2014b062d
Don't makeSingleInstance in a MAS build
It seems that makeSingleInstance will always return true in the MAS
build.* Luckily, OSX mostly enforces single-instance for us when opening
the app from Finder. If the user attempts to run a second instance from
the command line, it will create a window but fail to load.

*TODO: Revisit why makeSingleInstance is broken in the MAS build.

// FREEBIE
2017-09-14 16:53:42 -07:00
lilia 84fba7d968
Prevent window navigation
Navigation is the default handler for file drag and drop events on the
window.

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia c1fa33327d
Allow multi-instance in development 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 44adc04395
Closing the window hides the window on mac
Clicking the dock icon restores it again.

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia 77d5ef2f68
Add spellcheck
As of Electron 1.6.5, this requires disabling the sandbox in order to
get access to the `webFrame` api.

// 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 46b0146a4c
Log user data directory 2017-09-14 16:53:38 -07:00
lilia 934d06b512
Override environment vars in production
Don't allow environment vars to muck with configs in production.

// FREEBIE
2017-09-14 16:53:38 -07:00
lilia 14b65a9dce
Log on app ready 2017-09-14 16:53:38 -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 d0fc2f7e71
Ensure that package.json environment > NODE_ENV
We only set the environment in package.json when it is packaged for
deployment. When we do that, we don't want to allow a local environment
variable to override it.

// 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 590284e4cb
Open links in the default browser 2017-09-14 16:53:37 -07:00
lilia 9f47ff9040
Adjust initial window size 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 449c3e2428
Don't auto-open devtools in prod 2017-09-14 16:53:36 -07:00
lilia e112217095
Add standard menus 2017-09-14 16:53:36 -07:00
lilia 3b287185ef
Fix autoUpdater error in development 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 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 b176bd756c
Ensure app is single-instance
Remove some comments.

// FREEBIE
2017-09-14 16:53:35 -07:00
lilia f4df38735c
Enable sandbox
// FREEBIE
2017-09-14 16:53:35 -07:00
lilia 28e5c04633
Set AUMID to appId
It is also important to set the Application User Model ID (AUMID) to the
appId of the application, in order for notifications on Windows 8/8.1 to
function and for Window 10 notifications to display the app icon within
the notifications by default. The AUIMD should be set within the Main
process and before any BrowserWindows have been opened, it is normally
the first piece of code executed.

https://github.com/electron-userland/electron-builder/wiki/NSIS#guid-vs-application-name

// FREEBIE
2017-09-14 16:53:34 -07:00
lilia dcc6f599a2
Auto-update hourly 2017-09-14 16:53:34 -07:00
lilia 2cf7ea0a94
Hello Electron
In package.json, define our main entry point for electron, and add a
node script to start it up.

Add main.js from Electron/electron-quick-start with two modifications.
1. Load background.html instead of index.html
2. Disable node integration in the renderer

At this point we can load the background page in a window
with `npm start`, though it currently breaks on missing chrome app APIs.

// FREEBIE
2017-09-14 16:53:28 -07:00