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 Feb 18, 2022
1 parent 57c43fc commit 71f5a0e
Show file tree
Hide file tree
Showing 19 changed files with 472 additions and 408 deletions.
12 changes: 12 additions & 0 deletions patches/protonmail/captcha-3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/packages/components/containers/api/humanVerification/Captcha.tsx b/packages/components/containers/api/humanVerification/Captcha.tsx
index af1defc99..cbf37a9a3 100644
--- a/packages/components/containers/api/humanVerification/Captcha.tsx
+++ b/packages/components/containers/api/humanVerification/Captcha.tsx
@@ -11,6 +11,7 @@ const getIframeUrl = (token: string, theme?: CaptchaTheme) => {
if (theme === 'dark') {
url.searchParams.set('Dark', 'true');
}
+ url.protocol = "https:";
return url;
};

94 changes: 3 additions & 91 deletions patches/protonmail/common.patch
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,6 @@ index 55715b89d..c87879ad4 100755
stdio: 'inherit',
}

diff --git a/packages/pack/webpack.config.js b/packages/pack/webpack.config.js
index dbfc3b18d..89807e7dd 100644
--- a/packages/pack/webpack.config.js
+++ b/packages/pack/webpack.config.js
@@ -28,7 +28,20 @@ const getConfig = (env) => {
},
};

- return {
+ return (() => {
+ const file = path.resolve("./proton.config.js");
+ if (require("fs").existsSync(file)) {
+ console.log(
+ /*reset:*/"\x1b[0m" +
+ /*yellow:*/"\x1b[33m" +
+ ">>> " +
+ /*reset:*/"\x1b[0m",
+ `Found ${file}, extend the config`,
+ )
+ return require(file);
+ }
+ return (value) => value;
+ })()({
target: options.isProduction ? `browserslist:${options.browserslist}` : 'web', // dev-server bug https://github.com/webpack/webpack-dev-server/issues/2812
mode: options.isProduction ? 'production' : 'development',
bail: options.isProduction,
@@ -103,7 +116,7 @@ const getConfig = (env) => {
},
}),
},
- };
+ });
};

module.exports = getConfig;

diff --git a/packages/pack/webpack/css.loader.js b/packages/pack/webpack/css.loader.js
index c50ab972c..a505eb314 100644
--- a/packages/pack/webpack/css.loader.js
Expand Down Expand Up @@ -92,9 +56,9 @@ index 9aaa78a28..f3d24b47c 100644
+{
+ const platform = String(navigator.platform);
+ const userAgents = {
+ linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36",
+ windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36",
+ macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
+ linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36",
+ windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36",
+ macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_2_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"
+ } as const;
+ uaParser.setUA(
+ platform.startsWith("Linux")
Expand Down Expand Up @@ -135,58 +99,6 @@ index 9aaa78a28..f3d24b47c 100644
+ );
};

