gologin 1.0.30 → 1.0.34
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/browser-checker.js +26 -9
- package/gologin.js +130 -113
- package/package.json +3 -3
- package/selenium/gologin.py +1 -1
package/browser-checker.js
CHANGED
|
@@ -260,7 +260,8 @@ class BrowserChecker {
|
|
|
260
260
|
async replaceBrowser() {
|
|
261
261
|
console.log('Copy Orbita to target path');
|
|
262
262
|
if (PLATFORM === 'darwin') {
|
|
263
|
-
await
|
|
263
|
+
await this.deleteDir(path.join(this.#browserPath, 'Orbita-Browser.app'));
|
|
264
|
+
|
|
264
265
|
const files = await readdir(path.join(this.#browserPath, EXTRACTED_FOLDER));
|
|
265
266
|
const promises = [];
|
|
266
267
|
files.forEach((filename) => {
|
|
@@ -268,22 +269,25 @@ class BrowserChecker {
|
|
|
268
269
|
promises.push(copyFile(path.join(this.#browserPath, EXTRACTED_FOLDER, filename), path.join(this.#browserPath, filename)));
|
|
269
270
|
}
|
|
270
271
|
});
|
|
272
|
+
|
|
271
273
|
return Promise.all(promises);
|
|
272
|
-
} else {
|
|
273
|
-
await rmdir(path.join(this.#browserPath, 'orbita-browser'), { recursive: true });
|
|
274
|
-
await this.copyDir(
|
|
275
|
-
path.join(this.#browserPath, EXTRACTED_FOLDER, 'orbita-browser'),
|
|
276
|
-
path.join(this.#browserPath, 'orbita-browser')
|
|
277
|
-
);
|
|
278
274
|
}
|
|
275
|
+
|
|
276
|
+
const targetBrowserPath = path.join(this.#browserPath, 'orbita-browser');
|
|
277
|
+
await this.deleteDir(targetBrowserPath);
|
|
278
|
+
|
|
279
|
+
await this.copyDir(
|
|
280
|
+
path.join(this.#browserPath, EXTRACTED_FOLDER, 'orbita-browser'),
|
|
281
|
+
targetBrowserPath
|
|
282
|
+
);
|
|
279
283
|
}
|
|
280
284
|
|
|
281
285
|
async deleteOldArchives(deleteCurrentBrowser = false) {
|
|
282
286
|
if (deleteCurrentBrowser) {
|
|
283
|
-
return
|
|
287
|
+
return this.deleteDir(path.join(this.#browserPath));
|
|
284
288
|
}
|
|
285
289
|
|
|
286
|
-
await
|
|
290
|
+
await this.deleteDir(path.join(this.#browserPath, EXTRACTED_FOLDER));
|
|
287
291
|
return readdir(this.#browserPath)
|
|
288
292
|
.then((files) => {
|
|
289
293
|
const promises = [];
|
|
@@ -355,6 +359,19 @@ class BrowserChecker {
|
|
|
355
359
|
get getOrbitaPath() {
|
|
356
360
|
return this.#executableFilePath;
|
|
357
361
|
}
|
|
362
|
+
|
|
363
|
+
async deleteDir(path = '') {
|
|
364
|
+
if (!path) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const directoryExists = await access(path).then(() => true).catch(() => false);
|
|
369
|
+
if (!directoryExists) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return rmdir(path, { recursive: true });
|
|
374
|
+
}
|
|
358
375
|
}
|
|
359
376
|
|
|
360
377
|
module.exports = BrowserChecker;
|
package/gologin.js
CHANGED
|
@@ -5,6 +5,7 @@ const fs = require('fs');
|
|
|
5
5
|
const os = require('os');
|
|
6
6
|
const util = require('util');
|
|
7
7
|
const rimraf = util.promisify(require('rimraf'));
|
|
8
|
+
const { access, unlink, writeFile, readFile } = require('fs').promises;
|
|
8
9
|
const exec = util.promisify(require('child_process').exec);
|
|
9
10
|
const { spawn, execFile } = require('child_process');
|
|
10
11
|
const FormData = require('form-data');
|
|
@@ -12,7 +13,7 @@ const ProxyAgent = require('simple-proxy-agent');
|
|
|
12
13
|
const decompress = require('decompress');
|
|
13
14
|
const decompressUnzip = require('decompress-unzip');
|
|
14
15
|
const path = require('path');
|
|
15
|
-
const
|
|
16
|
+
const zipdir = require('zip-dir');
|
|
16
17
|
|
|
17
18
|
const BrowserChecker = require('./browser-checker');
|
|
18
19
|
const { BrowserUserDataManager } = require('./browser-user-data-manager');
|
|
@@ -54,7 +55,7 @@ class GoLogin {
|
|
|
54
55
|
this.tmpdir = options.tmpdir;
|
|
55
56
|
if (!fs.existsSync(this.tmpdir)) {
|
|
56
57
|
debug('making tmpdir', this.tmpdir);
|
|
57
|
-
|
|
58
|
+
fs.mkdirSync(this.tmpdir, { recursive: true })
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -127,7 +128,7 @@ class GoLogin {
|
|
|
127
128
|
throw new Error(`Gologin /browser/${id} response error ${profileResponse.statusCode} INVALID TOKEN OR PROFILE NOT FOUND`);
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
if(profileResponse.statusCode
|
|
131
|
+
if (profileResponse.statusCode === 401) {
|
|
131
132
|
throw new Error("invalid token");
|
|
132
133
|
}
|
|
133
134
|
|
|
@@ -135,77 +136,86 @@ class GoLogin {
|
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
async emptyProfile() {
|
|
138
|
-
|
|
139
|
+
return readFile(path.resolve(__dirname, 'gologin_zeroprofile.b64')).then(res => res.toString());
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
async getProfileS3(s3path) {
|
|
143
|
+
if (!s3path) {
|
|
144
|
+
throw new Error('s3path not found');
|
|
145
|
+
}
|
|
146
|
+
|
|
142
147
|
const token = this.access_token;
|
|
143
148
|
debug('getProfileS3 token=', token, 'profile=', this.profile_id, 's3path=', s3path);
|
|
144
|
-
if (s3path) { //загрузка профиля из публичного бакета s3 быстрее
|
|
145
|
-
const s3url = `https://gprofiles.gologin.com/${s3path}`.replace(/\s+/mg, '+');
|
|
146
|
-
debug('loading profile from public s3 bucket, url=', s3url);
|
|
147
|
-
const profileResponse = await requests.get(s3url, {
|
|
148
|
-
encoding: null
|
|
149
|
-
});
|
|
150
|
-
if (profileResponse.statusCode !== 200) {
|
|
151
|
-
debug(`Gologin S3 BUCKET ${s3url} response error ${profileResponse.statusCode} - use empty`);
|
|
152
|
-
return '';
|
|
153
|
-
}
|
|
154
|
-
return Buffer.from(profileResponse.body);
|
|
155
|
-
}
|
|
156
149
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
'Authorization': `Bearer ${token}`,
|
|
161
|
-
},
|
|
150
|
+
const s3url = `https://gprofiles.gologin.com/${s3path}`.replace(/\s+/mg, '+');
|
|
151
|
+
debug('loading profile from public s3 bucket, url=', s3url);
|
|
152
|
+
const profileResponse = await requests.get(s3url, {
|
|
162
153
|
encoding: null
|
|
163
154
|
});
|
|
155
|
+
|
|
164
156
|
if (profileResponse.statusCode !== 200) {
|
|
165
|
-
debug(`Gologin
|
|
157
|
+
debug(`Gologin S3 BUCKET ${s3url} response error ${profileResponse.statusCode} - use empty`);
|
|
166
158
|
return '';
|
|
167
159
|
}
|
|
160
|
+
|
|
168
161
|
return Buffer.from(profileResponse.body);
|
|
169
162
|
}
|
|
170
163
|
|
|
171
|
-
async postFile(fileName,
|
|
172
|
-
debug('POSTING FILE',
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
164
|
+
async postFile(fileName, fileBuff) {
|
|
165
|
+
debug('POSTING FILE', fileBuff.length);
|
|
166
|
+
debug('Getting signed URL for S3');
|
|
167
|
+
const apiUrl = `${API_URL}/browser/${this.profile_id}/storage-signature`;
|
|
168
|
+
|
|
169
|
+
const signedUrl = await requests.get(apiUrl, {
|
|
170
|
+
headers: {
|
|
171
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
172
|
+
'user-agent': 'gologin-api',
|
|
173
|
+
},
|
|
174
|
+
maxAttempts: 3,
|
|
175
|
+
retryDelay: 2000,
|
|
176
|
+
timeout: 10 * 1000,
|
|
177
|
+
fullResponse: false,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const [uploadedProfileUrl] = signedUrl.split('?');
|
|
181
|
+
|
|
182
|
+
console.log('Uploading profile by signed URL to S3');
|
|
183
|
+
const bodyBufferBiteLength = Buffer.byteLength(fileBuff);
|
|
184
|
+
console.log('BUFFER SIZE', bodyBufferBiteLength);
|
|
185
|
+
|
|
186
|
+
await requests.put(signedUrl, {
|
|
187
|
+
headers: {
|
|
188
|
+
'Content-Type': 'application/zip',
|
|
189
|
+
'Content-Length': bodyBufferBiteLength,
|
|
190
|
+
},
|
|
191
|
+
body: fileBuff,
|
|
192
|
+
maxBodyLength: Infinity,
|
|
193
|
+
maxContentLength: Infinity,
|
|
194
|
+
maxAttempts: 3,
|
|
195
|
+
retryDelay: 2000,
|
|
196
|
+
timeout: 30 * 1000,
|
|
197
|
+
fullResponse: false,
|
|
203
198
|
});
|
|
199
|
+
|
|
200
|
+
const uploadedProfileMetadata = await requests.head(uploadedProfileUrl, {
|
|
201
|
+
maxAttempts: 3,
|
|
202
|
+
retryDelay: 2000,
|
|
203
|
+
timeout: 10 * 1000,
|
|
204
|
+
fullResponse: true,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const uploadedFileLength = +uploadedProfileMetadata.headers['content-length'];
|
|
208
|
+
if (uploadedFileLength !== bodyBufferBiteLength) {
|
|
209
|
+
console.log('Uploaded file is incorrect. Retry with China File size:', uploadedFileLength);
|
|
210
|
+
throw new Error('Uploaded file is incorrect. Retry with China File size: ' + uploadedFileLength);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
console.log('Profile has been uploaded to S3 successfully');
|
|
204
214
|
}
|
|
205
215
|
|
|
206
216
|
async emptyProfileFolder() {
|
|
207
217
|
debug('get emptyProfileFolder');
|
|
208
|
-
const profile =
|
|
218
|
+
const profile = await readFile(path.resolve(__dirname, 'gologin_zeroprofile.zip'));
|
|
209
219
|
debug('emptyProfileFolder LENGTH ::', profile.length);
|
|
210
220
|
return profile;
|
|
211
221
|
}
|
|
@@ -246,9 +256,8 @@ class GoLogin {
|
|
|
246
256
|
.then(() => {
|
|
247
257
|
debug('extraction done');
|
|
248
258
|
debug('create uid.json');
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return extPath;
|
|
259
|
+
return writeFile(path.join(extPath, 'uid.json'), JSON.stringify({ uid: that.profile_id }, null, 2))
|
|
260
|
+
.then(() => extPath);
|
|
252
261
|
})
|
|
253
262
|
.catch(async (e) => {
|
|
254
263
|
debug('orbita extension error', e);
|
|
@@ -299,19 +308,21 @@ class GoLogin {
|
|
|
299
308
|
height: parseInt(screenHeight, 10),
|
|
300
309
|
};
|
|
301
310
|
|
|
302
|
-
|
|
311
|
+
const profileZipExists = await access(this.profile_zip_path).then(() => true).catch(() => false);
|
|
312
|
+
if (!(local && profileZipExists)) {
|
|
303
313
|
try {
|
|
304
314
|
profile_folder = await this.getProfileS3(_.get(profile, 's3Path', ''));
|
|
305
315
|
}
|
|
306
316
|
catch (e) {
|
|
307
317
|
debug('Cannot get profile - using empty', e);
|
|
308
318
|
}
|
|
319
|
+
|
|
309
320
|
debug('FILE READY', this.profile_zip_path);
|
|
310
321
|
if (!profile_folder.length) {
|
|
311
322
|
profile_folder = await this.emptyProfileFolder();
|
|
312
323
|
}
|
|
313
|
-
|
|
314
|
-
|
|
324
|
+
|
|
325
|
+
await writeFile(this.profile_zip_path, profile_folder);
|
|
315
326
|
|
|
316
327
|
debug('PROFILE LENGTH', profile_folder.length);
|
|
317
328
|
} else {
|
|
@@ -323,20 +334,23 @@ class GoLogin {
|
|
|
323
334
|
await this.extractProfile(profilePath, this.profile_zip_path);
|
|
324
335
|
debug('extraction done');
|
|
325
336
|
|
|
326
|
-
|
|
337
|
+
const singletonLockPath = path.join(profilePath, 'SingletonLock');
|
|
338
|
+
const singletonLockExists = await access(singletonLockPath).then(() => true).catch(() => false);
|
|
339
|
+
if (singletonLockExists) {
|
|
327
340
|
debug('removing SingletonLock');
|
|
328
|
-
|
|
341
|
+
await unlink(singletonLockPath);
|
|
329
342
|
debug('SingletonLock removed');
|
|
330
343
|
}
|
|
331
344
|
|
|
332
345
|
const pref_file_name = path.join(profilePath, 'Default', 'Preferences');
|
|
333
346
|
debug('reading', pref_file_name);
|
|
334
347
|
|
|
335
|
-
|
|
348
|
+
const prefFileExists = await access(pref_file_name).then(() => true).catch(() => false);
|
|
349
|
+
if (!prefFileExists) {
|
|
336
350
|
debug('Preferences file not exists waiting', pref_file_name);
|
|
337
351
|
}
|
|
338
352
|
|
|
339
|
-
const preferences_raw =
|
|
353
|
+
const preferences_raw = await readFile(pref_file_name);
|
|
340
354
|
let preferences = JSON.parse(preferences_raw.toString());
|
|
341
355
|
let proxy = _.get(profile, 'proxy');
|
|
342
356
|
let name = _.get(profile, 'name');
|
|
@@ -359,7 +373,7 @@ class GoLogin {
|
|
|
359
373
|
profile.proxy.password = _.get(profile, 'autoProxyPassword');
|
|
360
374
|
}
|
|
361
375
|
// console.log('proxy=', proxy);
|
|
362
|
-
|
|
376
|
+
|
|
363
377
|
if (proxy.mode === 'geolocation') {
|
|
364
378
|
proxy.mode = 'http';
|
|
365
379
|
}
|
|
@@ -436,7 +450,7 @@ class GoLogin {
|
|
|
436
450
|
await BrowserUserDataManager.composeFonts(families, profilePath, this.differentOs);
|
|
437
451
|
}
|
|
438
452
|
|
|
439
|
-
|
|
453
|
+
await writeFile(path.join(profilePath, 'Default', 'Preferences'), JSON.stringify(_.merge(preferences, {
|
|
440
454
|
gologin
|
|
441
455
|
})));
|
|
442
456
|
|
|
@@ -449,20 +463,23 @@ class GoLogin {
|
|
|
449
463
|
}
|
|
450
464
|
|
|
451
465
|
async commitProfile() {
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
466
|
+
const dataBuff = await this.getProfileDataToUpdate();
|
|
467
|
+
|
|
468
|
+
debug('begin updating', dataBuff.length);
|
|
469
|
+
if (!dataBuff.length) {
|
|
455
470
|
debug('WARN: profile zip data empty - SKIPPING PROFILE COMMIT');
|
|
456
471
|
|
|
457
472
|
return;
|
|
458
473
|
}
|
|
474
|
+
|
|
459
475
|
try {
|
|
460
476
|
debug('Patching profile');
|
|
461
|
-
await this.postFile('profile',
|
|
477
|
+
await this.postFile('profile', dataBuff);
|
|
462
478
|
}
|
|
463
479
|
catch (e) {
|
|
464
480
|
debug('CANNOT COMMIT PROFILE', e);
|
|
465
481
|
}
|
|
482
|
+
|
|
466
483
|
debug('COMMIT COMPLETED');
|
|
467
484
|
}
|
|
468
485
|
|
|
@@ -482,16 +499,16 @@ class GoLogin {
|
|
|
482
499
|
|
|
483
500
|
async checkPortAvailable(port) {
|
|
484
501
|
debug('CHECKING PORT AVAILABLE', port);
|
|
502
|
+
|
|
485
503
|
try {
|
|
486
504
|
const { stdout, stderr } = await exec(`lsof -i:${port}`);
|
|
487
|
-
if (
|
|
488
|
-
stdout && stdout.match(/LISTEN/gmi)
|
|
489
|
-
) {
|
|
505
|
+
if (stdout && stdout.match(/LISTEN/gmi)) {
|
|
490
506
|
debug(`PORT ${port} IS BUSY`)
|
|
491
507
|
return false;
|
|
492
508
|
}
|
|
493
|
-
} catch (e) {
|
|
509
|
+
} catch (e) {}
|
|
494
510
|
debug(`PORT ${port} IS OPEN`);
|
|
511
|
+
|
|
495
512
|
return true;
|
|
496
513
|
}
|
|
497
514
|
|
|
@@ -507,7 +524,7 @@ class GoLogin {
|
|
|
507
524
|
|
|
508
525
|
async getTimeZone(proxy) {
|
|
509
526
|
debug('getting timeZone proxy=', proxy);
|
|
510
|
-
if(this.timezone){
|
|
527
|
+
if (this.timezone) {
|
|
511
528
|
debug('getTimeZone from options', this.timezone);
|
|
512
529
|
this._tz = this.timezone;
|
|
513
530
|
return this._tz.timezone;
|
|
@@ -604,7 +621,7 @@ class GoLogin {
|
|
|
604
621
|
|
|
605
622
|
async spawnBrowser() {
|
|
606
623
|
let remote_debugging_port = this.remote_debugging_port;
|
|
607
|
-
if(!remote_debugging_port){
|
|
624
|
+
if (!remote_debugging_port) {
|
|
608
625
|
remote_debugging_port = await this.getRandomPort();
|
|
609
626
|
}
|
|
610
627
|
|
|
@@ -706,7 +723,9 @@ class GoLogin {
|
|
|
706
723
|
if (this.is_stopping) {
|
|
707
724
|
return true;
|
|
708
725
|
}
|
|
709
|
-
const is_posting = options.
|
|
726
|
+
const is_posting = options.posting ||
|
|
727
|
+
options.postings || // backward compability
|
|
728
|
+
false;
|
|
710
729
|
|
|
711
730
|
if (this.uploadCookiesToServer) {
|
|
712
731
|
await this.uploadProfileCookiesToServer();
|
|
@@ -782,34 +801,31 @@ class GoLogin {
|
|
|
782
801
|
|
|
783
802
|
async getProfileDataToUpdate() {
|
|
784
803
|
const zipPath = path.join(this.tmpdir, `gologin_${this.profile_id}_upload.zip`);
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
catch (e) {
|
|
804
|
+
const zipExists = await access(zipPath).then(() => true).catch(() => false);
|
|
805
|
+
if (zipExists) {
|
|
806
|
+
await unlink(zipPath);
|
|
789
807
|
}
|
|
808
|
+
|
|
790
809
|
await this.sanitizeProfile();
|
|
791
810
|
debug('profile sanitized');
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
debug('saveprofile error', e);
|
|
811
|
-
return '';
|
|
812
|
-
}
|
|
811
|
+
|
|
812
|
+
const profilePath = this.profilePath();
|
|
813
|
+
const fileBuff = await new Promise((resolve, reject) => zipdir(profilePath,
|
|
814
|
+
{
|
|
815
|
+
saveTo: zipPath,
|
|
816
|
+
filter: (path) => !/RunningChromeVersion/.test(path),
|
|
817
|
+
}, (err, buffer) => {
|
|
818
|
+
if (err) {
|
|
819
|
+
reject(err);
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
resolve(buffer);
|
|
824
|
+
})
|
|
825
|
+
)
|
|
826
|
+
|
|
827
|
+
debug('PROFILE ZIP CREATED', profilePath, zipPath);
|
|
828
|
+
return fileBuff;
|
|
813
829
|
}
|
|
814
830
|
|
|
815
831
|
async profileExists() {
|
|
@@ -853,11 +869,11 @@ class GoLogin {
|
|
|
853
869
|
const fingerprint = await this.getRandomFingerprint(options);
|
|
854
870
|
debug("fingerprint=", fingerprint)
|
|
855
871
|
|
|
856
|
-
if(fingerprint.statusCode
|
|
872
|
+
if (fingerprint.statusCode === 500) {
|
|
857
873
|
throw new Error("no valid random fingerprint check os param");
|
|
858
874
|
}
|
|
859
875
|
|
|
860
|
-
if(fingerprint.statusCode
|
|
876
|
+
if (fingerprint.statusCode === 401) {
|
|
861
877
|
throw new Error("invalid token");
|
|
862
878
|
}
|
|
863
879
|
|
|
@@ -887,7 +903,7 @@ class GoLogin {
|
|
|
887
903
|
let user_agent = options.navigator?.userAgent;
|
|
888
904
|
let orig_user_agent = json.navigator.userAgent;
|
|
889
905
|
Object.keys(options).map((e)=>{ json[e] = options[e] });
|
|
890
|
-
if(user_agent
|
|
906
|
+
if (user_agent === 'random') {
|
|
891
907
|
json.navigator.userAgent = orig_user_agent;
|
|
892
908
|
}
|
|
893
909
|
// console.log('profileOptions', json);
|
|
@@ -900,11 +916,11 @@ class GoLogin {
|
|
|
900
916
|
json,
|
|
901
917
|
});
|
|
902
918
|
|
|
903
|
-
if(response.body.statusCode
|
|
919
|
+
if (response.body.statusCode === 400) {
|
|
904
920
|
throw new Error(`gologin failed account creation with status code, ${data.statusCode} DATA ${JSON.stringify(response.body.message)}`);
|
|
905
921
|
}
|
|
906
922
|
|
|
907
|
-
if(response.body.statusCode
|
|
923
|
+
if (response.body.statusCode === 500) {
|
|
908
924
|
throw new Error(`gologin failed account creation with status code, ${data.statusCode}`);
|
|
909
925
|
}
|
|
910
926
|
debug(JSON.stringify(response.body));
|
|
@@ -1045,7 +1061,8 @@ class GoLogin {
|
|
|
1045
1061
|
|
|
1046
1062
|
const ORBITA_BROWSER = this.executablePath || this.browserChecker.getOrbitaPath;
|
|
1047
1063
|
|
|
1048
|
-
|
|
1064
|
+
const orbitaBrowserExists = await access(ORBITA_BROWSER).then(() => true).catch(() => false);
|
|
1065
|
+
if (!orbitaBrowserExists) {
|
|
1049
1066
|
throw new Error(`Orbita browser is not exists on path ${ORBITA_BROWSER}, check executablePath param`);
|
|
1050
1067
|
}
|
|
1051
1068
|
|
|
@@ -1071,12 +1088,12 @@ class GoLogin {
|
|
|
1071
1088
|
return this.stopRemote();
|
|
1072
1089
|
}
|
|
1073
1090
|
|
|
1074
|
-
await this.stopAndCommit({ posting:
|
|
1091
|
+
await this.stopAndCommit({ posting: true }, false);
|
|
1075
1092
|
}
|
|
1076
1093
|
|
|
1077
1094
|
async stopLocal(options) {
|
|
1078
1095
|
const opts = options || { posting: false };
|
|
1079
|
-
await this.stopAndCommit(
|
|
1096
|
+
await this.stopAndCommit(opts, true);
|
|
1080
1097
|
}
|
|
1081
1098
|
|
|
1082
1099
|
async waitDebuggingUrl(delay_ms, try_count=0) {
|
|
@@ -1098,7 +1115,7 @@ class GoLogin {
|
|
|
1098
1115
|
if (try_count < 3) {
|
|
1099
1116
|
return this.waitDebuggingUrl(delay_ms, try_count+1);
|
|
1100
1117
|
}
|
|
1101
|
-
return { 'status': 'failure', wsUrl }
|
|
1118
|
+
return { 'status': 'failure', wsUrl, 'message': 'Check proxy settings', 'profile_id': this.profile_id }
|
|
1102
1119
|
}
|
|
1103
1120
|
|
|
1104
1121
|
wsUrl = wsUrl.replace('ws://', `wss://`).replace('127.0.0.1', `${this.profile_id}.orbita.gologin.com`)
|
|
@@ -1113,7 +1130,7 @@ class GoLogin {
|
|
|
1113
1130
|
}
|
|
1114
1131
|
});
|
|
1115
1132
|
|
|
1116
|
-
if(profileResponse.statusCode
|
|
1133
|
+
if (profileResponse.statusCode === 401){
|
|
1117
1134
|
throw new Error("invalid token");
|
|
1118
1135
|
}
|
|
1119
1136
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gologin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.34",
|
|
4
4
|
"description": "A high-level API to control Orbita browser over GoLogin API",
|
|
5
5
|
"main": "./gologin.js",
|
|
6
6
|
"repository": {
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"requestretry": "^4.1.0",
|
|
27
27
|
"rimraf": "^3.0.2",
|
|
28
28
|
"selenium-webdriver": "^4.0.0-alpha.7",
|
|
29
|
-
"shelljs": "^0.8.4",
|
|
30
29
|
"simple-proxy-agent": "^1.1.0",
|
|
31
30
|
"sqlite": "^4.0.23",
|
|
32
|
-
"sqlite3": "^5.0.2"
|
|
31
|
+
"sqlite3": "^5.0.2",
|
|
32
|
+
"zip-dir": "^2.0.0"
|
|
33
33
|
},
|
|
34
34
|
"bugs": {
|
|
35
35
|
"url": "https://github.com/gologinapp/gologin/issues"
|
package/selenium/gologin.py
CHANGED
|
@@ -371,7 +371,7 @@ class GoLogin(object):
|
|
|
371
371
|
return json.loads(requests.get(API_URL + '/browser/fingerprint?os=' + os_type, headers=self.headers()).content.decode('utf-8'))
|
|
372
372
|
|
|
373
373
|
def profiles(self):
|
|
374
|
-
return json.loads(requests.get(API_URL + '/browser/', headers=self.headers()).content.decode('utf-8'))
|
|
374
|
+
return json.loads(requests.get(API_URL + '/browser/v2', headers=self.headers()).content.decode('utf-8'))
|
|
375
375
|
|
|
376
376
|
def create(self, options={}):
|
|
377
377
|
profile_options = self.getRandomFingerprint(options)
|