diff --git a/src/js/app-config.js b/src/js/app-config.js index 09dea00..5d6ff9c 100644 --- a/src/js/app-config.js +++ b/src/js/app-config.js @@ -1,52 +1,60 @@ -define([], function() { - 'use strict'; +define(function(require) { + 'use strict'; - /** - * Create the application namespace - */ - var app = {}; + var _ = require('underscore'), + app = {}, + cloudUrl, clientId; - /** - * Global app configurations - */ - app.config = { - cloudUrl: 'https://keys.whiteout.io', - symKeySize: 128, - symIvSize: 128, - asymKeySize: 2048, - workerPath: 'js', - gmail: { - clientId: '440907777130.apps.googleusercontent.com', - imap: { - secure: true, - port: 993, - host: 'imap.gmail.com' - }, - smtp: { - secure: true, - port: 465, - host: 'smtp.gmail.com' - } - }, - checkOutboxInterval: 30000, - iconPath: '/img/icon.png', - verificationUrl: '/verify/' - }; + // parse manifest to get configurations for current runtime + try { + var manifest = chrome.runtime.getManifest(); + cloudUrl = _.find(manifest.permissions, function(permission) { + return typeof permission === 'string' && permission.indexOf('http') === 0; + }); + clientId = manifest.oauth2.client_id; + } catch (e) {} - /** - * Strings are maintained here - */ - app.string = { - subjectPrefix: '[whiteout] ', - invitationSubject: 'Invitation to a private conversation', - invitationMessage: 'I would like to invite you to a private conversation. To read my encrypted messages, simply install Whiteout Mail for Chrome. The app is really easy to use and automatically encrypts sent emails, so that only the two of us can read them: https://chrome.google.com/webstore/detail/jjgghafhamholjigjoghcfcekhkonijg', - message: 'this is a private conversation. To read my encrypted message below, simply install Whiteout Mail for Chrome. The app is really easy to use and automatically encrypts sent emails, so that only the two of us can read them: https://chrome.google.com/webstore/detail/jjgghafhamholjigjoghcfcekhkonijg', - cryptPrefix: '-----BEGIN PGP MESSAGE-----', - cryptSuffix: '-----END PGP MESSAGE-----', - signature: 'Sent securely from whiteout mail', - webSite: 'http://whiteout.io', - verificationSubject: 'New public key uploaded' - }; + /** + * Global app configurations + */ + app.config = { + cloudUrl: cloudUrl || 'https://keys.whiteout.io', + symKeySize: 128, + symIvSize: 128, + asymKeySize: 2048, + workerPath: 'js', + gmail: { + clientId: clientId || '440907777130.apps.googleusercontent.com', + imap: { + secure: true, + port: 993, + host: 'imap.gmail.com' + }, + smtp: { + secure: true, + port: 465, + host: 'smtp.gmail.com' + } + }, + checkOutboxInterval: 5000, + iconPath: '/img/icon.png', + verificationUrl: '/verify/' + }; - return app; + /** + * Strings are maintained here + */ + app.string = { + subjectPrefix: '[whiteout] ', + invitationSubject: 'Invitation to a private conversation', + invitationMessage: 'I would like to invite you to a private conversation. To read my encrypted messages, simply install Whiteout Mail for Chrome. The app is really easy to use and automatically encrypts sent emails, so that only the two of us can read them: https://chrome.google.com/webstore/detail/jjgghafhamholjigjoghcfcekhkonijg', + message: 'this is a private conversation. To read my encrypted message below, simply install Whiteout Mail for Chrome. The app is really easy to use and automatically encrypts sent emails, so that only the two of us can read them: https://chrome.google.com/webstore/detail/jjgghafhamholjigjoghcfcekhkonijg', + cryptPrefix: '-----BEGIN PGP MESSAGE-----', + cryptSuffix: '-----END PGP MESSAGE-----', + signature: 'Sent securely from whiteout mail', + webSite: 'http://whiteout.io', + verificationSubject: 'New public key uploaded' + }; + + return app; }); \ No newline at end of file diff --git a/src/js/controller/navigation.js b/src/js/controller/navigation.js index 0b4063d..300a5b6 100644 --- a/src/js/controller/navigation.js +++ b/src/js/controller/navigation.js @@ -36,6 +36,19 @@ define(function(require) { $scope.state.nav.toggle(false); }; + $scope.onOutboxUpdate = function(err, count) { + if (err) { + $scope.onError(err); + return; + } + + var outbox = _.findWhere($scope.folders, { + type: 'Outbox' + }); + outbox.count = count; + $scope.$apply(); + }; + // // Start // @@ -64,7 +77,9 @@ define(function(require) { }); // start checking outbox periodically - outboxBo.startChecking(onOutboxUpdate); + outboxBo.startChecking($scope.onOutboxUpdate); + // make function available globally for write controller + $scope.emptyOutbox = outboxBo._processOutbox; callback(folders); $scope.$apply(); @@ -94,22 +109,6 @@ define(function(require) { path: 'TRASH' }]); } - - // update outbox count - - function onOutboxUpdate(err, count) { - if (err) { - $scope.onError(err); - return; - } - - var outbox = _.findWhere($scope.folders, { - type: 'Outbox' - }); - outbox.count = count; - $scope.$apply(); - } - }; // diff --git a/src/js/controller/write.js b/src/js/controller/write.js index ca5a5cd..a4f5138 100644 --- a/src/js/controller/write.js +++ b/src/js/controller/write.js @@ -146,15 +146,6 @@ define(function(require) { return; } - // only allow secure recipients until invitation is implemented - if (!$scope.toKey) { - $scope.onError({ - errMsg: 'Invitations not yet supported!', - sync: true - }); - return; - } - // remove generated html from body body = parseBody($scope.body); @@ -184,7 +175,7 @@ define(function(require) { $scope.state.writer.close(); $scope.$apply(); - $scope.emptyOutbox(); + $scope.emptyOutbox($scope.onOutboxUpdate); markAnwsered(); }); diff --git a/src/js/dao/invitation-dao.js b/src/js/dao/invitation-dao.js index 5fbfc97..517a5ac 100644 --- a/src/js/dao/invitation-dao.js +++ b/src/js/dao/invitation-dao.js @@ -35,7 +35,7 @@ define(function() { return; } - this._restDao.put(null, uri(options.recipient, options.sender), completed); + this._restDao.put({}, uri(options.recipient, options.sender), completed); function completed(error, res, status) { if (error) { @@ -71,7 +71,10 @@ define(function() { return; } - this._restDao.get(null, uri(options.recipient, options.sender), completed); + this._restDao.get({ + uri: uri(options.recipient, options.sender), + type: 'text' + }, completed); function completed(error, res, status) { // 404 is a meaningful return value from the web service diff --git a/src/manifest.json b/src/manifest.json index bb5ca8b..4a81d02 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -12,7 +12,7 @@ "fileSystem": ["write"] }, "notifications", - "https://keys.whiteout.io/", + "https://keys-test.whiteout.io", "identity", { "socket": [ "tcp-connect:imap.gmail.com:993",