gologin-commonjs 1.2.9 → 1.3.0

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.
Files changed (40) hide show
  1. package/babel.config.json +4 -3
  2. package/dist/package.json +53 -0
  3. package/dist/src/browser/browser-checker.js +7 -14
  4. package/dist/src/browser/browser-user-data-manager.js +2 -2
  5. package/dist/src/extensions/get-extensions.js +45 -0
  6. package/dist/src/gologin-api.js +1 -1
  7. package/dist/src/gologin.js +69 -30
  8. package/dist/src/utils/browser.js +3 -2
  9. package/dist/src/utils/common.js +6 -4
  10. package/dist/src/utils/http.js +6 -2
  11. package/dist/src/utils/sentry.js +2 -2
  12. package/gologin/src/browser/browser-checker.js +7 -17
  13. package/gologin/src/browser/browser-user-data-manager.js +2 -2
  14. package/gologin/src/extensions/get-extensions.js +42 -0
  15. package/gologin/src/gologin-api.js +1 -1
  16. package/gologin/src/gologin.js +71 -30
  17. package/gologin/src/utils/browser.js +5 -0
  18. package/gologin/src/utils/common.js +6 -4
  19. package/gologin/src/utils/http.js +14 -5
  20. package/gologin/src/utils/sentry.js +2 -2
  21. package/package.json +3 -2
  22. package/types/src/extensions/get-extensions.d.ts +1 -0
  23. package/types/src/gologin.d.ts +4 -5
  24. package/types/src/utils/browser.d.ts +1 -0
  25. package/types/src/utils/common.d.ts +1 -1
  26. package/types/src/utils/http.d.ts +1 -1
  27. package/dist/examples/example-amazon-cloud-browser.js +0 -34
  28. package/dist/examples/example-amazon-headless.js +0 -56
  29. package/dist/examples/example-amazon.js +0 -53
  30. package/dist/examples/example-create-custom-profile.js +0 -42
  31. package/dist/examples/example-create-profile.js +0 -43
  32. package/dist/examples/example-custom-args.js +0 -34
  33. package/dist/examples/example-fast-profile-settings.js +0 -59
  34. package/dist/examples/example-gmail.js +0 -82
  35. package/dist/examples/example-iphey.js +0 -19
  36. package/dist/examples/example-local-profile.js +0 -28
  37. package/dist/examples/example-login-walmart.js +0 -38
  38. package/dist/examples/example-stopremote.js +0 -22
  39. package/dist/examples/example-timezone.js +0 -51
  40. package/dist/src/utils/timezone.js +0 -21
package/babel.config.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "plugins": [
3
+ "@babel/plugin-syntax-import-attributes",
4
+ [
5
+ "babel-plugin-transform-import-meta"
6
+ ],
3
7
  [
4
8
  "@babel/plugin-transform-modules-commonjs",
5
9
  {
6
10
  "importInterop": "babel"
7
11
  }
8
- ],
9
- [
10
- "babel-plugin-transform-import-meta"
11
12
  ]
12
13
  ],
