gologin 2.1.16 → 2.1.17
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/browser/browser-checker.js +47 -70
- package/src/gologin.js +9 -13
- package/src/utils/constants.js +1 -1
package/package.json
CHANGED
|
@@ -6,10 +6,8 @@ import { get } from 'https';
|
|
|
6
6
|
import { homedir } from 'os';
|
|
7
7
|
import { join } from 'path';
|
|
8
8
|
import ProgressBar from 'progress';
|
|
9
|
-
import { createInterface } from 'readline';
|
|
10
9
|
import util from 'util';
|
|
11
10
|
|
|
12
|
-
import { findLatestBrowserVersionDirectory } from '../utils/utils.js';
|
|
13
11
|
import { API_URL, getOS } from '../utils/common.js';
|
|
14
12
|
|
|
15
13
|
const exec = util.promisify(execNonPromise);
|
|
@@ -37,87 +35,65 @@ const FAIL_SUM_MATCH_MESSAGE = 'hash_sum_not_matched';
|
|
|
37
35
|
const EXTRACTED_FOLDER = 'extracted-browser';
|
|
38
36
|
|
|
39
37
|
export class BrowserChecker {
|
|
40
|
-
#homedir;
|
|
41
|
-
#browserPath;
|
|
38
|
+
#homedir = homedir();
|
|
39
|
+
#browserPath = join(this.#homedir, '.gologin', 'browser');
|
|
42
40
|
#executableFilePath;
|
|
43
41
|
#skipOrbitaHashChecking = false;
|
|
44
42
|
|
|
45
|
-
constructor(
|
|
46
|
-
this.#skipOrbitaHashChecking = skipOrbitaHashChecking;
|
|
47
|
-
this.#homedir = homedir();
|
|
48
|
-
this.#browserPath = join(this.#homedir, '.gologin', 'browser');
|
|
43
|
+
constructor() {
|
|
49
44
|
|
|
50
|
-
let executableFilePath = join(this.#browserPath, 'orbita-browser', 'chrome');
|
|
51
|
-
if (PLATFORM === 'darwin') {
|
|
52
|
-
const orbitaFolderName = findLatestBrowserVersionDirectory(this.#browserPath);
|
|
53
|
-
if (orbitaFolderName === 'error') {
|
|
54
|
-
throw Error('Orbita folder not found in this directory: ' + this.#browserPath);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
executableFilePath = join(this.#browserPath, orbitaFolderName, 'Orbita-Browser.app', 'Contents', 'MacOS', 'Orbita');
|
|
58
|
-
} else if (PLATFORM === 'win32') {
|
|
59
|
-
executableFilePath = join(this.#browserPath, 'orbita-browser', 'chrome.exe');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
this.#executableFilePath = executableFilePath;
|
|
63
|
-
// console.log('executableFilePath:', executableFilePath);
|
|
64
45
|
}
|
|
65
46
|
|
|
66
|
-
async checkBrowser(
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (!browserFolderExists) {
|
|
72
|
-
return this.downloadBrowser(browserLatestVersion, browserDownloadUrl);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const currentVersionReq = await this.getCurrentVersion();
|
|
76
|
-
const currentVersion = (currentVersionReq?.stdout || '').replace(/(\r\n|\n|\r)/gm, '');
|
|
77
|
-
|
|
78
|
-
if (browserLatestVersion === currentVersion || !checkBrowserUpdate) {
|
|
79
|
-
return;
|
|
47
|
+
async checkBrowser(majorVersion) {
|
|
48
|
+
const isBrowserFolderExists = await access(join(this.#browserPath, `orbita-browser-${majorVersion}`)).then(() => true).catch(() => false);
|
|
49
|
+
if (isBrowserFolderExists) {
|
|
50
|
+
return this.getBrowserExecutablePath(majorVersion);
|
|
80
51
|
}
|
|
81
52
|
|
|
82
|
-
|
|
83
|
-
return this.downloadBrowser(browserLatestVersion, browserDownloadUrl);
|
|
84
|
-
}
|
|
53
|
+
await this.downloadBrowser(majorVersion);
|
|
85
54
|
|
|
86
|
-
return
|
|
87
|
-
const rl = createInterface(process.stdin, process.stdout);
|
|
88
|
-
const timeout = setTimeout(() => {
|
|
89
|
-
console.log(`\nContinue with current ${currentVersion} version.`);
|
|
90
|
-
resolve();
|
|
91
|
-
}, 10000);
|
|
92
|
-
|
|
93
|
-
rl.question(`New Orbita ${browserLatestVersion} is available. Update? [y/n] `, (answer) => {
|
|
94
|
-
clearTimeout(timeout);
|
|
95
|
-
rl.close();
|
|
96
|
-
if (answer && answer[0].toString().toLowerCase() === 'y') {
|
|
97
|
-
return this.downloadBrowser(browserLatestVersion, browserDownloadUrl).then(() => resolve());
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
console.log(`Continue with current ${currentVersion} version.`);
|
|
101
|
-
resolve();
|
|
102
|
-
});
|
|
103
|
-
});
|
|
55
|
+
return this.getBrowserExecutablePath(majorVersion);
|
|
104
56
|
}
|
|
105
57
|
|
|
106
|
-
async downloadBrowser(
|
|
107
|
-
await this.deleteOldArchives(true);
|
|
58
|
+
async downloadBrowser(majorVersion) {
|
|
108
59
|
await mkdir(this.#browserPath, { recursive: true });
|
|
109
60
|
|
|
110
|
-
const
|
|
61
|
+
const browserPath = join(this.#browserPath, BROWSER_ARCHIVE_NAME);
|
|
111
62
|
|
|
112
|
-
|
|
113
|
-
|
|
63
|
+
const browserDownloadUrl = this.getBrowserDownloadUrl(majorVersion);
|
|
64
|
+
|
|
65
|
+
await this.downloadBrowserArchive(browserDownloadUrl, browserPath);
|
|
114
66
|
await this.extractBrowser();
|
|
115
|
-
await this.
|
|
116
|
-
console.log('Orbita hash checked successfully');
|
|
117
|
-
await this.replaceBrowser();
|
|
118
|
-
await this.addLatestVersion(latestVersion).catch(() => null);
|
|
67
|
+
await this.replaceBrowser(majorVersion);
|
|
119
68
|
await this.deleteOldArchives();
|
|
120
|
-
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getBrowserExecutablePath(majorVersion) {
|
|
72
|
+
const os = getOS();
|
|
73
|
+
switch (os) {
|
|
74
|
+
case 'mac':
|
|
75
|
+
return join(this.#browserPath, `orbita-browser-${majorVersion}`, 'Orbita-Browser.app', 'Contents', 'MacOS', 'Orbita');
|
|
76
|
+
case 'win':
|
|
77
|
+
return join(this.#browserPath, `orbita-browser-${majorVersion}`, 'chrome.exe');
|
|
78
|
+
case 'macM1':
|
|
79
|
+
return join(this.#browserPath, `orbita-browser-${majorVersion}`, 'Orbita-Browser.app', 'Contents', 'MacOS', 'Orbita');
|
|
80
|
+
default:
|
|
81
|
+
return join(this.#browserPath, `orbita-browser-${majorVersion}`, 'chrome');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getBrowserDownloadUrl(majorVersion) {
|
|
86
|
+
const os = getOS();
|
|
87
|
+
switch (os) {
|
|
88
|
+
case 'mac':
|
|
89
|
+
return `https://orbita-browser-mac.gologin.com/orbita-browser-latest-${majorVersion}.tar.gz`;
|
|
90
|
+
case 'win':
|
|
91
|
+
return `https://orbita-browser-windows.gologin.com/orbita-browser-latest-${majorVersion}.zip`;
|
|
92
|
+
case 'macM1':
|
|
93
|
+
return `https://orbita-browser-mac-arm.gologin.com/orbita-browser-latest-${majorVersion}.tar.gz`;
|
|
94
|
+
default:
|
|
95
|
+
return `https://orbita-browser-linux.gologin.com/orbita-browser-latest-${majorVersion}.tar.gz`;
|
|
96
|
+
}
|
|
121
97
|
}
|
|
122
98
|
|
|
123
99
|
addLatestVersion(latestVersion) {
|
|
@@ -208,6 +184,7 @@ export class BrowserChecker {
|
|
|
208
184
|
if (ARCH === 'arm64') {
|
|
209
185
|
hashLink = MAC_ARM_HASHFILE_LINK;
|
|
210
186
|
}
|
|
187
|
+
|
|
211
188
|
resultPath = join(this.#browserPath, MAC_HASH_FILE);
|
|
212
189
|
}
|
|
213
190
|
|
|
@@ -282,13 +259,13 @@ export class BrowserChecker {
|
|
|
282
259
|
}
|
|
283
260
|
}
|
|
284
261
|
|
|
285
|
-
async replaceBrowser() {
|
|
262
|
+
async replaceBrowser(majorVersion) {
|
|
286
263
|
console.log('Copy Orbita to target path');
|
|
287
264
|
if (PLATFORM === 'darwin') {
|
|
288
|
-
return rename(join(this.#browserPath, EXTRACTED_FOLDER), join(this.#browserPath,
|
|
265
|
+
return rename(join(this.#browserPath, EXTRACTED_FOLDER), join(this.#browserPath, `orbita-browser-${majorVersion}`));
|
|
289
266
|
}
|
|
290
267
|
|
|
291
|
-
const targetBrowserPath = join(this.#browserPath,
|
|
268
|
+
const targetBrowserPath = join(this.#browserPath, `orbita-browser-${majorVersion}`);
|
|
292
269
|
await this.deleteDir(targetBrowserPath);
|
|
293
270
|
|
|
294
271
|
await this.copyDir(
|
package/src/gologin.js
CHANGED
|
@@ -92,8 +92,8 @@ export class GoLogin {
|
|
|
92
92
|
debug('INIT GOLOGIN', this.profile_id);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
async checkBrowser() {
|
|
96
|
-
|
|
95
|
+
async checkBrowser(majorVersion) {
|
|
96
|
+
this.executablePath = await this.browserChecker.checkBrowser(majorVersion);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
async setProfileId(profile_id) {
|
|
@@ -466,6 +466,12 @@ export class GoLogin {
|
|
|
466
466
|
throw new Error('Error fetching profile data');
|
|
467
467
|
}
|
|
468
468
|
|
|
469
|
+
if (!this.executablePath) {
|
|
470
|
+
const { userAgent } = profile.navigator;
|
|
471
|
+
const [browserMajorVersion] = userAgent.split('Chrome/')[1].split('.');
|
|
472
|
+
await this.checkBrowser(browserMajorVersion);
|
|
473
|
+
}
|
|
474
|
+
|
|
469
475
|
const { navigator = {}, fonts, os: profileOs } = profile;
|
|
470
476
|
this.fontsMasking = fonts?.enableMasking;
|
|
471
477
|
this.profileOs = profileOs;
|
|
@@ -927,7 +933,7 @@ export class GoLogin {
|
|
|
927
933
|
|
|
928
934
|
if (this.waitWebsocket) {
|
|
929
935
|
debug('GETTING WS URL FROM BROWSER');
|
|
930
|
-
const data = await requests.get(`http://127.0.0.1:${remote_debugging_port}/json/version`, { json: true });
|
|
936
|
+
const data = await requests.get(`http://127.0.0.1:${remote_debugging_port}/json/version`, { json: true, maxAttempts: 10, retryDelay: 1000 });
|
|
931
937
|
|
|
932
938
|
debug('WS IS', get(data, 'body.webSocketDebuggerUrl', ''));
|
|
933
939
|
this.is_active = true;
|
|
@@ -1427,16 +1433,6 @@ export class GoLogin {
|
|
|
1427
1433
|
}
|
|
1428
1434
|
|
|
1429
1435
|
async start() {
|
|
1430
|
-
if (!this.executablePath) {
|
|
1431
|
-
await this.checkBrowser();
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
const ORBITA_BROWSER = this.executablePath || this.browserChecker.getOrbitaPath;
|
|
1435
|
-
|
|
1436
|
-
const orbitaBrowserExists = await access(ORBITA_BROWSER).then(() => true).catch(() => false);
|
|
1437
|
-
if (!orbitaBrowserExists) {
|
|
1438
|
-
throw new Error(`Orbita browser is not exists on path ${ORBITA_BROWSER}, check executablePath param`);
|
|
1439
|
-
}
|
|
1440
1436
|
|
|
1441
1437
|
await this.createStartup();
|
|
1442
1438
|
// await this.createBrowserExtension();
|
package/src/utils/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const STORAGE_GATEWAY_BASE_URL = 'https://
|
|
1
|
+
export const STORAGE_GATEWAY_BASE_URL = 'https://storage-worker-test.gologin.com';
|