gologin 1.0.38 → 1.0.41

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
@@ -65,15 +65,16 @@ const GoLogin = require('gologin');
65
65
 
66
66
  - `options` <[Object]> Options for profile
67
67
  - `autoUpdateBrowser` <[boolean]> do not ask whether download new browser version (default false)
68
- - `token` <[string]> your API <a href="https://gologin.com/#/personalArea/TokenApi" target="_blank">token</a>
69
- - `profile_id` <[string]> profile ID
70
- - `executablePath` <[string]> path to executable Orbita file. Orbita will be downloaded automatically if not specified.
68
+ - `token` <[string]> your API <a href="https://gologin.com/#/personalArea/TokenApi" target="_blank">token</a>
69
+ - `profile_id` <[string]> profile ID
70
+ - `executablePath` <[string]> path to executable Orbita file. Orbita will be downloaded automatically if not specified.
71
71
  - `remote_debugging_port` <[int]> port for remote debugging
72
- - `vncPort` <[integer]> port of VNC server if you using it
72
+ - `vncPort` <[integer]> port of VNC server if you using it
73
73
  - `tmpdir` <[string]> path to temporary directore for saving profiles
74
74
  - `extra_params` arrayof <[string]> extra params for browser orbita (ex. extentions etc.)
75
75
  - `uploadCookiesToServer` <[boolean]> upload cookies to server after profile stopping (default false)
76
76
  - `writeCookesFromServer` <[boolean]> download cookies from server and write to profile cookies file (default true)
77
+ - `skipOrbitaHashChecking` <[boolean]> skip hash checking for Orbita after downloading process (default false)
77
78
 