13
14
  "ignore": [
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "gologin-commonjs",
3
+ "version": "1.2.9",
4
+ "description": "A Transpiled GoLogin API ESM to CommonJS",
5
+ "types": "./types/src/gologin.d.ts",
6
+ "main": "./dist/src/gologin.js",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/faridfadhlan/gologin-commonjs.git"
10
+ },
11
+ "engines": {
12
+ "node": ">=16.0.0"
13
+ },
14
+ "author": "Muhammad Farid Fadhlan",
15
+ "license": "GPL-3.0",
16
+ "dependencies": {
17
+ "adm-zip": "^0.5.1",
18
+ "archiver": "^3.1.1",
19
+ "axios": "^1.11.0",
20
+ "child_process": "^1.0.2",
21
+ "decompress": "^4.2.1",
22
+ "decompress-unzip": "^4.0.1",
23
+ "form-data": "^3.0.0",
24
+ "gologin": "^2.1.33",
25
+ "ncp": "^2.0.0",
26
+ "progress": "^2.0.3",
27
+ "puppeteer-core": "^2.1.1",
28
+ "request": "^2.88.2",
29
+ "requestretry": "^4.1.0",
30
+ "rimraf": "^3.0.2",
31
+ "socks-proxy-agent": "^8.0.3",
32
+ "sqlite": "^4.0.23",
33
+ "sqlite3": "^5.0.2"
34
+ },
35
+ "devDependencies": {
36
+ "@babel/cli": "^7.25.6",
37
+ "@babel/core": "^7.25.2",
38
+ "@babel/plugin-transform-modules-commonjs": "^7.24.8",
39
+ "@babel/plugin-syntax-import-attributes": "^7.25.0",
40
+ "babel-plugin-transform-import-meta": "^2.2.1",
41
+ "eslint": "^8.21.0",
42
+ "eslint-plugin-simple-import-sort": "^8.0.0",
43
+ "typescript": "^5.5.4"
44
+ },
45
+ "scripts": {
46
+ "build": "tsc && npm run build:common",
47
+ "build:common": "babel gologin --out-dir dist && npm run copy",
48
+ "copy": "ncp gologin/fonts_config dist/fonts_config && ncp gologin/gologin_zeroprofile.b64 dist/gologin_zeroprofile.b64 && ncp gologin/gologin-browser-ext.zip dist/gologin-browser-ext.zip && ncp gologin/zero_profile.zip dist/zero_profile.zip && ncp package.json dist/package.json",
49
+ "test": "echo \"Error: no test specified\" && exit 1",
50
+ "format": "npx prettier --single-quote src/* --write",
51
+ "iphey": "GOLOGIN_PROFILE_ID= GOLOGIN_API_TOKEN= node examples/example-iphey "
52
+ }
53
+ }
@@ -14,6 +14,7 @@ var _path = require("path");
14
14
  var _progress = _interopRequireDefault(require("progress"));
15
15
  var _util = _interopRequireDefault(require("util"));
16
16
  var _common = require("../utils/common.js");
17
+ var _http = require("../utils/http.js");
17
18
  var _browserDownloadManager = _interopRequireDefault(require("./browser-download-manager.js"));
18
19
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
20
  const exec = _util.default.promisify(_child_process.exec);
@@ -129,6 +130,8 @@ class BrowserChecker {
129
130
  return `https://orbita-browser-windows.gologin.com/orbita-browser-latest-${majorVersion}.zip`;
130
131
  case 'macM1':
131
132
  return `https://orbita-browser-mac-arm.gologin.com/orbita-browser-latest-${majorVersion}.tar.gz`;
133
+ case 'linArm':
134
+ return `https://orbita-browser-linux-arm.gologin.com/orbita-browser-latest-${majorVersion}.tar.gz`;
132
135
  default:
133
136
  return `https://orbita-browser-linux.gologin.com/orbita-browser-latest-${majorVersion}.tar.gz`;
134
137
  }
@@ -315,20 +318,10 @@ class BrowserChecker {
315
318
  }
316
319
  getLatestBrowserVersion() {
317
320
  const userOs = (0, _common.getOS)();
318
- return new Promise(resolve => (0, _https.get)(`${_common.API_URL}/gologin-global-settings/latest-browser-info?os=${userOs}`, {
319
- timeout: 15 * 1000,
320
- headers: {
321
- 'Content-Type': 'application/json',
322
- 'User-Agent': 'gologin-api'
323
- }
324
- }, res => {
325
- res.setEncoding('utf8');
326
- let resultResponse = '';
327
- res.on('data', data => resultResponse += data);
328
- res.on('end', () => {
329
- resolve(JSON.parse(resultResponse.trim()));
330
- });
331
- }).on('error', err => resolve('')));
321
+ const options = {
322
+ json: true
323
+ };
324
+ return (0, _http.makeRequest)(`${_common.API_URL}/gologin-global-settings/latest-browser-info?os=${userOs}`, options);
332
325
  }
