neozip-blockchain 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -15
- package/dist/constants/metadata.d.ts +2 -2
- package/dist/constants/metadata.js +4 -4
- package/dist/constants/metadata.js.map +1 -1
- package/dist/constants/servers.d.ts +17 -19
- package/dist/constants/servers.d.ts.map +1 -1
- package/dist/constants/servers.js +24 -27
- package/dist/constants/servers.js.map +1 -1
- package/dist/core/ZipkitMinter.js +4 -4
- package/dist/core/ZipkitMinter.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/{zipstamp-server → token-service}/CalendarManager.d.ts +6 -6
- package/dist/token-service/CalendarManager.d.ts.map +1 -0
- package/dist/{zipstamp-server → token-service}/CalendarManager.js +8 -8
- package/dist/token-service/CalendarManager.js.map +1 -0
- package/dist/{zipstamp-server/ZipstampServerAPI.d.ts → token-service/TokenServiceAPI.d.ts} +19 -19
- package/dist/token-service/TokenServiceAPI.d.ts.map +1 -0
- package/dist/{zipstamp-server/ZipstampServerAPI.js → token-service/TokenServiceAPI.js} +56 -56
- package/dist/token-service/TokenServiceAPI.js.map +1 -0
- package/dist/{zipstamp-server/ZipstampServerClient.d.ts → token-service/TokenServiceClient.d.ts} +41 -28
- package/dist/token-service/TokenServiceClient.d.ts.map +1 -0
- package/dist/{zipstamp-server/ZipstampServerClient.js → token-service/TokenServiceClient.js} +35 -27
- package/dist/token-service/TokenServiceClient.js.map +1 -0
- package/dist/{zipstamp-server/ZipstampServerHelpers.d.ts → token-service/TokenServiceHelpers.d.ts} +60 -47
- package/dist/token-service/TokenServiceHelpers.d.ts.map +1 -0
- package/dist/{zipstamp-server/ZipstampServerHelpers.js → token-service/TokenServiceHelpers.js} +71 -46
- package/dist/token-service/TokenServiceHelpers.js.map +1 -0
- package/dist/token-service/index.d.ts +24 -0
- package/dist/token-service/index.d.ts.map +1 -0
- package/dist/token-service/index.js +68 -0
- package/dist/token-service/index.js.map +1 -0
- package/package.json +25 -23
- package/dist/zipstamp-server/CalendarManager.d.ts.map +0 -1
- package/dist/zipstamp-server/CalendarManager.js.map +0 -1
- package/dist/zipstamp-server/ZipstampServerAPI.d.ts.map +0 -1
- package/dist/zipstamp-server/ZipstampServerAPI.js.map +0 -1
- package/dist/zipstamp-server/ZipstampServerClient.d.ts.map +0 -1
- package/dist/zipstamp-server/ZipstampServerClient.js.map +0 -1
- package/dist/zipstamp-server/ZipstampServerHelpers.d.ts.map +0 -1
- package/dist/zipstamp-server/ZipstampServerHelpers.js.map +0 -1
- package/dist/zipstamp-server/index.d.ts +0 -24
- package/dist/zipstamp-server/index.d.ts.map +0 -1
- package/dist/zipstamp-server/index.js +0 -67
- package/dist/zipstamp-server/index.js.map +0 -1
package/dist/{zipstamp-server/ZipstampServerHelpers.d.ts → token-service/TokenServiceHelpers.d.ts}
RENAMED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* NeoZip Token Service helpers
|
|
3
3
|
*
|
|
4
|
-
* High-level convenience functions for interacting with the
|
|
4
|
+
* High-level convenience functions for interacting with the NeoZip Token Service API.
|
|
5
5
|
* These functions provide a simplified interface for common operations like
|
|
6
6
|
* submitting digests, verifying timestamps, polling for confirmation, and NFT operations.
|
|
7
7
|
*
|
|
8
|
-
* This module wraps the core
|
|
8
|
+
* This module wraps the core TokenServiceClient with convenience functions
|
|
9
9
|
* and response type transformations for easier use in applications.
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { TokenServiceClient, type VerificationDelivery, type PrepareMintResponse, type NFTStatusResponse, type NFTContractInfoResponse } from './TokenServiceClient';
|
|
12
|
+
import { getTokenServiceUrl } from '../constants/servers';
|
|
13
13
|
/**
|
|
14
|
-
* Response from submitting a digest to the
|
|
14
|
+
* Response from submitting a digest to the NeoZip Token Service.
|
|
15
15
|
*
|
|
16
16
|
* Returned by `submitDigest` function after submitting a digest for timestamping.
|
|
17
17
|
*/
|
|
@@ -26,7 +26,7 @@ export interface SubmitDigestResponse {
|
|
|
26
26
|
error?: string;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* Response from verifying a digest with the
|
|
29
|
+
* Response from verifying a digest with the NeoZip Token Service.
|
|
30
30
|
*
|
|
31
31
|
* Returned by `verifyDigest` and `pollForConfirmation` functions after checking
|
|
32
32
|
* timestamp status. Contains detailed blockchain information if confirmed.
|
|
@@ -75,7 +75,7 @@ export interface TimestampMetadata {
|
|
|
75
75
|
* Extended Token Metadata (compatible with neozipkit TokenMetadata)
|
|
76
76
|
*
|
|
77
77
|
* This interface extends the base TokenMetadata with timestamp proof information
|
|
78
|
-
* for NFTs minted from timestamped ZIP files via the
|
|
78
|
+
* for NFTs minted from timestamped ZIP files via the NeoZip Token Service.
|
|
79
79
|
*
|
|
80
80
|
* The timestampProof section links the NFT to the original timestamp batch,
|
|
81
81
|
* proving both NFT ownership AND timestamp verification.
|
|
@@ -104,27 +104,39 @@ export interface ExtendedTokenMetadata {
|
|
|
104
104
|
serverUrl: string;
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
export type { PrepareMintResponse, NFTStatusResponse, NFTContractInfoResponse } from './
|
|
107
|
+
export type { PrepareMintResponse, NFTStatusResponse, NFTContractInfoResponse } from './TokenServiceClient';
|
|
108
108
|
/**
|
|
109
|
-
* Options for
|
|
109
|
+
* Options for NeoZip Token Service helper functions.
|
|
110
110
|
*
|
|
111
|
-
* Common configuration options used across helper functions in
|
|
111
|
+
* Common configuration options used across helper functions in TokenServiceHelpers.
|
|
112
112
|
* Stamping requires a verified email in the request (no API key).
|
|
113
113
|
*/
|
|
114
|
-
export interface
|
|
115
|
-
/**
|
|
114
|
+
export interface TokenServiceHelperOptions {
|
|
115
|
+
/** NeoZip Token Service URL (defaults to library constant / TOKEN_SERVICE_URL env) */
|
|
116
116
|
serverUrl?: string;
|
|
117
|
-
/** Key into
|
|
117
|
+
/** Key into TOKEN_SERVICE_URLS (e.g. "default", "staging") */
|
|
118
118
|
serverKey?: string;
|
|
119
119
|
/** Enable debug logging */
|
|
120
120
|
debug?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Only used by {@link registerEmail}: forwarded as `verificationDelivery` on `POST /auth/register`.
|
|
123
|
+
* `browser` (default when omitted): web confirm link + code. `app`: deep link + code only.
|
|
124
|
+
*/
|
|
125
|
+
verificationDelivery?: VerificationDelivery;
|
|
121
126
|
}
|
|
122
127
|
/** Re-export for callers that need to resolve server URL (single source: constants/servers.ts) */
|
|
123
|
-
export {
|
|
128
|
+
export { getTokenServiceUrl };
|
|
124
129
|
/**
|
|
125
|
-
*
|
|
130
|
+
* Parses env or CLI values for {@link registerEmail} (`POST /auth/register` body field `verificationDelivery`).
|
|
126
131
|
*
|
|
127
|
-
*
|
|
132
|
+
* @returns `undefined` when absent or empty (server defaults to `browser`).
|
|
133
|
+
* @throws Error when a non-empty value is not `browser` or `app`.
|
|
134
|
+
*/
|
|
135
|
+
export declare function parseVerificationDeliveryInput(raw: unknown): VerificationDelivery | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Submits a digest to the NeoZip Token Service for blockchain timestamping.
|
|
138
|
+
*
|
|
139
|
+
* Sends a SHA-256 digest (merkle root) to the NeoZip Token Service API to be included
|
|
128
140
|
* in the next batch for blockchain timestamping. The digest is typically the
|
|
129
141
|
* merkle root of a ZIP file's contents.
|
|
130
142
|
*
|
|
@@ -135,7 +147,7 @@ export { getZipStampServerUrl };
|
|
|
135
147
|
* @param email - Email address (must be verified on the server)
|
|
136
148
|
* @param chainId - Optional chain ID hint (server may use this to select the network)
|
|
137
149
|
* @param options - Optional configuration
|
|
138
|
-
* @param options.serverUrl -
|
|
150
|
+
* @param options.serverUrl - NeoZip Token Service URL (defaults to `TOKEN_SERVICE_URL` env var or `https://testnet.token-service.neozip.io`)
|
|
139
151
|
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
140
152
|
* @returns Promise resolving to response containing batch information and status
|
|
141
153
|
*
|
|
@@ -154,20 +166,20 @@ export { getZipStampServerUrl };
|
|
|
154
166
|
* }
|
|
155
167
|
* ```
|
|
156
168
|
*/
|
|
157
|
-
export declare function submitDigest(digest: string, email?: string, chainId?: number, options?:
|
|
169
|
+
export declare function submitDigest(digest: string, email?: string, chainId?: number, options?: TokenServiceHelperOptions): Promise<SubmitDigestResponse>;
|
|
158
170
|
/**
|
|
159
|
-
* Verifies a digest using the
|
|
171
|
+
* Verifies a digest using the NeoZip Token Service API.
|
|
160
172
|
*
|
|
161
|
-
* Checks with the
|
|
173
|
+
* Checks with the NeoZip Token Service whether a digest has been confirmed on the blockchain.
|
|
162
174
|
* Returns detailed verification information including transaction hash, block number,
|
|
163
175
|
* and merkle proof data if the timestamp is confirmed.
|
|
164
176
|
*
|
|
165
177
|
* @param digest - The SHA-256 digest (64-character hex string) to verify
|
|
166
178
|
* @param chainId - Optional chain ID hint to help server select the correct network
|
|
167
179
|
* @param batchId - Optional batch ID hint to help server disambiguate if digest appears in multiple batches
|
|
168
|
-
* @param client - Optional pre-configured
|
|
180
|
+
* @param client - Optional pre-configured TokenServiceClient instance (useful for polling with custom timeout/retry settings)
|
|
169
181
|
* @param options - Optional configuration
|
|
170
|
-
* @param options.serverUrl -
|
|
182
|
+
* @param options.serverUrl - NeoZip Token Service URL (defaults to `TOKEN_SERVICE_URL` env var or `https://testnet.token-service.neozip.io`)
|
|
171
183
|
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
172
184
|
* @returns Promise resolving to verification response with status and blockchain details
|
|
173
185
|
*
|
|
@@ -191,11 +203,11 @@ export declare function submitDigest(digest: string, email?: string, chainId?: n
|
|
|
191
203
|
* }
|
|
192
204
|
* ```
|
|
193
205
|
*/
|
|
194
|
-
export declare function verifyDigest(digest: string, chainId?: number, batchId?: string, client?:
|
|
206
|
+
export declare function verifyDigest(digest: string, chainId?: number, batchId?: string, client?: TokenServiceClient, options?: TokenServiceHelperOptions): Promise<VerifyDigestResponse>;
|
|
195
207
|
/**
|
|
196
|
-
* Polls the
|
|
208
|
+
* Polls the NeoZip Token Service for confirmation of a digest.
|
|
197
209
|
*
|
|
198
|
-
* Continuously checks the
|
|
210
|
+
* Continuously checks the NeoZip Token Service API until the digest is confirmed on the
|
|
199
211
|
* blockchain or the timeout is reached. Uses deadline-aware polling with per-request
|
|
200
212
|
* timeouts to ensure proper exit behavior.
|
|
201
213
|
*
|
|
@@ -210,7 +222,7 @@ export declare function verifyDigest(digest: string, chainId?: number, batchId?:
|
|
|
210
222
|
* @param timeout - Maximum time to poll in milliseconds (default: 300000 = 5 minutes)
|
|
211
223
|
* @param interval - Time between polling attempts in milliseconds (default: 5000 = 5 seconds)
|
|
212
224
|
* @param options - Optional configuration
|
|
213
|
-
* @param options.serverUrl -
|
|
225
|
+
* @param options.serverUrl - NeoZip Token Service URL (defaults to `TOKEN_SERVICE_URL` env var or `https://testnet.token-service.neozip.io`)
|
|
214
226
|
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
215
227
|
* @returns Promise resolving to verification response if confirmed, or `null` if timeout reached
|
|
216
228
|
*
|
|
@@ -238,7 +250,7 @@ export declare function verifyDigest(digest: string, chainId?: number, batchId?:
|
|
|
238
250
|
*/
|
|
239
251
|
export declare function pollForConfirmation(digest: string, chainId?: number, batchId?: string, timeout?: number, // 5 minutes default
|
|
240
252
|
interval?: number, // 5 seconds default
|
|
241
|
-
options?:
|
|
253
|
+
options?: TokenServiceHelperOptions): Promise<VerifyDigestResponse | null>;
|
|
242
254
|
/**
|
|
243
255
|
* Prepares mint data for NFT proof token minting.
|
|
244
256
|
*
|
|
@@ -254,7 +266,7 @@ options?: ZipstampServerHelperOptions): Promise<VerifyDigestResponse | null>;
|
|
|
254
266
|
* @param chainId - Optional chain ID hint
|
|
255
267
|
* @param batchId - Optional batch ID from TIMESTAMP.NZIP metadata to ensure the correct batch is used
|
|
256
268
|
* @param options - Optional configuration
|
|
257
|
-
* @param options.serverUrl -
|
|
269
|
+
* @param options.serverUrl - NeoZip Token Service URL (defaults to `TOKEN_SERVICE_URL` env var or `https://testnet.token-service.neozip.io`)
|
|
258
270
|
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
259
271
|
* @returns Promise resolving to mint data response containing all parameters needed for contract call
|
|
260
272
|
*
|
|
@@ -277,18 +289,18 @@ options?: ZipstampServerHelperOptions): Promise<VerifyDigestResponse | null>;
|
|
|
277
289
|
* }
|
|
278
290
|
* ```
|
|
279
291
|
*/
|
|
280
|
-
export declare function prepareMint(digest: string, chainId?: number, batchId?: string, options?:
|
|
292
|
+
export declare function prepareMint(digest: string, chainId?: number, batchId?: string, options?: TokenServiceHelperOptions): Promise<PrepareMintResponse>;
|
|
281
293
|
/**
|
|
282
294
|
* Checks if a digest has already been minted as an NFT proof token.
|
|
283
295
|
*
|
|
284
|
-
* Queries the
|
|
296
|
+
* Queries the NeoZip Token Service to determine if a digest has been minted as an NFT
|
|
285
297
|
* on the TimestampProofNFT contract. Returns token information if minted, including
|
|
286
298
|
* token ID, owner, and proof data.
|
|
287
299
|
*
|
|
288
300
|
* @param digest - The SHA-256 digest (64-character hex string) to check
|
|
289
301
|
* @param chainId - Optional chain ID hint
|
|
290
302
|
* @param options - Optional configuration
|
|
291
|
-
* @param options.serverUrl -
|
|
303
|
+
* @param options.serverUrl - NeoZip Token Service URL (defaults to `TOKEN_SERVICE_URL` env var or `https://testnet.token-service.neozip.io`)
|
|
292
304
|
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
293
305
|
* @returns Promise resolving to NFT status response indicating if minted and token details
|
|
294
306
|
*
|
|
@@ -305,16 +317,16 @@ export declare function prepareMint(digest: string, chainId?: number, batchId?:
|
|
|
305
317
|
* }
|
|
306
318
|
* ```
|
|
307
319
|
*/
|
|
308
|
-
export declare function checkNFTStatus(digest: string, chainId?: number, options?:
|
|
320
|
+
export declare function checkNFTStatus(digest: string, chainId?: number, options?: TokenServiceHelperOptions): Promise<NFTStatusResponse>;
|
|
309
321
|
/**
|
|
310
|
-
* Retrieves NFT contract information from the
|
|
322
|
+
* Retrieves NFT contract information from the NeoZip Token Service.
|
|
311
323
|
*
|
|
312
324
|
* Gets details about the TimestampProofNFT contract for a given network,
|
|
313
325
|
* including contract address, registry address, minting fee, and version.
|
|
314
326
|
*
|
|
315
327
|
* @param chainId - Optional chain ID hint (if not provided, server uses default network)
|
|
316
328
|
* @param options - Optional configuration
|
|
317
|
-
* @param options.serverUrl -
|
|
329
|
+
* @param options.serverUrl - NeoZip Token Service URL (defaults to `TOKEN_SERVICE_URL` env var or `https://testnet.token-service.neozip.io`)
|
|
318
330
|
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
319
331
|
* @returns Promise resolving to contract information response
|
|
320
332
|
*
|
|
@@ -330,9 +342,9 @@ export declare function checkNFTStatus(digest: string, chainId?: number, options
|
|
|
330
342
|
* }
|
|
331
343
|
* ```
|
|
332
344
|
*/
|
|
333
|
-
export declare function getNFTContractInfo(chainId?: number, options?:
|
|
334
|
-
import type { RegisterResponse, VerifyEmailResponse, CalendarIdentity, HealthCheckResponse } from './
|
|
335
|
-
export type { RegisterRequest, RegisterResponse, VerifyEmailRequest, VerifyEmailResponse, CalendarIdentity, CalendarChainInfo, HealthCheckResponse, ComponentHealth, } from './
|
|
345
|
+
export declare function getNFTContractInfo(chainId?: number, options?: TokenServiceHelperOptions): Promise<NFTContractInfoResponse>;
|
|
346
|
+
import type { RegisterResponse, VerifyEmailResponse, CalendarIdentity, HealthCheckResponse } from './TokenServiceClient';
|
|
347
|
+
export type { RegisterRequest, RegisterResponse, VerificationDelivery, VerifyEmailRequest, VerifyEmailResponse, CalendarIdentity, CalendarChainInfo, HealthCheckResponse, ComponentHealth, } from './TokenServiceClient';
|
|
336
348
|
/**
|
|
337
349
|
* Register an email address with a calendar server.
|
|
338
350
|
*
|
|
@@ -344,7 +356,8 @@ export type { RegisterRequest, RegisterResponse, VerifyEmailRequest, VerifyEmail
|
|
|
344
356
|
*
|
|
345
357
|
* @param email - Email address to register
|
|
346
358
|
* @param options - Optional configuration
|
|
347
|
-
* @param options.serverUrl -
|
|
359
|
+
* @param options.serverUrl - NeoZip Token Service URL
|
|
360
|
+
* @param options.verificationDelivery - `browser` (default) or `app`; matches token service `POST /auth/register`
|
|
348
361
|
* @returns Promise resolving to registration response
|
|
349
362
|
*
|
|
350
363
|
* @example
|
|
@@ -358,7 +371,7 @@ export type { RegisterRequest, RegisterResponse, VerifyEmailRequest, VerifyEmail
|
|
|
358
371
|
* }
|
|
359
372
|
* ```
|
|
360
373
|
*/
|
|
361
|
-
export declare function registerEmail(email: string, options?:
|
|
374
|
+
export declare function registerEmail(email: string, options?: TokenServiceHelperOptions): Promise<RegisterResponse>;
|
|
362
375
|
/**
|
|
363
376
|
* Verify email with code.
|
|
364
377
|
*
|
|
@@ -372,10 +385,10 @@ export declare function registerEmail(email: string, options?: ZipstampServerHel
|
|
|
372
385
|
* @param email - Email address that was registered
|
|
373
386
|
* @param code - Verification code from email
|
|
374
387
|
* @param options - Optional configuration
|
|
375
|
-
* @param options.serverUrl -
|
|
388
|
+
* @param options.serverUrl - NeoZip Token Service URL
|
|
376
389
|
* @returns Promise resolving to verification response
|
|
377
390
|
*/
|
|
378
|
-
export declare function verifyEmailCode(email: string, code: string, options?:
|
|
391
|
+
export declare function verifyEmailCode(email: string, code: string, options?: TokenServiceHelperOptions): Promise<VerifyEmailResponse>;
|
|
379
392
|
/**
|
|
380
393
|
* Get calendar server identity and capabilities.
|
|
381
394
|
*
|
|
@@ -385,7 +398,7 @@ export declare function verifyEmailCode(email: string, code: string, options?: Z
|
|
|
385
398
|
* PUBLIC: No API key required.
|
|
386
399
|
*
|
|
387
400
|
* @param options - Optional configuration
|
|
388
|
-
* @param options.serverUrl -
|
|
401
|
+
* @param options.serverUrl - NeoZip Token Service URL
|
|
389
402
|
* @returns Promise resolving to calendar identity information
|
|
390
403
|
*
|
|
391
404
|
* @example
|
|
@@ -399,7 +412,7 @@ export declare function verifyEmailCode(email: string, code: string, options?: Z
|
|
|
399
412
|
* console.log('Chains:', calendar.chains.map(c => c.network).join(', '));
|
|
400
413
|
* ```
|
|
401
414
|
*/
|
|
402
|
-
export declare function getCalendarIdentity(options?:
|
|
415
|
+
export declare function getCalendarIdentity(options?: TokenServiceHelperOptions): Promise<CalendarIdentity>;
|
|
403
416
|
/**
|
|
404
417
|
* Check health of a calendar server.
|
|
405
418
|
*
|
|
@@ -409,7 +422,7 @@ export declare function getCalendarIdentity(options?: ZipstampServerHelperOption
|
|
|
409
422
|
* PUBLIC: No API key required.
|
|
410
423
|
*
|
|
411
424
|
* @param options - Optional configuration
|
|
412
|
-
* @param options.serverUrl -
|
|
425
|
+
* @param options.serverUrl - NeoZip Token Service URL
|
|
413
426
|
* @param full - If true, returns detailed component health (default: false)
|
|
414
427
|
* @returns Promise resolving to health check response
|
|
415
428
|
*
|
|
@@ -426,5 +439,5 @@ export declare function getCalendarIdentity(options?: ZipstampServerHelperOption
|
|
|
426
439
|
* }
|
|
427
440
|
* ```
|
|
428
441
|
*/
|
|
429
|
-
export declare function checkCalendarHealth(options?:
|
|
430
|
-
//# sourceMappingURL=
|
|
442
|
+
export declare function checkCalendarHealth(options?: TokenServiceHelperOptions, full?: boolean): Promise<HealthCheckResponse>;
|
|
443
|
+
//# sourceMappingURL=TokenServiceHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenServiceHelpers.d.ts","sourceRoot":"","sources":["../../src/token-service/TokenServiceHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,kBAAkB,EAClB,KAAK,oBAAoB,EAEzB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAM1D;;;;GAIG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;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,CAAC,EAAE,yBAAyB,EACnC,IAAI,GAAE,OAAe,GACpB,OAAO,CAAC,mBAAmB,CAAC,CAW9B"}
|
package/dist/{zipstamp-server/ZipstampServerHelpers.js → token-service/TokenServiceHelpers.js}
RENAMED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* NeoZip Token Service helpers
|
|
4
4
|
*
|
|
5
|
-
* High-level convenience functions for interacting with the
|
|
5
|
+
* High-level convenience functions for interacting with the NeoZip Token Service API.
|
|
6
6
|
* These functions provide a simplified interface for common operations like
|
|
7
7
|
* submitting digests, verifying timestamps, polling for confirmation, and NFT operations.
|
|
8
8
|
*
|
|
9
|
-
* This module wraps the core
|
|
9
|
+
* This module wraps the core TokenServiceClient with convenience functions
|
|
10
10
|
* and response type transformations for easier use in applications.
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
13
|
+
exports.getTokenServiceUrl = void 0;
|
|
14
|
+
exports.parseVerificationDeliveryInput = parseVerificationDeliveryInput;
|
|
14
15
|
exports.submitDigest = submitDigest;
|
|
15
16
|
exports.verifyDigest = verifyDigest;
|
|
16
17
|
exports.pollForConfirmation = pollForConfirmation;
|
|
@@ -21,27 +22,46 @@ exports.registerEmail = registerEmail;
|
|
|
21
22
|
exports.verifyEmailCode = verifyEmailCode;
|
|
22
23
|
exports.getCalendarIdentity = getCalendarIdentity;
|
|
23
24
|
exports.checkCalendarHealth = checkCalendarHealth;
|
|
24
|
-
const
|
|
25
|
+
const TokenServiceClient_1 = require("./TokenServiceClient");
|
|
25
26
|
const servers_1 = require("../constants/servers");
|
|
26
|
-
Object.defineProperty(exports, "
|
|
27
|
+
Object.defineProperty(exports, "getTokenServiceUrl", { enumerable: true, get: function () { return servers_1.getTokenServiceUrl; } });
|
|
27
28
|
function getClient(options) {
|
|
28
|
-
return new
|
|
29
|
-
serverUrl: (0, servers_1.
|
|
29
|
+
return new TokenServiceClient_1.TokenServiceClient({
|
|
30
|
+
serverUrl: (0, servers_1.getTokenServiceUrl)(options),
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
function shouldDebug(options) {
|
|
33
34
|
if (options?.debug !== undefined) {
|
|
34
35
|
return options.debug;
|
|
35
36
|
}
|
|
36
|
-
return process.env.
|
|
37
|
+
return (process.env.TOKEN_SERVICE_DEBUG === 'true' ||
|
|
38
|
+
process.env.DEBUG === 'true');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parses env or CLI values for {@link registerEmail} (`POST /auth/register` body field `verificationDelivery`).
|
|
42
|
+
*
|
|
43
|
+
* @returns `undefined` when absent or empty (server defaults to `browser`).
|
|
44
|
+
* @throws Error when a non-empty value is not `browser` or `app`.
|
|
45
|
+
*/
|
|
46
|
+
function parseVerificationDeliveryInput(raw) {
|
|
47
|
+
if (raw === undefined || raw === null)
|
|
48
|
+
return undefined;
|
|
49
|
+
const s = String(raw).trim().toLowerCase();
|
|
50
|
+
if (s === '')
|
|
51
|
+
return undefined;
|
|
52
|
+
if (s === 'browser')
|
|
53
|
+
return 'browser';
|
|
54
|
+
if (s === 'app')
|
|
55
|
+
return 'app';
|
|
56
|
+
throw new Error(`verificationDelivery must be "browser" or "app" (got: ${JSON.stringify(raw)})`);
|
|
37
57
|
}
|
|
38
58
|
// ============================================================================
|
|
39
59
|
// API Functions
|
|
40
60
|
// ============================================================================
|
|
41
61
|
/**
|
|
42
|
-
* Submits a digest to the
|
|
62
|
+
* Submits a digest to the NeoZip Token Service for blockchain timestamping.
|
|
43
63
|
*
|
|
44
|
-
* Sends a SHA-256 digest (merkle root) to the
|
|
64
|
+
* Sends a SHA-256 digest (merkle root) to the NeoZip Token Service API to be included
|
|
45
65
|
* in the next batch for blockchain timestamping. The digest is typically the
|
|
46
66
|
* merkle root of a ZIP file's contents.
|
|
47
67
|
*
|
|
@@ -52,7 +72,7 @@ function shouldDebug(options) {
|
|
|
52
72
|
* @param email - Email address (must be verified on the server)
|
|
53
73
|
* @param chainId - Optional chain ID hint (server may use this to select the network)
|
|
54
74
|
* @param options - Optional configuration
|
|
55
|
-
* @param options.serverUrl -
|
|
75
|
+
* @param options.serverUrl - NeoZip Token Service URL (defaults to `TOKEN_SERVICE_URL` env var or `https://testnet.token-service.neozip.io`)
|
|
56
76
|
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
57
77
|
* @returns Promise resolving to response containing batch information and status
|
|
58
78
|
*
|
|
@@ -75,11 +95,11 @@ async function submitDigest(digest, email, chainId, options) {
|
|
|
75
95
|
const client = getClient(options);
|
|
76
96
|
const reqBody = { digest, chainId, email };
|
|
77
97
|
if (shouldDebug(options)) {
|
|
78
|
-
console.log('[
|
|
98
|
+
console.log('[TokenService] POST /stamp request:', JSON.stringify(reqBody, null, 2));
|
|
79
99
|
}
|
|
80
100
|
const res = await client.stamp(reqBody);
|
|
81
101
|
if (shouldDebug(options)) {
|
|
82
|
-
console.log('[
|
|
102
|
+
console.log('[TokenService] POST /stamp response:', JSON.stringify(res, null, 2));
|
|
83
103
|
}
|
|
84
104
|
return {
|
|
85
105
|
success: res.success,
|
|
@@ -93,18 +113,18 @@ async function submitDigest(digest, email, chainId, options) {
|
|
|
93
113
|
};
|
|
94
114
|
}
|
|
95
115
|
/**
|
|
96
|
-
* Verifies a digest using the
|
|
116
|
+
* Verifies a digest using the NeoZip Token Service API.
|
|
97
117
|
*
|
|
98
|
-
* Checks with the
|
|
118
|
+
* Checks with the NeoZip Token Service whether a digest has been confirmed on the blockchain.
|
|
99
119
|
* Returns detailed verification information including transaction hash, block number,
|
|
100
120
|
* and merkle proof data if the timestamp is confirmed.
|
|
101
121
|
*
|
|
102
122
|
* @param digest - The SHA-256 digest (64-character hex string) to verify
|
|
103
123
|
* @param chainId - Optional chain ID hint to help server select the correct network
|
|
104
124
|
* @param batchId - Optional batch ID hint to help server disambiguate if digest appears in multiple batches
|
|
105
|
-
* @param client - Optional pre-configured
|
|
125
|
+
* @param client - Optional pre-configured TokenServiceClient instance (useful for polling with custom timeout/retry settings)
|
|
106
126
|
* @param options - Optional configuration
|
|
107
|
-
* @param options.serverUrl -
|
|
127
|
+
* @param options.serverUrl - NeoZip Token Service URL (defaults to `TOKEN_SERVICE_URL` env var or `https://testnet.token-service.neozip.io`)
|
|
108
128
|
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
109
129
|
* @returns Promise resolving to verification response with status and blockchain details
|
|
110
130
|
*
|
|
@@ -132,11 +152,11 @@ async function verifyDigest(digest, chainId, batchId, client, options) {
|
|
|
132
152
|
const c = client ?? getClient(options);
|
|
133
153
|
const reqBody = { digest, chainId, batchId };
|
|
134
154
|
if (shouldDebug(options)) {
|
|
135
|
-
console.log('[
|
|
155
|
+
console.log('[TokenService] POST /verify request:', JSON.stringify(reqBody, null, 2));
|
|
136
156
|
}
|
|
137
157
|
const res = await c.verify(reqBody);
|
|
138
158
|
if (shouldDebug(options)) {
|
|
139
|
-
console.log('[
|
|
159
|
+
console.log('[TokenService] POST /verify response:', JSON.stringify(res, null, 2));
|
|
140
160
|
}
|
|
141
161
|
return {
|
|
142
162
|
success: res.success,
|
|
@@ -158,9 +178,9 @@ async function verifyDigest(digest, chainId, batchId, client, options) {
|
|
|
158
178
|
};
|
|
159
179
|
}
|
|
160
180
|
/**
|
|
161
|
-
* Polls the
|
|
181
|
+
* Polls the NeoZip Token Service for confirmation of a digest.
|
|
162
182
|
*
|
|
163
|
-
* Continuously checks the
|
|
183
|
+
* Continuously checks the NeoZip Token Service API until the digest is confirmed on the
|
|
164
184
|
* blockchain or the timeout is reached. Uses deadline-aware polling with per-request
|
|
165
185
|
* timeouts to ensure proper exit behavior.
|
|
166
186
|
*
|
|
@@ -175,7 +195,7 @@ async function verifyDigest(digest, chainId, batchId, client, options) {
|
|
|
175
195
|
* @param timeout - Maximum time to poll in milliseconds (default: 300000 = 5 minutes)
|
|
176
196
|
* @param interval - Time between polling attempts in milliseconds (default: 5000 = 5 seconds)
|
|
177
197
|
* @param options - Optional configuration
|
|
178
|
-
* @param options.serverUrl -
|
|
198
|
+
* @param options.serverUrl - NeoZip Token Service URL (defaults to `TOKEN_SERVICE_URL` env var or `https://testnet.token-service.neozip.io`)
|
|
179
199
|
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
180
200
|
* @returns Promise resolving to verification response if confirmed, or `null` if timeout reached
|
|
181
201
|
*
|
|
@@ -204,7 +224,7 @@ async function verifyDigest(digest, chainId, batchId, client, options) {
|
|
|
204
224
|
async function pollForConfirmation(digest, chainId, batchId, timeout = 300000, // 5 minutes default
|
|
205
225
|
interval = 5000, // 5 seconds default
|
|
206
226
|
options) {
|
|
207
|
-
const serverUrl = (0, servers_1.
|
|
227
|
+
const serverUrl = (0, servers_1.getTokenServiceUrl)(options);
|
|
208
228
|
let attempts = 0;
|
|
209
229
|
const startTime = Date.now();
|
|
210
230
|
const deadline = startTime + timeout;
|
|
@@ -217,13 +237,13 @@ options) {
|
|
|
217
237
|
attempts++;
|
|
218
238
|
const elapsed = now - startTime;
|
|
219
239
|
if (shouldDebug(options)) {
|
|
220
|
-
console.log(`[
|
|
240
|
+
console.log(`[TokenService] pollForConfirmation attempt=${attempts} elapsedMs=${elapsed} remainingMs=${remaining}`);
|
|
221
241
|
}
|
|
222
242
|
try {
|
|
223
243
|
// Ensure a single /verify call cannot exceed the overall poll timeout.
|
|
224
244
|
// Also disable retries during polling so the deadline is honored.
|
|
225
245
|
const perRequestTimeoutMs = Math.max(1000, Math.min(30000, remaining));
|
|
226
|
-
const client = new
|
|
246
|
+
const client = new TokenServiceClient_1.TokenServiceClient({
|
|
227
247
|
serverUrl,
|
|
228
248
|
timeout: perRequestTimeoutMs,
|
|
229
249
|
retries: 0,
|
|
@@ -252,7 +272,7 @@ options) {
|
|
|
252
272
|
}
|
|
253
273
|
catch (error) {
|
|
254
274
|
if (shouldDebug(options)) {
|
|
255
|
-
console.log(`[
|
|
275
|
+
console.log(`[TokenService] pollForConfirmation verify error: ${error instanceof Error ? error.message : String(error)}`);
|
|
256
276
|
}
|
|
257
277
|
// On error, wait and retry
|
|
258
278
|
const sleepMs = Math.min(interval, Math.max(0, deadline - Date.now()));
|
|
@@ -279,7 +299,7 @@ options) {
|
|
|
279
299
|
* @param chainId - Optional chain ID hint
|
|
280
300
|
* @param batchId - Optional batch ID from TIMESTAMP.NZIP metadata to ensure the correct batch is used
|
|
281
301
|
* @param options - Optional configuration
|
|
282
|
-
* @param options.serverUrl -
|
|
302
|
+
* @param options.serverUrl - NeoZip Token Service URL (defaults to `TOKEN_SERVICE_URL` env var or `https://testnet.token-service.neozip.io`)
|
|
283
303
|
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
284
304
|
* @returns Promise resolving to mint data response containing all parameters needed for contract call
|
|
285
305
|
*
|
|
@@ -309,14 +329,14 @@ async function prepareMint(digest, chainId, batchId, options) {
|
|
|
309
329
|
/**
|
|
310
330
|
* Checks if a digest has already been minted as an NFT proof token.
|
|
311
331
|
*
|
|
312
|
-
* Queries the
|
|
332
|
+
* Queries the NeoZip Token Service to determine if a digest has been minted as an NFT
|
|
313
333
|
* on the TimestampProofNFT contract. Returns token information if minted, including
|
|
314
334
|
* token ID, owner, and proof data.
|
|
315
335
|
*
|
|
316
336
|
* @param digest - The SHA-256 digest (64-character hex string) to check
|
|
317
337
|
* @param chainId - Optional chain ID hint
|
|
318
338
|
* @param options - Optional configuration
|
|
319
|
-
* @param options.serverUrl -
|
|
339
|
+
* @param options.serverUrl - NeoZip Token Service URL (defaults to `TOKEN_SERVICE_URL` env var or `https://testnet.token-service.neozip.io`)
|
|
320
340
|
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
321
341
|
* @returns Promise resolving to NFT status response indicating if minted and token details
|
|
322
342
|
*
|
|
@@ -338,14 +358,14 @@ async function checkNFTStatus(digest, chainId, options) {
|
|
|
338
358
|
return client.checkNFTStatus(digest, chainId);
|
|
339
359
|
}
|
|
340
360
|
/**
|
|
341
|
-
* Retrieves NFT contract information from the
|
|
361
|
+
* Retrieves NFT contract information from the NeoZip Token Service.
|
|
342
362
|
*
|
|
343
363
|
* Gets details about the TimestampProofNFT contract for a given network,
|
|
344
364
|
* including contract address, registry address, minting fee, and version.
|
|
345
365
|
*
|
|
346
366
|
* @param chainId - Optional chain ID hint (if not provided, server uses default network)
|
|
347
367
|
* @param options - Optional configuration
|
|
348
|
-
* @param options.serverUrl -
|
|
368
|
+
* @param options.serverUrl - NeoZip Token Service URL (defaults to `TOKEN_SERVICE_URL` env var or `https://testnet.token-service.neozip.io`)
|
|
349
369
|
* @param options.debug - Enable debug logging (defaults to `false`)
|
|
350
370
|
* @returns Promise resolving to contract information response
|
|
351
371
|
*
|
|
@@ -376,7 +396,8 @@ async function getNFTContractInfo(chainId, options) {
|
|
|
376
396
|
*
|
|
377
397
|
* @param email - Email address to register
|
|
378
398
|
* @param options - Optional configuration
|
|
379
|
-
* @param options.serverUrl -
|
|
399
|
+
* @param options.serverUrl - NeoZip Token Service URL
|
|
400
|
+
* @param options.verificationDelivery - `browser` (default) or `app`; matches token service `POST /auth/register`
|
|
380
401
|
* @returns Promise resolving to registration response
|
|
381
402
|
*
|
|
382
403
|
* @example
|
|
@@ -392,12 +413,16 @@ async function getNFTContractInfo(chainId, options) {
|
|
|
392
413
|
*/
|
|
393
414
|
async function registerEmail(email, options) {
|
|
394
415
|
const client = getClient(options);
|
|
416
|
+
const payload = { email };
|
|
417
|
+
if (options?.verificationDelivery !== undefined) {
|
|
418
|
+
payload.verificationDelivery = options.verificationDelivery;
|
|
419
|
+
}
|
|
395
420
|
if (shouldDebug(options)) {
|
|
396
|
-
console.log('[
|
|
421
|
+
console.log('[TokenService] POST /auth/register request:', payload);
|
|
397
422
|
}
|
|
398
|
-
const result = await client.register(
|
|
423
|
+
const result = await client.register(payload);
|
|
399
424
|
if (shouldDebug(options)) {
|
|
400
|
-
console.log('[
|
|
425
|
+
console.log('[TokenService] POST /auth/register response:', JSON.stringify(result, null, 2));
|
|
401
426
|
}
|
|
402
427
|
return result;
|
|
403
428
|
}
|
|
@@ -414,17 +439,17 @@ async function registerEmail(email, options) {
|
|
|
414
439
|
* @param email - Email address that was registered
|
|
415
440
|
* @param code - Verification code from email
|
|
416
441
|
* @param options - Optional configuration
|
|
417
|
-
* @param options.serverUrl -
|
|
442
|
+
* @param options.serverUrl - NeoZip Token Service URL
|
|
418
443
|
* @returns Promise resolving to verification response
|
|
419
444
|
*/
|
|
420
445
|
async function verifyEmailCode(email, code, options) {
|
|
421
446
|
const client = getClient(options);
|
|
422
447
|
if (shouldDebug(options)) {
|
|
423
|
-
console.log('[
|
|
448
|
+
console.log('[TokenService] POST /auth/verify request:', { email, code: '***' });
|
|
424
449
|
}
|
|
425
450
|
const result = await client.verifyEmail({ email, code });
|
|
426
451
|
if (shouldDebug(options)) {
|
|
427
|
-
console.log('[
|
|
452
|
+
console.log('[TokenService] POST /auth/verify response:', JSON.stringify(result, null, 2));
|
|
428
453
|
}
|
|
429
454
|
return result;
|
|
430
455
|
}
|
|
@@ -437,7 +462,7 @@ async function verifyEmailCode(email, code, options) {
|
|
|
437
462
|
* PUBLIC: No API key required.
|
|
438
463
|
*
|
|
439
464
|
* @param options - Optional configuration
|
|
440
|
-
* @param options.serverUrl -
|
|
465
|
+
* @param options.serverUrl - NeoZip Token Service URL
|
|
441
466
|
* @returns Promise resolving to calendar identity information
|
|
442
467
|
*
|
|
443
468
|
* @example
|
|
@@ -454,11 +479,11 @@ async function verifyEmailCode(email, code, options) {
|
|
|
454
479
|
async function getCalendarIdentity(options) {
|
|
455
480
|
const client = getClient(options);
|
|
456
481
|
if (shouldDebug(options)) {
|
|
457
|
-
console.log('[
|
|
482
|
+
console.log('[TokenService] GET /calendar');
|
|
458
483
|
}
|
|
459
484
|
const result = await client.getCalendar();
|
|
460
485
|
if (shouldDebug(options)) {
|
|
461
|
-
console.log('[
|
|
486
|
+
console.log('[TokenService] GET /calendar response:', JSON.stringify(result, null, 2));
|
|
462
487
|
}
|
|
463
488
|
return result;
|
|
464
489
|
}
|
|
@@ -471,7 +496,7 @@ async function getCalendarIdentity(options) {
|
|
|
471
496
|
* PUBLIC: No API key required.
|
|
472
497
|
*
|
|
473
498
|
* @param options - Optional configuration
|
|
474
|
-
* @param options.serverUrl -
|
|
499
|
+
* @param options.serverUrl - NeoZip Token Service URL
|
|
475
500
|
* @param full - If true, returns detailed component health (default: false)
|
|
476
501
|
* @returns Promise resolving to health check response
|
|
477
502
|
*
|
|
@@ -492,12 +517,12 @@ async function checkCalendarHealth(options, full = false) {
|
|
|
492
517
|
const client = getClient(options);
|
|
493
518
|
const endpoint = full ? '/health/full' : '/health';
|
|
494
519
|
if (shouldDebug(options)) {
|
|
495
|
-
console.log(`[
|
|
520
|
+
console.log(`[TokenService] GET ${endpoint}`);
|
|
496
521
|
}
|
|
497
522
|
const result = full ? await client.healthCheckFull() : await client.healthCheck();
|
|
498
523
|
if (shouldDebug(options)) {
|
|
499
|
-
console.log(`[
|
|
524
|
+
console.log(`[TokenService] GET ${endpoint} response:`, JSON.stringify(result, null, 2));
|
|
500
525
|
}
|
|
501
526
|
return result;
|
|
502
527
|
}
|
|
503
|
-
//# sourceMappingURL=
|
|
528
|
+
//# sourceMappingURL=TokenServiceHelpers.js.map
|