gologin 2.1.22 → 2.1.23
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 +13 -1
- package/.github/workflows/e2e-tests.yml +37 -0
- package/CHANGELOG.md +16 -0
- package/README.md +4 -47
- package/docker-compose.yml +32 -0
- package/docs/PRIVACY.md +36 -0
- package/index.d.ts +40 -15
- package/package.json +6 -2
- package/src/browser/browser-api.js +22 -23
- package/src/browser/browser-checker.js +38 -33
- package/src/browser/browser-user-data-manager.js +13 -12
- package/src/extensions/extensions-manager.js +21 -26
- package/src/extensions/user-extensions-manager.js +6 -8
- package/src/gologin-api.js +41 -98
- package/src/gologin.js +139 -214
- package/src/utils/common.js +1 -0
- package/src/utils/http.js +55 -0
- package/test/e2e/run-tests.js +73 -0
- package/types/profile-params.d.ts +3 -4
- package/gologin-browser-ext.zip +0 -0
- package/gologin_zeroprofile.b64 +0 -1
- package/profile_export_example.csv +0 -2
- package/zero_profile.zip +0 -0
package/.eslintrc.json
CHANGED
|
@@ -6,9 +6,21 @@
|
|
|
6
6
|
},
|
|
7
7
|
"extends": "eslint:recommended",
|
|
8
8
|
"overrides": [
|
|
9
|
+
{
|
|
10
|
+
"files": [
|
|
11
|
+
"*.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"parser": "@typescript-eslint/parser",
|
|
14
|
+
"plugins": [
|
|
15
|
+
"@typescript-eslint"
|
|
16
|
+
],
|
|
17
|
+
"rules": {
|
|
18
|
+
"no-unused-vars": "off"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
9
21
|
],
|
|
10
22
|
"parserOptions": {
|
|
11
|
-
"ecmaVersion":
|
|
23
|
+
"ecmaVersion": 2020,
|
|
12
24
|
"sourceType": "module"
|
|
13
25
|
},
|
|
14
26
|
"plugins": [
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Test App
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
timeout-minutes: 10
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [18.x]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v1
|
|
19
|
+
|
|
20
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
21
|
+
uses: actions/setup-node@v1
|
|
22
|
+
with:
|
|
23
|
+
node-version: ${{ matrix.node-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install system dependencies
|
|
26
|
+
run: |
|
|
27
|
+
sudo apt-get update
|
|
28
|
+
sudo apt-get install -y libnss3 libatk-bridge2.0-0 libdrm2 libxkbcommon0 libgbm1 libxss1 libasound2t64 fonts-liberation libcups2 libxcomposite1 libxdamage1 libxrandr2 libxfixes3 libxtst6 libxi6 libx11-xcb1 libx11-6 libxcb1 libxext6 libxrender1 libcairo2 libglib2.0-0 libgtk-3-0 libgdk-pixbuf2.0-0 libpango-1.0-0 libpangocairo-1.0-0 libatk1.0-0 libcairo-gobject2 libxshmfence1 libgl1-mesa-dri libegl1 libxau6 libxdmcp6 libappindicator3-1 xdg-utils
|
|
29
|
+
|
|
30
|
+
- name: Run and test app
|
|
31
|
+
working-directory: ./
|
|
32
|
+
run: |
|
|
33
|
+
npm install
|
|
34
|
+
npm run test:e2e
|
|
35
|
+
env:
|
|
36
|
+
GL_API_TOKEN: ${{ secrets.GL_API_TOKEN }}
|
|
37
|
+
GOLOGIN_PROFILE_ID: ${{ secrets.GOLOGIN_PROFILE_ID }}
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Combined changelog for GoLogin node.js SDK
|
|
4
4
|
|
|
5
|
+
## [2.1.23] 2025-06-09
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Fixes
|
|
9
|
+
|
|
10
|
+
* Viewport of puppeteer complies with profile resolution
|
|
11
|
+
|
|
12
|
+
### New
|
|
13
|
+
|
|
14
|
+
* Added fallback url for blocked countries
|
|
15
|
+
|
|
16
|
+
### Miscellaneous Chores
|
|
17
|
+
|
|
18
|
+
* Added sentry to have information about errors that users face
|
|
19
|
+
|
|
20
|
+
|
|
5
21
|
## [2.1.21] 2025-04-23
|
|
6
22
|
|
|
7
23
|
|
package/README.md
CHANGED
|
@@ -184,56 +184,13 @@ For debugging use `DEBUG=* node example.js` command
|
|
|
184
184
|
To use GoLogin with Selenium see `selenium/example.js`
|
|
185
185
|
|
|
186
186
|
## Full GoLogin API
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
**Postman:** <a href="https://documenter.getpostman.com/view/21126834/Uz5GnvaL" target="_blank">link here</a>
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
## For local profiles
|
|
193
|
-
|
|
194
|
-
#### startLocal()
|
|
195
|
-
|
|
196
|
-
- returns: string
|
|
197
|
-
|
|
198
|
-
start browser with profile id, return WebSocket url for puppeteer. Extracted profile folder should be in specified temp directory.
|
|
199
|
-
|
|
200
|
-
#### stopLocal()
|
|
201
|
-
|
|
202
|
-
stop current browser without removing archived profile
|
|
203
|
-
|
|
204
|
-
### example-local-profile.js
|
|
205
|
-
|
|
206
|
-
```js
|
|
207
|
-
import puppeteer from 'puppeteer-core';
|
|
208
|
-
|
|
209
|
-
import GoLogin from '../src/gologin.js';
|
|
210
|
-
|
|
211
|
-
const { connect } = puppeteer;
|
|
212
|
-
|
|
213
|
-
(async () => {
|
|
214
|
-
const GL = new GoLogin({
|
|
215
|
-
token: 'yU0token',
|
|
216
|
-
profile_id: 'yU0Pr0f1leiD',
|
|
217
|
-
executablePath: '/usr/bin/orbita-browser/chrome',
|
|
218
|
-
tmpdir: '/my/tmp/dir',
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
const wsUrl = await GL.startLocal();
|
|
222
|
-
const browser = await connect({
|
|
223
|
-
browserWSEndpoint: wsUrl.toString(),
|
|
224
|
-
ignoreHTTPSErrors: true,
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
const page = await browser.newPage();
|
|
228
|
-
await page.goto('https://myip.link');
|
|
229
|
-
console.log(await page.content());
|
|
230
|
-
await browser.close();
|
|
231
|
-
await GL.stopLocal({ posting: false });
|
|
232
|
-
})();
|
|
233
|
-
```
|
|
187
|
+
<a href="https://gologin.com/docs/api-reference/profile/get-all-profiles" target="_blank">Gologin Api Documentation</a>
|
|
234
188
|
|
|
235
189
|
## Python support
|
|
236
190
|
|
|
237
191
|
<a href="https://github.com/pyppeteer/pyppeteer" target="_blank">pyppeteer</a> (recommend) and <a href="https://www.selenium.dev" target="_blank">Selenium</a> supported (see file gologin.py)
|
|
238
192
|
|
|
239
193
|
for Selenium may need download <a href="https://chromedriver.chromium.org/downloads" target="_blank">webdriver</a>
|
|
194
|
+
|
|
195
|
+
## Privacy
|
|
196
|
+
Our full privacy policy you can finde <a href="https://github.com/gologinapp/gologin/blob/master/docs/PRIVACY.md">here</a>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
version: '3.8'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
gologin-browser:
|
|
5
|
+
image: node:18-bullseye
|
|
6
|
+
platform: linux/amd64
|
|
7
|
+
container_name: gologin-browser
|
|
8
|
+
working_dir: /app
|
|
9
|
+
volumes:
|
|
10
|
+
- .:/app
|
|
11
|
+
- node_modules_cache:/app/node_modules
|
|
12
|
+
environment:
|
|
13
|
+
- GL_API_TOKEN=your_token_here
|
|
14
|
+
- NODE_ENV=development
|
|
15
|
+
ports:
|
|
16
|
+
- "9222:9222"
|
|
17
|
+
command: >
|
|
18
|
+
sh -c "
|
|
19
|
+
apt-get update &&
|
|
20
|
+
apt-get install -y libnss3 libatk-bridge2.0-0 libdrm2 libxkbcommon0 libgbm1 libxss1 libasound2 fonts-liberation libcups2 libxcomposite1 libxdamage1 libxrandr2 libxfixes3 libxtst6 libxi6 libx11-xcb1 libx11-6 libxcb1 libxext6 libxrender1 libcairo2 libglib2.0-0 libgtk-3-0 libgdk-pixbuf2.0-0 libpango-1.0-0 libpangocairo-1.0-0 libatk1.0-0 libcairo-gobject2 libgconf-2-4 libxshmfence1 libgl1-mesa-glx libgl1-mesa-dri libegl1-mesa libxau6 libxdmcp6 libappindicator3-1 xdg-utils &&
|
|
21
|
+
npm install &&
|
|
22
|
+
npm run test:e2e
|
|
23
|
+
"
|
|
24
|
+
networks:
|
|
25
|
+
- gologin-network
|
|
26
|
+
|
|
27
|
+
volumes:
|
|
28
|
+
node_modules_cache:
|
|
29
|
+
|
|
30
|
+
networks:
|
|
31
|
+
gologin-network:
|
|
32
|
+
driver: bridge
|
package/docs/PRIVACY.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Privacy Policy
|
|
2
|
+
|
|
3
|
+
## Data Collection
|
|
4
|
+
|
|
5
|
+
### Error Reporting
|
|
6
|
+
|
|
7
|
+
We collect error information to improve the stability and performance of our application. Error data is sent to our self-hosted Sentry instance
|
|
8
|
+
|
|
9
|
+
**What we collect:**
|
|
10
|
+
- Error logs and stack traces only when application errors occur
|
|
11
|
+
- Basic hardware information (CPU architecture, memory usage)
|
|
12
|
+
- Software environment details (operating system, browser version)
|
|
13
|
+
- Application state at the time of error
|
|
14
|
+
|
|
15
|
+
**What we don't collect:**
|
|
16
|
+
- Personal user information
|
|
17
|
+
- User credentials or authentication data
|
|
18
|
+
- Private user content or files
|
|
19
|
+
- Browsing history or personal usage patterns
|
|
20
|
+
|
|
21
|
+
**When we collect data:**
|
|
22
|
+
- Only when application errors occur
|
|
23
|
+
- No continuous monitoring or tracking
|
|
24
|
+
- Data collection is limited to error scenarios
|
|
25
|
+
|
|
26
|
+
**Data storage:**
|
|
27
|
+
- All error data is stored on our self-hosted infrastructure
|
|
28
|
+
- Data is not shared with third-party services
|
|
29
|
+
- Error logs are retained for debugging and improvement purposes only
|
|
30
|
+
|
|
31
|
+
**How to disable error reporting:**
|
|
32
|
+
- Set environment variable: `DISABLE_TELEMETRY=true`
|
|
33
|
+
|
|
34
|
+
## Contact
|
|
35
|
+
|
|
36
|
+
If you have questions about this privacy policy or our data practices, please contact us.
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Browser } from 'puppeteer-core/lib/Browser';
|
|
2
2
|
|
|
3
3
|
import { CreateCustomBrowserValidation, BrowserProxyCreateValidation } from './types/profile-params';
|
|
4
4
|
|
|
@@ -12,10 +12,6 @@ export type OsType = (typeof OPERATING_SYSTEMS)[keyof typeof OPERATING_SYSTEMS];
|
|
|
12
12
|
|
|
13
13
|
type CloudLaunchParams = {
|
|
14
14
|
cloud: true;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Format: 'dataCenter:DE'
|
|
18
|
-
*/
|
|
19
15
|
geolocation?: string;
|
|
20
16
|
};
|
|
21
17
|
type LocalLaunchParams = {
|
|
@@ -36,14 +32,7 @@ type LaunchParams =
|
|
|
36
32
|
| ExistingProfileLaunchParams
|
|
37
33
|
| NewProfileLaunchParams
|
|
38
34
|
| {
|
|
39
|
-
/**
|
|
40
|
-
* default delay, 250
|
|
41
|
-
*/
|
|
42
35
|
defaultDelay: number;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Operating system
|
|
46
|
-
*/
|
|
47
36
|
os: OsType;
|
|
48
37
|
};
|
|
49
38
|
|
|
@@ -62,19 +51,55 @@ type Cookie = {
|
|
|
62
51
|
url?: string;
|
|
63
52
|
};
|
|
64
53
|
|
|
54
|
+
type TrafficData = {
|
|
55
|
+
trafficUsedBytes: number;
|
|
56
|
+
trafficLimitBytes: number;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type AvailableTrafficData = {
|
|
60
|
+
mobileTrafficData: TrafficData;
|
|
61
|
+
residentialTrafficData: TrafficData;
|
|
62
|
+
dataCenterTrafficData: TrafficData;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type ProxyType = 'mobile' | 'resident' | 'dataCenter';
|
|
66
|
+
|
|
67
|
+
type ProxyResponse = {
|
|
68
|
+
trafficLimitBytes: number;
|
|
69
|
+
trafficUsedBytes: number;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
type ProfileResponse = {
|
|
73
|
+
id: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
65
76
|
type GologinApiType = {
|
|
66
77
|
launch: (params?: LaunchParams) => Promise<{ browser: Browser }>;
|
|
67
|
-
|
|
78
|
+
createProfileWithCustomParams: (options: CreateCustomBrowserValidation) => Promise<string>;
|
|
79
|
+
refreshProfilesFingerprint: (profileIds: string[]) => Promise<any>;
|
|
80
|
+
createProfileRandomFingerprint: (name?: string) => Promise<ProfileResponse>;
|
|
81
|
+
updateUserAgentToLatestBrowser: (profileIds: string[], workspaceId?: string) => Promise<any>;
|
|
82
|
+
changeProfileProxy: (profileId: string, proxyData: BrowserProxyCreateValidation) => Promise<number>;
|
|
83
|
+
getAvailableType: (availableTrafficData: AvailableTrafficData) => ProxyType | 'none';
|
|
84
|
+
addGologinProxyToProfile: (profileId: string, countryCode: string, proxyType?: ProxyType | '') => Promise<ProxyResponse>;
|
|
85
|
+
addCookiesToProfile: (profileId: string, cookies: Cookie[]) => Promise<number>;
|
|
86
|
+
deleteProfile: (profileId: string) => Promise<number>;
|
|
87
|
+
exit: () => Promise<void>;
|
|
68
88
|
createCustom: (params: CreateCustomBrowserValidation) => Promise<string>;
|
|
69
89
|
updateProfileFingerprint: (profileId: string[]) => Promise<void>;
|
|
70
|
-
updateUserAgentToLatestBrowser: (profileIds: string[], workspaceId?: string) => Promise<void>;
|
|
71
90
|
updateProfileProxy: (profileId: string, proxyData: BrowserProxyCreateValidation) => Promise<void>;
|
|
72
|
-
addCookiesToProfile: (profileId: string, cookies: Cookie[]) => Promise<void>;
|
|
73
91
|
};
|
|
74
92
|
|
|
75
93
|
type GologinApiParams = {
|
|
76
94
|
token: string;
|
|
77
95
|
};
|
|
78
96
|
|
|
97
|
+
export declare function getDefaultParams(): {
|
|
98
|
+
token: string | undefined;
|
|
99
|
+
profile_id: string | undefined;
|
|
100
|
+
executablePath: string | undefined;
|
|
101
|
+
};
|
|
102
|
+
|
|
79
103
|
export declare function GologinApi(params: GologinApiParams): GologinApiType;
|
|
104
|
+
|
|
80
105
|
export declare function exitAll(): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gologin",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.23",
|
|
4
4
|
"description": "A high-level API to control Orbita browser over GoLogin API",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"main": "./src/gologin.js",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"author": "The GoLogin Authors",
|
|
16
16
|
"license": "GPL-3.0",
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@sentry/node": "^9.24.0",
|
|
18
19
|
"adm-zip": "^0.5.1",
|
|
19
20
|
"archiver": "^3.1.1",
|
|
20
21
|
"child_process": "^1.0.2",
|
|
@@ -42,7 +43,10 @@
|
|
|
42
43
|
"eslint-plugin-simple-import-sort": "^8.0.0"
|
|
43
44
|
},
|
|
44
45
|
"scripts": {
|
|
45
|
-
"test": "
|
|
46
|
+
"test": "npm run test:unit && npm run test:e2e",
|
|
47
|
+
"test:unit": "echo \"No unit tests specified\" && exit 0",
|
|
48
|
+
"test:e2e": "node test/e2e/run-tests.js",
|
|
49
|
+
"test:e2e:local": "HEADLESS=false npm run test:e2e",
|
|
46
50
|
"format": "npx prettier --single-quote src/* --write",
|
|
47
51
|
"iphey": "GOLOGIN_PROFILE_ID= GOLOGIN_API_TOKEN= node examples/example-iphey "
|
|
48
52
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { API_URL } from '../utils/common.js';
|
|
1
|
+
import { API_URL, FALLBACK_API_URL } from '../utils/common.js';
|
|
2
|
+
import { makeRequest } from '../utils/http.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* @param {string} profileId
|
|
@@ -8,15 +7,15 @@ import { API_URL } from '../utils/common.js';
|
|
|
8
7
|
* @param {string} resolution
|
|
9
8
|
*/
|
|
10
9
|
export const updateProfileResolution = (profileId, ACCESS_TOKEN, resolution) =>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
14
|
-
'user-agent': 'gologin-api',
|
|
15
|
-
},
|
|
10
|
+
makeRequest(`${API_URL}/browser/${profileId}/resolution`, {
|
|
11
|
+
method: 'PATCH',
|
|
16
12
|
json: { resolution },
|
|
17
13
|
maxAttempts: 3,
|
|
18
14
|
retryDelay: 2000,
|
|
19
15
|
timeout: 10 * 1000,
|
|
16
|
+
}, {
|
|
17
|
+
token: ACCESS_TOKEN,
|
|
18
|
+
fallbackUrl: `${FALLBACK_API_URL}/browser/${profileId}/resolution`,
|
|
20
19
|
}).catch((e) => {
|
|
21
20
|
console.log(e);
|
|
22
21
|
|
|
@@ -29,15 +28,15 @@ export const updateProfileResolution = (profileId, ACCESS_TOKEN, resolution) =>
|
|
|
29
28
|
* @param {string} userAgent
|
|
30
29
|
*/
|
|
31
30
|
export const updateProfileUserAgent = (profileId, ACCESS_TOKEN, userAgent) =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
35
|
-
'user-agent': 'gologin-api',
|
|
36
|
-
},
|
|
31
|
+
makeRequest(`${API_URL}/browser/${profileId}/ua`, {
|
|
32
|
+
method: 'PATCH',
|
|
37
33
|
json: { userAgent },
|
|
38
34
|
maxAttempts: 3,
|
|
39
35
|
retryDelay: 2000,
|
|
40
36
|
timeout: 10 * 1000,
|
|
37
|
+
}, {
|
|
38
|
+
token: ACCESS_TOKEN,
|
|
39
|
+
fallbackUrl: `${FALLBACK_API_URL}/browser/${profileId}/ua`,
|
|
41
40
|
}).catch((e) => {
|
|
42
41
|
console.log(e);
|
|
43
42
|
|
|
@@ -55,15 +54,15 @@ export const updateProfileUserAgent = (profileId, ACCESS_TOKEN, userAgent) =>
|
|
|
55
54
|
* @param {string} [browserProxyData.password]
|
|
56
55
|
*/
|
|
57
56
|
export const updateProfileProxy = (profileId, ACCESS_TOKEN, browserProxyData) =>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
61
|
-
'user-agent': 'gologin-api',
|
|
62
|
-
},
|
|
57
|
+
makeRequest(`${API_URL}/browser/${profileId}/proxy`, {
|
|
58
|
+
method: 'PATCH',
|
|
63
59
|
json: browserProxyData,
|
|
64
60
|
maxAttempts: 3,
|
|
65
61
|
retryDelay: 2000,
|
|
66
62
|
timeout: 10 * 1000,
|
|
63
|
+
}, {
|
|
64
|
+
token: ACCESS_TOKEN,
|
|
65
|
+
fallbackUrl: `${FALLBACK_API_URL}/browser/${profileId}/proxy`,
|
|
67
66
|
}).catch((e) => {
|
|
68
67
|
console.log(e);
|
|
69
68
|
|
|
@@ -81,15 +80,15 @@ export const updateProfileBookmarks = async (profileIds, ACCESS_TOKEN, bookmarks
|
|
|
81
80
|
bookmarks,
|
|
82
81
|
};
|
|
83
82
|
|
|
84
|
-
return
|
|
85
|
-
|
|
86
|
-
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
87
|
-
'user-agent': 'gologin-api',
|
|
88
|
-
},
|
|
83
|
+
return makeRequest(`${API_URL}/browser/bookmarks/many`, {
|
|
84
|
+
method: 'PATCH',
|
|
89
85
|
json: params,
|
|
90
86
|
maxAttempts: 3,
|
|
91
87
|
retryDelay: 2000,
|
|
92
88
|
timeout: 10 * 1000,
|
|
89
|
+
}, {
|
|
90
|
+
token: ACCESS_TOKEN,
|
|
91
|
+
fallbackUrl: `${FALLBACK_API_URL}/browser/bookmarks/many`,
|
|
93
92
|
}).catch((error) => console.log(error));
|
|
94
93
|
};
|
|
95
94
|
|
|
@@ -47,45 +47,50 @@ export class BrowserChecker {
|
|
|
47
47
|
|
|
48
48
|
async checkBrowser({ autoUpdateBrowser, checkBrowserUpdate, majorVersion }) {
|
|
49
49
|
const isBrowserFolderExists = await access(join(this.#browserPath, `orbita-browser-${majorVersion}`)).then(() => true).catch(() => false);
|
|
50
|
-
if (!isBrowserFolderExists) {
|
|
51
|
-
await this.downloadBrowser(majorVersion);
|
|
52
|
-
|
|
53
|
-
return this.getBrowserExecutablePath(majorVersion);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const { latestVersion: browserLatestVersion } = await this.getLatestBrowserVersion();
|
|
57
|
-
const [latestBrowserMajorVersion] = browserLatestVersion.split('.');
|
|
58
|
-
const currentVersion = await this.getCurrentVersion(majorVersion);
|
|
59
50
|
|
|
60
|
-
|
|
61
|
-
if (browserLatestVersion === currentVersion || !(checkBrowserUpdate && isCurrentVersionsLatest)) {
|
|
62
|
-
return this.getBrowserExecutablePath(majorVersion);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (autoUpdateBrowser) {
|
|
51
|
+
if (!isBrowserFolderExists || autoUpdateBrowser) {
|
|
66
52
|
await this.downloadBrowser(majorVersion);
|
|
67
53
|
|
|
68
54
|
return this.getBrowserExecutablePath(majorVersion);
|
|
69
55
|
}
|
|
70
56
|
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
57
|
+
return this.getBrowserExecutablePath(majorVersion);
|
|
58
|
+
|
|
59
|
+
// TO DO: add check for browser update
|
|
60
|
+
// const { latestVersion: browserLatestVersion } = await this.getLatestBrowserVersion();
|
|
61
|
+
// const [latestBrowserMajorVersion] = browserLatestVersion.split('.');
|
|
62
|
+
// const currentVersion = await this.getCurrentVersion(majorVersion);
|
|
63
|
+
|
|
64
|
+
// const isCurrentVersionsLatest = majorVersion === latestBrowserMajorVersion;
|
|
65
|
+
// console.log('browserLatestVersion', browserLatestVersion);
|
|
66
|
+
// console.log('currentVersion', currentVersion);
|
|
67
|
+
// console.log('isCurrentVersionsLatest', isCurrentVersionsLatest);
|
|
68
|
+
// console.log('checkBrowserUpdate', checkBrowserUpdate);
|
|
69
|
+
// console.log('autoUpdateBrowser', autoUpdateBrowser);
|
|
70
|
+
// if (browserLatestVersion === currentVersion || !(checkBrowserUpdate && isCurrentVersionsLatest)) {
|
|
71
|
+
// return this.getBrowserExecutablePath(majorVersion);
|
|
72
|
+
// }
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// return new Promise(resolve => {
|
|
77
|
+
// const rl = createInterface(process.stdin, process.stdout);
|
|
78
|
+
// const timeout = setTimeout(() => {
|
|
79
|
+
// console.log(`\nContinue with current ${currentVersion} version.`);
|
|
80
|
+
// resolve();
|
|
81
|
+
// }, 10000);
|
|
82
|
+
|
|
83
|
+
// rl.question(`New Orbita ${browserLatestVersion} is available. Update? [y/n] `, (answer) => {
|
|
84
|
+
// clearTimeout(timeout);
|
|
85
|
+
// rl.close();
|
|
86
|
+
// if (answer && answer[0].toString().toLowerCase() === 'y') {
|
|
87
|
+
// return this.downloadBrowser(majorVersion).then(() => resolve(this.getBrowserExecutablePath(majorVersion)));
|
|
88
|
+
// }
|
|
89
|
+
|
|
90
|
+
// console.log(`Continue with current ${currentVersion} version.`);
|
|
91
|
+
// resolve(this.getBrowserExecutablePath(majorVersion));
|
|
92
|
+
// });
|
|
93
|
+
// });
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
async downloadBrowser(majorVersion) {
|
|
@@ -2,10 +2,11 @@ import { createHash } from 'crypto';
|
|
|
2
2
|
import { createWriteStream, promises as _promises, rmdirSync } from 'fs';
|
|
3
3
|
import { homedir, tmpdir } from 'os';
|
|
4
4
|
import { dirname, join, resolve, sep } from 'path';
|
|
5
|
-
import requestretry from 'requestretry';
|
|
6
5
|
import { fileURLToPath } from 'url';
|
|
7
6
|
|
|
8
7
|
import { fontsCollection } from '../../fonts.js';
|
|
8
|
+
import { FALLBACK_API_URL } from '../utils/common.js';
|
|
9
|
+
import { makeRequest } from '../utils/http.js';
|
|
9
10
|
|
|
10
11
|
const { access, readFile, writeFile, mkdir, readdir, copyFile, rename } = _promises;
|
|
11
12
|
|
|
@@ -24,15 +25,15 @@ const GOLOGIN_TEST_FOLDER_NAME = '.gologin_test';
|
|
|
24
25
|
const osPlatform = process.platform;
|
|
25
26
|
|
|
26
27
|
export const downloadCookies = ({ profileId, ACCESS_TOKEN, API_BASE_URL }) =>
|
|
27
|
-
|
|
28
|
-
headers: {
|
|
29
|
-
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
30
|
-
'user-agent': 'gologin-api',
|
|
31
|
-
},
|
|
28
|
+
makeRequest(`${API_BASE_URL}/browser/${profileId}/cookies`, {
|
|
32
29
|
json: true,
|
|
33
30
|
maxAttempts: 3,
|
|
34
31
|
retryDelay: 2000,
|
|
35
32
|
timeout: 10 * 1000,
|
|
33
|
+
method: 'GET',
|
|
34
|
+
}, {
|
|
35
|
+
token: ACCESS_TOKEN,
|
|
36
|
+
fallbackUrl: `${FALLBACK_API_URL}/browser/${profileId}/cookies`,
|
|
36
37
|
}).catch((e) => {
|
|
37
38
|
console.log(e);
|
|
38
39
|
|
|
@@ -40,15 +41,15 @@ export const downloadCookies = ({ profileId, ACCESS_TOKEN, API_BASE_URL }) =>
|
|
|
40
41
|
});
|
|
41
42
|
|
|
42
43
|
export const uploadCookies = ({ cookies = [], profileId, ACCESS_TOKEN, API_BASE_URL }) =>
|
|
43
|
-
|
|
44
|
-
headers: {
|
|
45
|
-
Authorization: `Bearer ${ACCESS_TOKEN}`,
|
|
46
|
-
'User-Agent': 'gologin-api',
|
|
47
|
-
},
|
|
44
|
+
makeRequest(`${API_BASE_URL}/browser/${profileId}/cookies?encrypted=true`, {
|
|
48
45
|
json: cookies,
|
|
49
46
|
maxAttempts: 3,
|
|
50
47
|
retryDelay: 2000,
|
|
51
48
|
timeout: 20 * 1000,
|
|
49
|
+
method: 'POST',
|
|
50
|
+
}, {
|
|
51
|
+
token: ACCESS_TOKEN,
|
|
52
|
+
fallbackUrl: `${FALLBACK_API_URL}/browser/${profileId}/cookies?encrypted=true`,
|
|
52
53
|
}).catch((e) => {
|
|
53
54
|
console.log(e);
|
|
54
55
|
|
|
@@ -66,7 +67,7 @@ export const downloadFonts = async (fontsList = [], profilePath) => {
|
|
|
66
67
|
const files = await readdir(browserFontsPath);
|
|
67
68
|
const fontsToDownload = fontsList.filter(font => !files.includes(font));
|
|
68
69
|
|
|
69
|
-
let promises = fontsToDownload.map(font =>
|
|
70
|
+
let promises = fontsToDownload.map(font => makeRequest(FONTS_URL + font, {
|
|
70
71
|
maxAttempts: 5,
|
|
71
72
|
retryDelay: 2000,
|
|
72
73
|
timeout: 30 * 1000,
|
|
@@ -4,11 +4,13 @@ import request from 'requestretry';
|
|
|
4
4
|
|
|
5
5
|
import { CHROME_EXTENSIONS_PATH, composeExtractionPromises, USER_EXTENSIONS_PATH } from '../utils/common.js';
|
|
6
6
|
import UserExtensionsManager from './user-extensions-manager.js';
|
|
7
|
+
import { makeRequest } from '../utils/http.js';
|
|
8
|
+
import { FALLBACK_API_URL } from '../utils/common.js';
|
|
7
9
|
|
|
8
10
|
const { mkdir, readdir, rmdir, unlink } = _promises;
|
|
9
11
|
|
|
10
12
|
const EXTENSION_URL =
|
|
11
|
-
'https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&x=id%3D{ext_id}%26uc&prodversion=
|
|
13
|
+
'https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&x=id%3D{ext_id}%26uc&prodversion=135.0.7049.41';
|
|
12
14
|
|
|
13
15
|
export class ExtensionsManager extends UserExtensionsManager {
|
|
14
16
|
#existedChromeExtensions = [];
|
|
@@ -134,6 +136,7 @@ export class ExtensionsManager extends UserExtensionsManager {
|
|
|
134
136
|
|
|
135
137
|
const buffer = await new Promise((res) => {
|
|
136
138
|
const chunks = [];
|
|
139
|
+
console.log('extUrl', extUrl);
|
|
137
140
|
request.get(extUrl, {
|
|
138
141
|
maxAttempts: 3,
|
|
139
142
|
retryDelay: 1000,
|
|
@@ -143,7 +146,7 @@ export class ExtensionsManager extends UserExtensionsManager {
|
|
|
143
146
|
.on('data', (data) => chunks.push(data))
|
|
144
147
|
.on('end', () => res(Buffer.concat(chunks)));
|
|
145
148
|
});
|
|
146
|
-
|
|
149
|
+
console.log('buffer', buffer);
|
|
147
150
|
let zipExt;
|
|
148
151
|
try {
|
|
149
152
|
zipExt = crxToZip(buffer);
|
|
@@ -166,17 +169,15 @@ export class ExtensionsManager extends UserExtensionsManager {
|
|
|
166
169
|
}
|
|
167
170
|
|
|
168
171
|
async getExtensionsPolicies() {
|
|
169
|
-
const globalExtConfig = await
|
|
170
|
-
headers: {
|
|
171
|
-
Authorization: `Bearer ${this.accessToken}`,
|
|
172
|
-
'user-agent': this.userAgent,
|
|
173
|
-
'x-two-factor-token': this.twoFaKey || '',
|
|
174
|
-
},
|
|
172
|
+
const globalExtConfig = await makeRequest(`${this.apiBaseUrl}/gologin-settings/chrome_ext_policies`, {
|
|
175
173
|
json: true,
|
|
176
174
|
maxAttempts: 2,
|
|
177
175
|
retryDelay: 1000,
|
|
178
176
|
timeout: 10 * 1000,
|
|
179
|
-
|
|
177
|
+
method: 'GET',
|
|
178
|
+
}, {
|
|
179
|
+
token: this.accessToken,
|
|
180
|
+
fallbackUrl: `${FALLBACK_API_URL}/gologin-settings/chrome_ext_policies`,
|
|
180
181
|
});
|
|
181
182
|
|
|
182
183
|
const chromeExtPolicies = globalExtConfig?.chromeExtPolicies || {};
|
|
@@ -260,20 +261,17 @@ export class ExtensionsManager extends UserExtensionsManager {
|
|
|
260
261
|
return;
|
|
261
262
|
}
|
|
262
263
|
|
|
263
|
-
const checkResponse = await
|
|
264
|
+
const checkResponse = await makeRequest(`${this.apiBaseUrl}/extensions/check`, {
|
|
264
265
|
method: 'POST',
|
|
265
|
-
|
|
266
|
-
Authorization: `Bearer ${this.accessToken}`,
|
|
267
|
-
'user-agent': this.userAgent,
|
|
268
|
-
'x-two-factor-token': this.twoFaKey || '',
|
|
269
|
-
},
|
|
270
|
-
body: {
|
|
266
|
+
json: {
|
|
271
267
|
extensionsIds,
|
|
272
268
|
},
|
|
273
|
-
|
|
269
|
+
}, {
|
|
270
|
+
token: this.accessToken,
|
|
271
|
+
fallbackUrl: `${FALLBACK_API_URL}/extensions/check`,
|
|
274
272
|
});
|
|
275
273
|
|
|
276
|
-
const { extensionsToAdd = [] } = checkResponse
|
|
274
|
+
const { extensionsToAdd = [] } = checkResponse;
|
|
277
275
|
|
|
278
276
|
if (!extensionsToAdd.length) {
|
|
279
277
|
return;
|
|
@@ -281,17 +279,14 @@ export class ExtensionsManager extends UserExtensionsManager {
|
|
|
281
279
|
|
|
282
280
|
const extensionsToUpdate = await this.getExtensionsNameAndImage(extensionsToAdd, pathToExtensions);
|
|
283
281
|
|
|
284
|
-
|
|
282
|
+
makeRequest(`${this.apiBaseUrl}/extensions/create`, {
|
|
285
283
|
method: 'POST',
|
|
286
|
-
|
|
287
|
-
Authorization: `Bearer ${this.accessToken}`,
|
|
288
|
-
'user-agent': this.userAgent,
|
|
289
|
-
'x-two-factor-token': this.twoFaKey || '',
|
|
290
|
-
},
|
|
291
|
-
body: {
|
|
284
|
+
json: {
|
|
292
285
|
extensionsInfo: extensionsToUpdate,
|
|
293
286
|
},
|
|
294
|
-
|
|
287
|
+
}, {
|
|
288
|
+
token: this.accessToken,
|
|
289
|
+
fallbackUrl: `${FALLBACK_API_URL}/extensions/create`,
|
|
295
290
|
});
|
|
296
291
|
}
|
|
297
292
|
|