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