@haven_ai/sdk 0.6.0-alpha.0 → 0.7.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 +22 -7
- package/dist/{base64-cD9kR4JL.d.cts → base64-_seD1uw8.d.cts} +184 -4
- package/dist/{base64-cD9kR4JL.d.ts → base64-_seD1uw8.d.ts} +184 -4
- package/dist/{chunk-S42QSWJY.cjs → chunk-3SVPI4LS.cjs} +93 -8
- package/dist/chunk-3SVPI4LS.cjs.map +1 -0
- package/dist/{chunk-CK4NLLMO.cjs → chunk-J6DQEBK2.cjs} +36 -29
- package/dist/chunk-J6DQEBK2.cjs.map +1 -0
- package/dist/{chunk-63GPTEEY.js → chunk-NNIT7WAI.js} +90 -9
- package/dist/chunk-NNIT7WAI.js.map +1 -0
- package/dist/{chunk-3WSEX3GW.js → chunk-R3RZJJWL.js} +11 -5
- package/dist/chunk-R3RZJJWL.js.map +1 -0
- package/dist/edge.cjs +275 -64
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.d.cts +99 -2
- package/dist/edge.d.ts +99 -2
- package/dist/edge.js +204 -4
- package/dist/edge.js.map +1 -1
- package/dist/index.cjs +579 -348
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +118 -28
- package/dist/index.d.ts +118 -28
- package/dist/index.js +280 -70
- package/dist/index.js.map +1 -1
- package/dist/test-support.cjs +18 -18
- package/dist/test-support.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3WSEX3GW.js.map +0 -1
- package/dist/chunk-63GPTEEY.js.map +0 -1
- package/dist/chunk-CK4NLLMO.cjs.map +0 -1
- package/dist/chunk-S42QSWJY.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkJ6DQEBK2_cjs = require('./chunk-J6DQEBK2.cjs');
|
|
4
|
+
var chunk3SVPI4LS_cjs = require('./chunk-3SVPI4LS.cjs');
|
|
5
5
|
var viem = require('viem');
|
|
6
6
|
var ethers = require('ethers');
|
|
7
7
|
var async_hooks = require('async_hooks');
|
|
@@ -14,7 +14,7 @@ function signHash(privateKey, hash) {
|
|
|
14
14
|
const sig = signingKey.sign(hash);
|
|
15
15
|
return sig.serialized;
|
|
16
16
|
} catch (err) {
|
|
17
|
-
throw new
|
|
17
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
18
18
|
`Failed to sign hash: ${err instanceof Error ? err.message : String(err)}`
|
|
19
19
|
);
|
|
20
20
|
}
|
|
@@ -30,7 +30,7 @@ async function signTypedDataVerbatim(privateKey, typedData, label) {
|
|
|
30
30
|
typedData.message
|
|
31
31
|
);
|
|
32
32
|
} catch (err) {
|
|
33
|
-
throw new
|
|
33
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
34
34
|
`Failed to sign ${label}: ${err instanceof Error ? err.message : String(err)}`
|
|
35
35
|
);
|
|
36
36
|
}
|
|
@@ -45,7 +45,7 @@ function addressFromKey(privateKey) {
|
|
|
45
45
|
try {
|
|
46
46
|
return new ethers.ethers.Wallet(privateKey).address;
|
|
47
47
|
} catch (err) {
|
|
48
|
-
throw new
|
|
48
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
49
49
|
`Invalid private key: ${err instanceof Error ? err.message : String(err)}`
|
|
50
50
|
);
|
|
51
51
|
}
|
|
@@ -61,7 +61,7 @@ function verifySignature(hash, signature, expectedAddress) {
|
|
|
61
61
|
var DEFAULT_BASE_URL = "http://localhost:3001";
|
|
62
62
|
var DEFAULT_REQUEST_TIMEOUT = 3e4;
|
|
63
63
|
function withoutClientHeader(headers) {
|
|
64
|
-
const target =
|
|
64
|
+
const target = chunkJ6DQEBK2_cjs.HAVEN_CLIENT_HEADER.toLowerCase();
|
|
65
65
|
return Object.fromEntries(Object.entries(headers).filter(([name]) => name.toLowerCase() !== target));
|
|
66
66
|
}
|
|
67
67
|
var HavenApiTransport = class {
|
|
@@ -77,7 +77,7 @@ var HavenApiTransport = class {
|
|
|
77
77
|
this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
78
78
|
this.requestTimeout = config.requestTimeout ?? DEFAULT_REQUEST_TIMEOUT;
|
|
79
79
|
this.defaultHeaders = { ...config.defaultHeaders ?? {} };
|
|
80
|
-
this.clientIdentity = config.clientIdentity ??
|
|
80
|
+
this.clientIdentity = config.clientIdentity ?? chunkJ6DQEBK2_cjs.SDK_CLIENT_IDENTITY;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* The newest `client_update` the backend sent (#3303): inside a
|
|
@@ -90,7 +90,7 @@ var HavenApiTransport = class {
|
|
|
90
90
|
}
|
|
91
91
|
recordClientUpdate(data) {
|
|
92
92
|
if (data === null || typeof data !== "object" || Array.isArray(data)) return;
|
|
93
|
-
const hint =
|
|
93
|
+
const hint = chunkJ6DQEBK2_cjs.readClientUpdate(data.client_update);
|
|
94
94
|
if (!hint) return;
|
|
95
95
|
this.lastClientUpdate = hint;
|
|
96
96
|
const store = this.requestContext.getStore();
|
|
@@ -123,7 +123,7 @@ var HavenApiTransport = class {
|
|
|
123
123
|
// JOIN `x-haven-client` and `X-Haven-Client` into one unparseable
|
|
124
124
|
// value), so neither `defaultHeaders` nor a dispatch context can
|
|
125
125
|
// misname the client; `clientIdentity` is the one way to set it.
|
|
126
|
-
[
|
|
126
|
+
[chunkJ6DQEBK2_cjs.HAVEN_CLIENT_HEADER]: this.clientIdentity
|
|
127
127
|
},
|
|
128
128
|
body: body ? JSON.stringify(body) : void 0,
|
|
129
129
|
signal: controller.signal
|
|
@@ -136,15 +136,15 @@ var HavenApiTransport = class {
|
|
|
136
136
|
const rawDetails = record.details ?? record.detail;
|
|
137
137
|
const detailsText = typeof rawDetails === "string" ? rawDetails : rawDetails != null ? JSON.stringify(rawDetails) : void 0;
|
|
138
138
|
const message = errorText && detailsText ? `${errorText}: ${detailsText}` : errorText ?? detailsText ?? "API request failed";
|
|
139
|
-
throw new
|
|
139
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(message, res.status, data);
|
|
140
140
|
}
|
|
141
141
|
return data;
|
|
142
142
|
} catch (err) {
|
|
143
|
-
if (err instanceof
|
|
143
|
+
if (err instanceof chunk3SVPI4LS_cjs.HavenApiError) throw err;
|
|
144
144
|
if (err instanceof Error && err.name === "AbortError") {
|
|
145
|
-
throw new
|
|
145
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(`Request to ${path} timed out`, 408);
|
|
146
146
|
}
|
|
147
|
-
throw new
|
|
147
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
148
148
|
`Request to ${path} failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
149
149
|
0
|
|
150
150
|
);
|
|
@@ -161,7 +161,18 @@ function mapParties(raw) {
|
|
|
161
161
|
treasuryAccount: raw.treasury_account,
|
|
162
162
|
delegate: raw.delegate,
|
|
163
163
|
delegateAccount: raw.delegate_account,
|
|
164
|
-
merchant: raw.merchant
|
|
164
|
+
merchant: raw.merchant,
|
|
165
|
+
// #3332: additive — absent unless the wire shape carries it.
|
|
166
|
+
...raw.buyer ? {
|
|
167
|
+
buyer: {
|
|
168
|
+
legalName: raw.buyer.legal_name,
|
|
169
|
+
country: raw.buyer.country,
|
|
170
|
+
orgNumber: raw.buyer.org_number,
|
|
171
|
+
vatNumber: raw.buyer.vat_number,
|
|
172
|
+
viesStatus: raw.buyer.vies_status,
|
|
173
|
+
viesCheckedAt: raw.buyer.vies_checked_at
|
|
174
|
+
}
|
|
175
|
+
} : {}
|
|
165
176
|
};
|
|
166
177
|
}
|
|
167
178
|
function mapPaymentResult(raw, buildExplorerUrl2) {
|
|
@@ -205,6 +216,9 @@ function mapPaymentStatusResult(raw) {
|
|
|
205
216
|
expiresAt: raw.expires_at,
|
|
206
217
|
chainId: raw.chain_id,
|
|
207
218
|
message: raw.message,
|
|
219
|
+
// #3420: the delivered half of the settle vocabulary, additive — absent
|
|
220
|
+
// from the raw payload (older backend) stays absent here.
|
|
221
|
+
...raw.delivered === true ? { delivered: true } : {},
|
|
208
222
|
fee: raw.fee ? {
|
|
209
223
|
amount: raw.fee.amount,
|
|
210
224
|
token: raw.fee.token,
|
|
@@ -287,29 +301,29 @@ function paymentStateStatusCode(status, fallback = 502) {
|
|
|
287
301
|
return PAYMENT_STATE_STATUS_CODES[status] ?? fallback;
|
|
288
302
|
}
|
|
289
303
|
function phaseForStatus(status) {
|
|
290
|
-
if (status === "pending_signature") return
|
|
291
|
-
if (status === "submitted") return
|
|
292
|
-
if (status === "confirmed") return
|
|
293
|
-
if (status === "pending" || status === "pending_approval") return
|
|
294
|
-
if (status === "approved") return
|
|
295
|
-
if (status === "proposed") return
|
|
296
|
-
if (status === "executed") return
|
|
297
|
-
if (status === "rejected") return
|
|
298
|
-
if (status === "expired") return
|
|
299
|
-
if (status === "failed") return
|
|
304
|
+
if (status === "pending_signature") return chunk3SVPI4LS_cjs.AgentPaymentPhase.AgentSignatureRequired;
|
|
305
|
+
if (status === "submitted") return chunk3SVPI4LS_cjs.AgentPaymentPhase.PaymentSubmitted;
|
|
306
|
+
if (status === "confirmed") return chunk3SVPI4LS_cjs.AgentPaymentPhase.PaymentConfirmed;
|
|
307
|
+
if (status === "pending" || status === "pending_approval") return chunk3SVPI4LS_cjs.AgentPaymentPhase.UserApprovalRequired;
|
|
308
|
+
if (status === "approved") return chunk3SVPI4LS_cjs.AgentPaymentPhase.UserExecutionRequired;
|
|
309
|
+
if (status === "proposed") return chunk3SVPI4LS_cjs.AgentPaymentPhase.WaitingForAdditionalApprovals;
|
|
310
|
+
if (status === "executed") return chunk3SVPI4LS_cjs.AgentPaymentPhase.FundingSent;
|
|
311
|
+
if (status === "rejected") return chunk3SVPI4LS_cjs.AgentPaymentPhase.Rejected;
|
|
312
|
+
if (status === "expired") return chunk3SVPI4LS_cjs.AgentPaymentPhase.Expired;
|
|
313
|
+
if (status === "failed") return chunk3SVPI4LS_cjs.AgentPaymentPhase.Failed;
|
|
300
314
|
return null;
|
|
301
315
|
}
|
|
302
316
|
function nextActionForStatus(status) {
|
|
303
|
-
if (status === "pending_signature") return
|
|
304
|
-
if (status === "submitted") return
|
|
305
|
-
if (status === "confirmed") return
|
|
306
|
-
if (status === "pending" || status === "pending_approval") return
|
|
307
|
-
if (status === "approved") return
|
|
308
|
-
if (status === "proposed") return
|
|
309
|
-
if (status === "executed") return
|
|
310
|
-
if (status === "rejected") return
|
|
311
|
-
if (status === "expired") return
|
|
312
|
-
if (status === "failed") return
|
|
317
|
+
if (status === "pending_signature") return chunk3SVPI4LS_cjs.AgentPaymentNextAction.SignAndSubmitPayment;
|
|
318
|
+
if (status === "submitted") return chunk3SVPI4LS_cjs.AgentPaymentNextAction.CheckStatusLater;
|
|
319
|
+
if (status === "confirmed") return chunk3SVPI4LS_cjs.AgentPaymentNextAction.None;
|
|
320
|
+
if (status === "pending" || status === "pending_approval") return chunk3SVPI4LS_cjs.AgentPaymentNextAction.StopAndTellUser;
|
|
321
|
+
if (status === "approved") return chunk3SVPI4LS_cjs.AgentPaymentNextAction.StopAndTellUser;
|
|
322
|
+
if (status === "proposed") return chunk3SVPI4LS_cjs.AgentPaymentNextAction.StopAndTellUser;
|
|
323
|
+
if (status === "executed") return chunk3SVPI4LS_cjs.AgentPaymentNextAction.StopAndTellUser;
|
|
324
|
+
if (status === "rejected") return chunk3SVPI4LS_cjs.AgentPaymentNextAction.StopAndTellUser;
|
|
325
|
+
if (status === "expired") return chunk3SVPI4LS_cjs.AgentPaymentNextAction.RequestAgainIfUserStillWantsIt;
|
|
326
|
+
if (status === "failed") return chunk3SVPI4LS_cjs.AgentPaymentNextAction.StopAndTellUser;
|
|
313
327
|
return null;
|
|
314
328
|
}
|
|
315
329
|
function messageForState(label, status, paymentId, nextAction) {
|
|
@@ -383,17 +397,17 @@ function throwPaymentStateError(label, raw) {
|
|
|
383
397
|
const statusCode = paymentStateStatusCode(raw.status);
|
|
384
398
|
const state = paymentStateFromRaw(label, raw);
|
|
385
399
|
if (state) {
|
|
386
|
-
throw new
|
|
400
|
+
throw new chunk3SVPI4LS_cjs.HavenPaymentStateError(state.message, statusCode, state, raw);
|
|
387
401
|
}
|
|
388
402
|
if (raw.status === "pending_approval") {
|
|
389
|
-
throw new
|
|
403
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
390
404
|
`${label} exceeds the agent's on-chain budget and was declined; no approval is pending and none will arrive (payment_id: ${raw.payment_id}).`,
|
|
391
405
|
statusCode,
|
|
392
406
|
raw
|
|
393
407
|
);
|
|
394
408
|
}
|
|
395
409
|
if (raw.status === "expired") {
|
|
396
|
-
throw new
|
|
410
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
397
411
|
`${label} expired before it could be completed (payment_id: ${raw.payment_id}).`,
|
|
398
412
|
statusCode,
|
|
399
413
|
raw
|
|
@@ -401,7 +415,7 @@ function throwPaymentStateError(label, raw) {
|
|
|
401
415
|
}
|
|
402
416
|
const paymentId = raw.payment_id ? ` (payment_id: ${raw.payment_id})` : "";
|
|
403
417
|
const message = raw.error ?? `${label} ${raw.status}${paymentId}`;
|
|
404
|
-
throw new
|
|
418
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(message, statusCode, raw);
|
|
405
419
|
}
|
|
406
420
|
|
|
407
421
|
// src/x402-retry-target.ts
|
|
@@ -433,7 +447,7 @@ function isSecureX402RetryTarget(url) {
|
|
|
433
447
|
return RESERVED_SUFFIXES.some((suffix) => host.endsWith(suffix));
|
|
434
448
|
}
|
|
435
449
|
var INSECURE_RETRY_TARGET_CODE = "INSECURE_RETRY_TARGET";
|
|
436
|
-
var HavenInsecureRetryTargetError = class extends
|
|
450
|
+
var HavenInsecureRetryTargetError = class extends chunk3SVPI4LS_cjs.HavenError {
|
|
437
451
|
constructor(url) {
|
|
438
452
|
super(
|
|
439
453
|
`Refusing to send a payment header to ${url}: the paid x402 retry must go to an https URL (or a loopback / reserved test host). The merchant's challenge declared this resource URL; retry with the https URL you quoted (pass it as \`url\`), and report a merchant whose challenge downgrades the scheme.`,
|
|
@@ -475,7 +489,7 @@ var McpMerchantTransport = class {
|
|
|
475
489
|
return await this.fetchImpl(url, { ...init, signal });
|
|
476
490
|
} catch (err) {
|
|
477
491
|
if (timeoutSignal.aborted) {
|
|
478
|
-
throw new
|
|
492
|
+
throw new chunk3SVPI4LS_cjs.MerchantTimeoutError(`Merchant request timed out after ${timeoutMs}ms: ${url}`);
|
|
479
493
|
}
|
|
480
494
|
throw err;
|
|
481
495
|
}
|
|
@@ -612,8 +626,8 @@ var McpMerchantTransport = class {
|
|
|
612
626
|
async deliverPayment(url, init, paymentHeader) {
|
|
613
627
|
assertSecureX402RetryTarget(url);
|
|
614
628
|
const headers = new Headers(init?.headers);
|
|
615
|
-
const send =
|
|
616
|
-
for (const name of
|
|
629
|
+
const send = chunkJ6DQEBK2_cjs.x402PaymentHeaderNamesFor(paymentHeader);
|
|
630
|
+
for (const name of chunkJ6DQEBK2_cjs.X402_PAYMENT_HEADER_NAMES) {
|
|
617
631
|
if (send.includes(name)) headers.set(name, paymentHeader);
|
|
618
632
|
else headers.delete(name);
|
|
619
633
|
}
|
|
@@ -700,7 +714,7 @@ function mcpToolResultOf(value) {
|
|
|
700
714
|
function extractMcpPaymentRequired(toolResult) {
|
|
701
715
|
if (toolResult.isError !== true) return void 0;
|
|
702
716
|
if (isRecord(toolResult.structuredContent)) {
|
|
703
|
-
const parsed =
|
|
717
|
+
const parsed = chunkJ6DQEBK2_cjs.normalizePaymentRequired(toolResult.structuredContent);
|
|
704
718
|
if (parsed) return parsed;
|
|
705
719
|
}
|
|
706
720
|
if (Array.isArray(toolResult.content)) {
|
|
@@ -712,7 +726,7 @@ function extractMcpPaymentRequired(toolResult) {
|
|
|
712
726
|
} catch {
|
|
713
727
|
continue;
|
|
714
728
|
}
|
|
715
|
-
const parsed =
|
|
729
|
+
const parsed = chunkJ6DQEBK2_cjs.normalizePaymentRequired(candidate);
|
|
716
730
|
if (parsed) return parsed;
|
|
717
731
|
}
|
|
718
732
|
}
|
|
@@ -736,7 +750,7 @@ function withMcpPaymentMeta(init, paymentHeader) {
|
|
|
736
750
|
if (!request) return init;
|
|
737
751
|
let envelope;
|
|
738
752
|
try {
|
|
739
|
-
envelope =
|
|
753
|
+
envelope = chunkJ6DQEBK2_cjs.decodeBase64Json(paymentHeader);
|
|
740
754
|
} catch {
|
|
741
755
|
return init;
|
|
742
756
|
}
|
|
@@ -752,7 +766,7 @@ function withMcpPaymentMeta(init, paymentHeader) {
|
|
|
752
766
|
};
|
|
753
767
|
}
|
|
754
768
|
function encodeMcpSettlementReceipt(settlement) {
|
|
755
|
-
return
|
|
769
|
+
return chunkJ6DQEBK2_cjs.encodeBase64Json(settlement);
|
|
756
770
|
}
|
|
757
771
|
function parseJsonRpcToolsCall(body) {
|
|
758
772
|
if (typeof body !== "string") return void 0;
|
|
@@ -838,22 +852,93 @@ function selectJsonRpcResult(messages) {
|
|
|
838
852
|
return messages.find((message) => "result" in message || "error" in message) ?? messages.at(-1);
|
|
839
853
|
}
|
|
840
854
|
var RECEIPT_VERSION = "haven-receipt-1";
|
|
855
|
+
var DELEGATION_MANAGER_CHAIN_IDS = /* @__PURE__ */ new Set([8453, 84532]);
|
|
856
|
+
var EIP712_DOMAIN_TYPEHASH = viem.keccak256(
|
|
857
|
+
viem.toBytes("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
|
|
858
|
+
);
|
|
859
|
+
function delegationDomainSeparator(chainId) {
|
|
860
|
+
return viem.keccak256(
|
|
861
|
+
viem.encodeAbiParameters(
|
|
862
|
+
[{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint256" }, { type: "address" }],
|
|
863
|
+
[
|
|
864
|
+
EIP712_DOMAIN_TYPEHASH,
|
|
865
|
+
viem.keccak256(viem.toBytes("DelegationManager")),
|
|
866
|
+
viem.keccak256(viem.toBytes("1")),
|
|
867
|
+
BigInt(chainId),
|
|
868
|
+
chunk3SVPI4LS_cjs.DELEGATION_MANAGER
|
|
869
|
+
]
|
|
870
|
+
)
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
function delegationDigest(structHash, chainId) {
|
|
874
|
+
return viem.keccak256(viem.concatHex(["0x1901", delegationDomainSeparator(chainId), structHash]));
|
|
875
|
+
}
|
|
841
876
|
function defaultRecover(hash, signature) {
|
|
842
877
|
return ethers.ethers.recoverAddress(hash, signature);
|
|
843
878
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
if (!signature) return { verified: false, reason: "missing_signature" };
|
|
879
|
+
var NOT_A_SIGNED_RECEIPT = { verified: false, reason: "not_a_signed_receipt" };
|
|
880
|
+
function match(delegate, hash, signature, recover) {
|
|
847
881
|
let recovered;
|
|
848
882
|
try {
|
|
849
|
-
recovered = recover(
|
|
883
|
+
recovered = recover(hash, signature);
|
|
850
884
|
} catch {
|
|
851
|
-
return {
|
|
885
|
+
return { ok: false, reason: "bad_signature" };
|
|
852
886
|
}
|
|
853
887
|
if (recovered.toLowerCase() !== delegate.toLowerCase()) {
|
|
854
|
-
return {
|
|
888
|
+
return { ok: false, reason: "signer_mismatch", recoveredSigner: recovered };
|
|
889
|
+
}
|
|
890
|
+
return { ok: true, recoveredSigner: recovered };
|
|
891
|
+
}
|
|
892
|
+
function finish(result, verifiedOver) {
|
|
893
|
+
if (result.ok) {
|
|
894
|
+
return { verified: true, recoveredSigner: result.recoveredSigner, verifiedOver };
|
|
895
|
+
}
|
|
896
|
+
return result.recoveredSigner !== void 0 ? { verified: false, reason: result.reason, recoveredSigner: result.recoveredSigner } : { verified: false, reason: result.reason };
|
|
897
|
+
}
|
|
898
|
+
function verifyPaymentReceipt(receipt, recover = defaultRecover) {
|
|
899
|
+
if (typeof receipt !== "object" || receipt === null) return NOT_A_SIGNED_RECEIPT;
|
|
900
|
+
const source = receipt;
|
|
901
|
+
if (typeof source.authorization !== "object" || source.authorization === null) {
|
|
902
|
+
return NOT_A_SIGNED_RECEIPT;
|
|
903
|
+
}
|
|
904
|
+
const auth = source.authorization;
|
|
905
|
+
const { delegate, signHash: signHash2, signature, signatureScheme } = auth;
|
|
906
|
+
if (typeof delegate !== "string" || delegate === "" || typeof signHash2 !== "string" || signHash2 === "") {
|
|
907
|
+
return NOT_A_SIGNED_RECEIPT;
|
|
908
|
+
}
|
|
909
|
+
if (typeof signature !== "string" || signature === "") {
|
|
910
|
+
return { verified: false, reason: "missing_signature" };
|
|
911
|
+
}
|
|
912
|
+
const chainId = typeof source.onChain?.chainId === "number" ? source.onChain.chainId : void 0;
|
|
913
|
+
const digestVerifiable = chainId !== void 0 && DELEGATION_MANAGER_CHAIN_IDS.has(chainId);
|
|
914
|
+
if (signatureScheme === "eip712_userop") {
|
|
915
|
+
return { verified: false, reason: "not_verifiable_offline" };
|
|
916
|
+
}
|
|
917
|
+
if (signatureScheme === "eip712_delegation") {
|
|
918
|
+
if (!digestVerifiable) {
|
|
919
|
+
return { verified: false, reason: "not_verifiable_offline" };
|
|
920
|
+
}
|
|
921
|
+
let digest;
|
|
922
|
+
try {
|
|
923
|
+
digest = delegationDigest(signHash2, chainId);
|
|
924
|
+
} catch {
|
|
925
|
+
return { verified: false, reason: "bad_signature" };
|
|
926
|
+
}
|
|
927
|
+
return finish(match(delegate, digest, signature, recover), "delegation_digest");
|
|
855
928
|
}
|
|
856
|
-
|
|
929
|
+
const raw = match(delegate, signHash2, signature, recover);
|
|
930
|
+
if (raw.ok) return finish(raw, "sign_hash");
|
|
931
|
+
if (digestVerifiable) {
|
|
932
|
+
let digest;
|
|
933
|
+
try {
|
|
934
|
+
digest = delegationDigest(signHash2, chainId);
|
|
935
|
+
} catch {
|
|
936
|
+
return finish(raw, "sign_hash");
|
|
937
|
+
}
|
|
938
|
+
const delegated = match(delegate, digest, signature, recover);
|
|
939
|
+
if (delegated.ok) return finish(delegated, "delegation_digest");
|
|
940
|
+
}
|
|
941
|
+
return finish(raw, "sign_hash");
|
|
857
942
|
}
|
|
858
943
|
|
|
859
944
|
// src/account-reads.ts
|
|
@@ -876,9 +961,17 @@ function deriveReadiness(status, allowances) {
|
|
|
876
961
|
return allowances.some((allowance) => safeBigInt(allowance.remainingAtomic) > 0n) ? "ready" : "needs_approval";
|
|
877
962
|
}
|
|
878
963
|
function formatRemainingDisplay(tokenAddress, tokenSymbol, remainingAtomic) {
|
|
879
|
-
const token =
|
|
964
|
+
const token = chunkJ6DQEBK2_cjs.resolveTokenFromAddress(tokenAddress);
|
|
880
965
|
return token ? `${formatAtomicAmount(safeBigInt(remainingAtomic), token.decimals)} ${tokenSymbol}` : `${remainingAtomic} ${tokenSymbol} (atomic; unknown decimals)`;
|
|
881
966
|
}
|
|
967
|
+
function formatTokenAmount(atomic, decimals) {
|
|
968
|
+
const value = safeBigInt(atomic);
|
|
969
|
+
if (value < 0n) return "0";
|
|
970
|
+
const digits = value.toString().padStart(decimals + 1, "0");
|
|
971
|
+
const intPart = digits.slice(0, digits.length - decimals) || "0";
|
|
972
|
+
const fracPart = digits.slice(digits.length - decimals).replace(/0+$/, "");
|
|
973
|
+
return fracPart ? `${intPart}.${fracPart}` : intPart;
|
|
974
|
+
}
|
|
882
975
|
function mapTaskBudget(raw) {
|
|
883
976
|
return {
|
|
884
977
|
id: raw.id,
|
|
@@ -900,7 +993,7 @@ function mapTaskBudget(raw) {
|
|
|
900
993
|
};
|
|
901
994
|
}
|
|
902
995
|
function summarizeTaskBudget(taskBudget) {
|
|
903
|
-
const token =
|
|
996
|
+
const token = chunkJ6DQEBK2_cjs.resolveTokenFromAddress(taskBudget.tokenAddress);
|
|
904
997
|
const maxDisplay = token ? `${formatAtomicAmount(safeBigInt(taskBudget.maxAtomic), token.decimals)} ${token.symbol}` : `${taskBudget.maxAtomic} (atomic; unknown decimals)`;
|
|
905
998
|
return {
|
|
906
999
|
id: taskBudget.id,
|
|
@@ -912,6 +1005,13 @@ function summarizeTaskBudget(taskBudget) {
|
|
|
912
1005
|
expiresAt: taskBudget.expiresAt
|
|
913
1006
|
};
|
|
914
1007
|
}
|
|
1008
|
+
function compactReceipt(receipt) {
|
|
1009
|
+
const row = { ...receipt };
|
|
1010
|
+
delete row.challengePayload;
|
|
1011
|
+
delete row.selectedPayment;
|
|
1012
|
+
delete row.protocolReceiptPayload;
|
|
1013
|
+
return row;
|
|
1014
|
+
}
|
|
915
1015
|
var AccountReads = class {
|
|
916
1016
|
transport;
|
|
917
1017
|
getPaymentStatus;
|
|
@@ -1040,7 +1140,7 @@ var AccountReads = class {
|
|
|
1040
1140
|
payment: payment2,
|
|
1041
1141
|
allowance: null,
|
|
1042
1142
|
warnings: [{
|
|
1043
|
-
code:
|
|
1143
|
+
code: chunk3SVPI4LS_cjs.AgentPaymentWarningCode.AllowanceCheckUnavailable,
|
|
1044
1144
|
message: `Could not read the post-purchase allowance/budget for payment ${paymentId} (${detail}). The payment itself succeeded \u2014 the on-chain policy remains the actual spend gate; this only affects the remaining-budget figure reported here.`
|
|
1045
1145
|
}]
|
|
1046
1146
|
});
|
|
@@ -1062,22 +1162,22 @@ var AccountReads = class {
|
|
|
1062
1162
|
try {
|
|
1063
1163
|
const tokenAddress = payment.asset ?? payment.x402?.asset ?? null;
|
|
1064
1164
|
if (!tokenAddress) return unavailable("the settled payment does not carry a resolvable token address", payment);
|
|
1065
|
-
const
|
|
1165
|
+
const match2 = allowanceResult.value.allowances.find(
|
|
1066
1166
|
(allowance) => allowance.tokenAddress.toLowerCase() === tokenAddress.toLowerCase()
|
|
1067
1167
|
);
|
|
1068
|
-
if (!
|
|
1069
|
-
const token =
|
|
1070
|
-
const remainingDisplay = token ? `${formatAtomicAmount(safeBigInt(
|
|
1168
|
+
if (!match2) return unavailable("no allowance/budget row matches the settled token", payment);
|
|
1169
|
+
const token = chunkJ6DQEBK2_cjs.resolveTokenFromAddress(match2.tokenAddress);
|
|
1170
|
+
const remainingDisplay = token ? `${formatAtomicAmount(safeBigInt(match2.onchain.remaining), token.decimals)} ${match2.tokenSymbol}` : void 0;
|
|
1071
1171
|
const rail = agentResult.value.executionRail;
|
|
1072
1172
|
return {
|
|
1073
1173
|
payment,
|
|
1074
1174
|
allowance: {
|
|
1075
1175
|
rail,
|
|
1076
|
-
remaining_atomic:
|
|
1176
|
+
remaining_atomic: match2.onchain.remaining,
|
|
1077
1177
|
...remainingDisplay ? { remaining_display: remainingDisplay } : {},
|
|
1078
|
-
token_symbol:
|
|
1079
|
-
token_address:
|
|
1080
|
-
reset_period:
|
|
1178
|
+
token_symbol: match2.tokenSymbol,
|
|
1179
|
+
token_address: match2.tokenAddress,
|
|
1180
|
+
reset_period: match2.resetPeriodMin,
|
|
1081
1181
|
source: rail === "delegation" ? "active_delegations" : "allowance_module"
|
|
1082
1182
|
},
|
|
1083
1183
|
warnings: []
|
|
@@ -1097,8 +1197,13 @@ var AccountReads = class {
|
|
|
1097
1197
|
if (options.cursor) params.set("cursor", options.cursor);
|
|
1098
1198
|
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
1099
1199
|
const raw = await this.transport.get(`/machine-payments/receipts${query}`);
|
|
1200
|
+
const receipts = raw.receipts.map(mapPaymentReceipt);
|
|
1100
1201
|
return {
|
|
1101
|
-
|
|
1202
|
+
// #3423 (owner decision, opt-in): `compact` drops the three bulky
|
|
1203
|
+
// payload echoes (the merchant's full 402 challenge, the selected
|
|
1204
|
+
// option, and the merchant's PAYMENT-RESPONSE) from each row. The keys
|
|
1205
|
+
// are absent, not null, and the default shape is unchanged.
|
|
1206
|
+
receipts: options.compact ? receipts.map(compactReceipt) : receipts,
|
|
1102
1207
|
total: typeof raw.total === "number" ? raw.total : null,
|
|
1103
1208
|
hasMore: typeof raw.has_more === "boolean" ? raw.has_more : null,
|
|
1104
1209
|
nextCursor: typeof raw.next_cursor === "string" ? raw.next_cursor : null
|
|
@@ -1141,7 +1246,7 @@ function isWaitTimeout(err) {
|
|
|
1141
1246
|
async function waitForSweepTx(tx) {
|
|
1142
1247
|
let receipt;
|
|
1143
1248
|
try {
|
|
1144
|
-
receipt = await tx.wait(1,
|
|
1249
|
+
receipt = await tx.wait(1, chunk3SVPI4LS_cjs.DEFAULT_CONFIRMATION_TIMEOUT_MS);
|
|
1145
1250
|
} catch (err) {
|
|
1146
1251
|
if (!isWaitTimeout(err)) throw err;
|
|
1147
1252
|
return { txHash: tx.hash, confirmation: "unconfirmed" };
|
|
@@ -1155,16 +1260,16 @@ var DelegateSweepApi = class {
|
|
|
1155
1260
|
}
|
|
1156
1261
|
options;
|
|
1157
1262
|
async sweepDelegate() {
|
|
1158
|
-
if (!this.options.delegateKey) throw new
|
|
1263
|
+
if (!this.options.delegateKey) throw new chunk3SVPI4LS_cjs.HavenSigningError("delegateKey is required for sweepDelegate.");
|
|
1159
1264
|
const agent = await this.options.getAgent();
|
|
1160
|
-
if (!agent.delegateAddress) throw new
|
|
1265
|
+
if (!agent.delegateAddress) throw new chunk3SVPI4LS_cjs.HavenApiError("Agent has no delegate address.", 422);
|
|
1161
1266
|
const rpcUrl = this.options.chainRpcs[agent.chainId];
|
|
1162
|
-
if (!rpcUrl) throw new
|
|
1267
|
+
if (!rpcUrl) throw new chunk3SVPI4LS_cjs.HavenApiError(`chainRpcs[${agent.chainId}] must be configured to sweep the delegate wallet.`, 422);
|
|
1163
1268
|
const provider = createJsonRpcProvider(rpcUrl);
|
|
1164
1269
|
const wallet = createWallet(this.options.delegateKey, provider);
|
|
1165
1270
|
const transfers = [];
|
|
1166
|
-
if (
|
|
1167
|
-
const contract = createErc20Contract(
|
|
1271
|
+
if (chunkJ6DQEBK2_cjs.isSweepableChain(agent.chainId)) {
|
|
1272
|
+
const contract = createErc20Contract(chunkJ6DQEBK2_cjs.sweepUsdcAddress(agent.chainId), ["function balanceOf(address) view returns (uint256)", "function transfer(address to, uint256 amount) returns (bool)"], wallet);
|
|
1168
1273
|
const balance2 = await contract.balanceOf(agent.delegateAddress);
|
|
1169
1274
|
if (balance2 > 0n) {
|
|
1170
1275
|
const tx = await contract.transfer(agent.accountAddress, balance2);
|
|
@@ -1252,7 +1357,7 @@ function snapshotRequestBody(body) {
|
|
|
1252
1357
|
if (body == null) return void 0;
|
|
1253
1358
|
if (typeof body === "string") return body;
|
|
1254
1359
|
if (body instanceof URLSearchParams) return body.toString();
|
|
1255
|
-
throw new
|
|
1360
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1256
1361
|
"Quote helpers can only capture resumable request bodies that are strings or URLSearchParams. For streams, blobs, or binary bodies, preserve the original request yourself and call the matching resume method with fresh init.",
|
|
1257
1362
|
400
|
|
1258
1363
|
);
|
|
@@ -1273,25 +1378,25 @@ function requestInitFromSnapshot(request) {
|
|
|
1273
1378
|
};
|
|
1274
1379
|
}
|
|
1275
1380
|
function noCompatiblePaymentOptionError(accepts) {
|
|
1276
|
-
const erc7710Only =
|
|
1381
|
+
const erc7710Only = chunkJ6DQEBK2_cjs.selectErc7710PaymentOption(accepts) !== null;
|
|
1277
1382
|
const unsupportedOnly = !erc7710Only && accepts.some(
|
|
1278
|
-
(opt) => opt !== null && typeof opt === "object" && !
|
|
1383
|
+
(opt) => opt !== null && typeof opt === "object" && !chunkJ6DQEBK2_cjs.isErc7710Option(opt) && (chunkJ6DQEBK2_cjs.x402AssetTransferMethod(opt) !== null || opt.extra?.paymentFlow !== void 0)
|
|
1279
1384
|
);
|
|
1280
|
-
return new
|
|
1385
|
+
return new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1281
1386
|
"No compatible payment option found in x402 requirements. Haven supports standard x402 exact payments on Base USDC." + (erc7710Only ? " The only Haven-compatible option this merchant advertises is tagged extra.assetTransferMethod: 'erc7710' (direct settlement), which this EIP-3009 payment path cannot settle \u2014 the limitation is the settlement scheme, not the asset. Paying this merchant requires a delegation-rail erc7710 flow (settleX402Erc7710, or the hosted MCP purchase tools)." : unsupportedOnly ? " Every option this merchant advertises asks for a transfer method or payment flow Haven cannot construct (for example extra.assetTransferMethod: 'permit2', or an unrecognized extra.paymentFlow). No payment intent was created and no funds moved." : ""),
|
|
1282
1387
|
400
|
|
1283
1388
|
);
|
|
1284
1389
|
}
|
|
1285
1390
|
function buildX402Quote(paymentRequired, request, idempotencyKey, mcpTransport) {
|
|
1286
|
-
const standard =
|
|
1287
|
-
const option = standard ??
|
|
1391
|
+
const standard = chunkJ6DQEBK2_cjs.selectStandardPaymentOption(paymentRequired.accepts);
|
|
1392
|
+
const option = standard ?? chunkJ6DQEBK2_cjs.selectErc7710PaymentOption(paymentRequired.accepts);
|
|
1288
1393
|
if (!option) {
|
|
1289
1394
|
throw noCompatiblePaymentOptionError(paymentRequired.accepts);
|
|
1290
1395
|
}
|
|
1291
|
-
const token =
|
|
1396
|
+
const token = chunkJ6DQEBK2_cjs.resolveTokenFromAddress(option.asset, option.network);
|
|
1292
1397
|
return {
|
|
1293
1398
|
rail: "x402",
|
|
1294
|
-
idempotencyKey: idempotencyKey ??
|
|
1399
|
+
idempotencyKey: idempotencyKey ?? chunkJ6DQEBK2_cjs.buildX402IdempotencyKey(paymentRequired, option),
|
|
1295
1400
|
paymentRequired,
|
|
1296
1401
|
accepted: option,
|
|
1297
1402
|
acceptedScheme: standard ? "standard" : "erc7710",
|
|
@@ -1305,8 +1410,8 @@ function buildX402Quote(paymentRequired, request, idempotencyKey, mcpTransport)
|
|
|
1305
1410
|
resourceUrlDiffersFromRequest: paymentRequired.resource.url !== request.url,
|
|
1306
1411
|
description: paymentRequired.resource.description ?? option.description ?? null,
|
|
1307
1412
|
mimeType: paymentRequired.resource.mimeType ?? option.mimeType ?? null,
|
|
1308
|
-
amountAtomic:
|
|
1309
|
-
amount: decimalFromUsdcAtomic(
|
|
1413
|
+
amountAtomic: chunkJ6DQEBK2_cjs.x402AuthorizationAmount(option),
|
|
1414
|
+
amount: decimalFromUsdcAtomic(chunkJ6DQEBK2_cjs.x402AuthorizationAmount(option)),
|
|
1310
1415
|
token: token?.symbol ?? "USDC",
|
|
1311
1416
|
// #1351: null when the asset is unrecognised on this network — the
|
|
1312
1417
|
// `token` fallback above is a LABEL, not evidence of 6 decimals, and a
|
|
@@ -1345,7 +1450,7 @@ function buildX402Receipt(input) {
|
|
|
1345
1450
|
payTo: input.merchantTo ?? input.accepted.payTo
|
|
1346
1451
|
},
|
|
1347
1452
|
x402: {
|
|
1348
|
-
amount:
|
|
1453
|
+
amount: chunkJ6DQEBK2_cjs.x402AuthorizationAmount(input.accepted),
|
|
1349
1454
|
token: input.token,
|
|
1350
1455
|
network: input.accepted.network,
|
|
1351
1456
|
asset: input.accepted.asset,
|
|
@@ -1354,7 +1459,7 @@ function buildX402Receipt(input) {
|
|
|
1354
1459
|
};
|
|
1355
1460
|
}
|
|
1356
1461
|
function buildX402ResumeState(input) {
|
|
1357
|
-
const token =
|
|
1462
|
+
const token = chunkJ6DQEBK2_cjs.resolveTokenFromAddress(input.accepted.asset, input.accepted.network);
|
|
1358
1463
|
return {
|
|
1359
1464
|
rail: "x402",
|
|
1360
1465
|
paymentId: input.paymentId,
|
|
@@ -1365,8 +1470,8 @@ function buildX402ResumeState(input) {
|
|
|
1365
1470
|
request: input.request,
|
|
1366
1471
|
resourceUrl: input.paymentRequired.resource.url,
|
|
1367
1472
|
description: input.paymentRequired.resource.description ?? input.accepted.description ?? null,
|
|
1368
|
-
amountAtomic:
|
|
1369
|
-
amount: decimalFromUsdcAtomic(
|
|
1473
|
+
amountAtomic: chunkJ6DQEBK2_cjs.x402AuthorizationAmount(input.accepted),
|
|
1474
|
+
amount: decimalFromUsdcAtomic(chunkJ6DQEBK2_cjs.x402AuthorizationAmount(input.accepted)),
|
|
1370
1475
|
token: token?.symbol ?? "USDC",
|
|
1371
1476
|
asset: input.accepted.asset,
|
|
1372
1477
|
network: input.accepted.network,
|
|
@@ -1375,7 +1480,7 @@ function buildX402ResumeState(input) {
|
|
|
1375
1480
|
};
|
|
1376
1481
|
}
|
|
1377
1482
|
function attachX402ResumeState(err, paymentRequired, accepted, idempotencyKey, request) {
|
|
1378
|
-
if (!(err instanceof
|
|
1483
|
+
if (!(err instanceof chunk3SVPI4LS_cjs.HavenPaymentStateError)) return;
|
|
1379
1484
|
if (err.state.rail !== "x402") return;
|
|
1380
1485
|
err.resumeState = buildX402ResumeState({
|
|
1381
1486
|
paymentId: err.state.paymentId,
|
|
@@ -1396,17 +1501,17 @@ function attachResumeState(err, input) {
|
|
|
1396
1501
|
}
|
|
1397
1502
|
function assertCanResumeX402(status, paymentRequired, option) {
|
|
1398
1503
|
if (status.rail !== "x402") {
|
|
1399
|
-
throw new
|
|
1504
|
+
throw new chunk3SVPI4LS_cjs.HavenPaymentStateError(
|
|
1400
1505
|
`Payment ${status.paymentId} is ${status.rail}, not x402.`,
|
|
1401
1506
|
409,
|
|
1402
1507
|
status
|
|
1403
1508
|
);
|
|
1404
1509
|
}
|
|
1405
|
-
if (status.nextAction !==
|
|
1406
|
-
throw new
|
|
1510
|
+
if (status.nextAction !== chunk3SVPI4LS_cjs.AgentPaymentNextAction.RetryOriginalX402Request) {
|
|
1511
|
+
throw new chunk3SVPI4LS_cjs.HavenPaymentStateError(status.message, paymentStateStatusCode(status.status, 409), status);
|
|
1407
1512
|
}
|
|
1408
1513
|
if (!status.txHash) {
|
|
1409
|
-
throw new
|
|
1514
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1410
1515
|
`x402 payment ${status.paymentId} is ready to retry but has no Haven transaction hash.`,
|
|
1411
1516
|
502,
|
|
1412
1517
|
status,
|
|
@@ -1414,7 +1519,7 @@ function assertCanResumeX402(status, paymentRequired, option) {
|
|
|
1414
1519
|
);
|
|
1415
1520
|
}
|
|
1416
1521
|
if (status.resourceUrl && status.resourceUrl !== paymentRequired.resource.url) {
|
|
1417
|
-
throw new
|
|
1522
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1418
1523
|
"x402 resume request does not match the approved resource URL.",
|
|
1419
1524
|
409,
|
|
1420
1525
|
{ status, paymentRequired },
|
|
@@ -1422,7 +1527,7 @@ function assertCanResumeX402(status, paymentRequired, option) {
|
|
|
1422
1527
|
);
|
|
1423
1528
|
}
|
|
1424
1529
|
if (status.merchantAddress && !sameAddress(status.merchantAddress, option.payTo)) {
|
|
1425
|
-
throw new
|
|
1530
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1426
1531
|
"x402 resume request does not match the approved merchant.",
|
|
1427
1532
|
409,
|
|
1428
1533
|
{ status, selectedPayment: option },
|
|
@@ -1431,7 +1536,7 @@ function assertCanResumeX402(status, paymentRequired, option) {
|
|
|
1431
1536
|
}
|
|
1432
1537
|
const optionChainId = chainIdFromNetwork(option.network);
|
|
1433
1538
|
if (status.chainId && optionChainId && status.chainId !== optionChainId) {
|
|
1434
|
-
throw new
|
|
1539
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1435
1540
|
"x402 resume request does not match the approved network.",
|
|
1436
1541
|
409,
|
|
1437
1542
|
{ status, selectedPayment: option },
|
|
@@ -1439,7 +1544,7 @@ function assertCanResumeX402(status, paymentRequired, option) {
|
|
|
1439
1544
|
);
|
|
1440
1545
|
}
|
|
1441
1546
|
if (status.token && status.token !== "USDC") {
|
|
1442
|
-
throw new
|
|
1547
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1443
1548
|
"x402 resume request does not match the approved token.",
|
|
1444
1549
|
409,
|
|
1445
1550
|
{ status, selectedPayment: option },
|
|
@@ -1447,9 +1552,9 @@ function assertCanResumeX402(status, paymentRequired, option) {
|
|
|
1447
1552
|
);
|
|
1448
1553
|
}
|
|
1449
1554
|
const approvedAmount = status.amount ? normalizeDecimal(status.amount) : "";
|
|
1450
|
-
const requestedAmount = normalizeDecimal(decimalFromUsdcAtomic(
|
|
1555
|
+
const requestedAmount = normalizeDecimal(decimalFromUsdcAtomic(chunkJ6DQEBK2_cjs.x402AuthorizationAmount(option)));
|
|
1451
1556
|
if (approvedAmount && approvedAmount !== requestedAmount) {
|
|
1452
|
-
throw new
|
|
1557
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1453
1558
|
"x402 resume request does not match the approved amount.",
|
|
1454
1559
|
409,
|
|
1455
1560
|
{ status, selectedPayment: option },
|
|
@@ -1464,6 +1569,10 @@ function readX402ReceiptPayer(raw) {
|
|
|
1464
1569
|
}
|
|
1465
1570
|
|
|
1466
1571
|
// src/x402-funding-leg.ts
|
|
1572
|
+
function sameX402TaskBudget(a, b) {
|
|
1573
|
+
if (a === void 0 || b === void 0) return a === b;
|
|
1574
|
+
return a.toLowerCase() === b.toLowerCase();
|
|
1575
|
+
}
|
|
1467
1576
|
var X402FundingLeg = class {
|
|
1468
1577
|
delegateKey;
|
|
1469
1578
|
delegateAddress;
|
|
@@ -1489,25 +1598,40 @@ var X402FundingLeg = class {
|
|
|
1489
1598
|
this.assertSignableAuthorizationState = options.assertSignableAuthorizationState;
|
|
1490
1599
|
}
|
|
1491
1600
|
// ── Receipt cache ────────────────────────────────────────────────
|
|
1492
|
-
/**
|
|
1493
|
-
|
|
1601
|
+
/**
|
|
1602
|
+
* #3392: each cached receipt records the authorizing budget id(s) it was
|
|
1603
|
+
* created under (absent when none) — `taskBudgetId` since #3329, and since
|
|
1604
|
+
* #3330 `subBudgetId` (agent B's grant). A call naming a DIFFERENT
|
|
1605
|
+
* combination is refused here — before any network call — instead of
|
|
1606
|
+
* silently returning a receipt paid under another budget. Absent-vs-absent
|
|
1607
|
+
* and equal ids (case-insensitive) hit as before.
|
|
1608
|
+
*/
|
|
1609
|
+
cachedReceipt(idempotencyKey, taskBudgetId, subBudgetId) {
|
|
1494
1610
|
const cached = this.receiptCache.get(idempotencyKey);
|
|
1495
|
-
if (cached
|
|
1496
|
-
|
|
1611
|
+
if (!cached || cached.expiresAt <= Date.now()) return void 0;
|
|
1612
|
+
if (!sameX402TaskBudget(cached.taskBudgetId, taskBudgetId) || !sameX402TaskBudget(cached.subBudgetId, subBudgetId)) {
|
|
1613
|
+
throw new chunk3SVPI4LS_cjs.X402TaskBudgetMismatchError(
|
|
1614
|
+
`The x402 idempotency key '${idempotencyKey}' was already used under a different authorizing budget (task '${cached.taskBudgetId ?? "none"}' vs '${taskBudgetId ?? "none"}', sub '${cached.subBudgetId ?? "none"}' vs '${subBudgetId ?? "none"}'). Pass a new idempotencyKey to pay under this budget.`,
|
|
1615
|
+
idempotencyKey,
|
|
1616
|
+
cached.taskBudgetId,
|
|
1617
|
+
taskBudgetId
|
|
1618
|
+
);
|
|
1619
|
+
}
|
|
1620
|
+
return cached.receipt;
|
|
1497
1621
|
}
|
|
1498
|
-
cacheReceipt(idempotencyKey, paymentHeader, receipt) {
|
|
1622
|
+
cacheReceipt(idempotencyKey, paymentHeader, receipt, taskBudgetId, subBudgetId) {
|
|
1499
1623
|
const expiresAt = getPaymentHeaderValidBefore(paymentHeader);
|
|
1500
1624
|
if (expiresAt > Date.now()) {
|
|
1501
|
-
this.receiptCache.set(idempotencyKey, { expiresAt, receipt });
|
|
1625
|
+
this.receiptCache.set(idempotencyKey, { expiresAt, taskBudgetId, subBudgetId, receipt });
|
|
1502
1626
|
}
|
|
1503
1627
|
}
|
|
1504
1628
|
// ── Authorization ────────────────────────────────────────────────
|
|
1505
|
-
async authorize(paymentRequired, option, idempotencyKey, taskBudgetId) {
|
|
1629
|
+
async authorize(paymentRequired, option, idempotencyKey, taskBudgetId, subBudgetId) {
|
|
1506
1630
|
const raw = await this.post("/x402", {
|
|
1507
1631
|
url: paymentRequired.resource.url,
|
|
1508
1632
|
payTo: this.delegateAddress,
|
|
1509
1633
|
merchantPayTo: option.payTo,
|
|
1510
|
-
amount:
|
|
1634
|
+
amount: chunkJ6DQEBK2_cjs.x402AuthorizationAmount(option),
|
|
1511
1635
|
asset: option.asset,
|
|
1512
1636
|
network: option.network,
|
|
1513
1637
|
description: paymentRequired.resource.description,
|
|
@@ -1518,20 +1642,25 @@ var X402FundingLeg = class {
|
|
|
1518
1642
|
settlementScheme: "eip3009",
|
|
1519
1643
|
// #3329: `/x402` bodies are camelCase (`X402AuthorizeRequest`) — do not
|
|
1520
1644
|
// switch this to `task_budget_id`, which is only the `POST /payments` key.
|
|
1521
|
-
...taskBudgetId ? { taskBudgetId } : {}
|
|
1645
|
+
...taskBudgetId ? { taskBudgetId } : {},
|
|
1646
|
+
// #3330: same camelCase channel one level deeper — agent B pays through
|
|
1647
|
+
// the sub-budget agent A granted it (`[funding, B grant, A parent-child,
|
|
1648
|
+
// A budget]`). Mutually exclusive with `taskBudgetId` server-side; the
|
|
1649
|
+
// backend refuses a body naming both.
|
|
1650
|
+
...subBudgetId ? { subBudgetId } : {}
|
|
1522
1651
|
});
|
|
1523
1652
|
const state = paymentStateFromRaw("x402 payment", raw);
|
|
1524
|
-
const executedReplay = raw.success && raw.tx_hash ? "idempotency-collision" : state?.nextAction ===
|
|
1653
|
+
const executedReplay = raw.success && raw.tx_hash ? "idempotency-collision" : state?.nextAction === chunk3SVPI4LS_cjs.AgentPaymentNextAction.RetryOriginalX402Request ? "approval-resume" : null;
|
|
1525
1654
|
if (executedReplay) {
|
|
1526
1655
|
const canFund = await this.delegateCanFund(
|
|
1527
1656
|
raw.chain_id ?? state?.chainId ?? chainIdFromNetwork(option.network),
|
|
1528
1657
|
option.asset,
|
|
1529
|
-
|
|
1658
|
+
chunkJ6DQEBK2_cjs.x402AuthorizationAmount(option)
|
|
1530
1659
|
);
|
|
1531
1660
|
const refuse = executedReplay === "idempotency-collision" ? canFund !== true : canFund === false;
|
|
1532
1661
|
if (refuse) {
|
|
1533
1662
|
const settledReceipt = state && executedReplay === "approval-resume" ? this.receiptFromStatus(paymentRequired, option, void 0, state) : this.receiptFromAuthorization(paymentRequired, option, void 0, raw);
|
|
1534
|
-
throw new
|
|
1663
|
+
throw new chunk3SVPI4LS_cjs.X402AlreadySettledError(
|
|
1535
1664
|
canFund === false ? "This x402 payment already settled \u2014 the delegate no longer holds the funds to authorize it again. To buy the same item a second time, pass a distinct `idempotencyKey`; the synthesised key intentionally collapses repeat calls for the same product within a 5-minute window so a retried request cannot pay twice." : "This x402 payment already settled, and whether the delegate can still fund a new authorization could not be verified (no `chainRpcs` entry for this chain). Refusing rather than issue an authorization that may be unfundable. To buy the same item a second time, pass a distinct `idempotencyKey`; to finish an interrupted payment, resume it by `paymentId`.",
|
|
1536
1665
|
settledReceipt,
|
|
1537
1666
|
canFund === false ? "settled" : "unverifiable"
|
|
@@ -1541,21 +1670,21 @@ var X402FundingLeg = class {
|
|
|
1541
1670
|
const paymentHeader = await this.createPaymentHeader(paymentRequired, option);
|
|
1542
1671
|
if (raw.success && raw.tx_hash) {
|
|
1543
1672
|
const receipt2 = this.receiptFromAuthorization(paymentRequired, option, paymentHeader, raw);
|
|
1544
|
-
this.cacheReceipt(idempotencyKey, paymentHeader, receipt2);
|
|
1673
|
+
this.cacheReceipt(idempotencyKey, paymentHeader, receipt2, taskBudgetId, subBudgetId);
|
|
1545
1674
|
return receipt2;
|
|
1546
1675
|
}
|
|
1547
|
-
if (state?.nextAction ===
|
|
1676
|
+
if (state?.nextAction === chunk3SVPI4LS_cjs.AgentPaymentNextAction.RetryOriginalX402Request) {
|
|
1548
1677
|
const receipt2 = this.receiptFromStatus(paymentRequired, option, paymentHeader, state);
|
|
1549
|
-
this.cacheReceipt(idempotencyKey, paymentHeader, receipt2);
|
|
1678
|
+
this.cacheReceipt(idempotencyKey, paymentHeader, receipt2, taskBudgetId, subBudgetId);
|
|
1550
1679
|
return receipt2;
|
|
1551
1680
|
}
|
|
1552
1681
|
this.assertSignableAuthorizationState("x402 payment", raw);
|
|
1553
1682
|
if (!raw.sign_data?.hash) {
|
|
1554
|
-
throw new
|
|
1683
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError("No sign_hash returned from x402/authorize", 500, raw);
|
|
1555
1684
|
}
|
|
1556
1685
|
const sig = await this.signForData(raw.sign_data, {
|
|
1557
1686
|
asset: option.asset,
|
|
1558
|
-
amount:
|
|
1687
|
+
amount: chunkJ6DQEBK2_cjs.x402AuthorizationAmount(option)
|
|
1559
1688
|
});
|
|
1560
1689
|
const execResult = await this.post(
|
|
1561
1690
|
`/payments/${raw.payment_id}/sign`,
|
|
@@ -1569,31 +1698,31 @@ var X402FundingLeg = class {
|
|
|
1569
1698
|
execResult.chain_id ?? chainIdFromNetwork(option.network)
|
|
1570
1699
|
);
|
|
1571
1700
|
const receipt = this.receiptFromAuthorization(paymentRequired, option, paymentHeader, raw, execResult);
|
|
1572
|
-
this.cacheReceipt(idempotencyKey, paymentHeader, receipt);
|
|
1701
|
+
this.cacheReceipt(idempotencyKey, paymentHeader, receipt, taskBudgetId, subBudgetId);
|
|
1573
1702
|
return receipt;
|
|
1574
1703
|
}
|
|
1575
1704
|
// ── Header minting ───────────────────────────────────────────────
|
|
1576
1705
|
async createPaymentHeader(paymentRequired, option) {
|
|
1577
1706
|
if (!this.delegateKey) {
|
|
1578
|
-
throw new
|
|
1707
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError("delegateKey is required to sign x402 payment headers.");
|
|
1579
1708
|
}
|
|
1580
1709
|
const account = accounts.privateKeyToAccount(this.delegateKey);
|
|
1581
|
-
const requirements =
|
|
1710
|
+
const requirements = chunkJ6DQEBK2_cjs.toStandardPaymentRequirements(paymentRequired, option);
|
|
1582
1711
|
const header = await schemes.exact.evm.createPaymentHeader(
|
|
1583
1712
|
account,
|
|
1584
1713
|
paymentRequired.x402Version,
|
|
1585
1714
|
requirements
|
|
1586
1715
|
);
|
|
1587
1716
|
if (paymentRequired.x402Version < 2) return header;
|
|
1588
|
-
const payment =
|
|
1589
|
-
return
|
|
1717
|
+
const payment = chunkJ6DQEBK2_cjs.decodeBase64Json(header);
|
|
1718
|
+
return chunkJ6DQEBK2_cjs.encodeBase64Json(chunkJ6DQEBK2_cjs.x402V2PaymentEnvelope(paymentRequired, option, payment.payload));
|
|
1590
1719
|
}
|
|
1591
1720
|
// ── Receipt mapping ──────────────────────────────────────────────
|
|
1592
1721
|
receiptFromAuthorization(paymentRequired, option, paymentHeader, raw, execResult) {
|
|
1593
1722
|
const txHash = execResult?.tx_hash ?? raw.tx_hash ?? "";
|
|
1594
1723
|
const chainId = execResult?.chain_id ?? raw.chain_id ?? chainIdFromNetwork(option.network);
|
|
1595
1724
|
const token = execResult?.token ?? raw.token ?? "USDC";
|
|
1596
|
-
const amount = execResult?.amount ?? raw.amount ?? decimalFromUsdcAtomic(
|
|
1725
|
+
const amount = execResult?.amount ?? raw.amount ?? decimalFromUsdcAtomic(chunkJ6DQEBK2_cjs.x402AuthorizationAmount(option));
|
|
1597
1726
|
const to = execResult?.to ?? raw.to ?? this.delegateAddress ?? "";
|
|
1598
1727
|
const explorerUrl = execResult?.explorer_url ?? raw.explorer_url ?? explorerUrlOrEmpty(chainId, txHash);
|
|
1599
1728
|
const merchantTo = execResult?.merchant_to ?? raw.merchant_to ?? option.payTo;
|
|
@@ -1615,7 +1744,7 @@ var X402FundingLeg = class {
|
|
|
1615
1744
|
}
|
|
1616
1745
|
receiptFromStatus(paymentRequired, option, paymentHeader, status) {
|
|
1617
1746
|
if (!status.txHash) {
|
|
1618
|
-
throw new
|
|
1747
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1619
1748
|
`x402 payment ${status.paymentId} is ready to retry but has no Haven transaction hash.`,
|
|
1620
1749
|
502,
|
|
1621
1750
|
status,
|
|
@@ -1626,7 +1755,7 @@ var X402FundingLeg = class {
|
|
|
1626
1755
|
paymentId: status.paymentId,
|
|
1627
1756
|
txHash: status.txHash,
|
|
1628
1757
|
token: status.token || "USDC",
|
|
1629
|
-
amount: status.amount || decimalFromUsdcAtomic(
|
|
1758
|
+
amount: status.amount || decimalFromUsdcAtomic(chunkJ6DQEBK2_cjs.x402AuthorizationAmount(option)),
|
|
1630
1759
|
to: this.delegateAddress ?? "",
|
|
1631
1760
|
resourceUrl: paymentRequired.resource.url,
|
|
1632
1761
|
explorerUrl: explorerUrlOrEmpty(status.chainId, status.txHash),
|
|
@@ -1654,7 +1783,7 @@ var X402FundingLeg = class {
|
|
|
1654
1783
|
const provider = createJsonRpcProvider(rpcUrl);
|
|
1655
1784
|
const onChainReceipt = await provider.waitForTransaction(txHash, 1, timeoutMs);
|
|
1656
1785
|
if (!onChainReceipt || onChainReceipt.status !== 1) {
|
|
1657
|
-
throw new
|
|
1786
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1658
1787
|
"Funding tx did not confirm on-chain within the timeout window.",
|
|
1659
1788
|
500,
|
|
1660
1789
|
{ txHash, chainId }
|
|
@@ -1703,7 +1832,7 @@ var X402FundingLeg = class {
|
|
|
1703
1832
|
};
|
|
1704
1833
|
function getPaymentHeaderValidBefore(paymentHeader) {
|
|
1705
1834
|
try {
|
|
1706
|
-
const payment =
|
|
1835
|
+
const payment = chunkJ6DQEBK2_cjs.decodeBase64Json(
|
|
1707
1836
|
paymentHeader
|
|
1708
1837
|
);
|
|
1709
1838
|
const payload = payment.payload;
|
|
@@ -1758,7 +1887,7 @@ var X402Erc7710 = class {
|
|
|
1758
1887
|
*/
|
|
1759
1888
|
async settle(paymentRequired, options = {}) {
|
|
1760
1889
|
if (!this.delegateKey) {
|
|
1761
|
-
throw new
|
|
1890
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
1762
1891
|
"delegateKey is required for x402 payments. Pass it in the HavenClient config."
|
|
1763
1892
|
);
|
|
1764
1893
|
}
|
|
@@ -1783,21 +1912,21 @@ var X402Erc7710 = class {
|
|
|
1783
1912
|
async prepare(paymentRequired, options = {}) {
|
|
1784
1913
|
const delegationRail = options.delegationRail ?? (await this.getAgent()).executionRail === "delegation";
|
|
1785
1914
|
if (!delegationRail) {
|
|
1786
|
-
throw new
|
|
1915
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1787
1916
|
"erc7710 settlement requires a delegation-rail account; this one is not on it. Use authorizeX402() for the standard EIP-3009 path.",
|
|
1788
1917
|
400
|
|
1789
1918
|
);
|
|
1790
1919
|
}
|
|
1791
|
-
const selection =
|
|
1920
|
+
const selection = chunkJ6DQEBK2_cjs.selectX402SettlementScheme(paymentRequired.accepts, { delegationRail });
|
|
1792
1921
|
if (!selection || selection.scheme !== "erc7710") {
|
|
1793
|
-
throw new
|
|
1922
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1794
1923
|
"This merchant does not advertise an erc7710 settlement option (no accepts[] entry carries extra.assetTransferMethod: 'erc7710'). Use authorizeX402() for the standard EIP-3009 path.",
|
|
1795
1924
|
400
|
|
1796
1925
|
);
|
|
1797
1926
|
}
|
|
1798
1927
|
const option = selection.option;
|
|
1799
1928
|
const merchantPayTo = option.payTo;
|
|
1800
|
-
const amountAtomic =
|
|
1929
|
+
const amountAtomic = chunkJ6DQEBK2_cjs.x402AuthorizationAmount(option);
|
|
1801
1930
|
const raw = await this.post("/x402", {
|
|
1802
1931
|
url: options.resourceUrl ?? paymentRequired.resource?.url,
|
|
1803
1932
|
// #2373: the full 402 challenge, persisted verbatim by the backend
|
|
@@ -1835,14 +1964,30 @@ var X402Erc7710 = class {
|
|
|
1835
1964
|
...options.mcpCallContext ? { mcpCallContext: options.mcpCallContext } : {},
|
|
1836
1965
|
// #3329: `/x402` bodies are camelCase (`X402AuthorizeRequest`) — do not
|
|
1837
1966
|
// switch this to `task_budget_id`, which is only the `POST /payments` key.
|
|
1838
|
-
...options.taskBudgetId ? { taskBudgetId: options.taskBudgetId } : {}
|
|
1967
|
+
...options.taskBudgetId ? { taskBudgetId: options.taskBudgetId } : {},
|
|
1968
|
+
// #3330: same camelCase channel one level deeper; mutually exclusive
|
|
1969
|
+
// with `taskBudgetId` server-side.
|
|
1970
|
+
...options.subBudgetId ? { subBudgetId: options.subBudgetId } : {}
|
|
1839
1971
|
});
|
|
1840
1972
|
if (!raw.payment_id) {
|
|
1841
|
-
throw new
|
|
1973
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError("No payment_id returned from x402/authorize", 500, raw);
|
|
1974
|
+
}
|
|
1975
|
+
if (raw.status === "confirmed" && raw.tx_hash) {
|
|
1976
|
+
const requestedUrl = options.resourceUrl ?? paymentRequired.resource?.url;
|
|
1977
|
+
const samePurchase = typeof raw.to === "string" && raw.to.toLowerCase() === merchantPayTo.toLowerCase() && raw.resource_url === requestedUrl;
|
|
1978
|
+
if (!samePurchase) {
|
|
1979
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1980
|
+
`Idempotency key already belongs to confirmed payment ${raw.payment_id}, which is not this erc7710 purchase (different payee or resource). Nothing was signed and nothing was charged. Check that payment's status before buying again: a funded but undelivered EIP-3009 payment is recovered, not paid twice. Otherwise use a new idempotency key for this purchase.`,
|
|
1981
|
+
409,
|
|
1982
|
+
raw,
|
|
1983
|
+
raw.payment_id
|
|
1984
|
+
);
|
|
1985
|
+
}
|
|
1986
|
+
throw new chunk3SVPI4LS_cjs.X402Erc7710AlreadySettledError(raw.payment_id, raw.tx_hash, raw);
|
|
1842
1987
|
}
|
|
1843
1988
|
const signData = raw.sign_data;
|
|
1844
1989
|
if (signData?.signature_scheme !== "eip712_delegation" || !signData.typed_data) {
|
|
1845
|
-
throw new
|
|
1990
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1846
1991
|
`x402/authorize did not return an erc7710 settlement child (signature_scheme was ${JSON.stringify(signData?.signature_scheme)}). Refusing to sign a payload this path did not ask for.`,
|
|
1847
1992
|
500,
|
|
1848
1993
|
raw
|
|
@@ -1870,12 +2015,22 @@ var X402Erc7710 = class {
|
|
|
1870
2015
|
* hosted boundary) is irrelevant here.
|
|
1871
2016
|
*/
|
|
1872
2017
|
async submit(paymentId, signature) {
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
{ signature }
|
|
1876
|
-
)
|
|
2018
|
+
let settled;
|
|
2019
|
+
try {
|
|
2020
|
+
settled = await this.post(`/x402/${paymentId}/settle`, { signature });
|
|
2021
|
+
} catch (err) {
|
|
2022
|
+
const body = err instanceof chunk3SVPI4LS_cjs.HavenApiError ? err.body : void 0;
|
|
2023
|
+
if (err instanceof chunk3SVPI4LS_cjs.HavenApiError && err.statusCode === 409 && body?.code === "payment_already_settled" && typeof body.tx_hash === "string") {
|
|
2024
|
+
throw new chunk3SVPI4LS_cjs.X402Erc7710AlreadySettledError(
|
|
2025
|
+
typeof body.payment_id === "string" ? body.payment_id : paymentId,
|
|
2026
|
+
body.tx_hash,
|
|
2027
|
+
body
|
|
2028
|
+
);
|
|
2029
|
+
}
|
|
2030
|
+
throw err;
|
|
2031
|
+
}
|
|
1877
2032
|
if (!settled.payment_header) {
|
|
1878
|
-
throw new
|
|
2033
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
1879
2034
|
"x402 settle returned no payment_header \u2014 the merchant cannot be retried.",
|
|
1880
2035
|
500,
|
|
1881
2036
|
settled
|
|
@@ -1885,9 +2040,9 @@ var X402Erc7710 = class {
|
|
|
1885
2040
|
}
|
|
1886
2041
|
};
|
|
1887
2042
|
function settlementExpectationFromQuote(settlement) {
|
|
1888
|
-
const chainId =
|
|
2043
|
+
const chainId = chunk3SVPI4LS_cjs.chainIdForNetwork(settlement.network);
|
|
1889
2044
|
if (chainId === void 0) {
|
|
1890
|
-
throw new
|
|
2045
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
1891
2046
|
`Refusing to sign the x402 settlement child: the merchant's network ${JSON.stringify(settlement.network)} is not one this SDK can verify a settlement child on.`
|
|
1892
2047
|
);
|
|
1893
2048
|
}
|
|
@@ -1937,7 +2092,7 @@ function x402ToolReceipt(receipt) {
|
|
|
1937
2092
|
};
|
|
1938
2093
|
}
|
|
1939
2094
|
function toolError(err) {
|
|
1940
|
-
if (err instanceof
|
|
2095
|
+
if (err instanceof chunk3SVPI4LS_cjs.HavenPaymentStateError) {
|
|
1941
2096
|
return {
|
|
1942
2097
|
success: false,
|
|
1943
2098
|
payment_id: err.state.paymentId,
|
|
@@ -1982,7 +2137,7 @@ function toolError(err) {
|
|
|
1982
2137
|
error: err.message
|
|
1983
2138
|
};
|
|
1984
2139
|
}
|
|
1985
|
-
if (err instanceof
|
|
2140
|
+
if (err instanceof chunk3SVPI4LS_cjs.HavenApiError) {
|
|
1986
2141
|
return {
|
|
1987
2142
|
success: false,
|
|
1988
2143
|
status_code: err.statusCode,
|
|
@@ -2019,10 +2174,10 @@ var MerchantCompletion = class {
|
|
|
2019
2174
|
}
|
|
2020
2175
|
async retryRequest(url, initialInit, paymentRequired, receipt) {
|
|
2021
2176
|
if (!receipt.accepted) {
|
|
2022
|
-
throw new
|
|
2177
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError("No accepted x402 option was recorded for payment retry", 500);
|
|
2023
2178
|
}
|
|
2024
2179
|
if (!receipt.paymentHeader) {
|
|
2025
|
-
throw new
|
|
2180
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError("No x402 payment header was returned for payment retry", 500);
|
|
2026
2181
|
}
|
|
2027
2182
|
const retryResponse = await this.merchantTransport.deliverPaymentRecoveringSession(
|
|
2028
2183
|
url,
|
|
@@ -2047,7 +2202,7 @@ var MerchantCompletion = class {
|
|
|
2047
2202
|
delegate_to: receipt.to
|
|
2048
2203
|
}
|
|
2049
2204
|
});
|
|
2050
|
-
throw new
|
|
2205
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
2051
2206
|
"x402 retry failed after Haven funded the delegate wallet; reconciliation may be required.",
|
|
2052
2207
|
inBandRejection ? X402_RETRY_REJECTED_STATUS : merchant.merchant_status,
|
|
2053
2208
|
{
|
|
@@ -2080,7 +2235,7 @@ var MerchantCompletion = class {
|
|
|
2080
2235
|
merchantStatus: retryResponse.status,
|
|
2081
2236
|
challengePayload: paymentRequired,
|
|
2082
2237
|
selectedPayment: receipt.accepted,
|
|
2083
|
-
paymentProofHeaderName:
|
|
2238
|
+
paymentProofHeaderName: chunkJ6DQEBK2_cjs.x402PaymentHeaderNamesSent(receipt.paymentHeader),
|
|
2084
2239
|
paymentProofHeader: receipt.paymentHeader,
|
|
2085
2240
|
protocolReceiptHeaderName,
|
|
2086
2241
|
protocolReceiptHeader
|
|
@@ -2121,18 +2276,18 @@ var MerchantCompletion = class {
|
|
|
2121
2276
|
async resolveCompletionContext(input) {
|
|
2122
2277
|
const status = await this.getPaymentStatus(input.paymentId);
|
|
2123
2278
|
if (status.rail !== "x402") {
|
|
2124
|
-
throw new
|
|
2279
|
+
throw new chunk3SVPI4LS_cjs.HavenPaymentStateError(
|
|
2125
2280
|
`Payment ${status.paymentId} is ${status.rail}, not x402.`,
|
|
2126
2281
|
409,
|
|
2127
2282
|
status
|
|
2128
2283
|
);
|
|
2129
2284
|
}
|
|
2130
|
-
const readyForMerchantCompletion = input.noFundingLeg ? status.kind === "payment_intent" && status.status === "submitted" : status.nextAction ===
|
|
2285
|
+
const readyForMerchantCompletion = input.noFundingLeg ? status.kind === "payment_intent" && status.status === "submitted" : status.nextAction === chunk3SVPI4LS_cjs.AgentPaymentNextAction.RetryOriginalX402Request || status.kind === "payment_intent" && status.status === "confirmed" && status.phase === chunk3SVPI4LS_cjs.AgentPaymentPhase.PaymentConfirmed && status.nextAction === chunk3SVPI4LS_cjs.AgentPaymentNextAction.None;
|
|
2131
2286
|
if (!readyForMerchantCompletion) {
|
|
2132
|
-
throw new
|
|
2287
|
+
throw new chunk3SVPI4LS_cjs.HavenPaymentStateError(status.message, paymentStateStatusCode(status.status, 409), status);
|
|
2133
2288
|
}
|
|
2134
2289
|
if (!input.noFundingLeg && !status.txHash) {
|
|
2135
|
-
throw new
|
|
2290
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
2136
2291
|
`x402 payment ${status.paymentId} is ready for merchant completion but has no Haven transaction hash.`,
|
|
2137
2292
|
502,
|
|
2138
2293
|
status,
|
|
@@ -2141,7 +2296,7 @@ var MerchantCompletion = class {
|
|
|
2141
2296
|
}
|
|
2142
2297
|
const approvedResourceUrl = status.resourceUrl ?? status.x402?.resourceUrl ?? null;
|
|
2143
2298
|
if (approvedResourceUrl && approvedResourceUrl !== input.url) {
|
|
2144
|
-
throw new
|
|
2299
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
2145
2300
|
"x402 merchant completion does not match the approved resource URL.",
|
|
2146
2301
|
409,
|
|
2147
2302
|
{ status, url: input.url },
|
|
@@ -2227,7 +2382,7 @@ var MerchantCompletion = class {
|
|
|
2227
2382
|
*/
|
|
2228
2383
|
async reportMerchantOutcome(input) {
|
|
2229
2384
|
if (!Number.isInteger(input.merchantStatus) || input.merchantStatus < 100 || input.merchantStatus > 599) {
|
|
2230
|
-
throw new
|
|
2385
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
2231
2386
|
`merchant_status must be an integer HTTP status from 100 to 599 (received ${input.merchantStatus}).`,
|
|
2232
2387
|
400,
|
|
2233
2388
|
void 0,
|
|
@@ -2236,7 +2391,7 @@ var MerchantCompletion = class {
|
|
|
2236
2391
|
}
|
|
2237
2392
|
const looksAccepted = input.merchantStatus >= 200 && input.merchantStatus < 300;
|
|
2238
2393
|
if (looksAccepted !== (input.outcome === "accepted")) {
|
|
2239
|
-
throw new
|
|
2394
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
2240
2395
|
`outcome "${input.outcome}" contradicts merchant_status ${input.merchantStatus}: report "accepted" only for a 2xx and "rejected" only for a non-2xx.`,
|
|
2241
2396
|
400,
|
|
2242
2397
|
void 0,
|
|
@@ -2245,14 +2400,14 @@ var MerchantCompletion = class {
|
|
|
2245
2400
|
}
|
|
2246
2401
|
const status = await this.getPaymentStatus(input.paymentId);
|
|
2247
2402
|
if (status.rail !== "x402") {
|
|
2248
|
-
throw new
|
|
2403
|
+
throw new chunk3SVPI4LS_cjs.HavenPaymentStateError(
|
|
2249
2404
|
`Payment ${status.paymentId} is ${status.rail}, not x402 \u2014 there is no merchant retry to report.`,
|
|
2250
2405
|
409,
|
|
2251
2406
|
status
|
|
2252
2407
|
);
|
|
2253
2408
|
}
|
|
2254
2409
|
if (status.status !== "confirmed" || !status.txHash) {
|
|
2255
|
-
throw new
|
|
2410
|
+
throw new chunk3SVPI4LS_cjs.HavenPaymentStateError(
|
|
2256
2411
|
`Payment ${status.paymentId} has no confirmed Haven funding transaction to anchor a merchant report to (status ${status.status}). ${status.message}`,
|
|
2257
2412
|
paymentStateStatusCode(status.status, 409),
|
|
2258
2413
|
status
|
|
@@ -2260,7 +2415,7 @@ var MerchantCompletion = class {
|
|
|
2260
2415
|
}
|
|
2261
2416
|
const resourceUrl = status.resourceUrl ?? status.x402?.resourceUrl ?? null;
|
|
2262
2417
|
if (!resourceUrl) {
|
|
2263
|
-
throw new
|
|
2418
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
2264
2419
|
`Payment ${status.paymentId} has no recorded resource URL, so a merchant report cannot be stored.`,
|
|
2265
2420
|
409,
|
|
2266
2421
|
status,
|
|
@@ -2313,7 +2468,7 @@ var MerchantCompletion = class {
|
|
|
2313
2468
|
await this.post("/machine-payments/evidence", body);
|
|
2314
2469
|
return { outcome: "confirmed" };
|
|
2315
2470
|
} catch (err) {
|
|
2316
|
-
const statusCode = err instanceof
|
|
2471
|
+
const statusCode = err instanceof chunk3SVPI4LS_cjs.HavenApiError ? err.statusCode : void 0;
|
|
2317
2472
|
const retryable = statusCode === EVIDENCE_RETRYABLE_STATUS;
|
|
2318
2473
|
if (!retryable) {
|
|
2319
2474
|
return { outcome: "refused", statusCode: statusCode ?? 0 };
|
|
@@ -2350,7 +2505,7 @@ var MerchantCompletion = class {
|
|
|
2350
2505
|
*/
|
|
2351
2506
|
async reportSettlementEvidence(paymentId, settlementTxHash) {
|
|
2352
2507
|
if (isZeroSettlementTxHash(settlementTxHash)) {
|
|
2353
|
-
throw new
|
|
2508
|
+
throw new chunk3SVPI4LS_cjs.HavenZeroSettlementHashError(paymentId);
|
|
2354
2509
|
}
|
|
2355
2510
|
return this.reportEvidence({
|
|
2356
2511
|
paymentId,
|
|
@@ -2370,7 +2525,7 @@ function parseMerchantSettlement(header) {
|
|
|
2370
2525
|
}
|
|
2371
2526
|
function parseProtocolReceiptHeader(value) {
|
|
2372
2527
|
try {
|
|
2373
|
-
return
|
|
2528
|
+
return chunkJ6DQEBK2_cjs.decodeBase64Json(value);
|
|
2374
2529
|
} catch {
|
|
2375
2530
|
try {
|
|
2376
2531
|
return JSON.parse(value);
|
|
@@ -2387,7 +2542,7 @@ function x402TypedDataDigest(typedData) {
|
|
|
2387
2542
|
try {
|
|
2388
2543
|
return viem.hashTypedData(typedData);
|
|
2389
2544
|
} catch (err) {
|
|
2390
|
-
throw new
|
|
2545
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
2391
2546
|
`The x402 funding intent carried a sign_data.typed_data that is not a valid EIP-712 payload (needs domain, types, primaryType, message), so its digest cannot be derived and no signer could accept it. Underlying error: ${err instanceof Error ? err.message : String(err)}`
|
|
2392
2547
|
);
|
|
2393
2548
|
}
|
|
@@ -2436,6 +2591,15 @@ var HavenClient = class {
|
|
|
2436
2591
|
pollingInterval;
|
|
2437
2592
|
chainRpcs;
|
|
2438
2593
|
inFlightX402 = /* @__PURE__ */ new Map();
|
|
2594
|
+
/**
|
|
2595
|
+
* #3392: the task budget each in-flight x402 entry was created under
|
|
2596
|
+
* (`undefined` = none). A call joining an in-flight entry under a
|
|
2597
|
+
* different budget is refused before any network call — never silently
|
|
2598
|
+
* charged to another budget's payment.
|
|
2599
|
+
*/
|
|
2600
|
+
inFlightX402TaskBudget = /* @__PURE__ */ new Map();
|
|
2601
|
+
/** #3330: the sub-budget each in-flight entry was created under, same pin as `inFlightX402TaskBudget`. */
|
|
2602
|
+
inFlightX402SubBudget = /* @__PURE__ */ new Map();
|
|
2439
2603
|
/**
|
|
2440
2604
|
* The EIP-3009 funding-leg lifecycle (#1618). The facade holds a reference
|
|
2441
2605
|
* and delegates; it does not reimplement any of it.
|
|
@@ -2469,7 +2633,7 @@ var HavenClient = class {
|
|
|
2469
2633
|
});
|
|
2470
2634
|
this.x402Wallet = config.x402Wallet;
|
|
2471
2635
|
this.merchantTransport = new McpMerchantTransport({ merchantTimeout: config.merchantTimeout });
|
|
2472
|
-
this.confirmationTimeout = config.confirmationTimeout ??
|
|
2636
|
+
this.confirmationTimeout = config.confirmationTimeout ?? chunk3SVPI4LS_cjs.DEFAULT_CONFIRMATION_TIMEOUT_MS;
|
|
2473
2637
|
this.pollingInterval = config.pollingInterval ?? DEFAULT_POLLING_INTERVAL;
|
|
2474
2638
|
this.chainRpcs = config.chainRpcs ?? {};
|
|
2475
2639
|
if (this.delegateKey) {
|
|
@@ -2538,7 +2702,7 @@ var HavenClient = class {
|
|
|
2538
2702
|
*/
|
|
2539
2703
|
async pay(request) {
|
|
2540
2704
|
if (!this.delegateKey) {
|
|
2541
|
-
throw new
|
|
2705
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
2542
2706
|
"Cannot use pay() without a delegateKey. Use createIntent() + submitSignature() for manual signing."
|
|
2543
2707
|
);
|
|
2544
2708
|
}
|
|
@@ -2559,7 +2723,10 @@ var HavenClient = class {
|
|
|
2559
2723
|
amount: request.amount,
|
|
2560
2724
|
to: request.to,
|
|
2561
2725
|
...request.idempotencyKey ? { idempotency_key: request.idempotencyKey } : {},
|
|
2562
|
-
...request.taskBudgetId ? { task_budget_id: request.taskBudgetId } : {}
|
|
2726
|
+
...request.taskBudgetId ? { task_budget_id: request.taskBudgetId } : {},
|
|
2727
|
+
// #3330: `POST /payments` is snake_case — agent B pays through the
|
|
2728
|
+
// sub-budget A granted it; the backend refuses a body naming both ids.
|
|
2729
|
+
...request.subBudgetId ? { sub_budget_id: request.subBudgetId } : {}
|
|
2563
2730
|
});
|
|
2564
2731
|
if (raw.status === "pending_approval") {
|
|
2565
2732
|
throwPaymentStateError("Payment", raw);
|
|
@@ -2588,15 +2755,15 @@ var HavenClient = class {
|
|
|
2588
2755
|
* on-chain allowance — there is nothing to sign until the user approves.
|
|
2589
2756
|
*/
|
|
2590
2757
|
async createX402Intent(paymentRequired, options = {}) {
|
|
2591
|
-
const option =
|
|
2758
|
+
const option = chunkJ6DQEBK2_cjs.selectStandardPaymentOption(paymentRequired.accepts);
|
|
2592
2759
|
if (!option) {
|
|
2593
2760
|
throw noCompatiblePaymentOptionError(paymentRequired.accepts);
|
|
2594
2761
|
}
|
|
2595
2762
|
const fundingTo = options.delegateAddress ?? (await this.getAgent()).delegateAddress;
|
|
2596
2763
|
if (!fundingTo) {
|
|
2597
|
-
throw new
|
|
2764
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError("Authenticated agent has no delegate address registered.", 502);
|
|
2598
2765
|
}
|
|
2599
|
-
const idempotencyKey = options.idempotencyKey ??
|
|
2766
|
+
const idempotencyKey = options.idempotencyKey ?? chunkJ6DQEBK2_cjs.buildX402IdempotencyKey(paymentRequired, option);
|
|
2600
2767
|
const raw = await this.post("/x402", {
|
|
2601
2768
|
url: paymentRequired.resource.url,
|
|
2602
2769
|
payTo: fundingTo,
|
|
@@ -2607,7 +2774,7 @@ var HavenClient = class {
|
|
|
2607
2774
|
// of a silent reroute to the erc7710 settlement branch (the #1358
|
|
2608
2775
|
// review's open-budget misroute). Legacy-rail backends ignore the field.
|
|
2609
2776
|
settlementScheme: "eip3009",
|
|
2610
|
-
amount:
|
|
2777
|
+
amount: chunkJ6DQEBK2_cjs.x402AuthorizationAmount(option),
|
|
2611
2778
|
asset: option.asset,
|
|
2612
2779
|
network: option.network,
|
|
2613
2780
|
description: paymentRequired.resource.description,
|
|
@@ -2623,21 +2790,24 @@ var HavenClient = class {
|
|
|
2623
2790
|
// #3329: `/x402` bodies are camelCase (`X402AuthorizeRequest`), unlike
|
|
2624
2791
|
// `POST /payments`'s snake_case `task_budget_id` above — the two
|
|
2625
2792
|
// surfaces use different conventions, so this key is NOT `task_budget_id`.
|
|
2626
|
-
...options.taskBudgetId ? { taskBudgetId: options.taskBudgetId } : {}
|
|
2793
|
+
...options.taskBudgetId ? { taskBudgetId: options.taskBudgetId } : {},
|
|
2794
|
+
// #3330: same camelCase channel one level deeper (`X402AuthorizeRequest`);
|
|
2795
|
+
// mutually exclusive with `taskBudgetId` server-side.
|
|
2796
|
+
...options.subBudgetId ? { subBudgetId: options.subBudgetId } : {}
|
|
2627
2797
|
});
|
|
2628
2798
|
if (raw.status !== "pending_signature") {
|
|
2629
2799
|
throwPaymentStateError("x402 payment", raw);
|
|
2630
2800
|
}
|
|
2631
2801
|
if (!raw.sign_data?.hash) {
|
|
2632
|
-
throw new
|
|
2802
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError("No sign_hash returned from x402/authorize", 500, raw);
|
|
2633
2803
|
}
|
|
2634
2804
|
if (raw.sign_data.signature_scheme !== void 0 && !raw.sign_data.typed_data) {
|
|
2635
|
-
throw new
|
|
2805
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
2636
2806
|
`This account's x402 funding intent declares signature scheme '${raw.sign_data.signature_scheme}' but carried no typed_data to sign. Refusing to fall back to the bare hash \u2014 the account would reject that signature on-chain. This is a backend contract violation; report it rather than working around it.`
|
|
2637
2807
|
);
|
|
2638
2808
|
}
|
|
2639
2809
|
if (!raw.x402_expected_auth) {
|
|
2640
|
-
throw new
|
|
2810
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError("No x402 expected-context binding returned from x402/authorize", 500, raw);
|
|
2641
2811
|
}
|
|
2642
2812
|
return {
|
|
2643
2813
|
paymentId: raw.payment_id,
|
|
@@ -2648,7 +2818,7 @@ var HavenClient = class {
|
|
|
2648
2818
|
accepted: option,
|
|
2649
2819
|
resourceUrl: paymentRequired.resource.url,
|
|
2650
2820
|
merchantTo: raw.merchant_to ?? option.payTo,
|
|
2651
|
-
amountAtomic:
|
|
2821
|
+
amountAtomic: chunkJ6DQEBK2_cjs.x402AuthorizationAmount(option),
|
|
2652
2822
|
asset: option.asset,
|
|
2653
2823
|
network: option.network,
|
|
2654
2824
|
expectedAuth: raw.x402_expected_auth,
|
|
@@ -2673,13 +2843,13 @@ var HavenClient = class {
|
|
|
2673
2843
|
*/
|
|
2674
2844
|
sign(hash) {
|
|
2675
2845
|
if (!this.delegateKey) {
|
|
2676
|
-
throw new
|
|
2846
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
2677
2847
|
"Cannot sign without a delegateKey. Pass the private key in HavenClient config, or sign externally."
|
|
2678
2848
|
);
|
|
2679
2849
|
}
|
|
2680
2850
|
const signature = signHash(this.delegateKey, hash);
|
|
2681
2851
|
if (!verifySignature(hash, signature, this.delegateAddress)) {
|
|
2682
|
-
throw new
|
|
2852
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
2683
2853
|
"Local signature verification failed \u2014 recovered address does not match delegate key."
|
|
2684
2854
|
);
|
|
2685
2855
|
}
|
|
@@ -2697,29 +2867,29 @@ var HavenClient = class {
|
|
|
2697
2867
|
*/
|
|
2698
2868
|
async signForData(signData, settlementExpectation, fundingExpectation) {
|
|
2699
2869
|
if (!this.delegateKey) {
|
|
2700
|
-
throw new
|
|
2870
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
2701
2871
|
"Cannot sign without a delegateKey. Pass the private key in HavenClient config, or sign externally."
|
|
2702
2872
|
);
|
|
2703
2873
|
}
|
|
2704
2874
|
const scheme = signData.signature_scheme;
|
|
2705
2875
|
if (scheme === "eip191_userop") {
|
|
2706
|
-
throw new
|
|
2876
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
2707
2877
|
"The session rail is retired \u2014 'eip191_userop' intents can no longer be signed. Re-onboard the account on the delegation rail."
|
|
2708
2878
|
);
|
|
2709
2879
|
}
|
|
2710
2880
|
if (scheme === "eip712_userop") {
|
|
2711
2881
|
if (!signData.typed_data) {
|
|
2712
|
-
throw new
|
|
2882
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
2713
2883
|
"sign_data.signature_scheme is eip712_userop but typed_data is missing \u2014 refusing to sign the bare hash (the account would reject it)."
|
|
2714
2884
|
);
|
|
2715
2885
|
}
|
|
2716
|
-
|
|
2717
|
-
|
|
2886
|
+
chunk3SVPI4LS_cjs.assertUserOpTypedDataBinding(signData.typed_data, signData.hash);
|
|
2887
|
+
chunkJ6DQEBK2_cjs.assertBoundDirectPaymentUserOp(
|
|
2718
2888
|
signData.typed_data,
|
|
2719
2889
|
this.delegateAddress
|
|
2720
2890
|
);
|
|
2721
2891
|
if (fundingExpectation) {
|
|
2722
|
-
|
|
2892
|
+
chunkJ6DQEBK2_cjs.assertFundingLegPaysDelegate(signData.typed_data, {
|
|
2723
2893
|
delegateAddress: this.delegateAddress,
|
|
2724
2894
|
asset: fundingExpectation.asset,
|
|
2725
2895
|
amount: fundingExpectation.amount
|
|
@@ -2729,24 +2899,24 @@ var HavenClient = class {
|
|
|
2729
2899
|
}
|
|
2730
2900
|
if (scheme === "eip712_delegation") {
|
|
2731
2901
|
if (!signData.typed_data) {
|
|
2732
|
-
throw new
|
|
2902
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
2733
2903
|
"sign_data.signature_scheme is eip712_delegation but typed_data is missing \u2014 refusing to sign the bare hash (the settlement would be rejected on redemption)."
|
|
2734
2904
|
);
|
|
2735
2905
|
}
|
|
2736
2906
|
if (!settlementExpectation) {
|
|
2737
|
-
throw new
|
|
2907
|
+
throw new chunkJ6DQEBK2_cjs.HavenTypedDataRefusedError(
|
|
2738
2908
|
"Refusing to sign an x402 settlement child without an independent expectation of what it must pay (the merchant's 402). Pay erc7710 merchants through settleX402Erc7710(), which supplies it."
|
|
2739
2909
|
);
|
|
2740
2910
|
}
|
|
2741
|
-
|
|
2911
|
+
chunkJ6DQEBK2_cjs.assertOwnSettlementChild(signData.typed_data, settlementExpectation, this.delegateAddress);
|
|
2742
2912
|
return signSettlementDelegationTypedData(this.delegateKey, signData.typed_data);
|
|
2743
2913
|
}
|
|
2744
2914
|
if (scheme === void 0) {
|
|
2745
|
-
throw new
|
|
2915
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
2746
2916
|
"sign_data.signature_scheme is required \u2014 the legacy AllowanceModule rail that signed the bare hash is retired (#2850). Refusing to guess a signing scheme."
|
|
2747
2917
|
);
|
|
2748
2918
|
}
|
|
2749
|
-
throw new
|
|
2919
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
2750
2920
|
`Unknown sign_data.signature_scheme '${scheme}' \u2014 refusing to guess a signing scheme. Update @haven_ai/sdk.`
|
|
2751
2921
|
);
|
|
2752
2922
|
}
|
|
@@ -2930,7 +3100,7 @@ var HavenClient = class {
|
|
|
2930
3100
|
*/
|
|
2931
3101
|
async getPaymentStatusWithPostPurchaseAllowance(paymentId) {
|
|
2932
3102
|
const status = await this.getPaymentStatus(paymentId);
|
|
2933
|
-
if (status.rail ===
|
|
3103
|
+
if (status.rail === chunk3SVPI4LS_cjs.AgentPaymentRail.X402 && status.phase === chunk3SVPI4LS_cjs.AgentPaymentPhase.PaymentConfirmed) {
|
|
2934
3104
|
const { allowance, warnings } = await this.getPostPurchaseAllowanceSummary(paymentId);
|
|
2935
3105
|
return { ...status, allowance, ...warnings.length > 0 ? { warnings } : {} };
|
|
2936
3106
|
}
|
|
@@ -3003,7 +3173,12 @@ var HavenClient = class {
|
|
|
3003
3173
|
async listReceipts(options = {}) {
|
|
3004
3174
|
return this.accountReads.listReceipts(options);
|
|
3005
3175
|
}
|
|
3006
|
-
/**
|
|
3176
|
+
/**
|
|
3177
|
+
* One page of receipts with `total`, `hasMore` and `nextCursor` (#3128).
|
|
3178
|
+
* `compact: true` (#3423) drops each row's
|
|
3179
|
+
* `challengePayload`, `selectedPayment` and `protocolReceiptPayload`; the
|
|
3180
|
+
* default shape is unchanged.
|
|
3181
|
+
*/
|
|
3007
3182
|
async listReceiptsPage(options = {}) {
|
|
3008
3183
|
return this.accountReads.listReceiptsPage(options);
|
|
3009
3184
|
}
|
|
@@ -3128,7 +3303,7 @@ var HavenClient = class {
|
|
|
3128
3303
|
}
|
|
3129
3304
|
await sleep(this.pollingInterval);
|
|
3130
3305
|
}
|
|
3131
|
-
throw new
|
|
3306
|
+
throw new chunk3SVPI4LS_cjs.HavenTimeoutError(paymentId);
|
|
3132
3307
|
}
|
|
3133
3308
|
// ── x402 Protocol Support ────────────────────────────────────────
|
|
3134
3309
|
/**
|
|
@@ -3142,24 +3317,42 @@ var HavenClient = class {
|
|
|
3142
3317
|
*/
|
|
3143
3318
|
async authorizeX402(paymentRequired, options = {}) {
|
|
3144
3319
|
if (!this.delegateKey) {
|
|
3145
|
-
throw new
|
|
3320
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
3146
3321
|
"delegateKey is required for x402 payments. Pass it in the HavenClient config."
|
|
3147
3322
|
);
|
|
3148
3323
|
}
|
|
3149
3324
|
if (!this.delegateAddress) {
|
|
3150
|
-
throw new
|
|
3325
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError("delegateAddress could not be derived from delegateKey.");
|
|
3151
3326
|
}
|
|
3152
|
-
const option =
|
|
3327
|
+
const option = chunkJ6DQEBK2_cjs.selectStandardPaymentOption(paymentRequired.accepts);
|
|
3153
3328
|
if (!option) {
|
|
3154
3329
|
throw noCompatiblePaymentOptionError(paymentRequired.accepts);
|
|
3155
3330
|
}
|
|
3156
|
-
const idempotencyKey = options.idempotencyKey ??
|
|
3157
|
-
const cached = this.fundingLeg.cachedReceipt(idempotencyKey);
|
|
3331
|
+
const idempotencyKey = options.idempotencyKey ?? chunkJ6DQEBK2_cjs.buildX402IdempotencyKey(paymentRequired, option);
|
|
3332
|
+
const cached = this.fundingLeg.cachedReceipt(idempotencyKey, options.taskBudgetId, options.subBudgetId);
|
|
3158
3333
|
if (cached) return cached;
|
|
3159
3334
|
const inFlight = this.inFlightX402.get(idempotencyKey);
|
|
3160
|
-
if (inFlight)
|
|
3161
|
-
|
|
3335
|
+
if (inFlight) {
|
|
3336
|
+
if (!sameX402TaskBudget(this.inFlightX402TaskBudget.get(idempotencyKey), options.taskBudgetId) || !sameX402TaskBudget(this.inFlightX402SubBudget.get(idempotencyKey), options.subBudgetId)) {
|
|
3337
|
+
throw new chunk3SVPI4LS_cjs.X402TaskBudgetMismatchError(
|
|
3338
|
+
`The x402 idempotency key '${idempotencyKey}' has an in-flight payment created under a different authorizing budget (task '${this.inFlightX402TaskBudget.get(idempotencyKey) ?? "none"}' vs '${options.taskBudgetId ?? "none"}', sub '${this.inFlightX402SubBudget.get(idempotencyKey) ?? "none"}' vs '${options.subBudgetId ?? "none"}'). Pass a new idempotencyKey to pay under this budget.`,
|
|
3339
|
+
idempotencyKey,
|
|
3340
|
+
this.inFlightX402TaskBudget.get(idempotencyKey),
|
|
3341
|
+
options.taskBudgetId
|
|
3342
|
+
);
|
|
3343
|
+
}
|
|
3344
|
+
return inFlight;
|
|
3345
|
+
}
|
|
3346
|
+
const promise = this.fundingLeg.authorize(
|
|
3347
|
+
paymentRequired,
|
|
3348
|
+
option,
|
|
3349
|
+
idempotencyKey,
|
|
3350
|
+
options.taskBudgetId,
|
|
3351
|
+
options.subBudgetId
|
|
3352
|
+
);
|
|
3162
3353
|
this.inFlightX402.set(idempotencyKey, promise);
|
|
3354
|
+
this.inFlightX402TaskBudget.set(idempotencyKey, options.taskBudgetId);
|
|
3355
|
+
this.inFlightX402SubBudget.set(idempotencyKey, options.subBudgetId);
|
|
3163
3356
|
try {
|
|
3164
3357
|
return await promise;
|
|
3165
3358
|
} catch (err) {
|
|
@@ -3171,6 +3364,8 @@ var HavenClient = class {
|
|
|
3171
3364
|
throw err;
|
|
3172
3365
|
} finally {
|
|
3173
3366
|
this.inFlightX402.delete(idempotencyKey);
|
|
3367
|
+
this.inFlightX402TaskBudget.delete(idempotencyKey);
|
|
3368
|
+
this.inFlightX402SubBudget.delete(idempotencyKey);
|
|
3174
3369
|
}
|
|
3175
3370
|
}
|
|
3176
3371
|
/**
|
|
@@ -3193,16 +3388,16 @@ var HavenClient = class {
|
|
|
3193
3388
|
} catch {
|
|
3194
3389
|
body = void 0;
|
|
3195
3390
|
}
|
|
3196
|
-
throw new
|
|
3391
|
+
throw new chunk3SVPI4LS_cjs.X402UnexpectedStatusError(
|
|
3197
3392
|
`Expected an x402 quote response with HTTP 402, got HTTP ${response.status}.`,
|
|
3198
3393
|
response.status || 400,
|
|
3199
3394
|
body
|
|
3200
3395
|
);
|
|
3201
3396
|
}
|
|
3202
3397
|
if (response.headers.get("MACHINE-PAYMENT-CHALLENGE")) {
|
|
3203
|
-
throw new
|
|
3398
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError("quoteX402 only supports standard x402 Payment Required responses.", 400);
|
|
3204
3399
|
}
|
|
3205
|
-
const paymentRequired = await
|
|
3400
|
+
const paymentRequired = await chunkJ6DQEBK2_cjs.parsePaymentRequiredResponse(response);
|
|
3206
3401
|
const mcpTransport = await this.merchantTransport.detect(url, paymentRequired, response);
|
|
3207
3402
|
return buildX402Quote(paymentRequired, request, options.idempotencyKey, mcpTransport);
|
|
3208
3403
|
}
|
|
@@ -3220,7 +3415,7 @@ var HavenClient = class {
|
|
|
3220
3415
|
const wallet = await this.merchantCompletion.resolveWalletForMerchantCall();
|
|
3221
3416
|
const sessionId = await this.merchantTransport.initialize(url, init, wallet);
|
|
3222
3417
|
if (!sessionId) {
|
|
3223
|
-
throw new
|
|
3418
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError(
|
|
3224
3419
|
"The merchant did not establish an MCP session before the x402 quote. No payment was created.",
|
|
3225
3420
|
502,
|
|
3226
3421
|
{ mcpSessionNotEstablished: true }
|
|
@@ -3294,29 +3489,29 @@ var HavenClient = class {
|
|
|
3294
3489
|
}
|
|
3295
3490
|
async resumeAuthorizedX402(input) {
|
|
3296
3491
|
if (!this.delegateKey) {
|
|
3297
|
-
throw new
|
|
3492
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError(
|
|
3298
3493
|
"delegateKey is required for x402 payments. Pass it in the HavenClient config."
|
|
3299
3494
|
);
|
|
3300
3495
|
}
|
|
3301
3496
|
if (!this.delegateAddress) {
|
|
3302
|
-
throw new
|
|
3497
|
+
throw new chunk3SVPI4LS_cjs.HavenSigningError("delegateAddress could not be derived from delegateKey.");
|
|
3303
3498
|
}
|
|
3304
|
-
const option =
|
|
3499
|
+
const option = chunkJ6DQEBK2_cjs.selectStandardPaymentOption(input.paymentRequired.accepts);
|
|
3305
3500
|
if (!option) {
|
|
3306
3501
|
throw noCompatiblePaymentOptionError(input.paymentRequired.accepts);
|
|
3307
3502
|
}
|
|
3308
|
-
const idempotencyKey = input.idempotencyKey ??
|
|
3309
|
-
const cached = this.fundingLeg.cachedReceipt(idempotencyKey);
|
|
3503
|
+
const idempotencyKey = input.idempotencyKey ?? chunkJ6DQEBK2_cjs.buildX402IdempotencyKey(input.paymentRequired, option);
|
|
3504
|
+
const cached = this.fundingLeg.cachedReceipt(idempotencyKey, input.taskBudgetId);
|
|
3310
3505
|
if (cached) return cached;
|
|
3311
3506
|
const status = await this.getPaymentStatus(input.paymentId);
|
|
3312
3507
|
assertCanResumeX402(status, input.paymentRequired, option);
|
|
3313
3508
|
const canFund = await this.fundingLeg.delegateCanFund(
|
|
3314
3509
|
status.chainId ?? chainIdFromNetwork(option.network),
|
|
3315
3510
|
option.asset,
|
|
3316
|
-
|
|
3511
|
+
chunkJ6DQEBK2_cjs.x402AuthorizationAmount(option)
|
|
3317
3512
|
);
|
|
3318
3513
|
if (canFund === false) {
|
|
3319
|
-
throw new
|
|
3514
|
+
throw new chunk3SVPI4LS_cjs.X402AlreadySettledError(
|
|
3320
3515
|
`x402 payment ${status.paymentId} has already settled \u2014 the delegate no longer holds the funds to authorize it again, so there is nothing left to resume.`,
|
|
3321
3516
|
this.fundingLeg.receiptFromStatus(input.paymentRequired, option, void 0, status),
|
|
3322
3517
|
"settled"
|
|
@@ -3324,7 +3519,7 @@ var HavenClient = class {
|
|
|
3324
3519
|
}
|
|
3325
3520
|
const paymentHeader = await this.fundingLeg.createPaymentHeader(input.paymentRequired, option);
|
|
3326
3521
|
const receipt = this.fundingLeg.receiptFromStatus(input.paymentRequired, option, paymentHeader, status);
|
|
3327
|
-
this.fundingLeg.cacheReceipt(idempotencyKey, paymentHeader, receipt);
|
|
3522
|
+
this.fundingLeg.cacheReceipt(idempotencyKey, paymentHeader, receipt, input.taskBudgetId);
|
|
3328
3523
|
return receipt;
|
|
3329
3524
|
}
|
|
3330
3525
|
async resumeX402Payment(input) {
|
|
@@ -3337,13 +3532,13 @@ var HavenClient = class {
|
|
|
3337
3532
|
const url = input.url ?? input.request?.url;
|
|
3338
3533
|
if (!paymentRequired) {
|
|
3339
3534
|
if (!url) {
|
|
3340
|
-
throw new
|
|
3535
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError("x402 resume requires the original URL or a captured request snapshot.", 400);
|
|
3341
3536
|
}
|
|
3342
3537
|
const response = await this.merchantTransport.fetch(url, initialInit);
|
|
3343
3538
|
if (response.status !== 402) {
|
|
3344
|
-
throw new
|
|
3539
|
+
throw new chunk3SVPI4LS_cjs.HavenApiError("Expected the original x402 request to return HTTP 402 before resuming.", 400);
|
|
3345
3540
|
}
|
|
3346
|
-
paymentRequired = await
|
|
3541
|
+
paymentRequired = await chunkJ6DQEBK2_cjs.parsePaymentRequiredResponse(response);
|
|
3347
3542
|
}
|
|
3348
3543
|
const receipt = await this.resumeAuthorizedX402({
|
|
3349
3544
|
paymentId: input.paymentId,
|
|
@@ -3396,7 +3591,7 @@ var HavenClient = class {
|
|
|
3396
3591
|
nativeChallenge = true;
|
|
3397
3592
|
} else {
|
|
3398
3593
|
try {
|
|
3399
|
-
paymentRequired = await
|
|
3594
|
+
paymentRequired = await chunkJ6DQEBK2_cjs.parsePaymentRequiredResponse(response);
|
|
3400
3595
|
} catch {
|
|
3401
3596
|
return response;
|
|
3402
3597
|
}
|
|
@@ -3406,8 +3601,8 @@ var HavenClient = class {
|
|
|
3406
3601
|
if (mcpSessionId) requestInit = this.merchantTransport.withSessionHeaders(requestInit, mcpSessionId);
|
|
3407
3602
|
}
|
|
3408
3603
|
const request = snapshotX402Request(url, requestInit);
|
|
3409
|
-
const option =
|
|
3410
|
-
const idempotencyKey = options.idempotencyKey ?? (option ?
|
|
3604
|
+
const option = chunkJ6DQEBK2_cjs.selectStandardPaymentOption(paymentRequired.accepts);
|
|
3605
|
+
const idempotencyKey = options.idempotencyKey ?? (option ? chunkJ6DQEBK2_cjs.buildX402IdempotencyKey(paymentRequired, option) : void 0);
|
|
3411
3606
|
let receipt;
|
|
3412
3607
|
try {
|
|
3413
3608
|
receipt = await this.authorizeX402(paymentRequired, options);
|
|
@@ -3534,7 +3729,7 @@ var HavenClient = class {
|
|
|
3534
3729
|
txHash: evidenceTxHash,
|
|
3535
3730
|
resourceUrl: evidenceContext.resourceUrl,
|
|
3536
3731
|
merchantStatus: surfaced.status,
|
|
3537
|
-
paymentProofHeaderName:
|
|
3732
|
+
paymentProofHeaderName: chunkJ6DQEBK2_cjs.x402PaymentHeaderNamesSent(input.paymentHeader),
|
|
3538
3733
|
paymentProofHeader: input.paymentHeader,
|
|
3539
3734
|
protocolReceiptHeaderName,
|
|
3540
3735
|
protocolReceiptHeader
|
|
@@ -3751,7 +3946,7 @@ var toolDescriptions = {
|
|
|
3751
3946
|
// deleted `/demo/mpp/*` route. Use the x402 fragments above instead.
|
|
3752
3947
|
getPaymentStatus: {
|
|
3753
3948
|
summary: "Fetch structured Haven payment status for agent recovery.",
|
|
3754
|
-
behavior: "State: phase, nextAction, rail, amount, merchant, resource, idempotency, message; parties: treasury/delegate/delegateAccount/merchant. awaiting_settlement_evidence: poll once, else unverified.",
|
|
3949
|
+
behavior: "State: phase, nextAction, rail, amount, merchant, resource, idempotency, message; delivered when the merchant answered; parties: treasury/delegate/delegateAccount/merchant. awaiting_settlement_evidence: poll once, else unverified. delivered_unverified: terminal, stop.",
|
|
3755
3950
|
nextActionGuidance: ""
|
|
3756
3951
|
},
|
|
3757
3952
|
getResumeState: {
|
|
@@ -3786,9 +3981,9 @@ var toolDescriptions = {
|
|
|
3786
3981
|
nextActionGuidance: ""
|
|
3787
3982
|
},
|
|
3788
3983
|
verifyReceipt: {
|
|
3789
|
-
summary: "Verify a payment receipt offline \u2014 confirm the agent
|
|
3790
|
-
selectionGuidance: "
|
|
3791
|
-
behavior: "
|
|
3984
|
+
summary: "Verify a signed payment receipt offline \u2014 confirm the agent delegate signed its authorisation.",
|
|
3985
|
+
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.",
|
|
3986
|
+
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.",
|
|
3792
3987
|
nextActionGuidance: ""
|
|
3793
3988
|
},
|
|
3794
3989
|
payMcpTool: {
|
|
@@ -4075,7 +4270,7 @@ Your user gives you a **budget on their own account** \u2014 not their wallet, a
|
|
|
4075
4270
|
|
|
4076
4271
|
Four of the six steps are your user's \u2014 each needs a human signature or a human decision. The rest is yours. If they already have a funded account, start at step 3.
|
|
4077
4272
|
|
|
4078
|
-
1. **HUMAN \u2014 create the account.** Name, email, password, then a passkey (Face ID / Touch ID) or a wallet. Never offer to enter any of it: you must not have their password, and the passkey is bound to their device. With a terminal,
|
|
4273
|
+
1. **HUMAN \u2014 create the account.** Name, email, password, then a passkey (Face ID / Touch ID) or a wallet. Never offer to enter any of it: you must not have their password, and the passkey is bound to their device. With a terminal, \`<packages.cli.one_liner> login --api <api-url>\` afterwards gets you a scoped session for steps 3-4 (that flag or \`HAVEN_API_URL\`, on the first command \u2014 the session then remembers the backend; **the CLI's built-in default is Haven's hosted production backend**, so on any other deployment an omitted flag connects you somewhere real and wrong rather than failing) \u2014 they approve a code in the browser, you never hold their password. That command is the manifest's \`packages.cli.one_liner\` (\`/.well-known/haven.json\`) \u2014 run it as given: \`packages.cli.channel\` serves the full spec. Do not hold the process open while you wait: under \`--json\`, pass \`--no-wait\` to get the link object back at once, then poll it with \`haven login --poll <device_code>\` \u2014 one round per invocation, exit 3 while it is still pending, 0 once approved. It can set up agents and read the account; it cannot sign, approve a budget, move funds, or rotate any agent's keys.
|
|
4079
4274
|
2. **HUMAN \u2014 fund it.** USDC only, no ETH: Haven sponsors the gas. \`/.well-known/haven.json\` names \`chains.default\` as the deployment's expected chain, but after login \`haven wallets funding\` prints the address, the amount and which chain in one place; confirm that chain before you message your user. Without a CLI session, the dashboard's funding card shows the address and amount and its Receive-funds screen names the chain; never assume one: a testnet deployment and production both call themselves Haven. Before you write that message, read the manifest: \`environment\` says whether this deployment is \`production\`, and each \`chains.supported\` entry says whether that chain is a \`testnet\`. Real money is at stake only on a non-testnet chain of a \`production\` deployment \u2014 tell your user which case theirs is.
|
|
4080
4275
|
3. **HUMAN \u2014 create the agent, set its budget**, and paste you the **setup prompt** it hands back. With a CLI session (step 1) you can do this step yourself: \`haven agents connect --name <n> --budget <amount> --token USDC --period <minutes>\` prints the same connector command and approval link; add \`--run\` to do step 4 too.
|
|
4081
4276
|
4. **YOU \u2014 run the connector command** in that prompt (below). It makes your signing key locally, registering only the public address.
|
|
@@ -4153,7 +4348,7 @@ Nothing here needs you to. Steps 1-3 are links: hand your user the full \`<host>
|
|
|
4153
4348
|
|
|
4154
4349
|
## If something breaks
|
|
4155
4350
|
|
|
4156
|
-
If a Haven result carries \`client_update\`, that client is out of date:
|
|
4351
|
+
If a Haven result carries \`client_update\`, that client is out of date: run its \`upgrade_command\` as given, then any repair line it prints, then retry. \`required: true\` means payments are refused until you do. What changed: [/releases](/releases).
|
|
4157
4352
|
|
|
4158
4353
|
## Vocabulary
|
|
4159
4354
|
|
|
@@ -4173,12 +4368,12 @@ Start by reading {{HAVEN_ORIGIN}}/for-agents.md \u2014 it is written for you and
|
|
|
4173
4368
|
|
|
4174
4369
|
Then:
|
|
4175
4370
|
|
|
4176
|
-
1. Run
|
|
4371
|
+
1. Run \`<packages.cli.one_liner> login\`. That command is the manifest's \`packages.cli.one_liner\` (\`/.well-known/haven.json\`) \u2014 run it as given: \`packages.cli.channel\` serves the full spec. It prints a link and a code and does not need my password \u2014 it must never ask for it. Give me the link straight away and wait for me to approve it in my browser.
|
|
4177
4372
|
2. Once I have approved, run \`haven agents connect --name <a name you choose> --budget <amount> --token USDC --period <minutes>\` with the budget I tell you. If I have not given you one, ask me before running it. Add \`--run\` to complete the connection in the same step.
|
|
4178
4373
|
3. ${AGENT_APPROVAL_RELAY_JSON_SENTENCE}
|
|
4179
4374
|
4. Once I have approved the budget, verify with the \`haven_get_agent\` tool: \`ready\` means you can pay, \`needs_approval\` means my approval has not landed yet.
|
|
4180
4375
|
|
|
4181
|
-
Two things only I can do: approving that budget with my passkey, and funding the account with USDC
|
|
4376
|
+
Two things only I can do: approving that budget with my passkey, and funding the account with USDC \u2014 no ETH, Haven sponsors the gas. Tell me if either is missing rather than working around it.
|
|
4182
4377
|
|
|
4183
4378
|
${AGENT_SECRET_HYGIENE_SENTENCE}`;
|
|
4184
4379
|
|
|
@@ -4322,28 +4517,43 @@ the budget in the Haven dashboard, or wait for the period reset.
|
|
|
4322
4517
|
4. Then FOLLOW THE RESPONSE'S GUIDANCE FIELDS: \`next_action\`, \`next_tool\`,
|
|
4323
4518
|
and \`next_arguments\` name the exact next call \u2014 act on those first; the
|
|
4324
4519
|
prose in this section is fallback and debugging detail. If the catalog
|
|
4325
|
-
|
|
4326
|
-
\`
|
|
4327
|
-
the
|
|
4520
|
+
row is a plain-HTTP x402 paywall (no MCP tool metadata), the response
|
|
4521
|
+
instead names \`mcp__haven__haven_quote_x402\` with the entry's resource
|
|
4522
|
+
URL as \`url\`. If an MCP row is degraded or has no tool name, the response
|
|
4523
|
+
instead names \`mcp__haven__haven_pay_mcp_tool\` (merchant URL, tool name,
|
|
4524
|
+
arguments) as the manual fallback.
|
|
4328
4525
|
|
|
4329
|
-
**Signing:**
|
|
4526
|
+
**Signing:** which signer tool to call depends on the settlement scheme the
|
|
4527
|
+
prepare/pay response already named as \`next_tool\` \u2014 follow that field, never
|
|
4528
|
+
hard-code a choice. **erc7710** (direct settlement \u2014 chosen per merchant when
|
|
4529
|
+
its 402 advertises \`assetTransferMethod: "erc7710"\` AND your account is on
|
|
4530
|
+
the delegation rail; never a blanket default): \`mcp__haven-signer__haven_sign\`
|
|
4531
|
+
with \`payment_id\` ONLY; the signer fetches the settlement child itself.
|
|
4532
|
+
**EIP-3009** (the bridge \u2014 used otherwise, whenever the merchant offers a
|
|
4533
|
+
standard entry): \`mcp__haven-signer__haven_sign_x402\` with \`payment_id\` ONLY \u2014
|
|
4330
4534
|
the local signer fetches the exact signing bytes AND \`payment_required\`
|
|
4331
|
-
itself, so never relay \`typed_data\` or the 402 blob yourself.
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4535
|
+
itself, so never relay \`typed_data\` or the 402 blob yourself. A merchant
|
|
4536
|
+
that advertises ONLY erc7710 against an account that is NOT on the
|
|
4537
|
+
delegation rail is refused outright \u2014 it does not fall back to EIP-3009. If
|
|
4538
|
+
the signer reports its fetched context carried no \`payment_required\` (older
|
|
4539
|
+
backend), re-call with \`payment_required\` added verbatim. Fallback for an
|
|
4540
|
+
older signer or backend: re-run the quote/prepare tool with the SAME
|
|
4541
|
+
\`idempotency_key\` plus \`include_signing_payload=true\`, then pass
|
|
4542
|
+
\`payload_hash\`, \`x402_expected\` (the nested \`x402.expected\` object), and
|
|
4337
4543
|
\`typed_data\`/\`typed_data_b64\` through unchanged.
|
|
4338
4544
|
|
|
4339
|
-
**Settle:** \`mcp__haven__haven_settle_mcp_tool\` with \`payment_id
|
|
4340
|
-
\`signature
|
|
4545
|
+
**Settle:** \`mcp__haven__haven_settle_mcp_tool\` with \`payment_id\` and
|
|
4546
|
+
\`signature\` always. On **erc7710**, pass no \`payment_header\` \u2014 Haven
|
|
4547
|
+
assembles it at settle, so there is nothing to build locally and no funding
|
|
4548
|
+
transaction to wait for. On **EIP-3009**, also pass \`payment_header\` (from
|
|
4549
|
+
\`haven_sign_x402\`) ONLY. Either way Haven rehydrates the merchant call
|
|
4341
4550
|
context (\`merchant_url\`, \`tool_name\`, \`arguments\`, \`mcp_transport\`)
|
|
4342
4551
|
server-side from \`payment_id\`. Pass those four fields explicitly only as a
|
|
4343
4552
|
version-skew fallback when Haven has no stored context for the id \u2014 both or
|
|
4344
|
-
none together, never just one.
|
|
4345
|
-
funding has not confirmed
|
|
4346
|
-
|
|
4553
|
+
none together, never just one. On **EIP-3009**, \`settled: false\` means
|
|
4554
|
+
funding has not confirmed; on **erc7710** it means the merchant delivered but
|
|
4555
|
+
settlement is not yet verified. Either way, follow the result's guidance
|
|
4556
|
+
fields and do not re-pay.
|
|
4347
4557
|
|
|
4348
4558
|
Step-by-step alternative (also key-safe; for an older signer or backend, or
|
|
4349
4559
|
when you already have a merchant URL and tool name instead of a
|
|
@@ -4535,455 +4745,475 @@ function sameUrl(a, b) {
|
|
|
4535
4745
|
|
|
4536
4746
|
Object.defineProperty(exports, "DEFAULT_NEXT_TOOL_BY_ACTION", {
|
|
4537
4747
|
enumerable: true,
|
|
4538
|
-
get: function () { return
|
|
4748
|
+
get: function () { return chunkJ6DQEBK2_cjs.DEFAULT_NEXT_TOOL_BY_ACTION; }
|
|
4539
4749
|
});
|
|
4540
4750
|
Object.defineProperty(exports, "ERC7710_ASSET_TRANSFER_METHOD", {
|
|
4541
4751
|
enumerable: true,
|
|
4542
|
-
get: function () { return
|
|
4752
|
+
get: function () { return chunkJ6DQEBK2_cjs.ERC7710_ASSET_TRANSFER_METHOD; }
|
|
4543
4753
|
});
|
|
4544
4754
|
Object.defineProperty(exports, "HAVEN_CLIENT_HEADER", {
|
|
4545
4755
|
enumerable: true,
|
|
4546
|
-
get: function () { return
|
|
4756
|
+
get: function () { return chunkJ6DQEBK2_cjs.HAVEN_CLIENT_HEADER; }
|
|
4547
4757
|
});
|
|
4548
4758
|
Object.defineProperty(exports, "HAVEN_MINIMUM_NODE_VERSION", {
|
|
4549
4759
|
enumerable: true,
|
|
4550
|
-
get: function () { return
|
|
4760
|
+
get: function () { return chunkJ6DQEBK2_cjs.HAVEN_MINIMUM_NODE_VERSION; }
|
|
4551
4761
|
});
|
|
4552
4762
|
Object.defineProperty(exports, "HavenTypedDataRefusedError", {
|
|
4553
4763
|
enumerable: true,
|
|
4554
|
-
get: function () { return
|
|
4764
|
+
get: function () { return chunkJ6DQEBK2_cjs.HavenTypedDataRefusedError; }
|
|
4555
4765
|
});
|
|
4556
4766
|
Object.defineProperty(exports, "MAX_TASK_BUDGET_TTL_SECONDS", {
|
|
4557
4767
|
enumerable: true,
|
|
4558
|
-
get: function () { return
|
|
4768
|
+
get: function () { return chunkJ6DQEBK2_cjs.MAX_TASK_BUDGET_TTL_SECONDS; }
|
|
4559
4769
|
});
|
|
4560
4770
|
Object.defineProperty(exports, "NEXT_TOOL_SERVER_NAMES", {
|
|
4561
4771
|
enumerable: true,
|
|
4562
|
-
get: function () { return
|
|
4772
|
+
get: function () { return chunkJ6DQEBK2_cjs.NEXT_TOOL_SERVER_NAMES; }
|
|
4563
4773
|
});
|
|
4564
4774
|
Object.defineProperty(exports, "NEXT_TOOL_SERVER_ROLES", {
|
|
4565
4775
|
enumerable: true,
|
|
4566
|
-
get: function () { return
|
|
4776
|
+
get: function () { return chunkJ6DQEBK2_cjs.NEXT_TOOL_SERVER_ROLES; }
|
|
4567
4777
|
});
|
|
4568
4778
|
Object.defineProperty(exports, "SDK_CLIENT_IDENTITY", {
|
|
4569
4779
|
enumerable: true,
|
|
4570
|
-
get: function () { return
|
|
4780
|
+
get: function () { return chunkJ6DQEBK2_cjs.SDK_CLIENT_IDENTITY; }
|
|
4571
4781
|
});
|
|
4572
4782
|
Object.defineProperty(exports, "SDK_VERSION", {
|
|
4573
4783
|
enumerable: true,
|
|
4574
|
-
get: function () { return
|
|
4784
|
+
get: function () { return chunkJ6DQEBK2_cjs.SDK_VERSION; }
|
|
4575
4785
|
});
|
|
4576
4786
|
Object.defineProperty(exports, "SWEEP_BASE_CHAIN_ID", {
|
|
4577
4787
|
enumerable: true,
|
|
4578
|
-
get: function () { return
|
|
4788
|
+
get: function () { return chunkJ6DQEBK2_cjs.SWEEP_BASE_CHAIN_ID; }
|
|
4579
4789
|
});
|
|
4580
4790
|
Object.defineProperty(exports, "SWEEP_BASE_SEPOLIA_CHAIN_ID", {
|
|
4581
4791
|
enumerable: true,
|
|
4582
|
-
get: function () { return
|
|
4792
|
+
get: function () { return chunkJ6DQEBK2_cjs.SWEEP_BASE_SEPOLIA_CHAIN_ID; }
|
|
4583
4793
|
});
|
|
4584
4794
|
Object.defineProperty(exports, "SWEEP_BASE_SEPOLIA_USDC_ADDRESS", {
|
|
4585
4795
|
enumerable: true,
|
|
4586
|
-
get: function () { return
|
|
4796
|
+
get: function () { return chunkJ6DQEBK2_cjs.SWEEP_BASE_SEPOLIA_USDC_ADDRESS; }
|
|
4587
4797
|
});
|
|
4588
4798
|
Object.defineProperty(exports, "SWEEP_BASE_USDC_ADDRESS", {
|
|
4589
4799
|
enumerable: true,
|
|
4590
|
-
get: function () { return
|
|
4800
|
+
get: function () { return chunkJ6DQEBK2_cjs.SWEEP_BASE_USDC_ADDRESS; }
|
|
4591
4801
|
});
|
|
4592
4802
|
Object.defineProperty(exports, "TRANSFER_WITH_AUTHORIZATION_TYPES", {
|
|
4593
4803
|
enumerable: true,
|
|
4594
|
-
get: function () { return
|
|
4804
|
+
get: function () { return chunkJ6DQEBK2_cjs.TRANSFER_WITH_AUTHORIZATION_TYPES; }
|
|
4595
4805
|
});
|
|
4596
4806
|
Object.defineProperty(exports, "TYPED_DATA_NOT_ALLOWED", {
|
|
4597
4807
|
enumerable: true,
|
|
4598
|
-
get: function () { return
|
|
4808
|
+
get: function () { return chunkJ6DQEBK2_cjs.TYPED_DATA_NOT_ALLOWED; }
|
|
4599
4809
|
});
|
|
4600
4810
|
Object.defineProperty(exports, "X402PaymentHeaderValidationError", {
|
|
4601
4811
|
enumerable: true,
|
|
4602
|
-
get: function () { return
|
|
4812
|
+
get: function () { return chunkJ6DQEBK2_cjs.X402PaymentHeaderValidationError; }
|
|
4603
4813
|
});
|
|
4604
4814
|
Object.defineProperty(exports, "X402_LEGACY_PAYMENT_HEADER_NAME", {
|
|
4605
4815
|
enumerable: true,
|
|
4606
|
-
get: function () { return
|
|
4816
|
+
get: function () { return chunkJ6DQEBK2_cjs.X402_LEGACY_PAYMENT_HEADER_NAME; }
|
|
4607
4817
|
});
|
|
4608
4818
|
Object.defineProperty(exports, "X402_MAX_AUTHORIZATION_WINDOW_SECONDS", {
|
|
4609
4819
|
enumerable: true,
|
|
4610
|
-
get: function () { return
|
|
4820
|
+
get: function () { return chunkJ6DQEBK2_cjs.X402_MAX_AUTHORIZATION_WINDOW_SECONDS; }
|
|
4611
4821
|
});
|
|
4612
4822
|
Object.defineProperty(exports, "X402_PAYMENT_HEADER_NAME", {
|
|
4613
4823
|
enumerable: true,
|
|
4614
|
-
get: function () { return
|
|
4824
|
+
get: function () { return chunkJ6DQEBK2_cjs.X402_PAYMENT_HEADER_NAME; }
|
|
4615
4825
|
});
|
|
4616
4826
|
Object.defineProperty(exports, "X402_PAYMENT_HEADER_NAMES_SENT", {
|
|
4617
4827
|
enumerable: true,
|
|
4618
|
-
get: function () { return
|
|
4828
|
+
get: function () { return chunkJ6DQEBK2_cjs.X402_PAYMENT_HEADER_NAMES_SENT; }
|
|
4619
4829
|
});
|
|
4620
4830
|
Object.defineProperty(exports, "X402_PAYMENT_REQUIRED_HEADER_NAME", {
|
|
4621
4831
|
enumerable: true,
|
|
4622
|
-
get: function () { return
|
|
4832
|
+
get: function () { return chunkJ6DQEBK2_cjs.X402_PAYMENT_REQUIRED_HEADER_NAME; }
|
|
4623
4833
|
});
|
|
4624
4834
|
Object.defineProperty(exports, "X402_PAYMENT_RESPONSE_HEADER_NAME", {
|
|
4625
4835
|
enumerable: true,
|
|
4626
|
-
get: function () { return
|
|
4836
|
+
get: function () { return chunkJ6DQEBK2_cjs.X402_PAYMENT_RESPONSE_HEADER_NAME; }
|
|
4627
4837
|
});
|
|
4628
4838
|
Object.defineProperty(exports, "X402_SETTLEMENT_FORWARD_MARGIN_SECONDS", {
|
|
4629
4839
|
enumerable: true,
|
|
4630
|
-
get: function () { return
|
|
4840
|
+
get: function () { return chunkJ6DQEBK2_cjs.X402_SETTLEMENT_FORWARD_MARGIN_SECONDS; }
|
|
4631
4841
|
});
|
|
4632
4842
|
Object.defineProperty(exports, "assertBoundDirectPaymentUserOp", {
|
|
4633
4843
|
enumerable: true,
|
|
4634
|
-
get: function () { return
|
|
4844
|
+
get: function () { return chunkJ6DQEBK2_cjs.assertBoundDirectPaymentUserOp; }
|
|
4635
4845
|
});
|
|
4636
4846
|
Object.defineProperty(exports, "assertOwnTaskBudgetCloseUserOp", {
|
|
4637
4847
|
enumerable: true,
|
|
4638
|
-
get: function () { return
|
|
4848
|
+
get: function () { return chunkJ6DQEBK2_cjs.assertOwnTaskBudgetCloseUserOp; }
|
|
4639
4849
|
});
|
|
4640
4850
|
Object.defineProperty(exports, "assertOwnTaskChild", {
|
|
4641
4851
|
enumerable: true,
|
|
4642
|
-
get: function () { return
|
|
4852
|
+
get: function () { return chunkJ6DQEBK2_cjs.assertOwnTaskChild; }
|
|
4643
4853
|
});
|
|
4644
4854
|
Object.defineProperty(exports, "buildSweepAuthorizationMessage", {
|
|
4645
4855
|
enumerable: true,
|
|
4646
|
-
get: function () { return
|
|
4856
|
+
get: function () { return chunkJ6DQEBK2_cjs.buildSweepAuthorizationMessage; }
|
|
4647
4857
|
});
|
|
4648
4858
|
Object.defineProperty(exports, "buildSweepTypedData", {
|
|
4649
4859
|
enumerable: true,
|
|
4650
|
-
get: function () { return
|
|
4860
|
+
get: function () { return chunkJ6DQEBK2_cjs.buildSweepTypedData; }
|
|
4651
4861
|
});
|
|
4652
4862
|
Object.defineProperty(exports, "buildX402ExpectedMessage", {
|
|
4653
4863
|
enumerable: true,
|
|
4654
|
-
get: function () { return
|
|
4864
|
+
get: function () { return chunkJ6DQEBK2_cjs.buildX402ExpectedMessage; }
|
|
4655
4865
|
});
|
|
4656
4866
|
Object.defineProperty(exports, "compareNodeVersions", {
|
|
4657
4867
|
enumerable: true,
|
|
4658
|
-
get: function () { return
|
|
4868
|
+
get: function () { return chunkJ6DQEBK2_cjs.compareNodeVersions; }
|
|
4659
4869
|
});
|
|
4660
4870
|
Object.defineProperty(exports, "createNextStepBuilder", {
|
|
4661
4871
|
enumerable: true,
|
|
4662
|
-
get: function () { return
|
|
4872
|
+
get: function () { return chunkJ6DQEBK2_cjs.createNextStepBuilder; }
|
|
4663
4873
|
});
|
|
4664
4874
|
Object.defineProperty(exports, "decodeBase64Json", {
|
|
4665
4875
|
enumerable: true,
|
|
4666
|
-
get: function () { return
|
|
4876
|
+
get: function () { return chunkJ6DQEBK2_cjs.decodeBase64Json; }
|
|
4667
4877
|
});
|
|
4668
4878
|
Object.defineProperty(exports, "decodeBase64Utf8", {
|
|
4669
4879
|
enumerable: true,
|
|
4670
|
-
get: function () { return
|
|
4880
|
+
get: function () { return chunkJ6DQEBK2_cjs.decodeBase64Utf8; }
|
|
4671
4881
|
});
|
|
4672
4882
|
Object.defineProperty(exports, "defaultNextToolFor", {
|
|
4673
4883
|
enumerable: true,
|
|
4674
|
-
get: function () { return
|
|
4884
|
+
get: function () { return chunkJ6DQEBK2_cjs.defaultNextToolFor; }
|
|
4675
4885
|
});
|
|
4676
4886
|
Object.defineProperty(exports, "encodeBase64Json", {
|
|
4677
4887
|
enumerable: true,
|
|
4678
|
-
get: function () { return
|
|
4888
|
+
get: function () { return chunkJ6DQEBK2_cjs.encodeBase64Json; }
|
|
4679
4889
|
});
|
|
4680
4890
|
Object.defineProperty(exports, "encodeBase64Utf8", {
|
|
4681
4891
|
enumerable: true,
|
|
4682
|
-
get: function () { return
|
|
4892
|
+
get: function () { return chunkJ6DQEBK2_cjs.encodeBase64Utf8; }
|
|
4683
4893
|
});
|
|
4684
4894
|
Object.defineProperty(exports, "encodePaymentProof", {
|
|
4685
4895
|
enumerable: true,
|
|
4686
|
-
get: function () { return
|
|
4896
|
+
get: function () { return chunkJ6DQEBK2_cjs.encodePaymentProof; }
|
|
4687
4897
|
});
|
|
4688
4898
|
Object.defineProperty(exports, "hashDelegation", {
|
|
4689
4899
|
enumerable: true,
|
|
4690
|
-
get: function () { return
|
|
4900
|
+
get: function () { return chunkJ6DQEBK2_cjs.hashDelegation; }
|
|
4691
4901
|
});
|
|
4692
4902
|
Object.defineProperty(exports, "havenClientIdentity", {
|
|
4693
4903
|
enumerable: true,
|
|
4694
|
-
get: function () { return
|
|
4904
|
+
get: function () { return chunkJ6DQEBK2_cjs.havenClientIdentity; }
|
|
4695
4905
|
});
|
|
4696
4906
|
Object.defineProperty(exports, "isErc7710Option", {
|
|
4697
4907
|
enumerable: true,
|
|
4698
|
-
get: function () { return
|
|
4908
|
+
get: function () { return chunkJ6DQEBK2_cjs.isErc7710Option; }
|
|
4699
4909
|
});
|
|
4700
4910
|
Object.defineProperty(exports, "isSupportedNodeVersion", {
|
|
4701
4911
|
enumerable: true,
|
|
4702
|
-
get: function () { return
|
|
4912
|
+
get: function () { return chunkJ6DQEBK2_cjs.isSupportedNodeVersion; }
|
|
4703
4913
|
});
|
|
4704
4914
|
Object.defineProperty(exports, "isSweepableChain", {
|
|
4705
4915
|
enumerable: true,
|
|
4706
|
-
get: function () { return
|
|
4916
|
+
get: function () { return chunkJ6DQEBK2_cjs.isSweepableChain; }
|
|
4707
4917
|
});
|
|
4708
4918
|
Object.defineProperty(exports, "isTaskChildTypedData", {
|
|
4709
4919
|
enumerable: true,
|
|
4710
|
-
get: function () { return
|
|
4920
|
+
get: function () { return chunkJ6DQEBK2_cjs.isTaskChildTypedData; }
|
|
4711
4921
|
});
|
|
4712
4922
|
Object.defineProperty(exports, "normalizePaymentRequired", {
|
|
4713
4923
|
enumerable: true,
|
|
4714
|
-
get: function () { return
|
|
4924
|
+
get: function () { return chunkJ6DQEBK2_cjs.normalizePaymentRequired; }
|
|
4715
4925
|
});
|
|
4716
4926
|
Object.defineProperty(exports, "parseNextTool", {
|
|
4717
4927
|
enumerable: true,
|
|
4718
|
-
get: function () { return
|
|
4928
|
+
get: function () { return chunkJ6DQEBK2_cjs.parseNextTool; }
|
|
4719
4929
|
});
|
|
4720
4930
|
Object.defineProperty(exports, "parsePaymentRequired", {
|
|
4721
4931
|
enumerable: true,
|
|
4722
|
-
get: function () { return
|
|
4932
|
+
get: function () { return chunkJ6DQEBK2_cjs.parsePaymentRequired; }
|
|
4723
4933
|
});
|
|
4724
4934
|
Object.defineProperty(exports, "parsePaymentRequiredResponse", {
|
|
4725
4935
|
enumerable: true,
|
|
4726
|
-
get: function () { return
|
|
4936
|
+
get: function () { return chunkJ6DQEBK2_cjs.parsePaymentRequiredResponse; }
|
|
4727
4937
|
});
|
|
4728
4938
|
Object.defineProperty(exports, "readClientUpdate", {
|
|
4729
4939
|
enumerable: true,
|
|
4730
|
-
get: function () { return
|
|
4940
|
+
get: function () { return chunkJ6DQEBK2_cjs.readClientUpdate; }
|
|
4731
4941
|
});
|
|
4732
4942
|
Object.defineProperty(exports, "renderNextTool", {
|
|
4733
4943
|
enumerable: true,
|
|
4734
|
-
get: function () { return
|
|
4944
|
+
get: function () { return chunkJ6DQEBK2_cjs.renderNextTool; }
|
|
4945
|
+
});
|
|
4946
|
+
Object.defineProperty(exports, "resolveTokenBySymbol", {
|
|
4947
|
+
enumerable: true,
|
|
4948
|
+
get: function () { return chunkJ6DQEBK2_cjs.resolveTokenBySymbol; }
|
|
4735
4949
|
});
|
|
4736
4950
|
Object.defineProperty(exports, "resolveTokenFromAddress", {
|
|
4737
4951
|
enumerable: true,
|
|
4738
|
-
get: function () { return
|
|
4952
|
+
get: function () { return chunkJ6DQEBK2_cjs.resolveTokenFromAddress; }
|
|
4739
4953
|
});
|
|
4740
4954
|
Object.defineProperty(exports, "selectErc7710PaymentOption", {
|
|
4741
4955
|
enumerable: true,
|
|
4742
|
-
get: function () { return
|
|
4956
|
+
get: function () { return chunkJ6DQEBK2_cjs.selectErc7710PaymentOption; }
|
|
4743
4957
|
});
|
|
4744
4958
|
Object.defineProperty(exports, "selectPaymentOption", {
|
|
4745
4959
|
enumerable: true,
|
|
4746
|
-
get: function () { return
|
|
4960
|
+
get: function () { return chunkJ6DQEBK2_cjs.selectPaymentOption; }
|
|
4747
4961
|
});
|
|
4748
4962
|
Object.defineProperty(exports, "selectStandardPaymentOption", {
|
|
4749
4963
|
enumerable: true,
|
|
4750
|
-
get: function () { return
|
|
4964
|
+
get: function () { return chunkJ6DQEBK2_cjs.selectStandardPaymentOption; }
|
|
4751
4965
|
});
|
|
4752
4966
|
Object.defineProperty(exports, "selectX402SettlementScheme", {
|
|
4753
4967
|
enumerable: true,
|
|
4754
|
-
get: function () { return
|
|
4968
|
+
get: function () { return chunkJ6DQEBK2_cjs.selectX402SettlementScheme; }
|
|
4755
4969
|
});
|
|
4756
4970
|
Object.defineProperty(exports, "sweepUsdcAddress", {
|
|
4757
4971
|
enumerable: true,
|
|
4758
|
-
get: function () { return
|
|
4972
|
+
get: function () { return chunkJ6DQEBK2_cjs.sweepUsdcAddress; }
|
|
4759
4973
|
});
|
|
4760
4974
|
Object.defineProperty(exports, "sweepUsdcDomain", {
|
|
4761
4975
|
enumerable: true,
|
|
4762
|
-
get: function () { return
|
|
4976
|
+
get: function () { return chunkJ6DQEBK2_cjs.sweepUsdcDomain; }
|
|
4763
4977
|
});
|
|
4764
4978
|
Object.defineProperty(exports, "toStandardPaymentRequirements", {
|
|
4765
4979
|
enumerable: true,
|
|
4766
|
-
get: function () { return
|
|
4980
|
+
get: function () { return chunkJ6DQEBK2_cjs.toStandardPaymentRequirements; }
|
|
4767
4981
|
});
|
|
4768
4982
|
Object.defineProperty(exports, "unsupportedNodeVersionMessage", {
|
|
4769
4983
|
enumerable: true,
|
|
4770
|
-
get: function () { return
|
|
4984
|
+
get: function () { return chunkJ6DQEBK2_cjs.unsupportedNodeVersionMessage; }
|
|
4771
4985
|
});
|
|
4772
4986
|
Object.defineProperty(exports, "validateStandardX402PaymentHeader", {
|
|
4773
4987
|
enumerable: true,
|
|
4774
|
-
get: function () { return
|
|
4988
|
+
get: function () { return chunkJ6DQEBK2_cjs.validateStandardX402PaymentHeader; }
|
|
4775
4989
|
});
|
|
4776
4990
|
Object.defineProperty(exports, "x402AssetTransferMethod", {
|
|
4777
4991
|
enumerable: true,
|
|
4778
|
-
get: function () { return
|
|
4992
|
+
get: function () { return chunkJ6DQEBK2_cjs.x402AssetTransferMethod; }
|
|
4779
4993
|
});
|
|
4780
4994
|
Object.defineProperty(exports, "x402AuthorizationAmount", {
|
|
4781
4995
|
enumerable: true,
|
|
4782
|
-
get: function () { return
|
|
4996
|
+
get: function () { return chunkJ6DQEBK2_cjs.x402AuthorizationAmount; }
|
|
4783
4997
|
});
|
|
4784
4998
|
Object.defineProperty(exports, "x402FacilitatorAddresses", {
|
|
4785
4999
|
enumerable: true,
|
|
4786
|
-
get: function () { return
|
|
5000
|
+
get: function () { return chunkJ6DQEBK2_cjs.x402FacilitatorAddresses; }
|
|
4787
5001
|
});
|
|
4788
5002
|
Object.defineProperty(exports, "x402V2PaymentEnvelope", {
|
|
4789
5003
|
enumerable: true,
|
|
4790
|
-
get: function () { return
|
|
5004
|
+
get: function () { return chunkJ6DQEBK2_cjs.x402V2PaymentEnvelope; }
|
|
4791
5005
|
});
|
|
4792
5006
|
Object.defineProperty(exports, "AGENT_PAYMENT_FAILURE_CODE_VALUES", {
|
|
4793
5007
|
enumerable: true,
|
|
4794
|
-
get: function () { return
|
|
5008
|
+
get: function () { return chunk3SVPI4LS_cjs.AGENT_PAYMENT_FAILURE_CODE_VALUES; }
|
|
4795
5009
|
});
|
|
4796
5010
|
Object.defineProperty(exports, "AGENT_PAYMENT_NEXT_ACTION_VALUES", {
|
|
4797
5011
|
enumerable: true,
|
|
4798
|
-
get: function () { return
|
|
5012
|
+
get: function () { return chunk3SVPI4LS_cjs.AGENT_PAYMENT_NEXT_ACTION_VALUES; }
|
|
4799
5013
|
});
|
|
4800
5014
|
Object.defineProperty(exports, "AGENT_PAYMENT_PHASE_VALUES", {
|
|
4801
5015
|
enumerable: true,
|
|
4802
|
-
get: function () { return
|
|
5016
|
+
get: function () { return chunk3SVPI4LS_cjs.AGENT_PAYMENT_PHASE_VALUES; }
|
|
4803
5017
|
});
|
|
4804
5018
|
Object.defineProperty(exports, "AGENT_PAYMENT_RAIL_VALUES", {
|
|
4805
5019
|
enumerable: true,
|
|
4806
|
-
get: function () { return
|
|
5020
|
+
get: function () { return chunk3SVPI4LS_cjs.AGENT_PAYMENT_RAIL_VALUES; }
|
|
4807
5021
|
});
|
|
4808
5022
|
Object.defineProperty(exports, "AgentPaymentFailureCode", {
|
|
4809
5023
|
enumerable: true,
|
|
4810
|
-
get: function () { return
|
|
5024
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentFailureCode; }
|
|
4811
5025
|
});
|
|
4812
5026
|
Object.defineProperty(exports, "AgentPaymentFailureCodeDescriptions", {
|
|
4813
5027
|
enumerable: true,
|
|
4814
|
-
get: function () { return
|
|
5028
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentFailureCodeDescriptions; }
|
|
4815
5029
|
});
|
|
4816
5030
|
Object.defineProperty(exports, "AgentPaymentFailureCodeSchema", {
|
|
4817
5031
|
enumerable: true,
|
|
4818
|
-
get: function () { return
|
|
5032
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentFailureCodeSchema; }
|
|
4819
5033
|
});
|
|
4820
5034
|
Object.defineProperty(exports, "AgentPaymentNextAction", {
|
|
4821
5035
|
enumerable: true,
|
|
4822
|
-
get: function () { return
|
|
5036
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentNextAction; }
|
|
4823
5037
|
});
|
|
4824
5038
|
Object.defineProperty(exports, "AgentPaymentNextActionDescriptions", {
|
|
4825
5039
|
enumerable: true,
|
|
4826
|
-
get: function () { return
|
|
5040
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentNextActionDescriptions; }
|
|
4827
5041
|
});
|
|
4828
5042
|
Object.defineProperty(exports, "AgentPaymentNextActionSchema", {
|
|
4829
5043
|
enumerable: true,
|
|
4830
|
-
get: function () { return
|
|
5044
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentNextActionSchema; }
|
|
4831
5045
|
});
|
|
4832
5046
|
Object.defineProperty(exports, "AgentPaymentPhase", {
|
|
4833
5047
|
enumerable: true,
|
|
4834
|
-
get: function () { return
|
|
5048
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentPhase; }
|
|
4835
5049
|
});
|
|
4836
5050
|
Object.defineProperty(exports, "AgentPaymentPhaseDescriptions", {
|
|
4837
5051
|
enumerable: true,
|
|
4838
|
-
get: function () { return
|
|
5052
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentPhaseDescriptions; }
|
|
4839
5053
|
});
|
|
4840
5054
|
Object.defineProperty(exports, "AgentPaymentPhaseSchema", {
|
|
4841
5055
|
enumerable: true,
|
|
4842
|
-
get: function () { return
|
|
5056
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentPhaseSchema; }
|
|
4843
5057
|
});
|
|
4844
5058
|
Object.defineProperty(exports, "AgentPaymentRail", {
|
|
4845
5059
|
enumerable: true,
|
|
4846
|
-
get: function () { return
|
|
5060
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentRail; }
|
|
4847
5061
|
});
|
|
4848
5062
|
Object.defineProperty(exports, "AgentPaymentRailDescriptions", {
|
|
4849
5063
|
enumerable: true,
|
|
4850
|
-
get: function () { return
|
|
5064
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentRailDescriptions; }
|
|
4851
5065
|
});
|
|
4852
5066
|
Object.defineProperty(exports, "AgentPaymentRailSchema", {
|
|
4853
5067
|
enumerable: true,
|
|
4854
|
-
get: function () { return
|
|
5068
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentRailSchema; }
|
|
4855
5069
|
});
|
|
4856
5070
|
Object.defineProperty(exports, "AgentPaymentWarningCode", {
|
|
4857
5071
|
enumerable: true,
|
|
4858
|
-
get: function () { return
|
|
5072
|
+
get: function () { return chunk3SVPI4LS_cjs.AgentPaymentWarningCode; }
|
|
4859
5073
|
});
|
|
4860
5074
|
Object.defineProperty(exports, "CONNECTOR_PACKAGE_NAME", {
|
|
4861
5075
|
enumerable: true,
|
|
4862
|
-
get: function () { return
|
|
5076
|
+
get: function () { return chunk3SVPI4LS_cjs.CONNECTOR_PACKAGE_NAME; }
|
|
4863
5077
|
});
|
|
4864
5078
|
Object.defineProperty(exports, "DEFAULT_CONFIRMATION_TIMEOUT_MS", {
|
|
4865
5079
|
enumerable: true,
|
|
4866
|
-
get: function () { return
|
|
5080
|
+
get: function () { return chunk3SVPI4LS_cjs.DEFAULT_CONFIRMATION_TIMEOUT_MS; }
|
|
4867
5081
|
});
|
|
4868
5082
|
Object.defineProperty(exports, "DIRECT_SIGN_CONTEXT_VERSION", {
|
|
4869
5083
|
enumerable: true,
|
|
4870
|
-
get: function () { return
|
|
5084
|
+
get: function () { return chunk3SVPI4LS_cjs.DIRECT_SIGN_CONTEXT_VERSION; }
|
|
4871
5085
|
});
|
|
4872
5086
|
Object.defineProperty(exports, "ENTRY_POINT_V07", {
|
|
4873
5087
|
enumerable: true,
|
|
4874
|
-
get: function () { return
|
|
5088
|
+
get: function () { return chunk3SVPI4LS_cjs.ENTRY_POINT_V07; }
|
|
4875
5089
|
});
|
|
4876
5090
|
Object.defineProperty(exports, "HAVEN_CONNECTOR_CHANNEL", {
|
|
4877
5091
|
enumerable: true,
|
|
4878
|
-
get: function () { return
|
|
5092
|
+
get: function () { return chunk3SVPI4LS_cjs.HAVEN_CONNECTOR_CHANNEL; }
|
|
4879
5093
|
});
|
|
4880
5094
|
Object.defineProperty(exports, "HYBRID_DELEGATOR_DOMAIN_NAME", {
|
|
4881
5095
|
enumerable: true,
|
|
4882
|
-
get: function () { return
|
|
5096
|
+
get: function () { return chunk3SVPI4LS_cjs.HYBRID_DELEGATOR_DOMAIN_NAME; }
|
|
4883
5097
|
});
|
|
4884
5098
|
Object.defineProperty(exports, "HYBRID_DELEGATOR_DOMAIN_VERSION", {
|
|
4885
5099
|
enumerable: true,
|
|
4886
|
-
get: function () { return
|
|
5100
|
+
get: function () { return chunk3SVPI4LS_cjs.HYBRID_DELEGATOR_DOMAIN_VERSION; }
|
|
4887
5101
|
});
|
|
4888
5102
|
Object.defineProperty(exports, "HavenApiError", {
|
|
4889
5103
|
enumerable: true,
|
|
4890
|
-
get: function () { return
|
|
5104
|
+
get: function () { return chunk3SVPI4LS_cjs.HavenApiError; }
|
|
4891
5105
|
});
|
|
4892
5106
|
Object.defineProperty(exports, "HavenError", {
|
|
4893
5107
|
enumerable: true,
|
|
4894
|
-
get: function () { return
|
|
5108
|
+
get: function () { return chunk3SVPI4LS_cjs.HavenError; }
|
|
4895
5109
|
});
|
|
4896
5110
|
Object.defineProperty(exports, "HavenPaymentStateError", {
|
|
4897
5111
|
enumerable: true,
|
|
4898
|
-
get: function () { return
|
|
5112
|
+
get: function () { return chunk3SVPI4LS_cjs.HavenPaymentStateError; }
|
|
4899
5113
|
});
|
|
4900
5114
|
Object.defineProperty(exports, "HavenSigningError", {
|
|
4901
5115
|
enumerable: true,
|
|
4902
|
-
get: function () { return
|
|
5116
|
+
get: function () { return chunk3SVPI4LS_cjs.HavenSigningError; }
|
|
4903
5117
|
});
|
|
4904
5118
|
Object.defineProperty(exports, "HavenTimeoutError", {
|
|
4905
5119
|
enumerable: true,
|
|
4906
|
-
get: function () { return
|
|
5120
|
+
get: function () { return chunk3SVPI4LS_cjs.HavenTimeoutError; }
|
|
4907
5121
|
});
|
|
4908
5122
|
Object.defineProperty(exports, "HavenUnsupportedSignerVersionError", {
|
|
4909
5123
|
enumerable: true,
|
|
4910
|
-
get: function () { return
|
|
5124
|
+
get: function () { return chunk3SVPI4LS_cjs.HavenUnsupportedSignerVersionError; }
|
|
4911
5125
|
});
|
|
4912
5126
|
Object.defineProperty(exports, "HavenUserOpBindingError", {
|
|
4913
5127
|
enumerable: true,
|
|
4914
|
-
get: function () { return
|
|
5128
|
+
get: function () { return chunk3SVPI4LS_cjs.HavenUserOpBindingError; }
|
|
4915
5129
|
});
|
|
4916
5130
|
Object.defineProperty(exports, "HavenZeroSettlementHashError", {
|
|
4917
5131
|
enumerable: true,
|
|
4918
|
-
get: function () { return
|
|
5132
|
+
get: function () { return chunk3SVPI4LS_cjs.HavenZeroSettlementHashError; }
|
|
4919
5133
|
});
|
|
4920
5134
|
Object.defineProperty(exports, "MerchantTimeoutError", {
|
|
4921
5135
|
enumerable: true,
|
|
4922
|
-
get: function () { return
|
|
5136
|
+
get: function () { return chunk3SVPI4LS_cjs.MerchantTimeoutError; }
|
|
4923
5137
|
});
|
|
4924
5138
|
Object.defineProperty(exports, "PACKED_USER_OPERATION_FIELDS", {
|
|
4925
5139
|
enumerable: true,
|
|
4926
|
-
get: function () { return
|
|
5140
|
+
get: function () { return chunk3SVPI4LS_cjs.PACKED_USER_OPERATION_FIELDS; }
|
|
4927
5141
|
});
|
|
4928
5142
|
Object.defineProperty(exports, "ROOT_AUTHORITY", {
|
|
4929
5143
|
enumerable: true,
|
|
4930
|
-
get: function () { return
|
|
5144
|
+
get: function () { return chunk3SVPI4LS_cjs.ROOT_AUTHORITY; }
|
|
4931
5145
|
});
|
|
4932
5146
|
Object.defineProperty(exports, "SIGNER_UPDATE_FALLBACK", {
|
|
4933
5147
|
enumerable: true,
|
|
4934
|
-
get: function () { return
|
|
5148
|
+
get: function () { return chunk3SVPI4LS_cjs.SIGNER_UPDATE_FALLBACK; }
|
|
4935
5149
|
});
|
|
4936
5150
|
Object.defineProperty(exports, "SignerRefusalCode", {
|
|
4937
5151
|
enumerable: true,
|
|
4938
|
-
get: function () { return
|
|
5152
|
+
get: function () { return chunk3SVPI4LS_cjs.SignerRefusalCode; }
|
|
5153
|
+
});
|
|
5154
|
+
Object.defineProperty(exports, "TASK_SIGN_CONTEXT_VERSION", {
|
|
5155
|
+
enumerable: true,
|
|
5156
|
+
get: function () { return chunk3SVPI4LS_cjs.TASK_SIGN_CONTEXT_VERSION; }
|
|
4939
5157
|
});
|
|
4940
5158
|
Object.defineProperty(exports, "X402AlreadySettledError", {
|
|
4941
5159
|
enumerable: true,
|
|
4942
|
-
get: function () { return
|
|
5160
|
+
get: function () { return chunk3SVPI4LS_cjs.X402AlreadySettledError; }
|
|
5161
|
+
});
|
|
5162
|
+
Object.defineProperty(exports, "X402Erc7710AlreadySettledError", {
|
|
5163
|
+
enumerable: true,
|
|
5164
|
+
get: function () { return chunk3SVPI4LS_cjs.X402Erc7710AlreadySettledError; }
|
|
5165
|
+
});
|
|
5166
|
+
Object.defineProperty(exports, "X402TaskBudgetMismatchError", {
|
|
5167
|
+
enumerable: true,
|
|
5168
|
+
get: function () { return chunk3SVPI4LS_cjs.X402TaskBudgetMismatchError; }
|
|
4943
5169
|
});
|
|
4944
5170
|
Object.defineProperty(exports, "X402UnexpectedStatusError", {
|
|
4945
5171
|
enumerable: true,
|
|
4946
|
-
get: function () { return
|
|
5172
|
+
get: function () { return chunk3SVPI4LS_cjs.X402UnexpectedStatusError; }
|
|
4947
5173
|
});
|
|
4948
5174
|
Object.defineProperty(exports, "assertUserOpTypedDataBinding", {
|
|
4949
5175
|
enumerable: true,
|
|
4950
|
-
get: function () { return
|
|
5176
|
+
get: function () { return chunk3SVPI4LS_cjs.assertUserOpTypedDataBinding; }
|
|
4951
5177
|
});
|
|
4952
5178
|
Object.defineProperty(exports, "connectorRerunCommand", {
|
|
4953
5179
|
enumerable: true,
|
|
4954
|
-
get: function () { return
|
|
5180
|
+
get: function () { return chunk3SVPI4LS_cjs.connectorRerunCommand; }
|
|
4955
5181
|
});
|
|
4956
5182
|
Object.defineProperty(exports, "connectorSpec", {
|
|
4957
5183
|
enumerable: true,
|
|
4958
|
-
get: function () { return
|
|
5184
|
+
get: function () { return chunk3SVPI4LS_cjs.connectorSpec; }
|
|
5185
|
+
});
|
|
5186
|
+
Object.defineProperty(exports, "connectorUpgradeCommand", {
|
|
5187
|
+
enumerable: true,
|
|
5188
|
+
get: function () { return chunk3SVPI4LS_cjs.connectorUpgradeCommand; }
|
|
4959
5189
|
});
|
|
4960
5190
|
Object.defineProperty(exports, "deriveDelegateAccountAddress", {
|
|
4961
5191
|
enumerable: true,
|
|
4962
|
-
get: function () { return
|
|
5192
|
+
get: function () { return chunk3SVPI4LS_cjs.deriveDelegateAccountAddress; }
|
|
4963
5193
|
});
|
|
4964
5194
|
Object.defineProperty(exports, "isConnectorChannel", {
|
|
4965
5195
|
enumerable: true,
|
|
4966
|
-
get: function () { return
|
|
5196
|
+
get: function () { return chunk3SVPI4LS_cjs.isConnectorChannel; }
|
|
4967
5197
|
});
|
|
4968
5198
|
Object.defineProperty(exports, "isPackedUserOperationTypedData", {
|
|
4969
5199
|
enumerable: true,
|
|
4970
|
-
get: function () { return
|
|
5200
|
+
get: function () { return chunk3SVPI4LS_cjs.isPackedUserOperationTypedData; }
|
|
4971
5201
|
});
|
|
4972
5202
|
Object.defineProperty(exports, "packedUserOperationHash", {
|
|
4973
5203
|
enumerable: true,
|
|
4974
|
-
get: function () { return
|
|
5204
|
+
get: function () { return chunk3SVPI4LS_cjs.packedUserOperationHash; }
|
|
4975
5205
|
});
|
|
4976
5206
|
Object.defineProperty(exports, "resolveConnectorChannel", {
|
|
4977
5207
|
enumerable: true,
|
|
4978
|
-
get: function () { return
|
|
5208
|
+
get: function () { return chunk3SVPI4LS_cjs.resolveConnectorChannel; }
|
|
4979
5209
|
});
|
|
4980
5210
|
Object.defineProperty(exports, "signerUpdateFallback", {
|
|
4981
5211
|
enumerable: true,
|
|
4982
|
-
get: function () { return
|
|
5212
|
+
get: function () { return chunk3SVPI4LS_cjs.signerUpdateFallback; }
|
|
4983
5213
|
});
|
|
4984
5214
|
Object.defineProperty(exports, "verifySettlementChild", {
|
|
4985
5215
|
enumerable: true,
|
|
4986
|
-
get: function () { return
|
|
5216
|
+
get: function () { return chunk3SVPI4LS_cjs.verifySettlementChild; }
|
|
4987
5217
|
});
|
|
4988
5218
|
exports.AGENT_APPROVAL_RELAY_JSON_SENTENCE = AGENT_APPROVAL_RELAY_JSON_SENTENCE;
|
|
4989
5219
|
exports.AGENT_APPROVAL_RELAY_PROSE_SENTENCE = AGENT_APPROVAL_RELAY_PROSE_SENTENCE;
|
|
@@ -5009,6 +5239,7 @@ exports.addressFromKey = addressFromKey;
|
|
|
5009
5239
|
exports.assertSecureX402RetryTarget = assertSecureX402RetryTarget;
|
|
5010
5240
|
exports.composeDescription = composeDescription;
|
|
5011
5241
|
exports.discoverMerchantMcpUrl = discoverMerchantMcpUrl;
|
|
5242
|
+
exports.formatTokenAmount = formatTokenAmount;
|
|
5012
5243
|
exports.havenTools = havenTools;
|
|
5013
5244
|
exports.isSecureX402RetryTarget = isSecureX402RetryTarget;
|
|
5014
5245
|
exports.isZeroSettlementTxHash = isZeroSettlementTxHash;
|