uvd-x402-sdk 2.50.0 → 2.52.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.
- package/dist/backend/index.d.mts +82 -1
- package/dist/backend/index.d.ts +82 -1
- package/dist/backend/index.js +131 -1
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs +130 -2
- package/dist/backend/index.mjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/backend/index.ts +193 -1
package/dist/backend/index.d.mts
CHANGED
|
@@ -1532,6 +1532,27 @@ interface FeedbackResponse {
|
|
|
1532
1532
|
/**
|
|
1533
1533
|
* Reputation query response
|
|
1534
1534
|
*/
|
|
1535
|
+
/**
|
|
1536
|
+
* Error from an ERC-8004 lookup, carrying the HTTP status as a field.
|
|
1537
|
+
*
|
|
1538
|
+
* `notFound` and `retryable` are mutually exclusive and must stay that way in
|
|
1539
|
+
* calling code: the facilitator answers 404 for "this address owns no agent"
|
|
1540
|
+
* and 503 for "I could not find out", usually an RPC failure behind it.
|
|
1541
|
+
* Treating a 503 as absence is how a transient failure becomes a permanent
|
|
1542
|
+
* wrong answer — on a registration path it mints a second agent for an owner
|
|
1543
|
+
* who already has one, burning gas and leaving an orphan.
|
|
1544
|
+
*/
|
|
1545
|
+
declare class Erc8004LookupError extends Error {
|
|
1546
|
+
/** HTTP status returned by the facilitator */
|
|
1547
|
+
readonly status: number;
|
|
1548
|
+
/** Raw response body, for debugging */
|
|
1549
|
+
readonly body: string;
|
|
1550
|
+
constructor(message: string, status: number, body: string);
|
|
1551
|
+
/** The address genuinely owns no agent on this network. */
|
|
1552
|
+
get notFound(): boolean;
|
|
1553
|
+
/** The lookup reached no verdict. Retry; never read as "owns nothing". */
|
|
1554
|
+
get retryable(): boolean;
|
|
1555
|
+
}
|
|
1535
1556
|
/**
|
|
1536
1557
|
* ATOM Engine reputation analytics (Solana only).
|
|
1537
1558
|
*
|
|
@@ -1637,6 +1658,33 @@ interface IdentityByOwnerResponse {
|
|
|
1637
1658
|
/**
|
|
1638
1659
|
* Response from GET /identity/{network}/{agent_id}/metadata/{key}
|
|
1639
1660
|
*/
|
|
1661
|
+
/**
|
|
1662
|
+
* Lifecycle of an async registration. `mint_confirmed` and `done` carry an
|
|
1663
|
+
* `agentId`; `failed` carries an `error`.
|
|
1664
|
+
*/
|
|
1665
|
+
type RegisterJobStatus = 'pending' | 'mint_confirmed' | 'done' | 'failed';
|
|
1666
|
+
/**
|
|
1667
|
+
* Status of an asynchronous registration.
|
|
1668
|
+
*
|
|
1669
|
+
* Returned by `POST /register` with `Prefer: respond-async` (HTTP 202) and by
|
|
1670
|
+
* `GET /register/status/{jobId}`.
|
|
1671
|
+
*
|
|
1672
|
+
* Terminal jobs are retained for one hour and then age out, after which the
|
|
1673
|
+
* status endpoint 404s. Read the agent id before then, or it is only
|
|
1674
|
+
* recoverable from the chain.
|
|
1675
|
+
*/
|
|
1676
|
+
interface RegisterJobResponse {
|
|
1677
|
+
jobId: string;
|
|
1678
|
+
status: RegisterJobStatus;
|
|
1679
|
+
network?: string;
|
|
1680
|
+
agentId?: AgentId;
|
|
1681
|
+
transaction?: string;
|
|
1682
|
+
transferTransaction?: string;
|
|
1683
|
+
owner?: string;
|
|
1684
|
+
error?: string;
|
|
1685
|
+
}
|
|
1686
|
+
/** Whether polling can stop: the job either finished or failed. */
|
|
1687
|
+
declare function isRegisterJobTerminal(job: RegisterJobResponse): boolean;
|
|
1640
1688
|
interface IdentityMetadataResponse {
|
|
1641
1689
|
/** Agent ID (EVM: number, Solana: string) */
|
|
1642
1690
|
agentId: AgentId;
|
|
@@ -1897,6 +1945,39 @@ declare class Erc8004Client {
|
|
|
1897
1945
|
* ```
|
|
1898
1946
|
*/
|
|
1899
1947
|
registerAgent(request: RegisterAgentRequest): Promise<RegisterAgentResponse>;
|
|
1948
|
+
/**
|
|
1949
|
+
* Start a registration without waiting for the chain to confirm it.
|
|
1950
|
+
*
|
|
1951
|
+
* Registration waits on a mint receipt, which on a congested chain outlives
|
|
1952
|
+
* client and proxy timeouts. A timed-out synchronous call is genuinely
|
|
1953
|
+
* ambiguous — the mint may well have landed — and retrying it is how five
|
|
1954
|
+
* duplicate agents once got minted. This returns immediately with a job id
|
|
1955
|
+
* instead; poll {@link getRegisterStatus} or use {@link waitForRegistration}.
|
|
1956
|
+
*
|
|
1957
|
+
* On Solana, `recipient` is a base58 address: the facilitator mints,
|
|
1958
|
+
* initializes the ATOM stats and transfers, paying every fee.
|
|
1959
|
+
*/
|
|
1960
|
+
registerAgentAsync(request: RegisterAgentRequest): Promise<RegisterJobResponse>;
|
|
1961
|
+
/**
|
|
1962
|
+
* Read the current state of an asynchronous registration.
|
|
1963
|
+
*
|
|
1964
|
+
* Throws {@link Erc8004LookupError} with `notFound` when the job is unknown or
|
|
1965
|
+
* has aged out — terminal jobs are kept for one hour.
|
|
1966
|
+
*/
|
|
1967
|
+
getRegisterStatus(jobId: string): Promise<RegisterJobResponse>;
|
|
1968
|
+
/**
|
|
1969
|
+
* Poll an asynchronous registration until it finishes.
|
|
1970
|
+
*
|
|
1971
|
+
* Rejects on timeout rather than resolving with the last non-terminal status,
|
|
1972
|
+
* so "still pending" is never mistaken for "did not happen": the mint may
|
|
1973
|
+
* still land afterwards, and treating a timeout as failure is what leads to
|
|
1974
|
+
* registering the same agent twice. Keep the job id and poll again rather
|
|
1975
|
+
* than re-registering.
|
|
1976
|
+
*/
|
|
1977
|
+
waitForRegistration(jobId: string, options?: {
|
|
1978
|
+
pollIntervalMs?: number;
|
|
1979
|
+
timeoutMs?: number;
|
|
1980
|
+
}): Promise<RegisterJobResponse>;
|
|
1900
1981
|
/**
|
|
1901
1982
|
* Get registration endpoint metadata
|
|
1902
1983
|
*
|
|
@@ -2390,4 +2471,4 @@ declare class AdvancedEscrowClient {
|
|
|
2390
2471
|
private sendViaAdapter;
|
|
2391
2472
|
}
|
|
2392
2473
|
|
|
2393
|
-
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, 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 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, parsePaymentHeader };
|
|
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 };
|
package/dist/backend/index.d.ts
CHANGED
|
@@ -1532,6 +1532,27 @@ interface FeedbackResponse {
|
|
|
1532
1532
|
/**
|
|
1533
1533
|
* Reputation query response
|
|
1534
1534
|
*/
|
|
1535
|
+
/**
|
|
1536
|
+
* Error from an ERC-8004 lookup, carrying the HTTP status as a field.
|
|
1537
|
+
*
|
|
1538
|
+
* `notFound` and `retryable` are mutually exclusive and must stay that way in
|
|
1539
|
+
* calling code: the facilitator answers 404 for "this address owns no agent"
|
|
1540
|
+
* and 503 for "I could not find out", usually an RPC failure behind it.
|
|
1541
|
+
* Treating a 503 as absence is how a transient failure becomes a permanent
|
|
1542
|
+
* wrong answer — on a registration path it mints a second agent for an owner
|
|
1543
|
+
* who already has one, burning gas and leaving an orphan.
|
|
1544
|
+
*/
|
|
1545
|
+
declare class Erc8004LookupError extends Error {
|
|
1546
|
+
/** HTTP status returned by the facilitator */
|
|
1547
|
+
readonly status: number;
|
|
1548
|
+
/** Raw response body, for debugging */
|
|
1549
|
+
readonly body: string;
|
|
1550
|
+
constructor(message: string, status: number, body: string);
|
|
1551
|
+
/** The address genuinely owns no agent on this network. */
|
|
1552
|
+
get notFound(): boolean;
|
|
1553
|
+
/** The lookup reached no verdict. Retry; never read as "owns nothing". */
|
|
1554
|
+
get retryable(): boolean;
|
|
1555
|
+
}
|
|
1535
1556
|
/**
|
|
1536
1557
|
* ATOM Engine reputation analytics (Solana only).
|
|
1537
1558
|
*
|
|
@@ -1637,6 +1658,33 @@ interface IdentityByOwnerResponse {
|
|
|
1637
1658
|
/**
|
|
1638
1659
|
* Response from GET /identity/{network}/{agent_id}/metadata/{key}
|
|
1639
1660
|
*/
|
|
1661
|
+
/**
|
|
1662
|
+
* Lifecycle of an async registration. `mint_confirmed` and `done` carry an
|
|
1663
|
+
* `agentId`; `failed` carries an `error`.
|
|
1664
|
+
*/
|
|
1665
|
+
type RegisterJobStatus = 'pending' | 'mint_confirmed' | 'done' | 'failed';
|
|
1666
|
+
/**
|
|
1667
|
+
* Status of an asynchronous registration.
|
|
1668
|
+
*
|
|
1669
|
+
* Returned by `POST /register` with `Prefer: respond-async` (HTTP 202) and by
|
|
1670
|
+
* `GET /register/status/{jobId}`.
|
|
1671
|
+
*
|
|
1672
|
+
* Terminal jobs are retained for one hour and then age out, after which the
|
|
1673
|
+
* status endpoint 404s. Read the agent id before then, or it is only
|
|
1674
|
+
* recoverable from the chain.
|
|
1675
|
+
*/
|
|
1676
|
+
interface RegisterJobResponse {
|
|
1677
|
+
jobId: string;
|
|
1678
|
+
status: RegisterJobStatus;
|
|
1679
|
+
network?: string;
|
|
1680
|
+
agentId?: AgentId;
|
|
1681
|
+
transaction?: string;
|
|
1682
|
+
transferTransaction?: string;
|
|
1683
|
+
owner?: string;
|
|
1684
|
+
error?: string;
|
|
1685
|
+
}
|
|
1686
|
+
/** Whether polling can stop: the job either finished or failed. */
|
|
1687
|
+
declare function isRegisterJobTerminal(job: RegisterJobResponse): boolean;
|
|
1640
1688
|
interface IdentityMetadataResponse {
|
|
1641
1689
|
/** Agent ID (EVM: number, Solana: string) */
|
|
1642
1690
|
agentId: AgentId;
|
|
@@ -1897,6 +1945,39 @@ declare class Erc8004Client {
|
|
|
1897
1945
|
* ```
|
|
1898
1946
|
*/
|
|
1899
1947
|
registerAgent(request: RegisterAgentRequest): Promise<RegisterAgentResponse>;
|
|
1948
|
+
/**
|
|
1949
|
+
* Start a registration without waiting for the chain to confirm it.
|
|
1950
|
+
*
|
|
1951
|
+
* Registration waits on a mint receipt, which on a congested chain outlives
|
|
1952
|
+
* client and proxy timeouts. A timed-out synchronous call is genuinely
|
|
1953
|
+
* ambiguous — the mint may well have landed — and retrying it is how five
|
|
1954
|
+
* duplicate agents once got minted. This returns immediately with a job id
|
|
1955
|
+
* instead; poll {@link getRegisterStatus} or use {@link waitForRegistration}.
|
|
1956
|
+
*
|
|
1957
|
+
* On Solana, `recipient` is a base58 address: the facilitator mints,
|
|
1958
|
+
* initializes the ATOM stats and transfers, paying every fee.
|
|
1959
|
+
*/
|
|
1960
|
+
registerAgentAsync(request: RegisterAgentRequest): Promise<RegisterJobResponse>;
|
|
1961
|
+
/**
|
|
1962
|
+
* Read the current state of an asynchronous registration.
|
|
1963
|
+
*
|
|
1964
|
+
* Throws {@link Erc8004LookupError} with `notFound` when the job is unknown or
|
|
1965
|
+
* has aged out — terminal jobs are kept for one hour.
|
|
1966
|
+
*/
|
|
1967
|
+
getRegisterStatus(jobId: string): Promise<RegisterJobResponse>;
|
|
1968
|
+
/**
|
|
1969
|
+
* Poll an asynchronous registration until it finishes.
|
|
1970
|
+
*
|
|
1971
|
+
* Rejects on timeout rather than resolving with the last non-terminal status,
|
|
1972
|
+
* so "still pending" is never mistaken for "did not happen": the mint may
|
|
1973
|
+
* still land afterwards, and treating a timeout as failure is what leads to
|
|
1974
|
+
* registering the same agent twice. Keep the job id and poll again rather
|
|
1975
|
+
* than re-registering.
|
|
1976
|
+
*/
|
|
1977
|
+
waitForRegistration(jobId: string, options?: {
|
|
1978
|
+
pollIntervalMs?: number;
|
|
1979
|
+
timeoutMs?: number;
|
|
1980
|
+
}): Promise<RegisterJobResponse>;
|
|
1900
1981
|
/**
|
|
1901
1982
|
* Get registration endpoint metadata
|
|
1902
1983
|
*
|
|
@@ -2390,4 +2471,4 @@ declare class AdvancedEscrowClient {
|
|
|
2390
2471
|
private sendViaAdapter;
|
|
2391
2472
|
}
|
|
2392
2473
|
|
|
2393
|
-
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, 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 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, parsePaymentHeader };
|
|
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 };
|
package/dist/backend/index.js
CHANGED
|
@@ -2553,6 +2553,29 @@ var ERC8004_CONTRACTS = {
|
|
|
2553
2553
|
atomEngineProgram: SOLANA_ATOM_ENGINE
|
|
2554
2554
|
}
|
|
2555
2555
|
};
|
|
2556
|
+
var Erc8004LookupError = class extends Error {
|
|
2557
|
+
/** HTTP status returned by the facilitator */
|
|
2558
|
+
status;
|
|
2559
|
+
/** Raw response body, for debugging */
|
|
2560
|
+
body;
|
|
2561
|
+
constructor(message, status, body) {
|
|
2562
|
+
super(message);
|
|
2563
|
+
this.name = "Erc8004LookupError";
|
|
2564
|
+
this.status = status;
|
|
2565
|
+
this.body = body;
|
|
2566
|
+
}
|
|
2567
|
+
/** The address genuinely owns no agent on this network. */
|
|
2568
|
+
get notFound() {
|
|
2569
|
+
return this.status === 404;
|
|
2570
|
+
}
|
|
2571
|
+
/** The lookup reached no verdict. Retry; never read as "owns nothing". */
|
|
2572
|
+
get retryable() {
|
|
2573
|
+
return this.status === 503;
|
|
2574
|
+
}
|
|
2575
|
+
};
|
|
2576
|
+
function isRegisterJobTerminal(job) {
|
|
2577
|
+
return job.status === "done" || job.status === "failed";
|
|
2578
|
+
}
|
|
2556
2579
|
var Erc8004Client = class {
|
|
2557
2580
|
baseUrl;
|
|
2558
2581
|
timeout;
|
|
@@ -2616,7 +2639,11 @@ var Erc8004Client = class {
|
|
|
2616
2639
|
clearTimeout(timeoutId);
|
|
2617
2640
|
if (!response.ok) {
|
|
2618
2641
|
const errorText = await response.text();
|
|
2619
|
-
throw new
|
|
2642
|
+
throw new Erc8004LookupError(
|
|
2643
|
+
`ERC-8004 API error: ${response.status} - ${errorText}`,
|
|
2644
|
+
response.status,
|
|
2645
|
+
errorText
|
|
2646
|
+
);
|
|
2620
2647
|
}
|
|
2621
2648
|
return await response.json();
|
|
2622
2649
|
} catch (error) {
|
|
@@ -2984,6 +3011,107 @@ var Erc8004Client = class {
|
|
|
2984
3011
|
};
|
|
2985
3012
|
}
|
|
2986
3013
|
}
|
|
3014
|
+
/**
|
|
3015
|
+
* Start a registration without waiting for the chain to confirm it.
|
|
3016
|
+
*
|
|
3017
|
+
* Registration waits on a mint receipt, which on a congested chain outlives
|
|
3018
|
+
* client and proxy timeouts. A timed-out synchronous call is genuinely
|
|
3019
|
+
* ambiguous — the mint may well have landed — and retrying it is how five
|
|
3020
|
+
* duplicate agents once got minted. This returns immediately with a job id
|
|
3021
|
+
* instead; poll {@link getRegisterStatus} or use {@link waitForRegistration}.
|
|
3022
|
+
*
|
|
3023
|
+
* On Solana, `recipient` is a base58 address: the facilitator mints,
|
|
3024
|
+
* initializes the ATOM stats and transfers, paying every fee.
|
|
3025
|
+
*/
|
|
3026
|
+
async registerAgentAsync(request) {
|
|
3027
|
+
const url = `${this.baseUrl}/register`;
|
|
3028
|
+
const controller = new AbortController();
|
|
3029
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
3030
|
+
try {
|
|
3031
|
+
const response = await fetch(url, {
|
|
3032
|
+
method: "POST",
|
|
3033
|
+
headers: {
|
|
3034
|
+
"Content-Type": "application/json",
|
|
3035
|
+
"Accept": "application/json",
|
|
3036
|
+
"Prefer": "respond-async"
|
|
3037
|
+
},
|
|
3038
|
+
body: JSON.stringify(request),
|
|
3039
|
+
signal: controller.signal
|
|
3040
|
+
});
|
|
3041
|
+
clearTimeout(timeoutId);
|
|
3042
|
+
if (!response.ok) {
|
|
3043
|
+
const errorText = await response.text();
|
|
3044
|
+
throw new Erc8004LookupError(
|
|
3045
|
+
`ERC-8004 API error: ${response.status} - ${errorText}`,
|
|
3046
|
+
response.status,
|
|
3047
|
+
errorText
|
|
3048
|
+
);
|
|
3049
|
+
}
|
|
3050
|
+
return await response.json();
|
|
3051
|
+
} catch (error) {
|
|
3052
|
+
clearTimeout(timeoutId);
|
|
3053
|
+
throw error;
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
/**
|
|
3057
|
+
* Read the current state of an asynchronous registration.
|
|
3058
|
+
*
|
|
3059
|
+
* Throws {@link Erc8004LookupError} with `notFound` when the job is unknown or
|
|
3060
|
+
* has aged out — terminal jobs are kept for one hour.
|
|
3061
|
+
*/
|
|
3062
|
+
async getRegisterStatus(jobId) {
|
|
3063
|
+
const url = `${this.baseUrl}/register/status/${encodeURIComponent(jobId)}`;
|
|
3064
|
+
const controller = new AbortController();
|
|
3065
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
3066
|
+
try {
|
|
3067
|
+
const response = await fetch(url, {
|
|
3068
|
+
method: "GET",
|
|
3069
|
+
headers: { "Accept": "application/json" },
|
|
3070
|
+
signal: controller.signal
|
|
3071
|
+
});
|
|
3072
|
+
clearTimeout(timeoutId);
|
|
3073
|
+
if (!response.ok) {
|
|
3074
|
+
const errorText = await response.text();
|
|
3075
|
+
throw new Erc8004LookupError(
|
|
3076
|
+
`ERC-8004 API error: ${response.status} - ${errorText}`,
|
|
3077
|
+
response.status,
|
|
3078
|
+
errorText
|
|
3079
|
+
);
|
|
3080
|
+
}
|
|
3081
|
+
return await response.json();
|
|
3082
|
+
} catch (error) {
|
|
3083
|
+
clearTimeout(timeoutId);
|
|
3084
|
+
throw error;
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
/**
|
|
3088
|
+
* Poll an asynchronous registration until it finishes.
|
|
3089
|
+
*
|
|
3090
|
+
* Rejects on timeout rather than resolving with the last non-terminal status,
|
|
3091
|
+
* so "still pending" is never mistaken for "did not happen": the mint may
|
|
3092
|
+
* still land afterwards, and treating a timeout as failure is what leads to
|
|
3093
|
+
* registering the same agent twice. Keep the job id and poll again rather
|
|
3094
|
+
* than re-registering.
|
|
3095
|
+
*/
|
|
3096
|
+
async waitForRegistration(jobId, options) {
|
|
3097
|
+
const pollIntervalMs = options?.pollIntervalMs ?? 2e3;
|
|
3098
|
+
const timeoutMs = options?.timeoutMs ?? 3e5;
|
|
3099
|
+
const deadline = Date.now() + timeoutMs;
|
|
3100
|
+
for (; ; ) {
|
|
3101
|
+
const job = await this.getRegisterStatus(jobId);
|
|
3102
|
+
if (isRegisterJobTerminal(job)) {
|
|
3103
|
+
return job;
|
|
3104
|
+
}
|
|
3105
|
+
if (Date.now() >= deadline) {
|
|
3106
|
+
throw new Error(
|
|
3107
|
+
`Registration job ${jobId} still '${job.status}' after ${Math.round(
|
|
3108
|
+
timeoutMs / 1e3
|
|
3109
|
+
)}s. It may still complete: poll getRegisterStatus('${jobId}') rather than registering again.`
|
|
3110
|
+
);
|
|
3111
|
+
}
|
|
3112
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
2987
3115
|
/**
|
|
2988
3116
|
* Get registration endpoint metadata
|
|
2989
3117
|
*
|
|
@@ -4007,6 +4135,7 @@ exports.ERC8004_EXTENSION_ID = ERC8004_EXTENSION_ID;
|
|
|
4007
4135
|
exports.ESCROW_CONTRACTS = ESCROW_CONTRACTS;
|
|
4008
4136
|
exports.ESCROW_TIMEOUT_MS = ESCROW_TIMEOUT_MS;
|
|
4009
4137
|
exports.Erc8004Client = Erc8004Client;
|
|
4138
|
+
exports.Erc8004LookupError = Erc8004LookupError;
|
|
4010
4139
|
exports.EscrowClient = EscrowClient;
|
|
4011
4140
|
exports.FacilitatorClient = FacilitatorClient;
|
|
4012
4141
|
exports.HEALTH_FILTERS = HEALTH_FILTERS;
|
|
@@ -4040,6 +4169,7 @@ exports.getEscrowSupportedChainIds = getEscrowSupportedChainIds;
|
|
|
4040
4169
|
exports.isAlive = isAlive;
|
|
4041
4170
|
exports.isEscrowExpired = isEscrowExpired;
|
|
4042
4171
|
exports.isEscrowSupportedOnChain = isEscrowSupportedOnChain;
|
|
4172
|
+
exports.isRegisterJobTerminal = isRegisterJobTerminal;
|
|
4043
4173
|
exports.parsePaymentHeader = parsePaymentHeader;
|
|
4044
4174
|
//# sourceMappingURL=index.js.map
|
|
4045
4175
|
//# sourceMappingURL=index.js.map
|