gologin 2.0.2 → 2.0.5
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/README.md +3 -3
- package/example.js +6 -3
- package/examples/example-amazon-goless.js +1 -1
- package/examples/example-amazon-headless.js +1 -1
- package/examples/example-amazon.js +1 -1
- package/examples/example-fast-profile-settings.js +69 -0
- package/examples/example-gmail.js +1 -1
- package/examples/example-local-profile.js +1 -1
- package/examples/example-login-walmart.js +1 -1
- package/examples/example-timezone.js +1 -1
- package/package.json +2 -3
- package/src/browser/browser-api.js +71 -0
- package/{browser-checker.js → src/browser/browser-checker.js} +0 -0
- package/{browser-user-data-manager.js → src/browser/browser-user-data-manager.js} +1 -1
- package/{cookies-manager.js → src/cookies/cookies-manager.js} +0 -0
- package/{extensions-extractor.js → src/extensions/extensions-extractor.js} +0 -0
- package/{extensions-manager.js → src/extensions/extensions-manager.js} +3 -3
- package/{user-extensions-manager.js → src/extensions/user-extensions-manager.js} +4 -2
- package/{gologin.js → src/gologin.js} +25 -17
- package/{profile-archiver.js → src/profile/profile-archiver.js} +0 -0
- package/{profile-directories-to-remove.js → src/profile/profile-directories-to-remove.js} +0 -0
- package/{common.js → src/utils/common.js} +3 -1
- package/src/utils/utils.js +11 -0
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ To have an access to the page below you need <a href="https://app.gologin.com/#/
|
|
|
25
25
|
```js
|
|
26
26
|
import puppeteer from 'puppeteer-core';
|
|
27
27
|
|
|
28
|
-
import GoLogin from '
|
|
28
|
+
import GoLogin from '../src/gologin.js';
|
|
29
29
|
|
|
30
30
|
const { connect } = puppeteer;
|
|
31
31
|
|
|
@@ -82,7 +82,7 @@ const { connect } = puppeteer;
|
|
|
82
82
|
- `skipOrbitaHashChecking` <[boolean]> skip hash checking for Orbita after downloading process (default false)
|
|
83
83
|
|
|
84
84
|
```js
|
|
85
|
-
import GoLogin from '
|
|
85
|
+
import GoLogin from '../src/gologin.js';
|
|
86
86
|
const GL = new GoLogin({
|
|
87
87
|
token: 'yU0token',
|
|
88
88
|
profile_id: 'yU0Pr0f1leiD',
|
|
@@ -130,7 +130,7 @@ stop current browser without removing archived profile
|
|
|
130
130
|
```js
|
|
131
131
|
import puppeteer from 'puppeteer-core';
|
|
132
132
|
|
|
133
|
-
import GoLogin from '
|
|
133
|
+
import GoLogin from '../src/gologin.js';
|
|
134
134
|
|
|
135
135
|
const { connect } = puppeteer;
|
|
136
136
|
|
package/example.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import puppeteer from 'puppeteer-core';
|
|
2
2
|
|
|
3
|
-
import GoLogin from './gologin.js';
|
|
3
|
+
import GoLogin from './src/gologin.js';
|
|
4
|
+
|
|
5
|
+
const token = 'yU0token';
|
|
6
|
+
const profile_id = 'yU0Pr0f1leiD';
|
|
4
7
|
|
|
5
8
|
(async () => {
|
|
6
9
|
const GL = new GoLogin({
|
|
7
|
-
token
|
|
8
|
-
profile_id
|
|
10
|
+
token,
|
|
11
|
+
profile_id,
|
|
9
12
|
});
|
|
10
13
|
|
|
11
14
|
const { status, wsUrl } = await GL.start().catch((e) => {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import puppeteer from 'puppeteer-core';
|
|
2
|
+
|
|
3
|
+
import { updateProfileProxy, updateProfileResolution, updateProfileUserAgent } from '../src/browser/browser-api.js';
|
|
4
|
+
import GoLogin from '../src/gologin.js';
|
|
5
|
+
|
|
6
|
+
const token = 'yU0token';
|
|
7
|
+
const profile_id = 'yU0Pr0f1leiD';
|
|
8
|
+
|
|
9
|
+
(async () => {
|
|
10
|
+
const GL = new GoLogin({
|
|
11
|
+
token,
|
|
12
|
+
profile_id,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const { status, wsUrl } = await GL.start().catch((e) => {
|
|
16
|
+
console.trace(e);
|
|
17
|
+
|
|
18
|
+
return { status: 'failure' };
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (status !== 'success') {
|
|
22
|
+
console.log('Invalid status');
|
|
23
|
+
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const browser = await puppeteer.connect({
|
|
28
|
+
browserWSEndpoint: wsUrl.toString(),
|
|
29
|
+
ignoreHTTPSErrors: true,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const page = await browser.newPage();
|
|
33
|
+
await page.goto('https://myip.link/mini');
|
|
34
|
+
console.log(await page.content());
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @see updateProfileProxy
|
|
38
|
+
*/
|
|
39
|
+
const proxyData = {
|
|
40
|
+
mode: 'none',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
await GL.changeProfileProxy(proxyData);
|
|
44
|
+
|
|
45
|
+
await GL.changeProfileResolution('1920x1080');
|
|
46
|
+
|
|
47
|
+
const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.5359.71 Safari/537.36';
|
|
48
|
+
await GL.changeProfileUserAgent(userAgent);
|
|
49
|
+
|
|
50
|
+
await browser.close();
|
|
51
|
+
await GL.stop();
|
|
52
|
+
})();
|
|
53
|
+
|
|
54
|
+
(async () => {
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @see updateProfileProxy
|
|
58
|
+
*/
|
|
59
|
+
const proxyData = {
|
|
60
|
+
mode: 'none',
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
await updateProfileProxy(profile_id, token, proxyData);
|
|
64
|
+
|
|
65
|
+
await updateProfileResolution(profile_id, token, '1920x1080');
|
|
66
|
+
|
|
67
|
+
const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.5359.71 Safari/537.36';
|
|
68
|
+
await updateProfileUserAgent(profile_id, token, userAgent);
|
|
69
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gologin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "A high-level API to control Orbita browser over GoLogin API",
|
|
5
|
-
"main": "./gologin.js",
|
|
5
|
+
"main": "./src/gologin.js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/gologinapp/gologin.git"
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"decompress": "^4.2.1",
|
|
21
21
|
"decompress-unzip": "^4.0.1",
|
|
22
22
|
"form-data": "^3.0.0",
|
|
23
|
-
"lodash": "^4.17.15",
|
|
24
23
|
"progress": "^2.0.3",
|
|
25
24
|
"puppeteer-core": "^2.1.1",
|
|
26
25
|
"request": "^2.88.2",
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import requestretry from 'requestretry';
|
|
2
|
+
|
|
3
|
+
import { API_URL } from '../utils/common.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {string} profileId
|
|
7
|
+
* @param {string} ACCESS_TOKEN
|
|
8
|
+
* @param {string} resolution
|
|
9
|
+
*/
|
|
10
|
+
export const updateProfileResolution = (profileId, ACCESS_TOKEN, resolution) =>
|
|
11
|
+
requestretry.patch(`${API_URL}/browser/${profileId}/resolution`, {
|
|
12
|
+
headers: {
|
|
13
|
+
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
14
|
+
'user-agent': 'gologin-api',
|
|
15
|
+
},
|
|
16
|
+
json: { resolution },
|
|
17
|
+
maxAttempts: 3,
|
|
18
|
+
retryDelay: 2000,
|
|
19
|
+
timeout: 10 * 1000,
|
|
20
|
+
}).catch((e) => {
|
|
21
|
+
console.log(e);
|
|
22
|
+
|
|
23
|
+
return { body: [] };
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} profileId
|
|
28
|
+
* @param {string} ACCESS_TOKEN
|
|
29
|
+
* @param {string} userAgent
|
|
30
|
+
*/
|
|
31
|
+
export const updateProfileUserAgent = (profileId, ACCESS_TOKEN, userAgent) =>
|
|
32
|
+
requestretry.patch(`${API_URL}/browser/${profileId}/ua`, {
|
|
33
|
+
headers: {
|
|
34
|
+
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
35
|
+
'user-agent': 'gologin-api',
|
|
36
|
+
},
|
|
37
|
+
json: { userAgent },
|
|
38
|
+
maxAttempts: 3,
|
|
39
|
+
retryDelay: 2000,
|
|
40
|
+
timeout: 10 * 1000,
|
|
41
|
+
}).catch((e) => {
|
|
42
|
+
console.log(e);
|
|
43
|
+
|
|
44
|
+
return { body: [] };
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {string} profileId
|
|
49
|
+
* @param {string} ACCESS_TOKEN
|
|
50
|
+
* @param {Object} browserProxyData
|
|
51
|
+
* @param {'http' | 'socks4' | 'socks5' | 'none'} browserProxyData.mode
|
|
52
|
+
* @param {string} [browserProxyData.host]
|
|
53
|
+
* @param {string} [browserProxyData.port]
|
|
54
|
+
* @param {string} [browserProxyData.username]
|
|
55
|
+
* @param {string} [browserProxyData.password]
|
|
56
|
+
*/
|
|
57
|
+
export const updateProfileProxy = (profileId, ACCESS_TOKEN, browserProxyData) =>
|
|
58
|
+
requestretry.patch(`${API_URL}/browser/${profileId}/proxy`, {
|
|
59
|
+
headers: {
|
|
60
|
+
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
61
|
+
'user-agent': 'gologin-api',
|
|
62
|
+
},
|
|
63
|
+
json: browserProxyData,
|
|
64
|
+
maxAttempts: 3,
|
|
65
|
+
retryDelay: 2000,
|
|
66
|
+
timeout: 10 * 1000,
|
|
67
|
+
}).catch((e) => {
|
|
68
|
+
console.log(e);
|
|
69
|
+
|
|
70
|
+
return { body: [] };
|
|
71
|
+
});
|
|
File without changes
|
|
@@ -4,7 +4,7 @@ import { homedir, tmpdir } from 'os';
|
|
|
4
4
|
import { join, resolve, sep } from 'path';
|
|
5
5
|
import requestretry from 'requestretry';
|
|
6
6
|
|
|
7
|
-
import { fontsCollection } from '
|
|
7
|
+
import { fontsCollection } from '../../fonts.js';
|
|
8
8
|
|
|
9
9
|
const { access, readFile, writeFile, mkdir, readdir, copyFile, rename } = _promises;
|
|
10
10
|
|
|
File without changes
|
|
File without changes
|
|
@@ -2,13 +2,13 @@ import { createWriteStream, promises as _promises } from 'fs';
|
|
|
2
2
|
import { join, sep } from 'path';
|
|
3
3
|
import request from 'requestretry';
|
|
4
4
|
|
|
5
|
-
import { CHROME_EXTENSIONS_PATH, composeExtractionPromises, USER_EXTENSIONS_PATH } from '
|
|
5
|
+
import { CHROME_EXTENSIONS_PATH, composeExtractionPromises, USER_EXTENSIONS_PATH } from '../utils/common.js';
|
|
6
6
|
import UserExtensionsManager from './user-extensions-manager.js';
|
|
7
7
|
|
|
8
8
|
const { mkdir, readdir, rmdir, unlink } = _promises;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const EXTENSION_URL =
|
|
11
|
+
'https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&x=id%3D{ext_id}%26uc&prodversion=97.0.4692.71';
|
|
12
12
|
|
|
13
13
|
export class ExtensionsManager extends UserExtensionsManager {
|
|
14
14
|
#existedChromeExtensions = [];
|
|
@@ -2,7 +2,7 @@ import { createWriteStream, promises as _promises } from 'fs';
|
|
|
2
2
|
import { join, sep } from 'path';
|
|
3
3
|
import request from 'requestretry';
|
|
4
4
|
|
|
5
|
-
import { CHROME_EXTENSIONS_PATH, composeExtractionPromises, USER_EXTENSIONS_PATH } from '
|
|
5
|
+
import { CHROME_EXTENSIONS_PATH, composeExtractionPromises, USER_EXTENSIONS_PATH } from '../utils/common.js';
|
|
6
6
|
|
|
7
7
|
const { readdir, readFile, stat, mkdir, copyFile } = _promises;
|
|
8
8
|
|
|
@@ -73,7 +73,7 @@ export class UserExtensionsManager {
|
|
|
73
73
|
this.#existedUserExtensions = fileList;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
checkLocalUserChromeExtensions = async (userChromeExtensions) => {
|
|
76
|
+
checkLocalUserChromeExtensions = async (userChromeExtensions, profileId) => {
|
|
77
77
|
if (!userChromeExtensions.length) {
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
@@ -88,6 +88,8 @@ export class UserExtensionsManager {
|
|
|
88
88
|
},
|
|
89
89
|
body: {
|
|
90
90
|
existedUserChromeExtensions: this.#existedUserExtensions,
|
|
91
|
+
profileId,
|
|
92
|
+
userChromeExtensions,
|
|
91
93
|
},
|
|
92
94
|
}) || [];
|
|
93
95
|
|
|
@@ -4,7 +4,6 @@ import decompress from 'decompress';
|
|
|
4
4
|
import decompressUnzip from 'decompress-unzip';
|
|
5
5
|
import { existsSync, mkdirSync, promises as _promises } from 'fs';
|
|
6
6
|
import { get as _get } from 'https';
|
|
7
|
-
import lodash from 'lodash';
|
|
8
7
|
import { tmpdir } from 'os';
|
|
9
8
|
import { join, resolve as _resolve,sep } from 'path';
|
|
10
9
|
import requests from 'requestretry';
|
|
@@ -12,21 +11,22 @@ import rimraf from 'rimraf';
|
|
|
12
11
|
import ProxyAgent from 'simple-proxy-agent';
|
|
13
12
|
import util from 'util';
|
|
14
13
|
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
import {
|
|
14
|
+
import { fontsCollection } from '../fonts.js';
|
|
15
|
+
import { updateProfileProxy, updateProfileResolution, updateProfileUserAgent } from './browser/browser-api.js';
|
|
16
|
+
import BrowserChecker from './browser/browser-checker.js';
|
|
17
|
+
import { composeFonts, downloadCookies, setExtPathsAndRemoveDeleted,
|
|
18
|
+
setOriginalExtPaths, uploadCookies } from './browser/browser-user-data-manager.js';
|
|
19
|
+
import { getChunckedInsertValues, getDB, loadCookiesFromFile } from './cookies/cookies-manager.js';
|
|
20
|
+
import ExtensionsManager from './extensions/extensions-manager.js';
|
|
21
|
+
import { archiveProfile } from './profile/profile-archiver.js';
|
|
22
|
+
import { API_URL } from './utils/common.js';
|
|
23
|
+
import { get } from './utils/utils.js';
|
|
21
24
|
|
|
22
25
|
const exec = util.promisify(execNonPromise);
|
|
23
26
|
|
|
24
27
|
const { access, unlink, writeFile, readFile } = _promises;
|
|
25
|
-
const { get, merge } = lodash;
|
|
26
28
|
|
|
27
29
|
const SEPARATOR = sep;
|
|
28
|
-
const API_URL = 'https://api.gologin.com';
|
|
29
|
-
// const API_URL = 'http://localhost:3002';
|
|
30
30
|
const OS_PLATFORM = process.platform;
|
|
31
31
|
|
|
32
32
|
// process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
|
@@ -442,7 +442,7 @@ export class GoLogin {
|
|
|
442
442
|
|
|
443
443
|
return { profileExtensionsCheckRes: [] };
|
|
444
444
|
}),
|
|
445
|
-
ExtensionsManagerInst.checkLocalUserChromeExtensions(userChromeExtensions)
|
|
445
|
+
ExtensionsManagerInst.checkLocalUserChromeExtensions(userChromeExtensions, this.profile_id)
|
|
446
446
|
.then(res => ({ profileUserExtensionsCheckRes: res }))
|
|
447
447
|
.catch((error) => {
|
|
448
448
|
console.log('checkUserChromeExtensions error: ', error);
|
|
@@ -596,14 +596,10 @@ export class GoLogin {
|
|
|
596
596
|
preferences.gologin.langHeader = gologin.language;
|
|
597
597
|
preferences.gologin.languages = languages;
|
|
598
598
|
// debug("convertedPreferences=", preferences.gologin)
|
|
599
|
-
await writeFile(join(profilePath, 'Default', 'Preferences'), JSON.stringify(
|
|
599
|
+
await writeFile(join(profilePath, 'Default', 'Preferences'), JSON.stringify(Object.assign(preferences, {
|
|
600
600
|
gologin,
|
|
601
601
|
})));
|
|
602
602
|
|
|
603
|
-
// console.log('gologin=', _.merge(preferences, {
|
|
604
|
-
// gologin
|
|
605
|
-
// }));
|
|
606
|
-
|
|
607
603
|
debug('Profile ready. Path: ', profilePath, 'PROXY', JSON.stringify(get(preferences, 'gologin.proxy')));
|
|
608
604
|
|
|
609
605
|
return profilePath;
|
|
@@ -1379,7 +1375,7 @@ export class GoLogin {
|
|
|
1379
1375
|
};
|
|
1380
1376
|
|
|
1381
1377
|
const wsUrl = await this.waitDebuggingUrl(delay_ms);
|
|
1382
|
-
if (wsUrl
|
|
1378
|
+
if (wsUrl !== '') {
|
|
1383
1379
|
return { 'status': 'success', wsUrl };
|
|
1384
1380
|
}
|
|
1385
1381
|
|
|
@@ -1405,6 +1401,18 @@ export class GoLogin {
|
|
|
1405
1401
|
.filter(elem => elem.fileNames)
|
|
1406
1402
|
.map(elem => elem.name);
|
|
1407
1403
|
}
|
|
1404
|
+
|
|
1405
|
+
async changeProfileResolution(resolution) {
|
|
1406
|
+
return updateProfileResolution(this.profile_id, this.access_token, resolution);
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
async changeProfileUserAgent(userAgent) {
|
|
1410
|
+
return updateProfileUserAgent(this.profile_id, this.access_token, userAgent);
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
async changeProfileProxy(proxyData) {
|
|
1414
|
+
return updateProfileProxy(this.profile_id, this.access_token, proxyData);
|
|
1415
|
+
}
|
|
1408
1416
|
}
|
|
1409
1417
|
|
|
1410
1418
|
export default GoLogin;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { homedir } from 'os';
|
|
2
2
|
import { join, sep } from 'path';
|
|
3
3
|
|
|
4
|
-
import { deleteExtensionArchive, extractExtension } from '
|
|
4
|
+
import { deleteExtensionArchive, extractExtension } from '../extensions/extensions-extractor.js';
|
|
5
|
+
|
|
6
|
+
export const API_URL = 'https://api.gologin.com';
|
|
5
7
|
|
|
6
8
|
const HOMEDIR = homedir();
|
|
7
9
|
const CHROME_EXT_DIR_NAME = 'chrome-extensions';
|