Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template all base urls in Globals.js #511

Merged
merged 10 commits into from Apr 14, 2020
Next

pull cookie urls to global conf

  • Loading branch information
fcjr committed Mar 13, 2020
commit d90c061fa4fa6e5bb1025b8fa66ec3991f8307a3
@@ -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}`);
@@ -58,6 +58,8 @@ class Globals {
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.COOKIE_DOMAIN = `.${this.GHOSTERY_DOMAIN}.com`;
this.COOKIE_URL = `https://${this.GHOSTERY_DOMAIN}.com`;

// extension IDs
this.GHOSTERY_TAB_CHROME_PRODUCTION_ID = 'plmapebanmikcofllaaddgeocahboejc';
@@ -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 : ''));
})
ProTip! Use n and p to navigate between commits in a pull request.