From dce28d7fdb516bb6de0321defd02d9e7c0e1f199 Mon Sep 17 00:00:00 2001
From: "VL.Y" <1560781+vladimiry@users.noreply.github.com>
Date: Sat, 7 Dec 2024 15:54:35 +0300
Subject: [PATCH] update @ProtonMail web clients
---
patches/protonmail/app-calendar.patch | 21 ---
patches/protonmail/app-drive.patch | 82 ++++------
patches/protonmail/app-mail.patch | 28 ++--
patches/protonmail/common-15.patch | 8 +-
patches/protonmail/common-16.patch | 8 +-
patches/protonmail/link-handler-10.patch | 38 -----
patches/protonmail/meta.json | 16 +-
patches/protonmail/sentry-23.patch | 144 +++++++++++++++++
patches/protonmail/session-storage-9.patch | 170 +++++++++++++++++++++
src/shared/const/proton-apps.ts | 10 +-
10 files changed, 373 insertions(+), 152 deletions(-)
delete mode 100644 patches/protonmail/link-handler-10.patch
create mode 100644 patches/protonmail/sentry-23.patch
create mode 100644 patches/protonmail/session-storage-9.patch
diff --git a/patches/protonmail/app-calendar.patch b/patches/protonmail/app-calendar.patch
index 0444519a..361d654c 100644
--- a/patches/protonmail/app-calendar.patch
+++ b/patches/protonmail/app-calendar.patch
@@ -24,24 +24,3 @@ index b4d841c7cd..00ce66f767 100644
const container = document.querySelector('.app-root');
-diff --git a/applications/calendar/webpack.config.ts b/applications/calendar/webpack.config.ts
-index 729c7fc564..8c21b9143e 100644
---- a/applications/calendar/webpack.config.ts
-+++ b/applications/calendar/webpack.config.ts
-@@ -1,12 +1,12 @@
- import { Configuration } from 'webpack';
-
- import getConfig from '@proton/pack/webpack.config';
--import { addDevEntry } from '@proton/pack/webpack/entries';
-+import { addLoginEntry } from '@proton/pack/webpack/entries';
-
- const result = (env: any): Configuration => {
- const config = getConfig(env);
-- if (env.appMode === 'standalone') {
-- addDevEntry(config);
-+ if (env.appMode === 'standalone') { // keeping original condition, so login page only included for the "mail" app
-+ addLoginEntry(config);
- }
- return config;
- };
-
diff --git a/patches/protonmail/app-drive.patch b/patches/protonmail/app-drive.patch
index 7a9e2b3f..269d0d4d 100644
--- a/patches/protonmail/app-drive.patch
+++ b/patches/protonmail/app-drive.patch
@@ -25,31 +25,6 @@ index 7ca2da66f3..2a99b061bb 100644
ReactDOM.render(isPublicUrl ? : , document.querySelector('.app-root'));
-diff --git a/applications/drive/webpack.config.ts b/applications/drive/webpack.config.ts
-index afccc2a4b1..8682856d3a 100644
---- a/applications/drive/webpack.config.ts
-+++ b/applications/drive/webpack.config.ts
-@@ -2,7 +2,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin';
- import webpack from 'webpack';
-
- import getConfig from '@proton/pack/webpack.config';
--import { addDevEntry, getIndexChunks } from '@proton/pack/webpack/entries';
-+import { addLoginEntry, getIndexChunks } from '@proton/pack/webpack/entries';
-
- /**
- * There are some specific references to Buffer in the drive application,
-@@ -47,8 +47,8 @@ const result = (env: any): webpack.Configuration => {
- })
- );
-
-- if (env.appMode === 'standalone') {
-- addDevEntry(config);
-+ if (env.appMode === 'standalone') { // keeping original condition, so login page only included for the "mail" app
-+ addLoginEntry(config);
- }
-
- return {
-
diff --git a/applications/drive/src/.htaccess b/applications/drive/src/.htaccess
index b0b25a5fae..11d4e4af0f 100644
--- a/applications/drive/src/.htaccess
@@ -69,20 +44,36 @@ index b0b25a5fae..11d4e4af0f 100644
AddOutputFilter INCLUDES;DEFLATE svg
diff --git a/applications/drive/src/app/store/_downloads/fileSaver/download.ts b/applications/drive/src/app/store/_downloads/fileSaver/download.ts
-index 7483da5f4f..62d7bb7733 100644
+index e3a5bd4889..da2217e2f3 100644
--- a/applications/drive/src/app/store/_downloads/fileSaver/download.ts
+++ b/applications/drive/src/app/store/_downloads/fileSaver/download.ts
-@@ -13,8 +13,7 @@ import { TransferMeta } from '../../../components/TransferManager/transfer';
+@@ -1,6 +1,5 @@
+ import { WritableStream } from 'web-streams-polyfill';
+
+-import { isIos, isSafari } from '@proton/shared/lib/helpers/browser';
+ import { stripLeadingAndTrailingSlash } from '@proton/shared/lib/helpers/string';
+ import { PUBLIC_PATH } from '@proton/shared/lib/webpack.constants';
+
+@@ -15,17 +14,7 @@ let workerWakeupInterval: ReturnType;
* IOS - forces all browsers to use webkit, so same problems as safari in all browsers.
* For them download is done in-memory using blob response.
*/
--export const isUnsupported = () =>
-- !('serviceWorker' in navigator) || isSafari() || (isEdge() && !isEdgeChromium()) || isIos();
+-export const isUnsupported = () => {
+- /* TODO: To be removed after test DRVWEB-4375 */
+- if (typeof window !== 'undefined') {
+- const isSWForSafariEnabled = 'isSWForSafariEnabled' in window && window.isSWForSafariEnabled;
+- if (isSWForSafariEnabled) {
+- return !('serviceWorker' in navigator);
+- }
+- }
+- // Original
+- return !('serviceWorker' in navigator) || isSafari() || isIos();
+-};
+export const isUnsupported = () => !('serviceWorker' in navigator);
// createDownloadIframe opens download URL created in service worker to
// initialize the download in the browser. The response has headers to
-@@ -56,21 +55,28 @@ function serviceWorkerKeepAlive() {
+@@ -73,6 +62,7 @@ function serviceWorkerKeepAlive() {
}, 10000);
}
@@ -90,27 +81,16 @@ index 7483da5f4f..62d7bb7733 100644
export async function initDownloadSW() {
if (isUnsupported()) {
throw new Error('Saving file via download is unsupported by this browser');
- }
-
-- await navigator.serviceWorker.register(
-- /* webpackChunkName: "downloadSW" */
-- new URL('./downloadSW', import.meta.url),
-- {
-- scope: `/${stripLeadingAndTrailingSlash(PUBLIC_PATH)}`,
-- }
-- );
-+ try {
-+ await navigator.serviceWorker.register(
-+ /* webpackChunkName: "downloadSW" */
-+ new URL('./downloadSW', import.meta.url),
-+ {
-+ scope: `/${stripLeadingAndTrailingSlash(PUBLIC_PATH)}`,
-+ }
-+ );
-+ } catch (e) {
-+ console.error(`Failed to register service worker.`, e.message);
-+ throw e;
-+ }
+@@ -81,7 +71,7 @@ export async function initDownloadSW() {
+ await navigator.serviceWorker
+ .register(
+ /* webpackChunkName: "downloadSW" */
+- new URL('./downloadSW', import.meta.url),
++ new URL('./downloadSW', import.meta.url), // electron-mail-mark
+ {
+ scope: `/${stripLeadingAndTrailingSlash(PUBLIC_PATH)}`,
+ }
+@@ -107,6 +97,7 @@ export async function initDownloadSW() {
serviceWorkerKeepAlive();
}
diff --git a/patches/protonmail/app-mail.patch b/patches/protonmail/app-mail.patch
index b03d159f..90a43a49 100644
--- a/patches/protonmail/app-mail.patch
+++ b/patches/protonmail/app-mail.patch
@@ -26,18 +26,9 @@ index b4d841c7cd..96d2b5c9b4 100644
const container = document.querySelector('.app-root');
diff --git a/applications/mail/webpack.config.ts b/applications/mail/webpack.config.ts
-index 72f0b86274..22c087d99c 100644
+index 72f0b86274..68abcf32f9 100644
--- a/applications/mail/webpack.config.ts
+++ b/applications/mail/webpack.config.ts
-@@ -5,7 +5,7 @@ import { Configuration, ProvidePlugin } from 'webpack';
- import { InjectManifest } from 'workbox-webpack-plugin';
-
- import getConfig from '@proton/pack/webpack.config';
--import { addDevEntry, getIndexChunks, getSupportedEntry, mergeEntry } from '@proton/pack/webpack/entries';
-+import { addLoginEntry, getIndexChunks } from '@proton/pack/webpack/entries';
-
- const result = (env: any): Configuration => {
- setAutoFreeze(false);
@@ -41,14 +41,6 @@ const result = (env: any): Configuration => {
);
// }
@@ -53,16 +44,15 @@ index 72f0b86274..22c087d99c 100644
const htmlPlugin = config.plugins.find((plugin): plugin is HtmlWebpackPlugin => {
return plugin instanceof HtmlWebpackPlugin;
});
-@@ -58,7 +50,7 @@ const result = (env: any): Configuration => {
+@@ -57,7 +49,7 @@ const result = (env: any): Configuration => {
+ }
const htmlIndex = config.plugins.indexOf(htmlPlugin);
- if (env.appMode === 'standalone') {
-- addDevEntry(config);
-+ if (env.appMode === 'bundle') { // including login page for the "mail" app
-+ addLoginEntry(config);
++ if (env.appMode === 'bundle') { // making "login.html" page included in the root folder
+ addDevEntry(config);
}
- // We keep the order because the other plugins have an impact
@@ -75,19 +67,6 @@ const result = (env: any): Configuration => {
inject: 'body',
})
@@ -425,18 +415,18 @@ index 2aaa779d3..487f54ff3 100644
};
diff --git a/applications/mail/src/app/components/drawer/MailQuickSettings.tsx b/applications/mail/src/app/components/drawer/MailQuickSettings.tsx
-index c7fa985bb1..c7b33cf2f9 100644
+index a0158185f3..c9f107441d 100644
--- a/applications/mail/src/app/components/drawer/MailQuickSettings.tsx
+++ b/applications/mail/src/app/components/drawer/MailQuickSettings.tsx
-@@ -40,7 +40,6 @@ import { useGetStartedChecklist } from 'proton-mail/containers/onboardingCheckli
+@@ -51,7 +51,6 @@ import { useGetStartedChecklist } from 'proton-mail/containers/onboardingCheckli
import useMailModel from 'proton-mail/hooks/useMailModel';
import ClearBrowserDataModal from '../header/ClearBrowserDataModal';
-import MailDefaultHandlerModal from '../header/MailDefaultHandlerModal';
+ import { useMailOnboardingTelemetry } from '../onboarding/useMailOnboardingTelemetry';
const { OFF, UNSET, SERVER_ONLY } = AI_ASSISTANT_ACCESS;
-
-@@ -378,7 +377,6 @@ const MailQuickSettings = () => {
+@@ -417,7 +416,6 @@ const MailQuickSettings = () => {
diff --git a/patches/protonmail/common-15.patch b/patches/protonmail/common-15.patch
index e45fe6d5..ab02a1f7 100644
--- a/patches/protonmail/common-15.patch
+++ b/patches/protonmail/common-15.patch
@@ -69,18 +69,16 @@ index 55715b89d..c87879ad4 100755
}
diff --git a/packages/pack/webpack/entries.ts b/packages/pack/webpack/entries.ts
-index 30db3c5c9f..0a8a32dfba 100644
+index 30db3c5c9f..6c7a92bdc7 100644
--- a/packages/pack/webpack/entries.ts
+++ b/packages/pack/webpack/entries.ts
-@@ -27,25 +27,15 @@ export const mergeEntry = (originalEntry: any, entry: any) => {
- };
+@@ -28,24 +28,14 @@ export const mergeEntry = (originalEntry: any, entry: any) => {
};
--export const addDevEntry = (config: any) => {
+ export const addDevEntry = (config: any) => {
- if (config.mode === 'production') {
- return;
- }
-+export const addLoginEntry = (config: any) => {
// @ts-ignore
- config.entry.dev = [require.resolve('@proton/components/containers/app/StandaloneApp.tsx')];
+ config.entry.login = [require.resolve('@proton/components/containers/app/StandaloneApp.tsx')];
diff --git a/patches/protonmail/common-16.patch b/patches/protonmail/common-16.patch
index 5fe8a71e..e4b62521 100644
--- a/patches/protonmail/common-16.patch
+++ b/patches/protonmail/common-16.patch
@@ -69,18 +69,16 @@ index 55715b89d..c87879ad4 100755
}
diff --git a/packages/pack/webpack/entries.ts b/packages/pack/webpack/entries.ts
-index 30db3c5c9f..0a8a32dfba 100644
+index 30db3c5c9f..6c7a92bdc7 100644
--- a/packages/pack/webpack/entries.ts
+++ b/packages/pack/webpack/entries.ts
-@@ -27,25 +27,15 @@ export const mergeEntry = (originalEntry: any, entry: any) => {
- };
+@@ -28,24 +28,14 @@ export const mergeEntry = (originalEntry: any, entry: any) => {
};
--export const addDevEntry = (config: any) => {
+ export const addDevEntry = (config: any) => {
- if (config.mode === 'production') {
- return;
- }
-+export const addLoginEntry = (config: any) => {
// @ts-ignore
- config.entry.dev = [require.resolve('@proton/components/containers/app/StandaloneApp.tsx')];
+ config.entry.login = [require.resolve('@proton/components/containers/app/StandaloneApp.tsx')];
diff --git a/patches/protonmail/link-handler-10.patch b/patches/protonmail/link-handler-10.patch
deleted file mode 100644
index 3167c8a8..00000000
--- a/patches/protonmail/link-handler-10.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/packages/components/hooks/useLinkHandler.tsx b/packages/components/hooks/useLinkHandler.tsx
-index 30cda536c9..48d7c2c459 100644
---- a/packages/components/hooks/useLinkHandler.tsx
-+++ b/packages/components/hooks/useLinkHandler.tsx
-@@ -13,6 +13,7 @@ import isTruthy from '@proton/utils/isTruthy';
- import LinkConfirmationModal from '../components/notifications/LinkConfirmationModal/LinkConfirmationModal';
- import { getHostname, isExternal, punycodeUrl } from '../helpers/url';
- import { useHandler, useNotifications } from './index';
-+import { openNewTab } from '@proton/shared/lib/helpers/browser';
-
- // Reference : Angular/src/app/utils/directives/linkHandler.js
-
-@@ -130,6 +131,10 @@ export const useLinkHandler: UseLinkHandler = (
- return;
- }
-
-+ event.preventDefault();
-+ event.stopPropagation(); // Required for Safari
-+ const link = punycodeUrl(src.encoded || src.raw);
-+
- if (
- (askForConfirmation || isPhishingAttempt) &&
- isExternal(src.raw, window.location.hostname) &&
-@@ -137,12 +142,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 = punycodeUrl(src.encoded || src.raw);
- setLink(link);
- setLinkConfirmationModalOpen(true);
-+ } else {
-+ openNewTab(link);
- }
- });
-
diff --git a/patches/protonmail/meta.json b/patches/protonmail/meta.json
index 4f58f5e6..6cd390c4 100644
--- a/patches/protonmail/meta.json
+++ b/patches/protonmail/meta.json
@@ -2,7 +2,7 @@
"proton-mail": [
"common-15.patch",
"constants-13.patch",
- "link-handler-10.patch",
+ "link-handler-11.patch",
"pack-api-arg-5.patch",
"pack-webpack-11.patch",
"product-link-6.patch",
@@ -21,8 +21,8 @@
"pack-api-arg-5.patch",
"pack-webpack-12.patch",
"product-link-6.patch",
- "sentry-22.patch",
- "session-storage-8.patch",
+ "sentry-23.patch",
+ "session-storage-9.patch",
"url-8.patch",
"drawer-app.patch",
"slug-helper-1.patch",
@@ -32,7 +32,7 @@
"proton-calendar": [
"common-15.patch",
"constants-13.patch",
- "link-handler-10.patch",
+ "link-handler-11.patch",
"pack-api-arg-5.patch",
"pack-webpack-11.patch",
"product-link-6.patch",
@@ -45,11 +45,11 @@
"app-calendar.patch"
],
"proton-drive": [
- "common-15.patch",
+ "common-16.patch",
"constants-13.patch",
"link-handler-11.patch",
"pack-api-arg-5.patch",
- "pack-webpack-11.patch",
+ "pack-webpack-12.patch",
"product-link-6.patch",
"sentry-22.patch",
"session-storage-8.patch",
@@ -66,8 +66,8 @@
"pack-api-arg-5.patch",
"pack-webpack-12.patch",
"product-link-6.patch",
- "sentry-22.patch",
- "session-storage-8.patch",
+ "sentry-23.patch",
+ "session-storage-9.patch",
"url-8.patch",
"drawer-app.patch",
"slug-helper-1.patch",
diff --git a/patches/protonmail/sentry-23.patch b/patches/protonmail/sentry-23.patch
new file mode 100644
index 00000000..5e75667c
--- /dev/null
+++ b/patches/protonmail/sentry-23.patch
@@ -0,0 +1,144 @@
+diff --git a/packages/shared/lib/helpers/sentry.ts b/packages/shared/lib/helpers/sentry.ts
+index 10fbb88611..4a7ba54f7a 100644
+--- a/packages/shared/lib/helpers/sentry.ts
++++ b/packages/shared/lib/helpers/sentry.ts
+@@ -181,108 +181,14 @@ function main({
+ ignore = ({ host }) => isLocalhost(host),
+ denyUrls = getDefaultDenyUrls(),
+ ignoreErrors = getDefaultIgnoreErrors(),
+-}: SentryOptions) {
+- const { SENTRY_DSN, SENTRY_DESKTOP_DSN, APP_VERSION } = config;
+- const sentryDSN = isElectronApp ? SENTRY_DESKTOP_DSN || SENTRY_DSN : SENTRY_DSN;
+- const { host, release, environment } = sentryConfig;
+-
+- // No need to configure it if we don't load the DSN
+- if (!sentryDSN || ignore(sentryConfig)) {
+- return;
+- }
+-
+- setUID(UID);
+-
+- // Assumes sentryDSN is: https://111b3eeaaec34cae8e812df705690a36@sentry/11
+- // To get https://111b3eeaaec34cae8e812df705690a36@protonmail.com/api/core/v4/reports/sentry/11
+- const dsn = sentryDSN.replace('sentry', `${host}/api/core/v4/reports/sentry`);
+-
+- init({
+- dsn,
+- release,
+- environment,
+- normalizeDepth: 5,
+- transport: makeProtonFetchTransport,
+- autoSessionTracking: sessionTracking,
+- // do not log calls to console.log, console.error, etc.
+- integrations: [
+- new SentryIntegrations.Breadcrumbs({
+- console: false,
+- }),
+- ],
+- // 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 as any;
+- 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, or known errors
+- if (error instanceof ApiError || error?.trace === false) {
+- 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('#');
+- }
+- // keys/all endpoint accepts Email as parameter which is PII.
+- if (event.request && event.request.url) {
+- [event.request.url] = event.request.url.toLowerCase().split('email');
+- }
+- 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('#');
+- }
+-
+- // Button titles may contain accidental PII
+- if (
+- breadcrumb.category === 'ui.click' &&
+- breadcrumb.message &&
+- breadcrumb.message.startsWith('button')
+- ) {
+- breadcrumb.message = breadcrumb.message.replace(/\[title=".+?"\]/g, '[title="(Filtered)"]');
+- }
+-
+- 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,
+- denyUrls,
+- });
+-
+- configureScope((scope) => {
+- scope.setTag('appVersion', APP_VERSION);
+- });
+-}
++}: SentryOptions) {}
+
+ export const traceError = (...args: Parameters) => {
+- if (!isLocalhost(window.location.host)) {
+- captureException(...args);
+- Availability.mark(AvailabilityTypes.SENTRY);
+- }
++ console.error(...args);
+ };
+
+ export const captureMessage = (...args: Parameters) => {
+- if (!isLocalhost(window.location.host)) {
+- sentryCaptureMessage(...args);
+- }
++ console.log(...args);
+ };
+
+ type MailInitiative = 'drawer-security-center' | 'composer' | 'assistant' | 'mail-onboarding';
+@@ -295,13 +201,7 @@ type CaptureExceptionArgs = Parameters;
+ * @param error
+ */
+ export const traceInitiativeError = (initiative: MailInitiative, error: CaptureExceptionArgs[0]) => {
+- if (!isLocalhost(window.location.host)) {
+- captureException(error, {
+- tags: {
+- initiative,
+- },
+- });
+- }
++ console.error(initiative, error);
+ };
+
+ /**
+@@ -313,11 +213,7 @@ export const captureInitiativeMessage: (initiative: SentryInitiative, message: s
+ initiative,
+ message
+ ) => {
+- captureMessage(message, {
+- tags: {
+- initiative,
+- },
+- });
++ console.log(initiative, message);
+ };
+
+ export default main;
diff --git a/patches/protonmail/session-storage-9.patch b/patches/protonmail/session-storage-9.patch
new file mode 100644
index 00000000..4e200166
--- /dev/null
+++ b/patches/protonmail/session-storage-9.patch
@@ -0,0 +1,170 @@
+diff --git a/packages/account/bootstrap/index.ts b/packages/account/bootstrap/index.ts
+index d384249b94..916fcbd953 100644
+--- a/packages/account/bootstrap/index.ts
++++ b/packages/account/bootstrap/index.ts
+@@ -83,6 +83,7 @@ const handleUID = (UID: string | undefined) => {
+ metrics.setAuthHeaders(UID || '');
+ };
+
++/* tracking use of: createSecureSessionStorage() */
+ export const createAuthentication = (args?: Partial[0]>) => {
+ return createAuthenticationStore({
+ store: createSecureSessionStorage(),
+@@ -90,6 +91,7 @@ export const createAuthentication = (args?: Partial */
+
+ export const removeLoaderClassName = () => {
+ document.querySelector('.app-root-loader')?.classList.add('hidden');
+
+diff --git a/packages/shared/lib/authentication/createSecureSessionStorage.ts b/packages/shared/lib/authentication/createSecureSessionStorage.ts
+index 2477711b0..a6c9fe1a5 100644
+--- a/packages/shared/lib/authentication/createSecureSessionStorage.ts
++++ b/packages/shared/lib/authentication/createSecureSessionStorage.ts
+@@ -1,29 +1,26 @@
++/* */
+ import { load, save } from '../helpers/secureSessionStorage';
+ import createStore from '../helpers/store';
+
+ const createSecureSessionStorage = () => {
+ const store = createStore(load());
++ const saveStateDo = () => {
++ save(store.getState());
++ };
++
++ window.addEventListener("electron-mail:packages/shared/lib/authentication/createSecureSessionStorage.ts:unloadLike", saveStateDo);
+
+ if ('onpagehide' in window) {
+ const handlePageShow = () => {
+ // This does not need to do anything. The main purpose is just to reset window.name and sessionStorage to fix the Safari 13.1 described below
+ load();
+ };
+-
+- const handlePageHide = () => {
+- // Cannot use !event.persisted because Safari 13.1 does not send that when you are navigating on the same domain
+- save(store.getState());
+- };
+-
+ window.addEventListener('pageshow', handlePageShow, true);
+- window.addEventListener('pagehide', handlePageHide, true);
++ window.addEventListener('pagehide', saveStateDo, true);
+ } else {
+- const handleUnload = () => {
+- save(store.getState());
+- };
+ // This gets narrowed to never because of the onpagehide
+ // @ts-ignore
+- window.addEventListener('unload', handleUnload, true);
++ window.addEventListener('unload', saveStateDo, true);
+ }
+
+ return store;
+@@ -32,3 +29,4 @@ const createSecureSessionStorage = () => {
+ export type SecureSessionStorage = ReturnType;
+
+ export default createSecureSessionStorage;
++/* */
+
+diff --git a/packages/shared/lib/helpers/secureSessionStorage.ts b/packages/shared/lib/helpers/secureSessionStorage.ts
+index f24616faf9..6c05699766 100644
+--- a/packages/shared/lib/helpers/secureSessionStorage.ts
++++ b/packages/shared/lib/helpers/secureSessionStorage.ts
+@@ -119,6 +119,7 @@ export const separateParts = (data: any) =>
+ { share1: {}, share2: {} }
+ );
+
++/* */
+ const SESSION_STORAGE_KEY = 'proton:storage';
+ export const save = (data: any) => {
+ if (!hasSessionStorage()) {
+@@ -133,6 +134,34 @@ export const load = () => {
+ if (!hasSessionStorage()) {
+ return {};
+ }
++ {
++ const MAILBOX_PASSWORD_KEY = "proton:mailbox_pwd";
++ const UID_KEY = "proton:oauth:UID";
++ if ( // using old logic: https://github.com/ProtonMail/WebClients/commit/c0354e1522a5c499aacc0d43960473d8eb658793
++ !window.sessionStorage.getItem(SESSION_STORAGE_KEY)
++ &&
++ (
++ window.sessionStorage.getItem(MAILBOX_PASSWORD_KEY)
++ &&
++ window.sessionStorage.getItem(UID_KEY)
++ )
++ ) {
++ const readSessionStorage = (keys: string[] = []) => {
++ return keys.reduce<{ [key: string]: any }>((acc, key) => {
++ acc[key] = window.sessionStorage.getItem(key);
++ window.sessionStorage.removeItem(key);
++ return acc;
++ }, {});
++ };
++ const load = (keys: string[]) => {
++ const nameStorage = deserialize(window.name);
++ window.name = '';
++ const sessionData = readSessionStorage(keys);
++ return mergeParts(nameStorage, sessionData);
++ };
++ return load([MAILBOX_PASSWORD_KEY, UID_KEY]);
++ }
++ }
+ try {
+ const share1 = deserialize(window.name);
+ const share2 = window.sessionStorage.getItem(SESSION_STORAGE_KEY) || '';
+@@ -148,3 +177,4 @@ export const load = () => {
+ return {};
+ }
+ };
++/* */
+
+diff --git a/packages/shared/lib/authentication/createAuthenticationStore.ts b/packages/shared/lib/authentication/createAuthenticationStore.ts
+index b7d1404e84..211d35a460 100644
+--- a/packages/shared/lib/authentication/createAuthenticationStore.ts
++++ b/packages/shared/lib/authentication/createAuthenticationStore.ts
+@@ -4,6 +4,7 @@ import type { OfflineKey } from '@proton/shared/lib/authentication/offlineKey';
+ import { appMode } from '../webpack.constants';
+ import { getBasename, getLocalIDFromPathname, getParsedPathWithoutLocalIDBasename } from './pathnameHelper';
+ import { getPersistedSession } from './persistedSessionStorage';
++import { APPS_CONFIGURATION } from '@proton/shared/lib/constants';
+
+ const MAILBOX_PASSWORD_KEY = 'proton:mailbox_pwd';
+ const UID_KEY = 'proton:oauth:UID';
+@@ -32,8 +33,8 @@ const defaultAuthData = {
+ basename: undefined,
+ };
+
+-const getInitialState = (mode: 'sso' | 'standalone', oldUID?: string, oldLocalID?: number): AuthData => {
+- if (mode === 'standalone') {
++const getInitialState = (mode: 'sso' | 'standalone' | 'bundle', oldUID?: string, oldLocalID?: number): AuthData => {
++ if (mode === 'bundle') {
+ return {
+ UID: oldUID,
+ localID: undefined,
+@@ -152,6 +153,14 @@ const createAuthenticationStore = ({ mode = appMode, initialAuth, store: { set,
+ basename = undefined;
+ }
+
++ {
++ const protonApp = window.sessionStorage.getItem("electron_mail:proton_app_name");
++ if (protonApp && protonApp in APPS_CONFIGURATION) {
++ const {publicPath} = APPS_CONFIGURATION[protonApp as keyof typeof APPS_CONFIGURATION];
++ return publicPath || "/";
++ }
++ }
++
+ return getPath(basename, window.location.href, path);
+ };
+
+@@ -195,7 +204,7 @@ const createAuthenticationStore = ({ mode = appMode, initialAuth, store: { set,
+ return basename;
+ },
+ get ready(): boolean {
+- return Boolean(initialAuthData.UID && initialUID && getClientKey());
++ return Boolean(initialAuthData.UID && initialUID);
+ },
+ };
+ };
+
diff --git a/src/shared/const/proton-apps.ts b/src/shared/const/proton-apps.ts
index 62b603d2..e6898dc6 100644
--- a/src/shared/const/proton-apps.ts
+++ b/src/shared/const/proton-apps.ts
@@ -28,7 +28,7 @@ export const PROVIDER_REPO_MAP = {
basePath: "",
apiSubdomain: "mail-api",
repoRelativeDistDir: "./dist",
- tag: "proton-mail@5.0.51.12",
+ tag: "proton-mail@5.0.52.8",
protonPack: {
webpackIndexEntryItems: [
// immediate
@@ -55,14 +55,14 @@ export const PROVIDER_REPO_MAP = {
basePath: "account",
apiSubdomain: "account-api",
repoRelativeDistDir: "./dist",
- tag: "proton-account@5.0.188.2",
+ tag: "proton-account@5.0.194.0",
protonPack: {},
},
[PROVIDER_APP_NAMES[2]]: {
basePath: "calendar",
apiSubdomain: "calendar-api",
repoRelativeDistDir: "./dist",
- tag: "proton-calendar@5.0.36.11",
+ tag: "proton-calendar@5.0.37.11",
protonPack: {
webpackIndexEntryItems: [
// immediate
@@ -75,7 +75,7 @@ export const PROVIDER_REPO_MAP = {
basePath: "drive",
apiSubdomain: "drive-api",
repoRelativeDistDir: "./dist",
- tag: "proton-drive@5.2.0+5c841022",
+ tag: "proton-drive@5.2.0+f8bc23bc",
protonPack: {
webpackIndexEntryItems: [
// immediate
@@ -88,7 +88,7 @@ export const PROVIDER_REPO_MAP = {
basePath: "account/vpn",
apiSubdomain: "account-api",
repoRelativeDistDir: "./dist",
- tag: "proton-vpn-settings@5.0.154.1",
+ tag: "proton-vpn-settings@5.0.158.0",
protonPack: {},
},
} as const;