From 936eb7e3e187685980587e5a1b464c520ac84cdf Mon Sep 17 00:00:00 2001 From: "VL.Y" <1560781+vladimiry@users.noreply.github.com> Date: Mon, 13 Mar 2023 16:55:03 +0300 Subject: [PATCH] update @ProtonMail web clients, closes #598 --- patches/protonmail/common-3.patch | 28 ++++ patches/protonmail/constants-9.patch | 24 ---- patches/protonmail/meta.json | 4 +- patches/protonmail/sentry-11.patch | 188 +++++++++++++++++++++++++++ src/shared/const/proton-apps.ts | 2 +- 5 files changed, 219 insertions(+), 27 deletions(-) delete mode 100644 patches/protonmail/constants-9.patch create mode 100644 patches/protonmail/sentry-11.patch diff --git a/patches/protonmail/common-3.patch b/patches/protonmail/common-3.patch index 22290801..9a3c9cfe 100644 --- a/patches/protonmail/common-3.patch +++ b/patches/protonmail/common-3.patch @@ -125,3 +125,31 @@ 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(); + }; diff --git a/patches/protonmail/constants-9.patch b/patches/protonmail/constants-9.patch deleted file mode 100644 index 771294ea..00000000 --- a/patches/protonmail/constants-9.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/packages/shared/lib/constants.ts b/packages/shared/lib/constants.ts -index 632e91b83..fd463a184 100644 ---- a/packages/shared/lib/constants.ts -+++ b/packages/shared/lib/constants.ts -@@ -61,7 +61,7 @@ export const APPS = { - - export const APPS_CONFIGURATION = { - [APPS.PROTONACCOUNT]: { -- publicPath: '', -+ publicPath: '/account', - subdomain: 'account', - name: 'Proton Account', - bareName: 'Account', -@@ -133,8 +133,8 @@ export const APPS_CONFIGURATION = { - settingsSlug: '', - }, - [APPS.PROTONVPN_SETTINGS]: { -- publicPath: '', -- subdomain: '', -+ publicPath: 'account/vpn', -+ subdomain: 'account', - name: VPN_APP_NAME, - bareName: VPN_SHORT_APP_NAME, - clientID: 'web-vpn-settings', diff --git a/patches/protonmail/meta.json b/patches/protonmail/meta.json index a63b448f..1ca20524 100644 --- a/patches/protonmail/meta.json +++ b/patches/protonmail/meta.json @@ -49,8 +49,8 @@ "proton-vpn-settings": [ "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", diff --git a/patches/protonmail/sentry-11.patch b/patches/protonmail/sentry-11.patch new file mode 100644 index 00000000..d3de6c78 --- /dev/null +++ b/patches/protonmail/sentry-11.patch @@ -0,0 +1,188 @@ +diff --git a/packages/shared/lib/helpers/sentry.ts b/packages/shared/lib/helpers/sentry.ts +index 69e21214b..6d6a3fb2a 100644 +--- a/packages/shared/lib/helpers/sentry.ts ++++ b/packages/shared/lib/helpers/sentry.ts +@@ -1,14 +1,9 @@ + import { + captureException, +- configureScope, +- init, +- makeFetchTransport, + captureMessage as sentryCaptureMessage, + } from '@sentry/browser'; +-import { BrowserTransportOptions } from '@sentry/browser/types/transports/types'; + + import { VPN_HOSTNAME } from '../constants'; +-import { ApiError } from '../fetch/ApiError'; + import { getUIDHeaders } from '../fetch/headers'; + import { ProtonConfig } from '../interfaces'; + +@@ -61,21 +56,6 @@ export const getContentTypeHeaders = (input: RequestInfo | URL): HeadersInit => + return {}; + }; + +-const sentryFetch = (input: RequestInfo | URL, init?: RequestInit) => { +- return globalThis.fetch(input, { +- ...init, +- headers: { +- ...init?.headers, +- ...getContentTypeHeaders(input), +- ...context.authHeaders, +- }, +- }); +-}; +- +-const makeProtonFetchTransport = (options: BrowserTransportOptions) => { +- return makeFetchTransport(options, sentryFetch); +-}; +- + const isLocalhost = (host: string) => host.startsWith('localhost'); + const isProduction = (host: string) => host.endsWith('.proton.me') || host === VPN_HOSTNAME; + +@@ -94,143 +74,10 @@ function main({ + sessionTracking = false, + sentryConfig = getDefaultSentryConfig(config), + ignore = ({ host }) => isLocalhost(host), +-}: SentryOptions) { +- const { SENTRY_DSN, APP_VERSION } = config; +- const { host, release, environment } = sentryConfig; +- +- // No need to configure it if we don't load the DSN +- if (!SENTRY_DSN || ignore(sentryConfig)) { +- return; +- } ++}: SentryOptions) {} + +- setUID(uid); +- +- // 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`); +- +- init({ +- dsn, +- release, +- environment, +- normalizeDepth: 5, +- transport: makeProtonFetchTransport, +- autoSessionTracking: sessionTracking, +- // Disable client reports. Client reports are used by sentry to retry events that failed to send on visibility change. +- // 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 stack = typeof error === 'string' ? error : error?.stack; +- // Filter out broken ferdi errors +- if (stack && stack.match(/ferdi|franz/i)) { +- return null; +- } +- +- // Not interested in uncaught API errors +- if (error instanceof ApiError) { +- return null; +- } +- +- if (!context.enabled) { +- 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; +- }, +- // 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', +- 'Request timed out', +- 'No network connection', +- 'Failed to fetch', +- 'NetworkError when attempting to fetch resource.', +- '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. +- '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, +- ], +- }); +- +- configureScope((scope) => { +- scope.setTag('appVersion', APP_VERSION); +- }); +-} +- +-export const traceError = (...args: Parameters) => { +- if (!isLocalhost(window.location.host)) { +- captureException(...args); +- } +-}; ++export const traceError = (...args: Parameters) => console.error(...args); + +-export const captureMessage = (...args: Parameters) => { +- if (!isLocalhost(window.location.host)) { +- sentryCaptureMessage(...args); +- } +-}; ++export const captureMessage = (...args: Parameters) => console.log(...args); + + export default main; diff --git a/src/shared/const/proton-apps.ts b/src/shared/const/proton-apps.ts index e23f931d..7096f51a 100644 --- a/src/shared/const/proton-apps.ts +++ b/src/shared/const/proton-apps.ts @@ -76,7 +76,7 @@ export const PROVIDER_REPO_MAP = { basePath: "account/vpn", apiSubdomain: "account-api", repoRelativeDistDir: "./dist", - tag: "proton-vpn-settings@5.0.15.1", + tag: "proton-vpn-settings@5.0.16.0", protonPack: {}, }, } as const;