gologin 2.1.30 → 2.1.31

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  Combined changelog for GoLogin node.js SDK
4
4
 
5
+ ## [2.1.31] 2025-09-01
6
+
7
+
8
+ ### Fixes
9
+
10
+ * Orbita downloading doesnt break the flow if major version is skipped
11
+ * Languages passing now works correctly
12
+
5
13
  ## [2.1.29] 2025-07-11
6
14
 
7
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin",
3
- "version": "2.1.30",
3
+ "version": "2.1.31",
4
4
  "description": "A high-level API to control Orbita browser over GoLogin API",
5
5
  "types": "./index.d.ts",
6
6
  "main": "./src/gologin.js",
@@ -71,7 +71,7 @@ export class BrowserChecker {
71
71
  // return this.getBrowserExecutablePath(majorVersion);
72
72
  // }
73
73
 
74
-
74
+
75
75
 
76
76
  // return new Promise(resolve => {
77
77
  // const rl = createInterface(process.stdin, process.stdout);
@@ -139,7 +139,7 @@ export class BrowserChecker {
139
139
  .then(() => writeFile(join(this.#browserPath, 'orbita-browser', 'version', 'latest-version.txt'), latestVersion));
140
140
  }
141
141
 
142
- downloadBrowserArchive(link, pathStr) {
142
+ async downloadBrowserArchive(link, pathStr) {
143
143
  return new Promise((resolve, reject) => {
144
144
  const writableStream = createWriteStream(pathStr);
145
145
  writableStream.on('error', async err => {
@@ -153,6 +153,11 @@ export class BrowserChecker {
153
153
  }, (res) => {
154
154
  const len = parseInt(res.headers['content-length'], 10);
155
155
  const formattedLen = len / 1024 / 1024;
156
+ if (isNaN(formattedLen)) {
157
+ reject(new Error('Error downloading browser'));
158
+ return;
159
+ }
160
+
156
161
  const bar = new ProgressBar('Orbita downloading [:bar] :rate/mps :downloadedMb/:fullMbMB :percent :etas', {
157
162
  complete: '=',
158
163
  incomplete: ' ',
@@ -299,13 +304,13 @@ export class BrowserChecker {
299
304
 
300
305
  async replaceBrowser(majorVersion) {
301
306
  console.log('Copy Orbita to target path');
302
- if (PLATFORM === 'darwin') {
303
- return rename(join(this.#browserPath, EXTRACTED_FOLDER), join(this.#browserPath, `orbita-browser-${majorVersion}`));
304
- }
305
-
306
307
  const targetBrowserPath = join(this.#browserPath, `orbita-browser-${majorVersion}`);
307
308
  await this.deleteDir(targetBrowserPath);
308
309
 
310
+ if (PLATFORM === 'darwin') {
311
+ return rename(join(this.#browserPath, EXTRACTED_FOLDER), targetBrowserPath);
312
+ }
313
+
309
314
  await this.copyDir(
310
315
  join(this.#browserPath, EXTRACTED_FOLDER, 'orbita-browser'),
311
316
  targetBrowserPath,
@@ -67,13 +67,15 @@ export const downloadFonts = async (fontsList = [], profilePath) => {
67
67
  const files = await readdir(browserFontsPath);
68
68
  const fontsToDownload = fontsList.filter(font => !files.includes(font));
69
69
 
70
- let promises = fontsToDownload.map(font => makeRequest(FONTS_URL + font, {
71
- maxAttempts: 5,
72
- retryDelay: 2000,
73
- timeout: 30 * 1000,
74
- })
75
- .pipe(createWriteStream(join(browserFontsPath, font))),
76
- );
70
+ let promises = fontsToDownload.map(async font => {
71
+ const body = await makeRequest(FONTS_URL + font, {
72
+ maxAttempts: 5,
73
+ retryDelay: 2000,
74
+ timeout: 30 * 1000,
75
+ });
76
+
77
+ await writeFile(join(browserFontsPath, font), body);
78
+ });
77
79
 
78
80
  if (promises.length) {
79
81
  await Promise.all(promises);
@@ -55,9 +55,9 @@ export const createDBFile = async ({
55
55
 
56
56
  export const getUniqueCookies = async (cookiesArr, cookiesFilePath) => {
57
57
  const cookiesInFile = await loadCookiesFromFile(cookiesFilePath);
58
- const existingCookieNames = new Set(cookiesInFile.map(c => `${c.name}-${c.value.toString('base64')}`));
58
+ const existingCookieNames = new Set(cookiesInFile.map(c => `${c.name}-${c.domain}-${c.path}`));
59
59
 
60
- return cookiesArr.filter(cookie => !existingCookieNames.has(`${cookie.name}-${cookie.value.toString('base64')}`));
60
+ return cookiesArr.filter(cookie => !existingCookieNames.has(`${cookie.name}-${cookie.domain}-${cookie.path}`));
61
61
  };
62
62
 
63
63
  export const getChunckedInsertValues = (cookiesArr) => {
@@ -114,9 +114,21 @@ export const getChunckedInsertValues = (cookiesArr) => {
114
114
  });
115
115
  };
116
116
 
117
- export const loadCookiesFromFile = async (filePath) => {
117
+ export const loadCookiesFromFile = async (filePath, isSecondTry = false, profileId, tmpdir) => {
118
118
  let db;
119
119
  const cookies = [];
120
+ let secondCookiesFilePath;
121
+ try {
122
+ const isNetworkFolder = filePath.includes('Network');
123
+ secondCookiesFilePath = isNetworkFolder ?
124
+ join(tmpdir, `gologin_profile_${profileId}`, 'Default', 'Cookies') :
125
+ join(tmpdir, `gologin_profile_${profileId}`, 'Default', 'Network', 'Cookies');
126
+ } catch (error) {
127
+ console.log(error);
128
+ console.log('error in loadCookiesFromFile', error.message);
129
+ }
130
+
131
+ console.log(1);
120
132
 
121
133
  try {
122
134
  db = await getDB(filePath);
@@ -151,11 +163,18 @@ export const loadCookiesFromFile = async (filePath) => {
151
163
  });
152
164
  }
153
165
  } catch (error) {
154
- console.log(error);
166
+ console.log('error in loadCookiesFromFile', error.message);
167
+ if (!isSecondTry) {
168
+ return await loadCookiesFromFile(secondCookiesFilePath, true, profileId, tmpdir);
169
+ }
155
170
  } finally {
156
171
  db && await db.close();
157
172
  }
158
173
 
174
+ if (!cookies.length && !isSecondTry) {
175
+ return loadCookiesFromFile(secondCookiesFilePath, true, profileId, tmpdir);
176
+ }
177
+
159
178
  return cookies;
160
179
  };
161
180
 
package/src/gologin.js CHANGED
@@ -133,6 +133,8 @@ export class GoLogin {
133
133
  autoUpdateBrowser: true,
134
134
  checkBrowserUpdate: true,
135
135
  majorVersion,
136
+ }).catch((error) => {
137
+ console.log('Error Downloading Browser version', majorVersion, error);
136
138
  });
137
139
  }
138
140
  }
@@ -1036,7 +1038,7 @@ export class GoLogin {
1036
1038
  }
1037
1039
 
1038
1040
  async uploadProfileDataToServer() {
1039
- const cookies = await loadCookiesFromFile(this.cookiesFilePath);
1041
+ const cookies = await loadCookiesFromFile(this.cookiesFilePath, false, this.profile_id, this.tmpdir);
1040
1042
  const bookmarks = await getCurrentProfileBookmarks(this.bookmarksFilePath);
1041
1043
 
1042
1044
  const body = {
@@ -1391,15 +1393,6 @@ export class GoLogin {
1391
1393
  }
1392
1394
  }
1393
1395
 
1394
- async uploadProfileCookiesToServer() {
1395
- const cookies = await loadCookiesFromFile(this.cookiesFilePath);
1396
- if (!cookies.length) {
1397
- return;
1398
- }
1399
-
1400
- return this.postCookies(this.profile_id, cookies);
1401
- }
1402
-
1403
1396
  async saveBookmarksToDb() {
1404
1397
  const bookmarksData = await getCurrentProfileBookmarks(this.bookmarksFilePath);
1405
1398
  const bookmarks = bookmarksData.roots || {};
@@ -1436,6 +1429,7 @@ export class GoLogin {
1436
1429
 
1437
1430
  async stopLocal(options) {
1438
1431
  const opts = options || { posting: false };
1432
+ await new Promise(resolve => setTimeout(resolve, 1000));
1439
1433
  await this.stopAndCommit(opts, true);
1440
1434
  }
1441
1435