@dignetwork/dig-sdk 0.0.1-alpha.51 → 0.0.1-alpha.54
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/dist/DataIntegrityTree/DataIntegrityTree.js +1 -1
- package/dist/DigNetwork/DigNetwork.d.ts +2 -4
- package/dist/DigNetwork/DigNetwork.d.ts.map +1 -1
- package/dist/DigNetwork/DigNetwork.js +26 -48
- package/dist/DigNetwork/DigPeer.d.ts +2 -1
- package/dist/DigNetwork/DigPeer.d.ts.map +1 -1
- package/dist/DigNetwork/DigPeer.js +13 -57
- package/dist/DigNetwork/PropagationServer.d.ts +70 -42
- package/dist/DigNetwork/PropagationServer.d.ts.map +1 -1
- package/dist/DigNetwork/PropagationServer.js +308 -409
- package/dist/blockchain/DataStore.d.ts.map +1 -1
- package/dist/blockchain/DataStore.js +15 -5
- package/dist/utils/ContentScanner.d.ts +63 -0
- package/dist/utils/ContentScanner.d.ts.map +1 -0
- package/dist/utils/ContentScanner.js +175 -0
- package/package.json +5 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataStore.d.ts","sourceRoot":"","sources":["../../src/blockchain/DataStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,SAAS,IAAI,eAAe,EAE5B,iBAAiB,EAIlB,MAAM,8BAA8B,CAAC;AAWtC,OAAO,EAAE,eAAe,EAAW,MAAM,UAAU,CAAC;AAGpD,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAQjD,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,IAAI,CAAoB;gBAEpB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAiB/D,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,IAAW,IAAI,IAAI,iBAAiB,CAEnC;IA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M,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CA8CxE"}
|
|
@@ -12,6 +12,7 @@ const FullNodePeer_1 = require("./FullNodePeer");
|
|
|
12
12
|
const Wallet_1 = require("./Wallet");
|
|
13
13
|
const config_1 = require("../utils/config");
|
|
14
14
|
const coins_1 = require("./coins");
|
|
15
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
15
16
|
const hashUtils_1 = require("../utils/hashUtils");
|
|
16
17
|
const DataIntegrityTree_1 = require("../DataIntegrityTree");
|
|
17
18
|
const prompts_1 = require("../prompts");
|
|
@@ -289,10 +290,11 @@ class DataStore {
|
|
|
289
290
|
if (!rootHashes) {
|
|
290
291
|
return [];
|
|
291
292
|
}
|
|
293
|
+
// TODO: add 3 min cache to thisqwz ~
|
|
292
294
|
return rootHashes.map((rootHash, index) => ({
|
|
293
295
|
root_hash: rootHash.toString("hex"),
|
|
294
296
|
timestamp: Number(rootHashesTimestamps?.[index].toString()),
|
|
295
|
-
synced: fs_1.default.existsSync(
|
|
297
|
+
synced: fs_1.default.existsSync(path_1.default.join(config_1.STORE_PATH, this.storeId, `${rootHash.toString("hex")}.dat`)),
|
|
296
298
|
}));
|
|
297
299
|
}
|
|
298
300
|
async getMetaData() {
|
|
@@ -339,15 +341,23 @@ class DataStore {
|
|
|
339
341
|
const datFilePath = path_1.default.join(config_1.STORE_PATH, this.storeId, `${rootHash}.dat`);
|
|
340
342
|
const datFileContent = JSON.parse(fs_1.default.readFileSync(datFilePath, "utf-8"));
|
|
341
343
|
const heightDatFilePath = path_1.default.join(config_1.STORE_PATH, this.storeId, "height.json");
|
|
342
|
-
const manifestFilePath = path_1.default.join(config_1.STORE_PATH, this.storeId, "manifest.dat");
|
|
343
344
|
const filesInvolved = [];
|
|
344
|
-
filesInvolved.push(manifestFilePath);
|
|
345
345
|
filesInvolved.push(datFilePath);
|
|
346
346
|
filesInvolved.push(heightDatFilePath);
|
|
347
|
+
// Iterate over each file and perform an integrity check
|
|
347
348
|
for (const [fileKey, fileData] of Object.entries(datFileContent.files)) {
|
|
348
|
-
const filepath = path_1.default.join(config_1.STORE_PATH, this.storeId, "data", fileKey);
|
|
349
349
|
const filePath = (0, hashUtils_1.getFilePathFromSha256)(datFileContent.files[fileKey].sha256, path_1.default.join(config_1.STORE_PATH, this.storeId, "data"));
|
|
350
|
-
|
|
350
|
+
// Perform the integrity check before adding to the file set
|
|
351
|
+
const integrityCheck = await DataIntegrityTree_1.DataIntegrityTree.validateKeyIntegrityWithForeignTree(fileKey, datFileContent.files[fileKey].sha256, datFileContent, rootHash, path_1.default.join(config_1.STORE_PATH, this.storeId, "data"));
|
|
352
|
+
if (integrityCheck) {
|
|
353
|
+
console.log(chalk_1.default.green(`File ${fileKey} has passed the integrity check.`));
|
|
354
|
+
// Add the file to the file set only if the integrity check passes
|
|
355
|
+
filesInvolved.push(filePath);
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
console.error(chalk_1.default.red(`File ${fileKey} failed the integrity check.`));
|
|
359
|
+
throw new Error(`Integrity check failed for file: ${fileKey}. Aborting.`);
|
|
360
|
+
}
|
|
351
361
|
}
|
|
352
362
|
return filesInvolved;
|
|
353
363
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class IllegalContentScanner
|
|
3
|
+
* Scans files for illegal content using ClamAV running in a Docker container and deletes files if flagged.
|
|
4
|
+
*/
|
|
5
|
+
export declare class IllegalContentScanner {
|
|
6
|
+
private clamAVContainerName;
|
|
7
|
+
private virusTotalApiKey?;
|
|
8
|
+
private openAiApiKey?;
|
|
9
|
+
/**
|
|
10
|
+
* @constructor
|
|
11
|
+
* @param clamAVContainerName The name of the Docker container running ClamAV (default: 'clamav').
|
|
12
|
+
*/
|
|
13
|
+
constructor(clamAVContainerName?: string);
|
|
14
|
+
/**
|
|
15
|
+
* Scans a file for illegal content using ClamAV, VirusTotal, and OpenAI Moderation API.
|
|
16
|
+
* If a service is missing its API key, the scan for that service is skipped.
|
|
17
|
+
* @param filePath The path of the file to scan.
|
|
18
|
+
* @returns {Promise<void>} A promise that resolves after the scan and potential deletion.
|
|
19
|
+
*/
|
|
20
|
+
scanFile(filePath: string): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Scans a file using ClamAV running in Docker.
|
|
23
|
+
* @param filePath The path of the file to scan.
|
|
24
|
+
* @returns {Promise<string>} The result of the ClamAV scan.
|
|
25
|
+
*/
|
|
26
|
+
private scanWithClamAV;
|
|
27
|
+
/**
|
|
28
|
+
* Submits a file to VirusTotal for scanning.
|
|
29
|
+
* @param filePath The path of the file to scan.
|
|
30
|
+
* @returns {Promise<any>} The result from VirusTotal.
|
|
31
|
+
*/
|
|
32
|
+
private scanWithVirusTotal;
|
|
33
|
+
/**
|
|
34
|
+
* Scans file content (text) using OpenAI's Moderation API.
|
|
35
|
+
* @param content The text content to scan.
|
|
36
|
+
* @returns {Promise<any>} The result from OpenAI's Moderation API.
|
|
37
|
+
*/
|
|
38
|
+
private scanWithOpenAI;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if the ClamAV scan result indicates a malicious file.
|
|
41
|
+
* @param result The ClamAV scan output.
|
|
42
|
+
* @returns {boolean} True if the file is flagged, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
private isClamAVResultMalicious;
|
|
45
|
+
/**
|
|
46
|
+
* Checks if the VirusTotal result indicates a malicious file.
|
|
47
|
+
* @param result The VirusTotal scan result.
|
|
48
|
+
* @returns {boolean} True if the file is flagged, false otherwise.
|
|
49
|
+
*/
|
|
50
|
+
private isVirusTotalResultMalicious;
|
|
51
|
+
/**
|
|
52
|
+
* Checks if the OpenAI Moderation result indicates harmful content.
|
|
53
|
+
* @param result The OpenAI Moderation result.
|
|
54
|
+
* @returns {boolean} True if harmful content is detected, false otherwise.
|
|
55
|
+
*/
|
|
56
|
+
private isOpenAiResultMalicious;
|
|
57
|
+
/**
|
|
58
|
+
* Deletes a file from the filesystem.
|
|
59
|
+
* @param filePath The file to delete.
|
|
60
|
+
*/
|
|
61
|
+
private deleteFile;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=ContentScanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentScanner.d.ts","sourceRoot":"","sources":["../../src/utils/ContentScanner.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,YAAY,CAAC,CAAS;IAE9B;;;OAGG;gBACS,mBAAmB,GAAE,MAAiB;IAMlD;;;;;OAKG;IACU,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqDtD;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAYtB;;;;OAIG;YACW,kBAAkB;IAgBhC;;;;OAIG;YACW,cAAc;IAa5B;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAI/B;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAKnC;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAI/B;;;OAGG;IACH,OAAO,CAAC,UAAU;CASrB"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IllegalContentScanner = void 0;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const axios_1 = __importDefault(require("axios"));
|
|
11
|
+
/**
|
|
12
|
+
* @class IllegalContentScanner
|
|
13
|
+
* Scans files for illegal content using ClamAV running in a Docker container and deletes files if flagged.
|
|
14
|
+
*/
|
|
15
|
+
class IllegalContentScanner {
|
|
16
|
+
/**
|
|
17
|
+
* @constructor
|
|
18
|
+
* @param clamAVContainerName The name of the Docker container running ClamAV (default: 'clamav').
|
|
19
|
+
*/
|
|
20
|
+
constructor(clamAVContainerName = "clamav") {
|
|
21
|
+
this.clamAVContainerName = clamAVContainerName;
|
|
22
|
+
this.virusTotalApiKey = process.env.VIRUSTOTAL_API_KEY || undefined;
|
|
23
|
+
this.openAiApiKey = process.env.OPENAI_API_KEY || undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Scans a file for illegal content using ClamAV, VirusTotal, and OpenAI Moderation API.
|
|
27
|
+
* If a service is missing its API key, the scan for that service is skipped.
|
|
28
|
+
* @param filePath The path of the file to scan.
|
|
29
|
+
* @returns {Promise<void>} A promise that resolves after the scan and potential deletion.
|
|
30
|
+
*/
|
|
31
|
+
async scanFile(filePath) {
|
|
32
|
+
try {
|
|
33
|
+
// 1. ClamAV Scan
|
|
34
|
+
console.log(`Starting ClamAV scan for file: ${filePath}`);
|
|
35
|
+
const clamAvResult = await this.scanWithClamAV(filePath);
|
|
36
|
+
if (this.isClamAVResultMalicious(clamAvResult)) {
|
|
37
|
+
console.log(`ClamAV flagged file: ${filePath}. Deleting...`);
|
|
38
|
+
this.deleteFile(filePath);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.log(`ClamAV did not flag the file: ${filePath}.`);
|
|
43
|
+
}
|
|
44
|
+
// 2. VirusTotal Scan (if API key is provided)
|
|
45
|
+
if (this.virusTotalApiKey) {
|
|
46
|
+
console.log(`Submitting file to VirusTotal for scanning: ${filePath}`);
|
|
47
|
+
const virusTotalResult = await this.scanWithVirusTotal(filePath);
|
|
48
|
+
if (this.isVirusTotalResultMalicious(virusTotalResult)) {
|
|
49
|
+
console.log(`VirusTotal flagged file: ${filePath}. Deleting...`);
|
|
50
|
+
this.deleteFile(filePath);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
console.log(`VirusTotal did not flag the file: ${filePath}.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.log(`VirusTotal API key not provided. Skipping VirusTotal scan.`);
|
|
59
|
+
}
|
|
60
|
+
// 3. OpenAI Moderation API (if API key is provided and file is text-based)
|
|
61
|
+
const fileExtension = path_1.default.extname(filePath).toLowerCase();
|
|
62
|
+
if (this.openAiApiKey && (fileExtension === ".txt" || fileExtension === ".json")) {
|
|
63
|
+
console.log(`Scanning file content with OpenAI Moderation API: ${filePath}`);
|
|
64
|
+
const fileContent = await fs_1.default.promises.readFile(filePath, "utf-8");
|
|
65
|
+
const openAiResult = await this.scanWithOpenAI(fileContent);
|
|
66
|
+
if (this.isOpenAiResultMalicious(openAiResult)) {
|
|
67
|
+
console.log(`OpenAI flagged file: ${filePath}. Deleting...`);
|
|
68
|
+
this.deleteFile(filePath);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
if (!this.openAiApiKey) {
|
|
74
|
+
console.log(`OpenAI API key not provided. Skipping OpenAI scan.`);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
console.log(`OpenAI scan skipped: File type not supported (${fileExtension}).`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
console.log(`File ${filePath} passed all multilayer scans.`);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error(`Error scanning file: ${filePath}`, error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Scans a file using ClamAV running in Docker.
|
|
88
|
+
* @param filePath The path of the file to scan.
|
|
89
|
+
* @returns {Promise<string>} The result of the ClamAV scan.
|
|
90
|
+
*/
|
|
91
|
+
scanWithClamAV(filePath) {
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
(0, child_process_1.exec)(`docker exec ${this.clamAVContainerName} clamdscan ${filePath}`, (error, stdout, stderr) => {
|
|
94
|
+
if (error) {
|
|
95
|
+
reject(`ClamAV scan error: ${stderr}`);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
resolve(stdout);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Submits a file to VirusTotal for scanning.
|
|
105
|
+
* @param filePath The path of the file to scan.
|
|
106
|
+
* @returns {Promise<any>} The result from VirusTotal.
|
|
107
|
+
*/
|
|
108
|
+
async scanWithVirusTotal(filePath) {
|
|
109
|
+
const fileContent = await fs_1.default.promises.readFile(filePath);
|
|
110
|
+
const formData = new FormData();
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
formData.append("file", fileContent);
|
|
113
|
+
const response = await axios_1.default.post("https://www.virustotal.com/vtapi/v2/file/scan", formData, {
|
|
114
|
+
headers: {
|
|
115
|
+
"x-apikey": this.virusTotalApiKey,
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
...formData.getHeaders(),
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
return response.data;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Scans file content (text) using OpenAI's Moderation API.
|
|
124
|
+
* @param content The text content to scan.
|
|
125
|
+
* @returns {Promise<any>} The result from OpenAI's Moderation API.
|
|
126
|
+
*/
|
|
127
|
+
async scanWithOpenAI(content) {
|
|
128
|
+
const response = await axios_1.default.post("https://api.openai.com/v1/moderations", { input: content }, {
|
|
129
|
+
headers: {
|
|
130
|
+
Authorization: `Bearer ${this.openAiApiKey}`,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
return response.data;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Checks if the ClamAV scan result indicates a malicious file.
|
|
137
|
+
* @param result The ClamAV scan output.
|
|
138
|
+
* @returns {boolean} True if the file is flagged, false otherwise.
|
|
139
|
+
*/
|
|
140
|
+
isClamAVResultMalicious(result) {
|
|
141
|
+
return result.includes("FOUND");
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Checks if the VirusTotal result indicates a malicious file.
|
|
145
|
+
* @param result The VirusTotal scan result.
|
|
146
|
+
* @returns {boolean} True if the file is flagged, false otherwise.
|
|
147
|
+
*/
|
|
148
|
+
isVirusTotalResultMalicious(result) {
|
|
149
|
+
// Check if VirusTotal flagged the file based on its multiple antivirus results
|
|
150
|
+
return result.positives > 0;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Checks if the OpenAI Moderation result indicates harmful content.
|
|
154
|
+
* @param result The OpenAI Moderation result.
|
|
155
|
+
* @returns {boolean} True if harmful content is detected, false otherwise.
|
|
156
|
+
*/
|
|
157
|
+
isOpenAiResultMalicious(result) {
|
|
158
|
+
return result.flagged === true;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Deletes a file from the filesystem.
|
|
162
|
+
* @param filePath The file to delete.
|
|
163
|
+
*/
|
|
164
|
+
deleteFile(filePath) {
|
|
165
|
+
fs_1.default.unlink(filePath, (err) => {
|
|
166
|
+
if (err) {
|
|
167
|
+
console.error(`Error deleting file: ${filePath}`, err);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
console.log(`File ${filePath} was deleted successfully.`);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.IllegalContentScanner = IllegalContentScanner;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dignetwork/dig-sdk",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.54",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@dignetwork/datalayer-driver": "^0.1.24",
|
|
29
29
|
"archiver": "^7.0.1",
|
|
30
|
+
"axios": "^1.7.7",
|
|
30
31
|
"bip39": "^3.1.0",
|
|
32
|
+
"chalk": "^5.3.0",
|
|
31
33
|
"chia-bls": "^1.0.2",
|
|
32
34
|
"chia-config-loader": "^1.0.1",
|
|
33
35
|
"chia-root-resolver": "^1.0.0",
|
|
@@ -35,6 +37,7 @@
|
|
|
35
37
|
"chia-wallet": "^1.0.18",
|
|
36
38
|
"cli-progress": "^3.12.0",
|
|
37
39
|
"crypto-js": "^4.2.0",
|
|
40
|
+
"figures": "^6.1.0",
|
|
38
41
|
"fs-extra": "^11.2.0",
|
|
39
42
|
"ignore": "^5.3.2",
|
|
40
43
|
"inquirer": "^10.1.8",
|
|
@@ -43,6 +46,7 @@
|
|
|
43
46
|
"nanospinner": "^1.1.0",
|
|
44
47
|
"nconf": "^0.12.1",
|
|
45
48
|
"node-cache": "^5.1.2",
|
|
49
|
+
"ora": "^8.1.0",
|
|
46
50
|
"p-limit": "^6.1.0",
|
|
47
51
|
"superagent": "^10.0.0",
|
|
48
52
|
"unzipper": "^0.12.3"
|