@haven_ai/sdk 0.0.0-dev.202609282003.b645eff → 0.0.0-dev.202609282018.d7956ad
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/{base64-Br8mJPgm.d.cts → base64-BFXCO54F.d.cts} +1 -1
- package/dist/{base64-Br8mJPgm.d.ts → base64-BFXCO54F.d.ts} +1 -1
- package/dist/{chunk-AFJ7XDDI.js → chunk-LKWXAYWW.js} +3 -3
- package/dist/{chunk-AFJ7XDDI.js.map → chunk-LKWXAYWW.js.map} +1 -1
- package/dist/{chunk-PZLGXWSP.cjs → chunk-XLXOQZ3M.cjs} +3 -3
- package/dist/{chunk-PZLGXWSP.cjs.map → chunk-XLXOQZ3M.cjs.map} +1 -1
- package/dist/edge.cjs +31 -31
- package/dist/edge.d.cts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +1 -1
- package/dist/index.cjs +214 -143
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -18
- package/dist/index.d.ts +60 -18
- package/dist/index.js +93 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
|
-
import { R as RawPaymentParties, H as HavenClientConfig, a as HavenClientUpdate, P as PaymentRequest, b as PaymentResult, c as PaymentIntent, X as X402PaymentRequired, d as X402AuthorizationOptions, e as X402Intent, f as PaymentStatusResult, g as HavenAgent, h as HavenAgentSummary, S as SweepResult, i as SweepPrepareResponse, j as SweepAuthorization, k as SweepSubmitResponse, l as HavenAllowanceSummary, m as HavenBalanceCoverage, n as PostPurchaseAllowanceSummary, A as AgentPaymentWarning, o as HavenCatalogEntry, p as HavenCatalogSubmission, q as HavenPaymentReceipt, r as HavenPaymentReceiptsPage, O as OpenTaskBudgetResult, s as HavenTaskBudget, T as TaskBudgetSignContext, t as SubmitTaskBudgetResult, C as CloseTaskBudgetResult, u as PaymentResumeState, v as X402Receipt, w as X402Quote, x as X402Erc7710Settlement, y as X402McpCallContext, z as SignData, B as ResumeAuthorizedX402Input, D as ResumeX402PaymentInput, E as X402ResumeState, F as X402McpTransport, G as X402MerchantCallContext, I as HavenError } from './base64-
|
|
2
|
-
export { J as AGENT_PAYMENT_FAILURE_CODE_VALUES, K as AGENT_PAYMENT_NEXT_ACTION_VALUES, L as AGENT_PAYMENT_PHASE_VALUES, M as AGENT_PAYMENT_RAIL_VALUES, N as AgentNextStep, Q as AgentPaymentEnumSchema, U as AgentPaymentFailureCode, V as AgentPaymentFailureCodeDescriptions, W as AgentPaymentFailureCodeSchema, Y as AgentPaymentNextAction, Z as AgentPaymentNextActionDescriptions, _ as AgentPaymentNextActionSchema, $ as AgentPaymentPhase, a0 as AgentPaymentPhaseDescriptions, a1 as AgentPaymentPhaseSchema, a2 as AgentPaymentRail, a3 as AgentPaymentRailDescriptions, a4 as AgentPaymentRailSchema, a5 as AgentPaymentSummary, a6 as AgentPaymentWarningCode, a7 as AgentPurchaseSummary, a8 as CONNECTOR_PACKAGE_NAME, a9 as CatalogSubmissionAccepted, aa as DEFAULT_CONFIRMATION_TIMEOUT_MS, ab as DEFAULT_NEXT_TOOL_BY_ACTION, ac as DIRECT_SIGN_CONTEXT_VERSION, ad as ENTRY_POINT_V07, ae as ERC7710_ASSET_TRANSFER_METHOD, af as HAVEN_CLIENT_HEADER, ag as HAVEN_CONNECTOR_CHANNEL, ah as HAVEN_MINIMUM_NODE_VERSION, ai as HYBRID_DELEGATOR_DOMAIN_NAME, aj as HYBRID_DELEGATOR_DOMAIN_VERSION, ak as HavenAgentAllowanceSummary, al as HavenAgentReadiness, am as HavenAllowance, an as HavenApiError, ao as HavenCatalogMerchant, ap as HavenListScope, aq as HavenPaymentStateError, ar as HavenSigningError, as as HavenTimeoutError, at as HavenTypedDataRefusedError, au as HavenUnsupportedSignerVersionError, av as HavenUserOpBindingError, aw as HavenZeroSettlementHashError, ax as MAX_TASK_BUDGET_TTL_SECONDS, ay as MachinePaymentRail, az as MerchantTimeoutError, aA as NEXT_TOOL_SERVER_NAMES, aB as NEXT_TOOL_SERVER_ROLES, aC as NextStep, aD as NextStepArguments, aE as NextStepHandoff, aF as NextStepInput, aG as NextStepTarget, aH as NextStepTargets, aI as NextToolServerRole, aJ as PACKED_USER_OPERATION_FIELDS, aK as PaymentFee, aL as PaymentNextAction, aM as PaymentPhase, aN as PaymentStatus, aO as ROOT_AUTHORITY, aP as SDK_CLIENT_IDENTITY, aQ as SDK_VERSION, aR as SIGNER_UPDATE_FALLBACK, aS as SWEEP_BASE_CHAIN_ID, aT as SWEEP_BASE_SEPOLIA_CHAIN_ID, aU as SWEEP_BASE_SEPOLIA_USDC_ADDRESS, aV as SWEEP_BASE_USDC_ADDRESS, aW as SettlementChildExpectation, aX as SignerRefusalCode, aY as SweepConfirmation, aZ as SweepEip712Domain, a_ as SweepEntry, a$ as SweepExpectedAuth, b0 as SweepPreparation, b1 as SweepSubmitResult, b2 as SweepTypedData, b3 as TRANSFER_WITH_AUTHORIZATION_TYPES, b4 as TYPED_DATA_NOT_ALLOWED, b5 as TaskBudgetCloseExpectation, b6 as TaskChildExpectation, b7 as TaskChildTypedData, b8 as UnsupportedNodeVersionMessageOptions, b9 as X402AlreadySettledError, ba as X402Erc7710AlreadySettledError, bb as X402ExpectedAuth, bc as X402ExpectedContext, bd as X402PaymentHeaderContext, be as X402PaymentHeaderValidationError, bf as X402PaymentOption, bg as X402RequestSnapshot, bh as X402SchemeSelection, bi as X402TaskBudgetMismatchError, bj as X402UnexpectedStatusError, bk as X402_LEGACY_PAYMENT_HEADER_NAME, bl as X402_MAX_AUTHORIZATION_WINDOW_SECONDS, bm as X402_PAYMENT_HEADER_NAME, bn as X402_PAYMENT_HEADER_NAMES_SENT, bo as X402_PAYMENT_REQUIRED_HEADER_NAME, bp as X402_PAYMENT_RESPONSE_HEADER_NAME, bq as X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, br as assertBoundDirectPaymentUserOp, bs as assertOwnTaskBudgetCloseUserOp, bt as assertOwnTaskChild, bu as assertUserOpTypedDataBinding, bv as buildSweepAuthorizationMessage, bw as buildSweepTypedData, bx as buildX402ExpectedMessage, by as compareNodeVersions, bz as connectorRerunCommand, bA as connectorSpec, bB as connectorUpgradeCommand, bC as createNextStepBuilder, bD as decodeBase64Json, bE as decodeBase64Utf8, bF as defaultNextToolFor, bG as deriveDelegateAccountAddress, bH as encodeBase64Json, bI as encodeBase64Utf8, bJ as encodePaymentProof, bK as hashDelegation, bL as havenClientIdentity, bM as isConnectorChannel, bN as isErc7710Option, bO as isPackedUserOperationTypedData, bP as isSupportedNodeVersion, bQ as isSweepableChain, bR as isTaskChildTypedData, bS as normalizePaymentRequired, bT as packedUserOperationHash, bU as parseNextTool, bV as parsePaymentRequired, bW as parsePaymentRequiredResponse, bX as readClientUpdate, bY as renderNextTool, bZ as resolveConnectorChannel, b_ as resolveTokenBySymbol, b$ as resolveTokenFromAddress, c0 as selectErc7710PaymentOption, c1 as selectPaymentOption, c2 as selectStandardPaymentOption, c3 as selectX402SettlementScheme, c4 as signerUpdateFallback, c5 as sweepUsdcAddress, c6 as sweepUsdcDomain, c7 as toStandardPaymentRequirements, c8 as unsupportedNodeVersionMessage, c9 as validateStandardX402PaymentHeader, ca as verifySettlementChild, cb as x402AssetTransferMethod, cc as x402AuthorizationAmount, cd as x402FacilitatorAddresses, ce as x402V2PaymentEnvelope } from './base64-
|
|
1
|
+
import { R as RawPaymentParties, H as HavenClientConfig, a as HavenClientUpdate, P as PaymentRequest, b as PaymentResult, c as PaymentIntent, X as X402PaymentRequired, d as X402AuthorizationOptions, e as X402Intent, f as PaymentStatusResult, g as HavenAgent, h as HavenAgentSummary, S as SweepResult, i as SweepPrepareResponse, j as SweepAuthorization, k as SweepSubmitResponse, l as HavenAllowanceSummary, m as HavenBalanceCoverage, n as PostPurchaseAllowanceSummary, A as AgentPaymentWarning, o as HavenCatalogEntry, p as HavenCatalogSubmission, q as HavenPaymentReceipt, r as HavenPaymentReceiptsPage, O as OpenTaskBudgetResult, s as HavenTaskBudget, T as TaskBudgetSignContext, t as SubmitTaskBudgetResult, C as CloseTaskBudgetResult, u as PaymentResumeState, v as X402Receipt, w as X402Quote, x as X402Erc7710Settlement, y as X402McpCallContext, z as SignData, B as ResumeAuthorizedX402Input, D as ResumeX402PaymentInput, E as X402ResumeState, F as X402McpTransport, G as X402MerchantCallContext, I as HavenError } from './base64-BFXCO54F.cjs';
|
|
2
|
+
export { J as AGENT_PAYMENT_FAILURE_CODE_VALUES, K as AGENT_PAYMENT_NEXT_ACTION_VALUES, L as AGENT_PAYMENT_PHASE_VALUES, M as AGENT_PAYMENT_RAIL_VALUES, N as AgentNextStep, Q as AgentPaymentEnumSchema, U as AgentPaymentFailureCode, V as AgentPaymentFailureCodeDescriptions, W as AgentPaymentFailureCodeSchema, Y as AgentPaymentNextAction, Z as AgentPaymentNextActionDescriptions, _ as AgentPaymentNextActionSchema, $ as AgentPaymentPhase, a0 as AgentPaymentPhaseDescriptions, a1 as AgentPaymentPhaseSchema, a2 as AgentPaymentRail, a3 as AgentPaymentRailDescriptions, a4 as AgentPaymentRailSchema, a5 as AgentPaymentSummary, a6 as AgentPaymentWarningCode, a7 as AgentPurchaseSummary, a8 as CONNECTOR_PACKAGE_NAME, a9 as CatalogSubmissionAccepted, aa as DEFAULT_CONFIRMATION_TIMEOUT_MS, ab as DEFAULT_NEXT_TOOL_BY_ACTION, ac as DIRECT_SIGN_CONTEXT_VERSION, ad as ENTRY_POINT_V07, ae as ERC7710_ASSET_TRANSFER_METHOD, af as HAVEN_CLIENT_HEADER, ag as HAVEN_CONNECTOR_CHANNEL, ah as HAVEN_MINIMUM_NODE_VERSION, ai as HYBRID_DELEGATOR_DOMAIN_NAME, aj as HYBRID_DELEGATOR_DOMAIN_VERSION, ak as HavenAgentAllowanceSummary, al as HavenAgentReadiness, am as HavenAllowance, an as HavenApiError, ao as HavenCatalogMerchant, ap as HavenListScope, aq as HavenPaymentStateError, ar as HavenSigningError, as as HavenTimeoutError, at as HavenTypedDataRefusedError, au as HavenUnsupportedSignerVersionError, av as HavenUserOpBindingError, aw as HavenZeroSettlementHashError, ax as MAX_TASK_BUDGET_TTL_SECONDS, ay as MachinePaymentRail, az as MerchantTimeoutError, aA as NEXT_TOOL_SERVER_NAMES, aB as NEXT_TOOL_SERVER_ROLES, aC as NextStep, aD as NextStepArguments, aE as NextStepHandoff, aF as NextStepInput, aG as NextStepTarget, aH as NextStepTargets, aI as NextToolServerRole, aJ as PACKED_USER_OPERATION_FIELDS, aK as PaymentFee, aL as PaymentNextAction, aM as PaymentPhase, aN as PaymentStatus, aO as ROOT_AUTHORITY, aP as SDK_CLIENT_IDENTITY, aQ as SDK_VERSION, aR as SIGNER_UPDATE_FALLBACK, aS as SWEEP_BASE_CHAIN_ID, aT as SWEEP_BASE_SEPOLIA_CHAIN_ID, aU as SWEEP_BASE_SEPOLIA_USDC_ADDRESS, aV as SWEEP_BASE_USDC_ADDRESS, aW as SettlementChildExpectation, aX as SignerRefusalCode, aY as SweepConfirmation, aZ as SweepEip712Domain, a_ as SweepEntry, a$ as SweepExpectedAuth, b0 as SweepPreparation, b1 as SweepSubmitResult, b2 as SweepTypedData, b3 as TRANSFER_WITH_AUTHORIZATION_TYPES, b4 as TYPED_DATA_NOT_ALLOWED, b5 as TaskBudgetCloseExpectation, b6 as TaskChildExpectation, b7 as TaskChildTypedData, b8 as UnsupportedNodeVersionMessageOptions, b9 as X402AlreadySettledError, ba as X402Erc7710AlreadySettledError, bb as X402ExpectedAuth, bc as X402ExpectedContext, bd as X402PaymentHeaderContext, be as X402PaymentHeaderValidationError, bf as X402PaymentOption, bg as X402RequestSnapshot, bh as X402SchemeSelection, bi as X402TaskBudgetMismatchError, bj as X402UnexpectedStatusError, bk as X402_LEGACY_PAYMENT_HEADER_NAME, bl as X402_MAX_AUTHORIZATION_WINDOW_SECONDS, bm as X402_PAYMENT_HEADER_NAME, bn as X402_PAYMENT_HEADER_NAMES_SENT, bo as X402_PAYMENT_REQUIRED_HEADER_NAME, bp as X402_PAYMENT_RESPONSE_HEADER_NAME, bq as X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, br as assertBoundDirectPaymentUserOp, bs as assertOwnTaskBudgetCloseUserOp, bt as assertOwnTaskChild, bu as assertUserOpTypedDataBinding, bv as buildSweepAuthorizationMessage, bw as buildSweepTypedData, bx as buildX402ExpectedMessage, by as compareNodeVersions, bz as connectorRerunCommand, bA as connectorSpec, bB as connectorUpgradeCommand, bC as createNextStepBuilder, bD as decodeBase64Json, bE as decodeBase64Utf8, bF as defaultNextToolFor, bG as deriveDelegateAccountAddress, bH as encodeBase64Json, bI as encodeBase64Utf8, bJ as encodePaymentProof, bK as hashDelegation, bL as havenClientIdentity, bM as isConnectorChannel, bN as isErc7710Option, bO as isPackedUserOperationTypedData, bP as isSupportedNodeVersion, bQ as isSweepableChain, bR as isTaskChildTypedData, bS as normalizePaymentRequired, bT as packedUserOperationHash, bU as parseNextTool, bV as parsePaymentRequired, bW as parsePaymentRequiredResponse, bX as readClientUpdate, bY as renderNextTool, bZ as resolveConnectorChannel, b_ as resolveTokenBySymbol, b$ as resolveTokenFromAddress, c0 as selectErc7710PaymentOption, c1 as selectPaymentOption, c2 as selectStandardPaymentOption, c3 as selectX402SettlementScheme, c4 as signerUpdateFallback, c5 as sweepUsdcAddress, c6 as sweepUsdcDomain, c7 as toStandardPaymentRequirements, c8 as unsupportedNodeVersionMessage, c9 as validateStandardX402PaymentHeader, ca as verifySettlementChild, cb as x402AssetTransferMethod, cc as x402AuthorizationAmount, cd as x402FacilitatorAddresses, ce as x402V2PaymentEnvelope } from './base64-BFXCO54F.cjs';
|
|
3
3
|
import 'x402/types';
|
|
4
4
|
import 'viem';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Verifiable payment receipts.
|
|
8
8
|
*
|
|
9
|
-
* A self-contained
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `txHash`
|
|
9
|
+
* A self-contained bundle for a settled Haven payment whose agent
|
|
10
|
+
* authorisation can be checked offline. What `verifyPaymentReceipt` proves is
|
|
11
|
+
* deliberately narrow: the `payment` block (amount, recipient) is
|
|
12
|
+
* Haven-asserted and is NOT bound by the signature, and `verified: true` never
|
|
13
|
+
* proves the payment settled on-chain — settlement stays an explorer check on
|
|
14
|
+
* `onChain.txHash` / `settlementTxHash`.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* What `verified: true` means, per scheme:
|
|
17
|
+
*
|
|
18
|
+
* - erc7710 (`authorization.signatureScheme: 'eip712_delegation'`): the bundle
|
|
19
|
+
* carries the settlement child's EIP-712 struct hash as `signHash`. The
|
|
20
|
+
* verifier rebuilds the digest the delegate actually signed —
|
|
21
|
+
* `keccak256(0x1901 ‖ domainSeparator(DelegationManager, chainId) ‖ signHash)`
|
|
22
|
+
* — from the DelegationManager address the SDK pins and the bundle's
|
|
23
|
+
* `onChain.chainId`, never from a value the receipt itself vouches for.
|
|
24
|
+
* `verified: true` means the delegate key signed that settlement delegation
|
|
25
|
+
* (`verifiedOver: 'delegation_digest'`).
|
|
26
|
+
* - direct payments and the eip3009 funding leg
|
|
27
|
+
* (`signatureScheme: 'eip712_userop'`) sign an ERC-4337 user operation the
|
|
28
|
+
* bundle does not carry: they return `not_verifiable_offline` rather than a
|
|
29
|
+
* false accusation.
|
|
30
|
+
* - retired-rail bundles (no scheme) carry a raw-signed `signHash`; the
|
|
31
|
+
* verifier recovers over it directly, then over the delegation digest when
|
|
32
|
+
* the chain allows rebuilding it.
|
|
33
|
+
*
|
|
34
|
+
* Anything that is not a signed bundle — including a `haven_list_receipts`
|
|
35
|
+
* history row, which carries no signature at all — returns
|
|
36
|
+
* `not_a_signed_receipt`. Verification never throws.
|
|
37
|
+
*
|
|
38
|
+
* This lives in the SDK so agents and users can verify receipts client-side.
|
|
18
39
|
*/
|
|
19
40
|
declare const RECEIPT_VERSION = "haven-receipt-1";
|
|
20
41
|
interface PaymentReceipt {
|
|
@@ -44,6 +65,17 @@ interface PaymentReceipt {
|
|
|
44
65
|
delegate: string;
|
|
45
66
|
signHash: string;
|
|
46
67
|
signature: string | null;
|
|
68
|
+
/**
|
|
69
|
+
* #3418: which digest the delegate signed — selects what offline
|
|
70
|
+
* verification rebuilds. `'eip712_delegation'`: the settlement
|
|
71
|
+
* delegation's EIP-712 digest (erc7710). `'eip712_userop'`: an ERC-4337
|
|
72
|
+
* user-operation digest the bundle does not carry (direct payments, the
|
|
73
|
+
* eip3009 funding leg) — not verifiable offline. Absent on retired-rail
|
|
74
|
+
* bundles and on backends older than #3418, whose `signHash` was signed
|
|
75
|
+
* raw. The value is only a selector: a lying one cannot make a forged
|
|
76
|
+
* signature verify, because recovery must still return `delegate`.
|
|
77
|
+
*/
|
|
78
|
+
signatureScheme?: 'eip712_delegation' | 'eip712_userop';
|
|
47
79
|
};
|
|
48
80
|
onChain: {
|
|
49
81
|
txHash: string | null;
|
|
@@ -53,17 +85,27 @@ interface PaymentReceipt {
|
|
|
53
85
|
type ReceiptVerification = {
|
|
54
86
|
verified: true;
|
|
55
87
|
recoveredSigner: string;
|
|
88
|
+
verifiedOver: 'sign_hash' | 'delegation_digest';
|
|
56
89
|
} | {
|
|
57
90
|
verified: false;
|
|
58
|
-
reason:
|
|
91
|
+
reason:
|
|
92
|
+
/** #3418: the input is not a haven-receipt-1 bundle (a haven_list_receipts row, null, undefined, a non-object). */
|
|
93
|
+
'not_a_signed_receipt'
|
|
94
|
+
/** #3418: eip712_userop bundle; or a delegation bundle on a chain the SDK pins no DelegationManager for. */
|
|
95
|
+
| 'not_verifiable_offline' | 'missing_signature' | 'bad_signature' | 'signer_mismatch';
|
|
59
96
|
recoveredSigner?: string;
|
|
60
97
|
};
|
|
98
|
+
type RecoverFn = (hash: string, signature: string) => string;
|
|
61
99
|
/**
|
|
62
|
-
* Verify a receipt
|
|
63
|
-
* confirm it is the agent
|
|
64
|
-
*
|
|
100
|
+
* Verify a receipt's agent authorisation offline: recover the signer and
|
|
101
|
+
* confirm it is the agent delegate, over whichever digest the bundle's scheme
|
|
102
|
+
* names (see the module doc for what that proves — and what it does not).
|
|
103
|
+
* Never throws: anything that is not a signed receipt — a
|
|
104
|
+
* `haven_list_receipts` history row, null, undefined, a non-object — returns
|
|
105
|
+
* `not_a_signed_receipt`. Pure — `recover` is injectable but defaults to
|
|
106
|
+
* standard ECDSA recovery, so this runs anywhere (no Haven backend).
|
|
65
107
|
*/
|
|
66
|
-
declare function verifyPaymentReceipt(receipt:
|
|
108
|
+
declare function verifyPaymentReceipt(receipt: unknown, recover?: RecoverFn): ReceiptVerification;
|
|
67
109
|
|
|
68
110
|
/**
|
|
69
111
|
* Merchant delivery and the evidence trail behind it (#1620, epic #1613).
|
|
@@ -982,9 +1024,9 @@ declare const toolDescriptions: {
|
|
|
982
1024
|
readonly nextActionGuidance: "";
|
|
983
1025
|
};
|
|
984
1026
|
readonly verifyReceipt: {
|
|
985
|
-
readonly summary: "Verify a payment receipt offline — confirm the agent
|
|
986
|
-
readonly selectionGuidance: "
|
|
987
|
-
readonly behavior: "
|
|
1027
|
+
readonly summary: "Verify a signed payment receipt offline — confirm the agent delegate signed its authorisation.";
|
|
1028
|
+
readonly selectionGuidance: "Takes the signed bundle from GET /payments/{id}/receipt, not a haven_list_receipts row — a row carries no signature and returns not_a_signed_receipt. No network.";
|
|
1029
|
+
readonly behavior: "Never throws. An erc7710 bundle verifies over the delegation digest the delegate signed; a direct or eip3009 bundle returns not_verifiable_offline. verified true means only that the delegate signed the hash named by verifiedOver — payment facts are Haven-asserted and settlement is not proven; check settlementTxHash on an explorer.";
|
|
988
1030
|
readonly nextActionGuidance: "";
|
|
989
1031
|
};
|
|
990
1032
|
readonly payMcpTool: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
|
-
import { R as RawPaymentParties, H as HavenClientConfig, a as HavenClientUpdate, P as PaymentRequest, b as PaymentResult, c as PaymentIntent, X as X402PaymentRequired, d as X402AuthorizationOptions, e as X402Intent, f as PaymentStatusResult, g as HavenAgent, h as HavenAgentSummary, S as SweepResult, i as SweepPrepareResponse, j as SweepAuthorization, k as SweepSubmitResponse, l as HavenAllowanceSummary, m as HavenBalanceCoverage, n as PostPurchaseAllowanceSummary, A as AgentPaymentWarning, o as HavenCatalogEntry, p as HavenCatalogSubmission, q as HavenPaymentReceipt, r as HavenPaymentReceiptsPage, O as OpenTaskBudgetResult, s as HavenTaskBudget, T as TaskBudgetSignContext, t as SubmitTaskBudgetResult, C as CloseTaskBudgetResult, u as PaymentResumeState, v as X402Receipt, w as X402Quote, x as X402Erc7710Settlement, y as X402McpCallContext, z as SignData, B as ResumeAuthorizedX402Input, D as ResumeX402PaymentInput, E as X402ResumeState, F as X402McpTransport, G as X402MerchantCallContext, I as HavenError } from './base64-
|
|
2
|
-
export { J as AGENT_PAYMENT_FAILURE_CODE_VALUES, K as AGENT_PAYMENT_NEXT_ACTION_VALUES, L as AGENT_PAYMENT_PHASE_VALUES, M as AGENT_PAYMENT_RAIL_VALUES, N as AgentNextStep, Q as AgentPaymentEnumSchema, U as AgentPaymentFailureCode, V as AgentPaymentFailureCodeDescriptions, W as AgentPaymentFailureCodeSchema, Y as AgentPaymentNextAction, Z as AgentPaymentNextActionDescriptions, _ as AgentPaymentNextActionSchema, $ as AgentPaymentPhase, a0 as AgentPaymentPhaseDescriptions, a1 as AgentPaymentPhaseSchema, a2 as AgentPaymentRail, a3 as AgentPaymentRailDescriptions, a4 as AgentPaymentRailSchema, a5 as AgentPaymentSummary, a6 as AgentPaymentWarningCode, a7 as AgentPurchaseSummary, a8 as CONNECTOR_PACKAGE_NAME, a9 as CatalogSubmissionAccepted, aa as DEFAULT_CONFIRMATION_TIMEOUT_MS, ab as DEFAULT_NEXT_TOOL_BY_ACTION, ac as DIRECT_SIGN_CONTEXT_VERSION, ad as ENTRY_POINT_V07, ae as ERC7710_ASSET_TRANSFER_METHOD, af as HAVEN_CLIENT_HEADER, ag as HAVEN_CONNECTOR_CHANNEL, ah as HAVEN_MINIMUM_NODE_VERSION, ai as HYBRID_DELEGATOR_DOMAIN_NAME, aj as HYBRID_DELEGATOR_DOMAIN_VERSION, ak as HavenAgentAllowanceSummary, al as HavenAgentReadiness, am as HavenAllowance, an as HavenApiError, ao as HavenCatalogMerchant, ap as HavenListScope, aq as HavenPaymentStateError, ar as HavenSigningError, as as HavenTimeoutError, at as HavenTypedDataRefusedError, au as HavenUnsupportedSignerVersionError, av as HavenUserOpBindingError, aw as HavenZeroSettlementHashError, ax as MAX_TASK_BUDGET_TTL_SECONDS, ay as MachinePaymentRail, az as MerchantTimeoutError, aA as NEXT_TOOL_SERVER_NAMES, aB as NEXT_TOOL_SERVER_ROLES, aC as NextStep, aD as NextStepArguments, aE as NextStepHandoff, aF as NextStepInput, aG as NextStepTarget, aH as NextStepTargets, aI as NextToolServerRole, aJ as PACKED_USER_OPERATION_FIELDS, aK as PaymentFee, aL as PaymentNextAction, aM as PaymentPhase, aN as PaymentStatus, aO as ROOT_AUTHORITY, aP as SDK_CLIENT_IDENTITY, aQ as SDK_VERSION, aR as SIGNER_UPDATE_FALLBACK, aS as SWEEP_BASE_CHAIN_ID, aT as SWEEP_BASE_SEPOLIA_CHAIN_ID, aU as SWEEP_BASE_SEPOLIA_USDC_ADDRESS, aV as SWEEP_BASE_USDC_ADDRESS, aW as SettlementChildExpectation, aX as SignerRefusalCode, aY as SweepConfirmation, aZ as SweepEip712Domain, a_ as SweepEntry, a$ as SweepExpectedAuth, b0 as SweepPreparation, b1 as SweepSubmitResult, b2 as SweepTypedData, b3 as TRANSFER_WITH_AUTHORIZATION_TYPES, b4 as TYPED_DATA_NOT_ALLOWED, b5 as TaskBudgetCloseExpectation, b6 as TaskChildExpectation, b7 as TaskChildTypedData, b8 as UnsupportedNodeVersionMessageOptions, b9 as X402AlreadySettledError, ba as X402Erc7710AlreadySettledError, bb as X402ExpectedAuth, bc as X402ExpectedContext, bd as X402PaymentHeaderContext, be as X402PaymentHeaderValidationError, bf as X402PaymentOption, bg as X402RequestSnapshot, bh as X402SchemeSelection, bi as X402TaskBudgetMismatchError, bj as X402UnexpectedStatusError, bk as X402_LEGACY_PAYMENT_HEADER_NAME, bl as X402_MAX_AUTHORIZATION_WINDOW_SECONDS, bm as X402_PAYMENT_HEADER_NAME, bn as X402_PAYMENT_HEADER_NAMES_SENT, bo as X402_PAYMENT_REQUIRED_HEADER_NAME, bp as X402_PAYMENT_RESPONSE_HEADER_NAME, bq as X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, br as assertBoundDirectPaymentUserOp, bs as assertOwnTaskBudgetCloseUserOp, bt as assertOwnTaskChild, bu as assertUserOpTypedDataBinding, bv as buildSweepAuthorizationMessage, bw as buildSweepTypedData, bx as buildX402ExpectedMessage, by as compareNodeVersions, bz as connectorRerunCommand, bA as connectorSpec, bB as connectorUpgradeCommand, bC as createNextStepBuilder, bD as decodeBase64Json, bE as decodeBase64Utf8, bF as defaultNextToolFor, bG as deriveDelegateAccountAddress, bH as encodeBase64Json, bI as encodeBase64Utf8, bJ as encodePaymentProof, bK as hashDelegation, bL as havenClientIdentity, bM as isConnectorChannel, bN as isErc7710Option, bO as isPackedUserOperationTypedData, bP as isSupportedNodeVersion, bQ as isSweepableChain, bR as isTaskChildTypedData, bS as normalizePaymentRequired, bT as packedUserOperationHash, bU as parseNextTool, bV as parsePaymentRequired, bW as parsePaymentRequiredResponse, bX as readClientUpdate, bY as renderNextTool, bZ as resolveConnectorChannel, b_ as resolveTokenBySymbol, b$ as resolveTokenFromAddress, c0 as selectErc7710PaymentOption, c1 as selectPaymentOption, c2 as selectStandardPaymentOption, c3 as selectX402SettlementScheme, c4 as signerUpdateFallback, c5 as sweepUsdcAddress, c6 as sweepUsdcDomain, c7 as toStandardPaymentRequirements, c8 as unsupportedNodeVersionMessage, c9 as validateStandardX402PaymentHeader, ca as verifySettlementChild, cb as x402AssetTransferMethod, cc as x402AuthorizationAmount, cd as x402FacilitatorAddresses, ce as x402V2PaymentEnvelope } from './base64-
|
|
1
|
+
import { R as RawPaymentParties, H as HavenClientConfig, a as HavenClientUpdate, P as PaymentRequest, b as PaymentResult, c as PaymentIntent, X as X402PaymentRequired, d as X402AuthorizationOptions, e as X402Intent, f as PaymentStatusResult, g as HavenAgent, h as HavenAgentSummary, S as SweepResult, i as SweepPrepareResponse, j as SweepAuthorization, k as SweepSubmitResponse, l as HavenAllowanceSummary, m as HavenBalanceCoverage, n as PostPurchaseAllowanceSummary, A as AgentPaymentWarning, o as HavenCatalogEntry, p as HavenCatalogSubmission, q as HavenPaymentReceipt, r as HavenPaymentReceiptsPage, O as OpenTaskBudgetResult, s as HavenTaskBudget, T as TaskBudgetSignContext, t as SubmitTaskBudgetResult, C as CloseTaskBudgetResult, u as PaymentResumeState, v as X402Receipt, w as X402Quote, x as X402Erc7710Settlement, y as X402McpCallContext, z as SignData, B as ResumeAuthorizedX402Input, D as ResumeX402PaymentInput, E as X402ResumeState, F as X402McpTransport, G as X402MerchantCallContext, I as HavenError } from './base64-BFXCO54F.js';
|
|
2
|
+
export { J as AGENT_PAYMENT_FAILURE_CODE_VALUES, K as AGENT_PAYMENT_NEXT_ACTION_VALUES, L as AGENT_PAYMENT_PHASE_VALUES, M as AGENT_PAYMENT_RAIL_VALUES, N as AgentNextStep, Q as AgentPaymentEnumSchema, U as AgentPaymentFailureCode, V as AgentPaymentFailureCodeDescriptions, W as AgentPaymentFailureCodeSchema, Y as AgentPaymentNextAction, Z as AgentPaymentNextActionDescriptions, _ as AgentPaymentNextActionSchema, $ as AgentPaymentPhase, a0 as AgentPaymentPhaseDescriptions, a1 as AgentPaymentPhaseSchema, a2 as AgentPaymentRail, a3 as AgentPaymentRailDescriptions, a4 as AgentPaymentRailSchema, a5 as AgentPaymentSummary, a6 as AgentPaymentWarningCode, a7 as AgentPurchaseSummary, a8 as CONNECTOR_PACKAGE_NAME, a9 as CatalogSubmissionAccepted, aa as DEFAULT_CONFIRMATION_TIMEOUT_MS, ab as DEFAULT_NEXT_TOOL_BY_ACTION, ac as DIRECT_SIGN_CONTEXT_VERSION, ad as ENTRY_POINT_V07, ae as ERC7710_ASSET_TRANSFER_METHOD, af as HAVEN_CLIENT_HEADER, ag as HAVEN_CONNECTOR_CHANNEL, ah as HAVEN_MINIMUM_NODE_VERSION, ai as HYBRID_DELEGATOR_DOMAIN_NAME, aj as HYBRID_DELEGATOR_DOMAIN_VERSION, ak as HavenAgentAllowanceSummary, al as HavenAgentReadiness, am as HavenAllowance, an as HavenApiError, ao as HavenCatalogMerchant, ap as HavenListScope, aq as HavenPaymentStateError, ar as HavenSigningError, as as HavenTimeoutError, at as HavenTypedDataRefusedError, au as HavenUnsupportedSignerVersionError, av as HavenUserOpBindingError, aw as HavenZeroSettlementHashError, ax as MAX_TASK_BUDGET_TTL_SECONDS, ay as MachinePaymentRail, az as MerchantTimeoutError, aA as NEXT_TOOL_SERVER_NAMES, aB as NEXT_TOOL_SERVER_ROLES, aC as NextStep, aD as NextStepArguments, aE as NextStepHandoff, aF as NextStepInput, aG as NextStepTarget, aH as NextStepTargets, aI as NextToolServerRole, aJ as PACKED_USER_OPERATION_FIELDS, aK as PaymentFee, aL as PaymentNextAction, aM as PaymentPhase, aN as PaymentStatus, aO as ROOT_AUTHORITY, aP as SDK_CLIENT_IDENTITY, aQ as SDK_VERSION, aR as SIGNER_UPDATE_FALLBACK, aS as SWEEP_BASE_CHAIN_ID, aT as SWEEP_BASE_SEPOLIA_CHAIN_ID, aU as SWEEP_BASE_SEPOLIA_USDC_ADDRESS, aV as SWEEP_BASE_USDC_ADDRESS, aW as SettlementChildExpectation, aX as SignerRefusalCode, aY as SweepConfirmation, aZ as SweepEip712Domain, a_ as SweepEntry, a$ as SweepExpectedAuth, b0 as SweepPreparation, b1 as SweepSubmitResult, b2 as SweepTypedData, b3 as TRANSFER_WITH_AUTHORIZATION_TYPES, b4 as TYPED_DATA_NOT_ALLOWED, b5 as TaskBudgetCloseExpectation, b6 as TaskChildExpectation, b7 as TaskChildTypedData, b8 as UnsupportedNodeVersionMessageOptions, b9 as X402AlreadySettledError, ba as X402Erc7710AlreadySettledError, bb as X402ExpectedAuth, bc as X402ExpectedContext, bd as X402PaymentHeaderContext, be as X402PaymentHeaderValidationError, bf as X402PaymentOption, bg as X402RequestSnapshot, bh as X402SchemeSelection, bi as X402TaskBudgetMismatchError, bj as X402UnexpectedStatusError, bk as X402_LEGACY_PAYMENT_HEADER_NAME, bl as X402_MAX_AUTHORIZATION_WINDOW_SECONDS, bm as X402_PAYMENT_HEADER_NAME, bn as X402_PAYMENT_HEADER_NAMES_SENT, bo as X402_PAYMENT_REQUIRED_HEADER_NAME, bp as X402_PAYMENT_RESPONSE_HEADER_NAME, bq as X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, br as assertBoundDirectPaymentUserOp, bs as assertOwnTaskBudgetCloseUserOp, bt as assertOwnTaskChild, bu as assertUserOpTypedDataBinding, bv as buildSweepAuthorizationMessage, bw as buildSweepTypedData, bx as buildX402ExpectedMessage, by as compareNodeVersions, bz as connectorRerunCommand, bA as connectorSpec, bB as connectorUpgradeCommand, bC as createNextStepBuilder, bD as decodeBase64Json, bE as decodeBase64Utf8, bF as defaultNextToolFor, bG as deriveDelegateAccountAddress, bH as encodeBase64Json, bI as encodeBase64Utf8, bJ as encodePaymentProof, bK as hashDelegation, bL as havenClientIdentity, bM as isConnectorChannel, bN as isErc7710Option, bO as isPackedUserOperationTypedData, bP as isSupportedNodeVersion, bQ as isSweepableChain, bR as isTaskChildTypedData, bS as normalizePaymentRequired, bT as packedUserOperationHash, bU as parseNextTool, bV as parsePaymentRequired, bW as parsePaymentRequiredResponse, bX as readClientUpdate, bY as renderNextTool, bZ as resolveConnectorChannel, b_ as resolveTokenBySymbol, b$ as resolveTokenFromAddress, c0 as selectErc7710PaymentOption, c1 as selectPaymentOption, c2 as selectStandardPaymentOption, c3 as selectX402SettlementScheme, c4 as signerUpdateFallback, c5 as sweepUsdcAddress, c6 as sweepUsdcDomain, c7 as toStandardPaymentRequirements, c8 as unsupportedNodeVersionMessage, c9 as validateStandardX402PaymentHeader, ca as verifySettlementChild, cb as x402AssetTransferMethod, cc as x402AuthorizationAmount, cd as x402FacilitatorAddresses, ce as x402V2PaymentEnvelope } from './base64-BFXCO54F.js';
|
|
3
3
|
import 'x402/types';
|
|
4
4
|
import 'viem';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Verifiable payment receipts.
|
|
8
8
|
*
|
|
9
|
-
* A self-contained
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `txHash`
|
|
9
|
+
* A self-contained bundle for a settled Haven payment whose agent
|
|
10
|
+
* authorisation can be checked offline. What `verifyPaymentReceipt` proves is
|
|
11
|
+
* deliberately narrow: the `payment` block (amount, recipient) is
|
|
12
|
+
* Haven-asserted and is NOT bound by the signature, and `verified: true` never
|
|
13
|
+
* proves the payment settled on-chain — settlement stays an explorer check on
|
|
14
|
+
* `onChain.txHash` / `settlementTxHash`.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* What `verified: true` means, per scheme:
|
|
17
|
+
*
|
|
18
|
+
* - erc7710 (`authorization.signatureScheme: 'eip712_delegation'`): the bundle
|
|
19
|
+
* carries the settlement child's EIP-712 struct hash as `signHash`. The
|
|
20
|
+
* verifier rebuilds the digest the delegate actually signed —
|
|
21
|
+
* `keccak256(0x1901 ‖ domainSeparator(DelegationManager, chainId) ‖ signHash)`
|
|
22
|
+
* — from the DelegationManager address the SDK pins and the bundle's
|
|
23
|
+
* `onChain.chainId`, never from a value the receipt itself vouches for.
|
|
24
|
+
* `verified: true` means the delegate key signed that settlement delegation
|
|
25
|
+
* (`verifiedOver: 'delegation_digest'`).
|
|
26
|
+
* - direct payments and the eip3009 funding leg
|
|
27
|
+
* (`signatureScheme: 'eip712_userop'`) sign an ERC-4337 user operation the
|
|
28
|
+
* bundle does not carry: they return `not_verifiable_offline` rather than a
|
|
29
|
+
* false accusation.
|
|
30
|
+
* - retired-rail bundles (no scheme) carry a raw-signed `signHash`; the
|
|
31
|
+
* verifier recovers over it directly, then over the delegation digest when
|
|
32
|
+
* the chain allows rebuilding it.
|
|
33
|
+
*
|
|
34
|
+
* Anything that is not a signed bundle — including a `haven_list_receipts`
|
|
35
|
+
* history row, which carries no signature at all — returns
|
|
36
|
+
* `not_a_signed_receipt`. Verification never throws.
|
|
37
|
+
*
|
|
38
|
+
* This lives in the SDK so agents and users can verify receipts client-side.
|
|
18
39
|
*/
|
|
19
40
|
declare const RECEIPT_VERSION = "haven-receipt-1";
|
|
20
41
|
interface PaymentReceipt {
|
|
@@ -44,6 +65,17 @@ interface PaymentReceipt {
|
|
|
44
65
|
delegate: string;
|
|
45
66
|
signHash: string;
|
|
46
67
|
signature: string | null;
|
|
68
|
+
/**
|
|
69
|
+
* #3418: which digest the delegate signed — selects what offline
|
|
70
|
+
* verification rebuilds. `'eip712_delegation'`: the settlement
|
|
71
|
+
* delegation's EIP-712 digest (erc7710). `'eip712_userop'`: an ERC-4337
|
|
72
|
+
* user-operation digest the bundle does not carry (direct payments, the
|
|
73
|
+
* eip3009 funding leg) — not verifiable offline. Absent on retired-rail
|
|
74
|
+
* bundles and on backends older than #3418, whose `signHash` was signed
|
|
75
|
+
* raw. The value is only a selector: a lying one cannot make a forged
|
|
76
|
+
* signature verify, because recovery must still return `delegate`.
|
|
77
|
+
*/
|
|
78
|
+
signatureScheme?: 'eip712_delegation' | 'eip712_userop';
|
|
47
79
|
};
|
|
48
80
|
onChain: {
|
|
49
81
|
txHash: string | null;
|
|
@@ -53,17 +85,27 @@ interface PaymentReceipt {
|
|
|
53
85
|
type ReceiptVerification = {
|
|
54
86
|
verified: true;
|
|
55
87
|
recoveredSigner: string;
|
|
88
|
+
verifiedOver: 'sign_hash' | 'delegation_digest';
|
|
56
89
|
} | {
|
|
57
90
|
verified: false;
|
|
58
|
-
reason:
|
|
91
|
+
reason:
|
|
92
|
+
/** #3418: the input is not a haven-receipt-1 bundle (a haven_list_receipts row, null, undefined, a non-object). */
|
|
93
|
+
'not_a_signed_receipt'
|
|
94
|
+
/** #3418: eip712_userop bundle; or a delegation bundle on a chain the SDK pins no DelegationManager for. */
|
|
95
|
+
| 'not_verifiable_offline' | 'missing_signature' | 'bad_signature' | 'signer_mismatch';
|
|
59
96
|
recoveredSigner?: string;
|
|
60
97
|
};
|
|
98
|
+
type RecoverFn = (hash: string, signature: string) => string;
|
|
61
99
|
/**
|
|
62
|
-
* Verify a receipt
|
|
63
|
-
* confirm it is the agent
|
|
64
|
-
*
|
|
100
|
+
* Verify a receipt's agent authorisation offline: recover the signer and
|
|
101
|
+
* confirm it is the agent delegate, over whichever digest the bundle's scheme
|
|
102
|
+
* names (see the module doc for what that proves — and what it does not).
|
|
103
|
+
* Never throws: anything that is not a signed receipt — a
|
|
104
|
+
* `haven_list_receipts` history row, null, undefined, a non-object — returns
|
|
105
|
+
* `not_a_signed_receipt`. Pure — `recover` is injectable but defaults to
|
|
106
|
+
* standard ECDSA recovery, so this runs anywhere (no Haven backend).
|
|
65
107
|
*/
|
|
66
|
-
declare function verifyPaymentReceipt(receipt:
|
|
108
|
+
declare function verifyPaymentReceipt(receipt: unknown, recover?: RecoverFn): ReceiptVerification;
|
|
67
109
|
|
|
68
110
|
/**
|
|
69
111
|
* Merchant delivery and the evidence trail behind it (#1620, epic #1613).
|
|
@@ -982,9 +1024,9 @@ declare const toolDescriptions: {
|
|
|
982
1024
|
readonly nextActionGuidance: "";
|
|
983
1025
|
};
|
|
984
1026
|
readonly verifyReceipt: {
|
|
985
|
-
readonly summary: "Verify a payment receipt offline — confirm the agent
|
|
986
|
-
readonly selectionGuidance: "
|
|
987
|
-
readonly behavior: "
|
|
1027
|
+
readonly summary: "Verify a signed payment receipt offline — confirm the agent delegate signed its authorisation.";
|
|
1028
|
+
readonly selectionGuidance: "Takes the signed bundle from GET /payments/{id}/receipt, not a haven_list_receipts row — a row carries no signature and returns not_a_signed_receipt. No network.";
|
|
1029
|
+
readonly behavior: "Never throws. An erc7710 bundle verifies over the delegation digest the delegate signed; a direct or eip3009 bundle returns not_verifiable_offline. verified true means only that the delegate signed the hash named by verifiedOver — payment facts are Haven-asserted and settlement is not proven; check settlementTxHash on an explorer.";
|
|
988
1030
|
readonly nextActionGuidance: "";
|
|
989
1031
|
};
|
|
990
1032
|
readonly payMcpTool: {
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { selectStandardPaymentOption, buildX402IdempotencyKey, x402AuthorizationAmount, assertBoundDirectPaymentUserOp, assertFundingLegPaysDelegate, HavenTypedDataRefusedError, assertOwnSettlementChild, parsePaymentRequiredResponse, x402PaymentHeaderNamesSent, SDK_CLIENT_IDENTITY, readClientUpdate, HAVEN_CLIENT_HEADER, resolveTokenFromAddress, isSweepableChain, sweepUsdcAddress, x402PaymentHeaderNamesFor, X402_PAYMENT_HEADER_NAMES, toStandardPaymentRequirements, decodeBase64Json, encodeBase64Json, x402V2PaymentEnvelope, selectX402SettlementScheme, selectErc7710PaymentOption, isErc7710Option, x402AssetTransferMethod, normalizePaymentRequired } from './chunk-
|
|
2
|
-
export { DEFAULT_NEXT_TOOL_BY_ACTION, ERC7710_ASSET_TRANSFER_METHOD, HAVEN_CLIENT_HEADER, HAVEN_MINIMUM_NODE_VERSION, HavenTypedDataRefusedError, MAX_TASK_BUDGET_TTL_SECONDS, NEXT_TOOL_SERVER_NAMES, NEXT_TOOL_SERVER_ROLES, SDK_CLIENT_IDENTITY, SDK_VERSION, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, TRANSFER_WITH_AUTHORIZATION_TYPES, TYPED_DATA_NOT_ALLOWED, X402PaymentHeaderValidationError, X402_LEGACY_PAYMENT_HEADER_NAME, X402_MAX_AUTHORIZATION_WINDOW_SECONDS, X402_PAYMENT_HEADER_NAME, X402_PAYMENT_HEADER_NAMES_SENT, X402_PAYMENT_REQUIRED_HEADER_NAME, X402_PAYMENT_RESPONSE_HEADER_NAME, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, assertBoundDirectPaymentUserOp, assertOwnTaskBudgetCloseUserOp, assertOwnTaskChild, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, compareNodeVersions, createNextStepBuilder, decodeBase64Json, decodeBase64Utf8, defaultNextToolFor, encodeBase64Json, encodeBase64Utf8, encodePaymentProof, hashDelegation, havenClientIdentity, isErc7710Option, isSupportedNodeVersion, isSweepableChain, isTaskChildTypedData, normalizePaymentRequired, parseNextTool, parsePaymentRequired, parsePaymentRequiredResponse, readClientUpdate, renderNextTool, resolveTokenBySymbol, resolveTokenFromAddress, selectErc7710PaymentOption, selectPaymentOption, selectStandardPaymentOption, selectX402SettlementScheme, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, unsupportedNodeVersionMessage, validateStandardX402PaymentHeader, x402AssetTransferMethod, x402AuthorizationAmount, x402FacilitatorAddresses, x402V2PaymentEnvelope } from './chunk-
|
|
3
|
-
import { HavenSigningError, HavenError, DEFAULT_CONFIRMATION_TIMEOUT_MS, HavenApiError, assertUserOpTypedDataBinding, AgentPaymentRail, AgentPaymentPhase, HavenTimeoutError, X402TaskBudgetMismatchError, X402UnexpectedStatusError, X402AlreadySettledError, AgentPaymentWarningCode, MerchantTimeoutError, AgentPaymentNextAction, HavenPaymentStateError, HavenZeroSettlementHashError, X402Erc7710AlreadySettledError, chainIdForNetwork } from './chunk-Y2Q4DZVU.js';
|
|
1
|
+
import { selectStandardPaymentOption, buildX402IdempotencyKey, x402AuthorizationAmount, assertBoundDirectPaymentUserOp, assertFundingLegPaysDelegate, HavenTypedDataRefusedError, assertOwnSettlementChild, parsePaymentRequiredResponse, x402PaymentHeaderNamesSent, SDK_CLIENT_IDENTITY, readClientUpdate, HAVEN_CLIENT_HEADER, resolveTokenFromAddress, isSweepableChain, sweepUsdcAddress, x402PaymentHeaderNamesFor, X402_PAYMENT_HEADER_NAMES, toStandardPaymentRequirements, decodeBase64Json, encodeBase64Json, x402V2PaymentEnvelope, selectX402SettlementScheme, selectErc7710PaymentOption, isErc7710Option, x402AssetTransferMethod, normalizePaymentRequired } from './chunk-LKWXAYWW.js';
|
|
2
|
+
export { DEFAULT_NEXT_TOOL_BY_ACTION, ERC7710_ASSET_TRANSFER_METHOD, HAVEN_CLIENT_HEADER, HAVEN_MINIMUM_NODE_VERSION, HavenTypedDataRefusedError, MAX_TASK_BUDGET_TTL_SECONDS, NEXT_TOOL_SERVER_NAMES, NEXT_TOOL_SERVER_ROLES, SDK_CLIENT_IDENTITY, SDK_VERSION, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, TRANSFER_WITH_AUTHORIZATION_TYPES, TYPED_DATA_NOT_ALLOWED, X402PaymentHeaderValidationError, X402_LEGACY_PAYMENT_HEADER_NAME, X402_MAX_AUTHORIZATION_WINDOW_SECONDS, X402_PAYMENT_HEADER_NAME, X402_PAYMENT_HEADER_NAMES_SENT, X402_PAYMENT_REQUIRED_HEADER_NAME, X402_PAYMENT_RESPONSE_HEADER_NAME, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, assertBoundDirectPaymentUserOp, assertOwnTaskBudgetCloseUserOp, assertOwnTaskChild, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, compareNodeVersions, createNextStepBuilder, decodeBase64Json, decodeBase64Utf8, defaultNextToolFor, encodeBase64Json, encodeBase64Utf8, encodePaymentProof, hashDelegation, havenClientIdentity, isErc7710Option, isSupportedNodeVersion, isSweepableChain, isTaskChildTypedData, normalizePaymentRequired, parseNextTool, parsePaymentRequired, parsePaymentRequiredResponse, readClientUpdate, renderNextTool, resolveTokenBySymbol, resolveTokenFromAddress, selectErc7710PaymentOption, selectPaymentOption, selectStandardPaymentOption, selectX402SettlementScheme, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, unsupportedNodeVersionMessage, validateStandardX402PaymentHeader, x402AssetTransferMethod, x402AuthorizationAmount, x402FacilitatorAddresses, x402V2PaymentEnvelope } from './chunk-LKWXAYWW.js';
|
|
3
|
+
import { HavenSigningError, HavenError, DEFAULT_CONFIRMATION_TIMEOUT_MS, HavenApiError, assertUserOpTypedDataBinding, AgentPaymentRail, AgentPaymentPhase, HavenTimeoutError, X402TaskBudgetMismatchError, X402UnexpectedStatusError, X402AlreadySettledError, AgentPaymentWarningCode, MerchantTimeoutError, AgentPaymentNextAction, HavenPaymentStateError, HavenZeroSettlementHashError, X402Erc7710AlreadySettledError, DELEGATION_MANAGER, chainIdForNetwork } from './chunk-Y2Q4DZVU.js';
|
|
4
4
|
export { AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, AgentPaymentWarningCode, CONNECTOR_PACKAGE_NAME, DEFAULT_CONFIRMATION_TIMEOUT_MS, DIRECT_SIGN_CONTEXT_VERSION, ENTRY_POINT_V07, HAVEN_CONNECTOR_CHANNEL, HYBRID_DELEGATOR_DOMAIN_NAME, HYBRID_DELEGATOR_DOMAIN_VERSION, HavenApiError, HavenError, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, HavenUnsupportedSignerVersionError, HavenUserOpBindingError, HavenZeroSettlementHashError, MerchantTimeoutError, PACKED_USER_OPERATION_FIELDS, ROOT_AUTHORITY, SIGNER_UPDATE_FALLBACK, SignerRefusalCode, X402AlreadySettledError, X402Erc7710AlreadySettledError, X402TaskBudgetMismatchError, X402UnexpectedStatusError, assertUserOpTypedDataBinding, connectorRerunCommand, connectorSpec, connectorUpgradeCommand, deriveDelegateAccountAddress, isConnectorChannel, isPackedUserOperationTypedData, packedUserOperationHash, resolveConnectorChannel, signerUpdateFallback, verifySettlementChild } from './chunk-Y2Q4DZVU.js';
|
|
5
|
-
import { hashTypedData } from 'viem';
|
|
5
|
+
import { keccak256, toBytes, concatHex, hashTypedData, encodeAbiParameters } from 'viem';
|
|
6
6
|
import { ethers } from 'ethers';
|
|
7
7
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
8
8
|
import { exact } from 'x402/schemes';
|
|
@@ -849,22 +849,93 @@ function selectJsonRpcResult(messages) {
|
|
|
849
849
|
return messages.find((message) => "result" in message || "error" in message) ?? messages.at(-1);
|
|
850
850
|
}
|
|
851
851
|
var RECEIPT_VERSION = "haven-receipt-1";
|
|
852
|
+
var DELEGATION_MANAGER_CHAIN_IDS = /* @__PURE__ */ new Set([8453, 84532]);
|
|
853
|
+
var EIP712_DOMAIN_TYPEHASH = keccak256(
|
|
854
|
+
toBytes("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
|
|
855
|
+
);
|
|
856
|
+
function delegationDomainSeparator(chainId) {
|
|
857
|
+
return keccak256(
|
|
858
|
+
encodeAbiParameters(
|
|
859
|
+
[{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint256" }, { type: "address" }],
|
|
860
|
+
[
|
|
861
|
+
EIP712_DOMAIN_TYPEHASH,
|
|
862
|
+
keccak256(toBytes("DelegationManager")),
|
|
863
|
+
keccak256(toBytes("1")),
|
|
864
|
+
BigInt(chainId),
|
|
865
|
+
DELEGATION_MANAGER
|
|
866
|
+
]
|
|
867
|
+
)
|
|
868
|
+
);
|
|
869
|
+
}
|
|
870
|
+
function delegationDigest(structHash, chainId) {
|
|
871
|
+
return keccak256(concatHex(["0x1901", delegationDomainSeparator(chainId), structHash]));
|
|
872
|
+
}
|
|
852
873
|
function defaultRecover(hash, signature) {
|
|
853
874
|
return ethers.recoverAddress(hash, signature);
|
|
854
875
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
if (!signature) return { verified: false, reason: "missing_signature" };
|
|
876
|
+
var NOT_A_SIGNED_RECEIPT = { verified: false, reason: "not_a_signed_receipt" };
|
|
877
|
+
function match(delegate, hash, signature, recover) {
|
|
858
878
|
let recovered;
|
|
859
879
|
try {
|
|
860
|
-
recovered = recover(
|
|
880
|
+
recovered = recover(hash, signature);
|
|
861
881
|
} catch {
|
|
862
|
-
return {
|
|
882
|
+
return { ok: false, reason: "bad_signature" };
|
|
863
883
|
}
|
|
864
884
|
if (recovered.toLowerCase() !== delegate.toLowerCase()) {
|
|
865
|
-
return {
|
|
885
|
+
return { ok: false, reason: "signer_mismatch", recoveredSigner: recovered };
|
|
886
|
+
}
|
|
887
|
+
return { ok: true, recoveredSigner: recovered };
|
|
888
|
+
}
|
|
889
|
+
function finish(result, verifiedOver) {
|
|
890
|
+
if (result.ok) {
|
|
891
|
+
return { verified: true, recoveredSigner: result.recoveredSigner, verifiedOver };
|
|
892
|
+
}
|
|
893
|
+
return result.recoveredSigner !== void 0 ? { verified: false, reason: result.reason, recoveredSigner: result.recoveredSigner } : { verified: false, reason: result.reason };
|
|
894
|
+
}
|
|
895
|
+
function verifyPaymentReceipt(receipt, recover = defaultRecover) {
|
|
896
|
+
if (typeof receipt !== "object" || receipt === null) return NOT_A_SIGNED_RECEIPT;
|
|
897
|
+
const source = receipt;
|
|
898
|
+
if (typeof source.authorization !== "object" || source.authorization === null) {
|
|
899
|
+
return NOT_A_SIGNED_RECEIPT;
|
|
900
|
+
}
|
|
901
|
+
const auth = source.authorization;
|
|
902
|
+
const { delegate, signHash: signHash2, signature, signatureScheme } = auth;
|
|
903
|
+
if (typeof delegate !== "string" || delegate === "" || typeof signHash2 !== "string" || signHash2 === "") {
|
|
904
|
+
return NOT_A_SIGNED_RECEIPT;
|
|
905
|
+
}
|
|
906
|
+
if (typeof signature !== "string" || signature === "") {
|
|
907
|
+
return { verified: false, reason: "missing_signature" };
|
|
908
|
+
}
|
|
909
|
+
const chainId = typeof source.onChain?.chainId === "number" ? source.onChain.chainId : void 0;
|
|
910
|
+
const digestVerifiable = chainId !== void 0 && DELEGATION_MANAGER_CHAIN_IDS.has(chainId);
|
|
911
|
+
if (signatureScheme === "eip712_userop") {
|
|
912
|
+
return { verified: false, reason: "not_verifiable_offline" };
|
|
913
|
+
}
|
|
914
|
+
if (signatureScheme === "eip712_delegation") {
|
|
915
|
+
if (!digestVerifiable) {
|
|
916
|
+
return { verified: false, reason: "not_verifiable_offline" };
|
|
917
|
+
}
|
|
918
|
+
let digest;
|
|
919
|
+
try {
|
|
920
|
+
digest = delegationDigest(signHash2, chainId);
|
|
921
|
+
} catch {
|
|
922
|
+
return { verified: false, reason: "bad_signature" };
|
|
923
|
+
}
|
|
924
|
+
return finish(match(delegate, digest, signature, recover), "delegation_digest");
|
|
925
|
+
}
|
|
926
|
+
const raw = match(delegate, signHash2, signature, recover);
|
|
927
|
+
if (raw.ok) return finish(raw, "sign_hash");
|
|
928
|
+
if (digestVerifiable) {
|
|
929
|
+
let digest;
|
|
930
|
+
try {
|
|
931
|
+
digest = delegationDigest(signHash2, chainId);
|
|
932
|
+
} catch {
|
|
933
|
+
return finish(raw, "sign_hash");
|
|
934
|
+
}
|
|
935
|
+
const delegated = match(delegate, digest, signature, recover);
|
|
936
|
+
if (delegated.ok) return finish(delegated, "delegation_digest");
|
|
866
937
|
}
|
|
867
|
-
return
|
|
938
|
+
return finish(raw, "sign_hash");
|
|
868
939
|
}
|
|
869
940
|
|
|
870
941
|
// src/account-reads.ts
|
|
@@ -1081,22 +1152,22 @@ var AccountReads = class {
|
|
|
1081
1152
|
try {
|
|
1082
1153
|
const tokenAddress = payment.asset ?? payment.x402?.asset ?? null;
|
|
1083
1154
|
if (!tokenAddress) return unavailable("the settled payment does not carry a resolvable token address", payment);
|
|
1084
|
-
const
|
|
1155
|
+
const match2 = allowanceResult.value.allowances.find(
|
|
1085
1156
|
(allowance) => allowance.tokenAddress.toLowerCase() === tokenAddress.toLowerCase()
|
|
1086
1157
|
);
|
|
1087
|
-
if (!
|
|
1088
|
-
const token = resolveTokenFromAddress(
|
|
1089
|
-
const remainingDisplay = token ? `${formatAtomicAmount(safeBigInt(
|
|
1158
|
+
if (!match2) return unavailable("no allowance/budget row matches the settled token", payment);
|
|
1159
|
+
const token = resolveTokenFromAddress(match2.tokenAddress);
|
|
1160
|
+
const remainingDisplay = token ? `${formatAtomicAmount(safeBigInt(match2.onchain.remaining), token.decimals)} ${match2.tokenSymbol}` : void 0;
|
|
1090
1161
|
const rail = agentResult.value.executionRail;
|
|
1091
1162
|
return {
|
|
1092
1163
|
payment,
|
|
1093
1164
|
allowance: {
|
|
1094
1165
|
rail,
|
|
1095
|
-
remaining_atomic:
|
|
1166
|
+
remaining_atomic: match2.onchain.remaining,
|
|
1096
1167
|
...remainingDisplay ? { remaining_display: remainingDisplay } : {},
|
|
1097
|
-
token_symbol:
|
|
1098
|
-
token_address:
|
|
1099
|
-
reset_period:
|
|
1168
|
+
token_symbol: match2.tokenSymbol,
|
|
1169
|
+
token_address: match2.tokenAddress,
|
|
1170
|
+
reset_period: match2.resetPeriodMin,
|
|
1100
1171
|
source: rail === "delegation" ? "active_delegations" : "allowance_module"
|
|
1101
1172
|
},
|
|
1102
1173
|
warnings: []
|
|
@@ -3855,9 +3926,9 @@ var toolDescriptions = {
|
|
|
3855
3926
|
nextActionGuidance: ""
|
|
3856
3927
|
},
|
|
3857
3928
|
verifyReceipt: {
|
|
3858
|
-
summary: "Verify a payment receipt offline \u2014 confirm the agent
|
|
3859
|
-
selectionGuidance: "
|
|
3860
|
-
behavior: "
|
|
3929
|
+
summary: "Verify a signed payment receipt offline \u2014 confirm the agent delegate signed its authorisation.",
|
|
3930
|
+
selectionGuidance: "Takes the signed bundle from GET /payments/{id}/receipt, not a haven_list_receipts row \u2014 a row carries no signature and returns not_a_signed_receipt. No network.",
|
|
3931
|
+
behavior: "Never throws. An erc7710 bundle verifies over the delegation digest the delegate signed; a direct or eip3009 bundle returns not_verifiable_offline. verified true means only that the delegate signed the hash named by verifiedOver \u2014 payment facts are Haven-asserted and settlement is not proven; check settlementTxHash on an explorer.",
|
|
3861
3932
|
nextActionGuidance: ""
|
|
3862
3933
|
},
|
|
3863
3934
|
payMcpTool: {
|