neozipkit 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +410 -186
- package/contracts/ABI.txt +889 -0
- package/contracts/Bytecode.txt +1 -0
- package/contracts/COMPILATION_NOTES.md +59 -0
- package/contracts/QUICK_DEPLOY.md +286 -0
- package/contracts/README.md +235 -131
- package/contracts/VERIFICATION.md +308 -0
- package/contracts/deploy-interactive.js +448 -0
- package/contracts/deployment-arbitrum-sepolia.json +12 -0
- package/contracts/deployment-arbitrum.json +12 -0
- package/contracts/deployment-eth-sepolia.json +12 -0
- package/contracts/hardhat.config.js +114 -0
- package/contracts/package.json +20 -0
- package/contracts/scripts/compile-and-extract.js +119 -0
- package/contracts/scripts/verify-contract.js +223 -0
- package/contracts/src/{NZIP-NFT-Private.sol → NZIP-NFT-v2.0.sol} +66 -151
- package/contracts/src/NZIP-NFT.sol +9 -15
- package/dist/blockchain/browser/TokenVerifierBrowser.d.ts +67 -0
- package/dist/blockchain/browser/TokenVerifierBrowser.d.ts.map +1 -0
- package/dist/blockchain/browser/TokenVerifierBrowser.js +313 -0
- package/dist/blockchain/browser/TokenVerifierBrowser.js.map +1 -0
- package/dist/blockchain/browser/WalletManagerBrowser.d.ts +98 -0
- package/dist/blockchain/browser/WalletManagerBrowser.d.ts.map +1 -0
- package/dist/blockchain/browser/WalletManagerBrowser.js +434 -0
- package/dist/blockchain/browser/WalletManagerBrowser.js.map +1 -0
- package/dist/blockchain/browser/ZipkitMinterBrowser.d.ts +58 -0
- package/dist/blockchain/browser/ZipkitMinterBrowser.d.ts.map +1 -0
- package/dist/blockchain/browser/ZipkitMinterBrowser.js +317 -0
- package/dist/blockchain/browser/ZipkitMinterBrowser.js.map +1 -0
- package/dist/blockchain/browser/index.d.ts +11 -0
- package/dist/blockchain/browser/index.d.ts.map +1 -0
- package/dist/blockchain/browser/index.js +16 -0
- package/dist/blockchain/browser/index.js.map +1 -0
- package/dist/blockchain/core/WalletManager.d.ts +124 -0
- package/dist/blockchain/core/WalletManager.d.ts.map +1 -0
- package/dist/blockchain/{ZipKitWallet.js → core/WalletManager.js} +157 -177
- package/dist/blockchain/core/WalletManager.js.map +1 -0
- package/dist/blockchain/{ZipKitMinter.d.ts → core/ZipkitMinter.d.ts} +46 -11
- package/dist/blockchain/core/ZipkitMinter.d.ts.map +1 -0
- package/dist/blockchain/core/ZipkitMinter.js +548 -0
- package/dist/blockchain/core/ZipkitMinter.js.map +1 -0
- package/dist/blockchain/{ZipKitOTS.d.ts → core/ZipkitOTS.d.ts} +6 -15
- package/dist/blockchain/core/ZipkitOTS.d.ts.map +1 -0
- package/dist/blockchain/{ZipKitOTS.js → core/ZipkitOTS.js} +26 -84
- package/dist/blockchain/core/ZipkitOTS.js.map +1 -0
- package/dist/blockchain/core/ZipkitVerifier.d.ts +177 -0
- package/dist/blockchain/core/ZipkitVerifier.d.ts.map +1 -0
- package/dist/blockchain/core/ZipkitVerifier.js +632 -0
- package/dist/blockchain/core/ZipkitVerifier.js.map +1 -0
- package/dist/blockchain/core/contracts.d.ts +83 -0
- package/dist/blockchain/core/contracts.d.ts.map +1 -0
- package/dist/blockchain/core/contracts.js +341 -0
- package/dist/blockchain/core/contracts.js.map +1 -0
- package/dist/blockchain/core/index.d.ts +12 -0
- package/dist/blockchain/core/index.d.ts.map +1 -0
- package/dist/blockchain/core/index.js +59 -0
- package/dist/blockchain/core/index.js.map +1 -0
- package/dist/blockchain/index.d.ts +11 -7
- package/dist/blockchain/index.d.ts.map +1 -0
- package/dist/blockchain/index.js +18 -34
- package/dist/blockchain/index.js.map +1 -0
- package/dist/blockchain/node/WalletManagerNode.d.ts +47 -0
- package/dist/blockchain/node/WalletManagerNode.d.ts.map +1 -0
- package/dist/blockchain/node/WalletManagerNode.js +203 -0
- package/dist/blockchain/node/WalletManagerNode.js.map +1 -0
- package/dist/blockchain/node/index.d.ts +12 -0
- package/dist/blockchain/node/index.d.ts.map +1 -0
- package/dist/blockchain/node/index.js +24 -0
- package/dist/blockchain/node/index.js.map +1 -0
- package/dist/browser/ZipkitBrowser.d.ts +27 -0
- package/dist/browser/ZipkitBrowser.d.ts.map +1 -0
- package/dist/browser/{ZipKitBrowser.js → ZipkitBrowser.js} +96 -43
- package/dist/browser/ZipkitBrowser.js.map +1 -0
- package/dist/browser/index.d.ts +12 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +42 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser-esm/index.d.ts +12 -0
- package/dist/browser-esm/index.js +59559 -0
- package/dist/browser-esm/index.js.map +7 -0
- package/dist/browser-umd/index.d.ts +12 -0
- package/dist/browser-umd/index.js +59576 -0
- package/dist/browser-umd/index.js.map +7 -0
- package/dist/browser-umd/index.min.js +63 -0
- package/dist/browser.d.ts +8 -14
- package/dist/browser.js +13 -28
- package/dist/core/ZipCompress.d.ts +99 -0
- package/dist/core/ZipCompress.d.ts.map +1 -0
- package/dist/core/ZipCompress.js +309 -0
- package/dist/core/ZipCompress.js.map +1 -0
- package/dist/core/ZipDecompress.d.ts +58 -0
- package/dist/core/ZipDecompress.d.ts.map +1 -0
- package/dist/core/ZipDecompress.js +172 -0
- package/dist/core/ZipDecompress.js.map +1 -0
- package/dist/{shared → core}/ZipEntry.d.ts +8 -1
- package/dist/core/ZipEntry.d.ts.map +1 -0
- package/dist/{shared → core}/ZipEntry.js +225 -82
- package/dist/core/ZipEntry.js.map +1 -0
- package/dist/core/Zipkit.d.ts +315 -0
- package/dist/core/Zipkit.d.ts.map +1 -0
- package/dist/core/Zipkit.js +647 -0
- package/dist/core/Zipkit.js.map +1 -0
- package/dist/core/components/HashCalculator.d.ts +138 -0
- package/dist/core/components/HashCalculator.d.ts.map +1 -0
- package/dist/core/components/HashCalculator.js +360 -0
- package/dist/core/components/HashCalculator.js.map +1 -0
- package/dist/core/components/Logger.d.ts +73 -0
- package/dist/core/components/Logger.d.ts.map +1 -0
- package/dist/core/components/Logger.js +156 -0
- package/dist/core/components/Logger.js.map +1 -0
- package/dist/core/components/ProgressTracker.d.ts +43 -0
- package/dist/core/components/ProgressTracker.d.ts.map +1 -0
- package/dist/core/components/ProgressTracker.js +112 -0
- package/dist/core/components/ProgressTracker.js.map +1 -0
- package/dist/{shared → core}/components/Support.d.ts +1 -0
- package/dist/core/components/Support.d.ts.map +1 -0
- package/dist/{shared → core}/components/Support.js +1 -0
- package/dist/core/components/Support.js.map +1 -0
- package/dist/{shared → core}/components/Util.d.ts +7 -2
- package/dist/core/components/Util.d.ts.map +1 -0
- package/dist/{shared → core}/components/Util.js +14 -34
- package/dist/core/components/Util.js.map +1 -0
- package/dist/{shared → core}/constants/Errors.d.ts +1 -2
- package/dist/core/constants/Errors.d.ts.map +1 -0
- package/dist/{shared → core}/constants/Errors.js +1 -3
- package/dist/core/constants/Errors.js.map +1 -0
- package/dist/{shared → core}/constants/Headers.d.ts +3 -0
- package/dist/core/constants/Headers.d.ts.map +1 -0
- package/dist/{shared → core}/constants/Headers.js +20 -17
- package/dist/core/constants/Headers.js.map +1 -0
- package/dist/core/encryption/Manager.d.ts +58 -0
- package/dist/core/encryption/Manager.d.ts.map +1 -0
- package/dist/core/encryption/Manager.js +121 -0
- package/dist/core/encryption/Manager.js.map +1 -0
- package/dist/core/encryption/ZipCrypto.d.ts +172 -0
- package/dist/core/encryption/ZipCrypto.d.ts.map +1 -0
- package/dist/core/encryption/ZipCrypto.js +554 -0
- package/dist/core/encryption/ZipCrypto.js.map +1 -0
- package/dist/core/encryption/index.d.ts +9 -0
- package/dist/core/encryption/index.d.ts.map +1 -0
- package/dist/core/encryption/index.js +17 -0
- package/dist/core/encryption/index.js.map +1 -0
- package/dist/core/encryption/types.d.ts +29 -0
- package/dist/core/encryption/types.d.ts.map +1 -0
- package/dist/core/encryption/types.js +12 -0
- package/dist/core/encryption/types.js.map +1 -0
- package/dist/core/index.d.ts +24 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +57 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/version.d.ts +5 -0
- package/dist/core/version.d.ts.map +1 -0
- package/dist/core/version.js +31 -0
- package/dist/core/version.js.map +1 -0
- package/dist/index.d.ts +8 -18
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -35
- package/dist/index.js.map +1 -0
- package/dist/node/ZipCompressNode.d.ts +123 -0
- package/dist/node/ZipCompressNode.d.ts.map +1 -0
- package/dist/node/ZipCompressNode.js +576 -0
- package/dist/node/ZipCompressNode.js.map +1 -0
- package/dist/node/ZipDecompressNode.d.ts +120 -0
- package/dist/node/ZipDecompressNode.d.ts.map +1 -0
- package/dist/node/ZipDecompressNode.js +461 -0
- package/dist/node/ZipDecompressNode.js.map +1 -0
- package/dist/node/ZipkitNode.d.ts +406 -0
- package/dist/node/ZipkitNode.d.ts.map +1 -0
- package/dist/node/ZipkitNode.js +1305 -0
- package/dist/node/ZipkitNode.js.map +1 -0
- package/dist/node/index.d.ts +26 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +65 -0
- package/dist/node/index.js.map +1 -0
- package/dist/types/index.d.ts +59 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +36 -1
- package/dist/types/index.js.map +1 -0
- package/examples/README.md +269 -0
- package/examples/blockchain-tokenize.ts +354 -0
- package/examples/create-zip.ts +172 -0
- package/examples/extract-zip.ts +158 -0
- package/examples/list-zip.ts +161 -0
- package/examples/test-files/data.json +116 -0
- package/examples/test-files/document.md +80 -0
- package/examples/test-files/document.txt +2 -0
- package/examples/test-files/file1.txt +48 -0
- package/examples/test-files/file2.txt +80 -0
- package/examples/tsconfig.json +44 -0
- package/examples/unzip-token.ts +491 -0
- package/examples/verify-tokenized-zip.ts +305 -0
- package/examples/zip-token.ts +604 -0
- package/package.json +108 -24
- package/src/blockchain/README.md +59 -66
- package/src/{browser/TokenVerifierBrowser.ts-remove → blockchain/browser/TokenVerifierBrowser.ts} +125 -79
- package/src/blockchain/browser/WalletManagerBrowser.ts +486 -0
- package/src/blockchain/browser/ZipkitMinterBrowser.ts +400 -0
- package/src/blockchain/browser/index.ts +13 -0
- package/src/blockchain/{ZipKitWallet.ts → core/WalletManager.ts} +241 -143
- package/src/blockchain/core/ZipkitMinter.ts +716 -0
- package/src/blockchain/{ZipKitOTS.ts → core/ZipkitOTS.ts} +28 -62
- package/src/blockchain/core/ZipkitVerifier.ts +853 -0
- package/src/blockchain/core/contracts.ts +370 -0
- package/src/blockchain/core/index.ts +71 -0
- package/src/blockchain/index.ts +21 -55
- package/src/blockchain/node/WalletManagerNode.ts +171 -0
- package/src/blockchain/node/index.ts +40 -0
- package/src/browser/{ZipKitBrowser.ts → ZipkitBrowser.ts} +104 -41
- package/src/browser/index.esm.ts +37 -0
- package/src/browser/index.ts +25 -0
- package/src/core/ZipCompress.ts +398 -0
- package/src/core/ZipDecompress.ts +212 -0
- package/src/{shared → core}/ZipEntry.ts +240 -90
- package/src/core/Zipkit.ts +794 -0
- package/src/core/components/HashCalculator.ts +384 -0
- package/src/core/components/Logger.ts +180 -0
- package/src/core/components/ProgressTracker.ts +134 -0
- package/src/{shared → core}/components/Util.ts +12 -34
- package/src/{shared → core}/constants/Errors.ts +0 -4
- package/src/{shared → core}/constants/Headers.ts +19 -17
- package/src/core/encryption/Manager.ts +137 -0
- package/src/core/encryption/ZipCrypto.ts +650 -0
- package/src/core/encryption/index.ts +15 -0
- package/src/core/encryption/types.ts +33 -0
- package/src/core/index.ts +34 -0
- package/src/core/version.ts +33 -0
- package/src/index.ts +54 -25
- package/src/node/ZipCompressNode.ts +632 -0
- package/src/node/ZipDecompressNode.ts +508 -0
- package/src/node/ZipkitNode.ts +1559 -0
- package/src/node/index.ts +69 -0
- package/src/types/index.ts +131 -1
- package/src/types/modules.d.ts +1 -11
- package/src/types/opentimestamps.d.ts +1 -23
- package/contracts/INTEGRATION.md +0 -338
- package/contracts/NETWORKS.md +0 -156
- package/contracts/NZIP-NFT-bytecode.txt +0 -1
- package/contracts/constants.ts +0 -952
- package/contracts/deploy-bytecode.mjs +0 -94
- package/dist/blockchain/CertificateToken.d.ts +0 -48
- package/dist/blockchain/CertificateToken.js +0 -386
- package/dist/blockchain/ZipKitMinter.js +0 -347
- package/dist/blockchain/ZipKitNFT.d.ts +0 -3
- package/dist/blockchain/ZipKitNFT.js +0 -7
- package/dist/blockchain/ZipKitVerifier.d.ts +0 -69
- package/dist/blockchain/ZipKitVerifier.js +0 -289
- package/dist/blockchain/ZipKitWallet.d.ts +0 -69
- package/dist/blockchain/contracts.d.ts +0 -14
- package/dist/blockchain/contracts.js +0 -77
- package/dist/blockchain/types.d.ts +0 -47
- package/dist/blockchain/types.js +0 -30
- package/dist/browser/ZipKitBrowser.d.ts +0 -18
- package/dist/browser/ZipKitStampBrowser.d.ts +0 -2
- package/dist/browser/ZipKitStampBrowser.js +0 -12
- package/dist/browser-index.d.ts +0 -18
- package/dist/browser-index.js +0 -57
- package/dist/server/ZipKitServer.d.ts +0 -74
- package/dist/server/ZipKitServer.js +0 -310
- package/dist/shared/ZipKit.d.ts +0 -243
- package/dist/shared/ZipKit.js +0 -772
- package/dist/shared/components/CertificateOTS.d.ts +0 -15
- package/dist/shared/components/CertificateOTS.js +0 -116
- package/dist/shared/components/FileSys.d.ts +0 -2
- package/dist/shared/components/FileSys.js +0 -113
- package/dist/shared/components/HashAccumulator.d.ts +0 -55
- package/dist/shared/components/HashAccumulator.js +0 -100
- package/dist/shared/components/ZipCrypto.d.ts +0 -3
- package/dist/shared/components/ZipCrypto.js +0 -78
- package/dist/shared/components/merkleTree.d.ts +0 -66
- package/dist/shared/components/merkleTree.js +0 -136
- package/dist/shared/types/index.d.ts +0 -21
- package/dist/shared/types/index.js +0 -3
- package/dist/shared/types.d.ts +0 -33
- package/dist/shared/types.js +0 -8
- package/dist/shared/version.d.ts +0 -2
- package/dist/shared/version.js +0 -6
- package/src/blockchain/CertificateToken.ts +0 -444
- package/src/blockchain/ZipKitMinter.ts +0 -470
- package/src/blockchain/ZipKitNFT.ts +0 -12
- package/src/blockchain/ZipKitVerifier.ts +0 -382
- package/src/blockchain/contracts.ts +0 -88
- package/src/blockchain/types.ts +0 -91
- package/src/browser/CertificateGeneratorBrowser.ts-remove +0 -498
- package/src/browser/ZipKitStampBrowser.ts +0 -9
- package/src/browser-index.ts +0 -36
- package/src/server/README.md +0 -25
- package/src/server/ZipKitServer.ts +0 -305
- package/src/shared/ZipKit.ts +0 -881
- package/src/shared/components/CertificateOTS.ts +0 -132
- package/src/shared/components/FileSys.ts +0 -87
- package/src/shared/components/HashAccumulator.ts +0 -113
- package/src/shared/components/ZipCrypto.ts +0 -91
- package/src/shared/components/merkleTree.ts +0 -162
- package/src/shared/types/index.ts +0 -25
- package/src/shared/types/modules.d.ts +0 -22
- package/src/shared/types/opentimestamps.d.ts +0 -23
- package/src/shared/types.d.ts +0 -8
- package/src/shared/types.ts +0 -43
- package/src/shared/version.ts +0 -3
- /package/src/{shared → core}/components/Support.ts +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node Module Exports
|
|
3
|
+
* Node.js functionality for ZIP file processing and blockchain operations
|
|
4
|
+
*
|
|
5
|
+
* This is the entry point for Node.js-only imports:
|
|
6
|
+
* import ZipkitNode from 'neozipkit/node';
|
|
7
|
+
* // or
|
|
8
|
+
* import { Zipkit, ZipkitNode, ... } from 'neozipkit/node';
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Core ZIP functionality (re-exported from core module, but NOT the default)
|
|
12
|
+
export * from '../core';
|
|
13
|
+
import Zipkit from '../core';
|
|
14
|
+
export { Zipkit }; // Named export for backward compatibility
|
|
15
|
+
|
|
16
|
+
// Node.js-specific ZIP operations - default export (after export * to ensure it's the default)
|
|
17
|
+
import ZipkitNodeDefault from './ZipkitNode';
|
|
18
|
+
export { default as ZipkitNode } from './ZipkitNode';
|
|
19
|
+
// Set as default export - this will be the default when importing from this module
|
|
20
|
+
export default ZipkitNodeDefault;
|
|
21
|
+
export type { ZipFileWriter } from './ZipkitNode';
|
|
22
|
+
export { ZipCompressNode } from './ZipCompressNode';
|
|
23
|
+
export { ZipDecompressNode } from './ZipDecompressNode';
|
|
24
|
+
|
|
25
|
+
// Blockchain Node.js functionality
|
|
26
|
+
export {
|
|
27
|
+
WalletManagerNode,
|
|
28
|
+
ZipkitWallet,
|
|
29
|
+
ZipkitMinter,
|
|
30
|
+
ZipkitVerifier,
|
|
31
|
+
CoreWalletManager,
|
|
32
|
+
WalletAnalyzer,
|
|
33
|
+
createTimestamp,
|
|
34
|
+
verifyOts,
|
|
35
|
+
verifyOtsZip
|
|
36
|
+
} from '../blockchain';
|
|
37
|
+
export type {
|
|
38
|
+
EnhancedVerificationResult,
|
|
39
|
+
BatchVerificationResult,
|
|
40
|
+
VerificationJob,
|
|
41
|
+
MintingOptions,
|
|
42
|
+
MintingResult,
|
|
43
|
+
VerificationOptions,
|
|
44
|
+
VerificationResult,
|
|
45
|
+
WalletInfo,
|
|
46
|
+
NetworkConfig,
|
|
47
|
+
TokenMetadata,
|
|
48
|
+
WalletSetupResult,
|
|
49
|
+
CommonTokenConfig,
|
|
50
|
+
TokenInfo,
|
|
51
|
+
WalletBasicInfo,
|
|
52
|
+
TokenScanResult,
|
|
53
|
+
NZipTokenDetails,
|
|
54
|
+
TimestampResult,
|
|
55
|
+
TimestampInfo,
|
|
56
|
+
DeserializeOtsResult,
|
|
57
|
+
OtsVerifyResult
|
|
58
|
+
} from '../blockchain';
|
|
59
|
+
|
|
60
|
+
// Timestamp verification
|
|
61
|
+
export { verifyOts as verifyTimestamp } from '../blockchain/core/ZipkitOTS';
|
|
62
|
+
|
|
63
|
+
// Platform detection
|
|
64
|
+
export const PlatformUtils = {
|
|
65
|
+
// Browser detection
|
|
66
|
+
isBrowser: typeof window !== 'undefined' && typeof document !== 'undefined',
|
|
67
|
+
// Node.js detection
|
|
68
|
+
isNode: typeof process !== 'undefined' && process.versions && process.versions.node,
|
|
69
|
+
};
|
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,122 @@
|
|
|
1
|
+
import type { Wallet, JsonRpcProvider } from 'ethers';
|
|
2
|
+
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// Wallet and Network Types
|
|
5
|
+
// ============================================================================
|
|
6
|
+
|
|
7
|
+
export interface WalletInfo {
|
|
8
|
+
address: string;
|
|
9
|
+
privateKey: string;
|
|
10
|
+
mnemonic: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface NetworkConfig {
|
|
14
|
+
name: string;
|
|
15
|
+
rpcUrl: string;
|
|
16
|
+
chainId: number;
|
|
17
|
+
explorerUrl: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface WalletSetupResult {
|
|
21
|
+
wallet: Wallet | null;
|
|
22
|
+
provider: JsonRpcProvider | null;
|
|
23
|
+
success: boolean;
|
|
24
|
+
message?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface MintingResult {
|
|
28
|
+
success: boolean;
|
|
29
|
+
message: string;
|
|
30
|
+
tokenId?: string;
|
|
31
|
+
txHash?: string;
|
|
32
|
+
creationTimestamp?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface MintingOptions {
|
|
36
|
+
wallet?: string;
|
|
37
|
+
network: string;
|
|
38
|
+
mintToken: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// Token Metadata
|
|
43
|
+
// ============================================================================
|
|
44
|
+
|
|
45
|
+
// Canonical token metadata used across minting, verification, and ZIP embedding
|
|
46
|
+
export interface TokenMetadata {
|
|
47
|
+
// Core identifiers
|
|
48
|
+
tokenId: string;
|
|
49
|
+
contractAddress: string;
|
|
50
|
+
network: string;
|
|
51
|
+
merkleRoot: string;
|
|
52
|
+
|
|
53
|
+
// Optional chain info
|
|
54
|
+
networkChainId?: number;
|
|
55
|
+
transactionHash?: string;
|
|
56
|
+
blockNumber?: number;
|
|
57
|
+
owner?: string;
|
|
58
|
+
|
|
59
|
+
// Names and timestamps (support mintedAt/mintDate)
|
|
60
|
+
mintedAt?: string;
|
|
61
|
+
mintDate?: string;
|
|
62
|
+
creationTimestamp?: number;
|
|
63
|
+
|
|
64
|
+
// Optional content link
|
|
65
|
+
ipfsHash?: string;
|
|
66
|
+
|
|
67
|
+
// Versioning
|
|
68
|
+
version?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ============================================================================
|
|
72
|
+
// Network Configuration
|
|
73
|
+
// ============================================================================
|
|
74
|
+
|
|
75
|
+
export const NETWORKS: Record<string, NetworkConfig> = {
|
|
76
|
+
'base': {
|
|
77
|
+
name: 'Base Mainnet',
|
|
78
|
+
rpcUrl: 'https://mainnet.base.org',
|
|
79
|
+
chainId: 8453,
|
|
80
|
+
explorerUrl: 'https://basescan.org'
|
|
81
|
+
},
|
|
82
|
+
'base-sepolia': {
|
|
83
|
+
name: 'Base Sepolia',
|
|
84
|
+
rpcUrl: 'https://sepolia.base.org',
|
|
85
|
+
chainId: 84532,
|
|
86
|
+
explorerUrl: 'https://sepolia.basescan.org'
|
|
87
|
+
},
|
|
88
|
+
'base-goerli': {
|
|
89
|
+
name: 'Base Goerli',
|
|
90
|
+
rpcUrl: 'https://goerli.base.org',
|
|
91
|
+
chainId: 84531,
|
|
92
|
+
explorerUrl: 'https://goerli.basescan.org'
|
|
93
|
+
},
|
|
94
|
+
'localhost': {
|
|
95
|
+
name: 'Localhost',
|
|
96
|
+
rpcUrl: 'http://localhost:8545',
|
|
97
|
+
chainId: 31337,
|
|
98
|
+
explorerUrl: 'http://localhost:8545'
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// ============================================================================
|
|
103
|
+
// NeoZipKit Version Info
|
|
104
|
+
// ============================================================================
|
|
105
|
+
|
|
106
|
+
export interface NeoZipKitInfo {
|
|
107
|
+
version: string;
|
|
108
|
+
releaseDate: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export const NEOZIPKIT_INFO: NeoZipKitInfo = {
|
|
112
|
+
version: '0.70.0-alpha',
|
|
113
|
+
releaseDate: '2024-10-04'
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// ============================================================================
|
|
117
|
+
// File Data Interfaces
|
|
118
|
+
// ============================================================================
|
|
119
|
+
|
|
1
120
|
export interface FileData {
|
|
2
121
|
name: string;
|
|
3
122
|
size: number;
|
|
@@ -6,9 +125,20 @@ export interface FileData {
|
|
|
6
125
|
}
|
|
7
126
|
|
|
8
127
|
export interface ZipFileEntry {
|
|
128
|
+
filename: string;
|
|
129
|
+
comment?: string | null;
|
|
9
130
|
fileData?: FileData;
|
|
131
|
+
fileBuffer?: Buffer | null;
|
|
132
|
+
isDirectory: boolean;
|
|
133
|
+
isMetaData: boolean;
|
|
134
|
+
isEncrypted: boolean;
|
|
135
|
+
sha256?: string | null;
|
|
10
136
|
}
|
|
11
137
|
|
|
138
|
+
// ============================================================================
|
|
139
|
+
// Support Interface
|
|
140
|
+
// ============================================================================
|
|
141
|
+
|
|
12
142
|
export interface Support {
|
|
13
143
|
base64: boolean;
|
|
14
144
|
array: boolean;
|
|
@@ -22,4 +152,4 @@ export interface Support {
|
|
|
22
152
|
fileReader: boolean;
|
|
23
153
|
}
|
|
24
154
|
|
|
25
|
-
// External module types are handled by installed @types packages
|
|
155
|
+
// External module types are handled by installed @types packages
|
package/src/types/modules.d.ts
CHANGED
|
@@ -3,16 +3,6 @@ declare module 'pako' {
|
|
|
3
3
|
export function inflateRaw(data: Uint8Array | Buffer): Buffer;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
// Minimal typings to satisfy TS in environments without @types/moment-timezone
|
|
7
|
-
declare module 'moment' {
|
|
8
|
-
const moment: any;
|
|
9
|
-
export default moment;
|
|
10
|
-
}
|
|
11
|
-
declare module 'moment-timezone' {
|
|
12
|
-
const momentTz: any;
|
|
13
|
-
export default momentTz;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
6
|
declare module 'opentimestamps' {
|
|
17
7
|
export class Ops {
|
|
18
8
|
static OpSHA256: any;
|
|
@@ -29,4 +19,4 @@ declare module 'opentimestamps' {
|
|
|
29
19
|
export function upgrade(ots: DetachedTimestampFile): Promise<boolean>;
|
|
30
20
|
export function verify(ots: DetachedTimestampFile, hash: DetachedTimestampFile, options?: any): Promise<any>;
|
|
31
21
|
export function info(detached: DetachedTimestampFile): string;
|
|
32
|
-
}
|
|
22
|
+
}
|
|
@@ -1,23 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Type declarations for OpenTimestamps module
|
|
3
|
-
*/
|
|
4
|
-
declare module 'opentimestamps' {
|
|
5
|
-
namespace stamp {
|
|
6
|
-
function create(fileBuffer: Buffer): Promise<Buffer>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
namespace verify {
|
|
10
|
-
function verifyTimestamp(ots: Buffer, fileHash: Buffer): Promise<any>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
namespace utils {
|
|
14
|
-
function hexToBytes(hex: string): number[];
|
|
15
|
-
function bytesToHex(bytes: number[]): string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
stamp,
|
|
20
|
-
verify,
|
|
21
|
-
utils
|
|
22
|
-
};
|
|
23
|
-
}
|
|
1
|
+
declare module 'opentimestamps';
|
package/contracts/INTEGRATION.md
DELETED
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
# Contract Integration Guide
|
|
2
|
-
|
|
3
|
-
This guide shows how to integrate NeoZipKit smart contracts into your application.
|
|
4
|
-
|
|
5
|
-
## 🚀 Quick Integration
|
|
6
|
-
|
|
7
|
-
### Basic Setup
|
|
8
|
-
|
|
9
|
-
```typescript
|
|
10
|
-
import { ZipTokenProcessor, MintingOptions } from 'neozipkit/server/blockchain';
|
|
11
|
-
|
|
12
|
-
// Configure minting options
|
|
13
|
-
const options: MintingOptions = {
|
|
14
|
-
contractAddress: 'YOUR_DEPLOYED_CONTRACT_ADDRESS',
|
|
15
|
-
network: 'base-sepolia',
|
|
16
|
-
mintToken: true
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// Create processor
|
|
20
|
-
const processor = new ZipTokenProcessor('archive.zip', 'merkle_root_hash', options);
|
|
21
|
-
|
|
22
|
-
// Process and mint token
|
|
23
|
-
const result = await processor.processZipToken(options);
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### Environment Configuration
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
# Required environment variables
|
|
30
|
-
export RPC_URL="https://sepolia.base.org"
|
|
31
|
-
export NETWORK="base-sepolia"
|
|
32
|
-
export CONTRACT_ADDRESS="0xYourDeployedContractAddress"
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## 🔧 Core Components
|
|
36
|
-
|
|
37
|
-
### TokenVerifier
|
|
38
|
-
Verify tokenized ZIP files against blockchain:
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
import { TokenVerifier } from 'neozipkit/server/blockchain/TokenVerifier';
|
|
42
|
-
|
|
43
|
-
const verifier = new TokenVerifier({
|
|
44
|
-
network: 'base-sepolia',
|
|
45
|
-
contractAddress: '0xYourContractAddress'
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const isValid = await verifier.verifyToken(tokenId, merkleRoot);
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### NFTMinter
|
|
52
|
-
Mint NFTs for ZIP files:
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
import { NFTMinter } from 'neozipkit/server/blockchain/NFTMinter';
|
|
56
|
-
|
|
57
|
-
const minter = new NFTMinter({
|
|
58
|
-
network: 'base-sepolia',
|
|
59
|
-
contractAddress: process.env.CONTRACT_ADDRESS
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const tokenId = await minter.mintToken({
|
|
63
|
-
to: '0xRecipientAddress',
|
|
64
|
-
merkleRoot: 'merkle_root_hash',
|
|
65
|
-
metadata: {
|
|
66
|
-
name: 'My ZIP Archive',
|
|
67
|
-
description: 'Tokenized ZIP file',
|
|
68
|
-
// ... additional metadata
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### TokenQuerier
|
|
74
|
-
Query token information from blockchain:
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
import { TokenQuerier } from 'neozipkit/server/blockchain/TokenQuerier';
|
|
78
|
-
|
|
79
|
-
const querier = new TokenQuerier({
|
|
80
|
-
network: 'base-sepolia',
|
|
81
|
-
contractAddress: '0xYourContractAddress'
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Get token metadata
|
|
85
|
-
const metadata = await querier.getTokenMetadata(tokenId);
|
|
86
|
-
|
|
87
|
-
// Get token owner
|
|
88
|
-
const owner = await querier.getTokenOwner(tokenId);
|
|
89
|
-
|
|
90
|
-
// Check if token exists
|
|
91
|
-
const exists = await querier.tokenExists(tokenId);
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### WalletManager
|
|
95
|
-
Manage wallet connections and networks:
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
import { WalletManager } from 'neozipkit/server/blockchain/WalletManager';
|
|
99
|
-
|
|
100
|
-
const walletManager = new WalletManager({
|
|
101
|
-
network: 'base-sepolia',
|
|
102
|
-
rpcUrl: process.env.RPC_URL
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
// Get wallet balance
|
|
106
|
-
const balance = await walletManager.getBalance();
|
|
107
|
-
|
|
108
|
-
// Get network information
|
|
109
|
-
const networkInfo = await walletManager.getNetworkInfo();
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## 🌐 Browser Integration
|
|
113
|
-
|
|
114
|
-
### Browser-Compatible Components
|
|
115
|
-
|
|
116
|
-
```typescript
|
|
117
|
-
import { TokenVerifierBrowser } from 'neozipkit/browser';
|
|
118
|
-
|
|
119
|
-
const verifier = new TokenVerifierBrowser({
|
|
120
|
-
network: 'base-sepolia',
|
|
121
|
-
rpcUrl: 'https://sepolia.base.org',
|
|
122
|
-
contractAddress: '0xYourContractAddress'
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// Verify token (read-only operation)
|
|
126
|
-
const isValid = await verifier.verifyToken(tokenId, merkleRoot);
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Web3 Wallet Integration
|
|
130
|
-
|
|
131
|
-
```typescript
|
|
132
|
-
// Connect to user's wallet (MetaMask, etc.)
|
|
133
|
-
if (window.ethereum) {
|
|
134
|
-
const provider = new ethers.providers.Web3Provider(window.ethereum);
|
|
135
|
-
await provider.send("eth_requestAccounts", []);
|
|
136
|
-
|
|
137
|
-
const signer = provider.getSigner();
|
|
138
|
-
const userAddress = await signer.getAddress();
|
|
139
|
-
|
|
140
|
-
// Use with NeoZipKit components
|
|
141
|
-
const minter = new NFTMinter({
|
|
142
|
-
signer: signer,
|
|
143
|
-
contractAddress: process.env.CONTRACT_ADDRESS
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## 📝 Complete Example
|
|
149
|
-
|
|
150
|
-
### Server-Side Token Creation
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
import {
|
|
154
|
-
ZipTokenProcessor,
|
|
155
|
-
NFTMinter,
|
|
156
|
-
TokenVerifier
|
|
157
|
-
} from 'neozipkit/server/blockchain';
|
|
158
|
-
|
|
159
|
-
async function createAndVerifyToken() {
|
|
160
|
-
try {
|
|
161
|
-
// 1. Process ZIP file and create Merkle root
|
|
162
|
-
const processor = new ZipTokenProcessor('archive.zip', null, {
|
|
163
|
-
network: 'base-sepolia',
|
|
164
|
-
contractAddress: process.env.CONTRACT_ADDRESS
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
const { merkleRoot, zipHash } = await processor.generateHashes();
|
|
168
|
-
|
|
169
|
-
// 2. Mint NFT token
|
|
170
|
-
const minter = new NFTMinter({
|
|
171
|
-
network: 'base-sepolia',
|
|
172
|
-
contractAddress: process.env.CONTRACT_ADDRESS
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
const tokenId = await minter.mintToken({
|
|
176
|
-
to: '0xRecipientAddress',
|
|
177
|
-
merkleRoot: merkleRoot,
|
|
178
|
-
metadata: {
|
|
179
|
-
name: 'Archive Token',
|
|
180
|
-
description: 'Verified ZIP archive',
|
|
181
|
-
zipHash: zipHash
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
console.log(`Token minted with ID: ${tokenId}`);
|
|
186
|
-
|
|
187
|
-
// 3. Verify the token
|
|
188
|
-
const verifier = new TokenVerifier({
|
|
189
|
-
network: 'base-sepolia',
|
|
190
|
-
contractAddress: process.env.CONTRACT_ADDRESS
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
const isValid = await verifier.verifyToken(tokenId, merkleRoot);
|
|
194
|
-
console.log(`Token verification: ${isValid ? 'VALID' : 'INVALID'}`);
|
|
195
|
-
|
|
196
|
-
return { tokenId, merkleRoot, isValid };
|
|
197
|
-
|
|
198
|
-
} catch (error) {
|
|
199
|
-
console.error('Error creating token:', error);
|
|
200
|
-
throw error;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
### Client-Side Token Verification
|
|
206
|
-
|
|
207
|
-
```typescript
|
|
208
|
-
import { TokenVerifierBrowser } from 'neozipkit/browser';
|
|
209
|
-
|
|
210
|
-
async function verifyTokenFromBrowser(tokenId: string, merkleRoot: string) {
|
|
211
|
-
const verifier = new TokenVerifierBrowser({
|
|
212
|
-
network: 'base-sepolia',
|
|
213
|
-
rpcUrl: 'https://sepolia.base.org',
|
|
214
|
-
contractAddress: '0xYourContractAddress'
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
try {
|
|
218
|
-
const isValid = await verifier.verifyToken(tokenId, merkleRoot);
|
|
219
|
-
|
|
220
|
-
if (isValid) {
|
|
221
|
-
console.log('✅ Token is valid and verified on blockchain');
|
|
222
|
-
} else {
|
|
223
|
-
console.log('❌ Token verification failed');
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return isValid;
|
|
227
|
-
|
|
228
|
-
} catch (error) {
|
|
229
|
-
console.error('Verification error:', error);
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
## 🔒 Security Best Practices
|
|
236
|
-
|
|
237
|
-
### Contract Address Management
|
|
238
|
-
|
|
239
|
-
```typescript
|
|
240
|
-
// ✅ DO: Use environment variables for contract addresses
|
|
241
|
-
const contractAddress = process.env.CONTRACT_ADDRESS;
|
|
242
|
-
|
|
243
|
-
// ✅ DO: Validate contract addresses
|
|
244
|
-
import { ethers } from 'ethers';
|
|
245
|
-
if (!ethers.utils.isAddress(contractAddress)) {
|
|
246
|
-
throw new Error('Invalid contract address');
|
|
247
|
-
}
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
### Input Validation
|
|
251
|
-
|
|
252
|
-
```typescript
|
|
253
|
-
import { ethers } from 'ethers';
|
|
254
|
-
|
|
255
|
-
function validateInputs(tokenId: string, address: string) {
|
|
256
|
-
// Validate token ID
|
|
257
|
-
if (!tokenId || !/^\d+$/.test(tokenId)) {
|
|
258
|
-
throw new Error('Invalid token ID');
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Validate Ethereum address
|
|
262
|
-
if (!ethers.utils.isAddress(address)) {
|
|
263
|
-
throw new Error('Invalid Ethereum address');
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
### Error Handling
|
|
269
|
-
|
|
270
|
-
```typescript
|
|
271
|
-
async function safeTokenOperation() {
|
|
272
|
-
try {
|
|
273
|
-
const result = await processor.processZipToken(options);
|
|
274
|
-
return result;
|
|
275
|
-
} catch (error) {
|
|
276
|
-
if (error.code === 'NETWORK_ERROR') {
|
|
277
|
-
console.error('Network connectivity issue');
|
|
278
|
-
} else if (error.code === 'CONTRACT_ERROR') {
|
|
279
|
-
console.error('Contract interaction failed');
|
|
280
|
-
} else {
|
|
281
|
-
console.error('Unexpected error:', error.message);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// Log error for monitoring
|
|
285
|
-
logger.error('Token operation failed', { error, options });
|
|
286
|
-
|
|
287
|
-
throw error;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
## 📊 Monitoring and Analytics
|
|
293
|
-
|
|
294
|
-
### Event Listening
|
|
295
|
-
|
|
296
|
-
```typescript
|
|
297
|
-
import { ethers } from 'ethers';
|
|
298
|
-
|
|
299
|
-
// Listen for token mint events
|
|
300
|
-
const contract = new ethers.Contract(contractAddress, abi, provider);
|
|
301
|
-
|
|
302
|
-
contract.on('Transfer', (from, to, tokenId) => {
|
|
303
|
-
if (from === ethers.constants.AddressZero) {
|
|
304
|
-
console.log(`New token minted: ${tokenId} to ${to}`);
|
|
305
|
-
// Log to analytics
|
|
306
|
-
analytics.track('token_minted', { tokenId, recipient: to });
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
### Health Monitoring
|
|
312
|
-
|
|
313
|
-
```typescript
|
|
314
|
-
async function checkContractHealth() {
|
|
315
|
-
try {
|
|
316
|
-
const querier = new TokenQuerier({
|
|
317
|
-
network: process.env.NETWORK,
|
|
318
|
-
contractAddress: process.env.CONTRACT_ADDRESS
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
// Check if contract is responding
|
|
322
|
-
const totalSupply = await querier.getTotalSupply();
|
|
323
|
-
|
|
324
|
-
return {
|
|
325
|
-
status: 'healthy',
|
|
326
|
-
totalSupply: totalSupply,
|
|
327
|
-
timestamp: new Date().toISOString()
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
} catch (error) {
|
|
331
|
-
return {
|
|
332
|
-
status: 'unhealthy',
|
|
333
|
-
error: error.message,
|
|
334
|
-
timestamp: new Date().toISOString()
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
```
|