diff --git a/app/browser/tools/reactHandler.js b/app/browser/tools/reactHandler.js index ea27a6f8..a9d69f53 100644 --- a/app/browser/tools/reactHandler.js +++ b/app/browser/tools/reactHandler.js @@ -21,4 +21,6 @@ class ReactHandler { } //document.getElementById('app')._reactRootContainer.current.updateQueue.baseState.element.props.coreServices -module.exports = new ReactHandler(); \ No newline at end of file +module.exports = new ReactHandler(); + +// document.getElementById('app')._reactRootContainer.current.updateQueue.baseState.element.props.coreServices.authenticationService._coreAuthService._authProvider.acquireToken("https://graph.microsoft.com", { correlation: document.getElementById('app')._reactRootContainer.current.updateQueue.baseState.element.props.coreServices.correlation} ) diff --git a/app/config/index.js b/app/config/index.js index 1899b97b..9c165ff9 100644 --- a/app/config/index.js +++ b/app/config/index.js @@ -213,6 +213,11 @@ function extractYargConfig(configObject, appVersion) { default: false, describe: 'Use windows platform information in chromium. This is helpful if MFA app does not support Linux.' }, + enableBackgroundCallsAuthentication: { + default: true, + describe: 'Enable background calls for authentication to open in a child browser window (temporary solution for debugging)', + type: 'boolean' + }, followSystemTheme: { default: false, describe: 'Follow system theme', @@ -242,7 +247,7 @@ function extractYargConfig(configObject, appVersion) { default: { "transports": { "console": { - "level": "info" + "level": "debug" }, "file": { "level": false diff --git a/app/connectionManager/index.js b/app/connectionManager/index.js index 77e293f6..7528cc5e 100644 --- a/app/connectionManager/index.js +++ b/app/connectionManager/index.js @@ -28,15 +28,21 @@ class ConnectionManager { } async refresh() { - const currentUrl = this.window.webContents.getURL(); + if (!this.window) { + console.warn('Window is not available. Cannot refresh.'); + return; + } + const currentUrl = this.window?.webContents?.getURL() || ''; const hasUrl = currentUrl?.startsWith('https://'); - this.window.setTitle('Waiting for network...'); + this.window?.setTitle('Waiting for network...'); console.debug('Waiting for network...'); const connected = await this.isOnline(); if (connected) { if (hasUrl) { + console.debug('Reloading current page...'); this.window.reload(); } else { + console.debug('Loading initial URL...'); this.window.loadURL(this.currentUrl, { userAgent: this.config.chromeUserAgent }); } } else { diff --git a/app/mainAppWindow/index.js b/app/mainAppWindow/index.js index a9abaded..024890f5 100644 --- a/app/mainAppWindow/index.js +++ b/app/mainAppWindow/index.js @@ -1,5 +1,4 @@ -const { shell, app, nativeTheme, dialog, webFrameMain, Notification } = require('electron'); -const path = require('path'); +const { shell, BrowserWindow, app, nativeTheme, dialog, webFrameMain } = require('electron'); const login = require('../login'); const customCSS = require('../customCSS'); const Menus = require('../menus'); @@ -8,13 +7,11 @@ const { execFile } = require('child_process'); const TrayIconChooser = require('../browser/tools/trayIconChooser'); require('../appConfiguration'); const connMgr = require('../connectionManager'); -const fs = require('fs'); const BrowserWindowManager = require('../mainAppWindow/browserWindowManager'); let iconChooser; let intune; let isControlPressed = false; -let lastNotifyTime = null; let aboutBlankRequestCount = 0; let config; let window = null; @@ -237,10 +234,17 @@ function onBeforeRequestHandler(details, callback) { // Proceed normally callback({}); } else { - // Open the request externally console.debug('DEBUG - webRequest to ' + details.url + ' intercepted!'); - //shell.openExternal(details.url); - writeUrlBlockLog(details.url); + if (this.config.enableBackgroundCallsAuthentication) { + console.debug('Opening the request in a hidden child window for authentication'); + const child = new BrowserWindow({ parent: window, show: false }); + child.loadURL(details.url); + child.once('ready-to-show', () => { + console.debug('Destroying the hidden child window'); + child.destroy(); + }) + } + // decrement the counter aboutBlankRequestCount -= 1; callback({ cancel: true }); @@ -281,28 +285,6 @@ function onNewWindow(details) { return secureOpenLink(details); } -async function writeUrlBlockLog(url) { - const curBlockTime = new Date(); - const logfile = path.join(appConfig.configPath, 'teams-for-linux-blocked.log'); - const lstream = fs.createWriteStream(logfile, { flags: 'a' }).on('error', onLogStreamError); - lstream.write(`[${new Date().toLocaleString()}]: Blocked '${url}'\n`, onLogStreamError); - lstream.end(); - const notifDuration = lastNotifyTime == null ? 60 : (curBlockTime.getTime() - lastNotifyTime.getTime()) / 1000; - if (notifDuration >= 60) { - new Notification({ - title: 'Teams for Linux', - body: 'One or more web requests have been blocked. Please check the log for more details.' - }).show(); - lastNotifyTime = curBlockTime; - } -} - -function onLogStreamError(e) { - if (e) { - console.error(`onLogStreamError ${e.message}`); - } -} - function onPageTitleUpdated(_event, title) { window.webContents.send('page-title', title); } diff --git a/app/menus/tray.js b/app/menus/tray.js index e393b700..96d8c855 100644 --- a/app/menus/tray.js +++ b/app/menus/tray.js @@ -6,10 +6,7 @@ class ApplicationTray { this.iconPath = iconPath; this.appMenu = appMenu; this.config = config; - this.addTray(); - } - addTray() { this.tray = new Tray(this.iconPath); this.tray.setToolTip(this.config.appTitle); this.tray.on('click', () => this.showAndFocusWindow()); @@ -28,14 +25,18 @@ class ApplicationTray { } updateTrayImage(iconUrl, flash) { - const image = nativeImage.createFromDataURL(iconUrl); + if (this.tray && !this.tray.isDestroyed()) { + const image = nativeImage.createFromDataURL(iconUrl); - this.tray.setImage(image); - this.window.flashFrame(flash); + this.tray.setImage(image); + this.window.flashFrame(flash); + } } close() { - this.tray.destroy(); + if (!this.tray.isDestroyed()) { + this.tray.destroy() + } } } exports = module.exports = ApplicationTray; diff --git a/com.github.IsmaelMartinez.teams_for_linux.appdata.xml b/com.github.IsmaelMartinez.teams_for_linux.appdata.xml index 1f9a04a4..29663549 100644 --- a/com.github.IsmaelMartinez.teams_for_linux.appdata.xml +++ b/com.github.IsmaelMartinez.teams_for_linux.appdata.xml @@ -14,6 +14,16 @@ https://github.com/IsmaelMartinez/teams-for-linux/issues com.github.IsmaelMartinez.teams_for_linux.desktop + + +
    +
  • Adding enableBackgroundCallsAuthentication config option to validate if this keeps the user authenticated for longer
  • +
  • Removing the writeUrlBlockLog function that use to log those requests into a file for debugging
  • +
  • Handling of UnhandledPromiseRejectionWarning: TypeError: Cannot read properties of undefined (reading 'webContents') at PowerMonitor.refresh (.../app/connectionManager/index.js:31:34)
  • +
  • Checking the tray status before trying to update the badge count
  • +
+
+
    diff --git a/package-lock.json b/package-lock.json index 2189f4ac..d9a2c1a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "teams-for-linux", - "version": "1.12.6", + "version": "1.12.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "teams-for-linux", - "version": "1.12.6", + "version": "1.12.7", "hasInstallScript": true, "license": "GPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index 7f879028..54999493 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "teams-for-linux", - "version": "1.12.6", + "version": "1.12.7", "main": "app/index.js", "description": "Unofficial client for Microsoft Teams for Linux", "homepage": "https://github.com/IsmaelMartinez/teams-for-linux",