@mysten-incubation/suipay-buyer 0.4.0-dev.7 → 0.4.0-dev.9
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-ITZ6QTFI.js → chunk-RWUAPD7K.js} +11 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +33 -10
- package/dist/{native-transfer-DspFvMQc.d.ts → native-transfer-DWs55Mse.d.ts} +11 -1
- package/dist/native-transfer.d.ts +1 -1
- package/dist/native-transfer.js +1 -1
- package/package.json +3 -3
|
@@ -869,7 +869,7 @@ var DELIVERY_CODES = {
|
|
|
869
869
|
user: { title: "Something went wrong", message: "No result came back from the service." }
|
|
870
870
|
},
|
|
871
871
|
"delivery.seller_timeout": {
|
|
872
|
-
surfaces: ["gateway"],
|
|
872
|
+
surfaces: ["gateway", "sdk", "mcp_local", "mcp_hosted"],
|
|
873
873
|
status: 504,
|
|
874
874
|
title: "Seller timed out after payment",
|
|
875
875
|
paymentState: "charged",
|
|
@@ -1110,6 +1110,16 @@ var INDEXER_CODES = {
|
|
|
1110
1110
|
nextAction: "contact_support",
|
|
1111
1111
|
user: null,
|
|
1112
1112
|
logOnly: true
|
|
1113
|
+
},
|
|
1114
|
+
"indexer.unsettled_delivery": {
|
|
1115
|
+
surfaces: ["indexer"],
|
|
1116
|
+
status: null,
|
|
1117
|
+
title: "Delivered call has no matching on-chain settlement",
|
|
1118
|
+
paymentState: "not_charged",
|
|
1119
|
+
retry: "never",
|
|
1120
|
+
nextAction: "contact_support",
|
|
1121
|
+
user: null,
|
|
1122
|
+
logOnly: true
|
|
1113
1123
|
}
|
|
1114
1124
|
};
|
|
1115
1125
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as ErrorCode, P as PaymentState, N as NextAction, R as Receipt, C as CodeFor, D as DelegationScope, O as Offer } from './native-transfer-
|
|
2
|
-
export { B as BuildNativeTransferInput, M as McpPaymentSigner, a as NativeTransferAccept, b as NativeTransferBuild, c as NativeTransferError, d as NativeTransferGas, e as NativeTransferSignerInput, S as SuiPayError, f as SuiPayErrorFields, g as buildMcpPaymentPayload, h as buildNativeTransferBytes, i as createNativeTransferSigner, j as inspectNativeTransfer, t as toErrorFields } from './native-transfer-
|
|
1
|
+
import { E as ErrorCode, P as PaymentState, N as NextAction, R as Receipt, C as CodeFor, D as DelegationScope, O as Offer } from './native-transfer-DWs55Mse.js';
|
|
2
|
+
export { B as BuildNativeTransferInput, M as McpPaymentSigner, a as NativeTransferAccept, b as NativeTransferBuild, c as NativeTransferError, d as NativeTransferGas, e as NativeTransferSignerInput, S as SuiPayError, f as SuiPayErrorFields, g as buildMcpPaymentPayload, h as buildNativeTransferBytes, i as createNativeTransferSigner, j as inspectNativeTransfer, t as toErrorFields } from './native-transfer-DWs55Mse.js';
|
|
3
3
|
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
4
4
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
5
5
|
import { KeyObject } from 'node:crypto';
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
parseErrorPayload,
|
|
14
14
|
stricterPaymentState,
|
|
15
15
|
toErrorFields
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-RWUAPD7K.js";
|
|
17
17
|
|
|
18
18
|
// src/mcp.ts
|
|
19
19
|
async function buildMcpPaymentPayload(paymentRequired, signer) {
|
|
@@ -2988,6 +2988,25 @@ var SERVICE_STATE_TRANSITIONS = Object.freeze([
|
|
|
2988
2988
|
to: "none",
|
|
2989
2989
|
actors: ["system"],
|
|
2990
2990
|
requires: ["reason_code"]
|
|
2991
|
+
},
|
|
2992
|
+
// System listing moves for permissionless services: auto-list after
|
|
2993
|
+
// proof-of-settle (never lifts an operator delist) and reset to unlisted
|
|
2994
|
+
// when a revision changes the published seller URL.
|
|
2995
|
+
{
|
|
2996
|
+
id: "T26",
|
|
2997
|
+
dimension: "listing",
|
|
2998
|
+
from: ["unlisted"],
|
|
2999
|
+
to: "listed",
|
|
3000
|
+
actors: ["system"],
|
|
3001
|
+
requires: ["admission_admitted"]
|
|
3002
|
+
},
|
|
3003
|
+
{
|
|
3004
|
+
id: "T27",
|
|
3005
|
+
dimension: "listing",
|
|
3006
|
+
from: ["listed"],
|
|
3007
|
+
to: "unlisted",
|
|
3008
|
+
actors: ["system"],
|
|
3009
|
+
requires: ["reason_code"]
|
|
2991
3010
|
}
|
|
2992
3011
|
]);
|
|
2993
3012
|
|
|
@@ -8158,6 +8177,8 @@ var DELEGATED_PAY_ERROR_CODE_SET = new Set(Object.values(DELEGATED_PAY_ERROR_COD
|
|
|
8158
8177
|
function isDelegatedPayErrorCode(value) {
|
|
8159
8178
|
return typeof value === "string" && DELEGATED_PAY_ERROR_CODE_SET.has(value);
|
|
8160
8179
|
}
|
|
8180
|
+
var DELIVERY_SELLER_TIMEOUT_DETAIL = "Gateway timed out waiting for the paid service to deliver.";
|
|
8181
|
+
var EXECUTE_TIMEOUT_DETAIL = "Gateway timed out before confirming whether payment settled; check status before retrying.";
|
|
8161
8182
|
var PUBLIC_DETAIL = {
|
|
8162
8183
|
OFFER_SECRET_REQUIRED: "offer verification material is unavailable",
|
|
8163
8184
|
CHALLENGE_TAMPERED: "offer digest does not verify",
|
|
@@ -8324,14 +8345,15 @@ function withReconcileKeys(error, extras) {
|
|
|
8324
8345
|
};
|
|
8325
8346
|
}
|
|
8326
8347
|
async function gatewayDeliveryFailure(response, log, local) {
|
|
8348
|
+
const timedOut = response.status === 504;
|
|
8327
8349
|
const result = gatewayFailure(await readGatewayAnswer(response), {
|
|
8328
|
-
code: DELEGATED_PAY_CODES[local.code],
|
|
8350
|
+
code: timedOut ? "delivery.seller_timeout" : DELEGATED_PAY_CODES[local.code],
|
|
8329
8351
|
paymentState: "charged",
|
|
8330
|
-
detail: PUBLIC_DETAIL[local.code]
|
|
8352
|
+
detail: timedOut ? DELIVERY_SELLER_TIMEOUT_DETAIL : PUBLIC_DETAIL[local.code]
|
|
8331
8353
|
}, { paymentId: local.paymentId, txDigest: local.txDigest, settlement: local.settlement });
|
|
8332
8354
|
logInternal(log, {
|
|
8333
|
-
code: "delivery.proof_rejected",
|
|
8334
|
-
msg: "gateway did not deliver after settlement",
|
|
8355
|
+
code: timedOut ? "delivery.seller_timeout" : "delivery.proof_rejected",
|
|
8356
|
+
msg: timedOut ? "gateway timed out delivering after settlement" : "gateway did not deliver after settlement",
|
|
8335
8357
|
context: {
|
|
8336
8358
|
status: response.status,
|
|
8337
8359
|
header: response.headers.get(ERROR_CODE_HEADER),
|
|
@@ -9995,22 +10017,23 @@ async function recordX402Answer(ctx, answer) {
|
|
|
9995
10017
|
if (answer.kind === "undelivered") {
|
|
9996
10018
|
const stated = parseErrorPayload(answer.answer)?.paymentState;
|
|
9997
10019
|
const charged = answer.receipt !== null || stated === "charged";
|
|
10020
|
+
const timedOut = answer.answer.status === 504;
|
|
9998
10021
|
const settlement2 = answer.receipt ? { ...ctx.settlement, txDigest: answer.receipt.txDigest } : void 0;
|
|
9999
10022
|
const result = gatewayFailure(answer.answer, charged ? {
|
|
10000
|
-
code: DELEGATED_PAY_CODES.GATEWAY_REFUSED,
|
|
10023
|
+
code: timedOut ? "delivery.seller_timeout" : DELEGATED_PAY_CODES.GATEWAY_REFUSED,
|
|
10001
10024
|
paymentState: "charged",
|
|
10002
|
-
detail: PUBLIC_DETAIL.GATEWAY_REFUSED
|
|
10025
|
+
detail: timedOut ? DELIVERY_SELLER_TIMEOUT_DETAIL : PUBLIC_DETAIL.GATEWAY_REFUSED
|
|
10003
10026
|
} : {
|
|
10004
10027
|
code: DELEGATED_PAY_CODES.EXECUTE_AMBIGUOUS,
|
|
10005
10028
|
paymentState: "unknown",
|
|
10006
|
-
detail: PUBLIC_DETAIL.EXECUTE_AMBIGUOUS
|
|
10029
|
+
detail: timedOut ? EXECUTE_TIMEOUT_DETAIL : PUBLIC_DETAIL.EXECUTE_AMBIGUOUS
|
|
10007
10030
|
}, {
|
|
10008
10031
|
paymentId,
|
|
10009
10032
|
...settlement2 ? { txDigest: settlement2.txDigest, settlement: settlement2 } : answer.txDigest ? { txDigest: answer.txDigest } : {}
|
|
10010
10033
|
});
|
|
10011
10034
|
logInternal(log, {
|
|
10012
|
-
code: "delivery.proof_rejected",
|
|
10013
|
-
msg: "gateway did not deliver against an x402 credential",
|
|
10035
|
+
code: charged && timedOut ? "delivery.seller_timeout" : "delivery.proof_rejected",
|
|
10036
|
+
msg: charged && timedOut ? "gateway timed out delivering against an x402 credential" : "gateway did not deliver against an x402 credential",
|
|
10014
10037
|
context: { status: answer.answer.status, code: result.code }
|
|
10015
10038
|
});
|
|
10016
10039
|
return completeAttempt(ledger, paymentId, result, log);
|
|
@@ -160,6 +160,16 @@ declare const ERRORS: {
|
|
|
160
160
|
readonly user: null;
|
|
161
161
|
readonly logOnly: true;
|
|
162
162
|
};
|
|
163
|
+
readonly 'indexer.unsettled_delivery': {
|
|
164
|
+
readonly surfaces: readonly ["indexer"];
|
|
165
|
+
readonly status: null;
|
|
166
|
+
readonly title: "Delivered call has no matching on-chain settlement";
|
|
167
|
+
readonly paymentState: "not_charged";
|
|
168
|
+
readonly retry: "never";
|
|
169
|
+
readonly nextAction: "contact_support";
|
|
170
|
+
readonly user: null;
|
|
171
|
+
readonly logOnly: true;
|
|
172
|
+
};
|
|
163
173
|
readonly 'client.agent_handoff_failed': {
|
|
164
174
|
readonly surfaces: readonly ["browser", "mcp_local"];
|
|
165
175
|
readonly status: null;
|
|
@@ -1252,7 +1262,7 @@ declare const ERRORS: {
|
|
|
1252
1262
|
};
|
|
1253
1263
|
};
|
|
1254
1264
|
readonly 'delivery.seller_timeout': {
|
|
1255
|
-
readonly surfaces: readonly ["gateway"];
|
|
1265
|
+
readonly surfaces: readonly ["gateway", "sdk", "mcp_local", "mcp_hosted"];
|
|
1256
1266
|
readonly status: 504;
|
|
1257
1267
|
readonly title: "Seller timed out after payment";
|
|
1258
1268
|
readonly paymentState: "charged";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '@mysten/sui/client';
|
|
2
|
-
export { B as BuildNativeTransferInput, a as NativeTransferAccept, b as NativeTransferBuild, c as NativeTransferError, k as NativeTransferErrorCode, d as NativeTransferGas, e as NativeTransferSignerInput, h as buildNativeTransferBytes, i as createNativeTransferSigner, j as inspectNativeTransfer } from './native-transfer-
|
|
2
|
+
export { B as BuildNativeTransferInput, a as NativeTransferAccept, b as NativeTransferBuild, c as NativeTransferError, k as NativeTransferErrorCode, d as NativeTransferGas, e as NativeTransferSignerInput, h as buildNativeTransferBytes, i as createNativeTransferSigner, j as inspectNativeTransfer } from './native-transfer-DWs55Mse.js';
|
package/dist/native-transfer.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mysten-incubation/suipay-buyer",
|
|
3
|
-
"version": "0.4.0-dev.
|
|
3
|
+
"version": "0.4.0-dev.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "SuiPay buyer SDK — delegated spend-account pay plus a typed /v1 control-plane client.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"tsup": "^8.0.0",
|
|
41
41
|
"typescript": "^6.0.3",
|
|
42
42
|
"vitest": "^4.1.10",
|
|
43
|
-
"@cmdoss/suipay-
|
|
44
|
-
"@cmdoss/suipay-
|
|
43
|
+
"@cmdoss/suipay-sdk": "0.1.0",
|
|
44
|
+
"@cmdoss/suipay-core": "0.1.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsup",
|