gologin 2.0.22 → 2.0.24
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/.eslintrc.json +1 -10
- package/examples/example-custom-args.js +34 -0
- package/package.json +1 -1
- package/src/gologin.js +18 -35
- package/src/utils/constants.js +1 -0
package/.eslintrc.json
CHANGED
|
@@ -30,10 +30,7 @@
|
|
|
30
30
|
]
|
|
31
31
|
}
|
|
32
32
|
],
|
|
33
|
-
"linebreak-style":
|
|
34
|
-
"warn",
|
|
35
|
-
"windows"
|
|
36
|
-
],
|
|
33
|
+
"linebreak-style": 0,
|
|
37
34
|
"quotes": [
|
|
38
35
|
"warn",
|
|
39
36
|
"single"
|
|
@@ -55,12 +52,6 @@
|
|
|
55
52
|
"warn",
|
|
56
53
|
"as-needed"
|
|
57
54
|
],
|
|
58
|
-
"camelcase": [
|
|
59
|
-
"warn",
|
|
60
|
-
{
|
|
61
|
-
"ignoreGlobals": true
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
55
|
"curly": [
|
|
65
56
|
"warn",
|
|
66
57
|
"all"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import puppeteer from 'puppeteer-core';
|
|
2
|
+
|
|
3
|
+
import GoLogin from '../src/gologin.js';
|
|
4
|
+
|
|
5
|
+
(async () => {
|
|
6
|
+
const GL = new GoLogin({
|
|
7
|
+
profile_id: 'yU0Pr0f1leiD',
|
|
8
|
+
token: 'yU0token',
|
|
9
|
+
args: ['--disable-background-timer-throttling', '--disable-backgrounding-occluded-windows', '--disable-renderer-backgrounding'],
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const { status, wsUrl } = await GL.start().catch((e) => {
|
|
13
|
+
console.trace(e);
|
|
14
|
+
|
|
15
|
+
return { status: 'failure' };
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
if (status !== 'success') {
|
|
19
|
+
console.log('Invalid status');
|
|
20
|
+
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const browser = await puppeteer.connect({
|
|
25
|
+
browserWSEndpoint: wsUrl.toString(),
|
|
26
|
+
ignoreHTTPSErrors: true,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const page = await browser.newPage();
|
|
30
|
+
await page.goto('https://myip.link/mini');
|
|
31
|
+
console.log(await page.content());
|
|
32
|
+
await browser.close();
|
|
33
|
+
await GL.stop();
|
|
34
|
+
})();
|
package/package.json
CHANGED
package/src/gologin.js
CHANGED
|
@@ -19,14 +19,15 @@ import {
|
|
|
19
19
|
} from './browser/browser-user-data-manager.js';
|
|
20
20
|
import {
|
|
21
21
|
getChunckedInsertValues,
|
|
22
|
+
getCookiesFilePath,
|
|
22
23
|
getDB,
|
|
23
24
|
loadCookiesFromFile,
|
|
24
|
-
getCookiesFilePath,
|
|
25
25
|
} from './cookies/cookies-manager.js';
|
|
26
26
|
import ExtensionsManager from './extensions/extensions-manager.js';
|
|
27
27
|
import { archiveProfile } from './profile/profile-archiver.js';
|
|
28
28
|
import { checkAutoLang } from './utils/browser.js';
|
|
29
29
|
import { API_URL } from './utils/common.js';
|
|
30
|
+
import { STORAGE_GATEWAY_BASE_URL } from './utils/constants.js';
|
|
30
31
|
import { get, isPortReachable } from './utils/utils.js';
|
|
31
32
|
|
|
32
33
|
const { access, unlink, writeFile, readFile } = _promises;
|
|
@@ -73,6 +74,7 @@ export class GoLogin {
|
|
|
73
74
|
this.remote_debugging_port = options.remote_debugging_port || 0;
|
|
74
75
|
this.timezone = options.timezone;
|
|
75
76
|
this.extensionPathsToInstall = [];
|
|
77
|
+
this.customArgs = options.args || [];
|
|
76
78
|
this.restoreLastSession = options.restoreLastSession || false;
|
|
77
79
|
this.processSpawned = null;
|
|
78
80
|
this.processKillTimeout = 1 * 1000;
|
|
@@ -196,15 +198,19 @@ export class GoLogin {
|
|
|
196
198
|
|
|
197
199
|
const token = this.access_token;
|
|
198
200
|
debug('getProfileS3 token=', token, 'profile=', this.profile_id, 's3path=', s3path);
|
|
201
|
+
const downloadURL = `${STORAGE_GATEWAY_BASE_URL}/download`;
|
|
199
202
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const profileResponse = await requests.get(s3url, {
|
|
203
|
+
debug('loading profile from public s3 bucket, url=', downloadURL);
|
|
204
|
+
const profileResponse = await requests.get(downloadURL, {
|
|
203
205
|
encoding: null,
|
|
206
|
+
headers: {
|
|
207
|
+
Authorization: `Bearer ${token}`,
|
|
208
|
+
browserId: this.profile_id,
|
|
209
|
+
},
|
|
204
210
|
});
|
|
205
211
|
|
|
206
212
|
if (profileResponse.statusCode !== 200) {
|
|
207
|
-
debug(`Gologin S3 BUCKET ${
|
|
213
|
+
debug(`Gologin S3 BUCKET ${downloadURL} response error ${profileResponse.statusCode} - use empty`);
|
|
208
214
|
|
|
209
215
|
return '';
|
|
210
216
|
}
|
|
@@ -215,27 +221,15 @@ export class GoLogin {
|
|
|
215
221
|
async postFile(fileName, fileBuff) {
|
|
216
222
|
debug('POSTING FILE', fileBuff.length);
|
|
217
223
|
debug('Getting signed URL for S3');
|
|
218
|
-
const apiUrl = `${
|
|
224
|
+
const apiUrl = `${STORAGE_GATEWAY_BASE_URL}/upload`;
|
|
219
225
|
|
|
220
|
-
const signedUrl = await requests.get(apiUrl, {
|
|
221
|
-
headers: {
|
|
222
|
-
Authorization: `Bearer ${this.access_token}`,
|
|
223
|
-
'user-agent': 'gologin-api',
|
|
224
|
-
},
|
|
225
|
-
maxAttempts: 3,
|
|
226
|
-
retryDelay: 2000,
|
|
227
|
-
timeout: 10 * 1000,
|
|
228
|
-
fullResponse: false,
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
const [uploadedProfileUrl] = signedUrl.split('?');
|
|
232
|
-
|
|
233
|
-
console.log('Uploading profile by signed URL to S3');
|
|
234
226
|
const bodyBufferBiteLength = Buffer.byteLength(fileBuff);
|
|
235
227
|
console.log('BUFFER SIZE', bodyBufferBiteLength);
|
|
236
228
|
|
|
237
|
-
await requests.put(
|
|
229
|
+
await requests.put(apiUrl, {
|
|
238
230
|
headers: {
|
|
231
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
232
|
+
browserId: this.profile_id,
|
|
239
233
|
'Content-Type': 'application/zip',
|
|
240
234
|
'Content-Length': bodyBufferBiteLength,
|
|
241
235
|
},
|
|
@@ -248,19 +242,6 @@ export class GoLogin {
|
|
|
248
242
|
fullResponse: false,
|
|
249
243
|
});
|
|
250
244
|
|
|
251
|
-
const uploadedProfileMetadata = await requests.head(uploadedProfileUrl, {
|
|
252
|
-
maxAttempts: 3,
|
|
253
|
-
retryDelay: 2000,
|
|
254
|
-
timeout: 10 * 1000,
|
|
255
|
-
fullResponse: true,
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
const uploadedFileLength = +uploadedProfileMetadata.headers['content-length'];
|
|
259
|
-
if (uploadedFileLength !== bodyBufferBiteLength) {
|
|
260
|
-
console.log('Uploaded file is incorrect. Retry with China File size:', uploadedFileLength);
|
|
261
|
-
throw new Error('Uploaded file is incorrect. Retry with China File size: ' + uploadedFileLength);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
245
|
console.log('Profile has been uploaded to S3 successfully');
|
|
265
246
|
}
|
|
266
247
|
|
|
@@ -837,7 +818,7 @@ export class GoLogin {
|
|
|
837
818
|
}
|
|
838
819
|
|
|
839
820
|
async spawnBrowser() {
|
|
840
|
-
let { remote_debugging_port } = this;
|
|
821
|
+
let { remote_debugging_port, customArgs } = this;
|
|
841
822
|
if (!remote_debugging_port) {
|
|
842
823
|
remote_debugging_port = await this.getRandomPort();
|
|
843
824
|
}
|
|
@@ -928,6 +909,8 @@ export class GoLogin {
|
|
|
928
909
|
params.push('--restore-last-session');
|
|
929
910
|
}
|
|
930
911
|
|
|
912
|
+
params.push(...new Set(customArgs));
|
|
913
|
+
|
|
931
914
|
console.log(params);
|
|
932
915
|
const child = execFile(ORBITA_BROWSER, params, { env });
|
|
933
916
|
this.processSpawned = child;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const STORAGE_GATEWAY_BASE_URL = 'https://files-gateway.gologin.com';
|