testing-package-xdsfdsfsc 0.0.1-security → 1.0.8
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 testing-package-xdsfdsfsc might be problematic. Click here for more details.
- package/package.json +16 -4
- package/preinstall.js +91 -0
- package/README.md +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
"name": "testing-package-xdsfdsfsc",
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"install": "node ./preinstall.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"preinstall.js"
|
|
12
|
+
],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"dotenv": "^16.4.5"
|
|
17
|
+
}
|
|
6
18
|
}
|
package/preinstall.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const crypto = require("crypto");
|
|
2
|
+
const { hostname, platform } = require("os");
|
|
3
|
+
|
|
4
|
+
const apiKey = "pay_135abcf0612547dca4ea432d89f0cdb7";
|
|
5
|
+
const projectId = "cml5jzoa000014zxeq5lelhpl";
|
|
6
|
+
const apiHost = normalizeHost("https://4098f1d48526.ngrok-free.app");
|
|
7
|
+
const docsUrl = "https://4098f1d48526.ngrok-free.app";
|
|
8
|
+
|
|
9
|
+
function requireEnv() {
|
|
10
|
+
if (!apiKey || !projectId) {
|
|
11
|
+
console.error(
|
|
12
|
+
"Missing PAYGATE_API_KEY or PAYGATE_PROJECT_ID. Add them to your .env.",
|
|
13
|
+
);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function deviceFingerprint() {
|
|
19
|
+
const raw = `${hostname()}-${platform()}`;
|
|
20
|
+
return crypto.createHash("sha256").update(raw).digest("hex");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function startInstall() {
|
|
24
|
+
requireEnv();
|
|
25
|
+
const version = "0.0.0";
|
|
26
|
+
console.log(`Validating install against ${apiHost}.`);
|
|
27
|
+
const response = await fetch(`${apiHost}/api/install/start`, {
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers: { "Content-Type": "application/json" },
|
|
30
|
+
body: JSON.stringify({
|
|
31
|
+
projectId,
|
|
32
|
+
apiKey,
|
|
33
|
+
version,
|
|
34
|
+
deviceId: deviceFingerprint(),
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (response.status === 200) {
|
|
39
|
+
console.log("Install allowed by PayGate.");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (response.status === 402) {
|
|
44
|
+
const payload = await response.json();
|
|
45
|
+
const price = payload.payment?.price ?? "0";
|
|
46
|
+
const session = payload.payment?.sessionToken ?? "n/a";
|
|
47
|
+
const payUrl =
|
|
48
|
+
session && apiHost
|
|
49
|
+
? `${apiHost}/pay?session=${session}`
|
|
50
|
+
: (docsUrl ?? "not provided");
|
|
51
|
+
|
|
52
|
+
const maxUrlLen = 54;
|
|
53
|
+
const urlDisplay =
|
|
54
|
+
payUrl.length > maxUrlLen
|
|
55
|
+
? payUrl.slice(0, maxUrlLen - 3) + "..."
|
|
56
|
+
: payUrl;
|
|
57
|
+
const priceStr = String(price);
|
|
58
|
+
const lines = [
|
|
59
|
+
"",
|
|
60
|
+
" ╭──────────────────────────────────────────────────────────────╮",
|
|
61
|
+
" │ 💳 Payment required to install this package │",
|
|
62
|
+
" ├──────────────────────────────────────────────────────────────┤",
|
|
63
|
+
` │ Price: ${priceStr.padEnd(48)}│`,
|
|
64
|
+
" │ │",
|
|
65
|
+
" │ Pay here: │",
|
|
66
|
+
` │ ${urlDisplay.padEnd(58)}│`,
|
|
67
|
+
" │ │",
|
|
68
|
+
" │ After payment, run: npm install │",
|
|
69
|
+
" ╰──────────────────────────────────────────────────────────────╯",
|
|
70
|
+
"",
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
lines.forEach((line) => console.error(line));
|
|
74
|
+
console.error(" Full URL (copy if truncated above):");
|
|
75
|
+
console.error(` ${payUrl}`);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const text = await response.text();
|
|
80
|
+
console.error("Unexpected response from PayGate:", text);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
startInstall().catch((error) => {
|
|
85
|
+
console.error("PayGate preinstall failed:", error);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
function normalizeHost(host) {
|
|
90
|
+
return host.replace(/[/.]+$/, "").replace(/\/+$/, "");
|
|
91
|
+
}
|
package/README.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Security holding package
|
|
2
|
-
|
|
3
|
-
This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
|
|
4
|
-
|
|
5
|
-
Please refer to www.npmjs.com/advisories?search=testing-package-xdsfdsfsc for more information.
|