neozip-cli 0.90.0 → 0.95.0

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.
Files changed (74) hide show
  1. package/AGENTS.md +93 -0
  2. package/CHANGELOG.md +58 -1
  3. package/DOCUMENTATION.md +22 -30
  4. package/README.md +104 -42
  5. package/dist/src/account/account-state.js +95 -0
  6. package/dist/src/account/format-account-status.js +62 -0
  7. package/dist/src/account/identity-provision.js +79 -0
  8. package/dist/src/account/identity-wrap.js +106 -0
  9. package/dist/src/account/profile-crypto.js +85 -0
  10. package/dist/src/account/profile-store.js +129 -0
  11. package/dist/src/account/require-account.js +32 -0
  12. package/dist/src/account/types.js +3 -0
  13. package/dist/src/account/wallet-evm.js +46 -0
  14. package/dist/src/account/wallet-setup.js +33 -0
  15. package/dist/src/archive/crypto-self.js +117 -0
  16. package/dist/src/archive/identity-key.js +217 -0
  17. package/dist/src/archive/recipient-lookup.js +61 -0
  18. package/dist/src/cli/output.js +100 -0
  19. package/dist/src/cli/params.js +122 -0
  20. package/dist/src/cli/schema.js +186 -0
  21. package/dist/src/cli/validate.js +119 -0
  22. package/dist/src/commands/mintTimestampProof.js +26 -14
  23. package/dist/src/config/ConfigSetup.js +82 -423
  24. package/dist/src/connect/command.js +364 -0
  25. package/dist/src/connection/bootstrap.js +50 -0
  26. package/dist/src/connection/cli-guidance.js +101 -0
  27. package/dist/src/connection/cli-prefs.js +180 -0
  28. package/dist/src/connection/cli-settings.js +140 -0
  29. package/dist/src/connection/cli-types.js +14 -0
  30. package/dist/src/connection/coordinator.js +83 -0
  31. package/dist/src/connection/credentials.js +33 -0
  32. package/dist/src/connection/crypto.js +96 -0
  33. package/dist/src/connection/dump.js +117 -0
  34. package/dist/src/connection/funding.js +187 -0
  35. package/dist/src/connection/incomplete-setup.js +89 -0
  36. package/dist/src/connection/interactive.js +871 -0
  37. package/dist/src/connection/legacy-profile-reader.js +87 -0
  38. package/dist/src/connection/magic-link.js +142 -0
  39. package/dist/src/connection/migrate.js +115 -0
  40. package/dist/src/connection/onboarding.js +616 -0
  41. package/dist/src/connection/origin.js +69 -0
  42. package/dist/src/connection/phase.js +101 -0
  43. package/dist/src/connection/phone.js +26 -0
  44. package/dist/src/connection/promote-active.js +56 -0
  45. package/dist/src/connection/reset.js +56 -0
  46. package/dist/src/connection/status-report.js +52 -0
  47. package/dist/src/connection/store.js +406 -0
  48. package/dist/src/connection/token-auth.js +44 -0
  49. package/dist/src/connection/types.js +3 -0
  50. package/dist/src/connection/wallet-json-migration.js +155 -0
  51. package/dist/src/connection/wallet-login.js +65 -0
  52. package/dist/src/connection/wallet-setup.js +83 -0
  53. package/dist/src/constants/wallet-identity.js +14 -0
  54. package/dist/src/exit-codes.js +54 -10
  55. package/dist/src/neolist.js +93 -9
  56. package/dist/src/neounzip.js +217 -59
  57. package/dist/src/neozip/blockchain.js +18 -18
  58. package/dist/src/neozip/createZip.js +114 -91
  59. package/dist/src/neozip/upgradeZip.js +14 -11
  60. package/dist/src/neozip.js +252 -75
  61. package/dist/src/skills/command.js +256 -0
  62. package/dist/src/skills/locate.js +99 -0
  63. package/dist/src/util/mask.js +34 -0
  64. package/dist/src/util/token-service-fetch.js +26 -0
  65. package/env.example +18 -85
  66. package/package.json +89 -82
  67. package/skills/neozip-connect/SKILL.md +95 -0
  68. package/skills/neozip-create/SKILL.md +57 -0
  69. package/skills/neozip-extract/SKILL.md +58 -0
  70. package/skills/neozip-legacy/SKILL.md +48 -0
  71. package/skills/neozip-list/SKILL.md +56 -0
  72. package/skills/neozip-shared/SKILL.md +60 -0
  73. package/dist/src/commands/verifyEmail.js +0 -146
  74. package/dist/src/config/ConfigStore.js +0 -406
