uvd-x402-sdk 2.52.0 → 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.
- package/dist/backend/index.d.mts +24 -2
- package/dist/backend/index.d.ts +24 -2
- package/dist/backend/index.js +52 -6
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs +52 -7
- 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 +91 -6
package/dist/backend/index.mjs
CHANGED
|
@@ -2574,6 +2574,34 @@ var Erc8004LookupError = class extends Error {
|
|
|
2574
2574
|
function isRegisterJobTerminal(job) {
|
|
2575
2575
|
return job.status === "done" || job.status === "failed";
|
|
2576
2576
|
}
|
|
2577
|
+
var RegistrationPendingError = class extends Error {
|
|
2578
|
+
jobId;
|
|
2579
|
+
lastStatus;
|
|
2580
|
+
timeoutMs;
|
|
2581
|
+
retryable = true;
|
|
2582
|
+
constructor(jobId, lastStatus, timeoutMs) {
|
|
2583
|
+
super(
|
|
2584
|
+
`Registration job ${jobId} still '${lastStatus}' after ${Math.round(
|
|
2585
|
+
timeoutMs / 1e3
|
|
2586
|
+
)}s. It may still complete: poll getRegisterStatus('${jobId}') rather than registering again.`
|
|
2587
|
+
);
|
|
2588
|
+
this.name = "RegistrationPendingError";
|
|
2589
|
+
this.jobId = jobId;
|
|
2590
|
+
this.lastStatus = lastStatus;
|
|
2591
|
+
this.timeoutMs = timeoutMs;
|
|
2592
|
+
}
|
|
2593
|
+
};
|
|
2594
|
+
function jobToRegisterResponse(job, network) {
|
|
2595
|
+
return {
|
|
2596
|
+
success: job.status !== "failed",
|
|
2597
|
+
agentId: job.agentId,
|
|
2598
|
+
transaction: job.transaction,
|
|
2599
|
+
transferTransaction: job.transferTransaction,
|
|
2600
|
+
owner: job.owner,
|
|
2601
|
+
error: job.error,
|
|
2602
|
+
network: job.network ?? network
|
|
2603
|
+
};
|
|
2604
|
+
}
|
|
2577
2605
|
var Erc8004Client = class {
|
|
2578
2606
|
baseUrl;
|
|
2579
2607
|
timeout;
|
|
@@ -2976,7 +3004,15 @@ var Erc8004Client = class {
|
|
|
2976
3004
|
* console.log(`Agent #${result.agentId} transferred to user`);
|
|
2977
3005
|
* ```
|
|
2978
3006
|
*/
|
|
2979
|
-
async registerAgent(request) {
|
|
3007
|
+
async registerAgent(request, options) {
|
|
3008
|
+
if (options?.asyncTransport) {
|
|
3009
|
+
const job = await this.registerAgentAsync(request);
|
|
3010
|
+
const terminal = await this.waitForRegistration(job.jobId, {
|
|
3011
|
+
pollIntervalMs: options.pollIntervalMs,
|
|
3012
|
+
timeoutMs: options.timeoutMs
|
|
3013
|
+
});
|
|
3014
|
+
return jobToRegisterResponse(terminal, request.network);
|
|
3015
|
+
}
|
|
2980
3016
|
const url = `${this.baseUrl}/register`;
|
|
2981
3017
|
const controller = new AbortController();
|
|
2982
3018
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
@@ -2993,6 +3029,19 @@ var Erc8004Client = class {
|
|
|
2993
3029
|
clearTimeout(timeoutId);
|
|
2994
3030
|
if (!response.ok) {
|
|
2995
3031
|
const errorText = await response.text();
|
|
3032
|
+
try {
|
|
3033
|
+
const parsed = JSON.parse(errorText);
|
|
3034
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
3035
|
+
return {
|
|
3036
|
+
...parsed,
|
|
3037
|
+
// Never let a 4xx body claim success, whatever it says.
|
|
3038
|
+
success: false,
|
|
3039
|
+
error: parsed.error ?? `Facilitator error: ${response.status}`,
|
|
3040
|
+
network: parsed.network ?? request.network
|
|
3041
|
+
};
|
|
3042
|
+
}
|
|
3043
|
+
} catch {
|
|
3044
|
+
}
|
|
2996
3045
|
return {
|
|
2997
3046
|
success: false,
|
|
2998
3047
|
error: `Facilitator error: ${response.status} - ${errorText}`,
|
|
@@ -3101,11 +3150,7 @@ var Erc8004Client = class {
|
|
|
3101
3150
|
return job;
|
|
3102
3151
|
}
|
|
3103
3152
|
if (Date.now() >= deadline) {
|
|
3104
|
-
throw new
|
|
3105
|
-
`Registration job ${jobId} still '${job.status}' after ${Math.round(
|
|
3106
|
-
timeoutMs / 1e3
|
|
3107
|
-
)}s. It may still complete: poll getRegisterStatus('${jobId}') rather than registering again.`
|
|
3108
|
-
);
|
|
3153
|
+
throw new RegistrationPendingError(jobId, job.status, timeoutMs);
|
|
3109
3154
|
}
|
|
3110
3155
|
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
3111
3156
|
}
|
|
@@ -4124,6 +4169,6 @@ var AdvancedEscrowClient = class {
|
|
|
4124
4169
|
}
|
|
4125
4170
|
};
|
|
4126
4171
|
|
|
4127
|
-
export { AdvancedEscrowClient, BASE_MAINNET_CONTRACTS, BazaarClient, DEPOSIT_LIMIT_USDC, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, Erc8004LookupError, EscrowClient, FacilitatorClient, HEALTH_FILTERS, MAX_SEARCH_LEN, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, 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 };
|
|
4172
|
+
export { AdvancedEscrowClient, BASE_MAINNET_CONTRACTS, BazaarClient, DEPOSIT_LIMIT_USDC, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, Erc8004LookupError, EscrowClient, FacilitatorClient, HEALTH_FILTERS, MAX_SEARCH_LEN, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, RegistrationPendingError, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, 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 };
|
|
4128
4173
|
//# sourceMappingURL=index.mjs.map
|
|
4129
4174
|
//# sourceMappingURL=index.mjs.map
|