Skip to content

Commit

Permalink
fix @ProtonMail captcha endpoint/iframe URL resolving logic, #443
Browse files Browse the repository at this point in the history
All the available API entry points are https-based, so it's ok if we just hardcode the "https" scheme in the patches. The @ProtonMail  captcha endpoint at the moment is only available for the https://mail.protonmail.com API entry point only though see #419.

List of the available API entry points:
  - https://mail.protonmail.com
  - https://app.protonmail.ch
  - https://protonmailrmez3lotccipshtkleegetolb73fuirgj7r4o4vfu7ozyd.onion
  • Loading branch information
vladimiry committed Sep 27, 2021
1 parent a154bb6 commit e8b9828
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "electron-mail",
"description": "Unofficial ProtonMail Desktop App",
"version": "4.12.8",
"version": "4.12.9",
"author": "Vladimir Yakovlev <desktop-app@protonmail.ch>",
"license": "GPL-3.0",
"homepage": "https://github.com/vladimiry/ElectronMail",
Expand Down
15 changes: 15 additions & 0 deletions patches/protonmail/common-except-mail.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/packages/components/containers/api/humanVerification/Captcha.tsx b/packages/components/containers/api/humanVerification/Captcha.tsx
index 1192f7a32..44a5bcf04 100644
--- a/packages/components/containers/api/humanVerification/Captcha.tsx
+++ b/packages/components/containers/api/humanVerification/Captcha.tsx
@@ -7,6 +7,10 @@ const getIframeUrl = (apiUrl: string, token: string) => {
url.hostname = getRelativeApiHostname(url.hostname);
url.pathname = '/core/v4/captcha';
url.searchParams.set('Token', token);
+ // not really necessary for "apiUrl"-based logic
+ // but it's better to patch it still so we get the patching error when the account/drive/calendar tags adopt the following change:
+ // https://github.com/ProtonMail/WebClients/commit/fc43e8ddd0b79212119ebc05f053e6561c5e166f#diff-2debfe7bb7d7c2f9d2bba32af4e155d0885b324582ee8861e0d4bfe11985ebae commit
+ url.protocol = "https:";
return url;
};

7 changes: 5 additions & 2 deletions patches/protonmail/meta.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"proton-account": [
"common.patch",
"common-except-mail.patch",
"proton-account.patch"
],
"proton-calendar": [
"common.patch",
"common-except-mail-account.patch"
"common-except-mail-account.patch",
"common-except-mail.patch"
],
"proton-drive": [
"common.patch",
"proton-drive.patch",
"common-except-mail-account.patch"
"common-except-mail-account.patch",
"common-except-mail.patch"
],
"proton-mail": [
"common.patch",
Expand Down
12 changes: 12 additions & 0 deletions patches/protonmail/proton-mail.patch
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ index daece3840..557ceba0d 100644
export const API_VERSION = '3';
export const VERSION_PATH = '${appData.publicPath}assets/version.json';

diff --git a/packages/components/containers/api/humanVerification/Captcha.tsx b/packages/components/containers/api/humanVerification/Captcha.tsx
index e1c46dce5..fe184d5e7 100644
--- a/packages/components/containers/api/humanVerification/Captcha.tsx
+++ b/packages/components/containers/api/humanVerification/Captcha.tsx
@@ -4,6 +4,7 @@ import { getApiSubdomainUrl } from '@proton/shared/lib/helpers/url';
const getIframeUrl = (token: string) => {
const url = getApiSubdomainUrl('/core/v4/captcha');
url.searchParams.set('Token', token);
+ url.protocol = "https:";
return url;
};

diff --git a/packages/components/containers/login/MinimalLoginContainer.tsx b/packages/components/containers/login/MinimalLoginContainer.tsx
index 6fef05c..1719cc8 100644
--- a/packages/components/containers/login/MinimalLoginContainer.tsx
Expand Down

0 comments on commit e8b9828

Please sign in to comment.