uvd-x402-sdk 2.52.1 → 2.53.0

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.
@@ -1685,6 +1685,24 @@ interface RegisterJobResponse {
1685
1685
  }
1686
1686
  /** Whether polling can stop: the job either finished or failed. */
1687
1687
  declare function isRegisterJobTerminal(job: RegisterJobResponse): boolean;
1688
+ /**
1689
+ * Thrown when a registration is still running after the wait elapsed.
1690
+ *
1691
+ * This is emphatically **not** a failure. The mint may still land. `jobId` is a
1692
+ * field rather than only part of the message, because the correct recovery is to
1693
+ * keep polling `getRegisterStatus(jobId)` — and a caller who cannot reach the id
1694
+ * without parsing a string will re-register instead, minting a duplicate agent.
1695
+ * That is the exact sequence that once produced five duplicate mints.
1696
+ *
1697
+ * Never map this to "registration failed".
1698
+ */
1699
+ declare class RegistrationPendingError extends Error {
1700
+ readonly jobId: string;
1701
+ readonly lastStatus: RegisterJobStatus;
1702
+ readonly timeoutMs: number;
1703
+ readonly retryable = true;
1704
+ constructor(jobId: string, lastStatus: RegisterJobStatus, timeoutMs: number);
1705
+ }
1688
1706
  interface IdentityMetadataResponse {
1689
1707
  /** Agent ID (EVM: number, Solana: string) */
1690
1708
  agentId: AgentId;
@@ -1944,7 +1962,11 @@ declare class Erc8004Client {
1944
1962
  * console.log(`Agent #${result.agentId} transferred to user`);
1945
1963
  * ```
1946
1964
  */
1947
- registerAgent(request: RegisterAgentRequest): Promise<RegisterAgentResponse>;
1965
+ registerAgent(request: RegisterAgentRequest, options?: {
1966
+ asyncTransport?: boolean;
1967
+ pollIntervalMs?: number;
1968
+ timeoutMs?: number;
1969
+ }): Promise<RegisterAgentResponse>;
1948
1970
  /**
1949
1971
  * Start a registration without waiting for the chain to confirm it.
1950
1972
  *
@@ -2471,4 +2493,4 @@ declare class AdvancedEscrowClient {
2471
2493
  private sendViaAdapter;
2472
2494
  }
2473
2495
 
2474
- export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, type AtomStats, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, Erc8004LookupError, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentPayloadV2, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type PaymentRequirementsV2, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterJobResponse, type RegisterJobStatus, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type ResourceInfoV2, type SettleRequest, type SettleRequestV2, type SettleResponse, type SettleResponseWithProof, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyRequestV2, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, isRegisterJobTerminal, parsePaymentHeader };
2496
+ export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, type AtomStats, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, Erc8004LookupError, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentPayloadV2, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type PaymentRequirementsV2, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterJobResponse, type RegisterJobStatus, RegistrationPendingError, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type ResourceInfoV2, type SettleRequest, type SettleRequestV2, type SettleResponse, type SettleResponseWithProof, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyRequestV2, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, isRegisterJobTerminal, parsePaymentHeader };
@@ -1685,6 +1685,24 @@ interface RegisterJobResponse {
1685
1685
  }
1686
1686
  /** Whether polling can stop: the job either finished or failed. */
1687
1687
  declare function isRegisterJobTerminal(job: RegisterJobResponse): boolean;
1688
+ /**
1689
+ * Thrown when a registration is still running after the wait elapsed.
1690
+ *
1691
+ * This is emphatically **not** a failure. The mint may still land. `jobId` is a
1692
+ * field rather than only part of the message, because the correct recovery is to
1693
+ * keep polling `getRegisterStatus(jobId)` — and a caller who cannot reach the id
1694
+ * without parsing a string will re-register instead, minting a duplicate agent.
1695
+ * That is the exact sequence that once produced five duplicate mints.
1696
+ *
1697
+ * Never map this to "registration failed".
1698
+ */
1699
+ declare class RegistrationPendingError extends Error {
1700
+ readonly jobId: string;
1701
+ readonly lastStatus: RegisterJobStatus;
1702
+ readonly timeoutMs: number;
1703
+ readonly retryable = true;
1704
+ constructor(jobId: string, lastStatus: RegisterJobStatus, timeoutMs: number);
1705
+ }
1688
1706
  interface IdentityMetadataResponse {
1689
1707
  /** Agent ID (EVM: number, Solana: string) */
1690
1708
  agentId: AgentId;
@@ -1944,7 +1962,11 @@ declare class Erc8004Client {
1944
1962
  * console.log(`Agent #${result.agentId} transferred to user`);
1945
1963
  * ```
1946
1964
  */
1947
- registerAgent(request: RegisterAgentRequest): Promise<RegisterAgentResponse>;
1965
+ registerAgent(request: RegisterAgentRequest, options?: {
1966
+ asyncTransport?: boolean;
1967
+ pollIntervalMs?: number;
1968
+ timeoutMs?: number;
1969
+ }): Promise<RegisterAgentResponse>;
1948
1970
  /**
1949
1971
  * Start a registration without waiting for the chain to confirm it.
1950
1972
  *
@@ -2471,4 +2493,4 @@ declare class AdvancedEscrowClient {
2471
2493
  private sendViaAdapter;
2472
2494
  }
2473
2495
 
2474
- export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, type AtomStats, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, Erc8004LookupError, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentPayloadV2, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type PaymentRequirementsV2, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterJobResponse, type RegisterJobStatus, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type ResourceInfoV2, type SettleRequest, type SettleRequestV2, type SettleResponse, type SettleResponseWithProof, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyRequestV2, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, isRegisterJobTerminal, parsePaymentHeader };
2496
+ export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, type AtomStats, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, Erc8004LookupError, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentPayloadV2, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type PaymentRequirementsV2, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterJobResponse, type RegisterJobStatus, RegistrationPendingError, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type ResourceInfoV2, type SettleRequest, type SettleRequestV2, type SettleResponse, type SettleResponseWithProof, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyRequestV2, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, isRegisterJobTerminal, parsePaymentHeader };
@@ -2576,6 +2576,34 @@ var Erc8004LookupError = class extends Error {
2576
2576
  function isRegisterJobTerminal(job) {
2577
2577
  return job.status === "done" || job.status === "failed";
2578
2578
  }
2579
+ var RegistrationPendingError = class extends Error {
2580
+ jobId;
2581
+ lastStatus;
2582
+ timeoutMs;
2583
+ retryable = true;
2584
+ constructor(jobId, lastStatus, timeoutMs) {
2585
+ super(
2586
+ `Registration job ${jobId} still '${lastStatus}' after ${Math.round(
2587
+ timeoutMs / 1e3
2588
+ )}s. It may still complete: poll getRegisterStatus('${jobId}') rather than registering again.`
2589
+ );
2590
+ this.name = "RegistrationPendingError";
2591
+ this.jobId = jobId;
2592
+ this.lastStatus = lastStatus;
2593
+ this.timeoutMs = timeoutMs;
2594
+ }
2595
+ };
2596
+ function jobToRegisterResponse(job, network) {
2597
+ return {
2598
+ success: job.status !== "failed",
2599
+ agentId: job.agentId,
2600
+ transaction: job.transaction,
2601
+ transferTransaction: job.transferTransaction,
2602
+ owner: job.owner,
2603
+ error: job.error,
2604
+ network: job.network ?? network
2605
+ };
2606
+ }
2579
2607
  var Erc8004Client = class {
2580
2608
  baseUrl;
2581
2609
  timeout;
@@ -2978,7 +3006,15 @@ var Erc8004Client = class {
2978
3006
  * console.log(`Agent #${result.agentId} transferred to user`);
2979
3007
  * ```
2980
3008
  */
2981
- async registerAgent(request) {
3009
+ async registerAgent(request, options) {
3010
+ if (options?.asyncTransport) {
3011
+ const job = await this.registerAgentAsync(request);
3012
+ const terminal = await this.waitForRegistration(job.jobId, {
3013
+ pollIntervalMs: options.pollIntervalMs,
3014
+ timeoutMs: options.timeoutMs
3015
+ });
3016
+ return jobToRegisterResponse(terminal, request.network);
3017
+ }
2982
3018
  const url = `${this.baseUrl}/register`;
2983
3019
  const controller = new AbortController();
2984
3020
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
@@ -3116,11 +3152,7 @@ var Erc8004Client = class {
3116
3152
  return job;
3117
3153
  }
3118
3154
  if (Date.now() >= deadline) {
3119
- throw new Error(
3120
- `Registration job ${jobId} still '${job.status}' after ${Math.round(
3121
- timeoutMs / 1e3
3122
- )}s. It may still complete: poll getRegisterStatus('${jobId}') rather than registering again.`
3123
- );
3155
+ throw new RegistrationPendingError(jobId, job.status, timeoutMs);
3124
3156
  }
3125
3157
  await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
3126
3158
  }
@@ -4156,6 +4188,7 @@ exports.MAX_SEARCH_LEN = MAX_SEARCH_LEN;
4156
4188
  exports.OPERATOR_ABI = OPERATOR_ABI;
4157
4189
  exports.OPERATOR_ABI_CREATE3 = OPERATOR_ABI_CREATE3;
4158
4190
  exports.PAYMENT_INFO_TYPEHASH = PAYMENT_INFO_TYPEHASH;
4191
+ exports.RegistrationPendingError = RegistrationPendingError;
4159
4192
  exports.TIER_FILTERS = TIER_FILTERS;
4160
4193
  exports.TIER_TIMINGS = TIER_TIMINGS;
4161
4194
  exports.USDC_DOMAIN_NAME = USDC_DOMAIN_NAME;