@@ -1,9 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * ConfigSetup - Interactive setup wizard for NeoZip configuration
4
- * Provides CLI interface for configuring wallet, network, RPC, gas, and debug settings
5
- * This is the presentation layer - handles user interaction and uses ConfigStore for data operations
6
- */
7
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
3
  if (k2 === undefined) k2 = k;
9
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -39,8 +34,13 @@ var __importStar = (this && this.__importStar) || (function () {
39
34
  })();
40
35
  Object.defineProperty(exports, "__esModule", { value: true });
41
36
  exports.ConfigSetup = void 0;
37
+ /**
38
+ * Connection dashboard — replaces wallet.json config menu.
39
+ */
42
40
  const readline = __importStar(require("readline"));
43
- const ConfigStore_1 = require("./ConfigStore");
41
+ const onboarding_1 = require("../connection/onboarding");
42
+ const cli_prefs_1 = require("../connection/cli-prefs");
43
+ const store_1 = require("../connection/store");
44
44
  const neozip_blockchain_1 = require("neozip-blockchain");
45
45
  function resolveScriptPath(jsPath) {
46
46
  if (typeof __filename !== 'undefined' && __filename.endsWith('.ts')) {
@@ -49,436 +49,95 @@ function resolveScriptPath(jsPath) {
49
49
  return jsPath;
50
50
  }
51
51
  class ConfigSetup {
52
- constructor() {
53
- this.rl = readline.createInterface({
54
- input: process.stdin,
55
- output: process.stdout,
56
- });
57
- }
58
- /**
59
- * Prompt for selection from a numbered list
60
- */
61
- async promptSelection(title, options, defaultValue) {
62
- console.log(` ${title}`);
63
- // Display options with numbers
64
- options.forEach((opt, index) => {
65
- const isDefault = opt.value === defaultValue;
66
- const defaultTag = isDefault ? ' [DEFAULT]' : '';
67
- const description = opt.description ? ` - ${opt.description}` : '';
68
- console.log(` ${index + 1}. ${opt.label}${description}${defaultTag}`);
69
- });
70
- // Get default index
71
- const defaultIndex = defaultValue
72
- ? options.findIndex(opt => opt.value === defaultValue) + 1
73
- : 1;
74
- const answer = await this.prompt(' Enter choice', defaultIndex.toString());
75
- const choice = parseInt(answer);
76
- if (isNaN(choice) || choice < 1 || choice > options.length) {
77
- console.error(` ❌ Invalid choice. Please select 1-${options.length}`);
78
- return defaultValue || options[0].value;
79
- }
80
- return options[choice - 1].value;
81
- }
82
- /**
83
- * Prompt for a value with validation
84
- */
85
- async prompt(question, defaultValue, isPassword = false) {
86
- return new Promise((resolve) => {
87
- const displayQuestion = defaultValue
88
- ? `${question} (${defaultValue}): `
89
- : `${question}: `;
90
- if (isPassword) {
91
- // For password input, use readline with line clearing for security
92
- this.rl.question(displayQuestion, (answer) => {
93
- // Clear the line to hide the password from terminal history
94
- readline.clearLine(process.stdout, 0);
95
- readline.cursorTo(process.stdout, 0);
96
- process.stdout.write(question.split(':')[0] + ': ********\n');
97
- resolve(answer.trim() || defaultValue || '');
98
- });
99
- }
100
- else {
101
- this.rl.question(displayQuestion, (answer) => {
102
- resolve(answer.trim() || defaultValue || '');
103
- });
104
- }
105
- });
106
- }
107
- /**
108
- * Run the interactive setup wizard
109
- */
110
- async run() {
111
- console.log('\n🔧 NeoZip Wallet Configuration Setup\n');
112
- console.log('This wizard will help you configure your blockchain wallet settings.');
113
- console.log('Press Ctrl+C at any time to cancel.\n');
52
+ static async showAndManage() {
53
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
54
+ const question = (prompt) => new Promise((resolve) => rl.question(prompt, (answer) => resolve(answer.trim())));
114
55
  try {
115
- // Load existing config if available
116
- const existingConfig = ConfigStore_1.ConfigStore.load();
117
- const isUpdate = existingConfig !== null;
118
- if (isUpdate) {
119
- console.log('📝 Existing configuration found. You can update individual settings.\n');
120
- }
121
- // 1. Wallet Private Key
122
- console.log('1️⃣ Wallet Configuration');
123
- console.log(' Your private key is required for blockchain operations (minting, OTS).');
124
- let privateKey;
125
- if (isUpdate && existingConfig?.wallet?.privateKey) {
126
- const masked = `${existingConfig.wallet.privateKey.substring(0, 6)}...${existingConfig.wallet.privateKey.substring(existingConfig.wallet.privateKey.length - 4)}`;
127
- const keep = await this.promptSelection(`Keep existing private key (${masked})?`, [
128
- { value: 'y', label: 'Yes', description: 'Keep current key' },
129
- { value: 'n', label: 'No', description: 'Enter new key' }
130
- ], 'y');
131
- if (keep === 'y') {
132
- privateKey = existingConfig.wallet.privateKey;
133
- }
134
- else {
135
- privateKey = await this.prompt(' Enter wallet private key', '', true);
136
- }
56
+ console.log('\n📋 NeoZip Connection Dashboard');
57
+ console.log(`📁 Store: ${(0, store_1.getConnectionDir)()}\n`);
58
+ const status = await (0, onboarding_1.connectStatus)({ autoMigrate: true, verbose: true });
59
+ if (status.message) {
60
+ console.log(status.message);
137
61
  }
138
- else {
139
- privateKey = await this.prompt(' Enter wallet private key', '', true);
140
- }
141
- // Validate private key
142
- if (privateKey && !ConfigStore_1.ConfigStore.validatePrivateKey(privateKey)) {
143
- console.error('\n❌ Invalid private key format. Must be 64 hex characters (with or without 0x prefix).');
144
- this.rl.close();
145
- return false;
146
- }
147
- // Ensure 0x prefix
148
- if (privateKey && !privateKey.startsWith('0x')) {
149
- privateKey = `0x${privateKey}`;
150
- }
151
- // 2. Network Selection
152
- console.log('\n2️⃣ Network Selection');
153
- const currentNetwork = existingConfig?.wallet?.network || 'base-sepolia';
154
- // Dynamically build network options from CONTRACT_CONFIGS
155
- // CONTRACT_CONFIGS is already ordered correctly: Base (testnet/mainnet), Arbitrum (testnet/mainnet), Ethereum
156
- const networkOptions = [];
157
- const networkConfigs = Object.values(neozip_blockchain_1.CONTRACT_CONFIGS);
158
- // Verify we're loading networks
159
- if (networkConfigs.length === 0) {
160
- console.error('❌ Error: No networks found in CONTRACT_CONFIGS');
161
- console.error(' This should not happen. Please check the contracts configuration.');
162
- process.exit(1);
163
- }
164
- // Networks are already in the correct order from CONTRACT_CONFIGS (preserved by Object.values())
165
- for (const config of networkConfigs) {
166
- // Use the primary alias (first nameAlias) or network name as value
167
- const primaryAlias = config.nameAliases && config.nameAliases.length > 0
168
- ? config.nameAliases[0]
169
- : (0, neozip_blockchain_1.normalizeNetworkName)(config.network);
170
- // Determine description based on network type
171
- const isTestnet = config.network.toLowerCase().includes('testnet') ||
172
- config.network.toLowerCase().includes('sepolia');
173
- const description = isTestnet
174
- ? `Testnet (Chain ID: ${config.chainId})`
175
- : `Mainnet (Chain ID: ${config.chainId}) - Real ETH required`;
176
- networkOptions.push({
177
- value: primaryAlias,
178
- label: config.network,
179
- description: description
180
- });
181
- }
182
- const network = await this.promptSelection('Choose your blockchain network:', networkOptions, currentNetwork);
183
- // 3. Custom RPC (optional)
184
- console.log('\n3️⃣ RPC Configuration (optional)');
185
- const useCustomRpc = await this.promptSelection('Configure custom RPC endpoints?', [
186
- { value: 'n', label: 'No', description: 'Use default public RPC endpoints' },
187
- { value: 'y', label: 'Yes', description: 'Configure custom RPC URLs' }
188
- ], 'n');
189
- // Build RPC config dynamically from available networks
190
- const rpcConfig = {};
191
- // Preserve existing RPC config (for backward compatibility)
192
- if (existingConfig?.rpc) {
193
- Object.assign(rpcConfig, existingConfig.rpc);
194
- }
195
- if (useCustomRpc === 'y') {
196
- // Get the selected network config to show default RPC
197
- const selectedNetworkConfig = (0, neozip_blockchain_1.getNetworkByName)(network);
198
- // Prompt for RPC URL for the selected network
199
- if (selectedNetworkConfig) {
200
- const defaultRpc = selectedNetworkConfig.rpcUrls && selectedNetworkConfig.rpcUrls.length > 0
201
- ? selectedNetworkConfig.rpcUrls[0]
202
- : '';
203
- // Use primary alias as RPC key for consistency (or normalized network name as fallback)
204
- const rpcKey = (selectedNetworkConfig.nameAliases && selectedNetworkConfig.nameAliases.length > 0)
205
- ? selectedNetworkConfig.nameAliases[0]
206
- : (0, neozip_blockchain_1.normalizeNetworkName)(selectedNetworkConfig.network);
207
- // Check both new format and legacy format for backward compatibility
208
- const existingRpc = rpcConfig[rpcKey]
209
- || rpcConfig[(0, neozip_blockchain_1.normalizeNetworkName)(selectedNetworkConfig.network).replace(/\s+/g, '')]
210
- || existingConfig?.rpc?.[rpcKey]
211
- || existingConfig?.rpc?.[(0, neozip_blockchain_1.normalizeNetworkName)(selectedNetworkConfig.network).replace(/\s+/g, '')];
212
- const customRpc = await this.prompt(` ${selectedNetworkConfig.network} RPC URL`, existingRpc || defaultRpc);
213
- if (customRpc) {
214
- rpcConfig[rpcKey] = customRpc;
215
- }
216
- }
217
- // Optionally configure RPC for other networks
218
- const configureMore = await this.promptSelection('Configure RPC for additional networks?', [
219
- { value: 'n', label: 'No', description: 'Only configure selected network' },
220
- { value: 'y', label: 'Yes', description: 'Configure all networks' }
221
- ], 'n');
222
- if (configureMore === 'y') {
223
- for (const config of networkConfigs) {
224
- // Skip the already configured network
225
- const configAlias = config.nameAliases && config.nameAliases.length > 0
226
- ? config.nameAliases[0]
227
- : (0, neozip_blockchain_1.normalizeNetworkName)(config.network);
228
- if (configAlias === network)
229
- continue;
230
- // Use primary alias as RPC key for consistency (or normalized network name as fallback)
231
- const rpcKey = (config.nameAliases && config.nameAliases.length > 0)
232
- ? config.nameAliases[0]
233
- : (0, neozip_blockchain_1.normalizeNetworkName)(config.network);
234
- const defaultRpc = config.rpcUrls && config.rpcUrls.length > 0
235
- ? config.rpcUrls[0]
236
- : '';
237
- // Check both new format and legacy format for backward compatibility
238
- const existingRpc = rpcConfig[rpcKey]
239
- || rpcConfig[(0, neozip_blockchain_1.normalizeNetworkName)(config.network).replace(/\s+/g, '')]
240
- || existingConfig?.rpc?.[rpcKey]
241
- || existingConfig?.rpc?.[(0, neozip_blockchain_1.normalizeNetworkName)(config.network).replace(/\s+/g, '')];
242
- const customRpc = await this.prompt(` ${config.network} RPC URL`, existingRpc || defaultRpc);
243
- if (customRpc) {
244
- rpcConfig[rpcKey] = customRpc;
245
- }
246
- }
62
+ if (status.accounts?.length) {
63
+ console.log('');
64
+ for (const account of status.accounts) {
65
+ console.log(` ${account.label} ${account.email ?? '(no email)'} — phase ${account.phase}`);
247
66
  }
248
67
  }
249
- // 4. Gas Configuration (optional)
250
- console.log('\n4️⃣ Gas Configuration (optional)');
251
- const configureGas = await this.promptSelection('Configure gas settings?', [
252
- { value: 'n', label: 'No', description: 'Use default gas settings' },
253
- { value: 'y', label: 'Yes', description: 'Configure custom gas limits' }
254
- ], 'n');
255
- let gasMultiplier = existingConfig?.gas?.multiplier;
256
- let maxGasPrice = existingConfig?.gas?.maxPriceGwei;
257
- if (configureGas === 'y') {
258
- const multiplierStr = await this.prompt(' Gas price multiplier', gasMultiplier?.toString() || '1.0');
259
- const maxPriceStr = await this.prompt(' Max gas price (gwei)', maxGasPrice?.toString() || '100');
260
- gasMultiplier = parseFloat(multiplierStr);
261
- maxGasPrice = parseInt(maxPriceStr);
262
- }
263
- // 5. Debug Settings (optional)
264
- console.log('\n5️⃣ Debug Configuration (optional)');
265
- const configureDebug = await this.promptSelection('Enable debug/verbose mode?', [
266
- { value: 'n', label: 'No', description: 'Standard logging only' },
267
- { value: 'y', label: 'Yes', description: 'Enable verbose and debug output' }
268
- ], 'n');
269
- let verbose = existingConfig?.debug?.verbose || false;
270
- let debugEnabled = existingConfig?.debug?.enabled || false;
271
- if (configureDebug === 'y') {
272
- const verboseStr = await this.promptSelection('Enable verbose logging?', [
273
- { value: 'n', label: 'No' },
274
- { value: 'y', label: 'Yes' }
275
- ], verbose ? 'y' : 'n');
276
- const debugStr = await this.promptSelection('Enable debug mode?', [
277
- { value: 'n', label: 'No' },
278
- { value: 'y', label: 'Yes' }
279
- ], debugEnabled ? 'y' : 'n');
280
- verbose = verboseStr === 'y';
281
- debugEnabled = debugStr === 'y';
282
- }
283
- // 6. Zipstamp Email (optional - for timestamped ZIPs)
284
- console.log('\n6️⃣ Zipstamp Email (optional)');
285
- const configureZipstamp = await this.promptSelection('Configure email for Zipstamp timestamping?', [
286
- { value: 'n', label: 'No', description: 'Skip - run neozip verify-email later if needed' },
287
- { value: 'y', label: 'Yes', description: 'Set email (must verify with neozip verify-email)' }
288
- ], 'n');
289
- let zipstampEmail;
290
- if (configureZipstamp === 'y') {
291
- zipstampEmail = await this.prompt(' Zipstamp timestamp email', existingConfig?.zipstamp?.timestampEmail || '');
292
- if (zipstampEmail) {
293
- console.log(' 💡 Run "neozip verify-email" to verify this email before creating timestamped ZIPs.');
68
+ console.log('\nOn-chain preferences:');
69
+ console.log((0, cli_prefs_1.formatCliPreferencesSummary)());
70
+ console.log('');
71
+ console.log('What would you like to do?');
72
+ console.log(' 1. Run connect wizard (neozip connect)');
73
+ console.log(' 2. Change default network');
74
+ console.log(' 3. Set custom RPC URL for a network');
75
+ console.log(' 4. Migrate legacy wallet.json / MCP profiles');
76
+ console.log(' 5. Exit');
77
+ const choice = await question('\nEnter choice (1-5): ');
78
+ rl.close();
79
+ switch (choice) {
80
+ case '1': {
81
+ const { runConnectCommand } = await import(resolveScriptPath('../connect/command.js'));
82
+ const code = await runConnectCommand([]);
83
+ process.exit(code === 0 ? 0 : 1);
84
+ break;
294
85
  }
295
- }
296
- // Build configuration object (preserve existing zipstamp if not configuring)
297
- const zipstampConfig = zipstampEmail !== undefined
298
- ? (zipstampEmail ? { timestampEmail: zipstampEmail } : undefined)
299
- : existingConfig?.zipstamp;
300
- const config = {
301
- wallet: {
302
- privateKey,
303
- network,
304
- },
305
- zipstamp: zipstampConfig,
306
- rpc: Object.keys(rpcConfig).length > 0 ? rpcConfig : undefined,
307
- gas: gasMultiplier || maxGasPrice ? {
308
- multiplier: gasMultiplier,
309
- maxPriceGwei: maxGasPrice,
310
- } : undefined,
311
- debug: verbose || debugEnabled ? {
312
- verbose,
313
- enabled: debugEnabled,
314
- } : undefined,
315
- };
316
- // Save configuration
317
- console.log('\n💾 Saving configuration...');
318
- const saved = ConfigStore_1.ConfigStore.save(config);
319
- if (saved) {
320
- console.log(`✅ Configuration saved to: ${ConfigStore_1.ConfigStore.getConfigPath()}\n`);
321
- console.log('📋 Configuration summary:');
322
- console.log(` Wallet: ${privateKey ? `${privateKey.substring(0, 6)}...${privateKey.substring(privateKey.length - 4)}` : '(not set)'}`);
323
- console.log(` Network: ${network}`);
324
- if (Object.keys(rpcConfig).length > 0) {
325
- console.log(` RPC URLs: Custom (${Object.keys(rpcConfig).length} network(s))`);
86
+ case '2': {
87
+ const networks = (0, neozip_blockchain_1.getSupportedNetworkNames)();
88
+ console.log(`\nSupported networks:\n ${networks.join('\n ')}`);
89
+ const current = (0, cli_prefs_1.getCliPreferences)().defaultNetwork;
90
+ const rl2 = readline.createInterface({ input: process.stdin, output: process.stdout });
91
+ const network = await new Promise((resolve) => {
92
+ rl2.question(`Default network (${current}): `, (answer) => {
93
+ rl2.close();
94
+ resolve(answer.trim() || current);
95
+ });
96
+ });
97
+ const result = (0, cli_prefs_1.setCliPreference)('defaultNetwork', network);
98
+ console.log(result.success ? `✅ Default network set to ${network}` : `❌ ${result.message}`);
99
+ process.exit(result.success ? 0 : 1);
100
+ break;
326
101
  }
327
- if (gasMultiplier || maxGasPrice) {
328
- console.log(` Gas: Custom (${gasMultiplier}x, max ${maxGasPrice} gwei)`);
102
+ case '3': {
103
+ const rl2 = readline.createInterface({ input: process.stdin, output: process.stdout });
104
+ const network = await new Promise((resolve) => {
105
+ rl2.question('Network name (e.g. base-sepolia): ', (answer) => {
106
+ resolve(answer.trim());
107
+ });
108
+ });
109
+ const url = await new Promise((resolve) => {
110
+ rl2.question('RPC URL: ', (answer) => {
111
+ rl2.close();
112
+ resolve(answer.trim());
113
+ });
114
+ });
115
+ const result = (0, cli_prefs_1.setCliPreference)(`rpc.${network}`, url);
116
+ console.log(result.success ? '✅ RPC override saved' : `❌ ${result.message}`);
117
+ process.exit(result.success ? 0 : 1);
118
+ break;
329
119
  }
330
- if (verbose || debugEnabled) {
331
- console.log(` Debug: ${verbose ? 'verbose' : ''} ${debugEnabled ? 'enabled' : ''}`);
120
+ case '4': {
121
+ const { runConnectCommand } = await import(resolveScriptPath('../connect/command.js'));
122
+ const code = await runConnectCommand(['migrate']);
123
+ process.exit(code === 0 ? 0 : 1);
124
+ break;
332
125
  }
333
- console.log('\n💡 You can now use blockchain features: neozip -b <archive> <files>');
334
- console.log('💡 To update config: neozip config show | set | reset\n');
126
+ default:
127
+ process.exit(0);
335
128
  }
336
- this.rl.close();
337
- return saved;
338
129
  }
339
130
  catch (error) {
340
- console.error(`\n❌ Setup failed: ${error}`);
341
- this.rl.close();
342
- return false;
131
+ rl.close();
132
+ console.error(`\n❌ Dashboard error: ${error}`);
133
+ process.exit(1);
343
134
  }
344
135
  }
345
- /**
346
- * Show configuration and offer options to modify or reset
347
- */
348
- static async showAndManage() {
349
- if (!ConfigStore_1.ConfigStore.exists()) {
350
- console.log('\n⚠️ No wallet.json configuration found.');
351
- console.log('💡 Run "neozip init" to create your configuration.\n');
352
- process.exit(0);
353
- }
354
- console.log('\n📋 Current NeoZip Configuration:');
355
- console.log(`📁 Location: ${ConfigStore_1.ConfigStore.getConfigPath()}\n`);
356
- console.log(ConfigStore_1.ConfigStore.getMaskedConfig());
357
- console.log('');
358
- // Create readline interface for menu
359
- const rl = require('readline').createInterface({
360
- input: process.stdin,
361
- output: process.stdout
362
- });
363
- return new Promise((resolve) => {
364
- const showMenu = () => {
365
- const config = ConfigStore_1.ConfigStore.getConfig();
366
- const hasPrivateKey = config.walletKey !== null;
367
- console.log('What would you like to do?');
368
- console.log(' 1. Modify configuration (update settings)');
369
- console.log(' 2. Verify Zipstamp email (for timestamped ZIPs)');
370
- if (hasPrivateKey) {
371
- console.log(' 3. Delete private key (remove wallet key from configuration)');
372
- console.log(' 4. Reset to defaults (delete entire configuration)');
373
- console.log(' 5. Exit');
374
- }
375
- else {
376
- console.log(' 3. Reset to defaults (delete entire configuration)');
377
- console.log(' 4. Exit');
378
- }
379
- const maxChoice = hasPrivateKey ? 5 : 4;
380
- rl.question(`\nEnter choice (1-${maxChoice}): `, async (answer) => {
381
- const choice = parseInt(answer);
382
- switch (choice) {
383
- case 1:
384
- rl.close();
385
- const wizard = new ConfigSetup();
386
- const success = await wizard.run();
387
- process.exit(success ? 0 : 1);
388
- break;
389
- case 2:
390
- rl.close();
391
- const { runVerifyEmail } = await import(resolveScriptPath('../commands/verifyEmail.js'));
392
- const verifySuccess = await runVerifyEmail();
393
- process.exit(verifySuccess ? 0 : 1);
394
- break;
395
- case 3:
396
- if (hasPrivateKey) {
397
- // Delete private key only
398
- rl.question('\n⚠️ Are you sure you want to delete your private key? (y/n): ', (confirm) => {
399
- if (confirm.toLowerCase() === 'y') {
400
- const success = ConfigStore_1.ConfigStore.delete('wallet.privateKey');
401
- if (success) {
402
- console.log('✅ Private key deleted successfully.\n');
403
- }
404
- else {
405
- console.log('❌ Failed to delete private key.\n');
406
- }
407
- rl.close();
408
- process.exit(success ? 0 : 1);
409
- }
410
- else {
411
- console.log('❌ Deletion cancelled.\n');
412
- rl.close();
413
- process.exit(0);
414
- }
415
- });
416
- }
417
- else {
418
- // Reset entire config
419
- rl.question('\n⚠️ Are you sure you want to delete your wallet configuration? (y/n): ', (confirm) => {
420
- if (confirm.toLowerCase() === 'y') {
421
- const success = ConfigStore_1.ConfigStore.reset();
422
- if (success) {
423
- console.log('✅ Configuration deleted successfully.\n');
424
- }
425
- rl.close();
426
- process.exit(success ? 0 : 1);
427
- }
428
- else {
429
- console.log('❌ Reset cancelled.\n');
430
- rl.close();
431
- process.exit(0);
432
- }
433
- });
434
- }
435
- break;
436
- case 4:
437
- if (hasPrivateKey) {
438
- // Reset entire config
439
- rl.question('\n⚠️ Are you sure you want to delete your wallet configuration? (y/n): ', (confirm) => {
440
- if (confirm.toLowerCase() === 'y') {
441
- const success = ConfigStore_1.ConfigStore.reset();
442
- if (success) {
443
- console.log('✅ Configuration deleted successfully.\n');
444
- }
445
- rl.close();
446
- process.exit(success ? 0 : 1);
447
- }
448
- else {
449
- console.log('❌ Reset cancelled.\n');
450
- rl.close();
451
- process.exit(0);
452
- }
453
- });
454
- }
455
- else {
456
- // Exit
457
- console.log('');
458
- rl.close();
459
- process.exit(0);
460
- }
461
- break;
462
- case 5:
463
- if (hasPrivateKey) {
464
- // Exit
465
- console.log('');
466
- rl.close();
467
- process.exit(0);
468
- }
469
- else {
470
- console.log(`\n❌ Invalid choice. Please select 1-${maxChoice}.\n`);
471
- showMenu();
472
- }
473
- break;
474
- default:
475
- console.log(`\n❌ Invalid choice. Please select 1-${maxChoice}.\n`);
476
- showMenu();
477
- }
478
- });
479
- };
480
- showMenu();
481
- });
136
+ /** @deprecated init is now neozip connect */
137
+ static async run() {
138
+ const { runConnectCommand } = await import(resolveScriptPath('../connect/command.js'));
139
+ const code = await runConnectCommand([]);
140
+ return code === 0;
482
141
  }
483
142
  }
484
143
  exports.ConfigSetup = ConfigSetup;