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 16, 2022
1 parent b0d0150 commit 075a8ac
Show file tree
Hide file tree
Showing 6 changed files with 8,150 additions and 15 deletions.
6 changes: 3 additions & 3 deletions patches/protonmail/common.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/99.0.4844.84 Safari/537.36",
+ windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36",
+ macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36"
+ linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
+ windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
+ macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
+ } as const;
+ uaParser.setUA(
+ platform.startsWith("Linux")
Expand Down
12 changes: 6 additions & 6 deletions patches/protonmail/meta.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"proton-mail": [
"common.patch",
"constants-2.patch",
"sentry-4.patch",
"constants-3.patch",
"sentry-5.patch",
"captcha-3.patch",
"pack-api-arg-3.patch",
"pack-webpack-config-3.patch",
Expand All @@ -12,8 +12,8 @@
],
"proton-account": [
"common.patch",
"constants-2.patch",
"sentry-4.patch",
"constants-3.patch",
"sentry-5.patch",
"captcha-3.patch",
"pack-api-arg-3.patch",
"pack-webpack-config-3.patch",
Expand Down Expand Up @@ -44,8 +44,8 @@
],
"proton-vpn-settings": [
"common.patch",
"constants-2.patch",
"sentry-4.patch",
"constants-3.patch",
"sentry-5.patch",
"captcha-3.patch",
"pack-api-arg-3.patch",
"pack-webpack-config-3.patch",
Expand Down
36 changes: 34 additions & 2 deletions patches/protonmail/proton-mail.patch
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,29 @@ index 3da997386..c629fde0d 100644
const [hasInitialAuth] = useState(() => {
return !window.location.pathname.startsWith(G_OAUTH_REDIRECT_PATH);

diff --git a/applications/drive/src/app/store/search/useSearchEnabledFeature.tsx b/applications/drive/src/app/store/search/useSearchEnabledFeature.tsx
index bc23e00d8..82db68e53 100644
--- a/applications/drive/src/app/store/search/useSearchEnabledFeature.tsx
+++ b/applications/drive/src/app/store/search/useSearchEnabledFeature.tsx
@@ -1,11 +1,3 @@
-import { FeatureCode, useFeature, useUser } from '@proton/components';
-import { isMobile } from '@proton/shared/lib/helpers/browser';
-import { isPaid } from '@proton/shared/lib/user/helpers';
-
export default function useSearchEnabledFeature() {
- const [user] = useUser();
- const { feature } = useFeature(FeatureCode.DriveSearchEnabled);
-
- const showEncryptedSearch = !isMobile() && !!feature?.Value && !!isPaid(user);
- return showEncryptedSearch;
+ return false;
}

diff --git a/applications/mail/src/app/components/header/AdvancedSearchDropdown.tsx b/applications/mail/src/app/components/header/AdvancedSearchDropdown.tsx
index 7da0f183e..c07f51d91 100644
index 567260eb0..7d56243a6 100644
--- a/applications/mail/src/app/components/header/AdvancedSearchDropdown.tsx
+++ b/applications/mail/src/app/components/header/AdvancedSearchDropdown.tsx
@@ -200,7 +200,7 @@ const AdvancedSearchDropdown = ({ keyword: fullInput = '', isNarrow }: Props) =>
@@ -203,7 +203,7 @@ const AdvancedSearchDropdown = ({ keyword: fullInput = '', isNarrow }: Props) =>
loadingScheduledFeature;

// Switches
Expand All @@ -95,6 +113,20 @@ index 7da0f183e..c07f51d91 100644
const dropdownSearchButtonProps = {
ref: anchorRef,

diff --git a/applications/mail/src/app/components/header/search/MailSearch.tsx b/applications/mail/src/app/components/header/search/MailSearch.tsx
index 3faa0160b..e7b680365 100644
--- a/applications/mail/src/app/components/header/search/MailSearch.tsx
+++ b/applications/mail/src/app/components/header/search/MailSearch.tsx
@@ -54,7 +54,7 @@ const MailSearch = ({ breakpoints }: Props) => {
const { isDBLimited, dropdownOpened } = getESDBStatus();
const esState = useEncryptedSearchToggleState(isOpen);

- const showEncryptedSearch = !isMobile() && !!esFeature && !!esFeature.Value && !!isPaid(user);
+ const showEncryptedSearch = false;

// Show more from inside AdvancedSearch to persist the state when the overlay is closed
const { state: showMore, toggle: toggleShowMore } = useToggle(false);

diff --git a/applications/mail/src/app/containers/mailbox/MailboxContainer.tsx b/applications/mail/src/app/containers/mailbox/MailboxContainer.tsx
index 562696c4e..6531defba 100644
--- a/applications/mail/src/app/containers/mailbox/MailboxContainer.tsx
Expand Down
103 changes: 103 additions & 0 deletions patches/protonmail/sentry-5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
diff --git a/packages/shared/lib/helpers/sentry.ts b/packages/shared/lib/helpers/sentry.ts
index b2c44c589..375d20e29 100644
--- a/packages/shared/lib/helpers/sentry.ts
+++ b/packages/shared/lib/helpers/sentry.ts
@@ -1,96 +1,12 @@
import * as Sentry from '@sentry/browser';

import { ProtonConfig } from '../interfaces';
-import { VPN_HOSTNAME } from '../constants';
-
-const isLocalhost = (host: string) => host.startsWith('localhost');
-
-const isProduction = (host: string) => host.endsWith('.protonmail.com') || host === VPN_HOSTNAME;

function main({ SENTRY_DSN, COMMIT, APP_VERSION }: Pick<ProtonConfig, 'SENTRY_DSN' | 'COMMIT' | 'APP_VERSION'>) {
- const { host } = window.location;
-
- // No need to configure it if we don't load the DSN
- if (!SENTRY_DSN || isLocalhost(host)) {
- return;
- }
-
- // Assumes SENTRY_DSN is: https://111b3eeaaec34cae8e812df705690a36@sentry/11
- // To get https://111b3eeaaec34cae8e812df705690a36@protonmail.com/api/core/v4/reports/sentry/11
- const dsn = SENTRY_DSN.replace('sentry', `${host}/api/core/v4/reports/sentry`);
-
- Sentry.init({
- dsn,
- release: isProduction(host) ? APP_VERSION : COMMIT,
- environment: host.split('.').splice(1).join('.'),
- normalizeDepth: 5,
- beforeSend(event, hint) {
- const error = hint?.originalException;
- const stack = typeof error === 'string' ? error : error?.stack;
- // Filter out broken ferdi errors
- if (stack && stack.match(/ferdi|franz/i)) {
- return null;
- }
-
- // Remove the hash from the request URL and navigation breadcrumbs to avoid
- // leaking the search parameters of encrypted searches
- if (event.request && event.request.url) {
- [event.request.url] = event.request.url.split('#');
- }
- if (event.breadcrumbs) {
- event.breadcrumbs = event.breadcrumbs.map((breadcrumb) => {
- if (breadcrumb.category === 'navigation' && breadcrumb.data) {
- [breadcrumb.data.from] = breadcrumb.data.from.split('#');
- [breadcrumb.data.to] = breadcrumb.data.to.split('#');
- }
- return breadcrumb;
- });
- }
-
- return event;
- },
- ignoreErrors: [
- // Ignore random plugins/extensions
- 'top.GLOBALS',
- 'canvas.contentDocument',
- 'MyApp_RemoveAllHighlights',
- 'atomicFindClose',
- 'conduitPage',
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1678243
- 'XDR encoding failure',
- 'Request timed out',
- 'No network connection',
- 'Failed to fetch',
- 'NetworkError when attempting to fetch resource.',
- 'No network connection',
- 'webkitExitFullScreen', // Bug in Firefox for iOS.
- 'InactiveSession',
- 'UnhandledRejection', // Happens too often in extensions and we have lints for that, so should be safe to ignore.
- /chrome-extension/,
- /moz-extension/,
- 'TransferCancel', // User action to interrupt upload or download in Drive.
- 'UploadConflictError', // User uploading the same file again in Drive.
- 'UploadUserError', // Upload 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
- ],
- });
-
- Sentry.configureScope((scope) => {
- scope.setTag('appVersion', APP_VERSION);
- });
}

-export const traceError = (...args: Parameters<typeof Sentry.captureException>) => {
- if (!isLocalhost(window.location.host)) {
- Sentry.captureException(...args);
- }
-};
+export const traceError = (...args: Parameters<typeof Sentry.captureException>) => console.error(...args);

-export const captureMessage = (...args: Parameters<typeof Sentry.captureMessage>) => {
- if (!isLocalhost(window.location.host)) {
- Sentry.captureMessage(...args);
- }
-};
+export const captureMessage = (...args: Parameters<typeof Sentry.captureMessage>) => console.log(...args);

export default main;
8 changes: 4 additions & 4 deletions src/shared/proton-apps-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const PROVIDER_REPO_MAP = {
[PROVIDER_APP_NAMES[0]]: {
repoRelativeDistDir: "./dist",
basePath: "",
tag: "proton-mail@4.19.4",
tag: "proton-mail@4.20.3",
protonPack: {
webpackIndexEntryItems: [
// immediate
Expand All @@ -47,7 +47,7 @@ export const PROVIDER_REPO_MAP = {
[PROVIDER_APP_NAMES[1]]: {
repoRelativeDistDir: "./dist",
basePath: "account",
tag: "proton-account@4.25.1",
tag: "proton-account@4.27.1",
protonPack: {}
},
[PROVIDER_APP_NAMES[2]]: {
Expand All @@ -65,13 +65,13 @@ export const PROVIDER_REPO_MAP = {
[PROVIDER_APP_NAMES[3]]: {
repoRelativeDistDir: "./dist",
basePath: "drive",
tag: "proton-drive@4.11.0",
tag: "proton-drive@4.11.2",
protonPack: {},
},
[PROVIDER_APP_NAMES[4]]: {
repoRelativeDistDir: "./dist",
basePath: "account/vpn",
tag: "proton-vpn-settings@4.17.0",
tag: "proton-vpn-settings@4.21.1",
protonPack: {},
},
} as const;
Expand Down

0 comments on commit 075a8ac

Please sign in to comment.