Skip to content

Commit

Permalink
update @ProtonMail web clients
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimiry committed Sep 21, 2022
1 parent 09d6bc5 commit e60fbed
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 48 deletions.
19 changes: 0 additions & 19 deletions patches/protonmail/common.patch
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,6 @@ index 38e76fbcd..cace56733 100644
return null;
}

diff --git a/packages/shared/lib/fetch/helpers.ts b/packages/shared/lib/fetch/helpers.ts
index 6edb249f3..738c4da33 100644
--- a/packages/shared/lib/fetch/helpers.ts
+++ b/packages/shared/lib/fetch/helpers.ts
@@ -10,11 +10,13 @@ const appendQueryParams = (url: URL, params: { [key: string]: any }) => {
});
};

+/* <electron-mail-mark> */
export const createUrl = (urlString: string, params: { [key: string]: any } = {}) => {
const url = new URL(urlString, window.location.origin);
appendQueryParams(url, params);
return url;
};
+/* </electron-mail-mark> */

export const checkStatus = (response: Response, config: any) => {
const { status } = response;

diff --git a/packages/components/helpers/earlyAccessDesynchronization.ts b/packages/components/helpers/earlyAccessDesynchronization.ts
index 36bd0c712..c2fb3681c 100644
--- a/packages/components/helpers/earlyAccessDesynchronization.ts
Expand Down
24 changes: 24 additions & 0 deletions patches/protonmail/constants-5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/packages/shared/lib/constants.ts b/packages/shared/lib/constants.ts
index e98525020..9e27f7f97 100644
--- a/packages/shared/lib/constants.ts
+++ b/packages/shared/lib/constants.ts
@@ -52,7 +52,7 @@ export const APPS = {
} as const;
export const APPS_CONFIGURATION = {
[APPS.PROTONACCOUNT]: {
- publicPath: '',
+ publicPath: '/account',
subdomain: 'account',
name: ACCOUNT_APP_NAME,
bareName: 'Account',
@@ -115,8 +115,8 @@ export const APPS_CONFIGURATION = {
settingsSlug: '',
},
[APPS.PROTONVPN_SETTINGS]: {
- publicPath: '',
- subdomain: '',
+ publicPath: 'account/vpn',
+ subdomain: 'account',
name: VPN_APP_NAME,
bareName: 'VPN',
clientID: 'web-vpn-settings',
6 changes: 3 additions & 3 deletions patches/protonmail/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
"constants-4.patch",
"sentry-8.patch",
"pack-api-arg-3.patch",
"pack-webpack-4.patch",
"pack-webpack-5.patch",
"session-storage-3.patch",
"link-handler-5.patch",
"embedded-verification-1.patch",
"proton-mail.patch"
],
"proton-account": [
"common.patch",
"url-2.patch",
"constants-4.patch",
"url-3.patch",
"constants-5.patch",
"sentry-8.patch",
"pack-api-arg-3.patch",
"pack-webpack-5.patch",
Expand Down
9 changes: 4 additions & 5 deletions patches/protonmail/proton-account.patch
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,15 @@ index 8f5e56ef0..a40d9dc17 100644
export default Setup;

diff --git a/applications/account/src/app/content/MainContainer.tsx b/applications/account/src/app/content/MainContainer.tsx
index f14e76d5a..b21b54c97 100644
index ceb51ba56..7656f38f6 100644
--- a/applications/account/src/app/content/MainContainer.tsx
+++ b/applications/account/src/app/content/MainContainer.tsx
@@ -91,7 +91,7 @@ const MainContainer = () => {
setExpand(false);
}, [location.pathname, location.hash]);
@@ -119,7 +119,7 @@ const MainContainer = () => {

useDeviceRecovery();

- const app = getAppFromPathnameSafe(location.pathname) || DEFAULT_APP;
+ const app = getAppFromPathnameSafe(window.location.pathname) || DEFAULT_APP;
const appSlug = getSlugFromApp(app);

/*

35 changes: 17 additions & 18 deletions patches/protonmail/proton-mail.patch
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
diff --git a/packages/shared/lib/api/events.ts b/packages/shared/lib/api/events.ts
index 263d640ff..d1944c66e 100644
index 7c263575d..6d696e5f4 100644
--- a/packages/shared/lib/api/events.ts
+++ b/packages/shared/lib/api/events.ts
@@ -1,9 +1,11 @@
export const getLatestID = () => ({
url: 'v4/events/latest',
method: 'get',
+ params: { MessageCounts: "", ConversationCounts: "", },
});

export const getEvents = (eventID: string) => ({
@@ -6,5 +6,9 @@ export const getLatestID = () => ({
export const getEvents = (eventID: string, params?: { ConversationCounts: 1 | 0; MessageCounts: 1 | 0 }) => ({
url: `v4/events/${eventID}`,
method: 'get',
+ params: { MessageCounts: "", ConversationCounts: "", },
- params,
+ params: {
+ ...params,
+ ConversationCounts: 1,
+ MessageCounts: 1,
+ },
});

diff --git a/packages/components/containers/login/MinimalLoginContainer.tsx b/packages/components/containers/login/MinimalLoginContainer.tsx
Expand Down Expand Up @@ -324,18 +323,18 @@ index bdabb99e0..a56b8cdcb 100644
};

diff --git a/applications/mail/src/app/components/header/MailHeader.tsx b/applications/mail/src/app/components/header/MailHeader.tsx
index e68f73cd8..6a69bfb1f 100644
index d86dc9880..e75180b46 100644
--- a/applications/mail/src/app/components/header/MailHeader.tsx
+++ b/applications/mail/src/app/components/header/MailHeader.tsx
@@ -34,7 +34,6 @@ import { getLabelName } from '../../helpers/labels';
import { useEncryptedSearchContext } from '../../containers/EncryptedSearchProvider';
import { useOnCompose, useOnMailTo } from '../../containers/ComposeProvider';
import { MESSAGE_ACTIONS } from '../../constants';
-import MailDefaultHandlerModal from './MailDefaultHandlerModal';
@@ -38,7 +38,6 @@ import { setParamsInUrl } from '../../helpers/mailboxUrl';
import { Breakpoints } from '../../models/utils';
import MailOnboardingModal from '../onboarding/MailOnboardingModal';
import ClearBrowserDataModal from './ClearBrowserDataModal';
-import MailDefaultHandlerModal from './MailDefaultHandlerModal';
import MailSearch from './search/MailSearch';
import MailOnboardingModal from '../onboarding/MailOnboardingModal';
@@ -191,7 +190,6 @@ const MailHeader = ({ labelID, elementID, breakpoints, expanded, onToggleExpand

interface Props {
@@ -192,7 +191,6 @@ const MailHeader = ({ labelID, elementID, breakpoints, expanded, onToggleExpand
<MailViewLayoutModal {...mailViewLayoutProps} />
<MailDensityModal {...mailDensityProps} />
<MailComposerModeModal {...mailComposerModeProps} />
Expand Down
19 changes: 19 additions & 0 deletions patches/protonmail/url-2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,22 @@ index 11cd310f6..8019c07f5 100644
let cache = '';
export const getStaticURL = (path: string) => {
if (window.location.hostname === 'localhost' || getIsDohDomain(window.location.origin)) {

diff --git a/packages/shared/lib/fetch/helpers.ts b/packages/shared/lib/fetch/helpers.ts
index 6edb249f3..738c4da33 100644
--- a/packages/shared/lib/fetch/helpers.ts
+++ b/packages/shared/lib/fetch/helpers.ts
@@ -10,11 +10,13 @@ const appendQueryParams = (url: URL, params: { [key: string]: any }) => {
});
};

+/* <electron-mail-mark> */
export const createUrl = (urlString: string, params: { [key: string]: any } = {}) => {
const url = new URL(urlString, window.location.origin);
appendQueryParams(url, params);
return url;
};
+/* </electron-mail-mark> */

export const checkStatus = (response: Response, config: any) => {
const { status } = response;
75 changes: 75 additions & 0 deletions patches/protonmail/url-3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
diff --git a/packages/shared/lib/helpers/url.ts b/packages/shared/lib/helpers/url.ts
index 11cd310f6..8019c07f5 100644
--- a/packages/shared/lib/helpers/url.ts
+++ b/packages/shared/lib/helpers/url.ts
@@ -175,48 +175,16 @@ export const getSecondLevelDomain = (hostname: string) => {
return hostname.slice(hostname.indexOf('.') + 1);
};

-export const getRelativeApiHostname = (hostname: string) => {
- const idx = hostname.indexOf('.');
- const first = hostname.slice(0, idx);
- const second = hostname.slice(idx + 1);
- return `${first}-api.${second}`;
-};
-
export const getIsDohDomain = (origin: string) => {
return DOH_DOMAINS.some((dohDomain) => origin.endsWith(dohDomain));
};

export const getApiSubdomainUrl = (pathname: string) => {
- const url = new URL('/', window.location.origin);
- if (url.hostname === 'localhost' || getIsDohDomain(url.origin)) {
- url.pathname = `/api${pathname}`;
- return url;
- }
- url.hostname = getRelativeApiHostname(url.hostname);
+ const url = new URL('/', '___ELECTRON_MAIL_PROTON_API_ENTRY_URL_PLACEHOLDER___');
url.pathname = pathname;
return url;
};

-export const getAppUrlFromApiUrl = (apiUrl: string, appName: APP_NAMES) => {
- const { subdomain } = APPS_CONFIGURATION[appName];
- const url = new URL(apiUrl);
- const { hostname } = url;
- const index = hostname.indexOf('.');
- const tail = hostname.slice(index + 1);
- url.pathname = '';
- url.hostname = `${subdomain}.${tail}`;
- return url;
-};
-
-export const getAppUrlRelativeToOrigin = (origin: string, appName: APP_NAMES) => {
- const { subdomain } = APPS_CONFIGURATION[appName];
- const url = new URL(origin);
- const segments = url.host.split('.');
- segments[0] = subdomain;
- url.hostname = segments.join('.');
- return url;
-};
-
let cache = '';
export const getStaticURL = (path: string) => {
if (window.location.hostname === 'localhost' || getIsDohDomain(window.location.origin)) {

diff --git a/packages/shared/lib/fetch/helpers.ts b/packages/shared/lib/fetch/helpers.ts
index f0b3e2e31..90995e1fc 100644
--- a/packages/shared/lib/fetch/helpers.ts
+++ b/packages/shared/lib/fetch/helpers.ts
@@ -10,6 +10,7 @@ const appendQueryParams = (url: URL, params: { [key: string]: any }) => {
});
};

+/* <electron-mail-mark> */
export const createUrl = (urlString: string, params: { [key: string]: any } = {}) => {
let url: URL;
if (typeof window !== 'undefined') {
@@ -20,6 +21,7 @@ export const createUrl = (urlString: string, params: { [key: string]: any } = {}
appendQueryParams(url, params);
return url;
};
+/* </electron-mail-mark> */

export const checkStatus = (response: Response, config: any) => {
const { status } = response;
6 changes: 3 additions & 3 deletions src/shared/const/proton-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const PROVIDER_REPO_MAP = {
basePath: "",
apiSubdomain: "mail-api",
repoRelativeDistDir: "./dist",
tag: "[email protected].6.9",
tag: "[email protected].7.9",
protonPack: {
webpackIndexEntryItems: [
// immediate
Expand All @@ -49,14 +49,14 @@ export const PROVIDER_REPO_MAP = {
basePath: "account",
apiSubdomain: "account-api",
repoRelativeDistDir: "./dist",
tag: "[email protected].6.0",
tag: "[email protected].7.3",
protonPack: {}
},
[PROVIDER_APP_NAMES[2]]: {
basePath: "calendar",
apiSubdomain: "calendar-api",
repoRelativeDistDir: "./dist",
tag: "[email protected].1",
tag: "[email protected].4",
protonPack: {
webpackIndexEntryItems: [
// immediate
Expand Down

0 comments on commit e60fbed

Please sign in to comment.