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,132 +0,0 @@
|
|
|
1
|
-
// ======================================
|
|
2
|
-
// CertificateOTS.ts
|
|
3
|
-
// Copyright (c) 2025 NeoWare, Inc. All rights reserved.
|
|
4
|
-
// ======================================
|
|
5
|
-
|
|
6
|
-
import fs from 'fs';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import ZipEntry from '../ZipEntry';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
TIMESTAMP_SUBMITTED,
|
|
12
|
-
TIMESTAMP_METADATA,
|
|
13
|
-
} from '../constants/Headers';
|
|
14
|
-
|
|
15
|
-
// Add this at the top of the file
|
|
16
|
-
import type { AttestationValue } from '../types';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Generates a certificate HTML document based on timestamp information
|
|
20
|
-
*
|
|
21
|
-
* @param attestStr - Attestation message
|
|
22
|
-
* @param zipFile - Name of the zip file
|
|
23
|
-
* @param hashDigest - Hash digest of the zip file
|
|
24
|
-
* @param needsUpdateMsg - Message indicating if update is needed
|
|
25
|
-
* @param attestationValues - Array of attestation values
|
|
26
|
-
* @param zipEntries - Array of ZipEntry objects
|
|
27
|
-
* @param narrow - Whether to use narrow layout
|
|
28
|
-
* @returns Generated HTML certificate as string
|
|
29
|
-
*/
|
|
30
|
-
export default function CertificateTemplate(
|
|
31
|
-
attestStr: string | null,
|
|
32
|
-
zipFile: string,
|
|
33
|
-
hashDigest: string,
|
|
34
|
-
needsUpdateMsg: string,
|
|
35
|
-
attestationValues: AttestationValue[],
|
|
36
|
-
zipEntries: ZipEntry[],
|
|
37
|
-
narrow?: boolean
|
|
38
|
-
): string {
|
|
39
|
-
// Load the HTML template
|
|
40
|
-
let templatePath;
|
|
41
|
-
try {
|
|
42
|
-
// Try to find the template from the package root
|
|
43
|
-
templatePath = path.resolve(process.cwd(), 'assets/templates/certificate.html');
|
|
44
|
-
if (!fs.existsSync(templatePath)) {
|
|
45
|
-
// If not found in current working directory, try relative to this file
|
|
46
|
-
templatePath = path.resolve(__dirname, '../../assets/templates/certificate.html');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (!fs.existsSync(templatePath)) {
|
|
50
|
-
throw new Error('Certificate template not found');
|
|
51
|
-
}
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error('Error resolving template path:', error);
|
|
54
|
-
return '';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Read the template file
|
|
58
|
-
let htmlTemplate;
|
|
59
|
-
try {
|
|
60
|
-
htmlTemplate = fs.readFileSync(templatePath, 'utf8');
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.error('Error reading template file:', error);
|
|
63
|
-
return '';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const updateWarning = needsUpdateMsg || '';
|
|
67
|
-
|
|
68
|
-
// Generate attestation HTML
|
|
69
|
-
let attestHTML = '';
|
|
70
|
-
if (attestationValues && attestationValues.length > 0) {
|
|
71
|
-
attestationValues.forEach((attest) => {
|
|
72
|
-
attestHTML += `
|
|
73
|
-
<div class="key-value-pair">
|
|
74
|
-
<div class="key">Block Height:</div>
|
|
75
|
-
<div class="value">${attest['blockHeight']}</div>
|
|
76
|
-
</div>
|
|
77
|
-
<div class="key-value-pair">
|
|
78
|
-
<div class="key">Transaction:</div>
|
|
79
|
-
<div class="value">${attest['transactionId']}</div>
|
|
80
|
-
</div>
|
|
81
|
-
<div class="key-value-pair">
|
|
82
|
-
<div class="key">Merkle Root:</div>
|
|
83
|
-
<div class="value">${attest['merkleRoot']}</div>
|
|
84
|
-
</div>
|
|
85
|
-
<br/>
|
|
86
|
-
`;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Generate files table HTML
|
|
91
|
-
let stampEntry = null;
|
|
92
|
-
let files = [];
|
|
93
|
-
for (const entry of zipEntries) {
|
|
94
|
-
if (entry.filename === TIMESTAMP_METADATA) {
|
|
95
|
-
stampEntry = entry;
|
|
96
|
-
} else if (entry.filename === TIMESTAMP_SUBMITTED) {
|
|
97
|
-
if (stampEntry == null)
|
|
98
|
-
stampEntry = entry;
|
|
99
|
-
} else if (entry.sha256) {
|
|
100
|
-
let file = {
|
|
101
|
-
name: entry.filename,
|
|
102
|
-
size: entry.uncompressedSize.toString(),
|
|
103
|
-
date: entry.toFormattedUTCDateString(),
|
|
104
|
-
hash: entry.sha256,
|
|
105
|
-
}
|
|
106
|
-
files.push(file);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
let filesTableHTML = '';
|
|
111
|
-
files.forEach((file) => {
|
|
112
|
-
filesTableHTML += `
|
|
113
|
-
<tr>
|
|
114
|
-
<td class="table-data1">${file.name}</td>
|
|
115
|
-
<td class="table-data">${file.size}</td>
|
|
116
|
-
<td class="table-data">${file.date}</td>
|
|
117
|
-
<td class="table-data">${file.hash}</td>
|
|
118
|
-
</tr>
|
|
119
|
-
`;
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// Replace placeholders in the template
|
|
123
|
-
let html = htmlTemplate
|
|
124
|
-
.replace(/{{ATTEST_STR}}/g, attestStr || '')
|
|
125
|
-
.replace(/{{UPDATE_WARNING}}/g, needsUpdateMsg ? `<div class="warning">${needsUpdateMsg}</div>` : '')
|
|
126
|
-
.replace(/{{ZIP_FILE}}/g, zipFile)
|
|
127
|
-
.replace(/{{HASH_DIGEST}}/g, hashDigest)
|
|
128
|
-
.replace(/{{ATTESTATION_HTML}}/g, attestHTML)
|
|
129
|
-
.replace(/{{FILES_TABLE_HTML}}/g, filesTableHTML);
|
|
130
|
-
|
|
131
|
-
return html;
|
|
132
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// ======================================
|
|
2
|
-
// FileSys.ts
|
|
3
|
-
// Copyright (c) 2024 NeoWare, Inc. All rights reserved.
|
|
4
|
-
// ======================================
|
|
5
|
-
|
|
6
|
-
import * as fs from 'fs';
|
|
7
|
-
import * as pth from 'path';
|
|
8
|
-
|
|
9
|
-
import Errors from '../constants/Errors';
|
|
10
|
-
|
|
11
|
-
// Output a buffer to a file
|
|
12
|
-
export function outputToFile(
|
|
13
|
-
fileName: string,
|
|
14
|
-
buffer: Buffer,
|
|
15
|
-
dirPath: string,
|
|
16
|
-
overwrite: boolean,
|
|
17
|
-
never: boolean,
|
|
18
|
-
fileAttr: number)
|
|
19
|
-
{
|
|
20
|
-
// get Unix file permissions
|
|
21
|
-
const _fattr = fileAttr ? (((fileAttr >>> 0) | 0) >> 16) & 0xfff : 0;
|
|
22
|
-
|
|
23
|
-
const _path = dirPath ? dirPath + pth.sep + fileName : fileName;
|
|
24
|
-
|
|
25
|
-
if (fs.existsSync(_path)) {
|
|
26
|
-
console.log('File exists: ', _path);
|
|
27
|
-
if (never)
|
|
28
|
-
return false;
|
|
29
|
-
if (!overwrite) {
|
|
30
|
-
console.log('Overwrite file: ', _path);
|
|
31
|
-
return false; // cannot overwrite
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const stat = fs.statSync(_path);
|
|
35
|
-
if (stat.isDirectory())
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Check if we need to create a new folder
|
|
40
|
-
const _folder = pth.dirname(_path);
|
|
41
|
-
if (!fs.existsSync(_folder)) {
|
|
42
|
-
makeDir(_folder);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var fd;
|
|
46
|
-
try {
|
|
47
|
-
fd = fs.openSync(_path, "w", 438); // 0666
|
|
48
|
-
} catch (e) {
|
|
49
|
-
fs.chmodSync(_path, 438);
|
|
50
|
-
fd = fs.openSync(_path, "w", 438);
|
|
51
|
-
}
|
|
52
|
-
if (fd) {
|
|
53
|
-
try {
|
|
54
|
-
fs.writeSync(fd, buffer, 0, buffer.length, 0);
|
|
55
|
-
} finally {
|
|
56
|
-
fs.closeSync(fd);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (_fattr)
|
|
61
|
-
fs.chmodSync(_path, _fattr);
|
|
62
|
-
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Make directories tree for a given path
|
|
67
|
-
export function makeDir(folder: string) {
|
|
68
|
-
console.log('mkDir: ', folder);
|
|
69
|
-
|
|
70
|
-
// Sync - make directories tree
|
|
71
|
-
function mkdirSync(fpath: string) {
|
|
72
|
-
let resolvedPath = fpath.split(pth.sep)[0];
|
|
73
|
-
fpath.split(pth.sep).forEach(function (name) {
|
|
74
|
-
if (!name || name.endsWith(":")) return;
|
|
75
|
-
resolvedPath += pth.sep + name;
|
|
76
|
-
var stat;
|
|
77
|
-
try {
|
|
78
|
-
stat = fs.statSync(resolvedPath);
|
|
79
|
-
} catch (e) {
|
|
80
|
-
fs.mkdirSync(resolvedPath);
|
|
81
|
-
}
|
|
82
|
-
if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY.replace("%s", resolvedPath);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
mkdirSync(folder);
|
|
87
|
-
};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// ======================================
|
|
2
|
-
// HashAccumulator.ts
|
|
3
|
-
// ======================================
|
|
4
|
-
|
|
5
|
-
import { MerkleTree } from './merkleTree';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Class for accumulating and combining SHA-256 hashes using both XOR and Merkle tree methods
|
|
9
|
-
*
|
|
10
|
-
* Usage example:
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const accumulator = new HashAccumulator();
|
|
13
|
-
* accumulator.addHash('a1b2c3d4');
|
|
14
|
-
* accumulator.addHash('12345678');
|
|
15
|
-
* console.log(accumulator.xorHash()); // Outputs the accumulated XOR result
|
|
16
|
-
* console.log(accumulator.merkleRoot()); // Outputs the accumulated Merkle root
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export default class HashAccumulator {
|
|
20
|
-
private hashes: Buffer[]; // Array of hash buffers for Merkle tree
|
|
21
|
-
private xorResult: Buffer; // Running XOR of all hashes
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new HashAccumulator instance
|
|
25
|
-
* Initializes empty hash array and zero-filled XOR buffer
|
|
26
|
-
*/
|
|
27
|
-
constructor() {
|
|
28
|
-
this.hashes = [];
|
|
29
|
-
this.xorResult = Buffer.alloc(32, 0);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Adds a hash to both the XOR accumulation and hash array
|
|
34
|
-
* @param hash - Hash value as hex string or Buffer
|
|
35
|
-
* The hash must be 32 bytes (SHA-256)
|
|
36
|
-
*/
|
|
37
|
-
addHash(hash: string | Buffer) {
|
|
38
|
-
// Convert hash to Buffer if it's a string
|
|
39
|
-
const hashBuffer = typeof hash === 'string'
|
|
40
|
-
? Buffer.from(hash, 'hex')
|
|
41
|
-
: hash;
|
|
42
|
-
|
|
43
|
-
// Add to array for Merkle tree
|
|
44
|
-
this.hashes.push(hashBuffer);
|
|
45
|
-
|
|
46
|
-
// XOR accumulation
|
|
47
|
-
for (let i = 0; i < 32; i++) {
|
|
48
|
-
this.xorResult[i] ^= hashBuffer[i];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Gets the accumulated XOR of all added hashes
|
|
54
|
-
* @returns Hex string of XOR result
|
|
55
|
-
*/
|
|
56
|
-
xorHash(): string {
|
|
57
|
-
return this.xorResult.toString('hex');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Creates a Merkle tree from accumulated hashes and returns the root
|
|
62
|
-
* @returns Hex string of Merkle root, or null if no hashes added
|
|
63
|
-
*/
|
|
64
|
-
merkleRoot(): string | null {
|
|
65
|
-
let merkleRoot = null;
|
|
66
|
-
if (this.hashes.length > 0) {
|
|
67
|
-
const tree = new MerkleTree(this.hashes, {
|
|
68
|
-
hashLeaves: false, // Leaves are already hashed
|
|
69
|
-
sortLeaves: true, // Sort leaves for consistent results
|
|
70
|
-
sortPairs: true, // Sort pairs for consistent results
|
|
71
|
-
duplicateOdd: true // Duplicate odd leaf for balanced tree
|
|
72
|
-
});
|
|
73
|
-
merkleRoot = tree.getRoot().toString('hex');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return merkleRoot;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Gets the number of hashes accumulated
|
|
81
|
-
* @returns Number of accumulated hashes
|
|
82
|
-
*/
|
|
83
|
-
leafCount(): number {
|
|
84
|
-
return this.hashes.length;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Resets the accumulator to initial state
|
|
89
|
-
* Clears hash array and zeroes XOR buffer
|
|
90
|
-
*/
|
|
91
|
-
clear() {
|
|
92
|
-
this.hashes = [];
|
|
93
|
-
this.xorResult = Buffer.alloc(32, 0);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Combines multiple hash results into a single Merkle root
|
|
98
|
-
* @param results - Array of objects containing merkleRoot properties
|
|
99
|
-
* @returns Combined Merkle root as hex string, or null if no valid roots
|
|
100
|
-
*/
|
|
101
|
-
static combineResults(results: { merkleRoot?: string }[]) {
|
|
102
|
-
const accumulator = new HashAccumulator();
|
|
103
|
-
|
|
104
|
-
// Combine all hashes
|
|
105
|
-
for (const result of results) {
|
|
106
|
-
if (result.merkleRoot) {
|
|
107
|
-
accumulator.addHash(result.merkleRoot);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return accumulator.merkleRoot();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// ======================================
|
|
2
|
-
// ZipCrypto.ts
|
|
3
|
-
// Copyright (c) 2024 NeoWare, Inc. All rights reserved.
|
|
4
|
-
// ======================================
|
|
5
|
-
// Zip Cryptography Routines
|
|
6
|
-
|
|
7
|
-
"use strict";
|
|
8
|
-
|
|
9
|
-
import { createHash, randomFillSync } from 'crypto';
|
|
10
|
-
|
|
11
|
-
import { crc32update, uMul } from './Util';
|
|
12
|
-
import { ENCRYPT_HDR_SIZE } from '../constants/Headers';
|
|
13
|
-
|
|
14
|
-
// Return the SHA256 hash of a buffer
|
|
15
|
-
export function sha256(data: Buffer): string {
|
|
16
|
-
const hash = createHash('sha256');
|
|
17
|
-
|
|
18
|
-
return hash
|
|
19
|
-
.update(data)
|
|
20
|
-
.digest('hex');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
class InitKeys {
|
|
24
|
-
private keys: Uint32Array;
|
|
25
|
-
|
|
26
|
-
constructor(pw: string | Buffer) {
|
|
27
|
-
this.keys = new Uint32Array([0x12345678, 0x23456789, 0x34567890]);
|
|
28
|
-
const pass = typeof pw === 'string' ? Buffer.from(pw) : pw;
|
|
29
|
-
for (let i = 0; i < pass.length; i++) {
|
|
30
|
-
this.updateKeys(pass[i]);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
updateKeys(byteValue: number): number {
|
|
35
|
-
this.keys[0] = crc32update(this.keys[0], byteValue);
|
|
36
|
-
this.keys[1] = ((this.keys[1] + (this.keys[0] & 0xff)) * 0x08088405 + 1) >>> 0;
|
|
37
|
-
this.keys[2] = crc32update(this.keys[2], this.keys[1] >>> 24);
|
|
38
|
-
return byteValue;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
next(): number {
|
|
42
|
-
const k = (this.keys[2] | 2) >>> 0; // key
|
|
43
|
-
return (uMul(k, k ^ 1) >> 8) & 0xff; // decode
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Return encrypting function, result and pos is here so we dont have to merge buffers later
|
|
48
|
-
function make_encrypter(pwd: string | Buffer): Function {
|
|
49
|
-
const keys = new InitKeys(pwd);
|
|
50
|
-
|
|
51
|
-
return function (data: Buffer, result: Buffer, pos: number = 0): Buffer {
|
|
52
|
-
// result - we create new Buffer for results
|
|
53
|
-
if (!result) result = Buffer.alloc(data.length);
|
|
54
|
-
// process input data
|
|
55
|
-
for (let c of data) {
|
|
56
|
-
const k = keys.next(); // save key byte
|
|
57
|
-
result[pos++] = c ^ k; // save val
|
|
58
|
-
keys.updateKeys(c); // update keys with decoded byte
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Encrypt data with password and include a checkByte verification byte at the end
|
|
65
|
-
export function encrypter(data: Buffer | null, checkByte: number, pwd: string): Buffer | null {
|
|
66
|
-
if (!data) return null;
|
|
67
|
-
|
|
68
|
-
const _encrypter = make_encrypter(pwd);
|
|
69
|
-
|
|
70
|
-
const salt = randomFillSync(Buffer.alloc(ENCRYPT_HDR_SIZE));
|
|
71
|
-
salt[ENCRYPT_HDR_SIZE - 1] = checkByte;
|
|
72
|
-
|
|
73
|
-
// create encryption header
|
|
74
|
-
const result = Buffer.alloc(data.length + ENCRYPT_HDR_SIZE);
|
|
75
|
-
_encrypter(salt, result);
|
|
76
|
-
|
|
77
|
-
// encode content
|
|
78
|
-
return _encrypter(data, result, ENCRYPT_HDR_SIZE);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Return the decrypter function
|
|
82
|
-
export function decrypter(pwd: string | Buffer): Function {
|
|
83
|
-
const keys = new InitKeys(pwd);
|
|
84
|
-
|
|
85
|
-
return function (data: Buffer): Buffer {
|
|
86
|
-
for (let i=0; i<data.length; i++) {
|
|
87
|
-
data[i] = keys.updateKeys(data[i] ^ keys.next());
|
|
88
|
-
}
|
|
89
|
-
return data;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'crypto';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Configuration options for Merkle tree construction
|
|
5
|
-
*/
|
|
6
|
-
interface MerkleTreeOptions {
|
|
7
|
-
hashLeaves: boolean; // Whether to hash the leaf nodes before adding to tree
|
|
8
|
-
sortLeaves: boolean; // Whether to sort leaf nodes for consistent trees
|
|
9
|
-
sortPairs: boolean; // Whether to sort each pair before hashing
|
|
10
|
-
duplicateOdd: boolean; // Whether to duplicate last leaf when odd number of leaves
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Implementation of a Merkle Tree (hash tree) using SHA-256
|
|
15
|
-
*
|
|
16
|
-
* A Merkle tree is a binary tree where each non-leaf node is the hash of its two children.
|
|
17
|
-
* This allows efficient verification of large datasets by only storing/transmitting the root hash
|
|
18
|
-
* and generating proofs of inclusion for individual items.
|
|
19
|
-
*/
|
|
20
|
-
export class MerkleTree {
|
|
21
|
-
private leaves: Buffer[]; // Leaf nodes (original data or hashes)
|
|
22
|
-
private layers: Buffer[][]; // All layers of the tree, from leaves to root
|
|
23
|
-
private options: MerkleTreeOptions;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Creates a new Merkle tree from an array of leaf nodes
|
|
27
|
-
* @param leaves - Array of leaf node data as Buffers
|
|
28
|
-
* @param options - Configuration options for tree construction
|
|
29
|
-
*/
|
|
30
|
-
constructor(leaves: Buffer[], options: Partial<MerkleTreeOptions> = {}) {
|
|
31
|
-
this.options = {
|
|
32
|
-
hashLeaves: false,
|
|
33
|
-
sortLeaves: true,
|
|
34
|
-
sortPairs: true,
|
|
35
|
-
duplicateOdd: true,
|
|
36
|
-
...options
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Process leaves according to options
|
|
40
|
-
this.leaves = leaves.map(leaf => {
|
|
41
|
-
if (this.options.hashLeaves) {
|
|
42
|
-
return this.hash(leaf);
|
|
43
|
-
}
|
|
44
|
-
return Buffer.isBuffer(leaf) ? leaf : Buffer.from(leaf);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
if (this.options.sortLeaves) {
|
|
48
|
-
this.leaves.sort(Buffer.compare);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
this.layers = [this.leaves];
|
|
52
|
-
this.createHashes(this.leaves);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Computes SHA-256 hash of input data
|
|
57
|
-
* @param data - Data to hash
|
|
58
|
-
* @returns Buffer containing hash
|
|
59
|
-
*/
|
|
60
|
-
private hash(data: Buffer): Buffer {
|
|
61
|
-
return createHash('sha256').update(data).digest();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Combines two child hashes to create parent hash
|
|
66
|
-
* @param left - Left child hash
|
|
67
|
-
* @param right - Right child hash
|
|
68
|
-
* @returns Combined hash of children
|
|
69
|
-
*/
|
|
70
|
-
private combinedHash(left: Buffer, right: Buffer): Buffer {
|
|
71
|
-
if (this.options.sortPairs && Buffer.compare(left, right) > 0) {
|
|
72
|
-
[left, right] = [right, left];
|
|
73
|
-
}
|
|
74
|
-
return this.hash(Buffer.concat([left, right]));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Builds the Merkle tree by creating successive layers of hashes
|
|
79
|
-
* @param nodes - Array of nodes in current layer
|
|
80
|
-
*/
|
|
81
|
-
private createHashes(nodes: Buffer[]) {
|
|
82
|
-
while (nodes.length > 1) {
|
|
83
|
-
const layerIndex = this.layers.length;
|
|
84
|
-
this.layers.push([]);
|
|
85
|
-
|
|
86
|
-
// Process pairs of nodes
|
|
87
|
-
for (let i = 0; i < nodes.length - 1; i += 2) {
|
|
88
|
-
const left = nodes[i];
|
|
89
|
-
const right = nodes[i + 1];
|
|
90
|
-
const hash = this.combinedHash(left, right);
|
|
91
|
-
this.layers[layerIndex].push(hash);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Handle odd number of nodes
|
|
95
|
-
if (nodes.length % 2 === 1) {
|
|
96
|
-
const last = nodes[nodes.length - 1];
|
|
97
|
-
if (this.options.duplicateOdd) {
|
|
98
|
-
// Duplicate the last node if odd
|
|
99
|
-
const hash = this.combinedHash(last, last);
|
|
100
|
-
this.layers[layerIndex].push(hash);
|
|
101
|
-
} else {
|
|
102
|
-
// Push last node up to next layer
|
|
103
|
-
this.layers[layerIndex].push(last);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
nodes = this.layers[layerIndex];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Gets the root hash of the Merkle tree
|
|
113
|
-
* @returns Buffer containing root hash
|
|
114
|
-
*/
|
|
115
|
-
public getRoot(): Buffer {
|
|
116
|
-
return this.layers[this.layers.length - 1][0];
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Generates a proof of inclusion for a leaf node
|
|
121
|
-
* @param leaf - The leaf node to generate proof for
|
|
122
|
-
* @returns Array of sibling hashes needed to reconstruct root
|
|
123
|
-
* @throws Error if leaf not found in tree
|
|
124
|
-
*/
|
|
125
|
-
public getProof(leaf: Buffer): Buffer[] {
|
|
126
|
-
let index = this.leaves.findIndex(item => item.equals(leaf));
|
|
127
|
-
if (index === -1) {
|
|
128
|
-
throw new Error('Leaf not found in tree');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return this.layers.reduce((proof, layer) => {
|
|
132
|
-
if (layer.length === 1) return proof;
|
|
133
|
-
|
|
134
|
-
const pairIndex = index % 2 === 0 ? index + 1 : index - 1;
|
|
135
|
-
if (pairIndex < layer.length) {
|
|
136
|
-
proof.push(layer[pairIndex]);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
index = Math.floor(index / 2);
|
|
140
|
-
return proof;
|
|
141
|
-
}, [] as Buffer[]);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Verifies a proof of inclusion for a leaf node
|
|
146
|
-
* @param proof - Array of sibling hashes from getProof()
|
|
147
|
-
* @param targetHash - Hash of the leaf node being verified
|
|
148
|
-
* @param root - Expected root hash
|
|
149
|
-
* @returns boolean indicating if proof is valid
|
|
150
|
-
*/
|
|
151
|
-
public verify(proof: Buffer[], targetHash: Buffer, root: Buffer): boolean {
|
|
152
|
-
let computedHash = targetHash;
|
|
153
|
-
|
|
154
|
-
for (const proofElement of proof) {
|
|
155
|
-
computedHash = Buffer.compare(computedHash, proofElement) <= 0
|
|
156
|
-
? this.combinedHash(computedHash, proofElement)
|
|
157
|
-
: this.combinedHash(proofElement, computedHash);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return computedHash.equals(root);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export interface FileData {
|
|
2
|
-
name: string;
|
|
3
|
-
size: number;
|
|
4
|
-
lastModified: number;
|
|
5
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface ZipFileEntry {
|
|
9
|
-
fileData?: FileData;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface Support {
|
|
13
|
-
base64: boolean;
|
|
14
|
-
array: boolean;
|
|
15
|
-
string: boolean;
|
|
16
|
-
isNode: boolean;
|
|
17
|
-
buffer: boolean;
|
|
18
|
-
uint8array: boolean;
|
|
19
|
-
arrayBuffer: boolean;
|
|
20
|
-
blob: boolean;
|
|
21
|
-
streams: boolean;
|
|
22
|
-
fileReader: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// External module types are handled by installed @types packages
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
declare module 'pako' {
|
|
2
|
-
export function deflateRaw(data: Uint8Array | Buffer, options?: any): Buffer;
|
|
3
|
-
export function inflateRaw(data: Uint8Array | Buffer): Buffer;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
declare module 'opentimestamps' {
|
|
7
|
-
export class Ops {
|
|
8
|
-
static OpSHA256: any;
|
|
9
|
-
}
|
|
10
|
-
export class DetachedTimestampFile {
|
|
11
|
-
static fromHash(op: any, digest: Buffer): DetachedTimestampFile;
|
|
12
|
-
static deserialize(ots: Buffer): DetachedTimestampFile;
|
|
13
|
-
serializeToBytes(): Uint8Array;
|
|
14
|
-
timestamp?: {
|
|
15
|
-
allAttestations(): string[];
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export function stamp(detached: DetachedTimestampFile[]): Promise<void>;
|
|
19
|
-
export function upgrade(ots: DetachedTimestampFile): Promise<boolean>;
|
|
20
|
-
export function verify(ots: DetachedTimestampFile, hash: DetachedTimestampFile, options?: any): Promise<any>;
|
|
21
|
-
export function info(detached: DetachedTimestampFile): string;
|
|
22
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
}
|
package/src/shared/types.d.ts
DELETED