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,503 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Zipstamp Server Helpers
|
|
4
|
+
*
|
|
5
|
+
* High-level convenience functions for interacting with the Zipstamp server API.
|
|
6
|
+
* These functions provide a simplified interface for common operations like
|
|
7
|
+
* submitting digests, verifying timestamps, polling for confirmation, and NFT operations.
|
|
8
|
+
*
|
|
9
|
+
* This module wraps the core ZipstampServerClient with convenience functions
|
|
10
|
+
* and response type transformations for easier use in applications.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.getZipStampServerUrl = void 0;
|
|
14
|
+
exports.submitDigest = submitDigest;
|
|
15
|
+
exports.verifyDigest = verifyDigest;
|
|
16
|
+
exports.pollForConfirmation = pollForConfirmation;
|
|
17
|
+
exports.prepareMint = prepareMint;
|
|
18
|
+
exports.checkNFTStatus = checkNFTStatus;
|
|
19
|
+
exports.getNFTContractInfo = getNFTContractInfo;
|
|
20
|
+
exports.registerEmail = registerEmail;
|
|
21
|
+
exports.verifyEmailCode = verifyEmailCode;
|
|
22
|
+
exports.getCalendarIdentity = getCalendarIdentity;
|
|
23
|
+
exports.checkCalendarHealth = checkCalendarHealth;
|
|
24
|
+
const ZipstampServerClient_1 = require("./ZipstampServerClient");
|
|
25
|
+
const servers_1 = require("../constants/servers");
|
|
26
|
+
Object.defineProperty(exports, "getZipStampServerUrl", { enumerable: true, get: function () { return servers_1.getZipStampServerUrl; } });
|
|
27
|
+
function getClient(options) {
|
|
28
|
+
return new ZipstampServerClient_1.ZipstampServerClient({
|
|
29
|
+
serverUrl: (0, servers_1.getZipStampServerUrl)(options),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function shouldDebug(options) {
|
|
33
|
+
if (options?.debug !== undefined) {
|
|
34
|
+
return options.debug;
|
|
35
|
+
}
|
|
36
|
+
return process.env.ZIPSTAMP_DEBUG === 'true' || process.env.DEBUG === 'true';
|
|
37
|
+
}
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// API Functions
|
|
40
|
+
// ============================================================================
|
|
41
|
+
/**
|
|
42
|
+
* Submits a digest to the Zipstamp server for blockchain timestamping.
|
|
43
|
+
*
|
|
44
|
+
* Sends a SHA-256 digest (merkle root) to the Zipstamp server API to be included
|
|
45
|
+
* in the next batch for blockchain timestamping. The digest is typically the
|
|
46
|
+
* merkle root of a ZIP file's contents.
|
|
47
|
+
*
|
|
48
|
+
* Stamping requires a verified email (include email in the request; user must
|
|
49
|
+
* have verified via POST /auth/register and POST /auth/verify first).
|
|
50
|
+
*
|
|
51
|
+
* @param digest - SHA-256 hash as a 64-character hexadecimal string (no '0x' prefix)
|
|
52
|
+
* @param email - Email address (must be verified on the server)
|
|
53
|
+
* @param chainId - Optional chain ID hint (server may use this to select the network)
|
|
54
|
+
* @param options - Optional configuration
|
|
55
|
+
* @param options.serverUrl - Zipstamp server URL (defaults to `ZIPSTAMP_SERVER_URL` env var or `https://zipstamp-dev.neozip.io`)
|
|
56
|
+
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
57
|
+
* @returns Promise resolving to response containing batch information and status
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const response = await submitDigest(
|
|
62
|
+
* 'a1b2c3d4e5f6...', // 64-char hex string
|
|
63
|
+
* 'user@example.com',
|
|
64
|
+
* undefined, // Let server choose chain
|
|
65
|
+
* { debug: true }
|
|
66
|
+
* );
|
|
67
|
+
*
|
|
68
|
+
* if (response.success) {
|
|
69
|
+
* console.log('Submitted to batch:', response.batchId);
|
|
70
|
+
* console.log('Status:', response.status); // 'pending' | 'minting' | 'confirmed'
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
async function submitDigest(digest, email, chainId, options) {
|
|
75
|
+
const client = getClient(options);
|
|
76
|
+
const reqBody = { digest, chainId, email };
|
|
77
|
+
if (shouldDebug(options)) {
|
|
78
|
+
console.log('[Zipstamp Server API] POST /stamp request:', JSON.stringify(reqBody, null, 2));
|
|
79
|
+
}
|
|
80
|
+
const res = await client.stamp(reqBody);
|
|
81
|
+
if (shouldDebug(options)) {
|
|
82
|
+
console.log('[Zipstamp Server API] POST /stamp response:', JSON.stringify(res, null, 2));
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
success: res.success,
|
|
86
|
+
digest: res.digest,
|
|
87
|
+
batchId: res.batchId ?? null,
|
|
88
|
+
batchNumber: res.batchNumber,
|
|
89
|
+
chainId: res.chainId,
|
|
90
|
+
network: res.network,
|
|
91
|
+
status: res.status,
|
|
92
|
+
error: res.error,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Verifies a digest using the Zipstamp server API.
|
|
97
|
+
*
|
|
98
|
+
* Checks with the Zipstamp server whether a digest has been confirmed on the blockchain.
|
|
99
|
+
* Returns detailed verification information including transaction hash, block number,
|
|
100
|
+
* and merkle proof data if the timestamp is confirmed.
|
|
101
|
+
*
|
|
102
|
+
* @param digest - The SHA-256 digest (64-character hex string) to verify
|
|
103
|
+
* @param chainId - Optional chain ID hint to help server select the correct network
|
|
104
|
+
* @param batchId - Optional batch ID hint to help server disambiguate if digest appears in multiple batches
|
|
105
|
+
* @param client - Optional pre-configured ZipstampServerClient instance (useful for polling with custom timeout/retry settings)
|
|
106
|
+
* @param options - Optional configuration
|
|
107
|
+
* @param options.serverUrl - Zipstamp server URL (defaults to `ZIPSTAMP_SERVER_URL` env var or `https://zipstamp-dev.neozip.io`)
|
|
108
|
+
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
109
|
+
* @returns Promise resolving to verification response with status and blockchain details
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const response = await verifyDigest(
|
|
114
|
+
* 'a1b2c3d4e5f6...',
|
|
115
|
+
* 84532, // Base Sepolia
|
|
116
|
+
* 'base-sep-v0.90-n7', // Batch ID from metadata
|
|
117
|
+
* undefined, // Use default client
|
|
118
|
+
* { debug: true }
|
|
119
|
+
* );
|
|
120
|
+
*
|
|
121
|
+
* if (response.verified) {
|
|
122
|
+
* console.log('✅ Confirmed on blockchain');
|
|
123
|
+
* console.log('Transaction:', response.transactionHash);
|
|
124
|
+
* console.log('Block:', response.blockNumber);
|
|
125
|
+
* console.log('Merkle proof available:', !!response.merkleProof);
|
|
126
|
+
* } else {
|
|
127
|
+
* console.log('⏳ Pending confirmation');
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
async function verifyDigest(digest, chainId, batchId, client, options) {
|
|
132
|
+
const c = client ?? getClient(options);
|
|
133
|
+
const reqBody = { digest, chainId, batchId };
|
|
134
|
+
if (shouldDebug(options)) {
|
|
135
|
+
console.log('[Zipstamp Server API] POST /verify request:', JSON.stringify(reqBody, null, 2));
|
|
136
|
+
}
|
|
137
|
+
const res = await c.verify(reqBody);
|
|
138
|
+
if (shouldDebug(options)) {
|
|
139
|
+
console.log('[Zipstamp Server API] POST /verify response:', JSON.stringify(res, null, 2));
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
success: res.success,
|
|
143
|
+
verified: res.verified,
|
|
144
|
+
digest: res.digest,
|
|
145
|
+
tokenId: res.tokenId,
|
|
146
|
+
contractAddress: res.contractAddress,
|
|
147
|
+
network: res.network,
|
|
148
|
+
chainId: res.chainId,
|
|
149
|
+
transactionHash: res.transactionHash,
|
|
150
|
+
blockNumber: res.blockNumber,
|
|
151
|
+
timestamp: res.timestamp,
|
|
152
|
+
merkleRoot: res.merkleRoot,
|
|
153
|
+
merkleProof: res.merkleProof,
|
|
154
|
+
batchId: res.batchId,
|
|
155
|
+
batchNumber: res.batchNumber,
|
|
156
|
+
status: res.status,
|
|
157
|
+
error: res.error,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Polls the Zipstamp server for confirmation of a digest.
|
|
162
|
+
*
|
|
163
|
+
* Continuously checks the Zipstamp server API until the digest is confirmed on the
|
|
164
|
+
* blockchain or the timeout is reached. Uses deadline-aware polling with per-request
|
|
165
|
+
* timeouts to ensure proper exit behavior.
|
|
166
|
+
*
|
|
167
|
+
* **Use cases:**
|
|
168
|
+
* - Wait for batch confirmation after submitting a digest
|
|
169
|
+
* - Upgrade pending timestamps to confirmed status
|
|
170
|
+
* - Monitor timestamp status in real-time
|
|
171
|
+
*
|
|
172
|
+
* @param digest - The SHA-256 digest (64-character hex string) to poll for
|
|
173
|
+
* @param chainId - Optional chain ID hint
|
|
174
|
+
* @param batchId - Optional batch ID hint to help server disambiguate
|
|
175
|
+
* @param timeout - Maximum time to poll in milliseconds (default: 300000 = 5 minutes)
|
|
176
|
+
* @param interval - Time between polling attempts in milliseconds (default: 5000 = 5 seconds)
|
|
177
|
+
* @param options - Optional configuration
|
|
178
|
+
* @param options.serverUrl - Zipstamp server URL (defaults to `ZIPSTAMP_SERVER_URL` env var or `https://zipstamp-dev.neozip.io`)
|
|
179
|
+
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
180
|
+
* @returns Promise resolving to verification response if confirmed, or `null` if timeout reached
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* // Submit digest
|
|
185
|
+
* const submitResponse = await submitDigest(digest, email);
|
|
186
|
+
*
|
|
187
|
+
* // Poll until confirmed (or 5 minutes timeout)
|
|
188
|
+
* const confirmed = await pollForConfirmation(
|
|
189
|
+
* digest,
|
|
190
|
+
* undefined, // chainId
|
|
191
|
+
* submitResponse.batchId,
|
|
192
|
+
* 300000, // 5 minutes
|
|
193
|
+
* 5000, // Check every 5 seconds
|
|
194
|
+
* { debug: true }
|
|
195
|
+
* );
|
|
196
|
+
*
|
|
197
|
+
* if (confirmed && confirmed.verified) {
|
|
198
|
+
* console.log('✅ Confirmed! Transaction:', confirmed.transactionHash);
|
|
199
|
+
* } else {
|
|
200
|
+
* console.log('⏰ Timeout - batch not yet confirmed');
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
async function pollForConfirmation(digest, chainId, batchId, timeout = 300000, // 5 minutes default
|
|
205
|
+
interval = 5000, // 5 seconds default
|
|
206
|
+
options) {
|
|
207
|
+
const serverUrl = (0, servers_1.getZipStampServerUrl)(options);
|
|
208
|
+
let attempts = 0;
|
|
209
|
+
const startTime = Date.now();
|
|
210
|
+
const deadline = startTime + timeout;
|
|
211
|
+
while (true) {
|
|
212
|
+
const now = Date.now();
|
|
213
|
+
const remaining = deadline - now;
|
|
214
|
+
if (remaining <= 0) {
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
attempts++;
|
|
218
|
+
const elapsed = now - startTime;
|
|
219
|
+
if (shouldDebug(options)) {
|
|
220
|
+
console.log(`[Zipstamp Server API] pollForConfirmation attempt=${attempts} elapsedMs=${elapsed} remainingMs=${remaining}`);
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
// Ensure a single /verify call cannot exceed the overall poll timeout.
|
|
224
|
+
// Also disable retries during polling so the deadline is honored.
|
|
225
|
+
const perRequestTimeoutMs = Math.max(1000, Math.min(30000, remaining));
|
|
226
|
+
const client = new ZipstampServerClient_1.ZipstampServerClient({
|
|
227
|
+
serverUrl,
|
|
228
|
+
timeout: perRequestTimeoutMs,
|
|
229
|
+
retries: 0,
|
|
230
|
+
retryDelay: 0,
|
|
231
|
+
});
|
|
232
|
+
const result = await verifyDigest(digest, chainId, batchId, client, options);
|
|
233
|
+
// Confirmed if we have an on-chain tx hash (or server explicitly says confirmed).
|
|
234
|
+
if (result.success &&
|
|
235
|
+
(result.status === 'confirmed' || (result.verified && !!result.transactionHash))) {
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
// If the server returned a non-successful response, surface it immediately.
|
|
239
|
+
if (!result.success) {
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
// Pending: wait and retry, but never sleep past the deadline.
|
|
243
|
+
if (result.status === 'pending' || !result.transactionHash) {
|
|
244
|
+
const sleepMs = Math.min(interval, Math.max(0, deadline - Date.now()));
|
|
245
|
+
if (sleepMs <= 0)
|
|
246
|
+
break;
|
|
247
|
+
await new Promise(resolve => setTimeout(resolve, sleepMs));
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
// If verified but no transaction hash, return anyway
|
|
251
|
+
return result;
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
if (shouldDebug(options)) {
|
|
255
|
+
console.log(`[Zipstamp Server API] pollForConfirmation verify error: ${error instanceof Error ? error.message : String(error)}`);
|
|
256
|
+
}
|
|
257
|
+
// On error, wait and retry
|
|
258
|
+
const sleepMs = Math.min(interval, Math.max(0, deadline - Date.now()));
|
|
259
|
+
if (sleepMs <= 0)
|
|
260
|
+
break;
|
|
261
|
+
await new Promise(resolve => setTimeout(resolve, sleepMs));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// Timeout reached
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Prepares mint data for NFT proof token minting.
|
|
269
|
+
*
|
|
270
|
+
* Retrieves all data needed to call `mintProof()` on the TimestampProofNFT contract.
|
|
271
|
+
* This includes the merkle proof, batch information, contract addresses, and minting fee.
|
|
272
|
+
*
|
|
273
|
+
* **Use this before minting an NFT:**
|
|
274
|
+
* 1. Call `prepareMint()` to get mint data
|
|
275
|
+
* 2. Check `mintData.mintFeeWei` to ensure user has enough ETH
|
|
276
|
+
* 3. Call `mintProof(digest, merkleProof, batchMerkleRoot)` on the contract with the returned data
|
|
277
|
+
*
|
|
278
|
+
* @param digest - The SHA-256 digest (64-character hex string) to prepare mint data for
|
|
279
|
+
* @param chainId - Optional chain ID hint
|
|
280
|
+
* @param batchId - Optional batch ID from TIMESTAMP.NZIP metadata to ensure the correct batch is used
|
|
281
|
+
* @param options - Optional configuration
|
|
282
|
+
* @param options.serverUrl - Zipstamp server URL (defaults to `ZIPSTAMP_SERVER_URL` env var or `https://zipstamp-dev.neozip.io`)
|
|
283
|
+
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
284
|
+
* @returns Promise resolving to mint data response containing all parameters needed for contract call
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* const mintData = await prepareMint(
|
|
289
|
+
* digest,
|
|
290
|
+
* 84532, // Base Sepolia
|
|
291
|
+
* 'base-sep-v0.90-n7'
|
|
292
|
+
* );
|
|
293
|
+
*
|
|
294
|
+
* if (mintData.success && mintData.mintData) {
|
|
295
|
+
* const { digest, merkleProof, batchMerkleRoot, mintFeeWei, nftContractAddress } = mintData.mintData;
|
|
296
|
+
*
|
|
297
|
+
* // Call contract
|
|
298
|
+
* const tx = await contract.mintProof(digest, merkleProof, batchMerkleRoot, {
|
|
299
|
+
* value: mintFeeWei
|
|
300
|
+
* });
|
|
301
|
+
* await tx.wait();
|
|
302
|
+
* }
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
async function prepareMint(digest, chainId, batchId, options) {
|
|
306
|
+
const client = getClient(options);
|
|
307
|
+
return client.prepareMint(digest, chainId, batchId);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Checks if a digest has already been minted as an NFT proof token.
|
|
311
|
+
*
|
|
312
|
+
* Queries the Zipstamp server to determine if a digest has been minted as an NFT
|
|
313
|
+
* on the TimestampProofNFT contract. Returns token information if minted, including
|
|
314
|
+
* token ID, owner, and proof data.
|
|
315
|
+
*
|
|
316
|
+
* @param digest - The SHA-256 digest (64-character hex string) to check
|
|
317
|
+
* @param chainId - Optional chain ID hint
|
|
318
|
+
* @param options - Optional configuration
|
|
319
|
+
* @param options.serverUrl - Zipstamp server URL (defaults to `ZIPSTAMP_SERVER_URL` env var or `https://zipstamp-dev.neozip.io`)
|
|
320
|
+
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
321
|
+
* @returns Promise resolving to NFT status response indicating if minted and token details
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```typescript
|
|
325
|
+
* const status = await checkNFTStatus(digest, 84532);
|
|
326
|
+
*
|
|
327
|
+
* if (status.isMinted) {
|
|
328
|
+
* console.log('✅ Already minted as NFT');
|
|
329
|
+
* console.log('Token ID:', status.tokenId);
|
|
330
|
+
* console.log('Owner:', status.owner);
|
|
331
|
+
* } else {
|
|
332
|
+
* console.log('Not yet minted - can proceed with minting');
|
|
333
|
+
* }
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
async function checkNFTStatus(digest, chainId, options) {
|
|
337
|
+
const client = getClient(options);
|
|
338
|
+
return client.checkNFTStatus(digest, chainId);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Retrieves NFT contract information from the Zipstamp server.
|
|
342
|
+
*
|
|
343
|
+
* Gets details about the TimestampProofNFT contract for a given network,
|
|
344
|
+
* including contract address, registry address, minting fee, and version.
|
|
345
|
+
*
|
|
346
|
+
* @param chainId - Optional chain ID hint (if not provided, server uses default network)
|
|
347
|
+
* @param options - Optional configuration
|
|
348
|
+
* @param options.serverUrl - Zipstamp server URL (defaults to `ZIPSTAMP_SERVER_URL` env var or `https://zipstamp-dev.neozip.io`)
|
|
349
|
+
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
350
|
+
* @returns Promise resolving to contract information response
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```typescript
|
|
354
|
+
* const info = await getNFTContractInfo(84532); // Base Sepolia
|
|
355
|
+
*
|
|
356
|
+
* if (info.success) {
|
|
357
|
+
* console.log('NFT Contract:', info.contractAddress);
|
|
358
|
+
* console.log('Registry:', info.registryAddress);
|
|
359
|
+
* console.log('Mint Fee:', info.mintFee, 'ETH');
|
|
360
|
+
* console.log('Version:', info.contractVersion);
|
|
361
|
+
* }
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
async function getNFTContractInfo(chainId, options) {
|
|
365
|
+
const client = getClient(options);
|
|
366
|
+
return client.getNFTContractInfo(chainId);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Register an email address with a calendar server.
|
|
370
|
+
*
|
|
371
|
+
* This is the first step of the authentication flow. After calling this,
|
|
372
|
+
* the user will receive an email with a verification code. Use `verifyEmailCode`
|
|
373
|
+
* to complete registration.
|
|
374
|
+
*
|
|
375
|
+
* PUBLIC: No API key required.
|
|
376
|
+
*
|
|
377
|
+
* @param email - Email address to register
|
|
378
|
+
* @param options - Optional configuration
|
|
379
|
+
* @param options.serverUrl - Zipstamp server URL
|
|
380
|
+
* @returns Promise resolving to registration response
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* const result = await registerEmail('user@example.com', {
|
|
385
|
+
* serverUrl: 'https://calendar.neozip.io'
|
|
386
|
+
* });
|
|
387
|
+
*
|
|
388
|
+
* if (result.success) {
|
|
389
|
+
* console.log('Check your email for the verification code');
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
async function registerEmail(email, options) {
|
|
394
|
+
const client = getClient(options);
|
|
395
|
+
if (shouldDebug(options)) {
|
|
396
|
+
console.log('[Zipstamp Server API] POST /auth/register request:', { email });
|
|
397
|
+
}
|
|
398
|
+
const result = await client.register({ email });
|
|
399
|
+
if (shouldDebug(options)) {
|
|
400
|
+
console.log('[Zipstamp Server API] POST /auth/register response:', JSON.stringify(result, null, 2));
|
|
401
|
+
}
|
|
402
|
+
return result;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Verify email with code.
|
|
406
|
+
*
|
|
407
|
+
* This is the second step of the authentication flow. After calling `registerEmail`,
|
|
408
|
+
* the user receives a verification code via email. Submit that code here to complete
|
|
409
|
+
* registration. After verification, the user can submit digests by including their
|
|
410
|
+
* email in stamp requests.
|
|
411
|
+
*
|
|
412
|
+
* PUBLIC: No API key required.
|
|
413
|
+
*
|
|
414
|
+
* @param email - Email address that was registered
|
|
415
|
+
* @param code - Verification code from email
|
|
416
|
+
* @param options - Optional configuration
|
|
417
|
+
* @param options.serverUrl - Zipstamp server URL
|
|
418
|
+
* @returns Promise resolving to verification response
|
|
419
|
+
*/
|
|
420
|
+
async function verifyEmailCode(email, code, options) {
|
|
421
|
+
const client = getClient(options);
|
|
422
|
+
if (shouldDebug(options)) {
|
|
423
|
+
console.log('[Zipstamp Server API] POST /auth/verify request:', { email, code: '***' });
|
|
424
|
+
}
|
|
425
|
+
const result = await client.verifyEmail({ email, code });
|
|
426
|
+
if (shouldDebug(options)) {
|
|
427
|
+
console.log('[Zipstamp Server API] POST /auth/verify response:', JSON.stringify(result, null, 2));
|
|
428
|
+
}
|
|
429
|
+
return result;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Get calendar server identity and capabilities.
|
|
433
|
+
*
|
|
434
|
+
* Returns information about the calendar server including its unique ID,
|
|
435
|
+
* supported chains, capabilities, and current status.
|
|
436
|
+
*
|
|
437
|
+
* PUBLIC: No API key required.
|
|
438
|
+
*
|
|
439
|
+
* @param options - Optional configuration
|
|
440
|
+
* @param options.serverUrl - Zipstamp server URL
|
|
441
|
+
* @returns Promise resolving to calendar identity information
|
|
442
|
+
*
|
|
443
|
+
* @example
|
|
444
|
+
* ```typescript
|
|
445
|
+
* const calendar = await getCalendarIdentity({
|
|
446
|
+
* serverUrl: 'https://calendar.neozip.io'
|
|
447
|
+
* });
|
|
448
|
+
*
|
|
449
|
+
* console.log('Calendar ID:', calendar.id);
|
|
450
|
+
* console.log('Status:', calendar.status);
|
|
451
|
+
* console.log('Chains:', calendar.chains.map(c => c.network).join(', '));
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
454
|
+
async function getCalendarIdentity(options) {
|
|
455
|
+
const client = getClient(options);
|
|
456
|
+
if (shouldDebug(options)) {
|
|
457
|
+
console.log('[Zipstamp Server API] GET /calendar');
|
|
458
|
+
}
|
|
459
|
+
const result = await client.getCalendar();
|
|
460
|
+
if (shouldDebug(options)) {
|
|
461
|
+
console.log('[Zipstamp Server API] GET /calendar response:', JSON.stringify(result, null, 2));
|
|
462
|
+
}
|
|
463
|
+
return result;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Check health of a calendar server.
|
|
467
|
+
*
|
|
468
|
+
* Returns the current health status of the calendar server.
|
|
469
|
+
* Use this to check if a server is available before submitting timestamps.
|
|
470
|
+
*
|
|
471
|
+
* PUBLIC: No API key required.
|
|
472
|
+
*
|
|
473
|
+
* @param options - Optional configuration
|
|
474
|
+
* @param options.serverUrl - Zipstamp server URL
|
|
475
|
+
* @param full - If true, returns detailed component health (default: false)
|
|
476
|
+
* @returns Promise resolving to health check response
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```typescript
|
|
480
|
+
* const health = await checkCalendarHealth({
|
|
481
|
+
* serverUrl: 'https://calendar.neozip.io'
|
|
482
|
+
* });
|
|
483
|
+
*
|
|
484
|
+
* if (health.status === 'healthy') {
|
|
485
|
+
* console.log('Calendar is available');
|
|
486
|
+
* } else {
|
|
487
|
+
* console.log('Calendar status:', health.status);
|
|
488
|
+
* }
|
|
489
|
+
* ```
|
|
490
|
+
*/
|
|
491
|
+
async function checkCalendarHealth(options, full = false) {
|
|
492
|
+
const client = getClient(options);
|
|
493
|
+
const endpoint = full ? '/health/full' : '/health';
|
|
494
|
+
if (shouldDebug(options)) {
|
|
495
|
+
console.log(`[Zipstamp Server API] GET ${endpoint}`);
|
|
496
|
+
}
|
|
497
|
+
const result = full ? await client.healthCheckFull() : await client.healthCheck();
|
|
498
|
+
if (shouldDebug(options)) {
|
|
499
|
+
console.log(`[Zipstamp Server API] GET ${endpoint} response:`, JSON.stringify(result, null, 2));
|
|
500
|
+
}
|
|
501
|
+
return result;
|
|
502
|
+
}
|
|
503
|
+
//# sourceMappingURL=ZipstampServerHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZipstampServerHelpers.js","sourceRoot":"","sources":["../../src/zipstamp-server/ZipstampServerHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AA8LH,oCA0BC;AAsCD,oCAmCC;AA8CD,kDA2EC;AAwCD,kCAQC;AA6BD,wCAOC;AA0BD,gDAMC;AAkDD,sCAaC;AAkBD,0CAcC;AAyBD,kDAYC;AA4BD,kDAcC;AA1rBD,iEAA8I;AAC9I,kDAA4D;AAuInD,qGAvIA,8BAAoB,OAuIA;AAE7B,SAAS,SAAS,CAAC,OAAqC;IACtD,OAAO,IAAI,2CAAoB,CAAC;QAC9B,SAAS,EAAE,IAAA,8BAAoB,EAAC,OAAO,CAAC;KACzC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,OAAqC;IACxD,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC,KAAK,CAAC;IACvB,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC;AAC/E,CAAC;AAED,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACI,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,KAAc,EACd,OAAgB,EAChB,OAAqC;IAErC,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rC,OAAgB,KAAK;IAErB,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;IACnD,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,6BAA6B,QAAQ,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;IAClF,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,6BAA6B,QAAQ,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zipstamp Server API Module
|
|
3
|
+
*
|
|
4
|
+
* Provides timestamping functionality using Zipstamp server API,
|
|
5
|
+
* similar to OpenTimestamps but using Ethereum blockchain.
|
|
6
|
+
*
|
|
7
|
+
* **Authentication:**
|
|
8
|
+
* - Verification endpoints are PUBLIC (no API key required)
|
|
9
|
+
* - Stamping requires a verified email in the request (no API key)
|
|
10
|
+
*
|
|
11
|
+
* **Multi-Calendar Support:**
|
|
12
|
+
* - Use `CalendarManager` to submit to multiple calendars for redundancy
|
|
13
|
+
* - Similar to OpenTimestamps' approach of using multiple calendar servers
|
|
14
|
+
*/
|
|
15
|
+
export declare const SUBMIT_METADATA = "META-INF/TS-SUBMIT.NZIP";
|
|
16
|
+
export declare const TIMESTAMP_METADATA = "META-INF/TIMESTAMP.NZIP";
|
|
17
|
+
export declare const NFT_METADATA = "META-INF/TOKEN.NZIP";
|
|
18
|
+
export declare const NFT_METADATA_LEGACY = "META-INF/NZIP.TOKEN";
|
|
19
|
+
export { CMP_METHOD, createTimestamp, verifyTimestamp, verifyTimestampedZip, createTimestampedZip, createTimestampMetadataEntry, getEthTimestampEntry, extractTimestampData, type EthTimestampVerifyResult, type CreateTimestampOptions, type VerifyTimestampOptions, findMetadataEntry, getMetadataType, shouldUpgrade, getMetadataFileNames, type ZipEntry, type MetadataType, type MetadataEntryResult, verifyMerkleProofLocal, } from './ZipstampServerAPI';
|
|
20
|
+
export { ZipstampServerClient, type ZipstampServerOptions, type StampRequest, type StampResponse, type VerifyRequest, type VerifyResponse, type BatchQueueRequest, type BatchQueueResponse, type BatchStatusResponse, type TransferRequest, type TransferResponse, type CalendarInfo, type ServerStatus, type PrepareMintResponse, type NFTStatusResponse, type NFTContractInfoResponse, type RegisterRequest, type RegisterResponse, type VerifyEmailRequest, type VerifyEmailResponse, type CalendarIdentity, type CalendarChainInfo, type HealthCheckResponse, type ComponentHealth, } from './ZipstampServerClient';
|
|
21
|
+
export { submitDigest, verifyDigest, pollForConfirmation, prepareMint, checkNFTStatus, getNFTContractInfo, getZipStampServerUrl, registerEmail, verifyEmailCode, getCalendarIdentity, checkCalendarHealth, type SubmitDigestResponse, type VerifyDigestResponse, type TimestampMetadata, type ExtendedTokenMetadata, type ZipstampServerHelperOptions, } from './ZipstampServerHelpers';
|
|
22
|
+
export { DEFAULT_ZIPSTAMP_SERVER_URL, ZIPSTAMP_SERVER_URLS, getDefaultZipStampServerUrls, type GetZipStampServerUrlOptions, } from '../constants/servers';
|
|
23
|
+
export { CalendarManager, type CalendarConfig, type CalendarStatus, type SubmitResult, type MultiSubmitResult, type VerifyResult, type MultiCalendarOptions, } from './CalendarManager';
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/zipstamp-server/index.ts"],"names":[],"mappings":"AAAA;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ACtB,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,GACjC,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,EAC5B,KAAK,2BAA2B,GACjC,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Zipstamp Server API Module
|
|
4
|
+
*
|
|
5
|
+
* Provides timestamping functionality using Zipstamp server API,
|
|
6
|
+
* similar to OpenTimestamps but using Ethereum blockchain.
|
|
7
|
+
*
|
|
8
|
+
* **Authentication:**
|
|
9
|
+
* - Verification endpoints are PUBLIC (no API key required)
|
|
10
|
+
* - Stamping requires a verified email in the request (no API key)
|
|
11
|
+
*
|
|
12
|
+
* **Multi-Calendar Support:**
|
|
13
|
+
* - Use `CalendarManager` to submit to multiple calendars for redundancy
|
|
14
|
+
* - Similar to OpenTimestamps' approach of using multiple calendar servers
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.CalendarManager = exports.getDefaultZipStampServerUrls = exports.ZIPSTAMP_SERVER_URLS = exports.DEFAULT_ZIPSTAMP_SERVER_URL = exports.checkCalendarHealth = exports.getCalendarIdentity = exports.verifyEmailCode = exports.registerEmail = exports.getZipStampServerUrl = exports.getNFTContractInfo = exports.checkNFTStatus = exports.prepareMint = exports.pollForConfirmation = exports.verifyDigest = exports.submitDigest = exports.ZipstampServerClient = exports.verifyMerkleProofLocal = exports.getMetadataFileNames = exports.shouldUpgrade = exports.getMetadataType = exports.findMetadataEntry = exports.extractTimestampData = exports.getEthTimestampEntry = exports.createTimestampMetadataEntry = exports.createTimestampedZip = exports.verifyTimestampedZip = exports.verifyTimestamp = exports.createTimestamp = exports.CMP_METHOD = exports.NFT_METADATA_LEGACY = exports.NFT_METADATA = exports.TIMESTAMP_METADATA = exports.SUBMIT_METADATA = void 0;
|
|
18
|
+
const metadata_1 = require("../constants/metadata");
|
|
19
|
+
// Re-export metadata filenames (single source: src/constants/metadata.ts)
|
|
20
|
+
exports.SUBMIT_METADATA = metadata_1.TS_SUBMIT_NZIP;
|
|
21
|
+
exports.TIMESTAMP_METADATA = metadata_1.TIMESTAMP_NZIP;
|
|
22
|
+
exports.NFT_METADATA = metadata_1.TOKEN_NZIP;
|
|
23
|
+
exports.NFT_METADATA_LEGACY = metadata_1.TOKEN_NZIP_LEGACY;
|
|
24
|
+
var ZipstampServerAPI_1 = require("./ZipstampServerAPI");
|
|
25
|
+
Object.defineProperty(exports, "CMP_METHOD", { enumerable: true, get: function () { return ZipstampServerAPI_1.CMP_METHOD; } });
|
|
26
|
+
Object.defineProperty(exports, "createTimestamp", { enumerable: true, get: function () { return ZipstampServerAPI_1.createTimestamp; } });
|
|
27
|
+
Object.defineProperty(exports, "verifyTimestamp", { enumerable: true, get: function () { return ZipstampServerAPI_1.verifyTimestamp; } });
|
|
28
|
+
Object.defineProperty(exports, "verifyTimestampedZip", { enumerable: true, get: function () { return ZipstampServerAPI_1.verifyTimestampedZip; } });
|
|
29
|
+
Object.defineProperty(exports, "createTimestampedZip", { enumerable: true, get: function () { return ZipstampServerAPI_1.createTimestampedZip; } });
|
|
30
|
+
Object.defineProperty(exports, "createTimestampMetadataEntry", { enumerable: true, get: function () { return ZipstampServerAPI_1.createTimestampMetadataEntry; } });
|
|
31
|
+
Object.defineProperty(exports, "getEthTimestampEntry", { enumerable: true, get: function () { return ZipstampServerAPI_1.getEthTimestampEntry; } });
|
|
32
|
+
Object.defineProperty(exports, "extractTimestampData", { enumerable: true, get: function () { return ZipstampServerAPI_1.extractTimestampData; } });
|
|
33
|
+
// Metadata utilities
|
|
34
|
+
Object.defineProperty(exports, "findMetadataEntry", { enumerable: true, get: function () { return ZipstampServerAPI_1.findMetadataEntry; } });
|
|
35
|
+
Object.defineProperty(exports, "getMetadataType", { enumerable: true, get: function () { return ZipstampServerAPI_1.getMetadataType; } });
|
|
36
|
+
Object.defineProperty(exports, "shouldUpgrade", { enumerable: true, get: function () { return ZipstampServerAPI_1.shouldUpgrade; } });
|
|
37
|
+
Object.defineProperty(exports, "getMetadataFileNames", { enumerable: true, get: function () { return ZipstampServerAPI_1.getMetadataFileNames; } });
|
|
38
|
+
// Proof verification utilities
|
|
39
|
+
Object.defineProperty(exports, "verifyMerkleProofLocal", { enumerable: true, get: function () { return ZipstampServerAPI_1.verifyMerkleProofLocal; } });
|
|
40
|
+
// ZipstampServerClient and core types
|
|
41
|
+
var ZipstampServerClient_1 = require("./ZipstampServerClient");
|
|
42
|
+
Object.defineProperty(exports, "ZipstampServerClient", { enumerable: true, get: function () { return ZipstampServerClient_1.ZipstampServerClient; } });
|
|
43
|
+
// High-level convenience functions for Zipstamp server operations
|
|
44
|
+
var ZipstampServerHelpers_1 = require("./ZipstampServerHelpers");
|
|
45
|
+
// Core operations
|
|
46
|
+
Object.defineProperty(exports, "submitDigest", { enumerable: true, get: function () { return ZipstampServerHelpers_1.submitDigest; } });
|
|
47
|
+
Object.defineProperty(exports, "verifyDigest", { enumerable: true, get: function () { return ZipstampServerHelpers_1.verifyDigest; } });
|
|
48
|
+
Object.defineProperty(exports, "pollForConfirmation", { enumerable: true, get: function () { return ZipstampServerHelpers_1.pollForConfirmation; } });
|
|
49
|
+
Object.defineProperty(exports, "prepareMint", { enumerable: true, get: function () { return ZipstampServerHelpers_1.prepareMint; } });
|
|
50
|
+
Object.defineProperty(exports, "checkNFTStatus", { enumerable: true, get: function () { return ZipstampServerHelpers_1.checkNFTStatus; } });
|
|
51
|
+
Object.defineProperty(exports, "getNFTContractInfo", { enumerable: true, get: function () { return ZipstampServerHelpers_1.getNFTContractInfo; } });
|
|
52
|
+
Object.defineProperty(exports, "getZipStampServerUrl", { enumerable: true, get: function () { return ZipstampServerHelpers_1.getZipStampServerUrl; } });
|
|
53
|
+
// Authentication helpers
|
|
54
|
+
Object.defineProperty(exports, "registerEmail", { enumerable: true, get: function () { return ZipstampServerHelpers_1.registerEmail; } });
|
|
55
|
+
Object.defineProperty(exports, "verifyEmailCode", { enumerable: true, get: function () { return ZipstampServerHelpers_1.verifyEmailCode; } });
|
|
56
|
+
// Calendar discovery helpers
|
|
57
|
+
Object.defineProperty(exports, "getCalendarIdentity", { enumerable: true, get: function () { return ZipstampServerHelpers_1.getCalendarIdentity; } });
|
|
58
|
+
Object.defineProperty(exports, "checkCalendarHealth", { enumerable: true, get: function () { return ZipstampServerHelpers_1.checkCalendarHealth; } });
|
|
59
|
+
// Server URL constants (single source: src/constants/servers.ts)
|
|
60
|
+
var servers_1 = require("../constants/servers");
|
|
61
|
+
Object.defineProperty(exports, "DEFAULT_ZIPSTAMP_SERVER_URL", { enumerable: true, get: function () { return servers_1.DEFAULT_ZIPSTAMP_SERVER_URL; } });
|
|
62
|
+
Object.defineProperty(exports, "ZIPSTAMP_SERVER_URLS", { enumerable: true, get: function () { return servers_1.ZIPSTAMP_SERVER_URLS; } });
|
|
63
|
+
Object.defineProperty(exports, "getDefaultZipStampServerUrls", { enumerable: true, get: function () { return servers_1.getDefaultZipStampServerUrls; } });
|
|
64
|
+
// Multi-calendar support
|
|
65
|
+
var CalendarManager_1 = require("./CalendarManager");
|
|
66
|
+
Object.defineProperty(exports, "CalendarManager", { enumerable: true, get: function () { return CalendarManager_1.CalendarManager; } });
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/zipstamp-server/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,oDAK+B;AAE/B,0EAA0E;AAC7D,QAAA,eAAe,GAAG,yBAAc,CAAC;AACjC,QAAA,kB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