neozip-blockchain 0.5.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/LICENSE +22 -0
- package/README.md +189 -0
- package/dist/browser/TokenVerifierBrowser.d.ts +63 -0
- package/dist/browser/TokenVerifierBrowser.d.ts.map +1 -0
- package/dist/browser/TokenVerifierBrowser.js +358 -0
- package/dist/browser/TokenVerifierBrowser.js.map +1 -0
- package/dist/browser/WalletManagerBrowser.d.ts +99 -0
- package/dist/browser/WalletManagerBrowser.d.ts.map +1 -0
- package/dist/browser/WalletManagerBrowser.js +434 -0
- package/dist/browser/WalletManagerBrowser.js.map +1 -0
- package/dist/browser/ZipkitMinterBrowser.d.ts +59 -0
- package/dist/browser/ZipkitMinterBrowser.d.ts.map +1 -0
- package/dist/browser/ZipkitMinterBrowser.js +337 -0
- package/dist/browser/ZipkitMinterBrowser.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 +19 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/constants/index.d.ts +5 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +21 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/metadata.d.ts +18 -0
- package/dist/constants/metadata.d.ts.map +1 -0
- package/dist/constants/metadata.js +33 -0
- package/dist/constants/metadata.js.map +1 -0
- package/dist/constants/servers.d.ts +38 -0
- package/dist/constants/servers.d.ts.map +1 -0
- package/dist/constants/servers.js +54 -0
- package/dist/constants/servers.js.map +1 -0
- package/dist/core/ContractVersionRegistry.d.ts +63 -0
- package/dist/core/ContractVersionRegistry.d.ts.map +1 -0
- package/dist/core/ContractVersionRegistry.js +128 -0
- package/dist/core/ContractVersionRegistry.js.map +1 -0
- package/dist/core/WalletManager.d.ts +123 -0
- package/dist/core/WalletManager.d.ts.map +1 -0
- package/dist/core/WalletManager.js +360 -0
- package/dist/core/WalletManager.js.map +1 -0
- package/dist/core/ZipkitMinter.d.ts +155 -0
- package/dist/core/ZipkitMinter.d.ts.map +1 -0
- package/dist/core/ZipkitMinter.js +625 -0
- package/dist/core/ZipkitMinter.js.map +1 -0
- package/dist/core/ZipkitVerifier.d.ts +252 -0
- package/dist/core/ZipkitVerifier.d.ts.map +1 -0
- package/dist/core/ZipkitVerifier.js +1370 -0
- package/dist/core/ZipkitVerifier.js.map +1 -0
- package/dist/core/adapters/AdapterFactory.d.ts +22 -0
- package/dist/core/adapters/AdapterFactory.d.ts.map +1 -0
- package/dist/core/adapters/AdapterFactory.js +62 -0
- package/dist/core/adapters/AdapterFactory.js.map +1 -0
- package/dist/core/adapters/ContractVersionAdapter.d.ts +96 -0
- package/dist/core/adapters/ContractVersionAdapter.d.ts.map +1 -0
- package/dist/core/adapters/ContractVersionAdapter.js +9 -0
- package/dist/core/adapters/ContractVersionAdapter.js.map +1 -0
- package/dist/core/adapters/V2_10Adapter.d.ts +24 -0
- package/dist/core/adapters/V2_10Adapter.d.ts.map +1 -0
- package/dist/core/adapters/V2_10Adapter.js +87 -0
- package/dist/core/adapters/V2_10Adapter.js.map +1 -0
- package/dist/core/adapters/V2_11Adapter.d.ts +24 -0
- package/dist/core/adapters/V2_11Adapter.d.ts.map +1 -0
- package/dist/core/adapters/V2_11Adapter.js +87 -0
- package/dist/core/adapters/V2_11Adapter.js.map +1 -0
- package/dist/core/adapters/V2_50Adapter.d.ts +105 -0
- package/dist/core/adapters/V2_50Adapter.d.ts.map +1 -0
- package/dist/core/adapters/V2_50Adapter.js +263 -0
- package/dist/core/adapters/V2_50Adapter.js.map +1 -0
- package/dist/core/contracts.d.ts +169 -0
- package/dist/core/contracts.d.ts.map +1 -0
- package/dist/core/contracts.js +731 -0
- package/dist/core/contracts.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 +82 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/node/WalletManagerNode.d.ts +47 -0
- package/dist/node/WalletManagerNode.d.ts.map +1 -0
- package/dist/node/WalletManagerNode.js +203 -0
- package/dist/node/WalletManagerNode.js.map +1 -0
- package/dist/node/index.d.ts +12 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +21 -0
- package/dist/node/index.js.map +1 -0
- package/dist/ots/ZipkitOTS.d.ts +152 -0
- package/dist/ots/ZipkitOTS.d.ts.map +1 -0
- package/dist/ots/ZipkitOTS.js +544 -0
- package/dist/ots/ZipkitOTS.js.map +1 -0
- package/dist/ots/index.d.ts +9 -0
- package/dist/ots/index.d.ts.map +1 -0
- package/dist/ots/index.js +25 -0
- package/dist/ots/index.js.map +1 -0
- package/dist/types/index.d.ts +84 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +37 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/Logger.d.ts +73 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/dist/utils/Logger.js +156 -0
- package/dist/utils/Logger.js.map +1 -0
- package/dist/utils/crc32.d.ts +6 -0
- package/dist/utils/crc32.d.ts.map +1 -0
- package/dist/utils/crc32.js +23 -0
- package/dist/utils/crc32.js.map +1 -0
- package/dist/zipstamp-server/CalendarManager.d.ts +238 -0
- package/dist/zipstamp-server/CalendarManager.d.ts.map +1 -0
- package/dist/zipstamp-server/CalendarManager.js +364 -0
- package/dist/zipstamp-server/CalendarManager.js.map +1 -0
- package/dist/zipstamp-server/ZipstampServerAPI.d.ts +427 -0
- package/dist/zipstamp-server/ZipstampServerAPI.d.ts.map +1 -0
- package/dist/zipstamp-server/ZipstampServerAPI.js +696 -0
- package/dist/zipstamp-server/ZipstampServerAPI.js.map +1 -0
- package/dist/zipstamp-server/ZipstampServerClient.d.ts +590 -0
- package/dist/zipstamp-server/ZipstampServerClient.d.ts.map +1 -0
- package/dist/zipstamp-server/ZipstampServerClient.js +433 -0
- package/dist/zipstamp-server/ZipstampServerClient.js.map +1 -0
- package/dist/zipstamp-server/ZipstampServerHelpers.d.ts +430 -0
- package/dist/zipstamp-server/ZipstampServerHelpers.d.ts.map +1 -0
- package/dist/zipstamp-server/ZipstampServerHelpers.js +503 -0
- package/dist/zipstamp-server/ZipstampServerHelpers.js.map +1 -0
- package/dist/zipstamp-server/index.d.ts +24 -0
- package/dist/zipstamp-server/index.d.ts.map +1 -0
- package/dist/zipstamp-server/index.js +67 -0
- package/dist/zipstamp-server/index.js.map +1 -0
- package/package.json +117 -0
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ======================================
|
|
3
|
+
* ZipstampServerAPI.ts - Zipstamp Server API Integration
|
|
4
|
+
* ======================================
|
|
5
|
+
*
|
|
6
|
+
* This module provides timestamping functionality using the Zipstamp server API,
|
|
7
|
+
* similar to OpenTimestamps but using Ethereum blockchain.
|
|
8
|
+
*
|
|
9
|
+
* Key Features:
|
|
10
|
+
* - Ethereum blockchain timestamping via Zipstamp server
|
|
11
|
+
* - Merkle root calculation and verification
|
|
12
|
+
* - ZIP file integration for timestamp metadata
|
|
13
|
+
* - Support for immediate, batched, and transferable modes
|
|
14
|
+
*
|
|
15
|
+
* @fileoverview Zipstamp server API utilities for blockchain timestamping
|
|
16
|
+
* @author NeoWare Inc.
|
|
17
|
+
*/
|
|
18
|
+
import type { ZipkitLike, ZipEntryLike } from '../types';
|
|
19
|
+
import type { TimestampMetadata } from './ZipstampServerHelpers';
|
|
20
|
+
export declare const CMP_METHOD: {
|
|
21
|
+
STORED: number;
|
|
22
|
+
DEFLATED: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Timestamp metadata format stored in ZIP files
|
|
26
|
+
* Re-exported from ZipstampServerHelpers.ts
|
|
27
|
+
*/
|
|
28
|
+
export type { TimestampMetadata } from './ZipstampServerHelpers';
|
|
29
|
+
/**
|
|
30
|
+
* Verification result for timestamped ZIP files.
|
|
31
|
+
*
|
|
32
|
+
* Returned by `verifyTimestamp` and `verifyTimestampedZip` functions to indicate
|
|
33
|
+
* the verification status and provide blockchain details if confirmed.
|
|
34
|
+
*/
|
|
35
|
+
export interface EthTimestampVerifyResult {
|
|
36
|
+
status: 'none' | 'error' | 'pending' | 'valid';
|
|
37
|
+
verified?: boolean;
|
|
38
|
+
digest?: string;
|
|
39
|
+
tokenId?: string;
|
|
40
|
+
transactionHash?: string;
|
|
41
|
+
contractAddress?: string;
|
|
42
|
+
network?: string;
|
|
43
|
+
blockNumber?: number;
|
|
44
|
+
timestamp?: number;
|
|
45
|
+
message?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Options for creating timestamps.
|
|
49
|
+
*
|
|
50
|
+
* Configuration object passed to `createTimestamp` and `createTimestampedZip`
|
|
51
|
+
* functions to customize timestamp creation behavior.
|
|
52
|
+
*/
|
|
53
|
+
export interface CreateTimestampOptions {
|
|
54
|
+
mode?: 'immediate' | 'batched' | 'transferable';
|
|
55
|
+
recipientAddress?: string;
|
|
56
|
+
recipientEmail?: string;
|
|
57
|
+
metadata?: {
|
|
58
|
+
filename?: string;
|
|
59
|
+
fileSize?: number;
|
|
60
|
+
fileCount?: number;
|
|
61
|
+
};
|
|
62
|
+
serverUrl?: string;
|
|
63
|
+
debug?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Options for verifying timestamps.
|
|
67
|
+
*
|
|
68
|
+
* Configuration object passed to `verifyTimestamp` and `verifyTimestampedZip`
|
|
69
|
+
* functions to customize verification behavior.
|
|
70
|
+
*/
|
|
71
|
+
export interface VerifyTimestampOptions {
|
|
72
|
+
serverUrl?: string;
|
|
73
|
+
debug?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Finds the timestamp metadata entry in a ZIP file.
|
|
77
|
+
*
|
|
78
|
+
* Searches for timestamp metadata entries in the ZIP directory, preferring confirmed
|
|
79
|
+
* timestamps (TIMESTAMP.NZIP) over pending submissions (TS-SUBMIT.NZIP).
|
|
80
|
+
*
|
|
81
|
+
* @param zip - A ZipkitLike instance representing the ZIP file to search
|
|
82
|
+
* @returns The ZIP entry containing timestamp metadata, or `null` if not found
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const entry = getEthTimestampEntry(zipkit);
|
|
87
|
+
* if (entry) {
|
|
88
|
+
* const metadata = await extractTimestampData(zipkit, entry);
|
|
89
|
+
* console.log('Timestamp status:', metadata?.status);
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function getEthTimestampEntry(zip: ZipkitLike): ZipEntryLike | null;
|
|
94
|
+
/**
|
|
95
|
+
* Extracts timestamp metadata from a ZIP entry.
|
|
96
|
+
*
|
|
97
|
+
* Reads and parses the JSON metadata from a timestamp entry (either TIMESTAMP.NZIP
|
|
98
|
+
* or TS-SUBMIT.NZIP) in the ZIP file.
|
|
99
|
+
*
|
|
100
|
+
* @param zip - A ZipkitLike instance representing the ZIP file
|
|
101
|
+
* @param entry - The ZIP entry containing the timestamp metadata (from `getEthTimestampEntry`)
|
|
102
|
+
* @returns Parsed timestamp metadata object, or `null` if extraction fails
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const entry = getEthTimestampEntry(zipkit);
|
|
107
|
+
* if (entry) {
|
|
108
|
+
* const metadata = await extractTimestampData(zipkit, entry);
|
|
109
|
+
* if (metadata) {
|
|
110
|
+
* console.log('Digest:', metadata.digest);
|
|
111
|
+
* console.log('Batch ID:', metadata.batchId);
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare function extractTimestampData(zip: ZipkitLike, entry: ZipEntryLike): Promise<TimestampMetadata | null>;
|
|
117
|
+
/**
|
|
118
|
+
* Creates a timestamp by submitting a merkle root to the Zipstamp server.
|
|
119
|
+
*
|
|
120
|
+
* Submits a SHA-256 digest (merkle root) to the Zipstamp server API for blockchain
|
|
121
|
+
* timestamping. The digest is typically the merkle root of a ZIP file's contents.
|
|
122
|
+
*
|
|
123
|
+
* The function uses `submitDigest` internally and converts the response to a
|
|
124
|
+
* `TimestampMetadata` format suitable for storage in ZIP files.
|
|
125
|
+
*
|
|
126
|
+
* @param merkleRoot - A 64-character hexadecimal string representing the SHA-256 hash
|
|
127
|
+
* @param options - Configuration options for timestamp creation
|
|
128
|
+
* @param options.recipientEmail - Optional email address for notifications
|
|
129
|
+
* @param options.serverUrl - Optional Zipstamp server URL (defaults to `ZIPSTAMP_SERVER_URL` env var or `https://zipstamp-dev.neozip.io`)
|
|
130
|
+
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
131
|
+
* @param options.mode - **Deprecated**: For backward compatibility only, not sent to API
|
|
132
|
+
* @param options.recipientAddress - **Deprecated**: For backward compatibility only, not sent to API
|
|
133
|
+
* @param options.metadata - **Deprecated**: For backward compatibility only, not sent to API
|
|
134
|
+
* @returns Promise resolving to timestamp metadata, or `null` if creation fails
|
|
135
|
+
* @throws {Error} If merkle root format is invalid or API request fails
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const merkleRoot = 'a1b2c3d4e5f6...'; // 64-char hex string
|
|
140
|
+
* const metadata = await createTimestamp(merkleRoot, {
|
|
141
|
+
* recipientEmail: 'user@example.com',
|
|
142
|
+
* debug: true
|
|
143
|
+
* });
|
|
144
|
+
*
|
|
145
|
+
* if (metadata) {
|
|
146
|
+
* console.log('Timestamp created:', metadata.batchId);
|
|
147
|
+
* console.log('Status:', metadata.status); // 'pending' or 'confirmed'
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare function createTimestamp(merkleRoot: string, options?: CreateTimestampOptions): Promise<TimestampMetadata | null>;
|
|
152
|
+
/**
|
|
153
|
+
* Verifies a timestamp against the Zipstamp server.
|
|
154
|
+
*
|
|
155
|
+
* Verifies that a timestamp has been confirmed on the blockchain by checking
|
|
156
|
+
* with the Zipstamp server API. Uses `verifyDigest` internally and converts the
|
|
157
|
+
* response to an `EthTimestampVerifyResult` format.
|
|
158
|
+
*
|
|
159
|
+
* @param merkleRoot - The SHA-256 digest (merkle root) to verify
|
|
160
|
+
* @param timestampData - The timestamp metadata from the ZIP file (contains batchId, chainId, etc.)
|
|
161
|
+
* @param options - Configuration options for verification
|
|
162
|
+
* @param options.serverUrl - Optional Zipstamp server URL (defaults to `ZIPSTAMP_SERVER_URL` env var or `https://zipstamp-dev.neozip.io`)
|
|
163
|
+
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
164
|
+
* @returns Promise resolving to verification result with status and blockchain details
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const result = await verifyTimestamp(merkleRoot, timestampMetadata, {
|
|
169
|
+
* debug: true
|
|
170
|
+
* });
|
|
171
|
+
*
|
|
172
|
+
* if (result.status === 'valid') {
|
|
173
|
+
* console.log('Verified on blockchain!');
|
|
174
|
+
* console.log('Transaction:', result.transactionHash);
|
|
175
|
+
* console.log('Block:', result.blockNumber);
|
|
176
|
+
* } else if (result.status === 'pending') {
|
|
177
|
+
* console.log('Timestamp is pending confirmation');
|
|
178
|
+
* }
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
export declare function verifyTimestamp(merkleRoot: string, timestampData: TimestampMetadata, options?: VerifyTimestampOptions): Promise<EthTimestampVerifyResult>;
|
|
182
|
+
/**
|
|
183
|
+
* Verifies a timestamp within a ZIP file.
|
|
184
|
+
*
|
|
185
|
+
* Extracts the merkle root and timestamp metadata from a ZIP file, then verifies
|
|
186
|
+
* the timestamp against the Zipstamp server API. This is a convenience function that
|
|
187
|
+
* combines `getEthTimestampEntry`, `extractTimestampData`, and `verifyTimestamp`.
|
|
188
|
+
*
|
|
189
|
+
* @param zip - A ZipkitLike instance representing the timestamped ZIP file
|
|
190
|
+
* @param options - Configuration options for verification
|
|
191
|
+
* @param options.serverUrl - Optional Zipstamp server URL (defaults to `ZIPSTAMP_SERVER_URL` env var or `https://zipstamp-dev.neozip.io`)
|
|
192
|
+
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
193
|
+
* @returns Promise resolving to verification result
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const result = await verifyTimestampedZip(zipkit, { debug: true });
|
|
198
|
+
*
|
|
199
|
+
* switch (result.status) {
|
|
200
|
+
* case 'valid':
|
|
201
|
+
* console.log('✅ Timestamp verified on blockchain');
|
|
202
|
+
* break;
|
|
203
|
+
* case 'pending':
|
|
204
|
+
* console.log('⏳ Timestamp pending confirmation');
|
|
205
|
+
* break;
|
|
206
|
+
* case 'none':
|
|
207
|
+
* console.log('❌ No timestamp found in ZIP file');
|
|
208
|
+
* break;
|
|
209
|
+
* case 'error':
|
|
210
|
+
* console.log('❌ Verification error:', result.message);
|
|
211
|
+
* break;
|
|
212
|
+
* }
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export declare function verifyTimestampedZip(zip: ZipkitLike, options?: VerifyTimestampOptions): Promise<EthTimestampVerifyResult>;
|
|
216
|
+
/**
|
|
217
|
+
* Creates a ZIP entry containing timestamp metadata.
|
|
218
|
+
*
|
|
219
|
+
* Creates a ZIP entry object that can be added to a ZIP file. The entry contains
|
|
220
|
+
* the timestamp metadata as JSON. The filename is automatically chosen based on
|
|
221
|
+
* the timestamp status:
|
|
222
|
+
* - `TIMESTAMP.NZIP` for confirmed timestamps
|
|
223
|
+
* - `TS-SUBMIT.NZIP` for pending timestamps
|
|
224
|
+
*
|
|
225
|
+
* @param zipkit - A ZipkitLike instance for creating ZIP entries
|
|
226
|
+
* @param timestampMetadata - The timestamp metadata to embed in the ZIP entry
|
|
227
|
+
* @returns A ZIP entry object ready to be added to a ZIP file, or `null` if creation fails
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* // Create timestamp
|
|
232
|
+
* const metadata = await createTimestamp(merkleRoot);
|
|
233
|
+
*
|
|
234
|
+
* // Create ZIP entry
|
|
235
|
+
* const entry = createTimestampMetadataEntry(zipkit, metadata);
|
|
236
|
+
* if (entry) {
|
|
237
|
+
* // Add entry to ZIP file using zipkit methods
|
|
238
|
+
* zipkit.addEntry(entry);
|
|
239
|
+
* }
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
export declare function createTimestampMetadataEntry(zipkit: ZipkitLike, timestampMetadata: TimestampMetadata): any | null;
|
|
243
|
+
/**
|
|
244
|
+
* Creates timestamp metadata for a ZIP file.
|
|
245
|
+
*
|
|
246
|
+
* Extracts the merkle root from a ZIP file and submits it to the Zipstamp server
|
|
247
|
+
* for timestamping. Returns the timestamp metadata that can then be added to
|
|
248
|
+
* the ZIP file using `createTimestampMetadataEntry`.
|
|
249
|
+
*
|
|
250
|
+
* **Note**: This function does NOT modify the ZIP file. It only creates the
|
|
251
|
+
* timestamp metadata. You must use `createTimestampMetadataEntry` to create
|
|
252
|
+
* a ZIP entry and add it to your ZIP file.
|
|
253
|
+
*
|
|
254
|
+
* @param zipkit - A ZipkitLike instance representing the ZIP file to timestamp
|
|
255
|
+
* @param options - Configuration options for timestamp creation
|
|
256
|
+
* @param options.recipientEmail - Optional email address for notifications
|
|
257
|
+
* @param options.serverUrl - Optional Zipstamp server URL (defaults to `ZIPSTAMP_SERVER_URL` env var or `https://zipstamp-dev.neozip.io`)
|
|
258
|
+
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
259
|
+
* @returns Promise resolving to timestamp metadata, or `null` if creation fails
|
|
260
|
+
* @throws {Error} If merkle root is not found in ZIP or timestamp creation fails
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* // Create timestamp metadata
|
|
265
|
+
* const metadata = await createTimestampedZip(zipkit, {
|
|
266
|
+
* recipientEmail: 'user@example.com'
|
|
267
|
+
* });
|
|
268
|
+
*
|
|
269
|
+
* if (metadata) {
|
|
270
|
+
* // Create ZIP entry from metadata
|
|
271
|
+
* const entry = createTimestampMetadataEntry(zipkit, metadata);
|
|
272
|
+
* if (entry) {
|
|
273
|
+
* // Add entry to ZIP file
|
|
274
|
+
* zipkit.addEntry(entry);
|
|
275
|
+
* await zipkit.save('timestamped-file.nzip');
|
|
276
|
+
* }
|
|
277
|
+
* }
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
export declare function createTimestampedZip(zipkit: ZipkitLike, options?: CreateTimestampOptions): Promise<TimestampMetadata | null>;
|
|
281
|
+
/**
|
|
282
|
+
* ZIP entry type (from neozipkit).
|
|
283
|
+
*
|
|
284
|
+
* Type alias for neozipkit's internal ZipEntry type. Uses `any` to maintain
|
|
285
|
+
* compatibility with neozipkit's concrete ZipEntry shape while allowing these
|
|
286
|
+
* functions to work with entries from different sources.
|
|
287
|
+
*/
|
|
288
|
+
export type ZipEntry = any;
|
|
289
|
+
/**
|
|
290
|
+
* Metadata file type indicator.
|
|
291
|
+
*
|
|
292
|
+
* Indicates whether a timestamp metadata file represents a pending submission
|
|
293
|
+
* or a confirmed timestamp on the blockchain.
|
|
294
|
+
*/
|
|
295
|
+
export type MetadataType = 'pending' | 'confirmed' | null;
|
|
296
|
+
/**
|
|
297
|
+
* Result of finding a metadata entry in a ZIP file.
|
|
298
|
+
*
|
|
299
|
+
* Returned by `findMetadataEntry` to provide both the entry and its type
|
|
300
|
+
* for easier handling.
|
|
301
|
+
*/
|
|
302
|
+
export interface MetadataEntryResult {
|
|
303
|
+
entry: ZipEntry;
|
|
304
|
+
type: MetadataType;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Finds timestamp metadata entry in an array of ZIP directory entries.
|
|
308
|
+
*
|
|
309
|
+
* Searches through ZIP directory entries to find timestamp metadata files.
|
|
310
|
+
* Prefers confirmed timestamps (TIMESTAMP.NZIP) over pending submissions (TS-SUBMIT.NZIP).
|
|
311
|
+
* Returns both the entry and its type for easier handling.
|
|
312
|
+
*
|
|
313
|
+
* @param entries - Array of ZIP directory entries to search
|
|
314
|
+
* @returns Object containing the metadata entry and its type ('pending' | 'confirmed'), or `null` if not found
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```typescript
|
|
318
|
+
* const entries = zipkit.getDirectory(true);
|
|
319
|
+
* const result = findMetadataEntry(entries);
|
|
320
|
+
*
|
|
321
|
+
* if (result) {
|
|
322
|
+
* console.log('Found', result.type, 'timestamp');
|
|
323
|
+
* const metadata = await extractTimestampData(zipkit, result.entry);
|
|
324
|
+
* }
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
export declare function findMetadataEntry(entries: ZipEntry[]): MetadataEntryResult | null;
|
|
328
|
+
/**
|
|
329
|
+
* Determines the metadata type from a ZIP entry's filename.
|
|
330
|
+
*
|
|
331
|
+
* Examines the filename of a ZIP entry to determine if it's a timestamp metadata
|
|
332
|
+
* file and whether it represents a pending or confirmed timestamp.
|
|
333
|
+
*
|
|
334
|
+
* @param entry - The ZIP entry to examine (must have a `filename` property)
|
|
335
|
+
* @returns The metadata type: `'pending'` for TS-SUBMIT.NZIP, `'confirmed'` for TIMESTAMP.NZIP, or `null` if not a timestamp metadata file
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```typescript
|
|
339
|
+
* const entry = getEthTimestampEntry(zipkit);
|
|
340
|
+
* const type = getMetadataType(entry);
|
|
341
|
+
*
|
|
342
|
+
* if (type === 'pending') {
|
|
343
|
+
* console.log('Timestamp is pending confirmation');
|
|
344
|
+
* } else if (type === 'confirmed') {
|
|
345
|
+
* console.log('Timestamp is confirmed on blockchain');
|
|
346
|
+
* }
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
export declare function getMetadataType(entry: ZipEntry | null): MetadataType;
|
|
350
|
+
/**
|
|
351
|
+
* Determines if a timestamp metadata needs to be upgraded.
|
|
352
|
+
*
|
|
353
|
+
* Checks whether a timestamp should be upgraded from pending (TS-SUBMIT.NZIP) to
|
|
354
|
+
* confirmed (TIMESTAMP.NZIP) status. An upgrade is needed if:
|
|
355
|
+
* - The metadata file type is 'pending' (TS-SUBMIT.NZIP)
|
|
356
|
+
* - OR the metadata status is 'pending' (for backward compatibility)
|
|
357
|
+
* - OR the metadata lacks a transactionHash (not yet confirmed on blockchain)
|
|
358
|
+
*
|
|
359
|
+
* @param metadata - The timestamp metadata object to check
|
|
360
|
+
* @param metadataType - The type of metadata file ('pending' | 'confirmed' | null)
|
|
361
|
+
* @returns `true` if the timestamp should be upgraded, `false` otherwise
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```typescript
|
|
365
|
+
* const result = findMetadataEntry(entries);
|
|
366
|
+
* if (result && shouldUpgrade(metadata, result.type)) {
|
|
367
|
+
* console.log('Timestamp needs upgrade - batch may be confirmed now');
|
|
368
|
+
* // Call upgrade-zip script or pollForConfirmation
|
|
369
|
+
* }
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
export declare function shouldUpgrade(metadata: TimestampMetadata, metadataType: MetadataType): boolean;
|
|
373
|
+
/**
|
|
374
|
+
* Returns all timestamp metadata file names.
|
|
375
|
+
*
|
|
376
|
+
* Returns an array of all possible timestamp metadata filenames. Useful for
|
|
377
|
+
* error messages, validation, or filtering operations.
|
|
378
|
+
*
|
|
379
|
+
* @returns Array containing `['META-INF/TIMESTAMP.NZIP', 'META-INF/TS-SUBMIT.NZIP']`
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* ```typescript
|
|
383
|
+
* const metadataFiles = getMetadataFileNames();
|
|
384
|
+
* console.log('Looking for:', metadataFiles.join(', '));
|
|
385
|
+
*
|
|
386
|
+
* // Filter entries to exclude metadata files
|
|
387
|
+
* const dataEntries = entries.filter(
|
|
388
|
+
* entry => !metadataFiles.includes(entry.filename)
|
|
389
|
+
* );
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
export declare function getMetadataFileNames(): string[];
|
|
393
|
+
/**
|
|
394
|
+
* Verifies a Merkle proof locally using sorted pair hashing (keccak256).
|
|
395
|
+
*
|
|
396
|
+
* Performs local verification of a Merkle proof without requiring access to
|
|
397
|
+
* the Zipstamp server or blockchain. Uses the same sorted pair hashing algorithm
|
|
398
|
+
* as OpenZeppelin's MerkleProof library, ensuring compatibility with on-chain
|
|
399
|
+
* verification.
|
|
400
|
+
*
|
|
401
|
+
* This is useful for:
|
|
402
|
+
* - Verifying timestamps offline
|
|
403
|
+
* - Validating proofs before submitting to blockchain
|
|
404
|
+
* - Confirming proof integrity without API calls
|
|
405
|
+
*
|
|
406
|
+
* @param digest - The leaf digest (64-character hex string, bytes32) - typically the ZIP file's merkle root
|
|
407
|
+
* @param batchMerkleRoot - The root of the batch Merkle tree (64-character hex string, bytes32) stored on-chain
|
|
408
|
+
* @param merkleProof - Array of sibling hashes (each 64-character hex string, bytes32) forming the proof path from leaf to root
|
|
409
|
+
* @returns `true` if the proof is valid (digest is proven to be in the batch tree), `false` otherwise
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* ```typescript
|
|
413
|
+
* const isValid = verifyMerkleProofLocal(
|
|
414
|
+
* zipMerkleRoot, // Your ZIP file's merkle root
|
|
415
|
+
* batchMerkleRoot, // From TIMESTAMP.NZIP metadata
|
|
416
|
+
* merkleProof // From TIMESTAMP.NZIP metadata
|
|
417
|
+
* );
|
|
418
|
+
*
|
|
419
|
+
* if (isValid) {
|
|
420
|
+
* console.log('✅ Proof is valid - ZIP is in the confirmed batch');
|
|
421
|
+
* } else {
|
|
422
|
+
* console.log('❌ Proof is invalid');
|
|
423
|
+
* }
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
export declare function verifyMerkleProofLocal(digest: string, batchMerkleRoot: string, merkleProof: string[]): boolean;
|
|
427
|
+
//# sourceMappingURL=ZipstampServerAPI.d.ts.map
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