neozipkit 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +400 -0
- package/contracts/Lock.sol +34 -0
- package/contracts/bytecode.txt +1 -0
- package/contracts/compile-contract.js +168 -0
- package/contracts/deploy/deploy-both-contracts.js +286 -0
- package/contracts/deploy/deploy-enhanced-contract.js +197 -0
- package/contracts/deploy/deploy-private-contract.js +190 -0
- package/contracts/deploy/deploy-public-clean.js +1063 -0
- package/contracts/deploy/deploy-public-contract.js +1107 -0
- package/contracts/deployment.config.example.js +25 -0
- package/contracts/remix-compile.js +222 -0
- package/contracts/setup-deployment.js +51 -0
- package/contracts/src/NZIP-NFT-Private.sol +350 -0
- package/contracts/src/NZIP-NFT.sol +265 -0
- package/contracts/src/ZipFileNFT-DEPRECATED-6field.sol +260 -0
- package/contracts/src/ZipFileNFT-DEPRECATED-Enhanced.sol +289 -0
- package/dist/browser/CertificateGeneratorBrowser.d.ts +75 -0
- package/dist/browser/CertificateGeneratorBrowser.js +433 -0
- package/dist/browser/TokenVerifierBrowser.d.ts +76 -0
- package/dist/browser/TokenVerifierBrowser.js +299 -0
- package/dist/browser/ZipKitBrowser.d.ts +18 -0
- package/dist/browser/ZipKitBrowser.js +250 -0
- package/dist/browser/ZipKitStampBrowser.d.ts +2 -0
- package/dist/browser/ZipKitStampBrowser.js +12 -0
- package/dist/browser-index.d.ts +21 -0
- package/dist/browser-index.js +58 -0
- package/dist/browser.d.ts +21 -0
- package/dist/browser.js +58 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +76 -0
- package/dist/server/blockchain/CertificateToken.d.ts +48 -0
- package/dist/server/blockchain/CertificateToken.js +386 -0
- package/dist/server/blockchain/NFTMinter.d.ts +41 -0
- package/dist/server/blockchain/NFTMinter.js +323 -0
- package/dist/server/blockchain/TokenQuerier.d.ts +31 -0
- package/dist/server/blockchain/TokenQuerier.js +259 -0
- package/dist/server/blockchain/TokenVerifier.d.ts +20 -0
- package/dist/server/blockchain/TokenVerifier.js +395 -0
- package/dist/server/blockchain/WalletAnalyzer.d.ts +81 -0
- package/dist/server/blockchain/WalletAnalyzer.js +356 -0
- package/dist/server/blockchain/WalletFormatter.d.ts +39 -0
- package/dist/server/blockchain/WalletFormatter.js +196 -0
- package/dist/server/blockchain/WalletManager.d.ts +46 -0
- package/dist/server/blockchain/WalletManager.js +294 -0
- package/dist/server/blockchain/ZipMetadata.d.ts +27 -0
- package/dist/server/blockchain/ZipMetadata.js +131 -0
- package/dist/server/blockchain/ZipTokenProcessor.d.ts +44 -0
- package/dist/server/blockchain/ZipTokenProcessor.js +204 -0
- package/dist/server/blockchain/constants.d.ts +102 -0
- package/dist/server/blockchain/constants.js +968 -0
- package/dist/server/blockchain/index.d.ts +9 -0
- package/dist/server/blockchain/index.js +44 -0
- package/dist/server/blockchain/test-certificate.d.ts +8 -0
- package/dist/server/blockchain/test-certificate.js +100 -0
- package/dist/server/blockchain/types.d.ts +69 -0
- package/dist/server/blockchain/types.js +51 -0
- package/dist/server/platform/server/ZipKitServer.d.ts +105 -0
- package/dist/server/platform/server/ZipKitServer.js +437 -0
- package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +91 -0
- package/dist/server/platform/servercomponents/ZipKitOTS.js +271 -0
- package/dist/shared/ZipEntry.d.ts +131 -0
- package/dist/shared/ZipEntry.js +686 -0
- package/dist/shared/ZipKit.d.ts +249 -0
- package/dist/shared/ZipKit.js +789 -0
- package/dist/shared/components/CertificateOTS.d.ts +15 -0
- package/dist/shared/components/CertificateOTS.js +116 -0
- package/dist/shared/components/FileSys.d.ts +2 -0
- package/dist/shared/components/FileSys.js +113 -0
- package/dist/shared/components/HashAccumulator.d.ts +55 -0
- package/dist/shared/components/HashAccumulator.js +100 -0
- package/dist/shared/components/Support.d.ts +63 -0
- package/dist/shared/components/Support.js +70 -0
- package/dist/shared/components/Util.d.ts +21 -0
- package/dist/shared/components/Util.js +115 -0
- package/dist/shared/components/ZipCrypto.d.ts +3 -0
- package/dist/shared/components/ZipCrypto.js +78 -0
- package/dist/shared/components/merkleTree.d.ts +66 -0
- package/dist/shared/components/merkleTree.js +136 -0
- package/dist/shared/constants/Errors.d.ts +53 -0
- package/dist/shared/constants/Errors.js +69 -0
- package/dist/shared/constants/Headers.d.ts +167 -0
- package/dist/shared/constants/Headers.js +191 -0
- package/dist/shared/types/index.d.ts +21 -0
- package/dist/shared/types/index.js +3 -0
- package/dist/shared/types.d.ts +33 -0
- package/dist/shared/types.js +8 -0
- package/dist/shared/version.d.ts +4 -0
- package/dist/shared/version.js +7 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/index.js +3 -0
- package/examples/unzip-token.ts +488 -0
- package/examples/zip-token.ts +604 -0
- package/package.json +117 -0
- package/src/browser/CertificateGeneratorBrowser.ts +498 -0
- package/src/browser/TokenVerifierBrowser.ts +344 -0
- package/src/browser/ZipKitBrowser.ts +242 -0
- package/src/browser/ZipKitStampBrowser.ts +9 -0
- package/src/browser-index.ts +36 -0
- package/src/index.ts +48 -0
- package/src/server/blockchain/CertificateToken.ts +444 -0
- package/src/server/blockchain/NFTMinter.ts +357 -0
- package/src/server/blockchain/TokenQuerier.ts +287 -0
- package/src/server/blockchain/TokenVerifier.ts +453 -0
- package/src/server/blockchain/WalletAnalyzer.ts +397 -0
- package/src/server/blockchain/WalletFormatter.ts +206 -0
- package/src/server/blockchain/WalletManager.ts +294 -0
- package/src/server/blockchain/ZipMetadata.ts +117 -0
- package/src/server/blockchain/ZipTokenProcessor.ts +234 -0
- package/src/server/blockchain/constants.ts +969 -0
- package/src/server/blockchain/index.ts +42 -0
- package/src/server/blockchain/test-certificate.ts +137 -0
- package/src/server/blockchain/types.ts +134 -0
- package/src/server/platform/server/ZipKitServer.ts +459 -0
- package/src/server/platform/servercomponents/ZipKitOTS.ts +313 -0
- package/src/server/platform/servercomponents/opentimestamps.d.ts +23 -0
- package/src/shared/ZipEntry.ts +767 -0
- package/src/shared/ZipKit.ts +899 -0
- package/src/shared/components/CertificateOTS.ts +132 -0
- package/src/shared/components/FileSys.ts +87 -0
- package/src/shared/components/HashAccumulator.ts +113 -0
- package/src/shared/components/Support.ts +77 -0
- package/src/shared/components/Util.ts +113 -0
- package/src/shared/components/ZipCrypto.ts +91 -0
- package/src/shared/components/merkleTree.ts +162 -0
- package/src/shared/constants/Errors.ts +82 -0
- package/src/shared/constants/Headers.ts +203 -0
- package/src/shared/types/index.ts +25 -0
- package/src/shared/types/modules.d.ts +22 -0
- package/src/shared/types/opentimestamps.d.ts +23 -0
- package/src/shared/types.d.ts +8 -0
- package/src/shared/types.ts +43 -0
- package/src/shared/version.ts +4 -0
- package/src/types/index.ts +25 -0
- package/src/types/modules.d.ts +22 -0
- package/src/types/opentimestamps.d.ts +23 -0
|
@@ -0,0 +1,271 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { ZipFileEntry, FileData } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Class representing a single entry (file or directory) within a ZIP archive
|
|
4
|
+
*/
|
|
5
|
+
export default class ZipEntry implements ZipFileEntry {
|
|
6
|
+
debug: boolean;
|
|
7
|
+
verMadeBy: number;
|
|
8
|
+
verExtract: number;
|
|
9
|
+
bitFlags: number;
|
|
10
|
+
cmpMethod: number;
|
|
11
|
+
timeDateDOS: number;
|
|
12
|
+
crc: number;
|
|
13
|
+
compressedSize: number;
|
|
14
|
+
uncompressedSize: number;
|
|
15
|
+
volNumber: number;
|
|
16
|
+
intFileAttr: number;
|
|
17
|
+
extFileAttr: number;
|
|
18
|
+
localHdrOffset: number;
|
|
19
|
+
filename: string;
|
|
20
|
+
extraField: Buffer | null;
|
|
21
|
+
comment: string | null;
|
|
22
|
+
fileBuffer: Buffer | null;
|
|
23
|
+
cmpData: Buffer | null;
|
|
24
|
+
isEncrypted: boolean;
|
|
25
|
+
isStrongEncrypt: boolean;
|
|
26
|
+
encryptHdr: Buffer | null;
|
|
27
|
+
lastModTimeDate: number;
|
|
28
|
+
decrypt: Function | null;
|
|
29
|
+
isUpdated: boolean;
|
|
30
|
+
isDirectory: boolean;
|
|
31
|
+
isMetaData: boolean;
|
|
32
|
+
platform: string | null;
|
|
33
|
+
universalTime: number | null;
|
|
34
|
+
uid: number | null;
|
|
35
|
+
gid: number | null;
|
|
36
|
+
sha256: string | null;
|
|
37
|
+
fileData?: FileData;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new ZIP entry
|
|
40
|
+
* @param fname - Name of the file within the ZIP
|
|
41
|
+
* @param comment - Optional comment for this entry
|
|
42
|
+
* @param debug - Enable debug logging
|
|
43
|
+
*/
|
|
44
|
+
constructor(fname: string | null, comment?: string | null, debug?: boolean);
|
|
45
|
+
isMSDOS: boolean;
|
|
46
|
+
isUnixLike: boolean;
|
|
47
|
+
isMacOS: boolean;
|
|
48
|
+
isLinux: boolean;
|
|
49
|
+
VER_MADE_BY: number;
|
|
50
|
+
/**
|
|
51
|
+
* Reads ZIP entry data from a central directory buffer
|
|
52
|
+
* @param data - Buffer containing central directory entry data
|
|
53
|
+
* @returns Buffer positioned at start of next entry
|
|
54
|
+
* @throws Error if central directory entry is invalid
|
|
55
|
+
*/
|
|
56
|
+
readZipEntry(data: Buffer): Buffer;
|
|
57
|
+
/**
|
|
58
|
+
* Checks if the filename contains characters that require Unicode handling
|
|
59
|
+
* @returns true if the filename contains non-ASCII characters or special characters
|
|
60
|
+
*/
|
|
61
|
+
needsUnicodeHandling(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Adds UTF-8 Unicode Path field to a buffer
|
|
64
|
+
* @param buffer - The buffer to write to
|
|
65
|
+
* @param offset - The offset in the buffer to start writing
|
|
66
|
+
* @returns The new offset after writing
|
|
67
|
+
*/
|
|
68
|
+
private addUnicodePathField;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a local header for this ZIP entry
|
|
71
|
+
* @returns Buffer containing the local header data
|
|
72
|
+
*/
|
|
73
|
+
createLocalHdr(): Buffer;
|
|
74
|
+
/**
|
|
75
|
+
* Creates a central directory entry for this ZIP entry
|
|
76
|
+
* @returns Buffer containing the central directory entry data
|
|
77
|
+
*/
|
|
78
|
+
centralDirEntry(): Buffer;
|
|
79
|
+
/**
|
|
80
|
+
* Sets the DOS date/time for this entry
|
|
81
|
+
* @param date - Date to convert to DOS format
|
|
82
|
+
* @returns number - DOS format date/time
|
|
83
|
+
*/
|
|
84
|
+
setDateTime(date: Date): number;
|
|
85
|
+
/**
|
|
86
|
+
* Converts DOS date/time to JavaScript Date
|
|
87
|
+
* @param timeStamp - DOS format date/time
|
|
88
|
+
* @returns Date object or null if timestamp is 0
|
|
89
|
+
*/
|
|
90
|
+
parseDateTime(timeStamp: number): Date | null;
|
|
91
|
+
/**
|
|
92
|
+
* Formats the entry's date in local format
|
|
93
|
+
* @returns String in MM/DD/YYYY format or "--/--/----" if no date
|
|
94
|
+
*/
|
|
95
|
+
toLocalDateString(): string;
|
|
96
|
+
/**
|
|
97
|
+
* Formats the entry's time
|
|
98
|
+
* @returns String in HH:MM format or "--:--" if no time
|
|
99
|
+
*/
|
|
100
|
+
toTimeString(): string;
|
|
101
|
+
/**
|
|
102
|
+
* Formats the entry's date and time in local format
|
|
103
|
+
* @returns String like "Jan 01, 2024 13:45:30" or "--/--/-- --:--" if no date/time
|
|
104
|
+
*/
|
|
105
|
+
toFormattedDateString(): string;
|
|
106
|
+
/**
|
|
107
|
+
* Formats the entry's date and time in UTC
|
|
108
|
+
* @returns String like "Jan 01, 2024 13:45:30 UTC" or "--/--/-- --:--" if no date/time
|
|
109
|
+
*/
|
|
110
|
+
toFormattedUTCDateString(): string;
|
|
111
|
+
/**
|
|
112
|
+
* Converts compression method code to human-readable string
|
|
113
|
+
* @returns String describing the compression method
|
|
114
|
+
*/
|
|
115
|
+
cmpMethodToString(): string;
|
|
116
|
+
/**
|
|
117
|
+
* Converts file system code to human-readable string
|
|
118
|
+
* @returns String describing the file system
|
|
119
|
+
*/
|
|
120
|
+
fileSystemToString(): string;
|
|
121
|
+
/**
|
|
122
|
+
* Converts MS-DOS file attributes to string representation
|
|
123
|
+
* @returns String like "----" where R=readonly, H=hidden, S=system, A=archive
|
|
124
|
+
*/
|
|
125
|
+
private dosAttributesToString;
|
|
126
|
+
/**
|
|
127
|
+
* Outputs detailed information about this entry for debugging
|
|
128
|
+
* Includes compression, encryption, timestamps, and extra fields
|
|
129
|
+
*/
|
|
130
|
+
showVerboseInfo(): void;
|
|
131
|
+
}
|