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,433 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Zipstamp Server API Client
|
|
4
|
+
*
|
|
5
|
+
* Client for interacting with the Zipstamp server API endpoints.
|
|
6
|
+
* Provides methods for timestamping, verification, batch processing, and token transfers.
|
|
7
|
+
*
|
|
8
|
+
* **Authentication:**
|
|
9
|
+
* - Verification endpoints are PUBLIC (no API key required)
|
|
10
|
+
* - Stamping requires a verified email in the request body (no API key)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const client = new ZipstampServerClient({ serverUrl: 'https://calendar.neozip.io' });
|
|
15
|
+
* const result = await client.verify({ digest: '...' });
|
|
16
|
+
* const stamp = await client.stamp({ digest: '...', email: 'user@example.com' });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.ZipstampServerClient = void 0;
|
|
21
|
+
const servers_1 = require("../constants/servers");
|
|
22
|
+
/**
|
|
23
|
+
* Client for interacting with the Zipstamp server API.
|
|
24
|
+
*
|
|
25
|
+
* Provides low-level methods for all Zipstamp server endpoints including timestamping,
|
|
26
|
+
* verification, batch operations, transfers, and NFT proof minting. This is the
|
|
27
|
+
* base client that higher-level convenience functions (in ZipstampServerHelpers) wrap.
|
|
28
|
+
*
|
|
29
|
+
* **Features:**
|
|
30
|
+
* - Automatic retry with exponential backoff
|
|
31
|
+
* - Configurable timeouts
|
|
32
|
+
* - Type-safe request/response handling
|
|
33
|
+
* - Support for all Zipstamp server endpoints
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // Create client with custom settings
|
|
38
|
+
* const client = new ZipstampServerClient({
|
|
39
|
+
* serverUrl: 'https://Zipstamp server.example.com',
|
|
40
|
+
* timeout: 60000, // 60 seconds
|
|
41
|
+
* retries: 5,
|
|
42
|
+
* retryDelay: 2000 // 2 seconds
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* // Submit a digest
|
|
46
|
+
* const response = await client.stamp({
|
|
47
|
+
* digest: 'a1b2c3d4e5f6...',
|
|
48
|
+
* email: 'user@example.com',
|
|
49
|
+
* chainId: 84532
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
class ZipstampServerClient {
|
|
54
|
+
constructor(options = {}) {
|
|
55
|
+
this.serverUrl = (0, servers_1.getZipStampServerUrl)({ serverUrl: options.serverUrl });
|
|
56
|
+
this.timeout = options.timeout || 30000; // 30 seconds
|
|
57
|
+
this.retries = options.retries || 3;
|
|
58
|
+
this.retryDelay = options.retryDelay || 1000; // 1 second
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the current server URL
|
|
62
|
+
*/
|
|
63
|
+
getServerUrl() {
|
|
64
|
+
return this.serverUrl;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Make HTTP request with retry logic
|
|
68
|
+
*/
|
|
69
|
+
async request(method, path, body) {
|
|
70
|
+
const url = `${this.serverUrl}${path}`;
|
|
71
|
+
let lastError = null;
|
|
72
|
+
for (let attempt = 0; attempt <= this.retries; attempt++) {
|
|
73
|
+
try {
|
|
74
|
+
const controller = new AbortController();
|
|
75
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
76
|
+
const headers = {
|
|
77
|
+
'Content-Type': 'application/json',
|
|
78
|
+
};
|
|
79
|
+
const options = {
|
|
80
|
+
method,
|
|
81
|
+
headers,
|
|
82
|
+
signal: controller.signal,
|
|
83
|
+
};
|
|
84
|
+
if (body) {
|
|
85
|
+
options.body = JSON.stringify(body);
|
|
86
|
+
}
|
|
87
|
+
const response = await fetch(url, options);
|
|
88
|
+
clearTimeout(timeoutId);
|
|
89
|
+
if (!response.ok) {
|
|
90
|
+
const errorData = await response.json().catch(() => ({}));
|
|
91
|
+
throw new Error(errorData.error || `HTTP ${response.status}: ${response.statusText}`);
|
|
92
|
+
}
|
|
93
|
+
return await response.json();
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
97
|
+
// Don't retry on abort (timeout) or if it's the last attempt
|
|
98
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
99
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
100
|
+
}
|
|
101
|
+
if (attempt < this.retries) {
|
|
102
|
+
// Exponential backoff
|
|
103
|
+
const delay = this.retryDelay * Math.pow(2, attempt);
|
|
104
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
throw lastError || new Error('Request failed after retries');
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Retrieves calendar server information.
|
|
112
|
+
*
|
|
113
|
+
* Gets metadata about the Zipstamp server calendar including URI, donation address,
|
|
114
|
+
* version, network, and contract address.
|
|
115
|
+
*
|
|
116
|
+
* @returns Promise resolving to calendar information
|
|
117
|
+
*/
|
|
118
|
+
async getCalendarInfo() {
|
|
119
|
+
return this.request('GET', '/calendar/info');
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Creates a timestamp by submitting a digest to the Zipstamp server.
|
|
123
|
+
*
|
|
124
|
+
* Submits a SHA-256 digest (merkle root) to be included in the next batch for
|
|
125
|
+
* blockchain timestamping. The digest is typically the merkle root of a ZIP file.
|
|
126
|
+
*
|
|
127
|
+
* **Note:** Only `digest`, `chainId`, and `email` are sent to the API. Other
|
|
128
|
+
* fields in `StampRequest` are for backward compatibility only.
|
|
129
|
+
*
|
|
130
|
+
* @param request - Stamp request containing digest and optional metadata
|
|
131
|
+
* @param request.digest - SHA-256 hash as 64-character hex string (required)
|
|
132
|
+
* @param request.chainId - Optional chain ID hint
|
|
133
|
+
* @param request.email - Optional email address for notifications
|
|
134
|
+
* @returns Promise resolving to stamp response with batch information
|
|
135
|
+
* @throws {Error} If request fails or server returns error
|
|
136
|
+
*/
|
|
137
|
+
async stamp(request) {
|
|
138
|
+
// Zipstamp server expects { digest, chainId, email } and rejects unknown fields in strict validators.
|
|
139
|
+
const body = {
|
|
140
|
+
digest: request.digest,
|
|
141
|
+
chainId: request.chainId,
|
|
142
|
+
email: request.email ?? request.recipientEmail,
|
|
143
|
+
};
|
|
144
|
+
return this.request('POST', '/stamp', body);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Gets the status of a pending stamp by digest.
|
|
148
|
+
*
|
|
149
|
+
* Queries the Zipstamp server for the current status of a submitted digest,
|
|
150
|
+
* including batch information and confirmation status.
|
|
151
|
+
*
|
|
152
|
+
* @param digest - SHA-256 digest (64-character hex string) to check
|
|
153
|
+
* @returns Promise resolving to stamp status response
|
|
154
|
+
* @throws {Error} If digest format is invalid or request fails
|
|
155
|
+
*/
|
|
156
|
+
async getStampStatus(digest) {
|
|
157
|
+
if (!/^[a-f0-9]{64}$/i.test(digest)) {
|
|
158
|
+
throw new Error('Invalid digest format. Must be a 64-character hex string (SHA-256)');
|
|
159
|
+
}
|
|
160
|
+
return this.request('GET', `/stamp/${digest}`);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Verifies a timestamp by checking with the Zipstamp server.
|
|
164
|
+
*
|
|
165
|
+
* Verifies whether a digest has been confirmed on the blockchain. Returns
|
|
166
|
+
* detailed information including transaction hash, block number, and merkle proof
|
|
167
|
+
* if the timestamp is confirmed.
|
|
168
|
+
*
|
|
169
|
+
* **Note:** Only `digest`, `chainId`, and `batchId` are sent to the API.
|
|
170
|
+
* The `tokenId` field is for backward compatibility only.
|
|
171
|
+
*
|
|
172
|
+
* @param request - Verify request containing digest and optional hints
|
|
173
|
+
* @param request.digest - SHA-256 digest (64-character hex string) to verify (required)
|
|
174
|
+
* @param request.chainId - Optional chain ID hint
|
|
175
|
+
* @param request.batchId - Optional batch ID hint to help disambiguate
|
|
176
|
+
* @returns Promise resolving to verification response with status and blockchain details
|
|
177
|
+
* @throws {Error} If request fails or server returns error
|
|
178
|
+
*/
|
|
179
|
+
async verify(request) {
|
|
180
|
+
// Zipstamp server expects { digest, chainId, batchId } and rejects unknown fields in strict validators.
|
|
181
|
+
const body = {
|
|
182
|
+
digest: request.digest,
|
|
183
|
+
chainId: request.chainId,
|
|
184
|
+
batchId: request.batchId,
|
|
185
|
+
};
|
|
186
|
+
return this.request('POST', '/verify', body);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Verifies a Merkle proof directly on-chain via Zipstamp server (no database access).
|
|
190
|
+
*
|
|
191
|
+
* Performs on-chain verification of a Merkle proof without requiring database
|
|
192
|
+
* access. Useful for verifying proofs from confirmed timestamps that may have
|
|
193
|
+
* been removed from the server's database.
|
|
194
|
+
*
|
|
195
|
+
* Maps to `POST /verify-proof` endpoint.
|
|
196
|
+
*
|
|
197
|
+
* @param request - Proof verification request
|
|
198
|
+
* @param request.digest - Leaf digest (64-character hex string, bytes32)
|
|
199
|
+
* @param request.merkleProof - Array of sibling hashes (each 64-character hex string, bytes32)
|
|
200
|
+
* @param request.merkleRoot - Batch Merkle root (64-character hex string, bytes32)
|
|
201
|
+
* @param request.chainId - Chain ID for the network (required)
|
|
202
|
+
* @param request.contractAddress - Optional contract address hint
|
|
203
|
+
* @param request.transactionHash - Optional transaction hash hint
|
|
204
|
+
* @returns Promise resolving to proof verification result
|
|
205
|
+
*/
|
|
206
|
+
async verifyProof(request) {
|
|
207
|
+
return this.request('POST', '/verify-proof', request);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Verifies a timestamp by digest using GET method.
|
|
211
|
+
*
|
|
212
|
+
* Alternative verification endpoint using HTTP GET instead of POST.
|
|
213
|
+
* Useful for simple verification without needing to construct a request body.
|
|
214
|
+
*
|
|
215
|
+
* @param digest - SHA-256 digest (64-character hex string) to verify
|
|
216
|
+
* @returns Promise resolving to verification response
|
|
217
|
+
* @throws {Error} If digest format is invalid or request fails
|
|
218
|
+
*/
|
|
219
|
+
async verifyByDigest(digest) {
|
|
220
|
+
if (!/^[a-f0-9]{64}$/i.test(digest)) {
|
|
221
|
+
throw new Error('Invalid digest format. Must be a 64-character hex string (SHA-256)');
|
|
222
|
+
}
|
|
223
|
+
return this.request('GET', `/verify/${digest}`);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Queues a hash for batch processing.
|
|
227
|
+
*
|
|
228
|
+
* Adds a digest to the batch queue for later processing. Batches are processed
|
|
229
|
+
* periodically and submitted to the blockchain as a single transaction.
|
|
230
|
+
*
|
|
231
|
+
* @param request - Batch queue request
|
|
232
|
+
* @param request.digest - SHA-256 digest (64-character hex string) to queue
|
|
233
|
+
* @param request.metadata - Optional metadata about the file being timestamped
|
|
234
|
+
* @returns Promise resolving to batch queue response
|
|
235
|
+
*/
|
|
236
|
+
async queueBatch(request) {
|
|
237
|
+
return this.request('POST', '/batch/queue', request);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Gets batch status and included hashes.
|
|
241
|
+
*
|
|
242
|
+
* Retrieves detailed information about a batch including its status, merkle root,
|
|
243
|
+
* transaction hash (if confirmed), and all hashes included in the batch.
|
|
244
|
+
*
|
|
245
|
+
* @param batchId - The batch ID to query (e.g., 'base-sep-v0.90-n7')
|
|
246
|
+
* @returns Promise resolving to batch status response with batch details and included hashes
|
|
247
|
+
*/
|
|
248
|
+
async getBatchStatus(batchId) {
|
|
249
|
+
return this.request('GET', `/batch/${batchId}`);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Manually triggers batch processing (admin endpoint).
|
|
253
|
+
*
|
|
254
|
+
* Forces the Zipstamp server to process pending batches immediately. This is
|
|
255
|
+
* typically an admin-only operation and may require authentication.
|
|
256
|
+
*
|
|
257
|
+
* @returns Promise resolving to batch status response
|
|
258
|
+
*/
|
|
259
|
+
async processBatch() {
|
|
260
|
+
return this.request('POST', '/batch/process', {});
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Transfers a token to a user address.
|
|
264
|
+
*
|
|
265
|
+
* Transfers ownership of a timestamp token (NFT) to another address. Requires
|
|
266
|
+
* either a `tokenId` or `digest` to identify the token.
|
|
267
|
+
*
|
|
268
|
+
* @param request - Transfer request
|
|
269
|
+
* @param request.tokenId - Token ID to transfer (optional if digest provided)
|
|
270
|
+
* @param request.digest - Digest associated with token (optional if tokenId provided)
|
|
271
|
+
* @param request.recipientAddress - Ethereum address to transfer token to (required)
|
|
272
|
+
* @returns Promise resolving to transfer response with transaction hash
|
|
273
|
+
*/
|
|
274
|
+
async transfer(request) {
|
|
275
|
+
return this.request('POST', '/transfer', request);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Gets server status and health check information.
|
|
279
|
+
*
|
|
280
|
+
* Retrieves current server status including network, contract address, server
|
|
281
|
+
* wallet address, balance, and timestamp. Useful for health checks and monitoring.
|
|
282
|
+
*
|
|
283
|
+
* @returns Promise resolving to server status information
|
|
284
|
+
*/
|
|
285
|
+
async getStatus() {
|
|
286
|
+
return this.request('GET', '/status');
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Gets NFT contract information.
|
|
290
|
+
*
|
|
291
|
+
* Retrieves details about the TimestampProofNFT contract for a given network,
|
|
292
|
+
* including contract address, registry address, minting fee, version, and total supply.
|
|
293
|
+
*
|
|
294
|
+
* Maps to `GET /nft/contract-info` endpoint.
|
|
295
|
+
*
|
|
296
|
+
* @param chainId - Optional chain ID hint (if not provided, server uses default network)
|
|
297
|
+
* @returns Promise resolving to NFT contract information response
|
|
298
|
+
*/
|
|
299
|
+
async getNFTContractInfo(chainId) {
|
|
300
|
+
const qs = new URLSearchParams();
|
|
301
|
+
if (chainId)
|
|
302
|
+
qs.set('chainId', String(chainId));
|
|
303
|
+
const path = qs.toString() ? `/nft/contract-info?${qs.toString()}` : '/nft/contract-info';
|
|
304
|
+
return this.request('GET', path);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Checks if a digest has been minted as an NFT-proof token.
|
|
308
|
+
*
|
|
309
|
+
* Queries the Zipstamp server to determine if a digest has been minted as an NFT
|
|
310
|
+
* on the TimestampProofNFT contract. Returns token information if minted.
|
|
311
|
+
*
|
|
312
|
+
* Maps to `GET /nft/status` endpoint.
|
|
313
|
+
*
|
|
314
|
+
* @param digest - SHA-256 digest (64-character hex string) to check
|
|
315
|
+
* @param chainId - Optional chain ID hint
|
|
316
|
+
* @returns Promise resolving to NFT status response indicating if minted and token details
|
|
317
|
+
*/
|
|
318
|
+
async checkNFTStatus(digest, chainId) {
|
|
319
|
+
const qs = new URLSearchParams({ digest });
|
|
320
|
+
if (chainId)
|
|
321
|
+
qs.set('chainId', String(chainId));
|
|
322
|
+
return this.request('GET', `/nft/status?${qs.toString()}`);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Prepares mint data for NFT-proof token minting.
|
|
326
|
+
*
|
|
327
|
+
* Retrieves all data needed to call `mintProof()` on the TimestampProofNFT contract,
|
|
328
|
+
* including merkle proof, batch information, contract addresses, and minting fee.
|
|
329
|
+
*
|
|
330
|
+
* Maps to `GET /nft/prepare-mint` endpoint.
|
|
331
|
+
*
|
|
332
|
+
* @param digest - SHA-256 digest (64-character hex string) to prepare mint data for
|
|
333
|
+
* @param chainId - Optional chain ID hint
|
|
334
|
+
* @param batchId - Optional batch ID from TIMESTAMP.NZIP metadata to ensure correct batch
|
|
335
|
+
* @returns Promise resolving to mint data response containing all parameters for contract call
|
|
336
|
+
*/
|
|
337
|
+
async prepareMint(digest, chainId, batchId) {
|
|
338
|
+
const qs = new URLSearchParams({ digest });
|
|
339
|
+
if (chainId)
|
|
340
|
+
qs.set('chainId', String(chainId));
|
|
341
|
+
if (batchId)
|
|
342
|
+
qs.set('batchId', batchId);
|
|
343
|
+
return this.request('GET', `/nft/prepare-mint?${qs.toString()}`);
|
|
344
|
+
}
|
|
345
|
+
// ==========================================================================
|
|
346
|
+
// Authentication Methods (email verification only; no API keys)
|
|
347
|
+
// ==========================================================================
|
|
348
|
+
/**
|
|
349
|
+
* Request email verification (first step of registration).
|
|
350
|
+
*
|
|
351
|
+
* Sends a verification code to the provided email address. The user must
|
|
352
|
+
* then call `verifyEmail` with the code to complete registration.
|
|
353
|
+
*
|
|
354
|
+
* PUBLIC: No API key required.
|
|
355
|
+
*
|
|
356
|
+
* @param request - Registration request with email address
|
|
357
|
+
* @returns Promise resolving to registration response
|
|
358
|
+
*/
|
|
359
|
+
async register(request) {
|
|
360
|
+
return this.request('POST', '/auth/register', request);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Verify email with code.
|
|
364
|
+
*
|
|
365
|
+
* Completes the registration process. After verification, the user can
|
|
366
|
+
* submit digests by including their email in stamp requests.
|
|
367
|
+
*
|
|
368
|
+
* PUBLIC: No API key required.
|
|
369
|
+
*
|
|
370
|
+
* @param request - Verification request with email and code
|
|
371
|
+
* @returns Promise resolving to verification response
|
|
372
|
+
*/
|
|
373
|
+
async verifyEmail(request) {
|
|
374
|
+
return this.request('POST', '/auth/verify', request);
|
|
375
|
+
}
|
|
376
|
+
// ==========================================================================
|
|
377
|
+
// Calendar Discovery Methods
|
|
378
|
+
// ==========================================================================
|
|
379
|
+
/**
|
|
380
|
+
* Get calendar server identity and capabilities.
|
|
381
|
+
*
|
|
382
|
+
* Returns information about this calendar server including its unique ID,
|
|
383
|
+
* supported chains, capabilities, and current status.
|
|
384
|
+
*
|
|
385
|
+
* PUBLIC: No API key required.
|
|
386
|
+
*
|
|
387
|
+
* @returns Promise resolving to calendar identity information
|
|
388
|
+
*/
|
|
389
|
+
async getCalendar() {
|
|
390
|
+
return this.request('GET', '/calendar');
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Get calendar discovery document (standard format).
|
|
394
|
+
*
|
|
395
|
+
* Returns the same information as `getCalendar()` but at the standard
|
|
396
|
+
* `.well-known` location for automated discovery.
|
|
397
|
+
*
|
|
398
|
+
* PUBLIC: No API key required.
|
|
399
|
+
*
|
|
400
|
+
* @returns Promise resolving to calendar identity information
|
|
401
|
+
*/
|
|
402
|
+
async getCalendarDiscovery() {
|
|
403
|
+
return this.request('GET', '/.well-known/calendar.json');
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Quick health check.
|
|
407
|
+
*
|
|
408
|
+
* Returns basic health status of the calendar server.
|
|
409
|
+
* Use `healthCheckFull()` for detailed component status.
|
|
410
|
+
*
|
|
411
|
+
* PUBLIC: No API key required.
|
|
412
|
+
*
|
|
413
|
+
* @returns Promise resolving to health check response
|
|
414
|
+
*/
|
|
415
|
+
async healthCheck() {
|
|
416
|
+
return this.request('GET', '/health');
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Comprehensive health check with all component statuses.
|
|
420
|
+
*
|
|
421
|
+
* Returns detailed health information including database, scheduler,
|
|
422
|
+
* coordination service, and all configured blockchain chains.
|
|
423
|
+
*
|
|
424
|
+
* PUBLIC: No API key required.
|
|
425
|
+
*
|
|
426
|
+
* @returns Promise resolving to detailed health check response
|
|
427
|
+
*/
|
|
428
|
+
async healthCheckFull() {
|
|
429
|
+
return this.request('GET', '/health/full');
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
exports.ZipstampServerClient = ZipstampServerClient;
|
|
433
|
+
//# sourceMappingURL=ZipstampServerClient.js.map
|
|
@@ -0,0 +1 @@
|
|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