diff --git a/app/hub/Views/HomeView/HomeView.jsx b/app/hub/Views/HomeView/HomeView.jsx
index 82de8fdd3..b591fadde 100644
--- a/app/hub/Views/HomeView/HomeView.jsx
+++ b/app/hub/Views/HomeView/HomeView.jsx
@@ -36,7 +36,7 @@ const HomeView = (props) => {
email,
isPlus,
} = props;
- const accountHref = `https://account.${globals.GHOSTERY_DOMAIN}.com`;
+ const accountHref = globals.ACCOUNT_BASE_URL;
let headerInfoText = t('hub_home_header_info');
if (globals.BROWSER_INFO) {
diff --git a/app/hub/Views/PlusView/PlusView.jsx b/app/hub/Views/PlusView/PlusView.jsx
index 7a56806a4..ed8d77bda 100644
--- a/app/hub/Views/PlusView/PlusView.jsx
+++ b/app/hub/Views/PlusView/PlusView.jsx
@@ -29,7 +29,7 @@ class PlusView extends Component {
*/
_renderButton = (additionalClasses) => {
const { isPlus, onPlusClick } = this.props;
- const buttonHref = `https://checkout.${globals.GHOSTERY_DOMAIN}.com/plus?utm_source=gbe&utm_campaign=intro_hub_plus`;
+ const buttonHref = `${globals.CHECKOUT_BASE_URL}/plus?utm_source=gbe&utm_campaign=intro_hub_plus`;
const buttonClassNames = ClassNames('PlusView__button', 'button', additionalClasses, {
disabled: isPlus,
});
diff --git a/app/hub/Views/SideNavigationView/SideNavigationViewContainer.jsx b/app/hub/Views/SideNavigationView/SideNavigationViewContainer.jsx
index 5f0a5af56..1388a5ea7 100644
--- a/app/hub/Views/SideNavigationView/SideNavigationViewContainer.jsx
+++ b/app/hub/Views/SideNavigationView/SideNavigationViewContainer.jsx
@@ -57,7 +57,7 @@ class SideNavigationViewContainer extends Component {
{ href: '/products', icon: 'products', text: t('hub_side_navigation_products') }
];
const bottomItems = user ? [
- { id: 'email', href: `https://account.${globals.GHOSTERY_DOMAIN}.com/`, text: user.email },
+ { id: 'email', href: `${globals.ACCOUNT_BASE_URL}/`, text: user.email },
{ id: 'logout', text: t('sign_out'), clickHandler: this._handleLogoutClick },
] : [
{ id: 'create-account', href: '/create-account', text: t('create_account') },
diff --git a/app/panel/components/Blocking/GlobalTracker.jsx b/app/panel/components/Blocking/GlobalTracker.jsx
index 9538174e7..9169c3d1a 100644
--- a/app/panel/components/Blocking/GlobalTracker.jsx
+++ b/app/panel/components/Blocking/GlobalTracker.jsx
@@ -56,7 +56,7 @@ class GlobalTracker extends React.Component {
this.setState({ description: t('tracker_description_getting') });
sendMessageInPromise('getTrackerDescription', {
- url: `https://${globals.APPS_SUB_DOMAIN}.ghostery.com/${this.props.language}/apps/${
+ url: `${globals.APPS_BASE_URL}/${this.props.language}/apps/${
encodeURIComponent(tracker.name.replace(/\s+/g, '_').toLowerCase())}?format=json`,
}).then((data) => {
if (data) {
@@ -114,7 +114,7 @@ class GlobalTracker extends React.Component {
{
this.state.showTrackerLearnMore && (
{this.state.description}
diff --git a/app/panel/components/HeaderMenu.jsx b/app/panel/components/HeaderMenu.jsx
index bc03910c0..6467aa295 100644
--- a/app/panel/components/HeaderMenu.jsx
+++ b/app/panel/components/HeaderMenu.jsx
@@ -126,7 +126,7 @@ class HeaderMenu extends React.Component {
*/
clickSignedInAs = () => {
sendMessage('openNewTab', {
- url: `https://account.${globals.GHOSTERY_DOMAIN}.com/`,
+ url: `${globals.ACCOUNT_BASE_URL}/`,
become_active: true,
});
window.close();
diff --git a/app/panel/components/Settings/Account.jsx b/app/panel/components/Settings/Account.jsx
index 29cd2c0db..b40596074 100644
--- a/app/panel/components/Settings/Account.jsx
+++ b/app/panel/components/Settings/Account.jsx
@@ -37,7 +37,7 @@ class Account extends React.Component {
*/
clickEditAccount = () => {
sendMessage('openNewTab', {
- url: `https://account.${globals.GHOSTERY_DOMAIN}.com/`,
+ url: `${globals.GHOSTERY_ACCOUNT_BASE_URL}/`,
become_active: true,
});
window.close();
diff --git a/src/background.js b/src/background.js
index 5e704253f..12d0d5e31 100644
--- a/src/background.js
+++ b/src/background.js
@@ -64,11 +64,11 @@ const { sendMessage } = utils;
const { onMessage } = chrome.runtime;
// simple consts
const {
- CDN_SUB_DOMAIN, BROWSER_INFO, IS_CLIQZ, DEBUG
+ CDN_BASE_URL, BROWSER_INFO, IS_CLIQZ, DEBUG
} = globals;
const IS_EDGE = (BROWSER_INFO.name === 'edge');
const IS_FIREFOX = (BROWSER_INFO.name === 'firefox');
-const VERSION_CHECK_URL = `https://${CDN_SUB_DOMAIN}.ghostery.com/update/version`;
+const VERSION_CHECK_URL = `${CDN_BASE_URL}/update/version`;
const REAL_ESTATE_ID = 'ghostery';
const onBeforeRequest = events.onBeforeRequest.bind(events);
const onHeadersReceived = events.onHeadersReceived.bind(events);
@@ -845,11 +845,11 @@ function onMessageHandler(request, sender, callback) {
return true;
}
if (name === 'account.openSubscriptionPage') {
- utils.openNewTab({ url: `https://account.${globals.GHOSTERY_DOMAIN}.com/subscription`, become_active: true });
+ utils.openNewTab({ url: `${globals.CHECKOUT_BASE_URL}/subscription`, become_active: true });
return false;
}
if (name === 'account.openCheckoutPage') {
- let url = `https://checkout.${globals.GHOSTERY_DOMAIN}.com/plus`;
+ let url = `${globals.CHECKOUT_BASE_URL}/plus`;
const { utm } = message || null;
if (utm) {
url += `?utm_source=${utm.utm_source}&utm_campaign=${utm.utm_campaign}`;
@@ -860,7 +860,7 @@ function onMessageHandler(request, sender, callback) {
if (name === 'account.openSupportPage') {
metrics.ping('priority_support_submit');
const subscriber = account.hasScopesUnverified(['subscriptions:plus']);
- const tabUrl = subscriber ? `https://account.${globals.GHOSTERY_DOMAIN}.com/support` : 'https://www.ghostery.com/support/';
+ const tabUrl = subscriber ? `${globals.ACCOUNT_BASE_URL}/support` : 'https://www.ghostery.com/support/';
utils.openNewTab({ url: tabUrl, become_active: true });
return false;
}
diff --git a/src/classes/ABTest.js b/src/classes/ABTest.js
index e9bba4e8f..df7a235fb 100644
--- a/src/classes/ABTest.js
+++ b/src/classes/ABTest.js
@@ -19,7 +19,7 @@ import globals from './Globals';
import { getJson } from '../utils/utils';
import { log } from '../utils/common';
-const { BROWSER_INFO, CMP_SUB_DOMAIN, EXTENSION_VERSION } = globals;
+const { BROWSER_INFO, CMP_BASE_URL, EXTENSION_VERSION } = globals;
/** Helper class for handling A/B tests.
* @memberof BackgroundClasses
@@ -44,7 +44,7 @@ class ABTest {
fetch() {
log('A/B Tests: fetching...');
- const URL = `https://${CMP_SUB_DOMAIN}.ghostery.com/abtestcheck
+ const URL = `${CMP_BASE_URL}/abtestcheck
?os=${encodeURIComponent(BROWSER_INFO.os)}
&install_date=${encodeURIComponent(conf.install_date)}
&ir=${encodeURIComponent(conf.install_random_number)}
diff --git a/src/classes/Account.js b/src/classes/Account.js
index 61a427d7d..4dfd48a30 100644
--- a/src/classes/Account.js
+++ b/src/classes/Account.js
@@ -25,7 +25,7 @@ import Api from '../utils/api';
const api = new Api();
const {
- GHOSTERY_DOMAIN, AUTH_SERVER, ACCOUNT_SERVER, SYNC_ARRAY, IS_CLIQZ
+ COOKIE_DOMAIN, COOKIE_URL, AUTH_SERVER, ACCOUNT_SERVER, SYNC_ARRAY, IS_CLIQZ
} = globals;
const SYNC_SET = new Set(SYNC_ARRAY);
@@ -35,7 +35,7 @@ class Account {
const apiConfig = {
AUTH_SERVER,
ACCOUNT_SERVER,
- CSRF_DOMAIN: GHOSTERY_DOMAIN
+ COOKIE_URL
};
const opts = {
errorHandler: errors => (
@@ -114,7 +114,7 @@ class Account {
logout = () => (
new RSVP.Promise((resolve, reject) => {
chrome.cookies.get({
- url: `https://${GHOSTERY_DOMAIN}.com`,
+ url: COOKIE_URL,
name: 'csrf_token',
}, (cookie) => {
if (cookie === null) { return reject(); }
@@ -312,7 +312,7 @@ class Account {
return;
}
chrome.cookies.get({
- url: `https://${GHOSTERY_DOMAIN}.com`,
+ url: COOKIE_URL,
name: 'user_id',
}, (cookie) => {
if (cookie !== null) {
@@ -402,8 +402,8 @@ class Account {
chrome.cookies.set({
name,
value,
- url: `https://${GHOSTERY_DOMAIN}.com`,
- domain: `.${GHOSTERY_DOMAIN}.com`,
+ url: COOKIE_URL,
+ domain: COOKIE_DOMAIN,
expirationDate,
secure: true,
httpOnly,
@@ -502,7 +502,7 @@ class Account {
_getUserIDFromCookie = () => (
new Promise((resolve, reject) => {
chrome.cookies.get({
- url: `https://${GHOSTERY_DOMAIN}.com`,
+ url: COOKIE_URL,
name: 'user_id',
}, (cookie) => {
if (cookie) {
@@ -541,7 +541,7 @@ class Account {
const cookies = ['user_id', 'access_token', 'refresh_token', 'csrf_token', 'AUTH'];
cookies.forEach((name) => {
chrome.cookies.remove({
- url: `https://${GHOSTERY_DOMAIN}.com`,
+ url: COOKIE_URL,
name,
}, () => {
log(`Removed cookie with name: ${name}`);
diff --git a/src/classes/CMP.js b/src/classes/CMP.js
index fdd1f5594..e22ad49d4 100644
--- a/src/classes/CMP.js
+++ b/src/classes/CMP.js
@@ -16,7 +16,7 @@ import globals from './Globals';
import { getJson } from '../utils/utils';
import { log } from '../utils/common';
-const { BROWSER_INFO, CMP_SUB_DOMAIN, EXTENSION_VERSION } = globals;
+const { BROWSER_INFO, CMP_BASE_URL, EXTENSION_VERSION } = globals;
/**
* Class for handling notification and/or marketing campaigns.
@@ -36,7 +36,7 @@ class CMP {
return Promise.resolve(false);
}
- const URL = `https://${CMP_SUB_DOMAIN}.ghostery.com/check
+ const URL = `${CMP_BASE_URL}/check
?os=${encodeURIComponent(BROWSER_INFO.os)}
&offers=${encodeURIComponent(conf.enable_offers ? '1' : '0')}
&hw=${encodeURIComponent(conf.enable_human_web ? '1' : '0')}
diff --git a/src/classes/Globals.js b/src/classes/Globals.js
index e05ddee87..c1d3c27d4 100644
--- a/src/classes/Globals.js
+++ b/src/classes/Globals.js
@@ -50,14 +50,19 @@ class Globals {
this.initProps = {};
// domains
- this.GHOSTERY_DOMAIN = this.DEBUG ? 'ghosterystage' : 'ghostery';
- this.METRICS_SUB_DOMAIN = this.DEBUG ? 'staging-d' : 'd';
- this.CMP_SUB_DOMAIN = this.DEBUG ? 'staging-cmp-cdn' : 'cmp-cdn';
- this.CDN_SUB_DOMAIN = this.DEBUG ? 'staging-cdn' : 'cdn';
- this.APPS_SUB_DOMAIN = this.DEBUG ? 'staging-apps' : 'apps';
- this.GCACHE_SUB_DOMAIN = this.DEBUG ? 'staging-gcache' : 'gcache';
- this.AUTH_SERVER = `https://consumerapi.${this.GHOSTERY_DOMAIN}.com`;
- this.ACCOUNT_SERVER = `https://accountapi.${this.GHOSTERY_DOMAIN}.com`;
+ this.GHOSTERY_ROOT_DOMAIN = `${this.DEBUG ? 'ghosterystage' : 'ghostery'}.com`;
+ this.GHOSTERY_BASE_URL = `https://${this.GHOSTERY_ROOT_DOMAIN}`;
+ this.ACCOUNT_BASE_URL = `https://account.${this.GHOSTERY_ROOT_DOMAIN}`;
+ this.CHECKOUT_BASE_URL = `https://checkout.${this.GHOSTERY_ROOT_DOMAIN}`;
+ this.METRICS_BASE_URL = `https://${this.DEBUG ? 'staging-d' : 'd'}.ghostery.com`;
+ this.CMP_BASE_URL = `https://${this.DEBUG ? 'staging-cmp-cdn' : 'cmp-cdn'}.ghostery.com`;
+ this.CDN_BASE_URL = `https://${this.DEBUG ? 'staging-cdn' : 'cdn'}.ghostery.com`;
+ this.APPS_BASE_URL = `https://${this.DEBUG ? 'staging-apps' : 'apps'}.ghostery.com`;
+ this.GCACHE_BASE_URL = `https://${this.DEBUG ? 'staging-gcache' : 'gcache'}.ghostery.com`;
+ this.AUTH_SERVER = `https://consumerapi.${this.GHOSTERY_ROOT_DOMAIN}`;
+ this.ACCOUNT_SERVER = `https://accountapi.${this.GHOSTERY_ROOT_DOMAIN}`;
+ this.COOKIE_DOMAIN = `.${this.GHOSTERY_ROOT_DOMAIN}`;
+ this.COOKIE_URL = this.GHOSTERY_BASE_URL;
// extension IDs
this.GHOSTERY_TAB_CHROME_PRODUCTION_ID = 'plmapebanmikcofllaaddgeocahboejc';
diff --git a/src/classes/Metrics.js b/src/classes/Metrics.js
index 51377cc82..600683de0 100644
--- a/src/classes/Metrics.js
+++ b/src/classes/Metrics.js
@@ -25,7 +25,7 @@ const FREQUENCIES = { // in milliseconds
};
const CRITICAL_METRICS = ['install', 'install_complete', 'upgrade', 'active', 'engaged', 'uninstall'];
const CAMPAIGN_METRICS = ['install', 'active', 'uninstall'];
-const { METRICS_SUB_DOMAIN, EXTENSION_VERSION, BROWSER_INFO } = globals;
+const { METRICS_BASE_URL, EXTENSION_VERSION, BROWSER_INFO } = globals;
const MAX_DELAYED_PINGS = 100;
// Note that this threshold is intentionally different from the 30 second threshold in PolicySmartBlock,
@@ -299,7 +299,7 @@ class Metrics {
_buildMetricsUrl(type, frequency) {
const frequencyString = (type !== 'uninstall') ? `/${frequency}` : '';
- let metrics_url = `https://${METRICS_SUB_DOMAIN}.ghostery.com/${type}${frequencyString}?gr=-1` +
+ let metrics_url = `${METRICS_BASE_URL}/${type}${frequencyString}?gr=-1` +
// Old parameters, old names
// Human web
`&hw=${encodeURIComponent(conf.enable_human_web ? '1' : '0')}` +
diff --git a/src/classes/Updatable.js b/src/classes/Updatable.js
index 887495f12..b8a5ba576 100644
--- a/src/classes/Updatable.js
+++ b/src/classes/Updatable.js
@@ -17,7 +17,7 @@ import conf from './Conf';
import { getJson, fetchLocalJSONResource } from '../utils/utils';
import { log } from '../utils/common';
-const { CDN_SUB_DOMAIN } = globals;
+const { CDN_BASE_URL } = globals;
/**
* Base class for BugDb, Click2PlayDb, CompatibilityDb and SurrogateDb.
* It provides update functionality, which all of these subclasses
@@ -131,7 +131,7 @@ class Updatable {
*/
_remoteFetcher(callback) {
log(`fetching ${this.type} from remote`);
- const UPDATE_URL = `https://${CDN_SUB_DOMAIN}.ghostery.com/update/${
+ const UPDATE_URL = `${CDN_BASE_URL}/update/${
this.type === 'bugs' ? 'v3/bugs' : this.type}`;
getJson(UPDATE_URL).then((list) => {
diff --git a/src/utils/api.js b/src/utils/api.js
index 661749145..f2e3865f5 100644
--- a/src/utils/api.js
+++ b/src/utils/api.js
@@ -139,10 +139,10 @@ class Api {
});
}
- _getCsrfCookie = (csrfDomain = this.config.CSRF_DOMAIN) => (
+ _getCsrfCookie = (cookieUrl = this.config.COOKIE_URL) => (
new Promise((resolve) => {
chrome.cookies.get({
- url: `https://${csrfDomain}.com`,
+ url: cookieUrl,
name: 'csrf_token',
}, cookie => resolve((cookie !== null) ? cookie.value : ''));
})
diff --git a/src/utils/click2play.js b/src/utils/click2play.js
index 839aa0f0e..5e433db32 100644
--- a/src/utils/click2play.js
+++ b/src/utils/click2play.js
@@ -130,7 +130,7 @@ export function buildRedirectC2P(requestId, redirectUrls, app_id) {
'blocked_redirect_prevent',
// It is unlikely that apps pages will ever be translated
// [host_url, redirect_url, app_name, 'https://' + globals.APPS_SUB_DOMAIN + '.ghostery.com/' + conf.language + '/apps/' + encodeURIComponent(app_name.replace(/\s+/g, '_').toLowerCase())]),
- [host_url, redirect_url, app_name, `https://${globals.APPS_SUB_DOMAIN}.ghostery.com/en/apps/${encodeURIComponent(app_name.replace(/\s+/g, '_').toLowerCase())}`]
+ [host_url, redirect_url, app_name, `${globals.APPS_BASE_URL}/en/apps/${encodeURIComponent(app_name.replace(/\s+/g, '_').toLowerCase())}`]
),
blocked_redirect_action_always_title: t('blocked_redirect_action_always_title'),
blocked_redirect_action_through_once_title: t('blocked_redirect_action_through_once_title'),