uvd-x402-sdk 2.69.0 → 2.70.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.
@@ -2606,6 +2606,20 @@ var ERC8004_CONTRACTS = {
2606
2606
  function wireNetwork(network) {
2607
2607
  return network === "base-mainnet" ? "base" : network;
2608
2608
  }
2609
+ var RELAYED_FEEDBACK_NETWORKS = [
2610
+ "base",
2611
+ "ethereum",
2612
+ "polygon",
2613
+ "arbitrum",
2614
+ "optimism",
2615
+ "celo",
2616
+ "bsc",
2617
+ "monad",
2618
+ "base-sepolia"
2619
+ ];
2620
+ function supportsRelayedFeedback(network) {
2621
+ return RELAYED_FEEDBACK_NETWORKS.includes(wireNetwork(network));
2622
+ }
2609
2623
  var Erc8004LookupError = class extends Error {
2610
2624
  /** HTTP status returned by the facilitator */
2611
2625
  status;
@@ -2803,6 +2817,14 @@ var Erc8004Client = class {
2803
2817
  *
2804
2818
  * Requires proof of payment for authorized feedback submission.
2805
2819
  *
2820
+ * @deprecated On this route the facilitator is the AUTHOR: the registry
2821
+ * records `msg.sender`, and that is the facilitator's wallet — which can also
2822
+ * revoke what it wrote. On the networks in {@link RELAYED_FEEDBACK_NETWORKS}
2823
+ * use {@link Erc8004Client.prepareRelayedFeedback} +
2824
+ * {@link Erc8004Client.submitRelayedFeedback} instead, which record the RATER
2825
+ * as author. This route still works and is not going away without notice: it
2826
+ * is the only one available where no `FeedbackDelegate` is deployed.
2827
+ *
2806
2828
  * @param request - Feedback request with agent ID, value, and proof
2807
2829
  * @returns Feedback response with transaction hash
2808
2830
  *
@@ -2862,6 +2884,132 @@ var Erc8004Client = class {
2862
2884
  };
2863
2885
  }
2864
2886
  }
2887
+ /**
2888
+ * Ask the facilitator what the rater must sign to author a rating.
2889
+ *
2890
+ * Step 1 of the rater-authored rail. Writes nothing on-chain and costs
2891
+ * nothing: it reads the delegate, the rater's delegation state and their
2892
+ * account nonce, then hands back a digest, a deadline and a single-use nonce.
2893
+ *
2894
+ * Why this exists: the ERC-8004 Reputation Registry records `msg.sender` as
2895
+ * the author, and the deployed implementation has no delegation path — no
2896
+ * `giveFeedbackWithSignature`, no ERC-2771 forwarder. So a rating the
2897
+ * facilitator relays the ordinary way is a rating attributed to the
2898
+ * FACILITATOR. EIP-7702 fixes it without touching the registry: the rater
2899
+ * delegates their own EOA to the `FeedbackDelegate` and the transaction is
2900
+ * sent TO THE RATER'S ADDRESS, so the registry sees the rater while the
2901
+ * facilitator pays.
2902
+ *
2903
+ * What to do with the answer:
2904
+ * 1. Sign `digest` with the rater's key (EIP-191 personal-sign).
2905
+ * 2. If `delegated` is `false`, also produce an EIP-7702 authorization over
2906
+ * `(chainId, delegate, accountNonce)`.
2907
+ * 3. Hand both to {@link submitRelayedFeedback} with the SAME feedback
2908
+ * parameters, `deadline` and `nonce`.
2909
+ *
2910
+ * @param request - Network, rater address and feedback parameters
2911
+ * @returns Everything needed to sign, including whether an EIP-7702
2912
+ * authorization is still required
2913
+ *
2914
+ * @example
2915
+ * ```ts
2916
+ * const prep = await erc8004.prepareRelayedFeedback({
2917
+ * x402Version: 1,
2918
+ * network: 'base',
2919
+ * feedback: { agentId: 18896, value: 95, tag1: 'quality', rater: raterAddress },
2920
+ * });
2921
+ * // prep.delegated === false -> an EIP-7702 authorization is required
2922
+ * ```
2923
+ */
2924
+ async prepareRelayedFeedback(request) {
2925
+ const url = `${this.baseUrl}/feedback/evm/prepare`;
2926
+ const controller = new AbortController();
2927
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
2928
+ try {
2929
+ const response = await fetch(url, {
2930
+ method: "POST",
2931
+ headers: {
2932
+ "Content-Type": "application/json",
2933
+ "Accept": "application/json"
2934
+ },
2935
+ body: JSON.stringify({ ...request, network: wireNetwork(request.network) }),
2936
+ signal: controller.signal
2937
+ });
2938
+ clearTimeout(timeoutId);
2939
+ if (!response.ok) {
2940
+ const errorText = await response.text();
2941
+ return {
2942
+ success: false,
2943
+ delegated: false,
2944
+ chainId: 0,
2945
+ error: `Facilitator error: ${response.status} - ${errorText}`,
2946
+ network: request.network
2947
+ };
2948
+ }
2949
+ return await response.json();
2950
+ } catch (error) {
2951
+ clearTimeout(timeoutId);
2952
+ return {
2953
+ success: false,
2954
+ delegated: false,
2955
+ chainId: 0,
2956
+ error: error instanceof Error ? error.message : "Unknown error",
2957
+ network: request.network
2958
+ };
2959
+ }
2960
+ }
2961
+ /**
2962
+ * Relay a rater-authored rating; the facilitator pays the gas.
2963
+ *
2964
+ * Step 2 of the rater-authored rail. The on-chain record that comes out of it
2965
+ * has the RATER as `msg.sender`, so `getClients(agentId)` shows the rater
2966
+ * rather than the facilitator.
2967
+ *
2968
+ * Pass back the same feedback parameters, `deadline` and `nonce` that
2969
+ * {@link prepareRelayedFeedback} returned. They are not redundant: the
2970
+ * facilitator rebuilds the registry calldata from them and requires the
2971
+ * rater's signature to cover exactly that.
2972
+ *
2973
+ * `authorization` is required only when `prepare` answered
2974
+ * `delegated: false`. One that names a different delegate than the one
2975
+ * `prepare` offered is refused before any gas is spent.
2976
+ *
2977
+ * @param request - Feedback parameters plus the rater's signature
2978
+ * @returns Feedback response with the transaction hash
2979
+ */
2980
+ async submitRelayedFeedback(request) {
2981
+ const url = `${this.baseUrl}/feedback/evm/submit`;
2982
+ const controller = new AbortController();
2983
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
2984
+ try {
2985
+ const response = await fetch(url, {
2986
+ method: "POST",
2987
+ headers: {
2988
+ "Content-Type": "application/json",
2989
+ "Accept": "application/json"
2990
+ },
2991
+ body: JSON.stringify({ ...request, network: wireNetwork(request.network) }),
2992
+ signal: controller.signal
2993
+ });
2994
+ clearTimeout(timeoutId);
2995
+ if (!response.ok) {
2996
+ const errorText = await response.text();
2997
+ return {
2998
+ success: false,
2999
+ error: `Facilitator error: ${response.status} - ${errorText}`,
3000
+ network: request.network
3001
+ };
3002
+ }
3003
+ return await response.json();
3004
+ } catch (error) {
3005
+ clearTimeout(timeoutId);
3006
+ return {
3007
+ success: false,
3008
+ error: error instanceof Error ? error.message : "Unknown error",
3009
+ network: request.network
3010
+ };
3011
+ }
3012
+ }
2865
3013
  /**
2866
3014
  * Revoke previously submitted feedback
2867
3015
  *
@@ -4231,6 +4379,6 @@ var AdvancedEscrowClient = class {
4231
4379
  }
4232
4380
  };
4233
4381
 
4234
- 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, wireNetwork };
4382
+ 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, RELAYED_FEEDBACK_NETWORKS, 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, supportsRelayedFeedback, wireNetwork };
4235
4383
  //# sourceMappingURL=index.mjs.map
4236
4384
  //# sourceMappingURL=index.mjs.map