neozipkit 0.1.1
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/README.md +400 -0
- package/contracts/Lock.sol +34 -0
- package/contracts/bytecode.txt +1 -0
- package/contracts/compile-contract.js +168 -0
- package/contracts/deploy/deploy-both-contracts.js +286 -0
- package/contracts/deploy/deploy-enhanced-contract.js +197 -0
- package/contracts/deploy/deploy-private-contract.js +190 -0
- package/contracts/deploy/deploy-public-clean.js +1063 -0
- package/contracts/deploy/deploy-public-contract.js +1107 -0
- package/contracts/deployment.config.example.js +25 -0
- package/contracts/remix-compile.js +222 -0
- package/contracts/setup-deployment.js +51 -0
- package/contracts/src/NZIP-NFT-Private.sol +350 -0
- package/contracts/src/NZIP-NFT.sol +265 -0
- package/contracts/src/ZipFileNFT-DEPRECATED-6field.sol +260 -0
- package/contracts/src/ZipFileNFT-DEPRECATED-Enhanced.sol +289 -0
- package/dist/browser/CertificateGeneratorBrowser.d.ts +75 -0
- package/dist/browser/CertificateGeneratorBrowser.js +433 -0
- package/dist/browser/TokenVerifierBrowser.d.ts +76 -0
- package/dist/browser/TokenVerifierBrowser.js +299 -0
- package/dist/browser/ZipKitBrowser.d.ts +18 -0
- package/dist/browser/ZipKitBrowser.js +250 -0
- package/dist/browser/ZipKitStampBrowser.d.ts +2 -0
- package/dist/browser/ZipKitStampBrowser.js +12 -0
- package/dist/browser-index.d.ts +21 -0
- package/dist/browser-index.js +58 -0
- package/dist/browser.d.ts +21 -0
- package/dist/browser.js +58 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +76 -0
- package/dist/server/blockchain/CertificateToken.d.ts +48 -0
- package/dist/server/blockchain/CertificateToken.js +386 -0
- package/dist/server/blockchain/NFTMinter.d.ts +41 -0
- package/dist/server/blockchain/NFTMinter.js +323 -0
- package/dist/server/blockchain/TokenQuerier.d.ts +31 -0
- package/dist/server/blockchain/TokenQuerier.js +259 -0
- package/dist/server/blockchain/TokenVerifier.d.ts +20 -0
- package/dist/server/blockchain/TokenVerifier.js +395 -0
- package/dist/server/blockchain/WalletAnalyzer.d.ts +81 -0
- package/dist/server/blockchain/WalletAnalyzer.js +356 -0
- package/dist/server/blockchain/WalletFormatter.d.ts +39 -0
- package/dist/server/blockchain/WalletFormatter.js +196 -0
- package/dist/server/blockchain/WalletManager.d.ts +46 -0
- package/dist/server/blockchain/WalletManager.js +294 -0
- package/dist/server/blockchain/ZipMetadata.d.ts +27 -0
- package/dist/server/blockchain/ZipMetadata.js +131 -0
- package/dist/server/blockchain/ZipTokenProcessor.d.ts +44 -0
- package/dist/server/blockchain/ZipTokenProcessor.js +204 -0
- package/dist/server/blockchain/constants.d.ts +102 -0
- package/dist/server/blockchain/constants.js +968 -0
- package/dist/server/blockchain/index.d.ts +9 -0
- package/dist/server/blockchain/index.js +44 -0
- package/dist/server/blockchain/test-certificate.d.ts +8 -0
- package/dist/server/blockchain/test-certificate.js +100 -0
- package/dist/server/blockchain/types.d.ts +69 -0
- package/dist/server/blockchain/types.js +51 -0
- package/dist/server/platform/server/ZipKitServer.d.ts +105 -0
- package/dist/server/platform/server/ZipKitServer.js +437 -0
- package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +91 -0
- package/dist/server/platform/servercomponents/ZipKitOTS.js +271 -0
- package/dist/shared/ZipEntry.d.ts +131 -0
- package/dist/shared/ZipEntry.js +686 -0
- package/dist/shared/ZipKit.d.ts +249 -0
- package/dist/shared/ZipKit.js +789 -0
- package/dist/shared/components/CertificateOTS.d.ts +15 -0
- package/dist/shared/components/CertificateOTS.js +116 -0
- package/dist/shared/components/FileSys.d.ts +2 -0
- package/dist/shared/components/FileSys.js +113 -0
- package/dist/shared/components/HashAccumulator.d.ts +55 -0
- package/dist/shared/components/HashAccumulator.js +100 -0
- package/dist/shared/components/Support.d.ts +63 -0
- package/dist/shared/components/Support.js +70 -0
- package/dist/shared/components/Util.d.ts +21 -0
- package/dist/shared/components/Util.js +115 -0
- package/dist/shared/components/ZipCrypto.d.ts +3 -0
- package/dist/shared/components/ZipCrypto.js +78 -0
- package/dist/shared/components/merkleTree.d.ts +66 -0
- package/dist/shared/components/merkleTree.js +136 -0
- package/dist/shared/constants/Errors.d.ts +53 -0
- package/dist/shared/constants/Errors.js +69 -0
- package/dist/shared/constants/Headers.d.ts +167 -0
- package/dist/shared/constants/Headers.js +191 -0
- package/dist/shared/types/index.d.ts +21 -0
- package/dist/shared/types/index.js +3 -0
- package/dist/shared/types.d.ts +33 -0
- package/dist/shared/types.js +8 -0
- package/dist/shared/version.d.ts +4 -0
- package/dist/shared/version.js +7 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/index.js +3 -0
- package/examples/unzip-token.ts +488 -0
- package/examples/zip-token.ts +604 -0
- package/package.json +117 -0
- package/src/browser/CertificateGeneratorBrowser.ts +498 -0
- package/src/browser/TokenVerifierBrowser.ts +344 -0
- package/src/browser/ZipKitBrowser.ts +242 -0
- package/src/browser/ZipKitStampBrowser.ts +9 -0
- package/src/browser-index.ts +36 -0
- package/src/index.ts +48 -0
- package/src/server/blockchain/CertificateToken.ts +444 -0
- package/src/server/blockchain/NFTMinter.ts +357 -0
- package/src/server/blockchain/TokenQuerier.ts +287 -0
- package/src/server/blockchain/TokenVerifier.ts +453 -0
- package/src/server/blockchain/WalletAnalyzer.ts +397 -0
- package/src/server/blockchain/WalletFormatter.ts +206 -0
- package/src/server/blockchain/WalletManager.ts +294 -0
- package/src/server/blockchain/ZipMetadata.ts +117 -0
- package/src/server/blockchain/ZipTokenProcessor.ts +234 -0
- package/src/server/blockchain/constants.ts +969 -0
- package/src/server/blockchain/index.ts +42 -0
- package/src/server/blockchain/test-certificate.ts +137 -0
- package/src/server/blockchain/types.ts +134 -0
- package/src/server/platform/server/ZipKitServer.ts +459 -0
- package/src/server/platform/servercomponents/ZipKitOTS.ts +313 -0
- package/src/server/platform/servercomponents/opentimestamps.d.ts +23 -0
- package/src/shared/ZipEntry.ts +767 -0
- package/src/shared/ZipKit.ts +899 -0
- package/src/shared/components/CertificateOTS.ts +132 -0
- package/src/shared/components/FileSys.ts +87 -0
- package/src/shared/components/HashAccumulator.ts +113 -0
- package/src/shared/components/Support.ts +77 -0
- package/src/shared/components/Util.ts +113 -0
- package/src/shared/components/ZipCrypto.ts +91 -0
- package/src/shared/components/merkleTree.ts +162 -0
- package/src/shared/constants/Errors.ts +82 -0
- package/src/shared/constants/Headers.ts +203 -0
- package/src/shared/types/index.ts +25 -0
- package/src/shared/types/modules.d.ts +22 -0
- package/src/shared/types/opentimestamps.d.ts +23 -0
- package/src/shared/types.d.ts +8 -0
- package/src/shared/types.ts +43 -0
- package/src/shared/version.ts +4 -0
- package/src/types/index.ts +25 -0
- package/src/types/modules.d.ts +22 -0
- package/src/types/opentimestamps.d.ts +23 -0
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ======================================
|
|
3
|
+
// CertificateGeneratorBrowser.ts
|
|
4
|
+
// Browser-compatible certificate generator for tokenized ZIP files
|
|
5
|
+
// Copyright (c) 2025 NeoWare, Inc. All rights reserved.
|
|
6
|
+
// ======================================
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CertificateGeneratorBrowser = void 0;
|
|
9
|
+
exports.createCertificateGenerator = createCertificateGenerator;
|
|
10
|
+
exports.generateTokenCertificate = generateTokenCertificate;
|
|
11
|
+
const Headers_1 = require("../shared/constants/Headers");
|
|
12
|
+
/**
|
|
13
|
+
* Browser-compatible certificate generator class
|
|
14
|
+
*/
|
|
15
|
+
class CertificateGeneratorBrowser {
|
|
16
|
+
/**
|
|
17
|
+
* Generates a certificate HTML document for tokenized ZIP files
|
|
18
|
+
*/
|
|
19
|
+
createTokenCertificate(tokenInfo, zipFile, blockchainVerification, walletInfo, zipFiles, options) {
|
|
20
|
+
// Generate token information HTML
|
|
21
|
+
const tokenHTML = this.generateTokenSection(tokenInfo);
|
|
22
|
+
// Generate blockchain verification HTML
|
|
23
|
+
const verificationHTML = this.generateVerificationSection(blockchainVerification);
|
|
24
|
+
// Generate wallet information HTML
|
|
25
|
+
const walletHTML = walletInfo ? this.generateWalletSection(walletInfo) : '';
|
|
26
|
+
// Generate files table HTML
|
|
27
|
+
const filesTableHTML = zipFiles ? this.generateFilesTable(zipFiles) : '';
|
|
28
|
+
// Get the complete HTML template
|
|
29
|
+
const htmlTemplate = this.getCertificateTemplate();
|
|
30
|
+
// Create the complete attestation HTML combining all sections
|
|
31
|
+
const attestHTML = tokenHTML + verificationHTML + walletHTML;
|
|
32
|
+
// Replace placeholders in the template
|
|
33
|
+
const html = htmlTemplate
|
|
34
|
+
.replace(/{{ATTEST_STR}}/g, `NFT Token Certificate for ${zipFile}`)
|
|
35
|
+
.replace(/{{UPDATE_WARNING}}/g, blockchainVerification.verificationStatus === 'FAILED' ?
|
|
36
|
+
'<div class="warning">⚠️ Warning: Blockchain verification failed. This archive may have been tampered with.</div>' : '')
|
|
37
|
+
.replace(/{{ZIP_FILE}}/g, zipFile)
|
|
38
|
+
.replace(/{{HASH_DIGEST}}/g, blockchainVerification.calculatedMerkleRoot)
|
|
39
|
+
.replace(/{{ATTESTATION_HTML}}/g, attestHTML)
|
|
40
|
+
.replace(/{{FILES_TABLE_HTML}}/g, filesTableHTML)
|
|
41
|
+
.replace(/{{GENERATION_TIME}}/g, new Date().toUTCString());
|
|
42
|
+
return html;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Saves a certificate as a downloadable file (browser-compatible)
|
|
46
|
+
*/
|
|
47
|
+
saveCertificate(fileName, certificateHTML) {
|
|
48
|
+
const baseName = fileName.replace(/\.zip$/i, '');
|
|
49
|
+
const certFileName = `${baseName}.token-certificate.html`;
|
|
50
|
+
// Create a blob with the HTML content
|
|
51
|
+
const blob = new Blob([certificateHTML], { type: 'text/html' });
|
|
52
|
+
// Create a download link
|
|
53
|
+
const url = URL.createObjectURL(blob);
|
|
54
|
+
const link = document.createElement('a');
|
|
55
|
+
link.href = url;
|
|
56
|
+
link.download = certFileName;
|
|
57
|
+
// Trigger download
|
|
58
|
+
document.body.appendChild(link);
|
|
59
|
+
link.click();
|
|
60
|
+
document.body.removeChild(link);
|
|
61
|
+
// Clean up the URL object
|
|
62
|
+
URL.revokeObjectURL(url);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generate token information section
|
|
66
|
+
*/
|
|
67
|
+
generateTokenSection(tokenInfo) {
|
|
68
|
+
return `
|
|
69
|
+
<div class="token-section">
|
|
70
|
+
<h3>🎫 NFT Token Information</h3>
|
|
71
|
+
<div class="key-value-pair">
|
|
72
|
+
<div class="key">Token ID:</div>
|
|
73
|
+
<div class="value"><code>${tokenInfo.tokenId}</code></div>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="key-value-pair">
|
|
76
|
+
<div class="key">Network:</div>
|
|
77
|
+
<div class="value">${tokenInfo.network}</div>
|
|
78
|
+
</div>
|
|
79
|
+
<div class="key-value-pair">
|
|
80
|
+
<div class="key">Contract Address:</div>
|
|
81
|
+
<div class="value"><code>${tokenInfo.contractAddress}</code></div>
|
|
82
|
+
</div>
|
|
83
|
+
<div class="key-value-pair">
|
|
84
|
+
<div class="key">Transaction Hash:</div>
|
|
85
|
+
<div class="value"><code>${tokenInfo.transactionHash}</code></div>
|
|
86
|
+
</div>
|
|
87
|
+
${tokenInfo.wallet ? `
|
|
88
|
+
<div class="key-value-pair">
|
|
89
|
+
<div class="key">Wallet:</div>
|
|
90
|
+
<div class="value"><code>${tokenInfo.wallet}</code></div>
|
|
91
|
+
</div>
|
|
92
|
+
` : ''}
|
|
93
|
+
${tokenInfo.timestamp ? `
|
|
94
|
+
<div class="key-value-pair">
|
|
95
|
+
<div class="key">Minted At:</div>
|
|
96
|
+
<div class="value">${new Date(tokenInfo.timestamp * 1000).toUTCString()}</div>
|
|
97
|
+
</div>
|
|
98
|
+
` : ''}
|
|
99
|
+
${tokenInfo.note ? `
|
|
100
|
+
<div class="key-value-pair">
|
|
101
|
+
<div class="key">Note:</div>
|
|
102
|
+
<div class="value">${tokenInfo.note}</div>
|
|
103
|
+
</div>
|
|
104
|
+
` : ''}
|
|
105
|
+
</div>
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Generate blockchain verification section
|
|
110
|
+
*/
|
|
111
|
+
generateVerificationSection(verification) {
|
|
112
|
+
const statusIcon = verification.verificationStatus === 'PASSED' ? '✅' :
|
|
113
|
+
verification.verificationStatus === 'FAILED' ? '❌' : '⚠️';
|
|
114
|
+
return `
|
|
115
|
+
<div class="verification-section ${verification.verificationStatus.toLowerCase()}">
|
|
116
|
+
<h3>🔐 Blockchain Verification</h3>
|
|
117
|
+
<div class="verification-status ${verification.verificationStatus.toLowerCase()}">
|
|
118
|
+
${statusIcon} <strong>Status: ${verification.verificationStatus}</strong>
|
|
119
|
+
</div>
|
|
120
|
+
<div class="key-value-pair">
|
|
121
|
+
<div class="key">Blockchain Merkle Root:</div>
|
|
122
|
+
<div class="value"><code>${verification.blockchainMerkleRoot}</code></div>
|
|
123
|
+
</div>
|
|
124
|
+
<div class="key-value-pair">
|
|
125
|
+
<div class="key">Calculated Merkle Root:</div>
|
|
126
|
+
<div class="value"><code>${verification.calculatedMerkleRoot}</code></div>
|
|
127
|
+
</div>
|
|
128
|
+
<div class="key-value-pair">
|
|
129
|
+
<div class="key">Integrity Check:</div>
|
|
130
|
+
<div class="value">${verification.merkleRootMatches ?
|
|
131
|
+
'✅ Archive contents match blockchain record' :
|
|
132
|
+
'❌ Archive contents do not match blockchain record'}</div>
|
|
133
|
+
</div>
|
|
134
|
+
${verification.verificationTime ? `
|
|
135
|
+
<div class="key-value-pair">
|
|
136
|
+
<div class="key">Verified At:</div>
|
|
137
|
+
<div class="value">${new Date(verification.verificationTime * 1000).toUTCString()}</div>
|
|
138
|
+
</div>
|
|
139
|
+
` : ''}
|
|
140
|
+
${verification.blockNumber ? `
|
|
141
|
+
<div class="key-value-pair">
|
|
142
|
+
<div class="key">Block Number:</div>
|
|
143
|
+
<div class="value">${verification.blockNumber}</div>
|
|
144
|
+
</div>
|
|
145
|
+
` : ''}
|
|
146
|
+
</div>
|
|
147
|
+
`;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Generate wallet information section
|
|
151
|
+
*/
|
|
152
|
+
generateWalletSection(walletInfo) {
|
|
153
|
+
return `
|
|
154
|
+
<div class="wallet-section">
|
|
155
|
+
<h3>👛 Wallet Information</h3>
|
|
156
|
+
<div class="key-value-pair">
|
|
157
|
+
<div class="key">Address:</div>
|
|
158
|
+
<div class="value"><code>${walletInfo.address}</code></div>
|
|
159
|
+
</div>
|
|
160
|
+
<div class="key-value-pair">
|
|
161
|
+
<div class="key">Network:</div>
|
|
162
|
+
<div class="value">${walletInfo.network}</div>
|
|
163
|
+
</div>
|
|
164
|
+
${walletInfo.balance ? `
|
|
165
|
+
<div class="key-value-pair">
|
|
166
|
+
<div class="key">Balance:</div>
|
|
167
|
+
<div class="value">${walletInfo.balance}</div>
|
|
168
|
+
</div>
|
|
169
|
+
` : ''}
|
|
170
|
+
${walletInfo.ensName ? `
|
|
171
|
+
<div class="key-value-pair">
|
|
172
|
+
<div class="key">ENS Name:</div>
|
|
173
|
+
<div class="value">${walletInfo.ensName}</div>
|
|
174
|
+
</div>
|
|
175
|
+
` : ''}
|
|
176
|
+
</div>
|
|
177
|
+
`;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Generate files table
|
|
181
|
+
*/
|
|
182
|
+
generateFilesTable(zipFiles) {
|
|
183
|
+
if (zipFiles.length === 0) {
|
|
184
|
+
return '<tr><td colspan="4">No files found</td></tr>';
|
|
185
|
+
}
|
|
186
|
+
return zipFiles.map(file => `
|
|
187
|
+
<tr>
|
|
188
|
+
<td class="table-data1">${file.filename}</td>
|
|
189
|
+
<td>${file.size.toLocaleString()}</td>
|
|
190
|
+
<td>${file.date}</td>
|
|
191
|
+
<td><code>${file.hash}</code></td>
|
|
192
|
+
</tr>
|
|
193
|
+
`).join('');
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get the HTML template for certificates
|
|
197
|
+
*/
|
|
198
|
+
getCertificateTemplate() {
|
|
199
|
+
return `<!DOCTYPE html>
|
|
200
|
+
<html lang="en">
|
|
201
|
+
<head>
|
|
202
|
+
<meta charset="UTF-8">
|
|
203
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
204
|
+
<title>NFT Token Certificate - {{ZIP_FILE}}</title>
|
|
205
|
+
<style>
|
|
206
|
+
body {
|
|
207
|
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
208
|
+
line-height: 1.6;
|
|
209
|
+
margin: 0;
|
|
210
|
+
padding: 20px;
|
|
211
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
212
|
+
min-height: 100vh;
|
|
213
|
+
}
|
|
214
|
+
.certificate {
|
|
215
|
+
max-width: 900px;
|
|
216
|
+
margin: 0 auto;
|
|
217
|
+
background: white;
|
|
218
|
+
border-radius: 15px;
|
|
219
|
+
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
|
|
220
|
+
overflow: hidden;
|
|
221
|
+
}
|
|
222
|
+
.header {
|
|
223
|
+
background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
|
|
224
|
+
color: white;
|
|
225
|
+
padding: 30px;
|
|
226
|
+
text-align: center;
|
|
227
|
+
}
|
|
228
|
+
.header h1 {
|
|
229
|
+
margin: 0;
|
|
230
|
+
font-size: 2.5em;
|
|
231
|
+
font-weight: 300;
|
|
232
|
+
}
|
|
233
|
+
.header h2 {
|
|
234
|
+
margin: 10px 0 0 0;
|
|
235
|
+
font-size: 1.2em;
|
|
236
|
+
opacity: 0.9;
|
|
237
|
+
}
|
|
238
|
+
.content {
|
|
239
|
+
padding: 40px;
|
|
240
|
+
}
|
|
241
|
+
.token-section, .verification-section, .wallet-section {
|
|
242
|
+
margin-bottom: 30px;
|
|
243
|
+
padding: 20px;
|
|
244
|
+
border-radius: 10px;
|
|
245
|
+
border-left: 4px solid #3498db;
|
|
246
|
+
background: #f8f9fa;
|
|
247
|
+
}
|
|
248
|
+
.verification-section.passed {
|
|
249
|
+
border-left-color: #27ae60;
|
|
250
|
+
}
|
|
251
|
+
.verification-section.failed {
|
|
252
|
+
border-left-color: #e74c3c;
|
|
253
|
+
}
|
|
254
|
+
.verification-section.unavailable {
|
|
255
|
+
border-left-color: #f39c12;
|
|
256
|
+
}
|
|
257
|
+
.verification-status {
|
|
258
|
+
font-size: 1.2em;
|
|
259
|
+
margin-bottom: 15px;
|
|
260
|
+
padding: 10px;
|
|
261
|
+
border-radius: 5px;
|
|
262
|
+
}
|
|
263
|
+
.verification-status.passed {
|
|
264
|
+
background: #d4edda;
|
|
265
|
+
color: #155724;
|
|
266
|
+
}
|
|
267
|
+
.verification-status.failed {
|
|
268
|
+
background: #f8d7da;
|
|
269
|
+
color: #721c24;
|
|
270
|
+
}
|
|
271
|
+
.verification-status.unavailable {
|
|
272
|
+
background: #fff3cd;
|
|
273
|
+
color: #856404;
|
|
274
|
+
}
|
|
275
|
+
.key-value-pair {
|
|
276
|
+
display: flex;
|
|
277
|
+
margin-bottom: 10px;
|
|
278
|
+
align-items: flex-start;
|
|
279
|
+
}
|
|
280
|
+
.key {
|
|
281
|
+
font-weight: bold;
|
|
282
|
+
min-width: 200px;
|
|
283
|
+
color: #2c3e50;
|
|
284
|
+
}
|
|
285
|
+
.value {
|
|
286
|
+
flex: 1;
|
|
287
|
+
word-break: break-all;
|
|
288
|
+
}
|
|
289
|
+
.value code {
|
|
290
|
+
background: #e9ecef;
|
|
291
|
+
padding: 2px 6px;
|
|
292
|
+
border-radius: 3px;
|
|
293
|
+
font-family: 'Monaco', 'Menlo', monospace;
|
|
294
|
+
font-size: 0.9em;
|
|
295
|
+
}
|
|
296
|
+
.files-section {
|
|
297
|
+
margin-top: 30px;
|
|
298
|
+
}
|
|
299
|
+
.files-table {
|
|
300
|
+
width: 100%;
|
|
301
|
+
border-collapse: collapse;
|
|
302
|
+
margin-top: 15px;
|
|
303
|
+
}
|
|
304
|
+
.files-table th,
|
|
305
|
+
.files-table td {
|
|
306
|
+
padding: 12px;
|
|
307
|
+
text-align: left;
|
|
308
|
+
border-bottom: 1px solid #dee2e6;
|
|
309
|
+
}
|
|
310
|
+
.files-table th {
|
|
311
|
+
background: #f8f9fa;
|
|
312
|
+
font-weight: bold;
|
|
313
|
+
color: #2c3e50;
|
|
314
|
+
}
|
|
315
|
+
.table-data1 {
|
|
316
|
+
font-weight: bold;
|
|
317
|
+
}
|
|
318
|
+
.warning {
|
|
319
|
+
background: #fff3cd;
|
|
320
|
+
color: #856404;
|
|
321
|
+
padding: 15px;
|
|
322
|
+
border-radius: 5px;
|
|
323
|
+
margin-bottom: 20px;
|
|
324
|
+
border-left: 4px solid #ffc107;
|
|
325
|
+
}
|
|
326
|
+
.footer {
|
|
327
|
+
text-align: center;
|
|
328
|
+
padding: 20px;
|
|
329
|
+
background: #f8f9fa;
|
|
330
|
+
color: #6c757d;
|
|
331
|
+
font-size: 0.9em;
|
|
332
|
+
}
|
|
333
|
+
h3 {
|
|
334
|
+
margin-top: 0;
|
|
335
|
+
color: #2c3e50;
|
|
336
|
+
font-size: 1.3em;
|
|
337
|
+
}
|
|
338
|
+
</style>
|
|
339
|
+
</head>
|
|
340
|
+
<body>
|
|
341
|
+
<div class="certificate">
|
|
342
|
+
<div class="header">
|
|
343
|
+
<h1>🎫 NFT Token Certificate</h1>
|
|
344
|
+
<h2>Blockchain-Verified Digital Archive</h2>
|
|
345
|
+
</div>
|
|
346
|
+
|
|
347
|
+
<div class="content">
|
|
348
|
+
{{UPDATE_WARNING}}
|
|
349
|
+
|
|
350
|
+
<div class="key-value-pair" style="margin-bottom: 30px; font-size: 1.1em;">
|
|
351
|
+
<div class="key">Archive File:</div>
|
|
352
|
+
<div class="value"><strong>{{ZIP_FILE}}</strong></div>
|
|
353
|
+
</div>
|
|
354
|
+
|
|
355
|
+
{{ATTESTATION_HTML}}
|
|
356
|
+
|
|
357
|
+
<div class="files-section">
|
|
358
|
+
<h3>📁 Archive Contents</h3>
|
|
359
|
+
<table class="files-table">
|
|
360
|
+
<thead>
|
|
361
|
+
<tr>
|
|
362
|
+
<th>File Name</th>
|
|
363
|
+
<th>Size (bytes)</th>
|
|
364
|
+
<th>Date Modified</th>
|
|
365
|
+
<th>SHA256 Hash</th>
|
|
366
|
+
</tr>
|
|
367
|
+
</thead>
|
|
368
|
+
<tbody>
|
|
369
|
+
{{FILES_TABLE_HTML}}
|
|
370
|
+
</tbody>
|
|
371
|
+
</table>
|
|
372
|
+
</div>
|
|
373
|
+
</div>
|
|
374
|
+
|
|
375
|
+
<div class="footer">
|
|
376
|
+
<p>This certificate verifies the integrity and authenticity of the tokenized archive through blockchain technology.</p>
|
|
377
|
+
<p>Generated on: {{GENERATION_TIME}}</p>
|
|
378
|
+
</div>
|
|
379
|
+
</div>
|
|
380
|
+
</body>
|
|
381
|
+
</html>`;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Prepares file information from ZIP entries for certificate generation
|
|
385
|
+
*/
|
|
386
|
+
prepareZipFileInfo(zipEntries) {
|
|
387
|
+
const zipFiles = [];
|
|
388
|
+
for (const entry of zipEntries) {
|
|
389
|
+
// Skip the token file itself and directories
|
|
390
|
+
if (entry.filename !== Headers_1.TOKENIZED_METADATA &&
|
|
391
|
+
!entry.isDirectory &&
|
|
392
|
+
entry.sha256) {
|
|
393
|
+
zipFiles.push({
|
|
394
|
+
filename: entry.filename,
|
|
395
|
+
size: entry.uncompressedSize,
|
|
396
|
+
date: this.formatEntryDate(entry),
|
|
397
|
+
hash: entry.sha256
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return zipFiles;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Formats the date from a ZIP entry
|
|
405
|
+
*/
|
|
406
|
+
formatEntryDate(entry) {
|
|
407
|
+
try {
|
|
408
|
+
// Try to use the entry's date formatting if available
|
|
409
|
+
if (typeof entry.toFormattedUTCDateString === 'function') {
|
|
410
|
+
return entry.toFormattedUTCDateString();
|
|
411
|
+
}
|
|
412
|
+
// Fallback to current date
|
|
413
|
+
return new Date().toUTCString();
|
|
414
|
+
}
|
|
415
|
+
catch (error) {
|
|
416
|
+
return new Date().toUTCString();
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
exports.CertificateGeneratorBrowser = CertificateGeneratorBrowser;
|
|
421
|
+
/**
|
|
422
|
+
* Creates a new CertificateGeneratorBrowser instance
|
|
423
|
+
*/
|
|
424
|
+
function createCertificateGenerator() {
|
|
425
|
+
return new CertificateGeneratorBrowser();
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Convenience function to generate a certificate
|
|
429
|
+
*/
|
|
430
|
+
function generateTokenCertificate(tokenInfo, zipFile, blockchainVerification, walletInfo, zipFiles) {
|
|
431
|
+
const generator = new CertificateGeneratorBrowser();
|
|
432
|
+
return generator.createTokenCertificate(tokenInfo, zipFile, blockchainVerification, walletInfo, zipFiles);
|
|
433
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import ZipKitBrowser from './ZipKitBrowser';
|
|
2
|
+
import { ZipEntry } from '../shared/ZipKit';
|
|
3
|
+
export interface NZipTokenInfo {
|
|
4
|
+
version: string;
|
|
5
|
+
tokenId: string;
|
|
6
|
+
contractAddress: string;
|
|
7
|
+
network: string;
|
|
8
|
+
networkChainId: number;
|
|
9
|
+
transactionHash: string;
|
|
10
|
+
merkleRoot: string;
|
|
11
|
+
fileName: string;
|
|
12
|
+
mintedAt: string;
|
|
13
|
+
}
|
|
14
|
+
export interface TokenVerificationOptions {
|
|
15
|
+
skipHash?: boolean;
|
|
16
|
+
skipToken?: boolean;
|
|
17
|
+
generateCertificate?: boolean;
|
|
18
|
+
zipFileName?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface TokenVerificationResult {
|
|
21
|
+
isTokenized: boolean;
|
|
22
|
+
tokenMetadata: NZipTokenInfo | null;
|
|
23
|
+
calculatedMerkleRoot: string | null;
|
|
24
|
+
blockchainMerkleRoot: string | null;
|
|
25
|
+
blockchainTimestamp?: number;
|
|
26
|
+
verificationPassed: boolean;
|
|
27
|
+
certificatePath?: string;
|
|
28
|
+
errorMessage?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface BlockchainVerification {
|
|
31
|
+
merkleRootMatches: boolean;
|
|
32
|
+
blockchainMerkleRoot: string;
|
|
33
|
+
calculatedMerkleRoot: string;
|
|
34
|
+
verificationStatus: 'PASSED' | 'FAILED' | 'UNAVAILABLE';
|
|
35
|
+
verificationTime?: number;
|
|
36
|
+
blockNumber?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Browser-compatible token verification class
|
|
40
|
+
*/
|
|
41
|
+
export declare class TokenVerifierBrowser {
|
|
42
|
+
private zipKit;
|
|
43
|
+
constructor(zipKit: ZipKitBrowser);
|
|
44
|
+
/**
|
|
45
|
+
* Checks if the ZIP file contains NFT token metadata and verifies the merkle root
|
|
46
|
+
*/
|
|
47
|
+
checkForTokenization(zipEntries: ZipEntry[], options?: TokenVerificationOptions): Promise<TokenVerificationResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Validates token metadata structure
|
|
50
|
+
*/
|
|
51
|
+
private validateTokenInfo;
|
|
52
|
+
/**
|
|
53
|
+
* Calculates the merkle root excluding the token metadata file
|
|
54
|
+
*/
|
|
55
|
+
private calculateMerkleRootExcludingToken;
|
|
56
|
+
/**
|
|
57
|
+
* Queries the blockchain to get the actual merkle root and timestamp stored in the smart contract
|
|
58
|
+
*/
|
|
59
|
+
private queryBlockchainData;
|
|
60
|
+
/**
|
|
61
|
+
* Helper to convert Blob to string
|
|
62
|
+
*/
|
|
63
|
+
private blobToString;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a formatted summary of token information
|
|
66
|
+
*/
|
|
67
|
+
createTokenSummary(tokenMetadata: NZipTokenInfo): string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new TokenVerifierBrowser instance
|
|
71
|
+
*/
|
|
72
|
+
export declare function createTokenVerifier(zipKit: ZipKitBrowser): TokenVerifierBrowser;
|
|
73
|
+
/**
|
|
74
|
+
* Convenience function to check for tokenization
|
|
75
|
+
*/
|
|
76
|
+
export declare function checkForTokenization(zipKit: ZipKitBrowser, zipEntries: ZipEntry[], options?: TokenVerificationOptions): Promise<TokenVerificationResult>;
|