rcf-protocol 1.1.3 → 1.2.1
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/cli/index.js +44 -0
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const MarkerParser_1 = require("../core/MarkerParser");
|
|
|
10
10
|
const ComplianceValidator_1 = require("../core/ComplianceValidator");
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
12
|
const path_1 = require("path");
|
|
13
|
+
const crypto_1 = require("crypto");
|
|
13
14
|
const pkg = JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '../../package.json'), 'utf-8'));
|
|
14
15
|
const program = new commander_1.Command();
|
|
15
16
|
program
|
|
@@ -49,6 +50,49 @@ program
|
|
|
49
50
|
process.exit(1);
|
|
50
51
|
}
|
|
51
52
|
});
|
|
53
|
+
program
|
|
54
|
+
.command('audit [directory]')
|
|
55
|
+
.description('Generate an RCF Audit Report (Premium Feature)')
|
|
56
|
+
.option('-k, --license-key <key>', 'RCF Audit License Key')
|
|
57
|
+
.action(async (directory = '.', options) => {
|
|
58
|
+
const licenseKey = options.licenseKey || process.env.RCF_LICENSE_KEY;
|
|
59
|
+
const uuidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/;
|
|
60
|
+
if (!licenseKey || !licenseKey.startsWith('RCF-AUDIT-') || !uuidRegex.test(licenseKey.replace('RCF-AUDIT-', ''))) {
|
|
61
|
+
console.log(chalk_1.default.red("❌ RCF-PL ERROR: The 'audit' command is a premium feature."));
|
|
62
|
+
console.log(chalk_1.default.yellow(" Please provide a valid RCF-AUDIT license key via -k/--license-key or RCF_LICENSE_KEY env variable."));
|
|
63
|
+
console.log(chalk_1.default.blue(" Visit https://rcf.aliyev.site to obtain a license."));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
const parser = new MarkerParser_1.MarkerParser();
|
|
67
|
+
const results = await parser.scan(directory);
|
|
68
|
+
const auditReport = {
|
|
69
|
+
timestamp: new Date().toISOString(),
|
|
70
|
+
audit_type: "RCF-Audit as a Service",
|
|
71
|
+
protected_assets: []
|
|
72
|
+
};
|
|
73
|
+
for (const res of results) {
|
|
74
|
+
if (res.markers && res.markers.length > 0) {
|
|
75
|
+
try {
|
|
76
|
+
const fileBuffer = (0, fs_1.readFileSync)(res.file);
|
|
77
|
+
const fileHash = (0, crypto_1.createHash)('sha256').update(fileBuffer).digest('hex');
|
|
78
|
+
const uniqueMarkers = Array.from(new Set(res.markers.map((m) => m.type)));
|
|
79
|
+
const relPath = (0, path_1.relative)((0, path_1.resolve)(directory), res.file);
|
|
80
|
+
auditReport.protected_assets.push({
|
|
81
|
+
file: relPath,
|
|
82
|
+
markers: uniqueMarkers,
|
|
83
|
+
sha256: fileHash
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
// ignore
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const reportPath = (0, path_1.resolve)(directory, 'RCF-AUDIT-REPORT.json');
|
|
92
|
+
(0, fs_1.writeFileSync)(reportPath, JSON.stringify(auditReport, null, 2));
|
|
93
|
+
console.log(chalk_1.default.green(`✅ RCF-Audit Complete. Generated ${reportPath}`));
|
|
94
|
+
console.log(chalk_1.default.cyan(`🔒 Encrypted snapshot of ${auditReport.protected_assets.length} protected assets created.`));
|
|
95
|
+
});
|
|
52
96
|
function printSummary(results) {
|
|
53
97
|
const stats = { PUBLIC: 0, PROTECTED: 0, RESTRICTED: 0, NOTICE: 0 };
|
|
54
98
|
results.forEach(r => r.markers.forEach((m) => stats[m.type]++));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rcf-protocol",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "RCF Protocol SDK for TypeScript/JavaScript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,4 +36,4 @@
|
|
|
36
36
|
"ts-node": "^10.9.0",
|
|
37
37
|
"typescript": "^5.9.3"
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
}
|