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.
Files changed (301) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +410 -186
  3. package/contracts/ABI.txt +889 -0
  4. package/contracts/Bytecode.txt +1 -0
  5. package/contracts/COMPILATION_NOTES.md +59 -0
  6. package/contracts/QUICK_DEPLOY.md +286 -0
  7. package/contracts/README.md +235 -131
  8. package/contracts/VERIFICATION.md +308 -0
  9. package/contracts/deploy-interactive.js +448 -0
  10. package/contracts/deployment-arbitrum-sepolia.json +12 -0
  11. package/contracts/deployment-arbitrum.json +12 -0
  12. package/contracts/deployment-eth-sepolia.json +12 -0
  13. package/contracts/hardhat.config.js +114 -0
  14. package/contracts/package.json +20 -0
  15. package/contracts/scripts/compile-and-extract.js +119 -0
  16. package/contracts/scripts/verify-contract.js +223 -0
  17. package/contracts/src/{NZIP-NFT-Private.sol → NZIP-NFT-v2.0.sol} +66 -151
  18. package/contracts/src/NZIP-NFT.sol +9 -15
  19. package/dist/blockchain/browser/TokenVerifierBrowser.d.ts +67 -0
  20. package/dist/blockchain/browser/TokenVerifierBrowser.d.ts.map +1 -0
  21. package/dist/blockchain/browser/TokenVerifierBrowser.js +313 -0
  22. package/dist/blockchain/browser/TokenVerifierBrowser.js.map +1 -0
  23. package/dist/blockchain/browser/WalletManagerBrowser.d.ts +98 -0
  24. package/dist/blockchain/browser/WalletManagerBrowser.d.ts.map +1 -0
  25. package/dist/blockchain/browser/WalletManagerBrowser.js +434 -0
  26. package/dist/blockchain/browser/WalletManagerBrowser.js.map +1 -0
  27. package/dist/blockchain/browser/ZipkitMinterBrowser.d.ts +58 -0
  28. package/dist/blockchain/browser/ZipkitMinterBrowser.d.ts.map +1 -0
  29. package/dist/blockchain/browser/ZipkitMinterBrowser.js +317 -0
  30. package/dist/blockchain/browser/ZipkitMinterBrowser.js.map +1 -0
  31. package/dist/blockchain/browser/index.d.ts +11 -0
  32. package/dist/blockchain/browser/index.d.ts.map +1 -0
  33. package/dist/blockchain/browser/index.js +16 -0
  34. package/dist/blockchain/browser/index.js.map +1 -0
  35. package/dist/blockchain/core/WalletManager.d.ts +124 -0
  36. package/dist/blockchain/core/WalletManager.d.ts.map +1 -0
  37. package/dist/blockchain/{ZipKitWallet.js → core/WalletManager.js} +157 -177
  38. package/dist/blockchain/core/WalletManager.js.map +1 -0
  39. package/dist/blockchain/{ZipKitMinter.d.ts → core/ZipkitMinter.d.ts} +46 -11
  40. package/dist/blockchain/core/ZipkitMinter.d.ts.map +1 -0
  41. package/dist/blockchain/core/ZipkitMinter.js +548 -0
  42. package/dist/blockchain/core/ZipkitMinter.js.map +1 -0
  43. package/dist/blockchain/{ZipKitOTS.d.ts → core/ZipkitOTS.d.ts} +6 -15
  44. package/dist/blockchain/core/ZipkitOTS.d.ts.map +1 -0
  45. package/dist/blockchain/{ZipKitOTS.js → core/ZipkitOTS.js} +26 -84
  46. package/dist/blockchain/core/ZipkitOTS.js.map +1 -0
  47. package/dist/blockchain/core/ZipkitVerifier.d.ts +177 -0
  48. package/dist/blockchain/core/ZipkitVerifier.d.ts.map +1 -0
  49. package/dist/blockchain/core/ZipkitVerifier.js +632 -0
  50. package/dist/blockchain/core/ZipkitVerifier.js.map +1 -0
  51. package/dist/blockchain/core/contracts.d.ts +83 -0
  52. package/dist/blockchain/core/contracts.d.ts.map +1 -0
  53. package/dist/blockchain/core/contracts.js +341 -0
  54. package/dist/blockchain/core/contracts.js.map +1 -0
  55. package/dist/blockchain/core/index.d.ts +12 -0
  56. package/dist/blockchain/core/index.d.ts.map +1 -0
  57. package/dist/blockchain/core/index.js +59 -0
  58. package/dist/blockchain/core/index.js.map +1 -0
  59. package/dist/blockchain/index.d.ts +11 -7
  60. package/dist/blockchain/index.d.ts.map +1 -0
  61. package/dist/blockchain/index.js +18 -34
  62. package/dist/blockchain/index.js.map +1 -0
  63. package/dist/blockchain/node/WalletManagerNode.d.ts +47 -0
  64. package/dist/blockchain/node/WalletManagerNode.d.ts.map +1 -0
  65. package/dist/blockchain/node/WalletManagerNode.js +203 -0
  66. package/dist/blockchain/node/WalletManagerNode.js.map +1 -0
  67. package/dist/blockchain/node/index.d.ts +12 -0
  68. package/dist/blockchain/node/index.d.ts.map +1 -0
  69. package/dist/blockchain/node/index.js +24 -0
  70. package/dist/blockchain/node/index.js.map +1 -0
  71. package/dist/browser/ZipkitBrowser.d.ts +27 -0
  72. package/dist/browser/ZipkitBrowser.d.ts.map +1 -0
  73. package/dist/browser/{ZipKitBrowser.js → ZipkitBrowser.js} +96 -43
  74. package/dist/browser/ZipkitBrowser.js.map +1 -0
  75. package/dist/browser/index.d.ts +12 -0
  76. package/dist/browser/index.d.ts.map +1 -0
  77. package/dist/browser/index.js +42 -0
  78. package/dist/browser/index.js.map +1 -0
  79. package/dist/browser-esm/index.d.ts +12 -0
  80. package/dist/browser-esm/index.js +59559 -0
  81. package/dist/browser-esm/index.js.map +7 -0
  82. package/dist/browser-umd/index.d.ts +12 -0
  83. package/dist/browser-umd/index.js +59576 -0
  84. package/dist/browser-umd/index.js.map +7 -0
  85. package/dist/browser-umd/index.min.js +63 -0
  86. package/dist/browser.d.ts +8 -14
  87. package/dist/browser.js +13 -28
  88. package/dist/core/ZipCompress.d.ts +99 -0
  89. package/dist/core/ZipCompress.d.ts.map +1 -0
  90. package/dist/core/ZipCompress.js +309 -0
  91. package/dist/core/ZipCompress.js.map +1 -0
  92. package/dist/core/ZipDecompress.d.ts +58 -0
  93. package/dist/core/ZipDecompress.d.ts.map +1 -0
  94. package/dist/core/ZipDecompress.js +172 -0
  95. package/dist/core/ZipDecompress.js.map +1 -0
  96. package/dist/{shared → core}/ZipEntry.d.ts +8 -1
  97. package/dist/core/ZipEntry.d.ts.map +1 -0
  98. package/dist/{shared → core}/ZipEntry.js +225 -82
  99. package/dist/core/ZipEntry.js.map +1 -0
  100. package/dist/core/Zipkit.d.ts +315 -0
  101. package/dist/core/Zipkit.d.ts.map +1 -0
  102. package/dist/core/Zipkit.js +647 -0
  103. package/dist/core/Zipkit.js.map +1 -0
  104. package/dist/core/components/HashCalculator.d.ts +138 -0
  105. package/dist/core/components/HashCalculator.d.ts.map +1 -0
  106. package/dist/core/components/HashCalculator.js +360 -0
  107. package/dist/core/components/HashCalculator.js.map +1 -0
  108. package/dist/core/components/Logger.d.ts +73 -0
  109. package/dist/core/components/Logger.d.ts.map +1 -0
  110. package/dist/core/components/Logger.js +156 -0
  111. package/dist/core/components/Logger.js.map +1 -0
  112. package/dist/core/components/ProgressTracker.d.ts +43 -0
  113. package/dist/core/components/ProgressTracker.d.ts.map +1 -0
  114. package/dist/core/components/ProgressTracker.js +112 -0
  115. package/dist/core/components/ProgressTracker.js.map +1 -0
  116. package/dist/{shared → core}/components/Support.d.ts +1 -0
  117. package/dist/core/components/Support.d.ts.map +1 -0
  118. package/dist/{shared → core}/components/Support.js +1 -0
  119. package/dist/core/components/Support.js.map +1 -0
  120. package/dist/{shared → core}/components/Util.d.ts +7 -2
  121. package/dist/core/components/Util.d.ts.map +1 -0
  122. package/dist/{shared → core}/components/Util.js +14 -34
  123. package/dist/core/components/Util.js.map +1 -0
  124. package/dist/{shared → core}/constants/Errors.d.ts +1 -2
  125. package/dist/core/constants/Errors.d.ts.map +1 -0
  126. package/dist/{shared → core}/constants/Errors.js +1 -3
  127. package/dist/core/constants/Errors.js.map +1 -0
  128. package/dist/{shared → core}/constants/Headers.d.ts +3 -0
  129. package/dist/core/constants/Headers.d.ts.map +1 -0
  130. package/dist/{shared → core}/constants/Headers.js +20 -17
  131. package/dist/core/constants/Headers.js.map +1 -0
  132. package/dist/core/encryption/Manager.d.ts +58 -0
  133. package/dist/core/encryption/Manager.d.ts.map +1 -0
  134. package/dist/core/encryption/Manager.js +121 -0
  135. package/dist/core/encryption/Manager.js.map +1 -0
  136. package/dist/core/encryption/ZipCrypto.d.ts +172 -0
  137. package/dist/core/encryption/ZipCrypto.d.ts.map +1 -0
  138. package/dist/core/encryption/ZipCrypto.js +554 -0
  139. package/dist/core/encryption/ZipCrypto.js.map +1 -0
  140. package/dist/core/encryption/index.d.ts +9 -0
  141. package/dist/core/encryption/index.d.ts.map +1 -0
  142. package/dist/core/encryption/index.js +17 -0
  143. package/dist/core/encryption/index.js.map +1 -0
  144. package/dist/core/encryption/types.d.ts +29 -0
  145. package/dist/core/encryption/types.d.ts.map +1 -0
  146. package/dist/core/encryption/types.js +12 -0
  147. package/dist/core/encryption/types.js.map +1 -0
  148. package/dist/core/index.d.ts +24 -0
  149. package/dist/core/index.d.ts.map +1 -0
  150. package/dist/core/index.js +57 -0
  151. package/dist/core/index.js.map +1 -0
  152. package/dist/core/version.d.ts +5 -0
  153. package/dist/core/version.d.ts.map +1 -0
  154. package/dist/core/version.js +31 -0
  155. package/dist/core/version.js.map +1 -0
  156. package/dist/index.d.ts +8 -18
  157. package/dist/index.d.ts.map +1 -0
  158. package/dist/index.js +29 -35
  159. package/dist/index.js.map +1 -0
  160. package/dist/node/ZipCompressNode.d.ts +123 -0
  161. package/dist/node/ZipCompressNode.d.ts.map +1 -0
  162. package/dist/node/ZipCompressNode.js +576 -0
  163. package/dist/node/ZipCompressNode.js.map +1 -0
  164. package/dist/node/ZipDecompressNode.d.ts +120 -0
  165. package/dist/node/ZipDecompressNode.d.ts.map +1 -0
  166. package/dist/node/ZipDecompressNode.js +461 -0
  167. package/dist/node/ZipDecompressNode.js.map +1 -0
  168. package/dist/node/ZipkitNode.d.ts +406 -0
  169. package/dist/node/ZipkitNode.d.ts.map +1 -0
  170. package/dist/node/ZipkitNode.js +1305 -0
  171. package/dist/node/ZipkitNode.js.map +1 -0
  172. package/dist/node/index.d.ts +26 -0
  173. package/dist/node/index.d.ts.map +1 -0
  174. package/dist/node/index.js +65 -0
  175. package/dist/node/index.js.map +1 -0
  176. package/dist/types/index.d.ts +59 -0
  177. package/dist/types/index.d.ts.map +1 -0
  178. package/dist/types/index.js +36 -1
  179. package/dist/types/index.js.map +1 -0
  180. package/examples/README.md +269 -0
  181. package/examples/blockchain-tokenize.ts +354 -0
  182. package/examples/create-zip.ts +172 -0
  183. package/examples/extract-zip.ts +158 -0
  184. package/examples/list-zip.ts +161 -0
  185. package/examples/test-files/data.json +116 -0
  186. package/examples/test-files/document.md +80 -0
  187. package/examples/test-files/document.txt +2 -0
  188. package/examples/test-files/file1.txt +48 -0
  189. package/examples/test-files/file2.txt +80 -0
  190. package/examples/tsconfig.json +44 -0
  191. package/examples/unzip-token.ts +491 -0
  192. package/examples/verify-tokenized-zip.ts +305 -0
  193. package/examples/zip-token.ts +604 -0
  194. package/package.json +108 -24
  195. package/src/blockchain/README.md +59 -66
  196. package/src/{browser/TokenVerifierBrowser.ts-remove → blockchain/browser/TokenVerifierBrowser.ts} +125 -79
  197. package/src/blockchain/browser/WalletManagerBrowser.ts +486 -0
  198. package/src/blockchain/browser/ZipkitMinterBrowser.ts +400 -0
  199. package/src/blockchain/browser/index.ts +13 -0
  200. package/src/blockchain/{ZipKitWallet.ts → core/WalletManager.ts} +241 -143
  201. package/src/blockchain/core/ZipkitMinter.ts +716 -0
  202. package/src/blockchain/{ZipKitOTS.ts → core/ZipkitOTS.ts} +28 -62
  203. package/src/blockchain/core/ZipkitVerifier.ts +853 -0
  204. package/src/blockchain/core/contracts.ts +370 -0
  205. package/src/blockchain/core/index.ts +71 -0
  206. package/src/blockchain/index.ts +21 -55
  207. package/src/blockchain/node/WalletManagerNode.ts +171 -0
  208. package/src/blockchain/node/index.ts +40 -0
  209. package/src/browser/{ZipKitBrowser.ts → ZipkitBrowser.ts} +104 -41
  210. package/src/browser/index.esm.ts +37 -0
  211. package/src/browser/index.ts +25 -0
  212. package/src/core/ZipCompress.ts +398 -0
  213. package/src/core/ZipDecompress.ts +212 -0
  214. package/src/{shared → core}/ZipEntry.ts +240 -90
  215. package/src/core/Zipkit.ts +794 -0
  216. package/src/core/components/HashCalculator.ts +384 -0
  217. package/src/core/components/Logger.ts +180 -0
  218. package/src/core/components/ProgressTracker.ts +134 -0
  219. package/src/{shared → core}/components/Util.ts +12 -34
  220. package/src/{shared → core}/constants/Errors.ts +0 -4
  221. package/src/{shared → core}/constants/Headers.ts +19 -17
  222. package/src/core/encryption/Manager.ts +137 -0
  223. package/src/core/encryption/ZipCrypto.ts +650 -0
  224. package/src/core/encryption/index.ts +15 -0
  225. package/src/core/encryption/types.ts +33 -0
  226. package/src/core/index.ts +34 -0
  227. package/src/core/version.ts +33 -0
  228. package/src/index.ts +54 -25
  229. package/src/node/ZipCompressNode.ts +632 -0
  230. package/src/node/ZipDecompressNode.ts +508 -0
  231. package/src/node/ZipkitNode.ts +1559 -0
  232. package/src/node/index.ts +69 -0
  233. package/src/types/index.ts +131 -1
  234. package/src/types/modules.d.ts +1 -11
  235. package/src/types/opentimestamps.d.ts +1 -23
  236. package/contracts/INTEGRATION.md +0 -338
  237. package/contracts/NETWORKS.md +0 -156
  238. package/contracts/NZIP-NFT-bytecode.txt +0 -1
  239. package/contracts/constants.ts +0 -952
  240. package/contracts/deploy-bytecode.mjs +0 -94
  241. package/dist/blockchain/CertificateToken.d.ts +0 -48
  242. package/dist/blockchain/CertificateToken.js +0 -386
  243. package/dist/blockchain/ZipKitMinter.js +0 -347
  244. package/dist/blockchain/ZipKitNFT.d.ts +0 -3
  245. package/dist/blockchain/ZipKitNFT.js +0 -7
  246. package/dist/blockchain/ZipKitVerifier.d.ts +0 -69
  247. package/dist/blockchain/ZipKitVerifier.js +0 -289
  248. package/dist/blockchain/ZipKitWallet.d.ts +0 -69
  249. package/dist/blockchain/contracts.d.ts +0 -14
  250. package/dist/blockchain/contracts.js +0 -77
  251. package/dist/blockchain/types.d.ts +0 -47
  252. package/dist/blockchain/types.js +0 -30
  253. package/dist/browser/ZipKitBrowser.d.ts +0 -18
  254. package/dist/browser/ZipKitStampBrowser.d.ts +0 -2
  255. package/dist/browser/ZipKitStampBrowser.js +0 -12
  256. package/dist/browser-index.d.ts +0 -18
  257. package/dist/browser-index.js +0 -57
  258. package/dist/server/ZipKitServer.d.ts +0 -74
  259. package/dist/server/ZipKitServer.js +0 -310
  260. package/dist/shared/ZipKit.d.ts +0 -243
  261. package/dist/shared/ZipKit.js +0 -772
  262. package/dist/shared/components/CertificateOTS.d.ts +0 -15
  263. package/dist/shared/components/CertificateOTS.js +0 -116
  264. package/dist/shared/components/FileSys.d.ts +0 -2
  265. package/dist/shared/components/FileSys.js +0 -113
  266. package/dist/shared/components/HashAccumulator.d.ts +0 -55
  267. package/dist/shared/components/HashAccumulator.js +0 -100
  268. package/dist/shared/components/ZipCrypto.d.ts +0 -3
  269. package/dist/shared/components/ZipCrypto.js +0 -78
  270. package/dist/shared/components/merkleTree.d.ts +0 -66
  271. package/dist/shared/components/merkleTree.js +0 -136
  272. package/dist/shared/types/index.d.ts +0 -21
  273. package/dist/shared/types/index.js +0 -3
  274. package/dist/shared/types.d.ts +0 -33
  275. package/dist/shared/types.js +0 -8
  276. package/dist/shared/version.d.ts +0 -2
  277. package/dist/shared/version.js +0 -6
  278. package/src/blockchain/CertificateToken.ts +0 -444
  279. package/src/blockchain/ZipKitMinter.ts +0 -470
  280. package/src/blockchain/ZipKitNFT.ts +0 -12
  281. package/src/blockchain/ZipKitVerifier.ts +0 -382
  282. package/src/blockchain/contracts.ts +0 -88
  283. package/src/blockchain/types.ts +0 -91
  284. package/src/browser/CertificateGeneratorBrowser.ts-remove +0 -498
  285. package/src/browser/ZipKitStampBrowser.ts +0 -9
  286. package/src/browser-index.ts +0 -36
  287. package/src/server/README.md +0 -25
  288. package/src/server/ZipKitServer.ts +0 -305
  289. package/src/shared/ZipKit.ts +0 -881
  290. package/src/shared/components/CertificateOTS.ts +0 -132
  291. package/src/shared/components/FileSys.ts +0 -87
  292. package/src/shared/components/HashAccumulator.ts +0 -113
  293. package/src/shared/components/ZipCrypto.ts +0 -91
  294. package/src/shared/components/merkleTree.ts +0 -162
  295. package/src/shared/types/index.ts +0 -25
  296. package/src/shared/types/modules.d.ts +0 -22
  297. package/src/shared/types/opentimestamps.d.ts +0 -23
  298. package/src/shared/types.d.ts +0 -8
  299. package/src/shared/types.ts +0 -43
  300. package/src/shared/version.ts +0 -3
  301. /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
