Skip to content

Commit abd73df

Browse files
authored
Merge pull request #223 from gologinapp/custom_orbita_exec_path_fix
custom orbita exec path fix
2 parents a1b6bb4 + 1984d49 commit abd73df

4 files changed

Lines changed: 32 additions & 10 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gologin",
3-
"version": "2.2.7",
3+
"version": "2.2.8",
44
"description": "A high-level API to control Orbita browser over GoLogin API",
55
"types": "./index.d.ts",
66
"main": "./src/gologin.js",

src/browser/browser-checker.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,11 @@ export class BrowserChecker {
361361

362362
getLatestBrowserVersion() {
363363
const userOs = getOS();
364+
const options = {
365+
json: true,
366+
};
364367

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);
366369
}
367370

368371
get getOrbitaPath() {

src/gologin.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ export class GoLogin {
8080
this.restoreLastSession = options.restoreLastSession || true;
8181
this.processSpawned = null;
8282
this.processKillTimeout = 1 * 1000;
83-
this.browserMajorVersion = 0;
84-
this.newProxyOrbbitaMajorVersion = 135;
83+
this.browserMajorVersion = options.browserMajorVersion || 0;
84+
this.newProxyOrbitaMajorVersion = 135;
8585
this.proxyCheckTimeout = options.proxyCheckTimeout || 13 * 1000;
8686
this.proxyCheckAttempts = options.proxyCheckAttempts || 3;
87-
this.browserLatestMajorVersion = 137;
8887

8988
if (process.env.DISABLE_TELEMETRY !== 'true') {
9089
Sentry.init({
@@ -329,7 +328,7 @@ export class GoLogin {
329328
},
330329
};
331330

332-
if (this.browserMajorVersion >= this.newProxyOrbbitaMajorVersion && profileData.proxy?.mode !== 'none') {
331+
if (this.browserMajorVersion >= this.newProxyOrbitaMajorVersion && profileData.proxy?.mode !== 'none') {
333332
let proxyServer = `${profileData.proxy.mode}://`;
334333
if (profileData.proxy.username) {
335334
const encodedUsername = encodeURIComponent(profileData.proxy.username || '');
@@ -476,10 +475,29 @@ export class GoLogin {
476475
this.browserMajorVersion = latestVersionNumber;
477476
await this.checkBrowser(latestVersionNumber);
478477
}
479-
} else {
478+
} else if (!this.browserMajorVersion) {
480479
const { userAgent } = profile.navigator;
481480
const [browserMajorVersion] = userAgent.split('Chrome/')[1].split('.');
482481
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+
}
483501
}
484502

485503
const { navigator = {}, fonts, os: profileOs } = profile;
@@ -659,7 +677,7 @@ export class GoLogin {
659677

660678
this.browserLang = isMAC ? 'en-US' : checkAutoLangResult;
661679
const prefsToWrite = Object.assign(preferences, { gologin });
662-
if (this.browserMajorVersion >= this.newProxyOrbbitaMajorVersion && this.proxy?.mode !== 'none') {
680+
if (this.browserMajorVersion >= this.newProxyOrbitaMajorVersion && this.proxy?.mode !== 'none') {
663681
prefsToWrite.proxy = {
664682
mode: 'fixed_servers',
665683
server: gologin.proxy.server,
@@ -670,6 +688,7 @@ export class GoLogin {
670688
const orbitaConfig = {
671689
intl: intlConfig,
672690
gologin: {
691+
api_domain: API_URL,
673692
profile_token: orbitaParamsToken,
674693
...clientGologinOpts,
675694
},
@@ -981,7 +1000,7 @@ export class GoLogin {
9811000
params.push(`--host-resolver-rules=${hr_rules}`);
9821001
}
9831002

984-
if (proxy && Number(this.browserMajorVersion) < this.newProxyOrbbitaMajorVersion) {
1003+
if (proxy && Number(this.browserMajorVersion) < this.newProxyOrbitaMajorVersion) {
9851004
params.push(`--proxy-server=${proxy}`);
9861005
}
9871006

src/utils/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const attemptRequest = async (requestUrl, options) => {
3333
return req.body;
3434
};
3535

36-
export const makeRequest = async (url, options, internalOptions) => {
36+
export const makeRequest = async (url, options = {}, internalOptions) => {
3737
options.headers = {
3838
...options.headers,
3939
'User-Agent': `gologin-nodejs-sdk/${version}`,

0 commit comments

Comments
 (0)