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
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// NZIP-NFT deployment script using precompiled bytecode
|
|
2
|
-
// Usage (Base Mainnet):
|
|
3
|
-
// env PRIVATE_KEY=0x... BASE_RPC_URL=https://mainnet.base.org node contracts/deploy-bytecode.mjs
|
|
4
|
-
// Usage (Base Sepolia):
|
|
5
|
-
// env PRIVATE_KEY=0x... NETWORK=base-sepolia BASE_RPC_URL=https://sepolia.base.org node contracts/deploy-bytecode.mjs
|
|
6
|
-
// Usage (Ethereum Mainnet):
|
|
7
|
-
// env PRIVATE_KEY=0x... NETWORK=eth ETH_RPC_URL=https://mainnet.infura.io/v3/<KEY> node contracts/deploy-bytecode.mjs
|
|
8
|
-
// Optional env:
|
|
9
|
-
// BYTECODE_PATH=contracts/NZIP-NFT-bytecode.txt
|
|
10
|
-
// NETWORK=base | base-sepolia | eth
|
|
11
|
-
|
|
12
|
-
import fs from 'node:fs';
|
|
13
|
-
import path from 'node:path';
|
|
14
|
-
|
|
15
|
-
const { ethers } = await import('ethers');
|
|
16
|
-
|
|
17
|
-
const NETWORK = process.env.NETWORK || 'base';
|
|
18
|
-
const DEFAULT_RPCS = {
|
|
19
|
-
'base': 'https://mainnet.base.org',
|
|
20
|
-
'base-sepolia': 'https://sepolia.base.org',
|
|
21
|
-
'eth': 'https://eth.llamarpc.com',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const PRIVATE_KEY = process.env.PRIVATE_KEY;
|
|
25
|
-
// Prefer network-specific env var, then fall back to defaults
|
|
26
|
-
const RPC_URL = (
|
|
27
|
-
NETWORK === 'eth'
|
|
28
|
-
? process.env.ETH_RPC_URL
|
|
29
|
-
: process.env.BASE_RPC_URL
|
|
30
|
-
) || DEFAULT_RPCS[NETWORK] || DEFAULT_RPCS['base'];
|
|
31
|
-
const BYTECODE_PATH = process.env.BYTECODE_PATH || path.join(process.cwd(), 'contracts', 'NZIP-NFT-bytecode.txt');
|
|
32
|
-
|
|
33
|
-
if (!PRIVATE_KEY) {
|
|
34
|
-
console.error('Error: PRIVATE_KEY env var is required');
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function loadBytecode(filePath) {
|
|
39
|
-
const raw = fs.readFileSync(filePath, 'utf8').trim();
|
|
40
|
-
if (!raw) throw new Error(`Empty bytecode in ${filePath}`);
|
|
41
|
-
return raw.startsWith('0x') ? raw : '0x' + raw;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function main() {
|
|
45
|
-
console.log(`Deploying NZIP-NFT bytecode to ${NETWORK} via ${RPC_URL}`);
|
|
46
|
-
const provider = new ethers.JsonRpcProvider(RPC_URL);
|
|
47
|
-
const wallet = new ethers.Wallet(PRIVATE_KEY, provider);
|
|
48
|
-
|
|
49
|
-
const bytecode = loadBytecode(BYTECODE_PATH);
|
|
50
|
-
|
|
51
|
-
const [nonce, balanceWei] = await Promise.all([
|
|
52
|
-
provider.getTransactionCount(wallet.address),
|
|
53
|
-
provider.getBalance(wallet.address),
|
|
54
|
-
]);
|
|
55
|
-
console.log('Deployer address:', wallet.address);
|
|
56
|
-
console.log('Deployer balance:', ethers.formatEther(balanceWei), 'ETH');
|
|
57
|
-
const fee = await provider.getFeeData();
|
|
58
|
-
const txReq = {
|
|
59
|
-
from: wallet.address,
|
|
60
|
-
data: bytecode,
|
|
61
|
-
// EIP-1559 fields if available
|
|
62
|
-
maxFeePerGas: fee.maxFeePerGas ?? undefined,
|
|
63
|
-
maxPriorityFeePerGas: fee.maxPriorityFeePerGas ?? undefined,
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const gasLimit = await wallet.estimateGas(txReq).catch(() => null);
|
|
67
|
-
if (gasLimit) {
|
|
68
|
-
txReq.gasLimit = gasLimit;
|
|
69
|
-
console.log('Estimated gas limit:', gasLimit.toString());
|
|
70
|
-
} else {
|
|
71
|
-
console.log('Estimated gas limit: unavailable (provider failed to estimate)');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
console.log('Sending deployment tx...');
|
|
75
|
-
const tx = await wallet.sendTransaction(txReq);
|
|
76
|
-
console.log('Tx hash:', tx.hash);
|
|
77
|
-
const receipt = await tx.wait();
|
|
78
|
-
|
|
79
|
-
if (!receipt || !receipt.contractAddress) {
|
|
80
|
-
console.error('Deployment failed or contractAddress not returned. Receipt:', receipt);
|
|
81
|
-
process.exit(1);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
console.log('Deployed contract address:', receipt.contractAddress);
|
|
85
|
-
console.log('Block number:', receipt.blockNumber);
|
|
86
|
-
console.log('NOTE: Update src/server/blockchain/constants.ts with this address for the corresponding chainId.');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
main().catch((err) => {
|
|
90
|
-
console.error('Deployment error:', err);
|
|
91
|
-
process.exit(1);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export interface TokenInfo {
|
|
2
|
-
tokenId: string;
|
|
3
|
-
contractAddress: string;
|
|
4
|
-
network: string;
|
|
5
|
-
transactionHash: string;
|
|
6
|
-
wallet?: string;
|
|
7
|
-
timestamp?: number;
|
|
8
|
-
note?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface BlockchainVerification {
|
|
11
|
-
merkleRootMatches: boolean;
|
|
12
|
-
blockchainMerkleRoot: string;
|
|
13
|
-
calculatedMerkleRoot: string;
|
|
14
|
-
verificationStatus: 'PASSED' | 'FAILED' | 'UNAVAILABLE';
|
|
15
|
-
verificationTime?: number;
|
|
16
|
-
blockNumber?: number;
|
|
17
|
-
}
|
|
18
|
-
export interface WalletInfo {
|
|
19
|
-
address: string;
|
|
20
|
-
balance?: string;
|
|
21
|
-
network: string;
|
|
22
|
-
ensName?: string;
|
|
23
|
-
}
|
|
24
|
-
export interface ZipFileInfo {
|
|
25
|
-
filename: string;
|
|
26
|
-
size: number;
|
|
27
|
-
date: string;
|
|
28
|
-
hash: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Generates a certificate HTML document for tokenized ZIP files
|
|
32
|
-
*
|
|
33
|
-
* @param tokenInfo - NFT token information
|
|
34
|
-
* @param zipFile - Name of the zip file
|
|
35
|
-
* @param blockchainVerification - Blockchain verification results
|
|
36
|
-
* @param walletInfo - Wallet information (optional)
|
|
37
|
-
* @param zipFiles - Array of file information (optional)
|
|
38
|
-
* @param options - Certificate generation options
|
|
39
|
-
* @returns Generated HTML certificate as string
|
|
40
|
-
*/
|
|
41
|
-
export declare function createTokenCertificate(tokenInfo: TokenInfo, zipFile: string, blockchainVerification: BlockchainVerification, walletInfo?: WalletInfo, zipFiles?: ZipFileInfo[], options?: {
|
|
42
|
-
narrow?: boolean;
|
|
43
|
-
includeQR?: boolean;
|
|
44
|
-
}): string;
|
|
45
|
-
/**
|
|
46
|
-
* Saves a certificate to disk
|
|
47
|
-
*/
|
|
48
|
-
export declare function saveCertificate(fileName: string, certificateHTML: string, outputDir?: string): string;
|
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ======================================
|
|
3
|
-
// CertificateToken.ts
|
|
4
|
-
// Copyright (c) 2025 NeoWare, Inc. All rights reserved.
|
|
5
|
-
//
|
|
6
|
-
// Standalone certificate generator for tokenized ZIP files
|
|
7
|
-
// This will be integrated into neozipkit once fully functional
|
|
8
|
-
// ======================================
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.createTokenCertificate = createTokenCertificate;
|
|
14
|
-
exports.saveCertificate = saveCertificate;
|
|
15
|
-
const fs_1 = __importDefault(require("fs"));
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
/**
|
|
18
|
-
* Generates a certificate HTML document for tokenized ZIP files
|
|
19
|
-
*
|
|
20
|
-
* @param tokenInfo - NFT token information
|
|
21
|
-
* @param zipFile - Name of the zip file
|
|
22
|
-
* @param blockchainVerification - Blockchain verification results
|
|
23
|
-
* @param walletInfo - Wallet information (optional)
|
|
24
|
-
* @param zipFiles - Array of file information (optional)
|
|
25
|
-
* @param options - Certificate generation options
|
|
26
|
-
* @returns Generated HTML certificate as string
|
|
27
|
-
*/
|
|
28
|
-
function createTokenCertificate(tokenInfo, zipFile, blockchainVerification, walletInfo, zipFiles, options) {
|
|
29
|
-
// Generate token information HTML
|
|
30
|
-
const tokenHTML = generateTokenSection(tokenInfo);
|
|
31
|
-
// Generate blockchain verification HTML
|
|
32
|
-
const verificationHTML = generateVerificationSection(blockchainVerification);
|
|
33
|
-
// Generate wallet information HTML
|
|
34
|
-
const walletHTML = walletInfo ? generateWalletSection(walletInfo) : '';
|
|
35
|
-
// Generate files table HTML
|
|
36
|
-
const filesTableHTML = zipFiles ? generateFilesTable(zipFiles) : '';
|
|
37
|
-
// Get the complete HTML template
|
|
38
|
-
const htmlTemplate = getCertificateTemplate();
|
|
39
|
-
// Create the complete attestation HTML combining all sections
|
|
40
|
-
const attestHTML = tokenHTML + verificationHTML + walletHTML;
|
|
41
|
-
// Replace placeholders in the template
|
|
42
|
-
const html = htmlTemplate
|
|
43
|
-
.replace(/{{ATTEST_STR}}/g, `NFT Token Certificate for ${zipFile}`)
|
|
44
|
-
.replace(/{{UPDATE_WARNING}}/g, blockchainVerification.verificationStatus === 'FAILED' ?
|
|
45
|
-
'<div class="warning">⚠️ Warning: Blockchain verification failed. This archive may have been tampered with.</div>' : '')
|
|
46
|
-
.replace(/{{ZIP_FILE}}/g, zipFile)
|
|
47
|
-
.replace(/{{HASH_DIGEST}}/g, blockchainVerification.calculatedMerkleRoot)
|
|
48
|
-
.replace(/{{ATTESTATION_HTML}}/g, attestHTML)
|
|
49
|
-
.replace(/{{FILES_TABLE_HTML}}/g, filesTableHTML)
|
|
50
|
-
.replace(/{{GENERATION_TIME}}/g, new Date().toUTCString());
|
|
51
|
-
return html;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Saves a certificate to disk
|
|
55
|
-
*/
|
|
56
|
-
function saveCertificate(fileName, certificateHTML, outputDir) {
|
|
57
|
-
try {
|
|
58
|
-
const dir = outputDir || path_1.default.dirname(fileName);
|
|
59
|
-
const baseName = path_1.default.basename(fileName, '.zip');
|
|
60
|
-
const certFileName = path_1.default.join(dir, `${baseName}.token-certificate.html`);
|
|
61
|
-
// Ensure directory exists
|
|
62
|
-
if (!fs_1.default.existsSync(dir)) {
|
|
63
|
-
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
64
|
-
}
|
|
65
|
-
// Write the certificate HTML to a file
|
|
66
|
-
fs_1.default.writeFileSync(certFileName, certificateHTML, { encoding: 'utf8' });
|
|
67
|
-
return certFileName;
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
throw new Error(`Failed to save certificate: ${error}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Generate token information section
|
|
75
|
-
*/
|
|
76
|
-
function generateTokenSection(tokenInfo) {
|
|
77
|
-
return `
|
|
78
|
-
<div class="token-section">
|
|
79
|
-
<h3>🎫 NFT Token Information</h3>
|
|
80
|
-
<div class="key-value-pair">
|
|
81
|
-
<div class="key">Token ID:</div>
|
|
82
|
-
<div class="value">${tokenInfo.tokenId}</div>
|
|
83
|
-
</div>
|
|
84
|
-
<div class="key-value-pair">
|
|
85
|
-
<div class="key">Contract Address:</div>
|
|
86
|
-
<div class="value"><code>${tokenInfo.contractAddress}</code></div>
|
|
87
|
-
</div>
|
|
88
|
-
<div class="key-value-pair">
|
|
89
|
-
<div class="key">Network:</div>
|
|
90
|
-
<div class="value">${tokenInfo.network}</div>
|
|
91
|
-
</div>
|
|
92
|
-
<div class="key-value-pair">
|
|
93
|
-
<div class="key">Minting Transaction:</div>
|
|
94
|
-
<div class="value"><code>${tokenInfo.transactionHash}</code></div>
|
|
95
|
-
</div>
|
|
96
|
-
${tokenInfo.timestamp ? `
|
|
97
|
-
<div class="key-value-pair">
|
|
98
|
-
<div class="key">Token Created:</div>
|
|
99
|
-
<div class="value">${new Date(tokenInfo.timestamp * 1000).toUTCString()}</div>
|
|
100
|
-
</div>
|
|
101
|
-
` : ''}
|
|
102
|
-
${tokenInfo.note ? `
|
|
103
|
-
<div class="key-value-pair">
|
|
104
|
-
<div class="key">Note:</div>
|
|
105
|
-
<div class="value">${tokenInfo.note}</div>
|
|
106
|
-
</div>
|
|
107
|
-
` : ''}
|
|
108
|
-
</div>
|
|
109
|
-
`;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Generate blockchain verification section
|
|
113
|
-
*/
|
|
114
|
-
function generateVerificationSection(verification) {
|
|
115
|
-
const statusIcon = verification.verificationStatus === 'PASSED' ? '✅' :
|
|
116
|
-
verification.verificationStatus === 'FAILED' ? '❌' : '⚠️';
|
|
117
|
-
return `
|
|
118
|
-
<div class="verification-section ${verification.verificationStatus.toLowerCase()}">
|
|
119
|
-
<h3>🔐 Blockchain Verification</h3>
|
|
120
|
-
<div class="verification-status ${verification.verificationStatus.toLowerCase()}">
|
|
121
|
-
${statusIcon} <strong>Status: ${verification.verificationStatus}</strong>
|
|
122
|
-
</div>
|
|
123
|
-
<div class="key-value-pair">
|
|
124
|
-
<div class="key">Blockchain Merkle Root:</div>
|
|
125
|
-
<div class="value"><code>${verification.blockchainMerkleRoot}</code></div>
|
|
126
|
-
</div>
|
|
127
|
-
<div class="key-value-pair">
|
|
128
|
-
<div class="key">Calculated Merkle Root:</div>
|
|
129
|
-
<div class="value"><code>${verification.calculatedMerkleRoot}</code></div>
|
|
130
|
-
</div>
|
|
131
|
-
<div class="key-value-pair">
|
|
132
|
-
<div class="key">Integrity Check:</div>
|
|
133
|
-
<div class="value">${verification.merkleRootMatches ?
|
|
134
|
-
'✅ Archive contents match blockchain record' :
|
|
135
|
-
'❌ Archive contents do not match blockchain record'}</div>
|
|
136
|
-
</div>
|
|
137
|
-
${verification.verificationTime ? `
|
|
138
|
-
<div class="key-value-pair">
|
|
139
|
-
<div class="key">Verified At:</div>
|
|
140
|
-
<div class="value">${new Date(verification.verificationTime * 1000).toUTCString()}</div>
|
|
141
|
-
</div>
|
|
142
|
-
` : ''}
|
|
143
|
-
${verification.blockNumber ? `
|
|
144
|
-
<div class="key-value-pair">
|
|
145
|
-
<div class="key">Block Number:</div>
|
|
146
|
-
<div class="value">${verification.blockNumber}</div>
|
|
147
|
-
</div>
|
|
148
|
-
` : ''}
|
|
149
|
-
</div>
|
|
150
|
-
`;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Generate wallet information section
|
|
154
|
-
*/
|
|
155
|
-
function generateWalletSection(walletInfo) {
|
|
156
|
-
return `
|
|
157
|
-
<div class="wallet-section">
|
|
158
|
-
<h3>👛 Wallet Information</h3>
|
|
159
|
-
<div class="key-value-pair">
|
|
160
|
-
<div class="key">Wallet Address:</div>
|
|
161
|
-
<div class="value"><code>${walletInfo.address}</code></div>
|
|
162
|
-
</div>
|
|
163
|
-
${walletInfo.ensName ? `
|
|
164
|
-
<div class="key-value-pair">
|
|
165
|
-
<div class="key">ENS Name:</div>
|
|
166
|
-
<div class="value">${walletInfo.ensName}</div>
|
|
167
|
-
</div>
|
|
168
|
-
` : ''}
|
|
169
|
-
<div class="key-value-pair">
|
|
170
|
-
<div class="key">Network:</div>
|
|
171
|
-
<div class="value">${walletInfo.network}</div>
|
|
172
|
-
</div>
|
|
173
|
-
${walletInfo.balance ? `
|
|
174
|
-
<div class="key-value-pair">
|
|
175
|
-
<div class="key">Balance:</div>
|
|
176
|
-
<div class="value">${walletInfo.balance}</div>
|
|
177
|
-
</div>
|
|
178
|
-
` : ''}
|
|
179
|
-
</div>
|
|
180
|
-
`;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Generate files table HTML
|
|
184
|
-
*/
|
|
185
|
-
function generateFilesTable(files) {
|
|
186
|
-
let filesTableHTML = '';
|
|
187
|
-
files.forEach((file) => {
|
|
188
|
-
filesTableHTML += `
|
|
189
|
-
<tr>
|
|
190
|
-
<td class="table-data1">${file.filename}</td>
|
|
191
|
-
<td class="table-data">${file.size.toString()}</td>
|
|
192
|
-
<td class="table-data">${file.date}</td>
|
|
193
|
-
<td class="table-data"><code>${file.hash}</code></td>
|
|
194
|
-
</tr>
|
|
195
|
-
`;
|
|
196
|
-
});
|
|
197
|
-
return filesTableHTML;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Get the HTML template for certificates
|
|
201
|
-
*/
|
|
202
|
-
function getCertificateTemplate() {
|
|
203
|
-
return `<!DOCTYPE html>
|
|
204
|
-
<html lang="en">
|
|
205
|
-
<head>
|
|
206
|
-
<meta charset="UTF-8">
|
|
207
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
208
|
-
<title>NFT Token Certificate - {{ZIP_FILE}}</title>
|
|
209
|
-
<style>
|
|
210
|
-
body {
|
|
211
|
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
212
|
-
line-height: 1.6;
|
|
213
|
-
margin: 0;
|
|
214
|
-
padding: 20px;
|
|
215
|
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
216
|
-
min-height: 100vh;
|
|
217
|
-
}
|
|
218
|
-
.certificate {
|
|
219
|
-
max-width: 900px;
|
|
220
|
-
margin: 0 auto;
|
|
221
|
-
background: white;
|
|
222
|
-
border-radius: 15px;
|
|
223
|
-
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
|
|
224
|
-
overflow: hidden;
|
|
225
|
-
}
|
|
226
|
-
.header {
|
|
227
|
-
background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
|
|
228
|
-
color: white;
|
|
229
|
-
padding: 30px;
|
|
230
|
-
text-align: center;
|
|
231
|
-
}
|
|
232
|
-
.header h1 {
|
|
233
|
-
margin: 0;
|
|
234
|
-
font-size: 2.5em;
|
|
235
|
-
font-weight: 300;
|
|
236
|
-
}
|
|
237
|
-
.header h2 {
|
|
238
|
-
margin: 10px 0 0 0;
|
|
239
|
-
font-size: 1.2em;
|
|
240
|
-
opacity: 0.9;
|
|
241
|
-
}
|
|
242
|
-
.content {
|
|
243
|
-
padding: 40px;
|
|
244
|
-
}
|
|
245
|
-
.token-section, .verification-section, .wallet-section {
|
|
246
|
-
margin-bottom: 30px;
|
|
247
|
-
padding: 20px;
|
|
248
|
-
border-radius: 10px;
|
|
249
|
-
border-left: 4px solid #3498db;
|
|
250
|
-
background: #f8f9fa;
|
|
251
|
-
}
|
|
252
|
-
.verification-section.passed {
|
|
253
|
-
border-left-color: #27ae60;
|
|
254
|
-
}
|
|
255
|
-
.verification-section.failed {
|
|
256
|
-
border-left-color: #e74c3c;
|
|
257
|
-
}
|
|
258
|
-
.verification-section.unavailable {
|
|
259
|
-
border-left-color: #f39c12;
|
|
260
|
-
}
|
|
261
|
-
.verification-status {
|
|
262
|
-
font-size: 1.2em;
|
|
263
|
-
margin-bottom: 15px;
|
|
264
|
-
padding: 10px;
|
|
265
|
-
border-radius: 5px;
|
|
266
|
-
}
|
|
267
|
-
.verification-status.passed {
|
|
268
|
-
background: #d4edda;
|
|
269
|
-
color: #155724;
|
|
270
|
-
}
|
|
271
|
-
.verification-status.failed {
|
|
272
|
-
background: #f8d7da;
|
|
273
|
-
color: #721c24;
|
|
274
|
-
}
|
|
275
|
-
.verification-status.unavailable {
|
|
276
|
-
background: #fff3cd;
|
|
277
|
-
color: #856404;
|
|
278
|
-
}
|
|
279
|
-
.key-value-pair {
|
|
280
|
-
display: flex;
|
|
281
|
-
margin-bottom: 10px;
|
|
282
|
-
align-items: flex-start;
|
|
283
|
-
}
|
|
284
|
-
.key {
|
|
285
|
-
font-weight: bold;
|
|
286
|
-
min-width: 200px;
|
|
287
|
-
color: #2c3e50;
|
|
288
|
-
}
|
|
289
|
-
.value {
|
|
290
|
-
flex: 1;
|
|
291
|
-
word-break: break-all;
|
|
292
|
-
}
|
|
293
|
-
.value code {
|
|
294
|
-
background: #e9ecef;
|
|
295
|
-
padding: 2px 6px;
|
|
296
|
-
border-radius: 3px;
|
|
297
|
-
font-family: 'Monaco', 'Menlo', monospace;
|
|
298
|
-
font-size: 0.9em;
|
|
299
|
-
}
|
|
300
|
-
.files-section {
|
|
301
|
-
margin-top: 30px;
|
|
302
|
-
}
|
|
303
|
-
.files-table {
|
|
304
|
-
width: 100%;
|
|
305
|
-
border-collapse: collapse;
|
|
306
|
-
margin-top: 15px;
|
|
307
|
-
}
|
|
308
|
-
.files-table th,
|
|
309
|
-
.files-table td {
|
|
310
|
-
padding: 12px;
|
|
311
|
-
text-align: left;
|
|
312
|
-
border-bottom: 1px solid #dee2e6;
|
|
313
|
-
}
|
|
314
|
-
.files-table th {
|
|
315
|
-
background: #f8f9fa;
|
|
316
|
-
font-weight: bold;
|
|
317
|
-
color: #2c3e50;
|
|
318
|
-
}
|
|
319
|
-
.table-data1 {
|
|
320
|
-
font-weight: bold;
|
|
321
|
-
}
|
|
322
|
-
.warning {
|
|
323
|
-
background: #fff3cd;
|
|
324
|
-
color: #856404;
|
|
325
|
-
padding: 15px;
|
|
326
|
-
border-radius: 5px;
|
|
327
|
-
margin-bottom: 20px;
|
|
328
|
-
border-left: 4px solid #ffc107;
|
|
329
|
-
}
|
|
330
|
-
.footer {
|
|
331
|
-
text-align: center;
|
|
332
|
-
padding: 20px;
|
|
333
|
-
background: #f8f9fa;
|
|
334
|
-
color: #6c757d;
|
|
335
|
-
font-size: 0.9em;
|
|
336
|
-
}
|
|
337
|
-
h3 {
|
|
338
|
-
margin-top: 0;
|
|
339
|
-
color: #2c3e50;
|
|
340
|
-
font-size: 1.3em;
|
|
341
|
-
}
|
|
342
|
-
</style>
|
|
343
|
-
</head>
|
|
344
|
-
<body>
|
|
345
|
-
<div class="certificate">
|
|
346
|
-
<div class="header">
|
|
347
|
-
<h1>🎫 NFT Token Certificate</h1>
|
|
348
|
-
<h2>Blockchain-Verified Digital Archive</h2>
|
|
349
|
-
</div>
|
|
350
|
-
|
|
351
|
-
<div class="content">
|
|
352
|
-
{{UPDATE_WARNING}}
|
|
353
|
-
|
|
354
|
-
<div class="key-value-pair" style="margin-bottom: 30px; font-size: 1.1em;">
|
|
355
|
-
<div class="key">Archive File:</div>
|
|
356
|
-
<div class="value"><strong>{{ZIP_FILE}}</strong></div>
|
|
357
|
-
</div>
|
|
358
|
-
|
|
359
|
-
{{ATTESTATION_HTML}}
|
|
360
|
-
|
|
361
|
-
<div class="files-section">
|
|
362
|
-
<h3>📁 Archive Contents</h3>
|
|
363
|
-
<table class="files-table">
|
|
364
|
-
<thead>
|
|
365
|
-
<tr>
|
|
366
|
-
<th>File Name</th>
|
|
367
|
-
<th>Size (bytes)</th>
|
|
368
|
-
<th>Date Modified</th>
|
|
369
|
-
<th>SHA256 Hash</th>
|
|
370
|
-
</tr>
|
|
371
|
-
</thead>
|
|
372
|
-
<tbody>
|
|
373
|
-
{{FILES_TABLE_HTML}}
|
|
374
|
-
</tbody>
|
|
375
|
-
</table>
|
|
376
|
-
</div>
|
|
377
|
-
</div>
|
|
378
|
-
|
|
379
|
-
<div class="footer">
|
|
380
|
-
<p>This certificate verifies the integrity and authenticity of the tokenized archive through blockchain technology.</p>
|
|
381
|
-
<p>Generated on: {{GENERATION_TIME}}</p>
|
|
382
|
-
</div>
|
|
383
|
-
</div>
|
|
384
|
-
</body>
|
|
385
|
-
</html>`;
|
|
386
|
-
}
|