neozipkit 0.2.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 +410 -186
- 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 +235 -131
- 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/blockchain/browser/TokenVerifierBrowser.d.ts +67 -0
- package/dist/blockchain/browser/TokenVerifierBrowser.d.ts.map +1 -0
- package/dist/blockchain/browser/TokenVerifierBrowser.js +313 -0
- 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/blockchain/core/WalletManager.d.ts +124 -0
- package/dist/blockchain/core/WalletManager.d.ts.map +1 -0
- package/dist/blockchain/{ZipKitWallet.js → core/WalletManager.js} +157 -177
- package/dist/blockchain/core/WalletManager.js.map +1 -0
- package/dist/blockchain/{ZipKitMinter.d.ts → core/ZipkitMinter.d.ts} +46 -11
- 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/{ZipKitOTS.d.ts → core/ZipkitOTS.d.ts} +6 -15
- package/dist/blockchain/core/ZipkitOTS.d.ts.map +1 -0
- package/dist/blockchain/{ZipKitOTS.js → core/ZipkitOTS.js} +26 -84
- 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 -7
- package/dist/blockchain/index.d.ts.map +1 -0
- package/dist/blockchain/index.js +18 -34
- 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 -14
- package/dist/browser.js +13 -28
- 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 +225 -82
- 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/core/version.d.ts +5 -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 -18
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -35
- 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 +491 -0
- package/examples/verify-tokenized-zip.ts +305 -0
- package/examples/zip-token.ts +604 -0
- package/package.json +108 -24
- package/src/blockchain/README.md +59 -66
- package/src/{browser/TokenVerifierBrowser.ts-remove → 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/{ZipKitWallet.ts → core/WalletManager.ts} +241 -143
- package/src/blockchain/core/ZipkitMinter.ts +716 -0
- package/src/blockchain/{ZipKitOTS.ts → core/ZipkitOTS.ts} +28 -62
- 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 +21 -55
- 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 +240 -90
- 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 -25
- 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/modules.d.ts +1 -11
- package/src/types/opentimestamps.d.ts +1 -23
- package/contracts/INTEGRATION.md +0 -338
- package/contracts/NETWORKS.md +0 -156
- package/contracts/NZIP-NFT-bytecode.txt +0 -1
- package/contracts/constants.ts +0 -952
- package/contracts/deploy-bytecode.mjs +0 -94
- package/dist/blockchain/CertificateToken.d.ts +0 -48
- package/dist/blockchain/CertificateToken.js +0 -386
- package/dist/blockchain/ZipKitMinter.js +0 -347
- package/dist/blockchain/ZipKitNFT.d.ts +0 -3
- package/dist/blockchain/ZipKitNFT.js +0 -7
- package/dist/blockchain/ZipKitVerifier.d.ts +0 -69
- package/dist/blockchain/ZipKitVerifier.js +0 -289
- package/dist/blockchain/ZipKitWallet.d.ts +0 -69
- package/dist/blockchain/contracts.d.ts +0 -14
- package/dist/blockchain/contracts.js +0 -77
- package/dist/blockchain/types.d.ts +0 -47
- package/dist/blockchain/types.js +0 -30
- 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 -18
- package/dist/browser-index.js +0 -57
- package/dist/server/ZipKitServer.d.ts +0 -74
- package/dist/server/ZipKitServer.js +0 -310
- package/dist/shared/ZipKit.d.ts +0 -243
- package/dist/shared/ZipKit.js +0 -772
- 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.d.ts +0 -2
- package/dist/shared/version.js +0 -6
- package/src/blockchain/CertificateToken.ts +0 -444
- package/src/blockchain/ZipKitMinter.ts +0 -470
- package/src/blockchain/ZipKitNFT.ts +0 -12
- package/src/blockchain/ZipKitVerifier.ts +0 -382
- package/src/blockchain/contracts.ts +0 -88
- package/src/blockchain/types.ts +0 -91
- package/src/browser/CertificateGeneratorBrowser.ts-remove +0 -498
- package/src/browser/ZipKitStampBrowser.ts +0 -9
- package/src/browser-index.ts +0 -36
- package/src/server/README.md +0 -25
- package/src/server/ZipKitServer.ts +0 -305
- package/src/shared/ZipKit.ts +0 -881
- 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 -3
- /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,175 +23,239 @@ yarn add neozipkit
|
|
|
19
23
|
|
|
20
24
|
## 🚀 Quick Start
|
|
21
25
|
|
|
22
|
-
### Basic
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
import { ZipKitBrowser } from 'neozipkit/browser';
|
|
26
|
-
import { CompressOptions } from 'neozipkit';
|
|
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
|
-
```
|
|
26
|
+
### Basic Usage
|
|
38
27
|
|
|
39
|
-
|
|
28
|
+
NeoZipKit provides both browser and Node.js implementations for creating, extracting, and managing ZIP files.
|
|
40
29
|
|
|
30
|
+
**Node.js:**
|
|
41
31
|
```typescript
|
|
42
|
-
import {
|
|
43
|
-
import { ZipEntry } from 'neozipkit';
|
|
32
|
+
import { ZipkitNode } from 'neozipkit/node';
|
|
44
33
|
|
|
45
|
-
const
|
|
46
|
-
const entries: ZipEntry[] = await zipKit.loadFromBuffer(zipBuffer);
|
|
34
|
+
const zip = new ZipkitNode();
|
|
47
35
|
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
const isValid = await zipKit.verifyEntry(entry);
|
|
51
|
-
console.log(`${entry.filename}: ${isValid ? 'Valid' : 'Invalid'}`);
|
|
52
|
-
}
|
|
53
|
-
```
|
|
36
|
+
// Create a ZIP from files
|
|
37
|
+
await zip.createZipFromFiles(['file1.txt', 'file2.txt'], 'output.zip');
|
|
54
38
|
|
|
55
|
-
|
|
39
|
+
// Extract a ZIP file
|
|
40
|
+
await zip.extractZipFile('archive.zip', './output');
|
|
41
|
+
```
|
|
56
42
|
|
|
57
|
-
|
|
43
|
+
**Browser:**
|
|
44
|
+
```typescript
|
|
45
|
+
import { ZipkitBrowser } from 'neozipkit/browser-esm';
|
|
58
46
|
|
|
47
|
+
const zip = new ZipkitBrowser();
|
|
48
|
+
await zip.addFile(file, { level: 6 });
|
|
49
|
+
const zipBlob = await zip.createZipBlob();
|
|
59
50
|
```
|
|
60
51
|
|
|
61
|
-
###
|
|
52
|
+
### Examples
|
|
62
53
|
|
|
63
|
-
|
|
54
|
+
Complete, runnable examples are available in the `examples/` directory:
|
|
64
55
|
|
|
65
|
-
|
|
66
|
-
|
|
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
|
|
67
61
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
zip.
|
|
71
|
-
const merkleRoot = zip.getMerkleRoot(); // string | null
|
|
62
|
+
Run examples with:
|
|
63
|
+
```bash
|
|
64
|
+
ts-node examples/create-zip.ts
|
|
72
65
|
```
|
|
73
66
|
|
|
74
|
-
|
|
75
|
-
- `getMerkleRoot()` returns `null` if no entries are loaded or if entries don’t have `sha256` set.
|
|
76
|
-
- Ensure each content file has a SHA‑256 hash recorded:
|
|
77
|
-
- When creating ZIPs, set `useSHA256: true` in `CompressOptions` so hashes are written during compression.
|
|
78
|
-
- When reading existing ZIPs, calling `extract(entry)` will compute and set `entry.sha256` before you call `getMerkleRoot()`.
|
|
67
|
+
See [`examples/README.md`](examples/README.md) for detailed usage instructions and all available examples.
|
|
79
68
|
|
|
80
|
-
|
|
69
|
+
**Note:** The browser bundle includes all necessary polyfills (Buffer, crypto) automatically. No additional configuration is required.
|
|
81
70
|
|
|
82
|
-
|
|
83
|
-
import ZipKitServer, { CMP_METHOD } from 'neozipkit/server/platform/server/ZipKitServer';
|
|
71
|
+
## 🏗️ Package Architecture
|
|
84
72
|
|
|
85
|
-
|
|
86
|
-
// createZip uses CompressOptions internally; ensure useSHA256 when you pass options to compression
|
|
87
|
-
await zk.createZip('/tmp/out.zip', { level: 6, useSHA256: true, useZstd: false });
|
|
73
|
+
### Source Code Structure
|
|
88
74
|
|
|
89
|
-
// Load file and compute
|
|
90
|
-
zk.loadUnzipFile('/tmp/out.zip');
|
|
91
|
-
const root = zk.getMerkleRoot();
|
|
92
75
|
```
|
|
93
|
-
|
|
94
|
-
├──
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
│
|
|
103
|
-
│
|
|
104
|
-
│
|
|
105
|
-
│
|
|
106
|
-
|
|
107
|
-
│
|
|
108
|
-
│
|
|
109
|
-
|
|
110
|
-
│
|
|
111
|
-
│
|
|
112
|
-
│
|
|
113
|
-
│
|
|
114
|
-
|
|
115
|
-
│
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
│ ├──
|
|
119
|
-
│ ├──
|
|
120
|
-
│
|
|
121
|
-
|
|
122
|
-
├──
|
|
123
|
-
|
|
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)
|
|
124
129
|
```
|
|
125
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
|
+
|
|
126
144
|
## 📚 Import Patterns
|
|
127
145
|
|
|
128
146
|
### Browser Applications (Recommended)
|
|
129
147
|
|
|
130
148
|
```typescript
|
|
131
149
|
// Browser-only bundle (excludes Node.js dependencies)
|
|
132
|
-
import {
|
|
133
|
-
import {
|
|
150
|
+
import { ZipkitBrowser } from 'neozipkit/browser';
|
|
151
|
+
import { TokenMetadata } from 'neozipkit/browser';
|
|
134
152
|
```
|
|
135
153
|
|
|
136
154
|
### Universal Applications (Next.js, Node.js)
|
|
137
155
|
|
|
138
156
|
```typescript
|
|
139
|
-
// Main bundle
|
|
140
|
-
import
|
|
141
|
-
import {
|
|
157
|
+
// Main bundle
|
|
158
|
+
import Zipkit from 'neozipkit';
|
|
159
|
+
import { createTimestamp, verifyOts } from 'neozipkit/blockchain';
|
|
160
|
+
import { TokenMetadata } from 'neozipkit';
|
|
142
161
|
```
|
|
143
162
|
|
|
144
|
-
###
|
|
163
|
+
### Node.js-Only Components
|
|
145
164
|
|
|
146
165
|
```typescript
|
|
147
|
-
//
|
|
148
|
-
import {
|
|
149
|
-
import {
|
|
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';
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Blockchain Components
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
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';
|
|
150
184
|
```
|
|
151
185
|
|
|
152
186
|
## 🔗 Blockchain Integration
|
|
153
187
|
|
|
154
|
-
NeoZipKit includes comprehensive blockchain integration for creating and verifying tokenized ZIP files.
|
|
188
|
+
NeoZipKit includes comprehensive blockchain integration for creating and verifying tokenized ZIP files on Ethereum-compatible networks.
|
|
155
189
|
|
|
156
|
-
|
|
190
|
+
### Supported Features
|
|
157
191
|
|
|
158
|
-
|
|
192
|
+
- **NFT Tokenization**: Convert ZIP files into ERC-721 NFTs with complete metadata
|
|
193
|
+
- **Blockchain Verification**: Verify ZIP file authenticity against blockchain tokens
|
|
194
|
+
- **OpenTimestamps**: Bitcoin blockchain timestamping for file integrity
|
|
195
|
+
- **Multi-Network Support**: Base Mainnet, Base Sepolia, Ethereum, Polygon, Arbitrum
|
|
196
|
+
- **Smart Contracts**: Production-ready contracts for public and private tokenization
|
|
159
197
|
|
|
160
|
-
|
|
161
|
-
import { ZipTokenProcessor, MintingOptions } from 'neozipkit/server/blockchain';
|
|
198
|
+
### Blockchain Components
|
|
162
199
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
200
|
+
- **`TokenVerifier`** - Verify tokenized ZIP files against blockchain
|
|
201
|
+
- **`NFTMinter`** - Mint NFTs for ZIP files
|
|
202
|
+
- **`TokenQuerier`** - Query token information from blockchain
|
|
203
|
+
- **`TokenCertificate`** - Generate certificates for tokenized files
|
|
204
|
+
- **`ZipTokenProcessor`** - Process ZIP files for tokenization
|
|
205
|
+
- **`WalletManager`** - Manage wallet connections and networks
|
|
168
206
|
|
|
169
|
-
|
|
170
|
-
|
|
207
|
+
### Usage
|
|
208
|
+
|
|
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).
|
|
214
|
+
|
|
215
|
+
## 🎯 Smart Contracts
|
|
216
|
+
|
|
217
|
+
The package includes production-ready smart contracts for ZIP file tokenization:
|
|
218
|
+
|
|
219
|
+
### Contract Types
|
|
220
|
+
|
|
221
|
+
#### 🌐 Public Contract (`NZIP-NFT.sol`)
|
|
222
|
+
- **Universal verification** - Anyone can verify any token
|
|
223
|
+
- **Public blockchain metadata** - All data visible on blockchain
|
|
224
|
+
- **Use cases**: Certificates, public records, open-source projects
|
|
225
|
+
- **Symbol**: `NZIP`
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
### Current Deployment
|
|
229
|
+
|
|
230
|
+
**✅ Production Contract (v2.10)**:
|
|
171
231
|
```
|
|
232
|
+
Address: 0x6313074922717351986929879903441992482216
|
|
233
|
+
Network: Base Sepolia
|
|
234
|
+
Version: 2.10.0
|
|
235
|
+
Status: ✅ ACTIVE - Use for all new integrations
|
|
236
|
+
Explorer: https://sepolia.basescan.org/address/0x6313074922717351986929879903441992482216
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Contract Deployment
|
|
172
240
|
|
|
173
|
-
|
|
241
|
+
For contract deployment and verification, see [`contracts/README.md`](contracts/README.md) for complete instructions.
|
|
242
|
+
|
|
243
|
+
## 🔧 Development
|
|
174
244
|
|
|
175
245
|
### Build Process
|
|
176
246
|
|
|
177
247
|
```bash
|
|
178
|
-
#
|
|
179
|
-
|
|
248
|
+
# Production build
|
|
249
|
+
yarn build
|
|
250
|
+
|
|
251
|
+
# Development build (for feature branches)
|
|
252
|
+
yarn dev:build
|
|
180
253
|
|
|
181
|
-
#
|
|
182
|
-
|
|
183
|
-
npm run compile # TypeScript compilation
|
|
184
|
-
npm run watch # Watch mode for development
|
|
254
|
+
# Watch mode
|
|
255
|
+
yarn dev:watch
|
|
185
256
|
```
|
|
186
257
|
|
|
187
|
-
|
|
188
|
-
1. `npm run clean` - Removes old compiled files
|
|
189
|
-
2. `npm run compile` - Compiles TypeScript to dist/
|
|
190
|
-
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.
|
|
191
259
|
|
|
192
260
|
### TypeScript Configuration
|
|
193
261
|
|
|
@@ -197,86 +265,259 @@ This runs:
|
|
|
197
265
|
- **Output**: `./dist`
|
|
198
266
|
- **Declarations**: Generated alongside JavaScript files
|
|
199
267
|
|
|
200
|
-
|
|
268
|
+
## 📖 API Reference
|
|
269
|
+
|
|
270
|
+
### Zipkit Class
|
|
201
271
|
|
|
202
|
-
|
|
272
|
+
**Zipkit** is the core ZIP file processing library with dual-mode support for efficient handling of ZIP archives of any size.
|
|
203
273
|
|
|
204
|
-
|
|
205
|
-
import { NEOZIPKIT_VERSION, NEOZIPKIT_RELEASE_DATE } from 'neozipkit';
|
|
274
|
+
#### Architecture
|
|
206
275
|
|
|
207
|
-
|
|
208
|
-
|
|
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.
|
|
209
279
|
|
|
210
|
-
|
|
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.
|
|
211
388
|
|
|
212
389
|
### Core Classes
|
|
213
390
|
|
|
214
|
-
- **`ZipKit`** - Core ZIP functionality (shared)
|
|
215
|
-
- **`
|
|
216
|
-
- **`
|
|
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)
|
|
217
394
|
- **`ZipEntry`** - ZIP entry representation and manipulation
|
|
218
|
-
- **`
|
|
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
|
|
219
412
|
|
|
220
413
|
### Platform-Specific Components
|
|
221
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
|
+
|
|
222
452
|
#### Browser Components
|
|
223
|
-
- **`CertificateGeneratorBrowser`** - Generate verification certificates
|
|
224
453
|
- **`TokenVerifierBrowser`** - Browser-based token verification
|
|
225
|
-
- **`
|
|
226
|
-
|
|
227
|
-
#### Server Components
|
|
228
|
-
- **`ZipKitOTS`** - OpenTimestamps integration
|
|
229
|
-
- **Blockchain Classes** - Complete blockchain integration suite
|
|
454
|
+
- **`WalletManagerBrowser`** - Browser wallet management
|
|
230
455
|
|
|
231
456
|
### Constants and Types
|
|
232
457
|
|
|
233
458
|
- **`constants/Headers`** - ZIP header constants and compression methods
|
|
234
459
|
- **`constants/Errors`** - Error definitions
|
|
235
|
-
- **`
|
|
460
|
+
- **`types`** - TypeScript type definitions
|
|
236
461
|
- **`CMP_METHOD`** - Compression method constants
|
|
237
462
|
|
|
238
463
|
### Compression Methods
|
|
239
464
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const compressionType = entry.cmpMethod;
|
|
245
|
-
|
|
246
|
-
if (compressionType === CMP_METHOD.ZSTD) {
|
|
247
|
-
console.log('ZStandard compression');
|
|
248
|
-
} else if (compressionType === CMP_METHOD.DEFLATED) {
|
|
249
|
-
console.log('Deflate compression');
|
|
250
|
-
} else if (compressionType === CMP_METHOD.STORED) {
|
|
251
|
-
console.log('No compression');
|
|
252
|
-
}
|
|
253
|
-
```
|
|
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)
|
|
254
469
|
|
|
255
|
-
|
|
470
|
+
See the examples for usage patterns with different compression methods.
|
|
256
471
|
|
|
257
|
-
|
|
258
|
-
import { HashAccumulator } from 'neozipkit/shared/components/HashAccumulator';
|
|
472
|
+
## 🌐 Network Support
|
|
259
473
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
474
|
+
### Supported Networks
|
|
475
|
+
|
|
476
|
+
- **Base Sepolia** (Chain ID: 84532) - Testing
|
|
477
|
+
- **Base Mainnet** (Chain ID: 8453) - Production
|
|
478
|
+
- **Ethereum Mainnet** - Production
|
|
479
|
+
- **Polygon** - Production
|
|
480
|
+
- **Arbitrum** - Production
|
|
481
|
+
|
|
482
|
+
### Network Configuration
|
|
264
483
|
|
|
484
|
+
Network configurations are defined in `src/blockchain/core/contracts.ts`. Supported networks include Base Mainnet, Base Sepolia, Ethereum, Polygon, and Arbitrum.
|
|
265
485
|
|
|
486
|
+
See the blockchain examples for network usage.
|
|
266
487
|
|
|
267
488
|
## 🔐 Security Considerations
|
|
268
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
|
+
|
|
269
508
|
### Development Best Practices
|
|
270
509
|
|
|
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)
|
|
512
|
+
- **Network Security**: Use secure RPC endpoints and validate all inputs
|
|
513
|
+
- **Smart Contract Audits**: Audit contracts before production deployment
|
|
271
514
|
- **Error Handling**: Implement comprehensive error handling for all operations
|
|
272
515
|
- **Type Safety**: Leverage TypeScript for compile-time error detection
|
|
273
|
-
- **Input Validation**: Validate all file inputs before processing
|
|
274
|
-
- **Memory Management**: Handle large ZIP files efficiently
|
|
275
516
|
|
|
276
517
|
### File Verification
|
|
277
518
|
|
|
278
519
|
- **Merkle Trees**: All ZIP files use cryptographic Merkle trees for integrity verification
|
|
279
|
-
- **
|
|
520
|
+
- **Blockchain Anchoring**: Timestamps and hashes are anchored to blockchain networks
|
|
280
521
|
- **Multi-Layer Verification**: Support for both OpenTimestamps and NFT-based verification
|
|
281
522
|
|
|
282
523
|
## 📦 Dependencies
|
|
@@ -293,33 +534,14 @@ const merkleRoot = accumulator.finalize();
|
|
|
293
534
|
- **`@types/node`** - Node.js type definitions
|
|
294
535
|
- **`typescript`** - TypeScript compiler
|
|
295
536
|
|
|
296
|
-
## 🔄 Migration Guide
|
|
297
|
-
|
|
298
|
-
### From Previous Versions
|
|
299
|
-
|
|
300
|
-
If upgrading from previous versions:
|
|
301
|
-
|
|
302
|
-
1. **Update Import Paths**:
|
|
303
|
-
```typescript
|
|
304
|
-
// OLD
|
|
305
|
-
import { TokenVerifier } from 'neozipkit/server-components/blockchain/TokenVerifier';
|
|
306
|
-
|
|
307
|
-
// NEW
|
|
308
|
-
import { checkForTokenizationServer } from 'neozipkit/server/blockchain/TokenVerifier';
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
2. **Browser Imports**: Replace main package imports with browser-specific imports for browser applications
|
|
312
|
-
3. **Contract Addresses**: Update to use the new production contract address
|
|
313
|
-
4. **Build Process**: Remove any manual copying scripts - everything now uses TypeScript compilation
|
|
314
|
-
|
|
315
537
|
## 🤝 Contributing
|
|
316
538
|
|
|
317
539
|
### Development Setup
|
|
318
540
|
|
|
319
|
-
1. Clone the repository and install dependencies
|
|
541
|
+
1. Clone the repository and install dependencies: `yarn install`
|
|
320
542
|
2. Make changes to TypeScript files in `src/`
|
|
321
|
-
3. Run `
|
|
322
|
-
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`
|
|
323
545
|
5. Commit only source files, not generated files
|
|
324
546
|
|
|
325
547
|
### Making Changes
|
|
@@ -328,7 +550,9 @@ If upgrading from previous versions:
|
|
|
328
550
|
- Update exports in `src/index.ts` if adding new public modules
|
|
329
551
|
- Update `package.json` exports if creating new public modules
|
|
330
552
|
- Run build process to generate JavaScript
|
|
331
|
-
- Test
|
|
553
|
+
- Test using examples before submitting PRs
|
|
554
|
+
|
|
555
|
+
For detailed contributing guidelines, see [`docs/REPOSITORY_MANAGEMENT.md`](docs/REPOSITORY_MANAGEMENT.md).
|
|
332
556
|
|
|
333
557
|
## 📄 License
|
|
334
558
|
|
|
@@ -339,9 +563,9 @@ MIT
|
|
|
339
563
|
Ready to start using NeoZipKit? Here are some next steps:
|
|
340
564
|
|
|
341
565
|
1. **Install the package**: `yarn add neozipkit`
|
|
342
|
-
2. **
|
|
343
|
-
3. **
|
|
344
|
-
4. **
|
|
345
|
-
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
|
|
346
570
|
|
|
347
|
-
For detailed examples and advanced usage, explore the examples directory
|
|
571
|
+
For detailed examples and advanced usage, explore the `examples/` directory and [`src/blockchain/README.md`](src/blockchain/README.md) for blockchain integration.
|