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.
@@ -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,139 @@ 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. Produce the rater's signature. **Which value you sign depends on how you
2905
+ * sign it**, and getting it wrong yields a well-formed signature that
2906
+ * authorises nobody:
2907
+ * - raw key: sign `digest` as a **prehash**. It already carries the
2908
+ * EIP-191 envelope.
2909
+ * - wallet: `personal_sign` over `signingPayload`. `personal_sign` adds the
2910
+ * envelope itself, so signing `digest` with it wraps the value TWICE and
2911
+ * recovers a stranger — the only symptom is `relay_bad_signature`.
2912
+ * 2. If `delegated` is `false`, also produce an EIP-7702 authorization over
2913
+ * `(chainId, delegate, accountNonce)`.
2914
+ * 3. Hand both to {@link submitRelayedFeedback} with the SAME feedback
2915
+ * parameters, `deadline` and `nonce`.
2916
+ *
2917
+ * @param request - Network, rater address and feedback parameters
2918
+ * @returns Everything needed to sign, including whether an EIP-7702
2919
+ * authorization is still required
2920
+ *
2921
+ * @example
2922
+ * ```ts
2923
+ * const prep = await erc8004.prepareRelayedFeedback({
2924
+ * x402Version: 1,
2925
+ * network: 'base',
2926
+ * feedback: { agentId: 18896, value: 95, tag1: 'quality', rater: raterAddress },
2927
+ * });
2928
+ * // prep.delegated === false -> an EIP-7702 authorization is required
2929
+ * ```
2930
+ */
2931
+ async prepareRelayedFeedback(request) {
2932
+ const url = `${this.baseUrl}/feedback/evm/prepare`;
2933
+ const controller = new AbortController();
2934
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
2935
+ try {
2936
+ const response = await fetch(url, {
2937
+ method: "POST",
2938
+ headers: {
2939
+ "Content-Type": "application/json",
2940
+ "Accept": "application/json"
2941
+ },
2942
+ body: JSON.stringify({ ...request, network: wireNetwork(request.network) }),
2943
+ signal: controller.signal
2944
+ });
2945
+ clearTimeout(timeoutId);
2946
+ if (!response.ok) {
2947
+ const errorText = await response.text();
2948
+ return {
2949
+ success: false,
2950
+ delegated: false,
2951
+ chainId: 0,
2952
+ error: `Facilitator error: ${response.status} - ${errorText}`,
2953
+ network: request.network
2954
+ };
2955
+ }
2956
+ return await response.json();
2957
+ } catch (error) {
2958
+ clearTimeout(timeoutId);
2959
+ return {
2960
+ success: false,
2961
+ delegated: false,
2962
+ chainId: 0,
2963
+ error: error instanceof Error ? error.message : "Unknown error",
2964
+ network: request.network
2965
+ };
2966
+ }
2967
+ }
2968
+ /**
2969
+ * Relay a rater-authored rating; the facilitator pays the gas.
2970
+ *
2971
+ * Step 2 of the rater-authored rail. The on-chain record that comes out of it
2972
+ * has the RATER as `msg.sender`, so `getClients(agentId)` shows the rater
2973
+ * rather than the facilitator.
2974
+ *
2975
+ * Pass back the same feedback parameters, `deadline` and `nonce` that
2976
+ * {@link prepareRelayedFeedback} returned. They are not redundant: the
2977
+ * facilitator rebuilds the registry calldata from them and requires the
2978
+ * rater's signature to cover exactly that.
2979
+ *
2980
+ * `authorization` is required only when `prepare` answered
2981
+ * `delegated: false`. One that names a different delegate than the one
2982
+ * `prepare` offered is refused before any gas is spent.
2983
+ *
2984
+ * @param request - Feedback parameters plus the rater's signature
2985
+ * @returns Feedback response with the transaction hash
2986
+ */
2987
+ async submitRelayedFeedback(request) {
2988
+ const url = `${this.baseUrl}/feedback/evm/submit`;
2989
+ const controller = new AbortController();
2990
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
2991
+ try {
2992
+ const response = await fetch(url, {
2993
+ method: "POST",
2994
+ headers: {
2995
+ "Content-Type": "application/json",
2996
+ "Accept": "application/json"
2997
+ },
2998
+ body: JSON.stringify({ ...request, network: wireNetwork(request.network) }),
2999
+ signal: controller.signal
3000
+ });
3001
+ clearTimeout(timeoutId);
3002
+ if (!response.ok) {
3003
+ const errorText = await response.text();
3004
+ return {
3005
+ success: false,
3006
+ error: `Facilitator error: ${response.status} - ${errorText}`,
3007
+ network: request.network
3008
+ };
3009
+ }
3010
+ return await response.json();
3011
+ } catch (error) {
3012
+ clearTimeout(timeoutId);
3013
+ return {
3014
+ success: false,
3015
+ error: error instanceof Error ? error.message : "Unknown error",
3016
+ network: request.network
3017
+ };
3018
+ }
3019
+ }
2865
3020
  /**
2866
3021
  * Revoke previously submitted feedback
2867
3022
  *
@@ -4231,6 +4386,6 @@ var AdvancedEscrowClient = class {
4231
4386
  }
4232
4387
  };
4233
4388
 
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 };
4389
+ 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
4390
  //# sourceMappingURL=index.mjs.map
4236
4391
  //# sourceMappingURL=index.mjs.map