gologin 1.0.48 → 1.0.49
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/gologin.js +42 -42
- package/package.json +1 -1
package/gologin.js
CHANGED
|
@@ -60,16 +60,16 @@ class GoLogin {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
this.cookiesFilePath = path.join(this.tmpdir, `gologin_profile_${this.profile_id}`, 'Default', 'Cookies');
|
|
63
|
+
this.cookiesFilePath = path.join(this.tmpdir, `gologin_profile_${this.profile_id}`, 'Default', 'Network', 'Cookies');
|
|
64
64
|
this.profile_zip_path = path.join(this.tmpdir, `gologin_${this.profile_id}.zip`);
|
|
65
65
|
debug('INIT GOLOGIN', this.profile_id);
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
async checkBrowser() { return this.browserChecker.checkBrowser(this.autoUpdateBrowser) }
|
|
69
69
|
|
|
70
70
|
async setProfileId(profile_id) {
|
|
71
71
|
this.profile_id = profile_id;
|
|
72
|
-
this.cookiesFilePath = path.join(this.tmpdir, `gologin_profile_${this.profile_id}`, 'Default', 'Cookies');
|
|
72
|
+
this.cookiesFilePath = path.join(this.tmpdir, `gologin_profile_${this.profile_id}`, 'Default', 'Network', 'Cookies');
|
|
73
73
|
this.profile_zip_path = path.join(this.tmpdir, `gologin_${this.profile_id}.zip`);
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -125,15 +125,15 @@ class GoLogin {
|
|
|
125
125
|
}
|
|
126
126
|
})
|
|
127
127
|
debug("profileResponse", profileResponse.statusCode, profileResponse.body);
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
|
|
129
|
+
|
|
130
130
|
if (profileResponse.statusCode === 404) {
|
|
131
131
|
throw new Error(JSON.parse(profileResponse.body).message);
|
|
132
|
-
}
|
|
132
|
+
}
|
|
133
133
|
|
|
134
134
|
if (profileResponse.statusCode === 403) {
|
|
135
135
|
throw new Error(JSON.parse(profileResponse.body).message);
|
|
136
|
-
}
|
|
136
|
+
}
|
|
137
137
|
|
|
138
138
|
if (profileResponse.statusCode !== 200) {
|
|
139
139
|
throw new Error(`Gologin /browser/${id} response error ${profileResponse.statusCode} INVALID TOKEN OR PROFILE NOT FOUND`);
|
|
@@ -141,7 +141,7 @@ class GoLogin {
|
|
|
141
141
|
|
|
142
142
|
if (profileResponse.statusCode === 401) {
|
|
143
143
|
throw new Error("invalid token");
|
|
144
|
-
}
|
|
144
|
+
}
|
|
145
145
|
|
|
146
146
|
|
|
147
147
|
return JSON.parse(profileResponse.body);
|
|
@@ -268,7 +268,7 @@ class GoLogin {
|
|
|
268
268
|
enable: true,
|
|
269
269
|
width: parseInt(this.resolution.width, 10),
|
|
270
270
|
height: parseInt(this.resolution.height, 10),
|
|
271
|
-
device_scale_factor: deviceScaleFactor,
|
|
271
|
+
device_scale_factor: deviceScaleFactor,
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
|
|
@@ -278,7 +278,7 @@ class GoLogin {
|
|
|
278
278
|
audioInputs: preferences.mediaDevices.audioInputs,
|
|
279
279
|
audioOutputs: preferences.mediaDevices.audioOutputs,
|
|
280
280
|
}
|
|
281
|
-
|
|
281
|
+
|
|
282
282
|
return preferences;
|
|
283
283
|
}
|
|
284
284
|
|
|
@@ -306,7 +306,7 @@ class GoLogin {
|
|
|
306
306
|
});
|
|
307
307
|
|
|
308
308
|
debug('createBrowserExtension done');
|
|
309
|
-
}
|
|
309
|
+
}
|
|
310
310
|
|
|
311
311
|
extractProfile(path, zipfile) {
|
|
312
312
|
debug(`extactProfile ${zipfile}, ${path}`);
|
|
@@ -375,7 +375,7 @@ class GoLogin {
|
|
|
375
375
|
} catch(e) {
|
|
376
376
|
console.trace(e);
|
|
377
377
|
profile_folder = await this.emptyProfileFolder();
|
|
378
|
-
await writeFile(this.profile_zip_path, profile_folder);
|
|
378
|
+
await writeFile(this.profile_zip_path, profile_folder);
|
|
379
379
|
await this.extractProfile(profilePath, this.profile_zip_path);
|
|
380
380
|
}
|
|
381
381
|
|
|
@@ -394,12 +394,12 @@ class GoLogin {
|
|
|
394
394
|
if (!prefFileExists) {
|
|
395
395
|
debug('Preferences file not exists waiting', pref_file_name, '. Using empty profile');
|
|
396
396
|
profile_folder = await this.emptyProfileFolder();
|
|
397
|
-
await writeFile(this.profile_zip_path, profile_folder);
|
|
397
|
+
await writeFile(this.profile_zip_path, profile_folder);
|
|
398
398
|
await this.extractProfile(profilePath, this.profile_zip_path);
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
const preferences_raw = await readFile(pref_file_name);
|
|
402
|
-
let preferences = JSON.parse(preferences_raw.toString());
|
|
402
|
+
let preferences = JSON.parse(preferences_raw.toString());
|
|
403
403
|
let proxy = _.get(profile, 'proxy');
|
|
404
404
|
let name = _.get(profile, 'name');
|
|
405
405
|
const chromeExtensions = _.get(profile, 'chromeExtensions');
|
|
@@ -453,7 +453,7 @@ class GoLogin {
|
|
|
453
453
|
'username': _.get(profile, 'autoProxyUsername'),
|
|
454
454
|
'password': _.get(profile, 'autoProxyPassword'),
|
|
455
455
|
}
|
|
456
|
-
|
|
456
|
+
|
|
457
457
|
profile.proxy.username = _.get(profile, 'autoProxyUsername');
|
|
458
458
|
profile.proxy.password = _.get(profile, 'autoProxyPassword');
|
|
459
459
|
}
|
|
@@ -490,7 +490,7 @@ class GoLogin {
|
|
|
490
490
|
publicIP: _.get(profile, 'webRTC.fillBasedOnIp') ? this._tz.ip : _.get(profile, 'webRTC.publicIp'),
|
|
491
491
|
localIps: _.get(profile, 'webRTC.localIps', []),
|
|
492
492
|
};
|
|
493
|
-
|
|
493
|
+
|
|
494
494
|
debug('profile.webRtc=', profile.webRtc);
|
|
495
495
|
debug('profile.timezone=', profile.timezone);
|
|
496
496
|
debug('profile.mediaDevices=', profile.mediaDevices);
|
|
@@ -546,11 +546,11 @@ class GoLogin {
|
|
|
546
546
|
}
|
|
547
547
|
|
|
548
548
|
const [languages] = this.language.split(';');
|
|
549
|
-
|
|
549
|
+
|
|
550
550
|
if(preferences.gologin==null){
|
|
551
551
|
preferences.gologin = {};
|
|
552
552
|
}
|
|
553
|
-
|
|
553
|
+
|
|
554
554
|
preferences.gologin.langHeader = gologin.language;
|
|
555
555
|
preferences.gologin.languages = languages;
|
|
556
556
|
// debug("convertedPreferences=", preferences.gologin)
|
|
@@ -705,7 +705,7 @@ class GoLogin {
|
|
|
705
705
|
|
|
706
706
|
async spawnArguments() {
|
|
707
707
|
const profile_path = this.profilePath();
|
|
708
|
-
|
|
708
|
+
|
|
709
709
|
let proxy = this.proxy;
|
|
710
710
|
proxy = `${proxy.mode}://${proxy.host}:${proxy.port}`;
|
|
711
711
|
|
|
@@ -735,10 +735,10 @@ class GoLogin {
|
|
|
735
735
|
let remote_debugging_port = this.remote_debugging_port;
|
|
736
736
|
if (!remote_debugging_port) {
|
|
737
737
|
remote_debugging_port = await this.getRandomPort();
|
|
738
|
-
}
|
|
739
|
-
|
|
738
|
+
}
|
|
739
|
+
|
|
740
740
|
const profile_path = this.profilePath();
|
|
741
|
-
|
|
741
|
+
|
|
742
742
|
let proxy = this.proxy;
|
|
743
743
|
let proxy_host = '';
|
|
744
744
|
if (proxy) {
|
|
@@ -747,7 +747,7 @@ class GoLogin {
|
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
this.port = remote_debugging_port;
|
|
750
|
-
|
|
750
|
+
|
|
751
751
|
const ORBITA_BROWSER = this.executablePath || this.browserChecker.getOrbitaPath;
|
|
752
752
|
console.log("ORBITA_BROWSER=", ORBITA_BROWSER)
|
|
753
753
|
const env = {};
|
|
@@ -777,8 +777,8 @@ class GoLogin {
|
|
|
777
777
|
|
|
778
778
|
let params = [
|
|
779
779
|
`--remote-debugging-port=${remote_debugging_port}`,
|
|
780
|
-
`--user-data-dir=${profile_path}`,
|
|
781
|
-
`--password-store=basic`,
|
|
780
|
+
`--user-data-dir=${profile_path}`,
|
|
781
|
+
`--password-store=basic`,
|
|
782
782
|
`--tz=${tz}`,
|
|
783
783
|
`--lang=${browserLang}`,
|
|
784
784
|
];
|
|
@@ -824,13 +824,13 @@ class GoLogin {
|
|
|
824
824
|
const child = execFile(ORBITA_BROWSER, params, {env});
|
|
825
825
|
// const child = spawn(ORBITA_BROWSER, params, { env, shell: true });
|
|
826
826
|
child.stdout.on('data', (data) => debug(data.toString()));
|
|
827
|
-
debug('SPAWN CMD', ORBITA_BROWSER, params.join(" "));
|
|
827
|
+
debug('SPAWN CMD', ORBITA_BROWSER, params.join(" "));
|
|
828
828
|
}
|
|
829
829
|
|
|
830
830
|
debug('GETTING WS URL FROM BROWSER');
|
|
831
831
|
|
|
832
832
|
let data = await requests.get(`http://127.0.0.1:${remote_debugging_port}/json/version`, {json: true});
|
|
833
|
-
|
|
833
|
+
|
|
834
834
|
debug('WS IS', _.get(data, 'body.webSocketDebuggerUrl', ''))
|
|
835
835
|
this.is_active = true;
|
|
836
836
|
|
|
@@ -873,7 +873,7 @@ class GoLogin {
|
|
|
873
873
|
|
|
874
874
|
if (!local) {
|
|
875
875
|
await rimraf(path.join(this.tmpdir, `gologin_${this.profile_id}.zip`));
|
|
876
|
-
}
|
|
876
|
+
}
|
|
877
877
|
debug(`PROFILE ${this.profile_id} STOPPED AND CLEAR`);
|
|
878
878
|
return false;
|
|
879
879
|
}
|
|
@@ -883,7 +883,7 @@ class GoLogin {
|
|
|
883
883
|
if (!this.port) {
|
|
884
884
|
throw new Error('Empty GoLogin port');
|
|
885
885
|
}
|
|
886
|
-
const ls = await spawn('fuser',
|
|
886
|
+
const ls = await spawn('fuser',
|
|
887
887
|
[
|
|
888
888
|
'-k TERM',
|
|
889
889
|
`-n tcp ${this.port}`
|
|
@@ -918,7 +918,7 @@ class GoLogin {
|
|
|
918
918
|
await Promise.all(remove_dirs.map(d => {
|
|
919
919
|
const path_to_remove = `${that.profilePath()}${d}`
|
|
920
920
|
return new Promise(resolve => {
|
|
921
|
-
debug('DROPPING', path_to_remove);
|
|
921
|
+
debug('DROPPING', path_to_remove);
|
|
922
922
|
rimraf(path_to_remove, { maxBusyTries: 100 }, (e) => {
|
|
923
923
|
// debug('DROPPING RESULT', e);
|
|
924
924
|
resolve();
|
|
@@ -970,7 +970,7 @@ class GoLogin {
|
|
|
970
970
|
return false;
|
|
971
971
|
}
|
|
972
972
|
debug('profile is', profileResponse.body);
|
|
973
|
-
return true;
|
|
973
|
+
return true;
|
|
974
974
|
}
|
|
975
975
|
|
|
976
976
|
|
|
@@ -979,16 +979,16 @@ class GoLogin {
|
|
|
979
979
|
|
|
980
980
|
if (options.os) {
|
|
981
981
|
os = options.os;
|
|
982
|
-
}
|
|
982
|
+
}
|
|
983
983
|
|
|
984
984
|
let fingerprint = await requests.get(`${API_URL}/browser/fingerprint?os=${os}`,{
|
|
985
985
|
headers: {
|
|
986
986
|
'Authorization': `Bearer ${this.access_token}`,
|
|
987
987
|
'User-Agent': 'gologin-api',
|
|
988
988
|
}
|
|
989
|
-
});
|
|
989
|
+
});
|
|
990
990
|
|
|
991
|
-
return JSON.parse(fingerprint.body);
|
|
991
|
+
return JSON.parse(fingerprint.body);
|
|
992
992
|
}
|
|
993
993
|
|
|
994
994
|
async create(options) {
|
|
@@ -996,7 +996,7 @@ class GoLogin {
|
|
|
996
996
|
|
|
997
997
|
const fingerprint = await this.getRandomFingerprint(options);
|
|
998
998
|
debug("fingerprint=", fingerprint)
|
|
999
|
-
|
|
999
|
+
|
|
1000
1000
|
if (fingerprint.statusCode === 500) {
|
|
1001
1001
|
throw new Error("no valid random fingerprint check os param");
|
|
1002
1002
|
}
|
|
@@ -1068,7 +1068,7 @@ class GoLogin {
|
|
|
1068
1068
|
async update(options) {
|
|
1069
1069
|
this.profile_id = options.id;
|
|
1070
1070
|
const profile = await this.getProfile();
|
|
1071
|
-
|
|
1071
|
+
|
|
1072
1072
|
if (options.navigator) {
|
|
1073
1073
|
Object.keys(options.navigator).map((e)=>{profile.navigator[e]=options.navigator[e]});
|
|
1074
1074
|
}
|
|
@@ -1081,7 +1081,7 @@ class GoLogin {
|
|
|
1081
1081
|
headers: {
|
|
1082
1082
|
'Authorization': `Bearer ${this.access_token}`
|
|
1083
1083
|
}
|
|
1084
|
-
});
|
|
1084
|
+
});
|
|
1085
1085
|
debug('response', JSON.stringify(response.body));
|
|
1086
1086
|
return response.body
|
|
1087
1087
|
}
|
|
@@ -1106,7 +1106,7 @@ class GoLogin {
|
|
|
1106
1106
|
accuracy: profileGeolocationParams.accuracy,
|
|
1107
1107
|
}
|
|
1108
1108
|
};
|
|
1109
|
-
|
|
1109
|
+
|
|
1110
1110
|
getViewPort() {
|
|
1111
1111
|
return { ...this.resolution };
|
|
1112
1112
|
};
|
|
@@ -1186,7 +1186,7 @@ class GoLogin {
|
|
|
1186
1186
|
if (!this.executablePath) {
|
|
1187
1187
|
await this.checkBrowser();
|
|
1188
1188
|
}
|
|
1189
|
-
|
|
1189
|
+
|
|
1190
1190
|
const ORBITA_BROWSER = this.executablePath || this.browserChecker.getOrbitaPath;
|
|
1191
1191
|
|
|
1192
1192
|
const orbitaBrowserExists = await access(ORBITA_BROWSER).then(() => true).catch(() => false);
|
|
@@ -1258,7 +1258,7 @@ class GoLogin {
|
|
|
1258
1258
|
return {'status': 'failure', 'code': profileResponse.statusCode};
|
|
1259
1259
|
}
|
|
1260
1260
|
*/
|
|
1261
|
-
|
|
1261
|
+
|
|
1262
1262
|
// if (profileResponse.body === 'ok') {
|
|
1263
1263
|
const profile = await this.getProfile();
|
|
1264
1264
|
|
|
@@ -1267,7 +1267,7 @@ class GoLogin {
|
|
|
1267
1267
|
'Authorization': `Bearer ${this.access_token}`
|
|
1268
1268
|
}
|
|
1269
1269
|
});
|
|
1270
|
-
|
|
1270
|
+
|
|
1271
1271
|
debug('profileResponse', profileResponse.statusCode, profileResponse.body);
|
|
1272
1272
|
|
|
1273
1273
|
if (profileResponse.statusCode === 401){
|
|
@@ -1298,7 +1298,7 @@ class GoLogin {
|
|
|
1298
1298
|
let wsUrl = await this.waitDebuggingUrl(delay_ms);
|
|
1299
1299
|
if(wsUrl!=''){
|
|
1300
1300
|
return { 'status': 'success', wsUrl }
|
|
1301
|
-
}
|
|
1301
|
+
}
|
|
1302
1302
|
|
|
1303
1303
|
return { 'status': 'failure', 'message': profileResponse.body };
|
|
1304
1304
|
}
|