gologin 2.1.29 → 2.1.30
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/package.json +1 -1
- package/src/gologin.js +27 -11
- package/src/utils/browser.js +61 -3
- package/src/utils/common.js +5 -3
package/package.json
CHANGED
package/src/gologin.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from './cookies/cookies-manager.js';
|
|
28
28
|
import ExtensionsManager from './extensions/extensions-manager.js';
|
|
29
29
|
import { archiveProfile } from './profile/profile-archiver.js';
|
|
30
|
-
import { checkAutoLang } from './utils/browser.js';
|
|
30
|
+
import { checkAutoLang, getIntlProfileConfig } from './utils/browser.js';
|
|
31
31
|
import { API_URL, ensureDirectoryExists, FALLBACK_API_URL, getOsAdvanced } from './utils/common.js';
|
|
32
32
|
import { STORAGE_GATEWAY_BASE_URL } from './utils/constants.js';
|
|
33
33
|
import { get, isPortReachable } from './utils/utils.js';
|
|
@@ -82,6 +82,7 @@ export class GoLogin {
|
|
|
82
82
|
this.newProxyOrbbitaMajorVersion = 135;
|
|
83
83
|
this.proxyCheckTimeout = options.proxyCheckTimeout || 13 * 1000;
|
|
84
84
|
this.proxyCheckAttempts = options.proxyCheckAttempts || 3;
|
|
85
|
+
this.browserLatestMajorVersion = 137;
|
|
85
86
|
|
|
86
87
|
if (process.env.DISABLE_TELEMETRY !== 'true') {
|
|
87
88
|
Sentry.init({
|
|
@@ -120,9 +121,7 @@ export class GoLogin {
|
|
|
120
121
|
if (!(Array.isArray(versionsToDownload) && versionsToDownload.length)) {
|
|
121
122
|
versionsToDownload = [];
|
|
122
123
|
|
|
123
|
-
const
|
|
124
|
-
const [latestBrowserMajorVersion] = browserLatestVersion.split('.');
|
|
125
|
-
const latestVersionNumber = Number(latestBrowserMajorVersion);
|
|
124
|
+
const latestVersionNumber = await this.getLatestBrowserVersion();
|
|
126
125
|
|
|
127
126
|
for (let i = latestVersionNumber; i > latestVersionNumber - lastActualCount; i--) {
|
|
128
127
|
versionsToDownload.push(i.toString());
|
|
@@ -138,6 +137,15 @@ export class GoLogin {
|
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
139
|
|
|
140
|
+
async getLatestBrowserVersion() {
|
|
141
|
+
const { latestVersion: browserLatestVersion } = await this.browserChecker.getLatestBrowserVersion();
|
|
142
|
+
const [latestBrowserMajorVersion] = browserLatestVersion.split('.');
|
|
143
|
+
const latestVersionNumber = Number(latestBrowserMajorVersion);
|
|
144
|
+
this.latestBrowserMajorVersion = latestVersionNumber;
|
|
145
|
+
|
|
146
|
+
return latestVersionNumber;
|
|
147
|
+
}
|
|
148
|
+
|
|
141
149
|
async setProfileId(profile_id) {
|
|
142
150
|
this.profile_id = profile_id;
|
|
143
151
|
this.cookiesFilePath = await getCookiesFilePath(profile_id, this.tmpdir);
|
|
@@ -222,8 +230,6 @@ export class GoLogin {
|
|
|
222
230
|
const [screenWidth, screenHeight] = resolution.split('x').map(Number);
|
|
223
231
|
const langHeader = (profileData.navigator && profileData.navigator.language) || '';
|
|
224
232
|
const splittedLangs = langHeader ? langHeader.split(',')[0] : 'en-US';
|
|
225
|
-
const [browserMajorVersion] = profileData.navigator.userAgent.split('Chrome/')[1].split('.');
|
|
226
|
-
this.browserMajorVersion = browserMajorVersion;
|
|
227
233
|
|
|
228
234
|
const startupUrl = (profileData.startUrl || '').trim().split(',')[0];
|
|
229
235
|
const startupUrls = (profileData.startUrl || '').split(',')
|
|
@@ -315,7 +321,7 @@ export class GoLogin {
|
|
|
315
321
|
},
|
|
316
322
|
};
|
|
317
323
|
|
|
318
|
-
if (browserMajorVersion >= this.newProxyOrbbitaMajorVersion && profileData.proxy?.mode !== 'none') {
|
|
324
|
+
if (this.browserMajorVersion >= this.newProxyOrbbitaMajorVersion && profileData.proxy?.mode !== 'none') {
|
|
319
325
|
let proxyServer = `${profileData.proxy.mode}://`;
|
|
320
326
|
if (profileData.proxy.username) {
|
|
321
327
|
const encodedUsername = encodeURIComponent(profileData.proxy.username || '');
|
|
@@ -455,8 +461,15 @@ export class GoLogin {
|
|
|
455
461
|
|
|
456
462
|
if (!this.executablePath) {
|
|
457
463
|
const { userAgent } = profile.navigator;
|
|
458
|
-
|
|
459
|
-
|
|
464
|
+
try {
|
|
465
|
+
const [browserMajorVersion] = userAgent.split('Chrome/')[1].split('.');
|
|
466
|
+
this.browserMajorVersion = Number(browserMajorVersion);
|
|
467
|
+
await this.checkBrowser(browserMajorVersion);
|
|
468
|
+
} catch (e) {
|
|
469
|
+
const latestVersionNumber = await this.getLatestBrowserVersion();
|
|
470
|
+
this.browserMajorVersion = latestVersionNumber;
|
|
471
|
+
await this.checkBrowser(latestVersionNumber);
|
|
472
|
+
}
|
|
460
473
|
}
|
|
461
474
|
|
|
462
475
|
const { navigator = {}, fonts, os: profileOs } = profile;
|
|
@@ -626,9 +639,12 @@ export class GoLogin {
|
|
|
626
639
|
}
|
|
627
640
|
|
|
628
641
|
const isMAC = OS_PLATFORM === 'darwin';
|
|
629
|
-
const checkAutoLangResult = checkAutoLang(gologin, this._tz);
|
|
630
|
-
|
|
642
|
+
const checkAutoLangResult = checkAutoLang(gologin, this._tz, profile.autoLang);
|
|
643
|
+
const intlConfig = getIntlProfileConfig(profile, this._tz, profile.autoLang);
|
|
631
644
|
|
|
645
|
+
await writeFile(join(profilePath, 'orbita.config'), JSON.stringify({ intl: intlConfig }, null, '\t'), { encoding: 'utf-8' }).catch(console.log);
|
|
646
|
+
|
|
647
|
+
this.browserLang = isMAC ? 'en-US' : checkAutoLangResult;
|
|
632
648
|
const prefsToWrite = Object.assign(preferences, { gologin });
|
|
633
649
|
if (this.browserMajorVersion >= this.newProxyOrbbitaMajorVersion && this.proxy?.mode !== 'none') {
|
|
634
650
|
prefsToWrite.proxy = {
|
package/src/utils/browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const checkAutoLang = (profileData, timezoneCheckResult) => {
|
|
2
|
-
if (!
|
|
1
|
+
export const checkAutoLang = (profileData, timezoneCheckResult, autoLang) => {
|
|
2
|
+
if (!autoLang) {
|
|
3
3
|
return checkBrowserLang(profileData);
|
|
4
4
|
}
|
|
5
5
|
|
|
@@ -27,7 +27,7 @@ export const checkAutoLang = (profileData, timezoneCheckResult) => {
|
|
|
27
27
|
return acc;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const qualityParam = 10-index;
|
|
30
|
+
const qualityParam = 10 - index;
|
|
31
31
|
if (qualityParam > 0) {
|
|
32
32
|
const separator = (resultLangsArr.length - index) < 2 ? '' : ',';
|
|
33
33
|
gologinLangsArr.push(cur);
|
|
@@ -60,3 +60,61 @@ const checkBrowserLang = (profileData, defaultLocale = 'en-US') => {
|
|
|
60
60
|
|
|
61
61
|
return defaultLocale;
|
|
62
62
|
};
|
|
63
|
+
|
|
64
|
+
export const getIntlProfileConfig = (profileData, timezoneCheckResult, autoLang) => {
|
|
65
|
+
if (!autoLang) {
|
|
66
|
+
return checkBrowserLang(profileData);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let timezoneLang = '';
|
|
70
|
+
const { country: timezoneCountry = '', languages } = timezoneCheckResult;
|
|
71
|
+
if (!languages) {
|
|
72
|
+
return checkBrowserLang(profileData);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const [firstDetectedLangLocale] = languages.split(',');
|
|
76
|
+
// если есть languages, значит есть и timezoneCountry, иначе в languages пришла бы пустая строка
|
|
77
|
+
timezoneLang = `${firstDetectedLangLocale}-${timezoneCountry}` || '';
|
|
78
|
+
|
|
79
|
+
let resultLangsArr = [];
|
|
80
|
+
const [lang = '', country = ''] = timezoneLang.split('-');
|
|
81
|
+
if (country) {
|
|
82
|
+
resultLangsArr.push([lang, country].join('-'));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
resultLangsArr.push(lang, 'en-US', 'en');
|
|
86
|
+
resultLangsArr = [...new Set(resultLangsArr)];
|
|
87
|
+
|
|
88
|
+
const mainLanguage = getMainLanguage(resultLangsArr);
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
accept_languages: resultLangsArr.join(','),
|
|
92
|
+
selected_languages: resultLangsArr.join(','),
|
|
93
|
+
app_locale: mainLanguage,
|
|
94
|
+
forced_languages: [
|
|
95
|
+
mainLanguage,
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const mainLocaleList = ['af', 'am', 'ar', 'as', 'az', 'be', 'bg', 'bn', 'bs', 'ca', 'cs', 'cy', 'da', 'de', 'el', 'en-GB',
|
|
101
|
+
'es-419', 'fr', 'fr-CA', 'gl', 'gu', 'he', 'hi', 'hr', 'hu', 'hy', 'id', 'is', 'it', 'ja', 'ka', 'kk', 'km', 'kn', 'ko', 'ky', 'lo', 'lt', 'lv',
|
|
102
|
+
'ml', 'mn', 'mr', 'ms', 'my', 'nb', 'ne', 'nl', 'or', 'pa', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'si', 'sk', 'sl', 'sq', 'sr', 'sr-Latn', 'sv', 'sw',
|
|
103
|
+
'ta', 'te', 'th', 'tr', 'uk', 'ur', 'uz', 'vi', 'zh-CN', 'zh-HK', 'zh-TW', 'zu', 'es', 'en-US', 'mk',
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
const getMainLanguage = (langArr) => {
|
|
107
|
+
for (const lang of langArr) {
|
|
108
|
+
if (mainLocaleList.includes(lang)) {
|
|
109
|
+
return lang;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const [locale] = lang.split('-');
|
|
113
|
+
if (mainLocaleList.includes(locale)) {
|
|
114
|
+
return locale;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return '';
|
|
119
|
+
};
|
|
120
|
+
|
package/src/utils/common.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { exec } from 'child_process';
|
|
2
2
|
import { promises as fsPromises } from 'fs';
|
|
3
3
|
import { homedir } from 'os';
|
|
4
|
-
import { join, sep } from 'path';
|
|
4
|
+
import { dirname, join, sep } from 'path';
|
|
5
5
|
import { promisify } from 'util';
|
|
6
6
|
|
|
7
7
|
import { deleteExtensionArchive, extractExtension } from '../extensions/extensions-extractor.js';
|
|
@@ -38,8 +38,10 @@ const getMacArmSpec = async () => {
|
|
|
38
38
|
|
|
39
39
|
export const ensureDirectoryExists = async (filePath) => {
|
|
40
40
|
try {
|
|
41
|
-
const directory =
|
|
42
|
-
|
|
41
|
+
const directory = dirname(filePath);
|
|
42
|
+
if (directory && directory !== '.') {
|
|
43
|
+
await fsPromises.mkdir(directory, { recursive: true, force: true });
|
|
44
|
+
}
|
|
43
45
|
} catch (error) {
|
|
44
46
|
if (error.code !== 'EEXIST') {
|
|
45
47
|
console.error('Error creating directory:', error.message);
|