neozipkit 0.1.1 → 0.3.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.
- package/LICENSE +22 -0
- package/README.md +371 -200
- package/contracts/ABI.txt +889 -0
- package/contracts/Bytecode.txt +1 -0
- package/contracts/COMPILATION_NOTES.md +59 -0
- package/contracts/QUICK_DEPLOY.md +286 -0
- package/contracts/README.md +256 -0
- package/contracts/VERIFICATION.md +308 -0
- package/contracts/deploy-interactive.js +448 -0
- package/contracts/deployment-arbitrum-sepolia.json +12 -0
- package/contracts/deployment-arbitrum.json +12 -0
- package/contracts/deployment-eth-sepolia.json +12 -0
- package/contracts/hardhat.config.js +114 -0
- package/contracts/package.json +20 -0
- package/contracts/scripts/compile-and-extract.js +119 -0
- package/contracts/scripts/verify-contract.js +223 -0
- package/contracts/src/{NZIP-NFT-Private.sol → NZIP-NFT-v2.0.sol} +66 -151
- package/contracts/src/NZIP-NFT.sol +9 -15
- package/dist/{browser → blockchain/browser}/TokenVerifierBrowser.d.ts +11 -20
- package/dist/blockchain/browser/TokenVerifierBrowser.d.ts.map +1 -0
- package/dist/{browser → blockchain/browser}/TokenVerifierBrowser.js +106 -92
- package/dist/blockchain/browser/TokenVerifierBrowser.js.map +1 -0
- package/dist/blockchain/browser/WalletManagerBrowser.d.ts +98 -0
- package/dist/blockchain/browser/WalletManagerBrowser.d.ts.map +1 -0
- package/dist/blockchain/browser/WalletManagerBrowser.js +434 -0
- package/dist/blockchain/browser/WalletManagerBrowser.js.map +1 -0
- package/dist/blockchain/browser/ZipkitMinterBrowser.d.ts +58 -0
- package/dist/blockchain/browser/ZipkitMinterBrowser.d.ts.map +1 -0
- package/dist/blockchain/browser/ZipkitMinterBrowser.js +317 -0
- package/dist/blockchain/browser/ZipkitMinterBrowser.js.map +1 -0
- package/dist/blockchain/browser/index.d.ts +11 -0
- package/dist/blockchain/browser/index.d.ts.map +1 -0
- package/dist/blockchain/browser/index.js +16 -0
- package/dist/blockchain/browser/index.js.map +1 -0
- package/dist/{server/blockchain/WalletAnalyzer.d.ts → blockchain/core/WalletManager.d.ts} +69 -26
- package/dist/blockchain/core/WalletManager.d.ts.map +1 -0
- package/dist/{server/blockchain/WalletAnalyzer.js → blockchain/core/WalletManager.js} +172 -160
- package/dist/blockchain/core/WalletManager.js.map +1 -0
- package/dist/blockchain/core/ZipkitMinter.d.ts +141 -0
- package/dist/blockchain/core/ZipkitMinter.d.ts.map +1 -0
- package/dist/blockchain/core/ZipkitMinter.js +548 -0
- package/dist/blockchain/core/ZipkitMinter.js.map +1 -0
- package/dist/blockchain/core/ZipkitOTS.d.ts +126 -0
- package/dist/blockchain/core/ZipkitOTS.d.ts.map +1 -0
- package/dist/blockchain/core/ZipkitOTS.js +506 -0
- package/dist/blockchain/core/ZipkitOTS.js.map +1 -0
- package/dist/blockchain/core/ZipkitVerifier.d.ts +177 -0
- package/dist/blockchain/core/ZipkitVerifier.d.ts.map +1 -0
- package/dist/blockchain/core/ZipkitVerifier.js +632 -0
- package/dist/blockchain/core/ZipkitVerifier.js.map +1 -0
- package/dist/blockchain/core/contracts.d.ts +83 -0
- package/dist/blockchain/core/contracts.d.ts.map +1 -0
- package/dist/blockchain/core/contracts.js +341 -0
- package/dist/blockchain/core/contracts.js.map +1 -0
- package/dist/blockchain/core/index.d.ts +12 -0
- package/dist/blockchain/core/index.d.ts.map +1 -0
- package/dist/blockchain/core/index.js +59 -0
- package/dist/blockchain/core/index.js.map +1 -0
- package/dist/blockchain/index.d.ts +11 -0
- package/dist/blockchain/index.d.ts.map +1 -0
- package/dist/blockchain/index.js +34 -0
- package/dist/blockchain/index.js.map +1 -0
- package/dist/blockchain/node/WalletManagerNode.d.ts +47 -0
- package/dist/blockchain/node/WalletManagerNode.d.ts.map +1 -0
- package/dist/blockchain/node/WalletManagerNode.js +203 -0
- package/dist/blockchain/node/WalletManagerNode.js.map +1 -0
- package/dist/blockchain/node/index.d.ts +12 -0
- package/dist/blockchain/node/index.d.ts.map +1 -0
- package/dist/blockchain/node/index.js +24 -0
- package/dist/blockchain/node/index.js.map +1 -0
- package/dist/browser/ZipkitBrowser.d.ts +27 -0
- package/dist/browser/ZipkitBrowser.d.ts.map +1 -0
- package/dist/browser/{ZipKitBrowser.js → ZipkitBrowser.js} +96 -43
- package/dist/browser/ZipkitBrowser.js.map +1 -0
- package/dist/browser/index.d.ts +12 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +42 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser-esm/index.d.ts +12 -0
- package/dist/browser-esm/index.js +59559 -0
- package/dist/browser-esm/index.js.map +7 -0
- package/dist/browser-umd/index.d.ts +12 -0
- package/dist/browser-umd/index.js +59576 -0
- package/dist/browser-umd/index.js.map +7 -0
- package/dist/browser-umd/index.min.js +63 -0
- package/dist/browser.d.ts +8 -17
- package/dist/browser.js +13 -29
- package/dist/core/ZipCompress.d.ts +99 -0
- package/dist/core/ZipCompress.d.ts.map +1 -0
- package/dist/core/ZipCompress.js +309 -0
- package/dist/core/ZipCompress.js.map +1 -0
- package/dist/core/ZipDecompress.d.ts +58 -0
- package/dist/core/ZipDecompress.d.ts.map +1 -0
- package/dist/core/ZipDecompress.js +172 -0
- package/dist/core/ZipDecompress.js.map +1 -0
- package/dist/{shared → core}/ZipEntry.d.ts +8 -1
- package/dist/core/ZipEntry.d.ts.map +1 -0
- package/dist/{shared → core}/ZipEntry.js +224 -81
- package/dist/core/ZipEntry.js.map +1 -0
- package/dist/core/Zipkit.d.ts +315 -0
- package/dist/core/Zipkit.d.ts.map +1 -0
- package/dist/core/Zipkit.js +647 -0
- package/dist/core/Zipkit.js.map +1 -0
- package/dist/core/components/HashCalculator.d.ts +138 -0
- package/dist/core/components/HashCalculator.d.ts.map +1 -0
- package/dist/core/components/HashCalculator.js +360 -0
- package/dist/core/components/HashCalculator.js.map +1 -0
- package/dist/core/components/Logger.d.ts +73 -0
- package/dist/core/components/Logger.d.ts.map +1 -0
- package/dist/core/components/Logger.js +156 -0
- package/dist/core/components/Logger.js.map +1 -0
- package/dist/core/components/ProgressTracker.d.ts +43 -0
- package/dist/core/components/ProgressTracker.d.ts.map +1 -0
- package/dist/core/components/ProgressTracker.js +112 -0
- package/dist/core/components/ProgressTracker.js.map +1 -0
- package/dist/{shared → core}/components/Support.d.ts +1 -0
- package/dist/core/components/Support.d.ts.map +1 -0
- package/dist/{shared → core}/components/Support.js +1 -0
- package/dist/core/components/Support.js.map +1 -0
- package/dist/{shared → core}/components/Util.d.ts +7 -2
- package/dist/core/components/Util.d.ts.map +1 -0
- package/dist/{shared → core}/components/Util.js +14 -34
- package/dist/core/components/Util.js.map +1 -0
- package/dist/{shared → core}/constants/Errors.d.ts +1 -2
- package/dist/core/constants/Errors.d.ts.map +1 -0
- package/dist/{shared → core}/constants/Errors.js +1 -3
- package/dist/core/constants/Errors.js.map +1 -0
- package/dist/{shared → core}/constants/Headers.d.ts +3 -0
- package/dist/core/constants/Headers.d.ts.map +1 -0
- package/dist/{shared → core}/constants/Headers.js +20 -17
- package/dist/core/constants/Headers.js.map +1 -0
- package/dist/core/encryption/Manager.d.ts +58 -0
- package/dist/core/encryption/Manager.d.ts.map +1 -0
- package/dist/core/encryption/Manager.js +121 -0
- package/dist/core/encryption/Manager.js.map +1 -0
- package/dist/core/encryption/ZipCrypto.d.ts +172 -0
- package/dist/core/encryption/ZipCrypto.d.ts.map +1 -0
- package/dist/core/encryption/ZipCrypto.js +554 -0
- package/dist/core/encryption/ZipCrypto.js.map +1 -0
- package/dist/core/encryption/index.d.ts +9 -0
- package/dist/core/encryption/index.d.ts.map +1 -0
- package/dist/core/encryption/index.js +17 -0
- package/dist/core/encryption/index.js.map +1 -0
- package/dist/core/encryption/types.d.ts +29 -0
- package/dist/core/encryption/types.d.ts.map +1 -0
- package/dist/core/encryption/types.js +12 -0
- package/dist/core/encryption/types.js.map +1 -0
- package/dist/core/index.d.ts +24 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +57 -0
- package/dist/core/index.js.map +1 -0
- package/dist/{shared → core}/version.d.ts +1 -0
- package/dist/core/version.d.ts.map +1 -0
- package/dist/core/version.js +31 -0
- package/dist/core/version.js.map +1 -0
- package/dist/index.d.ts +8 -25
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -47
- package/dist/index.js.map +1 -0
- package/dist/node/ZipCompressNode.d.ts +123 -0
- package/dist/node/ZipCompressNode.d.ts.map +1 -0
- package/dist/node/ZipCompressNode.js +576 -0
- package/dist/node/ZipCompressNode.js.map +1 -0
- package/dist/node/ZipDecompressNode.d.ts +120 -0
- package/dist/node/ZipDecompressNode.d.ts.map +1 -0
- package/dist/node/ZipDecompressNode.js +461 -0
- package/dist/node/ZipDecompressNode.js.map +1 -0
- package/dist/node/ZipkitNode.d.ts +406 -0
- package/dist/node/ZipkitNode.d.ts.map +1 -0
- package/dist/node/ZipkitNode.js +1305 -0
- package/dist/node/ZipkitNode.js.map +1 -0
- package/dist/node/index.d.ts +26 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +65 -0
- package/dist/node/index.js.map +1 -0
- package/dist/types/index.d.ts +59 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +36 -1
- package/dist/types/index.js.map +1 -0
- package/examples/README.md +269 -0
- package/examples/blockchain-tokenize.ts +354 -0
- package/examples/create-zip.ts +172 -0
- package/examples/extract-zip.ts +158 -0
- package/examples/list-zip.ts +161 -0
- package/examples/test-files/data.json +116 -0
- package/examples/test-files/document.md +80 -0
- package/examples/test-files/document.txt +2 -0
- package/examples/test-files/file1.txt +48 -0
- package/examples/test-files/file2.txt +80 -0
- package/examples/tsconfig.json +44 -0
- package/examples/unzip-token.ts +6 -3
- package/examples/verify-tokenized-zip.ts +305 -0
- package/package.json +117 -23
- package/src/blockchain/README.md +222 -0
- package/src/{browser → blockchain/browser}/TokenVerifierBrowser.ts +125 -79
- package/src/blockchain/browser/WalletManagerBrowser.ts +486 -0
- package/src/blockchain/browser/ZipkitMinterBrowser.ts +400 -0
- package/src/blockchain/browser/index.ts +13 -0
- package/src/blockchain/core/WalletManager.ts +436 -0
- package/src/blockchain/core/ZipkitMinter.ts +716 -0
- package/src/blockchain/core/ZipkitOTS.ts +588 -0
- package/src/blockchain/core/ZipkitVerifier.ts +853 -0
- package/src/blockchain/core/contracts.ts +370 -0
- package/src/blockchain/core/index.ts +71 -0
- package/src/blockchain/index.ts +27 -0
- package/src/blockchain/node/WalletManagerNode.ts +171 -0
- package/src/blockchain/node/index.ts +40 -0
- package/src/browser/{ZipKitBrowser.ts → ZipkitBrowser.ts} +104 -41
- package/src/browser/index.esm.ts +37 -0
- package/src/browser/index.ts +25 -0
- package/src/core/ZipCompress.ts +398 -0
- package/src/core/ZipDecompress.ts +212 -0
- package/src/{shared → core}/ZipEntry.ts +239 -89
- package/src/core/Zipkit.ts +794 -0
- package/src/core/components/HashCalculator.ts +384 -0
- package/src/core/components/Logger.ts +180 -0
- package/src/core/components/ProgressTracker.ts +134 -0
- package/src/{shared → core}/components/Util.ts +12 -34
- package/src/{shared → core}/constants/Errors.ts +0 -4
- package/src/{shared → core}/constants/Headers.ts +19 -17
- package/src/core/encryption/Manager.ts +137 -0
- package/src/core/encryption/ZipCrypto.ts +650 -0
- package/src/core/encryption/index.ts +15 -0
- package/src/core/encryption/types.ts +33 -0
- package/src/core/index.ts +34 -0
- package/src/core/version.ts +33 -0
- package/src/index.ts +54 -32
- package/src/node/ZipCompressNode.ts +632 -0
- package/src/node/ZipDecompressNode.ts +508 -0
- package/src/node/ZipkitNode.ts +1559 -0
- package/src/node/index.ts +69 -0
- package/src/types/index.ts +131 -1
- package/src/types/opentimestamps.d.ts +1 -23
- package/contracts/Lock.sol +0 -34
- package/contracts/bytecode.txt +0 -1
- 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/ZipKitBrowser.d.ts +0 -18
- package/dist/browser/ZipKitStampBrowser.d.ts +0 -2
- package/dist/browser/ZipKitStampBrowser.js +0 -12
- package/dist/browser-index.d.ts +0 -21
- package/dist/browser-index.js +0 -58
- package/dist/server/blockchain/CertificateToken.d.ts +0 -48
- package/dist/server/blockchain/CertificateToken.js +0 -386
- 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/blockchain/types.d.ts +0 -69
- package/dist/server/blockchain/types.js +0 -51
- package/dist/server/platform/server/ZipKitServer.d.ts +0 -105
- package/dist/server/platform/server/ZipKitServer.js +0 -437
- package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +0 -91
- package/dist/server/platform/servercomponents/ZipKitOTS.js +0 -271
- package/dist/shared/ZipKit.d.ts +0 -249
- package/dist/shared/ZipKit.js +0 -789
- package/dist/shared/components/CertificateOTS.d.ts +0 -15
- package/dist/shared/components/CertificateOTS.js +0 -116
- package/dist/shared/components/FileSys.d.ts +0 -2
- package/dist/shared/components/FileSys.js +0 -113
- package/dist/shared/components/HashAccumulator.d.ts +0 -55
- package/dist/shared/components/HashAccumulator.js +0 -100
- package/dist/shared/components/ZipCrypto.d.ts +0 -3
- package/dist/shared/components/ZipCrypto.js +0 -78
- package/dist/shared/components/merkleTree.d.ts +0 -66
- package/dist/shared/components/merkleTree.js +0 -136
- package/dist/shared/types/index.d.ts +0 -21
- package/dist/shared/types/index.js +0 -3
- package/dist/shared/types.d.ts +0 -33
- package/dist/shared/types.js +0 -8
- package/dist/shared/version.js +0 -7
- package/src/browser/CertificateGeneratorBrowser.ts +0 -498
- package/src/browser/ZipKitStampBrowser.ts +0 -9
- package/src/browser-index.ts +0 -36
- package/src/server/blockchain/CertificateToken.ts +0 -444
- 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/constants.ts +0 -969
- 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/src/shared/ZipKit.ts +0 -899
- package/src/shared/components/CertificateOTS.ts +0 -132
- package/src/shared/components/FileSys.ts +0 -87
- package/src/shared/components/HashAccumulator.ts +0 -113
- package/src/shared/components/ZipCrypto.ts +0 -91
- package/src/shared/components/merkleTree.ts +0 -162
- package/src/shared/types/index.ts +0 -25
- package/src/shared/types/modules.d.ts +0 -22
- package/src/shared/types/opentimestamps.d.ts +0 -23
- package/src/shared/types.d.ts +0 -8
- package/src/shared/types.ts +0 -43
- package/src/shared/version.ts +0 -4
- /package/src/{shared → core}/components/Support.ts +0 -0
package/README.md
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
# neozipkit
|
|
2
2
|
|
|
3
|
+
> **⚠️ Alpha Release Notice**: This is an alpha/pre-release version (0.3.0). The API may change before the stable 1.0.0 release. Use with caution in production environments.
|
|
4
|
+
|
|
3
5
|
Advanced ZIP file creation and verification library with blockchain timestamping and NFT tokenization capabilities.
|
|
4
6
|
|
|
5
7
|
## 🌟 Features
|
|
6
8
|
|
|
7
9
|
- **Advanced ZIP compression** with support for multiple compression methods (Deflate, ZStandard, Stored)
|
|
8
|
-
- **
|
|
10
|
+
- **Streaming compression** for memory-efficient processing of large files
|
|
9
11
|
- **NFT tokenization** for creating blockchain-backed ZIP file certificates
|
|
10
12
|
- **Hash-based verification** with Merkle tree support
|
|
11
|
-
- **
|
|
13
|
+
- **Blockchain timestamping** using OpenTimestamps for file integrity verification
|
|
14
|
+
- **Real-time progress tracking** for long-running operations
|
|
15
|
+
- **Browser and Node.js compatibility** with clean platform separation
|
|
12
16
|
- **TypeScript support** with full type definitions
|
|
13
17
|
|
|
14
18
|
## 📦 Installation
|
|
@@ -19,101 +23,164 @@ yarn add neozipkit
|
|
|
19
23
|
|
|
20
24
|
## 🚀 Quick Start
|
|
21
25
|
|
|
22
|
-
### Basic
|
|
26
|
+
### Basic Usage
|
|
23
27
|
|
|
28
|
+
NeoZipKit provides both browser and Node.js implementations for creating, extracting, and managing ZIP files.
|
|
29
|
+
|
|
30
|
+
**Node.js:**
|
|
24
31
|
```typescript
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const zipKit = new ZipKitBrowser();
|
|
29
|
-
const options: CompressOptions = {
|
|
30
|
-
useZstd: false, // Use deflate compression
|
|
31
|
-
level: 6
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Add files to ZIP
|
|
35
|
-
await zipKit.addFile('example.txt', fileBuffer, options);
|
|
36
|
-
const zipBuffer = await zipKit.finalize();
|
|
37
|
-
```
|
|
32
|
+
import { ZipkitNode } from 'neozipkit/node';
|
|
33
|
+
|
|
34
|
+
const zip = new ZipkitNode();
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
// Create a ZIP from files
|
|
37
|
+
await zip.createZipFromFiles(['file1.txt', 'file2.txt'], 'output.zip');
|
|
40
38
|
|
|
39
|
+
// Extract a ZIP file
|
|
40
|
+
await zip.extractZipFile('archive.zip', './output');
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Browser:**
|
|
41
44
|
```typescript
|
|
42
|
-
import {
|
|
43
|
-
|
|
45
|
+
import { ZipkitBrowser } from 'neozipkit/browser-esm';
|
|
46
|
+
|
|
47
|
+
const zip = new ZipkitBrowser();
|
|
48
|
+
await zip.addFile(file, { level: 6 });
|
|
49
|
+
const zipBlob = await zip.createZipBlob();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Examples
|
|
53
|
+
|
|
54
|
+
Complete, runnable examples are available in the `examples/` directory:
|
|
44
55
|
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
- **`examples/create-zip.ts`** - Create ZIP archives from multiple files
|
|
57
|
+
- **`examples/extract-zip.ts`** - Extract ZIP files to directories
|
|
58
|
+
- **`examples/list-zip.ts`** - List ZIP archive contents
|
|
59
|
+
- **`examples/blockchain-tokenize.ts`** - Create tokenized ZIP files with NFT minting
|
|
60
|
+
- **`examples/verify-tokenized-zip.ts`** - Verify tokenized ZIP files on blockchain
|
|
47
61
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
console.log(`${entry.filename}: ${isValid ? 'Valid' : 'Invalid'}`);
|
|
52
|
-
}
|
|
62
|
+
Run examples with:
|
|
63
|
+
```bash
|
|
64
|
+
ts-node examples/create-zip.ts
|
|
53
65
|
```
|
|
54
66
|
|
|
67
|
+
See [`examples/README.md`](examples/README.md) for detailed usage instructions and all available examples.
|
|
68
|
+
|
|
69
|
+
**Note:** The browser bundle includes all necessary polyfills (Buffer, crypto) automatically. No additional configuration is required.
|
|
70
|
+
|
|
55
71
|
## 🏗️ Package Architecture
|
|
56
72
|
|
|
57
|
-
###
|
|
73
|
+
### Source Code Structure
|
|
58
74
|
|
|
59
75
|
```
|
|
60
|
-
|
|
61
|
-
├──
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
│
|
|
70
|
-
│
|
|
71
|
-
│
|
|
72
|
-
│
|
|
73
|
-
|
|
74
|
-
│
|
|
75
|
-
│
|
|
76
|
-
|
|
77
|
-
│
|
|
78
|
-
│
|
|
79
|
-
│
|
|
80
|
-
│
|
|
81
|
-
|
|
82
|
-
│
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
│ ├──
|
|
86
|
-
│ ├──
|
|
87
|
-
│
|
|
88
|
-
|
|
89
|
-
├──
|
|
90
|
-
|
|
76
|
+
src/
|
|
77
|
+
├── Zipkit.ts # Core ZipKit class with buffer-based ZIP operations
|
|
78
|
+
├── ZipEntry.ts # ZIP entry handling
|
|
79
|
+
├── ZipCompress.ts # Compression algorithms
|
|
80
|
+
├── ZipDecompress.ts # Decompression algorithms
|
|
81
|
+
├── Logger.ts # Logging utility
|
|
82
|
+
├── types.ts # Shared type definitions
|
|
83
|
+
├── version.ts # Version information
|
|
84
|
+
├── components/ # Core ZIP utilities
|
|
85
|
+
│ ├── HashCalculator.ts # Unified hash calculator (incremental hashing, accumulation, Merkle tree)
|
|
86
|
+
│ ├── ProgressTracker.ts # Progress tracking
|
|
87
|
+
│ ├── Support.ts # Feature support detection
|
|
88
|
+
│ └── Util.ts # General utilities (CRC32 delegates to ZipCrypto)
|
|
89
|
+
├── constants/ # Constants and definitions
|
|
90
|
+
│ ├── Errors.ts # Error definitions
|
|
91
|
+
│ └── Headers.ts # ZIP header constants
|
|
92
|
+
├── encryption/ # Encryption utilities
|
|
93
|
+
│ ├── index.ts # Encryption exports
|
|
94
|
+
│ ├── Manager.ts # Encryption manager (unified interface)
|
|
95
|
+
│ ├── types.ts # Encryption types
|
|
96
|
+
│ └── ZipCrypto.ts # ZIP crypto implementation (includes CRC32)
|
|
97
|
+
├── browser/ # Browser-only implementations
|
|
98
|
+
│ ├── ZipkitBrowser.ts # Browser ZIP operations with Blob support
|
|
99
|
+
│ └── index.ts # Browser-specific exports
|
|
100
|
+
├── node/ # Node.js-only implementations
|
|
101
|
+
│ ├── ZipkitNode.ts # Node.js file-based ZIP operations (extends Zipkit)
|
|
102
|
+
│ ├── ZipCompressNode.ts # Node.js compression with file I/O
|
|
103
|
+
│ ├── ZipDecompressNode.ts # Node.js decompression with file I/O
|
|
104
|
+
│ └── index.ts # Node.js exports
|
|
105
|
+
├── blockchain/ # Blockchain integration module
|
|
106
|
+
│ ├── core/ # Core blockchain functionality
|
|
107
|
+
│ │ ├── ZipkitOTS.ts # OpenTimestamps utilities
|
|
108
|
+
│ │ ├── ZipkitVerifier.ts # Token verification
|
|
109
|
+
│ │ ├── ZipkitMinter.ts # NFT minting
|
|
110
|
+
│ │ ├── WalletManager.ts # Core wallet management
|
|
111
|
+
│ │ ├── contracts.ts # Contract addresses & ABIs
|
|
112
|
+
│ │ ├── types.ts # Blockchain types
|
|
113
|
+
│ │ └── index.ts # Core exports
|
|
114
|
+
│ ├── browser/ # Browser blockchain components
|
|
115
|
+
│ │ ├── WalletManagerBrowser.ts # Browser wallet management
|
|
116
|
+
│ │ ├── ZipkitMinterBrowser.ts # Browser minting
|
|
117
|
+
│ │ ├── TokenVerifierBrowser.ts # Browser token verification
|
|
118
|
+
│ │ └── index.ts # Browser exports
|
|
119
|
+
│ ├── node/ # Node.js blockchain components
|
|
120
|
+
│ │ └── WalletManagerNode.ts # Node.js wallet management (file system)
|
|
121
|
+
│ │ └── index.ts # Node.js exports
|
|
122
|
+
│ ├── index.ts # Main blockchain exports
|
|
123
|
+
│ └── README.md # Blockchain module documentation
|
|
124
|
+
├── types/ # External module declarations
|
|
125
|
+
│ ├── index.ts # Type exports
|
|
126
|
+
│ ├── modules.d.ts # Module declarations
|
|
127
|
+
│ └── opentimestamps.d.ts # OpenTimestamps type definitions
|
|
128
|
+
└── index.ts # Main exports (all platforms)
|
|
91
129
|
```
|
|
92
130
|
|
|
131
|
+
### Architecture
|
|
132
|
+
|
|
133
|
+
NeoZipKit provides platform-specific implementations optimized for different environments:
|
|
134
|
+
|
|
135
|
+
- **`ZipkitBrowser`** - Browser implementation using Blob API for memory-efficient operations
|
|
136
|
+
- **`ZipkitNode`** - Node.js implementation with file-based streaming for large files
|
|
137
|
+
|
|
138
|
+
Both implementations support:
|
|
139
|
+
- Multiple compression methods (Deflate, ZStandard, Stored)
|
|
140
|
+
- Streaming for large files
|
|
141
|
+
- Progress tracking
|
|
142
|
+
- Hash verification (CRC-32, SHA-256)
|
|
143
|
+
|
|
93
144
|
## 📚 Import Patterns
|
|
94
145
|
|
|
95
146
|
### Browser Applications (Recommended)
|
|
96
147
|
|
|
97
148
|
```typescript
|
|
98
149
|
// Browser-only bundle (excludes Node.js dependencies)
|
|
99
|
-
import {
|
|
100
|
-
import {
|
|
150
|
+
import { ZipkitBrowser } from 'neozipkit/browser';
|
|
151
|
+
import { TokenMetadata } from 'neozipkit/browser';
|
|
101
152
|
```
|
|
102
153
|
|
|
103
154
|
### Universal Applications (Next.js, Node.js)
|
|
104
155
|
|
|
105
156
|
```typescript
|
|
106
|
-
// Main bundle
|
|
107
|
-
import
|
|
108
|
-
import {
|
|
157
|
+
// Main bundle
|
|
158
|
+
import Zipkit from 'neozipkit';
|
|
159
|
+
import { createTimestamp, verifyOts } from 'neozipkit/blockchain';
|
|
160
|
+
import { TokenMetadata } from 'neozipkit';
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Node.js-Only Components
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
// Node.js-specific components
|
|
167
|
+
import { ZipkitNode } from 'neozipkit/node';
|
|
168
|
+
import { ZipCompress } from 'neozipkit';
|
|
169
|
+
import { createTimestamp, verifyOts } from 'neozipkit/blockchain';
|
|
170
|
+
import { ZipkitVerifier, ZipkitMinter } from 'neozipkit/blockchain';
|
|
109
171
|
```
|
|
110
172
|
|
|
111
|
-
###
|
|
173
|
+
### Blockchain Components
|
|
112
174
|
|
|
113
175
|
```typescript
|
|
114
|
-
//
|
|
115
|
-
import {
|
|
116
|
-
|
|
176
|
+
// Blockchain functionality (works in both browser and Node.js)
|
|
177
|
+
import {
|
|
178
|
+
ZipkitVerifier,
|
|
179
|
+
ZipkitMinter,
|
|
180
|
+
WalletManager,
|
|
181
|
+
createTimestamp,
|
|
182
|
+
verifyOts
|
|
183
|
+
} from 'neozipkit/blockchain';
|
|
117
184
|
```
|
|
118
185
|
|
|
119
186
|
## 🔗 Blockchain Integration
|
|
@@ -133,30 +200,17 @@ NeoZipKit includes comprehensive blockchain integration for creating and verifyi
|
|
|
133
200
|
- **`TokenVerifier`** - Verify tokenized ZIP files against blockchain
|
|
134
201
|
- **`NFTMinter`** - Mint NFTs for ZIP files
|
|
135
202
|
- **`TokenQuerier`** - Query token information from blockchain
|
|
136
|
-
- **`
|
|
203
|
+
- **`TokenCertificate`** - Generate certificates for tokenized files
|
|
137
204
|
- **`ZipTokenProcessor`** - Process ZIP files for tokenization
|
|
138
205
|
- **`WalletManager`** - Manage wallet connections and networks
|
|
139
206
|
|
|
140
|
-
### Usage
|
|
207
|
+
### Usage
|
|
141
208
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
network: 'base-sepolia',
|
|
148
|
-
mintToken: true
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const processor = new ZipTokenProcessor('archive.zip', 'merkle_root_hash', options);
|
|
152
|
-
const result = await processor.processZipToken(options);
|
|
153
|
-
|
|
154
|
-
if (result.error) {
|
|
155
|
-
console.error('Processing failed:', result.error);
|
|
156
|
-
} else {
|
|
157
|
-
console.log('Success!', result);
|
|
158
|
-
}
|
|
159
|
-
```
|
|
209
|
+
See the blockchain examples for complete implementations:
|
|
210
|
+
- **`examples/blockchain-tokenize.ts`** - Create and mint tokenized ZIP files
|
|
211
|
+
- **`examples/verify-tokenized-zip.ts`** - Verify tokenized ZIP files on blockchain
|
|
212
|
+
|
|
213
|
+
For detailed blockchain integration documentation, see [`src/blockchain/README.md`](src/blockchain/README.md).
|
|
160
214
|
|
|
161
215
|
## 🎯 Smart Contracts
|
|
162
216
|
|
|
@@ -170,60 +224,38 @@ The package includes production-ready smart contracts for ZIP file tokenization:
|
|
|
170
224
|
- **Use cases**: Certificates, public records, open-source projects
|
|
171
225
|
- **Symbol**: `NZIP`
|
|
172
226
|
|
|
173
|
-
#### 🔒 Private Contract (`NZIP-NFT-Private.sol`)
|
|
174
|
-
- **Owner-only verification** - Only token owners can verify their tokens
|
|
175
|
-
- **Private blockchain metadata** - Sensitive data hidden from public
|
|
176
|
-
- **Selective authorization** - Owners can authorize specific verifiers
|
|
177
|
-
- **Use cases**: Medical records, legal documents, private archives
|
|
178
|
-
- **Symbol**: `NZIPPRV`
|
|
179
227
|
|
|
180
228
|
### Current Deployment
|
|
181
229
|
|
|
182
|
-
**✅ Production Contract (v2.
|
|
230
|
+
**✅ Production Contract (v2.10)**:
|
|
183
231
|
```
|
|
184
|
-
Address:
|
|
232
|
+
Address: 0x6313074922717351986929879903441992482216
|
|
185
233
|
Network: Base Sepolia
|
|
186
|
-
Version: 2.
|
|
234
|
+
Version: 2.10.0
|
|
187
235
|
Status: ✅ ACTIVE - Use for all new integrations
|
|
188
|
-
Explorer: https://sepolia.basescan.org/address/
|
|
236
|
+
Explorer: https://sepolia.basescan.org/address/0x6313074922717351986929879903441992482216
|
|
189
237
|
```
|
|
190
238
|
|
|
191
239
|
### Contract Deployment
|
|
192
240
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
```bash
|
|
196
|
-
# Setup deployment configuration
|
|
197
|
-
npm run setup-deployment
|
|
198
|
-
|
|
199
|
-
# Deploy both contracts (public + private)
|
|
200
|
-
npm run deploy:both
|
|
241
|
+
For contract deployment and verification, see [`contracts/README.md`](contracts/README.md) for complete instructions.
|
|
201
242
|
|
|
202
|
-
|
|
203
|
-
npm run deploy:public
|
|
204
|
-
|
|
205
|
-
# Deploy to mainnet
|
|
206
|
-
npm run deploy:both:mainnet
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
## 🔧 Development Workflow
|
|
243
|
+
## 🔧 Development
|
|
210
244
|
|
|
211
245
|
### Build Process
|
|
212
246
|
|
|
213
247
|
```bash
|
|
214
|
-
#
|
|
215
|
-
|
|
248
|
+
# Production build
|
|
249
|
+
yarn build
|
|
216
250
|
|
|
217
|
-
#
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
251
|
+
# Development build (for feature branches)
|
|
252
|
+
yarn dev:build
|
|
253
|
+
|
|
254
|
+
# Watch mode
|
|
255
|
+
yarn dev:watch
|
|
221
256
|
```
|
|
222
257
|
|
|
223
|
-
|
|
224
|
-
1. `npm run clean` - Removes old compiled files
|
|
225
|
-
2. `npm run compile` - Compiles TypeScript to dist/
|
|
226
|
-
3. `npm run create-browser-entry` - Creates browser-only bundle
|
|
258
|
+
See [`docs/DEV_BUILD.md`](docs/DEV_BUILD.md) for details on the development build system.
|
|
227
259
|
|
|
228
260
|
### TypeScript Configuration
|
|
229
261
|
|
|
@@ -235,58 +267,207 @@ This runs:
|
|
|
235
267
|
|
|
236
268
|
## 📖 API Reference
|
|
237
269
|
|
|
270
|
+
### Zipkit Class
|
|
271
|
+
|
|
272
|
+
**Zipkit** is the core ZIP file processing library with dual-mode support for efficient handling of ZIP archives of any size.
|
|
273
|
+
|
|
274
|
+
#### Architecture
|
|
275
|
+
|
|
276
|
+
Zipkit uses a dual-mode architecture:
|
|
277
|
+
- **Buffer-based mode**: Entire ZIP file is loaded into memory for fast random access. Ideal for small to medium archives (< 100MB).
|
|
278
|
+
- **File-based mode**: ZIP file is accessed via file handles with chunked reading/writing. Ideal for large archives (> 100MB) to minimize memory usage.
|
|
279
|
+
|
|
280
|
+
#### Core Components
|
|
281
|
+
|
|
282
|
+
- **ZipCompress**: Handles compression of ZIP entries (STORED, DEFLATED, ZSTD)
|
|
283
|
+
- **ZipDecompress**: Handles decompression of ZIP entries with streaming support
|
|
284
|
+
- **Zipkit**: Core class that manages parsing and loading of ZIP file structure (buffer-based)
|
|
285
|
+
- **ZipkitNode**: Extends Zipkit with file-based operations for Node.js environments
|
|
286
|
+
- **zipEntries[]**: Protected array that serves as the single source of truth for ZIP entry order and metadata (accessible by subclasses, use `getDirectory()` for external access)
|
|
287
|
+
|
|
288
|
+
#### Entry Management
|
|
289
|
+
|
|
290
|
+
The `zipEntries[]` array is the central repository for all ZIP entries. It maintains the order of entries as they appear in the ZIP file's Central Directory, ensuring consistency between write order and read order. Entries are automatically added to this array when:
|
|
291
|
+
- Loading an existing ZIP file via `loadZip()` or `loadZipFile()`
|
|
292
|
+
- Creating new entries via `createZipEntry()`
|
|
293
|
+
|
|
294
|
+
**Note**: The `zipEntries[]` array is now **protected** (not public). External code should use `getDirectory()` to access entries. Subclasses (like `ZipkitNode` and `ZipkitBrowser`) can still access it directly.
|
|
295
|
+
|
|
296
|
+
#### Usage Patterns
|
|
297
|
+
|
|
298
|
+
See the examples directory for complete usage patterns:
|
|
299
|
+
- **Creating ZIPs**: `examples/create-zip.ts`
|
|
300
|
+
- **Extracting ZIPs**: `examples/extract-zip.ts`
|
|
301
|
+
- **Listing ZIPs**: `examples/list-zip.ts`
|
|
302
|
+
|
|
303
|
+
#### Compression Methods
|
|
304
|
+
|
|
305
|
+
Zipkit supports three compression methods:
|
|
306
|
+
- **STORED (0)**: No compression, data stored as-is
|
|
307
|
+
- **DEFLATED (8)**: Standard deflate compression (default)
|
|
308
|
+
- **ZSTD (93)**: Zstandard compression (faster, modern algorithm)
|
|
309
|
+
|
|
310
|
+
#### Hash Calculation
|
|
311
|
+
|
|
312
|
+
Zipkit calculates and verifies file integrity using:
|
|
313
|
+
- **CRC-32**: Standard ZIP checksum (always calculated via `ZipCrypto.crc32()`)
|
|
314
|
+
- **SHA-256**: Optional cryptographic hash for enhanced security
|
|
315
|
+
|
|
316
|
+
#### ZipDecompress Component
|
|
317
|
+
|
|
318
|
+
ZipDecompress is the decompression component of Zipkit, responsible for:
|
|
319
|
+
- Extracting entries from ZIP archives (buffer-based or file-based)
|
|
320
|
+
- Decompressing data using STORED, DEFLATED, or ZSTD methods
|
|
321
|
+
- Verifying file integrity via CRC-32 or SHA-256 hashes
|
|
322
|
+
- Streaming decompression for memory-efficient extraction of large files
|
|
323
|
+
|
|
324
|
+
**Methods:**
|
|
325
|
+
- `extract(entry, skipHashCheck?)`: Extracts a ZIP entry from a buffer-based ZIP archive
|
|
326
|
+
- `extractToFile(entry, outputPath, options?)`: Extracts a ZIP entry directly to disk with true streaming
|
|
327
|
+
|
|
328
|
+
**Supported Compression Methods:**
|
|
329
|
+
- **STORED (0)**: No decompression needed, data passed through unchanged
|
|
330
|
+
- **DEFLATED (8)**: Standard deflate decompression using pako library
|
|
331
|
+
- **ZSTD (93)**: Zstandard decompression (lazy initialization on first use)
|
|
332
|
+
|
|
333
|
+
**Hash Verification:**
|
|
334
|
+
By default, extracted data is verified against stored hashes:
|
|
335
|
+
- If entry has SHA-256 hash, it is verified
|
|
336
|
+
- Otherwise, CRC-32 checksum is verified
|
|
337
|
+
- Hash verification can be skipped by passing `skipHashCheck: true`
|
|
338
|
+
|
|
339
|
+
**Streaming Architecture:**
|
|
340
|
+
For file-based ZIPs, ZipDecompress uses a streaming architecture:
|
|
341
|
+
1. Reads compressed data in chunks from the ZIP file
|
|
342
|
+
2. Decompresses chunks incrementally
|
|
343
|
+
3. Writes decompressed chunks directly to output file
|
|
344
|
+
4. Calculates and verifies hash during decompression
|
|
345
|
+
|
|
346
|
+
#### ZipCompress Component
|
|
347
|
+
|
|
348
|
+
ZipCompress is the compression component of Zipkit, responsible for:
|
|
349
|
+
- Compressing data using STORED, DEFLATED, or ZSTD methods
|
|
350
|
+
- Calculating CRC-32 and SHA-256 hashes during compression
|
|
351
|
+
- Chunked processing for memory-efficient compression of large files
|
|
352
|
+
- Supporting both buffer-based and streaming compression modes
|
|
353
|
+
|
|
354
|
+
**Methods:**
|
|
355
|
+
- `compressData(entry, data, options?, onOutputBuffer?)`: Main compression entry point
|
|
356
|
+
- `deflateCompress(data, options?, bufferSize?, entry?, onOutputBuffer?)`: Compresses using deflate algorithm
|
|
357
|
+
- `zstdCompress(input, options?, bufferSize?, entry?, onOutputBuffer?)`: Compresses using Zstandard algorithm
|
|
358
|
+
|
|
359
|
+
**Compression Options:**
|
|
360
|
+
- `level`: Compression level 1-9 (0 = store, default: 6)
|
|
361
|
+
- `useSHA256`: Calculate SHA-256 hash in addition to CRC-32 (default: false)
|
|
362
|
+
- `useZstd`: Use Zstandard compression instead of deflate (default: false)
|
|
363
|
+
- `bufferSize`: Override default buffer size for chunked processing (default: 512KB)
|
|
364
|
+
|
|
365
|
+
**Compression Method Selection:**
|
|
366
|
+
ZipCompress automatically selects the compression method based on options:
|
|
367
|
+
- **STORED**: If `options.level === 0` or file is too small for ZSTD (< 100 bytes)
|
|
368
|
+
- **ZSTD**: If `options.useZstd === true` and file is >= 100 bytes
|
|
369
|
+
- **DEFLATED**: Default method (standard ZIP compression)
|
|
370
|
+
|
|
371
|
+
**Hash Calculation:**
|
|
372
|
+
Hash calculation is performed incrementally during compression using HashCalculator:
|
|
373
|
+
- **CRC-32**: Always calculated for standard ZIP compatibility (via `ZipCrypto.crc32()`)
|
|
374
|
+
- **SHA-256**: Calculated if `options.useSHA256 === true`
|
|
375
|
+
|
|
376
|
+
**Chunked Processing:**
|
|
377
|
+
For large files, ZipCompress processes data in chunks for memory efficiency:
|
|
378
|
+
- **STORED**: Outputs chunks directly without accumulating
|
|
379
|
+
- **DEFLATED**: Streams compression using chunked reader, can output incrementally
|
|
380
|
+
- **ZSTD**: Accumulates all chunks, then compresses (requires full buffer)
|
|
381
|
+
|
|
382
|
+
**Streaming Output:**
|
|
383
|
+
When `onOutputBuffer` callback is provided, compressed data chunks are written incrementally as they are produced, allowing writing compressed data directly to output streams without accumulating everything in memory.
|
|
384
|
+
|
|
385
|
+
#### Merkle Root Calculation
|
|
386
|
+
|
|
387
|
+
For blockchain integration, Zipkit can calculate Merkle roots from entry SHA-256 hashes, automatically excluding metadata files (META-INF/*) to ensure consistent calculation across different ZIP creation methods.
|
|
388
|
+
|
|
238
389
|
### Core Classes
|
|
239
390
|
|
|
240
|
-
- **`ZipKit`** - Core ZIP functionality (shared)
|
|
241
|
-
- **`
|
|
242
|
-
- **`
|
|
391
|
+
- **`ZipKit`** - Core ZIP functionality (shared across all platforms, buffer-based)
|
|
392
|
+
- **`ZipkitBrowser`** - Browser-compatible ZIP operations (extends Zipkit, adds Blob support)
|
|
393
|
+
- **`ZipkitNode`** - Node.js file-based ZIP operations (extends Zipkit, adds file I/O)
|
|
243
394
|
- **`ZipEntry`** - ZIP entry representation and manipulation
|
|
244
|
-
- **`
|
|
395
|
+
- **`HashCalculator`** - Unified hash calculator supporting incremental hashing, hash accumulation, and Merkle tree operations
|
|
396
|
+
|
|
397
|
+
### Core Components
|
|
398
|
+
|
|
399
|
+
- **`ZipCompress`** - Compression algorithms (shared, handles both buffer and file modes)
|
|
400
|
+
- **`ZipDecompress`** - Decompression algorithms (shared, handles both buffer and file modes)
|
|
401
|
+
- **`ProgressTracker`** - Real-time progress tracking for operations
|
|
402
|
+
- **`EncryptionManager`** - Encryption manager (unified encryption interface)
|
|
403
|
+
- **`ZipCrypto`** - ZIP crypto implementation (includes CRC32 calculation)
|
|
404
|
+
|
|
405
|
+
### Blockchain Components
|
|
406
|
+
|
|
407
|
+
- **`ZipkitVerifier`** - Verify tokenized ZIP files against blockchain
|
|
408
|
+
- **`ZipkitMinter`** - Mint NFTs for ZIP files
|
|
409
|
+
- **`WalletManager`** - Manage wallet connections and networks
|
|
410
|
+
- **`createTimestamp`** - Create OpenTimestamps proofs
|
|
411
|
+
- **`verifyOts`** - Verify OpenTimestamps proofs
|
|
245
412
|
|
|
246
413
|
### Platform-Specific Components
|
|
247
414
|
|
|
415
|
+
#### Node.js Components
|
|
416
|
+
|
|
417
|
+
- **`ZipkitNode`** - Node.js file-based ZIP operations (extends Zipkit)
|
|
418
|
+
|
|
419
|
+
**File Loading:**
|
|
420
|
+
- `loadZipFile(filePath)` - Load ZIP from file path (asynchronous)
|
|
421
|
+
- `loadZipFromFile(filePath)` - Alias for `loadZipFile()`
|
|
422
|
+
|
|
423
|
+
**File Extraction:**
|
|
424
|
+
- `extractZipFile(archivePath, destination, options?)` - Extract entire ZIP file to directory (main unzip function with comprehensive options)
|
|
425
|
+
- `extractToFile(entry, outputPath, options?)` - Extract entry to file with streaming support
|
|
426
|
+
- `extractEntryToFile(entry, outputPath, options?)` - Alias for `extractToFile()`
|
|
427
|
+
- `extractEntryToPath(entry, outputPath, options?)` - Extract entry with advanced features (symlinks, hardlinks, timestamps, permissions)
|
|
428
|
+
- `extractAll(outputDir, options?)` - Extract all entries to directory with progress tracking
|
|
429
|
+
|
|
430
|
+
**File Compression:**
|
|
431
|
+
- `compressFile(filePath, entry, options?)` - Compress a file from disk
|
|
432
|
+
- `compressFileStream(filePath, entry, options?, onOutputBuffer?)` - Compress a file using streaming for large files
|
|
433
|
+
- `compressData(entry, data, options?, onOutputBuffer?)` - Compress data buffer (overrides base class)
|
|
434
|
+
|
|
435
|
+
**ZIP File Creation:**
|
|
436
|
+
- `createZipFromFiles(filePaths, outputPath, options?)` - Create a ZIP file from multiple file paths
|
|
437
|
+
- `addFileToZip(filePath, entryName?, options?)` - Add a file to the current ZIP
|
|
438
|
+
|
|
439
|
+
**Advanced ZIP Creation (Low-level API):**
|
|
440
|
+
- `initializeZipFile(outputPath)` - Initialize ZIP file for writing, returns ZipFileWriter
|
|
441
|
+
- `prepareEntryFromFile(filePath, entryName?)` - Prepare ZipEntry from file path with metadata
|
|
442
|
+
- `writeZipEntry(writer, entry, filePath, options?, callbacks?)` - Write a ZIP entry to the file
|
|
443
|
+
- `writeCentralDirectory(writer, entries, options?)` - Write central directory
|
|
444
|
+
- `writeEndOfCentralDirectory(writer, totalEntries, centralDirSize, centralDirOffset, comment?)` - Write end of central directory
|
|
445
|
+
- `finalizeZipFile(writer)` - Finalize and close ZIP file
|
|
446
|
+
|
|
447
|
+
**File Management:**
|
|
448
|
+
- `getFileHandle()` - Get underlying file handle for advanced operations
|
|
449
|
+
- `closeFile()` - Close file handle explicitly
|
|
450
|
+
- `copyEntry(entry)` - Copy entry from file-based ZIP (returns Buffer)
|
|
451
|
+
|
|
248
452
|
#### Browser Components
|
|
249
|
-
- **`CertificateGeneratorBrowser`** - Generate verification certificates
|
|
250
453
|
- **`TokenVerifierBrowser`** - Browser-based token verification
|
|
251
|
-
- **`
|
|
252
|
-
|
|
253
|
-
#### Server Components
|
|
254
|
-
- **`ZipKitOTS`** - OpenTimestamps integration
|
|
255
|
-
- **Blockchain Classes** - Complete blockchain integration suite
|
|
454
|
+
- **`WalletManagerBrowser`** - Browser wallet management
|
|
256
455
|
|
|
257
456
|
### Constants and Types
|
|
258
457
|
|
|
259
458
|
- **`constants/Headers`** - ZIP header constants and compression methods
|
|
260
459
|
- **`constants/Errors`** - Error definitions
|
|
261
|
-
- **`
|
|
460
|
+
- **`types`** - TypeScript type definitions
|
|
262
461
|
- **`CMP_METHOD`** - Compression method constants
|
|
263
462
|
|
|
264
463
|
### Compression Methods
|
|
265
464
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const compressionType = entry.cmpMethod;
|
|
271
|
-
|
|
272
|
-
if (compressionType === CMP_METHOD.ZSTD) {
|
|
273
|
-
console.log('ZStandard compression');
|
|
274
|
-
} else if (compressionType === CMP_METHOD.DEFLATED) {
|
|
275
|
-
console.log('Deflate compression');
|
|
276
|
-
} else if (compressionType === CMP_METHOD.STORED) {
|
|
277
|
-
console.log('No compression');
|
|
278
|
-
}
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### Hash Accumulation
|
|
465
|
+
Zipkit supports three compression methods:
|
|
466
|
+
- **STORED (0)**: No compression, data stored as-is
|
|
467
|
+
- **DEFLATED (8)**: Standard deflate compression (default)
|
|
468
|
+
- **ZSTD (93)**: Zstandard compression (faster, modern algorithm)
|
|
282
469
|
|
|
283
|
-
|
|
284
|
-
import { HashAccumulator } from 'neozipkit/shared/components/HashAccumulator';
|
|
285
|
-
|
|
286
|
-
const accumulator = new HashAccumulator();
|
|
287
|
-
accumulator.addFile('example.txt', fileBuffer);
|
|
288
|
-
const merkleRoot = accumulator.finalize();
|
|
289
|
-
```
|
|
470
|
+
See the examples for usage patterns with different compression methods.
|
|
290
471
|
|
|
291
472
|
## 🌐 Network Support
|
|
292
473
|
|
|
@@ -300,27 +481,34 @@ const merkleRoot = accumulator.finalize();
|
|
|
300
481
|
|
|
301
482
|
### Network Configuration
|
|
302
483
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
'base': {
|
|
307
|
-
chainId: 8453,
|
|
308
|
-
rpcUrl: 'https://mainnet.base.org',
|
|
309
|
-
explorer: 'https://basescan.org'
|
|
310
|
-
},
|
|
311
|
-
'base-sepolia': {
|
|
312
|
-
chainId: 84532,
|
|
313
|
-
rpcUrl: 'https://sepolia.base.org',
|
|
314
|
-
explorer: 'https://sepolia.basescan.org'
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
```
|
|
484
|
+
Network configurations are defined in `src/blockchain/core/contracts.ts`. Supported networks include Base Mainnet, Base Sepolia, Ethereum, Polygon, and Arbitrum.
|
|
485
|
+
|
|
486
|
+
See the blockchain examples for network usage.
|
|
318
487
|
|
|
319
488
|
## 🔐 Security Considerations
|
|
320
489
|
|
|
490
|
+
### Private Key Security
|
|
491
|
+
|
|
492
|
+
**CRITICAL**: Never commit private keys to version control or hardcode them in your code.
|
|
493
|
+
|
|
494
|
+
- ✅ **Use environment variables** - Store private keys in `.env` file (see `.env.example`)
|
|
495
|
+
- ✅ **Testnet only for examples** - Never use mainnet keys in examples
|
|
496
|
+
- ✅ **Exclude sensitive files** - Wallet files and `.env` files are automatically excluded from git
|
|
497
|
+
- ✅ **Secure key management for production** - Use HSMs or KMS for production applications
|
|
498
|
+
|
|
499
|
+
**Quick Security Checklist:**
|
|
500
|
+
- [ ] Private keys stored in environment variables (not hardcoded)
|
|
501
|
+
- [ ] `.env` file excluded from git (automatically via `.gitignore`)
|
|
502
|
+
- [ ] Wallet files excluded from git (automatically via `.gitignore`)
|
|
503
|
+
- [ ] Only testnet keys used for examples
|
|
504
|
+
- [ ] Secure key management for production deployments
|
|
505
|
+
|
|
506
|
+
For comprehensive security guidelines, see [SECURITY.md](SECURITY.md).
|
|
507
|
+
|
|
321
508
|
### Development Best Practices
|
|
322
509
|
|
|
323
510
|
- **Private Keys**: Never commit private keys or mnemonics to version control
|
|
511
|
+
- **Environment Variables**: Use `.env` file for private keys (see `.env.example` template)
|
|
324
512
|
- **Network Security**: Use secure RPC endpoints and validate all inputs
|
|
325
513
|
- **Smart Contract Audits**: Audit contracts before production deployment
|
|
326
514
|
- **Error Handling**: Implement comprehensive error handling for all operations
|
|
@@ -346,33 +534,14 @@ const networkConfig = {
|
|
|
346
534
|
- **`@types/node`** - Node.js type definitions
|
|
347
535
|
- **`typescript`** - TypeScript compiler
|
|
348
536
|
|
|
349
|
-
## 🔄 Migration Guide
|
|
350
|
-
|
|
351
|
-
### From Previous Versions
|
|
352
|
-
|
|
353
|
-
If upgrading from previous versions:
|
|
354
|
-
|
|
355
|
-
1. **Update Import Paths**:
|
|
356
|
-
```typescript
|
|
357
|
-
// OLD
|
|
358
|
-
import { TokenVerifier } from 'neozipkit/server-components/blockchain/TokenVerifier';
|
|
359
|
-
|
|
360
|
-
// NEW
|
|
361
|
-
import { checkForTokenizationServer } from 'neozipkit/server/blockchain/TokenVerifier';
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
2. **Browser Imports**: Replace main package imports with browser-specific imports for browser applications
|
|
365
|
-
3. **Contract Addresses**: Update to use the new production contract address
|
|
366
|
-
4. **Build Process**: Remove any manual copying scripts - everything now uses TypeScript compilation
|
|
367
|
-
|
|
368
537
|
## 🤝 Contributing
|
|
369
538
|
|
|
370
539
|
### Development Setup
|
|
371
540
|
|
|
372
|
-
1. Clone the repository and install dependencies
|
|
541
|
+
1. Clone the repository and install dependencies: `yarn install`
|
|
373
542
|
2. Make changes to TypeScript files in `src/`
|
|
374
|
-
3. Run `
|
|
375
|
-
4. Test changes
|
|
543
|
+
3. Run `yarn dev:build` for development builds
|
|
544
|
+
4. Test changes using the examples: `ts-node examples/create-zip.ts`
|
|
376
545
|
5. Commit only source files, not generated files
|
|
377
546
|
|
|
378
547
|
### Making Changes
|
|
@@ -381,7 +550,9 @@ If upgrading from previous versions:
|
|
|
381
550
|
- Update exports in `src/index.ts` if adding new public modules
|
|
382
551
|
- Update `package.json` exports if creating new public modules
|
|
383
552
|
- Run build process to generate JavaScript
|
|
384
|
-
- Test
|
|
553
|
+
- Test using examples before submitting PRs
|
|
554
|
+
|
|
555
|
+
For detailed contributing guidelines, see [`docs/REPOSITORY_MANAGEMENT.md`](docs/REPOSITORY_MANAGEMENT.md).
|
|
385
556
|
|
|
386
557
|
## 📄 License
|
|
387
558
|
|
|
@@ -392,9 +563,9 @@ MIT
|
|
|
392
563
|
Ready to start using NeoZipKit? Here are some next steps:
|
|
393
564
|
|
|
394
565
|
1. **Install the package**: `yarn add neozipkit`
|
|
395
|
-
2. **
|
|
396
|
-
3. **
|
|
397
|
-
4. **
|
|
398
|
-
5. **
|
|
566
|
+
2. **Run the examples**: Start with `ts-node examples/create-zip.ts` to see basic usage
|
|
567
|
+
3. **Explore the examples**: Check [`examples/README.md`](examples/README.md) for all available examples
|
|
568
|
+
4. **Read the API docs**: See the API Reference section below for detailed method documentation
|
|
569
|
+
5. **Try blockchain features**: Run `examples/blockchain-tokenize.ts` for NFT tokenization
|
|
399
570
|
|
|
400
|
-
For detailed examples and advanced usage, explore the examples directory and blockchain integration
|
|
571
|
+
For detailed examples and advanced usage, explore the `examples/` directory and [`src/blockchain/README.md`](src/blockchain/README.md) for blockchain integration.
|