- - **Blockchain timestamping** using OpenTimestamps for file integrity verification
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
- - **Browser and server compatibility** with clean platform separation
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 ZIP Creation
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
- ### ZIP Verification
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 { ZipKitBrowser } from 'neozipkit/browser';
43
- import { ZipEntry } from 'neozipkit';
32
+ import { ZipkitNode } from 'neozipkit/node';
44
33
 
45
- const zipKit = new ZipKitBrowser();
46
- const entries: ZipEntry[] = await zipKit.loadFromBuffer(zipBuffer);
34
+ const zip = new ZipkitNode();
47
35
 
48
- // Verify file integrity
49
- for (const entry of entries) {
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
- ## 🏗️ Package Architecture
39
+ // Extract a ZIP file
40
+ await zip.extractZipFile('archive.zip', './output');
41
+ ```
56
42
 
57
- ### Unified Directory Structure
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
- ### Merkle Root API (getMerkleRoot)
52
+ ### Examples
62
53
 
63
- The `getMerkleRoot()` symbol is an instance method on `ZipKit`/`ZipKitServer` (not a top‑level export). Instantiate and call it on the object:
54
+ Complete, runnable examples are available in the `examples/` directory:
64
55
 
65
- ```typescript
66
- import ZipKitServer from 'neozipkit/server/platform/server/ZipKitServer';
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
- // Load an existing ZIP from disk and compute Merkle Root (server/Node.js)
69
- const zip = new ZipKitServer();
70
- zip.loadUnzipFile('/path/to/archive.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
- Notes:
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
- Example (creating and then reading back):
69
+ **Note:** The browser bundle includes all necessary polyfills (Buffer, crypto) automatically. No additional configuration is required.
81
70
 
82
- ```typescript
83
- import ZipKitServer, { CMP_METHOD } from 'neozipkit/server/platform/server/ZipKitServer';
71
+ ## 🏗️ Package Architecture
84
72
 
85
- const zk = new ZipKitServer();
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
- packages/neozipkit/
94
- ├── src/ # TypeScript source files
95
- │ ├── browser/ # Browser-only implementations
96
- │ │ ├── ZipKitBrowser.ts
97
- │ │ ├── CertificateGeneratorBrowser.ts
98
- │ │ └── TokenVerifierBrowser.ts
99
- │ ├── server/ # Server-only implementations
100
- │ │ ├── blockchain/ # Blockchain integration utilities
101
- │ │ │ ├── TokenVerifier.ts # Verify tokenized ZIP files
102
- │ │ │ ├── NFTMinter.ts # Mint NFTs for ZIP files
103
- │ │ │ ├── WalletManager.ts # Manage wallet connections
104
- │ │ │ └── ... # Additional blockchain components
105
- │ │ └── platform/ # Server platform code
106
- │ │ ├── server/ # Server-specific ZIP operations
107
- │ │ └── servercomponents/ # OpenTimestamps & server utilities
108
- │ ├── shared/ # Shared utilities
109
- │ │ ├── components/ # Core ZIP utilities
110
- │ │ ├── constants/ # Headers, errors, etc.
111
- │ │ ├── types/ # Type definitions
112
- │ │ ├── ZipKit.ts # Main ZipKit class
113
- │ │ └── ZipEntry.ts # ZIP entry handling
114
- │ ├── browser-index.ts # Browser-specific exports
115
- │ └── index.ts # Main exports (all platforms)
116
- ├── dist/ # Compiled JavaScript output
117
- │ ├── browser.js/.d.ts # Browser-only bundle
118
- │ ├── server/ # Server bundle
119
- │ ├── shared/ # Shared code
120
- │ └── index.js/.d.ts # Main bundle
121
- ├── contracts/ # Smart contracts and documentation
122
- ├── examples/ # Usage examples
123
- └── docs/ # Documentation
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 { ZipKitBrowser, CertificateGeneratorBrowser } from 'neozipkit/browser';
133
- import { TOKENIZED_METADATA } from 'neozipkit/browser';
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 (includes both browser and server when possible)
140
- import { ZipKitBrowser, CertificateGeneratorBrowser } from 'neozipkit';
141
- import { TOKENIZED_METADATA } from 'neozipkit/shared/constants/Headers';
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
- ### Server-Only Components (Node.js)
163
+ ### Node.js-Only Components
145
164
 
146
165
  ```typescript
147
- // Direct TypeScript imports for server components
148
- import { TokenVerifier } from 'neozipkit/server/blockchain/TokenVerifier';
149
- import { ZipKitOTS } from 'neozipkit/server/platform/servercomponents/ZipKitOTS';
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
- **📄 For detailed information about smart contracts, deployment, and blockchain integration, see the [contracts documentation](./contracts/).**
190
+ ### Supported Features
157
191
 
158
- ### Quick Example
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
- ```typescript
161
- import { ZipTokenProcessor, MintingOptions } from 'neozipkit/server/blockchain';
198
+ ### Blockchain Components
162
199
 
163
- const options: MintingOptions = {
164
- wallet: 'path/to/wallet.json',
165
- network: 'base-sepolia',
166
- mintToken: true
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
- const processor = new ZipTokenProcessor('archive.zip', 'merkle_root_hash', options);
170
- const result = await processor.processZipToken(options);
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
- ## 🔧 Development Workflow
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
- # Full build process
179
- npm run build
248
+ # Production build
249
+ yarn build
250
+
251
+ # Development build (for feature branches)
252
+ yarn dev:build
180
253
 
181
- # Individual steps
182
- npm run clean # Remove compiled files
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
- This runs:
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
- ### Version constants
268
+ ## 📖 API Reference
269
+
270
+ ### Zipkit Class
201
271
 
202
- Import the library version and release date anywhere in your app:
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
- ```ts
205
- import { NEOZIPKIT_VERSION, NEOZIPKIT_RELEASE_DATE } from 'neozipkit';
274
+ #### Architecture
206
275
 
207
- console.log('NeoZipKit', NEOZIPKIT_VERSION, NEOZIPKIT_RELEASE_DATE);
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
- ## 📖 API Reference
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
- - **`ZipKitBrowser`** - Browser-compatible ZIP operations
216
- - **`ZipKitServer`** - Server-side ZIP operations with full Node.js support
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
- - **`HashAccumulator`** - Hash accumulation for Merkle tree verification
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
- - **`ZipKitStampBrowser`** - Browser timestamping utilities
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
- - **`shared/types`** - TypeScript type definitions
460
+ - **`types`** - TypeScript type definitions
236
461
  - **`CMP_METHOD`** - Compression method constants
237
462
 
238
463
  ### Compression Methods
239
464
 
240
- ```typescript
241
- import { CMP_METHOD } from 'neozipkit/shared/constants/Headers';
242
-
243
- // Available compression methods
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
- ### Hash Accumulation
470
+ See the examples for usage patterns with different compression methods.
256
471
 
257
- ```typescript
258
- import { HashAccumulator } from 'neozipkit/shared/components/HashAccumulator';
472
+ ## 🌐 Network Support
259
473
 
260
- const accumulator = new HashAccumulator();
261
- accumulator.addFile('example.txt', fileBuffer);
262
- const merkleRoot = accumulator.finalize();
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
- - **Hash Verification**: Multiple hash algorithms for file integrity checking
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 `npm run build` to compile changes
322
- 4. Test changes in consuming applications
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 in portal application
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. **Choose your use case**: Basic ZIP operations, OpenTimestamps, or NFT tokenization
343
- 3. **Follow the examples**: Check the `examples/` directory for complete implementations
344
- 4. **Deploy contracts**: See [contracts documentation](./contracts/) for blockchain features
345
- 5. **Build something amazing**: Leverage the full power of blockchain-backed file verification
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. For blockchain integration, see the [contracts documentation](./contracts/).
571
+ For detailed examples and advanced usage, explore the `examples/` directory and [`src/blockchain/README.md`](src/blockchain/README.md) for blockchain integration.