333
326
  get getOrbitaPath() {
334
327
  return this.executableFilePath;
@@ -21,8 +21,8 @@ const {
21
21
  copyFile,
22
22
  rename
23
23
  } = _fs.promises;
24
- const _filename = (0, _url.fileURLToPath)(require('url').pathToFileURL(__filename).toString());
25
- const _dirname = (0, _path.dirname)(_filename);
24
+ const _filename = typeof __filename !== 'undefined' ? __filename : process.cwd();
25
+ const _dirname = typeof __dirname !== 'undefined' ? __dirname : (0, _path.dirname)(_filename || process.cwd());
26
26
  const FONTS_URL = 'https://fonts.gologin.com/';
27
27
  const FONTS_DIR_NAME = 'fonts';
28
28
  const HOMEDIR = (0, _os.homedir)();
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getProfileChromeExtensions = void 0;
7
+ var _promises = require("fs/promises");
8
+ const getProfileChromeExtensions = async profilePreferencesPath => {
9
+ const profileChromeExtensions = [];
10
+ if (!profilePreferencesPath) {
11
+ return profileChromeExtensions;
12
+ }
13
+ const fileContent = await (0, _promises.readFile)(profilePreferencesPath, 'utf-8');
14
+ const settings = JSON.parse(fileContent);
15
+ const extensionsSettingsObj = settings?.extensions || {
16
+ settings: {}
17
+ };
18
+ const extensionsSettings = extensionsSettingsObj.settings || {};
19
+ const extensionsEntries = Object.entries(extensionsSettings);
20
+ if (!extensionsEntries.length) {
21
+ return profileChromeExtensions;
22
+ }
23
+ const currentExtensions = [];
24
+ extensionsEntries.forEach(extensionObj => {
25
+ const [extensionsId, extensionsContent] = extensionObj;
26
+ const {
27
+ path: extPath = ''
28
+ } = extensionsContent;
29
+ const formattedPath = extPath.replace(/\\|@/g, '/');
30
+ const regex = new RegExp(`^${extensionsId}|(?:chrome-extensions|user-extensions)/\\w+`);
31
+ const pathMatch = formattedPath.match(regex);
32
+ if (!pathMatch) {
33
+ return;
34
+ }
35
+ currentExtensions.push(extensionsId);
36
+ const [matched] = pathMatch;
37
+ const [originalExtId] = matched.split('/').reverse();
38
+ if (profileChromeExtensions.includes(originalExtId)) {
39
+ return;
40
+ }
41
+ profileChromeExtensions.push(originalExtId);
42
+ });
43
+ return profileChromeExtensions;
44
+ };
45
+ exports.getProfileChromeExtensions = getProfileChromeExtensions;
@@ -186,7 +186,7 @@ const GologinApi = ({
186
186
  token,
187
187
  fallbackUrl: `${_common.FALLBACK_API_URL}/users-proxies/geolocation/traffic`
188
188
  });
189
- const availableTrafficData = availableTraffic;
189
+ const availableTrafficData = JSON.parse(availableTraffic);
190
190
  const availableType = this.getAvailableType(availableTrafficData);
191
191
  if (availableType === 'none') {
192
192
  throw new Error(trafficLimitMessage);
@@ -40,6 +40,7 @@ var _common = require("./utils/common.js");
40
40
  var _constants = require("./utils/constants.js");
41
41
  var _utils2 = require("./utils/utils.js");
42
42
  var _gologinApi = require("./gologin-api.js");
43
+ var _getExtensions = require("./extensions/get-extensions.js");
43
44
  var _http = require("./utils/http.js");
44
45
  var _sentry = require("./utils/sentry.js");
45
46
  var _zeroProfileBookmarks = require("./utils/zero-profile-bookmarks.js");
@@ -93,17 +94,16 @@ class GoLogin {
93
94
  this.restoreLastSession = options.restoreLastSession || true;
94
95
  this.processSpawned = null;
95
96
  this.processKillTimeout = 1 * 1000;
96
- this.browserMajorVersion = 0;
97
- this.newProxyOrbbitaMajorVersion = 135;
97
+ this.browserMajorVersion = options.browserMajorVersion || 0;
98
+ this.newProxyOrbitaMajorVersion = 135;
98
99
  this.proxyCheckTimeout = options.proxyCheckTimeout || 13 * 1000;
99
100
  this.proxyCheckAttempts = options.proxyCheckAttempts || 3;
100
- this.browserLatestMajorVersion = 137;
101
101
  if (process.env.DISABLE_TELEMETRY !== 'true') {
102
102
  Sentry.init({
103
103
  dsn: 'https://a13d5939a60ae4f6583e228597f1f2a0@sentry-new.amzn.pro/24',
104
104
  tracesSampleRate: 1.0,
105
105
  defaultIntegrations: false,
106
- release: process.env.npm_package_version || '2.1.33'
106
+ release: process.env.npm_package_version || '2.1.34'
107
107
  });
108
108
  }
109
109
  if (options.tmpdir) {
@@ -154,9 +154,7 @@ class GoLogin {
154
154
  latestVersion: browserLatestVersion
155
155
  } = await this.browserChecker.getLatestBrowserVersion();
156
156
  const [latestBrowserMajorVersion] = browserLatestVersion.split('.');
157
- const latestVersionNumber = Number(latestBrowserMajorVersion);
158
- this.latestBrowserMajorVersion = latestVersionNumber;
159
- return latestVersionNumber;
157
+ return Number(latestBrowserMajorVersion);
160
158
  }
161
159
  async setProfileId(profile_id) {
162
160
  this.profile_id = profile_id;
@@ -175,6 +173,20 @@ class GoLogin {
175
173
  });
176
174
  return JSON.parse(profileResponse);
177
175
  }
176
+ async requestOrbitaProfileParamsToken(profileId) {
177
+ const tokenRes = await (0, _http.makeRequest)(`${_common.API_URL}/browser/features/${profileId}/profile-params-for-orbita-token`, {
178
+ method: 'GET'
179
+ }, {
180
+ token: this.access_token,
181
+ fallbackUrl: `${_common.FALLBACK_API_URL}/browser/features/${profileId}/profile-params-for-orbita-token`
182
+ });
183
+ return JSON.parse(tokenRes);
184
+ }
185
+ composeClientGologinOpts(gologinSettings) {
186
+ const clonedOpts = structuredClone(gologinSettings);
187
+ _browser.securedOrbitaOpts.forEach(field => delete clonedOpts[field]);
188
+ return clonedOpts;
189
+ }
178
190
  async getProfileS3() {
179
191
  const token = this.access_token;
180
192
  debug('getProfileS3 token=', token, 'profile=', this.profile_id);
@@ -310,7 +322,7 @@ class GoLogin {
310
322
  id: this._tz && this._tz.timezone || ''
311
323
  }
312
324
  };
313
- if (this.browserMajorVersion >= this.newProxyOrbbitaMajorVersion && profileData.proxy?.mode !== 'none') {
325
+ if (this.browserMajorVersion >= this.newProxyOrbitaMajorVersion && profileData.proxy?.mode !== 'none') {
314
326
  let proxyServer = `${profileData.proxy.mode}://`;
315
327
  if (profileData.proxy.username) {
316
328
  const encodedUsername = encodeURIComponent(profileData.proxy.username || '');
@@ -431,6 +443,29 @@ class GoLogin {
431
443
  this.browserMajorVersion = latestVersionNumber;
432
444
  await this.checkBrowser(latestVersionNumber);
433
445
  }
446
+ } else if (!this.browserMajorVersion) {
447
+ const {
448
+ userAgent
449
+ } = profile.navigator;
450
+ const [browserMajorVersion] = userAgent.split('Chrome/')[1].split('.');
451
+ this.browserMajorVersion = Number(browserMajorVersion);
452
+ let executableDir = (0, _path.join)(this.executablePath, '..');
453
+ if (OS_PLATFORM === 'darwin') {
454
+ executableDir = (0, _path.join)(this.executablePath, '..', '..', '..');
455
+ }
456
+ const versionFilePath = (0, _path.join)(executableDir, 'version');
457
+ try {
458
+ await access(versionFilePath);
459
+ const versionContent = await readFile(versionFilePath, 'utf8');
460
+ const versionFromFile = versionContent.trim();
461
+ const isValidVersion = /^\d+\.\d+\.\d+/.test(versionFromFile);
462
+ if (isValidVersion) {
463
+ const [browserMajorVersion] = isValidVersion.split('.');
464
+ this.browserMajorVersion = Number(browserMajorVersion);
465
+ }
466
+ } catch (error) {
467
+ console.warn('Error reading version file:', error);
468
+ }
434
469
  }
435
470
  const {
436
471
  navigator = {},
@@ -441,10 +476,8 @@ class GoLogin {
441
476
  this.profileOs = profileOs;
442
477
  this.differentOs = profileOs !== 'android' && (OS_PLATFORM === 'win32' && profileOs !== 'win' || OS_PLATFORM === 'darwin' && profileOs !== 'mac' || OS_PLATFORM === 'linux' && profileOs !== 'lin');
443
478
  const {
444
- resolution = '1920x1080',
445
- language = 'en-US,en;q=0.9'
479
+ resolution = '1920x1080'
446
480
  } = navigator;
447
- this.language = language;
448
481
  const [screenWidth, screenHeight] = resolution.split('x');
449
482
  this.resolution = {
450
483
  width: parseInt(screenWidth, 10),
@@ -563,27 +596,39 @@ class GoLogin {
563
596
  console.trace(e);
564
597
  }
565
598
  }
566
- if (preferences.gologin == null) {
599
+ if (preferences.gologin === null) {
567
600
  preferences.gologin = {};
568
601
  }
569
602
  const isMAC = OS_PLATFORM === 'darwin';
570
603
  const checkAutoLangResult = (0, _browser.checkAutoLang)(gologin, this._tz, profile.autoLang);
571
604
  const intlConfig = (0, _browser.getIntlProfileConfig)(profile, this._tz, profile.autoLang);
572
- await writeFile((0, _path.join)(profilePath, 'orbita.config'), JSON.stringify({
573
- intl: intlConfig
574
- }, null, '\t'), {
575
- encoding: 'utf-8'
576
- }).catch(console.log);
605
+ let orbitaParamsToken = '';
606
+ if (profile.securedOrbitaVersion && this.browserMajorVersion >= profile.securedOrbitaVersion) {
607
+ const tokenRes = await this.requestOrbitaProfileParamsToken(this.profile_id);
608
+ orbitaParamsToken = tokenRes.token;
609
+ }
577
610
  this.browserLang = isMAC ? 'en-US' : checkAutoLangResult;
578
611
  const prefsToWrite = Object.assign(preferences, {
579
612
  gologin
580
613
  });
581
- if (this.browserMajorVersion >= this.newProxyOrbbitaMajorVersion && this.proxy?.mode !== 'none') {
614
+ if (this.browserMajorVersion >= this.newProxyOrbitaMajorVersion && this.proxy?.mode !== 'none') {
582
615
  prefsToWrite.proxy = {
583
616
  mode: 'fixed_servers',
584
617
  server: gologin.proxy.server
585
618
  };
586
619
  }
620
+ const clientGologinOpts = this.composeClientGologinOpts(prefsToWrite.gologin);
621
+ const orbitaConfig = {
622
+ intl: intlConfig,
623
+ gologin: {
624
+ api_domain: _common.API_URL,
625
+ profile_token: orbitaParamsToken,
626
+ ...clientGologinOpts
627
+ }
628
+ };
629
+ await writeFile((0, _path.join)(profilePath, 'orbita.config'), JSON.stringify(orbitaConfig, null, '\t'), {
630
+ encoding: 'utf-8'
631
+ }).catch(console.log);
587
632
  await writeFile((0, _path.join)(profilePath, 'Default', 'Preferences'), JSON.stringify(prefsToWrite));
588
633
  const bookmarksParsedData = await (0, _utils.getCurrentProfileBookmarks)(this.bookmarksFilePath);
589
634
  const bookmarksFromDb = profile.bookmarks?.bookmark_bar;
@@ -837,10 +882,10 @@ class GoLogin {
837
882
  params.push(arg);
838
883
  }
839
884
  if (proxy) {
840
- const hr_rules = `"MAP * 0.0.0.0 , EXCLUDE ${proxy_host}"`;
885
+ const hr_rules = `"MAP * 0.0.0.0 , EXCLUDE ${proxy_host} , EXCLUDE api.gologin.com"`;
841
886
  params.push(`--host-resolver-rules=${hr_rules}`);
842
887
  }
843
- if (proxy && Number(this.browserMajorVersion) < this.newProxyOrbbitaMajorVersion) {
888
+ if (proxy && Number(this.browserMajorVersion) < this.newProxyOrbitaMajorVersion) {
844
889
  params.push(`--proxy-server=${proxy}`);
845
890
  }
846
891
  if (Array.isArray(this.extra_params) && this.extra_params.length) {
@@ -909,9 +954,12 @@ class GoLogin {
909
954
  async uploadProfileDataToServer() {
910
955
  const cookies = await (0, _cookiesManager.loadCookiesFromFile)(this.cookiesFilePath, false, this.profile_id, this.tmpdir);
911
956
  const bookmarks = await (0, _utils.getCurrentProfileBookmarks)(this.bookmarksFilePath);
957
+ const profilePreferencesPath = (0, _path.join)(this.profilePath(), 'Default', 'Preferences');
958
+ const extensions = await (0, _getExtensions.getProfileChromeExtensions)(profilePreferencesPath).catch(() => null);
912
959
  const body = {
913
960
  cookies,
914
- bookmarks,
961
+ bookmarks: bookmarks.roots,
962
+ extensionsIds: extensions,
915
963
  isCookiesEncrypted: true,
916
964
  isStorageGateway: true
917
965
  };
@@ -1009,12 +1057,6 @@ class GoLogin {
1009
1057
  debug('createProfile', options);
1010
1058
  const fingerprint = await this.getRandomFingerprint(options);
1011
1059
  debug('fingerprint=', fingerprint);
1012
- if (fingerprint.statusCode === 500) {
1013
- throw new Error('no valid random fingerprint check os param');
1014
- }
1015
- if (fingerprint.statusCode === 401) {
1016
- throw new Error('invalid token');
1017
- }
1018
1060
  const {
1019
1061
  navigator,
1020
1062
  fonts,
@@ -1338,9 +1380,6 @@ class GoLogin {
1338
1380
  token: this.access_token,
1339
1381
  fallbackUrl: `${_common.FALLBACK_API_URL}/browser/v2`
1340
1382
  });
1341
- if (profilesResponse.statusCode !== 200) {
1342
- throw new Error('Gologin /browser response error');
1343
- }
1344
1383
  return JSON.parse(profilesResponse);
1345
1384
  }
1346
1385
  async getNewFingerPrint(os) {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getIntlProfileConfig = exports.checkAutoLang = void 0;
6
+ exports.securedOrbitaOpts = exports.getIntlProfileConfig = exports.checkAutoLang = void 0;
7
7
  const checkAutoLang = (profileData, timezoneCheckResult, autoLang) => {
8
8
  if (!autoLang) {
9
9
  return checkBrowserLang(profileData);
@@ -100,4 +100,5 @@ const getMainLanguage = langArr => {
100
100
  }
101
101
  }
102
102
  return '';
103
- };
103
+ };
104
+ const securedOrbitaOpts = exports.securedOrbitaOpts = ['webGpu', 'webgl', 'webglParams', 'webRTC', 'webrtc', 'mediaDevices', 'plugins', 'audioContext', 'canvasMode', 'canvasNoise', 'webgl_noice_enable', 'webglNoiceEnable', 'webgl_noise_enable', 'client_rects_noise_enable', 'webgl_noise_value', 'webglNoiseValue', 'getClientRectsNoice', 'get_client_rects_noise'];
@@ -17,6 +17,8 @@ const CHROME_EXT_DIR_NAME = 'chrome-extensions';
17
17
  const EXTENSIONS_PATH = (0, _path.join)(HOMEDIR, '.gologin', 'extensions');
18
18
  const CHROME_EXTENSIONS_PATH = (0, _path.join)(EXTENSIONS_PATH, CHROME_EXT_DIR_NAME);
19
19
  const USER_EXTENSIONS_PATH = (0, _path.join)(HOMEDIR, '.gologin', 'extensions', 'user-extensions');
20
+ const PLATFORM = process.platform;
21
+ const ARCH = process.arch;
20
22
  const composeExtractionPromises = (filteredArchives, destPath = CHROME_EXTENSIONS_PATH) => filteredArchives.map(extArchivePath => {
21
23
  const [archiveName = ''] = extArchivePath.split(_path.sep).reverse();
22
24
  const [destFolder] = archiveName.split('.');
@@ -63,13 +65,13 @@ const getOsAdvanced = async () => {
63
65
  };
64
66
  };
65
67
  const getOS = () => {
66
- if (process.platform === 'win32') {
68
+ if (PLATFORM === 'win32') {
67
69
  return 'win';
68
70
  }
69
- if (process.platform === 'darwin') {
70
- return process.arch === 'arm64' ? 'macM1' : 'mac';
71
+ if (PLATFORM === 'darwin') {
72
+ return ARCH === 'arm64' ? 'macM1' : 'mac';
71
73
  }
72
- return 'lin';
74
+ return ARCH === 'arm64' ? 'linArm' : 'lin';
73
75
  };
74
76
  const _composeExtractionPromises = exports.composeExtractionPromises = composeExtractionPromises;
75
77
  const _getOS = exports.getOS = getOS;
@@ -6,7 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.makeRequest = exports.checkSocksProxy = void 0;
7
7
  var _https = require("https");
8
8
  var _requestretry = _interopRequireDefault(require("requestretry"));
9
+ var _package = _interopRequireDefault(require("../../package.json"));
9
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const {
12
+ version
13
+ } = _package.default;
10
14
  const TIMEZONE_URL = 'https://geo.myip.link';
11
15
  const createTimeoutPromise = timeoutMs => new Promise((_, reject) => {
12
16
  setTimeout(() => {
@@ -29,10 +33,10 @@ const attemptRequest = async (requestUrl, options) => {
29
33
  }
30
34
  return req.body;
31
35
  };
32
- const makeRequest = async (url, options, internalOptions) => {
36
+ const makeRequest = async (url, options = {}, internalOptions) => {
33
37
  options.headers = {
34
38
  ...options.headers,
35
- 'User-Agent': 'gologin-nodejs-sdk'
39
+ 'User-Agent': `gologin-nodejs-sdk/${version}`
36
40
  };
37
41
  if (internalOptions?.token) {
38
42
  options.headers = {
@@ -86,14 +86,14 @@ const captureGroupedSentryError = (error, context = {}) => {
86
86
  };
87
87
  break;
88
88
  }
89
- Sentry.withScope(scope => {
89
+ Sentry.captureException(error, scope => {
90
90
  scope.setFingerprint(fingerprint);
91
+ scope.setTransactionName(fingerprint);
91
92
  scope.setTags(tags);
92
93
  scope.setContext('errorDetails', {
93
94
  originalMessage: errorMessage,
94
95
  ...context
95
96
  });
96
- Sentry.captureException(error);
97
97
  });
98
98
  };
99
99
  exports.captureGroupedSentryError = captureGroupedSentryError;
@@ -9,6 +9,7 @@ import ProgressBar from 'progress';
9
9
  import util from 'util';
10
10
 
11
11
  import { API_URL, getOS } from '../utils/common.js';
12
+ import { makeRequest } from '../utils/http.js';
12
13
  import BrowserDownloadLockManager from './browser-download-manager.js';
13
14
 
14
15
  const exec = util.promisify(execNonPromise);
@@ -121,6 +122,8 @@ export class BrowserChecker {
121
122
  return `https://orbita-browser-windows.gologin.com/orbita-browser-latest-${majorVersion}.zip`;
122
123
  case 'macM1':
123
124
  return `https://orbita-browser-mac-arm.gologin.com/orbita-browser-latest-${majorVersion}.tar.gz`;
125
+ case 'linArm':
126
+ return `https://orbita-browser-linux-arm.gologin.com/orbita-browser-latest-${majorVersion}.tar.gz`;
124
127
  default:
125
128
  return `https://orbita-browser-linux.gologin.com/orbita-browser-latest-${majorVersion}.tar.gz`;
126
129
  }
@@ -358,24 +361,11 @@ export class BrowserChecker {
358
361
 
359
362
  getLatestBrowserVersion() {
360
363
  const userOs = getOS();
364
+ const options = {
365
+ json: true,
366
+ };
361
367
 
362
- return new Promise(resolve => get(`${API_URL}/gologin-global-settings/latest-browser-info?os=${userOs}`,
363
- {
364
- timeout: 15 * 1000,
365
- headers: {
366
- 'Content-Type': 'application/json',
367
- 'User-Agent': 'gologin-api',
368
- },
369
- }, (res) => {
370
- res.setEncoding('utf8');
371
-
372
- let resultResponse = '';
373
- res.on('data', (data) => resultResponse += data);
374
-
375
- res.on('end', () => {
376
- resolve(JSON.parse(resultResponse.trim()));
377
- });
378
- }).on('error', (err) => resolve('')));
368
+ return makeRequest(`${API_URL}/gologin-global-settings/latest-browser-info?os=${userOs}`, options);
379
369
  }
380
370
 
381
371
  get getOrbitaPath() {
@@ -10,8 +10,8 @@ import { makeRequest } from '../utils/http.js';
10
10
 
11
11
  const { access, readFile, writeFile, mkdir, readdir, copyFile, rename } = _promises;
12
12
 
13
- const __filename = fileURLToPath(import.meta.url);
14
- const __dirname = dirname(__filename);
13
+ const __filename = typeof __filename !== 'undefined' ? __filename : fileURLToPath(import.meta.url);
14
+ const __dirname = typeof __dirname !== 'undefined' ? __dirname : dirname(__filename || process.cwd());
15
15
 
16
16
  const FONTS_URL = 'https://fonts.gologin.com/';
17
17
  const FONTS_DIR_NAME = 'fonts';
@@ -0,0 +1,42 @@
1
+ import { readFile } from 'fs/promises';
2
+
3
+ export const getProfileChromeExtensions = async (profilePreferencesPath) => {
4
+ const profileChromeExtensions = [];
5
+ if (!profilePreferencesPath) {
6
+ return profileChromeExtensions;
7
+ }
8
+
9
+ const fileContent = await readFile(profilePreferencesPath, 'utf-8');
10
+ const settings = JSON.parse(fileContent);
11
+ const extensionsSettingsObj = settings?.extensions || { settings: {} };
12
+ const extensionsSettings = extensionsSettingsObj.settings || {};
13
+ const extensionsEntries = Object.entries(extensionsSettings);
14
+ if (!extensionsEntries.length) {
15
+ return profileChromeExtensions;
16
+ }
17
+
18
+ const currentExtensions = [];
19
+
20
+ extensionsEntries.forEach((extensionObj) => {
21
+ const [extensionsId, extensionsContent] = extensionObj;
22
+ const { path: extPath = '' } = extensionsContent;
23
+ const formattedPath = extPath.replace(/\\|@/g, '/');
24
+ const regex = new RegExp(`^${extensionsId}|(?:chrome-extensions|user-extensions)/\\w+`);
25
+ const pathMatch = formattedPath.match(regex);
26
+
27
+ if (!pathMatch) {
28
+ return;
29
+ }
30
+
31
+ currentExtensions.push(extensionsId);
32
+ const [matched] = pathMatch;
33
+ const [originalExtId] = matched.split('/').reverse();
34
+ if (profileChromeExtensions.includes(originalExtId)) {
35
+ return;
36
+ }
37
+
38
+ profileChromeExtensions.push(originalExtId);
39
+ });
40
+
41
+ return profileChromeExtensions;
42
+ };
@@ -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);