@haven_ai/sdk 0.9.0-alpha.0 → 0.10.0-alpha.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/README.md +1 -1
- package/dist/{base64-BZDPJ8M1.d.ts → base64-CiR5BJhk.d.cts} +11 -3
- package/dist/{base64-Cyxhsvqd.d.cts → base64-CxkinHPQ.d.ts} +11 -3
- package/dist/{chunk-ZDKNPNI3.cjs → chunk-22FJ4JQO.cjs} +41 -35
- package/dist/chunk-22FJ4JQO.cjs.map +1 -0
- package/dist/{chunk-7UTWSJC5.cjs → chunk-6LEXYQ7J.cjs} +4 -4
- package/dist/{chunk-7UTWSJC5.cjs.map → chunk-6LEXYQ7J.cjs.map} +1 -1
- package/dist/{chunk-VRKWNJ7H.js → chunk-EWTHDEIW.js} +3 -3
- package/dist/{chunk-VRKWNJ7H.js.map → chunk-EWTHDEIW.js.map} +1 -1
- package/dist/{chunk-4Z6ATE44.cjs → chunk-H37YVYZA.cjs} +6 -4
- package/dist/chunk-H37YVYZA.cjs.map +1 -0
- package/dist/{chunk-424S4QMG.js → chunk-MLUWABVT.js} +10 -6
- package/dist/chunk-MLUWABVT.js.map +1 -0
- package/dist/{chunk-J7N4LUZZ.js → chunk-TD2PHUYP.js} +6 -4
- package/dist/chunk-TD2PHUYP.js.map +1 -0
- package/dist/edge.cjs +99 -91
- package/dist/edge.d.cts +4 -4
- package/dist/edge.d.ts +4 -4
- package/dist/edge.js +4 -4
- package/dist/index.cjs +430 -333
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -9
- package/dist/index.d.ts +41 -9
- package/dist/index.js +109 -21
- package/dist/index.js.map +1 -1
- package/dist/{receipt-WkXHZGbu.d.ts → receipt-Cg9a5Seq.d.ts} +1 -1
- package/dist/{receipt-D4Roey3D.d.cts → receipt-q7ez8Zb2.d.cts} +1 -1
- package/dist/test-support.cjs +21 -21
- package/dist/test-support.d.cts +2 -2
- package/dist/test-support.d.ts +2 -2
- package/dist/test-support.js +2 -2
- package/dist/{types-CrszUJ7Z.d.cts → types-BKgqzvnk.d.cts} +31 -2
- package/dist/{types-CrszUJ7Z.d.ts → types-BKgqzvnk.d.ts} +31 -2
- package/package.json +1 -1
- package/dist/chunk-424S4QMG.js.map +0 -1
- package/dist/chunk-4Z6ATE44.cjs.map +0 -1
- package/dist/chunk-J7N4LUZZ.js.map +0 -1
- package/dist/chunk-ZDKNPNI3.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -454,7 +454,7 @@ Hosted MCP and signer tools also return stable `code` values on recoverable x402
|
|
|
454
454
|
| `PRICE_EXCEEDS_MAX` | The merchant-authoritative x402 price is above the caller's spending cap. No funding transfer was created. | Tell the user the live price exceeded the cap and retry only after they confirm a higher one. Payloads carry `next_action: stop_and_tell_user` and `retry_with_new_quote: true` — the latter means any retry needs a fresh quote, not that one should be attempted unattended. |
|
|
455
455
|
| `AMBIGUOUS_MAX_AMOUNT` | Both `max_amount` (atomic units) and `max_amount_human` (whole tokens) were sent for one purchase. Nothing was contacted and nothing was spent. | Re-send with exactly one — `max_amount_human` for a cap the user stated in tokens, `max_amount` for an exact atomic figure. |
|
|
456
456
|
| `MAX_AMOUNT_UNCONVERTIBLE` | `max_amount_human` could not be converted against this quote's asset — its decimals are unknown to Haven, or the cap has more decimal places than the asset supports. Nothing was spent. | Round the cap to the asset's decimals, or re-send it as an exact atomic `max_amount`. |
|
|
457
|
-
| `MERCHANT_NOT_READY` | The merchant answered the quote probe with its own `503 { error: 'merchant_not_ready', reason_code, retry_after_s }` instead of a 402 — it cannot settle right now (e.g. its settlement wallet is out of gas). No payment was created. | Tell the user and retry later (`retry_after_s` in the message when given); do not treat it as a wrong endpoint. Payloads carry `next_action: stop_and_tell_user` and `retry_with_new_quote: true`. |
|
|
457
|
+
| `MERCHANT_NOT_READY` | The merchant answered the quote probe with its own `503 { error: 'merchant_not_ready', reason_code, retry_after_s }` instead of a 402 — it cannot settle right now (e.g. its settlement wallet is out of gas). No payment was created. | Tell the user and retry later (`retry_after_s` in the message when given); do not treat it as a wrong endpoint. An out-of-gas refusal (`reason_code: settlement_wallet_out_of_gas`) needs the merchant's operator to top up its settlement wallet first; retrying before then is refused again. Payloads carry `next_action: stop_and_tell_user` and `retry_with_new_quote: true`. |
|
|
458
458
|
| `PAYMENT_WINDOW_EXPIRED` | The funding/quote window closed before `haven_x402_sign_header`, `haven_submit`, or `haven_complete_mcp_tool` could finish. | Re-run `haven_pay_mcp_tool` with the same `idempotency_key`, then sign and complete the fresh quote. Payloads include `retry_with_new_quote: true`. |
|
|
459
459
|
| `MERCHANT_REJECTED_AFTER_FUNDING` | The merchant rejected the paid retry. On eip3009 Haven's funding leg had succeeded; on erc7710 there is no funding leg (#2983). | eip3009: stop retrying the merchant and call `haven_sweep_delegate` so the user can recover stranded delegate USDC. erc7710: nothing to sweep — follow the message (re-quote later if the merchant declined to settle; otherwise check `haven_get_payment_status` after the payment window before re-quoting). |
|
|
460
460
|
| `MERCHANT_UNRESPONSIVE_AFTER_FUNDING` | The merchant did not answer the paid retry before the timeout — NOT proof of rejection, the merchant may still settle late. On eip3009 Haven's funding leg had succeeded; on erc7710 there is no funding leg (#3000). | eip3009: check `haven_get_payment_status`, retry `haven_complete_mcp_tool` once, and only then call `haven_sweep_delegate` if no settlement appears. erc7710: nothing to sweep and `haven_complete_mcp_tool` has no erc7710 branch — do not retry it; check `haven_get_payment_status` after the payment window and re-quote only if it shows no settlement. |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Q as AgentNextStep, Z as AgentPaymentNextAction,
|
|
1
|
+
import { Q as AgentNextStep, Z as AgentPaymentNextAction, aM as X402PaymentOption, aL as X402ExpectedContext, X as X402PaymentRequired, I as HavenError, an as HavenSigningError } from './types-BKgqzvnk.cjs';
|
|
2
2
|
import { PaymentRequirements } from 'x402/types';
|
|
3
3
|
import { Hex, Address } from 'viem';
|
|
4
4
|
|
|
@@ -200,7 +200,7 @@ declare function buildSweepAuthorizationMessage(auth: SweepAuthorization): strin
|
|
|
200
200
|
* This SDK's own version. Owned by `scripts/release-bump.mjs`, which rewrites
|
|
201
201
|
* it with the package version on every release — never hand-edit it.
|
|
202
202
|
*/
|
|
203
|
-
declare const SDK_VERSION = "0.
|
|
203
|
+
declare const SDK_VERSION = "0.10.0-alpha.0";
|
|
204
204
|
/** The request header every published Haven client sends. */
|
|
205
205
|
declare const HAVEN_CLIENT_HEADER = "X-Haven-Client";
|
|
206
206
|
/** `<package>/<version>` — the value of {@link HAVEN_CLIENT_HEADER}. */
|
|
@@ -846,6 +846,14 @@ declare function resolveTokenBySymbol(chainId: number, symbol: string): {
|
|
|
846
846
|
decimals: number;
|
|
847
847
|
} | null;
|
|
848
848
|
|
|
849
|
+
/** The fixed domain tag. Changing it orphans every settlement not yet detected. */
|
|
850
|
+
declare const X402_PAYMENT_NONCE_TAG = "haven-x402-payment-nonce:";
|
|
851
|
+
/**
|
|
852
|
+
* Derive the EIP-3009 nonce for a Haven payment id. Same input, same output,
|
|
853
|
+
* on every surface that imports this — the signer, the SDK and the backend.
|
|
854
|
+
*/
|
|
855
|
+
declare function deriveX402PaymentNonce(paymentId: string): `0x${string}`;
|
|
856
|
+
|
|
849
857
|
/**
|
|
850
858
|
* #3271: the integrity check every client runs before signing a direct
|
|
851
859
|
* delegation-rail payment's typed data.
|
|
@@ -1341,4 +1349,4 @@ declare function encodeBase64Json(value: unknown): string;
|
|
|
1341
1349
|
*/
|
|
1342
1350
|
declare function decodeBase64Json<T>(value: string, label?: string): T;
|
|
1343
1351
|
|
|
1344
|
-
export { X402_PAYMENT_HEADER_NAMES_SENT as $, type SweepEip712Domain as A, type SweepExpectedAuth as B, CONNECTOR_PACKAGE_NAME as C, DEFAULT_NEXT_TOOL_BY_ACTION as D, ENTRY_POINT_V07 as E, type SweepPreparation as F, type SweepSubmitResult as G, type HavenClientUpdate as H, type SweepTypedData as I, TRANSFER_WITH_AUTHORIZATION_TYPES as J, TYPED_DATA_NOT_ALLOWED as K, type TaskBudgetCloseExpectation as L, MAX_TASK_BUDGET_TTL_SECONDS as M, NEXT_TOOL_SERVER_NAMES as N, type TaskChildExpectation as O, PACKED_USER_OPERATION_FIELDS as P, type TaskChildTypedData as Q, ROOT_AUTHORITY as R, type SweepPrepareResponse as S, TASK_SIGN_CONTEXT_VERSION as T, type UnsupportedNodeVersionMessageOptions as U, X402PaymentHeaderValidationError as V, type X402SchemeSelection as W, type X402PaymentHeaderContext as X, X402_LEGACY_PAYMENT_HEADER_NAME as Y, X402_MAX_AUTHORIZATION_WINDOW_SECONDS as Z, X402_PAYMENT_HEADER_NAME as _, type SweepAuthorization as a,
|
|
1352
|
+
export { X402_PAYMENT_HEADER_NAMES_SENT as $, type SweepEip712Domain as A, type SweepExpectedAuth as B, CONNECTOR_PACKAGE_NAME as C, DEFAULT_NEXT_TOOL_BY_ACTION as D, ENTRY_POINT_V07 as E, type SweepPreparation as F, type SweepSubmitResult as G, type HavenClientUpdate as H, type SweepTypedData as I, TRANSFER_WITH_AUTHORIZATION_TYPES as J, TYPED_DATA_NOT_ALLOWED as K, type TaskBudgetCloseExpectation as L, MAX_TASK_BUDGET_TTL_SECONDS as M, NEXT_TOOL_SERVER_NAMES as N, type TaskChildExpectation as O, PACKED_USER_OPERATION_FIELDS as P, type TaskChildTypedData as Q, ROOT_AUTHORITY as R, type SweepPrepareResponse as S, TASK_SIGN_CONTEXT_VERSION as T, type UnsupportedNodeVersionMessageOptions as U, X402PaymentHeaderValidationError as V, type X402SchemeSelection as W, type X402PaymentHeaderContext as X, X402_LEGACY_PAYMENT_HEADER_NAME as Y, X402_MAX_AUTHORIZATION_WINDOW_SECONDS as Z, X402_PAYMENT_HEADER_NAME as _, type SweepAuthorization as a, DIRECT_PAYMENT_CHAIN_IDS as a$, X402_PAYMENT_NONCE_TAG as a0, X402_PAYMENT_REQUIRED_HEADER_NAME as a1, X402_PAYMENT_RESPONSE_HEADER_NAME as a2, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS as a3, assertBoundDirectPaymentUserOp as a4, assertOwnTaskBudgetCloseUserOp as a5, assertOwnTaskChild as a6, assertUserOpTypedDataBinding as a7, buildSweepAuthorizationMessage as a8, buildSweepTypedData as a9, parsePaymentRequiredResponse as aA, readClientUpdate as aB, renderNextTool as aC, resolveConnectorChannel as aD, resolveTokenBySymbol as aE, resolveTokenFromAddress as aF, selectErc7710PaymentOption as aG, selectPaymentOption as aH, selectStandardPaymentOption as aI, selectX402SettlementScheme as aJ, sweepUsdcAddress as aK, sweepUsdcDomain as aL, toStandardPaymentRequirements as aM, unsupportedNodeVersionMessage as aN, validateStandardX402PaymentHeader as aO, verifySettlementChild as aP, x402AssetTransferMethod as aQ, x402AuthorizationAmount as aR, x402FacilitatorAddresses as aS, x402PaymentHeaderNamesFor as aT, x402RetryHeadersFor as aU, x402V2PaymentEnvelope as aV, type DelegationForHashing as aW, CAVEAT_ENFORCERS as aX, CAVEAT_TYPEHASH as aY, DELEGATION_MANAGER as aZ, DELEGATION_TYPEHASH as a_, buildX402ExpectedMessage as aa, compareNodeVersions as ab, connectorRerunCommand as ac, connectorSpec as ad, connectorUpgradeCommand as ae, createNextStepBuilder as af, decodeBase64Json as ag, decodeBase64Utf8 as ah, defaultNextToolFor as ai, deriveDelegateAccountAddress as aj, deriveX402PaymentNonce as ak, encodeBase64Json as al, encodeBase64Utf8 as am, encodePaymentProof as an, hashDelegation as ao, havenClientIdentity as ap, isConnectorChannel as aq, isErc7710Option as ar, isPackedUserOperationTypedData as as, isSupportedNodeVersion as at, isSweepableChain as au, isTaskChildTypedData as av, normalizePaymentRequired as aw, packedUserOperationHash as ax, parseNextTool as ay, parsePaymentRequired as az, type SweepSubmitResponse as b, EXECUTE_ABI as b0, HYBRID_DELEGATOR_IMPLEMENTATION as b1, MAX_SETTLEMENT_WINDOW_SECONDS as b2, SIMPLE_FACTORY_ADDRESS as b3, type SettlementChildTypedData as b4, assertFundingLegPaysDelegate as b5, assertOwnSettlementChild as b6, chainIdForNetwork as b7, isSettlementChildTypedData as b8, DIRECT_SIGN_CONTEXT_VERSION as c, ERC7710_ASSET_TRANSFER_METHOD as d, HAVEN_CLIENT_HEADER as e, HAVEN_CONNECTOR_CHANNEL as f, HAVEN_MINIMUM_NODE_VERSION as g, HYBRID_DELEGATOR_DOMAIN_NAME as h, HYBRID_DELEGATOR_DOMAIN_VERSION as i, HavenTypedDataRefusedError as j, HavenUserOpBindingError as k, NEXT_TOOL_SERVER_ROLES as l, type NextStep as m, type NextStepArguments as n, type NextStepHandoff as o, type NextStepInput as p, type NextStepTarget as q, type NextStepTargets as r, type NextToolServerRole as s, SDK_CLIENT_IDENTITY as t, SDK_VERSION as u, SWEEP_BASE_CHAIN_ID as v, SWEEP_BASE_SEPOLIA_CHAIN_ID as w, SWEEP_BASE_SEPOLIA_USDC_ADDRESS as x, SWEEP_BASE_USDC_ADDRESS as y, type SettlementChildExpectation as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Q as AgentNextStep, Z as AgentPaymentNextAction,
|
|
1
|
+
import { Q as AgentNextStep, Z as AgentPaymentNextAction, aM as X402PaymentOption, aL as X402ExpectedContext, X as X402PaymentRequired, I as HavenError, an as HavenSigningError } from './types-BKgqzvnk.js';
|
|
2
2
|
import { PaymentRequirements } from 'x402/types';
|
|
3
3
|
import { Hex, Address } from 'viem';
|
|
4
4
|
|
|
@@ -200,7 +200,7 @@ declare function buildSweepAuthorizationMessage(auth: SweepAuthorization): strin
|
|
|
200
200
|
* This SDK's own version. Owned by `scripts/release-bump.mjs`, which rewrites
|
|
201
201
|
* it with the package version on every release — never hand-edit it.
|
|
202
202
|
*/
|
|
203
|
-
declare const SDK_VERSION = "0.
|
|
203
|
+
declare const SDK_VERSION = "0.10.0-alpha.0";
|
|
204
204
|
/** The request header every published Haven client sends. */
|
|
205
205
|
declare const HAVEN_CLIENT_HEADER = "X-Haven-Client";
|
|
206
206
|
/** `<package>/<version>` — the value of {@link HAVEN_CLIENT_HEADER}. */
|
|
@@ -846,6 +846,14 @@ declare function resolveTokenBySymbol(chainId: number, symbol: string): {
|
|
|
846
846
|
decimals: number;
|
|
847
847
|
} | null;
|
|
848
848
|
|
|
849
|
+
/** The fixed domain tag. Changing it orphans every settlement not yet detected. */
|
|
850
|
+
declare const X402_PAYMENT_NONCE_TAG = "haven-x402-payment-nonce:";
|
|
851
|
+
/**
|
|
852
|
+
* Derive the EIP-3009 nonce for a Haven payment id. Same input, same output,
|
|
853
|
+
* on every surface that imports this — the signer, the SDK and the backend.
|
|
854
|
+
*/
|
|
855
|
+
declare function deriveX402PaymentNonce(paymentId: string): `0x${string}`;
|
|
856
|
+
|
|
849
857
|
/**
|
|
850
858
|
* #3271: the integrity check every client runs before signing a direct
|
|
851
859
|
* delegation-rail payment's typed data.
|
|
@@ -1341,4 +1349,4 @@ declare function encodeBase64Json(value: unknown): string;
|
|
|
1341
1349
|
*/
|
|
1342
1350
|
declare function decodeBase64Json<T>(value: string, label?: string): T;
|
|
1343
1351
|
|
|
1344
|
-
export { X402_PAYMENT_HEADER_NAMES_SENT as $, type SweepEip712Domain as A, type SweepExpectedAuth as B, CONNECTOR_PACKAGE_NAME as C, DEFAULT_NEXT_TOOL_BY_ACTION as D, ENTRY_POINT_V07 as E, type SweepPreparation as F, type SweepSubmitResult as G, type HavenClientUpdate as H, type SweepTypedData as I, TRANSFER_WITH_AUTHORIZATION_TYPES as J, TYPED_DATA_NOT_ALLOWED as K, type TaskBudgetCloseExpectation as L, MAX_TASK_BUDGET_TTL_SECONDS as M, NEXT_TOOL_SERVER_NAMES as N, type TaskChildExpectation as O, PACKED_USER_OPERATION_FIELDS as P, type TaskChildTypedData as Q, ROOT_AUTHORITY as R, type SweepPrepareResponse as S, TASK_SIGN_CONTEXT_VERSION as T, type UnsupportedNodeVersionMessageOptions as U, X402PaymentHeaderValidationError as V, type X402SchemeSelection as W, type X402PaymentHeaderContext as X, X402_LEGACY_PAYMENT_HEADER_NAME as Y, X402_MAX_AUTHORIZATION_WINDOW_SECONDS as Z, X402_PAYMENT_HEADER_NAME as _, type SweepAuthorization as a,
|
|
1352
|
+
export { X402_PAYMENT_HEADER_NAMES_SENT as $, type SweepEip712Domain as A, type SweepExpectedAuth as B, CONNECTOR_PACKAGE_NAME as C, DEFAULT_NEXT_TOOL_BY_ACTION as D, ENTRY_POINT_V07 as E, type SweepPreparation as F, type SweepSubmitResult as G, type HavenClientUpdate as H, type SweepTypedData as I, TRANSFER_WITH_AUTHORIZATION_TYPES as J, TYPED_DATA_NOT_ALLOWED as K, type TaskBudgetCloseExpectation as L, MAX_TASK_BUDGET_TTL_SECONDS as M, NEXT_TOOL_SERVER_NAMES as N, type TaskChildExpectation as O, PACKED_USER_OPERATION_FIELDS as P, type TaskChildTypedData as Q, ROOT_AUTHORITY as R, type SweepPrepareResponse as S, TASK_SIGN_CONTEXT_VERSION as T, type UnsupportedNodeVersionMessageOptions as U, X402PaymentHeaderValidationError as V, type X402SchemeSelection as W, type X402PaymentHeaderContext as X, X402_LEGACY_PAYMENT_HEADER_NAME as Y, X402_MAX_AUTHORIZATION_WINDOW_SECONDS as Z, X402_PAYMENT_HEADER_NAME as _, type SweepAuthorization as a, DIRECT_PAYMENT_CHAIN_IDS as a$, X402_PAYMENT_NONCE_TAG as a0, X402_PAYMENT_REQUIRED_HEADER_NAME as a1, X402_PAYMENT_RESPONSE_HEADER_NAME as a2, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS as a3, assertBoundDirectPaymentUserOp as a4, assertOwnTaskBudgetCloseUserOp as a5, assertOwnTaskChild as a6, assertUserOpTypedDataBinding as a7, buildSweepAuthorizationMessage as a8, buildSweepTypedData as a9, parsePaymentRequiredResponse as aA, readClientUpdate as aB, renderNextTool as aC, resolveConnectorChannel as aD, resolveTokenBySymbol as aE, resolveTokenFromAddress as aF, selectErc7710PaymentOption as aG, selectPaymentOption as aH, selectStandardPaymentOption as aI, selectX402SettlementScheme as aJ, sweepUsdcAddress as aK, sweepUsdcDomain as aL, toStandardPaymentRequirements as aM, unsupportedNodeVersionMessage as aN, validateStandardX402PaymentHeader as aO, verifySettlementChild as aP, x402AssetTransferMethod as aQ, x402AuthorizationAmount as aR, x402FacilitatorAddresses as aS, x402PaymentHeaderNamesFor as aT, x402RetryHeadersFor as aU, x402V2PaymentEnvelope as aV, type DelegationForHashing as aW, CAVEAT_ENFORCERS as aX, CAVEAT_TYPEHASH as aY, DELEGATION_MANAGER as aZ, DELEGATION_TYPEHASH as a_, buildX402ExpectedMessage as aa, compareNodeVersions as ab, connectorRerunCommand as ac, connectorSpec as ad, connectorUpgradeCommand as ae, createNextStepBuilder as af, decodeBase64Json as ag, decodeBase64Utf8 as ah, defaultNextToolFor as ai, deriveDelegateAccountAddress as aj, deriveX402PaymentNonce as ak, encodeBase64Json as al, encodeBase64Utf8 as am, encodePaymentProof as an, hashDelegation as ao, havenClientIdentity as ap, isConnectorChannel as aq, isErc7710Option as ar, isPackedUserOperationTypedData as as, isSupportedNodeVersion as at, isSweepableChain as au, isTaskChildTypedData as av, normalizePaymentRequired as aw, packedUserOperationHash as ax, parseNextTool as ay, parsePaymentRequired as az, type SweepSubmitResponse as b, EXECUTE_ABI as b0, HYBRID_DELEGATOR_IMPLEMENTATION as b1, MAX_SETTLEMENT_WINDOW_SECONDS as b2, SIMPLE_FACTORY_ADDRESS as b3, type SettlementChildTypedData as b4, assertFundingLegPaysDelegate as b5, assertOwnSettlementChild as b6, chainIdForNetwork as b7, isSettlementChildTypedData as b8, DIRECT_SIGN_CONTEXT_VERSION as c, ERC7710_ASSET_TRANSFER_METHOD as d, HAVEN_CLIENT_HEADER as e, HAVEN_CONNECTOR_CHANNEL as f, HAVEN_MINIMUM_NODE_VERSION as g, HYBRID_DELEGATOR_DOMAIN_NAME as h, HYBRID_DELEGATOR_DOMAIN_VERSION as i, HavenTypedDataRefusedError as j, HavenUserOpBindingError as k, NEXT_TOOL_SERVER_ROLES as l, type NextStep as m, type NextStepArguments as n, type NextStepHandoff as o, type NextStepInput as p, type NextStepTarget as q, type NextStepTargets as r, type NextToolServerRole as s, SDK_CLIENT_IDENTITY as t, SDK_VERSION as u, SWEEP_BASE_CHAIN_ID as v, SWEEP_BASE_SEPOLIA_CHAIN_ID as w, SWEEP_BASE_SEPOLIA_USDC_ADDRESS as x, SWEEP_BASE_USDC_ADDRESS as y, type SettlementChildExpectation as z };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkH37YVYZA_cjs = require('./chunk-H37YVYZA.cjs');
|
|
4
4
|
var viem = require('viem');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
var secp256k1 = require('@noble/curves/secp256k1');
|
|
7
7
|
var accounts = require('viem/accounts');
|
|
8
8
|
|
|
9
9
|
var TYPED_DATA_NOT_ALLOWED = "TYPED_DATA_NOT_ALLOWED";
|
|
10
|
-
var HavenTypedDataRefusedError = class extends
|
|
10
|
+
var HavenTypedDataRefusedError = class extends chunkH37YVYZA_cjs.HavenSigningError {
|
|
11
11
|
constructor(message) {
|
|
12
12
|
super(message);
|
|
13
13
|
this.code = TYPED_DATA_NOT_ALLOWED;
|
|
@@ -48,7 +48,7 @@ function assertBoundDirectPaymentUserOp(typedData, delegateAddress) {
|
|
|
48
48
|
`This signer only signs direct payments on chains the delegation rail has pinned contracts for (${[...DIRECT_PAYMENT_CHAIN_IDS].join(", ")}); this typed data names chain ${String(domain.chainId)}. Refusing.`
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
|
-
const ownAccount =
|
|
51
|
+
const ownAccount = chunkH37YVYZA_cjs.deriveDelegateAccountAddress(delegateAddress);
|
|
52
52
|
const sender = typeof message.sender === "string" ? message.sender : "";
|
|
53
53
|
if (sender.toLowerCase() !== ownAccount.toLowerCase()) {
|
|
54
54
|
throw new HavenTypedDataRefusedError(
|
|
@@ -78,9 +78,9 @@ function assertBoundDirectPaymentUserOp(typedData, delegateAddress) {
|
|
|
78
78
|
"This UserOperation's execute() call does not re-encode to the exact callData bytes (trailing or non-canonical bytes). Refusing."
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
|
-
if (decoded.target.toLowerCase() !==
|
|
81
|
+
if (decoded.target.toLowerCase() !== chunkH37YVYZA_cjs.DELEGATION_MANAGER.toLowerCase()) {
|
|
82
82
|
throw new HavenTypedDataRefusedError(
|
|
83
|
-
`This UserOperation's execute() calls ${decoded.target}, not the DelegationManager (${
|
|
83
|
+
`This UserOperation's execute() calls ${decoded.target}, not the DelegationManager (${chunkH37YVYZA_cjs.DELEGATION_MANAGER}). A direct payment only ever redeems the agent's own budget delegation \u2014 refusing what looks like a self-call (e.g. transferOwnership, updateSigners, upgradeToAndCall) or a call to an unrelated contract.`
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
86
|
if (decoded.value !== 0n) {
|
|
@@ -89,20 +89,20 @@ function assertBoundDirectPaymentUserOp(typedData, delegateAddress) {
|
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
try {
|
|
92
|
-
|
|
92
|
+
chunkH37YVYZA_cjs.assertRedeemsOwnBudgetDelegation(decoded.callData, ownAccount);
|
|
93
93
|
} catch (err) {
|
|
94
94
|
throw new HavenTypedDataRefusedError(err instanceof Error ? err.message : String(err));
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
function assertOwnSettlementChild(typedData, expectation, delegateAddress) {
|
|
98
98
|
try {
|
|
99
|
-
|
|
99
|
+
chunkH37YVYZA_cjs.verifySettlementChild(typedData, {
|
|
100
100
|
...expectation,
|
|
101
|
-
delegatorAccount:
|
|
101
|
+
delegatorAccount: chunkH37YVYZA_cjs.deriveDelegateAccountAddress(delegateAddress)
|
|
102
102
|
});
|
|
103
103
|
} catch (err) {
|
|
104
104
|
if (err instanceof HavenTypedDataRefusedError) throw err;
|
|
105
|
-
if (err instanceof
|
|
105
|
+
if (err instanceof chunkH37YVYZA_cjs.HavenSigningError) throw new HavenTypedDataRefusedError(err.message);
|
|
106
106
|
throw new HavenTypedDataRefusedError(
|
|
107
107
|
`Refusing to sign the x402 settlement child: it is malformed (${err instanceof Error ? err.message : String(err)}).`
|
|
108
108
|
);
|
|
@@ -131,7 +131,7 @@ function assertFundingLegPaysDelegate(typedData, expected) {
|
|
|
131
131
|
try {
|
|
132
132
|
const { args: executeArgs } = viem.decodeFunctionData({ abi: EXECUTE_ABI, data: message.callData });
|
|
133
133
|
const inner = executeArgs[0].callData;
|
|
134
|
-
const { args } = viem.decodeFunctionData({ abi:
|
|
134
|
+
const { args } = viem.decodeFunctionData({ abi: chunkH37YVYZA_cjs.REDEEM_DELEGATIONS_ABI, data: inner });
|
|
135
135
|
const executions = args[2];
|
|
136
136
|
executionCallData = executions[0];
|
|
137
137
|
} catch {
|
|
@@ -250,7 +250,7 @@ var TRANSFER_WITH_AUTHORIZATION_TYPES = {
|
|
|
250
250
|
function sweepUsdcAddress(chainId) {
|
|
251
251
|
const address = USDC_ADDRESS_BY_CHAIN[chainId];
|
|
252
252
|
if (!address) {
|
|
253
|
-
throw new
|
|
253
|
+
throw new chunkH37YVYZA_cjs.HavenSigningError(
|
|
254
254
|
`Sweep is not supported on chain ${chainId}. Supported: ${SWEEPABLE_CHAIN_IDS.join(", ")}.`
|
|
255
255
|
);
|
|
256
256
|
}
|
|
@@ -259,7 +259,7 @@ function sweepUsdcAddress(chainId) {
|
|
|
259
259
|
function sweepUsdcDomain(chainId) {
|
|
260
260
|
const domain = USDC_EIP712_DOMAIN_BY_CHAIN[chainId];
|
|
261
261
|
if (!domain) {
|
|
262
|
-
throw new
|
|
262
|
+
throw new chunkH37YVYZA_cjs.HavenSigningError(
|
|
263
263
|
`Sweep is not supported on chain ${chainId}. Supported: ${SWEEPABLE_CHAIN_IDS.join(", ")}.`
|
|
264
264
|
);
|
|
265
265
|
}
|
|
@@ -272,12 +272,12 @@ function buildSweepTypedData(auth) {
|
|
|
272
272
|
const domain = sweepUsdcDomain(auth.chainId);
|
|
273
273
|
const expectedToken = sweepUsdcAddress(auth.chainId);
|
|
274
274
|
if (!sameAddress(auth.token, expectedToken)) {
|
|
275
|
-
throw new
|
|
275
|
+
throw new chunkH37YVYZA_cjs.HavenSigningError(
|
|
276
276
|
`Sweep token ${auth.token} is not the canonical USDC contract for chain ${auth.chainId}.`
|
|
277
277
|
);
|
|
278
278
|
}
|
|
279
279
|
if (!/^0x[0-9a-fA-F]{64}$/.test(auth.nonce)) {
|
|
280
|
-
throw new
|
|
280
|
+
throw new chunkH37YVYZA_cjs.HavenSigningError("Sweep nonce must be a 0x-prefixed 32-byte hex string.");
|
|
281
281
|
}
|
|
282
282
|
return {
|
|
283
283
|
domain,
|
|
@@ -782,7 +782,7 @@ function stableStringify2(value) {
|
|
|
782
782
|
}
|
|
783
783
|
|
|
784
784
|
// src/client-identity.ts
|
|
785
|
-
var SDK_VERSION = "0.
|
|
785
|
+
var SDK_VERSION = "0.10.0-alpha.0";
|
|
786
786
|
var HAVEN_CLIENT_HEADER = "X-Haven-Client";
|
|
787
787
|
function havenClientIdentity(pkg, version) {
|
|
788
788
|
return `${pkg}/${version}`;
|
|
@@ -815,7 +815,7 @@ function addressFromKey(privateKey) {
|
|
|
815
815
|
try {
|
|
816
816
|
return accounts.privateKeyToAddress(`0x${hexBytes(privateKey, 32, "private key")}`);
|
|
817
817
|
} catch (err) {
|
|
818
|
-
throw new
|
|
818
|
+
throw new chunkH37YVYZA_cjs.HavenSigningError(
|
|
819
819
|
`Invalid private key: ${err instanceof Error ? err.message : String(err)}`
|
|
820
820
|
);
|
|
821
821
|
}
|
|
@@ -829,7 +829,7 @@ function signHash(privateKey, hash) {
|
|
|
829
829
|
yParity: recovery
|
|
830
830
|
});
|
|
831
831
|
} catch (err) {
|
|
832
|
-
throw new
|
|
832
|
+
throw new chunkH37YVYZA_cjs.HavenSigningError(
|
|
833
833
|
`Failed to sign hash: ${err instanceof Error ? err.message : String(err)}`
|
|
834
834
|
);
|
|
835
835
|
}
|
|
@@ -865,7 +865,7 @@ var TAX_DECLARATION_TYPES = {
|
|
|
865
865
|
var X_TAX_DECLARATION_HEADER = "X-Tax-Declaration";
|
|
866
866
|
function validateContent(content) {
|
|
867
867
|
if (typeof content !== "object" || content === null || Array.isArray(content)) {
|
|
868
|
-
throw new
|
|
868
|
+
throw new chunkH37YVYZA_cjs.HavenSigningError("Tax declaration content must be an object.");
|
|
869
869
|
}
|
|
870
870
|
const record = content;
|
|
871
871
|
for (const field of ["principalId", "principalAttributionHash"]) {
|
|
@@ -918,7 +918,7 @@ function taxPrincipalId(network, delegateAddress) {
|
|
|
918
918
|
if (network.startsWith("eip155:")) {
|
|
919
919
|
return `did:pkh:${network}:${delegateAddress}`;
|
|
920
920
|
}
|
|
921
|
-
const chainId =
|
|
921
|
+
const chainId = chunkH37YVYZA_cjs.chainIdForNetwork(network);
|
|
922
922
|
if (chainId === void 0) {
|
|
923
923
|
throw new TaxDeclarationRefusedError(
|
|
924
924
|
`The accepted payment option's network '${network}' is not a CAIP-2 eip155 chain this SDK can name; refusing to build a tax principal without the settlement network.`
|
|
@@ -963,18 +963,22 @@ function addressFromKeyForTax(delegateKey) {
|
|
|
963
963
|
try {
|
|
964
964
|
return addressFromKey(delegateKey);
|
|
965
965
|
} catch (err) {
|
|
966
|
-
throw new
|
|
966
|
+
throw new chunkH37YVYZA_cjs.HavenSigningError(
|
|
967
967
|
`Invalid delegate key for tax declaration signing: ${err instanceof Error ? err.message : String(err)}`
|
|
968
968
|
);
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
|
-
var TaxDeclarationRefusedError = class extends
|
|
971
|
+
var TaxDeclarationRefusedError = class extends chunkH37YVYZA_cjs.HavenSigningError {
|
|
972
972
|
code = "TAX_DECLARATION_REFUSED";
|
|
973
973
|
constructor(message) {
|
|
974
974
|
super(message);
|
|
975
975
|
this.name = "TaxDeclarationRefusedError";
|
|
976
976
|
}
|
|
977
977
|
};
|
|
978
|
+
var X402_PAYMENT_NONCE_TAG = "haven-x402-payment-nonce:";
|
|
979
|
+
function deriveX402PaymentNonce(paymentId) {
|
|
980
|
+
return viem.keccak256(viem.concatHex([viem.toHex(X402_PAYMENT_NONCE_TAG), viem.toHex(paymentId)]));
|
|
981
|
+
}
|
|
978
982
|
|
|
979
983
|
// src/next-step.ts
|
|
980
984
|
var NEXT_TOOL_SERVER_NAMES = {
|
|
@@ -1120,10 +1124,10 @@ function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now
|
|
|
1120
1124
|
if (td?.primaryType !== "Delegation") {
|
|
1121
1125
|
refuseTaskChild("it is not a Delegation payload", `primaryType was '${String(td?.primaryType)}'.`);
|
|
1122
1126
|
}
|
|
1123
|
-
if (!same(td.domain?.verifyingContract,
|
|
1127
|
+
if (!same(td.domain?.verifyingContract, chunkH37YVYZA_cjs.DELEGATION_MANAGER)) {
|
|
1124
1128
|
refuseTaskChild(
|
|
1125
1129
|
"the EIP-712 domain names an unknown DelegationManager",
|
|
1126
|
-
`Expected ${
|
|
1130
|
+
`Expected ${chunkH37YVYZA_cjs.DELEGATION_MANAGER}, got ${td.domain?.verifyingContract}.`
|
|
1127
1131
|
);
|
|
1128
1132
|
}
|
|
1129
1133
|
if (td.domain?.name !== DELEGATION_DOMAIN_NAME || td.domain?.version !== DELEGATION_DOMAIN_VERSION) {
|
|
@@ -1151,7 +1155,7 @@ function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now
|
|
|
1151
1155
|
`Expected chain ${expected.chainId}; the child says ${td.domain?.chainId}.`
|
|
1152
1156
|
);
|
|
1153
1157
|
}
|
|
1154
|
-
const ownAccount =
|
|
1158
|
+
const ownAccount = chunkH37YVYZA_cjs.deriveDelegateAccountAddress(delegateAddress);
|
|
1155
1159
|
const delegator = td.message?.delegator;
|
|
1156
1160
|
if (typeof delegator !== "string" || !same(delegator, ownAccount)) {
|
|
1157
1161
|
refuseTaskChild(
|
|
@@ -1170,7 +1174,7 @@ function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now
|
|
|
1170
1174
|
if (typeof authority !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(authority)) {
|
|
1171
1175
|
refuseTaskChild("its authority is not a 32-byte delegation hash", `Got ${String(authority)}.`);
|
|
1172
1176
|
}
|
|
1173
|
-
if (authority.toLowerCase() ===
|
|
1177
|
+
if (authority.toLowerCase() === chunkH37YVYZA_cjs.ROOT_AUTHORITY) {
|
|
1174
1178
|
refuseTaskChild(
|
|
1175
1179
|
"it is a ROOT delegation, not a re-delegation of the agent budget",
|
|
1176
1180
|
"A task budget always chains under the agent budget delegation."
|
|
@@ -1183,7 +1187,7 @@ function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now
|
|
|
1183
1187
|
);
|
|
1184
1188
|
}
|
|
1185
1189
|
const caveats = td.message?.caveats ?? [];
|
|
1186
|
-
const transfer = findCaveat(caveats,
|
|
1190
|
+
const transfer = findCaveat(caveats, chunkH37YVYZA_cjs.CAVEAT_ENFORCERS.erc20TransferAmount);
|
|
1187
1191
|
if (!transfer) {
|
|
1188
1192
|
refuseTaskChild(
|
|
1189
1193
|
"it has no ERC-20 transfer-amount caveat",
|
|
@@ -1201,7 +1205,7 @@ function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now
|
|
|
1201
1205
|
`Expected ${expected.maxAmountAtomic}; the child allows ${amount.toString()}.`
|
|
1202
1206
|
);
|
|
1203
1207
|
}
|
|
1204
|
-
const timestamp = findCaveat(caveats,
|
|
1208
|
+
const timestamp = findCaveat(caveats, chunkH37YVYZA_cjs.CAVEAT_ENFORCERS.timestamp);
|
|
1205
1209
|
if (!timestamp) {
|
|
1206
1210
|
refuseTaskChild("it never expires", "A task-budget child without a timestamp caveat is open-ended.");
|
|
1207
1211
|
}
|
|
@@ -1222,7 +1226,7 @@ function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now
|
|
|
1222
1226
|
`Expected ${expected.expiresAt}; the child says ${beforeThreshold}.`
|
|
1223
1227
|
);
|
|
1224
1228
|
}
|
|
1225
|
-
const calldata = findCaveat(caveats,
|
|
1229
|
+
const calldata = findCaveat(caveats, chunkH37YVYZA_cjs.CAVEAT_ENFORCERS.allowedCalldata);
|
|
1226
1230
|
if (expected.recipientAddress) {
|
|
1227
1231
|
if (!calldata) {
|
|
1228
1232
|
refuseTaskChild(
|
|
@@ -1259,7 +1263,7 @@ var DISABLE_DELEGATION_ABI = [
|
|
|
1259
1263
|
{
|
|
1260
1264
|
type: "function",
|
|
1261
1265
|
name: "disableDelegation",
|
|
1262
|
-
inputs: [{ name: "delegation", type: "tuple", components:
|
|
1266
|
+
inputs: [{ name: "delegation", type: "tuple", components: chunkH37YVYZA_cjs.DELEGATION_TUPLE_COMPONENTS }],
|
|
1263
1267
|
outputs: [],
|
|
1264
1268
|
stateMutability: "nonpayable"
|
|
1265
1269
|
}
|
|
@@ -1278,7 +1282,7 @@ function assertOwnTaskBudgetCloseUserOp(typedData, expected, delegateAddress) {
|
|
|
1278
1282
|
`This signer only signs a task-budget close on chains the delegation rail has pinned contracts for (${[...DIRECT_PAYMENT_CHAIN_IDS].join(", ")}); this typed data names chain ${String(domain.chainId)}. Refusing.`
|
|
1279
1283
|
);
|
|
1280
1284
|
}
|
|
1281
|
-
const ownAccount =
|
|
1285
|
+
const ownAccount = chunkH37YVYZA_cjs.deriveDelegateAccountAddress(delegateAddress);
|
|
1282
1286
|
const sender = typeof message.sender === "string" ? message.sender : "";
|
|
1283
1287
|
if (sender.toLowerCase() !== ownAccount.toLowerCase()) {
|
|
1284
1288
|
throw new HavenTypedDataRefusedError(
|
|
@@ -1301,9 +1305,9 @@ function assertOwnTaskBudgetCloseUserOp(typedData, expected, delegateAddress) {
|
|
|
1301
1305
|
"This close UserOperation's execute() call does not re-encode to the exact callData bytes (trailing or non-canonical bytes). Refusing."
|
|
1302
1306
|
);
|
|
1303
1307
|
}
|
|
1304
|
-
if (decoded.target.toLowerCase() !==
|
|
1308
|
+
if (decoded.target.toLowerCase() !== chunkH37YVYZA_cjs.DELEGATION_MANAGER.toLowerCase()) {
|
|
1305
1309
|
throw new HavenTypedDataRefusedError(
|
|
1306
|
-
`This close UserOperation's execute() calls ${decoded.target}, not the DelegationManager (${
|
|
1310
|
+
`This close UserOperation's execute() calls ${decoded.target}, not the DelegationManager (${chunkH37YVYZA_cjs.DELEGATION_MANAGER}). Refusing what looks like a self-call or a call to an unrelated contract.`
|
|
1307
1311
|
);
|
|
1308
1312
|
}
|
|
1309
1313
|
if (decoded.value !== 0n) {
|
|
@@ -1340,7 +1344,7 @@ function assertOwnTaskBudgetCloseUserOp(typedData, expected, delegateAddress) {
|
|
|
1340
1344
|
`This close UserOperation disables a delegation granted to ${delegation.delegate}, not this signer's own account (${ownAccount}) \u2014 a task-budget child is always self-delegated. Refusing.`
|
|
1341
1345
|
);
|
|
1342
1346
|
}
|
|
1343
|
-
if (delegation.authority.toLowerCase() ===
|
|
1347
|
+
if (delegation.authority.toLowerCase() === chunkH37YVYZA_cjs.ROOT_AUTHORITY) {
|
|
1344
1348
|
throw new HavenTypedDataRefusedError(
|
|
1345
1349
|
"This close UserOperation disables a ROOT delegation, not a re-delegation of the agent budget. A task-budget child always chains under the agent budget delegation. Refusing."
|
|
1346
1350
|
);
|
|
@@ -1412,6 +1416,7 @@ exports.X402_MAX_AUTHORIZATION_WINDOW_SECONDS = X402_MAX_AUTHORIZATION_WINDOW_SE
|
|
|
1412
1416
|
exports.X402_PAYMENT_HEADER_NAME = X402_PAYMENT_HEADER_NAME;
|
|
1413
1417
|
exports.X402_PAYMENT_HEADER_NAMES = X402_PAYMENT_HEADER_NAMES;
|
|
1414
1418
|
exports.X402_PAYMENT_HEADER_NAMES_SENT = X402_PAYMENT_HEADER_NAMES_SENT;
|
|
1419
|
+
exports.X402_PAYMENT_NONCE_TAG = X402_PAYMENT_NONCE_TAG;
|
|
1415
1420
|
exports.X402_PAYMENT_REQUIRED_HEADER_NAME = X402_PAYMENT_REQUIRED_HEADER_NAME;
|
|
1416
1421
|
exports.X402_PAYMENT_RESPONSE_HEADER_NAME = X402_PAYMENT_RESPONSE_HEADER_NAME;
|
|
1417
1422
|
exports.X402_SETTLEMENT_FORWARD_MARGIN_SECONDS = X402_SETTLEMENT_FORWARD_MARGIN_SECONDS;
|
|
@@ -1432,6 +1437,7 @@ exports.createNextStepBuilder = createNextStepBuilder;
|
|
|
1432
1437
|
exports.decodeBase64Json = decodeBase64Json;
|
|
1433
1438
|
exports.decodeBase64Utf8 = decodeBase64Utf8;
|
|
1434
1439
|
exports.defaultNextToolFor = defaultNextToolFor;
|
|
1440
|
+
exports.deriveX402PaymentNonce = deriveX402PaymentNonce;
|
|
1435
1441
|
exports.encodeBase64Json = encodeBase64Json;
|
|
1436
1442
|
exports.encodeBase64Utf8 = encodeBase64Utf8;
|
|
1437
1443
|
exports.encodePaymentProof = encodePaymentProof;
|
|
@@ -1471,5 +1477,5 @@ exports.x402PaymentHeaderNamesFor = x402PaymentHeaderNamesFor;
|
|
|
1471
1477
|
exports.x402PaymentHeaderNamesSent = x402PaymentHeaderNamesSent;
|
|
1472
1478
|
exports.x402RetryHeadersFor = x402RetryHeadersFor;
|
|
1473
1479
|
exports.x402V2PaymentEnvelope = x402V2PaymentEnvelope;
|
|
1474
|
-
//# sourceMappingURL=chunk-
|
|
1475
|
-
//# sourceMappingURL=chunk-
|
|
1480
|
+
//# sourceMappingURL=chunk-22FJ4JQO.cjs.map
|
|
1481
|
+
//# sourceMappingURL=chunk-22FJ4JQO.cjs.map
|