gologin-commonjs 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/gologin.js +54 -55
- package/package.json +2 -1
package/dist/src/gologin.js
CHANGED
|
@@ -470,10 +470,7 @@ class GoLogin {
|
|
|
470
470
|
proxy = null;
|
|
471
471
|
}
|
|
472
472
|
this.proxy = proxy;
|
|
473
|
-
|
|
474
|
-
console.error("Proxy Error. Check it and try again.");
|
|
475
|
-
throw new Error(`Proxy Error. ${e.message}`);
|
|
476
|
-
});
|
|
473
|
+
this.getTimeZone(proxy)
|
|
477
474
|
const [latitude, longitude] = this._tz.ll;
|
|
478
475
|
const {
|
|
479
476
|
accuracy
|
|
@@ -621,7 +618,7 @@ class GoLogin {
|
|
|
621
618
|
}
|
|
622
619
|
return port;
|
|
623
620
|
}
|
|
624
|
-
|
|
621
|
+
getTimeZone(proxy) {
|
|
625
622
|
debug("getting timeZone proxy=", proxy);
|
|
626
623
|
if (this.timezone) {
|
|
627
624
|
debug("getTimeZone from options", this.timezone);
|
|
@@ -629,55 +626,63 @@ class GoLogin {
|
|
|
629
626
|
return this._tz.timezone;
|
|
630
627
|
}
|
|
631
628
|
let data = null;
|
|
632
|
-
if (proxy && proxy.mode !== PROXY_NONE) {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
const result =
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
languages: "en",
|
|
660
|
-
accuracy: 100
|
|
661
|
-
}
|
|
629
|
+
// if (proxy && proxy.mode !== PROXY_NONE) {
|
|
630
|
+
// if (proxy.mode.includes("socks")) {
|
|
631
|
+
// for (let i = 0; i < 5; i++) {
|
|
632
|
+
// try {
|
|
633
|
+
// debug("getting timeZone socks try", i + 1);
|
|
634
|
+
// return this.getTimezoneWithSocks(proxy);
|
|
635
|
+
// } catch (e) {
|
|
636
|
+
// console.log(e.message);
|
|
637
|
+
// }
|
|
638
|
+
// }
|
|
639
|
+
// throw new Error("Socks proxy connection timed out");
|
|
640
|
+
// }
|
|
641
|
+
// const proxyUrl = `${proxy.mode}://${proxy.username}:${proxy.password}@${proxy.host}:${proxy.port}`;
|
|
642
|
+
// debug(`getTimeZone start ${TIMEZONE_URL}`, proxyUrl);
|
|
643
|
+
// const response = await _requestretry.default.get(TIMEZONE_URL, {
|
|
644
|
+
// proxy: proxyUrl,
|
|
645
|
+
// timeout: 20 * 1000,
|
|
646
|
+
// maxAttempts: 5
|
|
647
|
+
// });
|
|
648
|
+
const result = {
|
|
649
|
+
country: "ID",
|
|
650
|
+
stateProv: "Jakarta",
|
|
651
|
+
city: "Jakarta",
|
|
652
|
+
timezone: "Asia/Jakarta",
|
|
653
|
+
ll: ["-6.21462", "106.84513"],
|
|
654
|
+
languages: "id",
|
|
655
|
+
accuracy: 100,
|
|
662
656
|
};
|
|
663
|
-
} else {
|
|
664
|
-
const response = await _requestretry.default.get(TIMEZONE_URL, {
|
|
665
|
-
timeout: 20 * 1000,
|
|
666
|
-
maxAttempts: 5
|
|
667
|
-
});
|
|
668
|
-
const result = JSON.parse(response.body);
|
|
669
657
|
data = {
|
|
670
658
|
body: {
|
|
671
|
-
country: result.
|
|
672
|
-
stateProv: result.
|
|
659
|
+
country: result.country,
|
|
660
|
+
stateProv: result.stateProv,
|
|
673
661
|
city: result.city,
|
|
674
|
-
timezone:
|
|
675
|
-
ll:
|
|
676
|
-
languages: "
|
|
662
|
+
timezone: result.timezone,
|
|
663
|
+
ll: result.ll,
|
|
664
|
+
languages: "id",
|
|
677
665
|
accuracy: 100
|
|
678
666
|
}
|
|
679
667
|
};
|
|
680
|
-
}
|
|
668
|
+
// } else {
|
|
669
|
+
// const response = await _requestretry.default.get(TIMEZONE_URL, {
|
|
670
|
+
// timeout: 20 * 1000,
|
|
671
|
+
// maxAttempts: 5
|
|
672
|
+
// });
|
|
673
|
+
// const result = JSON.parse(response.body);
|
|
674
|
+
// data = {
|
|
675
|
+
// body: {
|
|
676
|
+
// country: result.country_code,
|
|
677
|
+
// stateProv: result.city,
|
|
678
|
+
// city: result.city,
|
|
679
|
+
// timezone: (0, _timezone.tzlookup)(result.latitude, result.longitude),
|
|
680
|
+
// ll: [result.latitude, result.longitude],
|
|
681
|
+
// languages: "en",
|
|
682
|
+
// accuracy: 100
|
|
683
|
+
// }
|
|
684
|
+
// };
|
|
685
|
+
// }
|
|
681
686
|
debug("getTimeZone finish", data.body);
|
|
682
687
|
this._tz = data.body;
|
|
683
688
|
return this._tz.timezone;
|
|
@@ -736,10 +741,7 @@ class GoLogin {
|
|
|
736
741
|
Object.keys(process.env).forEach(key => {
|
|
737
742
|
env[key] = process.env[key];
|
|
738
743
|
});
|
|
739
|
-
const tz =
|
|
740
|
-
console.error("Proxy Error. Check it and try again.");
|
|
741
|
-
throw e;
|
|
742
|
-
});
|
|
744
|
+
const tz = this.getTimeZone(this.proxy)
|
|
743
745
|
env.TZ = tz;
|
|
744
746
|
let params = [`--proxy-server=${proxy}`, `--user-data-dir=${profile_path}`, "--password-store=basic", `--tz=${tz}`, "--lang=en"];
|
|
745
747
|
if (Array.isArray(this.extra_params) && this.extra_params.length) {
|
|
@@ -774,10 +776,7 @@ class GoLogin {
|
|
|
774
776
|
Object.keys(process.env).forEach(key => {
|
|
775
777
|
env[key] = process.env[key];
|
|
776
778
|
});
|
|
777
|
-
const tz =
|
|
778
|
-
console.error("Proxy Error. Check it and try again.");
|
|
779
|
-
throw e;
|
|
780
|
-
});
|
|
779
|
+
const tz = this.getTimeZone(this.proxy)
|
|
781
780
|
env.TZ = tz;
|
|
782
781
|
if (this.vnc_port) {
|
|
783
782
|
const script_path = (0, _path.resolve)(__dirname, "./run.sh");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gologin-commonjs",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "A Transpiled GoLogin API ESM to CommonJS",
|
|
5
5
|
"types": "./types/src/gologin.d.ts",
|
|
6
6
|
"main": "./dist/src/gologin.js",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"decompress-unzip": "^4.0.1",
|
|
22
22
|
"form-data": "^3.0.0",
|
|
23
23
|
"gologin": "^2.1.1",
|
|
24
|
+
"gologin-commonjs": "^1.2.2",
|
|
24
25
|
"ncp": "^2.0.0",
|
|
25
26
|
"progress": "^2.0.3",
|
|
26
27
|
"puppeteer-core": "^2.1.1",
|