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
package/package.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "neozipkit",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "NeoZipKit - Advanced ZIP file creation and verification with blockchain timestamping",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"browser": {
|
|
10
|
+
"types": "./dist/browser.d.ts",
|
|
11
|
+
"default": "./dist/browser.js"
|
|
12
|
+
},
|
|
13
|
+
"node": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./browser": {
|
|
21
|
+
"types": "./dist/browser.d.ts",
|
|
22
|
+
"default": "./dist/browser.js"
|
|
23
|
+
},
|
|
24
|
+
"./browser/*": {
|
|
25
|
+
"types": "./dist/browser/*.d.ts",
|
|
26
|
+
"default": "./dist/browser/*.js"
|
|
27
|
+
},
|
|
28
|
+
"./server": {
|
|
29
|
+
"types": "./dist/server/index.d.ts",
|
|
30
|
+
"default": "./dist/server/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./server/*": {
|
|
33
|
+
"types": "./dist/server/*.d.ts",
|
|
34
|
+
"default": "./dist/server/*.js"
|
|
35
|
+
},
|
|
36
|
+
"./server/blockchain/*": {
|
|
37
|
+
"types": "./dist/server/blockchain/*.d.ts",
|
|
38
|
+
"default": "./dist/server/blockchain/*.js"
|
|
39
|
+
},
|
|
40
|
+
"./server/platform/*": {
|
|
41
|
+
"types": "./dist/server/platform/*.d.ts",
|
|
42
|
+
"default": "./dist/server/platform/*.js"
|
|
43
|
+
},
|
|
44
|
+
"./shared": {
|
|
45
|
+
"types": "./dist/shared/index.d.ts",
|
|
46
|
+
"default": "./dist/shared/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./shared/*": {
|
|
49
|
+
"types": "./dist/shared/*.d.ts",
|
|
50
|
+
"default": "./dist/shared/*.js"
|
|
51
|
+
},
|
|
52
|
+
"./shared/components/*": {
|
|
53
|
+
"types": "./dist/shared/components/*.d.ts",
|
|
54
|
+
"default": "./dist/shared/components/*.js"
|
|
55
|
+
},
|
|
56
|
+
"./shared/constants/*": {
|
|
57
|
+
"types": "./dist/shared/constants/*.d.ts",
|
|
58
|
+
"default": "./dist/shared/constants/*.js"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"files": [
|
|
62
|
+
"dist/",
|
|
63
|
+
"src/",
|
|
64
|
+
"contracts/",
|
|
65
|
+
"examples/",
|
|
66
|
+
"README.md",
|
|
67
|
+
"PACKAGE_STRUCTURE.md",
|
|
68
|
+
"BLOCKCHAIN_INTEGRATION.md",
|
|
69
|
+
"TYPESCRIPT_WORKFLOW.md"
|
|
70
|
+
],
|
|
71
|
+
"scripts": {
|
|
72
|
+
"clean": "rm -rf dist/ && rm -rf *.js *.d.ts components constants platform types blockchain",
|
|
73
|
+
"compile": "tsc",
|
|
74
|
+
"create-browser-entry": "cp dist/browser-index.js dist/browser.js && cp dist/browser-index.d.ts dist/browser.d.ts",
|
|
75
|
+
"build": "npm run clean && npm run compile && npm run create-browser-entry",
|
|
76
|
+
"watch": "tsc --watch",
|
|
77
|
+
"test": "echo \"No tests specified\" && exit 0"
|
|
78
|
+
},
|
|
79
|
+
"keywords": [
|
|
80
|
+
"zip",
|
|
81
|
+
"archive",
|
|
82
|
+
"blockchain",
|
|
83
|
+
"timestamp",
|
|
84
|
+
"verification",
|
|
85
|
+
"nft",
|
|
86
|
+
"crypto",
|
|
87
|
+
"compression"
|
|
88
|
+
],
|
|
89
|
+
"author": "NeoWare, Inc.",
|
|
90
|
+
"repository": {
|
|
91
|
+
"type": "git",
|
|
92
|
+
"url": "git+https://github.com/NeoWareInc/neozipkit.git"
|
|
93
|
+
},
|
|
94
|
+
"bugs": {
|
|
95
|
+
"url": "https://github.com/NeoWareInc/neozipkit/issues"
|
|
96
|
+
},
|
|
97
|
+
"homepage": "https://github.com/NeoWareInc/neozipkit#readme",
|
|
98
|
+
"license": "MIT",
|
|
99
|
+
"devDependencies": {
|
|
100
|
+
"@types/node": "^20.0.0",
|
|
101
|
+
"@types/pako": "^2.0.3",
|
|
102
|
+
"@types/uuid": "^9.0.0",
|
|
103
|
+
"typescript": "^5.0.0"
|
|
104
|
+
},
|
|
105
|
+
"dependencies": {
|
|
106
|
+
"@oneidentity/zstd-js": "^1.0.3",
|
|
107
|
+
"ethers": "^6.0.0",
|
|
108
|
+
"opentimestamps": "^0.4.9",
|
|
109
|
+
"pako": "^2.1.0",
|
|
110
|
+
"uuid": "^9.0.0",
|
|
111
|
+
"web3": "^4.0.0"
|
|
112
|
+
},
|
|
113
|
+
"peerDependencies": {
|
|
114
|
+
"ethers": "^6.0.0",
|
|
115
|
+
"web3": "^4.0.0"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
// ======================================
|
|
2
|
+
// CertificateGeneratorBrowser.ts
|
|
3
|
+
// Browser-compatible certificate generator for tokenized ZIP files
|
|
4
|
+
// Copyright (c) 2025 NeoWare, Inc. All rights reserved.
|
|
5
|
+
// ======================================
|
|
6
|
+
|
|
7
|
+
import { ZipEntry } from '../shared/ZipKit';
|
|
8
|
+
import { NZipTokenInfo, BlockchainVerification } from './TokenVerifierBrowser';
|
|
9
|
+
import { TOKENIZED_METADATA } from '../shared/constants/Headers';
|
|
10
|
+
|
|
11
|
+
// Token-specific types
|
|
12
|
+
export interface TokenInfo {
|
|
13
|
+
tokenId: string;
|
|
14
|
+
contractAddress: string;
|
|
15
|
+
network: string;
|
|
16
|
+
transactionHash: string;
|
|
17
|
+
wallet?: string;
|
|
18
|
+
timestamp?: number;
|
|
19
|
+
note?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface WalletInfo {
|
|
23
|
+
address: string;
|
|
24
|
+
network: string;
|
|
25
|
+
balance?: string;
|
|
26
|
+
ensName?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ZipFileInfo {
|
|
30
|
+
filename: string;
|
|
31
|
+
size: number;
|
|
32
|
+
date: string;
|
|
33
|
+
hash: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Browser-compatible certificate generator class
|
|
38
|
+
*/
|
|
39
|
+
export class CertificateGeneratorBrowser {
|
|
40
|
+
/**
|
|
41
|
+
* Generates a certificate HTML document for tokenized ZIP files
|
|
42
|
+
*/
|
|
43
|
+
createTokenCertificate(
|
|
44
|
+
tokenInfo: TokenInfo,
|
|
45
|
+
zipFile: string,
|
|
46
|
+
blockchainVerification: BlockchainVerification,
|
|
47
|
+
walletInfo?: WalletInfo,
|
|
48
|
+
zipFiles?: ZipFileInfo[],
|
|
49
|
+
options?: { narrow?: boolean; includeQR?: boolean }
|
|
50
|
+
): string {
|
|
51
|
+
|
|
52
|
+
// Generate token information HTML
|
|
53
|
+
const tokenHTML = this.generateTokenSection(tokenInfo);
|
|
54
|
+
|
|
55
|
+
// Generate blockchain verification HTML
|
|
56
|
+
const verificationHTML = this.generateVerificationSection(blockchainVerification);
|
|
57
|
+
|
|
58
|
+
// Generate wallet information HTML
|
|
59
|
+
const walletHTML = walletInfo ? this.generateWalletSection(walletInfo) : '';
|
|
60
|
+
|
|
61
|
+
// Generate files table HTML
|
|
62
|
+
const filesTableHTML = zipFiles ? this.generateFilesTable(zipFiles) : '';
|
|
63
|
+
|
|
64
|
+
// Get the complete HTML template
|
|
65
|
+
const htmlTemplate = this.getCertificateTemplate();
|
|
66
|
+
|
|
67
|
+
// Create the complete attestation HTML combining all sections
|
|
68
|
+
const attestHTML = tokenHTML + verificationHTML + walletHTML;
|
|
69
|
+
|
|
70
|
+
// Replace placeholders in the template
|
|
71
|
+
const html = htmlTemplate
|
|
72
|
+
.replace(/{{ATTEST_STR}}/g, `NFT Token Certificate for ${zipFile}`)
|
|
73
|
+
.replace(/{{UPDATE_WARNING}}/g, blockchainVerification.verificationStatus === 'FAILED' ?
|
|
74
|
+
'<div class="warning">⚠️ Warning: Blockchain verification failed. This archive may have been tampered with.</div>' : '')
|
|
75
|
+
.replace(/{{ZIP_FILE}}/g, zipFile)
|
|
76
|
+
.replace(/{{HASH_DIGEST}}/g, blockchainVerification.calculatedMerkleRoot)
|
|
77
|
+
.replace(/{{ATTESTATION_HTML}}/g, attestHTML)
|
|
78
|
+
.replace(/{{FILES_TABLE_HTML}}/g, filesTableHTML)
|
|
79
|
+
.replace(/{{GENERATION_TIME}}/g, new Date().toUTCString());
|
|
80
|
+
|
|
81
|
+
return html;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Saves a certificate as a downloadable file (browser-compatible)
|
|
86
|
+
*/
|
|
87
|
+
saveCertificate(
|
|
88
|
+
fileName: string,
|
|
89
|
+
certificateHTML: string
|
|
90
|
+
): void {
|
|
91
|
+
const baseName = fileName.replace(/\.zip$/i, '');
|
|
92
|
+
const certFileName = `${baseName}.token-certificate.html`;
|
|
93
|
+
|
|
94
|
+
// Create a blob with the HTML content
|
|
95
|
+
const blob = new Blob([certificateHTML], { type: 'text/html' });
|
|
96
|
+
|
|
97
|
+
// Create a download link
|
|
98
|
+
const url = URL.createObjectURL(blob);
|
|
99
|
+
const link = document.createElement('a');
|
|
100
|
+
link.href = url;
|
|
101
|
+
link.download = certFileName;
|
|
102
|
+
|
|
103
|
+
// Trigger download
|
|
104
|
+
document.body.appendChild(link);
|
|
105
|
+
link.click();
|
|
106
|
+
document.body.removeChild(link);
|
|
107
|
+
|
|
108
|
+
// Clean up the URL object
|
|
109
|
+
URL.revokeObjectURL(url);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Generate token information section
|
|
114
|
+
*/
|
|
115
|
+
private generateTokenSection(tokenInfo: TokenInfo): string {
|
|
116
|
+
return `
|
|
117
|
+
<div class="token-section">
|
|
118
|
+
<h3>🎫 NFT Token Information</h3>
|
|
119
|
+
<div class="key-value-pair">
|
|
120
|
+
<div class="key">Token ID:</div>
|
|
121
|
+
<div class="value"><code>${tokenInfo.tokenId}</code></div>
|
|
122
|
+
</div>
|
|
123
|
+
<div class="key-value-pair">
|
|
124
|
+
<div class="key">Network:</div>
|
|
125
|
+
<div class="value">${tokenInfo.network}</div>
|
|
126
|
+
</div>
|
|
127
|
+
<div class="key-value-pair">
|
|
128
|
+
<div class="key">Contract Address:</div>
|
|
129
|
+
<div class="value"><code>${tokenInfo.contractAddress}</code></div>
|
|
130
|
+
</div>
|
|
131
|
+
<div class="key-value-pair">
|
|
132
|
+
<div class="key">Transaction Hash:</div>
|
|
133
|
+
<div class="value"><code>${tokenInfo.transactionHash}</code></div>
|
|
134
|
+
</div>
|
|
135
|
+
${tokenInfo.wallet ? `
|
|
136
|
+
<div class="key-value-pair">
|
|
137
|
+
<div class="key">Wallet:</div>
|
|
138
|
+
<div class="value"><code>${tokenInfo.wallet}</code></div>
|
|
139
|
+
</div>
|
|
140
|
+
` : ''}
|
|
141
|
+
${tokenInfo.timestamp ? `
|
|
142
|
+
<div class="key-value-pair">
|
|
143
|
+
<div class="key">Minted At:</div>
|
|
144
|
+
<div class="value">${new Date(tokenInfo.timestamp * 1000).toUTCString()}</div>
|
|
145
|
+
</div>
|
|
146
|
+
` : ''}
|
|
147
|
+
${tokenInfo.note ? `
|
|
148
|
+
<div class="key-value-pair">
|
|
149
|
+
<div class="key">Note:</div>
|
|
150
|
+
<div class="value">${tokenInfo.note}</div>
|
|
151
|
+
</div>
|
|
152
|
+
` : ''}
|
|
153
|
+
</div>
|
|
154
|
+
`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Generate blockchain verification section
|
|
159
|
+
*/
|
|
160
|
+
private generateVerificationSection(verification: BlockchainVerification): string {
|
|
161
|
+
const statusIcon = verification.verificationStatus === 'PASSED' ? '✅' :
|
|
162
|
+
verification.verificationStatus === 'FAILED' ? '❌' : '⚠️';
|
|
163
|
+
|
|
164
|
+
return `
|
|
165
|
+
<div class="verification-section ${verification.verificationStatus.toLowerCase()}">
|
|
166
|
+
<h3>🔐 Blockchain Verification</h3>
|
|
167
|
+
<div class="verification-status ${verification.verificationStatus.toLowerCase()}">
|
|
168
|
+
${statusIcon} <strong>Status: ${verification.verificationStatus}</strong>
|
|
169
|
+
</div>
|
|
170
|
+
<div class="key-value-pair">
|
|
171
|
+
<div class="key">Blockchain Merkle Root:</div>
|
|
172
|
+
<div class="value"><code>${verification.blockchainMerkleRoot}</code></div>
|
|
173
|
+
</div>
|
|
174
|
+
<div class="key-value-pair">
|
|
175
|
+
<div class="key">Calculated Merkle Root:</div>
|
|
176
|
+
<div class="value"><code>${verification.calculatedMerkleRoot}</code></div>
|
|
177
|
+
</div>
|
|
178
|
+
<div class="key-value-pair">
|
|
179
|
+
<div class="key">Integrity Check:</div>
|
|
180
|
+
<div class="value">${verification.merkleRootMatches ?
|
|
181
|
+
'✅ Archive contents match blockchain record' :
|
|
182
|
+
'❌ Archive contents do not match blockchain record'}</div>
|
|
183
|
+
</div>
|
|
184
|
+
${verification.verificationTime ? `
|
|
185
|
+
<div class="key-value-pair">
|
|
186
|
+
<div class="key">Verified At:</div>
|
|
187
|
+
<div class="value">${new Date(verification.verificationTime * 1000).toUTCString()}</div>
|
|
188
|
+
</div>
|
|
189
|
+
` : ''}
|
|
190
|
+
${verification.blockNumber ? `
|
|
191
|
+
<div class="key-value-pair">
|
|
192
|
+
<div class="key">Block Number:</div>
|
|
193
|
+
<div class="value">${verification.blockNumber}</div>
|
|
194
|
+
</div>
|
|
195
|
+
` : ''}
|
|
196
|
+
</div>
|
|
197
|
+
`;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Generate wallet information section
|
|
202
|
+
*/
|
|
203
|
+
private generateWalletSection(walletInfo: WalletInfo): string {
|
|
204
|
+
return `
|
|
205
|
+
<div class="wallet-section">
|
|
206
|
+
<h3>👛 Wallet Information</h3>
|
|
207
|
+
<div class="key-value-pair">
|
|
208
|
+
<div class="key">Address:</div>
|
|
209
|
+
<div class="value"><code>${walletInfo.address}</code></div>
|
|
210
|
+
</div>
|
|
211
|
+
<div class="key-value-pair">
|
|
212
|
+
<div class="key">Network:</div>
|
|
213
|
+
<div class="value">${walletInfo.network}</div>
|
|
214
|
+
</div>
|
|
215
|
+
${walletInfo.balance ? `
|
|
216
|
+
<div class="key-value-pair">
|
|
217
|
+
<div class="key">Balance:</div>
|
|
218
|
+
<div class="value">${walletInfo.balance}</div>
|
|
219
|
+
</div>
|
|
220
|
+
` : ''}
|
|
221
|
+
${walletInfo.ensName ? `
|
|
222
|
+
<div class="key-value-pair">
|
|
223
|
+
<div class="key">ENS Name:</div>
|
|
224
|
+
<div class="value">${walletInfo.ensName}</div>
|
|
225
|
+
</div>
|
|
226
|
+
` : ''}
|
|
227
|
+
</div>
|
|
228
|
+
`;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Generate files table
|
|
233
|
+
*/
|
|
234
|
+
private generateFilesTable(zipFiles: ZipFileInfo[]): string {
|
|
235
|
+
if (zipFiles.length === 0) {
|
|
236
|
+
return '<tr><td colspan="4">No files found</td></tr>';
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return zipFiles.map(file => `
|
|
240
|
+
<tr>
|
|
241
|
+
<td class="table-data1">${file.filename}</td>
|
|
242
|
+
<td>${file.size.toLocaleString()}</td>
|
|
243
|
+
<td>${file.date}</td>
|
|
244
|
+
<td><code>${file.hash}</code></td>
|
|
245
|
+
</tr>
|
|
246
|
+
`).join('');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Get the HTML template for certificates
|
|
251
|
+
*/
|
|
252
|
+
private getCertificateTemplate(): string {
|
|
253
|
+
return `<!DOCTYPE html>
|
|
254
|
+
<html lang="en">
|
|
255
|
+
<head>
|
|
256
|
+
<meta charset="UTF-8">
|
|
257
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
258
|
+
<title>NFT Token Certificate - {{ZIP_FILE}}</title>
|
|
259
|
+
<style>
|
|
260
|
+
body {
|
|
261
|
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
262
|
+
line-height: 1.6;
|
|
263
|
+
margin: 0;
|
|
264
|
+
padding: 20px;
|
|
265
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
266
|
+
min-height: 100vh;
|
|
267
|
+
}
|
|
268
|
+
.certificate {
|
|
269
|
+
max-width: 900px;
|
|
270
|
+
margin: 0 auto;
|
|
271
|
+
background: white;
|
|
272
|
+
border-radius: 15px;
|
|
273
|
+
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
|
|
274
|
+
overflow: hidden;
|
|
275
|
+
}
|
|
276
|
+
.header {
|
|
277
|
+
background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
|
|
278
|
+
color: white;
|
|
279
|
+
padding: 30px;
|
|
280
|
+
text-align: center;
|
|
281
|
+
}
|
|
282
|
+
.header h1 {
|
|
283
|
+
margin: 0;
|
|
284
|
+
font-size: 2.5em;
|
|
285
|
+
font-weight: 300;
|
|
286
|
+
}
|
|
287
|
+
.header h2 {
|
|
288
|
+
margin: 10px 0 0 0;
|
|
289
|
+
font-size: 1.2em;
|
|
290
|
+
opacity: 0.9;
|
|
291
|
+
}
|
|
292
|
+
.content {
|
|
293
|
+
padding: 40px;
|
|
294
|
+
}
|
|
295
|
+
.token-section, .verification-section, .wallet-section {
|
|
296
|
+
margin-bottom: 30px;
|
|
297
|
+
padding: 20px;
|
|
298
|
+
border-radius: 10px;
|
|
299
|
+
border-left: 4px solid #3498db;
|
|
300
|
+
background: #f8f9fa;
|
|
301
|
+
}
|
|
302
|
+
.verification-section.passed {
|
|
303
|
+
border-left-color: #27ae60;
|
|
304
|
+
}
|
|
305
|
+
.verification-section.failed {
|
|
306
|
+
border-left-color: #e74c3c;
|
|
307
|
+
}
|
|
308
|
+
.verification-section.unavailable {
|
|
309
|
+
border-left-color: #f39c12;
|
|
310
|
+
}
|
|
311
|
+
.verification-status {
|
|
312
|
+
font-size: 1.2em;
|
|
313
|
+
margin-bottom: 15px;
|
|
314
|
+
padding: 10px;
|
|
315
|
+
border-radius: 5px;
|
|
316
|
+
}
|
|
317
|
+
.verification-status.passed {
|
|
318
|
+
background: #d4edda;
|
|
319
|
+
color: #155724;
|
|
320
|
+
}
|
|
321
|
+
.verification-status.failed {
|
|
322
|
+
background: #f8d7da;
|
|
323
|
+
color: #721c24;
|
|
324
|
+
}
|
|
325
|
+
.verification-status.unavailable {
|
|
326
|
+
background: #fff3cd;
|
|
327
|
+
color: #856404;
|
|
328
|
+
}
|
|
329
|
+
.key-value-pair {
|
|
330
|
+
display: flex;
|
|
331
|
+
margin-bottom: 10px;
|
|
332
|
+
align-items: flex-start;
|
|
333
|
+
}
|
|
334
|
+
.key {
|
|
335
|
+
font-weight: bold;
|
|
336
|
+
min-width: 200px;
|
|
337
|
+
color: #2c3e50;
|
|
338
|
+
}
|
|
339
|
+
.value {
|
|
340
|
+
flex: 1;
|
|
341
|
+
word-break: break-all;
|
|
342
|
+
}
|
|
343
|
+
.value code {
|
|
344
|
+
background: #e9ecef;
|
|
345
|
+
padding: 2px 6px;
|
|
346
|
+
border-radius: 3px;
|
|
347
|
+
font-family: 'Monaco', 'Menlo', monospace;
|
|
348
|
+
font-size: 0.9em;
|
|
349
|
+
}
|
|
350
|
+
.files-section {
|
|
351
|
+
margin-top: 30px;
|
|
352
|
+
}
|
|
353
|
+
.files-table {
|
|
354
|
+
width: 100%;
|
|
355
|
+
border-collapse: collapse;
|
|
356
|
+
margin-top: 15px;
|
|
357
|
+
}
|
|
358
|
+
.files-table th,
|
|
359
|
+
.files-table td {
|
|
360
|
+
padding: 12px;
|
|
361
|
+
text-align: left;
|
|
362
|
+
border-bottom: 1px solid #dee2e6;
|
|
363
|
+
}
|
|
364
|
+
.files-table th {
|
|
365
|
+
background: #f8f9fa;
|
|
366
|
+
font-weight: bold;
|
|
367
|
+
color: #2c3e50;
|
|
368
|
+
}
|
|
369
|
+
.table-data1 {
|
|
370
|
+
font-weight: bold;
|
|
371
|
+
}
|
|
372
|
+
.warning {
|
|
373
|
+
background: #fff3cd;
|
|
374
|
+
color: #856404;
|
|
375
|
+
padding: 15px;
|
|
376
|
+
border-radius: 5px;
|
|
377
|
+
margin-bottom: 20px;
|
|
378
|
+
border-left: 4px solid #ffc107;
|
|
379
|
+
}
|
|
380
|
+
.footer {
|
|
381
|
+
text-align: center;
|
|
382
|
+
padding: 20px;
|
|
383
|
+
background: #f8f9fa;
|
|
384
|
+
color: #6c757d;
|
|
385
|
+
font-size: 0.9em;
|
|
386
|
+
}
|
|
387
|
+
h3 {
|
|
388
|
+
margin-top: 0;
|
|
389
|
+
color: #2c3e50;
|
|
390
|
+
font-size: 1.3em;
|
|
391
|
+
}
|
|
392
|
+
</style>
|
|
393
|
+
</head>
|
|
394
|
+
<body>
|
|
395
|
+
<div class="certificate">
|
|
396
|
+
<div class="header">
|
|
397
|
+
<h1>🎫 NFT Token Certificate</h1>
|
|
398
|
+
<h2>Blockchain-Verified Digital Archive</h2>
|
|
399
|
+
</div>
|
|
400
|
+
|
|
401
|
+
<div class="content">
|
|
402
|
+
{{UPDATE_WARNING}}
|
|
403
|
+
|
|
404
|
+
<div class="key-value-pair" style="margin-bottom: 30px; font-size: 1.1em;">
|
|
405
|
+
<div class="key">Archive File:</div>
|
|
406
|
+
<div class="value"><strong>{{ZIP_FILE}}</strong></div>
|
|
407
|
+
</div>
|
|
408
|
+
|
|
409
|
+
{{ATTESTATION_HTML}}
|
|
410
|
+
|
|
411
|
+
<div class="files-section">
|
|
412
|
+
<h3>📁 Archive Contents</h3>
|
|
413
|
+
<table class="files-table">
|
|
414
|
+
<thead>
|
|
415
|
+
<tr>
|
|
416
|
+
<th>File Name</th>
|
|
417
|
+
<th>Size (bytes)</th>
|
|
418
|
+
<th>Date Modified</th>
|
|
419
|
+
<th>SHA256 Hash</th>
|
|
420
|
+
</tr>
|
|
421
|
+
</thead>
|
|
422
|
+
<tbody>
|
|
423
|
+
{{FILES_TABLE_HTML}}
|
|
424
|
+
</tbody>
|
|
425
|
+
</table>
|
|
426
|
+
</div>
|
|
427
|
+
</div>
|
|
428
|
+
|
|
429
|
+
<div class="footer">
|
|
430
|
+
<p>This certificate verifies the integrity and authenticity of the tokenized archive through blockchain technology.</p>
|
|
431
|
+
<p>Generated on: {{GENERATION_TIME}}</p>
|
|
432
|
+
</div>
|
|
433
|
+
</div>
|
|
434
|
+
</body>
|
|
435
|
+
</html>`;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Prepares file information from ZIP entries for certificate generation
|
|
440
|
+
*/
|
|
441
|
+
prepareZipFileInfo(zipEntries: ZipEntry[]): ZipFileInfo[] {
|
|
442
|
+
const zipFiles: ZipFileInfo[] = [];
|
|
443
|
+
|
|
444
|
+
for (const entry of zipEntries) {
|
|
445
|
+
// Skip the token file itself and directories
|
|
446
|
+
if (entry.filename !== TOKENIZED_METADATA &&
|
|
447
|
+
!entry.isDirectory &&
|
|
448
|
+
entry.sha256) {
|
|
449
|
+
zipFiles.push({
|
|
450
|
+
filename: entry.filename,
|
|
451
|
+
size: entry.uncompressedSize,
|
|
452
|
+
date: this.formatEntryDate(entry),
|
|
453
|
+
hash: entry.sha256
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
return zipFiles;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Formats the date from a ZIP entry
|
|
463
|
+
*/
|
|
464
|
+
private formatEntryDate(entry: ZipEntry): string {
|
|
465
|
+
try {
|
|
466
|
+
// Try to use the entry's date formatting if available
|
|
467
|
+
if (typeof (entry as any).toFormattedUTCDateString === 'function') {
|
|
468
|
+
return (entry as any).toFormattedUTCDateString();
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Fallback to current date
|
|
472
|
+
return new Date().toUTCString();
|
|
473
|
+
} catch (error) {
|
|
474
|
+
return new Date().toUTCString();
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Creates a new CertificateGeneratorBrowser instance
|
|
481
|
+
*/
|
|
482
|
+
export function createCertificateGenerator(): CertificateGeneratorBrowser {
|
|
483
|
+
return new CertificateGeneratorBrowser();
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Convenience function to generate a certificate
|
|
488
|
+
*/
|
|
489
|
+
export function generateTokenCertificate(
|
|
490
|
+
tokenInfo: TokenInfo,
|
|
491
|
+
zipFile: string,
|
|
492
|
+
blockchainVerification: BlockchainVerification,
|
|
493
|
+
walletInfo?: WalletInfo,
|
|
494
|
+
zipFiles?: ZipFileInfo[]
|
|
495
|
+
): string {
|
|
496
|
+
const generator = new CertificateGeneratorBrowser();
|
|
497
|
+
return generator.createTokenCertificate(tokenInfo, zipFile, blockchainVerification, walletInfo, zipFiles);
|
|
498
|
+
}
|