mirror of
https://github.com/moparisthebest/mail
synced 2024-12-23 07:48:48 -05:00
Merge pull request #149 from whiteout-io/dev/WO-653
Use manifest config for webmail
This commit is contained in:
commit
a728e34e32
@ -18,6 +18,7 @@
|
|||||||
"unused": true,
|
"unused": true,
|
||||||
|
|
||||||
"predef": [
|
"predef": [
|
||||||
|
"$",
|
||||||
"self",
|
"self",
|
||||||
"importScripts",
|
"importScripts",
|
||||||
"console",
|
"console",
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "whiteout-mail",
|
"name": "whiteout-mail",
|
||||||
"version": "0.0.1",
|
|
||||||
"description": "Mail App with integrated OpenPGP encryption.",
|
"description": "Mail App with integrated OpenPGP encryption.",
|
||||||
"author": "Whiteout Networks",
|
"author": "Whiteout Networks",
|
||||||
"homepage": "https://whiteout.io",
|
"homepage": "https://whiteout.io",
|
||||||
|
@ -1,34 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var appVersion, cloudUrl, keychainUrl, clientId;
|
|
||||||
|
|
||||||
// parse manifest to get configurations for current runtime
|
|
||||||
try {
|
|
||||||
var manifest = chrome.runtime.getManifest();
|
|
||||||
// get key server base url
|
|
||||||
cloudUrl = _.find(manifest.permissions, function(permission) {
|
|
||||||
return typeof permission === 'string' && permission.indexOf('https://keys') === 0;
|
|
||||||
});
|
|
||||||
// remove last '/' from url due to required syntax in manifest
|
|
||||||
cloudUrl = cloudUrl.substring(0, cloudUrl.length - 1);
|
|
||||||
// get keychain server base url
|
|
||||||
keychainUrl = _.find(manifest.permissions, function(permission) {
|
|
||||||
return typeof permission === 'string' && permission.indexOf('https://keychain') === 0;
|
|
||||||
});
|
|
||||||
// remove last '/' from url due to required syntax in manifest
|
|
||||||
keychainUrl = keychainUrl.substring(0, keychainUrl.length - 1);
|
|
||||||
// get client ID for OAuth requests
|
|
||||||
clientId = manifest.oauth2.client_id;
|
|
||||||
// get the app version
|
|
||||||
appVersion = manifest.version;
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global app configurations
|
* Global app configurations
|
||||||
*/
|
*/
|
||||||
exports.config = {
|
exports.config = {
|
||||||
cloudUrl: cloudUrl || 'https://keys.whiteout.io',
|
cloudUrl: 'https://keys.whiteout.io',
|
||||||
privkeyServerUrl: keychainUrl || 'https://keychain.whiteout.io',
|
privkeyServerUrl: 'https://keychain.whiteout.io',
|
||||||
adminUrl: 'https://admin-node.whiteout.io',
|
adminUrl: 'https://admin-node.whiteout.io',
|
||||||
wmailDomain: 'wmail.io',
|
wmailDomain: 'wmail.io',
|
||||||
serverPrivateKeyId: 'EE342F0DDBB0F3BE',
|
serverPrivateKeyId: 'EE342F0DDBB0F3BE',
|
||||||
@ -57,7 +34,7 @@ exports.config = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
gmail: {
|
gmail: {
|
||||||
clientId: clientId || '440907777130.apps.googleusercontent.com',
|
clientId: '440907777130.apps.googleusercontent.com',
|
||||||
imap: {
|
imap: {
|
||||||
host: 'imap.gmail.com',
|
host: 'imap.gmail.com',
|
||||||
port: 993,
|
port: 993,
|
||||||
@ -171,7 +148,7 @@ exports.config = {
|
|||||||
verificationUrl: '/verify/',
|
verificationUrl: '/verify/',
|
||||||
verificationUuidLength: 36,
|
verificationUuidLength: 36,
|
||||||
dbVersion: 5,
|
dbVersion: 5,
|
||||||
appVersion: appVersion,
|
appVersion: undefined,
|
||||||
outboxMailboxPath: 'OUTBOX',
|
outboxMailboxPath: 'OUTBOX',
|
||||||
outboxMailboxName: 'Outbox',
|
outboxMailboxName: 'Outbox',
|
||||||
outboxMailboxType: 'Outbox',
|
outboxMailboxType: 'Outbox',
|
||||||
@ -179,6 +156,32 @@ exports.config = {
|
|||||||
imapUpdateBatchSize: 25
|
imapUpdateBatchSize: 25
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// parse manifest to get configurations for current runtime
|
||||||
|
if (typeof chrome !== 'undefined' && chrome.runtime && chrome.runtime.getManifest) {
|
||||||
|
setConfigParams(chrome.runtime.getManifest());
|
||||||
|
} else if (typeof $ !== 'undefined' && $.get) {
|
||||||
|
$.get('/manifest.json', setConfigParams, 'json');
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfigParams(manifest) {
|
||||||
|
var cfg = exports.config;
|
||||||
|
|
||||||
|
function getUrl(beginsWith) {
|
||||||
|
return _.find(manifest.permissions, function(permission) {
|
||||||
|
return typeof permission === 'string' && permission.indexOf(beginsWith) === 0;
|
||||||
|
}).replace(/\/$/, ''); // remove last '/' from url due to required syntax in manifest
|
||||||
|
}
|
||||||
|
|
||||||
|
// get key server base url
|
||||||
|
cfg.cloudUrl = getUrl('https://keys');
|
||||||
|
// get keychain server base url
|
||||||
|
cfg.privkeyServerUrl = getUrl('https://keychain');
|
||||||
|
// get client ID for OAuth requests
|
||||||
|
cfg.gmail.clientId = manifest.oauth2.client_id;
|
||||||
|
// get the app version
|
||||||
|
cfg.appVersion = manifest.version;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strings are maintained here
|
* Strings are maintained here
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user