neozipkit 0.1.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 +371 -200
- 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 +256 -0
- 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/{browser → blockchain/browser}/TokenVerifierBrowser.d.ts +11 -20
- package/dist/blockchain/browser/TokenVerifierBrowser.d.ts.map +1 -0
- package/dist/{browser → blockchain/browser}/TokenVerifierBrowser.js +106 -92
- 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/{server/blockchain/WalletAnalyzer.d.ts → blockchain/core/WalletManager.d.ts} +69 -26
- package/dist/blockchain/core/WalletManager.d.ts.map +1 -0
- package/dist/{server/blockchain/WalletAnalyzer.js → blockchain/core/WalletManager.js} +172 -160
- package/dist/blockchain/core/WalletManager.js.map +1 -0
- package/dist/blockchain/core/ZipkitMinter.d.ts +141 -0
- 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/core/ZipkitOTS.d.ts +126 -0
- package/dist/blockchain/core/ZipkitOTS.d.ts.map +1 -0
- package/dist/blockchain/core/ZipkitOTS.js +506 -0
- 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 -0
- package/dist/blockchain/index.d.ts.map +1 -0
- package/dist/blockchain/index.js +34 -0
- 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 -17
- package/dist/browser.js +13 -29
- 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 +224 -81
- 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/{shared → core}/version.d.ts +1 -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 -25
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -47
- 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 +6 -3
- package/examples/verify-tokenized-zip.ts +305 -0
- package/package.json +117 -23
- package/src/blockchain/README.md +222 -0
- package/src/{browser → 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/core/WalletManager.ts +436 -0
- package/src/blockchain/core/ZipkitMinter.ts +716 -0
- package/src/blockchain/core/ZipkitOTS.ts +588 -0
- 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 +27 -0
- 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 +239 -89
- 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 -32
- 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/opentimestamps.d.ts +1 -23
- package/contracts/Lock.sol +0 -34
- package/contracts/bytecode.txt +0 -1
- package/contracts/compile-contract.js +0 -168
- package/contracts/deploy/deploy-both-contracts.js +0 -286
- package/contracts/deploy/deploy-enhanced-contract.js +0 -197
- package/contracts/deploy/deploy-private-contract.js +0 -190
- package/contracts/deploy/deploy-public-clean.js +0 -1063
- package/contracts/deploy/deploy-public-contract.js +0 -1107
- package/contracts/deployment.config.example.js +0 -25
- package/contracts/remix-compile.js +0 -222
- package/contracts/setup-deployment.js +0 -51
- package/contracts/src/ZipFileNFT-DEPRECATED-6field.sol +0 -260
- package/contracts/src/ZipFileNFT-DEPRECATED-Enhanced.sol +0 -289
- package/dist/browser/CertificateGeneratorBrowser.d.ts +0 -75
- package/dist/browser/CertificateGeneratorBrowser.js +0 -433
- 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 -21
- package/dist/browser-index.js +0 -58
- package/dist/server/blockchain/CertificateToken.d.ts +0 -48
- package/dist/server/blockchain/CertificateToken.js +0 -386
- package/dist/server/blockchain/NFTMinter.d.ts +0 -41
- package/dist/server/blockchain/NFTMinter.js +0 -323
- package/dist/server/blockchain/TokenQuerier.d.ts +0 -31
- package/dist/server/blockchain/TokenQuerier.js +0 -259
- package/dist/server/blockchain/TokenVerifier.d.ts +0 -20
- package/dist/server/blockchain/TokenVerifier.js +0 -395
- package/dist/server/blockchain/WalletFormatter.d.ts +0 -39
- package/dist/server/blockchain/WalletFormatter.js +0 -196
- package/dist/server/blockchain/WalletManager.d.ts +0 -46
- package/dist/server/blockchain/WalletManager.js +0 -294
- package/dist/server/blockchain/ZipMetadata.d.ts +0 -27
- package/dist/server/blockchain/ZipMetadata.js +0 -131
- package/dist/server/blockchain/ZipTokenProcessor.d.ts +0 -44
- package/dist/server/blockchain/ZipTokenProcessor.js +0 -204
- package/dist/server/blockchain/constants.d.ts +0 -102
- package/dist/server/blockchain/constants.js +0 -968
- package/dist/server/blockchain/index.d.ts +0 -9
- package/dist/server/blockchain/index.js +0 -44
- package/dist/server/blockchain/test-certificate.d.ts +0 -8
- package/dist/server/blockchain/test-certificate.js +0 -100
- package/dist/server/blockchain/types.d.ts +0 -69
- package/dist/server/blockchain/types.js +0 -51
- package/dist/server/platform/server/ZipKitServer.d.ts +0 -105
- package/dist/server/platform/server/ZipKitServer.js +0 -437
- package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +0 -91
- package/dist/server/platform/servercomponents/ZipKitOTS.js +0 -271
- package/dist/shared/ZipKit.d.ts +0 -249
- package/dist/shared/ZipKit.js +0 -789
- 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.js +0 -7
- package/src/browser/CertificateGeneratorBrowser.ts +0 -498
- package/src/browser/ZipKitStampBrowser.ts +0 -9
- package/src/browser-index.ts +0 -36
- package/src/server/blockchain/CertificateToken.ts +0 -444
- package/src/server/blockchain/NFTMinter.ts +0 -357
- package/src/server/blockchain/TokenQuerier.ts +0 -287
- package/src/server/blockchain/TokenVerifier.ts +0 -453
- package/src/server/blockchain/WalletAnalyzer.ts +0 -397
- package/src/server/blockchain/WalletFormatter.ts +0 -206
- package/src/server/blockchain/WalletManager.ts +0 -294
- package/src/server/blockchain/ZipMetadata.ts +0 -117
- package/src/server/blockchain/ZipTokenProcessor.ts +0 -234
- package/src/server/blockchain/constants.ts +0 -969
- package/src/server/blockchain/index.ts +0 -42
- package/src/server/blockchain/test-certificate.ts +0 -137
- package/src/server/blockchain/types.ts +0 -134
- package/src/server/platform/server/ZipKitServer.ts +0 -459
- package/src/server/platform/servercomponents/ZipKitOTS.ts +0 -313
- package/src/server/platform/servercomponents/opentimestamps.d.ts +0 -23
- package/src/shared/ZipKit.ts +0 -899
- 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 -4
- /package/src/{shared → core}/components/Support.ts +0 -0
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
// ======================================
|
|
2
|
-
// ZipKitOTS.ts
|
|
3
|
-
// Copyright (c) 2025 NeoWare, Inc. All rights reserved.
|
|
4
|
-
// ======================================
|
|
5
|
-
// ZipKit OpenTimestamps Routines
|
|
6
|
-
"use server";
|
|
7
|
-
"use strict";
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.verifyTimestamp = verifyTimestamp;
|
|
46
|
-
exports.createTimestamp = createTimestamp;
|
|
47
|
-
exports.deserializeOts = deserializeOts;
|
|
48
|
-
exports.parseVerifyResult = parseVerifyResult;
|
|
49
|
-
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
50
|
-
if (global._bitcore)
|
|
51
|
-
delete global._bitcore;
|
|
52
|
-
let OTSInstance = null;
|
|
53
|
-
async function getOTS() {
|
|
54
|
-
if (!OTSInstance) {
|
|
55
|
-
OTSInstance = (await Promise.resolve().then(() => __importStar(require('opentimestamps')))).default;
|
|
56
|
-
}
|
|
57
|
-
return OTSInstance;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Verifies a timestamp proof against a file hash
|
|
61
|
-
*
|
|
62
|
-
* @param hashDigest - SHA-256 hash digest of the file or merkle root (hex string)
|
|
63
|
-
* @param otsData - The OpenTimestamps proof data
|
|
64
|
-
* @returns Promise with verification result or null on critical failure
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* // Verify a timestamp proof
|
|
68
|
-
* const hashDigest = "8a9d..."; // SHA-256 digest in hex format
|
|
69
|
-
* const result = await verifyTimestamp(hashDigest, otsBuffer);
|
|
70
|
-
*
|
|
71
|
-
* if (result) {
|
|
72
|
-
* if (result.error) {
|
|
73
|
-
* console.error("Verification failed:", result.error);
|
|
74
|
-
* } else {
|
|
75
|
-
* console.log("Verification succeeded:", result.verified);
|
|
76
|
-
*
|
|
77
|
-
* if (result.upgradedOts) {
|
|
78
|
-
* // Save the upgraded timestamp
|
|
79
|
-
* }
|
|
80
|
-
* }
|
|
81
|
-
* }
|
|
82
|
-
*/
|
|
83
|
-
async function verifyTimestamp(hashDigest, ots) {
|
|
84
|
-
if (!hashDigest || !ots) {
|
|
85
|
-
console.error('verifyTimestamp - Invalid parameters');
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
const tsResult = {
|
|
89
|
-
merkleRoot: hashDigest,
|
|
90
|
-
ots: ots,
|
|
91
|
-
verified: false,
|
|
92
|
-
results: null,
|
|
93
|
-
error: null,
|
|
94
|
-
attestations: null,
|
|
95
|
-
upgradedOts: null,
|
|
96
|
-
};
|
|
97
|
-
try {
|
|
98
|
-
const OpenTimestamps = await getOTS();
|
|
99
|
-
// Convert the base64 string to a Buffer
|
|
100
|
-
// const _otsBuffer = Buffer.from(ots, 'base64');
|
|
101
|
-
const _otsBuffer = Buffer.from(ots);
|
|
102
|
-
const detachedOts = OpenTimestamps.DetachedTimestampFile.deserialize(_otsBuffer);
|
|
103
|
-
const digest = Buffer.from(hashDigest, 'hex');
|
|
104
|
-
const hashOts = OpenTimestamps.DetachedTimestampFile.fromHash(new OpenTimestamps.Ops.OpSHA256(), digest);
|
|
105
|
-
// Check if the MetaStamp should be upgraded
|
|
106
|
-
const upgrade = await OpenTimestamps.upgrade(detachedOts);
|
|
107
|
-
if (upgrade) {
|
|
108
|
-
console.log('verifyTimestamp === Timestamp should be upgraded!');
|
|
109
|
-
tsResult.upgradedOts = detachedOts.serializeToBytes();
|
|
110
|
-
}
|
|
111
|
-
// Verify the MetaStamp
|
|
112
|
-
tsResult.results = await OpenTimestamps.verify(detachedOts, hashOts, {
|
|
113
|
-
ignoreBitcoinNode: true, // Don't check for local Bitcoin node
|
|
114
|
-
timeout: 5000
|
|
115
|
-
});
|
|
116
|
-
var _attest = [];
|
|
117
|
-
detachedOts.timestamp.allAttestations().forEach((attestation) => {
|
|
118
|
-
if (attestation instanceof OpenTimestamps.Notary.UnknownAttestation) {
|
|
119
|
-
console.log('Unknown attestation type');
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
// console.log(attestation);
|
|
123
|
-
_attest.push(attestation);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
tsResult.attestations = JSON.stringify(_attest);
|
|
127
|
-
// Check if the results show a verified timestamp
|
|
128
|
-
if (Object.keys(tsResult.results).length < 1) {
|
|
129
|
-
tsResult.results = null;
|
|
130
|
-
tsResult.verified = false;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
tsResult.verified = true;
|
|
134
|
-
}
|
|
135
|
-
console.log('verifyTimestamp === tsResult: ', tsResult);
|
|
136
|
-
return tsResult;
|
|
137
|
-
}
|
|
138
|
-
catch (error) {
|
|
139
|
-
let errMsg = error?.message || 'Timestamp Verification Failed!';
|
|
140
|
-
if (errMsg.indexOf('ESOCKETTIMEDOUT') != -1) {
|
|
141
|
-
errMsg = 'Server timed out, Try again in a few minutes.';
|
|
142
|
-
}
|
|
143
|
-
else if (errMsg.indexOf('502') != -1) {
|
|
144
|
-
errMsg = 'Server failed to respond, Try again in a few minutes.';
|
|
145
|
-
}
|
|
146
|
-
else if (errMsg.indexOf('ECONNRESET') != -1) {
|
|
147
|
-
errMsg = 'Server connection reset, Try again in a few minutes.';
|
|
148
|
-
}
|
|
149
|
-
return { error: errMsg };
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Creates a timestamp proof for a file hash using OpenTimestamps
|
|
154
|
-
*
|
|
155
|
-
* @param hashDigest - SHA-256 hash digest of the file or merkle root (hex string)
|
|
156
|
-
* @returns Promise containing the OpenTimestamps proof or null on failure
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
* // Create a timestamp for a file hash
|
|
160
|
-
* const hashDigest = "8a9d..."; // SHA-256 digest in hex format
|
|
161
|
-
* const timestampProof = await createTimestamp(hashDigest);
|
|
162
|
-
*
|
|
163
|
-
* if (timestampProof) {
|
|
164
|
-
* // Save the timestamp proof to storage
|
|
165
|
-
* }
|
|
166
|
-
*/
|
|
167
|
-
async function createTimestamp(hashDigest) {
|
|
168
|
-
if (!hashDigest)
|
|
169
|
-
return null;
|
|
170
|
-
try {
|
|
171
|
-
const OpenTimestamps = await getOTS();
|
|
172
|
-
// Convert hex string to Buffer
|
|
173
|
-
const hashBuffer = Buffer.from(hashDigest, 'hex');
|
|
174
|
-
// Create detached timestamp file
|
|
175
|
-
const detached = OpenTimestamps.DetachedTimestampFile.fromHash(new OpenTimestamps.Ops.OpSHA256(), hashBuffer);
|
|
176
|
-
// Create the timestamp
|
|
177
|
-
await OpenTimestamps.stamp(detached);
|
|
178
|
-
// Return the serialized timestamp
|
|
179
|
-
return Buffer.from(detached.serializeToBytes());
|
|
180
|
-
}
|
|
181
|
-
catch (error) {
|
|
182
|
-
console.error('Error creating timestamp:', error);
|
|
183
|
-
throw new Error('Error creating timestamp');
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Deserializes timestamp metadata to extract attestation information
|
|
188
|
-
* Used for generating timestamp certificates and displaying verification details
|
|
189
|
-
*
|
|
190
|
-
* @param tsResult - Timestamp verification result to deserialize
|
|
191
|
-
* @returns JSON string of deserialized data or null on failure
|
|
192
|
-
*/
|
|
193
|
-
async function deserializeOts(tsResult) {
|
|
194
|
-
let result = {
|
|
195
|
-
attestStr: null,
|
|
196
|
-
needsUpdateMsg: null,
|
|
197
|
-
attestationValues: [],
|
|
198
|
-
};
|
|
199
|
-
for (const chain in tsResult.results) {
|
|
200
|
-
let _results = tsResult.results[chain];
|
|
201
|
-
const _attestDate = (0, moment_timezone_1.default)(_results.timestamp * 1000).tz(moment_timezone_1.default.tz.guess()).format('MM-DD-YYYY hh:mma z');
|
|
202
|
-
const blockchain = chain.charAt(0).toUpperCase() + chain.slice(1);
|
|
203
|
-
result.attestStr = `<b>${blockchain} block ${_results.height}</b> attests existence as of <b>${_attestDate}</b>`;
|
|
204
|
-
}
|
|
205
|
-
;
|
|
206
|
-
let timestamp = tsResult.ots;
|
|
207
|
-
if (tsResult.upgradedOts != null) {
|
|
208
|
-
result.needsUpdateMsg = "This Zip file requires updated Timestamp Metadata!";
|
|
209
|
-
// Use the updated timestamp metadata
|
|
210
|
-
timestamp = tsResult.upgradedOts;
|
|
211
|
-
}
|
|
212
|
-
// Extract the attestation values from the timestamp metadata
|
|
213
|
-
if (!timestamp)
|
|
214
|
-
return null;
|
|
215
|
-
const OpenTimestamps = await getOTS();
|
|
216
|
-
const detached = OpenTimestamps.DetachedTimestampFile.deserialize(Buffer.from(timestamp));
|
|
217
|
-
const infoResult = OpenTimestamps.info(detached);
|
|
218
|
-
// Extract all transaction IDs using a regular expression
|
|
219
|
-
const transactionIdMatches = [...infoResult.matchAll(/transaction id ([a-f0-9]+)/gi)];
|
|
220
|
-
const transactionIds = transactionIdMatches.map(match => match[1]);
|
|
221
|
-
// Extract the value inside the parentheses using a regular expression
|
|
222
|
-
const blockHeightMatches = [...infoResult.matchAll(/verify BitcoinBlockHeaderAttestation\((\d+)\)/g)];
|
|
223
|
-
const blockHeights = blockHeightMatches.map(match => match[1]);
|
|
224
|
-
// Extract all values after "block merkle root" using a regular expression
|
|
225
|
-
const merkleRootMatches = [...infoResult.matchAll(/block merkle root ([a-f0-9]+)/gi)];
|
|
226
|
-
const merkleRoots = merkleRootMatches.map(match => match[1]);
|
|
227
|
-
// Group the values in a loop
|
|
228
|
-
result.attestationValues = [];
|
|
229
|
-
if (transactionIds.length === blockHeights.length && transactionIds.length === merkleRoots.length) {
|
|
230
|
-
for (let i = 0; i < transactionIds.length; i++) {
|
|
231
|
-
result.attestationValues.push({
|
|
232
|
-
blockHeight: blockHeights[i],
|
|
233
|
-
transactionId: transactionIds[i],
|
|
234
|
-
merkleRoot: merkleRoots[i]
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
// Sort the grouped values by blockHeight in ascending order
|
|
238
|
-
result.attestationValues.sort((a, b) => a.blockHeight - b.blockHeight);
|
|
239
|
-
}
|
|
240
|
-
return JSON.stringify(result);
|
|
241
|
-
}
|
|
242
|
-
// Parse the verifyResult into a TimestampInfo object
|
|
243
|
-
async function parseVerifyResult(verifyResult) {
|
|
244
|
-
let tsInfo = {
|
|
245
|
-
message: '',
|
|
246
|
-
results: [],
|
|
247
|
-
attestDate: null,
|
|
248
|
-
attestHeight: null,
|
|
249
|
-
submittedUri: null,
|
|
250
|
-
otsUpgraded: false
|
|
251
|
-
};
|
|
252
|
-
for (const chain in verifyResult?.results) {
|
|
253
|
-
let _results = verifyResult.results[chain];
|
|
254
|
-
const _date = (0, moment_timezone_1.default)(_results.timestamp * 1000)
|
|
255
|
-
.tz('UTC')
|
|
256
|
-
.format('MM-DD-YYYY hh:mma z');
|
|
257
|
-
const _blockchain = chain.charAt(0).toUpperCase() + chain.slice(1);
|
|
258
|
-
tsInfo.message = 'Validated - ' + _blockchain + ' block ' + _results.height + ' attests existence as of ' + _date;
|
|
259
|
-
if (tsInfo.attestHeight == null) {
|
|
260
|
-
tsInfo.attestDate = new Date(_results.timestamp * 1000);
|
|
261
|
-
tsInfo.attestHeight = _results.height;
|
|
262
|
-
}
|
|
263
|
-
tsInfo.results.push(tsInfo.message);
|
|
264
|
-
}
|
|
265
|
-
;
|
|
266
|
-
if (verifyResult?.upgradedOts) {
|
|
267
|
-
tsInfo.otsUpgraded = true;
|
|
268
|
-
tsInfo.results.push('Notice: Please select "Upgrade Timestamp" to save the upgraded timestamp.');
|
|
269
|
-
}
|
|
270
|
-
return tsInfo;
|
|
271
|
-
}
|
package/dist/shared/ZipKit.d.ts
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import ZipEntry from './ZipEntry';
|
|
2
|
-
import Errors from './constants/Errors';
|
|
3
|
-
import { LOCAL_HDR, ENCRYPT_HDR_SIZE, CMP_METHOD, CENTRAL_END, CENTRAL_DIR, ZIP64_CENTRAL_END, ZIP64_CENTRAL_DIR, GP_FLAG, TIMESTAMP_SUBMITTED, TIMESTAMP_METADATA, TOKENIZED_METADATA, LOCAL_FILE_HEADER, CENTRAL_FILE_HEADER, CENTRAL_DIRECTORY_END, HDR_ID } from './constants/Headers';
|
|
4
|
-
export { ZipEntry, Errors, CMP_METHOD, TIMESTAMP_METADATA, TIMESTAMP_SUBMITTED, TOKENIZED_METADATA, LOCAL_HDR, ENCRYPT_HDR_SIZE, CENTRAL_END, CENTRAL_DIR, ZIP64_CENTRAL_END, ZIP64_CENTRAL_DIR, GP_FLAG, LOCAL_FILE_HEADER, CENTRAL_FILE_HEADER, CENTRAL_DIRECTORY_END, HDR_ID };
|
|
5
|
-
/**
|
|
6
|
-
* Options for compressing files in a ZIP archive
|
|
7
|
-
*/
|
|
8
|
-
export interface CompressOptions {
|
|
9
|
-
level?: number;
|
|
10
|
-
password?: string | null;
|
|
11
|
-
useSHA256?: boolean;
|
|
12
|
-
useZstd?: boolean;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Callbacks for ZIP file creation process
|
|
16
|
-
*/
|
|
17
|
-
export interface CreateZipOptions {
|
|
18
|
-
onError?: (error: Error) => void;
|
|
19
|
-
onEntryDone?: (entry: ZipEntry, status: string) => void;
|
|
20
|
-
onReadEntryData?: (entry: ZipEntry) => Buffer;
|
|
21
|
-
onOutputBuffer?: (data: Buffer) => void;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Main class for ZIP file operations including compression, extraction, and encryption
|
|
25
|
-
*/
|
|
26
|
-
export default class ZipKit {
|
|
27
|
-
static readonly version: string;
|
|
28
|
-
static readonly releaseDate: string;
|
|
29
|
-
private inBuffer;
|
|
30
|
-
private zipEntries;
|
|
31
|
-
private sortName;
|
|
32
|
-
private centralDirSize;
|
|
33
|
-
private centralDirOffset;
|
|
34
|
-
private stampEntry;
|
|
35
|
-
zipComment: string | null;
|
|
36
|
-
static support: {
|
|
37
|
-
base64: boolean;
|
|
38
|
-
array: boolean;
|
|
39
|
-
string: boolean;
|
|
40
|
-
isNode: boolean;
|
|
41
|
-
buffer: boolean;
|
|
42
|
-
uint8array: boolean;
|
|
43
|
-
arrayBuffer: boolean;
|
|
44
|
-
blob: boolean;
|
|
45
|
-
streams: boolean;
|
|
46
|
-
fileReader: boolean;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Creates a new ZipKit instance
|
|
50
|
-
*/
|
|
51
|
-
constructor();
|
|
52
|
-
/**
|
|
53
|
-
* Resets all ZIP-related data to initial state
|
|
54
|
-
*/
|
|
55
|
-
resetZipData(): void;
|
|
56
|
-
/**
|
|
57
|
-
* Loads a ZIP file from a buffer
|
|
58
|
-
* @param inBuf - Buffer containing ZIP file data
|
|
59
|
-
*/
|
|
60
|
-
loadZip(inBuf: Buffer): void;
|
|
61
|
-
/**
|
|
62
|
-
* Tests if data matches the CRC32 checksum
|
|
63
|
-
* @param entry - ZIP entry to check
|
|
64
|
-
* @param data - Data buffer to verify
|
|
65
|
-
* @returns boolean indicating if CRC matches
|
|
66
|
-
*/
|
|
67
|
-
testCRC32(entry: ZipEntry, data: Buffer): boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Tests if data matches the SHA256 hash
|
|
70
|
-
* @param entry - ZIP entry to check
|
|
71
|
-
* @param data - Data buffer to verify
|
|
72
|
-
* @returns boolean indicating if SHA256 matches
|
|
73
|
-
* @throws Error if entry has no SHA256 hash
|
|
74
|
-
*/
|
|
75
|
-
testSHA256(entry: ZipEntry, data: Buffer): boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Locates and parses the central end directory
|
|
78
|
-
* @param inBuffer - Buffer containing ZIP file data
|
|
79
|
-
* @returns Number of entries in ZIP file
|
|
80
|
-
* @throws Error if central directory is invalid
|
|
81
|
-
*/
|
|
82
|
-
getCentralEnd(inBuffer: Buffer): number;
|
|
83
|
-
/**
|
|
84
|
-
* Creates the central end directory header
|
|
85
|
-
* @param centralDirSize - Size of central directory
|
|
86
|
-
* @param centralDirOffset - Offset to central directory
|
|
87
|
-
* @returns Buffer containing end directory header
|
|
88
|
-
*/
|
|
89
|
-
centralEndHdr(centralDirSize: number, centralDirOffset: number): Buffer;
|
|
90
|
-
/**
|
|
91
|
-
* Reads and parses the ZIP file directory
|
|
92
|
-
* @param debug - Enable debug logging
|
|
93
|
-
* @returns Array of ZIP entries
|
|
94
|
-
*/
|
|
95
|
-
getDirectory(debug?: boolean): ZipEntry[];
|
|
96
|
-
/**
|
|
97
|
-
* Gets a ZIP entry by filename
|
|
98
|
-
* @param fname - Filename to search for
|
|
99
|
-
* @returns ZipEntry if found, null otherwise
|
|
100
|
-
*/
|
|
101
|
-
getZipEntry(fname: string): ZipEntry | null;
|
|
102
|
-
/**
|
|
103
|
-
* Creates a new ZIP entry
|
|
104
|
-
* @param fname - Filename for new entry
|
|
105
|
-
* @param comment - Optional entry comment
|
|
106
|
-
* @returns Created ZipEntry
|
|
107
|
-
*/
|
|
108
|
-
createZipEntry(fname: string, comment?: string): ZipEntry;
|
|
109
|
-
/**
|
|
110
|
-
* Deletes an entry from the ZIP file
|
|
111
|
-
* @param fname - Filename to delete
|
|
112
|
-
* @returns boolean indicating if file was deleted
|
|
113
|
-
*/
|
|
114
|
-
deleteFile(fname: string): boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Parses local header and returns entry data
|
|
117
|
-
* @param entry - ZIP entry to parse
|
|
118
|
-
* @param withLocalHdrData - Include header in returned data
|
|
119
|
-
* @returns Buffer containing entry data
|
|
120
|
-
* @throws Error if header is invalid
|
|
121
|
-
*/
|
|
122
|
-
parseLocalHeader(entry: ZipEntry, withLocalHdrData?: boolean): Buffer;
|
|
123
|
-
/**
|
|
124
|
-
* Copies an entry's data from source ZIP
|
|
125
|
-
* @param entry - Entry to copy
|
|
126
|
-
* @returns Buffer containing entry data with headers
|
|
127
|
-
*/
|
|
128
|
-
copyEntry(entry: ZipEntry): Buffer;
|
|
129
|
-
/**
|
|
130
|
-
* Compresses data for a ZIP entry
|
|
131
|
-
* @param entry - ZIP entry to compress
|
|
132
|
-
* @param data - Data to compress
|
|
133
|
-
* @param options - Compression options
|
|
134
|
-
* @returns Buffer containing compressed data
|
|
135
|
-
*/
|
|
136
|
-
compressData(entry: ZipEntry, data: Buffer, options?: CompressOptions): Promise<Buffer>;
|
|
137
|
-
/**
|
|
138
|
-
* Compresses data using deflate algorithm
|
|
139
|
-
* @param inbuf - Data to compress
|
|
140
|
-
* @param options - Compression options
|
|
141
|
-
* @returns Compressed data buffer
|
|
142
|
-
*/
|
|
143
|
-
private deflate;
|
|
144
|
-
/**
|
|
145
|
-
* Compresses data using Zstandard (zstd) algorithm
|
|
146
|
-
* @param inbuf - Data to compress
|
|
147
|
-
* @param options - Compression options
|
|
148
|
-
* @returns Compressed data buffer
|
|
149
|
-
*/
|
|
150
|
-
private zstdCompress;
|
|
151
|
-
/**
|
|
152
|
-
* Decompresses data using Zstandard (zstd) algorithm
|
|
153
|
-
* @param inbuf - Compressed data buffer
|
|
154
|
-
* @returns Decompressed data buffer
|
|
155
|
-
*/
|
|
156
|
-
zstdDecompress(inbuf: Buffer): Promise<Buffer>;
|
|
157
|
-
/**
|
|
158
|
-
* Creates new Zip data file with the passed ZipEntries
|
|
159
|
-
* @param cmpOptions - Compression options
|
|
160
|
-
* @param zipOptions - Create ZIP options
|
|
161
|
-
* @returns Promise<number> - The offset of the last entry
|
|
162
|
-
*/
|
|
163
|
-
createZipFileData(cmpOptions?: CompressOptions, zipOptions?: CreateZipOptions): Promise<number>;
|
|
164
|
-
/**
|
|
165
|
-
* Finishes Zip data file by adding any Metadata entries and the Central End Directory
|
|
166
|
-
* @param offset - The current offset in the zip data file
|
|
167
|
-
* @param onOutputBuffer - The callback function to output the data buffer
|
|
168
|
-
* @param metaEntry - The Metadata ZipEntry to add to the Zip file
|
|
169
|
-
*/
|
|
170
|
-
finishZipFileData(offset: number, onOutputBuffer: (data: Buffer) => void, metaEntry?: ZipEntry): Promise<void>;
|
|
171
|
-
/**
|
|
172
|
-
* Unzips the data buffer using pako inflate method
|
|
173
|
-
* @param inbuf - Data buffer to inflate
|
|
174
|
-
* @returns Inflated data buffer
|
|
175
|
-
* @throws Error if extraction fails
|
|
176
|
-
*/
|
|
177
|
-
inflate(inbuf: Buffer): Buffer;
|
|
178
|
-
/**
|
|
179
|
-
* Extracts the data from the ZipEntry and returns the data as a Buffer
|
|
180
|
-
* @param entry - ZIP entry to extract
|
|
181
|
-
* @param skipHashCheck - Whether to skip hash checking
|
|
182
|
-
* @returns Buffer containing extracted data or null if extraction fails
|
|
183
|
-
*/
|
|
184
|
-
extract(entry: ZipEntry, skipHashCheck?: boolean): Promise<Buffer | null>;
|
|
185
|
-
/**
|
|
186
|
-
* Decrypts the entry data
|
|
187
|
-
* @param entry - ZIP entry to decrypt
|
|
188
|
-
* @param password - Password for decryption
|
|
189
|
-
* @returns Decrypted data buffer or null if decryption fails
|
|
190
|
-
*/
|
|
191
|
-
decryptEntry(entry: ZipEntry, password: string): Buffer | null;
|
|
192
|
-
/**
|
|
193
|
-
* Checks if a filename is a blockchain metadata file that should be excluded from Merkle Root calculation
|
|
194
|
-
* @param filename - The filename to check
|
|
195
|
-
* @returns boolean - True if the file is a metadata file
|
|
196
|
-
*/
|
|
197
|
-
private isMetadataFile;
|
|
198
|
-
/**
|
|
199
|
-
* Calculates the Merkle Root of the ZIP file
|
|
200
|
-
* Excludes blockchain metadata files (META-INF/*) to ensure consistent calculation
|
|
201
|
-
* @returns string - The Merkle Root of the ZIP file
|
|
202
|
-
*/
|
|
203
|
-
getMerkleRoot(): string | null;
|
|
204
|
-
/**
|
|
205
|
-
* Checks if a ZIP file contains valid timestamp metadata
|
|
206
|
-
* @returns { merkleRoot: string | null, ots: Buffer | null }
|
|
207
|
-
* Returns the merkle root hash and timestamp metadata if found, null otherwise
|
|
208
|
-
*/
|
|
209
|
-
checkForTimestamp(): string | null;
|
|
210
|
-
/**
|
|
211
|
-
* Gets the OTS from the timestamp metadata entry
|
|
212
|
-
* @returns Promise<Buffer | null> - The OTS from the timestamp metadata entry or null if not found
|
|
213
|
-
*/
|
|
214
|
-
getOts(): Promise<Buffer | null>;
|
|
215
|
-
/**
|
|
216
|
-
* Creates a new timestamp metadata entry for the ZIP file
|
|
217
|
-
* Calculates merkle root from file hashes and obtains blockchain timestamp
|
|
218
|
-
* @returns Promise<ZipEntry | null> The created timestamp metadata entry or null if failed
|
|
219
|
-
*/
|
|
220
|
-
createTimestampMetadataEntry(ots: Buffer | null): ZipEntry | null;
|
|
221
|
-
/**
|
|
222
|
-
* Sets the ZIP file comment
|
|
223
|
-
* @param msg - Comment to set
|
|
224
|
-
*/
|
|
225
|
-
setZipComment(msg: string | null): void;
|
|
226
|
-
/**
|
|
227
|
-
* Gets the ZIP file comment
|
|
228
|
-
* @returns string | null - The ZIP file comment
|
|
229
|
-
*/
|
|
230
|
-
getZipComment(): string | null;
|
|
231
|
-
/**
|
|
232
|
-
* Converts the compression method to a string
|
|
233
|
-
* @param cmpMethod - Compression method number
|
|
234
|
-
* @returns string - Compression method as a string
|
|
235
|
-
*/
|
|
236
|
-
cmpMethodToString(cmpMethod: number): string;
|
|
237
|
-
/**
|
|
238
|
-
* Ensures ZIP entries are loaded
|
|
239
|
-
* @returns Array of ZIP entries
|
|
240
|
-
* @throws Error if no ZIP entries are loaded
|
|
241
|
-
*/
|
|
242
|
-
private ensureZipEntries;
|
|
243
|
-
/**
|
|
244
|
-
* Ensures ZIP data buffer is loaded
|
|
245
|
-
* @returns Buffer containing ZIP data
|
|
246
|
-
* @throws Error if no ZIP data is loaded
|
|
247
|
-
*/
|
|
248
|
-
private ensureBuffer;
|
|
249
|
-
}
|