Repository: manusa/electronim (js)

Issue:
Impossible to retrieve latest Chrome version -omahaproxy.appspot.com decommissioned-
## Description

It's impossible to retrieve the latest Chrome version since omahaproxy has been decommissioned.

https://groups.google.com/a/chromium.org/g/chromium-dev/c/uH-nFrOLWtE

This is visible at startup when ElectronIM complains with `ElectronIM: No network available`

The recommended alternative is:
```
https://versionhistory.googleapis.com/v1/chrome/platforms/all/channels/all/versions/all/releases?filter=endtime>2024-01-01T00:00:00Z
```

However, this is a very slow endpoint.

Another viable solution seems to be:

```
https://versionhistory.googleapis.com/v1/chrome/platforms/linux/channels/stable/versions/all/releases?filter=endtime=none
```

Which is what powers https://chromiumdash.appspot.com/releases?platform=Linux

Pull request description:
🐛 latest Chrome release retrieved from versionhistory.googleapis.com
Fix #367 

Patch:
diff --git a/src/user-agent/index.js b/src/user-agent/index.js
index cf1f8f5..846ddaa 100644
--- a/src/user-agent/index.js
+++ b/src/user-agent/index.js
@@ -14,7 +14,7 @@
    limitations under the License.
  */
 const axios = require('axios');
-const CHROMIUM_VERSIONS = 'https://omahaproxy.appspot.com/all.json';
+const CHROMIUM_VERSIONS = `https://versionhistory.googleapis.com/v1/chrome/platforms/linux/channels/stable/versions/all/releases?filter=endtime>${new Date().toISOString()}`;
 const FIREFOX_VERSIONS = 'https://product-details.mozilla.org/1.0/firefox_versions.json';
 
 const BROWSER_VERSIONS = {
@@ -28,12 +28,10 @@ const USER_AGENT_INTERCEPTOR_FILTER = {
 };
 
 const latestChromium = async () => {
-  const {data: tags} = await axios.get(CHROMIUM_VERSIONS);
-  const stableVersion = tags
-    .filter(version => version.os === 'linux')
-    .flatMap(version => version.versions)
-    .filter(version => version.channel === 'stable');
-  return stableVersion && stableVersion.length > 0 ? stableVersion[0].version : null;
+  const {data} = await axios.get(CHROMIUM_VERSIONS);
+  const stableVersion = data.releases
+    .flatMap(release => release.version);
+  return stableVersion && stableVersion.length > 0 ? stableVersion[0] : null;
 };
 
 const latestFirefox = async () => {


Test patch:
diff --git a/src/user-agent/__tests__/index.test.js b/src/user-agent/__tests__/index.test.js
index 9e355aa..d1eb440 100644
--- a/src/user-agent/__tests__/index.test.js
+++ b/src/user-agent/__tests__/index.test.js
@@ -25,10 +25,12 @@ describe('User Agent module test suite', () => {
   describe('initBrowserVersions', () => {
     test('valid responses, should return a valid version for all browsers,', async () => {
       // Given
-      axios.get.mockImplementationOnce(async () => ({data: [
-        {os: 'linux', versions: [{channel: 'other', version: '5uck5'}, {channel: 'stable', version: '1337'}]},
-        {os: 'win'}
-      ]}));
+      axios.get.mockImplementationOnce(async () => ({data: {
+        releases: [
+          {name: 'chrome/platforms/linux/channels/stable/versions/1337/releases/1704308709', version: '1337'},
+          {name: 'chrome/platforms/linux/channels/stable/versions/1336/releases/1704308708', version: '1336'}
+        ]
+      }}));
       axios.get.mockImplementation(async () => ({data: {
         FIREFOX_DEVEDITION: '313373',
         LATEST_FIREFOX_VERSION: 'ff.1337',
@@ -43,9 +45,11 @@ describe('User Agent module test suite', () => {
     });
     test('invalidResponse, should return null,', async () => {
       // Given
-      axios.get.mockImplementation(async () => ({data: [
-        {os: 'win'}, 'not Valid'
-      ]}));
+      axios.get.mockImplementation(async () => ({data: {
+        releases: [
+          {os: 'win'}, 'not Valid'
+        ]
+      }}));
       // When
       await userAgent.initBrowserVersions();
       // Then