gologin 2.1.23 → 2.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/gologin.js +34 -3
- package/src/utils/http.js +5 -5
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/gologin.js
CHANGED
|
@@ -78,6 +78,8 @@ export class GoLogin {
|
|
|
78
78
|
this.restoreLastSession = options.restoreLastSession || true;
|
|
79
79
|
this.processSpawned = null;
|
|
80
80
|
this.processKillTimeout = 1 * 1000;
|
|
81
|
+
this.browserMajorVersion = 0;
|
|
82
|
+
this.newProxyOrbbitaMajorVersion = 135;
|
|
81
83
|
|
|
82
84
|
if (process.env.DISABLE_TELEMETRY !== 'true') {
|
|
83
85
|
Sentry.init({
|
|
@@ -220,6 +222,8 @@ export class GoLogin {
|
|
|
220
222
|
const [screenWidth, screenHeight] = resolution.split('x').map(Number);
|
|
221
223
|
const langHeader = (profileData.navigator && profileData.navigator.language) || '';
|
|
222
224
|
const splittedLangs = langHeader ? langHeader.split(',')[0] : 'en-US';
|
|
225
|
+
const [browserMajorVersion] = profileData.navigator.userAgent.split('Chrome/')[1].split('.');
|
|
226
|
+
this.browserMajorVersion = browserMajorVersion;
|
|
223
227
|
|
|
224
228
|
const startupUrl = (profileData.startUrl || '').trim().split(',')[0];
|
|
225
229
|
const startupUrls = (profileData.startUrl || '').split(',')
|
|
@@ -311,6 +315,27 @@ export class GoLogin {
|
|
|
311
315
|
},
|
|
312
316
|
};
|
|
313
317
|
|
|
318
|
+
console.log('profileData.proxy', profileData);
|
|
319
|
+
if (browserMajorVersion >= this.newProxyOrbbitaMajorVersion && profileData.proxy?.mode !== 'none') {
|
|
320
|
+
let proxyServer = `${profileData.proxy.mode}://`;
|
|
321
|
+
if (profileData.proxy.username) {
|
|
322
|
+
const encodedUsername = encodeURIComponent(profileData.proxy.username || '');
|
|
323
|
+
const encodedPassword = encodeURIComponent(profileData.proxy.password || '');
|
|
324
|
+
|
|
325
|
+
proxyServer += encodedPassword
|
|
326
|
+
? `${encodedUsername}:${encodedPassword}@`
|
|
327
|
+
: `${encodedUsername}@`;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
proxyServer += `${profileData.proxy.host}:${profileData.proxy.port}`;
|
|
331
|
+
preferences.proxy = {
|
|
332
|
+
...preferences.proxy,
|
|
333
|
+
mode: 'fixed_servers',
|
|
334
|
+
schema: profileData.proxy.mode,
|
|
335
|
+
server: proxyServer,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
314
339
|
return preferences;
|
|
315
340
|
}
|
|
316
341
|
|
|
@@ -599,9 +624,15 @@ export class GoLogin {
|
|
|
599
624
|
const checkAutoLangResult = checkAutoLang(gologin, this._tz);
|
|
600
625
|
this.browserLang = isMAC ? 'en-US' : checkAutoLangResult;
|
|
601
626
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
627
|
+
const prefsToWrite = Object.assign(preferences, { gologin });
|
|
628
|
+
if (this.browserMajorVersion >= this.newProxyOrbbitaMajorVersion && this.proxy?.mode !== 'none') {
|
|
629
|
+
prefsToWrite.proxy = {
|
|
630
|
+
mode: 'fixed_servers',
|
|
631
|
+
server: gologin.proxy.server,
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
await writeFile(join(profilePath, 'Default', 'Preferences'), JSON.stringify(prefsToWrite));
|
|
605
636
|
|
|
606
637
|
const bookmarksParsedData = await getCurrentProfileBookmarks(this.bookmarksFilePath);
|
|
607
638
|
const bookmarksFromDb = profile.bookmarks?.bookmark_bar;
|
package/src/utils/http.js
CHANGED
|
@@ -4,14 +4,14 @@ import requests from 'requestretry';
|
|
|
4
4
|
const TIMEZONE_URL = 'https://geo.myip.link';
|
|
5
5
|
|
|
6
6
|
const attemptRequest = async (requestUrl, options) => {
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
const error = new Error(body);
|
|
10
|
-
error.statusCode =
|
|
7
|
+
const req = await requests(requestUrl, options);
|
|
8
|
+
if (req.statusCode >= 400) {
|
|
9
|
+
const error = new Error(req.body);
|
|
10
|
+
error.statusCode = req.statusCode;
|
|
11
11
|
throw error;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
return body;
|
|
14
|
+
return req.body;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export const makeRequest = async (url, options, internalOptions) => {
|