Repository: manusa/electronim (js)

Issue:
Can't login to Office365/Teams
Trying to add https://teams.microsoft.com/ tab.
ElectronIM shows 'Checking your credentials...' in tab header, at the same time authentication page is opened in external browser. After login messenger is displayed in external browser too..

It think it's done such way to open random URL's in browser. But I think that some 'whitelist' or temporary disable of such behavior is needed. 

Pull request description:
Add support for Skype, MS Teams and Webex Teams
Just added a few IM accounts I know (fixes #42)
All of them seems to be working (if no third-party 2FA configured).

Patch:
diff --git a/src/tab-manager/redirect.js b/src/tab-manager/redirect.js
index 48872b0..46e045c 100644
--- a/src/tab-manager/redirect.js
+++ b/src/tab-manager/redirect.js
@@ -24,7 +24,13 @@ const isOAuth = matchUrls([
   /^https:\/\/.+\.google\.com\/signin\/oauth.*/, // NOSONAR
   /^https:\/\/accounts\.google\.com\/.*/, // NOSONAR
   /^https:\/\/(.+\.)?github\.com\/login\/oauth.*/, // NOSONAR
-  /^https:\/\/auth\.redhat\.com\/auth\/.*/ // NOSONAR
+  /^https:\/\/auth\.redhat\.com\/auth\/.*/, // NOSONAR
+  /^https:\/\/account\.live\.com\/.*/, // NOSONAR
+  /^https:\/\/login\.live\.com\/.*/, // NOSONAR
+  /^https:\/\/login\.microsoftonline\.com\/.*/, // NOSONAR
+  /^https:\/\/.+\.skype\.com\/login\/.*/, // NOSONAR
+  /^https:\/\/.+\.skype\.com\/Auth\/.*/, // NOSONAR
+  /^https:\/\/idbroker\.webex\.com\/idb\/oauth2\/.*/ // NOSONAR
 ]);
 
 const isSameOrigin = (browserViewUrl, url) => url.origin === browserViewUrl.origin;


Test patch:
diff --git a/src/tab-manager/__tests__/redirect.test.js b/src/tab-manager/__tests__/redirect.test.js
index 663b361..d5d7de5 100644
--- a/src/tab-manager/__tests__/redirect.test.js
+++ b/src/tab-manager/__tests__/redirect.test.js
@@ -82,5 +82,45 @@ describe('Tab Manager Redirect module test suite', () => {
         expect(result).toBe(false);
       });
     });
+    describe('Skype OAuth', () => {
+      test('From Skype to OAuth, should return false', () => {
+        // Given
+        mockBrowserViewUrl = 'https://web.skype.com';
+        // When
+        const result = redirect.shouldOpenInExternalBrowser(mockBrowserView,
+          new URL('https://login.skype.com/login/oauth/microsoft?client_id=313373'));
+        // Then
+        expect(result).toBe(false);
+      });
+      test('From Skype OAuth to Microsoft, should return false', () => {
+        // Given
+        mockBrowserViewUrl = 'https://web.skype.com';
+        // When
+        const result = redirect.shouldOpenInExternalBrowser(mockBrowserView,
+          new URL('https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=13&ct=1610780563'));
+        // Then
+        expect(result).toBe(false);
+      });
+    });
+    describe('Teams OAuth', () => {
+      test('From Teams to Microsoft Online, should return false', () => {
+        // Given
+        mockBrowserViewUrl = 'https://teams.microsoft.com';
+        // When
+        const result = redirect.shouldOpenInExternalBrowser(mockBrowserView,
+          new URL('https://login.microsoftonline.com/common/oauth2/authorize?response_type=id_token'));
+        // Then
+        expect(result).toBe(false);
+      });
+      test('From Teams to Microsoft Login, should return false', () => {
+        // Given
+        mockBrowserViewUrl = 'https://teams.microsoft.com';
+        // When
+        const result = redirect.shouldOpenInExternalBrowser(mockBrowserView,
+          new URL('https://login.live.com/Me.htm?v=3'));
+        // Then
+        expect(result).toBe(false);
+      });
+    });
   });
 });