gologin-commonjs 2.1.14 → 3.0.1
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/dist/src/gologin.js +411 -718
- package/dist/src/utils/timezone.js +21 -0
- package/gologin/.eslintrc.json +290 -0
- package/gologin/package.json +1 -1
- package/gologin/src/gologin.js +71 -17
- package/gologin/src/utils/timezone.js +470 -0
- package/package.json +4 -2
- package/tes.js +2 -1
- package/tsconfig.json +23 -0
- package/types/fonts.d.ts +21 -0
- package/types/{bookmarks → src/bookmarks}/utils.d.ts +0 -1
- package/types/src/browser/browser-api.d.ts +10 -0
- package/types/{browser → src/browser}/browser-checker.d.ts +1 -2
- package/types/{browser → src/browser}/browser-user-data-manager.d.ts +0 -1
- package/types/{cookies → src/cookies}/cookies-manager.d.ts +7 -3
- package/types/{extensions → src/extensions}/extensions-extractor.d.ts +0 -1
- package/types/{extensions → src/extensions}/extensions-manager.d.ts +4 -7
- package/types/{extensions → src/extensions}/user-extensions-manager.d.ts +1 -2
- package/types/src/gologin-api.d.ts +17 -0
- package/types/{gologin.d.ts → src/gologin.d.ts} +18 -35
- package/types/{profile → src/profile}/profile-archiver.d.ts +1 -2
- package/types/{profile → src/profile}/profile-directories-to-remove.d.ts +0 -1
- package/types/{utils → src/utils}/browser.d.ts +0 -1
- package/types/src/utils/common.d.ts +10 -0
- package/types/{utils → src/utils}/constants.d.ts +0 -1
- package/types/src/utils/timezone.d.ts +1 -0
- package/types/{utils → src/utils}/utils.d.ts +0 -1
- package/types/src/utils/zero-profile-bookmarks.d.ts +41 -0
- package/types/src/utils/zero-profile-preferences.d.ts +219 -0
- package/dist/fonts_config +0 -104
- package/dist/gologin-browser-ext.zip +0 -0
- package/dist/gologin_zeroprofile.b64 +0 -1
- package/dist/index.d.ts +0 -61
- package/dist/zero_profile.zip +0 -0
- package/types/browser/browser-api.d.ts +0 -10
- package/types/utils/common.d.ts +0 -10
package/dist/src/gologin.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.GoLogin = void 0;
|
|
7
7
|
Object.defineProperty(exports, "GologinApi", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
10
10
|
return _gologinApi.GologinApi;
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
12
|
});
|
|
13
13
|
exports.default = void 0;
|
|
14
14
|
Object.defineProperty(exports, "exitAll", {
|
|
15
15
|
enumerable: true,
|
|
16
16
|
get: function () {
|
|
17
17
|
return _gologinApi.exitAll;
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
});
|
|
20
20
|
var _child_process = require("child_process");
|
|
21
21
|
var _debug = _interopRequireDefault(require("debug"));
|
|
@@ -28,17 +28,14 @@ var _path = require("path");
|
|
|
28
28
|
var _requestretry = _interopRequireDefault(require("requestretry"));
|
|
29
29
|
var _rimraf = _interopRequireDefault(require("rimraf"));
|
|
30
30
|
var _socksProxyAgent = require("socks-proxy-agent");
|
|
31
|
+
var _url = require("url");
|
|
31
32
|
var _fonts = require("../fonts.js");
|
|
32
33
|
var _utils = require("./bookmarks/utils.js");
|
|
33
34
|
var _browserApi = require("./browser/browser-api.js");
|
|
34
|
-
var _browserChecker = _interopRequireDefault(
|
|
35
|
-
require("./browser/browser-checker.js")
|
|
36
|
-
);
|
|
35
|
+
var _browserChecker = _interopRequireDefault(require("./browser/browser-checker.js"));
|
|
37
36
|
var _browserUserDataManager = require("./browser/browser-user-data-manager.js");
|
|
38
37
|
var _cookiesManager = require("./cookies/cookies-manager.js");
|
|
39
|
-
var _extensionsManager = _interopRequireDefault(
|
|
40
|
-
require("./extensions/extensions-manager.js")
|
|
41
|
-
);
|
|
38
|
+
var _extensionsManager = _interopRequireDefault(require("./extensions/extensions-manager.js"));
|
|
42
39
|
var _profileArchiver = require("./profile/profile-archiver.js");
|
|
43
40
|
var _browser = require("./utils/browser.js");
|
|
44
41
|
var _common = require("./utils/common.js");
|
|
@@ -47,16 +44,23 @@ var _utils2 = require("./utils/utils.js");
|
|
|
47
44
|
var _gologinApi = require("./gologin-api.js");
|
|
48
45
|
var _zeroProfileBookmarks = require("./utils/zero-profile-bookmarks.js");
|
|
49
46
|
var _zeroProfilePreferences = require("./utils/zero-profile-preferences.js");
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
var _timezone = require("./utils/timezone.js");
|
|
48
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
49
|
+
const {
|
|
50
|
+
access,
|
|
51
|
+
unlink,
|
|
52
|
+
writeFile,
|
|
53
|
+
readFile,
|
|
54
|
+
mkdir,
|
|
55
|
+
copyFile
|
|
56
|
+
} = _fs.promises;
|
|
54
57
|
const SEPARATOR = _path.sep;
|
|
55
58
|
const OS_PLATFORM = process.platform;
|
|
56
|
-
const TIMEZONE_URL = "https://
|
|
59
|
+
const TIMEZONE_URL = "https://geolocation-db.com/json/";
|
|
60
|
+
// const TIMEZONE_URL = 'https://geo.myip.link';
|
|
57
61
|
const PROXY_NONE = "none";
|
|
58
62
|
const debug = (0, _debug.default)("gologin");
|
|
59
|
-
const delay =
|
|
63
|
+
const delay = time => new Promise(resolve => setTimeout(resolve, time));
|
|
60
64
|
class GoLogin {
|
|
61
65
|
constructor(options = {}) {
|
|
62
66
|
this.browserLang = "en-US";
|
|
@@ -75,12 +79,11 @@ class GoLogin {
|
|
|
75
79
|
this.isEmptyFonts = false;
|
|
76
80
|
this.isFirstSession = false;
|
|
77
81
|
this.isCloudHeadless = options.isCloudHeadless ?? true;
|
|
82
|
+
this.storageGatewayUrl = `${_constants.STORAGE_GATEWAY_BASE_URL}/upload`;
|
|
78
83
|
this.tmpdir = (0, _os.tmpdir)();
|
|
79
84
|
this.autoUpdateBrowser = !!options.autoUpdateBrowser;
|
|
80
85
|
this.checkBrowserUpdate = options.checkBrowserUpdate ?? true;
|
|
81
|
-
this.browserChecker = new _browserChecker.default(
|
|
82
|
-
options.skipOrbitaHashChecking
|
|
83
|
-
);
|
|
86
|
+
this.browserChecker = new _browserChecker.default(options.skipOrbitaHashChecking);
|
|
84
87
|
this.uploadCookiesToServer = options.uploadCookiesToServer || false;
|
|
85
88
|
this.writeCookiesFromServer = options.writeCookiesFromServer;
|
|
86
89
|
this.remote_debugging_port = options.remote_debugging_port || 0;
|
|
@@ -95,87 +98,52 @@ class GoLogin {
|
|
|
95
98
|
if (!(0, _fs.existsSync)(this.tmpdir)) {
|
|
96
99
|
debug("making tmpdir", this.tmpdir);
|
|
97
100
|
(0, _fs.mkdirSync)(this.tmpdir, {
|
|
98
|
-
recursive: true
|
|
101
|
+
recursive: true
|
|
99
102
|
});
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
|
-
this.profile_zip_path = (0, _path.join)(
|
|
103
|
-
|
|
104
|
-
`gologin_${this.profile_id}.zip`
|
|
105
|
-
);
|
|
106
|
-
this.bookmarksFilePath = (0, _path.join)(
|
|
107
|
-
this.tmpdir,
|
|
108
|
-
`gologin_profile_${this.profile_id}`,
|
|
109
|
-
"Default",
|
|
110
|
-
"Bookmarks"
|
|
111
|
-
);
|
|
105
|
+
this.profile_zip_path = (0, _path.join)(this.tmpdir, `gologin_${this.profile_id}.zip`);
|
|
106
|
+
this.bookmarksFilePath = (0, _path.join)(this.tmpdir, `gologin_profile_${this.profile_id}`, "Default", "Bookmarks");
|
|
112
107
|
debug("INIT GOLOGIN", this.profile_id);
|
|
113
108
|
}
|
|
114
109
|
async checkBrowser() {
|
|
115
|
-
return this.browserChecker.checkBrowser(
|
|
116
|
-
this.autoUpdateBrowser,
|
|
117
|
-
this.checkBrowserUpdate
|
|
118
|
-
);
|
|
110
|
+
return this.browserChecker.checkBrowser(this.autoUpdateBrowser, this.checkBrowserUpdate);
|
|
119
111
|
}
|
|
120
112
|
async setProfileId(profile_id) {
|
|
121
113
|
this.profile_id = profile_id;
|
|
122
|
-
this.cookiesFilePath = await (0, _cookiesManager.getCookiesFilePath)(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
);
|
|
126
|
-
this.profile_zip_path = (0, _path.join)(
|
|
127
|
-
this.tmpdir,
|
|
128
|
-
`gologin_${this.profile_id}.zip`
|
|
129
|
-
);
|
|
130
|
-
this.bookmarksFilePath = (0, _path.join)(
|
|
131
|
-
this.tmpdir,
|
|
132
|
-
`gologin_profile_${this.profile_id}`,
|
|
133
|
-
"Default",
|
|
134
|
-
"Bookmarks"
|
|
135
|
-
);
|
|
114
|
+
this.cookiesFilePath = await (0, _cookiesManager.getCookiesFilePath)(profile_id, this.tmpdir);
|
|
115
|
+
this.profile_zip_path = (0, _path.join)(this.tmpdir, `gologin_${this.profile_id}.zip`);
|
|
116
|
+
this.bookmarksFilePath = (0, _path.join)(this.tmpdir, `gologin_profile_${this.profile_id}`, "Default", "Bookmarks");
|
|
136
117
|
}
|
|
137
118
|
async getToken(username, password) {
|
|
138
|
-
const data = await _requestretry.default.post(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
username,
|
|
143
|
-
password,
|
|
144
|
-
},
|
|
119
|
+
const data = await _requestretry.default.post(`${_common.API_URL}/user/login`, {
|
|
120
|
+
json: {
|
|
121
|
+
username,
|
|
122
|
+
password
|
|
145
123
|
}
|
|
146
|
-
);
|
|
124
|
+
});
|
|
147
125
|
if (!Reflect.has(data, "body.access_token")) {
|
|
148
|
-
throw new Error(
|
|
149
|
-
`gologin auth failed with status code, ${
|
|
150
|
-
data.statusCode
|
|
151
|
-
} DATA ${JSON.stringify(data)}`
|
|
152
|
-
);
|
|
126
|
+
throw new Error(`gologin auth failed with status code, ${data.statusCode} DATA ${JSON.stringify(data)}`);
|
|
153
127
|
}
|
|
154
128
|
}
|
|
155
129
|
async getNewFingerPrint(os) {
|
|
156
130
|
debug("GETTING FINGERPRINT");
|
|
157
|
-
const fpResponse = await _requestretry.default.get(
|
|
158
|
-
|
|
159
|
-
{
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
Authorization: `Bearer ${this.access_token}`,
|
|
163
|
-
"User-Agent": "gologin-api",
|
|
164
|
-
},
|
|
131
|
+
const fpResponse = await _requestretry.default.get(`${_common.API_URL}/browser/fingerprint?os=${os}`, {
|
|
132
|
+
json: true,
|
|
133
|
+
headers: {
|
|
134
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
135
|
+
"User-Agent": "gologin-api"
|
|
165
136
|
}
|
|
166
|
-
);
|
|
137
|
+
});
|
|
167
138
|
return fpResponse?.body || {};
|
|
168
139
|
}
|
|
169
140
|
async profiles() {
|
|
170
|
-
const profilesResponse = await _requestretry.default.get(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
Authorization: `Bearer ${this.access_token}`,
|
|
175
|
-
"User-Agent": "gologin-api",
|
|
176
|
-
},
|
|
141
|
+
const profilesResponse = await _requestretry.default.get(`${_common.API_URL}/browser/v2`, {
|
|
142
|
+
headers: {
|
|
143
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
144
|
+
"User-Agent": "gologin-api"
|
|
177
145
|
}
|
|
178
|
-
);
|
|
146
|
+
});
|
|
179
147
|
if (profilesResponse.statusCode !== 200) {
|
|
180
148
|
throw new Error("Gologin /browser response error");
|
|
181
149
|
}
|
|
@@ -184,17 +152,16 @@ class GoLogin {
|
|
|
184
152
|
async getProfile(profile_id) {
|
|
185
153
|
const id = profile_id || this.profile_id;
|
|
186
154
|
debug("getProfile", this.access_token, id);
|
|
187
|
-
const profileResponse = await _requestretry.default.get(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
Authorization: `Bearer ${this.access_token}`,
|
|
192
|
-
"User-Agent": "gologin-api",
|
|
193
|
-
},
|
|
155
|
+
const profileResponse = await _requestretry.default.get(`${_common.API_URL}/browser/features/${id}/info-for-run`, {
|
|
156
|
+
headers: {
|
|
157
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
158
|
+
"User-Agent": "gologin-api"
|
|
194
159
|
}
|
|
195
|
-
);
|
|
160
|
+
});
|
|
196
161
|
debug("profileResponse", profileResponse.statusCode, profileResponse.body);
|
|
197
|
-
const {
|
|
162
|
+
const {
|
|
163
|
+
body: errorBody = ""
|
|
164
|
+
} = profileResponse;
|
|
198
165
|
const backendErrorHeader = "backend@error::";
|
|
199
166
|
if (errorBody.includes(backendErrorHeader)) {
|
|
200
167
|
const errorData = errorBody.replace(backendErrorHeader, "").slice(1, -1);
|
|
@@ -207,9 +174,7 @@ class GoLogin {
|
|
|
207
174
|
throw new Error(JSON.parse(profileResponse.body).message);
|
|
208
175
|
}
|
|
209
176
|
if (profileResponse.statusCode !== 200) {
|
|
210
|
-
throw new Error(
|
|
211
|
-
`Gologin /browser/${id} response error ${profileResponse.statusCode} INVALID TOKEN OR PROFILE NOT FOUND`
|
|
212
|
-
);
|
|
177
|
+
throw new Error(`Gologin /browser/${id} response error ${profileResponse.statusCode} INVALID TOKEN OR PROFILE NOT FOUND`);
|
|
213
178
|
}
|
|
214
179
|
if (profileResponse.statusCode === 401) {
|
|
215
180
|
throw new Error("invalid token");
|
|
@@ -217,9 +182,7 @@ class GoLogin {
|
|
|
217
182
|
return JSON.parse(profileResponse.body);
|
|
218
183
|
}
|
|
219
184
|
async emptyProfile() {
|
|
220
|
-
return readFile(
|
|
221
|
-
(0, _path.resolve)(__dirname, "gologin_zeroprofile.b64")
|
|
222
|
-
).then((res) => res.toString());
|
|
185
|
+
return readFile((0, _path.resolve)(__dirname, "gologin_zeroprofile.b64")).then(res => res.toString());
|
|
223
186
|
}
|
|
224
187
|
async getProfileS3() {
|
|
225
188
|
const token = this.access_token;
|
|
@@ -229,14 +192,12 @@ class GoLogin {
|
|
|
229
192
|
const profileResponse = await fetch(downloadURL, {
|
|
230
193
|
headers: {
|
|
231
194
|
Authorization: `Bearer ${token}`,
|
|
232
|
-
browserId: this.profile_id
|
|
233
|
-
}
|
|
195
|
+
browserId: this.profile_id
|
|
196
|
+
}
|
|
234
197
|
});
|
|
235
198
|
const profileResponseBody = await profileResponse.arrayBuffer();
|
|
236
199
|
if (profileResponse.status !== 200) {
|
|
237
|
-
debug(
|
|
238
|
-
`Gologin S3 BUCKET ${downloadURL} response error ${profileResponse.statusCode} - use empty`
|
|
239
|
-
);
|
|
200
|
+
debug(`Gologin S3 BUCKET ${downloadURL} response error ${profileResponse.statusCode} - use empty`);
|
|
240
201
|
return "";
|
|
241
202
|
}
|
|
242
203
|
return Buffer.from(profileResponseBody);
|
|
@@ -244,15 +205,14 @@ class GoLogin {
|
|
|
244
205
|
async postFile(fileName, fileBuff) {
|
|
245
206
|
debug("POSTING FILE", fileBuff.length);
|
|
246
207
|
debug("Getting signed URL for S3");
|
|
247
|
-
const apiUrl = `${_constants.STORAGE_GATEWAY_BASE_URL}/upload`;
|
|
248
208
|
const bodyBufferBiteLength = Buffer.byteLength(fileBuff);
|
|
249
209
|
console.log("BUFFER SIZE", bodyBufferBiteLength);
|
|
250
|
-
await _requestretry.default.put(
|
|
210
|
+
await _requestretry.default.put(this.storageGatewayUrl, {
|
|
251
211
|
headers: {
|
|
252
212
|
Authorization: `Bearer ${this.access_token}`,
|
|
253
213
|
browserId: this.profile_id,
|
|
254
214
|
"Content-Type": "application/zip",
|
|
255
|
-
"Content-Length": bodyBufferBiteLength
|
|
215
|
+
"Content-Length": bodyBufferBiteLength
|
|
256
216
|
},
|
|
257
217
|
body: fileBuff,
|
|
258
218
|
maxBodyLength: Infinity,
|
|
@@ -260,71 +220,43 @@ class GoLogin {
|
|
|
260
220
|
maxAttempts: 3,
|
|
261
221
|
retryDelay: 2000,
|
|
262
222
|
timeout: 30 * 1000,
|
|
263
|
-
fullResponse: false
|
|
223
|
+
fullResponse: false
|
|
264
224
|
});
|
|
265
225
|
console.log("Profile has been uploaded to S3 successfully");
|
|
266
226
|
}
|
|
267
227
|
async emptyProfileFolder() {
|
|
268
228
|
debug("get emptyProfileFolder");
|
|
269
|
-
const currentDir = (0, _path.dirname)(
|
|
270
|
-
|
|
271
|
-
);
|
|
272
|
-
const zeroProfilePath = (0, _path.join)(
|
|
273
|
-
currentDir,
|
|
274
|
-
"..",
|
|
275
|
-
"zero_profile.zip"
|
|
276
|
-
);
|
|
229
|
+
const currentDir = (0, _path.dirname)((0, _url.fileURLToPath)(require('url').pathToFileURL(__filename).toString()));
|
|
230
|
+
const zeroProfilePath = (0, _path.join)(currentDir, "..", "zero_profile.zip");
|
|
277
231
|
const profile = await readFile((0, _path.resolve)(zeroProfilePath));
|
|
278
232
|
debug("emptyProfileFolder LENGTH ::", profile.length);
|
|
279
233
|
return profile;
|
|
280
234
|
}
|
|
281
235
|
convertPreferences(preferences) {
|
|
282
236
|
if ((0, _utils2.get)(preferences, "navigator.userAgent")) {
|
|
283
|
-
preferences.userAgent = (0, _utils2.get)(
|
|
284
|
-
preferences,
|
|
285
|
-
"navigator.userAgent"
|
|
286
|
-
);
|
|
237
|
+
preferences.userAgent = (0, _utils2.get)(preferences, "navigator.userAgent");
|
|
287
238
|
}
|
|
288
239
|
if ((0, _utils2.get)(preferences, "navigator.doNotTrack")) {
|
|
289
|
-
preferences.doNotTrack = (0, _utils2.get)(
|
|
290
|
-
preferences,
|
|
291
|
-
"navigator.doNotTrack"
|
|
292
|
-
);
|
|
240
|
+
preferences.doNotTrack = (0, _utils2.get)(preferences, "navigator.doNotTrack");
|
|
293
241
|
}
|
|
294
242
|
if ((0, _utils2.get)(preferences, "navigator.hardwareConcurrency")) {
|
|
295
|
-
preferences.hardwareConcurrency = (0, _utils2.get)(
|
|
296
|
-
preferences,
|
|
297
|
-
"navigator.hardwareConcurrency"
|
|
298
|
-
);
|
|
243
|
+
preferences.hardwareConcurrency = (0, _utils2.get)(preferences, "navigator.hardwareConcurrency");
|
|
299
244
|
}
|
|
300
245
|
if ((0, _utils2.get)(preferences, "navigator.deviceMemory")) {
|
|
301
|
-
preferences.deviceMemory =
|
|
302
|
-
(0, _utils2.get)(preferences, "navigator.deviceMemory") * 1024;
|
|
246
|
+
preferences.deviceMemory = (0, _utils2.get)(preferences, "navigator.deviceMemory") * 1024;
|
|
303
247
|
}
|
|
304
248
|
if ((0, _utils2.get)(preferences, "navigator.language")) {
|
|
305
|
-
preferences.langHeader = (0, _utils2.get)(
|
|
306
|
-
|
|
307
|
-
"navigator.language"
|
|
308
|
-
);
|
|
309
|
-
preferences.languages = (0, _utils2.get)(
|
|
310
|
-
preferences,
|
|
311
|
-
"navigator.language"
|
|
312
|
-
).replace(/;|q=[\d\.]+/gim, "");
|
|
249
|
+
preferences.langHeader = (0, _utils2.get)(preferences, "navigator.language");
|
|
250
|
+
preferences.languages = (0, _utils2.get)(preferences, "navigator.language").replace(/;|q=[\d\.]+/gim, "");
|
|
313
251
|
}
|
|
314
252
|
if ((0, _utils2.get)(preferences, "navigator.maxTouchPoints")) {
|
|
315
|
-
preferences.navigator.max_touch_points = (0, _utils2.get)(
|
|
316
|
-
preferences,
|
|
317
|
-
"navigator.maxTouchPoints"
|
|
318
|
-
);
|
|
253
|
+
preferences.navigator.max_touch_points = (0, _utils2.get)(preferences, "navigator.maxTouchPoints");
|
|
319
254
|
}
|
|
320
255
|
if ((0, _utils2.get)(preferences, "isM1")) {
|
|
321
256
|
preferences.is_m1 = (0, _utils2.get)(preferences, "isM1");
|
|
322
257
|
}
|
|
323
258
|
if ((0, _utils2.get)(preferences, "os") == "android") {
|
|
324
|
-
const devicePixelRatio = (0, _utils2.get)(
|
|
325
|
-
preferences,
|
|
326
|
-
"devicePixelRatio"
|
|
327
|
-
);
|
|
259
|
+
const devicePixelRatio = (0, _utils2.get)(preferences, "devicePixelRatio");
|
|
328
260
|
const deviceScaleFactorCeil = Math.ceil(devicePixelRatio || 3.5);
|
|
329
261
|
let deviceScaleFactor = devicePixelRatio;
|
|
330
262
|
if (deviceScaleFactorCeil === devicePixelRatio) {
|
|
@@ -334,22 +266,19 @@ class GoLogin {
|
|
|
334
266
|
enable: true,
|
|
335
267
|
width: parseInt(this.resolution.width, 10),
|
|
336
268
|
height: parseInt(this.resolution.height, 10),
|
|
337
|
-
device_scale_factor: deviceScaleFactor
|
|
269
|
+
device_scale_factor: deviceScaleFactor
|
|
338
270
|
};
|
|
339
271
|
}
|
|
340
272
|
preferences.mediaDevices = {
|
|
341
273
|
enable: preferences.mediaDevices.enableMasking,
|
|
342
274
|
videoInputs: preferences.mediaDevices.videoInputs,
|
|
343
275
|
audioInputs: preferences.mediaDevices.audioInputs,
|
|
344
|
-
audioOutputs: preferences.mediaDevices.audioOutputs
|
|
276
|
+
audioOutputs: preferences.mediaDevices.audioOutputs
|
|
345
277
|
};
|
|
346
278
|
preferences.webRtc = {
|
|
347
279
|
...preferences.webRtc,
|
|
348
280
|
fill_based_on_ip: !!(0, _utils2.get)(preferences, "webRTC.fillBasedOnIp"),
|
|
349
|
-
local_ip_masking: !!(0, _utils2.get)(
|
|
350
|
-
preferences,
|
|
351
|
-
"webRTC.local_ip_masking"
|
|
352
|
-
),
|
|
281
|
+
local_ip_masking: !!(0, _utils2.get)(preferences, "webRTC.local_ip_masking")
|
|
353
282
|
};
|
|
354
283
|
return preferences;
|
|
355
284
|
}
|
|
@@ -359,49 +288,32 @@ class GoLogin {
|
|
|
359
288
|
await (0, _rimraf.default)(this.orbitaExtensionPath(), () => null);
|
|
360
289
|
const extPath = this.orbitaExtensionPath();
|
|
361
290
|
debug("extension folder sanitized");
|
|
362
|
-
const extension_source = (0, _path.resolve)(
|
|
363
|
-
__dirname,
|
|
364
|
-
"gologin-browser-ext.zip"
|
|
365
|
-
);
|
|
291
|
+
const extension_source = (0, _path.resolve)(__dirname, "gologin-browser-ext.zip");
|
|
366
292
|
await (0, _decompress.default)(extension_source, extPath, {
|
|
367
293
|
plugins: [(0, _decompressUnzip.default)()],
|
|
368
|
-
filter:
|
|
369
|
-
})
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
},
|
|
379
|
-
null,
|
|
380
|
-
2
|
|
381
|
-
)
|
|
382
|
-
).then(() => extPath);
|
|
383
|
-
})
|
|
384
|
-
.catch(async (e) => {
|
|
385
|
-
debug("orbita extension error", e);
|
|
386
|
-
});
|
|
294
|
+
filter: file => !file.path.endsWith("/")
|
|
295
|
+
}).then(() => {
|
|
296
|
+
debug("extraction done");
|
|
297
|
+
debug("create uid.json");
|
|
298
|
+
return writeFile((0, _path.join)(extPath, "uid.json"), JSON.stringify({
|
|
299
|
+
uid: that.profile_id
|
|
300
|
+
}, null, 2)).then(() => extPath);
|
|
301
|
+
}).catch(async e => {
|
|
302
|
+
debug("orbita extension error", e);
|
|
303
|
+
});
|
|
387
304
|
debug("createBrowserExtension done");
|
|
388
305
|
}
|
|
389
306
|
extractProfile(path, zipfile) {
|
|
390
307
|
debug(`extactProfile ${zipfile}, ${path}`);
|
|
391
308
|
return (0, _decompress.default)(zipfile, path, {
|
|
392
309
|
plugins: [(0, _decompressUnzip.default)()],
|
|
393
|
-
filter:
|
|
310
|
+
filter: file => !file.path.endsWith("/")
|
|
394
311
|
});
|
|
395
312
|
}
|
|
396
313
|
async downloadProfileAndExtract(profile, local) {
|
|
397
314
|
let profile_folder;
|
|
398
|
-
const profilePath = (0, _path.join)(
|
|
399
|
-
|
|
400
|
-
`gologin_profile_${this.profile_id}`
|
|
401
|
-
);
|
|
402
|
-
const profileZipExists = await access(this.profile_zip_path)
|
|
403
|
-
.then(() => true)
|
|
404
|
-
.catch(() => false);
|
|
315
|
+
const profilePath = (0, _path.join)(this.tmpdir, `gologin_profile_${this.profile_id}`);
|
|
316
|
+
const profileZipExists = await access(this.profile_zip_path).then(() => true).catch(() => false);
|
|
405
317
|
if (!(local && profileZipExists)) {
|
|
406
318
|
try {
|
|
407
319
|
profile_folder = await this.getProfileS3();
|
|
@@ -425,9 +337,7 @@ class GoLogin {
|
|
|
425
337
|
await this.extractProfile(profilePath, this.profile_zip_path);
|
|
426
338
|
}
|
|
427
339
|
const singletonLockPath = (0, _path.join)(profilePath, "SingletonLock");
|
|
428
|
-
const singletonLockExists = await access(singletonLockPath)
|
|
429
|
-
.then(() => true)
|
|
430
|
-
.catch(() => false);
|
|
340
|
+
const singletonLockExists = await access(singletonLockPath).then(() => true).catch(() => false);
|
|
431
341
|
if (singletonLockExists) {
|
|
432
342
|
debug("removing SingletonLock");
|
|
433
343
|
await unlink(singletonLockPath);
|
|
@@ -435,72 +345,47 @@ class GoLogin {
|
|
|
435
345
|
}
|
|
436
346
|
}
|
|
437
347
|
async createZeroProfile(createCookiesTableQuery) {
|
|
438
|
-
const profilePath = (0, _path.join)(
|
|
439
|
-
this.tmpdir,
|
|
440
|
-
`gologin_profile_${this.profile_id}`
|
|
441
|
-
);
|
|
348
|
+
const profilePath = (0, _path.join)(this.tmpdir, `gologin_profile_${this.profile_id}`);
|
|
442
349
|
const defaultFilePath = (0, _path.resolve)(profilePath, "Default");
|
|
443
|
-
const preferencesFilePath = (0, _path.resolve)(
|
|
444
|
-
defaultFilePath,
|
|
445
|
-
"Preferences"
|
|
446
|
-
);
|
|
350
|
+
const preferencesFilePath = (0, _path.resolve)(defaultFilePath, "Preferences");
|
|
447
351
|
const bookmarksFilePath = (0, _path.resolve)(defaultFilePath, "Bookmarks");
|
|
448
|
-
const cookiesFilePath = (0, _path.resolve)(
|
|
449
|
-
|
|
450
|
-
"Network",
|
|
451
|
-
"Cookies"
|
|
452
|
-
);
|
|
453
|
-
const cookiesFileSecondPath = (0, _path.resolve)(
|
|
454
|
-
defaultFilePath,
|
|
455
|
-
"Cookies"
|
|
456
|
-
);
|
|
352
|
+
const cookiesFilePath = (0, _path.resolve)(defaultFilePath, "Network", "Cookies");
|
|
353
|
+
const cookiesFileSecondPath = (0, _path.resolve)(defaultFilePath, "Cookies");
|
|
457
354
|
await mkdir((0, _path.resolve)(defaultFilePath, "Network"), {
|
|
458
|
-
recursive: true
|
|
355
|
+
recursive: true
|
|
459
356
|
}).catch(console.log);
|
|
460
|
-
await Promise.all([
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
bookmarksFilePath,
|
|
470
|
-
JSON.stringify(_zeroProfileBookmarks.zeroProfileBookmarks),
|
|
471
|
-
{
|
|
472
|
-
mode: 0o666,
|
|
473
|
-
}
|
|
474
|
-
),
|
|
475
|
-
(0, _cookiesManager.createDBFile)({
|
|
476
|
-
cookiesFilePath,
|
|
477
|
-
cookiesFileSecondPath,
|
|
478
|
-
createCookiesTableQuery,
|
|
479
|
-
}),
|
|
480
|
-
]);
|
|
357
|
+
await Promise.all([writeFile(preferencesFilePath, JSON.stringify(_zeroProfilePreferences.zeroProfilePreferences), {
|
|
358
|
+
mode: 0o666
|
|
359
|
+
}), writeFile(bookmarksFilePath, JSON.stringify(_zeroProfileBookmarks.zeroProfileBookmarks), {
|
|
360
|
+
mode: 0o666
|
|
361
|
+
}), (0, _cookiesManager.createDBFile)({
|
|
362
|
+
cookiesFilePath,
|
|
363
|
+
cookiesFileSecondPath,
|
|
364
|
+
createCookiesTableQuery
|
|
365
|
+
})]);
|
|
481
366
|
}
|
|
482
367
|
async createStartup(local = false) {
|
|
483
|
-
const profilePath = (0, _path.join)(
|
|
484
|
-
this.tmpdir,
|
|
485
|
-
`gologin_profile_${this.profile_id}`
|
|
486
|
-
);
|
|
368
|
+
const profilePath = (0, _path.join)(this.tmpdir, `gologin_profile_${this.profile_id}`);
|
|
487
369
|
await (0, _rimraf.default)(profilePath, () => null);
|
|
488
370
|
debug("-", profilePath, "dropped");
|
|
489
371
|
const profile = await this.getProfile();
|
|
490
|
-
const {
|
|
372
|
+
const {
|
|
373
|
+
navigator = {},
|
|
374
|
+
fonts,
|
|
375
|
+
os: profileOs
|
|
376
|
+
} = profile;
|
|
491
377
|
this.fontsMasking = fonts?.enableMasking;
|
|
492
378
|
this.profileOs = profileOs;
|
|
493
|
-
this.differentOs =
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
const { resolution = "1920x1080", language = "en-US,en;q=0.9" } = navigator;
|
|
379
|
+
this.differentOs = profileOs !== "android" && (OS_PLATFORM === "win32" && profileOs !== "win" || OS_PLATFORM === "darwin" && profileOs !== "mac" || OS_PLATFORM === "linux" && profileOs !== "lin");
|
|
380
|
+
const {
|
|
381
|
+
resolution = "1920x1080",
|
|
382
|
+
language = "en-US,en;q=0.9"
|
|
383
|
+
} = navigator;
|
|
499
384
|
this.language = language;
|
|
500
385
|
const [screenWidth, screenHeight] = resolution.split("x");
|
|
501
386
|
this.resolution = {
|
|
502
387
|
width: parseInt(screenWidth, 10),
|
|
503
|
-
height: parseInt(screenHeight, 10)
|
|
388
|
+
height: parseInt(screenHeight, 10)
|
|
504
389
|
};
|
|
505
390
|
if (profile.storageInfo.isNewProfile) {
|
|
506
391
|
this.isFirstSession = true;
|
|
@@ -509,102 +394,54 @@ class GoLogin {
|
|
|
509
394
|
this.isFirstSession = false;
|
|
510
395
|
await this.downloadProfileAndExtract(profile, local);
|
|
511
396
|
}
|
|
512
|
-
const pref_file_name = (0, _path.join)(
|
|
513
|
-
profilePath,
|
|
514
|
-
"Default",
|
|
515
|
-
"Preferences"
|
|
516
|
-
);
|
|
397
|
+
const pref_file_name = (0, _path.join)(profilePath, "Default", "Preferences");
|
|
517
398
|
debug("reading", pref_file_name);
|
|
518
|
-
const prefFileExists = await access(pref_file_name)
|
|
519
|
-
.then(() => true)
|
|
520
|
-
.catch(() => false);
|
|
399
|
+
const prefFileExists = await access(pref_file_name).then(() => true).catch(() => false);
|
|
521
400
|
if (!prefFileExists) {
|
|
522
|
-
debug(
|
|
523
|
-
"Preferences file not exists waiting",
|
|
524
|
-
pref_file_name,
|
|
525
|
-
". Using empty profile"
|
|
526
|
-
);
|
|
401
|
+
debug("Preferences file not exists waiting", pref_file_name, ". Using empty profile");
|
|
527
402
|
await writeFile(pref_file_name, "{}");
|
|
528
403
|
}
|
|
529
404
|
const preferences_raw = await readFile(pref_file_name);
|
|
530
405
|
const preferences = JSON.parse(preferences_raw.toString());
|
|
531
406
|
let proxy = (0, _utils2.get)(profile, "proxy");
|
|
532
407
|
const name = (0, _utils2.get)(profile, "name");
|
|
533
|
-
const chromeExtensions =
|
|
534
|
-
|
|
535
|
-
const userChromeExtensions =
|
|
536
|
-
(0, _utils2.get)(profile, "userChromeExtensions") || [];
|
|
408
|
+
const chromeExtensions = (0, _utils2.get)(profile, "chromeExtensions") || [];
|
|
409
|
+
const userChromeExtensions = (0, _utils2.get)(profile, "userChromeExtensions") || [];
|
|
537
410
|
const allExtensions = [...chromeExtensions, ...userChromeExtensions];
|
|
538
411
|
if (allExtensions.length) {
|
|
539
412
|
const ExtensionsManagerInst = new _extensionsManager.default();
|
|
540
413
|
ExtensionsManagerInst.apiUrl = _common.API_URL;
|
|
541
|
-
await ExtensionsManagerInst.init()
|
|
542
|
-
.then(() => ExtensionsManagerInst.updateExtensions())
|
|
543
|
-
.catch(() => {});
|
|
414
|
+
await ExtensionsManagerInst.init().then(() => ExtensionsManagerInst.updateExtensions()).catch(() => {});
|
|
544
415
|
ExtensionsManagerInst.accessToken = this.access_token;
|
|
545
416
|
await ExtensionsManagerInst.getExtensionsPolicies();
|
|
546
417
|
let profileExtensionsCheckRes = [];
|
|
547
418
|
if (ExtensionsManagerInst.useLocalExtStorage) {
|
|
548
|
-
const promises = [
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
this.profile_id
|
|
562
|
-
)
|
|
563
|
-
.then((res) => ({
|
|
564
|
-
profileUserExtensionsCheckRes: res,
|
|
565
|
-
}))
|
|
566
|
-
.catch((error) => {
|
|
567
|
-
console.log("checkUserChromeExtensions error: ", error);
|
|
568
|
-
return null;
|
|
569
|
-
}),
|
|
570
|
-
];
|
|
419
|
+
const promises = [ExtensionsManagerInst.checkChromeExtensions(allExtensions).then(res => ({
|
|
420
|
+
profileExtensionsCheckRes: res
|
|
421
|
+
})).catch(e => {
|
|
422
|
+
console.log("checkChromeExtensions error: ", e);
|
|
423
|
+
return {
|
|
424
|
+
profileExtensionsCheckRes: []
|
|
425
|
+
};
|
|
426
|
+
}), ExtensionsManagerInst.checkLocalUserChromeExtensions(userChromeExtensions, this.profile_id).then(res => ({
|
|
427
|
+
profileUserExtensionsCheckRes: res
|
|
428
|
+
})).catch(error => {
|
|
429
|
+
console.log("checkUserChromeExtensions error: ", error);
|
|
430
|
+
return null;
|
|
431
|
+
})];
|
|
571
432
|
const extensionsResult = await Promise.all(promises);
|
|
572
|
-
const profileExtensionPathRes =
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
const profileUserExtensionPathRes = extensionsResult.find(
|
|
576
|
-
(el) => "profileUserExtensionsCheckRes" in el
|
|
577
|
-
);
|
|
578
|
-
profileExtensionsCheckRes = (
|
|
579
|
-
profileExtensionPathRes?.profileExtensionsCheckRes || []
|
|
580
|
-
).concat(
|
|
581
|
-
profileUserExtensionPathRes?.profileUserExtensionsCheckRes || []
|
|
582
|
-
);
|
|
433
|
+
const profileExtensionPathRes = extensionsResult.find(el => "profileExtensionsCheckRes" in el) || {};
|
|
434
|
+
const profileUserExtensionPathRes = extensionsResult.find(el => "profileUserExtensionsCheckRes" in el);
|
|
435
|
+
profileExtensionsCheckRes = (profileExtensionPathRes?.profileExtensionsCheckRes || []).concat(profileUserExtensionPathRes?.profileUserExtensionsCheckRes || []);
|
|
583
436
|
}
|
|
584
437
|
let extSettings;
|
|
585
438
|
if (ExtensionsManagerInst.useLocalExtStorage) {
|
|
586
|
-
extSettings = await (0,
|
|
587
|
-
_browserUserDataManager.setExtPathsAndRemoveDeleted)(
|
|
588
|
-
preferences,
|
|
589
|
-
profileExtensionsCheckRes,
|
|
590
|
-
this.profile_id
|
|
591
|
-
);
|
|
439
|
+
extSettings = await (0, _browserUserDataManager.setExtPathsAndRemoveDeleted)(preferences, profileExtensionsCheckRes, this.profile_id);
|
|
592
440
|
} else {
|
|
593
|
-
const originalExtensionsFolder = (0, _path.join)(
|
|
594
|
-
|
|
595
|
-
"Default",
|
|
596
|
-
"Extensions"
|
|
597
|
-
);
|
|
598
|
-
extSettings = await (0, _browserUserDataManager.setOriginalExtPaths)(
|
|
599
|
-
preferences,
|
|
600
|
-
originalExtensionsFolder
|
|
601
|
-
);
|
|
441
|
+
const originalExtensionsFolder = (0, _path.join)(profilePath, "Default", "Extensions");
|
|
442
|
+
extSettings = await (0, _browserUserDataManager.setOriginalExtPaths)(preferences, originalExtensionsFolder);
|
|
602
443
|
}
|
|
603
|
-
this.extensionPathsToInstall =
|
|
604
|
-
ExtensionsManagerInst.getExtensionsToInstall(
|
|
605
|
-
extSettings,
|
|
606
|
-
profileExtensionsCheckRes
|
|
607
|
-
);
|
|
444
|
+
this.extensionPathsToInstall = ExtensionsManagerInst.getExtensionsToInstall(extSettings, profileExtensionsCheckRes);
|
|
608
445
|
if (extSettings) {
|
|
609
446
|
const currentExtSettings = preferences.extensions || {};
|
|
610
447
|
currentExtSettings.settings = extSettings;
|
|
@@ -621,7 +458,7 @@ class GoLogin {
|
|
|
621
458
|
host: splittedProxyAddress[0],
|
|
622
459
|
port,
|
|
623
460
|
username: (0, _utils2.get)(profile, "autoProxyUsername"),
|
|
624
|
-
password: (0, _utils2.get)(profile, "autoProxyPassword")
|
|
461
|
+
password: (0, _utils2.get)(profile, "autoProxyPassword")
|
|
625
462
|
};
|
|
626
463
|
profile.proxy.username = (0, _utils2.get)(profile, "autoProxyUsername");
|
|
627
464
|
profile.proxy.password = (0, _utils2.get)(profile, "autoProxyPassword");
|
|
@@ -633,47 +470,44 @@ class GoLogin {
|
|
|
633
470
|
proxy = null;
|
|
634
471
|
}
|
|
635
472
|
this.proxy = proxy;
|
|
636
|
-
await this.getTimeZone(proxy).catch(
|
|
473
|
+
await this.getTimeZone(proxy).catch(e => {
|
|
637
474
|
console.error("Proxy Error. Check it and try again.");
|
|
638
475
|
throw new Error(`Proxy Error. ${e.message}`);
|
|
639
476
|
});
|
|
640
477
|
const [latitude, longitude] = this._tz.ll;
|
|
641
|
-
const {
|
|
478
|
+
const {
|
|
479
|
+
accuracy
|
|
480
|
+
} = this._tz;
|
|
642
481
|
const profileGeolocation = profile.geolocation;
|
|
643
482
|
const tzGeoLocation = {
|
|
644
483
|
latitude,
|
|
645
484
|
longitude,
|
|
646
|
-
accuracy
|
|
485
|
+
accuracy
|
|
647
486
|
};
|
|
648
|
-
profile.geoLocation = this.getGeolocationParams(
|
|
649
|
-
profileGeolocation,
|
|
650
|
-
tzGeoLocation
|
|
651
|
-
);
|
|
487
|
+
profile.geoLocation = this.getGeolocationParams(profileGeolocation, tzGeoLocation);
|
|
652
488
|
profile.name = name;
|
|
653
489
|
profile.name_base64 = Buffer.from(name).toString("base64");
|
|
654
490
|
profile.profile_id = this.profile_id;
|
|
655
491
|
profile.webRtc = {
|
|
656
|
-
mode:
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
: (0, _utils2.get)(profile, "webRTC.mode"),
|
|
660
|
-
publicIP: (0, _utils2.get)(profile, "webRTC.fillBasedOnIp")
|
|
661
|
-
? this._tz.ip
|
|
662
|
-
: (0, _utils2.get)(profile, "webRTC.publicIp"),
|
|
663
|
-
localIps: (0, _utils2.get)(profile, "webRTC.localIps", []),
|
|
492
|
+
mode: (0, _utils2.get)(profile, "webRTC.mode") === "alerted" ? "public" : (0, _utils2.get)(profile, "webRTC.mode"),
|
|
493
|
+
publicIP: (0, _utils2.get)(profile, "webRTC.fillBasedOnIp") ? this._tz.ip : (0, _utils2.get)(profile, "webRTC.publicIp"),
|
|
494
|
+
localIps: (0, _utils2.get)(profile, "webRTC.localIps", [])
|
|
664
495
|
};
|
|
665
496
|
debug("profile.webRtc=", profile.webRtc);
|
|
666
497
|
debug("profile.timezone=", profile.timezone);
|
|
667
498
|
debug("profile.mediaDevices=", profile.mediaDevices);
|
|
668
499
|
const audioContext = profile.audioContext || {};
|
|
669
|
-
const {
|
|
500
|
+
const {
|
|
501
|
+
mode: audioCtxMode = "off",
|
|
502
|
+
noise: audioCtxNoise
|
|
503
|
+
} = audioContext;
|
|
670
504
|
if (profile.timezone.fillBasedOnIp === false) {
|
|
671
505
|
profile.timezone = {
|
|
672
|
-
id: profile.timezone.timezone
|
|
506
|
+
id: profile.timezone.timezone
|
|
673
507
|
};
|
|
674
508
|
} else {
|
|
675
509
|
profile.timezone = {
|
|
676
|
-
id: this._tz.timezone
|
|
510
|
+
id: this._tz.timezone
|
|
677
511
|
};
|
|
678
512
|
}
|
|
679
513
|
profile.webgl_noise_value = profile.webGL.noise;
|
|
@@ -682,30 +516,24 @@ class GoLogin {
|
|
|
682
516
|
profile.canvasNoise = profile.canvas.noise;
|
|
683
517
|
profile.audioContext = {
|
|
684
518
|
enable: audioCtxMode !== "off",
|
|
685
|
-
noiseValue: audioCtxNoise
|
|
519
|
+
noiseValue: audioCtxNoise
|
|
686
520
|
};
|
|
687
521
|
profile.webgl = {
|
|
688
522
|
metadata: {
|
|
689
523
|
vendor: (0, _utils2.get)(profile, "webGLMetadata.vendor"),
|
|
690
524
|
renderer: (0, _utils2.get)(profile, "webGLMetadata.renderer"),
|
|
691
|
-
mode: (0, _utils2.get)(profile, "webGLMetadata.mode") === "mask"
|
|
692
|
-
}
|
|
525
|
+
mode: (0, _utils2.get)(profile, "webGLMetadata.mode") === "mask"
|
|
526
|
+
}
|
|
693
527
|
};
|
|
694
528
|
profile.custom_fonts = {
|
|
695
|
-
enable: !!fonts?.enableMasking
|
|
529
|
+
enable: !!fonts?.enableMasking
|
|
696
530
|
};
|
|
697
531
|
const gologin = this.convertPreferences(profile);
|
|
698
|
-
debug(
|
|
699
|
-
`Writing profile for screenWidth ${profilePath}`,
|
|
700
|
-
JSON.stringify(gologin)
|
|
701
|
-
);
|
|
532
|
+
debug(`Writing profile for screenWidth ${profilePath}`, JSON.stringify(gologin));
|
|
702
533
|
gologin.screenWidth = this.resolution.width;
|
|
703
534
|
gologin.screenHeight = this.resolution.height;
|
|
704
535
|
debug("writeCookiesFromServer", this.writeCookiesFromServer);
|
|
705
|
-
this.cookiesFilePath = await (0, _cookiesManager.getCookiesFilePath)(
|
|
706
|
-
this.profile_id,
|
|
707
|
-
this.tmpdir
|
|
708
|
-
);
|
|
536
|
+
this.cookiesFilePath = await (0, _cookiesManager.getCookiesFilePath)(this.profile_id, this.tmpdir);
|
|
709
537
|
if (this.writeCookiesFromServer) {
|
|
710
538
|
await this.writeCookiesToFile(profile.cookies?.cookies);
|
|
711
539
|
}
|
|
@@ -715,11 +543,7 @@ class GoLogin {
|
|
|
715
543
|
this.isEmptyFonts = true;
|
|
716
544
|
}
|
|
717
545
|
try {
|
|
718
|
-
await (0, _browserUserDataManager.composeFonts)(
|
|
719
|
-
families,
|
|
720
|
-
profilePath,
|
|
721
|
-
this.differentOs
|
|
722
|
-
);
|
|
546
|
+
await (0, _browserUserDataManager.composeFonts)(families, profilePath, this.differentOs);
|
|
723
547
|
} catch (e) {
|
|
724
548
|
console.trace(e);
|
|
725
549
|
}
|
|
@@ -736,31 +560,14 @@ class GoLogin {
|
|
|
736
560
|
const isMAC = OS_PLATFORM === "darwin";
|
|
737
561
|
const checkAutoLangResult = (0, _browser.checkAutoLang)(gologin, this._tz);
|
|
738
562
|
this.browserLang = isMAC ? "en-US" : checkAutoLangResult;
|
|
739
|
-
await writeFile(
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
gologin,
|
|
744
|
-
})
|
|
745
|
-
)
|
|
746
|
-
);
|
|
747
|
-
const bookmarksParsedData = await (0, _utils.getCurrentProfileBookmarks)(
|
|
748
|
-
this.bookmarksFilePath
|
|
749
|
-
);
|
|
563
|
+
await writeFile((0, _path.join)(profilePath, "Default", "Preferences"), JSON.stringify(Object.assign(preferences, {
|
|
564
|
+
gologin
|
|
565
|
+
})));
|
|
566
|
+
const bookmarksParsedData = await (0, _utils.getCurrentProfileBookmarks)(this.bookmarksFilePath);
|
|
750
567
|
const bookmarksFromDb = profile.bookmarks?.bookmark_bar;
|
|
751
|
-
bookmarksParsedData.roots = bookmarksFromDb
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
await writeFile(
|
|
755
|
-
this.bookmarksFilePath,
|
|
756
|
-
JSON.stringify(bookmarksParsedData)
|
|
757
|
-
);
|
|
758
|
-
debug(
|
|
759
|
-
"Profile ready. Path: ",
|
|
760
|
-
profilePath,
|
|
761
|
-
"PROXY",
|
|
762
|
-
JSON.stringify((0, _utils2.get)(preferences, "gologin.proxy"))
|
|
763
|
-
);
|
|
568
|
+
bookmarksParsedData.roots = bookmarksFromDb ? profile.bookmarks : bookmarksParsedData.roots;
|
|
569
|
+
await writeFile(this.bookmarksFilePath, JSON.stringify(bookmarksParsedData));
|
|
570
|
+
debug("Profile ready. Path: ", profilePath, "PROXY", JSON.stringify((0, _utils2.get)(preferences, "gologin.proxy")));
|
|
764
571
|
return profilePath;
|
|
765
572
|
}
|
|
766
573
|
async commitProfile() {
|
|
@@ -793,7 +600,7 @@ class GoLogin {
|
|
|
793
600
|
debug("CHECKING PORT AVAILABLE", port);
|
|
794
601
|
try {
|
|
795
602
|
const portAvailable = await (0, _utils2.isPortReachable)(port, {
|
|
796
|
-
host: "localhost"
|
|
603
|
+
host: "localhost"
|
|
797
604
|
});
|
|
798
605
|
if (portAvailable) {
|
|
799
606
|
debug(`PORT ${port} IS OPEN`);
|
|
@@ -836,30 +643,52 @@ class GoLogin {
|
|
|
836
643
|
}
|
|
837
644
|
const proxyUrl = `${proxy.mode}://${proxy.username}:${proxy.password}@${proxy.host}:${proxy.port}`;
|
|
838
645
|
debug(`getTimeZone start ${TIMEZONE_URL}`, proxyUrl);
|
|
839
|
-
|
|
646
|
+
const response = await _requestretry.default.get(TIMEZONE_URL, {
|
|
840
647
|
proxy: proxyUrl,
|
|
841
648
|
timeout: 20 * 1000,
|
|
842
|
-
maxAttempts:
|
|
649
|
+
maxAttempts: 5
|
|
843
650
|
});
|
|
651
|
+
const result = JSON.parse(response.body);
|
|
652
|
+
data = {
|
|
653
|
+
body: {
|
|
654
|
+
country: result.country_code,
|
|
655
|
+
stateProv: result.city,
|
|
656
|
+
city: result.city,
|
|
657
|
+
timezone: (0, _timezone.tzlookup)(result.latitude, result.longitude),
|
|
658
|
+
ll: [result.latitude, result.longitude],
|
|
659
|
+
languages: "en",
|
|
660
|
+
accuracy: 100
|
|
661
|
+
}
|
|
662
|
+
};
|
|
844
663
|
} else {
|
|
664
|
+
const response = await _requestretry.default.get(TIMEZONE_URL, {
|
|
665
|
+
timeout: 20 * 1000,
|
|
666
|
+
maxAttempts: 5
|
|
667
|
+
});
|
|
668
|
+
const result = JSON.parse(response.body);
|
|
845
669
|
data = {
|
|
846
|
-
body:
|
|
847
|
-
country:
|
|
848
|
-
stateProv:
|
|
849
|
-
city:
|
|
850
|
-
timezone:
|
|
851
|
-
ll: [
|
|
852
|
-
languages: "
|
|
853
|
-
accuracy: 100
|
|
854
|
-
}
|
|
670
|
+
body: {
|
|
671
|
+
country: result.country_code,
|
|
672
|
+
stateProv: result.city,
|
|
673
|
+
city: result.city,
|
|
674
|
+
timezone: (0, _timezone.tzlookup)(result.latitude, result.longitude),
|
|
675
|
+
ll: [result.latitude, result.longitude],
|
|
676
|
+
languages: "en",
|
|
677
|
+
accuracy: 100
|
|
678
|
+
}
|
|
855
679
|
};
|
|
856
680
|
}
|
|
857
681
|
debug("getTimeZone finish", data.body);
|
|
858
|
-
this._tz =
|
|
682
|
+
this._tz = data.body;
|
|
859
683
|
return this._tz.timezone;
|
|
860
684
|
}
|
|
861
685
|
async getTimezoneWithSocks(params) {
|
|
862
|
-
const {
|
|
686
|
+
const {
|
|
687
|
+
host,
|
|
688
|
+
port,
|
|
689
|
+
username = "",
|
|
690
|
+
password = ""
|
|
691
|
+
} = params;
|
|
863
692
|
let body;
|
|
864
693
|
let proxy = "socks://";
|
|
865
694
|
if (username) {
|
|
@@ -869,29 +698,25 @@ class GoLogin {
|
|
|
869
698
|
proxy += host + ":" + port;
|
|
870
699
|
const agent = new _socksProxyAgent.SocksProxyAgent(proxy);
|
|
871
700
|
const checkData = await new Promise((resolve, reject) => {
|
|
872
|
-
(0, _https.get)(
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
(
|
|
879
|
-
let
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
resolve({
|
|
889
|
-
...res,
|
|
890
|
-
body: parsedData,
|
|
891
|
-
});
|
|
701
|
+
(0, _https.get)(TIMEZONE_URL, {
|
|
702
|
+
agent,
|
|
703
|
+
timeout: 10000
|
|
704
|
+
}, res => {
|
|
705
|
+
let resultResponse = "";
|
|
706
|
+
res.on("data", data => resultResponse += data);
|
|
707
|
+
res.on("end", () => {
|
|
708
|
+
let parsedData;
|
|
709
|
+
try {
|
|
710
|
+
parsedData = JSON.parse(resultResponse);
|
|
711
|
+
} catch (e) {
|
|
712
|
+
reject(e);
|
|
713
|
+
}
|
|
714
|
+
resolve({
|
|
715
|
+
...res,
|
|
716
|
+
body: parsedData
|
|
892
717
|
});
|
|
893
|
-
}
|
|
894
|
-
).on("error",
|
|
718
|
+
});
|
|
719
|
+
}).on("error", err => reject(err));
|
|
895
720
|
});
|
|
896
721
|
body = checkData.body || {};
|
|
897
722
|
if (!body.ip && checkData.statusCode.toString().startsWith("4")) {
|
|
@@ -903,24 +728,20 @@ class GoLogin {
|
|
|
903
728
|
}
|
|
904
729
|
async spawnArguments() {
|
|
905
730
|
const profile_path = this.profilePath();
|
|
906
|
-
let {
|
|
731
|
+
let {
|
|
732
|
+
proxy
|
|
733
|
+
} = this;
|
|
907
734
|
proxy = `${proxy.mode}://${proxy.host}:${proxy.port}`;
|
|
908
735
|
const env = {};
|
|
909
|
-
Object.keys(process.env).forEach(
|
|
736
|
+
Object.keys(process.env).forEach(key => {
|
|
910
737
|
env[key] = process.env[key];
|
|
911
738
|
});
|
|
912
|
-
const tz = await this.getTimeZone(this.proxy).catch(
|
|
739
|
+
const tz = await this.getTimeZone(this.proxy).catch(e => {
|
|
913
740
|
console.error("Proxy Error. Check it and try again.");
|
|
914
741
|
throw e;
|
|
915
742
|
});
|
|
916
743
|
env.TZ = tz;
|
|
917
|
-
let params = [
|
|
918
|
-
`--proxy-server=${proxy}`,
|
|
919
|
-
`--user-data-dir=${profile_path}`,
|
|
920
|
-
"--password-store=basic",
|
|
921
|
-
`--tz=${tz}`,
|
|
922
|
-
"--lang=en",
|
|
923
|
-
];
|
|
744
|
+
let params = [`--proxy-server=${proxy}`, `--user-data-dir=${profile_path}`, "--password-store=basic", `--tz=${tz}`, "--lang=en"];
|
|
924
745
|
if (Array.isArray(this.extra_params) && this.extra_params.length) {
|
|
925
746
|
params = params.concat(this.extra_params);
|
|
926
747
|
}
|
|
@@ -930,63 +751,42 @@ class GoLogin {
|
|
|
930
751
|
return params;
|
|
931
752
|
}
|
|
932
753
|
async spawnBrowser() {
|
|
933
|
-
let {
|
|
754
|
+
let {
|
|
755
|
+
remote_debugging_port,
|
|
756
|
+
customArgs
|
|
757
|
+
} = this;
|
|
934
758
|
if (!remote_debugging_port) {
|
|
935
759
|
remote_debugging_port = await this.getRandomPort();
|
|
936
760
|
}
|
|
937
761
|
const profile_path = this.profilePath();
|
|
938
|
-
let {
|
|
762
|
+
let {
|
|
763
|
+
proxy
|
|
764
|
+
} = this;
|
|
939
765
|
let proxy_host = "";
|
|
940
766
|
if (proxy) {
|
|
941
767
|
proxy_host = this.proxy.host;
|
|
942
768
|
proxy = `${proxy.mode}://${proxy.host}:${proxy.port}`;
|
|
943
769
|
}
|
|
944
770
|
this.port = remote_debugging_port;
|
|
945
|
-
const ORBITA_BROWSER =
|
|
946
|
-
this.executablePath || this.browserChecker.getOrbitaPath;
|
|
771
|
+
const ORBITA_BROWSER = this.executablePath || this.browserChecker.getOrbitaPath;
|
|
947
772
|
debug(`ORBITA_BROWSER=${ORBITA_BROWSER}`);
|
|
948
773
|
const env = {};
|
|
949
|
-
Object.keys(process.env).forEach(
|
|
774
|
+
Object.keys(process.env).forEach(key => {
|
|
950
775
|
env[key] = process.env[key];
|
|
951
776
|
});
|
|
952
|
-
const tz = await this.getTimeZone(this.proxy).catch(
|
|
777
|
+
const tz = await this.getTimeZone(this.proxy).catch(e => {
|
|
953
778
|
console.error("Proxy Error. Check it and try again.");
|
|
954
779
|
throw e;
|
|
955
780
|
});
|
|
956
781
|
env.TZ = tz;
|
|
957
782
|
if (this.vnc_port) {
|
|
958
783
|
const script_path = (0, _path.resolve)(__dirname, "./run.sh");
|
|
959
|
-
debug(
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
remote_debugging_port,
|
|
964
|
-
proxy,
|
|
965
|
-
profile_path,
|
|
966
|
-
this.vnc_port
|
|
967
|
-
);
|
|
968
|
-
(0, _child_process.execFile)(
|
|
969
|
-
script_path,
|
|
970
|
-
[
|
|
971
|
-
ORBITA_BROWSER,
|
|
972
|
-
remote_debugging_port,
|
|
973
|
-
proxy,
|
|
974
|
-
profile_path,
|
|
975
|
-
this.vnc_port,
|
|
976
|
-
tz,
|
|
977
|
-
],
|
|
978
|
-
{
|
|
979
|
-
env,
|
|
980
|
-
}
|
|
981
|
-
);
|
|
784
|
+
debug("RUNNING", script_path, ORBITA_BROWSER, remote_debugging_port, proxy, profile_path, this.vnc_port);
|
|
785
|
+
(0, _child_process.execFile)(script_path, [ORBITA_BROWSER, remote_debugging_port, proxy, profile_path, this.vnc_port, tz], {
|
|
786
|
+
env
|
|
787
|
+
});
|
|
982
788
|
} else {
|
|
983
|
-
let params = [
|
|
984
|
-
`--remote-debugging-port=${remote_debugging_port}`,
|
|
985
|
-
`--user-data-dir=${profile_path}`,
|
|
986
|
-
"--password-store=basic",
|
|
987
|
-
`--tz=${tz}`,
|
|
988
|
-
`--lang=${this.browserLang}`,
|
|
989
|
-
];
|
|
789
|
+
let params = [`--remote-debugging-port=${remote_debugging_port}`, `--user-data-dir=${profile_path}`, "--password-store=basic", `--tz=${tz}`, `--lang=${this.browserLang}`];
|
|
990
790
|
if (this.extensionPathsToInstall.length) {
|
|
991
791
|
if (Array.isArray(this.extra_params) && this.extra_params.length) {
|
|
992
792
|
this.extra_params.forEach((param, index) => {
|
|
@@ -995,16 +795,11 @@ class GoLogin {
|
|
|
995
795
|
}
|
|
996
796
|
const [_, extPathsString] = param.split("=");
|
|
997
797
|
const extPathsArray = extPathsString.split(",");
|
|
998
|
-
this.extensionPathsToInstall = [
|
|
999
|
-
...this.extensionPathsToInstall,
|
|
1000
|
-
...extPathsArray,
|
|
1001
|
-
];
|
|
798
|
+
this.extensionPathsToInstall = [...this.extensionPathsToInstall, ...extPathsArray];
|
|
1002
799
|
this.extra_params.splice(index, 1);
|
|
1003
800
|
});
|
|
1004
801
|
}
|
|
1005
|
-
params.push(
|
|
1006
|
-
`--load-extension=${this.extensionPathsToInstall.join(",")}`
|
|
1007
|
-
);
|
|
802
|
+
params.push(`--load-extension=${this.extensionPathsToInstall.join(",")}`);
|
|
1008
803
|
}
|
|
1009
804
|
if (this.fontsMasking) {
|
|
1010
805
|
let arg = "--font-masking-mode=2";
|
|
@@ -1030,21 +825,18 @@ class GoLogin {
|
|
|
1030
825
|
params.push(...new Set(customArgs));
|
|
1031
826
|
console.log(params);
|
|
1032
827
|
const child = (0, _child_process.execFile)(ORBITA_BROWSER, params, {
|
|
1033
|
-
env
|
|
828
|
+
env
|
|
1034
829
|
});
|
|
1035
830
|
this.processSpawned = child;
|
|
1036
831
|
// const child = spawn(ORBITA_BROWSER, params, { env, shell: true });
|
|
1037
|
-
child.stdout.on("data",
|
|
832
|
+
child.stdout.on("data", data => debug(data.toString()));
|
|
1038
833
|
debug("SPAWN CMD", ORBITA_BROWSER, params.join(" "));
|
|
1039
834
|
}
|
|
1040
835
|
if (this.waitWebsocket) {
|
|
1041
836
|
debug("GETTING WS URL FROM BROWSER");
|
|
1042
|
-
const data = await _requestretry.default.get(
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
json: true,
|
|
1046
|
-
}
|
|
1047
|
-
);
|
|
837
|
+
const data = await _requestretry.default.get(`http://127.0.0.1:${remote_debugging_port}/json/version`, {
|
|
838
|
+
json: true
|
|
839
|
+
});
|
|
1048
840
|
debug("WS IS", (0, _utils2.get)(data, "body.webSocketDebuggerUrl", ""));
|
|
1049
841
|
this.is_active = true;
|
|
1050
842
|
return (0, _utils2.get)(data, "body.webSocketDebuggerUrl", "");
|
|
@@ -1056,31 +848,23 @@ class GoLogin {
|
|
|
1056
848
|
return this.spawnBrowser();
|
|
1057
849
|
}
|
|
1058
850
|
async clearProfileFiles() {
|
|
1059
|
-
await (0, _rimraf.default)(
|
|
1060
|
-
|
|
1061
|
-
() => null
|
|
1062
|
-
);
|
|
1063
|
-
await (0, _rimraf.default)(
|
|
1064
|
-
(0, _path.join)(this.tmpdir, `gologin_${this.profile_id}_upload.zip`),
|
|
1065
|
-
() => null
|
|
1066
|
-
);
|
|
851
|
+
await (0, _rimraf.default)((0, _path.join)(this.tmpdir, `gologin_profile_${this.profile_id}`), () => null);
|
|
852
|
+
await (0, _rimraf.default)((0, _path.join)(this.tmpdir, `gologin_${this.profile_id}_upload.zip`), () => null);
|
|
1067
853
|
}
|
|
1068
854
|
async stopAndCommit(options, local = false) {
|
|
1069
855
|
if (this.is_stopping) {
|
|
1070
856
|
return true;
|
|
1071
857
|
}
|
|
1072
|
-
const is_posting =
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
// backward compability
|
|
1076
|
-
false;
|
|
858
|
+
const is_posting = options.posting || options.postings ||
|
|
859
|
+
// backward compability
|
|
860
|
+
false;
|
|
1077
861
|
if (this.uploadCookiesToServer) {
|
|
1078
|
-
await this.
|
|
862
|
+
const updateResult = await this.uploadProfileDataToServer();
|
|
863
|
+
this.storageGatewayUrl = updateResult.storageGateway.url;
|
|
1079
864
|
}
|
|
1080
865
|
this.is_stopping = true;
|
|
1081
866
|
await this.sanitizeProfile();
|
|
1082
867
|
if (is_posting) {
|
|
1083
|
-
await this.saveBookmarksToDb();
|
|
1084
868
|
await this.commitProfile();
|
|
1085
869
|
}
|
|
1086
870
|
this.is_stopping = false;
|
|
@@ -1088,25 +872,42 @@ class GoLogin {
|
|
|
1088
872
|
await delay(3000);
|
|
1089
873
|
await this.clearProfileFiles();
|
|
1090
874
|
if (!local) {
|
|
1091
|
-
await (0, _rimraf.default)(
|
|
1092
|
-
(0, _path.join)(this.tmpdir, `gologin_${this.profile_id}.zip`),
|
|
1093
|
-
() => null
|
|
1094
|
-
);
|
|
875
|
+
await (0, _rimraf.default)((0, _path.join)(this.tmpdir, `gologin_${this.profile_id}.zip`), () => null);
|
|
1095
876
|
}
|
|
1096
877
|
debug(`PROFILE ${this.profile_id} STOPPED AND CLEAR`);
|
|
1097
878
|
return false;
|
|
1098
879
|
}
|
|
880
|
+
async uploadProfileDataToServer() {
|
|
881
|
+
const cookies = await (0, _cookiesManager.loadCookiesFromFile)(this.cookiesFilePath);
|
|
882
|
+
const bookmarks = await (0, _utils.getCurrentProfileBookmarks)(this.bookmarksFilePath);
|
|
883
|
+
const body = {
|
|
884
|
+
cookies,
|
|
885
|
+
bookmarks,
|
|
886
|
+
isCookiesEncrypted: true,
|
|
887
|
+
isStorageGateway: true
|
|
888
|
+
};
|
|
889
|
+
const updateResult = await _requestretry.default.post(`${_common.API_URL}/browser/features/profile/${this.profile_id}/update_after_close`, {
|
|
890
|
+
headers: {
|
|
891
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
892
|
+
"User-Agent": "gologin-api"
|
|
893
|
+
},
|
|
894
|
+
json: body,
|
|
895
|
+
maxAttempts: 3,
|
|
896
|
+
retryDelay: 2000,
|
|
897
|
+
timeout: 20 * 1000
|
|
898
|
+
}).catch(e => {
|
|
899
|
+
console.log(e);
|
|
900
|
+
return e;
|
|
901
|
+
});
|
|
902
|
+
return updateResult.body;
|
|
903
|
+
}
|
|
1099
904
|
async stopBrowser() {
|
|
1100
905
|
if (!this.port) {
|
|
1101
906
|
throw new Error("Empty GoLogin port");
|
|
1102
907
|
}
|
|
1103
|
-
const ls = await (0, _child_process.spawn)(
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
{
|
|
1107
|
-
shell: true,
|
|
1108
|
-
}
|
|
1109
|
-
);
|
|
908
|
+
const ls = await (0, _child_process.spawn)("fuser", ["-k TERM", `-n tcp ${this.port}`], {
|
|
909
|
+
shell: true
|
|
910
|
+
});
|
|
1110
911
|
debug("browser killed");
|
|
1111
912
|
}
|
|
1112
913
|
killBrowser() {
|
|
@@ -1126,57 +927,24 @@ class GoLogin {
|
|
|
1126
927
|
await this.stopAndCommit(options, local).catch(console.error);
|
|
1127
928
|
}
|
|
1128
929
|
async sanitizeProfile() {
|
|
1129
|
-
const remove_dirs = [
|
|
1130
|
-
`${SEPARATOR}Default${SEPARATOR}Cache`,
|
|
1131
|
-
`${SEPARATOR}Default${SEPARATOR}Service Worker`,
|
|
1132
|
-
`${SEPARATOR}Default${SEPARATOR}Code Cache`,
|
|
1133
|
-
`${SEPARATOR}Default${SEPARATOR}GPUCache`,
|
|
1134
|
-
`${SEPARATOR}Default${SEPARATOR}Extensions`,
|
|
1135
|
-
`${SEPARATOR}Default${SEPARATOR}IndexedDB`,
|
|
1136
|
-
`${SEPARATOR}Default${SEPARATOR}GPUCache`,
|
|
1137
|
-
`${SEPARATOR}Default${SEPARATOR}DawnCache`,
|
|
1138
|
-
`${SEPARATOR}Default${SEPARATOR}fonts_config`,
|
|
1139
|
-
`${SEPARATOR}GrShaderCache`,
|
|
1140
|
-
`${SEPARATOR}ShaderCache`,
|
|
1141
|
-
`${SEPARATOR}biahpgbdmdkfgndcmfiipgcebobojjkp`,
|
|
1142
|
-
`${SEPARATOR}afalakplffnnnlkncjhbmahjfjhmlkal`,
|
|
1143
|
-
`${SEPARATOR}cffkpbalmllkdoenhmdmpbkajipdjfam`,
|
|
1144
|
-
`${SEPARATOR}Dictionaries`,
|
|
1145
|
-
`${SEPARATOR}enkheaiicpeffbfgjiklngbpkilnbkoi`,
|
|
1146
|
-
`${SEPARATOR}oofiananboodjbbmdelgdommihjbkfag`,
|
|
1147
|
-
`${SEPARATOR}SafetyTips`,
|
|
1148
|
-
`${SEPARATOR}fonts`,
|
|
1149
|
-
`${SEPARATOR}BrowserMetrics`,
|
|
1150
|
-
`${SEPARATOR}BrowserMetrics-spare.pma`,
|
|
1151
|
-
];
|
|
930
|
+
const remove_dirs = [`${SEPARATOR}Default${SEPARATOR}Cache`, `${SEPARATOR}Default${SEPARATOR}Service Worker`, `${SEPARATOR}Default${SEPARATOR}Code Cache`, `${SEPARATOR}Default${SEPARATOR}GPUCache`, `${SEPARATOR}Default${SEPARATOR}Extensions`, `${SEPARATOR}Default${SEPARATOR}IndexedDB`, `${SEPARATOR}Default${SEPARATOR}GPUCache`, `${SEPARATOR}Default${SEPARATOR}DawnCache`, `${SEPARATOR}Default${SEPARATOR}fonts_config`, `${SEPARATOR}GrShaderCache`, `${SEPARATOR}ShaderCache`, `${SEPARATOR}biahpgbdmdkfgndcmfiipgcebobojjkp`, `${SEPARATOR}afalakplffnnnlkncjhbmahjfjhmlkal`, `${SEPARATOR}cffkpbalmllkdoenhmdmpbkajipdjfam`, `${SEPARATOR}Dictionaries`, `${SEPARATOR}enkheaiicpeffbfgjiklngbpkilnbkoi`, `${SEPARATOR}oofiananboodjbbmdelgdommihjbkfag`, `${SEPARATOR}SafetyTips`, `${SEPARATOR}fonts`, `${SEPARATOR}BrowserMetrics`, `${SEPARATOR}BrowserMetrics-spare.pma`];
|
|
1152
931
|
const that = this;
|
|
1153
|
-
await Promise.all(
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
},
|
|
1163
|
-
(e) => {
|
|
1164
|
-
// debug('DROPPING RESULT', e);
|
|
1165
|
-
resolve();
|
|
1166
|
-
}
|
|
1167
|
-
);
|
|
932
|
+
await Promise.all(remove_dirs.map(d => {
|
|
933
|
+
const path_to_remove = `${that.profilePath()}${d}`;
|
|
934
|
+
return new Promise(resolve => {
|
|
935
|
+
debug("DROPPING", path_to_remove);
|
|
936
|
+
(0, _rimraf.default)(path_to_remove, {
|
|
937
|
+
maxBusyTries: 100
|
|
938
|
+
}, e => {
|
|
939
|
+
// debug('DROPPING RESULT', e);
|
|
940
|
+
resolve();
|
|
1168
941
|
});
|
|
1169
|
-
})
|
|
1170
|
-
);
|
|
942
|
+
});
|
|
943
|
+
}));
|
|
1171
944
|
}
|
|
1172
945
|
async getProfileDataToUpdate() {
|
|
1173
|
-
const zipPath = (0, _path.join)(
|
|
1174
|
-
|
|
1175
|
-
`gologin_${this.profile_id}_upload.zip`
|
|
1176
|
-
);
|
|
1177
|
-
const zipExists = await access(zipPath)
|
|
1178
|
-
.then(() => true)
|
|
1179
|
-
.catch(() => false);
|
|
946
|
+
const zipPath = (0, _path.join)(this.tmpdir, `gologin_${this.profile_id}_upload.zip`);
|
|
947
|
+
const zipExists = await access(zipPath).then(() => true).catch(() => false);
|
|
1180
948
|
if (zipExists) {
|
|
1181
949
|
await unlink(zipPath);
|
|
1182
950
|
}
|
|
@@ -1188,16 +956,13 @@ class GoLogin {
|
|
|
1188
956
|
return fileBuff;
|
|
1189
957
|
}
|
|
1190
958
|
async profileExists() {
|
|
1191
|
-
const profileResponse = await _requestretry.default.post(
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
json: {},
|
|
1199
|
-
}
|
|
1200
|
-
);
|
|
959
|
+
const profileResponse = await _requestretry.default.post(`${_common.API_URL}/browser`, {
|
|
960
|
+
headers: {
|
|
961
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
962
|
+
"User-Agent": "gologin-api"
|
|
963
|
+
},
|
|
964
|
+
json: {}
|
|
965
|
+
});
|
|
1201
966
|
if (profileResponse.statusCode !== 200) {
|
|
1202
967
|
return false;
|
|
1203
968
|
}
|
|
@@ -1216,8 +981,8 @@ class GoLogin {
|
|
|
1216
981
|
const fingerprint = await _requestretry.default.get(url, {
|
|
1217
982
|
headers: {
|
|
1218
983
|
Authorization: `Bearer ${this.access_token}`,
|
|
1219
|
-
"User-Agent": "gologin-api"
|
|
1220
|
-
}
|
|
984
|
+
"User-Agent": "gologin-api"
|
|
985
|
+
}
|
|
1221
986
|
});
|
|
1222
987
|
return JSON.parse(fingerprint.body);
|
|
1223
988
|
}
|
|
@@ -1231,7 +996,12 @@ class GoLogin {
|
|
|
1231
996
|
if (fingerprint.statusCode === 401) {
|
|
1232
997
|
throw new Error("invalid token");
|
|
1233
998
|
}
|
|
1234
|
-
const {
|
|
999
|
+
const {
|
|
1000
|
+
navigator,
|
|
1001
|
+
fonts,
|
|
1002
|
+
webGLMetadata,
|
|
1003
|
+
webRTC
|
|
1004
|
+
} = fingerprint;
|
|
1235
1005
|
let deviceMemory = navigator.deviceMemory || 2;
|
|
1236
1006
|
if (deviceMemory < 1) {
|
|
1237
1007
|
deviceMemory = 1;
|
|
@@ -1246,20 +1016,20 @@ class GoLogin {
|
|
|
1246
1016
|
name: "default_name",
|
|
1247
1017
|
notes: "auto generated",
|
|
1248
1018
|
fonts: {
|
|
1249
|
-
families: fonts
|
|
1019
|
+
families: fonts
|
|
1250
1020
|
},
|
|
1251
1021
|
webRTC: {
|
|
1252
1022
|
...webRTC,
|
|
1253
|
-
mode: "alerted"
|
|
1254
|
-
}
|
|
1023
|
+
mode: "alerted"
|
|
1024
|
+
}
|
|
1255
1025
|
};
|
|
1256
1026
|
const user_agent = options.navigator?.userAgent;
|
|
1257
1027
|
const orig_user_agent = json.navigator.userAgent;
|
|
1258
|
-
Object.keys(options).forEach(
|
|
1028
|
+
Object.keys(options).forEach(key => {
|
|
1259
1029
|
if (typeof json[key] === "object") {
|
|
1260
1030
|
json[key] = {
|
|
1261
1031
|
...json[key],
|
|
1262
|
-
...options[key]
|
|
1032
|
+
...options[key]
|
|
1263
1033
|
};
|
|
1264
1034
|
return;
|
|
1265
1035
|
}
|
|
@@ -1268,112 +1038,87 @@ class GoLogin {
|
|
|
1268
1038
|
if (user_agent === "random") {
|
|
1269
1039
|
json.navigator.userAgent = orig_user_agent;
|
|
1270
1040
|
}
|
|
1271
|
-
const response = await _requestretry.default.post(
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
json,
|
|
1279
|
-
}
|
|
1280
|
-
);
|
|
1041
|
+
const response = await _requestretry.default.post(`${_common.API_URL}/browser`, {
|
|
1042
|
+
headers: {
|
|
1043
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
1044
|
+
"User-Agent": "gologin-api"
|
|
1045
|
+
},
|
|
1046
|
+
json
|
|
1047
|
+
});
|
|
1281
1048
|
if (response.statusCode === 400) {
|
|
1282
|
-
throw new Error(
|
|
1283
|
-
`gologin failed account creation with status code, ${
|
|
1284
|
-
response.statusCode
|
|
1285
|
-
} DATA ${JSON.stringify(response.body.message)}`
|
|
1286
|
-
);
|
|
1049
|
+
throw new Error(`gologin failed account creation with status code, ${response.statusCode} DATA ${JSON.stringify(response.body.message)}`);
|
|
1287
1050
|
}
|
|
1288
1051
|
if (response.statusCode === 500) {
|
|
1289
|
-
throw new Error(
|
|
1290
|
-
`gologin failed account creation with status code, ${response.statusCode}`
|
|
1291
|
-
);
|
|
1052
|
+
throw new Error(`gologin failed account creation with status code, ${response.statusCode}`);
|
|
1292
1053
|
}
|
|
1293
1054
|
debug(JSON.stringify(response.body));
|
|
1294
1055
|
return response.body.id;
|
|
1295
1056
|
}
|
|
1296
1057
|
async createCustom(options) {
|
|
1297
1058
|
debug("createCustomProfile", options);
|
|
1298
|
-
const response = await _requestretry.default.post(
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
json: options,
|
|
1306
|
-
}
|
|
1307
|
-
);
|
|
1059
|
+
const response = await _requestretry.default.post(`${_common.API_URL}/browser/custom`, {
|
|
1060
|
+
headers: {
|
|
1061
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
1062
|
+
"User-Agent": "gologin-api"
|
|
1063
|
+
},
|
|
1064
|
+
json: options
|
|
1065
|
+
});
|
|
1308
1066
|
if (response.statusCode === 400) {
|
|
1309
|
-
throw new Error(
|
|
1310
|
-
`gologin failed account creation with status code, ${
|
|
1311
|
-
response.statusCode
|
|
1312
|
-
} DATA ${JSON.stringify(response.body.message)}`
|
|
1313
|
-
);
|
|
1067
|
+
throw new Error(`gologin failed account creation with status code, ${response.statusCode} DATA ${JSON.stringify(response.body.message)}`);
|
|
1314
1068
|
}
|
|
1315
1069
|
if (response.statusCode === 500) {
|
|
1316
|
-
throw new Error(
|
|
1317
|
-
`gologin failed account creation with status code, ${response.statusCode}`
|
|
1318
|
-
);
|
|
1070
|
+
throw new Error(`gologin failed account creation with status code, ${response.statusCode}`);
|
|
1319
1071
|
}
|
|
1320
1072
|
debug(JSON.stringify(response));
|
|
1321
1073
|
return response.body.id;
|
|
1322
1074
|
}
|
|
1323
1075
|
async quickCreateProfile(name = "") {
|
|
1324
1076
|
const osInfo = await (0, _common.getOsAdvanced)();
|
|
1325
|
-
const {
|
|
1077
|
+
const {
|
|
1078
|
+
os,
|
|
1079
|
+
osSpec
|
|
1080
|
+
} = osInfo;
|
|
1326
1081
|
const resultName = name || "api-generated";
|
|
1327
|
-
return _requestretry.default
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
})
|
|
1339
|
-
.then((res) => res.body);
|
|
1082
|
+
return _requestretry.default.post(`${_common.API_URL}/browser/quick`, {
|
|
1083
|
+
headers: {
|
|
1084
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
1085
|
+
"User-Agent": "gologin-api"
|
|
1086
|
+
},
|
|
1087
|
+
json: {
|
|
1088
|
+
os,
|
|
1089
|
+
osSpec,
|
|
1090
|
+
name: resultName
|
|
1091
|
+
}
|
|
1092
|
+
}).then(res => res.body);
|
|
1340
1093
|
}
|
|
1341
1094
|
async delete(pid) {
|
|
1342
1095
|
const profile_id = pid || this.profile_id;
|
|
1343
|
-
await _requestretry.default.delete(
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
Authorization: `Bearer ${this.access_token}`,
|
|
1348
|
-
"User-Agent": "gologin-api",
|
|
1349
|
-
},
|
|
1096
|
+
await _requestretry.default.delete(`${_common.API_URL}/browser/${profile_id}`, {
|
|
1097
|
+
headers: {
|
|
1098
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
1099
|
+
"User-Agent": "gologin-api"
|
|
1350
1100
|
}
|
|
1351
|
-
);
|
|
1101
|
+
});
|
|
1352
1102
|
}
|
|
1353
1103
|
async update(options) {
|
|
1354
1104
|
this.profile_id = options.id;
|
|
1355
1105
|
const profile = await this.getProfile();
|
|
1356
1106
|
if (options.navigator) {
|
|
1357
|
-
Object.keys(options.navigator).map(
|
|
1107
|
+
Object.keys(options.navigator).map(e => {
|
|
1358
1108
|
profile.navigator[e] = options.navigator[e];
|
|
1359
1109
|
});
|
|
1360
1110
|
}
|
|
1361
|
-
Object.keys(options)
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
profile[el] = options[el];
|
|
1365
|
-
});
|
|
1111
|
+
Object.keys(options).filter(el => el !== "navigator").forEach(el => {
|
|
1112
|
+
profile[el] = options[el];
|
|
1113
|
+
});
|
|
1366
1114
|
debug("update profile", profile);
|
|
1367
|
-
const response = await _requestretry.default.put(
|
|
1368
|
-
|
|
1369
|
-
{
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
Authorization: `Bearer ${this.access_token}`,
|
|
1373
|
-
"User-Agent": "gologin-api",
|
|
1374
|
-
},
|
|
1115
|
+
const response = await _requestretry.default.put(`${_common.API_URL}/browser/${options.id}`, {
|
|
1116
|
+
json: profile,
|
|
1117
|
+
headers: {
|
|
1118
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
1119
|
+
"User-Agent": "gologin-api"
|
|
1375
1120
|
}
|
|
1376
|
-
);
|
|
1121
|
+
});
|
|
1377
1122
|
debug("response", JSON.stringify(response.body));
|
|
1378
1123
|
return response.body;
|
|
1379
1124
|
}
|
|
@@ -1386,28 +1131,24 @@ class GoLogin {
|
|
|
1386
1131
|
mode: profileGeolocationParams.mode,
|
|
1387
1132
|
latitude: Number(tzGeolocationParams.latitude),
|
|
1388
1133
|
longitude: Number(tzGeolocationParams.longitude),
|
|
1389
|
-
accuracy: Number(tzGeolocationParams.accuracy)
|
|
1134
|
+
accuracy: Number(tzGeolocationParams.accuracy)
|
|
1390
1135
|
};
|
|
1391
1136
|
}
|
|
1392
1137
|
return {
|
|
1393
1138
|
mode: profileGeolocationParams.mode,
|
|
1394
1139
|
latitude: profileGeolocationParams.latitude,
|
|
1395
1140
|
longitude: profileGeolocationParams.longitude,
|
|
1396
|
-
accuracy: profileGeolocationParams.accuracy
|
|
1141
|
+
accuracy: profileGeolocationParams.accuracy
|
|
1397
1142
|
};
|
|
1398
1143
|
}
|
|
1399
1144
|
getViewPort() {
|
|
1400
1145
|
return {
|
|
1401
|
-
...this.resolution
|
|
1146
|
+
...this.resolution
|
|
1402
1147
|
};
|
|
1403
1148
|
}
|
|
1404
1149
|
async postCookies(profileId, cookies) {
|
|
1405
|
-
const formattedCookies = cookies.map(
|
|
1406
|
-
if (
|
|
1407
|
-
!["no_restriction", "lax", "strict", "unspecified"].includes(
|
|
1408
|
-
cookie.sameSite
|
|
1409
|
-
)
|
|
1410
|
-
) {
|
|
1150
|
+
const formattedCookies = cookies.map(cookie => {
|
|
1151
|
+
if (!["no_restriction", "lax", "strict", "unspecified"].includes(cookie.sameSite)) {
|
|
1411
1152
|
cookie.sameSite = "unspecified";
|
|
1412
1153
|
}
|
|
1413
1154
|
return cookie;
|
|
@@ -1416,7 +1157,7 @@ class GoLogin {
|
|
|
1416
1157
|
profileId,
|
|
1417
1158
|
cookies: formattedCookies,
|
|
1418
1159
|
API_BASE_URL: _common.API_URL,
|
|
1419
|
-
ACCESS_TOKEN: this.access_token
|
|
1160
|
+
ACCESS_TOKEN: this.access_token
|
|
1420
1161
|
});
|
|
1421
1162
|
if (response.statusCode === 200) {
|
|
1422
1163
|
return response.body;
|
|
@@ -1424,14 +1165,14 @@ class GoLogin {
|
|
|
1424
1165
|
return {
|
|
1425
1166
|
status: "failure",
|
|
1426
1167
|
status_code: response.statusCode,
|
|
1427
|
-
body: response.body
|
|
1168
|
+
body: response.body
|
|
1428
1169
|
};
|
|
1429
1170
|
}
|
|
1430
1171
|
async getCookies(profileId) {
|
|
1431
1172
|
const response = await (0, _browserUserDataManager.downloadCookies)({
|
|
1432
1173
|
profileId,
|
|
1433
1174
|
API_BASE_URL: _common.API_URL,
|
|
1434
|
-
ACCESS_TOKEN: this.access_token
|
|
1175
|
+
ACCESS_TOKEN: this.access_token
|
|
1435
1176
|
});
|
|
1436
1177
|
return response.body;
|
|
1437
1178
|
}
|
|
@@ -1444,7 +1185,7 @@ class GoLogin {
|
|
|
1444
1185
|
}
|
|
1445
1186
|
return {
|
|
1446
1187
|
primary,
|
|
1447
|
-
secondary
|
|
1188
|
+
secondary
|
|
1448
1189
|
};
|
|
1449
1190
|
}
|
|
1450
1191
|
async writeCookiesToFile(cookies) {
|
|
@@ -1454,27 +1195,19 @@ class GoLogin {
|
|
|
1454
1195
|
if (!cookies?.length) {
|
|
1455
1196
|
return;
|
|
1456
1197
|
}
|
|
1457
|
-
const resultCookies = cookies.map(
|
|
1198
|
+
const resultCookies = cookies.map(el => ({
|
|
1458
1199
|
...el,
|
|
1459
|
-
value: Buffer.from(el.value)
|
|
1200
|
+
value: Buffer.from(el.value)
|
|
1460
1201
|
}));
|
|
1461
1202
|
let db;
|
|
1462
|
-
const profilePath = (0, _path.join)(
|
|
1463
|
-
this.tmpdir,
|
|
1464
|
-
`gologin_profile_${this.profile_id}`
|
|
1465
|
-
);
|
|
1203
|
+
const profilePath = (0, _path.join)(this.tmpdir, `gologin_profile_${this.profile_id}`);
|
|
1466
1204
|
const defaultFilePath = (0, _path.resolve)(profilePath, "Default");
|
|
1467
1205
|
const cookiesPaths = this.getCookiePath(defaultFilePath);
|
|
1468
1206
|
try {
|
|
1469
1207
|
db = await (0, _cookiesManager.getDB)(cookiesPaths.primary, false);
|
|
1470
|
-
const cookiesToInsert = await (0, _cookiesManager.getUniqueCookies)(
|
|
1471
|
-
resultCookies,
|
|
1472
|
-
cookiesPaths.primary
|
|
1473
|
-
);
|
|
1208
|
+
const cookiesToInsert = await (0, _cookiesManager.getUniqueCookies)(resultCookies, cookiesPaths.primary);
|
|
1474
1209
|
if (cookiesToInsert.length) {
|
|
1475
|
-
const chunckInsertValues = (0, _cookiesManager.getChunckedInsertValues)(
|
|
1476
|
-
cookiesToInsert
|
|
1477
|
-
);
|
|
1210
|
+
const chunckInsertValues = (0, _cookiesManager.getChunckedInsertValues)(cookiesToInsert);
|
|
1478
1211
|
for (const [query, queryParams] of chunckInsertValues) {
|
|
1479
1212
|
const insertStmt = await db.prepare(query);
|
|
1480
1213
|
await insertStmt.run(queryParams);
|
|
@@ -1485,44 +1218,29 @@ class GoLogin {
|
|
|
1485
1218
|
console.log(error.message);
|
|
1486
1219
|
} finally {
|
|
1487
1220
|
db && (await db.close());
|
|
1488
|
-
await copyFile(cookiesPaths.primary, cookiesPaths.secondary).catch(
|
|
1489
|
-
console.log
|
|
1490
|
-
);
|
|
1221
|
+
await copyFile(cookiesPaths.primary, cookiesPaths.secondary).catch(console.log);
|
|
1491
1222
|
}
|
|
1492
1223
|
}
|
|
1493
1224
|
async uploadProfileCookiesToServer() {
|
|
1494
|
-
const cookies = await (0, _cookiesManager.loadCookiesFromFile)(
|
|
1495
|
-
this.cookiesFilePath
|
|
1496
|
-
);
|
|
1225
|
+
const cookies = await (0, _cookiesManager.loadCookiesFromFile)(this.cookiesFilePath);
|
|
1497
1226
|
if (!cookies.length) {
|
|
1498
1227
|
return;
|
|
1499
1228
|
}
|
|
1500
1229
|
return this.postCookies(this.profile_id, cookies);
|
|
1501
1230
|
}
|
|
1502
1231
|
async saveBookmarksToDb() {
|
|
1503
|
-
const bookmarksData = await (0, _utils.getCurrentProfileBookmarks)(
|
|
1504
|
-
this.bookmarksFilePath
|
|
1505
|
-
);
|
|
1232
|
+
const bookmarksData = await (0, _utils.getCurrentProfileBookmarks)(this.bookmarksFilePath);
|
|
1506
1233
|
const bookmarks = bookmarksData.roots || {};
|
|
1507
|
-
await (0, _browserApi.updateProfileBookmarks)(
|
|
1508
|
-
[this.profile_id],
|
|
1509
|
-
this.access_token,
|
|
1510
|
-
bookmarks
|
|
1511
|
-
);
|
|
1234
|
+
await (0, _browserApi.updateProfileBookmarks)([this.profile_id], this.access_token, bookmarks);
|
|
1512
1235
|
}
|
|
1513
1236
|
async start() {
|
|
1514
1237
|
if (!this.executablePath) {
|
|
1515
1238
|
await this.checkBrowser();
|
|
1516
1239
|
}
|
|
1517
|
-
const ORBITA_BROWSER =
|
|
1518
|
-
|
|
1519
|
-
const orbitaBrowserExists = await access(ORBITA_BROWSER)
|
|
1520
|
-
.then(() => true)
|
|
1521
|
-
.catch(() => false);
|
|
1240
|
+
const ORBITA_BROWSER = this.executablePath || this.browserChecker.getOrbitaPath;
|
|
1241
|
+
const orbitaBrowserExists = await access(ORBITA_BROWSER).then(() => true).catch(() => false);
|
|
1522
1242
|
if (!orbitaBrowserExists) {
|
|
1523
|
-
throw new Error(
|
|
1524
|
-
`Orbita browser is not exists on path ${ORBITA_BROWSER}, check executablePath param`
|
|
1525
|
-
);
|
|
1243
|
+
throw new Error(`Orbita browser is not exists on path ${ORBITA_BROWSER}, check executablePath param`);
|
|
1526
1244
|
}
|
|
1527
1245
|
await this.createStartup();
|
|
1528
1246
|
// await this.createBrowserExtension();
|
|
@@ -1530,7 +1248,7 @@ class GoLogin {
|
|
|
1530
1248
|
this.setActive(true);
|
|
1531
1249
|
return {
|
|
1532
1250
|
status: "success",
|
|
1533
|
-
wsUrl
|
|
1251
|
+
wsUrl
|
|
1534
1252
|
};
|
|
1535
1253
|
}
|
|
1536
1254
|
async startLocal() {
|
|
@@ -1540,21 +1258,18 @@ class GoLogin {
|
|
|
1540
1258
|
this.setActive(true);
|
|
1541
1259
|
return {
|
|
1542
1260
|
status: "success",
|
|
1543
|
-
wsUrl
|
|
1261
|
+
wsUrl
|
|
1544
1262
|
};
|
|
1545
1263
|
}
|
|
1546
1264
|
async stop() {
|
|
1547
|
-
await new Promise(
|
|
1548
|
-
await this.stopAndCommit(
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
},
|
|
1552
|
-
false
|
|
1553
|
-
);
|
|
1265
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
1266
|
+
await this.stopAndCommit({
|
|
1267
|
+
posting: true
|
|
1268
|
+
}, false);
|
|
1554
1269
|
}
|
|
1555
1270
|
async stopLocal(options) {
|
|
1556
1271
|
const opts = options || {
|
|
1557
|
-
posting: false
|
|
1272
|
+
posting: false
|
|
1558
1273
|
};
|
|
1559
1274
|
await this.stopAndCommit(opts, true);
|
|
1560
1275
|
}
|
|
@@ -1579,60 +1294,38 @@ class GoLogin {
|
|
|
1579
1294
|
status: "failure",
|
|
1580
1295
|
wsUrl,
|
|
1581
1296
|
message: "Check proxy settings",
|
|
1582
|
-
profile_id: this.profile_id
|
|
1297
|
+
profile_id: this.profile_id
|
|
1583
1298
|
};
|
|
1584
1299
|
}
|
|
1585
|
-
const remoteOrbitaUrlWithoutProtocol = remoteOrbitaUrl.replace(
|
|
1586
|
-
|
|
1587
|
-
""
|
|
1588
|
-
);
|
|
1589
|
-
wsUrl = wsUrl
|
|
1590
|
-
.replace("ws://", "wss://")
|
|
1591
|
-
.replace("127.0.0.1", remoteOrbitaUrlWithoutProtocol);
|
|
1300
|
+
const remoteOrbitaUrlWithoutProtocol = remoteOrbitaUrl.replace("https://", "");
|
|
1301
|
+
wsUrl = wsUrl.replace("ws://", "wss://").replace("127.0.0.1", remoteOrbitaUrlWithoutProtocol);
|
|
1592
1302
|
return wsUrl;
|
|
1593
1303
|
}
|
|
1594
1304
|
async stopRemote() {
|
|
1595
1305
|
debug(`stopRemote ${this.profile_id}`);
|
|
1596
|
-
const profileResponse = await _requestretry.default.delete(
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
Authorization: `Bearer ${this.access_token}`,
|
|
1601
|
-
"User-Agent": "gologin-api",
|
|
1602
|
-
},
|
|
1306
|
+
const profileResponse = await _requestretry.default.delete(`${_common.API_URL}/browser/${this.profile_id}/web`, {
|
|
1307
|
+
headers: {
|
|
1308
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
1309
|
+
"User-Agent": "gologin-api"
|
|
1603
1310
|
}
|
|
1604
|
-
);
|
|
1311
|
+
});
|
|
1605
1312
|
console.log(`stopRemote ${profileResponse.body}`);
|
|
1606
1313
|
if (profileResponse.body) {
|
|
1607
1314
|
return JSON.parse(profileResponse.body);
|
|
1608
1315
|
}
|
|
1609
1316
|
}
|
|
1610
1317
|
getAvailableFonts() {
|
|
1611
|
-
return _fonts.fontsCollection
|
|
1612
|
-
.filter((elem) => elem.fileNames)
|
|
1613
|
-
.map((elem) => elem.name);
|
|
1318
|
+
return _fonts.fontsCollection.filter(elem => elem.fileNames).map(elem => elem.name);
|
|
1614
1319
|
}
|
|
1615
1320
|
async changeProfileResolution(resolution) {
|
|
1616
|
-
return (0, _browserApi.updateProfileResolution)(
|
|
1617
|
-
this.profile_id,
|
|
1618
|
-
this.access_token,
|
|
1619
|
-
resolution
|
|
1620
|
-
);
|
|
1321
|
+
return (0, _browserApi.updateProfileResolution)(this.profile_id, this.access_token, resolution);
|
|
1621
1322
|
}
|
|
1622
1323
|
async changeProfileUserAgent(userAgent) {
|
|
1623
|
-
return (0, _browserApi.updateProfileUserAgent)(
|
|
1624
|
-
this.profile_id,
|
|
1625
|
-
this.access_token,
|
|
1626
|
-
userAgent
|
|
1627
|
-
);
|
|
1324
|
+
return (0, _browserApi.updateProfileUserAgent)(this.profile_id, this.access_token, userAgent);
|
|
1628
1325
|
}
|
|
1629
1326
|
async changeProfileProxy(proxyData) {
|
|
1630
|
-
return (0, _browserApi.updateProfileProxy)(
|
|
1631
|
-
this.profile_id,
|
|
1632
|
-
this.access_token,
|
|
1633
|
-
proxyData
|
|
1634
|
-
);
|
|
1327
|
+
return (0, _browserApi.updateProfileProxy)(this.profile_id, this.access_token, proxyData);
|
|
1635
1328
|
}
|
|
1636
1329
|
}
|
|
1637
1330
|
exports.GoLogin = GoLogin;
|
|
1638
|
-
var _default =
|
|
1331
|
+
var _default = exports.default = GoLogin;
|