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 Apr 4, 2023
1 parent 3b0dd98 commit 7e33af9
Show file tree
Hide file tree
Showing 10 changed files with 294 additions and 66 deletions.
34 changes: 3 additions & 31 deletions patches/protonmail/common-3.patch
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/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"
+ linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
+ windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
+ macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
+ } as const;
+ uaParser.setUA(
+ platform.startsWith("Linux")
Expand Down Expand Up @@ -125,31 +125,3 @@ index 36bd0c712..c2fb3681c 100644
if (doesNotSupportEarlyAccessVersion()) {
return;
}

diff --git a/applications/mail/src/app/helpers/message/messageImages.ts b/applications/mail/src/app/helpers/message/messageImages.ts
index effa61709..2d54ff153 100644
--- a/applications/mail/src/app/helpers/message/messageImages.ts
+++ b/applications/mail/src/app/helpers/message/messageImages.ts
@@ -194,7 +194,7 @@ export const replaceProxyWithOriginalURLAttributes = (message: MessageState, doc

export const forgeImageURL = (url: string, uid: string) => {
const config = getImage(url, 0, uid);
- const prefixedUrl = `api/${config.url}`; // api/ is required to set the AUTH cookie
+ const prefixedUrl = `___ELECTRON_MAIL_PROTON_API_ENTRY_URL_PLACEHOLDER___/${config.url}`;
const urlToLoad = createUrl(prefixedUrl, config.params);
return urlToLoad.toString();
};

diff --git a/packages/components/containers/contacts/helpers/senderImage.ts b/packages/components/containers/contacts/helpers/senderImage.ts
index 24578bbc0..6b38625e0 100644
--- a/packages/components/containers/contacts/helpers/senderImage.ts
+++ b/packages/components/containers/contacts/helpers/senderImage.ts
@@ -58,7 +58,7 @@ export const getSenderImageUrl = (
mode?: SenderImageMode
) => {
const config = getLogo(emailAddress, size, bimiSelector, mode, UID);
- const prefixedUrl = `api/${config.url}`; // api/ is required to set the AUTH cookie
+ const prefixedUrl = `___ELECTRON_MAIL_PROTON_API_ENTRY_URL_PLACEHOLDER___/${config.url}`;
const url = createUrl(prefixedUrl, config.params);
return url.toString();
};
107 changes: 107 additions & 0 deletions patches/protonmail/common-4.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
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/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/111.0.0.0 Safari/537.36",
+ windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
+ macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.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 5081c4003..cde37c0cb 100644
--- a/packages/components/components/link/SettingsLink.tsx
+++ b/packages/components/components/link/SettingsLink.tsx
@@ -48,7 +48,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={canOpenInSameTab(APP_NAME, settingsApp, toSettingsForApp) ? '_self' : '_blank'}
+ target={canOpenInSameTab(APP_NAME, settingsApp, toSettingsForApp) || 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;
}
20 changes: 10 additions & 10 deletions patches/protonmail/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"common-3.patch",
"url-3.patch",
"constants-8.patch",
"sentry-10.patch",
"sentry-11.patch",
"pack-api-arg-4.patch",
"pack-webpack-6.patch",
"session-storage-5.patch",
Expand All @@ -13,9 +13,9 @@
],
"proton-account": [
"common-3.patch",
"url-3.patch",
"url-4.patch",
"constants-8.patch",
"sentry-10.patch",
"sentry-12.patch",
"pack-api-arg-4.patch",
"pack-webpack-6.patch",
"session-storage-5.patch",
Expand All @@ -26,8 +26,8 @@
"proton-calendar": [
"common-3.patch",
"url-3.patch",
"constants-8.patch",
"sentry-10.patch",
"constants-10.patch",
"sentry-11.patch",
"pack-api-arg-4.patch",
"pack-webpack-6.patch",
"session-storage-5.patch",
Expand All @@ -36,9 +36,9 @@
],
"proton-drive": [
"common-3.patch",
"url-3.patch",
"url-4.patch",
"constants-10.patch",
"sentry-10.patch",
"sentry-12.patch",
"pack-api-arg-4.patch",
"pack-webpack-6.patch",
"session-storage-5.patch",
Expand All @@ -47,10 +47,10 @@
"proton-drive.patch"
],
"proton-vpn-settings": [
"common-3.patch",
"url-3.patch",
"common-4.patch",
"url-4.patch",
"constants-10.patch",
"sentry-11.patch",
"sentry-12.patch",
"pack-api-arg-4.patch",
"pack-webpack-6.patch",
"session-storage-5.patch",
Expand Down
8 changes: 4 additions & 4 deletions patches/protonmail/proton-mail.patch
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
diff --git a/packages/shared/lib/api/events.ts b/packages/shared/lib/api/events.ts
index 7c263575d..6d696e5f4 100644
index 519a50349..819bdb911 100644
--- a/packages/shared/lib/api/events.ts
+++ b/packages/shared/lib/api/events.ts
@@ -6,5 +6,9 @@ export const getLatestID = () => ({
export const getEvents = (eventID: string, params?: { ConversationCounts: 1 | 0; MessageCounts: 1 | 0 }) => ({
url: `v4/events/${eventID}`,
url: `core/v4/events/${eventID}`,
method: 'get',
- params,
+ params: {
+ ...params,
+ ConversationCounts: 1,
+ MessageCounts: 1,
+ },
+ MessageCounts: 1
+ }
});

diff --git a/packages/components/containers/login/MinimalLoginContainer.tsx b/packages/components/containers/login/MinimalLoginContainer.tsx
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/packages/shared/lib/helpers/sentry.ts b/packages/shared/lib/helpers/sentry.ts
index fb3124ec7..6d6a3fb2a 100644
index 731fc8566..6d6a3fb2a 100644
--- a/packages/shared/lib/helpers/sentry.ts
+++ b/packages/shared/lib/helpers/sentry.ts
@@ -1,14 +1,9 @@
Expand Down Expand Up @@ -39,7 +39,7 @@ index fb3124ec7..6d6a3fb2a 100644
const isLocalhost = (host: string) => host.startsWith('localhost');
const isProduction = (host: string) => host.endsWith('.proton.me') || host === VPN_HOSTNAME;

@@ -94,107 +74,10 @@ function main({
@@ -94,143 +74,10 @@ function main({
sessionTracking = false,
sentryConfig = getDefaultSentryConfig(config),
ignore = ({ host }) => isLocalhost(host),
Expand Down Expand Up @@ -70,7 +70,7 @@ index fb3124ec7..6d6a3fb2a 100644
- // Unfortunately Sentry does not use the custom transport for those, and thus fails to add the headers the API requires.
- sendClientReports: false,
- beforeSend(event, hint) {
- const error = hint?.originalException;
- const error = hint?.originalException as any;
- const stack = typeof error === 'string' ? error : error?.stack;
- // Filter out broken ferdi errors
- if (stack && stack.match(/ferdi|franz/i)) {
Expand Down Expand Up @@ -103,12 +103,15 @@ index fb3124ec7..6d6a3fb2a 100644
-
- return event;
- },
- // Some ignoreErrors and denyUrls are taken from this gist: https://gist.github.com/Chocksy/e9b2cdd4afc2aadc7989762c4b8b495a
- // This gist is suggested in the Sentry documentation: https://docs.sentry.io/clients/javascript/tips/#decluttering-sentry
- ignoreErrors: [
- // Ignore random plugins/extensions
- 'top.GLOBALS',
- 'canvas.contentDocument',
- 'MyApp_RemoveAllHighlights',
- 'atomicFindClose',
- // See http://toolbar.conduit.com/Developer/HtmlAndGadget/Methods/JSInjection.aspx
- 'conduitPage',
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1678243
- 'XDR encoding failure',
Expand All @@ -127,6 +130,39 @@ index fb3124ec7..6d6a3fb2a 100644
- 'ValidationError', // Validation error on user's side in Drive.
- 'ChunkLoadError', // WebPack loading source code.
- /ResizeObserver loop/, // Chromium bug https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded
- // See: http://blog.errorception.com/2012/03/tale-of-unfindable-js-error.html
- 'originalCreateNotification',
- 'http://tt.epicplay.com',
- "Can't find variable: ZiteReader",
- 'jigsaw is not defined',
- 'ComboSearch is not defined',
- 'http://loading.retry.widdit.com/',
- // Facebook borked
- 'fb_xd_fragment',
- // ISP "optimizing" proxy - `Cache-Control: no-transform` seems to reduce this. (thanks @acdha)
- // See http://stackoverflow.com/questions/4113268/how-to-stop-javascript-injection-from-vodafone-proxy
- 'bmi_SafeAddOnload',
- 'EBCallBackMessageReceived',
- // Avast extension error
- '_avast_submit',
- ],
- denyUrls: [
- // Google Adsense
- /pagead\/js/i,
- // Facebook flakiness
- /graph\.facebook\.com/i,
- // Facebook blocked
- /connect\.facebook\.net\/en_US\/all\.js/i,
- // Woopra flakiness
- /eatdifferent\.com\.woopra-ns\.com/i,
- /static\.woopra\.com\/js\/woopra\.js/i,
- // Chrome extensions
- /extensions\//i,
- /^chrome:\/\//i,
- // Other plugins
- /127\.0\.0\.1:4001\/isrunning/i, // Cacaoweb
- /webappstoolbarba\.texthelp\.com\//i,
- /metrics\.itunes\.apple\.com\.edgesuite\.net\//i,
- ],
- });
-
Expand Down
28 changes: 28 additions & 0 deletions patches/protonmail/url-3.patch
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,31 @@ index f0b3e2e31..90995e1fc 100644

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

diff --git a/applications/mail/src/app/helpers/message/messageImages.ts b/applications/mail/src/app/helpers/message/messageImages.ts
index effa61709..2d54ff153 100644
--- a/applications/mail/src/app/helpers/message/messageImages.ts
+++ b/applications/mail/src/app/helpers/message/messageImages.ts
@@ -194,7 +194,7 @@ export const replaceProxyWithOriginalURLAttributes = (message: MessageState, doc

export const forgeImageURL = (url: string, uid: string) => {
const config = getImage(url, 0, uid);
- const prefixedUrl = `api/${config.url}`; // api/ is required to set the AUTH cookie
+ const prefixedUrl = `___ELECTRON_MAIL_PROTON_API_ENTRY_URL_PLACEHOLDER___/${config.url}`;
const urlToLoad = createUrl(prefixedUrl, config.params);
return urlToLoad.toString();
};

diff --git a/packages/components/containers/contacts/helpers/senderImage.ts b/packages/components/containers/contacts/helpers/senderImage.ts
index 24578bbc0..6b38625e0 100644
--- a/packages/components/containers/contacts/helpers/senderImage.ts
+++ b/packages/components/containers/contacts/helpers/senderImage.ts
@@ -58,7 +58,7 @@ export const getSenderImageUrl = (
mode?: SenderImageMode
) => {
const config = getLogo(emailAddress, size, bimiSelector, mode, UID);
- const prefixedUrl = `api/${config.url}`; // api/ is required to set the AUTH cookie
+ const prefixedUrl = `___ELECTRON_MAIL_PROTON_API_ENTRY_URL_PLACEHOLDER___/${config.url}`;
const url = createUrl(prefixedUrl, config.params);
return url.toString();
};
Loading

0 comments on commit 7e33af9

Please sign in to comment.