gologin 2.0.17 → 2.0.19

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/gologin.js +13 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin",
3
- "version": "2.0.17",
3
+ "version": "2.0.19",
4
4
  "description": "A high-level API to control Orbita browser over GoLogin API",
5
5
  "main": "./src/gologin.js",
6
6
  "repository": {
package/src/gologin.js CHANGED
@@ -151,6 +151,17 @@ export class GoLogin {
151
151
 
152
152
  debug('profileResponse', profileResponse.statusCode, profileResponse.body);
153
153
 
154
+ const { body: errorBody = '' } = profileResponse;
155
+ const backendErrorHeader = 'backend@error::';
156
+ if (errorBody.includes(backendErrorHeader)) {
157
+ const errorData =
158
+ errorBody
159
+ .replace(backendErrorHeader, '')
160
+ .slice(1, -1);
161
+
162
+ throw new Error(errorData);
163
+ }
164
+
154
165
  if (profileResponse.statusCode === 404) {
155
166
  throw new Error(JSON.parse(profileResponse.body).message);
156
167
  }
@@ -182,7 +193,7 @@ export class GoLogin {
182
193
  const token = this.access_token;
183
194
  debug('getProfileS3 token=', token, 'profile=', this.profile_id, 's3path=', s3path);
184
195
 
185
- const s3url = `https://gprofiles.gologin.com/${s3path}`.replace(/\s+/mg, '+');
196
+ const s3url = `https://gprofiles-new.gologin.com/${s3path}`.replace(/\s+/mg, '+');
186
197
  debug('loading profile from public s3 bucket, url=', s3url);
187
198
  const profileResponse = await requests.get(s3url, {
188
199
  encoding: null,
@@ -1298,7 +1309,7 @@ export class GoLogin {
1298
1309
  db = await getDB(this.cookiesFilePath, false);
1299
1310
  if (resultCookies.length) {
1300
1311
  const chunckInsertValues = getChunckedInsertValues(resultCookies);
1301
-
1312
+
1302
1313
  for (const [query, queryParams] of chunckInsertValues) {
1303
1314
  const insertStmt = await db.prepare(query);
1304
1315
  await insertStmt.run(queryParams);