gologin 1.0.39 → 1.0.42

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.
@@ -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
@@ -225,7 +225,7 @@ class GoLogin {
225
225
 
226
226
  async emptyProfileFolder() {
227
227
  debug('get emptyProfileFolder');
228
- const profile = await readFile(path.resolve(__dirname, 'gologin_zeroprofile.zip'));
228
+ const profile = await readFile(path.resolve(__dirname, 'zero_profile.zip'));
229
229
  debug('emptyProfileFolder LENGTH ::', profile.length);
230
230
  return profile;
231
231
  }
@@ -286,10 +286,6 @@ class GoLogin {
286
286
  );
287
287
  }
288
288
 
289
- async checkLocalProfile() {
290
-
291
- }
292
-
293
289
  async createStartup(local=false) {
294
290
  const profilePath = path.join(this.tmpdir, `gologin_profile_${this.profile_id}`);
295
291
  let profile;
@@ -341,8 +337,15 @@ class GoLogin {
341
337
 
342
338
  debug('Cleaning up..', profilePath);
343
339
 
344
- await this.extractProfile(profilePath, this.profile_zip_path);
345
- 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
+ }
346
349
 
347
350
  const singletonLockPath = path.join(profilePath, 'SingletonLock');
348
351
  const singletonLockExists = await access(singletonLockPath).then(() => true).catch(() => false);
@@ -357,11 +360,14 @@ class GoLogin {
357
360
 
358
361
  const prefFileExists = await access(pref_file_name).then(() => true).catch(() => false);
359
362
  if (!prefFileExists) {
360
- debug('Preferences file not exists waiting', pref_file_name);
363
+ debug('Preferences file not exists waiting', pref_file_name, '. Using empty profile');
364
+ profile_folder = await this.emptyProfileFolder();
365
+ await writeFile(this.profile_zip_path, profile_folder);
366
+ await this.extractProfile(profilePath, this.profile_zip_path);
361
367
  }
362
368
 
363
369
  const preferences_raw = await readFile(pref_file_name);
364
- let preferences = JSON.parse(preferences_raw.toString());
370
+ let preferences = JSON.parse(preferences_raw.toString());
365
371
  let proxy = _.get(profile, 'proxy');
366
372
  let name = _.get(profile, 'name');
367
373
 
@@ -457,10 +463,19 @@ class GoLogin {
457
463
  throw new Error('No fonts list provided');
458
464
  }
459
465
 
460
- await BrowserUserDataManager.composeFonts(families, profilePath, this.differentOs);
466
+ try{
467
+ await BrowserUserDataManager.composeFonts(families, profilePath, this.differentOs);
468
+ } catch (e) {
469
+ console.trace(e);
470
+ }
461
471
  }
462
472
 
463
473
  const [languages] = this.language.split(';');
474
+
475
+ if(preferences.gologin==null){
476
+ preferences.gologin = {};
477
+ }
478
+
464
479
  preferences.gologin.langHeader = gologin.language;
465
480
  preferences.gologin.languages = languages;
466
481
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin",
3
- "version": "1.0.39",
3
+ "version": "1.0.42",
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