gologin 2.0.24 → 2.0.27
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/package.json +2 -2
- package/src/gologin.js +19 -12
- package/zero_profile.zip +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gologin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.27",
|
|
4
4
|
"description": "A high-level API to control Orbita browser over GoLogin API",
|
|
5
5
|
"main": "./src/gologin.js",
|
|
6
6
|
"repository": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"url": "git+https://github.com/gologinapp/gologin.git"
|
|
9
9
|
},
|
|
10
10
|
"engines": {
|
|
11
|
-
"node": ">=
|
|
11
|
+
"node": ">=16.0.0"
|
|
12
12
|
},
|
|
13
13
|
"type": "module",
|
|
14
14
|
"author": "The GoLogin Authors",
|
package/src/gologin.js
CHANGED
|
@@ -5,7 +5,7 @@ import decompressUnzip from 'decompress-unzip';
|
|
|
5
5
|
import { existsSync, mkdirSync, promises as _promises } from 'fs';
|
|
6
6
|
import { get as _get } from 'https';
|
|
7
7
|
import { tmpdir } from 'os';
|
|
8
|
-
import { join, resolve as _resolve,sep } from 'path';
|
|
8
|
+
import { dirname, join, resolve as _resolve, sep } from 'path';
|
|
9
9
|
import requests from 'requestretry';
|
|
10
10
|
import rimraf from 'rimraf';
|
|
11
11
|
import ProxyAgent from 'simple-proxy-agent';
|
|
@@ -35,8 +35,6 @@ const { access, unlink, writeFile, readFile } = _promises;
|
|
|
35
35
|
const SEPARATOR = sep;
|
|
36
36
|
const OS_PLATFORM = process.platform;
|
|
37
37
|
|
|
38
|
-
// process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
|
39
|
-
|
|
40
38
|
const debug = debugDefault('gologin');
|
|
41
39
|
const delay = (time) => new Promise((resolve) => setTimeout(resolve, time));
|
|
42
40
|
|
|
@@ -60,7 +58,7 @@ export class GoLogin {
|
|
|
60
58
|
this.waitWebsocket = false;
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
this.isCloudHeadless = options.isCloudHeadless
|
|
61
|
+
this.isCloudHeadless = options.isCloudHeadless ?? true;
|
|
64
62
|
this.isNewCloudBrowser = true;
|
|
65
63
|
if (options.isNewCloudBrowser === false) {
|
|
66
64
|
this.isNewCloudBrowser = false;
|
|
@@ -247,7 +245,9 @@ export class GoLogin {
|
|
|
247
245
|
|
|
248
246
|
async emptyProfileFolder() {
|
|
249
247
|
debug('get emptyProfileFolder');
|
|
250
|
-
const
|
|
248
|
+
const currentDir = dirname(new URL(import.meta.url).pathname);
|
|
249
|
+
const zeroProfilePath = join(currentDir, '..', 'zero_profile.zip');
|
|
250
|
+
const profile = await readFile(_resolve(zeroProfilePath));
|
|
251
251
|
debug('emptyProfileFolder LENGTH ::', profile.length);
|
|
252
252
|
|
|
253
253
|
return profile;
|
|
@@ -1422,7 +1422,7 @@ export class GoLogin {
|
|
|
1422
1422
|
return this.waitDebuggingUrl(delay_ms, try_count + 1, remoteOrbitaUrl);
|
|
1423
1423
|
}
|
|
1424
1424
|
|
|
1425
|
-
return {
|
|
1425
|
+
return { status: 'failure', wsUrl, message: 'Check proxy settings', 'profile_id': this.profile_id };
|
|
1426
1426
|
}
|
|
1427
1427
|
|
|
1428
1428
|
const remoteOrbitaUrlWithoutProtocol = remoteOrbitaUrl.replace('https://', '');
|
|
@@ -1440,20 +1440,27 @@ export class GoLogin {
|
|
|
1440
1440
|
}
|
|
1441
1441
|
*/
|
|
1442
1442
|
|
|
1443
|
-
// if (profileResponse.body === 'ok') {
|
|
1444
1443
|
const profile = await this.getProfile();
|
|
1445
|
-
|
|
1446
1444
|
const profileResponse = await requests.post(`${API_URL}/browser/${this.profile_id}/web`, {
|
|
1447
1445
|
headers: { 'Authorization': `Bearer ${this.access_token}` },
|
|
1448
1446
|
json: { isNewCloudBrowser: this.isNewCloudBrowser, isHeadless: this.isCloudHeadless },
|
|
1449
|
-
});
|
|
1447
|
+
}).catch(() => null);
|
|
1450
1448
|
|
|
1451
|
-
|
|
1449
|
+
if (!profileResponse) {
|
|
1450
|
+
throw new Error('invalid request');
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
const { body, statusCode } = profileResponse;
|
|
1454
|
+
debug('profileResponse', statusCode, body);
|
|
1452
1455
|
|
|
1453
1456
|
if (profileResponse.statusCode === 401) {
|
|
1454
1457
|
throw new Error('invalid token');
|
|
1455
1458
|
}
|
|
1456
1459
|
|
|
1460
|
+
if (body.status === 'profileStatuses.pending') {
|
|
1461
|
+
return { status: 'pending', message: 'remote browser is being prepared, please try in 1 minute.' };
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1457
1464
|
let remoteOrbitaUrl = `https://${this.profile_id}.orbita.gologin.com`;
|
|
1458
1465
|
if (this.isNewCloudBrowser) {
|
|
1459
1466
|
if (!profileResponse.body.remoteOrbitaUrl) {
|
|
@@ -1487,10 +1494,10 @@ export class GoLogin {
|
|
|
1487
1494
|
|
|
1488
1495
|
const wsUrl = await this.waitDebuggingUrl(delay_ms, 0, remoteOrbitaUrl);
|
|
1489
1496
|
if (wsUrl !== '') {
|
|
1490
|
-
return {
|
|
1497
|
+
return { status: 'success', wsUrl };
|
|
1491
1498
|
}
|
|
1492
1499
|
|
|
1493
|
-
return {
|
|
1500
|
+
return { status: 'failure', message: body };
|
|
1494
1501
|
}
|
|
1495
1502
|
|
|
1496
1503
|
async stopRemote() {
|
package/zero_profile.zip
CHANGED
|
Binary file
|