@haven_ai/sdk 0.0.0-dev.202609241737.2d2b91b → 0.0.0-dev.202609241802.ea320de
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{base64-fVc9Cnn-.d.cts → base64-CPxbmyU9.d.cts} +16 -16
- package/dist/{base64-fVc9Cnn-.d.ts → base64-CPxbmyU9.d.ts} +16 -16
- package/dist/{chunk-YGSM2WRP.js → chunk-FR5R26V3.js} +6 -6
- package/dist/chunk-FR5R26V3.js.map +1 -0
- package/dist/{chunk-CSWZXQ2L.cjs → chunk-M57KOLAN.cjs} +6 -6
- package/dist/chunk-M57KOLAN.cjs.map +1 -0
- package/dist/edge.cjs +32 -32
- package/dist/edge.d.cts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +2 -2
- package/dist/index.cjs +260 -259
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-CSWZXQ2L.cjs.map +0 -1
- package/dist/chunk-YGSM2WRP.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkM57KOLAN_cjs = require('./chunk-M57KOLAN.cjs');
|
|
4
4
|
var viem = require('viem');
|
|
5
5
|
var ethers = require('ethers');
|
|
6
6
|
var async_hooks = require('async_hooks');
|
|
@@ -13,7 +13,7 @@ function signHash(privateKey, hash) {
|
|
|
13
13
|
const sig = signingKey.sign(hash);
|
|
14
14
|
return sig.serialized;
|
|
15
15
|
} catch (err) {
|
|
16
|
-
throw new
|
|
16
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
17
17
|
`Failed to sign hash: ${err instanceof Error ? err.message : String(err)}`
|
|
18
18
|
);
|
|
19
19
|
}
|
|
@@ -29,7 +29,7 @@ async function signTypedDataVerbatim(privateKey, typedData, label) {
|
|
|
29
29
|
typedData.message
|
|
30
30
|
);
|
|
31
31
|
} catch (err) {
|
|
32
|
-
throw new
|
|
32
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
33
33
|
`Failed to sign ${label}: ${err instanceof Error ? err.message : String(err)}`
|
|
34
34
|
);
|
|
35
35
|
}
|
|
@@ -44,7 +44,7 @@ function addressFromKey(privateKey) {
|
|
|
44
44
|
try {
|
|
45
45
|
return new ethers.ethers.Wallet(privateKey).address;
|
|
46
46
|
} catch (err) {
|
|
47
|
-
throw new
|
|
47
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
48
48
|
`Invalid private key: ${err instanceof Error ? err.message : String(err)}`
|
|
49
49
|
);
|
|
50
50
|
}
|
|
@@ -105,15 +105,15 @@ var HavenApiTransport = class {
|
|
|
105
105
|
const rawDetails = record.details ?? record.detail;
|
|
106
106
|
const detailsText = typeof rawDetails === "string" ? rawDetails : rawDetails != null ? JSON.stringify(rawDetails) : void 0;
|
|
107
107
|
const message = errorText && detailsText ? `${errorText}: ${detailsText}` : errorText ?? detailsText ?? "API request failed";
|
|
108
|
-
throw new
|
|
108
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(message, res.status, data);
|
|
109
109
|
}
|
|
110
110
|
return data;
|
|
111
111
|
} catch (err) {
|
|
112
|
-
if (err instanceof
|
|
112
|
+
if (err instanceof chunkM57KOLAN_cjs.HavenApiError) throw err;
|
|
113
113
|
if (err instanceof Error && err.name === "AbortError") {
|
|
114
|
-
throw new
|
|
114
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(`Request to ${path} timed out`, 408);
|
|
115
115
|
}
|
|
116
|
-
throw new
|
|
116
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
117
117
|
`Request to ${path} failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
118
118
|
0
|
|
119
119
|
);
|
|
@@ -260,29 +260,29 @@ function paymentStateStatusCode(status, fallback = 502) {
|
|
|
260
260
|
return PAYMENT_STATE_STATUS_CODES[status] ?? fallback;
|
|
261
261
|
}
|
|
262
262
|
function phaseForStatus(status) {
|
|
263
|
-
if (status === "pending_signature") return
|
|
264
|
-
if (status === "submitted") return
|
|
265
|
-
if (status === "confirmed") return
|
|
266
|
-
if (status === "pending" || status === "pending_approval") return
|
|
267
|
-
if (status === "approved") return
|
|
268
|
-
if (status === "proposed") return
|
|
269
|
-
if (status === "executed") return
|
|
270
|
-
if (status === "rejected") return
|
|
271
|
-
if (status === "expired") return
|
|
272
|
-
if (status === "failed") return
|
|
263
|
+
if (status === "pending_signature") return chunkM57KOLAN_cjs.AgentPaymentPhase.AgentSignatureRequired;
|
|
264
|
+
if (status === "submitted") return chunkM57KOLAN_cjs.AgentPaymentPhase.PaymentSubmitted;
|
|
265
|
+
if (status === "confirmed") return chunkM57KOLAN_cjs.AgentPaymentPhase.PaymentConfirmed;
|
|
266
|
+
if (status === "pending" || status === "pending_approval") return chunkM57KOLAN_cjs.AgentPaymentPhase.UserApprovalRequired;
|
|
267
|
+
if (status === "approved") return chunkM57KOLAN_cjs.AgentPaymentPhase.UserExecutionRequired;
|
|
268
|
+
if (status === "proposed") return chunkM57KOLAN_cjs.AgentPaymentPhase.WaitingForAdditionalApprovals;
|
|
269
|
+
if (status === "executed") return chunkM57KOLAN_cjs.AgentPaymentPhase.FundingSent;
|
|
270
|
+
if (status === "rejected") return chunkM57KOLAN_cjs.AgentPaymentPhase.Rejected;
|
|
271
|
+
if (status === "expired") return chunkM57KOLAN_cjs.AgentPaymentPhase.Expired;
|
|
272
|
+
if (status === "failed") return chunkM57KOLAN_cjs.AgentPaymentPhase.Failed;
|
|
273
273
|
return null;
|
|
274
274
|
}
|
|
275
275
|
function nextActionForStatus(status) {
|
|
276
|
-
if (status === "pending_signature") return
|
|
277
|
-
if (status === "submitted") return
|
|
278
|
-
if (status === "confirmed") return
|
|
279
|
-
if (status === "pending" || status === "pending_approval") return
|
|
280
|
-
if (status === "approved") return
|
|
281
|
-
if (status === "proposed") return
|
|
282
|
-
if (status === "executed") return
|
|
283
|
-
if (status === "rejected") return
|
|
284
|
-
if (status === "expired") return
|
|
285
|
-
if (status === "failed") return
|
|
276
|
+
if (status === "pending_signature") return chunkM57KOLAN_cjs.AgentPaymentNextAction.SignAndSubmitPayment;
|
|
277
|
+
if (status === "submitted") return chunkM57KOLAN_cjs.AgentPaymentNextAction.CheckStatusLater;
|
|
278
|
+
if (status === "confirmed") return chunkM57KOLAN_cjs.AgentPaymentNextAction.None;
|
|
279
|
+
if (status === "pending" || status === "pending_approval") return chunkM57KOLAN_cjs.AgentPaymentNextAction.StopAndTellUser;
|
|
280
|
+
if (status === "approved") return chunkM57KOLAN_cjs.AgentPaymentNextAction.StopAndTellUser;
|
|
281
|
+
if (status === "proposed") return chunkM57KOLAN_cjs.AgentPaymentNextAction.StopAndTellUser;
|
|
282
|
+
if (status === "executed") return chunkM57KOLAN_cjs.AgentPaymentNextAction.StopAndTellUser;
|
|
283
|
+
if (status === "rejected") return chunkM57KOLAN_cjs.AgentPaymentNextAction.StopAndTellUser;
|
|
284
|
+
if (status === "expired") return chunkM57KOLAN_cjs.AgentPaymentNextAction.RequestAgainIfUserStillWantsIt;
|
|
285
|
+
if (status === "failed") return chunkM57KOLAN_cjs.AgentPaymentNextAction.StopAndTellUser;
|
|
286
286
|
return null;
|
|
287
287
|
}
|
|
288
288
|
function messageForState(label, status, paymentId, nextAction) {
|
|
@@ -356,17 +356,17 @@ function throwPaymentStateError(label, raw) {
|
|
|
356
356
|
const statusCode = paymentStateStatusCode(raw.status);
|
|
357
357
|
const state = paymentStateFromRaw(label, raw);
|
|
358
358
|
if (state) {
|
|
359
|
-
throw new
|
|
359
|
+
throw new chunkM57KOLAN_cjs.HavenPaymentStateError(state.message, statusCode, state, raw);
|
|
360
360
|
}
|
|
361
361
|
if (raw.status === "pending_approval") {
|
|
362
|
-
throw new
|
|
362
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
363
363
|
`${label} exceeds the agent's on-chain budget and was declined; no approval is pending and none will arrive (payment_id: ${raw.payment_id}).`,
|
|
364
364
|
statusCode,
|
|
365
365
|
raw
|
|
366
366
|
);
|
|
367
367
|
}
|
|
368
368
|
if (raw.status === "expired") {
|
|
369
|
-
throw new
|
|
369
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
370
370
|
`${label} expired before it could be completed (payment_id: ${raw.payment_id}).`,
|
|
371
371
|
statusCode,
|
|
372
372
|
raw
|
|
@@ -374,7 +374,7 @@ function throwPaymentStateError(label, raw) {
|
|
|
374
374
|
}
|
|
375
375
|
const paymentId = raw.payment_id ? ` (payment_id: ${raw.payment_id})` : "";
|
|
376
376
|
const message = raw.error ?? `${label} ${raw.status}${paymentId}`;
|
|
377
|
-
throw new
|
|
377
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(message, statusCode, raw);
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
// src/x402-retry-target.ts
|
|
@@ -406,7 +406,7 @@ function isSecureX402RetryTarget(url) {
|
|
|
406
406
|
return RESERVED_SUFFIXES.some((suffix) => host.endsWith(suffix));
|
|
407
407
|
}
|
|
408
408
|
var INSECURE_RETRY_TARGET_CODE = "INSECURE_RETRY_TARGET";
|
|
409
|
-
var HavenInsecureRetryTargetError = class extends
|
|
409
|
+
var HavenInsecureRetryTargetError = class extends chunkM57KOLAN_cjs.HavenError {
|
|
410
410
|
constructor(url) {
|
|
411
411
|
super(
|
|
412
412
|
`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.`,
|
|
@@ -448,7 +448,7 @@ var McpMerchantTransport = class {
|
|
|
448
448
|
return await this.fetchImpl(url, { ...init, signal });
|
|
449
449
|
} catch (err) {
|
|
450
450
|
if (timeoutSignal.aborted) {
|
|
451
|
-
throw new
|
|
451
|
+
throw new chunkM57KOLAN_cjs.MerchantTimeoutError(`Merchant request timed out after ${timeoutMs}ms: ${url}`);
|
|
452
452
|
}
|
|
453
453
|
throw err;
|
|
454
454
|
}
|
|
@@ -585,8 +585,8 @@ var McpMerchantTransport = class {
|
|
|
585
585
|
async deliverPayment(url, init, paymentHeader) {
|
|
586
586
|
assertSecureX402RetryTarget(url);
|
|
587
587
|
const headers = new Headers(init?.headers);
|
|
588
|
-
const send =
|
|
589
|
-
for (const name of
|
|
588
|
+
const send = chunkM57KOLAN_cjs.x402PaymentHeaderNamesFor(paymentHeader);
|
|
589
|
+
for (const name of chunkM57KOLAN_cjs.X402_PAYMENT_HEADER_NAMES) {
|
|
590
590
|
if (send.includes(name)) headers.set(name, paymentHeader);
|
|
591
591
|
else headers.delete(name);
|
|
592
592
|
}
|
|
@@ -673,7 +673,7 @@ function mcpToolResultOf(value) {
|
|
|
673
673
|
function extractMcpPaymentRequired(toolResult) {
|
|
674
674
|
if (toolResult.isError !== true) return void 0;
|
|
675
675
|
if (isRecord(toolResult.structuredContent)) {
|
|
676
|
-
const parsed =
|
|
676
|
+
const parsed = chunkM57KOLAN_cjs.normalizePaymentRequired(toolResult.structuredContent);
|
|
677
677
|
if (parsed) return parsed;
|
|
678
678
|
}
|
|
679
679
|
if (Array.isArray(toolResult.content)) {
|
|
@@ -685,7 +685,7 @@ function extractMcpPaymentRequired(toolResult) {
|
|
|
685
685
|
} catch {
|
|
686
686
|
continue;
|
|
687
687
|
}
|
|
688
|
-
const parsed =
|
|
688
|
+
const parsed = chunkM57KOLAN_cjs.normalizePaymentRequired(candidate);
|
|
689
689
|
if (parsed) return parsed;
|
|
690
690
|
}
|
|
691
691
|
}
|
|
@@ -709,7 +709,7 @@ function withMcpPaymentMeta(init, paymentHeader) {
|
|
|
709
709
|
if (!request) return init;
|
|
710
710
|
let envelope;
|
|
711
711
|
try {
|
|
712
|
-
envelope =
|
|
712
|
+
envelope = chunkM57KOLAN_cjs.decodeBase64Json(paymentHeader);
|
|
713
713
|
} catch {
|
|
714
714
|
return init;
|
|
715
715
|
}
|
|
@@ -725,7 +725,7 @@ function withMcpPaymentMeta(init, paymentHeader) {
|
|
|
725
725
|
};
|
|
726
726
|
}
|
|
727
727
|
function encodeMcpSettlementReceipt(settlement) {
|
|
728
|
-
return
|
|
728
|
+
return chunkM57KOLAN_cjs.encodeBase64Json(settlement);
|
|
729
729
|
}
|
|
730
730
|
function parseJsonRpcToolsCall(body) {
|
|
731
731
|
if (typeof body !== "string") return void 0;
|
|
@@ -849,7 +849,7 @@ function deriveReadiness(status, allowances) {
|
|
|
849
849
|
return allowances.some((allowance) => safeBigInt(allowance.remainingAtomic) > 0n) ? "ready" : "needs_approval";
|
|
850
850
|
}
|
|
851
851
|
function formatRemainingDisplay(tokenAddress, tokenSymbol, remainingAtomic) {
|
|
852
|
-
const token =
|
|
852
|
+
const token = chunkM57KOLAN_cjs.resolveTokenFromAddress(tokenAddress);
|
|
853
853
|
return token ? `${formatAtomicAmount(safeBigInt(remainingAtomic), token.decimals)} ${tokenSymbol}` : `${remainingAtomic} ${tokenSymbol} (atomic; unknown decimals)`;
|
|
854
854
|
}
|
|
855
855
|
var AccountReads = class {
|
|
@@ -953,7 +953,7 @@ var AccountReads = class {
|
|
|
953
953
|
payment: payment2,
|
|
954
954
|
allowance: null,
|
|
955
955
|
warnings: [{
|
|
956
|
-
code:
|
|
956
|
+
code: chunkM57KOLAN_cjs.AgentPaymentWarningCode.AllowanceCheckUnavailable,
|
|
957
957
|
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.`
|
|
958
958
|
}]
|
|
959
959
|
});
|
|
@@ -979,7 +979,7 @@ var AccountReads = class {
|
|
|
979
979
|
(allowance) => allowance.tokenAddress.toLowerCase() === tokenAddress.toLowerCase()
|
|
980
980
|
);
|
|
981
981
|
if (!match) return unavailable("no allowance/budget row matches the settled token", payment);
|
|
982
|
-
const token =
|
|
982
|
+
const token = chunkM57KOLAN_cjs.resolveTokenFromAddress(match.tokenAddress);
|
|
983
983
|
const remainingDisplay = token ? `${formatAtomicAmount(safeBigInt(match.onchain.remaining), token.decimals)} ${match.tokenSymbol}` : void 0;
|
|
984
984
|
const rail = agentResult.value.executionRail;
|
|
985
985
|
return {
|
|
@@ -1054,7 +1054,7 @@ function isWaitTimeout(err) {
|
|
|
1054
1054
|
async function waitForSweepTx(tx) {
|
|
1055
1055
|
let receipt;
|
|
1056
1056
|
try {
|
|
1057
|
-
receipt = await tx.wait(1,
|
|
1057
|
+
receipt = await tx.wait(1, chunkM57KOLAN_cjs.DEFAULT_CONFIRMATION_TIMEOUT_MS);
|
|
1058
1058
|
} catch (err) {
|
|
1059
1059
|
if (!isWaitTimeout(err)) throw err;
|
|
1060
1060
|
return { txHash: tx.hash, confirmation: "unconfirmed" };
|
|
@@ -1068,16 +1068,16 @@ var DelegateSweepApi = class {
|
|
|
1068
1068
|
}
|
|
1069
1069
|
options;
|
|
1070
1070
|
async sweepDelegate() {
|
|
1071
|
-
if (!this.options.delegateKey) throw new
|
|
1071
|
+
if (!this.options.delegateKey) throw new chunkM57KOLAN_cjs.HavenSigningError("delegateKey is required for sweepDelegate.");
|
|
1072
1072
|
const agent = await this.options.getAgent();
|
|
1073
|
-
if (!agent.delegateAddress) throw new
|
|
1073
|
+
if (!agent.delegateAddress) throw new chunkM57KOLAN_cjs.HavenApiError("Agent has no delegate address.", 422);
|
|
1074
1074
|
const rpcUrl = this.options.chainRpcs[agent.chainId];
|
|
1075
|
-
if (!rpcUrl) throw new
|
|
1075
|
+
if (!rpcUrl) throw new chunkM57KOLAN_cjs.HavenApiError(`chainRpcs[${agent.chainId}] must be configured to sweep the delegate wallet.`, 422);
|
|
1076
1076
|
const provider = createJsonRpcProvider(rpcUrl);
|
|
1077
1077
|
const wallet = createWallet(this.options.delegateKey, provider);
|
|
1078
1078
|
const transfers = [];
|
|
1079
|
-
if (
|
|
1080
|
-
const contract = createErc20Contract(
|
|
1079
|
+
if (chunkM57KOLAN_cjs.isSweepableChain(agent.chainId)) {
|
|
1080
|
+
const contract = createErc20Contract(chunkM57KOLAN_cjs.sweepUsdcAddress(agent.chainId), ["function balanceOf(address) view returns (uint256)", "function transfer(address to, uint256 amount) returns (bool)"], wallet);
|
|
1081
1081
|
const balance2 = await contract.balanceOf(agent.delegateAddress);
|
|
1082
1082
|
if (balance2 > 0n) {
|
|
1083
1083
|
const tx = await contract.transfer(agent.accountAddress, balance2);
|
|
@@ -1165,7 +1165,7 @@ function snapshotRequestBody(body) {
|
|
|
1165
1165
|
if (body == null) return void 0;
|
|
1166
1166
|
if (typeof body === "string") return body;
|
|
1167
1167
|
if (body instanceof URLSearchParams) return body.toString();
|
|
1168
|
-
throw new
|
|
1168
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1169
1169
|
"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.",
|
|
1170
1170
|
400
|
|
1171
1171
|
);
|
|
@@ -1186,25 +1186,25 @@ function requestInitFromSnapshot(request) {
|
|
|
1186
1186
|
};
|
|
1187
1187
|
}
|
|
1188
1188
|
function noCompatiblePaymentOptionError(accepts) {
|
|
1189
|
-
const erc7710Only =
|
|
1189
|
+
const erc7710Only = chunkM57KOLAN_cjs.selectErc7710PaymentOption(accepts) !== null;
|
|
1190
1190
|
const unsupportedOnly = !erc7710Only && accepts.some(
|
|
1191
|
-
(opt) => opt !== null && typeof opt === "object" && !
|
|
1191
|
+
(opt) => opt !== null && typeof opt === "object" && !chunkM57KOLAN_cjs.isErc7710Option(opt) && (chunkM57KOLAN_cjs.x402AssetTransferMethod(opt) !== null || opt.extra?.paymentFlow !== void 0)
|
|
1192
1192
|
);
|
|
1193
|
-
return new
|
|
1193
|
+
return new chunkM57KOLAN_cjs.HavenApiError(
|
|
1194
1194
|
"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." : ""),
|
|
1195
1195
|
400
|
|
1196
1196
|
);
|
|
1197
1197
|
}
|
|
1198
1198
|
function buildX402Quote(paymentRequired, request, idempotencyKey, mcpTransport) {
|
|
1199
|
-
const standard =
|
|
1200
|
-
const option = standard ??
|
|
1199
|
+
const standard = chunkM57KOLAN_cjs.selectStandardPaymentOption(paymentRequired.accepts);
|
|
1200
|
+
const option = standard ?? chunkM57KOLAN_cjs.selectErc7710PaymentOption(paymentRequired.accepts);
|
|
1201
1201
|
if (!option) {
|
|
1202
1202
|
throw noCompatiblePaymentOptionError(paymentRequired.accepts);
|
|
1203
1203
|
}
|
|
1204
|
-
const token =
|
|
1204
|
+
const token = chunkM57KOLAN_cjs.resolveTokenFromAddress(option.asset, option.network);
|
|
1205
1205
|
return {
|
|
1206
1206
|
rail: "x402",
|
|
1207
|
-
idempotencyKey: idempotencyKey ??
|
|
1207
|
+
idempotencyKey: idempotencyKey ?? chunkM57KOLAN_cjs.buildX402IdempotencyKey(paymentRequired, option),
|
|
1208
1208
|
paymentRequired,
|
|
1209
1209
|
accepted: option,
|
|
1210
1210
|
acceptedScheme: standard ? "standard" : "erc7710",
|
|
@@ -1218,8 +1218,8 @@ function buildX402Quote(paymentRequired, request, idempotencyKey, mcpTransport)
|
|
|
1218
1218
|
resourceUrlDiffersFromRequest: paymentRequired.resource.url !== request.url,
|
|
1219
1219
|
description: paymentRequired.resource.description ?? option.description ?? null,
|
|
1220
1220
|
mimeType: paymentRequired.resource.mimeType ?? option.mimeType ?? null,
|
|
1221
|
-
amountAtomic:
|
|
1222
|
-
amount: decimalFromUsdcAtomic(
|
|
1221
|
+
amountAtomic: chunkM57KOLAN_cjs.x402AuthorizationAmount(option),
|
|
1222
|
+
amount: decimalFromUsdcAtomic(chunkM57KOLAN_cjs.x402AuthorizationAmount(option)),
|
|
1223
1223
|
token: token?.symbol ?? "USDC",
|
|
1224
1224
|
// #1351: null when the asset is unrecognised on this network — the
|
|
1225
1225
|
// `token` fallback above is a LABEL, not evidence of 6 decimals, and a
|
|
@@ -1258,7 +1258,7 @@ function buildX402Receipt(input) {
|
|
|
1258
1258
|
payTo: input.merchantTo ?? input.accepted.payTo
|
|
1259
1259
|
},
|
|
1260
1260
|
x402: {
|
|
1261
|
-
amount:
|
|
1261
|
+
amount: chunkM57KOLAN_cjs.x402AuthorizationAmount(input.accepted),
|
|
1262
1262
|
token: input.token,
|
|
1263
1263
|
network: input.accepted.network,
|
|
1264
1264
|
asset: input.accepted.asset,
|
|
@@ -1267,7 +1267,7 @@ function buildX402Receipt(input) {
|
|
|
1267
1267
|
};
|
|
1268
1268
|
}
|
|
1269
1269
|
function buildX402ResumeState(input) {
|
|
1270
|
-
const token =
|
|
1270
|
+
const token = chunkM57KOLAN_cjs.resolveTokenFromAddress(input.accepted.asset, input.accepted.network);
|
|
1271
1271
|
return {
|
|
1272
1272
|
rail: "x402",
|
|
1273
1273
|
paymentId: input.paymentId,
|
|
@@ -1278,8 +1278,8 @@ function buildX402ResumeState(input) {
|
|
|
1278
1278
|
request: input.request,
|
|
1279
1279
|
resourceUrl: input.paymentRequired.resource.url,
|
|
1280
1280
|
description: input.paymentRequired.resource.description ?? input.accepted.description ?? null,
|
|
1281
|
-
amountAtomic:
|
|
1282
|
-
amount: decimalFromUsdcAtomic(
|
|
1281
|
+
amountAtomic: chunkM57KOLAN_cjs.x402AuthorizationAmount(input.accepted),
|
|
1282
|
+
amount: decimalFromUsdcAtomic(chunkM57KOLAN_cjs.x402AuthorizationAmount(input.accepted)),
|
|
1283
1283
|
token: token?.symbol ?? "USDC",
|
|
1284
1284
|
asset: input.accepted.asset,
|
|
1285
1285
|
network: input.accepted.network,
|
|
@@ -1288,7 +1288,7 @@ function buildX402ResumeState(input) {
|
|
|
1288
1288
|
};
|
|
1289
1289
|
}
|
|
1290
1290
|
function attachX402ResumeState(err, paymentRequired, accepted, idempotencyKey, request) {
|
|
1291
|
-
if (!(err instanceof
|
|
1291
|
+
if (!(err instanceof chunkM57KOLAN_cjs.HavenPaymentStateError)) return;
|
|
1292
1292
|
if (err.state.rail !== "x402") return;
|
|
1293
1293
|
err.resumeState = buildX402ResumeState({
|
|
1294
1294
|
paymentId: err.state.paymentId,
|
|
@@ -1309,17 +1309,17 @@ function attachResumeState(err, input) {
|
|
|
1309
1309
|
}
|
|
1310
1310
|
function assertCanResumeX402(status, paymentRequired, option) {
|
|
1311
1311
|
if (status.rail !== "x402") {
|
|
1312
|
-
throw new
|
|
1312
|
+
throw new chunkM57KOLAN_cjs.HavenPaymentStateError(
|
|
1313
1313
|
`Payment ${status.paymentId} is ${status.rail}, not x402.`,
|
|
1314
1314
|
409,
|
|
1315
1315
|
status
|
|
1316
1316
|
);
|
|
1317
1317
|
}
|
|
1318
|
-
if (status.nextAction !==
|
|
1319
|
-
throw new
|
|
1318
|
+
if (status.nextAction !== chunkM57KOLAN_cjs.AgentPaymentNextAction.RetryOriginalX402Request) {
|
|
1319
|
+
throw new chunkM57KOLAN_cjs.HavenPaymentStateError(status.message, paymentStateStatusCode(status.status, 409), status);
|
|
1320
1320
|
}
|
|
1321
1321
|
if (!status.txHash) {
|
|
1322
|
-
throw new
|
|
1322
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1323
1323
|
`x402 payment ${status.paymentId} is ready to retry but has no Haven transaction hash.`,
|
|
1324
1324
|
502,
|
|
1325
1325
|
status,
|
|
@@ -1327,7 +1327,7 @@ function assertCanResumeX402(status, paymentRequired, option) {
|
|
|
1327
1327
|
);
|
|
1328
1328
|
}
|
|
1329
1329
|
if (status.resourceUrl && status.resourceUrl !== paymentRequired.resource.url) {
|
|
1330
|
-
throw new
|
|
1330
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1331
1331
|
"x402 resume request does not match the approved resource URL.",
|
|
1332
1332
|
409,
|
|
1333
1333
|
{ status, paymentRequired },
|
|
@@ -1335,7 +1335,7 @@ function assertCanResumeX402(status, paymentRequired, option) {
|
|
|
1335
1335
|
);
|
|
1336
1336
|
}
|
|
1337
1337
|
if (status.merchantAddress && !sameAddress(status.merchantAddress, option.payTo)) {
|
|
1338
|
-
throw new
|
|
1338
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1339
1339
|
"x402 resume request does not match the approved merchant.",
|
|
1340
1340
|
409,
|
|
1341
1341
|
{ status, selectedPayment: option },
|
|
@@ -1344,7 +1344,7 @@ function assertCanResumeX402(status, paymentRequired, option) {
|
|
|
1344
1344
|
}
|
|
1345
1345
|
const optionChainId = chainIdFromNetwork(option.network);
|
|
1346
1346
|
if (status.chainId && optionChainId && status.chainId !== optionChainId) {
|
|
1347
|
-
throw new
|
|
1347
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1348
1348
|
"x402 resume request does not match the approved network.",
|
|
1349
1349
|
409,
|
|
1350
1350
|
{ status, selectedPayment: option },
|
|
@@ -1352,7 +1352,7 @@ function assertCanResumeX402(status, paymentRequired, option) {
|
|
|
1352
1352
|
);
|
|
1353
1353
|
}
|
|
1354
1354
|
if (status.token && status.token !== "USDC") {
|
|
1355
|
-
throw new
|
|
1355
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1356
1356
|
"x402 resume request does not match the approved token.",
|
|
1357
1357
|
409,
|
|
1358
1358
|
{ status, selectedPayment: option },
|
|
@@ -1360,9 +1360,9 @@ function assertCanResumeX402(status, paymentRequired, option) {
|
|
|
1360
1360
|
);
|
|
1361
1361
|
}
|
|
1362
1362
|
const approvedAmount = status.amount ? normalizeDecimal(status.amount) : "";
|
|
1363
|
-
const requestedAmount = normalizeDecimal(decimalFromUsdcAtomic(
|
|
1363
|
+
const requestedAmount = normalizeDecimal(decimalFromUsdcAtomic(chunkM57KOLAN_cjs.x402AuthorizationAmount(option)));
|
|
1364
1364
|
if (approvedAmount && approvedAmount !== requestedAmount) {
|
|
1365
|
-
throw new
|
|
1365
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1366
1366
|
"x402 resume request does not match the approved amount.",
|
|
1367
1367
|
409,
|
|
1368
1368
|
{ status, selectedPayment: option },
|
|
@@ -1420,7 +1420,7 @@ var X402FundingLeg = class {
|
|
|
1420
1420
|
url: paymentRequired.resource.url,
|
|
1421
1421
|
payTo: this.delegateAddress,
|
|
1422
1422
|
merchantPayTo: option.payTo,
|
|
1423
|
-
amount:
|
|
1423
|
+
amount: chunkM57KOLAN_cjs.x402AuthorizationAmount(option),
|
|
1424
1424
|
asset: option.asset,
|
|
1425
1425
|
network: option.network,
|
|
1426
1426
|
description: paymentRequired.resource.description,
|
|
@@ -1431,17 +1431,17 @@ var X402FundingLeg = class {
|
|
|
1431
1431
|
settlementScheme: "eip3009"
|
|
1432
1432
|
});
|
|
1433
1433
|
const state = paymentStateFromRaw("x402 payment", raw);
|
|
1434
|
-
const executedReplay = raw.success && raw.tx_hash ? "idempotency-collision" : state?.nextAction ===
|
|
1434
|
+
const executedReplay = raw.success && raw.tx_hash ? "idempotency-collision" : state?.nextAction === chunkM57KOLAN_cjs.AgentPaymentNextAction.RetryOriginalX402Request ? "approval-resume" : null;
|
|
1435
1435
|
if (executedReplay) {
|
|
1436
1436
|
const canFund = await this.delegateCanFund(
|
|
1437
1437
|
raw.chain_id ?? state?.chainId ?? chainIdFromNetwork(option.network),
|
|
1438
1438
|
option.asset,
|
|
1439
|
-
|
|
1439
|
+
chunkM57KOLAN_cjs.x402AuthorizationAmount(option)
|
|
1440
1440
|
);
|
|
1441
1441
|
const refuse = executedReplay === "idempotency-collision" ? canFund !== true : canFund === false;
|
|
1442
1442
|
if (refuse) {
|
|
1443
1443
|
const settledReceipt = state && executedReplay === "approval-resume" ? this.receiptFromStatus(paymentRequired, option, void 0, state) : this.receiptFromAuthorization(paymentRequired, option, void 0, raw);
|
|
1444
|
-
throw new
|
|
1444
|
+
throw new chunkM57KOLAN_cjs.X402AlreadySettledError(
|
|
1445
1445
|
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`.",
|
|
1446
1446
|
settledReceipt,
|
|
1447
1447
|
canFund === false ? "settled" : "unverifiable"
|
|
@@ -1454,14 +1454,14 @@ var X402FundingLeg = class {
|
|
|
1454
1454
|
this.cacheReceipt(idempotencyKey, paymentHeader, receipt2);
|
|
1455
1455
|
return receipt2;
|
|
1456
1456
|
}
|
|
1457
|
-
if (state?.nextAction ===
|
|
1457
|
+
if (state?.nextAction === chunkM57KOLAN_cjs.AgentPaymentNextAction.RetryOriginalX402Request) {
|
|
1458
1458
|
const receipt2 = this.receiptFromStatus(paymentRequired, option, paymentHeader, state);
|
|
1459
1459
|
this.cacheReceipt(idempotencyKey, paymentHeader, receipt2);
|
|
1460
1460
|
return receipt2;
|
|
1461
1461
|
}
|
|
1462
1462
|
this.assertSignableAuthorizationState("x402 payment", raw);
|
|
1463
1463
|
if (!raw.sign_data?.hash) {
|
|
1464
|
-
throw new
|
|
1464
|
+
throw new chunkM57KOLAN_cjs.HavenApiError("No sign_hash returned from x402/authorize", 500, raw);
|
|
1465
1465
|
}
|
|
1466
1466
|
const sig = await this.signForData(raw.sign_data);
|
|
1467
1467
|
const execResult = await this.post(
|
|
@@ -1482,25 +1482,25 @@ var X402FundingLeg = class {
|
|
|
1482
1482
|
// ── Header minting ───────────────────────────────────────────────
|
|
1483
1483
|
async createPaymentHeader(paymentRequired, option) {
|
|
1484
1484
|
if (!this.delegateKey) {
|
|
1485
|
-
throw new
|
|
1485
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError("delegateKey is required to sign x402 payment headers.");
|
|
1486
1486
|
}
|
|
1487
1487
|
const account = accounts.privateKeyToAccount(this.delegateKey);
|
|
1488
|
-
const requirements =
|
|
1488
|
+
const requirements = chunkM57KOLAN_cjs.toStandardPaymentRequirements(paymentRequired, option);
|
|
1489
1489
|
const header = await schemes.exact.evm.createPaymentHeader(
|
|
1490
1490
|
account,
|
|
1491
1491
|
paymentRequired.x402Version,
|
|
1492
1492
|
requirements
|
|
1493
1493
|
);
|
|
1494
1494
|
if (paymentRequired.x402Version < 2) return header;
|
|
1495
|
-
const payment =
|
|
1496
|
-
return
|
|
1495
|
+
const payment = chunkM57KOLAN_cjs.decodeBase64Json(header);
|
|
1496
|
+
return chunkM57KOLAN_cjs.encodeBase64Json(chunkM57KOLAN_cjs.x402V2PaymentEnvelope(paymentRequired, option, payment.payload));
|
|
1497
1497
|
}
|
|
1498
1498
|
// ── Receipt mapping ──────────────────────────────────────────────
|
|
1499
1499
|
receiptFromAuthorization(paymentRequired, option, paymentHeader, raw, execResult) {
|
|
1500
1500
|
const txHash = execResult?.tx_hash ?? raw.tx_hash ?? "";
|
|
1501
1501
|
const chainId = execResult?.chain_id ?? raw.chain_id ?? chainIdFromNetwork(option.network);
|
|
1502
1502
|
const token = execResult?.token ?? raw.token ?? "USDC";
|
|
1503
|
-
const amount = execResult?.amount ?? raw.amount ?? decimalFromUsdcAtomic(
|
|
1503
|
+
const amount = execResult?.amount ?? raw.amount ?? decimalFromUsdcAtomic(chunkM57KOLAN_cjs.x402AuthorizationAmount(option));
|
|
1504
1504
|
const to = execResult?.to ?? raw.to ?? this.delegateAddress ?? "";
|
|
1505
1505
|
const explorerUrl = execResult?.explorer_url ?? raw.explorer_url ?? explorerUrlOrEmpty(chainId, txHash);
|
|
1506
1506
|
const merchantTo = execResult?.merchant_to ?? raw.merchant_to ?? option.payTo;
|
|
@@ -1522,7 +1522,7 @@ var X402FundingLeg = class {
|
|
|
1522
1522
|
}
|
|
1523
1523
|
receiptFromStatus(paymentRequired, option, paymentHeader, status) {
|
|
1524
1524
|
if (!status.txHash) {
|
|
1525
|
-
throw new
|
|
1525
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1526
1526
|
`x402 payment ${status.paymentId} is ready to retry but has no Haven transaction hash.`,
|
|
1527
1527
|
502,
|
|
1528
1528
|
status,
|
|
@@ -1533,7 +1533,7 @@ var X402FundingLeg = class {
|
|
|
1533
1533
|
paymentId: status.paymentId,
|
|
1534
1534
|
txHash: status.txHash,
|
|
1535
1535
|
token: status.token || "USDC",
|
|
1536
|
-
amount: status.amount || decimalFromUsdcAtomic(
|
|
1536
|
+
amount: status.amount || decimalFromUsdcAtomic(chunkM57KOLAN_cjs.x402AuthorizationAmount(option)),
|
|
1537
1537
|
to: this.delegateAddress ?? "",
|
|
1538
1538
|
resourceUrl: paymentRequired.resource.url,
|
|
1539
1539
|
explorerUrl: explorerUrlOrEmpty(status.chainId, status.txHash),
|
|
@@ -1561,7 +1561,7 @@ var X402FundingLeg = class {
|
|
|
1561
1561
|
const provider = createJsonRpcProvider(rpcUrl);
|
|
1562
1562
|
const onChainReceipt = await provider.waitForTransaction(txHash, 1, timeoutMs);
|
|
1563
1563
|
if (!onChainReceipt || onChainReceipt.status !== 1) {
|
|
1564
|
-
throw new
|
|
1564
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1565
1565
|
"Funding tx did not confirm on-chain within the timeout window.",
|
|
1566
1566
|
500,
|
|
1567
1567
|
{ txHash, chainId }
|
|
@@ -1610,7 +1610,7 @@ var X402FundingLeg = class {
|
|
|
1610
1610
|
};
|
|
1611
1611
|
function getPaymentHeaderValidBefore(paymentHeader) {
|
|
1612
1612
|
try {
|
|
1613
|
-
const payment =
|
|
1613
|
+
const payment = chunkM57KOLAN_cjs.decodeBase64Json(
|
|
1614
1614
|
paymentHeader
|
|
1615
1615
|
);
|
|
1616
1616
|
const payload = payment.payload;
|
|
@@ -1665,7 +1665,7 @@ var X402Erc7710 = class {
|
|
|
1665
1665
|
*/
|
|
1666
1666
|
async settle(paymentRequired, options = {}) {
|
|
1667
1667
|
if (!this.delegateKey) {
|
|
1668
|
-
throw new
|
|
1668
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
1669
1669
|
"delegateKey is required for x402 payments. Pass it in the HavenClient config."
|
|
1670
1670
|
);
|
|
1671
1671
|
}
|
|
@@ -1687,21 +1687,21 @@ var X402Erc7710 = class {
|
|
|
1687
1687
|
async prepare(paymentRequired, options = {}) {
|
|
1688
1688
|
const delegationRail = options.delegationRail ?? (await this.getAgent()).executionRail === "delegation";
|
|
1689
1689
|
if (!delegationRail) {
|
|
1690
|
-
throw new
|
|
1690
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1691
1691
|
"erc7710 settlement requires a delegation-rail account; this one is not on it. Use authorizeX402() for the standard EIP-3009 path.",
|
|
1692
1692
|
400
|
|
1693
1693
|
);
|
|
1694
1694
|
}
|
|
1695
|
-
const selection =
|
|
1695
|
+
const selection = chunkM57KOLAN_cjs.selectX402SettlementScheme(paymentRequired.accepts, { delegationRail });
|
|
1696
1696
|
if (!selection || selection.scheme !== "erc7710") {
|
|
1697
|
-
throw new
|
|
1697
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1698
1698
|
"This merchant does not advertise an erc7710 settlement option (no accepts[] entry carries extra.assetTransferMethod: 'erc7710'). Use authorizeX402() for the standard EIP-3009 path.",
|
|
1699
1699
|
400
|
|
1700
1700
|
);
|
|
1701
1701
|
}
|
|
1702
1702
|
const option = selection.option;
|
|
1703
1703
|
const merchantPayTo = option.payTo;
|
|
1704
|
-
const amountAtomic =
|
|
1704
|
+
const amountAtomic = chunkM57KOLAN_cjs.x402AuthorizationAmount(option);
|
|
1705
1705
|
const raw = await this.post("/x402", {
|
|
1706
1706
|
url: options.resourceUrl ?? paymentRequired.resource?.url,
|
|
1707
1707
|
// #2373: the full 402 challenge, persisted verbatim by the backend
|
|
@@ -1739,11 +1739,11 @@ var X402Erc7710 = class {
|
|
|
1739
1739
|
...options.mcpCallContext ? { mcpCallContext: options.mcpCallContext } : {}
|
|
1740
1740
|
});
|
|
1741
1741
|
if (!raw.payment_id) {
|
|
1742
|
-
throw new
|
|
1742
|
+
throw new chunkM57KOLAN_cjs.HavenApiError("No payment_id returned from x402/authorize", 500, raw);
|
|
1743
1743
|
}
|
|
1744
1744
|
const signData = raw.sign_data;
|
|
1745
1745
|
if (signData?.signature_scheme !== "eip712_delegation" || !signData.typed_data) {
|
|
1746
|
-
throw new
|
|
1746
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1747
1747
|
`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.`,
|
|
1748
1748
|
500,
|
|
1749
1749
|
raw
|
|
@@ -1776,7 +1776,7 @@ var X402Erc7710 = class {
|
|
|
1776
1776
|
{ signature }
|
|
1777
1777
|
);
|
|
1778
1778
|
if (!settled.payment_header) {
|
|
1779
|
-
throw new
|
|
1779
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1780
1780
|
"x402 settle returned no payment_header \u2014 the merchant cannot be retried.",
|
|
1781
1781
|
500,
|
|
1782
1782
|
settled
|
|
@@ -1823,7 +1823,7 @@ function x402ToolReceipt(receipt) {
|
|
|
1823
1823
|
};
|
|
1824
1824
|
}
|
|
1825
1825
|
function toolError(err) {
|
|
1826
|
-
if (err instanceof
|
|
1826
|
+
if (err instanceof chunkM57KOLAN_cjs.HavenPaymentStateError) {
|
|
1827
1827
|
return {
|
|
1828
1828
|
success: false,
|
|
1829
1829
|
payment_id: err.state.paymentId,
|
|
@@ -1868,7 +1868,7 @@ function toolError(err) {
|
|
|
1868
1868
|
error: err.message
|
|
1869
1869
|
};
|
|
1870
1870
|
}
|
|
1871
|
-
if (err instanceof
|
|
1871
|
+
if (err instanceof chunkM57KOLAN_cjs.HavenApiError) {
|
|
1872
1872
|
return {
|
|
1873
1873
|
success: false,
|
|
1874
1874
|
status_code: err.statusCode,
|
|
@@ -1905,10 +1905,10 @@ var MerchantCompletion = class {
|
|
|
1905
1905
|
}
|
|
1906
1906
|
async retryRequest(url, initialInit, paymentRequired, receipt) {
|
|
1907
1907
|
if (!receipt.accepted) {
|
|
1908
|
-
throw new
|
|
1908
|
+
throw new chunkM57KOLAN_cjs.HavenApiError("No accepted x402 option was recorded for payment retry", 500);
|
|
1909
1909
|
}
|
|
1910
1910
|
if (!receipt.paymentHeader) {
|
|
1911
|
-
throw new
|
|
1911
|
+
throw new chunkM57KOLAN_cjs.HavenApiError("No x402 payment header was returned for payment retry", 500);
|
|
1912
1912
|
}
|
|
1913
1913
|
const retryResponse = await this.merchantTransport.deliverPaymentRecoveringSession(
|
|
1914
1914
|
url,
|
|
@@ -1933,7 +1933,7 @@ var MerchantCompletion = class {
|
|
|
1933
1933
|
delegate_to: receipt.to
|
|
1934
1934
|
}
|
|
1935
1935
|
});
|
|
1936
|
-
throw new
|
|
1936
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
1937
1937
|
"x402 retry failed after Haven funded the delegate wallet; reconciliation may be required.",
|
|
1938
1938
|
inBandRejection ? X402_RETRY_REJECTED_STATUS : merchant.merchant_status,
|
|
1939
1939
|
{
|
|
@@ -1966,7 +1966,7 @@ var MerchantCompletion = class {
|
|
|
1966
1966
|
merchantStatus: retryResponse.status,
|
|
1967
1967
|
challengePayload: paymentRequired,
|
|
1968
1968
|
selectedPayment: receipt.accepted,
|
|
1969
|
-
paymentProofHeaderName:
|
|
1969
|
+
paymentProofHeaderName: chunkM57KOLAN_cjs.x402PaymentHeaderNamesSent(receipt.paymentHeader),
|
|
1970
1970
|
paymentProofHeader: receipt.paymentHeader,
|
|
1971
1971
|
protocolReceiptHeaderName,
|
|
1972
1972
|
protocolReceiptHeader
|
|
@@ -2007,18 +2007,18 @@ var MerchantCompletion = class {
|
|
|
2007
2007
|
async resolveCompletionContext(input) {
|
|
2008
2008
|
const status = await this.getPaymentStatus(input.paymentId);
|
|
2009
2009
|
if (status.rail !== "x402") {
|
|
2010
|
-
throw new
|
|
2010
|
+
throw new chunkM57KOLAN_cjs.HavenPaymentStateError(
|
|
2011
2011
|
`Payment ${status.paymentId} is ${status.rail}, not x402.`,
|
|
2012
2012
|
409,
|
|
2013
2013
|
status
|
|
2014
2014
|
);
|
|
2015
2015
|
}
|
|
2016
|
-
const readyForMerchantCompletion = input.noFundingLeg ? status.kind === "payment_intent" && status.status === "submitted" : status.nextAction ===
|
|
2016
|
+
const readyForMerchantCompletion = input.noFundingLeg ? status.kind === "payment_intent" && status.status === "submitted" : status.nextAction === chunkM57KOLAN_cjs.AgentPaymentNextAction.RetryOriginalX402Request || status.kind === "payment_intent" && status.status === "confirmed" && status.phase === chunkM57KOLAN_cjs.AgentPaymentPhase.PaymentConfirmed && status.nextAction === chunkM57KOLAN_cjs.AgentPaymentNextAction.None;
|
|
2017
2017
|
if (!readyForMerchantCompletion) {
|
|
2018
|
-
throw new
|
|
2018
|
+
throw new chunkM57KOLAN_cjs.HavenPaymentStateError(status.message, paymentStateStatusCode(status.status, 409), status);
|
|
2019
2019
|
}
|
|
2020
2020
|
if (!input.noFundingLeg && !status.txHash) {
|
|
2021
|
-
throw new
|
|
2021
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
2022
2022
|
`x402 payment ${status.paymentId} is ready for merchant completion but has no Haven transaction hash.`,
|
|
2023
2023
|
502,
|
|
2024
2024
|
status,
|
|
@@ -2027,7 +2027,7 @@ var MerchantCompletion = class {
|
|
|
2027
2027
|
}
|
|
2028
2028
|
const approvedResourceUrl = status.resourceUrl ?? status.x402?.resourceUrl ?? null;
|
|
2029
2029
|
if (approvedResourceUrl && approvedResourceUrl !== input.url) {
|
|
2030
|
-
throw new
|
|
2030
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
2031
2031
|
"x402 merchant completion does not match the approved resource URL.",
|
|
2032
2032
|
409,
|
|
2033
2033
|
{ status, url: input.url },
|
|
@@ -2113,7 +2113,7 @@ var MerchantCompletion = class {
|
|
|
2113
2113
|
*/
|
|
2114
2114
|
async reportMerchantOutcome(input) {
|
|
2115
2115
|
if (!Number.isInteger(input.merchantStatus) || input.merchantStatus < 100 || input.merchantStatus > 599) {
|
|
2116
|
-
throw new
|
|
2116
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
2117
2117
|
`merchant_status must be an integer HTTP status from 100 to 599 (received ${input.merchantStatus}).`,
|
|
2118
2118
|
400,
|
|
2119
2119
|
void 0,
|
|
@@ -2122,7 +2122,7 @@ var MerchantCompletion = class {
|
|
|
2122
2122
|
}
|
|
2123
2123
|
const looksAccepted = input.merchantStatus >= 200 && input.merchantStatus < 300;
|
|
2124
2124
|
if (looksAccepted !== (input.outcome === "accepted")) {
|
|
2125
|
-
throw new
|
|
2125
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
2126
2126
|
`outcome "${input.outcome}" contradicts merchant_status ${input.merchantStatus}: report "accepted" only for a 2xx and "rejected" only for a non-2xx.`,
|
|
2127
2127
|
400,
|
|
2128
2128
|
void 0,
|
|
@@ -2131,14 +2131,14 @@ var MerchantCompletion = class {
|
|
|
2131
2131
|
}
|
|
2132
2132
|
const status = await this.getPaymentStatus(input.paymentId);
|
|
2133
2133
|
if (status.rail !== "x402") {
|
|
2134
|
-
throw new
|
|
2134
|
+
throw new chunkM57KOLAN_cjs.HavenPaymentStateError(
|
|
2135
2135
|
`Payment ${status.paymentId} is ${status.rail}, not x402 \u2014 there is no merchant retry to report.`,
|
|
2136
2136
|
409,
|
|
2137
2137
|
status
|
|
2138
2138
|
);
|
|
2139
2139
|
}
|
|
2140
2140
|
if (status.status !== "confirmed" || !status.txHash) {
|
|
2141
|
-
throw new
|
|
2141
|
+
throw new chunkM57KOLAN_cjs.HavenPaymentStateError(
|
|
2142
2142
|
`Payment ${status.paymentId} has no confirmed Haven funding transaction to anchor a merchant report to (status ${status.status}). ${status.message}`,
|
|
2143
2143
|
paymentStateStatusCode(status.status, 409),
|
|
2144
2144
|
status
|
|
@@ -2146,7 +2146,7 @@ var MerchantCompletion = class {
|
|
|
2146
2146
|
}
|
|
2147
2147
|
const resourceUrl = status.resourceUrl ?? status.x402?.resourceUrl ?? null;
|
|
2148
2148
|
if (!resourceUrl) {
|
|
2149
|
-
throw new
|
|
2149
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
2150
2150
|
`Payment ${status.paymentId} has no recorded resource URL, so a merchant report cannot be stored.`,
|
|
2151
2151
|
409,
|
|
2152
2152
|
status,
|
|
@@ -2199,7 +2199,7 @@ var MerchantCompletion = class {
|
|
|
2199
2199
|
await this.post("/machine-payments/evidence", body);
|
|
2200
2200
|
return { outcome: "confirmed" };
|
|
2201
2201
|
} catch (err) {
|
|
2202
|
-
const statusCode = err instanceof
|
|
2202
|
+
const statusCode = err instanceof chunkM57KOLAN_cjs.HavenApiError ? err.statusCode : void 0;
|
|
2203
2203
|
const retryable = statusCode === EVIDENCE_RETRYABLE_STATUS;
|
|
2204
2204
|
if (!retryable) {
|
|
2205
2205
|
return { outcome: "refused", statusCode: statusCode ?? 0 };
|
|
@@ -2236,7 +2236,7 @@ var MerchantCompletion = class {
|
|
|
2236
2236
|
*/
|
|
2237
2237
|
async reportSettlementEvidence(paymentId, settlementTxHash) {
|
|
2238
2238
|
if (isZeroSettlementTxHash(settlementTxHash)) {
|
|
2239
|
-
throw new
|
|
2239
|
+
throw new chunkM57KOLAN_cjs.HavenZeroSettlementHashError(paymentId);
|
|
2240
2240
|
}
|
|
2241
2241
|
return this.reportEvidence({
|
|
2242
2242
|
paymentId,
|
|
@@ -2256,7 +2256,7 @@ function parseMerchantSettlement(header) {
|
|
|
2256
2256
|
}
|
|
2257
2257
|
function parseProtocolReceiptHeader(value) {
|
|
2258
2258
|
try {
|
|
2259
|
-
return
|
|
2259
|
+
return chunkM57KOLAN_cjs.decodeBase64Json(value);
|
|
2260
2260
|
} catch {
|
|
2261
2261
|
try {
|
|
2262
2262
|
return JSON.parse(value);
|
|
@@ -2273,7 +2273,7 @@ function x402TypedDataDigest(typedData) {
|
|
|
2273
2273
|
try {
|
|
2274
2274
|
return viem.hashTypedData(typedData);
|
|
2275
2275
|
} catch (err) {
|
|
2276
|
-
throw new
|
|
2276
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
2277
2277
|
`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)}`
|
|
2278
2278
|
);
|
|
2279
2279
|
}
|
|
@@ -2355,7 +2355,7 @@ var HavenClient = class {
|
|
|
2355
2355
|
});
|
|
2356
2356
|
this.x402Wallet = config.x402Wallet;
|
|
2357
2357
|
this.merchantTransport = new McpMerchantTransport({ merchantTimeout: config.merchantTimeout });
|
|
2358
|
-
this.confirmationTimeout = config.confirmationTimeout ??
|
|
2358
|
+
this.confirmationTimeout = config.confirmationTimeout ?? chunkM57KOLAN_cjs.DEFAULT_CONFIRMATION_TIMEOUT_MS;
|
|
2359
2359
|
this.pollingInterval = config.pollingInterval ?? DEFAULT_POLLING_INTERVAL;
|
|
2360
2360
|
this.chainRpcs = config.chainRpcs ?? {};
|
|
2361
2361
|
if (this.delegateKey) {
|
|
@@ -2415,7 +2415,7 @@ var HavenClient = class {
|
|
|
2415
2415
|
*/
|
|
2416
2416
|
async pay(request) {
|
|
2417
2417
|
if (!this.delegateKey) {
|
|
2418
|
-
throw new
|
|
2418
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
2419
2419
|
"Cannot use pay() without a delegateKey. Use createIntent() + submitSignature() for manual signing."
|
|
2420
2420
|
);
|
|
2421
2421
|
}
|
|
@@ -2464,15 +2464,15 @@ var HavenClient = class {
|
|
|
2464
2464
|
* on-chain allowance — there is nothing to sign until the user approves.
|
|
2465
2465
|
*/
|
|
2466
2466
|
async createX402Intent(paymentRequired, options = {}) {
|
|
2467
|
-
const option =
|
|
2467
|
+
const option = chunkM57KOLAN_cjs.selectStandardPaymentOption(paymentRequired.accepts);
|
|
2468
2468
|
if (!option) {
|
|
2469
2469
|
throw noCompatiblePaymentOptionError(paymentRequired.accepts);
|
|
2470
2470
|
}
|
|
2471
2471
|
const fundingTo = options.delegateAddress ?? (await this.getAgent()).delegateAddress;
|
|
2472
2472
|
if (!fundingTo) {
|
|
2473
|
-
throw new
|
|
2473
|
+
throw new chunkM57KOLAN_cjs.HavenApiError("Authenticated agent has no delegate address registered.", 502);
|
|
2474
2474
|
}
|
|
2475
|
-
const idempotencyKey = options.idempotencyKey ??
|
|
2475
|
+
const idempotencyKey = options.idempotencyKey ?? chunkM57KOLAN_cjs.buildX402IdempotencyKey(paymentRequired, option);
|
|
2476
2476
|
const raw = await this.post("/x402", {
|
|
2477
2477
|
url: paymentRequired.resource.url,
|
|
2478
2478
|
payTo: fundingTo,
|
|
@@ -2483,7 +2483,7 @@ var HavenClient = class {
|
|
|
2483
2483
|
// of a silent reroute to the erc7710 settlement branch (the #1358
|
|
2484
2484
|
// review's open-budget misroute). Legacy-rail backends ignore the field.
|
|
2485
2485
|
settlementScheme: "eip3009",
|
|
2486
|
-
amount:
|
|
2486
|
+
amount: chunkM57KOLAN_cjs.x402AuthorizationAmount(option),
|
|
2487
2487
|
asset: option.asset,
|
|
2488
2488
|
network: option.network,
|
|
2489
2489
|
description: paymentRequired.resource.description,
|
|
@@ -2501,15 +2501,15 @@ var HavenClient = class {
|
|
|
2501
2501
|
throwPaymentStateError("x402 payment", raw);
|
|
2502
2502
|
}
|
|
2503
2503
|
if (!raw.sign_data?.hash) {
|
|
2504
|
-
throw new
|
|
2504
|
+
throw new chunkM57KOLAN_cjs.HavenApiError("No sign_hash returned from x402/authorize", 500, raw);
|
|
2505
2505
|
}
|
|
2506
2506
|
if (raw.sign_data.signature_scheme !== void 0 && !raw.sign_data.typed_data) {
|
|
2507
|
-
throw new
|
|
2507
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
2508
2508
|
`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.`
|
|
2509
2509
|
);
|
|
2510
2510
|
}
|
|
2511
2511
|
if (!raw.x402_expected_auth) {
|
|
2512
|
-
throw new
|
|
2512
|
+
throw new chunkM57KOLAN_cjs.HavenApiError("No x402 expected-context binding returned from x402/authorize", 500, raw);
|
|
2513
2513
|
}
|
|
2514
2514
|
return {
|
|
2515
2515
|
paymentId: raw.payment_id,
|
|
@@ -2520,7 +2520,7 @@ var HavenClient = class {
|
|
|
2520
2520
|
accepted: option,
|
|
2521
2521
|
resourceUrl: paymentRequired.resource.url,
|
|
2522
2522
|
merchantTo: raw.merchant_to ?? option.payTo,
|
|
2523
|
-
amountAtomic:
|
|
2523
|
+
amountAtomic: chunkM57KOLAN_cjs.x402AuthorizationAmount(option),
|
|
2524
2524
|
asset: option.asset,
|
|
2525
2525
|
network: option.network,
|
|
2526
2526
|
expectedAuth: raw.x402_expected_auth,
|
|
@@ -2545,13 +2545,13 @@ var HavenClient = class {
|
|
|
2545
2545
|
*/
|
|
2546
2546
|
sign(hash) {
|
|
2547
2547
|
if (!this.delegateKey) {
|
|
2548
|
-
throw new
|
|
2548
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
2549
2549
|
"Cannot sign without a delegateKey. Pass the private key in HavenClient config, or sign externally."
|
|
2550
2550
|
);
|
|
2551
2551
|
}
|
|
2552
2552
|
const signature = signHash(this.delegateKey, hash);
|
|
2553
2553
|
if (!verifySignature(hash, signature, this.delegateAddress)) {
|
|
2554
|
-
throw new
|
|
2554
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
2555
2555
|
"Local signature verification failed \u2014 recovered address does not match delegate key."
|
|
2556
2556
|
);
|
|
2557
2557
|
}
|
|
@@ -2569,39 +2569,39 @@ var HavenClient = class {
|
|
|
2569
2569
|
*/
|
|
2570
2570
|
async signForData(signData) {
|
|
2571
2571
|
if (!this.delegateKey) {
|
|
2572
|
-
throw new
|
|
2572
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
2573
2573
|
"Cannot sign without a delegateKey. Pass the private key in HavenClient config, or sign externally."
|
|
2574
2574
|
);
|
|
2575
2575
|
}
|
|
2576
2576
|
const scheme = signData.signature_scheme;
|
|
2577
2577
|
if (scheme === "eip191_userop") {
|
|
2578
|
-
throw new
|
|
2578
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
2579
2579
|
"The session rail is retired \u2014 'eip191_userop' intents can no longer be signed. Re-onboard the account on the delegation rail."
|
|
2580
2580
|
);
|
|
2581
2581
|
}
|
|
2582
2582
|
if (scheme === "eip712_userop") {
|
|
2583
2583
|
if (!signData.typed_data) {
|
|
2584
|
-
throw new
|
|
2584
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
2585
2585
|
"sign_data.signature_scheme is eip712_userop but typed_data is missing \u2014 refusing to sign the bare hash (the account would reject it)."
|
|
2586
2586
|
);
|
|
2587
2587
|
}
|
|
2588
|
-
|
|
2588
|
+
chunkM57KOLAN_cjs.assertUserOpTypedDataBinding(signData.typed_data, signData.hash);
|
|
2589
2589
|
return signUserOpTypedDataForDelegation(this.delegateKey, signData.typed_data);
|
|
2590
2590
|
}
|
|
2591
2591
|
if (scheme === "eip712_delegation") {
|
|
2592
2592
|
if (!signData.typed_data) {
|
|
2593
|
-
throw new
|
|
2593
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
2594
2594
|
"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)."
|
|
2595
2595
|
);
|
|
2596
2596
|
}
|
|
2597
2597
|
return signSettlementDelegationTypedData(this.delegateKey, signData.typed_data);
|
|
2598
2598
|
}
|
|
2599
2599
|
if (scheme === void 0) {
|
|
2600
|
-
throw new
|
|
2600
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
2601
2601
|
"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."
|
|
2602
2602
|
);
|
|
2603
2603
|
}
|
|
2604
|
-
throw new
|
|
2604
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
2605
2605
|
`Unknown sign_data.signature_scheme '${scheme}' \u2014 refusing to guess a signing scheme. Update @haven_ai/sdk.`
|
|
2606
2606
|
);
|
|
2607
2607
|
}
|
|
@@ -2654,11 +2654,12 @@ var HavenClient = class {
|
|
|
2654
2654
|
return this.accountReads.getAgentSummary();
|
|
2655
2655
|
}
|
|
2656
2656
|
/**
|
|
2657
|
-
* Sweep stranded USDC and ETH from the delegate EOA back to the
|
|
2657
|
+
* Sweep stranded USDC and ETH from the delegate EOA back to the agent's Haven account.
|
|
2658
2658
|
*
|
|
2659
2659
|
* The delegate key held by this client signs and submits the transfer transactions
|
|
2660
2660
|
* directly — Haven's backend never handles the key or constructs signed txs
|
|
2661
|
-
* (CASP/MiCA Red Line #2). Funds always go to the
|
|
2661
|
+
* (CASP/MiCA Red Line #2). Funds always go to the Haven account linked to this agent
|
|
2662
|
+
* (`accountAddress` from `getAgent()`).
|
|
2662
2663
|
*
|
|
2663
2664
|
* Requires `chainRpcs` to be set for the agent's chain in `HavenClientConfig`.
|
|
2664
2665
|
*/
|
|
@@ -2784,7 +2785,7 @@ var HavenClient = class {
|
|
|
2784
2785
|
*/
|
|
2785
2786
|
async getPaymentStatusWithPostPurchaseAllowance(paymentId) {
|
|
2786
2787
|
const status = await this.getPaymentStatus(paymentId);
|
|
2787
|
-
if (status.rail ===
|
|
2788
|
+
if (status.rail === chunkM57KOLAN_cjs.AgentPaymentRail.X402 && status.phase === chunkM57KOLAN_cjs.AgentPaymentPhase.PaymentConfirmed) {
|
|
2788
2789
|
const { allowance, warnings } = await this.getPostPurchaseAllowanceSummary(paymentId);
|
|
2789
2790
|
return { ...status, allowance, ...warnings.length > 0 ? { warnings } : {} };
|
|
2790
2791
|
}
|
|
@@ -2892,7 +2893,7 @@ var HavenClient = class {
|
|
|
2892
2893
|
}
|
|
2893
2894
|
await sleep(this.pollingInterval);
|
|
2894
2895
|
}
|
|
2895
|
-
throw new
|
|
2896
|
+
throw new chunkM57KOLAN_cjs.HavenTimeoutError(paymentId);
|
|
2896
2897
|
}
|
|
2897
2898
|
// ── x402 Protocol Support ────────────────────────────────────────
|
|
2898
2899
|
/**
|
|
@@ -2906,18 +2907,18 @@ var HavenClient = class {
|
|
|
2906
2907
|
*/
|
|
2907
2908
|
async authorizeX402(paymentRequired, options = {}) {
|
|
2908
2909
|
if (!this.delegateKey) {
|
|
2909
|
-
throw new
|
|
2910
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
2910
2911
|
"delegateKey is required for x402 payments. Pass it in the HavenClient config."
|
|
2911
2912
|
);
|
|
2912
2913
|
}
|
|
2913
2914
|
if (!this.delegateAddress) {
|
|
2914
|
-
throw new
|
|
2915
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError("delegateAddress could not be derived from delegateKey.");
|
|
2915
2916
|
}
|
|
2916
|
-
const option =
|
|
2917
|
+
const option = chunkM57KOLAN_cjs.selectStandardPaymentOption(paymentRequired.accepts);
|
|
2917
2918
|
if (!option) {
|
|
2918
2919
|
throw noCompatiblePaymentOptionError(paymentRequired.accepts);
|
|
2919
2920
|
}
|
|
2920
|
-
const idempotencyKey = options.idempotencyKey ??
|
|
2921
|
+
const idempotencyKey = options.idempotencyKey ?? chunkM57KOLAN_cjs.buildX402IdempotencyKey(paymentRequired, option);
|
|
2921
2922
|
const cached = this.fundingLeg.cachedReceipt(idempotencyKey);
|
|
2922
2923
|
if (cached) return cached;
|
|
2923
2924
|
const inFlight = this.inFlightX402.get(idempotencyKey);
|
|
@@ -2957,16 +2958,16 @@ var HavenClient = class {
|
|
|
2957
2958
|
} catch {
|
|
2958
2959
|
body = void 0;
|
|
2959
2960
|
}
|
|
2960
|
-
throw new
|
|
2961
|
+
throw new chunkM57KOLAN_cjs.X402UnexpectedStatusError(
|
|
2961
2962
|
`Expected an x402 quote response with HTTP 402, got HTTP ${response.status}.`,
|
|
2962
2963
|
response.status || 400,
|
|
2963
2964
|
body
|
|
2964
2965
|
);
|
|
2965
2966
|
}
|
|
2966
2967
|
if (response.headers.get("MACHINE-PAYMENT-CHALLENGE")) {
|
|
2967
|
-
throw new
|
|
2968
|
+
throw new chunkM57KOLAN_cjs.HavenApiError("quoteX402 only supports standard x402 Payment Required responses.", 400);
|
|
2968
2969
|
}
|
|
2969
|
-
const paymentRequired = await
|
|
2970
|
+
const paymentRequired = await chunkM57KOLAN_cjs.parsePaymentRequiredResponse(response);
|
|
2970
2971
|
const mcpTransport = await this.merchantTransport.detect(url, paymentRequired, response);
|
|
2971
2972
|
return buildX402Quote(paymentRequired, request, options.idempotencyKey, mcpTransport);
|
|
2972
2973
|
}
|
|
@@ -2984,7 +2985,7 @@ var HavenClient = class {
|
|
|
2984
2985
|
const wallet = await this.merchantCompletion.resolveWalletForMerchantCall();
|
|
2985
2986
|
const sessionId = await this.merchantTransport.initialize(url, init, wallet);
|
|
2986
2987
|
if (!sessionId) {
|
|
2987
|
-
throw new
|
|
2988
|
+
throw new chunkM57KOLAN_cjs.HavenApiError(
|
|
2988
2989
|
"The merchant did not establish an MCP session before the x402 quote. No payment was created.",
|
|
2989
2990
|
502,
|
|
2990
2991
|
{ mcpSessionNotEstablished: true }
|
|
@@ -3058,18 +3059,18 @@ var HavenClient = class {
|
|
|
3058
3059
|
}
|
|
3059
3060
|
async resumeAuthorizedX402(input) {
|
|
3060
3061
|
if (!this.delegateKey) {
|
|
3061
|
-
throw new
|
|
3062
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError(
|
|
3062
3063
|
"delegateKey is required for x402 payments. Pass it in the HavenClient config."
|
|
3063
3064
|
);
|
|
3064
3065
|
}
|
|
3065
3066
|
if (!this.delegateAddress) {
|
|
3066
|
-
throw new
|
|
3067
|
+
throw new chunkM57KOLAN_cjs.HavenSigningError("delegateAddress could not be derived from delegateKey.");
|
|
3067
3068
|
}
|
|
3068
|
-
const option =
|
|
3069
|
+
const option = chunkM57KOLAN_cjs.selectStandardPaymentOption(input.paymentRequired.accepts);
|
|
3069
3070
|
if (!option) {
|
|
3070
3071
|
throw noCompatiblePaymentOptionError(input.paymentRequired.accepts);
|
|
3071
3072
|
}
|
|
3072
|
-
const idempotencyKey = input.idempotencyKey ??
|
|
3073
|
+
const idempotencyKey = input.idempotencyKey ?? chunkM57KOLAN_cjs.buildX402IdempotencyKey(input.paymentRequired, option);
|
|
3073
3074
|
const cached = this.fundingLeg.cachedReceipt(idempotencyKey);
|
|
3074
3075
|
if (cached) return cached;
|
|
3075
3076
|
const status = await this.getPaymentStatus(input.paymentId);
|
|
@@ -3077,10 +3078,10 @@ var HavenClient = class {
|
|
|
3077
3078
|
const canFund = await this.fundingLeg.delegateCanFund(
|
|
3078
3079
|
status.chainId ?? chainIdFromNetwork(option.network),
|
|
3079
3080
|
option.asset,
|
|
3080
|
-
|
|
3081
|
+
chunkM57KOLAN_cjs.x402AuthorizationAmount(option)
|
|
3081
3082
|
);
|
|
3082
3083
|
if (canFund === false) {
|
|
3083
|
-
throw new
|
|
3084
|
+
throw new chunkM57KOLAN_cjs.X402AlreadySettledError(
|
|
3084
3085
|
`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.`,
|
|
3085
3086
|
this.fundingLeg.receiptFromStatus(input.paymentRequired, option, void 0, status),
|
|
3086
3087
|
"settled"
|
|
@@ -3101,13 +3102,13 @@ var HavenClient = class {
|
|
|
3101
3102
|
const url = input.url ?? input.request?.url;
|
|
3102
3103
|
if (!paymentRequired) {
|
|
3103
3104
|
if (!url) {
|
|
3104
|
-
throw new
|
|
3105
|
+
throw new chunkM57KOLAN_cjs.HavenApiError("x402 resume requires the original URL or a captured request snapshot.", 400);
|
|
3105
3106
|
}
|
|
3106
3107
|
const response = await this.merchantTransport.fetch(url, initialInit);
|
|
3107
3108
|
if (response.status !== 402) {
|
|
3108
|
-
throw new
|
|
3109
|
+
throw new chunkM57KOLAN_cjs.HavenApiError("Expected the original x402 request to return HTTP 402 before resuming.", 400);
|
|
3109
3110
|
}
|
|
3110
|
-
paymentRequired = await
|
|
3111
|
+
paymentRequired = await chunkM57KOLAN_cjs.parsePaymentRequiredResponse(response);
|
|
3111
3112
|
}
|
|
3112
3113
|
const receipt = await this.resumeAuthorizedX402({
|
|
3113
3114
|
paymentId: input.paymentId,
|
|
@@ -3160,7 +3161,7 @@ var HavenClient = class {
|
|
|
3160
3161
|
nativeChallenge = true;
|
|
3161
3162
|
} else {
|
|
3162
3163
|
try {
|
|
3163
|
-
paymentRequired = await
|
|
3164
|
+
paymentRequired = await chunkM57KOLAN_cjs.parsePaymentRequiredResponse(response);
|
|
3164
3165
|
} catch {
|
|
3165
3166
|
return response;
|
|
3166
3167
|
}
|
|
@@ -3170,8 +3171,8 @@ var HavenClient = class {
|
|
|
3170
3171
|
if (mcpSessionId) requestInit = this.merchantTransport.withSessionHeaders(requestInit, mcpSessionId);
|
|
3171
3172
|
}
|
|
3172
3173
|
const request = snapshotX402Request(url, requestInit);
|
|
3173
|
-
const option =
|
|
3174
|
-
const idempotencyKey = options.idempotencyKey ?? (option ?
|
|
3174
|
+
const option = chunkM57KOLAN_cjs.selectStandardPaymentOption(paymentRequired.accepts);
|
|
3175
|
+
const idempotencyKey = options.idempotencyKey ?? (option ? chunkM57KOLAN_cjs.buildX402IdempotencyKey(paymentRequired, option) : void 0);
|
|
3175
3176
|
let receipt;
|
|
3176
3177
|
try {
|
|
3177
3178
|
receipt = await this.authorizeX402(paymentRequired, options);
|
|
@@ -3208,7 +3209,7 @@ var HavenClient = class {
|
|
|
3208
3209
|
* collapses an SSE JSON-RPC response to its `result`.
|
|
3209
3210
|
*/
|
|
3210
3211
|
/**
|
|
3211
|
-
* Wait for a payment's
|
|
3212
|
+
* Wait for a payment's account→delegate funding tx to reach ≥1 on-chain
|
|
3212
3213
|
* confirmation. The hosted x402 completion path MUST call this after funding
|
|
3213
3214
|
* and before delivering the merchant payment header, so the merchant's
|
|
3214
3215
|
* balanceOf(delegate) / transferWithAuthorization verification sees the funded
|
|
@@ -3298,7 +3299,7 @@ var HavenClient = class {
|
|
|
3298
3299
|
txHash: evidenceTxHash,
|
|
3299
3300
|
resourceUrl: evidenceContext.resourceUrl,
|
|
3300
3301
|
merchantStatus: surfaced.status,
|
|
3301
|
-
paymentProofHeaderName:
|
|
3302
|
+
paymentProofHeaderName: chunkM57KOLAN_cjs.x402PaymentHeaderNamesSent(input.paymentHeader),
|
|
3302
3303
|
paymentProofHeader: input.paymentHeader,
|
|
3303
3304
|
protocolReceiptHeaderName,
|
|
3304
3305
|
protocolReceiptHeader
|
|
@@ -4295,391 +4296,391 @@ function sameUrl(a, b) {
|
|
|
4295
4296
|
|
|
4296
4297
|
Object.defineProperty(exports, "AGENT_PAYMENT_FAILURE_CODE_VALUES", {
|
|
4297
4298
|
enumerable: true,
|
|
4298
|
-
get: function () { return
|
|
4299
|
+
get: function () { return chunkM57KOLAN_cjs.AGENT_PAYMENT_FAILURE_CODE_VALUES; }
|
|
4299
4300
|
});
|
|
4300
4301
|
Object.defineProperty(exports, "AGENT_PAYMENT_NEXT_ACTION_VALUES", {
|
|
4301
4302
|
enumerable: true,
|
|
4302
|
-
get: function () { return
|
|
4303
|
+
get: function () { return chunkM57KOLAN_cjs.AGENT_PAYMENT_NEXT_ACTION_VALUES; }
|
|
4303
4304
|
});
|
|
4304
4305
|
Object.defineProperty(exports, "AGENT_PAYMENT_PHASE_VALUES", {
|
|
4305
4306
|
enumerable: true,
|
|
4306
|
-
get: function () { return
|
|
4307
|
+
get: function () { return chunkM57KOLAN_cjs.AGENT_PAYMENT_PHASE_VALUES; }
|
|
4307
4308
|
});
|
|
4308
4309
|
Object.defineProperty(exports, "AGENT_PAYMENT_RAIL_VALUES", {
|
|
4309
4310
|
enumerable: true,
|
|
4310
|
-
get: function () { return
|
|
4311
|
+
get: function () { return chunkM57KOLAN_cjs.AGENT_PAYMENT_RAIL_VALUES; }
|
|
4311
4312
|
});
|
|
4312
4313
|
Object.defineProperty(exports, "AgentPaymentFailureCode", {
|
|
4313
4314
|
enumerable: true,
|
|
4314
|
-
get: function () { return
|
|
4315
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentFailureCode; }
|
|
4315
4316
|
});
|
|
4316
4317
|
Object.defineProperty(exports, "AgentPaymentFailureCodeDescriptions", {
|
|
4317
4318
|
enumerable: true,
|
|
4318
|
-
get: function () { return
|
|
4319
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentFailureCodeDescriptions; }
|
|
4319
4320
|
});
|
|
4320
4321
|
Object.defineProperty(exports, "AgentPaymentFailureCodeSchema", {
|
|
4321
4322
|
enumerable: true,
|
|
4322
|
-
get: function () { return
|
|
4323
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentFailureCodeSchema; }
|
|
4323
4324
|
});
|
|
4324
4325
|
Object.defineProperty(exports, "AgentPaymentNextAction", {
|
|
4325
4326
|
enumerable: true,
|
|
4326
|
-
get: function () { return
|
|
4327
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentNextAction; }
|
|
4327
4328
|
});
|
|
4328
4329
|
Object.defineProperty(exports, "AgentPaymentNextActionDescriptions", {
|
|
4329
4330
|
enumerable: true,
|
|
4330
|
-
get: function () { return
|
|
4331
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentNextActionDescriptions; }
|
|
4331
4332
|
});
|
|
4332
4333
|
Object.defineProperty(exports, "AgentPaymentNextActionSchema", {
|
|
4333
4334
|
enumerable: true,
|
|
4334
|
-
get: function () { return
|
|
4335
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentNextActionSchema; }
|
|
4335
4336
|
});
|
|
4336
4337
|
Object.defineProperty(exports, "AgentPaymentPhase", {
|
|
4337
4338
|
enumerable: true,
|
|
4338
|
-
get: function () { return
|
|
4339
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentPhase; }
|
|
4339
4340
|
});
|
|
4340
4341
|
Object.defineProperty(exports, "AgentPaymentPhaseDescriptions", {
|
|
4341
4342
|
enumerable: true,
|
|
4342
|
-
get: function () { return
|
|
4343
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentPhaseDescriptions; }
|
|
4343
4344
|
});
|
|
4344
4345
|
Object.defineProperty(exports, "AgentPaymentPhaseSchema", {
|
|
4345
4346
|
enumerable: true,
|
|
4346
|
-
get: function () { return
|
|
4347
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentPhaseSchema; }
|
|
4347
4348
|
});
|
|
4348
4349
|
Object.defineProperty(exports, "AgentPaymentRail", {
|
|
4349
4350
|
enumerable: true,
|
|
4350
|
-
get: function () { return
|
|
4351
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentRail; }
|
|
4351
4352
|
});
|
|
4352
4353
|
Object.defineProperty(exports, "AgentPaymentRailDescriptions", {
|
|
4353
4354
|
enumerable: true,
|
|
4354
|
-
get: function () { return
|
|
4355
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentRailDescriptions; }
|
|
4355
4356
|
});
|
|
4356
4357
|
Object.defineProperty(exports, "AgentPaymentRailSchema", {
|
|
4357
4358
|
enumerable: true,
|
|
4358
|
-
get: function () { return
|
|
4359
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentRailSchema; }
|
|
4359
4360
|
});
|
|
4360
4361
|
Object.defineProperty(exports, "AgentPaymentWarningCode", {
|
|
4361
4362
|
enumerable: true,
|
|
4362
|
-
get: function () { return
|
|
4363
|
+
get: function () { return chunkM57KOLAN_cjs.AgentPaymentWarningCode; }
|
|
4363
4364
|
});
|
|
4364
4365
|
Object.defineProperty(exports, "CONNECTOR_PACKAGE_NAME", {
|
|
4365
4366
|
enumerable: true,
|
|
4366
|
-
get: function () { return
|
|
4367
|
+
get: function () { return chunkM57KOLAN_cjs.CONNECTOR_PACKAGE_NAME; }
|
|
4367
4368
|
});
|
|
4368
4369
|
Object.defineProperty(exports, "DEFAULT_CONFIRMATION_TIMEOUT_MS", {
|
|
4369
4370
|
enumerable: true,
|
|
4370
|
-
get: function () { return
|
|
4371
|
+
get: function () { return chunkM57KOLAN_cjs.DEFAULT_CONFIRMATION_TIMEOUT_MS; }
|
|
4371
4372
|
});
|
|
4372
4373
|
Object.defineProperty(exports, "DEFAULT_NEXT_TOOL_BY_ACTION", {
|
|
4373
4374
|
enumerable: true,
|
|
4374
|
-
get: function () { return
|
|
4375
|
+
get: function () { return chunkM57KOLAN_cjs.DEFAULT_NEXT_TOOL_BY_ACTION; }
|
|
4375
4376
|
});
|
|
4376
4377
|
Object.defineProperty(exports, "DIRECT_SIGN_CONTEXT_VERSION", {
|
|
4377
4378
|
enumerable: true,
|
|
4378
|
-
get: function () { return
|
|
4379
|
+
get: function () { return chunkM57KOLAN_cjs.DIRECT_SIGN_CONTEXT_VERSION; }
|
|
4379
4380
|
});
|
|
4380
4381
|
Object.defineProperty(exports, "ENTRY_POINT_V07", {
|
|
4381
4382
|
enumerable: true,
|
|
4382
|
-
get: function () { return
|
|
4383
|
+
get: function () { return chunkM57KOLAN_cjs.ENTRY_POINT_V07; }
|
|
4383
4384
|
});
|
|
4384
4385
|
Object.defineProperty(exports, "ERC7710_ASSET_TRANSFER_METHOD", {
|
|
4385
4386
|
enumerable: true,
|
|
4386
|
-
get: function () { return
|
|
4387
|
+
get: function () { return chunkM57KOLAN_cjs.ERC7710_ASSET_TRANSFER_METHOD; }
|
|
4387
4388
|
});
|
|
4388
4389
|
Object.defineProperty(exports, "HAVEN_CONNECTOR_CHANNEL", {
|
|
4389
4390
|
enumerable: true,
|
|
4390
|
-
get: function () { return
|
|
4391
|
+
get: function () { return chunkM57KOLAN_cjs.HAVEN_CONNECTOR_CHANNEL; }
|
|
4391
4392
|
});
|
|
4392
4393
|
Object.defineProperty(exports, "HAVEN_MINIMUM_NODE_VERSION", {
|
|
4393
4394
|
enumerable: true,
|
|
4394
|
-
get: function () { return
|
|
4395
|
+
get: function () { return chunkM57KOLAN_cjs.HAVEN_MINIMUM_NODE_VERSION; }
|
|
4395
4396
|
});
|
|
4396
4397
|
Object.defineProperty(exports, "HYBRID_DELEGATOR_DOMAIN_NAME", {
|
|
4397
4398
|
enumerable: true,
|
|
4398
|
-
get: function () { return
|
|
4399
|
+
get: function () { return chunkM57KOLAN_cjs.HYBRID_DELEGATOR_DOMAIN_NAME; }
|
|
4399
4400
|
});
|
|
4400
4401
|
Object.defineProperty(exports, "HYBRID_DELEGATOR_DOMAIN_VERSION", {
|
|
4401
4402
|
enumerable: true,
|
|
4402
|
-
get: function () { return
|
|
4403
|
+
get: function () { return chunkM57KOLAN_cjs.HYBRID_DELEGATOR_DOMAIN_VERSION; }
|
|
4403
4404
|
});
|
|
4404
4405
|
Object.defineProperty(exports, "HavenApiError", {
|
|
4405
4406
|
enumerable: true,
|
|
4406
|
-
get: function () { return
|
|
4407
|
+
get: function () { return chunkM57KOLAN_cjs.HavenApiError; }
|
|
4407
4408
|
});
|
|
4408
4409
|
Object.defineProperty(exports, "HavenError", {
|
|
4409
4410
|
enumerable: true,
|
|
4410
|
-
get: function () { return
|
|
4411
|
+
get: function () { return chunkM57KOLAN_cjs.HavenError; }
|
|
4411
4412
|
});
|
|
4412
4413
|
Object.defineProperty(exports, "HavenPaymentStateError", {
|
|
4413
4414
|
enumerable: true,
|
|
4414
|
-
get: function () { return
|
|
4415
|
+
get: function () { return chunkM57KOLAN_cjs.HavenPaymentStateError; }
|
|
4415
4416
|
});
|
|
4416
4417
|
Object.defineProperty(exports, "HavenSigningError", {
|
|
4417
4418
|
enumerable: true,
|
|
4418
|
-
get: function () { return
|
|
4419
|
+
get: function () { return chunkM57KOLAN_cjs.HavenSigningError; }
|
|
4419
4420
|
});
|
|
4420
4421
|
Object.defineProperty(exports, "HavenTimeoutError", {
|
|
4421
4422
|
enumerable: true,
|
|
4422
|
-
get: function () { return
|
|
4423
|
+
get: function () { return chunkM57KOLAN_cjs.HavenTimeoutError; }
|
|
4423
4424
|
});
|
|
4424
4425
|
Object.defineProperty(exports, "HavenUnsupportedSignerVersionError", {
|
|
4425
4426
|
enumerable: true,
|
|
4426
|
-
get: function () { return
|
|
4427
|
+
get: function () { return chunkM57KOLAN_cjs.HavenUnsupportedSignerVersionError; }
|
|
4427
4428
|
});
|
|
4428
4429
|
Object.defineProperty(exports, "HavenUserOpBindingError", {
|
|
4429
4430
|
enumerable: true,
|
|
4430
|
-
get: function () { return
|
|
4431
|
+
get: function () { return chunkM57KOLAN_cjs.HavenUserOpBindingError; }
|
|
4431
4432
|
});
|
|
4432
4433
|
Object.defineProperty(exports, "HavenZeroSettlementHashError", {
|
|
4433
4434
|
enumerable: true,
|
|
4434
|
-
get: function () { return
|
|
4435
|
+
get: function () { return chunkM57KOLAN_cjs.HavenZeroSettlementHashError; }
|
|
4435
4436
|
});
|
|
4436
4437
|
Object.defineProperty(exports, "MerchantTimeoutError", {
|
|
4437
4438
|
enumerable: true,
|
|
4438
|
-
get: function () { return
|
|
4439
|
+
get: function () { return chunkM57KOLAN_cjs.MerchantTimeoutError; }
|
|
4439
4440
|
});
|
|
4440
4441
|
Object.defineProperty(exports, "NEXT_TOOL_SERVER_NAMES", {
|
|
4441
4442
|
enumerable: true,
|
|
4442
|
-
get: function () { return
|
|
4443
|
+
get: function () { return chunkM57KOLAN_cjs.NEXT_TOOL_SERVER_NAMES; }
|
|
4443
4444
|
});
|
|
4444
4445
|
Object.defineProperty(exports, "NEXT_TOOL_SERVER_ROLES", {
|
|
4445
4446
|
enumerable: true,
|
|
4446
|
-
get: function () { return
|
|
4447
|
+
get: function () { return chunkM57KOLAN_cjs.NEXT_TOOL_SERVER_ROLES; }
|
|
4447
4448
|
});
|
|
4448
4449
|
Object.defineProperty(exports, "PACKED_USER_OPERATION_FIELDS", {
|
|
4449
4450
|
enumerable: true,
|
|
4450
|
-
get: function () { return
|
|
4451
|
+
get: function () { return chunkM57KOLAN_cjs.PACKED_USER_OPERATION_FIELDS; }
|
|
4451
4452
|
});
|
|
4452
4453
|
Object.defineProperty(exports, "SIGNER_UPDATE_FALLBACK", {
|
|
4453
4454
|
enumerable: true,
|
|
4454
|
-
get: function () { return
|
|
4455
|
+
get: function () { return chunkM57KOLAN_cjs.SIGNER_UPDATE_FALLBACK; }
|
|
4455
4456
|
});
|
|
4456
4457
|
Object.defineProperty(exports, "SWEEP_BASE_CHAIN_ID", {
|
|
4457
4458
|
enumerable: true,
|
|
4458
|
-
get: function () { return
|
|
4459
|
+
get: function () { return chunkM57KOLAN_cjs.SWEEP_BASE_CHAIN_ID; }
|
|
4459
4460
|
});
|
|
4460
4461
|
Object.defineProperty(exports, "SWEEP_BASE_SEPOLIA_CHAIN_ID", {
|
|
4461
4462
|
enumerable: true,
|
|
4462
|
-
get: function () { return
|
|
4463
|
+
get: function () { return chunkM57KOLAN_cjs.SWEEP_BASE_SEPOLIA_CHAIN_ID; }
|
|
4463
4464
|
});
|
|
4464
4465
|
Object.defineProperty(exports, "SWEEP_BASE_SEPOLIA_USDC_ADDRESS", {
|
|
4465
4466
|
enumerable: true,
|
|
4466
|
-
get: function () { return
|
|
4467
|
+
get: function () { return chunkM57KOLAN_cjs.SWEEP_BASE_SEPOLIA_USDC_ADDRESS; }
|
|
4467
4468
|
});
|
|
4468
4469
|
Object.defineProperty(exports, "SWEEP_BASE_USDC_ADDRESS", {
|
|
4469
4470
|
enumerable: true,
|
|
4470
|
-
get: function () { return
|
|
4471
|
+
get: function () { return chunkM57KOLAN_cjs.SWEEP_BASE_USDC_ADDRESS; }
|
|
4471
4472
|
});
|
|
4472
4473
|
Object.defineProperty(exports, "SignerRefusalCode", {
|
|
4473
4474
|
enumerable: true,
|
|
4474
|
-
get: function () { return
|
|
4475
|
+
get: function () { return chunkM57KOLAN_cjs.SignerRefusalCode; }
|
|
4475
4476
|
});
|
|
4476
4477
|
Object.defineProperty(exports, "TRANSFER_WITH_AUTHORIZATION_TYPES", {
|
|
4477
4478
|
enumerable: true,
|
|
4478
|
-
get: function () { return
|
|
4479
|
+
get: function () { return chunkM57KOLAN_cjs.TRANSFER_WITH_AUTHORIZATION_TYPES; }
|
|
4479
4480
|
});
|
|
4480
4481
|
Object.defineProperty(exports, "X402AlreadySettledError", {
|
|
4481
4482
|
enumerable: true,
|
|
4482
|
-
get: function () { return
|
|
4483
|
+
get: function () { return chunkM57KOLAN_cjs.X402AlreadySettledError; }
|
|
4483
4484
|
});
|
|
4484
4485
|
Object.defineProperty(exports, "X402PaymentHeaderValidationError", {
|
|
4485
4486
|
enumerable: true,
|
|
4486
|
-
get: function () { return
|
|
4487
|
+
get: function () { return chunkM57KOLAN_cjs.X402PaymentHeaderValidationError; }
|
|
4487
4488
|
});
|
|
4488
4489
|
Object.defineProperty(exports, "X402UnexpectedStatusError", {
|
|
4489
4490
|
enumerable: true,
|
|
4490
|
-
get: function () { return
|
|
4491
|
+
get: function () { return chunkM57KOLAN_cjs.X402UnexpectedStatusError; }
|
|
4491
4492
|
});
|
|
4492
4493
|
Object.defineProperty(exports, "X402_LEGACY_PAYMENT_HEADER_NAME", {
|
|
4493
4494
|
enumerable: true,
|
|
4494
|
-
get: function () { return
|
|
4495
|
+
get: function () { return chunkM57KOLAN_cjs.X402_LEGACY_PAYMENT_HEADER_NAME; }
|
|
4495
4496
|
});
|
|
4496
4497
|
Object.defineProperty(exports, "X402_MAX_AUTHORIZATION_WINDOW_SECONDS", {
|
|
4497
4498
|
enumerable: true,
|
|
4498
|
-
get: function () { return
|
|
4499
|
+
get: function () { return chunkM57KOLAN_cjs.X402_MAX_AUTHORIZATION_WINDOW_SECONDS; }
|
|
4499
4500
|
});
|
|
4500
4501
|
Object.defineProperty(exports, "X402_PAYMENT_HEADER_NAME", {
|
|
4501
4502
|
enumerable: true,
|
|
4502
|
-
get: function () { return
|
|
4503
|
+
get: function () { return chunkM57KOLAN_cjs.X402_PAYMENT_HEADER_NAME; }
|
|
4503
4504
|
});
|
|
4504
4505
|
Object.defineProperty(exports, "X402_PAYMENT_HEADER_NAMES_SENT", {
|
|
4505
4506
|
enumerable: true,
|
|
4506
|
-
get: function () { return
|
|
4507
|
+
get: function () { return chunkM57KOLAN_cjs.X402_PAYMENT_HEADER_NAMES_SENT; }
|
|
4507
4508
|
});
|
|
4508
4509
|
Object.defineProperty(exports, "X402_PAYMENT_REQUIRED_HEADER_NAME", {
|
|
4509
4510
|
enumerable: true,
|
|
4510
|
-
get: function () { return
|
|
4511
|
+
get: function () { return chunkM57KOLAN_cjs.X402_PAYMENT_REQUIRED_HEADER_NAME; }
|
|
4511
4512
|
});
|
|
4512
4513
|
Object.defineProperty(exports, "X402_PAYMENT_RESPONSE_HEADER_NAME", {
|
|
4513
4514
|
enumerable: true,
|
|
4514
|
-
get: function () { return
|
|
4515
|
+
get: function () { return chunkM57KOLAN_cjs.X402_PAYMENT_RESPONSE_HEADER_NAME; }
|
|
4515
4516
|
});
|
|
4516
4517
|
Object.defineProperty(exports, "X402_SETTLEMENT_FORWARD_MARGIN_SECONDS", {
|
|
4517
4518
|
enumerable: true,
|
|
4518
|
-
get: function () { return
|
|
4519
|
+
get: function () { return chunkM57KOLAN_cjs.X402_SETTLEMENT_FORWARD_MARGIN_SECONDS; }
|
|
4519
4520
|
});
|
|
4520
4521
|
Object.defineProperty(exports, "assertUserOpTypedDataBinding", {
|
|
4521
4522
|
enumerable: true,
|
|
4522
|
-
get: function () { return
|
|
4523
|
+
get: function () { return chunkM57KOLAN_cjs.assertUserOpTypedDataBinding; }
|
|
4523
4524
|
});
|
|
4524
4525
|
Object.defineProperty(exports, "buildSweepAuthorizationMessage", {
|
|
4525
4526
|
enumerable: true,
|
|
4526
|
-
get: function () { return
|
|
4527
|
+
get: function () { return chunkM57KOLAN_cjs.buildSweepAuthorizationMessage; }
|
|
4527
4528
|
});
|
|
4528
4529
|
Object.defineProperty(exports, "buildSweepTypedData", {
|
|
4529
4530
|
enumerable: true,
|
|
4530
|
-
get: function () { return
|
|
4531
|
+
get: function () { return chunkM57KOLAN_cjs.buildSweepTypedData; }
|
|
4531
4532
|
});
|
|
4532
4533
|
Object.defineProperty(exports, "buildX402ExpectedMessage", {
|
|
4533
4534
|
enumerable: true,
|
|
4534
|
-
get: function () { return
|
|
4535
|
+
get: function () { return chunkM57KOLAN_cjs.buildX402ExpectedMessage; }
|
|
4535
4536
|
});
|
|
4536
4537
|
Object.defineProperty(exports, "compareNodeVersions", {
|
|
4537
4538
|
enumerable: true,
|
|
4538
|
-
get: function () { return
|
|
4539
|
+
get: function () { return chunkM57KOLAN_cjs.compareNodeVersions; }
|
|
4539
4540
|
});
|
|
4540
4541
|
Object.defineProperty(exports, "connectorRerunCommand", {
|
|
4541
4542
|
enumerable: true,
|
|
4542
|
-
get: function () { return
|
|
4543
|
+
get: function () { return chunkM57KOLAN_cjs.connectorRerunCommand; }
|
|
4543
4544
|
});
|
|
4544
4545
|
Object.defineProperty(exports, "connectorSpec", {
|
|
4545
4546
|
enumerable: true,
|
|
4546
|
-
get: function () { return
|
|
4547
|
+
get: function () { return chunkM57KOLAN_cjs.connectorSpec; }
|
|
4547
4548
|
});
|
|
4548
4549
|
Object.defineProperty(exports, "createNextStepBuilder", {
|
|
4549
4550
|
enumerable: true,
|
|
4550
|
-
get: function () { return
|
|
4551
|
+
get: function () { return chunkM57KOLAN_cjs.createNextStepBuilder; }
|
|
4551
4552
|
});
|
|
4552
4553
|
Object.defineProperty(exports, "decodeBase64Json", {
|
|
4553
4554
|
enumerable: true,
|
|
4554
|
-
get: function () { return
|
|
4555
|
+
get: function () { return chunkM57KOLAN_cjs.decodeBase64Json; }
|
|
4555
4556
|
});
|
|
4556
4557
|
Object.defineProperty(exports, "decodeBase64Utf8", {
|
|
4557
4558
|
enumerable: true,
|
|
4558
|
-
get: function () { return
|
|
4559
|
+
get: function () { return chunkM57KOLAN_cjs.decodeBase64Utf8; }
|
|
4559
4560
|
});
|
|
4560
4561
|
Object.defineProperty(exports, "defaultNextToolFor", {
|
|
4561
4562
|
enumerable: true,
|
|
4562
|
-
get: function () { return
|
|
4563
|
+
get: function () { return chunkM57KOLAN_cjs.defaultNextToolFor; }
|
|
4563
4564
|
});
|
|
4564
4565
|
Object.defineProperty(exports, "encodeBase64Json", {
|
|
4565
4566
|
enumerable: true,
|
|
4566
|
-
get: function () { return
|
|
4567
|
+
get: function () { return chunkM57KOLAN_cjs.encodeBase64Json; }
|
|
4567
4568
|
});
|
|
4568
4569
|
Object.defineProperty(exports, "encodeBase64Utf8", {
|
|
4569
4570
|
enumerable: true,
|
|
4570
|
-
get: function () { return
|
|
4571
|
+
get: function () { return chunkM57KOLAN_cjs.encodeBase64Utf8; }
|
|
4571
4572
|
});
|
|
4572
4573
|
Object.defineProperty(exports, "encodePaymentProof", {
|
|
4573
4574
|
enumerable: true,
|
|
4574
|
-
get: function () { return
|
|
4575
|
+
get: function () { return chunkM57KOLAN_cjs.encodePaymentProof; }
|
|
4575
4576
|
});
|
|
4576
4577
|
Object.defineProperty(exports, "isConnectorChannel", {
|
|
4577
4578
|
enumerable: true,
|
|
4578
|
-
get: function () { return
|
|
4579
|
+
get: function () { return chunkM57KOLAN_cjs.isConnectorChannel; }
|
|
4579
4580
|
});
|
|
4580
4581
|
Object.defineProperty(exports, "isErc7710Option", {
|
|
4581
4582
|
enumerable: true,
|
|
4582
|
-
get: function () { return
|
|
4583
|
+
get: function () { return chunkM57KOLAN_cjs.isErc7710Option; }
|
|
4583
4584
|
});
|
|
4584
4585
|
Object.defineProperty(exports, "isPackedUserOperationTypedData", {
|
|
4585
4586
|
enumerable: true,
|
|
4586
|
-
get: function () { return
|
|
4587
|
+
get: function () { return chunkM57KOLAN_cjs.isPackedUserOperationTypedData; }
|
|
4587
4588
|
});
|
|
4588
4589
|
Object.defineProperty(exports, "isSupportedNodeVersion", {
|
|
4589
4590
|
enumerable: true,
|
|
4590
|
-
get: function () { return
|
|
4591
|
+
get: function () { return chunkM57KOLAN_cjs.isSupportedNodeVersion; }
|
|
4591
4592
|
});
|
|
4592
4593
|
Object.defineProperty(exports, "isSweepableChain", {
|
|
4593
4594
|
enumerable: true,
|
|
4594
|
-
get: function () { return
|
|
4595
|
+
get: function () { return chunkM57KOLAN_cjs.isSweepableChain; }
|
|
4595
4596
|
});
|
|
4596
4597
|
Object.defineProperty(exports, "normalizePaymentRequired", {
|
|
4597
4598
|
enumerable: true,
|
|
4598
|
-
get: function () { return
|
|
4599
|
+
get: function () { return chunkM57KOLAN_cjs.normalizePaymentRequired; }
|
|
4599
4600
|
});
|
|
4600
4601
|
Object.defineProperty(exports, "packedUserOperationHash", {
|
|
4601
4602
|
enumerable: true,
|
|
4602
|
-
get: function () { return
|
|
4603
|
+
get: function () { return chunkM57KOLAN_cjs.packedUserOperationHash; }
|
|
4603
4604
|
});
|
|
4604
4605
|
Object.defineProperty(exports, "parseNextTool", {
|
|
4605
4606
|
enumerable: true,
|
|
4606
|
-
get: function () { return
|
|
4607
|
+
get: function () { return chunkM57KOLAN_cjs.parseNextTool; }
|
|
4607
4608
|
});
|
|
4608
4609
|
Object.defineProperty(exports, "parsePaymentRequired", {
|
|
4609
4610
|
enumerable: true,
|
|
4610
|
-
get: function () { return
|
|
4611
|
+
get: function () { return chunkM57KOLAN_cjs.parsePaymentRequired; }
|
|
4611
4612
|
});
|
|
4612
4613
|
Object.defineProperty(exports, "parsePaymentRequiredResponse", {
|
|
4613
4614
|
enumerable: true,
|
|
4614
|
-
get: function () { return
|
|
4615
|
+
get: function () { return chunkM57KOLAN_cjs.parsePaymentRequiredResponse; }
|
|
4615
4616
|
});
|
|
4616
4617
|
Object.defineProperty(exports, "renderNextTool", {
|
|
4617
4618
|
enumerable: true,
|
|
4618
|
-
get: function () { return
|
|
4619
|
+
get: function () { return chunkM57KOLAN_cjs.renderNextTool; }
|
|
4619
4620
|
});
|
|
4620
4621
|
Object.defineProperty(exports, "resolveConnectorChannel", {
|
|
4621
4622
|
enumerable: true,
|
|
4622
|
-
get: function () { return
|
|
4623
|
+
get: function () { return chunkM57KOLAN_cjs.resolveConnectorChannel; }
|
|
4623
4624
|
});
|
|
4624
4625
|
Object.defineProperty(exports, "resolveTokenFromAddress", {
|
|
4625
4626
|
enumerable: true,
|
|
4626
|
-
get: function () { return
|
|
4627
|
+
get: function () { return chunkM57KOLAN_cjs.resolveTokenFromAddress; }
|
|
4627
4628
|
});
|
|
4628
4629
|
Object.defineProperty(exports, "selectErc7710PaymentOption", {
|
|
4629
4630
|
enumerable: true,
|
|
4630
|
-
get: function () { return
|
|
4631
|
+
get: function () { return chunkM57KOLAN_cjs.selectErc7710PaymentOption; }
|
|
4631
4632
|
});
|
|
4632
4633
|
Object.defineProperty(exports, "selectPaymentOption", {
|
|
4633
4634
|
enumerable: true,
|
|
4634
|
-
get: function () { return
|
|
4635
|
+
get: function () { return chunkM57KOLAN_cjs.selectPaymentOption; }
|
|
4635
4636
|
});
|
|
4636
4637
|
Object.defineProperty(exports, "selectStandardPaymentOption", {
|
|
4637
4638
|
enumerable: true,
|
|
4638
|
-
get: function () { return
|
|
4639
|
+
get: function () { return chunkM57KOLAN_cjs.selectStandardPaymentOption; }
|
|
4639
4640
|
});
|
|
4640
4641
|
Object.defineProperty(exports, "selectX402SettlementScheme", {
|
|
4641
4642
|
enumerable: true,
|
|
4642
|
-
get: function () { return
|
|
4643
|
+
get: function () { return chunkM57KOLAN_cjs.selectX402SettlementScheme; }
|
|
4643
4644
|
});
|
|
4644
4645
|
Object.defineProperty(exports, "signerUpdateFallback", {
|
|
4645
4646
|
enumerable: true,
|
|
4646
|
-
get: function () { return
|
|
4647
|
+
get: function () { return chunkM57KOLAN_cjs.signerUpdateFallback; }
|
|
4647
4648
|
});
|
|
4648
4649
|
Object.defineProperty(exports, "sweepUsdcAddress", {
|
|
4649
4650
|
enumerable: true,
|
|
4650
|
-
get: function () { return
|
|
4651
|
+
get: function () { return chunkM57KOLAN_cjs.sweepUsdcAddress; }
|
|
4651
4652
|
});
|
|
4652
4653
|
Object.defineProperty(exports, "sweepUsdcDomain", {
|
|
4653
4654
|
enumerable: true,
|
|
4654
|
-
get: function () { return
|
|
4655
|
+
get: function () { return chunkM57KOLAN_cjs.sweepUsdcDomain; }
|
|
4655
4656
|
});
|
|
4656
4657
|
Object.defineProperty(exports, "toStandardPaymentRequirements", {
|
|
4657
4658
|
enumerable: true,
|
|
4658
|
-
get: function () { return
|
|
4659
|
+
get: function () { return chunkM57KOLAN_cjs.toStandardPaymentRequirements; }
|
|
4659
4660
|
});
|
|
4660
4661
|
Object.defineProperty(exports, "unsupportedNodeVersionMessage", {
|
|
4661
4662
|
enumerable: true,
|
|
4662
|
-
get: function () { return
|
|
4663
|
+
get: function () { return chunkM57KOLAN_cjs.unsupportedNodeVersionMessage; }
|
|
4663
4664
|
});
|
|
4664
4665
|
Object.defineProperty(exports, "validateStandardX402PaymentHeader", {
|
|
4665
4666
|
enumerable: true,
|
|
4666
|
-
get: function () { return
|
|
4667
|
+
get: function () { return chunkM57KOLAN_cjs.validateStandardX402PaymentHeader; }
|
|
4667
4668
|
});
|
|
4668
4669
|
Object.defineProperty(exports, "x402AssetTransferMethod", {
|
|
4669
4670
|
enumerable: true,
|
|
4670
|
-
get: function () { return
|
|
4671
|
+
get: function () { return chunkM57KOLAN_cjs.x402AssetTransferMethod; }
|
|
4671
4672
|
});
|
|
4672
4673
|
Object.defineProperty(exports, "x402AuthorizationAmount", {
|
|
4673
4674
|
enumerable: true,
|
|
4674
|
-
get: function () { return
|
|
4675
|
+
get: function () { return chunkM57KOLAN_cjs.x402AuthorizationAmount; }
|
|
4675
4676
|
});
|
|
4676
4677
|
Object.defineProperty(exports, "x402FacilitatorAddresses", {
|
|
4677
4678
|
enumerable: true,
|
|
4678
|
-
get: function () { return
|
|
4679
|
+
get: function () { return chunkM57KOLAN_cjs.x402FacilitatorAddresses; }
|
|
4679
4680
|
});
|
|
4680
4681
|
Object.defineProperty(exports, "x402V2PaymentEnvelope", {
|
|
4681
4682
|
enumerable: true,
|
|
4682
|
-
get: function () { return
|
|
4683
|
+
get: function () { return chunkM57KOLAN_cjs.x402V2PaymentEnvelope; }
|
|
4683
4684
|
});
|
|
4684
4685
|
exports.AGENT_APPROVAL_RELAY_JSON_SENTENCE = AGENT_APPROVAL_RELAY_JSON_SENTENCE;
|
|
4685
4686
|
exports.AGENT_APPROVAL_RELAY_PROSE_SENTENCE = AGENT_APPROVAL_RELAY_PROSE_SENTENCE;
|