gologin 1.0.26 → 1.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/examples/example-amazon-headless.js +1 -1
- package/gologin.js +19 -22
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ const GoLogin = require('../gologin');
|
|
|
5
5
|
const GL = new GoLogin({
|
|
6
6
|
token: 'yU0token',
|
|
7
7
|
profile_id: 'yU0Pr0f1leiD',
|
|
8
|
-
extra_params: ['--headless'],
|
|
8
|
+
extra_params: ['--headless', '--no-sandbox'],
|
|
9
9
|
});
|
|
10
10
|
const {status, wsUrl} = await GL.start();
|
|
11
11
|
const browser = await puppeteer.connect({
|
package/gologin.js
CHANGED
|
@@ -8,7 +8,7 @@ const rimraf = util.promisify(require('rimraf'));
|
|
|
8
8
|
const exec = util.promisify(require('child_process').exec);
|
|
9
9
|
const { spawn, execFile } = require('child_process');
|
|
10
10
|
const FormData = require('form-data');
|
|
11
|
-
const
|
|
11
|
+
const ProxyAgent = require('simple-proxy-agent');
|
|
12
12
|
const decompress = require('decompress');
|
|
13
13
|
const decompressUnzip = require('decompress-unzip');
|
|
14
14
|
const path = require('path');
|
|
@@ -18,6 +18,7 @@ const BrowserChecker = require('./browser-checker');
|
|
|
18
18
|
const { BrowserUserDataManager } = require('./browser-user-data-manager');
|
|
19
19
|
const { CookiesManager } = require('./cookies-manager');
|
|
20
20
|
const fontsCollection = require('./fonts');
|
|
21
|
+
const https = require('https');
|
|
21
22
|
|
|
22
23
|
const SEPARATOR = path.sep;
|
|
23
24
|
const API_URL = 'https://api.gologin.com';
|
|
@@ -122,7 +123,7 @@ class GoLogin {
|
|
|
122
123
|
})
|
|
123
124
|
debug(profileResponse.body);
|
|
124
125
|
if (profileResponse.statusCode !== 200) {
|
|
125
|
-
throw new Error(`Gologin /browser/${id} response error ${profileResponse.statusCode}`);
|
|
126
|
+
throw new Error(`Gologin /browser/${id} response error ${profileResponse.statusCode} INVALID TOKEN OR PROFILE NOT FOUND`);
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
if(profileResponse.statusCode == 401){
|
|
@@ -520,35 +521,31 @@ class GoLogin {
|
|
|
520
521
|
return this._tz.timezone;
|
|
521
522
|
}
|
|
522
523
|
|
|
523
|
-
async getTimezoneWithSocks(
|
|
524
|
-
const { host, port, username, password } =
|
|
524
|
+
async getTimezoneWithSocks(params) {
|
|
525
|
+
const { mode = 'http', host, port, username = '', password = '' } = params;
|
|
525
526
|
let body;
|
|
526
527
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
const req = socks5Http.get({
|
|
534
|
-
hostname: 'time.gologin.com',
|
|
535
|
-
path: '/timezone',
|
|
536
|
-
socksHost: host,
|
|
537
|
-
socksPort: port,
|
|
538
|
-
socksUsername: username || '',
|
|
539
|
-
socksPassword: password || '',
|
|
540
|
-
}, (res) => {
|
|
541
|
-
res.setEncoding('utf8');
|
|
528
|
+
let proxy = mode + '://';
|
|
529
|
+
if (username) {
|
|
530
|
+
const resultPassword = password ? ':' + password + '@' : '@';
|
|
531
|
+
proxy += username + resultPassword;
|
|
532
|
+
}
|
|
533
|
+
proxy += host + ':' + port;
|
|
542
534
|
|
|
535
|
+
const agent = new ProxyAgent(proxy, { tunnel: true, timeout: 10000 });
|
|
536
|
+
|
|
537
|
+
const checkData = await new Promise((resolve, reject) => {
|
|
538
|
+
https.get('https://time.gologin.com/timezone', { agent }, (res) => {
|
|
543
539
|
let resultResponse = '';
|
|
544
540
|
res.on('data', (data) => resultResponse += data);
|
|
545
541
|
|
|
546
542
|
res.on('end', () => {
|
|
547
|
-
clearTimeout(timer);
|
|
548
543
|
let parsedData;
|
|
549
544
|
try {
|
|
550
545
|
parsedData = JSON.parse(resultResponse);
|
|
551
|
-
} catch (e) {
|
|
546
|
+
} catch (e) {
|
|
547
|
+
reject(e);
|
|
548
|
+
}
|
|
552
549
|
|
|
553
550
|
resolve({
|
|
554
551
|
...res,
|
|
@@ -558,7 +555,7 @@ class GoLogin {
|
|
|
558
555
|
}).on('error', (err) => reject(err));
|
|
559
556
|
});
|
|
560
557
|
|
|
561
|
-
console.log('checkData:', checkData);
|
|
558
|
+
// console.log('checkData:', checkData);
|
|
562
559
|
body = checkData.body || {};
|
|
563
560
|
if (!body.ip && checkData.statusCode.toString().startsWith('4')) {
|
|
564
561
|
throw checkData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gologin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "A high-level API to control Orbita browser over GoLogin API",
|
|
5
5
|
"main": "./gologin.js",
|
|
6
6
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"rimraf": "^3.0.2",
|
|
28
28
|
"selenium-webdriver": "^4.0.0-alpha.7",
|
|
29
29
|
"shelljs": "^0.8.4",
|
|
30
|
-
"
|
|
30
|
+
"simple-proxy-agent": "^1.1.0",
|
|
31
31
|
"sqlite": "^4.0.23",
|
|
32
32
|
"sqlite3": "^5.0.2"
|
|
33
33
|
},
|