78
79
  ```js
79
80
  const GoLogin = require('gologin');
@@ -39,8 +39,10 @@ class BrowserChecker {
39
39
  #homedir;
40
40
  #browserPath;
41
41
  #executableFilePath;
42
+ #skipOrbitaHashChecking = false;
42
43
 
43
- constructor() {
44
+ constructor(skipOrbitaHashChecking) {
45
+ this.#skipOrbitaHashChecking = skipOrbitaHashChecking;
44
46
  this.#homedir = os.homedir();
45
47
  this.#browserPath = path.join(this.#homedir, '.gologin', 'browser');
46
48
 
@@ -221,6 +223,10 @@ class BrowserChecker {
221
223
  }
222
224
 
223
225
  async checkBrowserSum() {
226
+ if (this.#skipOrbitaHashChecking) {
227
+ return Promise.resolve();
228
+ }
229
+
224
230
  console.log('Orbita hash checking');
225
231
  if (PLATFORM === 'win32') {
226
232
  return Promise.resolve();
@@ -58,9 +58,9 @@ class BrowserUserDataManager {
58
58
  const fontsToDownload = fontsList.filter(font => !files.includes(font));
59
59
 
60
60
  let promises = fontsToDownload.map(font => request.get(FONTS_URL + font, {
61
- maxAttempts: 3,
61
+ maxAttempts: 5,
62
62
  retryDelay: 2000,
63
- timeout: 10 * 1000,
63
+ timeout: 30 * 1000,
64
64
  })
65
65
  .pipe(createWriteStream(path.join(browserFontsPath, font)))
66
66
  );
package/gologin.js CHANGED
@@ -8,7 +8,6 @@ const rimraf = util.promisify(require('rimraf'));
8
8
  const { access, unlink, writeFile, readFile } = require('fs').promises;
9
9
  const exec = util.promisify(require('child_process').exec);
10
10
  const { spawn, execFile } = require('child_process');
11
- const FormData = require('form-data');
12
11
  const ProxyAgent = require('simple-proxy-agent');
13
12
  const decompress = require('decompress');
14
13
  const decompressUnzip = require('decompress-unzip');
@@ -30,7 +29,7 @@ const OS_PLATFORM = process.platform;
30
29
  const delay = (time) => new Promise((resolve) => setTimeout(resolve, time));
31
30
 
32
31
  class GoLogin {
33
- constructor(options) {
32
+ constructor(options = {}) {
34
33
  this.is_remote = options.remote || false;
35
34
  this.access_token = options.token;
36
35
  this.profile_id = options.profile_id;
@@ -45,7 +44,7 @@ class GoLogin {
45
44
  this.profileOs = 'lin';
46
45
  this.tmpdir = os.tmpdir();
47
46
  this.autoUpdateBrowser = !!options.autoUpdateBrowser;
48
- this.browserChecker = new BrowserChecker();
47
+ this.browserChecker = new BrowserChecker(options.skipOrbitaHashChecking);
49
48
  this.uploadCookiesToServer = options.uploadCookiesToServer || false;
50
49
  this.writeCookesFromServer = options.writeCookesFromServer || true;
51
50
  this.remote_debugging_port = options.remote_debugging_port || 0;
@@ -226,7 +225,7 @@ class GoLogin {
226
225
 
227
226
  async emptyProfileFolder() {
228
227
  debug('get emptyProfileFolder');
229
- const profile = await readFile(path.resolve(__dirname, 'gologin_zeroprofile.zip'));
228
+ const profile = await readFile(path.resolve(__dirname, 'zero_profile.zip'));
230
229
  debug('emptyProfileFolder LENGTH ::', profile.length);
231
230
  return profile;
232
231
  }
@@ -287,10 +286,6 @@ class GoLogin {
287
286
  );
288
287
  }
289
288
 
290
- async checkLocalProfile() {
291
-
292
- }
293
-
294
289
  async createStartup(local=false) {
295
290
  const profilePath = path.join(this.tmpdir, `gologin_profile_${this.profile_id}`);
296
291
  let profile;
@@ -342,8 +337,15 @@ class GoLogin {
342
337
 
343
338
  debug('Cleaning up..', profilePath);
344
339
 
345
- await this.extractProfile(profilePath, this.profile_zip_path);
346
- debug('extraction done');
340
+ try {
341
+ await this.extractProfile(profilePath, this.profile_zip_path);
342
+ debug('extraction done');
343
+ } catch(e) {
344
+ console.trace(e);
345
+ profile_folder = await this.emptyProfileFolder();
346
+ await writeFile(this.profile_zip_path, profile_folder);
347
+ await this.extractProfile(profilePath, this.profile_zip_path);
348
+ }
347
349
 
348
350
  const singletonLockPath = path.join(profilePath, 'SingletonLock');
349
351
  const singletonLockExists = await access(singletonLockPath).then(() => true).catch(() => false);
@@ -362,7 +364,7 @@ class GoLogin {
362
364
  }
363
365
 
364
366
  const preferences_raw = await readFile(pref_file_name);
365
- let preferences = JSON.parse(preferences_raw.toString());
367
+ let preferences = JSON.parse(preferences_raw.toString());
366
368
  let proxy = _.get(profile, 'proxy');
367
369
  let name = _.get(profile, 'name');
368
370
 
@@ -458,10 +460,19 @@ class GoLogin {
458
460
  throw new Error('No fonts list provided');
459
461
  }
460
462
 
461
- await BrowserUserDataManager.composeFonts(families, profilePath, this.differentOs);
463
+ try{
464
+ await BrowserUserDataManager.composeFonts(families, profilePath, this.differentOs);
465
+ } catch (e) {
466
+ console.trace(e);
467
+ }
462
468
  }
463
469
 
464
470
  const [languages] = this.language.split(';');
471
+
472
+ if(preferences.gologin==null){
473
+ preferences.gologin = {};
474
+ }
475
+
465
476
  preferences.gologin.langHeader = gologin.language;
466
477
  preferences.gologin.languages = languages;
467
478
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin",
3
- "version": "1.0.38",
3
+ "version": "1.0.41",
4
4
  "description": "A high-level API to control Orbita browser over GoLogin API",
5
5
  "main": "./gologin.js",
6
6
  "repository": {
Binary file
Binary file