neozip-cli 0.70.0-alpha → 0.75.1-beta
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/README.md +12 -12
- package/dist/neozipkit-bundles/blockchain.js +1491 -857
- package/dist/neozipkit-bundles/browser.js +755 -302
- package/dist/neozipkit-bundles/core.js +235 -162
- package/dist/neozipkit-bundles/{server.js → node.js} +4415 -1681
- package/dist/neozipkit-wrappers/index.js +2 -2
- package/dist/neozipkit-wrappers/node/index.js +2 -0
- package/dist/src/config/ConfigSetup.js +11 -11
- package/dist/src/config/ConfigStore.js +3 -3
- package/dist/src/neolist.js +10 -10
- package/dist/src/neounzip.js +50 -70
- package/dist/src/neozip/blockchain.js +12 -8
- package/dist/src/neozip/createZip.js +84 -69
- package/dist/src/neozip/file-operations.js +13 -9
- package/dist/src/neozip/user-interaction.js +13 -3
- package/dist/src/neozip.js +3 -3
- package/package.json +7 -8
- package/dist/neozipkit-wrappers/server/index.js +0 -2
- package/dist/src/config/ConfigWizard.js +0 -453
- package/dist/src/config/WalletConfig.js +0 -372
- package/dist/src/server/CommentManager.js +0 -240
|
@@ -44,12 +44,9 @@ exports.testArchiveIntegrity = testArchiveIntegrity;
|
|
|
44
44
|
exports.upgradeZipForTokenization = upgradeZipForTokenization;
|
|
45
45
|
const fs = __importStar(require("fs"));
|
|
46
46
|
const path = __importStar(require("path"));
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const blockchain_1 = require('../../neozipkit-wrappers/blockchain');
|
|
51
|
-
const contracts_1 = require('../../neozipkit-wrappers/blockchain/core/contracts');
|
|
52
|
-
const HashCalculator_1 = __importDefault(require('../../neozipkit-wrappers/core/components/HashCalculator'));
|
|
47
|
+
const neozipkit_1 = require("neozipkit");
|
|
48
|
+
const node_1 = __importDefault(require("neozipkit/node"));
|
|
49
|
+
const blockchain_1 = require("neozipkit/blockchain");
|
|
53
50
|
const CommentManager_1 = require("./CommentManager");
|
|
54
51
|
const utils_1 = require("./utils");
|
|
55
52
|
const file_operations_1 = require("./file-operations");
|
|
@@ -255,15 +252,15 @@ class ZipCreator {
|
|
|
255
252
|
this.fdCache = new Map();
|
|
256
253
|
this.compressionOffset = 0;
|
|
257
254
|
this.centralDirOffset = 0;
|
|
258
|
-
this.zip = new
|
|
255
|
+
this.zip = new node_1.default(); // Use ZipkitNode for ZIP operations
|
|
259
256
|
// Initialize HashAccumulator if blockchain features are enabled
|
|
260
257
|
if (this.options.blockchain || this.options.blockchainOts) {
|
|
261
|
-
this.hashAccumulator = new
|
|
258
|
+
this.hashAccumulator = new neozipkit_1.HashCalculator({ enableAccumulation: true });
|
|
262
259
|
}
|
|
263
260
|
}
|
|
264
261
|
/**
|
|
265
262
|
* Initialize the output file stream for direct writing
|
|
266
|
-
* Uses
|
|
263
|
+
* Uses ZipkitNode's initializeZipFile() method
|
|
267
264
|
* Always writes to temporary file first for atomic operations
|
|
268
265
|
*/
|
|
269
266
|
async initializeOutput() {
|
|
@@ -322,7 +319,7 @@ class ZipCreator {
|
|
|
322
319
|
}
|
|
323
320
|
/**
|
|
324
321
|
* Close the output stream and file descriptor
|
|
325
|
-
* Uses
|
|
322
|
+
* Uses ZipkitNode's finalizeZipFile() method
|
|
326
323
|
*/
|
|
327
324
|
async closeOutput() {
|
|
328
325
|
if (this.zipWriter) {
|
|
@@ -565,7 +562,8 @@ class ZipCreator {
|
|
|
565
562
|
const existingData = await (async () => {
|
|
566
563
|
try {
|
|
567
564
|
const buf = fs.readFileSync(this.archiveName);
|
|
568
|
-
const
|
|
565
|
+
const { default: Zipkit } = require('neozipkit');
|
|
566
|
+
const kit = new Zipkit();
|
|
569
567
|
kit.loadZip(buf);
|
|
570
568
|
return await kit.extract(existingEntry);
|
|
571
569
|
}
|
|
@@ -828,8 +826,8 @@ class ZipCreator {
|
|
|
828
826
|
// In-memory mode: use compressFileBuffer with BufferOutputWriter
|
|
829
827
|
(0, utils_1.log)(`🔧 Using in-memory compression (browser compatible)`, this.options);
|
|
830
828
|
(0, utils_1.log)(`🔄 Compressing ${zipEntries.length} files in memory...`, this.options);
|
|
831
|
-
// Create
|
|
832
|
-
const zipkit = new
|
|
829
|
+
// Create ZipkitNode instance for buffer-based compression
|
|
830
|
+
const zipkit = new node_1.default();
|
|
833
831
|
// Determine if we need to write to file (for blockchain mode)
|
|
834
832
|
const writeToFile = this.options.blockchain || this.options.blockchainOts;
|
|
835
833
|
// Create appropriate output writer
|
|
@@ -913,9 +911,9 @@ class ZipCreator {
|
|
|
913
911
|
if (this.hashAccumulator && entry.sha256) {
|
|
914
912
|
const filename = entry.filename || '';
|
|
915
913
|
// Skip blockchain metadata files
|
|
916
|
-
if (filename !==
|
|
917
|
-
filename !==
|
|
918
|
-
filename !==
|
|
914
|
+
if (filename !== neozipkit_1.TOKENIZED_METADATA &&
|
|
915
|
+
filename !== neozipkit_1.TIMESTAMP_METADATA &&
|
|
916
|
+
filename !== neozipkit_1.TIMESTAMP_SUBMITTED) {
|
|
919
917
|
const hashBuffer = Buffer.from(entry.sha256, 'hex');
|
|
920
918
|
this.hashAccumulator.addHash(hashBuffer);
|
|
921
919
|
if (this.options.verbose) {
|
|
@@ -957,7 +955,7 @@ class ZipCreator {
|
|
|
957
955
|
return writer.getPosition();
|
|
958
956
|
}
|
|
959
957
|
else {
|
|
960
|
-
// File-based mode: use
|
|
958
|
+
// File-based mode: use ZipkitNode's writeZipEntry() method
|
|
961
959
|
// Get entries to compress from zip.getDirectory() (populated by processFiles())
|
|
962
960
|
const zipEntries = this.zip.getDirectory().length > 0 ? this.zip.getDirectory() : await this.zip.getDirectory() || [];
|
|
963
961
|
if (zipEntries.length === 0) {
|
|
@@ -980,9 +978,9 @@ class ZipCreator {
|
|
|
980
978
|
for (let index = 0; index < entryCnt; index++) {
|
|
981
979
|
const entry = zipEntries[index];
|
|
982
980
|
// Filter out metadata entries (handled separately in handleTokenization)
|
|
983
|
-
if (entry.filename ===
|
|
984
|
-
entry.filename ===
|
|
985
|
-
entry.filename ===
|
|
981
|
+
if (entry.filename === neozipkit_1.TOKENIZED_METADATA ||
|
|
982
|
+
entry.filename === neozipkit_1.TIMESTAMP_METADATA ||
|
|
983
|
+
entry.filename === neozipkit_1.TIMESTAMP_SUBMITTED) {
|
|
986
984
|
zipEntries.splice(index, 1);
|
|
987
985
|
entryCnt--;
|
|
988
986
|
index--;
|
|
@@ -1027,7 +1025,7 @@ class ZipCreator {
|
|
|
1027
1025
|
if (fileBuffer) {
|
|
1028
1026
|
// For pre-loaded buffers, compress in memory and write manually
|
|
1029
1027
|
// This handles symlinks, hardlinks, and line-ending conversion
|
|
1030
|
-
const zipkit = new
|
|
1028
|
+
const zipkit = new node_1.default();
|
|
1031
1029
|
const cmpData = await zipkit.compressData(entry, fileBuffer, cmpOptions);
|
|
1032
1030
|
// Write header manually
|
|
1033
1031
|
entry.compressedSize = 0; // Placeholder
|
|
@@ -1061,9 +1059,9 @@ class ZipCreator {
|
|
|
1061
1059
|
if (this.hashAccumulator) {
|
|
1062
1060
|
const filename = entry.filename || '';
|
|
1063
1061
|
// Skip blockchain metadata files
|
|
1064
|
-
if (filename !==
|
|
1065
|
-
filename !==
|
|
1066
|
-
filename !==
|
|
1062
|
+
if (filename !== neozipkit_1.TOKENIZED_METADATA &&
|
|
1063
|
+
filename !== neozipkit_1.TIMESTAMP_METADATA &&
|
|
1064
|
+
filename !== neozipkit_1.TIMESTAMP_SUBMITTED) {
|
|
1067
1065
|
this.hashAccumulator.addHash(hash);
|
|
1068
1066
|
if (this.options.verbose) {
|
|
1069
1067
|
(0, utils_1.logDebug)(`Added SHA-256 hash to accumulator for ${filename}`, this.options);
|
|
@@ -1112,7 +1110,7 @@ class ZipCreator {
|
|
|
1112
1110
|
tokenEntry.compressedSize = tokenBuffer.length;
|
|
1113
1111
|
tokenEntry.uncompressedSize = tokenBuffer.length;
|
|
1114
1112
|
tokenEntry.cmpMethod = 0; // STORED (no compression for small metadata file)
|
|
1115
|
-
tokenEntry.crc = (0,
|
|
1113
|
+
tokenEntry.crc = (0, neozipkit_1.crc32)(tokenBuffer);
|
|
1116
1114
|
// Use current file position for local header offset (not compressionOffset)
|
|
1117
1115
|
tokenEntry.localHdrOffset = this.currentPosition;
|
|
1118
1116
|
// Track entry position for central directory
|
|
@@ -1137,13 +1135,13 @@ class ZipCreator {
|
|
|
1137
1135
|
if (!entries || entries.length === 0) {
|
|
1138
1136
|
return null;
|
|
1139
1137
|
}
|
|
1140
|
-
const hashAccumulator = new
|
|
1138
|
+
const hashAccumulator = new neozipkit_1.HashCalculator({ enableAccumulation: true });
|
|
1141
1139
|
// Filter out blockchain metadata files to ensure consistent Merkle Root calculation
|
|
1142
1140
|
const contentEntries = entries.filter(entry => {
|
|
1143
1141
|
const filename = entry.filename || '';
|
|
1144
|
-
return filename !==
|
|
1145
|
-
filename !==
|
|
1146
|
-
filename !==
|
|
1142
|
+
return filename !== neozipkit_1.TOKENIZED_METADATA &&
|
|
1143
|
+
filename !== neozipkit_1.TIMESTAMP_METADATA &&
|
|
1144
|
+
filename !== neozipkit_1.TIMESTAMP_SUBMITTED;
|
|
1147
1145
|
});
|
|
1148
1146
|
// Add SHA-256 hashes to accumulator
|
|
1149
1147
|
for (const entry of contentEntries) {
|
|
@@ -1232,7 +1230,7 @@ class ZipCreator {
|
|
|
1232
1230
|
try {
|
|
1233
1231
|
if (fs.existsSync(this.archiveName)) {
|
|
1234
1232
|
// Load the ZIP file to get entries with SHA-256 hashes
|
|
1235
|
-
const zipkit = new
|
|
1233
|
+
const zipkit = new node_1.default();
|
|
1236
1234
|
if (this.options.inMemory) {
|
|
1237
1235
|
// For in-memory mode, load as buffer
|
|
1238
1236
|
const zipBuffer = fs.readFileSync(this.archiveName);
|
|
@@ -1277,8 +1275,33 @@ class ZipCreator {
|
|
|
1277
1275
|
const network = this.options.network || 'base-sepolia';
|
|
1278
1276
|
// Always display network when tokenization is enabled
|
|
1279
1277
|
console.log(`🌐 Network: ${network}`);
|
|
1278
|
+
// Get network config for contract address and version info
|
|
1279
|
+
const networkConfig = (0, blockchain_1.getNetworkByName)(network);
|
|
1280
|
+
let contractAddress;
|
|
1281
|
+
let networkChainId;
|
|
1282
|
+
let contractVersion;
|
|
1283
|
+
if (networkConfig) {
|
|
1284
|
+
contractAddress = networkConfig.address;
|
|
1285
|
+
networkChainId = networkConfig.chainId;
|
|
1286
|
+
// Determine contract version: v2.11+ has version in config, prior versions are "unknown"
|
|
1287
|
+
const versionStr = networkConfig.version || '0';
|
|
1288
|
+
const versionNum = parseFloat(versionStr);
|
|
1289
|
+
contractVersion = versionNum >= 2.11 ? versionStr : 'unknown';
|
|
1290
|
+
}
|
|
1291
|
+
else {
|
|
1292
|
+
// Fallback to default (Base Sepolia)
|
|
1293
|
+
const defaultConfig = (0, blockchain_1.getContractConfig)(84532);
|
|
1294
|
+
contractAddress = defaultConfig.address;
|
|
1295
|
+
networkChainId = defaultConfig.chainId;
|
|
1296
|
+
const versionStr = defaultConfig.version || '0';
|
|
1297
|
+
const versionNum = parseFloat(versionStr);
|
|
1298
|
+
contractVersion = versionNum >= 2.11 ? versionStr : 'unknown';
|
|
1299
|
+
}
|
|
1300
|
+
// Display contract address and version right after network
|
|
1301
|
+
console.log(`📄 Contract: ${contractAddress}`);
|
|
1302
|
+
console.log(`🔢 Version: ${contractVersion}`);
|
|
1280
1303
|
if (!(0, blockchain_2.isSupportedNetwork)(network)) {
|
|
1281
|
-
const supportedNetworks = (0,
|
|
1304
|
+
const supportedNetworks = (0, blockchain_1.getSupportedNetworkNames)();
|
|
1282
1305
|
console.error(`❌ Error: Unsupported network: ${network}`);
|
|
1283
1306
|
console.error(` Currently supported networks: ${supportedNetworks.join(', ')}`);
|
|
1284
1307
|
(0, exit_codes_1.exitZip)(exit_codes_1.ZIP_EXIT_CODES.BLOCKCHAIN_CONFIG_ERROR);
|
|
@@ -1286,7 +1309,7 @@ class ZipCreator {
|
|
|
1286
1309
|
let minter = null;
|
|
1287
1310
|
try {
|
|
1288
1311
|
// Initialize blockchain minter
|
|
1289
|
-
minter = new
|
|
1312
|
+
minter = new neozipkit_1.ZipkitMinter(merkleRoot, {
|
|
1290
1313
|
network: network,
|
|
1291
1314
|
walletPrivateKey: this.options.walletPasskey,
|
|
1292
1315
|
verbose: this.options.verbose,
|
|
@@ -1300,6 +1323,7 @@ class ZipCreator {
|
|
|
1300
1323
|
]);
|
|
1301
1324
|
console.log(`💳 Wallet: ${processResult.walletInfo.address}`);
|
|
1302
1325
|
console.log(`💰 Balance: ${processResult.walletInfo.balance} ETH`);
|
|
1326
|
+
// Network config already retrieved above (contractAddress and networkChainId are available)
|
|
1303
1327
|
// Check if tokens already exist for this merkle root
|
|
1304
1328
|
if (processResult.duplicateCheck.hasExistingTokens) {
|
|
1305
1329
|
let userChoice;
|
|
@@ -1324,34 +1348,25 @@ class ZipCreator {
|
|
|
1324
1348
|
}
|
|
1325
1349
|
else {
|
|
1326
1350
|
// Present user with choices (interactive mode)
|
|
1327
|
-
userChoice = await (0, user_interaction_1.getUserTokenChoice)(processResult.duplicateCheck
|
|
1351
|
+
userChoice = await (0, user_interaction_1.getUserTokenChoice)(processResult.duplicateCheck, {
|
|
1352
|
+
contractAddress,
|
|
1353
|
+
version: contractVersion
|
|
1354
|
+
});
|
|
1328
1355
|
}
|
|
1329
1356
|
if (userChoice.action === 'use-existing' && userChoice.selectedToken) {
|
|
1330
1357
|
console.log(`\n✅ Using existing token ID ${userChoice.selectedToken.tokenId}`);
|
|
1331
1358
|
// Create TokenMetadata from selected existing token
|
|
1332
1359
|
// Use a fixed timestamp for existing tokens to ensure consistency
|
|
1333
|
-
//
|
|
1334
|
-
const networkConfig = (0, contracts_1.getNetworkByName)(network);
|
|
1335
|
-
let contractAddress;
|
|
1336
|
-
let networkChainId;
|
|
1337
|
-
if (networkConfig) {
|
|
1338
|
-
contractAddress = networkConfig.address;
|
|
1339
|
-
networkChainId = networkConfig.chainId;
|
|
1340
|
-
}
|
|
1341
|
-
else {
|
|
1342
|
-
// Fallback to default (Base Sepolia)
|
|
1343
|
-
const defaultConfig = (0, contracts_1.getContractConfig)(84532);
|
|
1344
|
-
contractAddress = defaultConfig.address;
|
|
1345
|
-
networkChainId = defaultConfig.chainId;
|
|
1346
|
-
}
|
|
1360
|
+
// Network config already retrieved above
|
|
1347
1361
|
tokenMeta = {
|
|
1348
|
-
|
|
1362
|
+
contractVersion: contractVersion,
|
|
1349
1363
|
tokenId: userChoice.selectedToken.tokenId,
|
|
1350
1364
|
contractAddress: contractAddress,
|
|
1351
1365
|
network: processResult.walletInfo.networkName,
|
|
1352
1366
|
networkChainId: networkChainId,
|
|
1353
1367
|
transactionHash: userChoice.selectedToken.tokenData?.transactionHash || '',
|
|
1354
1368
|
merkleRoot: merkleRoot,
|
|
1369
|
+
encryptedHash: undefined, // Currently unused
|
|
1355
1370
|
mintedAt: '2025-01-01T00:00:00.000Z' // Fixed timestamp for existing tokens
|
|
1356
1371
|
};
|
|
1357
1372
|
// Add token metadata to ZIP (after compression, at the end)
|
|
@@ -1480,7 +1495,7 @@ class ZipCreator {
|
|
|
1480
1495
|
try {
|
|
1481
1496
|
if (fs.existsSync(this.archiveName)) {
|
|
1482
1497
|
// Load the ZIP file to get entries with SHA-256 hashes
|
|
1483
|
-
const zipkit = new
|
|
1498
|
+
const zipkit = new node_1.default();
|
|
1484
1499
|
if (this.options.inMemory) {
|
|
1485
1500
|
// For in-memory mode, load as buffer
|
|
1486
1501
|
const zipBuffer = fs.readFileSync(this.archiveName);
|
|
@@ -1522,7 +1537,7 @@ class ZipCreator {
|
|
|
1522
1537
|
console.log(`📋 Merkle Root: ${merkleRoot}`);
|
|
1523
1538
|
// Create actual OpenTimestamp proof
|
|
1524
1539
|
try {
|
|
1525
|
-
const otsProof = await (0,
|
|
1540
|
+
const otsProof = await (0, neozipkit_1.createTimestamp)(merkleRoot, { debug: this.options.verbose });
|
|
1526
1541
|
if (!otsProof) {
|
|
1527
1542
|
throw new Error('Failed to create OpenTimestamp proof');
|
|
1528
1543
|
}
|
|
@@ -1531,7 +1546,7 @@ class ZipCreator {
|
|
|
1531
1546
|
const metaEntry = (0, blockchain_1.createOtsMetadataEntry)(this.zip, otsProof);
|
|
1532
1547
|
if (metaEntry) {
|
|
1533
1548
|
// Ensure the filename is set correctly
|
|
1534
|
-
metaEntry.filename =
|
|
1549
|
+
metaEntry.filename = neozipkit_1.TIMESTAMP_SUBMITTED;
|
|
1535
1550
|
// Ensure OTS entry uses STORED compression (no compression for small metadata file)
|
|
1536
1551
|
metaEntry.cmpMethod = 0; // STORED
|
|
1537
1552
|
metaEntry.compressedSize = metaEntry.fileBuffer?.length || metaEntry.uncompressedSize || 0;
|
|
@@ -1634,7 +1649,7 @@ class ZipCreator {
|
|
|
1634
1649
|
}
|
|
1635
1650
|
}
|
|
1636
1651
|
// For file-based mode or in-memory blockchain mode, write central directory to file
|
|
1637
|
-
// Use
|
|
1652
|
+
// Use ZipkitNode's writeCentralDirectory() and writeEndOfCentralDirectory() methods
|
|
1638
1653
|
if (!this.zipWriter) {
|
|
1639
1654
|
throw new Error('ZIP writer not initialized for finalization');
|
|
1640
1655
|
}
|
|
@@ -1653,7 +1668,7 @@ class ZipCreator {
|
|
|
1653
1668
|
// Update mode - get entries from loaded ZIP
|
|
1654
1669
|
zipEntries = await this.zip.getDirectory() || [];
|
|
1655
1670
|
}
|
|
1656
|
-
// Write central directory using
|
|
1671
|
+
// Write central directory using ZipkitNode method
|
|
1657
1672
|
const centralDirOffset = this.zipWriter.currentPosition;
|
|
1658
1673
|
if (this.options.verbose) {
|
|
1659
1674
|
(0, utils_1.log)(`📊 Central directory starts at offset: ${centralDirOffset}`, this.options);
|
|
@@ -1670,7 +1685,7 @@ class ZipCreator {
|
|
|
1670
1685
|
});
|
|
1671
1686
|
// Update currentPosition from zipWriter
|
|
1672
1687
|
this.currentPosition = this.zipWriter.currentPosition;
|
|
1673
|
-
// Write end of central directory using
|
|
1688
|
+
// Write end of central directory using ZipkitNode method
|
|
1674
1689
|
if (this.options.verbose) {
|
|
1675
1690
|
(0, utils_1.log)(`📝 Writing end of central directory`, this.options);
|
|
1676
1691
|
(0, utils_1.log)(`📊 Central directory size: ${centralDirSize} bytes`, this.options);
|
|
@@ -1887,7 +1902,7 @@ async function upgradeZipForTokenization(inputZipPath, options) {
|
|
|
1887
1902
|
}
|
|
1888
1903
|
const tempOutputPath = path.join(tempDir, `${path.basename(outputZipPath)}.tmp.${Date.now()}`);
|
|
1889
1904
|
// Load existing ZIP
|
|
1890
|
-
const sourceZip = new
|
|
1905
|
+
const sourceZip = new node_1.default();
|
|
1891
1906
|
await sourceZip.loadZipFile(inputZipPath);
|
|
1892
1907
|
const entries = await sourceZip.getDirectory();
|
|
1893
1908
|
if (!entries || entries.length === 0) {
|
|
@@ -1895,21 +1910,21 @@ async function upgradeZipForTokenization(inputZipPath, options) {
|
|
|
1895
1910
|
}
|
|
1896
1911
|
(0, utils_1.log)(` Found ${entries.length} entries in ZIP`, options);
|
|
1897
1912
|
// Check for existing token metadata (ignore per requirement 3a)
|
|
1898
|
-
const hasTokenMetadata = entries.some((e) => e.filename ===
|
|
1913
|
+
const hasTokenMetadata = entries.some((e) => e.filename === neozipkit_1.TOKENIZED_METADATA);
|
|
1899
1914
|
if (hasTokenMetadata && options.verbose) {
|
|
1900
1915
|
(0, utils_1.log)(` Note: ZIP already contains token metadata (will create new token)`, options);
|
|
1901
1916
|
}
|
|
1902
1917
|
// Process entries: extract if missing SHA-256, calculate hash, preserve compression
|
|
1903
1918
|
const processedEntries = [];
|
|
1904
|
-
const hashAccumulator = new
|
|
1919
|
+
const hashAccumulator = new neozipkit_1.HashCalculator({ enableAccumulation: true });
|
|
1905
1920
|
let tempFiles = [];
|
|
1906
1921
|
try {
|
|
1907
1922
|
for (const entry of entries) {
|
|
1908
1923
|
const filename = entry.filename || '';
|
|
1909
1924
|
// Skip metadata entries and directories
|
|
1910
|
-
if (filename ===
|
|
1911
|
-
filename ===
|
|
1912
|
-
filename ===
|
|
1925
|
+
if (filename === neozipkit_1.TOKENIZED_METADATA ||
|
|
1926
|
+
filename === neozipkit_1.TIMESTAMP_METADATA ||
|
|
1927
|
+
filename === neozipkit_1.TIMESTAMP_SUBMITTED ||
|
|
1913
1928
|
entry.isDirectory) {
|
|
1914
1929
|
continue;
|
|
1915
1930
|
}
|
|
@@ -1951,7 +1966,7 @@ async function upgradeZipForTokenization(inputZipPath, options) {
|
|
|
1951
1966
|
(0, exit_codes_1.exitZip)(exit_codes_1.ZIP_EXIT_CODES.READ_ERROR, `Error: Failed to extract entry "${filename}": ${errorMsg}`);
|
|
1952
1967
|
}
|
|
1953
1968
|
// Calculate SHA-256 hash
|
|
1954
|
-
const hashHex = (0,
|
|
1969
|
+
const hashHex = (0, neozipkit_1.sha256)(uncompressedData);
|
|
1955
1970
|
entry.sha256 = hashHex;
|
|
1956
1971
|
if (options.verbose) {
|
|
1957
1972
|
(0, utils_1.log)(` SHA-256: ${hashHex.substring(0, 16)}...`, options);
|
|
@@ -2006,14 +2021,14 @@ async function upgradeZipForTokenization(inputZipPath, options) {
|
|
|
2006
2021
|
(0, utils_1.log)(` Calculated merkle root: ${merkleRoot.substring(0, 16)}...`, options);
|
|
2007
2022
|
// Rebuild ZIP with updated entries (write to temp file first for atomic operation)
|
|
2008
2023
|
(0, utils_1.log)(` Rebuilding ZIP with updated entries...`, options);
|
|
2009
|
-
const outputZip = new
|
|
2024
|
+
const outputZip = new node_1.default();
|
|
2010
2025
|
const writer = await outputZip.initializeZipFile(tempOutputPath);
|
|
2011
2026
|
try {
|
|
2012
2027
|
let currentOffset = 0;
|
|
2013
2028
|
// Write all entries with updated SHA-256 hashes
|
|
2014
2029
|
for (const { entry, compressedData } of processedEntries) {
|
|
2015
2030
|
// Create new entry with same properties but updated SHA-256
|
|
2016
|
-
const newEntry = new
|
|
2031
|
+
const newEntry = new neozipkit_1.ZipEntry(entry.filename || '', null, false);
|
|
2017
2032
|
Object.assign(newEntry, {
|
|
2018
2033
|
filename: entry.filename,
|
|
2019
2034
|
cmpMethod: entry.cmpMethod,
|
|
@@ -2106,27 +2121,27 @@ async function upgradeZipForTokenization(inputZipPath, options) {
|
|
|
2106
2121
|
if (!(0, blockchain_2.isSupportedNetwork)(network)) {
|
|
2107
2122
|
(0, exit_codes_1.exitZip)(exit_codes_1.ZIP_EXIT_CODES.BLOCKCHAIN_CONFIG_ERROR, `Error: Unsupported network: ${network}`);
|
|
2108
2123
|
}
|
|
2109
|
-
const minter = new
|
|
2124
|
+
const minter = new neozipkit_1.ZipkitMinter(merkleRoot, {
|
|
2110
2125
|
network,
|
|
2111
2126
|
walletPrivateKey: walletPasskey,
|
|
2112
2127
|
verbose: options.verbose,
|
|
2113
2128
|
debug: options.debug,
|
|
2114
2129
|
rpcUrlIndex: 0
|
|
2115
2130
|
});
|
|
2116
|
-
// Create a temporary
|
|
2131
|
+
// Create a temporary ZipkitNode instance for handleTokenMinting
|
|
2117
2132
|
// (it needs a zip instance, but we'll add metadata manually)
|
|
2118
|
-
const tempZip = new
|
|
2133
|
+
const tempZip = new node_1.default();
|
|
2119
2134
|
const mintResult = await (0, blockchain_2.handleTokenMinting)(minter, tempZip, options.nonInteractive || false, 0);
|
|
2120
2135
|
if (mintResult.success && mintResult.tokenInfo) {
|
|
2121
2136
|
// Add token metadata entry before central directory
|
|
2122
2137
|
const tokenContent = JSON.stringify(mintResult.tokenInfo, null, 2);
|
|
2123
2138
|
const tokenBuffer = Buffer.from(tokenContent, 'utf8');
|
|
2124
|
-
const tokenEntry = new
|
|
2139
|
+
const tokenEntry = new neozipkit_1.ZipEntry(neozipkit_1.TOKENIZED_METADATA, null, false);
|
|
2125
2140
|
tokenEntry.timeDateDOS = tokenEntry.setDateTime(new Date());
|
|
2126
2141
|
tokenEntry.compressedSize = tokenBuffer.length;
|
|
2127
2142
|
tokenEntry.uncompressedSize = tokenBuffer.length;
|
|
2128
2143
|
tokenEntry.cmpMethod = 0; // STORED
|
|
2129
|
-
tokenEntry.crc = (0,
|
|
2144
|
+
tokenEntry.crc = (0, neozipkit_1.crc32)(tokenBuffer);
|
|
2130
2145
|
tokenEntry.localHdrOffset = currentOffset;
|
|
2131
2146
|
// Write token metadata entry
|
|
2132
2147
|
const tokenLocalHeader = tokenEntry.createLocalHdr();
|
|
@@ -2175,7 +2190,7 @@ async function upgradeZipForTokenization(inputZipPath, options) {
|
|
|
2175
2190
|
const finalCentralDirOffset = currentOffset;
|
|
2176
2191
|
let finalCentralDirSize = 0;
|
|
2177
2192
|
for (const { entry } of processedEntries) {
|
|
2178
|
-
const newEntry = new
|
|
2193
|
+
const newEntry = new neozipkit_1.ZipEntry(entry.filename || '', null, false);
|
|
2179
2194
|
Object.assign(newEntry, {
|
|
2180
2195
|
filename: entry.filename,
|
|
2181
2196
|
cmpMethod: entry.cmpMethod,
|
|
@@ -35,6 +35,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
return result;
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
38
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
42
|
exports.shouldUpdateFile = shouldUpdateFile;
|
|
40
43
|
exports.loadExistingArchive = loadExistingArchive;
|
|
@@ -47,8 +50,9 @@ exports.loadExistingArchiveLarge = loadExistingArchiveLarge;
|
|
|
47
50
|
const fs = __importStar(require("fs"));
|
|
48
51
|
const path = __importStar(require("path"));
|
|
49
52
|
const minimatch_1 = require("minimatch");
|
|
50
|
-
const
|
|
51
|
-
const
|
|
53
|
+
const neozipkit_1 = __importDefault(require("neozipkit"));
|
|
54
|
+
const neozipkit_2 = require("neozipkit");
|
|
55
|
+
const node_1 = __importDefault(require("neozipkit/node"));
|
|
52
56
|
const utils_1 = require("./utils");
|
|
53
57
|
const exit_codes_1 = require("../exit-codes");
|
|
54
58
|
/**
|
|
@@ -140,7 +144,7 @@ function loadExistingArchive(archiveName, options) {
|
|
|
140
144
|
}
|
|
141
145
|
// Standard loader (existing code)
|
|
142
146
|
const data = fs.readFileSync(archiveName);
|
|
143
|
-
const zip = new
|
|
147
|
+
const zip = new neozipkit_1.default();
|
|
144
148
|
zip.loadZip(data);
|
|
145
149
|
return zip;
|
|
146
150
|
}
|
|
@@ -456,7 +460,7 @@ async function deleteFromArchive(archiveName, filesToDelete, options) {
|
|
|
456
460
|
try {
|
|
457
461
|
// Read the existing archive
|
|
458
462
|
const zipData = fs.readFileSync(archiveName);
|
|
459
|
-
const zip = new
|
|
463
|
+
const zip = new neozipkit_1.default();
|
|
460
464
|
zip.loadZip(zipData);
|
|
461
465
|
const entries = zip.getDirectory() || [];
|
|
462
466
|
const originalCount = entries.length;
|
|
@@ -497,20 +501,20 @@ async function deleteFromArchive(archiveName, filesToDelete, options) {
|
|
|
497
501
|
return;
|
|
498
502
|
}
|
|
499
503
|
// Create new archive without the deleted files
|
|
500
|
-
const newZip = new
|
|
504
|
+
const newZip = new node_1.default();
|
|
501
505
|
const outParts = [];
|
|
502
506
|
// Build entries list for new archive
|
|
503
507
|
const newEntries = [];
|
|
504
508
|
for (const entry of entries) {
|
|
505
509
|
if (!entriesToDelete.includes(entry.filename)) {
|
|
506
510
|
// Copy entry to new archive
|
|
507
|
-
const newEntry = new
|
|
511
|
+
const newEntry = new neozipkit_2.ZipEntry(entry.filename);
|
|
508
512
|
Object.assign(newEntry, entry);
|
|
509
513
|
// Copy the file data from the existing archive
|
|
510
514
|
try {
|
|
511
515
|
const existingData = await (async () => {
|
|
512
516
|
try {
|
|
513
|
-
const kit = new
|
|
517
|
+
const kit = new node_1.default();
|
|
514
518
|
kit.loadZip(zipData);
|
|
515
519
|
return await kit.extract(entry);
|
|
516
520
|
}
|
|
@@ -711,7 +715,7 @@ function parseCentralDirectoryEntry(data, offset) {
|
|
|
711
715
|
// Convert DOS date/time to JavaScript timestamp
|
|
712
716
|
const modifiedTime = dosDateTimeToTimestamp(lastModDate, lastModTime);
|
|
713
717
|
// Create ZipEntry object
|
|
714
|
-
const entry = new
|
|
718
|
+
const entry = new neozipkit_2.ZipEntry(filename);
|
|
715
719
|
entry.filename = filename;
|
|
716
720
|
entry.uncompressedSize = uncompressedSize;
|
|
717
721
|
entry.compressedSize = compressedSize;
|
|
@@ -898,7 +902,7 @@ function loadExistingArchiveLarge(archiveName) {
|
|
|
898
902
|
fs.readSync(fd, eocdAndCommentBuffer, 0, eocdAndCommentSize, eocdLocation.offset);
|
|
899
903
|
// Create complete ZIP buffer: CD + EOCD + comment
|
|
900
904
|
const completeZipBuffer = Buffer.concat([cdBuffer, eocdAndCommentBuffer]);
|
|
901
|
-
const zip = new
|
|
905
|
+
const zip = new neozipkit_1.default();
|
|
902
906
|
zip.loadZip(completeZipBuffer);
|
|
903
907
|
return zip;
|
|
904
908
|
}
|
|
@@ -137,12 +137,17 @@ async function promptPassword(question) {
|
|
|
137
137
|
/**
|
|
138
138
|
* Get user's token choice from available options
|
|
139
139
|
*/
|
|
140
|
-
async function getUserTokenChoice(duplicateCheck) {
|
|
140
|
+
async function getUserTokenChoice(duplicateCheck, contractInfo) {
|
|
141
141
|
// Display owned tokens
|
|
142
142
|
if (duplicateCheck.userOwnedTokens.length > 0) {
|
|
143
143
|
console.log('\nYour tokens:');
|
|
144
144
|
duplicateCheck.userOwnedTokens.forEach((token, index) => {
|
|
145
|
-
|
|
145
|
+
let tokenInfo = ` ${index + 1}. Token ID ${token.tokenId}`;
|
|
146
|
+
if (contractInfo) {
|
|
147
|
+
const shortAddress = `${contractInfo.contractAddress.substring(0, 6)}...${contractInfo.contractAddress.substring(38)}`;
|
|
148
|
+
tokenInfo += ` (Contract: ${shortAddress}, Version: ${contractInfo.version})`;
|
|
149
|
+
}
|
|
150
|
+
console.log(tokenInfo);
|
|
146
151
|
});
|
|
147
152
|
}
|
|
148
153
|
// Display tokens owned by others
|
|
@@ -183,7 +188,12 @@ async function getUserTokenChoice(duplicateCheck) {
|
|
|
183
188
|
options[optionNumber.toString()] = async () => {
|
|
184
189
|
console.log('\nYour tokens:');
|
|
185
190
|
duplicateCheck.userOwnedTokens.forEach((token, index) => {
|
|
186
|
-
|
|
191
|
+
let tokenInfo = ` ${index + 1}. Token ID ${token.tokenId}`;
|
|
192
|
+
if (contractInfo) {
|
|
193
|
+
const shortAddress = `${contractInfo.contractAddress.substring(0, 6)}...${contractInfo.contractAddress.substring(38)}`;
|
|
194
|
+
tokenInfo += ` (Contract: ${shortAddress}, Version: ${contractInfo.version})`;
|
|
195
|
+
}
|
|
196
|
+
console.log(tokenInfo);
|
|
187
197
|
});
|
|
188
198
|
const tokenChoice = await promptUser('Enter token number: ');
|
|
189
199
|
const tokenIndex = parseInt(tokenChoice) - 1;
|
package/dist/src/neozip.js
CHANGED
|
@@ -67,7 +67,7 @@ const user_interaction_1 = require("./neozip/user-interaction");
|
|
|
67
67
|
const createZip_1 = require("./neozip/createZip");
|
|
68
68
|
const file_operations_1 = require("./neozip/file-operations");
|
|
69
69
|
// ConfigSetup is lazy-loaded only when needed (init/config commands)
|
|
70
|
-
const
|
|
70
|
+
const blockchain_1 = require("neozipkit/blockchain");
|
|
71
71
|
const ConfigStore_1 = require("./config/ConfigStore");
|
|
72
72
|
const exit_codes_1 = require("./exit-codes");
|
|
73
73
|
const version_1 = require("./version");
|
|
@@ -185,8 +185,8 @@ function parseArgs(args) {
|
|
|
185
185
|
case '-n':
|
|
186
186
|
case '--network':
|
|
187
187
|
const network = args[++i];
|
|
188
|
-
if ((0,
|
|
189
|
-
const supportedNetworks = (0,
|
|
188
|
+
if ((0, blockchain_1.getChainIdByName)(network) === null) {
|
|
189
|
+
const supportedNetworks = (0, blockchain_1.getSupportedNetworkNames)();
|
|
190
190
|
console.error(`Error: Unsupported network: "${network}"`);
|
|
191
191
|
console.error(`Supported networks: ${supportedNetworks.join(', ')}`);
|
|
192
192
|
(0, exit_codes_1.exitZip)(exit_codes_1.ZIP_EXIT_CODES.PARAMETER_ERROR);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neozip-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.75.1-beta",
|
|
4
4
|
"description": "A full-featured command-line ZIP application with NeoZipKit integration",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -110,10 +110,8 @@
|
|
|
110
110
|
"test:upgrade-zip": "echo '=== Testing ZIP Upgrade ===' && mkdir -p output && echo '' && echo '--- Creating initial ZIP with Calgary corpus files (deflate compression) ---' && npx ts-node src/neozip.ts --deflate output/test-upgrade.nzip test-suite/calgary/bib test-suite/calgary/book1 test-suite/calgary/book2 && echo '' && echo '--- Upgrading ZIP for tokenization ---' && npx ts-node src/neozip.ts --upgrade output/test-upgrade.nzip && echo '' && echo '--- Listing upgraded ZIP contents ---' && npx ts-node src/neolist.ts output/test-upgrade-tokenized.nzip && echo '' && echo '--- Verifying upgraded ZIP with neounzip -t ---' && npx ts-node src/neounzip.ts -t output/test-upgrade-tokenized.nzip && echo '' && echo '✅ ZIP upgrade test completed successfully!'",
|
|
111
111
|
"test:pre-verify": "echo '=== Testing Pre-Verify Option (-T) ===' && echo '' && echo '--- Testing pre-verify on tokenized ZIP ---' && npx ts-node src/neounzip.ts -T output/test-upgrade-tokenized.nzip test-output/preverify/ && echo '' && echo '--- Testing pre-verify on non-tokenized ZIP ---' && npx ts-node src/neozip.ts --deflate output/test-preverify-nontoken.nzip test-suite/calgary/bib test-suite/calgary/book1 test-suite/calgary/book2 && npx ts-node src/neounzip.ts -T output/test-preverify-nontoken.nzip test-output/preverify-nontoken/ && rm -rf test-output/preverify* output/test-preverify-nontoken.nzip 2>/dev/null && echo '' && echo '✅ Pre-verify test completed successfully!'",
|
|
112
112
|
"test:package": "node scripts/test-package.js",
|
|
113
|
-
"
|
|
114
|
-
"update:neozipkit": "echo '📥 Updating local neozipkit from external ../neozipkit...' && rsync -av --delete ../neozipkit/src/ neozipkit/src/ && rsync -av ../neozipkit/package.json neozipkit/package.json && rsync -av ../neozipkit/tsconfig.json neozipkit/tsconfig.json && echo '✅ Successfully updated neozipkit from ../neozipkit'",
|
|
113
|
+
"switch:neozipkit:npm": "node scripts/switch-neozipkit.js npm",
|
|
115
114
|
"switch:neozipkit:local": "node scripts/switch-neozipkit.js local",
|
|
116
|
-
"switch:neozipkit:external": "node scripts/switch-neozipkit.js external",
|
|
117
115
|
"switch:neozipkit:status": "node scripts/switch-neozipkit.js status"
|
|
118
116
|
},
|
|
119
117
|
"keywords": [
|
|
@@ -140,7 +138,6 @@
|
|
|
140
138
|
"dotenv": "^17.2.1",
|
|
141
139
|
"ethers": "^6.0.0",
|
|
142
140
|
"inquirer": "^8.2.6",
|
|
143
|
-
"neozipkit": "file:./neozipkit",
|
|
144
141
|
"minimatch": "^10.0.3",
|
|
145
142
|
"moment": "^2.29.4",
|
|
146
143
|
"moment-timezone": "^0.5.43",
|
|
@@ -150,7 +147,8 @@
|
|
|
150
147
|
"ts-node": "^10.9.1",
|
|
151
148
|
"typescript": "^5.0.0",
|
|
152
149
|
"uuid": "^9.0.0",
|
|
153
|
-
"web3": "^4.0.0"
|
|
150
|
+
"web3": "^4.0.0",
|
|
151
|
+
"neozipkit": "^0.3.1"
|
|
154
152
|
},
|
|
155
153
|
"devDependencies": {
|
|
156
154
|
"@types/chalk": "^2.2.4",
|
|
@@ -158,7 +156,8 @@
|
|
|
158
156
|
"@types/minimatch": "^5.1.2",
|
|
159
157
|
"@types/node": "^24.5.1",
|
|
160
158
|
"@types/ora": "^3.2.0",
|
|
161
|
-
"@types/uuid": "^10.0.0"
|
|
159
|
+
"@types/uuid": "^10.0.0",
|
|
160
|
+
"esbuild": "^0.27.0"
|
|
162
161
|
},
|
|
163
162
|
"engines": {
|
|
164
163
|
"node": ">=16.0.0"
|
|
@@ -171,5 +170,5 @@
|
|
|
171
170
|
"url": "https://github.com/NeoWareInc/neozip-support/issues"
|
|
172
171
|
},
|
|
173
172
|
"homepage": "https://github.com/NeoWareInc/neozip-cli#readme",
|
|
174
|
-
"packageManager": "yarn@
|
|
173
|
+
"packageManager": "yarn@1.22.19"
|
|
175
174
|
}
|