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 Nov 19, 2021
1 parent 2720b0c commit 7170eaa
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 25 deletions.
27 changes: 25 additions & 2 deletions patches/protonmail/common.patch
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,32 @@ index c50ab972c..a505eb314 100644


diff --git a/packages/shared/lib/helpers/browser.ts b/packages/shared/lib/helpers/browser.ts
index 8c94fae..3602b68 100644
index 9aaa78a28..f3d24b47c 100644
--- a/packages/shared/lib/helpers/browser.ts
+++ b/packages/shared/lib/helpers/browser.ts
@@ -117,20 +117,10 @@ export const requireDirectAction = () => isSafari() || isFirefox() || isEdge();
@@ -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/96.0.4664.45 Safari/537.36",
+ windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36",
+ macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 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) => {
Expand All @@ -112,6 +134,7 @@ index 8c94fae..3602b68 100644
+ ),
+ );
};

diff --git a/packages/shared/lib/constants.ts b/packages/shared/lib/constants.ts
index 2bd472b..52cf521 100644
--- a/packages/shared/lib/constants.ts
Expand Down
4 changes: 2 additions & 2 deletions patches/protonmail/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
],
"proton-drive": [
"common.patch",
"sentry-1.patch",
"captcha-1.patch",
"sentry-2.patch",
"captcha-2.patch",
"pack-api-arg.patch",
"proton-drive.patch"
],
Expand Down
35 changes: 25 additions & 10 deletions patches/protonmail/proton-drive.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
diff --git a/applications/drive/src/app/components/ShareLinkModal/GeneratedLinkState.tsx b/applications/drive/src/app/components/ShareLinkModal/GeneratedLinkState.tsx
index 3cb6545..4ad120b 100644
--- a/applications/drive/src/app/components/ShareLinkModal/GeneratedLinkState.tsx
+++ b/applications/drive/src/app/components/ShareLinkModal/GeneratedLinkState.tsx
@@ -73,7 +73,7 @@ function GeneratedLinkState({
}: Props) {
const contentRef = useRef<HTMLDivElement>(null);
const { createNotification } = useNotifications();
diff --git a/applications/drive/src/app/utils/FileSaver/download.ts b/applications/drive/src/app/utils/FileSaver/download.ts
index 92eb4e5e2..e1664fd78 100644
--- a/applications/drive/src/app/utils/FileSaver/download.ts
+++ b/applications/drive/src/app/utils/FileSaver/download.ts
@@ -11,8 +11,7 @@ import { TransferMeta } from '@proton/shared/lib/interfaces/drive/transfer';
* 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 = () => !('serviceWorker' in navigator)

// createDownloadIframe opens download URL created in service worker to
// initialize the download in the browser. The response has headers to

diff --git a/applications/drive/src/app/utils/link.ts b/applications/drive/src/app/utils/link.ts
index 31b5d775d..c08a2317d 100644
--- a/applications/drive/src/app/utils/link.ts
+++ b/applications/drive/src/app/utils/link.ts
@@ -65,7 +65,7 @@ export const getSharedLink = (sharedURL?: { Token: string; Password: string; Fla

const [generatedPassword] = splitGeneratedAndCustomPassword(sharedURL.Password, sharedURL);

- const baseUrl = `${window.location.origin}/urls`;
+ const baseUrl = "https://drive.protonmail.com/urls";
return `${baseUrl}/${sharedURL.Token}${generatedPassword !== '' ? `#${generatedPassword}` : ''}`;
};

const [password, setPassword] = useState(customPassword);
const [expiration, setExpiration] = useState(initialExpiration);
8 changes: 7 additions & 1 deletion scripts/electron-builder/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,14 @@ export async function build(
await execShell([
"npm",
[
"run", `electron-builder:dist:linux:${packageType}:do`,
...`run electron-builder:shortcut -- --x64 --publish never --linux ${packageType}`.split(" "),
],
{
env: {
// see https://github.com/develar/app-builder/blob/e229f413d635b78a59b0d4ef1a9aa0f3967c0fd4/pkg/node-modules/rebuild.go#L377
npm_config_user_agent: (process.env.npm_config_user_agent ?? "").replace(/yarn/i, ""),
},
},
]);

// TODO move "fastGlob" to lib function with inner "sanitizeFastGlobPattern" call
Expand Down
18 changes: 17 additions & 1 deletion scripts/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ export async function execShell(
printStdErr = true,
printEnvWhitelist = [],
doNotRethrow = false,
doNotDropNodeOptionsRelatedEnvVars = false,
}: {
printStdOut?: boolean;
printStdErr?: boolean;
printEnvWhitelist?: readonly string[];
doNotRethrow?: boolean
doNotDropNodeOptionsRelatedEnvVars?: boolean
} = {},
): Promise<Unpacked<ReturnType<typeof spawnAsync>>> {
{
Expand All @@ -92,7 +94,21 @@ export async function execShell(
);
}

const spawnPromise = spawnAsync(command, args, options);
const spawnPromise = spawnAsync(
command,
args,
{
...options,
env: {
...process.env,
...options?.env,
...(!doNotDropNodeOptionsRelatedEnvVars && { // disable node options inheritance form the parent/own process
NODE_OPTIONS: "",
npm_config_node_options: "",
}),
},
},
);
const {stdout, stderr} = spawnPromise.child;
const print = (std: import("stream").Readable): void => {
byline(std).on("data", (chunk) => {
Expand Down
7 changes: 1 addition & 6 deletions scripts/prepare-webclient/webclients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ async function executeBuildFlow(
}
}

// TODO drop "yarn install" hacks when executing on CI env
if (process.env.CI) {
if (process.env.CI) { // TODO drop "yarn install" hacks when executing on CI env
// hacks applied to avoid the following error:
// eslint-disable-next-line max-len
// YN0018: │ sieve.js@https://github.com/ProtonMail/sieve.js.git#commit=a09ab52092164af74278e77612a091e730e9b7e9: The remote archive doesn't match the expected checksum
Expand All @@ -268,10 +267,6 @@ async function executeBuildFlow(
cwd: repoDir,
env: {
...process.env,
...{ // disable node options inheritance form the parent/own process
NODE_OPTIONS: "",
npm_config_node_options: "",
},
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "1",
YARN_CHECKSUM_BEHAVIOR: "update",
YARN_ENABLE_IMMUTABLE_INSTALLS: "false",
Expand Down
6 changes: 3 additions & 3 deletions src/shared/proton-apps-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const PROVIDER_REPO_MAP = {
[PROVIDER_APP_NAMES[0]]: {
repoRelativeDistDir: "./dist",
baseDirName: "",
tag: "[email protected].1",
tag: "[email protected].2",
protonPack: {
appConfig: {clientId: "WebMail"},
webpackIndexEntryItems: [
Expand Down Expand Up @@ -48,7 +48,7 @@ export const PROVIDER_REPO_MAP = {
[PROVIDER_APP_NAMES[1]]: {
repoRelativeDistDir: "./dist",
baseDirName: "account",
tag: "proton-account@4.12.8",
tag: "proton-account@4.13.0",
protonPack: {appConfig: {clientId: "WebAccount"}}
},
[PROVIDER_APP_NAMES[2]]: {
Expand All @@ -67,7 +67,7 @@ export const PROVIDER_REPO_MAP = {
[PROVIDER_APP_NAMES[3]]: {
repoRelativeDistDir: "./dist",
baseDirName: "drive",
tag: "proton-drive@4.6.1",
tag: "proton-drive@4.7.1",
protonPack: {appConfig: {clientId: "WebDrive"}},
},
} as const;
Expand Down

0 comments on commit 7170eaa

Please sign in to comment.