gologin 1.0.29 → 1.0.30

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/README.md CHANGED
@@ -18,7 +18,7 @@ for running example.js install puppeteer-core
18
18
  Where is token? API token is <a href="https://app.gologin.com/#/personalArea/TokenApi" target="_blank">here</a>.
19
19
  To have an access to the page below you need <a href="https://app.gologin.com/#/createUser" target="_blank">register</a> GoLogin account.
20
20
 
21
- ![Token API in Settings](https://user-images.githubusercontent.com/62306291/78453427-53220100-769a-11ea-9465-0aae3ae602b7.jpg)
21
+ ![Token API in Settings](https://user-images.githubusercontent.com/12957968/146891933-c3b60b4d-c850-47a5-8adf-bc8c37372664.gif)
22
22
 
23
23
  ### Example
24
24
 
@@ -1,7 +1,9 @@
1
1
  const puppeteer = require('puppeteer-core');
2
2
  const GoLogin = require('../gologin');
3
3
 
4
- (async () =>{
4
+ const delay = (time) => new Promise((resolve) => setTimeout(resolve, time));
5
+
6
+ (async () =>{
5
7
  const GL = new GoLogin({
6
8
  token: 'yU0token',
7
9
  profile_id: 'yU0Pr0f1leiD',
@@ -14,6 +16,7 @@ const GoLogin = require('../gologin');
14
16
  });
15
17
 
16
18
  const page = await browser.newPage();
19
+ await delay(300);
17
20
 
18
21
  const viewPort = GL.getViewPort();
19
22
  await page.setViewport({ width: Math.round(viewPort.width * 0.994), height: Math.round(viewPort.height * 0.92) });
package/gologin.js CHANGED
@@ -359,6 +359,11 @@ class GoLogin {
359
359
  profile.proxy.password = _.get(profile, 'autoProxyPassword');
360
360
  }
361
361
  // console.log('proxy=', proxy);
362
+
363
+ if (proxy.mode === 'geolocation') {
364
+ proxy.mode = 'http';
365
+ }
366
+
362
367
  if (proxy.mode === 'none') {
363
368
  proxy = null;
364
369
  }
@@ -501,6 +506,7 @@ class GoLogin {
501
506
  }
502
507
 
503
508
  async getTimeZone(proxy) {
509
+ debug('getting timeZone proxy=', proxy);
504
510
  if(this.timezone){
505
511
  debug('getTimeZone from options', this.timezone);
506
512
  this._tz = this.timezone;
@@ -508,16 +514,16 @@ class GoLogin {
508
514
  }
509
515
 
510
516
  let data = null;
511
- if (proxy) {
517
+ if (proxy!==null && proxy.mode !== "none") {
512
518
  if (proxy.mode.includes('socks')) {
513
519
  return this.getTimezoneWithSocks(proxy);
514
520
  }
515
521
 
516
522
  const proxyUrl = `${proxy.mode}://${proxy.username}:${proxy.password}@${proxy.host}:${proxy.port}`;
517
523
  debug('getTimeZone start https://time.gologin.com', proxyUrl);
518
- data = await requests.get('https://time.gologin.com', { proxy: proxyUrl, timeout: 10 * 1000, maxAttempts: 2 });
524
+ data = await requests.get('https://time.gologin.com', { proxy: proxyUrl, timeout: 20 * 1000, maxAttempts: 5 });
519
525
  } else {
520
- data = await requests.get('https://time.gologin.com', { timeout: 10 * 1000, maxAttempts: 2 });
526
+ data = await requests.get('https://time.gologin.com', { timeout: 20 * 1000, maxAttempts: 5 });
521
527
  }
522
528
  debug('getTimeZone finish', data.body);
523
529
  this._tz = JSON.parse(data.body);
@@ -1036,6 +1042,12 @@ class GoLogin {
1036
1042
  if (!this.executablePath) {
1037
1043
  await this.checkBrowser();
1038
1044
  }
1045
+
1046
+ const ORBITA_BROWSER = this.executablePath || this.browserChecker.getOrbitaPath;
1047
+
1048
+ if(!fs.existsSync(ORBITA_BROWSER)){
1049
+ throw new Error(`Orbita browser is not exists on path ${ORBITA_BROWSER}, check executablePath param`);
1050
+ }
1039
1051
 
1040
1052
  await this.createStartup();
1041
1053
  // await this.createBrowserExtension();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "description": "A high-level API to control Orbita browser over GoLogin API",
5
5
  "main": "./gologin.js",
6
6
  "repository": {
@@ -45,7 +45,7 @@ class GoLogin(object):
45
45
  proxy = self.proxy
46
46
  proxy_host = ''
47
47
  if proxy:
48
- if proxy.get('mode')==None:
48
+ if proxy.get('mode')==None or proxy.get('mode')=='geolocation':
49
49
  proxy['mode'] = 'http'
50
50
  proxy_host = proxy.get('host')
51
51
  proxy = self.formatProxyUrl(proxy)