From de43286279877ced4ada253f0111d8633ffb2a24 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Tue, 10 Jun 2025 16:33:26 +0200 Subject: [PATCH 1/2] adapt to upstream --- apps/passwords/js/Static/compatibility.js | 67 ++++++++++++++--------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/apps/passwords/js/Static/compatibility.js b/apps/passwords/js/Static/compatibility.js index c7970f56..d8074227 100644 --- a/apps/passwords/js/Static/compatibility.js +++ b/apps/passwords/js/Static/compatibility.js @@ -1,52 +1,60 @@ -function isCompatibleBrowser() { +function checkBrowserSupport() { try { if(!window.hasOwnProperty('crypto') || typeof window.crypto.subtle !== "object") { - console.error('Web Crypto API not supported'); - return false; + return 'crypto'; } if(!window.hasOwnProperty('TextEncoder')) { - console.error('TextEncoder not supported'); - return false; + return 'TextEncoder'; } if(!window.hasOwnProperty('WebAssembly') || typeof window.WebAssembly.instantiate !== "function") { - console.error('WebAssembly not supported'); - return false; + return 'WebAssembly'; } } catch(e) { console.error(e); - return false; + return 'ECMAScript 2017 / ES2017'; } return true; } -function showBrowserCompatibilityWarning() { +function showBrowserCompatibilityWarning(reason) { + var tl = function(t) {return OC.L10N.translate('passwords', t);}, + imgpath = OC.filePath('passwords', 'img', 'browser/'), + container = document.getElementById('main'), + title = tl('CompatHeadline'), + message = tl('CompatText1') + '
' + tl('CompatText2'); + + if(reason === 'WebAssembly') { + var handbookLink = null, + settings = OCP.InitialState.loadState('passwords', 'settings'); + + if(settings && settings['server.handbook.url']) { + handbookLink = settings['server.handbook.url.web'] + 'Enable-WebAssembly'; + } + + title = tl('CompatWASMHeadline'); + message = tl('CompatWASMText1') + + '
' + tl('CompatWASMText2') + '
' + + (handbookLink ? '':'') + + tl('CompatWASMHandbookLink') + + (handbookLink ? '':'') + + '

' + tl('CompatWASMText3'); + } - var imgpath = OC.filePath('passwords', 'img', 'browser/'), - container = document.getElementById('main'); container.innerHTML = - '
' + - '

'+t('passwords', 'Your Browser is outdated')+'

' + - '
'+t('passwords', 'Your browser is outdated and does not provide the necessary functionality to display this page.') + - '
'+t('passwords', 'Please check if an update is available for your browser or choose a modern and compatible browser from the list below.') + - '
' + + '

' + title + '

' + message + '
' + 'Firefox' + 'Vivaldi' + + 'Brave' + 'Tor Browser' + '
'; container.setAttribute('class', ''); - throw new Error('Browser does not suport ECMAScript 2017 / ES2017'); -} - -function isWebAssemblyEnable(){ - if(!window.hasOwnProperty('WebAssembly') || typeof window.WebAssembly.instantiate !== "function") { - console.error('WebAssembly not supported'); - return false; - } + console.error('Browser does not support ' + reason); + throw new Error('Browser does not support ' + reason); } function showWebAssemblyCompatibilityWarning() { @@ -65,9 +73,14 @@ function showWebAssemblyCompatibilityWarning() { throw new Error('Browser does not suport WebAssembly'); } + + function checkSystem() { - // if(!isWebAssemblyEnable()) showWebAssemblyCompatibilityWarning(); - if(!isCompatibleBrowser()) showBrowserCompatibilityWarning(); + var reason = checkBrowserSupport(); + if(reason !== true){ + if(reason == "") showWebAssemblyCompatibilityWarning(); + else showBrowserCompatibilityWarning(reason); + } } -window.addEventListener('DOMContentLoaded', checkSystem, false); +window.addEventListener('DOMContentLoaded', checkSystem, false); \ No newline at end of file -- GitLab From 16ab3d440f9e05a8b2228f51900c2fff44242355 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Tue, 10 Jun 2025 16:35:11 +0200 Subject: [PATCH 2/2] fix reason --- apps/passwords/js/Static/compatibility.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/passwords/js/Static/compatibility.js b/apps/passwords/js/Static/compatibility.js index d8074227..34f6f315 100644 --- a/apps/passwords/js/Static/compatibility.js +++ b/apps/passwords/js/Static/compatibility.js @@ -78,7 +78,7 @@ function showWebAssemblyCompatibilityWarning() { function checkSystem() { var reason = checkBrowserSupport(); if(reason !== true){ - if(reason == "") showWebAssemblyCompatibilityWarning(); + if(reason === "WebAssembly") showWebAssemblyCompatibilityWarning(); else showBrowserCompatibilityWarning(reason); } } -- GitLab