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
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Unified hash calculator supporting:
3
+ * - Incremental CRC-32 and SHA-256 calculation from raw data chunks
4
+ * - Accumulation of pre-computed SHA-256 hashes with XOR and Merkle tree operations
5
+ * - Merkle tree construction, proof generation, and verification
6
+ *
7
+ * Usage examples:
8
+ *
9
+ * Incremental hash calculation:
10
+ * ```typescript
11
+ * const calculator = new HashCalculator({ useSHA256: true });
12
+ * calculator.update(dataChunk);
13
+ * const crc32 = calculator.finalizeCRC32();
14
+ * const sha256 = calculator.finalizeSHA256();
15
+ * ```
16
+ *
17
+ * Hash accumulation:
18
+ * ```typescript
19
+ * const calculator = new HashCalculator({ enableAccumulation: true });
20
+ * calculator.addHash(sha256Hash1);
21
+ * calculator.addHash(sha256Hash2);
22
+ * const xor = calculator.xorHash();
23
+ * const merkle = calculator.merkleRoot();
24
+ * ```
25
+ */
26
+ export declare class HashCalculator {
27
+ private crc32State;
28
+ private sha256Hash;
29
+ private useSHA256;
30
+ private hashes;
31
+ private xorResult;
32
+ private enableAccumulation;
33
+ private merkleLeaves;
34
+ private merkleLayers;
35
+ private merkleOptions;
36
+ /**
37
+ * Creates a new HashCalculator instance
38
+ * @param options - Configuration options:
39
+ * - useSHA256: Enable SHA-256 calculation for incremental mode (default: false)
40
+ * - enableAccumulation: Enable hash accumulation mode (default: false)
41
+ */
42
+ constructor(options?: {
43
+ useSHA256?: boolean;
44
+ enableAccumulation?: boolean;
45
+ });
46
+ /**
47
+ * Update hash state with a new chunk of data
48
+ * Updates both CRC-32 and SHA-256 (if enabled) incrementally
49
+ * @param chunk - Data chunk to process
50
+ */
51
+ update(chunk: Buffer): void;
52
+ /**
53
+ * Get final CRC-32 value
54
+ * @returns Final CRC-32 value as unsigned 32-bit integer
55
+ */
56
+ finalizeCRC32(): number;
57
+ /**
58
+ * Get final SHA-256 hash as hex string
59
+ * @returns SHA-256 hash as hex string, or null if SHA-256 not enabled
60
+ */
61
+ finalizeSHA256(): string | null;
62
+ /**
63
+ * Reset the incremental hash calculation state
64
+ */
65
+ reset(): void;
66
+ /**
67
+ * Adds a pre-computed SHA-256 hash to both the XOR accumulation and hash array
68
+ * @param hash - Hash value as hex string or Buffer (must be 32 bytes for SHA-256)
69
+ */
70
+ addHash(hash: string | Buffer): void;
71
+ /**
72
+ * Gets the accumulated XOR of all added hashes
73
+ * @returns Hex string of XOR result
74
+ */
75
+ xorHash(): string;
76
+ /**
77
+ * Creates a Merkle tree from accumulated hashes and returns the root
78
+ * @returns Hex string of Merkle root, or null if no hashes added
79
+ */
80
+ merkleRoot(): string | null;
81
+ /**
82
+ * Gets the number of hashes accumulated
83
+ * @returns Number of accumulated hashes
84
+ */
85
+ leafCount(): number;
86
+ /**
87
+ * Clears the accumulated hashes and resets XOR buffer
88
+ */
89
+ clear(): void;
90
+ /**
91
+ * Combines multiple hash results into a single Merkle root
92
+ * Static method for combining results from multiple HashCalculator instances
93
+ * @param results - Array of objects containing merkleRoot properties
94
+ * @returns Combined Merkle root as hex string, or null if no valid roots
95
+ */
96
+ static combineResults(results: {
97
+ merkleRoot?: string;
98
+ }[]): string | null;
99
+ /**
100
+ * Computes SHA-256 hash of input data
101
+ * @param data - Data to hash
102
+ * @returns Buffer containing hash
103
+ */
104
+ private hash;
105
+ /**
106
+ * Combines two child hashes to create parent hash
107
+ * @param left - Left child hash
108
+ * @param right - Right child hash
109
+ * @returns Combined hash of children
110
+ */
111
+ private combinedHash;
112
+ /**
113
+ * Builds the Merkle tree by creating successive layers of hashes
114
+ * @param nodes - Array of nodes in current layer
115
+ */
116
+ private createHashes;
117
+ /**
118
+ * Rebuilds the Merkle tree from current leaves
119
+ */
120
+ private rebuildMerkleTree;
121
+ /**
122
+ * Generates a proof of inclusion for a leaf node
123
+ * @param leaf - The leaf node to generate proof for
124
+ * @returns Array of sibling hashes needed to reconstruct root
125
+ * @throws Error if leaf not found in tree or accumulation not enabled
126
+ */
127
+ getProof(leaf: Buffer): Buffer[];
128
+ /**
129
+ * Verifies a proof of inclusion for a leaf node
130
+ * @param proof - Array of sibling hashes from getProof()
131
+ * @param targetHash - Hash of the leaf node being verified
132
+ * @param root - Expected root hash
133
+ * @returns boolean indicating if proof is valid
134
+ */
135
+ verify(proof: Buffer[], targetHash: Buffer, root: Buffer): boolean;
136
+ }
137
+ export default HashCalculator;
138
+ //# sourceMappingURL=HashCalculator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HashCalculator.d.ts","sourceRoot":"","sources":["../../../src/core/components/HashCalculator.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,cAAc;IAEzB,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,SAAS,CAAkB;IAGnC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,kBAAkB,CAAkB;IAG5C,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,aAAa,CAKnB;IAEF;;;;;OAKG;gBACS,OAAO,CAAC,EAAE;QACpB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B;IAaD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAY3B;;;OAGG;IACH,aAAa,IAAI,MAAM;IAIvB;;;OAGG;IACH,cAAc,IAAI,MAAM,GAAG,IAAI;IAO/B;;OAEG;IACH,KAAK,IAAI,IAAI;IAWb;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAuBpC;;;OAGG;IACH,OAAO,IAAI,MAAM;IAOjB;;;OAGG;IACH,UAAU,IAAI,MAAM,GAAG,IAAI;IAsB3B;;;OAGG;IACH,SAAS,IAAI,MAAM;IAOnB;;OAEG;IACH,KAAK,IAAI,IAAI;IAUb;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,MAAM,GAAG,IAAI;IAiBxE;;;;OAIG;IACH,OAAO,CAAC,IAAI;IAIZ;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAOpB;;;OAGG;IACH,OAAO,CAAC,YAAY;IA8BpB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAsBzB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IA2BhC;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;CAWnE;AAGD,eAAe,cAAc,CAAC"}
@@ -0,0 +1,360 @@
1
+ "use strict";
2
+ // ======================================
3
+ // HashCalculator.ts - Unified Hash Component
4
+ // Combines StreamHashCalculator, HashAccumulator, and MerkleTree functionality
5
+ // ======================================
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.HashCalculator = void 0;
41
+ const crypto = __importStar(require("crypto"));
42
+ const ZipCrypto_1 = require("../encryption/ZipCrypto");
43
+ /**
44
+ * Unified hash calculator supporting:
45
+ * - Incremental CRC-32 and SHA-256 calculation from raw data chunks
46
+ * - Accumulation of pre-computed SHA-256 hashes with XOR and Merkle tree operations
47
+ * - Merkle tree construction, proof generation, and verification
48
+ *
49
+ * Usage examples:
50
+ *
51
+ * Incremental hash calculation:
52
+ * ```typescript
53
+ * const calculator = new HashCalculator({ useSHA256: true });
54
+ * calculator.update(dataChunk);
55
+ * const crc32 = calculator.finalizeCRC32();
56
+ * const sha256 = calculator.finalizeSHA256();
57
+ * ```
58
+ *
59
+ * Hash accumulation:
60
+ * ```typescript
61
+ * const calculator = new HashCalculator({ enableAccumulation: true });
62
+ * calculator.addHash(sha256Hash1);
63
+ * calculator.addHash(sha256Hash2);
64
+ * const xor = calculator.xorHash();
65
+ * const merkle = calculator.merkleRoot();
66
+ * ```
67
+ */
68
+ class HashCalculator {
69
+ /**
70
+ * Creates a new HashCalculator instance
71
+ * @param options - Configuration options:
72
+ * - useSHA256: Enable SHA-256 calculation for incremental mode (default: false)
73
+ * - enableAccumulation: Enable hash accumulation mode (default: false)
74
+ */
75
+ constructor(options) {
76
+ // Incremental hash calculation state (from StreamHashCalculator)
77
+ this.crc32State = ~0;
78
+ this.sha256Hash = null;
79
+ this.useSHA256 = false;
80
+ // Hash accumulation state (from HashAccumulator)
81
+ this.hashes = [];
82
+ this.xorResult = Buffer.alloc(32, 0);
83
+ this.enableAccumulation = false;
84
+ // Merkle tree state (from MerkleTree)
85
+ this.merkleLeaves = [];
86
+ this.merkleLayers = [];
87
+ this.merkleOptions = {
88
+ hashLeaves: false,
89
+ sortLeaves: true,
90
+ sortPairs: true,
91
+ duplicateOdd: true
92
+ };
93
+ this.useSHA256 = options?.useSHA256 || false;
94
+ this.enableAccumulation = options?.enableAccumulation || false;
95
+ if (this.useSHA256) {
96
+ this.sha256Hash = crypto.createHash('sha256');
97
+ }
98
+ }
99
+ // ============================================================================
100
+ // Incremental Hash Calculation Methods (from StreamHashCalculator)
101
+ // ============================================================================
102
+ /**
103
+ * Update hash state with a new chunk of data
104
+ * Updates both CRC-32 and SHA-256 (if enabled) incrementally
105
+ * @param chunk - Data chunk to process
106
+ */
107
+ update(chunk) {
108
+ // Update CRC-32 incrementally using existing crc32update function
109
+ for (let i = 0; i < chunk.length; i++) {
110
+ this.crc32State = (0, ZipCrypto_1.crc32update)(this.crc32State, chunk[i]);
111
+ }
112
+ // Update SHA-256 incrementally
113
+ if (this.sha256Hash) {
114
+ this.sha256Hash.update(chunk);
115
+ }
116
+ }
117
+ /**
118
+ * Get final CRC-32 value
119
+ * @returns Final CRC-32 value as unsigned 32-bit integer
120
+ */
121
+ finalizeCRC32() {
122
+ return ~this.crc32State >>> 0; // Finalize with ~0 like the existing crc32 function
123
+ }
124
+ /**
125
+ * Get final SHA-256 hash as hex string
126
+ * @returns SHA-256 hash as hex string, or null if SHA-256 not enabled
127
+ */
128
+ finalizeSHA256() {
129
+ if (this.sha256Hash) {
130
+ return this.sha256Hash.digest('hex');
131
+ }
132
+ return null;
133
+ }
134
+ /**
135
+ * Reset the incremental hash calculation state
136
+ */
137
+ reset() {
138
+ this.crc32State = ~0;
139
+ if (this.sha256Hash) {
140
+ this.sha256Hash = crypto.createHash('sha256');
141
+ }
142
+ }
143
+ // ============================================================================
144
+ // Hash Accumulation Methods (from HashAccumulator)
145
+ // ============================================================================
146
+ /**
147
+ * Adds a pre-computed SHA-256 hash to both the XOR accumulation and hash array
148
+ * @param hash - Hash value as hex string or Buffer (must be 32 bytes for SHA-256)
149
+ */
150
+ addHash(hash) {
151
+ if (!this.enableAccumulation) {
152
+ throw new Error('Hash accumulation not enabled. Set enableAccumulation: true in constructor.');
153
+ }
154
+ // Convert hash to Buffer if it's a string
155
+ const hashBuffer = typeof hash === 'string'
156
+ ? Buffer.from(hash, 'hex')
157
+ : hash;
158
+ // Add to array for Merkle tree
159
+ this.hashes.push(hashBuffer);
160
+ this.merkleLeaves.push(hashBuffer);
161
+ // XOR accumulation
162
+ for (let i = 0; i < 32; i++) {
163
+ this.xorResult[i] ^= hashBuffer[i];
164
+ }
165
+ // Rebuild Merkle tree when hash is added
166
+ this.rebuildMerkleTree();
167
+ }
168
+ /**
169
+ * Gets the accumulated XOR of all added hashes
170
+ * @returns Hex string of XOR result
171
+ */
172
+ xorHash() {
173
+ if (!this.enableAccumulation) {
174
+ throw new Error('Hash accumulation not enabled. Set enableAccumulation: true in constructor.');
175
+ }
176
+ return this.xorResult.toString('hex');
177
+ }
178
+ /**
179
+ * Creates a Merkle tree from accumulated hashes and returns the root
180
+ * @returns Hex string of Merkle root, or null if no hashes added
181
+ */
182
+ merkleRoot() {
183
+ if (!this.enableAccumulation) {
184
+ throw new Error('Hash accumulation not enabled. Set enableAccumulation: true in constructor.');
185
+ }
186
+ if (this.merkleLeaves.length === 0) {
187
+ return null;
188
+ }
189
+ // If Merkle tree not built yet, build it
190
+ if (this.merkleLayers.length === 0) {
191
+ this.rebuildMerkleTree();
192
+ }
193
+ const root = this.merkleLayers[this.merkleLayers.length - 1];
194
+ if (root && root.length > 0) {
195
+ return root[0].toString('hex');
196
+ }
197
+ return null;
198
+ }
199
+ /**
200
+ * Gets the number of hashes accumulated
201
+ * @returns Number of accumulated hashes
202
+ */
203
+ leafCount() {
204
+ if (!this.enableAccumulation) {
205
+ throw new Error('Hash accumulation not enabled. Set enableAccumulation: true in constructor.');
206
+ }
207
+ return this.hashes.length;
208
+ }
209
+ /**
210
+ * Clears the accumulated hashes and resets XOR buffer
211
+ */
212
+ clear() {
213
+ if (!this.enableAccumulation) {
214
+ throw new Error('Hash accumulation not enabled. Set enableAccumulation: true in constructor.');
215
+ }
216
+ this.hashes = [];
217
+ this.merkleLeaves = [];
218
+ this.merkleLayers = [];
219
+ this.xorResult = Buffer.alloc(32, 0);
220
+ }
221
+ /**
222
+ * Combines multiple hash results into a single Merkle root
223
+ * Static method for combining results from multiple HashCalculator instances
224
+ * @param results - Array of objects containing merkleRoot properties
225
+ * @returns Combined Merkle root as hex string, or null if no valid roots
226
+ */
227
+ static combineResults(results) {
228
+ const calculator = new HashCalculator({ enableAccumulation: true });
229
+ // Combine all hashes
230
+ for (const result of results) {
231
+ if (result.merkleRoot) {
232
+ calculator.addHash(result.merkleRoot);
233
+ }
234
+ }
235
+ return calculator.merkleRoot();
236
+ }
237
+ // ============================================================================
238
+ // Merkle Tree Methods (from MerkleTree)
239
+ // ============================================================================
240
+ /**
241
+ * Computes SHA-256 hash of input data
242
+ * @param data - Data to hash
243
+ * @returns Buffer containing hash
244
+ */
245
+ hash(data) {
246
+ return crypto.createHash('sha256').update(data).digest();
247
+ }
248
+ /**
249
+ * Combines two child hashes to create parent hash
250
+ * @param left - Left child hash
251
+ * @param right - Right child hash
252
+ * @returns Combined hash of children
253
+ */
254
+ combinedHash(left, right) {
255
+ if (this.merkleOptions.sortPairs && Buffer.compare(left, right) > 0) {
256
+ [left, right] = [right, left];
257
+ }
258
+ return this.hash(Buffer.concat([left, right]));
259
+ }
260
+ /**
261
+ * Builds the Merkle tree by creating successive layers of hashes
262
+ * @param nodes - Array of nodes in current layer
263
+ */
264
+ createHashes(nodes) {
265
+ while (nodes.length > 1) {
266
+ const layerIndex = this.merkleLayers.length;
267
+ this.merkleLayers.push([]);
268
+ // Process pairs of nodes
269
+ for (let i = 0; i < nodes.length - 1; i += 2) {
270
+ const left = nodes[i];
271
+ const right = nodes[i + 1];
272
+ const hash = this.combinedHash(left, right);
273
+ this.merkleLayers[layerIndex].push(hash);
274
+ }
275
+ // Handle odd number of nodes
276
+ if (nodes.length % 2 === 1) {
277
+ const last = nodes[nodes.length - 1];
278
+ if (this.merkleOptions.duplicateOdd) {
279
+ // Duplicate the last node if odd
280
+ const hash = this.combinedHash(last, last);
281
+ this.merkleLayers[layerIndex].push(hash);
282
+ }
283
+ else {
284
+ // Push last node up to next layer
285
+ this.merkleLayers[layerIndex].push(last);
286
+ }
287
+ }
288
+ nodes = this.merkleLayers[layerIndex];
289
+ }
290
+ }
291
+ /**
292
+ * Rebuilds the Merkle tree from current leaves
293
+ */
294
+ rebuildMerkleTree() {
295
+ if (this.merkleLeaves.length === 0) {
296
+ this.merkleLayers = [];
297
+ return;
298
+ }
299
+ // Process leaves according to options
300
+ const processedLeaves = this.merkleLeaves.map(leaf => {
301
+ if (this.merkleOptions.hashLeaves) {
302
+ return this.hash(leaf);
303
+ }
304
+ return Buffer.isBuffer(leaf) ? leaf : Buffer.from(leaf);
305
+ });
306
+ if (this.merkleOptions.sortLeaves) {
307
+ processedLeaves.sort(Buffer.compare);
308
+ }
309
+ this.merkleLayers = [processedLeaves];
310
+ this.createHashes(processedLeaves);
311
+ }
312
+ /**
313
+ * Generates a proof of inclusion for a leaf node
314
+ * @param leaf - The leaf node to generate proof for
315
+ * @returns Array of sibling hashes needed to reconstruct root
316
+ * @throws Error if leaf not found in tree or accumulation not enabled
317
+ */
318
+ getProof(leaf) {
319
+ if (!this.enableAccumulation) {
320
+ throw new Error('Hash accumulation not enabled. Set enableAccumulation: true in constructor.');
321
+ }
322
+ if (this.merkleLayers.length === 0) {
323
+ this.rebuildMerkleTree();
324
+ }
325
+ let index = this.merkleLeaves.findIndex(item => item.equals(leaf));
326
+ if (index === -1) {
327
+ throw new Error('Leaf not found in tree');
328
+ }
329
+ return this.merkleLayers.reduce((proof, layer) => {
330
+ if (layer.length === 1)
331
+ return proof;
332
+ const pairIndex = index % 2 === 0 ? index + 1 : index - 1;
333
+ if (pairIndex < layer.length) {
334
+ proof.push(layer[pairIndex]);
335
+ }
336
+ index = Math.floor(index / 2);
337
+ return proof;
338
+ }, []);
339
+ }
340
+ /**
341
+ * Verifies a proof of inclusion for a leaf node
342
+ * @param proof - Array of sibling hashes from getProof()
343
+ * @param targetHash - Hash of the leaf node being verified
344
+ * @param root - Expected root hash
345
+ * @returns boolean indicating if proof is valid
346
+ */
347
+ verify(proof, targetHash, root) {
348
+ let computedHash = targetHash;
349
+ for (const proofElement of proof) {
350
+ computedHash = Buffer.compare(computedHash, proofElement) <= 0
351
+ ? this.combinedHash(computedHash, proofElement)
352
+ : this.combinedHash(proofElement, computedHash);
353
+ }
354
+ return computedHash.equals(root);
355
+ }
356
+ }
357
+ exports.HashCalculator = HashCalculator;
358
+ // Default export
359
+ exports.default = HashCalculator;
360
+ //# sourceMappingURL=HashCalculator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HashCalculator.js","sourceRoot":"","sources":["../../../src/core/components/HashCalculator.ts"],"names":[],"mappings":";AAAA,yCAAyC;AACzC,8CAA8C;AAC9C,gFAAgF;AAChF,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzC,+CAAiC;AACjC,uDAAsD;AAYtD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,cAAc;IAqBzB;;;;;OAKG;IACH,YAAY,OAGX;QA7BD,iEAAiE;QACzD,eAAU,GAAW,CAAC,CAAC,CAAC;QACxB,eAAU,GAAuB,IAAI,CAAC;QACtC,cAAS,GAAY,KAAK,CAAC;QAEnC,iDAAiD;QACzC,WAAM,GAAa,EAAE,CAAC;QACtB,cAAS,GAAW,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACxC,uBAAkB,G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,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;YAC1D,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC7B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;YAC/B,CAAC;YAED,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YAC9B,OAAO,KAAK,CAAC;QACf,CAAC,EAAE,EAAc,CAAC,CAAC;IACrB,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAe,EAAE,UAAkB,EAAE,IAAY;QACtD,IAAI,YAAY,GAAG,UAAU,CAAC;QAE9B,KAAK,MAAM,YAAY,IAAI,KAAK,EAAE,CAAC;YACjC,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,IAAI,CAAC;gBAC5D,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC;gBAC/C,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QACpD,CAAC;QAED,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF;AAhVD,wCAgVC;AAED,iBAAiB;AACjB,kBAAe,cAAc,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Global Logger Utility for NeoZipKit
3
+ * Provides centralized console control with configurable log levels
4
+ */
5
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
6
+ export interface LoggerConfig {
7
+ enabled: boolean;
8
+ level: LogLevel;
9
+ }
10
+ /**
11
+ * Global Logger class for controlling console output throughout NeoZipKit
12
+ */
13
+ export declare class Logger {
14
+ private static config;
15
+ private static originalConsole;
16
+ /**
17
+ * Configure the logger
18
+ */
19
+ static configure(config: Partial<LoggerConfig>): void;
20
+ /**
21
+ * Get current logger configuration
22
+ */
23
+ static getConfig(): LoggerConfig;
24
+ /**
25
+ * Enable logging
26
+ */
27
+ static enable(): void;
28
+ /**
29
+ * Disable all logging
30
+ */
31
+ static disable(): void;
32
+ /**
33
+ * Set log level
34
+ */
35
+ static setLevel(level: LogLevel): void;
36
+ /**
37
+ * Check if a log level should be output
38
+ */
39
+ private static shouldLog;
40
+ /**
41
+ * Log a message
42
+ */
43
+ static log(...args: any[]): void;
44
+ /**
45
+ * Log an error message
46
+ */
47
+ static error(...args: any[]): void;
48
+ /**
49
+ * Log a warning message
50
+ */
51
+ static warn(...args: any[]): void;
52
+ /**
53
+ * Log a debug message
54
+ */
55
+ static debug(...args: any[]): void;
56
+ /**
57
+ * Log an info message
58
+ */
59
+ static info(...args: any[]): void;
60
+ /**
61
+ * Override console methods globally (use with caution)
62
+ */
63
+ static overrideConsole(): void;
64
+ /**
65
+ * Restore original console methods
66
+ */
67
+ static restoreConsole(): void;
68
+ }
69
+ /**
70
+ * Environment-based configuration
71
+ */
72
+ export declare function configureLoggerFromEnvironment(): void;
73
+ //# sourceMappingURL=Logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../../src/core/components/Logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,MAAM,CAGnB;IAEF,OAAO,CAAC,MAAM,CAAC,eAAe,CAM5B;IAEF;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAIrD;;OAEG;IACH,MAAM,CAAC,SAAS,IAAI,YAAY;IAIhC;;OAEG;IACH,MAAM,C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