From aa3013c3c7773d1402f13e6eac8c98bdc82e3909 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Tue, 26 Nov 2024 13:02:52 +0100 Subject: [PATCH 1/2] qt: fix cam access by restoring window.isSecureContext In d78380f45, we switched from qrc:/ to the bitboxapp:/ custom scheme so we can force mimetypes in the scheme handler. This somehow made window.isSecureContext be false, breaking camera (which requires a secure context). The issue was that our scheme handler was never registered, because it was configued with HostAndPort but no default port was specified. We could specify one, or switch to Host only, but in our case Path seems to be most appropriate. The frontend navigation is changed from browser router to hash based router, as somehow navigation breaks in the custom scheme, as the frontend tries to actually request the individual pages from QtWebEngine. Not sure why it was working before or what causes it, but a local hash based router seems to work. --- frontends/qt/main.cpp | 13 +++++-------- frontends/web/src/app.tsx | 4 ++-- frontends/web/src/index.tsx | 6 +++--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/frontends/qt/main.cpp b/frontends/qt/main.cpp index 3c28524338..2b7175b455 100644 --- a/frontends/qt/main.cpp +++ b/frontends/qt/main.cpp @@ -184,8 +184,8 @@ class RequestInterceptor : public QWebEngineUrlRequestInterceptor { // We treat the exchange pages specially because we need to allow exchange // widgets to load in an iframe as well as let them open external links // in a browser. - bool onExchangePage = currentUrl.contains(QRegularExpression(QString("^%1:/exchange/.*$").arg(scheme))); - bool onBitsurancePage = currentUrl.contains(QRegularExpression(QString("^%1:/bitsurance/.*$").arg(scheme))); + bool onExchangePage = currentUrl.contains(QRegularExpression(QString("^%1:/index\.html\#/exchange/.*$").arg(scheme))); + bool onBitsurancePage = currentUrl.contains(QRegularExpression(QString("^%1:/index\.html\#/bitsurance/.*$").arg(scheme))); if (onExchangePage || onBitsurancePage) { if (info.firstPartyUrl().toString() == info.requestUrl().toString()) { // Ignore requests for certain file types (e.g., .js, .css) Somehow Moonpay loads @@ -208,7 +208,7 @@ class RequestInterceptor : public QWebEngineUrlRequestInterceptor { // All the requests originated in the wallet-connect section are allowed, as they are needed to // load the Dapp logos and it is not easy to filter out non-images requests. - bool onWCPage = currentUrl.contains(QRegularExpression(QString(R"(^%1:/account/[^\/]+/wallet-connect/.*$)").arg(scheme))); + bool onWCPage = currentUrl.contains(QRegularExpression(QString(R"(^%1:/index\.html\#/account/[^\/]+/wallet-connect/.*$)").arg(scheme))); if (onWCPage) { return; } @@ -339,11 +339,8 @@ int main(int argc, char *argv[]) } QWebEngineUrlScheme bbappScheme(scheme); - bbappScheme.setSyntax(QWebEngineUrlScheme::Syntax::HostAndPort); - bbappScheme.setFlags( - QWebEngineUrlScheme::LocalScheme | - QWebEngineUrlScheme::SecureScheme | - QWebEngineUrlScheme::LocalAccessAllowed); + bbappScheme.setSyntax(QWebEngineUrlScheme::Syntax::Path); + bbappScheme.setFlags(QWebEngineUrlScheme::SecureScheme); QWebEngineUrlScheme::registerScheme(bbappScheme); view = new WebEngineView(); diff --git a/frontends/web/src/app.tsx b/frontends/web/src/app.tsx index 918e3f83b8..9f58c7d401 100644 --- a/frontends/web/src/app.tsx +++ b/frontends/web/src/app.tsx @@ -63,8 +63,8 @@ export const App = () => { }, [t]); const maybeRoute = useCallback(() => { - const currentURL = window.location.pathname; - const isIndex = currentURL === '/' || currentURL === '/index.html' || currentURL === '/android_asset/web/index.html' || currentURL.endsWith('/assets/web/index.html'); + const currentURL = window.location.hash.replace(/^#/, ''); + const isIndex = currentURL === '' || currentURL === '/'; const inAccounts = currentURL.startsWith('/account/'); // QT and Android start their apps in '/index.html' and '/android_asset/web/index.html' respectively diff --git a/frontends/web/src/index.tsx b/frontends/web/src/index.tsx index 97c969a99b..b4c16163b7 100644 --- a/frontends/web/src/index.tsx +++ b/frontends/web/src/index.tsx @@ -18,7 +18,7 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; import { I18nextProvider } from 'react-i18next'; -import { BrowserRouter } from 'react-router-dom'; +import { HashRouter } from 'react-router-dom'; import { App } from './app'; import { i18n } from './i18n/i18n'; import './style/index.css'; @@ -30,9 +30,9 @@ root.render( - + - + From f3f3d12a200186872e159d50dbdfe8c33275c56b Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Tue, 26 Nov 2024 13:39:21 +0100 Subject: [PATCH 2/2] backend: update to version 4.46.3 --- CHANGELOG.md | 3 +++ backend/update.go | 2 +- frontends/android/BitBoxApp/app/build.gradle | 4 ++-- frontends/ios/BitBoxApp/Config.xcconfig | 4 ++-- frontends/qt/Makefile | 4 ++-- frontends/qt/resources/MacOS/Info.plist | 4 ++-- frontends/qt/setup.nsi | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0004fc4ec8..cfafae41b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +# 4.46.3 +- Fix camera access on linux + # 4.46.2 - Fix Linux blank screen issue related to the local mimetype database diff --git a/backend/update.go b/backend/update.go index 7fc260d92e..32c716500a 100644 --- a/backend/update.go +++ b/backend/update.go @@ -27,7 +27,7 @@ const updateFileURL = "https://bitboxapp.shiftcrypto.io/desktop.json" var ( // Version of the backend as displayed to the user. - Version = semver.NewSemVer(4, 46, 2) + Version = semver.NewSemVer(4, 46, 3) ) // UpdateFile is retrieved from the server. diff --git a/frontends/android/BitBoxApp/app/build.gradle b/frontends/android/BitBoxApp/app/build.gradle index c11b8a7a2c..30d0996e26 100644 --- a/frontends/android/BitBoxApp/app/build.gradle +++ b/frontends/android/BitBoxApp/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "ch.shiftcrypto.bitboxapp" minSdkVersion 21 targetSdkVersion 34 - versionCode 57 - versionName "android-4.46.2" + versionCode 58 + versionName "android-4.46.3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/frontends/ios/BitBoxApp/Config.xcconfig b/frontends/ios/BitBoxApp/Config.xcconfig index 434ce8d08f..9fcf6ac523 100644 --- a/frontends/ios/BitBoxApp/Config.xcconfig +++ b/frontends/ios/BitBoxApp/Config.xcconfig @@ -2,8 +2,8 @@ // https://help.apple.com/xcode/#/dev745c5c974 // App version -MARKETING_VERSION = 4.46.2 +MARKETING_VERSION = 4.46.3 // Build number, increment this for every separate publication, // even if the app version is the same. -CURRENT_PROJECT_VERSION = 5 +CURRENT_PROJECT_VERSION = 6 diff --git a/frontends/qt/Makefile b/frontends/qt/Makefile index 9f41243562..12585f2c8f 100644 --- a/frontends/qt/Makefile +++ b/frontends/qt/Makefile @@ -37,8 +37,8 @@ linux: cp resources/linux/usr/share/icons/hicolor/128x128/apps/bitbox.png build/linux-tmp mkdir build/tmp-deb/opt/ cp -aR build/linux-tmp build/tmp-deb/opt/bitbox - cd build/linux && fpm --after-install ../../resources/deb-afterinstall.sh -s dir -t deb -n bitbox -v 4.46.2 -C ../tmp-deb/ - cd build/linux && fpm --after-install ../../resources/deb-afterinstall.sh -s dir -t rpm -n bitbox -v 4.46.2 -C ../tmp-deb/ + cd build/linux && fpm --after-install ../../resources/deb-afterinstall.sh -s dir -t deb -n bitbox -v 4.46.3 -C ../tmp-deb/ + cd build/linux && fpm --after-install ../../resources/deb-afterinstall.sh -s dir -t rpm -n bitbox -v 4.46.3 -C ../tmp-deb/ # create AppImage cd build/linux-tmp && /opt/linuxdeployqt-continuous-x86_64.AppImage BitBox -appimage -unsupported-allow-new-glibc mv build/linux-tmp/BitBoxApp-*-x86_64.AppImage build/linux/ diff --git a/frontends/qt/resources/MacOS/Info.plist b/frontends/qt/resources/MacOS/Info.plist index 10f0476ec4..7da7fabfb5 100644 --- a/frontends/qt/resources/MacOS/Info.plist +++ b/frontends/qt/resources/MacOS/Info.plist @@ -21,10 +21,10 @@ APPL CFBundleVersion - 4.46.2 + 4.46.3 CFBundleShortVersionString - 4.46.2 + 4.46.3 CFBundleSignature ???? diff --git a/frontends/qt/setup.nsi b/frontends/qt/setup.nsi index 7b420b4d47..1ae1a1bf53 100755 --- a/frontends/qt/setup.nsi +++ b/frontends/qt/setup.nsi @@ -22,7 +22,7 @@ SetCompressor /SOLID lzma # General Symbol Definitions !define REGKEY "SOFTWARE\$(^Name)" -!define VERSION 4.46.2.0 +!define VERSION 4.46.3.0 !define COMPANY "Shift Crypto AG" !define URL https://github.com/BitBoxSwiss/bitbox-wallet-app/releases/ !define BINDIR "build\windows"