@mysten-incubation/suipay-buyer 0.4.0-dev.8 → 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 +14 -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) {
|
|
@@ -8177,6 +8177,8 @@ var DELEGATED_PAY_ERROR_CODE_SET = new Set(Object.values(DELEGATED_PAY_ERROR_COD
|
|
|
8177
8177
|
function isDelegatedPayErrorCode(value) {
|
|
8178
8178
|
return typeof value === "string" && DELEGATED_PAY_ERROR_CODE_SET.has(value);
|
|
8179
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.";
|
|
8180
8182
|
var PUBLIC_DETAIL = {
|
|
8181
8183
|
OFFER_SECRET_REQUIRED: "offer verification material is unavailable",
|
|
8182
8184
|
CHALLENGE_TAMPERED: "offer digest does not verify",
|
|
@@ -8343,14 +8345,15 @@ function withReconcileKeys(error, extras) {
|
|
|
8343
8345
|
};
|
|
8344
8346
|
}
|
|
8345
8347
|
async function gatewayDeliveryFailure(response, log, local) {
|
|
8348
|
+
const timedOut = response.status === 504;
|
|
8346
8349
|
const result = gatewayFailure(await readGatewayAnswer(response), {
|
|
8347
|
-
code: DELEGATED_PAY_CODES[local.code],
|
|
8350
|
+
code: timedOut ? "delivery.seller_timeout" : DELEGATED_PAY_CODES[local.code],
|
|
8348
8351
|
paymentState: "charged",
|
|
8349
|
-
detail: PUBLIC_DETAIL[local.code]
|
|
8352
|
+
detail: timedOut ? DELIVERY_SELLER_TIMEOUT_DETAIL : PUBLIC_DETAIL[local.code]
|
|
8350
8353
|
}, { paymentId: local.paymentId, txDigest: local.txDigest, settlement: local.settlement });
|
|
8351
8354
|
logInternal(log, {
|
|
8352
|
-
code: "delivery.proof_rejected",
|
|
8353
|
-
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",
|
|
8354
8357
|
context: {
|
|
8355
8358
|
status: response.status,
|
|
8356
8359
|
header: response.headers.get(ERROR_CODE_HEADER),
|
|
@@ -10014,22 +10017,23 @@ async function recordX402Answer(ctx, answer) {
|
|
|
10014
10017
|
if (answer.kind === "undelivered") {
|
|
10015
10018
|
const stated = parseErrorPayload(answer.answer)?.paymentState;
|
|
10016
10019
|
const charged = answer.receipt !== null || stated === "charged";
|
|
10020
|
+
const timedOut = answer.answer.status === 504;
|
|
10017
10021
|
const settlement2 = answer.receipt ? { ...ctx.settlement, txDigest: answer.receipt.txDigest } : void 0;
|
|
10018
10022
|
const result = gatewayFailure(answer.answer, charged ? {
|
|
10019
|
-
code: DELEGATED_PAY_CODES.GATEWAY_REFUSED,
|
|
10023
|
+
code: timedOut ? "delivery.seller_timeout" : DELEGATED_PAY_CODES.GATEWAY_REFUSED,
|
|
10020
10024
|
paymentState: "charged",
|
|
10021
|
-
detail: PUBLIC_DETAIL.GATEWAY_REFUSED
|
|
10025
|
+
detail: timedOut ? DELIVERY_SELLER_TIMEOUT_DETAIL : PUBLIC_DETAIL.GATEWAY_REFUSED
|
|
10022
10026
|
} : {
|
|
10023
10027
|
code: DELEGATED_PAY_CODES.EXECUTE_AMBIGUOUS,
|
|
10024
10028
|
paymentState: "unknown",
|
|
10025
|
-
detail: PUBLIC_DETAIL.EXECUTE_AMBIGUOUS
|
|
10029
|
+
detail: timedOut ? EXECUTE_TIMEOUT_DETAIL : PUBLIC_DETAIL.EXECUTE_AMBIGUOUS
|
|
10026
10030
|
}, {
|
|
10027
10031
|
paymentId,
|
|
10028
10032
|
...settlement2 ? { txDigest: settlement2.txDigest, settlement: settlement2 } : answer.txDigest ? { txDigest: answer.txDigest } : {}
|
|
10029
10033
|
});
|
|
10030
10034
|
logInternal(log, {
|
|
10031
|
-
code: "delivery.proof_rejected",
|
|
10032
|
-
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",
|
|
10033
10037
|
context: { status: answer.answer.status, code: result.code }
|
|
10034
10038
|
});
|
|
10035
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",
|