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 Jan 14, 2023
1 parent dda0127 commit 6c0e869
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,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/102.0.5005.63 Safari/537.36",
+ windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36",
+ macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36"
+ linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
+ windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
+ macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
+ } as const;
+ uaParser.setUA(
+ platform.startsWith("Linux")
Expand Down
127 changes: 127 additions & 0 deletions patches/protonmail/common-2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
diff --git a/packages/pack/scripts/validate.sh b/packages/pack/scripts/validate.sh
index 1a2ea64..bae388c 100755
--- a/packages/pack/scripts/validate.sh
+++ b/packages/pack/scripts/validate.sh
@@ -58,7 +58,7 @@ function main {
fi;

if [ "$hasSourceMap" -eq 0 ]; then
- hasError=true;
+ #hasError=true;
echo "[error] no SourceMaps found inside the directory: $OUTPUT_DIR";
fi;

diff --git a/packages/pack/bin/protonPack.js b/packages/pack/bin/protonPack.js
index 55715b89d..c87879ad4 100755
--- a/packages/pack/bin/protonPack.js
+++ b/packages/pack/bin/protonPack.js
@@ -81,7 +81,7 @@ addGlobalOptions(program.command('build').description('create an optimized produ
const outputPath = path.resolve('./dist');
await commandWithLog(`rm -rf ${outputPath}`);
await commandWithLog(
- `${require.resolve('webpack-cli/bin/cli.js')} --progress --output-path=${outputPath} ${webpackArgs}`,
+ `${require.resolve('webpack-cli/bin/cli.js')} --output-path=${outputPath} ${webpackArgs}`,
{
stdio: 'inherit',
}

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
+++ b/packages/pack/webpack/css.loader.js
@@ -44,11 +44,13 @@ module.exports = ({ browserslist }) => {
},
{
loader: require.resolve('resolve-url-loader'),
+ options: {sourceMap: false},
},
{
loader: require.resolve('sass-loader'),
options: {
additionalData: PREPEND_SASS,
+ sourceMap: true, // to please "resolve-url-loader"
},
},
].filter(Boolean);


diff --git a/packages/shared/lib/helpers/browser.ts b/packages/shared/lib/helpers/browser.ts
index 9aaa78a28..f3d24b47c 100644
--- a/packages/shared/lib/helpers/browser.ts
+++ b/packages/shared/lib/helpers/browser.ts
@@ -1,6 +1,21 @@
import UAParser from 'ua-parser-js';

const uaParser = new UAParser();
+{
+ const platform = String(navigator.platform);
+ const userAgents = {
+ linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
+ windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
+ macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
+ } as const;
+ uaParser.setUA(
+ platform.startsWith("Linux")
+ ? userAgents.linux
+ : platform.startsWith("Win")
+ ? userAgents.windows
+ : userAgents.macos
+ );
+}
const ua = uaParser.getResult();

export const hasModulesSupport = () => {
@@ -89,20 +104,10 @@ export const requireDirectAction = () => isSafari() || isFirefox() || isEdge();
* @links { https://mathiasbynens.github.io/rel-noopener/}
*/
export const openNewTab = (url: string) => {
- if (isIE11()) {
- const otherWindow = window.open();
- if (!otherWindow) {
- return;
- }
- otherWindow.opener = null;
- otherWindow.location.href = url;
- return;
- }
- const anchor = document.createElement('a');
-
- anchor.setAttribute('rel', 'noreferrer nofollow noopener');
- anchor.setAttribute('target', '_blank');
- anchor.href = url;
-
- return anchor.click();
+ window.dispatchEvent(
+ new CustomEvent(
+ "electron-mail:packages/shared/lib/helpers/browser.ts:openNewTab",
+ {detail: {url}},
+ ),
+ );
};

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
+++ b/packages/components/components/link/SettingsLink.tsx
@@ -37,7 +37,7 @@ const SettingsLink = ({ path, app, children, ...rest }: Props, ref: Ref<HTMLAnch
ref={ref}
toApp={APPS.PROTONACCOUNT}
// If going to settings for the same app
- target={isGoingToSameSettings ? '_self' : '_blank'}
+ target={isGoingToSameSettings || app === APPS.PROTONVPN_SETTINGS ? '_self' : '_blank'}
{...rest}
>
{children}

diff --git a/packages/components/helpers/earlyAccessDesynchronization.ts b/packages/components/helpers/earlyAccessDesynchronization.ts
index 36bd0c712..c2fb3681c 100644
--- a/packages/components/helpers/earlyAccessDesynchronization.ts
+++ b/packages/components/helpers/earlyAccessDesynchronization.ts
@@ -42,6 +42,7 @@ export const handleEarlyAccessDesynchronization = ({
earlyAccessScope: Feature<Environment> | undefined;
appName: APP_NAMES;
}) => {
+ return;
if (doesNotSupportEarlyAccessVersion()) {
return;
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
diff --git a/packages/shared/lib/constants.ts b/packages/shared/lib/constants.ts
index e98525020..9e27f7f97 100644
index a5c634a9f..c1cbd799a 100644
--- a/packages/shared/lib/constants.ts
+++ b/packages/shared/lib/constants.ts
@@ -52,7 +52,7 @@ export const APPS = {
} as const;
@@ -57,7 +57,7 @@ export const APPS = {

export const APPS_CONFIGURATION = {
[APPS.PROTONACCOUNT]: {
- publicPath: '',
+ publicPath: '/account',
subdomain: 'account',
name: ACCOUNT_APP_NAME,
name: 'Proton Account',
bareName: 'Account',
@@ -115,8 +115,8 @@ export const APPS_CONFIGURATION = {
@@ -129,8 +129,8 @@ export const APPS_CONFIGURATION = {
settingsSlug: '',
},
[APPS.PROTONVPN_SETTINGS]: {
Expand All @@ -20,5 +20,5 @@ index e98525020..9e27f7f97 100644
+ publicPath: 'account/vpn',
+ subdomain: 'account',
name: VPN_APP_NAME,
bareName: 'VPN',
bareName: VPN_SHORT_APP_NAME,
clientID: 'web-vpn-settings',
129 changes: 0 additions & 129 deletions patches/protonmail/embedded-verification-2.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
diff --git a/packages/components/hooks/useLinkHandler.tsx b/packages/components/hooks/useLinkHandler.tsx
index cd4a0af3a..7d192d8d6 100644
index 4038ff8b0..8faca2d95 100644
--- a/packages/components/hooks/useLinkHandler.tsx
+++ b/packages/components/hooks/useLinkHandler.tsx
@@ -4,7 +4,7 @@ import punycode from 'punycode.js';
@@ -2,6 +2,7 @@ import { ReactNode, RefObject, useEffect, useState } from 'react';

import { c } from 'ttag';

+import { openNewTab } from '@proton/shared/lib/helpers/browser';
import { PROTON_DOMAINS } from '@proton/shared/lib/constants';
-import { isEdge, isIE11 } from '@proton/shared/lib/helpers/browser';
+import { isEdge, isIE11, openNewTab } from '@proton/shared/lib/helpers/browser';
import { getSecondLevelDomain } from '@proton/shared/lib/helpers/url';
import { MailSettings } from '@proton/shared/lib/interfaces';
import isTruthy from '@proton/utils/isTruthy';
@@ -165,6 +165,10 @@ export const useLinkHandler: UseLinkHandler = (
@@ -128,6 +129,10 @@ export const useLinkHandler: UseLinkHandler = (
return;
}

+ event.preventDefault();
+ event.stopPropagation(); // Required for Safari
+ const encodedLink = await encoder(src);
+ const encodedLink = await punycodeUrl(src.encoded || src.raw);
+
if (
(askForConfirmation || isPhishingAttempt) &&
isExternal(src.raw) &&
@@ -172,13 +176,10 @@ export const useLinkHandler: UseLinkHandler = (
@@ -135,12 +140,10 @@ export const useLinkHandler: UseLinkHandler = (
.filter(isTruthy) // currentDomain can be null
.some((domain) => isSubDomain(hostname, domain))
) {
- event.preventDefault();
- event.stopPropagation(); // Required for Safari
-
- const link = await encoder(src);
- const link = punycodeUrl(src.encoded || src.raw);
- setLink(link);
-
+ setLink(encodedLink);
setLinkConfirmationModalOpen(true);
+ } else {
+ openNewTab(encodedLink ?? src.raw);
+ openNewTab(encodedLink);
}
});

Loading

0 comments on commit 6c0e869

Please sign in to comment.