@t2000/cli 10.13.1 → 10.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-I6UGZOTH.js → chunk-M3VP3LAY.js} +38 -7
- package/dist/{chunk-I6UGZOTH.js.map → chunk-M3VP3LAY.js.map} +1 -1
- package/dist/{dist-G2XQHKA6.js → dist-4BBYOHH2.js} +2 -2
- package/dist/{dist-GIJDTUKJ.js → dist-QEBZPEX3.js} +41 -10
- package/dist/{dist-GIJDTUKJ.js.map → dist-QEBZPEX3.js.map} +1 -1
- package/dist/index.js +3 -3
- package/package.json +4 -4
- /package/dist/{dist-G2XQHKA6.js.map → dist-4BBYOHH2.js.map} +0 -0
|
@@ -9981,8 +9981,9 @@ async function payWithMpp(args) {
|
|
|
9981
9981
|
if (probe.status !== 402) {
|
|
9982
9982
|
return finalize(probe, { paid: false });
|
|
9983
9983
|
}
|
|
9984
|
-
const
|
|
9985
|
-
if (
|
|
9984
|
+
const pick = await pickSuiExactRequirements(probe, client.network);
|
|
9985
|
+
if (pick.kind === "payable") {
|
|
9986
|
+
const requirements = pick.requirements;
|
|
9986
9987
|
const { isX402EscrowRequirements } = await import("./x402-N4N7VWNW.js");
|
|
9987
9988
|
if (isX402EscrowRequirements(requirements)) {
|
|
9988
9989
|
const escrow = requirements.extra.escrow;
|
|
@@ -10015,6 +10016,13 @@ async function payWithMpp(args) {
|
|
|
10015
10016
|
await reportDirectPayment(result, options.url);
|
|
10016
10017
|
return result;
|
|
10017
10018
|
}
|
|
10019
|
+
if (pick.kind === "incomplete") {
|
|
10020
|
+
throw new T2000Error(
|
|
10021
|
+
"FACILITATOR_REJECTION",
|
|
10022
|
+
"Seller's x402 challenge is incomplete (missing extra.suimpp) \u2014 nothing was paid. The 402 advertises an exact/sui entry but carries no settlement challenge to bind a payment to; the seller must emit the createX402Requirements shape to be x402-payable.",
|
|
10023
|
+
{ reason: "incomplete-x402-accepts" }
|
|
10024
|
+
);
|
|
10025
|
+
}
|
|
10018
10026
|
throw new T2000Error(
|
|
10019
10027
|
"FACILITATOR_REJECTION",
|
|
10020
10028
|
`Endpoint returned 402 without an x402 'exact' / sui:${client.network} requirement in the body or an MPP 'sui' challenge in WWW-Authenticate. Nothing this SDK can pay.`
|
|
@@ -10053,17 +10061,34 @@ async function parseMppSuiChallenge(response) {
|
|
|
10053
10061
|
return void 0;
|
|
10054
10062
|
}
|
|
10055
10063
|
}
|
|
10064
|
+
function hasCompleteSuimppChallenge(entry) {
|
|
10065
|
+
const s = entry.extra?.suimpp;
|
|
10066
|
+
return !!s && typeof s.challengeId === "string" && s.challengeId.length > 0 && typeof s.nonce === "number" && typeof s.chain === "string" && s.chain.length > 0 && typeof s.minEpoch === "string" && typeof s.maxEpoch === "string";
|
|
10067
|
+
}
|
|
10056
10068
|
async function pickSuiExactRequirements(response, network) {
|
|
10057
10069
|
try {
|
|
10058
10070
|
const body2 = await response.clone().json();
|
|
10059
10071
|
const want = `sui:${network === "testnet" ? "testnet" : "mainnet"}`;
|
|
10060
|
-
|
|
10072
|
+
const entry = body2.accepts?.find((a) => a.scheme === "exact" && a.network === want);
|
|
10073
|
+
if (!entry) return { kind: "none" };
|
|
10074
|
+
const { isX402EscrowRequirements } = await import("./x402-N4N7VWNW.js");
|
|
10075
|
+
if (hasCompleteSuimppChallenge(entry) || isX402EscrowRequirements(entry)) {
|
|
10076
|
+
return { kind: "payable", requirements: entry };
|
|
10077
|
+
}
|
|
10078
|
+
return { kind: "incomplete" };
|
|
10061
10079
|
} catch {
|
|
10062
|
-
return
|
|
10080
|
+
return { kind: "none" };
|
|
10063
10081
|
}
|
|
10064
10082
|
}
|
|
10065
10083
|
async function payViaX402(args) {
|
|
10066
10084
|
const { signer, client, options, reqInit, requirements } = args;
|
|
10085
|
+
if (!hasCompleteSuimppChallenge(requirements)) {
|
|
10086
|
+
throw new T2000Error(
|
|
10087
|
+
"FACILITATOR_REJECTION",
|
|
10088
|
+
"Seller's x402 challenge is incomplete (missing extra.suimpp) \u2014 nothing was paid.",
|
|
10089
|
+
{ reason: "incomplete-x402-accepts" }
|
|
10090
|
+
);
|
|
10091
|
+
}
|
|
10067
10092
|
const { buildX402SignedPayment, X402_PAYMENT_HEADER, X402_PAYMENT_RESPONSE_HEADER } = await import("./x402-N4N7VWNW.js");
|
|
10068
10093
|
const amountRaw = BigInt(requirements.maxAmountRequired);
|
|
10069
10094
|
assertWithinMaxPrice(atomicToHuman(amountRaw, await assetDecimals(requirements.asset)), options.maxPrice);
|
|
@@ -12241,7 +12266,12 @@ function requirementFieldMap(listing) {
|
|
|
12241
12266
|
return listing;
|
|
12242
12267
|
}
|
|
12243
12268
|
function requirementHint(value) {
|
|
12244
|
-
|
|
12269
|
+
if (typeof value === "string") return value;
|
|
12270
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
12271
|
+
const desc = value.description;
|
|
12272
|
+
if (typeof desc === "string" && desc.trim().length > 0) return desc;
|
|
12273
|
+
}
|
|
12274
|
+
return JSON.stringify(value);
|
|
12245
12275
|
}
|
|
12246
12276
|
function isPlainObject(value) {
|
|
12247
12277
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -12252,7 +12282,8 @@ function assertBuyerRequirements(listingRequirements, buyerPayload) {
|
|
|
12252
12282
|
}
|
|
12253
12283
|
if (isPlainObject(listingRequirements)) {
|
|
12254
12284
|
const fields = requirementFieldMap(listingRequirements);
|
|
12255
|
-
const
|
|
12285
|
+
const requiredRaw = listingRequirements.required;
|
|
12286
|
+
const keys = isPlainObject(listingRequirements.properties) && Array.isArray(requiredRaw) && requiredRaw.every((k) => typeof k === "string") ? requiredRaw : Object.keys(fields);
|
|
12256
12287
|
if (keys.length === 0) {
|
|
12257
12288
|
return;
|
|
12258
12289
|
}
|
|
@@ -13314,4 +13345,4 @@ export {
|
|
|
13314
13345
|
@scure/bip39/index.js:
|
|
13315
13346
|
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
13316
13347
|
*/
|
|
13317
|
-
//# sourceMappingURL=chunk-
|
|
13348
|
+
//# sourceMappingURL=chunk-M3VP3LAY.js.map
|