gologin 1.0.25 → 1.0.29

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.
@@ -34,7 +34,7 @@ class CookiesManager {
34
34
  const queryParams = cookies.flatMap((cookie) => {
35
35
  const creationDate = cookie.creationDate ? cookie.creationDate : this.unixToLDAP(todayUnix);
36
36
  let expirationDate = cookie.session ? 0 : this.unixToLDAP(cookie.expirationDate);
37
- const encryptedValue = Buffer.concat([Buffer.from('v11'), Buffer.from(encrypt(cookie.value), 'binary')]);
37
+ const encryptedValue = cookie.value;
38
38
  const samesite = Object.keys(SAME_SITE).find((key) => SAME_SITE[key] === (cookie.sameSite || '-1'));
39
39
  const isSecure =
40
40
  cookie.name.startsWith('__Host-') || cookie.name.startsWith('__Secure-') ? 1 : Number(cookie.secure);
@@ -5,7 +5,7 @@ const GoLogin = require('../gologin');
5
5
  const GL = new GoLogin({
6
6
  token: 'yU0token',
7
7
  profile_id: 'yU0Pr0f1leiD',
8
- extra_params: ['--headless'],
8
+ extra_params: ['--headless', '--no-sandbox'],
9
9
  });
10
10
  const {status, wsUrl} = await GL.start();
11
11
  const browser = await puppeteer.connect({
package/gologin.js CHANGED
@@ -8,7 +8,7 @@ const rimraf = util.promisify(require('rimraf'));
8
8
  const exec = util.promisify(require('child_process').exec);
9
9
  const { spawn, execFile } = require('child_process');
10
10
  const FormData = require('form-data');
11
- const socks5Http = require('socks5-https-client');
11
+ const ProxyAgent = require('simple-proxy-agent');
12
12
  const decompress = require('decompress');
13
13
  const decompressUnzip = require('decompress-unzip');
14
14
  const path = require('path');
@@ -18,6 +18,7 @@ const BrowserChecker = require('./browser-checker');
18
18
  const { BrowserUserDataManager } = require('./browser-user-data-manager');
19
19
  const { CookiesManager } = require('./cookies-manager');
20
20
  const fontsCollection = require('./fonts');
21
+ const https = require('https');
21
22
 
22
23
  const SEPARATOR = path.sep;
23
24
  const API_URL = 'https://api.gologin.com';
@@ -46,7 +47,6 @@ class GoLogin {
46
47
  this.browserChecker = new BrowserChecker();
47
48
  this.uploadCookiesToServer = options.uploadCookiesToServer || false;
48
49
  this.writeCookesFromServer = options.writeCookesFromServer || true;
49
- this.cookiesFilePath = path.join(os.tmpdir(), `gologin_profile_${this.profile_id}`, 'Default', 'Cookies');
50
50
  this.remote_debugging_port = options.remote_debugging_port || 0;
51
51
  this.timezone = options.timezone;
52
52
 
@@ -58,6 +58,7 @@ class GoLogin {
58
58
  }
59
59
  }
60
60
 
61
+ this.cookiesFilePath = path.join(this.tmpdir, `gologin_profile_${this.profile_id}`, 'Default', 'Cookies');
61
62
  this.profile_zip_path = path.join(this.tmpdir, `gologin_${this.profile_id}.zip`);
62
63
  debug('INIT GOLOGIN', this.profile_id);
63
64
  }
@@ -66,6 +67,7 @@ class GoLogin {
66
67
 
67
68
  async setProfileId(profile_id) {
68
69
  this.profile_id = profile_id;
70
+ this.cookiesFilePath = path.join(this.tmpdir, `gologin_profile_${this.profile_id}`, 'Default', 'Cookies');
69
71
  this.profile_zip_path = path.join(this.tmpdir, `gologin_${this.profile_id}.zip`);
70
72
  }
71
73
 
@@ -122,7 +124,7 @@ class GoLogin {
122
124
  })
123
125
  debug(profileResponse.body);
124
126
  if (profileResponse.statusCode !== 200) {
125
- throw new Error(`Gologin /browser/${id} response error ${profileResponse.statusCode}`);
127
+ throw new Error(`Gologin /browser/${id} response error ${profileResponse.statusCode} INVALID TOKEN OR PROFILE NOT FOUND`);
126
128
  }
127
129
 
128
130
  if(profileResponse.statusCode == 401){
@@ -384,6 +386,8 @@ class GoLogin {
384
386
  publicIP: _.get(profile, 'webRTC.fillBasedOnIp') ? this._tz.ip : _.get(profile, 'webRTC.publicIp'),
385
387
  localIps: _.get(profile, 'webRTC.localIps', []),
386
388
  };
389
+
390
+ debug('profile.webRtc=', profile.webRtc);
387
391
 
388
392
  const audioContext = profile.audioContext || {};
389
393
  const { mode: audioCtxMode = 'off', noise: audioCtxNoise } = audioContext;
@@ -520,35 +524,31 @@ class GoLogin {
520
524
  return this._tz.timezone;
521
525
  }
522
526
 
523
- async getTimezoneWithSocks(proxy) {
524
- const { host, port, username, password } = proxy;
527
+ async getTimezoneWithSocks(params) {
528
+ const { mode = 'http', host, port, username = '', password = '' } = params;
525
529
  let body;
526
530
 
527
- const checkData = await new Promise((resolve, reject) => {
528
- const timer = setTimeout(() => {
529
- req.abort();
530
- reject(new Error('Timeout exceeded'));
531
- }, 10000);
532
-
533
- const req = socks5Http.get({
534
- hostname: 'time.gologin.com',
535
- path: '/timezone',
536
- socksHost: host,
537
- socksPort: port,
538
- socksUsername: username || '',
539
- socksPassword: password || '',
540
- }, (res) => {
541
- res.setEncoding('utf8');
531
+ let proxy = mode + '://';
532
+ if (username) {
533
+ const resultPassword = password ? ':' + password + '@' : '@';
534
+ proxy += username + resultPassword;
535
+ }
536
+ proxy += host + ':' + port;
537
+
538
+ const agent = new ProxyAgent(proxy, { tunnel: true, timeout: 10000 });
542
539
 
540
+ const checkData = await new Promise((resolve, reject) => {
541
+ https.get('https://time.gologin.com/timezone', { agent }, (res) => {
543
542
  let resultResponse = '';
544
543
  res.on('data', (data) => resultResponse += data);
545
544
 
546
545
  res.on('end', () => {
547
- clearTimeout(timer);
548
546
  let parsedData;
549
547
  try {
550
548
  parsedData = JSON.parse(resultResponse);
551
- } catch (e) {}
549
+ } catch (e) {
550
+ reject(e);
551
+ }
552
552
 
553
553
  resolve({
554
554
  ...res,
@@ -558,14 +558,13 @@ class GoLogin {
558
558
  }).on('error', (err) => reject(err));
559
559
  });
560
560
 
561
- console.log('checkData:', checkData);
561
+ // console.log('checkData:', checkData);
562
562
  body = checkData.body || {};
563
563
  if (!body.ip && checkData.statusCode.toString().startsWith('4')) {
564
564
  throw checkData;
565
565
  }
566
566
  debug('getTimeZone finish', body.body);
567
567
  this._tz = body;
568
-
569
568
  return this._tz.timezone;
570
569
  }
571
570
 
@@ -697,7 +696,7 @@ class GoLogin {
697
696
  await rimraf(path.join(this.tmpdir, `gologin_${this.profile_id}_upload.zip`));
698
697
  }
699
698
 
700
- async stopAndCommit(options, local= false) {
699
+ async stopAndCommit(options, local = false) {
701
700
  if (this.is_stopping) {
702
701
  return true;
703
702
  }
@@ -1060,12 +1059,12 @@ class GoLogin {
1060
1059
  return this.stopRemote();
1061
1060
  }
1062
1061
 
1063
- await this.stopAndCommit(false, {});
1062
+ await this.stopAndCommit({ posting: false }, false);
1064
1063
  }
1065
1064
 
1066
1065
  async stopLocal(options) {
1067
- const opts = options || {posting: false};
1068
- await this.stopAndCommit(true, opts.posting);
1066
+ const opts = options || { posting: false };
1067
+ await this.stopAndCommit(options, true);
1069
1068
  }
1070
1069
 
1071
1070
  async waitDebuggingUrl(delay_ms, try_count=0) {
@@ -1112,6 +1111,28 @@ class GoLogin {
1112
1111
  }
1113
1112
 
1114
1113
  if (profileResponse.body === 'ok') {
1114
+ const profile = await this.getProfile();
1115
+ const { navigator = {}, fonts, os: profileOs } = profile;
1116
+ this.fontsMasking = fonts?.enableMasking;
1117
+ this.profileOs = profileOs;
1118
+ this.differentOs =
1119
+ profileOs !== 'android' && (
1120
+ OS_PLATFORM === 'win32' && profileOs !== 'win' ||
1121
+ OS_PLATFORM === 'darwin' && profileOs !== 'mac' ||
1122
+ OS_PLATFORM === 'linux' && profileOs !== 'lin'
1123
+ );
1124
+
1125
+ const {
1126
+ resolution = '1920x1080',
1127
+ language = 'en-US,en;q=0.9',
1128
+ } = navigator;
1129
+ this.language = language;
1130
+ const [screenWidth, screenHeight] = resolution.split('x');
1131
+ this.resolution = {
1132
+ width: parseInt(screenWidth, 10),
1133
+ height: parseInt(screenHeight, 10),
1134
+ };
1135
+
1115
1136
  let wsUrl = await this.waitDebuggingUrl(delay_ms);
1116
1137
  return { 'status': 'success', wsUrl }
1117
1138
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin",
3
- "version": "1.0.25",
3
+ "version": "1.0.29",
4
4
  "description": "A high-level API to control Orbita browser over GoLogin API",
5
5
  "main": "./gologin.js",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "rimraf": "^3.0.2",
28
28
  "selenium-webdriver": "^4.0.0-alpha.7",
29
29
  "shelljs": "^0.8.4",
30
- "socks5-https-client": "^1.2.1",
30
+ "simple-proxy-agent": "^1.1.0",
31
31
  "sqlite": "^4.0.23",
32
32
  "sqlite3": "^5.0.2"
33
33
  },