neozipkit 0.1.1 → 0.2.1
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 +52 -105
- package/contracts/INTEGRATION.md +338 -0
- package/contracts/NETWORKS.md +156 -0
- package/contracts/README.md +152 -0
- package/{src/server/blockchain → contracts}/constants.ts +5 -22
- package/contracts/deploy-bytecode.mjs +94 -0
- package/dist/blockchain/ZipKitMinter.d.ts +106 -0
- package/dist/blockchain/ZipKitMinter.js +347 -0
- package/dist/blockchain/ZipKitNFT.d.ts +3 -0
- package/dist/blockchain/ZipKitNFT.js +7 -0
- package/dist/blockchain/ZipKitOTS.d.ts +135 -0
- package/dist/blockchain/ZipKitOTS.js +564 -0
- package/dist/blockchain/ZipKitVerifier.d.ts +69 -0
- package/dist/blockchain/ZipKitVerifier.js +289 -0
- package/dist/{server/blockchain/WalletAnalyzer.d.ts → blockchain/ZipKitWallet.d.ts} +31 -43
- package/dist/{server/blockchain/WalletAnalyzer.js → blockchain/ZipKitWallet.js} +193 -161
- package/dist/blockchain/contracts.d.ts +14 -0
- package/dist/blockchain/contracts.js +77 -0
- package/dist/blockchain/index.d.ts +7 -0
- package/dist/blockchain/index.js +50 -0
- package/dist/{server/blockchain → blockchain}/types.d.ts +12 -34
- package/dist/{server/blockchain → blockchain}/types.js +1 -22
- package/dist/browser-index.d.ts +0 -3
- package/dist/browser-index.js +4 -5
- package/dist/browser.d.ts +0 -3
- package/dist/browser.js +4 -5
- package/dist/index.d.ts +8 -15
- package/dist/index.js +12 -24
- package/dist/server/{platform/server/ZipKitServer.d.ts → ZipKitServer.d.ts} +4 -35
- package/dist/server/{platform/server/ZipKitServer.js → ZipKitServer.js} +55 -182
- package/dist/shared/ZipEntry.js +1 -1
- package/dist/shared/ZipKit.d.ts +0 -6
- package/dist/shared/ZipKit.js +1 -18
- package/dist/shared/types.js +2 -2
- package/dist/shared/version.d.ts +2 -4
- package/dist/shared/version.js +4 -5
- package/package.json +13 -3
- package/src/blockchain/README.md +229 -0
- package/src/blockchain/ZipKitMinter.ts +470 -0
- package/src/blockchain/ZipKitNFT.ts +12 -0
- package/src/blockchain/ZipKitOTS.ts +622 -0
- package/src/blockchain/ZipKitVerifier.ts +382 -0
- package/src/blockchain/ZipKitWallet.ts +338 -0
- package/src/blockchain/contracts.ts +88 -0
- package/src/blockchain/index.ts +61 -0
- package/src/blockchain/types.ts +91 -0
- package/src/browser/{TokenVerifierBrowser.ts → TokenVerifierBrowser.ts-remove} +1 -1
- package/src/browser-index.ts +3 -3
- package/src/index.ts +10 -17
- package/src/server/README.md +25 -0
- package/src/server/ZipKitServer.ts +305 -0
- package/src/shared/ZipEntry.ts +1 -1
- package/src/shared/ZipKit.ts +1 -19
- package/src/shared/types.ts +3 -3
- package/src/shared/version.ts +3 -4
- package/src/types/modules.d.ts +11 -1
- package/contracts/Lock.sol +0 -34
- package/contracts/compile-contract.js +0 -168
- package/contracts/deploy/deploy-both-contracts.js +0 -286
- package/contracts/deploy/deploy-enhanced-contract.js +0 -197
- package/contracts/deploy/deploy-private-contract.js +0 -190
- package/contracts/deploy/deploy-public-clean.js +0 -1063
- package/contracts/deploy/deploy-public-contract.js +0 -1107
- package/contracts/deployment.config.example.js +0 -25
- package/contracts/remix-compile.js +0 -222
- package/contracts/setup-deployment.js +0 -51
- package/contracts/src/ZipFileNFT-DEPRECATED-6field.sol +0 -260
- package/contracts/src/ZipFileNFT-DEPRECATED-Enhanced.sol +0 -289
- package/dist/browser/CertificateGeneratorBrowser.d.ts +0 -75
- package/dist/browser/CertificateGeneratorBrowser.js +0 -433
- package/dist/browser/TokenVerifierBrowser.d.ts +0 -76
- package/dist/browser/TokenVerifierBrowser.js +0 -299
- package/dist/server/blockchain/NFTMinter.d.ts +0 -41
- package/dist/server/blockchain/NFTMinter.js +0 -323
- package/dist/server/blockchain/TokenQuerier.d.ts +0 -31
- package/dist/server/blockchain/TokenQuerier.js +0 -259
- package/dist/server/blockchain/TokenVerifier.d.ts +0 -20
- package/dist/server/blockchain/TokenVerifier.js +0 -395
- package/dist/server/blockchain/WalletFormatter.d.ts +0 -39
- package/dist/server/blockchain/WalletFormatter.js +0 -196
- package/dist/server/blockchain/WalletManager.d.ts +0 -46
- package/dist/server/blockchain/WalletManager.js +0 -294
- package/dist/server/blockchain/ZipMetadata.d.ts +0 -27
- package/dist/server/blockchain/ZipMetadata.js +0 -131
- package/dist/server/blockchain/ZipTokenProcessor.d.ts +0 -44
- package/dist/server/blockchain/ZipTokenProcessor.js +0 -204
- package/dist/server/blockchain/constants.d.ts +0 -102
- package/dist/server/blockchain/constants.js +0 -968
- package/dist/server/blockchain/index.d.ts +0 -9
- package/dist/server/blockchain/index.js +0 -44
- package/dist/server/blockchain/test-certificate.d.ts +0 -8
- package/dist/server/blockchain/test-certificate.js +0 -100
- package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +0 -91
- package/dist/server/platform/servercomponents/ZipKitOTS.js +0 -271
- package/examples/unzip-token.ts +0 -488
- package/examples/zip-token.ts +0 -604
- package/src/server/blockchain/NFTMinter.ts +0 -357
- package/src/server/blockchain/TokenQuerier.ts +0 -287
- package/src/server/blockchain/TokenVerifier.ts +0 -453
- package/src/server/blockchain/WalletAnalyzer.ts +0 -397
- package/src/server/blockchain/WalletFormatter.ts +0 -206
- package/src/server/blockchain/WalletManager.ts +0 -294
- package/src/server/blockchain/ZipMetadata.ts +0 -117
- package/src/server/blockchain/ZipTokenProcessor.ts +0 -234
- package/src/server/blockchain/index.ts +0 -42
- package/src/server/blockchain/test-certificate.ts +0 -137
- package/src/server/blockchain/types.ts +0 -134
- package/src/server/platform/server/ZipKitServer.ts +0 -459
- package/src/server/platform/servercomponents/ZipKitOTS.ts +0 -313
- package/src/server/platform/servercomponents/opentimestamps.d.ts +0 -23
- /package/contracts/{bytecode.txt → NZIP-NFT-bytecode.txt} +0 -0
- /package/dist/{server/blockchain → blockchain}/CertificateToken.d.ts +0 -0
- /package/dist/{server/blockchain → blockchain}/CertificateToken.js +0 -0
- /package/src/{server/blockchain → blockchain}/CertificateToken.ts +0 -0
- /package/src/browser/{CertificateGeneratorBrowser.ts → CertificateGeneratorBrowser.ts-remove} +0 -0
|
@@ -52,15 +52,11 @@ const fs = __importStar(require("fs"));
|
|
|
52
52
|
const path = __importStar(require("path"));
|
|
53
53
|
const uuid_1 = require("uuid");
|
|
54
54
|
const process_1 = require("process");
|
|
55
|
-
const ZipKit_1 =
|
|
56
|
-
const
|
|
57
|
-
const Headers = __importStar(require("../../../shared/constants/Headers"));
|
|
55
|
+
const ZipKit_1 = __importDefault(require("../shared/ZipKit"));
|
|
56
|
+
const Headers = __importStar(require("../shared/constants/Headers"));
|
|
58
57
|
exports.Headers = Headers;
|
|
59
|
-
const Util_1 = require("../../../shared/components/Util");
|
|
60
|
-
const CertificateOTS_1 = __importDefault(require("../../../shared/components/CertificateOTS"));
|
|
61
|
-
const Errors_1 = __importDefault(require("../../../shared/constants/Errors"));
|
|
62
58
|
// Re-export everything from ZipKit
|
|
63
|
-
__exportStar(require("
|
|
59
|
+
__exportStar(require("../shared/ZipKit"), exports);
|
|
64
60
|
/**
|
|
65
61
|
* This implementation is optimized for server environments and handles all
|
|
66
62
|
* ZIP operations including compression, extraction, encryption, and file management.
|
|
@@ -74,11 +70,6 @@ class ZipKitServer extends ZipKit_1.default {
|
|
|
74
70
|
*/
|
|
75
71
|
constructor() {
|
|
76
72
|
super(); // Call the parent constructor
|
|
77
|
-
// console.log('ZipKit.support.isNode: ', ZipKit.support.isNode);
|
|
78
|
-
// console.log('ZipKit.support.buffer: ', ZipKit.support.buffer);
|
|
79
|
-
// console.log('ZipKit.support.blob: ', ZipKit.support.blob);
|
|
80
|
-
// console.log('ZipKit.support.streams: ', ZipKit.support.streams);
|
|
81
|
-
// console.log('ZipKit.support.fileReader: ', ZipKit.support.fileReader);
|
|
82
73
|
}
|
|
83
74
|
/**
|
|
84
75
|
* Loads a ZIP file from the filesystem for updating/creating operations
|
|
@@ -97,6 +88,7 @@ class ZipKitServer extends ZipKit_1.default {
|
|
|
97
88
|
fdIn = fs.openSync(zipFile, 'r');
|
|
98
89
|
const stats = fs.fstatSync(fdIn);
|
|
99
90
|
inBuffer = Buffer.alloc(stats.size);
|
|
91
|
+
// inBuffer is allocated above; ensure non-null for readSync
|
|
100
92
|
fs.readSync(fdIn, inBuffer, 0, stats.size, 0);
|
|
101
93
|
}
|
|
102
94
|
else {
|
|
@@ -114,7 +106,7 @@ class ZipKitServer extends ZipKit_1.default {
|
|
|
114
106
|
}
|
|
115
107
|
}
|
|
116
108
|
// Initialize empty buffer if null
|
|
117
|
-
const buffer = inBuffer
|
|
109
|
+
const buffer = inBuffer ?? Buffer.alloc(0);
|
|
118
110
|
super.loadZip(buffer);
|
|
119
111
|
}
|
|
120
112
|
/**
|
|
@@ -182,14 +174,6 @@ class ZipKitServer extends ZipKit_1.default {
|
|
|
182
174
|
entry.isDirectory = attr.isDirectory();
|
|
183
175
|
let _fattr = (attr.mode & 0xfff) | (entry.isDirectory ? 0x4000 : 0x8000);
|
|
184
176
|
entry.extFileAttr = ((_fattr << 16) | (entry.isDirectory ? 0x10 : 0)) >>> 0;
|
|
185
|
-
// Set Compression method
|
|
186
|
-
// if (options.store) {
|
|
187
|
-
// entry.cmpMethod = CMP_METHOD.STORED;
|
|
188
|
-
// } else if (options.Z) {
|
|
189
|
-
// entry.cmpMethod = Headers.CMP_METHOD.DEFLATED;
|
|
190
|
-
// } else {
|
|
191
|
-
// entry.cmpMethod = CMP_METHOD.ZSTD;
|
|
192
|
-
// }
|
|
193
177
|
}
|
|
194
178
|
/**
|
|
195
179
|
* Processes files to be added to the ZIP archive
|
|
@@ -199,7 +183,6 @@ class ZipKitServer extends ZipKit_1.default {
|
|
|
199
183
|
let filesAdded = 0;
|
|
200
184
|
for (var i = 0; files[i] != undefined; i++) {
|
|
201
185
|
const filename = String(files[i]);
|
|
202
|
-
// console.log('filename: ', filename);
|
|
203
186
|
// Skip arguments that look like options (start with hyphen but aren't files)
|
|
204
187
|
if (filename.startsWith('-') && !fs.existsSync(filename)) {
|
|
205
188
|
console.warn(`Warning: Skipping '${filename}' which appears to be an option, not a file.`);
|
|
@@ -211,14 +194,7 @@ class ZipKitServer extends ZipKit_1.default {
|
|
|
211
194
|
return filesAdded;
|
|
212
195
|
}
|
|
213
196
|
/**
|
|
214
|
-
* Creates a ZIP file
|
|
215
|
-
*
|
|
216
|
-
* This method creates a ZIP file with optional OpenTimestamps (OTS) metadata,
|
|
217
|
-
* which includes a timestamp of the ZIP file's contents on the Bitcoin blockchain.
|
|
218
|
-
*
|
|
219
|
-
* @param zipFile - The path to the ZIP file to create
|
|
220
|
-
* @param compressOptions - The compression options for the ZIP file
|
|
221
|
-
* @returns void - The method triggers a download of the ZIP file
|
|
197
|
+
* Creates a ZIP file
|
|
222
198
|
*/
|
|
223
199
|
async createZip(zipFile, compressOptions) {
|
|
224
200
|
// Ensure the directory structure for the output file exists
|
|
@@ -232,14 +208,12 @@ class ZipKitServer extends ZipKit_1.default {
|
|
|
232
208
|
const fd = fs.openSync(_tempZipFile, 'w');
|
|
233
209
|
let offset = await super.createZipFileData(compressOptions, {
|
|
234
210
|
onReadEntryData: (entry) => {
|
|
235
|
-
// console.log(`Reading file: ${entry.filename}`);
|
|
236
211
|
try {
|
|
237
212
|
return fs.readFileSync(entry.filename);
|
|
238
213
|
}
|
|
239
214
|
catch (error) {
|
|
240
215
|
throw new Error(`Failed to read file: ${entry.filename}`);
|
|
241
216
|
}
|
|
242
|
-
// return fs.readFileSync(entry.filename);
|
|
243
217
|
},
|
|
244
218
|
onOutputBuffer: (buffer) => {
|
|
245
219
|
fs.writeSync(fd, buffer);
|
|
@@ -263,62 +237,56 @@ class ZipKitServer extends ZipKit_1.default {
|
|
|
263
237
|
}
|
|
264
238
|
/**
|
|
265
239
|
* Creates a ZIP file with OpenTimestamps (OTS) metadata
|
|
266
|
-
*
|
|
267
|
-
* This method creates a ZIP file with OpenTimestamps (OTS) metadata, which
|
|
268
|
-
* includes a timestamp of the ZIP file's contents on the Bitcoin blockchain.
|
|
269
|
-
*
|
|
270
|
-
* @param zipFile - The path to the ZIP file to create
|
|
271
|
-
* @param compressOptions - The compression options for the ZIP file
|
|
272
|
-
* @returns void - The method triggers a download of the ZIP file
|
|
273
240
|
*/
|
|
274
|
-
async createZipOTS(zipFile, compressOptions) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
241
|
+
// async createZipOTS(zipFile: string, compressOptions: CompressOptions) {
|
|
242
|
+
// // Ensure the directory structure for the output file exists
|
|
243
|
+
// const outputDir = path.dirname(zipFile);
|
|
244
|
+
// if (!fs.existsSync(outputDir)) {
|
|
245
|
+
// fs.mkdirSync(outputDir, { recursive: true });
|
|
246
|
+
// }
|
|
247
|
+
// // Generate a unique temporary file name in the output directory
|
|
248
|
+
// const _tempZipFile = path.join(outputDir, `neozip-${uuidv4()}.zip`);
|
|
249
|
+
// // Open or create the .zip file for writing
|
|
250
|
+
// const fd = fs.openSync(_tempZipFile, 'w');
|
|
251
|
+
// let offset = await super.createZipFileData(compressOptions, {
|
|
252
|
+
// onReadEntryData: (entry: ZipEntry) => {
|
|
253
|
+
// try {
|
|
254
|
+
// return fs.readFileSync(entry.filename);
|
|
255
|
+
// } catch (error) {
|
|
256
|
+
// throw new Error(`Failed to read file: ${entry.filename}`);
|
|
257
|
+
// }
|
|
258
|
+
// },
|
|
259
|
+
// onOutputBuffer: (buffer: Buffer) => {
|
|
260
|
+
// fs.writeSync(fd, buffer);
|
|
261
|
+
// },
|
|
262
|
+
// onEntryDone: (entry: ZipEntry, status: string) => {
|
|
263
|
+
// console.log(`${status} ${entry.filename} to ${zipFile}`);
|
|
264
|
+
// }
|
|
265
|
+
// });
|
|
266
|
+
// // Timestamp the zip file to the Bitcoin blockchain
|
|
267
|
+
// let _metadataEntry = null;
|
|
268
|
+
// console.log('Timestamping to Bitcoin blockchain...');
|
|
269
|
+
// const _merkleRoot = super.getMerkleRoot();
|
|
270
|
+
// console.log('Merkle Root: ' + _merkleRoot);
|
|
271
|
+
// const _ots = await createTimestamp(_merkleRoot);
|
|
272
|
+
// _metadataEntry = super.createTimestampMetadataEntry(_ots);
|
|
273
|
+
// // Write the metadata entry to the .zip fi
|
|
274
|
+
// await super.finishZipFileData(
|
|
275
|
+
// offset,
|
|
276
|
+
// function onOutputBuffer(buffer: Buffer) {
|
|
277
|
+
// fs.writeSync(fd, buffer);
|
|
278
|
+
// },
|
|
279
|
+
// _metadataEntry || undefined
|
|
280
|
+
// );
|
|
281
|
+
// // Close the .zip file
|
|
282
|
+
// fs.closeSync(fd);
|
|
283
|
+
// // Delete the existing .zip file if it exists
|
|
284
|
+
// if (fs.existsSync(zipFile)) {
|
|
285
|
+
// fs.unlinkSync(zipFile);
|
|
286
|
+
// }
|
|
287
|
+
// // Replace the existing .zip file with the temporary file
|
|
288
|
+
// fs.renameSync(_tempZipFile, zipFile);
|
|
289
|
+
// }
|
|
322
290
|
/**
|
|
323
291
|
* Removes specified files from the ZIP archive
|
|
324
292
|
* Deletes matching ZipEntry objects and rebuilds the archive if any files were removed
|
|
@@ -338,100 +306,5 @@ class ZipKitServer extends ZipKit_1.default {
|
|
|
338
306
|
});
|
|
339
307
|
return filesDel;
|
|
340
308
|
}
|
|
341
|
-
/**
|
|
342
|
-
* Upgrades a timestamp in an existing ZIP file
|
|
343
|
-
*
|
|
344
|
-
* This method takes an existing ZIP file and upgrades its timestamp by:
|
|
345
|
-
* 1. Loading the original ZIP file
|
|
346
|
-
* 2. Removing any existing timestamp metadata entries
|
|
347
|
-
* 3. Adding a new timestamp metadata entry with the upgraded OTS proof
|
|
348
|
-
* 4. Creating a new ZIP file with the updated timestamp
|
|
349
|
-
*
|
|
350
|
-
* @param zipFile - The original ZIP file to upgrade
|
|
351
|
-
* @param upgradedOts - The upgraded OpenTimestamps proof as an ArrayBuffer
|
|
352
|
-
* @returns void - The method triggers a download of the upgraded ZIP file
|
|
353
|
-
*/
|
|
354
|
-
async upgradeOTS(fileName, upgradedOts) {
|
|
355
|
-
// Generate a unique temporary file name in the output directory
|
|
356
|
-
let tempName = fileName.replace('.zip', '.upgrade.zip');
|
|
357
|
-
// Open or create the .zip file for writing
|
|
358
|
-
const fd = fs.openSync(tempName, 'w');
|
|
359
|
-
try {
|
|
360
|
-
const zipEntries = this.getDirectory();
|
|
361
|
-
let offset = 0;
|
|
362
|
-
// Copy the entries from the original file to the output file
|
|
363
|
-
for (const entry of zipEntries) {
|
|
364
|
-
if (entry.filename === ZipKit_1.TIMESTAMP_METADATA || entry.filename === ZipKit_1.TIMESTAMP_SUBMITTED) {
|
|
365
|
-
this.deleteFile(entry.filename);
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
// Copy the entry data to the output file
|
|
369
|
-
console.log('Copying entry: ', entry.filename);
|
|
370
|
-
const inData = this.copyEntry(entry);
|
|
371
|
-
entry.localHdrOffset = offset;
|
|
372
|
-
offset += inData.length;
|
|
373
|
-
fs.writeSync(fd, inData);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
// Add the new timestamp metadata file
|
|
377
|
-
let tsEntry = this.createZipEntry(ZipKit_1.TIMESTAMP_METADATA);
|
|
378
|
-
tsEntry.timeDateDOS = tsEntry.setDateTime(new Date());
|
|
379
|
-
tsEntry.compressedSize = upgradedOts.byteLength;
|
|
380
|
-
tsEntry.uncompressedSize = upgradedOts.byteLength;
|
|
381
|
-
tsEntry.cmpMethod = ZipKit_1.CMP_METHOD.STORED;
|
|
382
|
-
tsEntry.crc = (0, Util_1.crc32)(upgradedOts);
|
|
383
|
-
tsEntry.fileBuffer = upgradedOts;
|
|
384
|
-
console.log('tsEntry: ', tsEntry);
|
|
385
|
-
const localHdr = tsEntry.createLocalHdr();
|
|
386
|
-
// Save local header offset for entry and calculate next offset
|
|
387
|
-
tsEntry.localHdrOffset = offset;
|
|
388
|
-
offset += localHdr.length + tsEntry.compressedSize;
|
|
389
|
-
fs.writeSync(fd, localHdr);
|
|
390
|
-
fs.writeSync(fd, upgradedOts);
|
|
391
|
-
// Output ZipEntries as Central End Directory
|
|
392
|
-
const centralDirOffset = offset;
|
|
393
|
-
for (const entry of zipEntries) {
|
|
394
|
-
const centralDirEntry = entry.centralDirEntry();
|
|
395
|
-
offset += centralDirEntry.length;
|
|
396
|
-
fs.writeSync(fd, centralDirEntry);
|
|
397
|
-
}
|
|
398
|
-
const centralDirSize = offset - centralDirOffset;
|
|
399
|
-
let ceBuf = this.centralEndHdr(centralDirSize, centralDirOffset);
|
|
400
|
-
fs.writeSync(fd, ceBuf);
|
|
401
|
-
// Close the .zip file
|
|
402
|
-
fs.closeSync(fd);
|
|
403
|
-
// Delete the existing .zip file if it exists
|
|
404
|
-
if (fs.existsSync(fileName)) {
|
|
405
|
-
fs.unlinkSync(fileName);
|
|
406
|
-
}
|
|
407
|
-
// Replace the existing .zip file with the temporary file
|
|
408
|
-
fs.renameSync(tempName, fileName);
|
|
409
|
-
}
|
|
410
|
-
catch (err) {
|
|
411
|
-
console.error('Error-upgradeOTS: ', err);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
async createCertificateOTS(fileName, zipEntries, timestampResult) {
|
|
415
|
-
if (!timestampResult || !timestampResult.merkleRoot || !fileName)
|
|
416
|
-
return Errors_1.default.CERTIFICATE_OTS_BAD;
|
|
417
|
-
let rsp = await (0, ZipKitOTS_1.deserializeOts)(timestampResult);
|
|
418
|
-
if (!rsp)
|
|
419
|
-
return Errors_1.default.CERTIFICATE_OTS_FAILED;
|
|
420
|
-
const result = JSON.parse(rsp);
|
|
421
|
-
const cert = (0, CertificateOTS_1.default)(result.attestStr, fileName, timestampResult.merkleRoot, result.needsUpdateMsg, result.attestationValues, zipEntries, false);
|
|
422
|
-
if (!cert)
|
|
423
|
-
return Errors_1.default.CERTIFICATE_OTS_FAILED;
|
|
424
|
-
// Generate certificate file name
|
|
425
|
-
const certFileName = fileName + '.certificate.html';
|
|
426
|
-
try {
|
|
427
|
-
// Write the certificate HTML to a file
|
|
428
|
-
fs.writeFileSync(certFileName, cert, { encoding: 'utf8' });
|
|
429
|
-
return `Certificate created as ${certFileName}`;
|
|
430
|
-
}
|
|
431
|
-
catch (error) {
|
|
432
|
-
console.error(`Failed to write certificate file: ${error}`);
|
|
433
|
-
return Errors_1.default.CERTIFICATE_OTS_FAILED;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
309
|
}
|
|
437
310
|
exports.default = ZipKitServer;
|
package/dist/shared/ZipEntry.js
CHANGED
|
@@ -24,7 +24,7 @@ class ZipEntry {
|
|
|
24
24
|
* @param debug - Enable debug logging
|
|
25
25
|
*/
|
|
26
26
|
constructor(fname, comment, debug) {
|
|
27
|
-
this.debug =
|
|
27
|
+
this.debug = false;
|
|
28
28
|
this.verMadeBy = 0; // Read Version Made By
|
|
29
29
|
this.verExtract = 0; // Read Version Needed to Extract
|
|
30
30
|
this.bitFlags = 0; // General purpose bit flag
|
package/dist/shared/ZipKit.d.ts
CHANGED
|
@@ -212,12 +212,6 @@ export default class ZipKit {
|
|
|
212
212
|
* @returns Promise<Buffer | null> - The OTS from the timestamp metadata entry or null if not found
|
|
213
213
|
*/
|
|
214
214
|
getOts(): Promise<Buffer | null>;
|
|
215
|
-
/**
|
|
216
|
-
* Creates a new timestamp metadata entry for the ZIP file
|
|
217
|
-
* Calculates merkle root from file hashes and obtains blockchain timestamp
|
|
218
|
-
* @returns Promise<ZipEntry | null> The created timestamp metadata entry or null if failed
|
|
219
|
-
*/
|
|
220
|
-
createTimestampMetadataEntry(ots: Buffer | null): ZipEntry | null;
|
|
221
215
|
/**
|
|
222
216
|
* Sets the ZIP file comment
|
|
223
217
|
* @param msg - Comment to set
|
package/dist/shared/ZipKit.js
CHANGED
|
@@ -383,7 +383,7 @@ class ZipKit {
|
|
|
383
383
|
// console.log('CRC: '+ sprintf("%08x", entry.crc));
|
|
384
384
|
if (options?.useSHA256) {
|
|
385
385
|
entry.sha256 = (0, ZipCrypto_1.sha256)(data);
|
|
386
|
-
console.log('SHA256: ', entry.sha256);
|
|
386
|
+
// console.log('SHA256: ', entry.sha256);
|
|
387
387
|
}
|
|
388
388
|
;
|
|
389
389
|
if (options?.password) {
|
|
@@ -716,23 +716,6 @@ class ZipKit {
|
|
|
716
716
|
const ots = await this.extract(this.stampEntry);
|
|
717
717
|
return ots;
|
|
718
718
|
}
|
|
719
|
-
/**
|
|
720
|
-
* Creates a new timestamp metadata entry for the ZIP file
|
|
721
|
-
* Calculates merkle root from file hashes and obtains blockchain timestamp
|
|
722
|
-
* @returns Promise<ZipEntry | null> The created timestamp metadata entry or null if failed
|
|
723
|
-
*/
|
|
724
|
-
createTimestampMetadataEntry(ots) {
|
|
725
|
-
if (!ots)
|
|
726
|
-
return null;
|
|
727
|
-
const tsEntry = this.createZipEntry(Headers_1.TIMESTAMP_SUBMITTED);
|
|
728
|
-
tsEntry.crc = (0, Util_1.crc32)(ots);
|
|
729
|
-
tsEntry.uncompressedSize = ots.length;
|
|
730
|
-
tsEntry.compressedSize = ots.length;
|
|
731
|
-
tsEntry.cmpMethod = Headers_1.CMP_METHOD.STORED;
|
|
732
|
-
tsEntry.fileBuffer = ots;
|
|
733
|
-
tsEntry.isMetaData = true;
|
|
734
|
-
return tsEntry;
|
|
735
|
-
}
|
|
736
719
|
/**
|
|
737
720
|
* Sets the ZIP file comment
|
|
738
721
|
* @param msg - Comment to set
|
package/dist/shared/types.js
CHANGED
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NEOZIPKIT_INFO = void 0;
|
|
4
4
|
const version_1 = require("./version");
|
|
5
5
|
exports.NEOZIPKIT_INFO = {
|
|
6
|
-
version: version_1.
|
|
7
|
-
releaseDate: version_1.
|
|
6
|
+
version: version_1.NEOZIPKIT_VERSION,
|
|
7
|
+
releaseDate: version_1.NEOZIPKIT_RELEASE_DATE
|
|
8
8
|
};
|
package/dist/shared/version.d.ts
CHANGED
package/dist/shared/version.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
3
|
+
exports.NEOZIPKIT_RELEASE_DATE = exports.NEOZIPKIT_VERSION = void 0;
|
|
4
|
+
// Global-style constants for easy import across the package
|
|
5
|
+
exports.NEOZIPKIT_VERSION = '0.1.2';
|
|
6
|
+
exports.NEOZIPKIT_RELEASE_DATE = '08-12-2025';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neozipkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "NeoZipKit - Advanced ZIP file creation and verification with blockchain timestamping",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -56,6 +56,14 @@
|
|
|
56
56
|
"./shared/constants/*": {
|
|
57
57
|
"types": "./dist/shared/constants/*.d.ts",
|
|
58
58
|
"default": "./dist/shared/constants/*.js"
|
|
59
|
+
},
|
|
60
|
+
"./blockchain": {
|
|
61
|
+
"types": "./dist/blockchain/index.d.ts",
|
|
62
|
+
"default": "./dist/blockchain/index.js"
|
|
63
|
+
},
|
|
64
|
+
"./blockchain/*": {
|
|
65
|
+
"types": "./dist/blockchain/*.d.ts",
|
|
66
|
+
"default": "./dist/blockchain/*.js"
|
|
59
67
|
}
|
|
60
68
|
},
|
|
61
69
|
"files": [
|
|
@@ -69,12 +77,14 @@
|
|
|
69
77
|
"TYPESCRIPT_WORKFLOW.md"
|
|
70
78
|
],
|
|
71
79
|
"scripts": {
|
|
72
|
-
"clean": "rm -rf dist/ &&
|
|
80
|
+
"clean": "rm -rf dist/ && find . -maxdepth 1 -name '*.js' -delete && find . -maxdepth 1 -name '*.d.ts' -delete && rm -rf components constants platform types blockchain",
|
|
73
81
|
"compile": "tsc",
|
|
74
82
|
"create-browser-entry": "cp dist/browser-index.js dist/browser.js && cp dist/browser-index.d.ts dist/browser.d.ts",
|
|
75
83
|
"build": "npm run clean && npm run compile && npm run create-browser-entry",
|
|
76
84
|
"watch": "tsc --watch",
|
|
77
|
-
"test": "echo \"No tests specified\" && exit 0"
|
|
85
|
+
"test": "echo \"No tests specified\" && exit 0",
|
|
86
|
+
"deploy:base": "node contracts/deploy-bytecode.mjs",
|
|
87
|
+
"deploy:base:sepolia": "NETWORK=base-sepolia node contracts/deploy-bytecode.mjs"
|
|
78
88
|
},
|
|
79
89
|
"keywords": [
|
|
80
90
|
"zip",
|