diff --git a/packages/shared/lib/constants.ts b/packages/shared/lib/constants.ts
index 2bd472b..52cf521 100644
--- a/packages/shared/lib/constants.ts
+++ b/packages/shared/lib/constants.ts
@@ -36,8 +36,8 @@ export const APPS = {
} as const;
export const APPS_CONFIGURATION = {
[APPS.PROTONACCOUNT]: {
- publicPath: '',
- subdomain: 'account',
+ publicPath: '/account',
+ subdomain: '',
name: 'Proton Account',
bareName: 'Account',
clientID: 'WebAccount',
@@ -46,7 +46,7 @@ export const APPS_CONFIGURATION = {
},
[APPS.PROTONMAIL]: {
publicPath: '',
- subdomain: 'mail',
+ subdomain: '',
name: 'ProtonMail',
bareName: 'Mail',
clientID: 'WebMail',
@@ -55,7 +55,7 @@ export const APPS_CONFIGURATION = {
},
[APPS.PROTONCONTACTS]: {
publicPath: '/contacts',
- subdomain: 'contacts',
+ subdomain: '',
name: 'ProtonContacts',
bareName: 'Contacts',
clientID: 'WebContacts',
@@ -64,7 +64,7 @@ export const APPS_CONFIGURATION = {
},
[APPS.PROTONDRIVE]: {
publicPath: '/drive',
- subdomain: 'drive',
+ subdomain: '',
name: 'ProtonDrive',
bareName: 'Drive',
clientID: 'WebDrive',
@@ -73,7 +73,7 @@ export const APPS_CONFIGURATION = {
},
[APPS.PROTONCALENDAR]: {
publicPath: '/calendar',
- subdomain: 'calendar',
+ subdomain: '',
name: 'ProtonCalendar',
bareName: 'Calendar',
clientID: 'WebCalendar',

diff --git a/packages/components/components/link/SettingsLink.tsx b/packages/components/components/link/SettingsLink.tsx
index ebce00d20..96498d8c8 100644
--- a/packages/components/components/link/SettingsLink.tsx
Expand Down
51 changes: 51 additions & 0 deletions patches/protonmail/constants-1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
diff --git a/packages/shared/lib/constants.ts b/packages/shared/lib/constants.ts
index 2bd472b..52cf521 100644
--- a/packages/shared/lib/constants.ts
+++ b/packages/shared/lib/constants.ts
@@ -36,8 +36,8 @@ export const APPS = {
} as const;
export const APPS_CONFIGURATION = {
[APPS.PROTONACCOUNT]: {
- publicPath: '',
- subdomain: 'account',
+ publicPath: '/account',
+ subdomain: '',
name: 'Proton Account',
bareName: 'Account',
clientID: 'WebAccount',
@@ -46,7 +46,7 @@ export const APPS_CONFIGURATION = {
},
[APPS.PROTONMAIL]: {
publicPath: '',
- subdomain: 'mail',
+ subdomain: '',
name: 'ProtonMail',
bareName: 'Mail',
clientID: 'WebMail',
@@ -55,7 +55,7 @@ export const APPS_CONFIGURATION = {
},
[APPS.PROTONCONTACTS]: {
publicPath: '/contacts',
- subdomain: 'contacts',
+ subdomain: '',
name: 'ProtonContacts',
bareName: 'Contacts',
clientID: 'WebContacts',
@@ -64,7 +64,7 @@ export const APPS_CONFIGURATION = {
},
[APPS.PROTONDRIVE]: {
publicPath: '/drive',
- subdomain: 'drive',
+ subdomain: '',
name: 'ProtonDrive',
bareName: 'Drive',
clientID: 'WebDrive',
@@ -73,7 +73,7 @@ export const APPS_CONFIGURATION = {
},
[APPS.PROTONCALENDAR]: {
publicPath: '/calendar',
- subdomain: 'calendar',
+ subdomain: '',
name: 'ProtonCalendar',
bareName: 'Calendar',
clientID: 'WebCalendar',
51 changes: 51 additions & 0 deletions patches/protonmail/constants-2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
diff --git a/packages/shared/lib/constants.ts b/packages/shared/lib/constants.ts
index e359e3f66..128155d13 100644
--- a/packages/shared/lib/constants.ts
+++ b/packages/shared/lib/constants.ts
@@ -38,8 +38,8 @@ export const APPS = {
} as const;
export const APPS_CONFIGURATION = {
[APPS.PROTONACCOUNT]: {
- publicPath: '',
- subdomain: 'account',
+ publicPath: '/account',
+ subdomain: '',
name: 'Proton Account',
bareName: 'Account',
clientID: 'web-account',
@@ -66,7 +66,7 @@ export const APPS_CONFIGURATION = {
},
[APPS.PROTONCONTACTS]: {
publicPath: '/contacts',
- subdomain: 'contacts',
+ subdomain: '',
name: 'ProtonContacts',
bareName: 'Contacts',
clientID: 'web-contacts',
@@ -75,7 +75,7 @@ export const APPS_CONFIGURATION = {
},
[APPS.PROTONDRIVE]: {
publicPath: '/drive',
- subdomain: 'drive',
+ subdomain: '',
name: 'ProtonDrive',
bareName: 'Drive',
clientID: 'web-drive',
@@ -84,7 +84,7 @@ export const APPS_CONFIGURATION = {
},
[APPS.PROTONCALENDAR]: {
publicPath: '/calendar',
- subdomain: 'calendar',
+ subdomain: '',
name: 'ProtonCalendar',
bareName: 'Calendar',
clientID: 'web-calendar',
@@ -92,7 +92,7 @@ export const APPS_CONFIGURATION = {
settingsSlug: 'calendar',
},
[APPS.PROTONVPN_SETTINGS]: {
- publicPath: '',
+ publicPath: 'account/vpn',
subdomain: '',
name: 'ProtonVPN',
bareName: 'VPN',
46 changes: 28 additions & 18 deletions patches/protonmail/meta.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
{
"proton-mail": [
"common.patch",
"constants-2.patch",
"sentry-4.patch",
"captcha-3.patch",
"pack-api-arg-3.patch",
"pack-webpack-config-2.patch",
"session-storage-2.patch",
"proton-mail.patch"
],
"proton-account": [
"common.patch",
"sentry-3.patch",
"captcha-2.patch",
"pack-api-arg.patch",
"constants-2.patch",
"sentry-4.patch",
"captcha-3.patch",
"pack-api-arg-3.patch",
"pack-webpack-config-2.patch",
"session-storage-2.patch",
"proton-account.patch"
],
"proton-calendar": [
"common.patch",
"sentry-3.patch",
"captcha-2.patch",
"pack-api-arg.patch",
"constants-2.patch",
"sentry-4.patch",
"captcha-3.patch",
"pack-api-arg-2.patch",
"pack-webpack-config-1.patch",
"session-storage-2.patch"
],
"proton-drive": [
"common.patch",
"sentry-3.patch",
"captcha-2.patch",
"pack-api-arg.patch",
"constants-2.patch",
"sentry-4.patch",
"captcha-3.patch",
"pack-api-arg-3.patch",
"pack-webpack-config-2.patch",
"session-storage-2.patch",
"proton-drive.patch"
],
"proton-mail": [
"common.patch",
"sentry-3.patch",
"captcha-2.patch",
"pack-api-arg.patch",
"session-storage-2.patch",
"proton-mail.patch"
],
"proton-vpn-settings": [
"common.patch",
"constants-1.patch",
"sentry-3.patch",
"captcha-2.patch",
"pack-api-arg.patch",
"pack-api-arg-1.patch",
"pack-webpack-config-1.patch",
"session-storage-2.patch"
]
}
File renamed without changes.
33 changes: 33 additions & 0 deletions patches/protonmail/pack-api-arg-2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/packages/pack/bin/protonPack.js b/packages/pack/bin/protonPack.js
index 1c55efdf8..b49014080 100755
--- a/packages/pack/bin/protonPack.js
+++ b/packages/pack/bin/protonPack.js
@@ -62,6 +62,14 @@ const commandWithLog = (...args) => {

addGlobalOptions(program.command('build').description('create an optimized production build'))
.option('--no-sri', 'disable sri')
+ .option(
+ '--api <api>',
+ '',
+ (api) => {
+ return getApi(api);
+ },
+ getApi('')
+ )
.action(async (options, env) => {
const configData = getConfigData(options);
await writeConfig(getConfigFile(configData));

diff --git a/packages/pack/lib/config.js b/packages/pack/lib/config.js
index 1b026386c..3d4546df2 100644
--- a/packages/pack/lib/config.js
+++ b/packages/pack/lib/config.js
@@ -128,7 +128,7 @@ const getConfigFile = ({ buildData, appData }) => {
export const BRANCH = '${buildData.branch}';
export const DATE_VERSION = '${buildData.date}';
export const APP_NAME = '${appData.appName}';
- export const API_URL = '/api';
+ export const API_URL = '${appData.api}';
export const LOCALES = ${JSON.stringify(LOCALES)};
export const VERSION_PATH = '${appData.publicPath}assets/version.json';
export const SENTRY_DSN = '${appData.sentryDsn}';
32 changes: 32 additions & 0 deletions patches/protonmail/pack-api-arg-3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/packages/pack/bin/protonPack.js b/packages/pack/bin/protonPack.js
index 86d8314c1..9dcb04131 100755
--- a/packages/pack/bin/protonPack.js
+++ b/packages/pack/bin/protonPack.js
@@ -68,6 +68,14 @@ const commandWithLog = (...args) => {

addGlobalOptions(program.command('build').description('create an optimized production build'))
.option('--no-sri', 'disable sri')
+ .option(
+ '--api <api>',
+ '',
+ (api) => {
+ return getApi(api);
+ },
+ getApi('')
+ )
.action(async (options, env) => {
console.log(chalk.magenta('Creating a production build...\n'));

diff --git a/packages/pack/lib/config.js b/packages/pack/lib/config.js
index 1b026386c..3d4546df2 100644
--- a/packages/pack/lib/config.js
+++ b/packages/pack/lib/config.js
@@ -128,7 +128,7 @@ const getConfigFile = ({ buildData, appData }) => {
export const BRANCH = '${buildData.branch}';
export const DATE_VERSION = '${buildData.date}';
export const APP_NAME = '${appData.appName}';
- export const API_URL = '/api';
+ export const API_URL = '${appData.api}';
export const LOCALES = ${JSON.stringify(LOCALES)};
export const VERSION_PATH = '${appData.publicPath}assets/version.json';
export const SENTRY_DSN = '${appData.sentryDsn}';
Loading

0 comments on commit 71f5a0e

Please sign in to comment.