gologin 2.2.6 → 2.2.8
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
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/src/bookmarks/utils.js
CHANGED
|
@@ -7,11 +7,6 @@ export const getCurrentProfileBookmarks = async (pathToBookmarks) => {
|
|
|
7
7
|
try {
|
|
8
8
|
const currentBookmarksFileData = await readFile(pathToBookmarks, { encoding: 'utf-8' });
|
|
9
9
|
bookmarks = JSON.parse(currentBookmarksFileData);
|
|
10
|
-
if (bookmarks.bookmark_bar) {
|
|
11
|
-
return bookmarks;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return bookmarks.roots || {};
|
|
15
10
|
} catch (error) {
|
|
16
11
|
console.log(error);
|
|
17
12
|
}
|
|
@@ -361,8 +361,11 @@ export class BrowserChecker {
|
|
|
361
361
|
|
|
362
362
|
getLatestBrowserVersion() {
|
|
363
363
|
const userOs = getOS();
|
|
364
|
+
const options = {
|
|
365
|
+
json: true,
|
|
366
|
+
};
|
|
364
367
|
|
|
365
|
-
return makeRequest(`${API_URL}/gologin-global-settings/latest-browser-info?os=${userOs}
|
|
368
|
+
return makeRequest(`${API_URL}/gologin-global-settings/latest-browser-info?os=${userOs}`, options);
|
|
366
369
|
}
|
|
367
370
|
|
|
368
371
|
get getOrbitaPath() {
|
package/src/gologin-api.js
CHANGED
|
@@ -175,7 +175,7 @@ export const GologinApi = ({ token }) => {
|
|
|
175
175
|
method: 'GET',
|
|
176
176
|
}, { token, fallbackUrl: `${FALLBACK_API_URL}/users-proxies/geolocation/traffic` });
|
|
177
177
|
|
|
178
|
-
const availableTrafficData = availableTraffic;
|
|
178
|
+
const availableTrafficData = JSON.parse(availableTraffic);
|
|
179
179
|
const availableType = this.getAvailableType(availableTrafficData);
|
|
180
180
|
if (availableType === 'none') {
|
|
181
181
|
throw new Error(trafficLimitMessage);
|
package/src/gologin.js
CHANGED
|
@@ -80,11 +80,10 @@ export class GoLogin {
|
|
|
80
80
|
this.restoreLastSession = options.restoreLastSession || true;
|
|
81
81
|
this.processSpawned = null;
|
|
82
82
|
this.processKillTimeout = 1 * 1000;
|
|
83
|
-
this.browserMajorVersion = 0;
|
|
84
|
-
this.
|
|
83
|
+
this.browserMajorVersion = options.browserMajorVersion || 0;
|
|
84
|
+
this.newProxyOrbitaMajorVersion = 135;
|
|
85
85
|
this.proxyCheckTimeout = options.proxyCheckTimeout || 13 * 1000;
|
|
86
86
|
this.proxyCheckAttempts = options.proxyCheckAttempts || 3;
|
|
87
|
-
this.browserLatestMajorVersion = 137;
|
|
88
87
|
|
|
89
88
|
if (process.env.DISABLE_TELEMETRY !== 'true') {
|
|
90
89
|
Sentry.init({
|
|
@@ -329,7 +328,7 @@ export class GoLogin {
|
|
|
329
328
|
},
|
|
330
329
|
};
|
|
331
330
|
|
|
332
|
-
if (this.browserMajorVersion >= this.
|
|
331
|
+
if (this.browserMajorVersion >= this.newProxyOrbitaMajorVersion && profileData.proxy?.mode !== 'none') {
|
|
333
332
|
let proxyServer = `${profileData.proxy.mode}://`;
|
|
334
333
|
if (profileData.proxy.username) {
|
|
335
334
|
const encodedUsername = encodeURIComponent(profileData.proxy.username || '');
|
|
@@ -476,6 +475,29 @@ export class GoLogin {
|
|
|
476
475
|
this.browserMajorVersion = latestVersionNumber;
|
|
477
476
|
await this.checkBrowser(latestVersionNumber);
|
|
478
477
|
}
|
|
478
|
+
} else if (!this.browserMajorVersion) {
|
|
479
|
+
const { userAgent } = profile.navigator;
|
|
480
|
+
const [browserMajorVersion] = userAgent.split('Chrome/')[1].split('.');
|
|
481
|
+
this.browserMajorVersion = Number(browserMajorVersion);
|
|
482
|
+
|
|
483
|
+
let executableDir = join(this.executablePath, '..');
|
|
484
|
+
if (OS_PLATFORM === 'darwin') {
|
|
485
|
+
executableDir = join(this.executablePath, '..', '..', '..');
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const versionFilePath = join(executableDir, 'version');
|
|
489
|
+
try {
|
|
490
|
+
await access(versionFilePath);
|
|
491
|
+
const versionContent = await readFile(versionFilePath, 'utf8');
|
|
492
|
+
const versionFromFile = versionContent.trim();
|
|
493
|
+
const isValidVersion = /^\d+\.\d+\.\d+/.test(versionFromFile);
|
|
494
|
+
if (isValidVersion) {
|
|
495
|
+
const [browserMajorVersion] = isValidVersion.split('.');
|
|
496
|
+
this.browserMajorVersion = Number(browserMajorVersion);
|
|
497
|
+
}
|
|
498
|
+
} catch (error) {
|
|
499
|
+
console.warn('Error reading version file:', error);
|
|
500
|
+
}
|
|
479
501
|
}
|
|
480
502
|
|
|
481
503
|
const { navigator = {}, fonts, os: profileOs } = profile;
|
|
@@ -655,7 +677,7 @@ export class GoLogin {
|
|
|
655
677
|
|
|
656
678
|
this.browserLang = isMAC ? 'en-US' : checkAutoLangResult;
|
|
657
679
|
const prefsToWrite = Object.assign(preferences, { gologin });
|
|
658
|
-
if (this.browserMajorVersion >= this.
|
|
680
|
+
if (this.browserMajorVersion >= this.newProxyOrbitaMajorVersion && this.proxy?.mode !== 'none') {
|
|
659
681
|
prefsToWrite.proxy = {
|
|
660
682
|
mode: 'fixed_servers',
|
|
661
683
|
server: gologin.proxy.server,
|
|
@@ -666,6 +688,7 @@ export class GoLogin {
|
|
|
666
688
|
const orbitaConfig = {
|
|
667
689
|
intl: intlConfig,
|
|
668
690
|
gologin: {
|
|
691
|
+
api_domain: API_URL,
|
|
669
692
|
profile_token: orbitaParamsToken,
|
|
670
693
|
...clientGologinOpts,
|
|
671
694
|
},
|
|
@@ -674,11 +697,10 @@ export class GoLogin {
|
|
|
674
697
|
await writeFile(join(profilePath, 'orbita.config'), JSON.stringify(orbitaConfig, null, '\t'), { encoding: 'utf-8' }).catch(console.log);
|
|
675
698
|
await writeFile(join(profilePath, 'Default', 'Preferences'), JSON.stringify(prefsToWrite));
|
|
676
699
|
|
|
677
|
-
const bookmarksToWrite = {};
|
|
678
700
|
const bookmarksParsedData = await getCurrentProfileBookmarks(this.bookmarksFilePath);
|
|
679
701
|
const bookmarksFromDb = profile.bookmarks?.bookmark_bar;
|
|
680
|
-
|
|
681
|
-
await writeFile(this.bookmarksFilePath, JSON.stringify(
|
|
702
|
+
bookmarksParsedData.roots = bookmarksFromDb ? profile.bookmarks : bookmarksParsedData.roots;
|
|
703
|
+
await writeFile(this.bookmarksFilePath, JSON.stringify(bookmarksParsedData));
|
|
682
704
|
|
|
683
705
|
debug('Profile ready. Path: ', profilePath, 'PROXY', JSON.stringify(get(preferences, 'gologin.proxy')));
|
|
684
706
|
|
|
@@ -978,7 +1000,7 @@ export class GoLogin {
|
|
|
978
1000
|
params.push(`--host-resolver-rules=${hr_rules}`);
|
|
979
1001
|
}
|
|
980
1002
|
|
|
981
|
-
if (proxy && Number(this.browserMajorVersion) < this.
|
|
1003
|
+
if (proxy && Number(this.browserMajorVersion) < this.newProxyOrbitaMajorVersion) {
|
|
982
1004
|
params.push(`--proxy-server=${proxy}`);
|
|
983
1005
|
}
|
|
984
1006
|
|
|
@@ -1062,7 +1084,7 @@ export class GoLogin {
|
|
|
1062
1084
|
const extensions = await getProfileChromeExtensions(profilePreferencesPath).catch(() => null);
|
|
1063
1085
|
const body = {
|
|
1064
1086
|
cookies,
|
|
1065
|
-
bookmarks,
|
|
1087
|
+
bookmarks: bookmarks.roots,
|
|
1066
1088
|
extensionsIds: extensions,
|
|
1067
1089
|
isCookiesEncrypted: true,
|
|
1068
1090
|
isStorageGateway: true,
|
|
@@ -1410,7 +1432,7 @@ export class GoLogin {
|
|
|
1410
1432
|
|
|
1411
1433
|
async saveBookmarksToDb() {
|
|
1412
1434
|
const bookmarksData = await getCurrentProfileBookmarks(this.bookmarksFilePath);
|
|
1413
|
-
const bookmarks = bookmarksData || {};
|
|
1435
|
+
const bookmarks = bookmarksData.roots || {};
|
|
1414
1436
|
await updateProfileBookmarks([this.profile_id], this.access_token, bookmarks);
|
|
1415
1437
|
}
|
|
1416
1438
|
|
package/src/utils/http.js
CHANGED
|
@@ -33,7 +33,7 @@ const attemptRequest = async (requestUrl, options) => {
|
|
|
33
33
|
return req.body;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
export const makeRequest = async (url, options, internalOptions) => {
|
|
36
|
+
export const makeRequest = async (url, options = {}, internalOptions) => {
|
|
37
37
|
options.headers = {
|
|
38
38
|
...options.headers,
|
|
39
39
|
'User-Agent': `gologin-nodejs-sdk/${version}`,
|