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