gologin 2.0.26 → 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 +15 -10
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
|
@@ -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;
|
|
@@ -1424,7 +1422,7 @@ export class GoLogin {
|
|
|
1424
1422
|
return this.waitDebuggingUrl(delay_ms, try_count + 1, remoteOrbitaUrl);
|
|
1425
1423
|
}
|
|
1426
1424
|
|
|
1427
|
-
return {
|
|
1425
|
+
return { status: 'failure', wsUrl, message: 'Check proxy settings', 'profile_id': this.profile_id };
|
|
1428
1426
|
}
|
|
1429
1427
|
|
|
1430
1428
|
const remoteOrbitaUrlWithoutProtocol = remoteOrbitaUrl.replace('https://', '');
|
|
@@ -1442,20 +1440,27 @@ export class GoLogin {
|
|
|
1442
1440
|
}
|
|
1443
1441
|
*/
|
|
1444
1442
|
|
|
1445
|
-
// if (profileResponse.body === 'ok') {
|
|
1446
1443
|
const profile = await this.getProfile();
|
|
1447
|
-
|
|
1448
1444
|
const profileResponse = await requests.post(`${API_URL}/browser/${this.profile_id}/web`, {
|
|
1449
1445
|
headers: { 'Authorization': `Bearer ${this.access_token}` },
|
|
1450
1446
|
json: { isNewCloudBrowser: this.isNewCloudBrowser, isHeadless: this.isCloudHeadless },
|
|
1451
|
-
});
|
|
1447
|
+
}).catch(() => null);
|
|
1452
1448
|
|
|
1453
|
-
|
|
1449
|
+
if (!profileResponse) {
|
|
1450
|
+
throw new Error('invalid request');
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
const { body, statusCode } = profileResponse;
|
|
1454
|
+
debug('profileResponse', statusCode, body);
|
|
1454
1455
|
|
|
1455
1456
|
if (profileResponse.statusCode === 401) {
|
|
1456
1457
|
throw new Error('invalid token');
|
|
1457
1458
|
}
|
|
1458
1459
|
|
|
1460
|
+
if (body.status === 'profileStatuses.pending') {
|
|
1461
|
+
return { status: 'pending', message: 'remote browser is being prepared, please try in 1 minute.' };
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1459
1464
|
let remoteOrbitaUrl = `https://${this.profile_id}.orbita.gologin.com`;
|
|
1460
1465
|
if (this.isNewCloudBrowser) {
|
|
1461
1466
|
if (!profileResponse.body.remoteOrbitaUrl) {
|
|
@@ -1489,10 +1494,10 @@ export class GoLogin {
|
|
|
1489
1494
|
|
|
1490
1495
|
const wsUrl = await this.waitDebuggingUrl(delay_ms, 0, remoteOrbitaUrl);
|
|
1491
1496
|
if (wsUrl !== '') {
|
|
1492
|
-
return {
|
|
1497
|
+
return { status: 'success', wsUrl };
|
|
1493
1498
|
}
|
|
1494
1499
|
|
|
1495
|
-
return {
|
|
1500
|
+
return { status: 'failure', message: body };
|
|
1496
1501
|
}
|
|
1497
1502
|
|
|
1498
1503
|
async stopRemote() {
|