neozip-cli 0.70.0-alpha
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/CHANGELOG.md +72 -0
- package/DOCUMENTATION.md +194 -0
- package/LICENSE +22 -0
- package/README.md +504 -0
- package/WHY_NEOZIP.md +212 -0
- package/bin/neolist +16 -0
- package/bin/neounzip +16 -0
- package/bin/neozip +15 -0
- package/dist/neozipkit-bundles/blockchain.js +13091 -0
- package/dist/neozipkit-bundles/browser.js +5733 -0
- package/dist/neozipkit-bundles/core.js +3766 -0
- package/dist/neozipkit-bundles/server.js +14996 -0
- package/dist/neozipkit-wrappers/blockchain/core/contracts.js +16 -0
- package/dist/neozipkit-wrappers/blockchain/index.js +2 -0
- package/dist/neozipkit-wrappers/core/ZipDecompress.js +2 -0
- package/dist/neozipkit-wrappers/core/components/HashCalculator.js +2 -0
- package/dist/neozipkit-wrappers/core/components/Logger.js +2 -0
- package/dist/neozipkit-wrappers/core/constants/Errors.js +2 -0
- package/dist/neozipkit-wrappers/core/constants/Headers.js +2 -0
- package/dist/neozipkit-wrappers/core/encryption/ZipCrypto.js +7 -0
- package/dist/neozipkit-wrappers/core/index.js +3 -0
- package/dist/neozipkit-wrappers/index.js +13 -0
- package/dist/neozipkit-wrappers/server/index.js +2 -0
- package/dist/src/config/ConfigSetup.js +455 -0
- package/dist/src/config/ConfigStore.js +373 -0
- package/dist/src/config/ConfigWizard.js +453 -0
- package/dist/src/config/WalletConfig.js +372 -0
- package/dist/src/exit-codes.js +210 -0
- package/dist/src/index.js +141 -0
- package/dist/src/neolist.js +1194 -0
- package/dist/src/neounzip.js +2177 -0
- package/dist/src/neozip/CommentManager.js +240 -0
- package/dist/src/neozip/blockchain.js +383 -0
- package/dist/src/neozip/createZip.js +2273 -0
- package/dist/src/neozip/file-operations.js +920 -0
- package/dist/src/neozip/types.js +6 -0
- package/dist/src/neozip/user-interaction.js +256 -0
- package/dist/src/neozip/utils.js +96 -0
- package/dist/src/neozip.js +785 -0
- package/dist/src/server/CommentManager.js +240 -0
- package/dist/src/version.js +59 -0
- package/env.example +101 -0
- package/package.json +175 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* WalletConfig - Configuration manager for NeoZip wallet and blockchain settings
|
|
4
|
+
* Supports wallet.json file in user's home directory with fallback to environment variables
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.WalletConfig = void 0;
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const os = __importStar(require("os"));
|
|
44
|
+
const contracts_1 = require('../../neozipkit-wrappers/blockchain/core/contracts');
|
|
45
|
+
const DEFAULTS = {
|
|
46
|
+
network: 'base-sepolia',
|
|
47
|
+
rpcUrls: {
|
|
48
|
+
baseSepolia: 'https://sepolia.base.org',
|
|
49
|
+
baseMainnet: 'https://mainnet.base.org',
|
|
50
|
+
},
|
|
51
|
+
gas: {
|
|
52
|
+
multiplier: 1.0,
|
|
53
|
+
maxPriceGwei: 100,
|
|
54
|
+
},
|
|
55
|
+
debug: {
|
|
56
|
+
verbose: false,
|
|
57
|
+
enabled: false,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
class WalletConfig {
|
|
61
|
+
/**
|
|
62
|
+
* Get the configuration directory path
|
|
63
|
+
*/
|
|
64
|
+
static getConfigDir() {
|
|
65
|
+
return this.configDir;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the configuration file path
|
|
69
|
+
*/
|
|
70
|
+
static getConfigPath() {
|
|
71
|
+
return this.configPath;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if wallet.json exists
|
|
75
|
+
*/
|
|
76
|
+
static exists() {
|
|
77
|
+
return fs.existsSync(this.getConfigPath());
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Load configuration from wallet.json
|
|
81
|
+
*/
|
|
82
|
+
static load() {
|
|
83
|
+
if (!this.exists()) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const content = fs.readFileSync(this.getConfigPath(), 'utf-8');
|
|
88
|
+
return JSON.parse(content);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.error(`⚠️ Failed to load wallet.json: ${error}`);
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Save configuration to wallet.json
|
|
97
|
+
*/
|
|
98
|
+
static save(config) {
|
|
99
|
+
try {
|
|
100
|
+
// Ensure config directory exists
|
|
101
|
+
const configDir = this.getConfigDir();
|
|
102
|
+
if (!fs.existsSync(configDir)) {
|
|
103
|
+
fs.mkdirSync(configDir, { recursive: true, mode: 0o700 });
|
|
104
|
+
}
|
|
105
|
+
// Write config file with restricted permissions
|
|
106
|
+
fs.writeFileSync(this.getConfigPath(), JSON.stringify(config, null, 2), { mode: 0o600 });
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
console.error(`❌ Failed to save wallet.json: ${error}`);
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Delete wallet.json configuration
|
|
116
|
+
*/
|
|
117
|
+
static reset() {
|
|
118
|
+
try {
|
|
119
|
+
if (this.exists()) {
|
|
120
|
+
fs.unlinkSync(this.getConfigPath());
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
console.error(`❌ Failed to delete wallet.json: ${error}`);
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get resolved configuration with precedence: CLI args > ENV vars > wallet.json > defaults
|
|
131
|
+
* @param cliWalletKey - Wallet key from CLI argument (highest priority)
|
|
132
|
+
*/
|
|
133
|
+
static getConfig(cliWalletKey) {
|
|
134
|
+
const jsonConfig = this.load();
|
|
135
|
+
// Wallet key precedence: CLI > ENV > wallet.json
|
|
136
|
+
let walletKey = null;
|
|
137
|
+
if (cliWalletKey) {
|
|
138
|
+
walletKey = cliWalletKey;
|
|
139
|
+
}
|
|
140
|
+
else if (process.env.NEOZIP_WALLET_PASSKEY) {
|
|
141
|
+
walletKey = process.env.NEOZIP_WALLET_PASSKEY;
|
|
142
|
+
}
|
|
143
|
+
else if (jsonConfig?.wallet?.privateKey) {
|
|
144
|
+
walletKey = jsonConfig.wallet.privateKey;
|
|
145
|
+
}
|
|
146
|
+
// Network precedence: ENV > wallet.json > default
|
|
147
|
+
const network = process.env.NEOZIP_NETWORK ||
|
|
148
|
+
jsonConfig?.wallet?.network ||
|
|
149
|
+
DEFAULTS.network;
|
|
150
|
+
// RPC URLs precedence: ENV > wallet.json > default
|
|
151
|
+
const rpcUrls = {
|
|
152
|
+
baseSepolia: process.env.NEOZIP_BASE_SEPOLIA_RPC_URL ||
|
|
153
|
+
jsonConfig?.rpc?.baseSepolia ||
|
|
154
|
+
DEFAULTS.rpcUrls.baseSepolia,
|
|
155
|
+
baseMainnet: process.env.NEOZIP_BASE_MAINNET_RPC_URL ||
|
|
156
|
+
jsonConfig?.rpc?.baseMainnet ||
|
|
157
|
+
DEFAULTS.rpcUrls.baseMainnet,
|
|
158
|
+
};
|
|
159
|
+
// Gas settings precedence: ENV > wallet.json > default
|
|
160
|
+
const gas = {
|
|
161
|
+
multiplier: process.env.NEOZIP_GAS_MULTIPLIER ?
|
|
162
|
+
parseFloat(process.env.NEOZIP_GAS_MULTIPLIER) :
|
|
163
|
+
jsonConfig?.gas?.multiplier ||
|
|
164
|
+
DEFAULTS.gas.multiplier,
|
|
165
|
+
maxPriceGwei: process.env.NEOZIP_MAX_GAS_PRICE ?
|
|
166
|
+
parseInt(process.env.NEOZIP_MAX_GAS_PRICE) :
|
|
167
|
+
jsonConfig?.gas?.maxPriceGwei ||
|
|
168
|
+
DEFAULTS.gas.maxPriceGwei,
|
|
169
|
+
};
|
|
170
|
+
// Debug settings precedence: ENV > wallet.json > default
|
|
171
|
+
const debug = {
|
|
172
|
+
verbose: process.env.NEOZIP_VERBOSE === 'true' ||
|
|
173
|
+
jsonConfig?.debug?.verbose ||
|
|
174
|
+
DEFAULTS.debug.verbose,
|
|
175
|
+
enabled: process.env.NEOZIP_DEBUG === 'true' ||
|
|
176
|
+
jsonConfig?.debug?.enabled ||
|
|
177
|
+
DEFAULTS.debug.enabled,
|
|
178
|
+
};
|
|
179
|
+
return {
|
|
180
|
+
walletKey,
|
|
181
|
+
network,
|
|
182
|
+
rpcUrls,
|
|
183
|
+
gas,
|
|
184
|
+
debug,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Validate wallet private key format
|
|
189
|
+
*/
|
|
190
|
+
static validatePrivateKey(key) {
|
|
191
|
+
// Must be 66 characters (0x + 64 hex chars) or 64 characters (without 0x)
|
|
192
|
+
const withPrefix = /^0x[0-9a-fA-F]{64}$/;
|
|
193
|
+
const withoutPrefix = /^[0-9a-fA-F]{64}$/;
|
|
194
|
+
return withPrefix.test(key) || withoutPrefix.test(key);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Validate network name (uses nameAliases from CONTRACT_CONFIGS)
|
|
198
|
+
*/
|
|
199
|
+
static validateNetwork(network) {
|
|
200
|
+
return (0, contracts_1.getChainIdByName)(network) !== null;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Update a specific configuration value
|
|
204
|
+
*/
|
|
205
|
+
static set(key, value) {
|
|
206
|
+
let config = this.load() || {
|
|
207
|
+
wallet: {},
|
|
208
|
+
rpc: {},
|
|
209
|
+
gas: {},
|
|
210
|
+
debug: {},
|
|
211
|
+
};
|
|
212
|
+
// Parse the key path (e.g., "wallet.privateKey", "gas.multiplier")
|
|
213
|
+
const parts = key.split('.');
|
|
214
|
+
switch (parts[0]) {
|
|
215
|
+
case 'wallet':
|
|
216
|
+
if (parts[1] === 'privateKey') {
|
|
217
|
+
if (!this.validatePrivateKey(value)) {
|
|
218
|
+
console.error('❌ Invalid private key format');
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
config.wallet.privateKey = value.startsWith('0x') ? value : `0x${value}`;
|
|
222
|
+
}
|
|
223
|
+
else if (parts[1] === 'network') {
|
|
224
|
+
if (!this.validateNetwork(value)) {
|
|
225
|
+
const supportedNetworks = (0, contracts_1.getSupportedNetworkNames)();
|
|
226
|
+
console.error(`❌ Invalid network: "${value}"`);
|
|
227
|
+
console.error(`Supported networks: ${supportedNetworks.join(', ')}`);
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
config.wallet.network = value;
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
case 'rpc':
|
|
234
|
+
if (!config.rpc)
|
|
235
|
+
config.rpc = {};
|
|
236
|
+
// Support both legacy keys and dynamic network keys
|
|
237
|
+
if (parts[1] === 'baseSepolia') {
|
|
238
|
+
config.rpc.baseSepolia = value;
|
|
239
|
+
}
|
|
240
|
+
else if (parts[1] === 'baseMainnet') {
|
|
241
|
+
config.rpc.baseMainnet = value;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
// Allow dynamic network keys (e.g., "rpc.baseSepolia", "rpc.arbitrumSepolia")
|
|
245
|
+
config.rpc[parts[1]] = value;
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
case 'gas':
|
|
249
|
+
if (!config.gas)
|
|
250
|
+
config.gas = {};
|
|
251
|
+
if (parts[1] === 'multiplier') {
|
|
252
|
+
config.gas.multiplier = parseFloat(value);
|
|
253
|
+
}
|
|
254
|
+
else if (parts[1] === 'maxPriceGwei') {
|
|
255
|
+
config.gas.maxPriceGwei = parseInt(value);
|
|
256
|
+
}
|
|
257
|
+
break;
|
|
258
|
+
case 'debug':
|
|
259
|
+
if (!config.debug)
|
|
260
|
+
config.debug = {};
|
|
261
|
+
if (parts[1] === 'verbose') {
|
|
262
|
+
config.debug.verbose = value === 'true';
|
|
263
|
+
}
|
|
264
|
+
else if (parts[1] === 'enabled') {
|
|
265
|
+
config.debug.enabled = value === 'true';
|
|
266
|
+
}
|
|
267
|
+
break;
|
|
268
|
+
default:
|
|
269
|
+
console.error(`❌ Unknown configuration key: ${key}`);
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
return this.save(config);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Delete a specific configuration key
|
|
276
|
+
*/
|
|
277
|
+
static delete(key) {
|
|
278
|
+
const config = this.load();
|
|
279
|
+
if (!config) {
|
|
280
|
+
console.error('❌ No configuration found');
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
// Parse the key path (e.g., "wallet.privateKey", "gas.multiplier")
|
|
284
|
+
const parts = key.split('.');
|
|
285
|
+
switch (parts[0]) {
|
|
286
|
+
case 'wallet':
|
|
287
|
+
if (parts[1] === 'privateKey') {
|
|
288
|
+
delete config.wallet.privateKey;
|
|
289
|
+
}
|
|
290
|
+
else if (parts[1] === 'network') {
|
|
291
|
+
delete config.wallet.network;
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
console.error(`❌ Unknown wallet key: ${parts[1]}`);
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
break;
|
|
298
|
+
case 'rpc':
|
|
299
|
+
if (!config.rpc) {
|
|
300
|
+
console.error('❌ No RPC configuration found');
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
// Support both legacy keys and dynamic network keys
|
|
304
|
+
if (parts[1] === 'baseSepolia' || parts[1] === 'baseMainnet' || parts[1] in config.rpc) {
|
|
305
|
+
delete config.rpc[parts[1]];
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
console.error(`❌ Unknown RPC key: ${parts[1]}`);
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
break;
|
|
312
|
+
case 'gas':
|
|
313
|
+
if (!config.gas) {
|
|
314
|
+
console.error('❌ No gas configuration found');
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
if (parts[1] === 'multiplier') {
|
|
318
|
+
delete config.gas.multiplier;
|
|
319
|
+
}
|
|
320
|
+
else if (parts[1] === 'maxPriceGwei') {
|
|
321
|
+
delete config.gas.maxPriceGwei;
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
console.error(`❌ Unknown gas key: ${parts[1]}`);
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
break;
|
|
328
|
+
case 'debug':
|
|
329
|
+
if (!config.debug) {
|
|
330
|
+
console.error('❌ No debug configuration found');
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
if (parts[1] === 'verbose') {
|
|
334
|
+
delete config.debug.verbose;
|
|
335
|
+
}
|
|
336
|
+
else if (parts[1] === 'enabled') {
|
|
337
|
+
delete config.debug.enabled;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
console.error(`❌ Unknown debug key: ${parts[1]}`);
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
break;
|
|
344
|
+
default:
|
|
345
|
+
console.error(`❌ Unknown configuration key: ${key}`);
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
return this.save(config);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Get a masked version of the config for display (hides sensitive data)
|
|
352
|
+
*/
|
|
353
|
+
static getMaskedConfig() {
|
|
354
|
+
const config = this.getConfig();
|
|
355
|
+
const masked = {
|
|
356
|
+
wallet: {
|
|
357
|
+
privateKey: config.walletKey ?
|
|
358
|
+
`${config.walletKey.substring(0, 6)}...${config.walletKey.substring(config.walletKey.length - 4)}` :
|
|
359
|
+
'(not set)',
|
|
360
|
+
network: config.network,
|
|
361
|
+
},
|
|
362
|
+
rpc: config.rpcUrls,
|
|
363
|
+
gas: config.gas,
|
|
364
|
+
debug: config.debug,
|
|
365
|
+
};
|
|
366
|
+
return JSON.stringify(masked, null, 2);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
exports.WalletConfig = WalletConfig;
|
|
370
|
+
WalletConfig.configDir = path.join(os.homedir(), '.neozip');
|
|
371
|
+
WalletConfig.configPath = path.join(WalletConfig.configDir, 'wallet.json');
|
|
372
|
+
//# sourceMappingURL=WalletConfig.js.map
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Exit Codes for NeoZip Applications
|
|
4
|
+
*
|
|
5
|
+
* Standardized exit codes matching InfoZip conventions for compatibility
|
|
6
|
+
* and consistency across neozip, neounzip, and neolist applications.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ZIPINFO_EXIT_CODES = exports.UNZIP_EXIT_CODES = exports.ZIP_EXIT_CODES = void 0;
|
|
10
|
+
exports.exitZip = exitZip;
|
|
11
|
+
exports.exitUnzip = exitUnzip;
|
|
12
|
+
exports.exitZipinfo = exitZipinfo;
|
|
13
|
+
exports.getExitCodeDescription = getExitCodeDescription;
|
|
14
|
+
/**
|
|
15
|
+
* Exit codes for NEOZIP application
|
|
16
|
+
* Based on InfoZip ZIP exit codes
|
|
17
|
+
*/
|
|
18
|
+
exports.ZIP_EXIT_CODES = {
|
|
19
|
+
SUCCESS: 0, // Normal (no errors)
|
|
20
|
+
UNEXPECTED_END: 2, // Unexpected end of ZIP file
|
|
21
|
+
STRUCTURAL_ERROR: 3, // Structural error in ZIP file
|
|
22
|
+
MEMORY_ERROR: 4, // Memory allocation error
|
|
23
|
+
WRITE_ERROR: 5, // Write error (disk full?)
|
|
24
|
+
CANT_CREATE_FILE: 6, // Can't create file
|
|
25
|
+
CANT_CREATE_DIR: 7, // Can't create directory
|
|
26
|
+
USER_INTERRUPT: 9, // User interrupt (Ctrl-C)
|
|
27
|
+
PARAMETER_ERROR: 10, // Parameter error
|
|
28
|
+
NO_FILES_MATCHED: 11, // No files matched pattern
|
|
29
|
+
BAD_ARCHIVE_FORMAT: 12, // Bad archive format
|
|
30
|
+
CANT_OPEN_ARCHIVE: 13, // Can't open archive
|
|
31
|
+
READ_ERROR: 14, // Read error
|
|
32
|
+
CANT_WRITE_ARCHIVE: 15, // Can't write archive
|
|
33
|
+
CANT_FIND_ARCHIVE: 18, // Can't find archive
|
|
34
|
+
// NeoZip-specific exit codes (20-49)
|
|
35
|
+
TOKEN_MINT_FAILED: 20, // Token minting failed (non-fatal, ZIP created without token)
|
|
36
|
+
TOKEN_MINT_TIMEOUT: 21, // Token minting timeout
|
|
37
|
+
TOKEN_MINT_NETWORK_ERROR: 22, // Token minting network/RPC error
|
|
38
|
+
TOKEN_MINT_INSUFFICIENT_BALANCE: 23, // Insufficient balance for token minting
|
|
39
|
+
TOKEN_MINT_GAS_ERROR: 24, // Gas estimation/submission error
|
|
40
|
+
TOKEN_MINT_USER_CANCELLED: 25, // User cancelled token minting
|
|
41
|
+
BLOCKCHAIN_CONFIG_ERROR: 26, // Blockchain configuration error (wallet, network)
|
|
42
|
+
OTS_CREATE_FAILED: 27, // OpenTimestamp creation failed
|
|
43
|
+
OTS_MERKLE_ERROR: 28, // OpenTimestamp merkle root calculation error
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Exit codes for NEOUNZIP application
|
|
47
|
+
* Based on InfoZip UNZIP exit codes
|
|
48
|
+
*/
|
|
49
|
+
exports.UNZIP_EXIT_CODES = {
|
|
50
|
+
SUCCESS: 0, // Success
|
|
51
|
+
WARNING: 1, // Warning errors (but completed)
|
|
52
|
+
ZIP_FORMAT_ERROR: 2, // Generic ZIP format error
|
|
53
|
+
SEVERE_ZIP_ERROR: 3, // Severe ZIP format error
|
|
54
|
+
MEMORY_ERROR: 4, // Memory allocation error
|
|
55
|
+
MEMORY_PASSWORD_ERROR: 5, // Memory/password error
|
|
56
|
+
MEMORY_DECOMPRESS_ERROR: 6, // Memory error during decompression
|
|
57
|
+
MEMORY_INMEMORY_ERROR: 7, // Memory error (in-memory decompression)
|
|
58
|
+
FILES_NOT_FOUND: 9, // Specified files not found
|
|
59
|
+
INVALID_OPTIONS: 10, // Invalid options on command line
|
|
60
|
+
NO_MATCHING_FILES: 11, // No matching files found
|
|
61
|
+
DISK_FULL: 50, // Disk full
|
|
62
|
+
UNEXPECTED_END: 51, // Unexpected end of ZIP file
|
|
63
|
+
USER_ABORTED: 80, // User aborted (Ctrl-C)
|
|
64
|
+
UNSUPPORTED_COMPRESSION: 81, // Unsupported compression/decryption
|
|
65
|
+
BAD_PASSWORD: 82, // Bad password
|
|
66
|
+
// NeoZip-specific exit codes (83-89)
|
|
67
|
+
TOKEN_VERIFY_FAILED: 83, // Token verification failed
|
|
68
|
+
TOKEN_VERIFY_TIMEOUT: 84, // Token verification timeout
|
|
69
|
+
TOKEN_VERIFY_NETWORK_ERROR: 85, // Token verification network/RPC error
|
|
70
|
+
TOKEN_VERIFY_METADATA_ERROR: 86, // Token metadata missing or invalid
|
|
71
|
+
TOKEN_VERIFY_MERKLE_MISMATCH: 87, // Merkle root mismatch during verification
|
|
72
|
+
TOKEN_VERIFY_USER_CANCELLED: 88, // User cancelled verification
|
|
73
|
+
OTS_VERIFY_FAILED: 89, // OpenTimestamp verification failed
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Exit codes for NEOLIST application
|
|
77
|
+
* Based on InfoZip ZIPINFO exit codes
|
|
78
|
+
*/
|
|
79
|
+
exports.ZIPINFO_EXIT_CODES = {
|
|
80
|
+
SUCCESS: 0, // Success
|
|
81
|
+
WARNING: 1, // One or more warnings (but completed)
|
|
82
|
+
ZIP_FORMAT_ERROR: 2, // Error in ZIP file format
|
|
83
|
+
SEVERE_ZIP_ERROR: 3, // Severe error in ZIP file format
|
|
84
|
+
MEMORY_ERROR: 4, // Memory allocation error
|
|
85
|
+
FILES_NOT_FOUND: 9, // Specified files not found
|
|
86
|
+
INVALID_OPTIONS: 10, // Invalid command-line options
|
|
87
|
+
NO_MATCHING_FILES: 11, // No matching files found
|
|
88
|
+
USER_ABORTED: 80, // User aborted (Ctrl-C)
|
|
89
|
+
PASSWORD_PROTECTED: 82, // Archive is password-protected (can't list without password)
|
|
90
|
+
// NeoZip-specific exit codes (83-89)
|
|
91
|
+
TOKEN_VERIFY_FAILED: 83, // Token verification failed
|
|
92
|
+
TOKEN_VERIFY_TIMEOUT: 84, // Token verification timeout
|
|
93
|
+
TOKEN_VERIFY_NETWORK_ERROR: 85, // Token verification network/RPC error
|
|
94
|
+
TOKEN_VERIFY_METADATA_ERROR: 86, // Token metadata missing or invalid
|
|
95
|
+
TOKEN_VERIFY_MERKLE_MISMATCH: 87, // Merkle root mismatch during verification
|
|
96
|
+
TOKEN_VERIFY_USER_CANCELLED: 88, // User cancelled verification
|
|
97
|
+
OTS_VERIFY_FAILED: 89, // OpenTimestamp verification failed
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Helper function to exit with a ZIP exit code
|
|
101
|
+
*/
|
|
102
|
+
function exitZip(code, message) {
|
|
103
|
+
if (message) {
|
|
104
|
+
console.error(message);
|
|
105
|
+
}
|
|
106
|
+
process.exit(code);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Helper function to exit with an UNZIP exit code
|
|
110
|
+
*/
|
|
111
|
+
function exitUnzip(code, message) {
|
|
112
|
+
if (message) {
|
|
113
|
+
console.error(message);
|
|
114
|
+
}
|
|
115
|
+
process.exit(code);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Helper function to exit with a ZIPINFO exit code
|
|
119
|
+
*/
|
|
120
|
+
function exitZipinfo(code, message) {
|
|
121
|
+
if (message) {
|
|
122
|
+
console.error(message);
|
|
123
|
+
}
|
|
124
|
+
process.exit(code);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get exit code description for documentation
|
|
128
|
+
*/
|
|
129
|
+
function getExitCodeDescription(app, code) {
|
|
130
|
+
if (app === 'zip') {
|
|
131
|
+
const descriptions = {
|
|
132
|
+
0: 'Normal (no errors)',
|
|
133
|
+
2: 'Unexpected end of ZIP file',
|
|
134
|
+
3: 'Structural error in ZIP file',
|
|
135
|
+
4: 'Memory allocation error',
|
|
136
|
+
5: 'Write error (disk full?)',
|
|
137
|
+
6: 'Can\'t create file',
|
|
138
|
+
7: 'Can\'t create directory',
|
|
139
|
+
9: 'User interrupt (Ctrl-C)',
|
|
140
|
+
10: 'Parameter error',
|
|
141
|
+
11: 'No files matched pattern',
|
|
142
|
+
12: 'Bad archive format',
|
|
143
|
+
13: 'Can\'t open archive',
|
|
144
|
+
14: 'Read error',
|
|
145
|
+
15: 'Can\'t write archive',
|
|
146
|
+
18: 'Can\'t find archive',
|
|
147
|
+
20: 'Token minting failed (non-fatal, ZIP created without token)',
|
|
148
|
+
21: 'Token minting timeout',
|
|
149
|
+
22: 'Token minting network/RPC error',
|
|
150
|
+
23: 'Insufficient balance for token minting',
|
|
151
|
+
24: 'Gas estimation/submission error',
|
|
152
|
+
25: 'User cancelled token minting',
|
|
153
|
+
26: 'Blockchain configuration error (wallet, network)',
|
|
154
|
+
27: 'OpenTimestamp creation failed',
|
|
155
|
+
28: 'OpenTimestamp merkle root calculation error',
|
|
156
|
+
};
|
|
157
|
+
return descriptions[code] || 'Unknown exit code';
|
|
158
|
+
}
|
|
159
|
+
else if (app === 'unzip') {
|
|
160
|
+
const descriptions = {
|
|
161
|
+
0: 'Success',
|
|
162
|
+
1: 'Warning errors (but completed)',
|
|
163
|
+
2: 'Generic ZIP format error',
|
|
164
|
+
3: 'Severe ZIP format error',
|
|
165
|
+
4: 'Memory allocation error',
|
|
166
|
+
5: 'Memory/password error',
|
|
167
|
+
6: 'Memory error during decompression',
|
|
168
|
+
7: 'Memory error (in-memory decompression)',
|
|
169
|
+
9: 'Specified files not found',
|
|
170
|
+
10: 'Invalid options on command line',
|
|
171
|
+
11: 'No matching files found',
|
|
172
|
+
50: 'Disk full',
|
|
173
|
+
51: 'Unexpected end of ZIP file',
|
|
174
|
+
80: 'User aborted (Ctrl-C)',
|
|
175
|
+
81: 'Unsupported compression/decryption',
|
|
176
|
+
82: 'Bad password',
|
|
177
|
+
83: 'Token verification failed',
|
|
178
|
+
84: 'Token verification timeout',
|
|
179
|
+
85: 'Token verification network/RPC error',
|
|
180
|
+
86: 'Token metadata missing or invalid',
|
|
181
|
+
87: 'Merkle root mismatch during verification',
|
|
182
|
+
88: 'User cancelled verification',
|
|
183
|
+
89: 'OpenTimestamp verification failed',
|
|
184
|
+
};
|
|
185
|
+
return descriptions[code] || 'Unknown exit code';
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
const descriptions = {
|
|
189
|
+
0: 'Success',
|
|
190
|
+
1: 'One or more warnings (but completed)',
|
|
191
|
+
2: 'Error in ZIP file format',
|
|
192
|
+
3: 'Severe error in ZIP file format',
|
|
193
|
+
4: 'Memory allocation error',
|
|
194
|
+
9: 'Specified files not found',
|
|
195
|
+
10: 'Invalid command-line options',
|
|
196
|
+
11: 'No matching files found',
|
|
197
|
+
80: 'User aborted (Ctrl-C)',
|
|
198
|
+
82: 'Archive is password-protected (can\'t list without password)',
|
|
199
|
+
83: 'Token verification failed',
|
|
200
|
+
84: 'Token verification timeout',
|
|
201
|
+
85: 'Token verification network/RPC error',
|
|
202
|
+
86: 'Token metadata missing or invalid',
|
|
203
|
+
87: 'Merkle root mismatch during verification',
|
|
204
|
+
88: 'User cancelled verification',
|
|
205
|
+
89: 'OpenTimestamp verification failed',
|
|
206
|
+
};
|
|
207
|
+
return descriptions[code] || 'Unknown exit code';
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=exit-codes.js.map
|