gologin 1.0.29 → 1.0.33

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
 
@@ -260,7 +260,8 @@ class BrowserChecker {
260
260
  async replaceBrowser() {
261
261
  console.log('Copy Orbita to target path');
262
262
  if (PLATFORM === 'darwin') {
263
- await rmdir(path.join(this.#browserPath, 'Orbita-Browser.app'), { recursive: true });
263
+ await this.deleteDir(path.join(this.#browserPath, 'Orbita-Browser.app'));
264
+
264
265
  const files = await readdir(path.join(this.#browserPath, EXTRACTED_FOLDER));
265
266
  const promises = [];
266
267
  files.forEach((filename) => {
@@ -268,22 +269,25 @@ class BrowserChecker {
268
269
  promises.push(copyFile(path.join(this.#browserPath, EXTRACTED_FOLDER, filename), path.join(this.#browserPath, filename)));
269
270
  }
270
271
  });
272
+
271
273
  return Promise.all(promises);
272
- } else {
273
- await rmdir(path.join(this.#browserPath, 'orbita-browser'), { recursive: true });
274
- await this.copyDir(
275
- path.join(this.#browserPath, EXTRACTED_FOLDER, 'orbita-browser'),
276
- path.join(this.#browserPath, 'orbita-browser')
277
- );
278
274
  }
275
+
276
+ const targetBrowserPath = path.join(this.#browserPath, 'orbita-browser');
277
+ await this.deleteDir(targetBrowserPath);
278
+
279
+ await this.copyDir(
280
+ path.join(this.#browserPath, EXTRACTED_FOLDER, 'orbita-browser'),
281
+ targetBrowserPath
282
+ );
279
283
  }
280
284
 
281
285
  async deleteOldArchives(deleteCurrentBrowser = false) {
282
286
  if (deleteCurrentBrowser) {
283
- return await rmdir(path.join(this.#browserPath), { recursive: true });
287
+ return this.deleteDir(path.join(this.#browserPath));
284
288
  }
285
289
 
286
- await rmdir(path.join(this.#browserPath, EXTRACTED_FOLDER), { recursive: true });
290
+ await this.deleteDir(path.join(this.#browserPath, EXTRACTED_FOLDER));
287
291
  return readdir(this.#browserPath)
288
292
  .then((files) => {
289
293
  const promises = [];
@@ -355,6 +359,19 @@ class BrowserChecker {
355
359
  get getOrbitaPath() {
356
360
  return this.#executableFilePath;
357
361
  }
362
+
363
+ async deleteDir(path = '') {
364
+ if (!path) {
365
+ return;
366
+ }
367
+
368
+ const directoryExists = await access(path).then(() => true).catch(() => false);
369
+ if (!directoryExists) {
370
+ return;
371
+ }
372
+
373
+ return rmdir(path, { recursive: true });
374
+ }
358
375
  }
359
376
 
360
377
  module.exports = BrowserChecker;
@@ -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
@@ -5,6 +5,7 @@ const fs = require('fs');
5
5
  const os = require('os');
6
6
  const util = require('util');
7
7
  const rimraf = util.promisify(require('rimraf'));
8
+ const { access, unlink, writeFile, readFile } = require('fs').promises;
8
9
  const exec = util.promisify(require('child_process').exec);
9
10
  const { spawn, execFile } = require('child_process');
10
11
  const FormData = require('form-data');
@@ -12,7 +13,7 @@ const ProxyAgent = require('simple-proxy-agent');
12
13
  const decompress = require('decompress');
13
14
  const decompressUnzip = require('decompress-unzip');
14
15
  const path = require('path');
15
- const shell = require('shelljs');
16
+ const zipdir = require('zip-dir');
16
17
 
17
18
  const BrowserChecker = require('./browser-checker');
18
19
  const { BrowserUserDataManager } = require('./browser-user-data-manager');
@@ -54,7 +55,7 @@ class GoLogin {
54
55
  this.tmpdir = options.tmpdir;
55
56
  if (!fs.existsSync(this.tmpdir)) {
56
57
  debug('making tmpdir', this.tmpdir);
57
- shell.mkdir('-p', this.tmpdir);
58
+ fs.mkdirSync(this.tmpdir, { recursive: true })
58
59
  }
59
60
  }
60
61
 
@@ -127,7 +128,7 @@ class GoLogin {
127
128
  throw new Error(`Gologin /browser/${id} response error ${profileResponse.statusCode} INVALID TOKEN OR PROFILE NOT FOUND`);
128
129
  }
129
130
 
130
- if(profileResponse.statusCode == 401){
131
+ if (profileResponse.statusCode === 401) {
131
132
  throw new Error("invalid token");
132
133
  }
133
134
 
@@ -135,77 +136,86 @@ class GoLogin {
135
136
  }
136
137
 
137
138
  async emptyProfile() {
138
- return fs.readFileSync(path.resolve(__dirname, 'gologin_zeroprofile.b64')).toString();
139
+ return readFile(path.resolve(__dirname, 'gologin_zeroprofile.b64')).then(res => res.toString());
139
140
  }
140
141
 
141
142
  async getProfileS3(s3path) {
143
+ if (!s3path) {
144
+ throw new Error('s3path not found');
145
+ }
146
+
142
147
  const token = this.access_token;
143
148
  debug('getProfileS3 token=', token, 'profile=', this.profile_id, 's3path=', s3path);
144
- if (s3path) { //загрузка профиля из публичного бакета s3 быстрее
145
- const s3url = `https://gprofiles.gologin.com/${s3path}`.replace(/\s+/mg, '+');
146
- debug('loading profile from public s3 bucket, url=', s3url);
147
- const profileResponse = await requests.get(s3url, {
148
- encoding: null
149
- });
150
- if (profileResponse.statusCode !== 200) {
151
- debug(`Gologin S3 BUCKET ${s3url} response error ${profileResponse.statusCode} - use empty`);
152
- return '';
153
- }
154
- return Buffer.from(profileResponse.body);
155
- }
156
149
 
157
- debug('old-way loading profile');
158
- const profileResponse = await requests.get(`${API_URL}/browser/${this.profile_id}/profile-s3`, {
159
- headers: {
160
- 'Authorization': `Bearer ${token}`,
161
- },
150
+ const s3url = `https://gprofiles.gologin.com/${s3path}`.replace(/\s+/mg, '+');
151
+ debug('loading profile from public s3 bucket, url=', s3url);
152
+ const profileResponse = await requests.get(s3url, {
162
153
  encoding: null
163
154
  });
155
+
164
156
  if (profileResponse.statusCode !== 200) {
165
- debug(`Gologin /browser/${this.profile_id} response error ${profileResponse.statusCode} - use empty`);
157
+ debug(`Gologin S3 BUCKET ${s3url} response error ${profileResponse.statusCode} - use empty`);
166
158
  return '';
167
159
  }
160
+
168
161
  return Buffer.from(profileResponse.body);
169
162
  }
170
163
 
171
- async postFile(fileName, fileBody) {
172
- debug('POSTING FILE', fileBody.length);
173
- const fd = new FormData();
174
- const boundary = fd.getBoundary();
175
- const body = Buffer.concat([
176
- Buffer.from('--'),
177
- Buffer.from(boundary),
178
- Buffer.from('\r\n'),
179
- Buffer.from(`Content-Disposition: form-data; name="profile"; filename="${fileName}"`),
180
- Buffer.from('\r\n'),
181
- Buffer.from('\r\n'),
182
- Buffer.from(fileBody),
183
- Buffer.from('\r\n'),
184
- Buffer.from('--'),
185
- Buffer.from(boundary),
186
- Buffer.from('--'),
187
- Buffer.from('\r\n')
188
- ]);
189
- await new Promise((resolve) => {
190
- let options = {
191
- method: 'PATCH',
192
- headers: {
193
- 'Authorization': `Bearer ${this.access_token}`,
194
- 'Content-Type': 'multipart/form-data; boundary=' + boundary,
195
- 'Content-Length': body.length
196
- },
197
- body: body,
198
- url: `${API_URL}/browser/${this.profile_id}/profile-s3`,
199
- };
200
- requests(_.merge(options, {}), () => {
201
- resolve();
202
- });
164
+ async postFile(fileName, fileBuff) {
165
+ debug('POSTING FILE', fileBuff.length);
166
+ debug('Getting signed URL for S3');
167
+ const apiUrl = `${API_URL}/browser/${this.profile_id}/storage-signature`;
168
+
169
+ const signedUrl = await requests.get(apiUrl, {
170
+ headers: {
171
+ Authorization: `Bearer ${this.access_token}`,
172
+ 'user-agent': 'gologin-api',
173
+ },
174
+ maxAttempts: 3,
175
+ retryDelay: 2000,
176
+ timeout: 10 * 1000,
177
+ fullResponse: false,
203
178
  });
179
+
180
+ const [uploadedProfileUrl] = signedUrl.split('?');
181
+
182
+ console.log('Uploading profile by signed URL to S3');
183
+ const bodyBufferBiteLength = Buffer.byteLength(fileBuff);
184
+ console.log('BUFFER SIZE', bodyBufferBiteLength);
185
+
186
+ await requests.put(signedUrl, {
187
+ headers: {
188
+ 'Content-Type': 'application/zip',
189
+ 'Content-Length': bodyBufferBiteLength,
190
+ },
191
+ body: fileBuff,
192
+ maxBodyLength: Infinity,
193
+ maxContentLength: Infinity,
194
+ maxAttempts: 3,
195
+ retryDelay: 2000,
196
+ timeout: 30 * 1000,
197
+ fullResponse: false,
198
+ });
199
+
200
+ const uploadedProfileMetadata = await requests.head(uploadedProfileUrl, {
201
+ maxAttempts: 3,
202
+ retryDelay: 2000,
203
+ timeout: 10 * 1000,
204
+ fullResponse: true,
205
+ });
206
+
207
+ const uploadedFileLength = +uploadedProfileMetadata.headers['content-length'];
208
+ if (uploadedFileLength !== bodyBufferBiteLength) {
209
+ console.log('Uploaded file is incorrect. Retry with China File size:', uploadedFileLength);
210
+ throw new Error('Uploaded file is incorrect. Retry with China File size: ' + uploadedFileLength);
211
+ }
212
+
213
+ console.log('Profile has been uploaded to S3 successfully');
204
214
  }
205
215
 
206
216
  async emptyProfileFolder() {
207
217
  debug('get emptyProfileFolder');
208
- const profile = fs.readFileSync(path.resolve(__dirname, 'gologin_zeroprofile.zip'));
218
+ const profile = await readFile(path.resolve(__dirname, 'gologin_zeroprofile.zip'));
209
219
  debug('emptyProfileFolder LENGTH ::', profile.length);
210
220
  return profile;
211
221
  }
@@ -246,9 +256,8 @@ class GoLogin {
246
256
  .then(() => {
247
257
  debug('extraction done');
248
258
  debug('create uid.json');
249
- fs.writeFileSync(path.join(extPath, 'uid.json'), JSON.stringify({uid: that.profile_id}, null, 2))
250
- debug('uid.json created', fs.readFileSync(path.join(extPath, 'uid.json')).toString())
251
- return extPath;
259
+ return writeFile(path.join(extPath, 'uid.json'), JSON.stringify({ uid: that.profile_id }, null, 2))
260
+ .then(() => extPath);
252
261
  })
253
262
  .catch(async (e) => {
254
263
  debug('orbita extension error', e);
@@ -299,19 +308,21 @@ class GoLogin {
299
308
  height: parseInt(screenHeight, 10),
300
309
  };
301
310
 
302
- if (!(local && fs.existsSync(this.profile_zip_path))) {
311
+ const profileZipExists = await access(this.profile_zip_path).then(() => true).catch(() => false);
312
+ if (!(local && profileZipExists)) {
303
313
  try {
304
314
  profile_folder = await this.getProfileS3(_.get(profile, 's3Path', ''));
305
315
  }
306
316
  catch (e) {
307
317
  debug('Cannot get profile - using empty', e);
308
318
  }
319
+
309
320
  debug('FILE READY', this.profile_zip_path);
310
321
  if (!profile_folder.length) {
311
322
  profile_folder = await this.emptyProfileFolder();
312
323
  }
313
-
314
- fs.writeFileSync(this.profile_zip_path, profile_folder);
324
+
325
+ await writeFile(this.profile_zip_path, profile_folder);
315
326
 
316
327
  debug('PROFILE LENGTH', profile_folder.length);
317
328
  } else {
@@ -323,20 +334,23 @@ class GoLogin {
323
334
  await this.extractProfile(profilePath, this.profile_zip_path);
324
335
  debug('extraction done');
325
336
 
326
- if (fs.existsSync(path.join(profilePath, 'SingletonLock'))) {
337
+ const singletonLockPath = path.join(profilePath, 'SingletonLock');
338
+ const singletonLockExists = await access(singletonLockPath).then(() => true).catch(() => false);
339
+ if (singletonLockExists) {
327
340
  debug('removing SingletonLock');
328
- fs.unlinkSync(path.join(profilePath, 'SingletonLock'));
341
+ await unlink(singletonLockPath);
329
342
  debug('SingletonLock removed');
330
343
  }
331
344
 
332
345
  const pref_file_name = path.join(profilePath, 'Default', 'Preferences');
333
346
  debug('reading', pref_file_name);
334
347
 
335
- if (!fs.existsSync(pref_file_name)) {
348
+ const prefFileExists = await access(pref_file_name).then(() => true).catch(() => false);
349
+ if (!prefFileExists) {
336
350
  debug('Preferences file not exists waiting', pref_file_name);
337
351
  }
338
352
 
339
- const preferences_raw = fs.readFileSync(pref_file_name);
353
+ const preferences_raw = await readFile(pref_file_name);
340
354
  let preferences = JSON.parse(preferences_raw.toString());
341
355
  let proxy = _.get(profile, 'proxy');
342
356
  let name = _.get(profile, 'name');
@@ -359,6 +373,11 @@ class GoLogin {
359
373
  profile.proxy.password = _.get(profile, 'autoProxyPassword');
360
374
  }
361
375
  // console.log('proxy=', proxy);
376
+
377
+ if (proxy.mode === 'geolocation') {
378
+ proxy.mode = 'http';
379
+ }
380
+
362
381
  if (proxy.mode === 'none') {
363
382
  proxy = null;
364
383
  }
@@ -431,7 +450,7 @@ class GoLogin {
431
450
  await BrowserUserDataManager.composeFonts(families, profilePath, this.differentOs);
432
451
  }
433
452
 
434
- fs.writeFileSync(path.join(profilePath, 'Default', 'Preferences'), JSON.stringify(_.merge(preferences, {
453
+ await writeFile(path.join(profilePath, 'Default', 'Preferences'), JSON.stringify(_.merge(preferences, {
435
454
  gologin
436
455
  })));
437
456
 
@@ -444,20 +463,23 @@ class GoLogin {
444
463
  }
445
464
 
446
465
  async commitProfile() {
447
- const data = await this.getProfileDataToUpdate();
448
- debug('begin updating', data.length);
449
- if (!data.length) {
466
+ const dataBuff = await this.getProfileDataToUpdate();
467
+
468
+ debug('begin updating', dataBuff.length);
469
+ if (!dataBuff.length) {
450
470
  debug('WARN: profile zip data empty - SKIPPING PROFILE COMMIT');
451
471
 
452
472
  return;
453
473
  }
474
+
454
475
  try {
455
476
  debug('Patching profile');
456
- await this.postFile('profile', data);
477
+ await this.postFile('profile', dataBuff);
457
478
  }
458
479
  catch (e) {
459
480
  debug('CANNOT COMMIT PROFILE', e);
460
481
  }
482
+
461
483
  debug('COMMIT COMPLETED');
462
484
  }
463
485
 
@@ -477,16 +499,16 @@ class GoLogin {
477
499
 
478
500
  async checkPortAvailable(port) {
479
501
  debug('CHECKING PORT AVAILABLE', port);
502
+
480
503
  try {
481
504
  const { stdout, stderr } = await exec(`lsof -i:${port}`);
482
- if (
483
- stdout && stdout.match(/LISTEN/gmi)
484
- ) {
505
+ if (stdout && stdout.match(/LISTEN/gmi)) {
485
506
  debug(`PORT ${port} IS BUSY`)
486
507
  return false;
487
508
  }
488
- } catch (e) { }
509
+ } catch (e) {}
489
510
  debug(`PORT ${port} IS OPEN`);
511
+
490
512
  return true;
491
513
  }
492
514
 
@@ -501,23 +523,24 @@ class GoLogin {
501
523
  }
502
524
 
503
525
  async getTimeZone(proxy) {
504
- if(this.timezone){
526
+ debug('getting timeZone proxy=', proxy);
527
+ if (this.timezone) {
505
528
  debug('getTimeZone from options', this.timezone);
506
529
  this._tz = this.timezone;
507
530
  return this._tz.timezone;
508
531
  }
509
532
 
510
533
  let data = null;
511
- if (proxy) {
534
+ if (proxy!==null && proxy.mode !== "none") {
512
535
  if (proxy.mode.includes('socks')) {
513
536
  return this.getTimezoneWithSocks(proxy);
514
537
  }
515
538
 
516
539
  const proxyUrl = `${proxy.mode}://${proxy.username}:${proxy.password}@${proxy.host}:${proxy.port}`;
517
540
  debug('getTimeZone start https://time.gologin.com', proxyUrl);
518
- data = await requests.get('https://time.gologin.com', { proxy: proxyUrl, timeout: 10 * 1000, maxAttempts: 2 });
541
+ data = await requests.get('https://time.gologin.com', { proxy: proxyUrl, timeout: 20 * 1000, maxAttempts: 5 });
519
542
  } else {
520
- data = await requests.get('https://time.gologin.com', { timeout: 10 * 1000, maxAttempts: 2 });
543
+ data = await requests.get('https://time.gologin.com', { timeout: 20 * 1000, maxAttempts: 5 });
521
544
  }
522
545
  debug('getTimeZone finish', data.body);
523
546
  this._tz = JSON.parse(data.body);
@@ -598,7 +621,7 @@ class GoLogin {
598
621
 
599
622
  async spawnBrowser() {
600
623
  let remote_debugging_port = this.remote_debugging_port;
601
- if(!remote_debugging_port){
624
+ if (!remote_debugging_port) {
602
625
  remote_debugging_port = await this.getRandomPort();
603
626
  }
604
627
 
@@ -700,7 +723,9 @@ class GoLogin {
700
723
  if (this.is_stopping) {
701
724
  return true;
702
725
  }
703
- const is_posting = options.postings || false;
726
+ const is_posting = options.posting ||
727
+ options.postings || // backward compability
728
+ false;
704
729
 
705
730
  if (this.uploadCookiesToServer) {
706
731
  await this.uploadProfileCookiesToServer();
@@ -776,34 +801,31 @@ class GoLogin {
776
801
 
777
802
  async getProfileDataToUpdate() {
778
803
  const zipPath = path.join(this.tmpdir, `gologin_${this.profile_id}_upload.zip`);
779
- try {
780
- fs.unlinkSync(zipPath);
781
- }
782
- catch (e) {
804
+ const zipExists = await access(zipPath).then(() => true).catch(() => false);
805
+ if (zipExists) {
806
+ await unlink(zipPath);
783
807
  }
808
+
784
809
  await this.sanitizeProfile();
785
810
  debug('profile sanitized');
786
- await new Promise(resolve => {
787
- debug('begin zipping');
788
- execFile(`cd ${this.profilePath()}; /usr/bin/zip`, [
789
- `-r ${zipPath}`,
790
- '*'
791
- ], {
792
- shell: true
793
- }, () => {
794
- debug('zipping done');
795
- resolve();
796
- });
797
- });
798
- debug('PROFILE ZIP CREATED', this.profilePath(), zipPath);
799
- try {
800
- const data = fs.readFileSync(zipPath);
801
- return data;
802
- }
803
- catch (e) {
804
- debug('saveprofile error', e);
805
- return '';
806
- }
811
+
812
+ const profilePath = this.profilePath();
813
+ const fileBuff = await new Promise((resolve, reject) => zipdir(profilePath,
814
+ {
815
+ saveTo: zipPath,
816
+ filter: (path) => !/RunningChromeVersion/.test(path),
817
+ }, (err, buffer) => {
818
+ if (err) {
819
+ reject(err);
820
+ return;
821
+ }
822
+
823
+ resolve(buffer);
824
+ })
825
+ )
826
+
827
+ debug('PROFILE ZIP CREATED', profilePath, zipPath);
828
+ return fileBuff;
807
829
  }
808
830
 
809
831
  async profileExists() {
@@ -847,11 +869,11 @@ class GoLogin {
847
869
  const fingerprint = await this.getRandomFingerprint(options);
848
870
  debug("fingerprint=", fingerprint)
849
871
 
850
- if(fingerprint.statusCode == 500){
872
+ if (fingerprint.statusCode === 500) {
851
873
  throw new Error("no valid random fingerprint check os param");
852
874
  }
853
875
 
854
- if(fingerprint.statusCode == 401){
876
+ if (fingerprint.statusCode === 401) {
855
877
  throw new Error("invalid token");
856
878
  }
857
879
 
@@ -881,7 +903,7 @@ class GoLogin {
881
903
  let user_agent = options.navigator?.userAgent;
882
904
  let orig_user_agent = json.navigator.userAgent;
883
905
  Object.keys(options).map((e)=>{ json[e] = options[e] });
884
- if(user_agent=='random'){
906
+ if (user_agent === 'random') {
885
907
  json.navigator.userAgent = orig_user_agent;
886
908
  }
887
909
  // console.log('profileOptions', json);
@@ -894,11 +916,11 @@ class GoLogin {
894
916
  json,
895
917
  });
896
918
 
897
- if(response.body.statusCode==400){
919
+ if (response.body.statusCode === 400) {
898
920
  throw new Error(`gologin failed account creation with status code, ${data.statusCode} DATA ${JSON.stringify(response.body.message)}`);
899
921
  }
900
922
 
901
- if(response.body.statusCode==500){
923
+ if (response.body.statusCode === 500) {
902
924
  throw new Error(`gologin failed account creation with status code, ${data.statusCode}`);
903
925
  }
904
926
  debug(JSON.stringify(response.body));
@@ -1036,6 +1058,13 @@ class GoLogin {
1036
1058
  if (!this.executablePath) {
1037
1059
  await this.checkBrowser();
1038
1060
  }
1061
+
1062
+ const ORBITA_BROWSER = this.executablePath || this.browserChecker.getOrbitaPath;
1063
+
1064
+ const orbitaBrowserExists = await access(ORBITA_BROWSER).then(() => true).catch(() => false);
1065
+ if (!orbitaBrowserExists) {
1066
+ throw new Error(`Orbita browser is not exists on path ${ORBITA_BROWSER}, check executablePath param`);
1067
+ }
1039
1068
 
1040
1069
  await this.createStartup();
1041
1070
  // await this.createBrowserExtension();
@@ -1059,12 +1088,12 @@ class GoLogin {
1059
1088
  return this.stopRemote();
1060
1089
  }
1061
1090
 
1062
- await this.stopAndCommit({ posting: false }, false);
1091
+ await this.stopAndCommit({ posting: true }, false);
1063
1092
  }
1064
1093
 
1065
1094
  async stopLocal(options) {
1066
1095
  const opts = options || { posting: false };
1067
- await this.stopAndCommit(options, true);
1096
+ await this.stopAndCommit(opts, true);
1068
1097
  }
1069
1098
 
1070
1099
  async waitDebuggingUrl(delay_ms, try_count=0) {
@@ -1086,7 +1115,7 @@ class GoLogin {
1086
1115
  if (try_count < 3) {
1087
1116
  return this.waitDebuggingUrl(delay_ms, try_count+1);
1088
1117
  }
1089
- return { 'status': 'failure', wsUrl }
1118
+ return { 'status': 'failure', wsUrl, 'message': 'Check proxy settings', 'profile_id': this.profile_id }
1090
1119
  }
1091
1120
 
1092
1121
  wsUrl = wsUrl.replace('ws://', `wss://`).replace('127.0.0.1', `${this.profile_id}.orbita.gologin.com`)
@@ -1101,7 +1130,7 @@ class GoLogin {
1101
1130
  }
1102
1131
  });
1103
1132
 
1104
- if(profileResponse.statusCode == 401){
1133
+ if (profileResponse.statusCode === 401){
1105
1134
  throw new Error("invalid token");
1106
1135
  }
1107
1136
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin",
3
- "version": "1.0.29",
3
+ "version": "1.0.33",
4
4
  "description": "A high-level API to control Orbita browser over GoLogin API",
5
5
  "main": "./gologin.js",
6
6
  "repository": {
@@ -26,10 +26,10 @@
26
26
  "requestretry": "^4.1.0",
27
27
  "rimraf": "^3.0.2",
28
28
  "selenium-webdriver": "^4.0.0-alpha.7",
29
- "shelljs": "^0.8.4",
30
29
  "simple-proxy-agent": "^1.1.0",
31
30
  "sqlite": "^4.0.23",
32
- "sqlite3": "^5.0.2"
31
+ "sqlite3": "^5.0.2",
32
+ "zip-dir": "^2.0.0"
33
33
  },
34
34
  "bugs": {
35
35
  "url": "https://github.com/gologinapp/gologin/issues"
@@ -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)